query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
PATCH/PUT /producers/1 PATCH/PUT /producers/1.json
def update @producer = Pusher.update_producer(params) if @producer.valid? head :no_content else render json: @producer.errors, status: :unprocessable_entity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n authorize @producer\n if @producer.update(producer_params)\n head :no_content\n else\n render json: @producer.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @producer.update(producer_params)\n format.html { redirect_to @producer, notice: \"Producer was successfully updated.\" }\n format.json { render :show, status: :ok, location: @producer }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @producer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n course = Course.includes(:professors).find(params[:id])\n course.update!(course_params)\n \n course.professor_ids=(params[:professors])\n\n render json: course.to_json(include: :professors)\n end", "def update\n @producer = Producer.find(params[:id])\n\n @groupings = Grouping.all\n grouping_ids = params[:grouping_ids] if params[:grouping_ids] \n grouping_ids ||= []\n @producer.grouping_ids = grouping_ids\n\n\n\n respond_to do |format|\n if @producer.update_attributes(params[:producer])\n grouping_ids.each do |id|\n grouping_code = params[:grouping_code]\n code = grouping_code['grouping_'+id]\n gc = GroupingsProducer.where(:grouping_id => id, :producer_id => @producer.id).first\n if gc.nil?\n GroupingsProducer.create(:grouping_id => id, :producer_id => @producer.id, :code => code) \n else\n gc.code = code\n gc.save\n end \n end\n format.html { redirect_to producers_path, notice: \"El productor #{@producer.name} fue editado exitosamente.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @producer.errors, status: :unprocessable_entity }\n end\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 # PATCH\n raise NotImplementedError\n end", "def patch_resource(payload)\n execute(resource_path, method: :patch, payload: payload.to_json)\n end", "def patch!\n request! :patch\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def put!\n request! :put\n end", "def update\n @grocery = Grocery.find(params[:id])\n\n if @grocery.update(grocery_params)\n head :no_content\n else\n render json: @grocery.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @supplier_produce.update(supplier_produce_params)\n format.html { redirect_to @supplier_produce, notice: 'Supplier produce was successfully updated.' }\n format.json { render :show, status: :ok, location: @supplier_produce }\n else\n format.html { render :edit }\n format.json { render json: @supplier_produce.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @producer = args[:producer] if args.key?(:producer)\n @first = args[:first] if args.key?(:first)\n @last = args[:last] if args.key?(:last)\n end", "def update\n respond_to do |format|\n if @propperty.update(propperty_params)\n format.html { redirect_to @propperty, notice: 'Propperty was successfully updated.' }\n format.json { render :show, status: :ok, location: @propperty }\n else\n format.html { render :edit }\n format.json { render json: @propperty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @pocket = Pocket.find(params[:id])\n\n respond_to do |format|\n if @pocket.update_attributes(params[:pocket])\n format.html { redirect_to @pocket, notice: 'Pocket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pocket.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @primer = Primer.find(params[:id])\n\n respond_to do |format|\n if @primer.update_attributes(params[:primer])\n format.html { redirect_to @primer, notice: 'Primer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @primer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @proposal = Proposal.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(update_params)\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @proposal = Proposal.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n new_properties = params[:d]\n profile = Profile[params[:id]]\n profile.update_with(new_properties)\n\n respond_with(profile) do |format|\n format.json { render json: profile.stripped }\n end\n end", "def update\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @content_producer.update(content_producer_params)\n format.html { redirect_to @content_producer, notice: 'Content producer was successfully updated.' }\n format.json { render :show, status: :ok, location: @content_producer }\n else\n format.html { render :edit }\n format.json { render json: @content_producer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @proposal.update(proposal_params)\n format.html { redirect_to :back, notice: 'La proposition a été modifiée.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @prayer.update(prayer_params)\n format.html { redirect_to @prayer, notice: 'Prayer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @topic.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prospect.update(prospect_params)\n format.html { redirect_to @prospect, notice: 'Prospect was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prospect.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n puts \"pregnancy_params => #{pregnancy_params}\"\n if @pregnancy.update(pregnancy_params)\n format.html { redirect_to rabbit_pregnancies_path(@rabbit), notice: 'Gravidanza aggiornata con successo.' }\n format.json { render :show, status: :ok, location: @pregnancy }\n else\n format.html { render :edit }\n format.json { render json: @pregnancy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @prod = Prod.find(params[:id])\n\n respond_to do |format|\n if @prod.update_attributes(params[:prod])\n format.html { redirect_to @prod, :notice => 'Prod was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @prod.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @proposal = listing.proposals.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @producer_company.update(producer_company_params)\n format.html { redirect_to @producer_company, notice: 'Producer company was successfully updated.' }\n format.json { render :show, status: :ok, location: @producer_company }\n else\n format.html { render :edit }\n format.json { render json: @producer_company.errors, status: :unprocessable_entity }\n end\n end\n end", "def producer_params\n params.permit(:name, :producers_type)\n end", "def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def update(path)\n output { patch(path, params) }\n end", "def update\n respond_to do |format|\n if @prim.update(prim_params)\n format.html { redirect_to @prim, notice: 'Prim was successfully updated.' }\n format.json { render :show, status: :ok, location: @prim }\n else\n format.html { render :edit }\n format.json { render json: @prim.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n @review = Review.find(params[:id])\n @review.update(review_params)\n render json: @review\n end", "def update\n @prayer = Prayer.find(params[:id])\n\n respond_to do |format|\n if @prayer.update_attributes(params[:prayer])\n format.html { redirect_to @prayer, notice: 'Prayer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prayer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @prayer = Prayer.find(params[:id])\n\n respond_to do |format|\n if @prayer.update_attributes(params[:prayer])\n format.html { redirect_to @prayer, notice: 'Prayer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prayer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @prayer = Prayer.find(params[:id])\n\n respond_to do |format|\n if @prayer.update_attributes(params[:prayer])\n format.html { redirect_to @prayer, notice: 'Prayer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prayer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @proverb.update(proverb_params)\n format.html { redirect_to @proverb, notice: \"Proverb was successfully updated.\" }\n format.json { render :show, status: :ok, location: @proverb }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @proverb.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n logger.info('PUT Update:')\n logger.info(request_body)\n new_pub = hashed_request\n old_pub = Publication.find_by(id: params[:id])\n if old_pub.blank?\n head :not_found\n return\n elsif old_pub.deleted?\n head :gone\n return\n end\n if old_pub.harvested_pub? # only manually entered (i.e. non-harvested) publications may be updated with this method\n render json: {\n error: \"This record SulPubID #{old_pub.id} may not be modified. If you had originally entered details for the record, \" \\\n 'it has been superceded by a central record.'\n },\n status: :forbidden, format: 'json'\n return\n elsif !validate_or_create_authors(new_pub[:authorship])\n render json: { error: 'You have not supplied a valid authorship record.' }, status: :not_acceptable,\n format: 'json'\n return\n end\n logger.info(\"Update manual publication #{old_pub.inspect} with BibJSON:\")\n logger.info(request_body)\n old_pub.update_manual_pub_from_pub_hash(new_pub, request_body)\n old_pub.save!\n old_pub.reload\n logger.debug(\"resulting pub hash: #{old_pub.pub_hash}\")\n render json: old_pub.pub_hash, status: :accepted\n end", "def update\n @topic.update_attributes!(topic_params)\n json_response(@topic)\n end", "def update\n put :update\n end", "def update\n @promos = Promos.find(params[:id])\n\n respond_to do |format|\n if @promos.update_attributes(params[:promos])\n flash[:notice] = 'Promos was successfully updated.'\n format.html { redirect_to(@promos) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @promos.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @procedure.update(procedure_params)\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n end\n end\n end", "def update\n respond_to do |format|\n if @combine.update(combine_params)\n format.html { redirect_to @combine, notice: 'Combine was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @combine.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @provisor.update(provisor_params)\n format.html { redirect_to @provisor, notice: t('helpers.success-upd') }\n format.json { render :show, status: :ok, location: @provisor }\n else\n format.html { render :edit }\n format.json { render json: @provisor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @profesor = Profesor.find(params[:id])\n\n if @profesor.update(profesor_params)\n head :no_content\n else\n render json: @profesor.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @prospect.update(prospect_params)\n format.html { redirect_to @prospect, notice: t('.prospect_was_successfully_updated') }\n format.json { render :show, status: :ok, location: @prospect }\n else\n format.html { render :edit }\n format.json { render json: @prospect.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(uri, payload)\n url = \"#{@config[:base_url]}#{@config[:rest_path]}/#{extract_pid(uri)}\"\n request = Request.new(\n \"Put\", url, payload.to_s, {\n \"Accept\" => \"application/json\",\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => \"nnnn\",\n @auth_header => @token\n }\n )\n response = request.perform\n response\n end", "def update\n @prayer_request = PrayerRequest.find(params[:id])\n\n respond_to do |format|\n if @prayer_request.update_attributes(params[:prayer_request])\n format.html { redirect_to @prayer_request, notice: 'Prayer request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prayer_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @proposal.update(proposal_params)\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { render :show, status: :ok, location: @proposal }\n else\n format.html { render :edit }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @redpack = Redpack.find(params[:id])\n\n respond_to do |format|\n if @redpack.update_attributes(params[:redpack])\n format.html { redirect_to @redpack, notice: 'Redpack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @redpack.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prospect.update(prospect_params)\n format.html { redirect_to prospects_path, notice: 'Prospect was successfully updated.' }\n format.json { render :show, status: :ok, location: @prospect }\n else\n format.html { render :edit }\n format.json { render json: @prospect.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 @pregnancy.update(pregnancy_params)\n format.html { redirect_to @pregnancy, notice: 'Pregnancy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @pregnancy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n job = Job.find(params[:id])\n job.update_attributes(job_params)\n render json: job\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 @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 patch(url, payload, headers={})\n RestClient.patch url, payload, headers\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 respond_to do |format|\n if @prospect.update(prospect_params)\n format.html { redirect_to @prospect, notice: 'Prospect was successfully updated.' }\n format.json { render :show, status: :ok, location: @prospect }\n else\n format.html { render :edit }\n format.json { render json: @prospect.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prop.update(prop_params)\n format.html { redirect_to @prop, notice: \"Prop was successfully updated.\" }\n format.json { render :show, status: :ok, location: @prop }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @prop.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end", "def update\n if @review.update(review_params)\n render json: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\nend", "def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end", "def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end", "def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end", "def update\n respond_to do |format|\n# if @proposal.update(proposal_params)\n if @proposal.update_with_conflict_validation(proposal_params)\n format.html { redirect_to @proposal, notice: '提案を1件更新しました。' }\n format.json { render :show, status: :ok, location: @proposal }\n else\n format.html { render :edit }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(payload)\n post_like payload, Net::HTTP::Patch.new(@uri.path)\n end", "def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end", "def update\n @precioproducto = Precioproducto.find(params[:id])\n\n respond_to do |format|\n if @precioproducto.update_attributes(params[:precioproducto])\n format.html { redirect_to @precioproducto, notice: 'Precioproducto was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @precioproducto.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if params[:resource][:document].present?\n @resource.document.purge\n @resource.document.attach(params[:resource][:document])\n end\n if params[:resource][:sample].present?\n @resource.sample.purge\n @resource.sample.attach(params[:resource][:sample])\n end\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to @resource, notice: 'Resource was successfully updated.' }\n format.json { render :show, status: :ok, location: @resource }\n else\n format.html { render :edit }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n professor = Professor.find(params[:id])\n professor.update!(professor_params)\n\n render json: professor.to_json(include: :courses)\n end", "def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, :notice => 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @premio.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @major.update(major_params)\n format.html { redirect_to @major, notice: 'Major was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @major.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n topic = Topic.find(params[:id])\n if topic.update(params_topic)\n render json: topic, status: 200\n else\n render json: topic.errors, status: 422\n end\n\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 @my_prayer_request = PrayerRequest.find(params[:id])\n\n respond_to do |format|\n if @my_prayer_request.update_attributes(params[:my_prayer_request])\n format.html { redirect_to @my_prayer_request, notice: 'My prayer request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_prayer_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @coffeeshop.update(coffeeshop_params)\n format.html { redirect_to @coffeeshop, notice: 'Coffeeshop was successfully updated.' }\n format.json { render :show, status: :ok, location: @coffeeshop }\n else\n format.html { render :edit }\n format.json { render json: @coffeeshop.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(params = {})\n validate_id(params)\n submit(id_url(params.delete(:id)), :patch, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(path, params = {})\n request(:patch, path, params)\n end", "def patch(action, **args); end", "def update\n respond_to do |format|\n if @property_closet.update(property_closet_params)\n format.html { redirect_to @property_closet, notice: 'Property closet was successfully updated.' }\n format.json { render :show, status: :ok, location: @property_closet }\n else\n format.html { render :edit }\n format.json { render json: @property_closet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @badge = Badge.find(params[:id])\n\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @new_pro = NewPro.find(params[:id])\n\n respond_to do |format|\n if @new_pro.update_attributes(params[:new_pro])\n format.html { redirect_to @new_pro, notice: 'New pro was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @new_pro.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n #if producer updated successfully, show notice\n if @sample.update(sample_params)\n format.html { redirect_to @sample, notice: 'Sample was successfully updated.' }\n format.json { render :show, status: :ok, location: @sample }\n else\n format.html { render :edit }\n format.json { render json: @sample.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n recipe.update(recipe_params)\n render json: recipe\n end", "def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end", "def update\n @premio = Premio.find(params[:id])\n\n respond_to do |format|\n if @premio.update_attributes(params[:premio])\n format.html { redirect_to @premio, notice: 'Premio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @premio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe_prod.update(recipe_prod_params)\n format.html { redirect_to @recipe_prod, notice: 'Recipe prod was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_prod }\n else\n format.html { render :edit }\n format.json { render json: @recipe_prod.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @prosumer_category.update(prosumer_category_params)\n format.html { redirect_to @prosumer_category, notice: 'Prosumer category was successfully updated.' }\n format.json { render :show, status: :ok, location: @prosumer_category }\n else\n format.html { render :edit }\n format.json { render json: @prosumer_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @first = args[:first] if args.key?(:first)\n @id = args[:id] if args.key?(:id)\n @last = args[:last] if args.key?(:last)\n @producer = args[:producer] if args.key?(:producer)\n end" ]
[ "0.6487498", "0.6350371", "0.5804539", "0.58020866", "0.57748497", "0.5707767", "0.56957006", "0.5679055", "0.56272244", "0.5599534", "0.5597903", "0.5591269", "0.55858034", "0.5566249", "0.5565811", "0.5561921", "0.55531967", "0.5543999", "0.55323875", "0.5526327", "0.55198807", "0.5518337", "0.5514791", "0.55091596", "0.55008394", "0.54939145", "0.54863495", "0.54683346", "0.5466193", "0.5463726", "0.54572344", "0.54354566", "0.54353595", "0.5434604", "0.5423034", "0.54213107", "0.5420583", "0.5420263", "0.54125637", "0.53937495", "0.5393486", "0.53932106", "0.538988", "0.538988", "0.538988", "0.5385566", "0.5384791", "0.53823787", "0.53739226", "0.53572595", "0.5356423", "0.53503835", "0.53474903", "0.5346231", "0.5345403", "0.5341408", "0.5340956", "0.53380364", "0.5335947", "0.5333951", "0.5331425", "0.5330305", "0.5329509", "0.53274155", "0.5324882", "0.53232384", "0.5315599", "0.5307209", "0.5301531", "0.5301346", "0.5293019", "0.5289434", "0.5289339", "0.5282834", "0.5279053", "0.5268184", "0.5267931", "0.5267165", "0.52639514", "0.5263045", "0.52580017", "0.52577513", "0.5255376", "0.5255215", "0.52543896", "0.52533525", "0.52527755", "0.52472687", "0.52472687", "0.52394986", "0.5239127", "0.52372414", "0.52366364", "0.52356434", "0.52293617", "0.5229324", "0.5229172", "0.5228941", "0.5227499", "0.52269083" ]
0.6214617
2
DELETE /producers/1 DELETE /producers/1.json
def destroy @producer = Pusher.destroy_producer(params) head :no_content end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @producer = Producer.find(params[:id])\n @producer.destroy\n\n respond_to do |format|\n format.html { redirect_to producers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @producer.destroy\n respond_to do |format|\n format.html { redirect_to producers_url, notice: 'Producer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @producer.destroy\n respond_to do |format|\n format.html { redirect_to producers_url, notice: \"Producer was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @producer.destroy\n @producers = Producer.by_store(current_store.id)\n end", "def destroy\n authorize @producer\n @producer.destroy\n head :no_content\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @prossumer.destroy\n head :no_content\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def destroy\n @content_producer.destroy\n respond_to do |format|\n format.html { redirect_to content_producers_url, notice: 'Content producer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Post.delete(params[\"id\"])\n end", "def destroy\n @prod = Prod.find(params[:id])\n @prod.destroy\n\n respond_to do |format|\n format.html { redirect_to prods_url }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @redux.destroy\n respond_to do |format|\n format.html { redirect_to reduxes_url, notice: 'Redux was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(*rest) end", "def destroy\n onesecgroup('delete', resource[:name])\n @property_hash.clear\n end", "def destroy\n @supplier_produce.destroy\n respond_to do |format|\n format.html { redirect_to supplier_produces_url, notice: 'Supplier produce was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n Generator.where(id: params[:id] ).first.destroy\n respond_to do |format|\n format.html { redirect_to generators_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @combine.destroy\n respond_to do |format|\n format.html { redirect_to combines_url }\n format.json { head :no_content }\n end\n end", "def delete(query)\n\n connect if @persevere.nil?\n\n deleted = 0\n\n if ! query.is_a?(DataMapper::Query)\n resources = [query].flatten\n else\n resources = read_many(query)\n end\n\n resources.each do |resource|\n tblname = resource.model.storage_name\n id = resource.attributes(:field)['id']\n \n # Retrieve the ID from persever if the resource doesn't have an ID field\n if id.nil?\n query = Persevere.enhance(resource.query)\n path = \"/#{tblname}/#{query.to_json_query_filter}[={'id':id}]\"\n response = @persevere.retrieve(path, {})\n id = JSON.parse(response.body)[0]['id'].match(/(\\w+\\/)*(\\d+)/)[2]\n end\n \n path = \"/#{tblname}/#{id}\"\n # path = \"/#{tblname}/#{resource.key.first}\"\n \n DataMapper.logger.debug(\"(Delete) PATH/QUERY: #{path}\")\n\n result = @persevere.delete(path)\n\n if result.code == \"204\" # ok\n deleted += 1\n end\n end\n return deleted\n end", "def destroy\n @consume.destroy\n respond_to do |format|\n format.html { redirect_to consumes_url, notice: 'El consumo se eliminó correctamente' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def destroy\n @provisor.destroy\n respond_to do |format|\n format.html { redirect_to provisors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prospect.destroy\n respond_to do |format|\n format.html { redirect_to prospects_url }\n format.json { head :no_content }\n end\n end", "def delete!\n request! :delete\n end", "def destroy\n @promos = Promos.find(params[:id])\n @promos.destroy\n\n respond_to do |format|\n format.html { redirect_to(promos_url) }\n format.xml { head :ok }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n product = Product.find(params[:id])\n product.destroy\n\n render json: { deleted: params[:id] }\n end", "def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end", "def soccer_delete\n base_delete(params, \"Soccer\")\n end", "def destroy\n @redpack = Redpack.find(params[:id])\n @redpack.destroy\n\n respond_to do |format|\n format.html { redirect_to redpacks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @storage_processor = StorageProcessor.find(params[:id])\n @storage_processor.destroy\n\n respond_to do |format|\n format.html { redirect_to storage_processors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @promocion = Promocion.find(params[:id])\n @promocion.destroy\n\n respond_to do |format|\n format.html { redirect_to promocions_url }\n #format.json { head :ok }\n end\n end", "def destroy\n @green = Green.find(params[:id])\n @green.destroy\n\n respond_to do |format|\n format.html { redirect_to scaffold_greens_url }\n format.json { head :ok }\n end\n end", "def destroy\n resource.destroy\n render json: {success: true}, status: :ok\n end", "def destroy\n resource.destroy\n render json: {success: true}, status: :ok\n end", "def destroy\n # no op\n end", "def destroy\n @small_generator = SmallGenerator.find(params[:id])\n @small_generator.destroy\n\n respond_to do |format|\n format.html { redirect_to small_generators_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @grep_multi.destroy\n respond_to do |format|\n format.html { redirect_to grep_multis_url, notice: 'Grep multi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @consume.destroy\n respond_to do |format|\n format.html { redirect_to consumes_url, notice: 'Consume was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @batch.destroy\n render json: @batch, status: :ok\n end", "def destroy\n @promo = Promo.find(params[:id])\n @promo.destroy\n\n respond_to do |format|\n format.html { redirect_to promos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @promo = Promo.find(params[:id])\n @promo.destroy\n\n respond_to do |format|\n format.html { redirect_to promos_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @grocery = Grocery.find(params[:id])\n @grocery.destroy\n\n head :no_content\n end", "def destroy\n @shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @competency.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def destroy\n @shelf.destroy\n respond_to do |format|\n format.html { redirect_to shelves_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @primary.destroy\n respond_to do |format|\n format.html { redirect_to primaries_url, notice: 'Primary was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @produccion = Produccion.find(params[:id])\n @produccion.destroy\n\n respond_to do |format|\n format.html { redirect_to produccions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @primer = Primer.find(params[:id])\n @primer.destroy\n\n respond_to do |format|\n format.html { redirect_to primers_url }\n format.json { head :no_content }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def delete(path)\n RestClient.delete request_base+path\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 @round_robin_promo = RoundRobinPromo.find(params[:id])\n @round_robin_promo.destroy\n\n respond_to do |format|\n format.html { redirect_to round_robin_promos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pdevice = Pdevice.find(params[:id])\n @pdevice.destroy\n\n respond_to do |format|\n format.html { redirect_to pdevices_url }\n format.json { head :no_content }\n end\n end", "def delete!(*rest) end", "def destroy\n @prim.destroy\n respond_to do |format|\n format.html { redirect_to prims_url, notice: 'Prim was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(*args)\n request(:delete, *args)\n end", "def destroy\n @produccion = Produccion.find(params[:id])\n @produccion.destroy\n\n respond_to do |format|\n format.html { redirect_to producciones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prospecto.destroy\n respond_to do |format|\n format.html { redirect_to prospectos_url, notice: 'Prospecto eliminado' }\n format.json { head :no_content }\n end\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def destroy\n Topic.find(params[:id]).destroy\n render :json => {:ok => true}, :head => :no_content\n end", "def destroy\n @propose = Propose.find(params[:id])\n @propose.destroy\n\n respond_to do |format|\n format.html { redirect_to proposes_url }\n format.json { head :no_content }\n end\n end", "def delete(payload = {})\n request! do\n options = {payload: to_payload(payload)}\n api(options)[url.path].delete(API_HEADERS)\n end\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def delete(path, params = {})\n post(path, params.merge(\"_method\" => \"delete\"))\n end", "def destroy\n @payload.destroy\n respond_to do |format|\n format.html { redirect_to payloads_url, notice: 'Payload was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy; delete end", "def delete\n client.delete(url)\n @deleted = true\nend", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def destroy\n @plasmid_probe.destroy\n respond_to do |format|\n format.html { redirect_to plasmid_probes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @collector.destroy\n respond_to do |format|\n format.html { redirect_to collectors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pregnancy.destroy\n respond_to do |format|\n format.html { redirect_to rabbit_pregnancies_path(@rabbit), notice: 'Gravidanza rimossa con successo' }\n format.json { head :no_content }\n end\n end", "def delete(path, params)\n request(:delete, path, {})\n end", "def destroy\n @prog.destroy\n respond_to do |format|\n format.html { redirect_to progs_url, notice: 'Prog was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @prospect.destroy\n respond_to do |format|\n format.html { redirect_to prospects_url, notice: t('.prospect_was_successfully_destroyed') }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @proverb.destroy\n respond_to do |format|\n format.html { redirect_to proverbs_url, notice: \"Proverb was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @precioproducto = Precioproducto.find(params[:id])\n @precioproducto.destroy\n\n respond_to do |format|\n format.html { redirect_to precioproductos_url }\n format.json { head :ok }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end", "def destroy\n @prosumer_category.prosumers.each do |p|\n p.prosumer_category = nil\n p.save\n end\n @prosumer_category.destroy\n respond_to do |format|\n format.html { redirect_to prosumer_categories_url, notice: 'Prosumer category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @progre = Progre.find(params[:id])\n @progre.destroy\n\n respond_to do |format|\n format.html { redirect_to(progres_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @prayer = Prayer.find(params[:id])\n @prayer.destroy\n\n respond_to do |format|\n format.html { redirect_to prayers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prayer = Prayer.find(params[:id])\n @prayer.destroy\n\n respond_to do |format|\n format.html { redirect_to prayers_url }\n format.json { head :no_content }\n end\n end", "def delete\n \n end", "def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to badges_url, notice: 'Badge was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @propperty.destroy\n respond_to do |format|\n format.html { redirect_to propperties_url, notice: 'Propperty was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @prospecto.destroy\n respond_to do |format|\n format.html { redirect_to prospectos_url, notice: 'Prospecto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @preservative = Preservative.find(params[:id])\n @preservative.destroy\n\n respond_to do |format|\n format.html { redirect_to preservatives_url }\n format.json { head :ok }\n end\n end", "def destroy\n @edds_prochy.destroy\n respond_to do |format|\n format.html { redirect_to edds_prochies_url, notice: 'Запись успешно удалена.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @prayer.destroy\n respond_to do |format|\n format.html { redirect_to prayers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @topickey = Topickey.find(params[:id])\n @topickey.destroy\n\n respond_to do |format|\n format.html { redirect_to topickeys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prod_cli.destroy\n respond_to do |format|\n format.html { redirect_to prod_clis_url, notice: 'produto excluido com sucesso.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7154517", "0.677698", "0.67714006", "0.64637613", "0.64623994", "0.63576084", "0.6248228", "0.62432295", "0.62385875", "0.6217202", "0.6178175", "0.61697525", "0.6138118", "0.6136051", "0.6121802", "0.611557", "0.6107682", "0.6098637", "0.60703355", "0.6069831", "0.60676837", "0.6059933", "0.6055681", "0.60500485", "0.6042809", "0.6038654", "0.60345143", "0.6017924", "0.60017866", "0.5987461", "0.5982309", "0.59781027", "0.597443", "0.5953151", "0.5952483", "0.5952483", "0.5951265", "0.5947808", "0.59473157", "0.5947019", "0.5945318", "0.59445", "0.59445", "0.59334475", "0.59297514", "0.5929299", "0.5928186", "0.5928178", "0.5927586", "0.5926938", "0.59236175", "0.5918139", "0.59169716", "0.59097964", "0.59065646", "0.5905076", "0.58964485", "0.58964485", "0.589351", "0.58883476", "0.58836895", "0.58836603", "0.58836526", "0.58776146", "0.5874365", "0.5872942", "0.5870327", "0.5869897", "0.58689106", "0.5864824", "0.5864015", "0.5860307", "0.5859059", "0.5851138", "0.58508873", "0.58495533", "0.58469915", "0.5844962", "0.58419645", "0.5839751", "0.5838921", "0.5836715", "0.5836715", "0.5835828", "0.58355904", "0.58341056", "0.58338064", "0.5831582", "0.58315545", "0.5831408", "0.5831408", "0.5830421", "0.5828967", "0.58272725", "0.5824967", "0.58246475", "0.582153", "0.5819028", "0.58189565", "0.5818909" ]
0.6649517
3
most common letter in the array, and a count of how many times it appears. Difficulty: medium.
def most_common_letter(string) idx = 0 while idx < string.length letter = string[idx] count = 0 idx1 = 0 while idx1 < string.length if string[idx1] == letter count += 1 end idx1 += 1 end idx += 1 end puts [letter, count] return [letter, count] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def most_common_letter(string)\n # #create array, letter and count to return \n # mostCommon = []\n # count = 0\n # #assign the first letter to a variable\n # i = 0\n # #loop through array\n # while i < string.length\n # count = string.count(string[i])\n # for j in string\n # #count how many times that first letter exists\n # if string.count(j) > count\n # #count how many times the second letter exists\n # mostCommonLetter = j\n # count = string.count(j)\n # #if first is greater, make it mostcommon\n # end \n # #if second is greater, make it most common\n # end \n # end\n \n #loop through array\n i = 0\n j = 0\n counter = 0\n greatestCount = 0\n #for every element, keep a tally counter\n while i < string.length\n j = 0\n #loop through the array and count how many times this char occurs\n while j < string.length\n if string[i] == string[j]\n counter += 1\n end \n j += 1\n end \n #if it is greater than the last count\n if counter > greatestCount \n #reassign it to the last count\n greatestCount = counter\n #put the char and the count in an array\n mostCounted = [string[i], greatestCount]\n end \n counter = 0\n i += 1\n end \n #return array\n return mostCounted\nend", "def most_common_letter(string)\n # letter : how many times\n letter_count = Hash.new(0)\n\n (0...string.length).each do |i|\n letter_count[string[i]] += 1\n end\n\n letter = string[0]\n count = letter_count[letter]\n\n (1...string.length).each do |i|\n if letter_count[string[i]] > count\n count = letter_count[string[i]]\n letter = string[i]\n end\n end\n\n [letter, count]\nend", "def most_common_letter(string)\nletters = {}\nletters.default = 0\t\nstring.each_char do |letter| letters[\"#{letter}\"] += 1 unless letter == \" \" end\n\tletter_counts = letters.invert.sort.reverse\n\tarr = letter_counts[0]\n\treturn letter_counts[0].reverse\nend", "def most_common_letter(string)\n\t\n\t\n\tarr = string.split(\"\")\n\tletters = Hash.new\t\n\t\n\tarr.each do |x|\n\tletters[x] = arr.count[\"x\"]\n end\n\tputs letters\n\nend", "def most_common_letter(string)\n\ti = 0\n\tcount2 = 0\n\tarr = []\n\twhile(i < string.length)\n\t\tj = 0\n\t\tcount1 = 0\n\t\twhile(j < string.length)\n\t\t\tif(string[i] == string[j] && !arr.include?(string[j]))\n\t\t\t\tcount1 += 1\n\t\t\tend\n\t\t\tj += 1\n\t\tend\n\t\tif(count1 > count2)\n\t\t count2 = count1\n\t\t arr << string[i]\n\t\t most_num = [string[i],count2]\n\t\tend\t\n\t\ti += 1\n\tend\n\treturn most_num\nend", "def most_common_letter(string)\n\n\tcount = Hash.new(0)\n\n\tstring.each_char do |x|\n\t\tcount[x] += 1\n\tend\n\n\tcount.sort[0]\nend", "def letter_count(string)\n\narray = string.split(' ')\nmax_word = \"\"\nmax_counter = 0\n\ni = 0\nwhile i < array.length #loop through sentence\n\tk = 0\n\tcounter = 0\n\trepeats = []\n\twhile k < array[i].length #loop through each letter in each word\n\t\tletter = array[i][k]\n\n\t\tj = k+1\n\t\t\twhile j < array[i].length #compare each letter to the rest\n\t\t\t\tif letter == array[i][j] && repeats.include?(letter) == false\n\t\t\t\n\t\t\t\t\trepeats.push(letter)\n\t\t\t\tend\n\n\t\t\t\tj += 1\n\t\t\tend\n\t\tk += 1\t\n\tend\n\t\n\tif repeats.length > max_counter \n\t\tmax_counter = repeats.length\n\t\tmax_word = array[i]\n\tend\n\n\ti += 1\nend\n\nif max_counter == 0\n\treturn -1\nend\n\nreturn max_word\nend", "def most_common_letter(string)\n popular_letter = string[0]\n most_frequency = 1\n\n idx = 0\n while idx < string.length\n letter = string[idx]\n\n frequency = 0\n idx1 = 0\n while idx1 < string.length\n\t\t\n\n if string[idx] == string[idx1]\n frequency += 1\n end\n\n if most_frequency < frequency\n most_frequency = frequency\n popular_letter = string[idx1]\n end\n\n\n #take first letter, \n #find number of occurnces\n\n #store in most popular\n\n #check 2nd number\n #if == first number, skip\n\n #if not 2nd number\n #\tcount,\n\n #if more popular\n\n #store as most popular\n\n\n\n\n\n ## return [(string[idx]), idx]\n idx1 += 1\n end\n\n\n idx += 1 \n end\n \n return [popular_letter, most_frequency]\nend", "def six\n puts \"Type a sentence and lets see what the most common letter is\"\n input = gets.strip\n input = input.split(\"\")\n arr =[]\n arr << input\n counts = Hash.new(0)\n b = counts.each { |x| counts[x] += 1 }\n binding.pry\nend", "def common_chars(arr)\n new_arr = []\n test_letters = arr[0].chars.uniq\n test_letters.each do |letter|\n count = arr[0].count(letter)\n arr.each do |word|\n temp_count = word.count(letter)\n count = temp_count if temp_count < count \n end\n new_arr += [letter] * count \n end\n new_arr\nend", "def most_common_letter(string)\n\n\tletters = string.split('')\n\tfrequencies = Hash.new(0)\n\n\tletters.each do |letter|\n \tfrequencies[letter] += 1\n\tend\n\n\t#puts frequencies\n\n\t#frequencies = frequencies.sort_by do |letter, count|\n #\tcount\n\t#end\n\n\t#frequencies.reverse!\n\t#return frequencies\n\n\tmost_common_letter_value = frequencies.max_by do |key, value|\n\t\tvalue\n\tend\n\t\n\t#puts most_common_letter_value\n\treturn most_common_letter_value\n\t\nend", "def most_used_letter\n s1 = @text.gsub(/[^a-z]/, '')\n arr= s1.split('')\n arr1 = arr.uniq #rids chars array of duplicates\n arr2 = {}\n\n #makes an object with a count of all unique characters\n arr1.map do |c|\n arr2[c] = arr.count(c) #count searches an array and returns the number of occurrances of the specified element\n end\n\n #to start the following loop with the first key/value pair of arr2\n biggest = { arr2.keys.first => arr2.values.first }\n arr2.each do |key, value|\n if value > biggest.values.first\n biggest = {}\n biggest[key] = value\n end\n end\n\n biggest\nend", "def most_common_letter(string)\nletters = string.split(\"\")\n# Making a new hash \nfrequencies = Hash.new (0)\n# Add one to the key's value every time the key appears\nletters.each { |letter| frequencies|letter| += 1 }\n# Sorting frequencies by the value of letter \nfrequencies = frequencies.sort_by do |letters, letter| \n letter\nend\n \n puts letters + \" \" + letter \nend", "def most_common_letter(string)\n list = {}\n array = string.split('')\n\n array.each do |letter|\n list[letter] += 1 if list[letter]\n list[letter] = 1 if !list[letter]\n end\n\n highest_count = list.values.max\n\n [list.key(highest_count), highest_count]\nend", "def most_common_letter(string)\n idx = jdx = ctr = 0\n most = [ string[idx], 1 ]\n\n while idx < string.length # Iterate through string\n\n while jdx < string.length # Iterate through remainder of string\n\n if string[jdx] == string[idx] # Count matches\n ctr += 1\n end\n\n jdx += 1\n end\n\n if ctr > most[1] # If more common, update\n most = [string[idx], ctr]\n end\n\n jdx = idx += 1\n ctr = 0\n end\n\n return most\nend", "def most_frequent_letter(string)\n \n #get rid of spaces\n string.gsub!(\" \", \"\")\n \n hash = Hash.new(0)\n string.split(\"\").each {|char| hash[char] += 1}\n \n #create hash and get max by first index\n hash.max_by{|char, num| num}[0]\n \nend", "def high x \n letters = ('a'..'z').to_a\n indexes = (1..26).to_a\n obj = letters.zip(indexes)\n highest_count = 0\n highest_word = ''\n\n word_arr = x.split(' ')\n word_arr.each do |word|\n current_count = 0\n letter_arr = word.split('')\n letter_arr.each do |l|\n obj.each do |o|\n if l == o[0]\n current_count += o[1]\n end\n end\n end\n if current_count > highest_count\n highest_count = current_count\n highest_word = word \n end\n end\n return highest_word\nend", "def most_frequent_letter(string)\nend", "def most_common_letter(string)\r\nidx = 0\r\ncommon_letter = nil\r\nletter_counter = nil\r\n\r\n while idx < string.length\r\n letter = string[idx]\r\n count = 0\r\n idx2 = 0\r\n while idx2 < string.length\r\n if string[idx2] == letter\r\n count = count+1\r\n end\r\n idx2 = idx2 + 1\r\n end\r\n if(letter_counter == nil)||(count > letter_counter)\r\n common_letter = letter\r\n letter_counter = count\r\n end\r\n idx = idx + 1\r\n end\r\n return [common_letter,letter_counter].to_s\r\nend", "def most_common_letter(string)\n most_common = \"\"\n highest_occurance = 0\n \n counter = {}\n i = 0\n \n while i < string.length \n counter[string[i]].nil? ? counter[string[i]] = 1 : counter[string[i]] += 1\n i += 1\n end\n \n counter.each do |char, count|\n if count > highest_occurance\n most_common = char\n highest_occurance = count\n end\n end\n \n return [most_common, highest_occurance]\nend", "def LetterCount(str)\n\n \n words = str.split(\" \")\n most = \"\"\n count = 0\n \n words.each do |word|\n hash = Hash.new(0)\n word.split(\"\").each {|letter| hash[letter] += 1} #must split word\n repeats = hash.select {|letter, count| count >= 2}.size\n if repeats > count\n count = repeats\n most = word\n end\n \n end\n \n return most\n \nend", "def letter_per_word(array,letter)\n array.max\nend", "def char_occurence(str)\n return puts \"Input must be a non-empty string\" if str.nil? or !str.is_a? String or str.empty?\n\n characters = {}\n str.chars.each do |char|\n if characters.has_key? char\n characters[char] += 1\n else\n characters[char] = 1\n end\n end\n\n count = characters.values.sort\n max_count = count.last\n min_count = count.first\n max_char = characters.select { |k,v| v == max_count }.sort.first[0]\n min_char = characters.select { |k,v| v == min_count }.sort.first[0]\n\n p \"The character '#{max_char}' appears the most with a total of #{max_count} count\"\n p \"The character '#{min_char}' appears the least with a total of #{min_count} count\"\nend", "def letterCountI(str)\n\t# count = 0\n\t# mostRepeatedLetters = ''\n\t# str = str.split('').each{|letter| \n\t# \tif(str.count(letter) > count)\n\t# \t\tcount = str.count(letter)\n\t# \t\tmostRepeatedLetters = str\n\t# \tend\n\t# }\n\t# return mostRepeatedLetters\n\n\tletterCount = 0\n\tletterMaxWord = ''\n\tstr = str.split(' ').each{|word| word.split('').each{|letter| \n\t\tif(word.downcase.count(letter) > letterCount)\n\t\t\tletterCount = word.downcase.count(letter)\n\t\t\tletterMaxWord = word\n\t\tend\n\t\t}}\n\tletterCount > 1 ? (return letterMaxWord) : (return -1)\n\t\nend", "def frequent_letters(string)\n output = []\n count_table = Hash.new(0)\n\n string.each_char do |char|\n count_table[char] += 1\n if count_table[char] == 3\n output.push(char)\n end\n end\n\n return output\nend", "def frequent_letters(string)\n count_letters = Hash.new{0}\n frequent_letter = []\n string.each_char do |char|\n count_letters[char] += 1\n if count_letters[char] > 2 && frequent_letter.include?(char) == false\n frequent_letter << char\n end\n end\n return frequent_letter.reverse\nend", "def solve(array)\n alphabet = ('a'..'z').to_a.join\n results = []\n \n array.each do |string|\n count = 0\n string.downcase!\n string.chars.each_with_index do |char, index|\n count += 1 if string[index] == alphabet[index]\n end\n results << count\n end\n results \nend", "def hash_letter_freq( array )\n\n i = 0 # keeps track of outter loop\n hash = Hash.new()\n\n while( array.length > i )\n\n count = 1\n\n i2 = 1 + i # keeps track of inner while loop\n\n while( array.length > i2 ) # this will never check the last element of the array - otherwise have i2 check itself by doing i2 = i\n\n # puts(\"i #{i} | i2 #{i2}\") -- check if iteration is made right\n\n if( array[i] == array[i2] )\n count += 1\n end\n\n i2 += 1\n end # inner - while\n\n # alternative cond: hash.has_key?(\"#{array[i]}\") http://ruby-doc.org/core-1.9.3/Hash.html#method-i-has_key-3F\n if( hash[\"#{array[i]}\"] == nil ) # checks if key exists\n hash[\"#{array[i]}\"] = count\n end\n\n # for the last element in the array -- skipped by i2\n if( i2 == array.length )\n if( hash[\"#{array[i]}\"] == nil )\n hash[\"#{array[i]}\"] = 1\n end\n end\n\n\n i += 1\n end # while -outter\n\n # puts( hash )\n return hash\n\nend", "def frequency(char)\n return 0 if (@size.nil? || @size <= 0)\n @map[char.upcase] * 100/@size\n end", "def solve(array)\n aplhabet = ('a'..'z').to_a\n array.map do |string|\n count = 0\n string.chars.each_with_index do |char, idx|\n count += 1 if char.downcase == aplhabet[idx]\n end\n count\n end\nend", "def find_the_most_letter_a(array)\n most_as = 0\n most_as_string = \"\"\n array.each_with_index do |string,i|\n a = 0\n string.each_char do |char|\n if char.downcase == \"a\"\n a +=1\n end\n end\n if a > most_as\n most_as = a\n most_as_string = array[i]\n end\n\n end\n most_as_string\nend", "def most_common_letter(string)\n\thistogram = {}\n\tstring.split(\"\").each do |i|\n\t\tif !histogram.has_key?(i)\n\t\t\thistogram[i] = 0\n\t\tend\n\tend\n\thistogram.each_key do |key|\n\t\tstring.split(\"\").each do |i|\n\t\t\tif key == i\n\t\t\t\thistogram[key] += 1\n\t\t\tend\n\t\tend\n\tend\n\thighest_count_letter = [histogram.keys[0], histogram.values[0]]\n\thistogram.each_key do |key|\n\t\tif histogram[key] > highest_count_letter[1]\n\t\t\thighest_count_letter = [key, histogram[key]]\n\t\tend\n\tend\n\treturn highest_count_letter\nend", "def character_count(array)\nend", "def letter_freq(string)\n length = string.length\n i = 0\n \n max_letter = \"\"\n max_count = 0\n \n count = 1\n \n while i < length\n if string[i] == string[i+1]\n count += 1\n else\n if count > max_count\n max_count = count\n max_letter = string[i]\n end\n count = 1\n end\n i += 1\n end\n \n return \"#{max_letter}#{max_count}\"\nend", "def frequent_letters(string)\n array = []\n count = Hash.new(0)\n string.each_char { |c| count[c] += 1 }\n count.each { |k, v| array << k if v > 2}\n array\nend", "def letter_counts(word) =\n word.chars.each_with_object(Hash.new(0)) { |c, counts| counts[c] += 1 }", "def words_longer_than(array,num)\n new_array = []\n array.map{ |w|\n new_array.push(w.count(\"e\"))\n }\n letter_per_word(new_array, new_array.length)\nend", "def get_most_used_letter(word)\n\t\tletter_counts = Hash.new(0)\n\t\tword.each do |letter|\n\t\t\tletter_counts[letter] += 1\n\t\tend\n\n\t\tmax_letter = \"\"\n\t\tmax_letter_count = 0\n\t\tletter_counts.each do |letter, count| \n\t\t\tif(count > max_letter_count)\n\t\t\t\tmax_letter_count = count\n\t\t\t\tmax_letter = letter\n\t\t\tend\n\t\tend\n\n\t\tmax_letter\t\t\n\tend", "def most_frequent_letter(regex)\n temp_dict = []\n @dict.each {|word| temp_dict << word if word.match(/#{regex}/)}\n #p temp_dict\n flattened_dic = flatten_dict(temp_dict)\n\n @alphabet.keys.each do |letter|\n @alphabet[letter] =flattened_dic.count(letter)\n end\n\n @guessed_letters.each { |char| @alphabet.delete(char) } #delete all the @guessed_letters\n #puts \"guessed letter below\"\n guessed_letter = @alphabet.key(@alphabet.values.max)\n #p guessed_letter\n @guessed_letters << guessed_letter\n return guessed_letter\n #p @alphabet\n end", "def common_characters(arr)\n target_count = arr.count\n\n hash = Hash.new(0)\n (0...target_count).each do |i|\n arr[i].split('').each do |letter|\n hash[letter] += 1\n end\n end\n\n result = []\n hash.each do |k, v|\n while v >= target_count\n if v >= target_count\n result << k\n v -= target_count\n end\n end\n end\n\n result\nend", "def most_common_letter(string)\n most_common_letter = nil\n most_common_letter_count = nil\n \n index1 = 0\n while index1 < string.length\n letter = string[index1] \n count = 0 \n \n index2 = 0\n while index2 < string.length \n if string[index2] == letter \n count += 1 \n end\n index2 += 1\n end\n\n if (most_common_letter_count == nil) || (count > most_common_letter_count)\n most_common_letter = letter\n most_common_letter_count = count\n end\n\n index1 += 1\n end\n \n return [most_common_letter, most_common_letter_count]\n end", "def letter_frequency(text)\n\n #create blank hash\n character_hash = Hash.new\n character_hash.default = 0\n\n #delete other characters\n text.delete! \"^a-zA-Z\"\n\n #all lower case\n text = text.downcase\n\n #turn string into array\n text_array = text.chars\n\n #move each letter to hash with number of times it appears in the array\n text_array.each do |letter|\n character_hash[letter] +=1\n end \n character_hash\n\n#sort hash in descending order unless values are the same, then sort alphabetically\n character_hash.sort do |(letter1, value1), (letter2, value2)|\n if value1 == value2\n letter1 <=> letter2\n else\n value2 <=> value1\n end\n end\n\nend", "def letter_count(letter)\n @letter_counts ||= compute_counts\n @letter_counts[letter[0] - ?a]\n end", "def frequent_letters(string)\n count = Hash.new(0)\n string.each_char { |char| count[char] += 1 }\n\n frequents = []\n count.each do |char, num|\n if num > 2\n frequents << char\n end\n end\n return frequents\nend", "def frequent_letters(string)\n hash = Hash.new(0)\n string.each_char { |char| hash[char] += 1 }\n\n frequent = []\n hash.each_key do |k|\n if hash[k] > 2\n frequent << k\n end\n end\n return frequent\nend", "def gemstones(arr)\n common_chars = ('a'..'z').to_a\n arr.each do |a|\n common_chars = common_chars & a.chars\n end\n common_chars.size\nend", "def frequencies(chars)\n freq = Hash.new(0)\n chars.each do |char|\n freq[char] += 1\n end\n freq = freq.sort_by { |char, count| count } # order by highest frequency\n freq.reverse!\n freq = Hash[freq]\n return freq\nend", "def most_common_letter(str)\n counts = Hash.new(0)\n str.delete(\" \").gsub(/[^a-zA-Z0-9\\-]/,\"\").split(\"\").each do |char|\n counts[char] += 1\n end\n counts.max_by{ |key,value| value }\nend", "def most_common_vowel(string)\n count = Hash.new(0)\n vowels = %w(a e i o u)\n string.each_char do |letter|\n count[letter] += 1 if vowels.include?(letter)\n end \n\n count.sort_by { |k, v| v }.last.first\nend", "def frequent_letters(string)\n frequent = []\n letters_count = Hash.new(0)\n\n string.each_char { | char | letters_count[char] += 1 }\n letters_count.each do | k, v |\n if v > 2\n frequent << k\n end\n end\n\n return frequent\nend", "def frequent_letters(str)\n letter_count = Hash.new(0)\n str.each_char { |char| letter_count[char] += 1 }\n\n frequent_chars = []\n letter_count.each do |char, num|\n if num > 2\n frequent_chars << char\n end\n end\n return frequent_chars\nend", "def LetterCountI(str)\n\n str = str.split\n repeating_letters = []\n str.each do |word| \n word = word.split(\"\")\n letters = Hash.new(0)\n word.each { |letter| letters[letter] += 1 }\n selected_letters = letters.select { |key, value| value > 1 }\n repeating_letters << selected_letters.keys.length\n end\n if (repeating_letters.select {|l| l >= 1}).empty?\n return -1\n else\n max = repeating_letters.max\n return str[repeating_letters.index(max)]\n end\nend", "def count_letters(word)\n\thashMap = {}\n\tword.each_char do |a|\n\t\tif hashMap.has_key?(a)\n\t\t\thashMap[a] = hashMap[a] + 1\n\t\telse\n\t\t\thashMap[a] = 1\n\t\tend\n\tend\n\t\n\tmax = hashMap[word[0]]\n\thashMap.each do |value,entry|\n\t\tif entry > max\n\t\t\tmax = entry\n\t\tend\n\tend\n\treturn max\n end", "def frequent_letters(string)\n hash = Hash.new(0)\n results = []\n\n string.each_char do |char|\n hash[char] += 1\n end\n\n hash.each do |k, v|\n if v > 2\n results << k\n end\n end\n\n return results\nend", "def LetterCount(str)\n mayor = 0 \n arr = []\n \n str.split(\" \").each do |word|\n if (CountMax(word) > mayor)\n mayor = CountMax(word)\n arr << word \n end\n end\n \n # code goes here\n return (CountMax(arr.last) <= 1)? -1 : arr.last\n \n \nend", "def count_letters(word)\r\n letter_count = Hash.new(0)\r\n word.chars { |letter| letter_count[letter.to_sym] += 1 }\r\n # Note: a better way to do the following is:\r\n #letter_count.values.max\r\n # but the requrements say to use .each, so...\r\n max = 0\r\n letter_count.each do |key, value|\r\n if value > max\r\n max = value\r\n end\r\n end\r\n max\r\n end", "def letter_counts(word)\n answer = Hash.new(0)\n word.each_char { |chr| answer[chr] += 1 }\n answer\nend", "def love_letter string\n\n count = 0\n\n arr = string.chars\n\n alpha = ('a'..'z').to_a\n\n arr.each_with_index do |x,xi|\n while arr[xi] != arr[-(xi+1)]\n opposite = arr[-(xi+1)]\n cur_letter = [arr[xi], opposite].max\n\n alpha_index = alpha.index(cur_letter)\n\n if opposite > arr[xi]\n arr[-(xi+1)] = alpha[alpha_index - 1]\n count += 1\n end\n\n if arr[xi] > opposite\n arr[xi] = alpha[alpha_index-1]\n count +=1\n end\n\n end\n end\n\n count\n\nend", "def love_letter string\n arr = string.chars\n alpha = ('a'..'z').to_a\n count = 0\n\n arr.each_with_index do |x,xi|\n while arr[xi] != arr[-(xi+1)]\n opposite = arr[-(xi+1)]\n cur_letter = [opposite, arr[xi]].max\n a_index = alpha.index(cur_letter) - 1\n new_char = alpha[a_index]\n\n if opposite > arr[xi]\n arr[-(xi+1)] = new_char\n count +=1\n else\n arr[xi] = new_char\n count +=1\n end\n end\n end\n count\nend", "def LetterCountI(str)\n largest_count = 0\n words = str.split(\" \")\n i = 0\n while i < words.length\n if count(words[i]) > largest_count\n largest_count = count(words[i])\n largest_word = words[i]\n end\n i += 1\n end\n if largest_count == 0\n return -1\n else\n return largest_word\n end\nend", "def most_common(string)\n count = Hash.new(0)\n string.split(\"\").each { |letter| count[letter] += 1 }\n count.max_by{ |key,value| value }[0]\nend", "def five_most_common_letters(string)\n # have hash keep track of num appearances\n # have heap keep track of most common letter\n hash = Hash.new\n heap = Heap.new(hash)\n\n string.each_char do |letter|\n if hash[letter] \n hash[letter] += 1\n else\n hash[letter] = 1\n end\n \n if heap.length < 5\n heap.insert(letter)\n elsif hash[letter] > hash[heap.min]\n old_value = heap.deleteMin\n heap.insert(letter)\n end\n end\n\n result = []\n while heap.length > 0\n result << heap.deleteMin\n end\n\n result.reverse.map {|char| \"#{char}: #{hash[char]}\"}\nend", "def high(string)\n letter_scores = ('a'..'z').zip(1..26).to_h\n words = string.split\n\n word_scores = words.map do |word|\n score = 0\n word.chars.each { |char| score += letter_scores[char]}\n score \n end\n words[word_scores.index(word_scores.max)]\nend", "def count_letters (name, counts)\n sum = 0\n $alphabet.each_with_index { |val, index| counts[index] += name.count(val) }\n counts\nend", "def letter_counts(word)\n count = Hash.new(0)\n word.each_char { |char| count[char] += 1}\n count\nend", "def most_frequent_occurrence(str)\n lower_str = str.downcase\n letters = {}\n most_frequent = []\n\n for i in 0..lower_str.length - 1\n if letters[lower_str[i]]\n letters[lower_str[i]] += 1\n else\n letters[lower_str[i]] = 1\n end\n end\n\n letters.each do |key, value|\n if most_frequent.length == 0 || letters[key] > most_frequent[1]\n most_frequent = [key, value]\n end\n end\n\n return most_frequent[0]\nend", "def letter_counts(word)\n counter = Hash.new(0)\n word.chars.each do |x|\n counter[x] += 1\n end\n counter\nend", "def most_common(string)\n # binding.pry\n arr = string.downcase.gsub(/[^a-z0-9\\s]/i, '').split(\" \")\n arr = arr.map { |x| x.downcase }\n words_hash = arr.group_by { |x| x }\n final_arr = []\n words_hash.each do |k,v|\n #binding.pry\n if v.length > 1\n final_arr << k\n end\n end\n p final_arr\nend", "def most_repeated_letter(string)\n letter = \"\"\n count = 0\n \n length = string.length\n i = 0\n current_count = 1\n \n while i < length \n if string[i] == string[i+1]\n current_count += 1\n else\n if current_count > count\n count = current_count\n letter = string[i]\n end\n current_count = 1\n end\n \n i += 1\n end\n \n return \"#{letter}#{count}\"\nend", "def letter_counter2(string)\n string.split.each_with_object({}) do | word, hash| # word (calling on array)\n if hash.has_key?(word.size) \n hash[word.size] += 1\n else\n hash[word.size] = 1\n end\n end\nend", "def count_repeated_letters(word)\n # character: # of occurences\n occurences = Hash.new(0)\n count = 0\n\n word.each_char do |c|\n occurences[c] += 1\n if occurences[c] == 2\n count+=1\n end\n end\n count\nend", "def word_counter(string)\n array = string.downcase.split(\" \")\n word_count = array.count\n the_count = array.count(\"the\")\n\n # option 1 for getting longest work\n # longest_word = \"\"\n # array.each do |x|\n # longest_word = x if longest_word.length < x.length\n # end\n\n # option 2 for getting longest word\n longest_word = array.max_by { |x| x.length }\n\n puts \"The number of words is #{word_count}, the longest word is #{longest_word}, and 'the' is used #{the_count} times.\"\nend", "def char_count (arr, hash)\n arr.each_with_index do |k, i|\n hash[k] = 0\n end\n \n arr.each_with_index do |char, j|\n if hash.has_key?(char)\n hash[char] += 1\n end\n end\n\n return hash\nend", "def most_common_word\n if word_counts.size == 0\n WordCount.new(:word=>'n/a',:count=>0)\n else\n sort_word_counts\n word_counts.to_a[0]\n end\n end", "def good_word(wordlist)\n # letter frequency\n freqs = Hash.new { |h,k| h[k] = 0 }\n wordlist.each do |w|\n w.chars.each { |c| freqs[c] += 1 }\n end\n\n # score = number of unique chars X sum of letter frequencies\n wordlist.max_by do |w|\n chars = w.chars.to_a.uniq\n chars.length * chars.map{|c| freqs[c]}.inject{|sum,n| sum + n}\n end\nend", "def mode(input_array)\n\n counts = Hash.new(0)\n input_array.each do |element|\n counts[element] += 1\n end\n\n output_array = Array.new\n\n counts.each do |word, count|\n if count == counts.values.max\n output_array << word\n end\n end\n\n return output_array\n\nend", "def best_letter string\n alphabet = ('a'..'z').to_a\n frequency_hash = Hash['a' => 1]\n alphabet.each do |x|\n frequency_hash[x] = alphabet_frequency(string, x)\n end\n #puts frequency_hash\n number_alphabet [(alphabet_number(frequency_hash.min_by{|k,v| v}.first.split(\"\")).first + 1) % 26]\nend", "def high(x)\n arr = x.split(\" \")\n alphab = (\"a\"..\"z\").to_a\n scores = []\n \n arr.each do |word|\n score = 0\n word.split(\"\").each do |letter| \n score += (alphab.index(letter) + 1) \n end\n scores.push(score)\n end\n \n puts arr[scores.index(scores.max)]\nend", "def most_frequent_word(string)\n hash = {}\n splitstring = string.split(\" \")\n splitstring.each {|element| element.downcase!}\n p splitstring\n splitstring.each{|element| if hash[element].nil?\n hash[element]=1\n else\n hash[element]+=1\n end}\nmost_frequent_item = hash.max_by{ |i| hash.count( i ) }\nputs most_frequent_item\nend", "def frequent_letters(string)\n hash = Hash.new(0)\n string.each_char do |char|\n hash[char] += 1\n end\n\n hash.keys.select { |k| hash[k] > 2 }\nend", "def duplicate_count(str)\n arr = str.downcase.chars\n counts = {}\n arr.each do |char|\n if counts.include?(char)\n counts[char] += 1\n else\n counts[char] = 1\n end\n end\n output = 0\n counts.each_value do |num|\n output += 1 if num > 1\n end\n output\nend", "def high(string)\n letter_scores = ('a'..'z').to_a\n words = string.split\n\n word_scores = words.map do |word|\n score = 0\n word.chars.each { |char| score += letter_scores.index(char}\n score \n end\n words[word_scores.index(word_scores.max)]\nend", "def letter_frequency(s)\n s.downcase.scan(/[a-z]/).group_by(&:itself).\n transform_values(&:size).sort_by {|k,v| [-v, k]}\nend", "def high(string)\n letter_array = (\"a\"..\"z\").to_a\n score_hash = Hash.new(0)\n\n word_array = string.split\n word_array.each do |word|\n word.chars.each do |letter|\n score_hash[word] += letter_array.index(letter) + 1\n end\n end\n max_word_value = score_hash.values.max\n score_hash.key(max_word_value)\nend", "def count_occurrences(array)\n array.uniq.each { |word| puts \"#{word} => #{array.count(word)}\"}\nend", "def letter_counts(word)\n hash = Hash.new(0)\n word.chars {|letter| hash[letter] += 1}\n hash\nend", "def letter_counts(word)\n hash = Hash.new(0)\n word.each_char do |ch|\n hash[ch] += 1\n end\n hash\nend", "def frequency\n # normal string which has assigned all the alphabets\n name = 'abcdefghijklmnopqrstuvwxyz'\n # this line will first split 'name' string and then assign it to hash\n @letters = name.split('').reduce(@letters){|alphabet,count| alphabet[count] +=0; alphabet}\n # this will convert all the alphabets of 'str' to lower case\n @str = @str.downcase\n # this will remove special characters from the string and only allow lower case alphabets\n @str = @str.gsub(/[^a-z]/, '')\n # this will split the 'str' and assign the letters to hash and add 1 each time the letter appeared\n @letters = @str.split('').reduce(@letters){|alphabet,count| alphabet[count] +=1; alphabet}\n\n end", "def mode(input_array)\n counts = Hash.new\n\n # i=0\n # while i < input_array.length\n # if counts.has_key?(input_array[i])\n # counts[input_array[i]]+=1\n # else\n # counts[input_array[i]]=1\n # end\n # i+=1\n # end\n\n input_array.each do |element|\n if counts.has_key?(element)\n counts[element]+=1\n else\n counts[element]=1\n end\n end\n\n # puts counts\n\n max=0\n\n counts.each do |word,count|\n if count > max\n max = count\n end\n end\n\n # puts max\n\n output_array = Array.new\n\n counts.each do |word,count|\n if count == max\n output_array.push(word)\n end\n end\n\n p output_array\n\nend", "def charFreq(someFile)\ntext = \"\"\nFile.open(someFile, 'r') do |file|\n text = file.to_a.to_s.downcase.gsub(/[^a-z\\s]/, '')\nend\n\nfreq = {}\nchar = text.split(\"\")\nfreq = char.uniq.each{|c| freq[c] = char.count(c)}\n\ncounts = {}\nfor c in char \n if counts.key?(c)\n counts[c] += 1\n else \n counts[c] = 1\n end\nend \n\nprint(counts)\nend", "def LetterCountI(str)\n\n arr=str.split\n arr.each{|word|\n word.each_char{|char|\n return word if word.count(char)>1\n }\n \n }\n -1\nend", "def letter_frequency_x(s)\n s.downcase.chars.\n each_with_object(Hash.new(0)) {|c,h| h[c] += 1 if c !~ /[^a-z]/}.\n sort_by {|k,v| [-v,k]}\nend", "def frequency(string,char)\n\t\tstring.count(char) / string.length.to_f\n\tend", "def common_chars(array)\n commons = []\n array.first.chars.each do |char|\n if arr_includes_char?(char, array) && array.all? { |word| word.count(char) == array.first.count(char) }\n commons << char\n end\n end\n commons\nend", "def letter_counts(word)\n hash = {}\n word.chars.uniq.each {|char| hash[char] = word.count(char)}\n hash\nend", "def count_occurrences1(array)\n occurrences = {}\n\n array.map(&:downcase).each do |element|\n occurrences[element] = array.count(element)\n end\n\n occurrences.each do |element, count|\n puts \"#{element} => #{count}\"\n end\nend", "def most_common_vowel(string)\n alpha = %w[a e i o u]\n letters = string.split(\" \").join(\" \").chars\n our = letters.select {|x| alpha.include?(x) }\n count = Hash.new(0)\n our.each do |x|\n count[x] += 1\n end\ncount.sort_by {|k, v| v}.last.first\nend", "def most_chars(str)\n hash = Hash.new(0)\n str.each_char { |chr| hash[chr] += 1 if chr != ' ' }\n \n hi_chr = ''\n count = 0\n hash.each do |k, v|\n if v > count\n hi_chr, count = k, v\n end\n end\n \n hi_chr\nend", "def letter_counts(word)\n hashed = word.chars.map {|char| [char, word.count(char)]}.flatten\n return Hash[*hashed]\nend", "def repeat_letters\n puts \"Type in as many words as you want to find the word with most repeats\"\n user_input = gets.chomp\n word = word.max_by {|string| string.chars.count - string.char.uniq.count}\n puts word\nend" ]
[ "0.78851956", "0.7627264", "0.76267445", "0.7623407", "0.7517604", "0.7409256", "0.7402383", "0.7383039", "0.7335671", "0.73182625", "0.72361624", "0.7208984", "0.7204907", "0.7200099", "0.7183736", "0.7168996", "0.71407104", "0.71365255", "0.70735353", "0.70425355", "0.70299363", "0.69919455", "0.69893163", "0.69835037", "0.69767946", "0.69739884", "0.69554675", "0.695054", "0.69419426", "0.69189644", "0.69179016", "0.6917858", "0.69135326", "0.6899236", "0.6895406", "0.68665296", "0.68592286", "0.6855538", "0.6851107", "0.6836363", "0.6824379", "0.68215376", "0.6817666", "0.6815717", "0.6790093", "0.67876816", "0.67778873", "0.6770043", "0.67684424", "0.67511183", "0.6745543", "0.67308706", "0.67107624", "0.6702605", "0.66864103", "0.6681467", "0.6677791", "0.667191", "0.6670908", "0.6670559", "0.6656358", "0.66506624", "0.66412807", "0.66320086", "0.6628181", "0.6623614", "0.6616557", "0.6616274", "0.6612603", "0.66088396", "0.6608002", "0.66055954", "0.6598199", "0.65954787", "0.6595053", "0.65931267", "0.6592212", "0.6583918", "0.6576786", "0.6566056", "0.6562969", "0.65591", "0.65548044", "0.65546256", "0.65542454", "0.6553785", "0.65508556", "0.65501356", "0.65315825", "0.65272593", "0.6523859", "0.65234005", "0.65145445", "0.6510623", "0.6496958", "0.6490623", "0.64761084", "0.6470572", "0.6460096", "0.6454936" ]
0.75683826
4
propose a new item with quantity
def propose_item_with_quantity(name, price, quantity, selling_mode, increment, end_time, description = "", log = true) item = self.propose_item(name,price,selling_mode,increment,end_time, quantity, description,log) item end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add\n @item.increment(:quantity)\n @item.save!\n\n refresh\n end", "def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n\n order_item = order.items.find_or_create_by(\n product_id: product_id\n )\n\n order_item.price = product.price\n order_item.quantity = 1\n order_item.save\n end", "def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend", "def add_item(title, price, quantity=1) \n self.total += price * quantity\n quantity.times do\n items << title \n end\n self.last_transaction = price * quantity\n\n end", "def add_item(title, price, quantity=1)\n #and increases the total\n self.total += price * quantity\n #times.do for all the items\n quantity.times do\n @items << title\n end\n #doesn't forget about the previous total\n self.last_transaction = price * quantity\n end", "def add_item(title, price, quantity=1)\n self.total += price * quantity\n #quantity amount of times it'll add the title to the items array\n quantity.times {items << title}\n self.last_transaction = price * quantity\n end", "def add_item(title, p, q=1) # accepts a title and a price AND inc. the total. Optional quantity set to 1 since u will always have at least one item.\n @total += (p*q) # @ total is price times quantity, and increments (does not forget previous total as u add new items)\n q.times do # want to add the item as many times to the list as its quantity so keep doing this the # of times its quantity is\n @items << title\n end\n @last_transaction = p # the last transaction = the price of the last item added\n end", "def add_item(item, price, quantity=1)\n @total += (price * quantity)\n @items.fill(item, @items.size, quantity)\n @last_transaction = {item => (price * quantity)}\n @last_qty = quantity\n end", "def add_item(title, amount, quantity=1)\n self.total += amount * quantity\n quantity.times do\n items << title\n end\n self.last_transaction = amount * quantity\n end", "def add_item (title, price, quantity=1)\n self.total += price * quantity\n quantity.times do\n @items << title\n end\n end", "def create_item(name, price, quantity, description=\"No description available\", image=\"\")\n new_item = Item.created( name, price, self.working_for, quantity, description, image)\n if !(identical = self.working_for.list_items_inactive.detect{|i| i == new_item }).nil?\n identical.quantity += new_item.quantity\n else\n self.working_for.offers.push(new_item)\n new_item.save\n end\n Activity.log(self, \"add_item\", new_item, self.working_for)\n return new_item\n end", "def add_item(title, price, quantity=1)\n self.total += price * quantity #Think about this logically\n #you go into a store and buy and item. How do you get the total of the item.\n #you MULTIPLY BY THE PRICE!!!! DURRRRR!!! GOD MORTY YOUR SO DUMB\n @price = price\n #do this x amount of times.\n quantity.times do\n @items << title\n end\n\n end", "def add_item(product_id)\n item = line_items.where(product_id: product_id).first\n if item.present?\n item.quantity += 1\n item\n else\n line_items.new(product_id: product_id)\n end\n end", "def update_qty(shopping_list, item, quantity)\r\n\r\n\tadd_item(shopping_list, item, quantity)\r\n\r\nend", "def add_item(title, price, quantity = 1)\n @title = title\n @price = price\n quantity.times {@items << title}\n @last_transaction = @price * quantity\n @total = @total + (@price * quantity)\n @total\n end", "def new_quantity args={}\n SY::Quantity.new args.merge( composition: self )\n end", "def update_quantity(grocery_list, item, quantity)\r\n add_item(grocery_list, item, quantity)\r\n \r\nend", "def add_item (title, price, quantity = 1)\n # adds purchase price to total\n @total += price * quantity\n # Adds proper quanity of item to cart\n count = 0\n while count < quantity\n @items << title\n count += 1\n end\n # keeps track of last_added item\n @last_transaction[:item] = title\n @last_transaction[:price] = price\n @last_transaction[:quantity] = quantity\n\n end", "def add_item(new_list, item_name, quantity=1)\r\n \r\n new_list[item_name] = quantity\r\n \r\nend", "def add_item(item, quantity, list)\n\tlist[item] = quantity\n\titem\nend", "def propose_item(name, price, selling_mode, increment, end_time, quantity = 1, description = \"\", log = true)\r\n if selling_mode == :fixed\r\n item = Item.fixed(name, price, self, description)\r\n elsif selling_mode == :auction\r\n item = Item.auction(name, price, self, increment.to_i, end_time, description)\r\n end\r\n item.quantity = quantity\r\n item.save\r\n\r\n self.attach_item(item)\r\n ItemAddActivity.create(self, item).log if log\r\n\r\n item\r\n end", "def add_item(product_id, quantity)\n product = Product.find(product_id) # product is exists?\n\n quantity = quantity.blank? ? 1 : (quantity.to_i > 99? 99 : quantity.to_i)\n\n return if quantity < 1 # return if invalid quantity is provided\n \n if cart_item = @items.find { |item| item.id.to_i == product_id.to_i }\n cart_item.quantity += quantity\n cart_item.quantity < 99 ? cart_item.quantity : cart_item.quantity =99\n else\n @items << CartItem.new(product.id, quantity)\n end\n\n end", "def add_item(item, quantity = 1)\n order_item = self.order_items.find_by item: item, price: item.price\n if order_item.is_a? OrderItem\n order_item.add quantity\n else\n self.order_items.create item: item, price: item.price, quantity: quantity\n end\n recalculate!\n end", "def update_quantity (grocery, item_name, new_quantity)\n grocery[item_name] = new_quantity\n display_list(grocery)\n end", "def add_product(product)\n # inicia transação\n transaction do \n item = self.items.detect{|item| item.product == product}\n if item\n item.quantity += 1\n item.save\n else\n self.items.create(:product => product, :quantity => 1, :price => product.price)\n end\n end\n end", "def add_units(qty)\n qty.to_i.times do\n #create item\n item = supply_items.new\n item.status = SupplyItem::STATUS_AVAILABLE\n item.save\n end\n end", "def add_item (title, price, quantity = 1)\n i = 0\n while i < quantity\n @items << title\n i += 1\n end\n my_price = price * quantity\n @transactions << my_price\n @total += (price * quantity)\n end", "def add_item(name, price, quantity = 1)\n self.total += price * quantity\n quantity.times {self.items << name}\n record_trans(name, price, quantity)\n end", "def add_item(title, price, quantity = 1)\n @total += price*quantity\n @instance_items << [title, price, quantity]\nend", "def use_item(item_name:, quantity:)\n total_items_quantity[item_name] -= quantity\n end", "def add_item(item_name, price, quantity = 1)\n @transactions << Transaction.new(item_name, price, quantity)\n quantity.times{self.items << item_name}\n self.total += price*quantity\n end", "def add_new_items(list, item_name, quantity=1)\n list[item_name] = quantity\n list\nend", "def new_qty(list, item, qty)\n list[item] = qty\n return list\nend", "def add_item (grocery, item_name, quantity)\n grocery[item_name] = quantity\n display_list(grocery)\n end", "def add_product(product, quantity)\n current_item = OrderItem.find_by(product_id: product.id, order_id: self.id )\n\n if current_item\n current_item.quantity = quantity\n current_item.save\n else\n new_item = OrderItem.new(product_id: product.id, quantity: quantity, order_id: self.id)\n new_item.save\n end\n end", "def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n order_item = order.items.find_or_initialize_by(\n product_id: product_id,\n price: product.price,\n quantity: quantity\n )\n\n order_item.save!\n end", "def add_item(grocery_list,new_item,quantity=1)\n grocery_list[new_item] = quantity\nend", "def test_adds_up_in_quanttity\n\t\tcart = Cart.new\n\t\t3.times { cart.add_item 1 }\n\n\t\tassert_equal cart.items.length, 1 #solo un item\n\t\tassert_equal cart.items.first.quantity, 3 #varias unidades del mismo item\n\tend", "def add_item(list, new_item, quantity=1)\n list[new_item] = quantity \nend", "def update (item, quantity)\n @groceries[item]=quantity\n end", "def add_item(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(item_id)\n line_item = self.line_items.find_by(item_id: item_id)\n if line_item\n line_item.quantity += 1\n else\n line_item=self.line_items.build(item_id: item_id)\n end\n line_item\n end", "def add_product(product_id)\n current_item = line_item.find_by_product_id(product_id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product_id)\n end\t\n current_item\nend", "def update_quantity(new_list, item_name, quantity)\r\n \r\n new_list[item_name] = quantity\r\nend", "def add_item(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend", "def add_product(product, quantity=1, payment_method='deposit')\n item = @items.find { |i| i.product_id == product.id && i.payment_method == payment_method }\n if item\n item.quantity += quantity\n if item.quantity > 20\n item.quantity = 20\n @quantity_error=\"Only 20 Items may be added at one time. If you need to purchase additional items please contact customer service.\"\n end\n else\n @items << OrderLineItem.new(\n :product_id => product.id,\n :quantity => quantity,\n :unit_deposit => product.deposit,\n :unit_price => product.price,\n :payment_method => payment_method\n )\n end\n end", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(item, price, quantity = 1)\n self.total += price * quantity\n self.last_item = price\n self.last_quantity = quantity\n\n counter = 0\n while counter < quantity\n self.cart << item\n counter += 1\n end\n self.cart\n end", "def add_item(item, price, *quantity)\n q = quantity.join(\"\").to_i\n if q > 1\n q.times do\n @items.push(item)\n end\n else\n @items.push(item)\n end\n if q > 1\n price_with_quantity = q * price\n @last = price_with_quantity\n @total += price_with_quantity\n else\n @last = price\n @total += price\n end\n\n end", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(item_id)\n if line_item = line_items.find_by(item_id: item_id)\n line_item.quantity += 1\n else\n line_item = line_items.build(item_id: item_id)\n end\n line_item\n end", "def add_an_item(grocery_list, new_item, qty = 1)\n grocery_list[new_item] = qty\n grocery_list\nend", "def initialize(item, quantity)\n @item = item\n @quantity = quantity\n end", "def update_quantity_of_item(list,item,quantity)\r\n add_item_to_list(list,item,quantity)\r\n list\r\nend", "def add_item(list, new_item, qty=1)\n list[new_item] = qty\nend", "def update_quantity(list,item,item_count)\n\tlist[item] = item_count\nend", "def add_item(hash_of_items, item, quantity=1)\n hash_of_items[item] = quantity\n hash_of_items\nend", "def add_item(item, quant=0)\n\t$grocery_list.store(item, quant)\n\tp \"You added #{item} to your list.\"\nend", "def add_item(item_name, grocery_list, quantity=1)\n grocery_list[item_name] = quantity\n grocery_list\n end", "def new_item(which = 0,opts={})\n defaults = {:number => @holdings[which].items.count}\n @holdings[which].new_item(defaults.merge(opts))\n end", "def add_product(product_id)\n \tcurrent_item = line_items.find_by(product_id: product_id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product_id)\n end\n current_item\n end", "def update_quantity(grocery_list, item_name, qty = 1)\r\n\tgrocery_list = add_item(grocery_list, item_name, qty)\r\n\treturn grocery_list\r\nend", "def update_quantity(item_name, grocery_list, quantity)\n grocery_list[item_name] = quantity\n grocery_list\n end", "def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_product(product)\n current_item = line_items.find_by(product_id: product.id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product.id)\n end\n current_item\n end", "def add_product(product)\n current_item = line_items.find_by(product_id: product.id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product.id)\n end\n current_item\n end", "def add_product(product_id)\n \t#current_item = line_items.where(product_id: product_id).first\n\n \t# if current_item\n \t# if (current_item.quantity == nil) \n # current_item.quantity = 0\n # end\n # current_item.quantity = 1\n \t# else\n \t# current_item = line_items.build(:product_id => product_id)\n # current_item.quantity += 1\n # end\n #current_item\n line_items.create(:product_id => product_id, :quantity => 1)\n end", "def update_quantity(list, item, quantity)\n\tadd_to_list(list, item, quantity)\nend", "def add_item(item, price, quantity = 1)\n @total += price * quantity\n @transactions << price * quantity\n i = quantity\n until i == 0 do\n @items << item\n i -= 1\n end\n end", "def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity.to_i\n\tlist\nend", "def updated_quantity(list, item_name, quantity)\r\n\tlist[item_name] = quantity\r\n\tlist\r\nend", "def new_quantity(list, item, qty)\n list[item] += qty\n p list\nend", "def add(quant)\n self.quantity_consumed -= quant\n save\n \"added #{quant} #{name}\"\n end", "def add_item(current_list, item_added, quantity)\n current_list[item_added] = quantity\n current_list\nend", "def increment_quantity\n @quantity += 1\n end", "def add(selected_item, count = 1)\n item = find_item(selected_item)\n if item != nil\n init_count = item.fetch(\"count\").to_i\n init_count += count.to_i\n item.store(\"count\", init_count)\n else\n struct = CartItem.new\n struct.cart_item_id = selected_item.id\n struct.count = count.to_i\n @items.push(struct)\n end\n end", "def update_quantity(grocery_list,item,new_quantity)\n # if item on the list\n grocery_list.store(item,new_quantity)\n puts \"When you pick up #{item}, make sure to grab #{new_quantity} instead.\"\nend", "def add_item(list, item_name, quantity=1)\n list[item_name] = quantity\nend", "def add_item(item, price, quantity=1)\n # to call an instance method inside another instance method, use the self keyword to refer to the instance on which you are operating\n self.total += price * quantity # increment the total by the result of (price X quantity)\n # puts \"total: #{self.total}\"\n\n quantity.times do\n @items << item # add item to array 'quantity' # of times ***see note below\n end\n\n @last_transaction = price * quantity # keep track of the last transaction amount added\n # puts \"last transaction: #{@last_transaction}\"\n end", "def add(list, item_name, quantity)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, item, quantity=0)\n\tlist[item] = quantity\n\tlist\nend", "def add_product (product_id)\n current_item = line_items.find_by_product_id(product_id)\n if current_item\n current_item.quantity += 1\n else\n # The default quantity is 1. \n current_item = line_items.build(product_id: product_id)\n end\n current_item\n end", "def add_item(list, item, quantity)\n\n\tlist[item] = quantity\n\tlist\n\nend", "def add_item(inventory, item, quantity)\n\tinventory[item] = quantity\n\t@full_inventory = inventory\n\t#this is what updates your inventory with the new item & quantity.\nend", "def add_item(equipment_model, _quantity = nil)\n return if equipment_model.nil?\n key = equipment_model.id\n items[key] = items[key] ? items[key] + 1 : 1\n end", "def add_item\n\t\tset_sale\n\t\tpopulate_products\n\n\t\tline_item = Item.where(sale_id: params[:sale_id], product_id: params[:product_id]).first\n\t\tline_item.quantity += 1\n\t\tline_item.save\n\n\t\t# Llama método que reduce cantidad de stock\n\t\tremove_item_from_stock(params[:product_id])\n\t\tupdate_line_item_totals(line_item)\n\n\t\tupdate_totals\n\n\t\trespond_to do |format|\n\t\t\tformat.js { ajax_refresh }\n\t\tend\n\tend", "def add_item(item, list, quantity)\n list[item] = quantity\nend", "def add_item(title, price, quantity =1)\t#increases the total\n\t\tcounter = quantity\n\n\t\twhile counter > 0\n\t\t\t@@all << title\n\t\t\tcounter -= 1\n\t\tend\n\n\t\t\n\t\t@prev_total = @total\n\t\t\n\t\t@total = (@prev_total + (price * quantity))\n\n\n\t\t@total \t\t\t\n\tend", "def reshelf(product, quantity)\n # NOT DEFINED IN EXAMPLES\n @inventory[product][\"quantity\"] += quantity\nend", "def increment_quantity\n self.quantity_needed += self.quantity\n save\n end", "def update_qty(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend", "def add_item\n\t puts \"What is the name of the item you'd like to add?\"\n\t\t@item_name = gets.chomp\n\t\tputs \"And how many?\"\n\t\t@quantity = gets.chomp.to_i\n\t\tif @quantity <= 0\n\t\t puts \"Please enter a number higher than 0.\"\n\t\t puts \"(Also, must be '1' not 'one'.)\"\n\t\telse\n\t\t @grocery_list[@item_name] = @quantity\n\t\tend\n\t\tget_item\n\tend", "def add_item(g_hash,new_item,quantity = 1)\n g_hash[new_item] = quantity\nend", "def add_item(g_hash,new_item,quantity = 1)\n g_hash[new_item] = quantity\nend", "def update_quantity(grocery_list, item_name, qty = 1)\n\tgrocery_list = add_item(grocery_list, item_name, qty)\n\treturn grocery_list\nend", "def refill(item_name:, quantity:)\n total_items_quantity[item_name] += quantity\n items_running_low[item_name] = false\n end", "def add_product(product_id)\n current_item = line_items.where(:product_id => product_id).first\n if current_item\n current_item.quantity += 1\n # Otherwise create a new line_item\n else\n current_item = LineItem.new(:product_id => product_id)\n line_items << current_item # add the current_item to the end of the line_items\n end\n current_item\n end" ]
[ "0.7752051", "0.7704649", "0.75937855", "0.7586079", "0.7562667", "0.7522789", "0.75090563", "0.7491194", "0.74564815", "0.7416457", "0.74152505", "0.7402384", "0.73710334", "0.73679346", "0.7359215", "0.7333172", "0.73271745", "0.72894347", "0.7275302", "0.7266912", "0.72657496", "0.7265434", "0.7261998", "0.72609204", "0.7253747", "0.72534716", "0.72389686", "0.72222126", "0.7208448", "0.720636", "0.7190581", "0.71887374", "0.7186407", "0.71854365", "0.715906", "0.7157221", "0.7156968", "0.7155116", "0.7150236", "0.7147247", "0.7126157", "0.7126157", "0.7119947", "0.7119096", "0.7113923", "0.7109947", "0.71074563", "0.7106001", "0.7106001", "0.71054494", "0.7104958", "0.7104512", "0.710311", "0.7097481", "0.7096181", "0.7078384", "0.70729697", "0.7069452", "0.706186", "0.7054756", "0.7054602", "0.7053455", "0.7052832", "0.7052496", "0.7046336", "0.7045958", "0.7045958", "0.70240307", "0.7023388", "0.7018074", "0.70164186", "0.70100564", "0.7005617", "0.70030004", "0.70001537", "0.69931024", "0.6988469", "0.698283", "0.6979957", "0.697623", "0.6973448", "0.69618636", "0.6961502", "0.6956977", "0.695538", "0.69536304", "0.69514906", "0.6945819", "0.6941532", "0.693344", "0.69312024", "0.692881", "0.69264364", "0.6925767", "0.6925738", "0.6923182", "0.6923182", "0.692174", "0.6914231", "0.6909556" ]
0.785348
0
propose a new item
def propose_item(name, price, selling_mode, increment, end_time, quantity = 1, description = "", log = true) if selling_mode == :fixed item = Item.fixed(name, price, self, description) elsif selling_mode == :auction item = Item.auction(name, price, self, increment.to_i, end_time, description) end item.quantity = quantity item.save self.attach_item(item) ItemAddActivity.create(self, item).log if log item end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_item(new_item)\n item = Item.new(new_item)\n items.push(item)\n end", "def add_item(new_item)\n item = Item.new(new_item)\n @items.push(item)\n end", "def propose_item(name, price, selling_mode, increment, end_time, description = \"\", log = true)\n if selling_mode == \"fixed\"\n item = Item.named_priced_with_owner_fixed(name, price, self, description)\n else\n item = Item.named_priced_with_owner_auction(name, price, self, increment.to_i, end_time, description)\n end\n item.save\n\n self.attach_item(item)\n Analytics::ItemAddActivity.with_creator_item(self, item).log if log\n\n item\n end", "def set_new_item\n @new_item = NewItem.find(params[:id])\n end", "def add_new_item(new_item)\n @items.push(new_item)\n end", "def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n\n order_item = order.items.find_or_create_by(\n product_id: product_id\n )\n\n order_item.price = product.price\n order_item.quantity = 1\n order_item.save\n end", "def set_item(new_item)\n return if @item == new_item\n @item = new_item\n refresh\n end", "def propose_item_with_quantity(name, price, quantity, selling_mode, increment, end_time, description = \"\", log = true)\r\n item = self.propose_item(name,price,selling_mode,increment,end_time, quantity, description,log)\r\n item\r\n end", "def create_item(name, price, quantity, description=\"No description available\", image=\"\")\n new_item = Item.created( name, price, self.working_for, quantity, description, image)\n if !(identical = self.working_for.list_items_inactive.detect{|i| i == new_item }).nil?\n identical.quantity += new_item.quantity\n else\n self.working_for.offers.push(new_item)\n new_item.save\n end\n Activity.log(self, \"add_item\", new_item, self.working_for)\n return new_item\n end", "def new\n\t\t@item = Product.new\n\tend", "def add_item(item)\n @chores << item\n end", "def create_item(name, price)\r\n new_item = Models::Item.created( name, price, self )\r\n self.item_list.push(new_item)\r\n new_item.save\r\n return new_item\r\n end", "def create_item( *args )\n raise NotImplementedError.new(\"Subclasses must implement #create_item\")\n end", "def new_item(which = 0,opts={})\n defaults = {:number => @holdings[which].items.count}\n @holdings[which].new_item(defaults.merge(opts))\n end", "def add_item(new_list, item_name, quantity=1)\r\n \r\n new_list[item_name] = quantity\r\n \r\nend", "def new_item(opts={})\n defaults = {:number => @items.count + 1}\n @items << ItemRecord.new(defaults.merge(opts))\n end", "def create_item(name, price)\r\n new_item = Trading::Item.created( name, price, self )\r\n self.item_list.push(new_item) # AK You can also do `item_list << new_item`\r\n return new_item\r\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 newitem\n entry = Pages::Storage::Entry.new(self)\n\n entry.title = ''\n entry.tags = []\n entry.date = Time.new\n entry.content = ''\n entry.draft = false\n\n @items << entry\n\n return entry\n end", "def new\n @item = Item.new\n end", "def add_item(list, new_item, quantity=1)\n list[new_item] = quantity \nend", "def new_item\n pause(item_delay) if item_delay\n self[:index] = nil\n self[:value] = nil\n end", "def item_add item\n\t\tret = super\n\t\titem.known! if (ret)\n\t\treturn ret\n\tend", "def saw_item(item); end", "def add_new(type, new_item)\n #Add exercise to exercise_list\n if type == \"exercise\"\n @exercise_list.push(new_item)\n return 0\n #Add a workout to workout_routines\n elsif type == \"workout\"\n @workout_routines.push(new_item)\n return 0\n #Error handling\n else\n return -1\n end\n\n end", "def attach_item(item)\r\n equal_item = self.check_for_equal_item(item.name,item.price,item.description)\r\n if equal_item == nil\r\n self.items << item\r\n item.owner = self\r\n item.deactivate\r\n else\r\n equal_item.quantity += item.quantity\r\n equal_item.deactivate\r\n item.delete\r\n end\r\n end", "def new\n \t@item=Item.new({:ItemName =>'def'})\n end", "def add_item(itemToAdd)\r\n itemToAdd.set_owner(self)\r\n itemToAdd.deactivate\r\n self.items.push(itemToAdd)\r\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 new_item(content)\n Item.new(:project_id => @project_id, :content => content)\n end", "def add_new_items(list, item_name, quantity=1)\n list[item_name] = quantity\n list\nend", "def add_new_product\n array_product = @view.new_product_info\n new_product = Product.new(array_product[0],array_product[1],array_product[2])\n @seller.save_product_info(new_product)\n input = @view.menu(\"2\")\n seller_actions(input)\n end", "def add(product)\n items.create(product: product)\n end", "def add_item(name, annotation, content, avaliability, units, userId)\r\n @newInstance = Ingredience.new\r\n @newInstance.name = name;\r\n @newInstance.annotation = annotation\r\n @newInstance.content = content\r\n @newInstance.avaliability = avaliability\r\n @newInstance.units = units;\r\n @newInstance.user_id = userId;\r\n @newInstance.activation_state = 1;\r\n\r\n @newInstance.save\r\n end", "def add_item(list, item, quantity = 1)\r\n# input: list, item name, and optional quantity\r\n# steps: \r\n # check for optional quantity. if not present, set to default (1)\r\n list[item] = quantity\r\n # update list with input\r\n puts \"#{item.upcase} has been added to your grocery list!\"\r\n p list\r\n# output: complete list, updated\r\nend", "def add_item(list, new_item, qty=1)\n list[new_item] = qty\nend", "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 item_create\n @brief = Brief.find(params[:brief_id])\n @brief_vendor = @brief.brief_vendors.find_by_org_id(@cur_user.org_id)\n invalid_op unless @brief_vendor\n @brief_vendor.items << Item.new(params[:item]){|r|r.kind = params[:kind]}\n redirect_to vendor_show_brief_path(@brief)\n end", "def item_new\n @brief = Brief.find(params[:brief_id])\n @item = Item.new\n @item.kind = params[:kind]\n @action_to = vendor_item_create_path(@brief,@item.kind)\n end", "def add(todo)\n @items << Item.new(todo)\n save\n @items.last\n end", "def item=(new_item)\n @item = new_item\n self.item_id = @item.id\n self.item_type = new_item.class.name.classify\n end", "def add_an_item(grocery_list, new_item, qty = 1)\n grocery_list[new_item] = qty\n grocery_list\nend", "def item_insert(item)\n insert(playlist_url, @response.new_index, item)\n end", "def add_product(product_id)\n current_item = line_item.find_by_product_id(product_id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product_id)\n end\t\n current_item\nend", "def add_item(grocery_list,new_item,quantity=1)\n grocery_list[new_item] = quantity\nend", "def add_item(list, name, quantity = 1) \r\n# input: item name and optional quantity\r\n# steps: \r\n# create add method with name and optional quantity arguments\r\n# add name and quantity to hash\r\n list[name] = quantity\r\n# output: print \"your item has been added to the hash\"\r\n return list\r\nend", "def add(item)\n item.available? ? items.create(cartable: item) : false\n release\n end", "def set_item\n # 出品機能未実装のため仮置き\n @item = Item.find(params[:id])\n end", "def update_item\n pcp_item.update_new_assmt( self )\n end", "def update!(**args)\n @create_item = args[:create_item] if args.key?(:create_item)\n end", "def add(item)\r\n fail \"missing item\" if item.nil?\r\n fail \"item is not active, it cannot be put in your wish list\" unless item.is_active?\r\n\r\n self.items << item\r\n item.add_observer(self)\r\n end", "def add_item(existing_list, new_item, item_integer)\n\t# input: item name and optional quantity\n\t# steps: pass in item name as key and assign value\n\texisting_list[new_item] = item_integer\n\t# output: hash\n\tp existing_list\nend", "def add_item(list, item_name, quantity = 1)\r\n list[item_name] = quantity\r\nend", "def add_item(product_id)\n item = line_items.where(product_id: product_id).first\n if item.present?\n item.quantity += 1\n item\n else\n line_items.new(product_id: product_id)\n end\n end", "def updating_item(list,item,quantity)\r\n\r\n adding_item(list,item, quantity)\r\n\r\nend", "def add_item(current_list, item_added, quantity)\n current_list[item_added] = quantity\n current_list\nend", "def add_item\n\t\tcurrent_user.saved.items.push(Item.find(params[:item]))\n\t\tredirect_to :back\n\tend", "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 add_item(item, quant=0)\n\t$grocery_list.store(item, quant)\n\tp \"You added #{item} to your list.\"\nend", "def add_item(list, item_name, optional_quantity)\n\nlist[item_name] = optional_quantity\n\n# input: list, item name, and optional quantity\n# steps:\n # Add new hash key based on item name\n # Tell method there may or may not be a argument passed in for quantity\n # assign quantity to 'optional-quantity' argument in method definition\n # Access method that contains initialized hash def add_item(create_list, item_name, quantity = 3)\n# output:\n # updated grocery list\nend", "def add_item(name)\n\t\ttodo_items.push(TodoItem.new(name))\n\tend", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def add_item(list, item_name, quantity = 1)\n\tlist[item_name] = quantity\n\tlist\nend", "def set_item(item_id)\n @kind = 2\n @item_id = item_id\n end", "def add_new_itemized_partner(partner)\n # basic partner info\n fill_company_info(partner)\n # admin & company type info\n fill_partner_admin_info(partner)\n fill_partner_specific_info(partner)\n # itemized partner specific info\n fill_itemized_discounts(partner)\n fill_subscription_period(partner.subscription_period)\n fill_itemized_info(partner)\n # billing info\n fill_billing_info(partner)\n # submission\n create_partner_btn.click\n partner_created\n end", "def add_item(list, item_name, quantity=1)\n list[item_name] = quantity\nend", "def push(item); end", "def prorate_create_item(t, tariff, invoice_id, subcode, price, quantity, measure, tax_type_id, discount_pct, user_id, d)\n if t == 'P'\n create_pre_invoice_item(tariff, invoice_id, subcode, price, quantity, measure, tax_type_id, discount_pct, user_id, d)\n else\n create_invoice_item(tariff, invoice_id, subcode, price, quantity, measure, tax_type_id, discount_pct, user_id, d)\n end\n end", "def add_instance_item(item)\n container = item_container(item.class)\n container[item.template_id] ||= 0\n container[item.template_id] += 1\n container[item.id] = 1\n container_list = item_container_list(item)\n container_list.push(item)\n end", "def add_item(item, quantity, list)\n\tlist[item] = quantity\n\titem\nend", "def add_to_list(list,item,quantity)\n\tupdate_item(list,item,quantity)\nend", "def add_item(list,new_item,item_count)\n\tlist[new_item] = item_count\nend", "def add_item(grocery,item_name,quantity)\n # input: list, item name, and optional quantity\n # steps: insert item_name as a key and quantity as a value to the hash \n grocery[item_name] = quantity\n # output:display the latest list\n display_list(grocery)\nend", "def add_product(product_id)\n \tcurrent_item = line_items.find_by(product_id: product_id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product_id)\n end\n current_item\n end", "def <<(item)\n add_item(item)\n end", "def quick_new\n @bill = Bill.new\n @bill.items.build\n end", "def addItem(item)\n @items << item\n end", "def push(item)\n end", "def add_item(title, price, quantity = 1)\n @total += price*quantity\n @instance_items << [title, price, quantity]\nend", "def upsert(kind, item)\n end", "def <<(item)\n add!(item)\n end", "def add_product(product_id)\n current_item = line_items.where(:product_id => product_id).first\n if current_item\n current_item.quantity += 1\n # Otherwise create a new line_item\n else\n current_item = LineItem.new(:product_id => product_id)\n line_items << current_item # add the current_item to the end of the line_items\n end\n current_item\n end", "def item\n @new = New.find(params[:id])\n end", "def update(list, item, qty)\n add_item(list, item, qty)\nend", "def <<(item)\n item = ensure_type(Item, item)\n\n original_item = find_item(item)\n\n if original_item\n original_item.quantity += (item.quantity || 1)\n else\n store << item\n end\n end", "def new\r\n @item = Item.new\r\n @item.user_id = 0\r\n end", "def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n order_item = order.items.find_or_initialize_by(\n product_id: product_id,\n price: product.price,\n quantity: quantity\n )\n\n order_item.save!\n end", "def set_item(item)\n set_text(item ? item.description : \"\")\n if item != @item\n @item = item\n refresh\n end\n end", "def add_product(product)\n current_item = line_items.find_by(product_id: product.id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product.id)\n end\n current_item\n end", "def add_product(product)\n current_item = line_items.find_by(product_id: product.id)\n if current_item\n current_item.quantity += 1\n else\n current_item = line_items.build(product_id: product.id)\n end\n current_item\n end", "def add_product(product)\n # inicia transação\n transaction do \n item = self.items.detect{|item| item.product == product}\n if item\n item.quantity += 1\n item.save\n else\n self.items.create(:product => product, :quantity => 1, :price => product.price)\n end\n end\n end", "def add\n @item.increment(:quantity)\n @item.save!\n\n refresh\n end", "def add_item(list,name,value)\n list = List.find(list)\n list.add(Item.new(name,value))\n say_set list.name, name, value\n end", "def create\n item = Item.find(params[:item][:id])\n item.update_attribute(:preferred, true)\n redirect_to edit_sku_list_path\n end", "def set_item(item)\n return if @item == item\n @item = item\n refresh\n end", "def set_item(item)\n return if @item == item\n @item = item\n refresh\n end", "def add_item(grocery_list, new_item_to_add, quanity)\n\tgrocery_list[new_item_to_add] = quanity\n\tp grocery_list\n\nend" ]
[ "0.6981362", "0.6852838", "0.674562", "0.6734719", "0.6647732", "0.6625688", "0.6613227", "0.6558322", "0.65454644", "0.650865", "0.6504293", "0.64834315", "0.6445756", "0.64384943", "0.6434799", "0.64330024", "0.64062095", "0.6404805", "0.6404805", "0.6404805", "0.6393626", "0.6382583", "0.63792837", "0.6376214", "0.63689786", "0.6361992", "0.63452345", "0.63289136", "0.6307923", "0.62869287", "0.627132", "0.6268995", "0.626251", "0.6260983", "0.62220347", "0.62159556", "0.62116426", "0.6208318", "0.6189424", "0.6169202", "0.6163739", "0.6162838", "0.6161434", "0.61605805", "0.616041", "0.6153022", "0.6152049", "0.6148911", "0.61376977", "0.61136067", "0.61084455", "0.6104192", "0.6102465", "0.60998696", "0.60924786", "0.60899615", "0.60878706", "0.60839385", "0.6082361", "0.6076552", "0.60682654", "0.6063703", "0.60570675", "0.6056755", "0.6056755", "0.60563916", "0.60466975", "0.6041393", "0.60333085", "0.6029494", "0.60290813", "0.60275453", "0.6019986", "0.60186213", "0.601235", "0.601162", "0.6011301", "0.60100335", "0.6007492", "0.59992784", "0.59988075", "0.59953904", "0.59914374", "0.59913456", "0.5991236", "0.5991032", "0.59900683", "0.5988384", "0.5987273", "0.5986866", "0.5986492", "0.5985334", "0.5980309", "0.5979524", "0.59745586", "0.59740186", "0.5973103", "0.5971549", "0.5971549", "0.5969459" ]
0.7235941
0
sell item matching an offer
def sell_to_offer(offer,item) active = item.active? item.activate if !active #offer.from.credits +=offer.price*offer.quantity purchase = Purchase.create(item,offer.quantity,item.owner,offer.from) purchase.adapt_price_to_offer(offer) purchase.prepare PurchaseActivity.successful(purchase).log offer.delete item.deactivate if !active end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sell(item)\r\n self.add_credits(item.price * item.quantity)\r\n Marketplace::Activity.create(Activity.ITEM_SOLD, item, \"#{item.name} has been sold by #{self.name}\")\r\n Marketplace::Activity.create(Activity.USER_SOLD_ITEM, self, \"#{self.name} sold #{item.name}\")\r\n end", "def sell_requested_item(request, buyer)\r\n item = get_matching_item(request)\r\n buyer.buy_requested_item(request, item)\r\n end", "def sell\n \t\t\n \tend", "def offer\n loc = @item.location || @item.zone\n @engine.push_context(\"offered_action\" => @action_name, \"offered_location\" => loc.name, \"offering_item\" => @item.name) do\n loc.receive_offer(@action_name, self)\n end\n end", "def sell!(qty, price)\n order = Fyb::Order.new qty, price, :sell\n order.perform\n end", "def sell(amount:, price:)\n OpenOrderParser.parse(post(\"sell\", amount: amount, price: price))\n end", "def do_sell(number)\r\r\n $game_party.gain_currency(@gold_window.currency, number * selling_price)\r\r\n $game_party.lose_item(@item, number)\r\r\n end", "def sell(item, quantity)\n if total_inventory.has_key?(item) && quantity < total_inventory[item]\n @vendors.each do |vendor|\n if vendor.inventory.has_key?(item)\n if vendor.inventory[item] >= quantity\n vendor.inventory[item] -= quantity\n else\n vendor.inventory[item] -= quantity\n diff = vendor.inventory[item].abs\n vendor.inventory[item] = 0\n @vendors.each do |vendor|\n if vendor.inventory.has_key?(item)\n if vendor.inventory[item] != 0\n require \"pry\"\n binding.pry\n vendor.inventory[item] - diff\n end\n end\n end\n end\n end\n end\n return true\n else\n return false\n end\n end", "def sell(store)\n\t\tprint \"Enter the item you want to return or press <enter> to go back: \"\n\t\titem = gets.chomp.downcase\n\t\tif @cart.include?(item)\n\t\t\t@wallet_amt += store.get_price(item) # increase wallet_amt by item price\n\t\t\t@cart.delete_at(@cart.find_index(item)) # remove item from cart\n\t\t\tstore.increment(item,\"sell\") #increment the inventory\n\t\t\tputs \"You returned #{item} and got $%.2f back.\" % store.get_price(item)\t\t\n\t\telse\n\t\t\tputs \"You can not return an item you did not buy.\"\n\t\tend\n\tend", "def item_sell_price(item)\n bonus = 1.0\n bonus += sell_bonus\n bonus += $game_party.sell_bonus\n (item.selling_price * bonus).to_i\n end", "def sell(item, count)\n wanted = Hash.new\n wanted[item] = count\n if total_inventory[item] >= wanted[item]\n return true\n elsif total_inventory[item] < wanted[item]\n then false\n else\n \"Error\"\n end\n end", "def sell!(amount, price)\n add_order!(:sell, amount, price)\n end", "def set_item\n @bid_offer = BidOffer.find(params[:id])\n end", "def purchase_item(item, seller_id, buyer_id)\n seller = User.new(seller_id)\n buyer = User.new(buyer_id)\n @conn.watch([\"market\", buyer.id]) do\n fund = @conn.hget(buyer.id, \"fund\")\n price = @conn.zscore(\"market\", seller.item_id(item))\n\n if price && price <= fund.to_i\n @conn.multi do |multi|\n multi.hincrby(buyer.id, \"fund\", -price.to_i)\n multi.hincrby(seller.id, \"fund\", price.to_i)\n multi.zrem(\"market\", seller.item_id(item))\n multi.sadd(buyer.inventory_id, item)\n end\n else\n @conn.unwatch\n end\n end\n end", "def valuate_sell_article(article)\n return if article.unlimited?\n return if article.sell_locked?\n (0..article.quantity - 1).each {\n if rand(100) < depletion_rate\n deplenish_article(article)\n if article.rare?\n $game_shops.add_on_trade_flow(article.item)\n end\n end\n }\n end", "def choice_a_shop\n sell_item\n end", "def sell(player)\n # The player has nothing to sell.\n if player.inventory.empty?\n print NOTHING_TO_SELL\n return\n end\n\n player.print_inventory\n\n print 'What would you like to sell? (or none): '\n input = player_input\n inventory_entry = player.inventory_entry(input)\n\n # The player does not want to sell an item.\n return if input.casecmp?('none')\n\n unless inventory_entry # non-existent item.\n print \"You can't sell what you don't have.\\n\\n\"\n return\n end\n\n item = inventory_entry.first\n item_count = inventory_entry.second\n\n unless item.disposable # non-disposable item (cannot sell/drop).\n print \"You cannot sell that item.\\n\\n\"\n return\n end\n\n puts \"I'll buy that for #{purchase_price(item)} gold.\"\n print 'How many do you want to sell?: '\n amount_to_sell = player_input.to_i\n\n if amount_to_sell > item_count # more than in the inventory.\n print \"You don't have that many to sell!\\n\\n\"\n return\n elsif amount_to_sell < 1 # non-positive amount specified.\n puts 'Is this some kind of joke?'\n print \"You need to sell a positive amount!\\n\\n\"\n return\n end\n\n player.adjust_gold_by((purchase_price(item) * amount_to_sell))\n player.remove_item(item, amount_to_sell)\n print \"Thank you for your patronage!\\n\\n\"\n end", "def buy_requested_item(request, item)\r\n self.overlay.delete_item_request(request.id)\r\n item.price = request.price #The prize given in the request is relevant.\r\n buy(item, true)\r\n end", "def sell_to_current_winner\r\n if self.rank_one != nil\r\n winner = self.get_current_winner\r\n item.price = self.get_current_price\r\n item.take_ownership(winner)\r\n item.state = :pending\r\n winner.credits_in_auction -= self.get_current_bid\r\n winner.credits += (self.get_current_bid - self.get_current_price)\r\n EmailSender.win_auction(winner, item)\r\n else\r\n item.state = :inactive\r\n end\r\n end", "def sell(ticker, shares, days_ago)\n @broker.sell(self, ticker, shares, days_ago)\n end", "def sell(ticker, shares, timestamp)\n broker.sell(self, ticker, shares, timestamp)\n end", "def offer\n item.try(:offer)\n end", "def set_sell\n @sell = Sell.find(params[:id])\n end", "def set_sell\n @sell = Sell.find(params[:id])\n end", "def decrease_sell_in(item)\n item.sell_in -= 1\n end", "def place_offer(proposer, amount)\n\t\t\tif proposer.balance >= amount\n\t\t\t\tsell_to(proposer, amount) if @owner.decide(:consider_proposed_trade, game: @owner.game, player: @owner, proposer: proposer, property: self, amount: amount).is_yes?\n\t\t\tend\n\t\tend", "def sell(amount)\n @quantity_in_stock -= amount\n @quantity_sold += amount\n end", "def sell(params)\n fail ArgumentError, 'Hash is expected as params' unless params.is_a?(Hash)\n fail ArgumentError, 'Hash is expected as :sender' unless params[:sender].is_a?(Hash)\n sender = params[:sender]\n fail ArgumentError, 'String is expected as sender[:amount]' unless sender[:amount].is_a?(String)\n fail ArgumentError, 'Invalid amount format' unless sender[:amount] =~ /^\\d+\\.\\d+$/\n fail ArgumentError, 'Hash is expected as :receiver' unless params[:receiver].is_a?(Hash)\n receiver = params[:receiver]\n fail ArgumentError, 'String is expected as receiver[:currency]' unless receiver[:currency].is_a?(String)\n Cubits.connection.post(\n '/api/v1/sell',\n sender: {\n amount: sender[:amount]\n },\n receiver: {\n currency: receiver[:currency]\n }\n )\n end", "def settle_item_purchase(seller, buyer, item)\n seller.credits += item.price + Integer((item.price * SELL_BONUS).ceil)\n buyer.credits -= item.price\n end", "def sell_action(shopItems)\n for shop_item in shopItems\n $game_party.gain_gold(shop_item.item.price * shop_item.quantity)\n $game_party.lose_item(shop_item.item, shop_item.quantity)\n end\n end", "def list_item(item, seller_id, price)\n u = User.new(seller_id)\n @conn.multi do |multi|\n multi.srem(u.inventory_id, item)\n multi.zadd(\"market\", price, u.item_id(item))\n end\n end", "def sell_product(name:)\n find_product(name: name).quantity -= 1\n end", "def pick_out(amnt)\n if amount - amnt > CONST::PRODUCT_IN_STOCK && on_sell?\n update(amount: amount - amnt)\n else\n errors.add(\n :base,\n Response::PRODUCT[:PRODUCT_IN_STOCK]\n ); false\n end\n end", "def selling_price\r\r\n (@buy_window.price(@item) * ($game_variables[CSCA::CURRENCY::SELL_PERC].to_f/100)).to_i\r\r\n end", "def giveItem\n toLocation = Company.where(name: params[:recepCompany]).first.locations.where(address: params[:recepLocation]).first\n location = current_company.locations.where(id: params[:locationId]).first\n if(location.is_supplier === true)\n updatedItem = location.items.where(name: params[:name]).first\n toUpdatedItem = toLocation.items.where(name: params[:name]).first\n if(toUpdatedItem.present? && updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n toUpdatedItem.increment!(:amount, params[:amount].to_i)\n elsif(updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n item = Item.create(name: params[:name], amount:params[:amount].to_i, price: updatedItem.price, autoRestock: false, lastSupplier:location.id)\n toLocation.items << item\n end\n if(updatedItem.amount <= updatedItem.restockPoint)\n changeItemSupplier(updatedItem.id)\n end\n end\n end", "def save\n if @@offers.empty?\n @@offers = Hash.new\n end\n unless self.auction\n raise \"Duplicated item\" if @@offers.has_key? self.id and @@offers[self.id] != self\n else\n raise \"Duplicated item\" if @@offers.has_key? self.id and @@offers[self.id] and @@offers[self.id] != self.item\n end\n @@offers[self.id] = self\n @@count += 1\n end", "def sell_pending\n end", "def remove_offer(offer)\n self.offers.delete(offer) #AS Not sure if it works that simple, because they have concepts like quantity. But let's face the problems as they appear.\n end", "def pass_to_se(id)\n se.find_merchant_by_item_id(id)\n end", "def sell(params)\n params[:side] = 'sell'\n params[:product_id] = id\n\n Order.create(params)\n end", "def order_method\n :sell\n end", "def sell_shop_items (params={})\r\n url = api_url \"/sell/shop/items\"\r\n req = request_params(params)\r\n\r\n feed_or_retry do\r\n RestClient.get url, req\r\n end \r\n end", "def sell_quote\n\t\tresult = money_quote('ask', btc_float2int(1.0))\n\t\treturn result['amount']\n\tend", "def sell_value(penny)\n (Item.find(item_id).price_w * sell_w)*(1.00+(penny*0.015))\n end", "def set_upsell\n @upsell = Upsell.find(params[:id])\n end", "def sell_at_any_cost(percent_decrease = 0.3)\n market_name = @market_name\n open_orders_url = get_url({ :api_type => \"market\", :action => \"open_orders\", :market => market_name })\n open_orders = call_secret_api(open_orders_url)\n #cancel all orders\n if open_orders.size > 0\n open_orders.each do |open_order|\n cancel_order_url = get_url({ :api_type => \"market\", :action => \"cancel_by_uuid\", :uuid => open_order[\"OrderUuid\"] })\n call_secret_api(cancel_order_url)\n end\n end\n # call sell bot again with lower profit\n sell_order = sell_bot(percent_decrease)\nend", "def set_buysell\n @buysell = Buysell.find(params[:id])\n end", "def offer\n end", "def offer\n end", "def offer\n end", "def deactivate_item(id)\n item = Offer.get_offer(id)\n return false unless item.owner == self.working_for\n if !(identical = self.list_items_inactive.detect{|i| i == item }).nil?\n identical.quantity+=item.quantity\n item.delete\n else\n item.active = false\n item.expiration_date=nil\n end\n\n if !item.wishlist_users.empty?\n item.wishlist_users.each {|user| user.remove_from_wishlist(item); item.wishlist_users.delete(user)}\n end\n Activity.log(self, \"deactivate_item\", item, self.working_for)\n end", "def place_sell_order(price, amount)\n @log.info \"placing sell order for price: #{price}, amount: #{amount}\"\n @api.place_order('sell', amount, price, @couple)\n end", "def buy(item, quantity)\r\n if quantity < item.quantity\r\n item_to_buy = item.split(quantity)\r\n else\r\n item_to_buy = item\r\n end\r\n seller = item_to_buy.owner\r\n seller.sell(item_to_buy)\r\n item_to_buy.owner = self\r\n self.remove_credits(item_to_buy.price * quantity)\r\n item_to_buy.deactivate\r\n Marketplace::Activity.create(Activity.ITEM_BOUGHT, item, \"#{item.name} has been bought by #{self.name}\")\r\n Marketplace::Activity.create(Activity.USER_BOUGHT_ITEM, self, \"#{self.name} bought #{item.name}\")\r\n #delete the history in the description log, except the newest entry\r\n item_to_buy.clean_description_log\r\n item_to_buy.clean_comments\r\n item_to_buy\r\n end", "def vendors_that_sell(query_item)\n @vendors.find_all do |vendor|\n vendor.inventory.keys.include?(query_item)\n end\n end", "def deal_with_other_offers\n if self.selling?\n if self.sender.nil? == false\n self.sender.active_offers_for_textbook(self.textbook_id).each do |offer|\n offer.update_status(3)\n\n if self.sender_id == offer.sender_id\n\t Offer.notify_buyer_book_sold(offer.reciever,offer.sender,textbook)\n\t else\n\t Offer.notify_buyer_book_sold(offer.sender,offer.reciever,textbook)\n\t end\n\t end\n end\n\tif self.reciever.nil? == false\n\t self.reciever.active_offers_for_textbook(self.textbook_id).each do |offer|\n\t offer.update_status(4)\n\n if self.sender_id == offer.sender_id\n\t Offer.notify_seller_book_bought(offer.reciever,offer.sender,textbook)\n\t else\n\t Offer.notify_seller_book_bought(offer.sender, offer.reciever, textbook)\n\t end\n\t end\n\tend\n else\n if self.sender.nil? == false\n self.sender.active_offers_for_textbook(self.textbook_id).each do |offer|\n offer.update_status(4)\n\n if self.sender_id == offer.sender_id\n\t Offer.notify_seller_book_bought(offer.reciever, offer.sender, textbook)\n\t else\n\t Offer.notify_seller_book_bought(offer.sender, offer.reciever, textbook)\n\t end\n\t end\n\tend\n\tif self.reciever.nil? == false\n\t self.reciever.active_offers_for_textbook(self.textbook_id).each do |offer|\n\t offer.update_status(3)\n\n if self.sender_id == offer.sender_id\n Offer.notify_buyer_book_sold(offer.reciever, offer.sender, textbook)\n\t else\n Offer.notify_buyer_book_sold(offer.sender, offer.reciever, textbook)\n\t end\n\t end\n\tend\n end\n end", "def sell(instrument, quantity, options = {}, &blk)\n params = options.merge instrument: instrument, quantity: quantity, auth: true\n if block_given?\n websocket.subscribe :sell, params: params, &blk\n else\n http.post :sell, params\n end\n end", "def buy_item(item)\r\n if !item.active || item.price > self.credits\r\n false\r\n else\r\n seller = item.owner\r\n price = item.price\r\n\r\n seller.give_credits(price)\r\n self.take_credits(price)\r\n seller.remove_item(item)\r\n self.add_item(item)\r\n item.active = false\r\n true\r\n end\r\n end", "def buying_item item_name\n @buying_results_parser.read @querier.buying_item(item_name)\n end", "def hold_sell_trade(hnum, snum, tnum, player, game, acquired_hotel)\n snum = snum.to_i\n tnum = tnum.to_i\n # do nothing when holding shares\n # deal with selling of shares\n if (snum > 0)\n # give player money\n acquired_game_hotel = game.game_hotels.where(name: acquired_hotel).first\n acquired_hotel_share_price = acquired_game_hotel.share_price\n player.cash = player.cash + (acquired_hotel_share_price * snum)\n # remove shares from stock cards and return to game pool\n snum.times do\n card = player.stock_cards.where(hotel: acquired_hotel).first\n player.stock_cards.delete(card)\n game.stock_cards << card\n end\n\n player.save\n game.save\n end\n\n # deal with trading of shares\n if (tnum > 0)\n dominant_hotel = game.dominant_hotel\n num_of_trades = tnum/2\n num_of_trades.times do\n 2.times do\n a_card = player.stock_cards.where(hotel: acquired_hotel).first\n player.stock_cards.delete(a_card)\n game.stock_cards << a_card\n end\n d_card = game.stock_cards.where(hotel: dominant_hotel).first\n game.stock_cards.delete(d_card)\n player.stock_cards << d_card\n end\n\n player.save\n game.save\n end\n end", "def click_offer_by_index(idx)\n # @todo: This should raise if the offer is not on the wall.\n click_url = offer_map.values[idx][:click_url]\n rest_request(:get, click_url, payload: {}, format: :html)\n offers.find { |offer| offer.id == id }\n offer\n end", "def sell(btc_int_value, price_per_btc = nil)\n\t\tprice_per_btc = sell_quote if price_per_btc == nil\n\t\tusd_int_value = btc_int2float(btc_int_value) * price_per_btc\n\t\ttransaction(:btc, -btc_int_value, :spent)\n\t\ttransaction(:usd, +usd_int_value, :earn)\n\t\ttransaction(:usd, -usd_int_value * fee, :fee)\n\t\tcommit_transactions\n\tend", "def buy\n user = User.find_by_guid(params[:id])\n if user\n user.dollaz -= params[:price].to_i\n PlayerInventory.create(pid: user.id, item_id: params[:item].id)\n user.save!\n render nothing:true, notice: \"Item bought!\"\n else\n render nothing:true, notice: \"Error: unable to purchase item\"\n end\n end", "def sell(quant = nil)\n if quant.nil?\n iname, quant = name, quantity\n destroy\n \"sold #{quant} #{iname}\"\n else\n self.quantity_initial -= quant\n save\n \"sold #{quant} #{i.name}\"\n end\n end", "def buy_item(name)\n change = @calculator.buy @items[name].last\n [@items[name].pop, change]\n end", "def sell_price\r\n price\r\n end", "def buys_drink(pub, drink_name)\n drink_to_buy = pub.sell_drink(self, drink_name)\n @wallet -= drink_to_buy.price\n end", "def do_buy(number)\r\r\n $game_party.lose_currency(@gold_window.currency, number * buying_price)\r\r\n $game_party.gain_item(@item, number)\r\r\n end", "def lose_item(item, amount, include_equip = false, opp = Vocab::Coinbase, info = '', display = true)\n gain_item(item, -amount, true, opp, info, display) if include_equip\n gain_item(item, -amount, false, opp, info, display) if !include_equip\n end", "def best_offer_auto_accept_price\n return nil unless best_offer?\n item_hash.deep_find([:listing_details, :best_offer_auto_accept_price])\n end", "def sell(player)\n unless player.nil?\n player.free\n reordenate_team\n end\n end", "def set_sell_point\n @sell_point = SellPoint.find(params[:id])\n end", "def hit_ebay\n self.gimmie_the_goods(self.ebay_grab)\n end", "def return_item\n items = self.see_purchases.map do |merchandise|\n {name: merchandise.name, merch_id: merchandise.id}\n end\n merch = TTY::Prompt.new.select(\"Here is a list of your purchases. What would you like to return?\",items)\n purchase = self.specific_purchase(merch)\n purchase.destroy \n puts \"your item has been refunded!\"\n restock = self.select_merchandise(merch)\n restock.update(inventory: restock.inventory + 1)\n end", "def propose_item(name, price, selling_mode, increment, end_time, quantity = 1, description = \"\", log = true)\r\n if selling_mode == :fixed\r\n item = Item.fixed(name, price, self, description)\r\n elsif selling_mode == :auction\r\n item = Item.auction(name, price, self, increment.to_i, end_time, description)\r\n end\r\n item.quantity = quantity\r\n item.save\r\n\r\n self.attach_item(item)\r\n ItemAddActivity.create(self, item).log if log\r\n\r\n item\r\n end", "def click_offer(id)\n # @todo: This should raise if the offer is not on the wall.\n offer = offers.find { |o| o.id == id }\n offer.click_with_rest!(@app)\n offer\n end", "def max_sell\r\n $game_party.item_number(@item)\r\n end", "def click_offer_by_index(idx)\n # @todo: This should raise if the offer is not on the wall.\n raise NotImplementedError\n end", "def select(description, amt)\n hand = Clutch.new() # this new Clutch will store the selection\n\n # iterate over @items in Bag. if item matches the description, add to clutch\n items.each do |item|\n # stop if items added to hand reaches the max amount \n break if hand.items.length == amt\n\n next if description[:item] != nil && description[:item] != item.type\n next if description[:sides] != nil && description[:sides] != item.sides\n next if description[:colour] != nil && description[:colour] != item.colour\n next if description[:denomination] != nil && description[:denomination] != item.denomination\n\n hand.store(item)\n end\n\n # remove all the items we took out the bag from the Bag's @items list\n self.items = self.items - hand.items\n hand\n end", "def update_sell_selection()\n item = @sell_window.selected_item.item\n\n if Input.trigger?(Input::B)\n Sound.play_cancel\n cancel_command()\n \n elsif Input.repeat?(Input::DOWN) || Input.repeat?(Input::UP)\n update_item_stats(item)\n \n elsif Input.repeat?(Input::Y) || Input.repeat?(Input::Z)\n update_character_select(Input.press?(Input::Z))\n \n elsif Input.repeat?(Input::RIGHT) || Input.repeat?(Input::LEFT)\n if (Input.press?(Input::RIGHT) && !@sell_window.selected_item.is_max_number?) ||\n (Input.press?(Input::LEFT) && !@sell_window.selected_item.is_min_number?)\n Sound.play_cursor\n update_number_select(Input.press?(Input::RIGHT), @sell_window)\n update_transaction(@sell_window.selected_items)\n end\n \n elsif Input.trigger?(Input::C)\n if (@sell_window.selected_items.size == 0)\n Sound.play_buzzer\n else\n Sound.play_decision\n @confirm_sell_window.show()\n @sell_window.active=false\n end\n end\n end", "def create_item(name, price, quantity, description=\"No description available\", image=\"\")\n new_item = Item.created( name, price, self.working_for, quantity, description, image)\n if !(identical = self.working_for.list_items_inactive.detect{|i| i == new_item }).nil?\n identical.quantity += new_item.quantity\n else\n self.working_for.offers.push(new_item)\n new_item.save\n end\n Activity.log(self, \"add_item\", new_item, self.working_for)\n return new_item\n end", "def offer\n @offer ||= params[:id].present? ? Offer.find(params[:id]) : Offer.find_by(listing_id: params[:listing_id])\n end", "def max_sell\n $game_party.item_number(@item)\n end", "def purchase_price(item)\n item.price / 2\n end", "def hideOffer()\n @item['offer']['activate'] = false\n self.updateOffer()\n end", "def sell_to(player)\n return if @price > player.balance \n !player.subtract_balance(@price)\n @owner = player.piece\n @owned = true\n end", "def purchase(item_price)\n @total += item_price\n total\n end", "def click_offer(id)\n # @todo: This should raise if the offer is not on the wall.\n raise NotImplementedError\n end", "def sell_inventory(material, quantity)\n material.quantity -= quantity\n end", "def find_on_sale(name)\n flyer_items.find do |i|\n i.match?(name) unless i.nil?\n end\n end", "def command_number_sell\r\n # Sell process\r\n $game_party.gain_gold(@number_window.number * (@item.price / 2))\r\n case @item\r\n when RPG::Item\r\n $game_party.lose_item(@item.id, @number_window.number)\r\n when RPG::Weapon\r\n $game_party.lose_weapon(@item.id, @number_window.number)\r\n when RPG::Armor\r\n $game_party.lose_armor(@item.id, @number_window.number)\r\n end\r\n # Refresh each window\r\n @gold_window.refresh\r\n @sell_window.refresh\r\n @status_window.refresh\r\n # Change windows to sell mode\r\n @sell_window.active = true\r\n @sell_window.visible = true\r\n @status_window.visible = false\r\n end", "def buy_item\n merchant = Merchant.find(params[:merchant_id])\n item = merchant.determine_item(params.keys.second, params.values.second )\n \n # potions run differently since a user can have multiple of the item, so it checks if it is a potion\n if Merchant.is_potion?(item)\n response = merchant.buy_potion(item, merchant.get_character_from_game)\n flash[:notice] = response\n redirect_to user_character_path(current_user, merchant.get_character_from_game) \n \n # if not it runs the normal buy method \n else \n response = merchant.buy_item(item, merchant.get_character_from_game)\n flash[:notice] = response\n redirect_to user_character_path(current_user, merchant.get_character_from_game) \n end\n end", "def buy_action(shopItems)\n for shop_item in shopItems\n $game_party.lose_gold(shop_item.item.price * shop_item.quantity)\n $game_party.gain_item(shop_item.item, shop_item.quantity)\n end\n end", "def find_match_and_decrement_available(line_item)\n gs = Orders::LineItemPresenter.new(line_item).global_sku\n if rii = ReturnInventoryItem.where([\"upc= ? and active = true and available > 0\", gs&.id]).first\n rii.available -= 1\n rii.save\n elsif gs\n #do this check since global skus are jacked up and can't be trusted\n gs = GlobalSku.where(\n style_number: gs.style_number,\n product_name: gs.product_name,\n size: gs.size,\n color_id: gs.color_id,\n customisation_id: gs.customisation_id,\n height_value: gs.height_value,\n product_id: gs.product_id,\n ).first\n\n if rii = ReturnInventoryItem.where([\"upc = ? and active = true and available > 0\", gs&.id]).first\n rii.available -= 1\n rii.save\n end\n end\n rii\n end", "def can_sell?\n inventory.any? { |inv| inv.price > 0 }\n end", "def buy_item(user, item)\r\n if(self.has_enough_money(item) and user.has_item(item))\r\n self.get_item(user, item)\r\n self.pay_amount(user, item.get_price)\r\n else\r\n #transaction not possible\r\n end\r\n end", "def offers; global.offers end", "def buy_item(item_to_buy, user)\r\n fail \"only users can buy items in behalve of an organisation\" if (user.organisation)\r\n fail \"only users that are part of #{self.name} can buy items for it\" unless (is_member?(user))\r\n fail \"would exceed #{user.email}'s organisation limit for today\" unless within_limit_of?(item_to_buy, user)\r\n fail \"not enough credits\" if item_to_buy.price > self.credits\r\n fail \"Item not in System\" unless (DAOItem.instance.item_exists?(item_to_buy.id))\r\n\r\n old_owner = item_to_buy.owner\r\n\r\n #Subtracts price from buyer\r\n self.credits = self.credits - item_to_buy.price\r\n #Adds price to owner\r\n old_owner.credits += item_to_buy.price\r\n #decreases the limit of the buyer\r\n @member_limits[user.email].spend(item_to_buy.price) unless self.limit.nil? || is_admin?(user)\r\n\r\n item_to_buy.bought_by(self)\r\n end", "def seller\n # the user owning the inventory\n offer.inventory_item.user\n end", "def homeoffer2\n @seller_listing = SellerListing.find(params[:id])\n end", "def sell(*arguments)\n sellables = []\n options = default_sell_options\n\n # distinguish between options and attributes\n arguments = arguments.flatten\n arguments.each do |argument|\n case argument.class.name\n when 'Hash'\n options.merge! argument\n else\n sellables << argument\n end\n end\n \n raise ArgumentError.new(\"No sellable (e.g. product) model provided\") if sellables.empty?\n raise ArgumentError.new(\"Sellable models must have a :price\") unless sellables.all? {|sellable| sellable.respond_to? :price}\n \n returning self.sales_orders.build do |so|\n so.buyer = options[:buyer]\n so.build_addresses\n \n sellables.each do |sellable|\n if sellable && sellable.respond_to?(:before_add_to_order)\n sellable.send(:before_add_to_order, self)\n sellable.reload unless sellable.new_record?\n end\n li = LineItem.new(:sellable => sellable, :order => so)\n so.line_items.push(li)\n sellable.send(:after_add_to_order, self) if sellable && sellable.respond_to?(:after_add_to_order)\n end\n \n end\n end" ]
[ "0.7122848", "0.69785243", "0.6918258", "0.6728744", "0.66711533", "0.6624512", "0.65788925", "0.65503424", "0.64741457", "0.6469359", "0.6461519", "0.64297235", "0.642102", "0.6401419", "0.63795", "0.6374036", "0.63039875", "0.6261828", "0.6261102", "0.6260047", "0.62582946", "0.6223582", "0.62077904", "0.62077904", "0.61878026", "0.6172865", "0.61660254", "0.616268", "0.61530256", "0.613694", "0.6111415", "0.6086719", "0.60833937", "0.60574335", "0.60321826", "0.60192686", "0.60083556", "0.5999226", "0.5991901", "0.5985636", "0.59776944", "0.5974347", "0.59521353", "0.5929987", "0.59263116", "0.59254515", "0.5917977", "0.58836573", "0.58836573", "0.58836573", "0.58471453", "0.5842972", "0.5835132", "0.5833657", "0.5813895", "0.58108306", "0.57946146", "0.5784392", "0.5783109", "0.57787323", "0.5766834", "0.57472694", "0.5744033", "0.57414204", "0.57320523", "0.57268953", "0.5721741", "0.5715899", "0.5709612", "0.57032543", "0.5693805", "0.5693584", "0.56855416", "0.5668507", "0.56669444", "0.5666652", "0.5657291", "0.56427455", "0.56156987", "0.5610063", "0.5608762", "0.56032014", "0.5598726", "0.5596613", "0.559652", "0.5594216", "0.55911666", "0.55824506", "0.55613995", "0.55442625", "0.5543051", "0.5540478", "0.55335176", "0.55297905", "0.5524147", "0.55152744", "0.5514787", "0.551384", "0.5512934", "0.55027276" ]
0.76911545
0
get a list of all active items of a user
def get_active_items self.items.select { |i| i.active? } #TODO only fixed or only auction end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_all_active_items\n @items.values.select{|item| item.active}\n end", "def get_active_items\n self.items.select { |i| i.active? } #TODO only fixed or only auction\n end", "def index\n @items = @current_user.items\n end", "def index \n \t@items = Item.paginate(page: params[:page])\n\n @user_items = current_user.user_items.pluck(:id).uniq\n @all_user_items = UserItem.where(id: @user_items)\n end", "def list_items\r\n return_list = Array.new\r\n for s in self.item_list\r\n if s.is_active?\r\n return_list.push(s)\r\n end\r\n end\r\n return return_list\r\n end", "def show_user_items\n\t\t# gather user items of current user\n \t@user_items = UserItem.paginate :per_page => 8, :page => params[:page], :conditions => { :user_id => current_user.id }, :order => 'created_at DESC'\n\t\t# gather sold items of current user\n @sold = Transaction.find_all_by_seller_id(current_user.id)\n\t\t# gather bought items of current user\n @bought = Transaction.find_all_by_buyer_id(current_user.id)\n\t\t# gather all users the current user follows\n @following_users = current_user.followings\n\t\t# gather items the current user is watching\n @watched = Watch.find_all_by_watcher_id(current_user.id)\n end", "def user_items(user_id=self.username, context='pack')\n response = connection.get do |req|\n req.url \"/users/#{user_id}/items\", :context => context\n end\n response.body.items\n end", "def index\n\t\t@item = current_user.items\n\n\tend", "def users\n self.class.get(\"/user\", @options).parsed_response[\"items\"]\n end", "def index\n @items = @user.items\n end", "def index\n if params[:user_id].present?\n @items = current_user.items.page params[:page]\n else\n @items = Item.available.page params[:page]\n end\n end", "def list_items\r\n return_list = Array.new\r\n for s in self.item_list\r\n if s.is_active?\r\n return_list.push(s)\r\n end\r\n end\r\n # AK This is a very common pattern, so there is a method for that:\r\n #return item_list.select {|s| s.is_active?}\r\n return return_list\r\n end", "def items\n @items = current_user.items.paginate(:page => params[:page])\n end", "def index\n\t\t @items = Item.find_my_items(current_user) \n end", "def fetch_active_items_of(account_id)\n fetch_items_of(account_id.to_i).select {|s| s.is_active? }\n end", "def get_items(user,ex_items)\r\n\t\trv = []\r\n\t\tdb.each { |x,y|\r\n\t\t\trv << y if(x==user)\r\n\t\t\t}\r\n\t\trv - ex_items\r\n\tend", "def list_items_inactive\r\n return_list = Array.new\r\n for s in self.item_list\r\n if !s.is_active?\r\n return_list.push(s)\r\n end\r\n end\r\n return return_list\r\n end", "def list_items_inactive\r\n return_list = Array.new\r\n for s in self.item_list\r\n if !s.is_active?\r\n return_list.push(s)\r\n end\r\n end\r\n return return_list\r\n end", "def all_items_for_sell\r\n list = Array.new\r\n items.each{ |item|\r\n if item.active == true\r\n list.push(item)\r\n end}\r\n list\r\n end", "def active_items\n @items.values.select { |value| value.state == :active || value.state == :auction}\n end", "def index\n @items = Item.find_all_by_user_id(current_user.id)\n end", "def index\n @items = Item.includes(:user).where(availability: TRUE)\n end", "def index\n @load = Item.includes(:user, thumbnail_attachment: :blob)\n @items = []\n for item in @load\n if item.active == true\n @items << item\n end\n end\n end", "def index\n @users_items = UsersItem.all\n end", "def getUserList\n @userList\n end", "def items\n response = JSON.parse(@client.get(\"users/#{send(:id)}/items\").body)\n users = response.key?('items') ? response['items'] : []\n users.map { |attributes| Promisepay::Item.new(@client, attributes) }\n end", "def list_current_users *args\r\n puts \"not implemented yet\"\r\n end", "def user_items_list\n @items = Item.find_all_by_user_id(current_user.id)\n @categories = Category.all\n @search = Item.search(params[:search])\n @keyword = params[:search]\n end", "def active_users\n return User.find_by_sql(\"SELECT users.* from users inner join roles_users ru on users.id=ru.user_id\n INNER JOIN roles r on ru.role_id=r.id\n WHERE users.activo=true AND r.name='#{self.name}'\")\n end", "def index\n @active_users = ActiveUser.all\n end", "def fetch_all_active_items_but_of(account_id)\n fail \"No account with id #{account_id}\" unless DAOAccount.instance.account_exists?(account_id)\n @items.values.select{|item| item.owner.id != account_id && item.active}\n end", "def index\n @items = current_user.items.where.not(group_id: nil).includes(:group, :user).all.order('created_at DESC')\n end", "def get_users\n\t\t\t@users = User.all.where(:on_beverage_list => true).order('firstname, lastname')\n\t\tend", "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\t#display only activated users\n\t@users=User.where(activated: true).paginate(page: params[:page])\n\tend", "def active_users\n PullRequest.active_users(current_year)\n end", "def show\n @user=User.find(params[:id])\n @items = @user.items\n end", "def index\n if can? :all, @items\n @items = Item.all\n elsif \n @items = Item.where(:user_id => current_user.id)\n end\n \n end", "def index\n @profile_items = current_user.profile_items\n end", "def index\n @items = Item.where(user: @user).order(:list_order)\n end", "def get_users\n @get_users = Rails.cache.fetch(\"get_aside_users\", :expires_in => 1.hours) do\n if @current_user.present?\n Core::User.active.where(\"verified = 1 AND id != #{@current_user.id}\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n else\n Core::User.active.where(\"verified = 1\").order(position: :desc, created_at: :desc).limit(10).sample(3)\n end\n end\n end", "def get_autocomplete_items(parameters)\n items = super(parameters)\n if current_user.admin?\n items\n else\n items.includes(:users).where(users:{id: current_user.id})\n end\n end", "def 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 @users = User.where(activated: true).paginate(page: params[:page])\n end", "def filtered_items_list(filter, params = {})\n resp = @client.access_token.get(ItemList.merge_query_string(\"/reader/api/0/stream/contents/user/#{user_id}/state/com.google/#{filter}?output=json\", params))\n raise \"unable to retrieve the list of #{filter} items for user \\\"#{user_id}\\\": #{resp.inspect}\" unless resp.code_type == Net::HTTPOK\n Google::Reader::ItemList.new(@client, resp.body)\n end", "def list_items\n return_list = Array.new\n for s in self.offers\n unless s.auction\n if s.is_active?\n return_list.push(s)\n end\n end\n end\n return return_list\n end", "def show \n available_users\n end", "def list_all_users\n\n end", "def get_user_items(user_id, course_id)\r\n relative_url = PATH_USERS_COURSES_ITEMS % [user_id, course_id]\r\n get(relative_url)\r\n end", "def index\n @all_items = Item.all #for testing only\n if signed_in?\n @items = current_user.items\n else\n redirect_to new_user_session_path, alert: \"Необходимо войти в систему, чтобы посмотреть Items\"\n end\n end", "def list\n @all_users = User.find(:all)\n end", "def index\n # calling the paginate method returns users in chunks of 30 by default\n @users = User.where(activated: true).paginate(page: params[:page])\n end", "def list\n logger.debug \"Processing the list...\"\n @users = User.all.order('updated_at desc') #where(:status=>1)\n end", "def list\n get('users')['users']\n end", "def index\n @users = User.find_all_with_authorization(current_user)\n end", "def my\n items = current_user.items\n render json: items\n end", "def get_items\r\n @list\r\n end", "def all(instance)\n data = service.list_users(instance).to_h[:items] || []\n load(data)\n end", "def index\n @target = current_user.keep_base_open ? '_blank' : '_self'\n @user_name = current_user.person.user_name \n @all = BaseItemList.all( current_user )\n end", "def users\n unless @users\n userListService = $viewContext.getViewService(OTUserListService.java_class)\n @users = userListService.getUserList().sort_by { |user| #sort users by name\n (user.name && !user.name.empty?) ? user.name.downcase.split.values_at(-1, 0) : [''] \n }\n end\n @users\n end", "def users\n unless @users\n userListService = $viewContext.getViewService(OTUserListService.java_class)\n @users = userListService.getUserList().sort_by { |user| #sort users by name\n (user.name && !user.name.empty?) ? user.name.downcase.split.values_at(-1, 0) : [''] \n }\n end\n @users\n end", "def show\n @task_items = @task_list.items.active\n end", "def active_user\n User.find_by(activated: true)\n end", "def users\n @users_by_href.values\n end", "def row_items\n object.manifest_items.scope.active\n end", "def show\n @line_items = @list.line_items.includes(:item)\n\n my_items = current_user.items.order(name: :asc)\n other_items = Item.where(\"user_id <> ? OR user_id IS NULL\", current_user.id).order(name: :asc)\n @items = my_items | other_items\n end", "def active_students\n Student.where(:user_id => id).all\n end", "def items\n @item_data ||= @active_domain.nil? ? EMPTY_ITEM_DATA : get_items(@query)\n @item_data[:items]\n end", "def getMEELeadActivities\n users = User.all.pluck(:id)\n activities = []\n users.each do |id|\n username = User.find(id).display_name\n #create list of [[user, [their activities...]]...]\n activities.push([username, Activity.where(user_id: id)]) \n end\n return activities \n end", "def index\n @my_subscriptions = current_user.active_subscriptions\n end", "def index\n @availabilities = Availability.where(user: current_user)\n end", "def get_all_activities\n \tself.is_manager? ? Activity.all : Activity.joins(:task).where(:tasks => { user_id: self.id })\n end", "def index\n @users = current_user.users\n end", "def show\n @available_group_items = []\n @unavailable_group_items = []\n @group.users.includes(:items).each do |user|\n if user != current_user && user.group_membership(@group).state != \"pending\"\n @available_group_items = @available_group_items + user.items.where(:state => \"available\")\n @unavailable_group_items = @unavailable_group_items + user.items.where.not(:state => \"available\")\n end \n end\n @members = @group.memberships.where.not(:state => \"pending\")\n @pending = @group.memberships.where(:state => \"pending\")\n end", "def users\n GroupMembers.new(:id => id).get.items\n end", "def cemetary\n unfiltered_users = User.search(params[:term])\n @users = unfiltered_users.select do | user | user.archived == true end\n end", "def index\n @items = Item.select { |item| item.user == current_user}\n @bookings = Booking.select { |booking| booking.user == current_user }\n end", "def curator_list\n users.map(&:email)\n end", "def list\n\t\t# retrieve all users\n @users = User.find(:all)\n end", "def equipment\n @items = Item.where(user_id: params[:user_id])\n end", "def users\n User.where(network_id: context[:current_network]&.id)\n end", "def list_items_to_sell\r\n list = \"\"\r\n items.each{ |item|\r\n if item.active == true\r\n list = list + item.name + \"\\n\"\r\n end}\r\n list\r\n end", "def active_facebook_accounts\n facebook_accounts.where(is_active: true)\n end", "def get_list\n \t@items\n end", "def index\n @active = 2\n @users = User.all\n end", "def members(show_staged=false)\n invites = show_staged ? self.org_invites.active_or_staged : self.org_invites.active\n [self.users, invites.to_a].flatten\n end", "def active_users\n joins = DepartmentsUser.where(department_id: self, active: true)\n joins.map{|j| User.find(j.user_id)}\n end", "def users\n user_arr = []\n subscriptions.each do |s|\n user_arr << User.find(s.user.id)\n end\n user_arr\n end", "def inactive\n @inactive_users = User.where(isActive:false).paginate(:page => params[:inactive_users_page], :per_page => 10)\n end", "def list(garbage, start)\n @all_user = session_user.agency.users\n @start = start.to_i || 0\n @limit = request.params[\"limit\"] || UserListingLength\n @user = @all_user[@start .. (@start+@limit)-1] # FIXME: Do it with sequel!\n @uparted = @user.partition{|u| @user.index(u) % 2 == 0 }\n end", "def users\n result = Rails.cache.read([:ibiza, id, :users])\n get_users_only_once if result.nil?\n result\n end", "def user_items_by_site(username)\n response = get \"v1/market/user-items-by-site:#{username}.json\"\n response[:'user-items-by-site']\n end", "def available_users\n\t\tfree_users = []\n\t\tfor user in User.all\n\t\t\tunless user.assignments.nil? || user.assignments.empty?\n\t\t\t\tfor assignment in user.assignments\n\t\t\t\t\tif assignment.active\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tfree_users << user\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tfree_users << user\n\t\t\tend\n\t\tend\n\t\treturn free_users\n\tend", "def get_items\n @items\n end", "def page_users(context='access')\n usrs = []\n self.where(active: true).find_each do |u|\n usrs << Secure::UserProfile.new(u)\n end\n usrs\n rescue Exception => e\n Rails.logger.error(\" #{self.name.to_s}.#{__method__}() returns: #{e.class.name} msg: #{e.message}\")\n []\n end", "def index\n @basket_items = current_user.basket_items.includes(:product)\n @user = current_user\n end", "def index\n @activities = current_user.activities\n end", "def user_list\n @user=User.all\n end", "def show\n @list = current_user.list\n end", "def get_list(params = {})\n http_helper.send_get_request(\"#{@url_prefix}/#{get_user_id!(params)}#{@url_suffix}\", params)\n end" ]
[ "0.7867313", "0.73099804", "0.7211172", "0.7211117", "0.7161697", "0.710768", "0.7060774", "0.7047599", "0.70148796", "0.6965865", "0.69565445", "0.6945257", "0.68824565", "0.6881317", "0.68749595", "0.6871562", "0.686274", "0.686274", "0.68104917", "0.68051094", "0.68002504", "0.669862", "0.66108346", "0.65960157", "0.65310544", "0.65209246", "0.65161014", "0.65080726", "0.64859", "0.64595646", "0.64557", "0.64527065", "0.64452827", "0.64074475", "0.64058995", "0.6399608", "0.6386868", "0.6366877", "0.63556147", "0.634394", "0.6341218", "0.63118446", "0.63085353", "0.6308377", "0.6306354", "0.6300773", "0.62980443", "0.6292617", "0.6290286", "0.6288287", "0.62830883", "0.62813437", "0.62795156", "0.6279003", "0.6253001", "0.62422657", "0.6236936", "0.62338173", "0.62265706", "0.620617", "0.620617", "0.6196869", "0.6190947", "0.61846894", "0.6182239", "0.6169805", "0.61619735", "0.61592066", "0.61588955", "0.6157222", "0.6153598", "0.61526877", "0.6147245", "0.6142561", "0.6142474", "0.61407727", "0.61388856", "0.6133654", "0.6127642", "0.6124233", "0.6112596", "0.6112156", "0.61096436", "0.6107578", "0.61054087", "0.61017823", "0.60966676", "0.60912", "0.6073645", "0.60716975", "0.60657716", "0.6051001", "0.6048456", "0.6046104", "0.60457194", "0.60358554", "0.60324603", "0.60085994", "0.5998902", "0.5996985" ]
0.7312948
1
attach a bought item to the user. If the bought item matches an already owned item, items will be composed, i.e their respective quantities will be added
def attach_item(item) equal_item = self.check_for_equal_item(item.name,item.price,item.description) if equal_item == nil self.items << item item.owner = self item.deactivate else equal_item.quantity += item.quantity equal_item.deactivate item.delete end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def buy_item(user, item)\r\n if(self.has_enough_money(item) and user.has_item(item))\r\n self.get_item(user, item)\r\n self.pay_amount(user, item.get_price)\r\n else\r\n #transaction not possible\r\n end\r\n end", "def buy_new_item(item_to_buy, quantity, account)\n return false if item_to_buy.auction\n preowner = item_to_buy.owner\n\n if (Integer(item_to_buy.price*quantity) > self.credits and item_to_buy.currency == \"credits\") or Integer(item_to_buy.quantity)<quantity\n Activity.log(account, \"item_bought_failure\", item_to_buy, self)\n Activity.log(account, \"item_sold_failure\", item_to_buy, preowner)\n return false\n end\n\n\n if !item_to_buy.wishlist_users.empty? and item_to_buy.quantity == quantity and !item_to_buy.permanent\n item_to_buy.wishlist_users.each {|trader| trader.remove_from_wishlist(item_to_buy); item_to_buy.wishlist_users.delete(trader)}\n end\n\n Holding.ship_item(item_to_buy, item_to_buy.owner, self, quantity)\n Activity.log(account, \"item_bought_success\", item_to_buy, self)\n Activity.log(account, \"item_sold_success\", item_to_buy, preowner)\n Mailer.item_sold(preowner.e_mail, \"Hi #{preowner.name}, \\n #{self.name} bought your Item #{item_to_buy.name}.\n Please Contact him for completing the trade. His E-Mail is: #{self.e_mail}\")\n\n return true\n end", "def buy\n user = User.find_by_guid(params[:id])\n if user\n user.dollaz -= params[:price].to_i\n PlayerInventory.create(pid: user.id, item_id: params[:item].id)\n user.save!\n render nothing:true, notice: \"Item bought!\"\n else\n render nothing:true, notice: \"Error: unable to purchase item\"\n end\n end", "def buy(item, quantity)\r\n if quantity < item.quantity\r\n item_to_buy = item.split(quantity)\r\n else\r\n item_to_buy = item\r\n end\r\n seller = item_to_buy.owner\r\n seller.sell(item_to_buy)\r\n item_to_buy.owner = self\r\n self.remove_credits(item_to_buy.price * quantity)\r\n item_to_buy.deactivate\r\n Marketplace::Activity.create(Activity.ITEM_BOUGHT, item, \"#{item.name} has been bought by #{self.name}\")\r\n Marketplace::Activity.create(Activity.USER_BOUGHT_ITEM, self, \"#{self.name} bought #{item.name}\")\r\n #delete the history in the description log, except the newest entry\r\n item_to_buy.clean_description_log\r\n item_to_buy.clean_comments\r\n item_to_buy\r\n end", "def buy_item(item_to_buy, user)\r\n fail \"only users can buy items in behalve of an organisation\" if (user.organisation)\r\n fail \"only users that are part of #{self.name} can buy items for it\" unless (is_member?(user))\r\n fail \"would exceed #{user.email}'s organisation limit for today\" unless within_limit_of?(item_to_buy, user)\r\n fail \"not enough credits\" if item_to_buy.price > self.credits\r\n fail \"Item not in System\" unless (DAOItem.instance.item_exists?(item_to_buy.id))\r\n\r\n old_owner = item_to_buy.owner\r\n\r\n #Subtracts price from buyer\r\n self.credits = self.credits - item_to_buy.price\r\n #Adds price to owner\r\n old_owner.credits += item_to_buy.price\r\n #decreases the limit of the buyer\r\n @member_limits[user.email].spend(item_to_buy.price) unless self.limit.nil? || is_admin?(user)\r\n\r\n item_to_buy.bought_by(self)\r\n end", "def buy_item(item)\r\n if !item.active || item.price > self.credits\r\n false\r\n else\r\n seller = item.owner\r\n price = item.price\r\n\r\n seller.give_credits(price)\r\n self.take_credits(price)\r\n seller.remove_item(item)\r\n self.add_item(item)\r\n item.active = false\r\n true\r\n end\r\n end", "def save_to_inventory\n @user = User.find(params[:id])\n @item = Item.find(1)\n @user.items.push(@item)\n end", "def set_bought_item\n @bought_item = BoughtItem.find(params[:id])\n end", "def purchase_item(item, seller_id, buyer_id)\n seller = User.new(seller_id)\n buyer = User.new(buyer_id)\n @conn.watch([\"market\", buyer.id]) do\n fund = @conn.hget(buyer.id, \"fund\")\n price = @conn.zscore(\"market\", seller.item_id(item))\n\n if price && price <= fund.to_i\n @conn.multi do |multi|\n multi.hincrby(buyer.id, \"fund\", -price.to_i)\n multi.hincrby(seller.id, \"fund\", price.to_i)\n multi.zrem(\"market\", seller.item_id(item))\n multi.sadd(buyer.inventory_id, item)\n end\n else\n @conn.unwatch\n end\n end\n end", "def add_item(order_id, item_sku, price, quantity, name = nil, category = nil, utmhid = random_id)\n check_account_params\n hey(item_params(order_id, item_sku, name, category, price, quantity, utmhid))\n end", "def buyEvent\n client.arecord_user_action_on_item('buy', getUser, getCart) \n end", "def add_item(item)\n fail \"An items id should initially be nil, but was #{item.id}\" unless (item.id == nil)\n fail \"An item must have an owner when added to the system.\" if (item.owner == nil)\n item.id = @item_id_count\n @items.store(@item_id_count, item)\n @item_id_count += 1\n end", "def add_to_inventory(item)\n @items << item\n equip(item)\n items_weight\n end", "def buy_item(item, log = true)\n seller = item.owner\n\n if seller.nil?\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"item_no_owner\" #Item does not belong to anybody\n elsif self.credits < item.price\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"not_enough_credits\" #Buyer does not have enough credits\n elsif !item.active?\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"buy_inactive_item\" #Trying to buy inactive item\n elsif !seller.items.include?(item)\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"seller_not_own_item\" #Seller does not own item to buy\n end\n\n seller.release_item(item)\n\n TradingAuthority.settle_item_purchase(seller, self, item)\n\n item.deactivate\n self.attach_item(item)\n\n item.notify_change\n\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item).log if log\n\n return true, \"Transaction successful\"\n end", "def create\r\n @cart_item = CartItem.new(cart_item_params)\r\n @cart_item.user = current_user\r\n\r\n if is_enough && @cart_item.save\r\n @cart_item.buy # pre-emtively \"buys\" the item to save it from other users\r\n flash[:notice] = \"Item was added to cart!\"\r\n else\r\n flash[:danger] = \"Item could not be added to cart!\"\r\n end\r\n redirect_to products_path\r\n end", "def add_item(item, price, quantity=1)\n @total += (price * quantity)\n @items.fill(item, @items.size, quantity)\n @last_transaction = {item => (price * quantity)}\n @last_qty = quantity\n end", "def buy_requested_item(request, item)\r\n self.overlay.delete_item_request(request.id)\r\n item.price = request.price #The prize given in the request is relevant.\r\n buy(item, true)\r\n end", "def add_item(item, quantity = 1)\n order_item = self.order_items.find_by item: item, price: item.price\n if order_item.is_a? OrderItem\n order_item.add quantity\n else\n self.order_items.create item: item, price: item.price, quantity: quantity\n end\n recalculate!\n end", "def bought_item_params\n params.require(:bought_item).permit(:name, :price, :apartment_id, :user_id)\n end", "def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n\n order_item = order.items.find_or_create_by(\n product_id: product_id\n )\n\n order_item.price = product.price\n order_item.quantity = 1\n order_item.save\n end", "def propose_item(name, price, selling_mode, increment, end_time, description = \"\", log = true)\n if selling_mode == \"fixed\"\n item = Item.named_priced_with_owner_fixed(name, price, self, description)\n else\n item = Item.named_priced_with_owner_auction(name, price, self, increment.to_i, end_time, description)\n end\n item.save\n\n self.attach_item(item)\n Analytics::ItemAddActivity.with_creator_item(self, item).log if log\n\n item\n end", "def add_item\n\t\tcurrent_user.saved.items.push(Item.find(params[:item]))\n\t\tredirect_to :back\n\tend", "def giveItem\n toLocation = Company.where(name: params[:recepCompany]).first.locations.where(address: params[:recepLocation]).first\n location = current_company.locations.where(id: params[:locationId]).first\n if(location.is_supplier === true)\n updatedItem = location.items.where(name: params[:name]).first\n toUpdatedItem = toLocation.items.where(name: params[:name]).first\n if(toUpdatedItem.present? && updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n toUpdatedItem.increment!(:amount, params[:amount].to_i)\n elsif(updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n item = Item.create(name: params[:name], amount:params[:amount].to_i, price: updatedItem.price, autoRestock: false, lastSupplier:location.id)\n toLocation.items << item\n end\n if(updatedItem.amount <= updatedItem.restockPoint)\n changeItemSupplier(updatedItem.id)\n end\n end\n end", "def add_item(item)\r\n items.push(item)\r\n item.owner = self\r\n end", "def propose_item(name, price, selling_mode, increment, end_time, quantity = 1, description = \"\", log = true)\r\n if selling_mode == :fixed\r\n item = Item.fixed(name, price, self, description)\r\n elsif selling_mode == :auction\r\n item = Item.auction(name, price, self, increment.to_i, end_time, description)\r\n end\r\n item.quantity = quantity\r\n item.save\r\n\r\n self.attach_item(item)\r\n ItemAddActivity.create(self, item).log if log\r\n\r\n item\r\n end", "def add(item)\n self.items.push(item)\n if self.min_price > item.price.to_i\n self.min_price = item.price.to_i\n end\n self.owners.push(item.owner)\n self.owners = self.owners.uniq\n self.quantity += item.quantity\n self\n end", "def add_item(itemToAdd)\r\n itemToAdd.set_owner(self)\r\n itemToAdd.deactivate\r\n self.items.push(itemToAdd)\r\n end", "def add_item(item, amount)\n # Check if the Entity already has that item\n # in the inventory. If so, just increase\n # the amount.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n # If not already in the inventory, push a Couple.\n @inventory.push(Couple.new(item, amount))\n end", "def buy_item (item, character)\n \n if item.inventory == nil \n if character.gold >= item.cost\n item_transaction(item, character)\n \"you bought #{item.name}!\"\n else\n \"you don't have enough money\"\n end\n else\n \"Your character already has this item in their invetory\"\n end\n end", "def add(item)\n item.available? ? items.create(cartable: item) : false\n release\n end", "def add_item(d_item, name=nil)\n item = d_item.item\n if !name then name = item.name end\n #if we already have an item in this box\n if @d_item\n #if same item or\n if (item.id == @d_item.item.id) && (item.quality == @d_item.item.quality)\n max = @d_item.max?\n total = @d_item.item.quantity+item.quantity\n if total > max\n @d_item.item.quantity = max\n item.quantity = (total - max)\n @d_item.refresh\n return 2\n else\n @d_item.item.quantity += item.quantity\n @d_item.refresh\n return 1\n end\n end\n #if different item or quality, cannot merge\n return 2\n end\n #if empty, add the item\n @d_item, @last_item = d_item, item.clone\n @d_item.refresh\n return 3\n end", "def brief_vendor_add_item\n brief = Brief.find(params[:brief_id])\n brief_vendor = brief.brief_vendors.find_by_org_id(params[:vendor_id])\n brief_vendor.items << Item.new{|r| r.parent_id = params[:item_id]}\n\n redirect_to(cheil_brief_vendor_items_path(params[:brief_id],params[:vendor_id])) \n end", "def pick_up(item)\n return false if items_weight + item.weight > MAX_WEIGHT\n\n @equipped_weapon = item if item.is_a?(Weapon)\n @items << item\n end", "def add_item(item)\n @inventory.push(item)\n if item.include? \"weapon\"\n @weapon = item\n end\n end", "def add_item(item_id)\n line_item = self.line_items.find_by(item_id: item_id)\n if line_item\n line_item.quantity += 1\n else\n line_item=self.line_items.build(item_id: item_id)\n end\n line_item\n end", "def create\n\n @item = Item.new(params[:item])\n\n if(!@item.borrower.nil? && @item.borrower != \"\")\n UserMailer.loaned_notification_email(current_user, @item).deliver\n end\n\n current_user.items.push @item\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to(root_path, :notice => 'Item was successfully created.') }\n format.xml { render :xml => @item, :status => :created, :location => @item }\n else\n\n format.html { render :action => \"new\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def pick_up(item)\n @items.push(item) unless items_weight + item.weight > CAPACITY\n @equipped_weapon = item if item.is_a?(Weapon) \n if item.is_a?(BoxOfBolts) \n item.feed(self) if self.health <= 80\n end\n end", "def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end", "def create_item(name, price, quantity, description=\"No description available\", image=\"\")\n new_item = Item.created( name, price, self.working_for, quantity, description, image)\n if !(identical = self.working_for.list_items_inactive.detect{|i| i == new_item }).nil?\n identical.quantity += new_item.quantity\n else\n self.working_for.offers.push(new_item)\n new_item.save\n end\n Activity.log(self, \"add_item\", new_item, self.working_for)\n return new_item\n end", "def sell(item)\r\n self.add_credits(item.price * item.quantity)\r\n Marketplace::Activity.create(Activity.ITEM_SOLD, item, \"#{item.name} has been sold by #{self.name}\")\r\n Marketplace::Activity.create(Activity.USER_SOLD_ITEM, self, \"#{self.name} sold #{item.name}\")\r\n end", "def pick_up(item)\n\n puts \"in pick_up item = #{item}\"\n puts \"equipped_weapon #{equipped_weapon}\"\n\n # binding.pry\n\n if (CAPACITY - items_weight) >= item.weight\n @items << item\n\n # binding.pry\n if item.class == PlasmaCannon || item.class == Laser\n # binding.pry\n self.equipped_weapon = item\n end\n\n true\n\n else\n false\n end\n\n end", "def add_to_inventory(item)\n @inventory.push(item)\n update\n end", "def give_item(id, amount)\n item = $data_items[id];\n $game_party.gain_item(item, amount)\n end", "def add(item)\r\n fail \"missing item\" if item.nil?\r\n fail \"item is not active, it cannot be put in your wish list\" unless item.is_active?\r\n\r\n self.items << item\r\n item.add_observer(self)\r\n end", "def add_item(item)\n item = Item.find item unless item.is_a? Item\n $logger.debug{\"#{self} add #{item}\"}\n items << item\n inventory << item.id\n item\n end", "def add_item (title, price, quantity = 1)\n # adds purchase price to total\n @total += price * quantity\n # Adds proper quanity of item to cart\n count = 0\n while count < quantity\n @items << title\n count += 1\n end\n # keeps track of last_added item\n @last_transaction[:item] = title\n @last_transaction[:price] = price\n @last_transaction[:quantity] = quantity\n\n end", "def add_item(item_id)\n if line_item = line_items.find_by(item_id: item_id)\n line_item.quantity += 1\n else\n line_item = line_items.build(item_id: item_id)\n end\n line_item\n end", "def add_item(item)\n if @item\n log(\"Item is already equipped in EquipSlot.\")\n return\n end\n @item = item\n return\n end", "def add_chocolate_bar(chocolate_bar)\ncurrent_item = line_items.find_by(chocolate_bar_id: chocolate_bar.id)\nif current_item\ncurrent_item.quantity += 1\nelse\ncurrent_item = line_items.build(chocolate_bar_id: chocolate_bar.id)\nend\ncurrent_item\nend", "def test_can_buy_org_item\n user = User.named(\"user\")\n org = Organization.named(\"org\")\n\n item = org.propose_item(\"Item\", 20, :fixed, nil, nil)\n item.activate\n\n assert(user.can_buy?(item))\n\n user.work_on_behalf_of(org)\n assert(!user.on_behalf_of.can_buy?(item))\n end", "def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n order_item = order.items.find_or_initialize_by(\n product_id: product_id,\n price: product.price,\n quantity: quantity\n )\n\n order_item.save!\n end", "def add_product(product)\n # inicia transação\n transaction do \n item = self.items.detect{|item| item.product == product}\n if item\n item.quantity += 1\n item.save\n else\n self.items.create(:product => product, :quantity => 1, :price => product.price)\n end\n end\n end", "def add_to_pending(purchase)\r\n self.pending_purchases.push(purchase)\r\n end", "def settle_item_purchase(seller, buyer, item)\n seller.credits += item.price + Integer((item.price * SELL_BONUS).ceil)\n buyer.credits -= item.price\n end", "def add_item(item, amount = 1)\n\n # Increase the amount if the item already exists in the inventory.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n\n # If not already in the inventory, push a Couple.\n @inventory.push(Couple.new(item, amount))\n end", "def reserved(item, buyer)\n @item = item\n @buyer = buyer\n @greeting = \"Hi\"\n @name = item.owner.name\n\n mail to: @buyer.email\n end", "def buy\n @character = Character.find(params[:id])\n errors = findErrors(item_params)\n if errors.length < 1 && canAfford?(item_params[:cost].to_f, @character)\n @character.gp -= item_params[:cost].to_f\n @item = Item.new\n @item.cost = item_params[:cost]\n @item.name = item_params[:name]\n @item.save\n association = CharacterItem.new\n association.character_id = @character.id\n association.item_id = @item.id\n association.save\n @character.save\n redirect_to @character, notice: 'Item Was Purchased succesfully'\n else\n errors.length > 0 ? flash[:errors] = errors[0] : flash[:errors] = \"Whoops! this item costs #{item_params[:cost]} GP\n But you have #{@character.gp}\"\n @item = Item.new(item_params)\n render 'purchase_item/new'\n end\n end", "def create\n @bought_item = BoughtItem.new(bought_item_params)\n\n respond_to do |format|\n if @bought_item.save\n format.html { redirect_to @bought_item.apartment, notice: 'Bought item was successfully created.' }\n format.json { render :show, status: :created, location: @bought_item }\n else\n format.html { render :new }\n format.json { render json: @bought_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_item(item, qty)\n for ele in @order do\n order_item = ele.keys[0]\n if order_item.name == item.name\n ele[order_item] += qty\n return \n end\n end\n @order.push({item => qty})\n \n end", "def add_item(hash_of_items, item, quantity=1)\n hash_of_items[item] = quantity\n hash_of_items\nend", "def create\n @item = Item.new(purchase_item_params)\n\n item_cost = 2\n\n # if params[:item] == \"coin\" || params[:item] == :coin\n # @item = current_user.items.create(item: params[:item], denomination: params[:denomination])\n # elsif params[:item] == \"die\" || params[:item] == :die\n # item_cost = @item.sides\n # @item = current_user.items.create(item: params[:item], sides: params[:sides], colour: params[:colour])\n # end\n\n alert_text = \"Purchase alert: \"\n if @item.item == \"coin\" || @item.item == :coin\n if @item.sides || @item.sides != 0\n alert_text += \"Ignored number of sides '#{@item.sides}' when purchasing the coin. \"\n end\n if @item.colour || @item.colour != nil || @item.colour != \"\"\n alert_text += \"Ignored colour '#{@item.colour}' when purchasing the coin. \"\n end\n @item = current_user.items.create(purchase_coin_params)\n elsif @item.item == \"die\" || @item.item == :die\n if @item.denomination\n alert_text += \"Ignored denomination '#{@item.denomination}' when purchasing the die. \"\n end\n item_cost = @item.sides\n @item = current_user.items.create(purchase_die_params)\n end\n\n # @item = current_user.items.create(purchase_item_params)\n\n if !item_cost\n alert_text += \"Purchase refused - Please input a number of sides for the die you want to purchase.\"\n flash.now[:alert] = \"#{alert_text}\"\n render :new\n elsif current_user.gems < item_cost\n alert_text += \"Purchase refused - You don't have enough gems. The item costs #{item_cost}, but you only have #{current_user.gems} gems.\"\n flash.now[:alert] = \"#{alert_text}\"\n render :new\n else\n respond_to do |format|\n if @item.save\n current_user.gems -= item_cost\n current_user.save\n\n format.html { redirect_to purchaseitems_path, notice: 'Item was successfully purchased.', alert: alert_text }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, alert: alert_text }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def approve_items(with_product)\n items = InventoryItem.where(name: name, unit_id: unit_id, category_id: category_id).where(\"type is null and product_id is null\").where(\"id <> ?\", id)\n items << self\n items.each do |item|\n item.name = \"#{with_product.name} \"#(#{with_product.unit_name})\"\n item.unit_id = with_product.unit_id\n item.product_id = with_product.id\n item.save(:validate => false)\n end\n end", "def add_to_receipt(item)\n balance = item.is_a?(Array) ? item[2] ? item[2].to_i <=> 0 : 0 : 0\n if @marw_queue.empty? || @marw_queue.all? { |receipt| \n receipt.closed || balance != receipt.balance }\n label = (balance == 0 ? marw_label_default : (balance > 0 ? \n MARW_CONFIGURATION[:vocab_gain_label] : MARW_CONFIGURATION[:vocab_lose_label]))\n show_receipt_window(label, [], balance)\n end\n @marw_queue.reverse.each { |receipt| \n if !receipt.closed && receipt.balance == balance\n receipt.item_array.push(item) \n break\n end\n }\n end", "def add_item(olist, item, quant=1)\n new_list = {item => quant}\n olist.merge(new_list)\nend", "def add_item(title, amount, quantity=1)\n self.total += amount * quantity\n quantity.times do\n items << title\n end\n self.last_transaction = amount * quantity\n end", "def item_create\n @brief = Brief.find(params[:brief_id])\n @brief_vendor = @brief.brief_vendors.find_by_org_id(@cur_user.org_id)\n invalid_op unless @brief_vendor\n @brief_vendor.items << Item.new(params[:item]){|r|r.kind = params[:kind]}\n redirect_to vendor_show_brief_path(@brief)\n end", "def add_item(new_item)\n item = Item.new(new_item)\n items.push(item)\n end", "def add_to_basket\n if Basket.exists?(user_id: params[:user_id], book_id: params[:book_id])\n @basket = Basket.find_by(user_id: params[:user_id], book_id: params[:book_id])\n @basket.increment!(:amount)\n else\n Basket.create(user_id: params[:user_id], book_id: params[:book_id], amount: 1)\n end\n redirect_to my_basket_path(params[:user_id])\n end", "def add_item(item)\n item.item_number = @@item_number\n @@item_number += 1\n @grocery_item << item\n\n # starting the logic for finding out what type of item it is and if it will be\n # allowed to be taxed. < -- Continue here\n if @grocery_item.item_type == \"books\"\n\n end\n\n\n\nend", "def add_item(item, price, quantity = 1)\n @total += price * quantity\n @transactions << price * quantity\n i = quantity\n until i == 0 do\n @items << item\n i -= 1\n end\n end", "def buy_now(item_params)\n new_item = cart_items.new(item_id: item_params[:item][:item_id], quantity: item_params[:quantity], buy_now: item_params[:buy_now], cart_id: self.id)\n end", "def add_item(item, quant=0)\n\t$grocery_list.store(item, quant)\n\tp \"You added #{item} to your list.\"\nend", "def create\n @item = Item.new(item_params)\n vendor = Vendor.find(item_params[:vendor_id])\n @item.build_vendor(:id => vendor.id)\n @item.save!\n @current_item = @item\n @items = Item.all\n end", "def buying_item item_name\n @buying_results_parser.read @querier.buying_item(item_name)\n end", "def add_item_to_basket(item_id)\n @session[:item_basket] << item_id unless @session[:item_basket].include? item_id\n end", "def add_product(product, quantity)\n current_item = OrderItem.find_by(product_id: product.id, order_id: self.id )\n\n if current_item\n current_item.quantity = quantity\n current_item.save\n else\n new_item = OrderItem.new(product_id: product.id, quantity: quantity, order_id: self.id)\n new_item.save\n end\n end", "def add_item(item, amount = 1)\n\n # Increase the amount if the item already exists in the inventory.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n\n # If not already in the inventory, push a couple.\n @inventory.push(C[item, amount])\n end", "def buy(item)\n raise_no_money! if item.price > pending_amount\n change = calc_change(pending_amount - item.price)\n transfer_pending_to_money\n remove_from_money change\n change\n end", "def add_item(inventory, item, quantity)\n\tinventory[item] = quantity\n\t@full_inventory = inventory\n\t#this is what updates your inventory with the new item & quantity.\nend", "def create\n\n @item = Item.new(item_params)\n #@item.user_id = current_user.id \n if !@item.buyitnow \n @item.qty = 1; \n end\n if @item.seq.blank? \n @item.seq = Item.maximum(\"seq\") + 1\n else \n @items = @item.auction.items.all\n @items.each do |i|\n if i.seq >= @item.seq \n i.seq += 1 \n end\n end\n end\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 put(item)\n @inv.push(item)\n end", "def trade_item_with_party(new_item, old_item)\n return false if new_item && !$game_party.has_item?(new_item)\n temp = UI_MSG::ITEM\n UI_MSG.const_set(:ITEM, false)\n $game_party.gain_item(old_item, 1)\n $game_party.lose_item(new_item, 1)\n UI_MSG.const_set(:ITEM, temp)\n return true\n end", "def add(product)\n items.create(product: product)\n end", "def add_item_to_guest_cart(item)\n post_wrapper(\"/V1/guest-carts/#{guest_cart_key}/items\", item.to_json, default_headers)\n end", "def add_item(product_id)\n item = line_items.where(product_id: product_id).first\n if item.present?\n item.quantity += 1\n item\n else\n line_items.new(product_id: product_id)\n end\n end", "def buy_item\n merchant = Merchant.find(params[:merchant_id])\n item = merchant.determine_item(params.keys.second, params.values.second )\n \n # potions run differently since a user can have multiple of the item, so it checks if it is a potion\n if Merchant.is_potion?(item)\n response = merchant.buy_potion(item, merchant.get_character_from_game)\n flash[:notice] = response\n redirect_to user_character_path(current_user, merchant.get_character_from_game) \n \n # if not it runs the normal buy method \n else \n response = merchant.buy_item(item, merchant.get_character_from_game)\n flash[:notice] = response\n redirect_to user_character_path(current_user, merchant.get_character_from_game) \n end\n end", "def create\n @purchasable = find_purchasable\n @order_item = @purchasable.order_items.new(order_item_params)\n @order_item.user_id = current_user.id\n @order_item.channel_id = current_user.profile.selected_channel_id\n @order_item.product = @purchasable.product\n# @order_item.cost = @purchasable.product.price\n \n respond_to do |format|\n if @order_item.save\n format.html { redirect_to [@purchasable, :order_items], notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @order_item }\n else\n format.html { render :new }\n format.json { render json: @purchasable.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_item(new_item)\n item = Item.new(new_item)\n @items.push(item)\n end", "def <<(item)\n item = ensure_type(Item, item)\n\n original_item = find_item(item)\n\n if original_item\n original_item.quantity += (item.quantity || 1)\n else\n store << item\n end\n end", "def analytics_add_item(order_id, product_id, product_name, product_variation, unit_price, quantity)\n analytics_render_event(GA::Events::Ecommerce::AddItem.new(order_id, product_id, product_name, product_variation, unit_price, quantity))\n end", "def add_item(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend", "def buy(amount)\n @bought_amount += amount if amount_remaining >= amount\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 @bid = Bid.new(bid_params)\n @bid.user_id = current_user.id\n if @bid.item.buyitnow \n @bid.amount = @bid.item.start_bid\n @bid.item.qty -= @bid.qty\n end\n if outbid_user = outbid\n UserMailer.outbid(@bid).deliver\n # mail message\n end\n respond_to do |format|\n if @bid.save\n @bid.item.update_attributes(:qty => @bid.item.qty)\n format.html { redirect_to @bid.item, notice: 'Bid was successfully created.' }\n format.json { render :show, status: :created, location: @bid }\n else\n format.html { render :new }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n\nend", "def item_added(item)\n @item = item\n\n mail subject: \"New item available!\",\n to: \"nobody@yardsale.com\",\n bcc: User.all.pluck(:email)\n end", "def add_item\n item = params[:item]\n image = Image.find(item[:image_id])\n\n order = current_user.init_cart.order\n line_item = order.line_items.where(\n image_id: image.id,\n product_id: item[:product_id],\n product_option_id: item[:product_option_id]\n ).first\n\n if line_item.present?\n line_item.quantity += item[:quantity].to_i\n else\n line_item = order.line_items.build(item)\n end\n\n line_item.price = Product.find(line_item.product_id).price_for_tier(image.tier_id, image.owner?(current_user))\n line_item.tax = line_item.price * PER_TAX\n\n if line_item.save\n render json: line_item, status: :created\n else\n render json: { msg: line_item.errors.full_messages.to_sentence }, status: :bad_request\n end\n end", "def add_item(item, amount, quantity = 1)\n\n if quantity > 1\n self.total += (amount * quantity)\n quantity.times do \n @items << item\n end\n else\n self.total += amount\n @items << item\n end\n @last_amount = amount * quantity\n end", "def add_item(product_id, quantity)\n product = Product.find(product_id) # product is exists?\n\n quantity = quantity.blank? ? 1 : (quantity.to_i > 99? 99 : quantity.to_i)\n\n return if quantity < 1 # return if invalid quantity is provided\n \n if cart_item = @items.find { |item| item.id.to_i == product_id.to_i }\n cart_item.quantity += quantity\n cart_item.quantity < 99 ? cart_item.quantity : cart_item.quantity =99\n else\n @items << CartItem.new(product.id, quantity)\n end\n\n end", "def gain_item\n\t\titem = $data_items\n\t\t$game_party.gain_item(item[1], 1)\n\tend", "def bought_by(new_owner)\r\n self.owner = new_owner\r\n self.to_inactive\r\n end" ]
[ "0.73715043", "0.7309045", "0.7253374", "0.70903224", "0.7074505", "0.70599717", "0.69619083", "0.6961877", "0.6881912", "0.68477535", "0.6728815", "0.6710392", "0.66967636", "0.6684488", "0.66226447", "0.66168904", "0.6609025", "0.65925187", "0.6570102", "0.6564247", "0.6559136", "0.654311", "0.6530474", "0.65215755", "0.65175796", "0.651593", "0.64685875", "0.6442833", "0.64324224", "0.64280504", "0.64253306", "0.64196557", "0.6417057", "0.64053833", "0.639547", "0.6394004", "0.6392455", "0.63819736", "0.63614166", "0.6356621", "0.634249", "0.63354063", "0.6335205", "0.6335189", "0.63227165", "0.63092583", "0.63023376", "0.62939966", "0.6289272", "0.6277194", "0.6275896", "0.62551564", "0.6232988", "0.6229718", "0.61931264", "0.61920196", "0.6187206", "0.61849505", "0.6182615", "0.6181833", "0.61811304", "0.61487675", "0.614851", "0.6143217", "0.6142621", "0.61380315", "0.6137993", "0.6136709", "0.613442", "0.61318856", "0.6129746", "0.61294687", "0.6129283", "0.612566", "0.6115212", "0.6099655", "0.60967666", "0.6094425", "0.60903794", "0.60902905", "0.6083575", "0.60785615", "0.606881", "0.6063995", "0.6062895", "0.6061458", "0.60600615", "0.6052205", "0.6051067", "0.60475516", "0.60468054", "0.60467476", "0.6036768", "0.60292953", "0.6026966", "0.6020291", "0.60146844", "0.601171", "0.6009895", "0.6009235" ]
0.7787981
0
releases a certain quantity of an item
def release_quantity_of_item(item, quantity) if self.items.include?(item) item.quantity -= quantity end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def use_item(item_name:, quantity:)\n total_items_quantity[item_name] -= quantity\n end", "def reserve_inventory!(order_quantity)\n self.quantity -= order_quantity\n save!\n end", "def sell_inventory(material, quantity)\n material.quantity -= quantity\n end", "def purchase\n \t@stock -= 1\n end", "def set_quantity(purchase, n, entry = find_or_create_item(purchase))\n\n if n == 0\n delete(entry)\n else\n entry.components.clear\n\n max_qty = maximum_quantity_allowed(purchase)\n\n if max_qty > n\n assign_components(entry, purchase, n)\n else\n assign_components(entry, purchase, max_qty)\n if !stock_available?(purchase, n)\n entry.errors.add(:quantity, \"There #{max_qty > 1 ? 'are' : 'is'} only #{max_qty} of this item available.\")\n elsif purchase_limited?(purchase)\n entry.errors.add(:quantity, \"This item is limited to #{purchase.purchase_limit} per customer.\")\n end\n end\n\n entry.quantity = entry.components.map(&:quantity).sum\n\n if entry.quantity == 0\n delete(entry)\n else\n entry.total = entry.components.reduce(SpookAndPuff::Money.new('0')) {|m, c| m + c.total }\n entry.pre_discount_total = entry.total\n end\n end\n\n entry\n end", "def update_usage(served_quantity) \n self.used_quantity += served_quantity \n self.save \n \n self.mark_as_finished\n \n item = self.item \n item.deduct_ready_quantity(served_quantity ) \n \n return self \n end", "def update_usage(served_quantity) \n self.used_quantity += served_quantity \n self.save \n \n self.mark_as_finished\n \n item = self.item \n item.deduct_ready_quantity(served_quantity ) \n \n return self \n end", "def purchase\n @order = current_order\n @order_items = @order.order_items\n @order_items.each do |item|\n new_inventory = Product.find(item.product_id).inventory_count - item.quantity\n Product.update(item.product_id, inventory_count: new_inventory)\n end\n @order_items.destroy_all\n end", "def sell_product(name:)\n find_product(name: name).quantity -= 1\n end", "def increment_quantity(purchase, n)\n entry = find_or_create_item(purchase)\n set_quantity(purchase, (entry.quantity || 0) + n.to_i, entry)\n end", "def buy_requested_item(request, item)\r\n self.overlay.delete_item_request(request.id)\r\n item.price = request.price #The prize given in the request is relevant.\r\n buy(item, true)\r\n end", "def buy(item, quantity)\r\n if quantity < item.quantity\r\n item_to_buy = item.split(quantity)\r\n else\r\n item_to_buy = item\r\n end\r\n seller = item_to_buy.owner\r\n seller.sell(item_to_buy)\r\n item_to_buy.owner = self\r\n self.remove_credits(item_to_buy.price * quantity)\r\n item_to_buy.deactivate\r\n Marketplace::Activity.create(Activity.ITEM_BOUGHT, item, \"#{item.name} has been bought by #{self.name}\")\r\n Marketplace::Activity.create(Activity.USER_BOUGHT_ITEM, self, \"#{self.name} bought #{item.name}\")\r\n #delete the history in the description log, except the newest entry\r\n item_to_buy.clean_description_log\r\n item_to_buy.clean_comments\r\n item_to_buy\r\n end", "def reshelf(product, quantity)\n # NOT DEFINED IN EXAMPLES\n @inventory[product][\"quantity\"] += quantity\nend", "def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend", "def sell(item, quantity)\n if total_inventory.has_key?(item) && quantity < total_inventory[item]\n @vendors.each do |vendor|\n if vendor.inventory.has_key?(item)\n if vendor.inventory[item] >= quantity\n vendor.inventory[item] -= quantity\n else\n vendor.inventory[item] -= quantity\n diff = vendor.inventory[item].abs\n vendor.inventory[item] = 0\n @vendors.each do |vendor|\n if vendor.inventory.has_key?(item)\n if vendor.inventory[item] != 0\n require \"pry\"\n binding.pry\n vendor.inventory[item] - diff\n end\n end\n end\n end\n end\n end\n return true\n else\n return false\n end\n end", "def refill(item_name:, quantity:)\n total_items_quantity[item_name] += quantity\n items_running_low[item_name] = false\n end", "def increase!(amount = 1)\n transaction do\n self.quantity += amount\n unless in_stock?\n # fail Shoppe::Errors::NotEnoughStock, ordered_item: ordered_item, requested_stock: self.quantity\n end\n save!\n # order.remove_delivery_service_if_invalid\n end\n end", "def propose_item_with_quantity(name, price, quantity, selling_mode, increment, end_time, description = \"\", log = true)\r\n item = self.propose_item(name,price,selling_mode,increment,end_time, quantity, description,log)\r\n item\r\n end", "def update_qty(shopping_list, item, quantity)\r\n\r\n\tadd_item(shopping_list, item, quantity)\r\n\r\nend", "def receive(n)\r\n\t if n > 0 then\r\n\t\t @quantity = @quantity + n\r\n\t end\r\n end", "def sell_quantity\r\n 100000000000\r\n end", "def buy\n user = User.find_by_guid(params[:id])\n if user\n user.dollaz -= params[:price].to_i\n PlayerInventory.create(pid: user.id, item_id: params[:item].id)\n user.save!\n render nothing:true, notice: \"Item bought!\"\n else\n render nothing:true, notice: \"Error: unable to purchase item\"\n end\n end", "def purchase(item_price)\n @total += item_price\n total\n end", "def perform_item_scrapping( served_quantity) \n self.scrapped_quantity += served_quantity \n self.save \n \n self.mark_as_finished \n \n item.add_scrap_quantity( served_quantity ) \n \n return self\n end", "def perform_item_scrapping( served_quantity) \n self.scrapped_quantity += served_quantity \n self.save \n \n self.mark_as_finished \n \n item.add_scrap_quantity( served_quantity ) \n \n return self\n end", "def decrease_sell_in(item)\n item.sell_in -= 1\n end", "def increment_quantity\n @quantity += 1\n end", "def test_adds_up_in_quanttity\n\t\tcart = Cart.new\n\t\t3.times { cart.add_item 1 }\n\n\t\tassert_equal cart.items.length, 1 #solo un item\n\t\tassert_equal cart.items.first.quantity, 3 #varias unidades del mismo item\n\tend", "def recover_usage(quantity_to_be_recovered)\n self.used_quantity -= quantity_to_be_recovered \n self.save \n \n self.unmark_as_finished\n \n item = self.item \n item.update_ready_quantity\n \n return self \n end", "def put_to_cart(item, amount)\n cart[item.to_sym] = cart[item.to_sym].to_i + amount.to_i\n list[item.to_sym] = list[item.to_sym].to_i - amount.to_i\n list.delete(item.to_sym) if list[item.to_sym] <= 0\n end", "def stock_minus(product, amount)\n product = Product.find(product)\n quantity = product.quantity\n quantity -= amount.to_i\n product.update(quantity: quantity)\n end", "def add_item(title, price, quantity=1)\n self.total += price * quantity #Think about this logically\n #you go into a store and buy and item. How do you get the total of the item.\n #you MULTIPLY BY THE PRICE!!!! DURRRRR!!! GOD MORTY YOUR SO DUMB\n @price = price\n #do this x amount of times.\n quantity.times do\n @items << title\n end\n\n end", "def sell(amount)\n @quantity_in_stock -= amount\n @quantity_sold += amount\n end", "def add_item(title, p, q=1) # accepts a title and a price AND inc. the total. Optional quantity set to 1 since u will always have at least one item.\n @total += (p*q) # @ total is price times quantity, and increments (does not forget previous total as u add new items)\n q.times do # want to add the item as many times to the list as its quantity so keep doing this the # of times its quantity is\n @items << title\n end\n @last_transaction = p # the last transaction = the price of the last item added\n end", "def recover_usage(quantity_to_be_recovered)\n self.used_quantity -= quantity_to_be_recovered \n self.save \n \n self.unmark_as_finished\n \n \n \n item = self.item \n item.add_ready_quantity( quantity_to_be_recovered ) \n \n return self \n end", "def reserve_quantity(quantity)\n quantity = quantity.to_i\n begin\n Deal.transaction do\n deal = Deal.find(self.deal.id, :lock => true)\n if deal.max == 0 or deal.coupon_count + quantity - self.quantity <= deal.max\n self.update_attributes!(:quantity => quantity, :amount => quantity*deal.deal_price.to_f, :updated_at => Time.zone.now)\n return true\n end\n end\n rescue ActiveRecord::RecordInvalid => invalid\n logger.error \"Order.reserce_quantity: Failed for Order #{self.inspect} #{invalid}\"\n end\n return false\n end", "def increment(n = 1)\n @quantity += n\n end", "def bump(sign = '+')\n\t\tsign == '-' ? self.quantity -= 1 : self.quantity += 1\n\tend", "def add(item)\n item.available? ? items.create(cartable: item) : false\n release\n end", "def set_quantity\n @subscription.quantity += 1 if @subscription.persisted?\n end", "def buy_item(name)\n change = @calculator.buy @items[name].last\n [@items[name].pop, change]\n end", "def add_item(item, price, quantity = 1)\n @total += price * quantity\n @transactions << price * quantity\n i = quantity\n until i == 0 do\n @items << item\n i -= 1\n end\n end", "def update_quantity(grocery_list, item, quantity)\r\n add_item(grocery_list, item, quantity)\r\n \r\nend", "def add_item(item, price, quantity=1)\n @total += (price * quantity)\n @items.fill(item, @items.size, quantity)\n @last_transaction = {item => (price * quantity)}\n @last_qty = quantity\n end", "def update (item, quantity)\n @groceries[item]=quantity\n end", "def update_quantity(list, item, quantity)\n\tadd_to_list(list, item, quantity)\nend", "def update_quant(item, quant)\n\t$grocery_list.store(item, quant)\n\tp \"You updated #{item} number to #{quant}.\"\nend", "def add\n @item.increment(:quantity)\n @item.save!\n\n refresh\n end", "def update_quantity(grocery_list,item,new_quantity)\n # if item on the list\n grocery_list.store(item,new_quantity)\n puts \"When you pick up #{item}, make sure to grab #{new_quantity} instead.\"\nend", "def remove_quantity(inventory_item_id, quantity, concept = 3)\n item_location = ItemLocation.find_by(\n inventory_item_id: inventory_item_id,\n warehouse_location_id: id\n )\n\n return NOT_ENOUGH_STOCKS if quantity > item_location.quantity\n\n item_location.quantity -= quantity\n quantity = item_location.quantity if item_location.quantity.negative?\n\n item_location.save\n WarehouseTransaction.create(\n inventory_item_id: inventory_item_id,\n warehouse_location_id: id,\n quantity: quantity,\n concept: concept\n )\n\n if item_location.quantity <= 0\n item_location.destroy\n return 0\n end\n update_status\n item_location.quantity\n end", "def update_quantity(list,item,item_count)\n\tlist[item] = item_count\nend", "def update_quantity token, cart_id, product_code, qty = 1\n\tend", "def perform_scrap_item_replacement( scrap_recover_quantity) \n self.scrapped_quantity -= scrap_recover_quantity \n self.save \n \n self.unmark_as_finished \n \n item.deduct_scrap_quantity( scrap_recover_quantity ) \n \n return self\n end", "def perform_scrap_item_replacement( scrap_recover_quantity) \n self.scrapped_quantity -= scrap_recover_quantity \n self.save \n \n self.unmark_as_finished \n \n item.deduct_scrap_quantity( scrap_recover_quantity ) \n \n return self\n end", "def quantity=(q)\n delta = quantity - q\n self.quantity_consumed += delta\n save\n end", "def consume!(entity, resource, qty)\n current_qty = entity_state_for(entity)[resource.to_sym]\n new_qty = [0, current_qty - qty].max\n entity_state_for(entity)[resource.to_sym] = new_qty\n\n current_qty != new_qty\n end", "def increment_quantity\n self.quantity_needed += self.quantity\n save\n end", "def loot\r\n\t@@item_number += 1\r\n\tend", "def change_inventory\n order_item_obj = OrderItem.last\n product_id = order_item_obj.product_id\n inventory_of_ordered_product = InventoryStock.where(product_id:product_id)\n quantity_in_inventory = inventory_of_ordered_product[0].quantity\n quantity_in_ordered_item = order_item_obj.quantity\n updated_quantity_in_inventory = quantity_in_inventory.to_i-quantity_in_ordered_item.to_i\n InventoryStock.where(product_id:product_id).update(quantity: updated_quantity_in_inventory)\n end", "def decrement_inventory!\n self.available_inventory = self.available_inventory - 1\n self.save\n end", "def calculate_quantity(quantity)\r\n if (quantity.nil? or quantity == 0) then\r\n quantity = -1\r\n else\r\n quantity -= 1\r\n end\r\n end", "def add_item(item, price, *quantity)\n q = quantity.join(\"\").to_i\n if q > 1\n q.times do\n @items.push(item)\n end\n else\n @items.push(item)\n end\n if q > 1\n price_with_quantity = q * price\n @last = price_with_quantity\n @total += price_with_quantity\n else\n @last = price\n @total += price\n end\n\n end", "def add_item(title, price, quantity=1)\n #and increases the total\n self.total += price * quantity\n #times.do for all the items\n quantity.times do\n @items << title\n end\n #doesn't forget about the previous total\n self.last_transaction = price * quantity\n end", "def add_to_inventory(item)\n @items << item\n equip(item)\n items_weight\n end", "def add_item(title, price, quantity=1) \n self.total += price * quantity\n quantity.times do\n items << title \n end\n self.last_transaction = price * quantity\n\n end", "def remove\n if @item.quantity == 1\n @item.destroy!\n else\n @item.decrement(:quantity)\n @item.save!\n end\n\n refresh\n end", "def add_item(title, amount, quantity=1)\n self.total += amount * quantity\n quantity.times do\n items << title\n end\n self.last_transaction = amount * quantity\n end", "def set_quantity_and_price(purchase, n, price, entry = find_or_create_item(purchase))\n entry.components.clear\n update_entry(entry) do |i|\n i.components.build(:price => price, :quantity => n, :total => price * n)\n end\n end", "def add_item(title, price, quantity=1)\n self.total += price * quantity\n #quantity amount of times it'll add the title to the items array\n quantity.times {items << title}\n self.last_transaction = price * quantity\n end", "def buy(item)\n raise_no_money! if item.price > pending_amount\n change = calc_change(pending_amount - item.price)\n transfer_pending_to_money\n remove_from_money change\n change\n end", "def update_quantity_of_item(list,item,quantity)\r\n add_item_to_list(list,item,quantity)\r\n list\r\nend", "def add_product(product)\n # inicia transação\n transaction do \n item = self.items.detect{|item| item.product == product}\n if item\n item.quantity += 1\n item.save\n else\n self.items.create(:product => product, :quantity => 1, :price => product.price)\n end\n end\n end", "def purchase_item(item, seller_id, buyer_id)\n seller = User.new(seller_id)\n buyer = User.new(buyer_id)\n @conn.watch([\"market\", buyer.id]) do\n fund = @conn.hget(buyer.id, \"fund\")\n price = @conn.zscore(\"market\", seller.item_id(item))\n\n if price && price <= fund.to_i\n @conn.multi do |multi|\n multi.hincrby(buyer.id, \"fund\", -price.to_i)\n multi.hincrby(seller.id, \"fund\", price.to_i)\n multi.zrem(\"market\", seller.item_id(item))\n multi.sadd(buyer.inventory_id, item)\n end\n else\n @conn.unwatch\n end\n end\n end", "def decrease_items_count\n # ensure count cannot go below 1\n s_id = params[:product_id].to_s\n return if session[:shopping_cart][s_id]['quantity'].to_i <= 1\n\n session[:shopping_cart][s_id]['quantity'] =\n session[:shopping_cart][s_id]['quantity'].to_i - 1\n\n @product = Product.find(params[:product_id].to_i)\n calculate_order_total\n end", "def item_inventory_update\n \n item = Item.find(params[:item_id])\n order= Order.find(params[:id])\n item_order = ItemOrder.where(item_id: item.id, order_id: order.id).first\n new_inventory = item.inventory - item_order.quantity\n item_order.update(status: \"fulfilled\")\n item.update(inventory: new_inventory)\n end", "def add_units(qty)\n qty.to_i.times do\n #create item\n item = supply_items.new\n item.status = SupplyItem::STATUS_AVAILABLE\n item.save\n end\n end", "def add(quant)\n self.quantity_consumed -= quant\n save\n \"added #{quant} #{name}\"\n end", "def add_quantity(number)\n @quantity += number\n end", "def update_qty(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend", "def deduct_quantity\n line_items.each do |i|\n i.product.current_stock -= i.quantity\n i.product.save\n end\n end", "def update_quality(items)\n items.each do |item|\n if is_special_item?(item)\n special_item(item)\n else\n item.sell_in > 0 ? decrement_normal_item(item, 1) : decrement_normal_item(item, 2)\n end\n\n item.sell_in -= 1\n end\nend", "def quantity\n @quantity ||= sold_out ? 0 : rand(100)\n end", "def add_item(product_id, quantity)\n product = Product.find(product_id) # product is exists?\n\n quantity = quantity.blank? ? 1 : (quantity.to_i > 99? 99 : quantity.to_i)\n\n return if quantity < 1 # return if invalid quantity is provided\n \n if cart_item = @items.find { |item| item.id.to_i == product_id.to_i }\n cart_item.quantity += quantity\n cart_item.quantity < 99 ? cart_item.quantity : cart_item.quantity =99\n else\n @items << CartItem.new(product.id, quantity)\n end\n\n end", "def gain_item(item, n, include_equip = false)\n number = item_number(item)\n case item\n when RPG::Item\n @items[item.id] = [[number + n, 0].max, 99].min\n when RPG::Weapon\n @weapons[item.id] = [[number + n, 0].max, 99].min\n when RPG::Armor\n @armors[item.id] = [[number + n, 0].max, 99].min\n end\n n += number\n if include_equip and n < 0\n for actor in members\n while n < 0 and actor.equips.include?(item)\n actor.discard_equip(item)\n n += 1\n end\n end\n end\n end", "def item_quantity(list, item_to_update, quantity)\n list[item_to_update] = quantity \nend", "def buy3(num, item)\n return 0 if num < 3\n diff = item.price - item.sale_price\n amount = diff * num\n\n if amount > 0\n @subtract += amount\n @promos[item.code] = diff\n @promo_counts[\"BUY3\"] = num\n end\n end", "def transfer(qty,prod,from,to)\n #Ensure from location has product in Stock\n if (get_product_qauntity(from.id) >= qty)\n #remove product from from Store\n rmv = from.remove_product(prod,qty)\n if rmv == 99\n puts \"REMOVED #{qty} ITEMS - (ID:#{prod.id}) from #{from.name}\"\n end\n to.add_product(prod,qty)\n puts \"SENT #{qty} ITEMS - (ID:#{prod.id}) to #{to.name}\"\n #Report action\n #puts \"Moved #{qty} items from #{from.name} to #{to.name}\"\n else\n puts \"ERROR: Tried to transfer more items than you have!\"\n end\n end", "def create\n\n @item = Item.new(item_params)\n #@item.user_id = current_user.id \n if !@item.buyitnow \n @item.qty = 1; \n end\n if @item.seq.blank? \n @item.seq = Item.maximum(\"seq\") + 1\n else \n @items = @item.auction.items.all\n @items.each do |i|\n if i.seq >= @item.seq \n i.seq += 1 \n end\n end\n end\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 change_quantity(list, item, new_qty)\n list[item] = new_qty\nend", "def decrement_line_item_quantity(line_item_id)\n current_item = line_items.find(line_item_id)\n if current_item.quantity > 1\n current_item.quantity -= 1\n else\n current_item.destroy\n end\n current_item\n end", "def buy(amount)\n @bought_amount += amount if amount_remaining >= amount\n end", "def add_item (title, price, quantity=1)\n self.total += price * quantity\n quantity.times do\n @items << title\n end\n end", "def update_quantity(list, item_name, quantity)\n\tlist[item_name] = quantity.to_i\n\tlist\nend", "def update_cart\n product = Product.find_by_cs_sku(params[:sku])\n item = ReservedItem.where('user_id = ? and product_id = ? and session_id = ?', current_user.id,\n product.id,\n session.id).first\n qty = BigDecimal.new(get_qty)\n\n if available?(product, item, qty)\n product.update_attribute(:qty, (product.qty + item.qty) - qty)\n item.update_attribute(:qty, qty)\n respond_with_format { @cart.update_item(params[:sku], get_qty) }\n else\n flash[:error] = 'Not enough item in inventory'\n respond_with_format\n end\n end", "def quantity\n quantity_initial - quantity_consumed\n end", "def add_item(item, price, quantity=1)\n # to call an instance method inside another instance method, use the self keyword to refer to the instance on which you are operating\n self.total += price * quantity # increment the total by the result of (price X quantity)\n # puts \"total: #{self.total}\"\n\n quantity.times do\n @items << item # add item to array 'quantity' # of times ***see note below\n end\n\n @last_transaction = price * quantity # keep track of the last transaction amount added\n # puts \"last transaction: #{@last_transaction}\"\n end", "def sell!(qty, price)\n order = Fyb::Order.new qty, price, :sell\n order.perform\n end", "def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n\n order_item = order.items.find_or_create_by(\n product_id: product_id\n )\n\n order_item.price = product.price\n order_item.quantity = 1\n order_item.save\n end", "def update_quan(list, item, quantity)\n list[item] = quantity\nend", "def update_qty(list_items, item_name, new_qty)\n raise ArguementError.new(\"This item does not exist\") unless list_items.include?(item_name)\n list_items[item_name] = item_qty\nend" ]
[ "0.7100202", "0.7001074", "0.69820267", "0.687481", "0.67463577", "0.67162484", "0.67162484", "0.66184425", "0.6617048", "0.6597131", "0.6555539", "0.654294", "0.65269905", "0.6490382", "0.64864016", "0.6464276", "0.64587927", "0.63866997", "0.6383126", "0.6379867", "0.6366713", "0.63495016", "0.6331978", "0.6325444", "0.6325444", "0.631303", "0.63105047", "0.630016", "0.62887883", "0.6282883", "0.6275376", "0.62493145", "0.6247413", "0.624602", "0.6243585", "0.62292284", "0.6228292", "0.62231696", "0.6202692", "0.6197716", "0.6194674", "0.6179607", "0.61699444", "0.6168897", "0.6152235", "0.61492884", "0.61452776", "0.61361533", "0.6126336", "0.6121142", "0.6116817", "0.611501", "0.6106078", "0.6106078", "0.6093166", "0.6078308", "0.6068003", "0.60637856", "0.6062149", "0.6057927", "0.605613", "0.6053192", "0.6045269", "0.60438424", "0.6039781", "0.60370255", "0.603272", "0.6030878", "0.6026093", "0.60222185", "0.6021753", "0.6008444", "0.60070205", "0.6001519", "0.60010594", "0.5989126", "0.59811133", "0.5978819", "0.59779406", "0.5966348", "0.59636086", "0.596184", "0.59579057", "0.59560907", "0.5953168", "0.59497297", "0.5947565", "0.59450036", "0.59405077", "0.5938225", "0.59348327", "0.59337115", "0.592121", "0.59200686", "0.59188575", "0.5917376", "0.591672", "0.5912165", "0.59107745", "0.5909236" ]
0.79756016
0
deletes the owner of an item to release it
def release_item(item) if self.items.include?(item) item.owner = nil self.items.delete(item) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def release_item(item)\n if self.items.include?(item)\n item.owner = nil\n self.items.delete(item)\n end\n end", "def remove_item(item)\r\n items.delete(item)\r\n item.owner = nil\r\n end", "def dispose_item(item)\n if self == item.owner\n equipments.delete(item.in_slot) if EquipmentSlots.include? item.in_slot\n item.destroy\n # TODO: notify\n end\n end", "def free item\n item.order_book.remove item if item.order_book\n end", "def destroy\n @item.destroy!\n end", "def remove item #(item: pointer)\n freeitem item\n delete item\n end", "def destroy\n @rentable_item.destroy\n end", "def unlinkItem _obj, _args\n \"_obj unlinkItem _args;\" \n end", "def destroy\n get_item\n @pcp_subject = @pcp_item.pcp_subject\n if @pcp_subject.user_is_owner_or_deputy?( current_user, @pcp_item.pcp_step.acting_group_index )\n if @pcp_item.released?\n notice = 'pcp_items.msg.cannot_del'\n else \n @pcp_item.destroy\n notice = 'pcp_items.msg.delete_ok'\n end\n respond_to do |format|\n format.html { redirect_to pcp_subject_pcp_items_path( @pcp_subject ), notice: t( notice )}\n end\n else\n render_no_permission\n end\n end", "def brief_vendor_del_item\n brief = Brief.find(params[:brief_id])\n brief_vendor = brief.brief_vendors.find_by_org_id(params[:vendor_id])\n item = brief_vendor.items.find_by_parent_id(params[:item_id])\n\n item.destroy\n\n redirect_to(cheil_brief_vendor_items_url(params[:brief_id],params[:vendor_id])) \n end", "def destroy\n @wish_list = WishList.find(params[:wish_list_id])\n @item = @wish_list.items.find(params[:item_id])\n\n if @item.purchased_by == current_user\n @item.purchased_by = nil\n @item.save\n else\n flash[:alert] = \"You do not have permission to unpurchase this Item.\"\n end\n head 200\n end", "def destroy\n @item_alias.destroy\n end", "def destroy\n set_proposed_item\n calculate_saving\n \n\n @proposed_item.destroy\n respond_to do |format|\n format.html { redirect_to @budget, notice: 'Proposed item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \t@user = User.find(params[:user_id])\n \t@item = @user.items.find(params[:id])\n \t@item.destroy\n \tredirect_to @user\n \tend", "def deleteItem\n\t\tif @public_id\n\t\t\tCloudinary::Uploader.destroy(@public_id)\n\t\tend\n\tend", "def destroy\n authorize! :edit, @item\n @item.destroy\n redirect_to items_path\n end", "def destroy\n @item = Item.find(params[:id])\n\n if @item.user.id == current_user.id\n @item.destroy\n redirect_to root_path\n else\n redirect_to item_path(@item)\n end\n end", "def remove_item\n\n end", "def destroy\n\t\t@item.destroy\n\t\thead :no_content\n\tend", "def delete_item(item_id, log = true)\n item = Item.by_id(item_id)\n\n fail if item.nil?\n fail unless self.can_delete?(item)\n\n item.owner.release_item(item)\n item.delete\n\n Analytics::ItemDeleteActivity.with_remover_item(self, item).log if log\n end", "def delete_item(item)\n @chores.delete(item)\n end", "def destroy\n item = Item.find(params[:item_id])\n user = User.find(item[:user_id])\n if(user && user[:username] == session['username'])\n if (item.item_type == 'file')\n FileUploader.delete_file item.path\n end\n Item.delete(params[:item_id])\n end\n end", "def delete_item(item_id, log = true)\r\n item = Item.by_id(item_id)\r\n\r\n fail if item.nil?\r\n fail unless self.can_delete?(item)\r\n\r\n item.owner.release_item(item)\r\n item.delete\r\n\r\n ItemDeleteActivity.create(self, item).log if log\r\n end", "def release_lock( my_owner = oval )\n # Use my_owner = oval to make testing easier.\n with_watch( okey, xkey ) do\n owner = redis.get( okey )\n if owner == my_owner then\n redis.multi do |multi|\n multi.del( okey )\n multi.del( xkey )\n end\n end\n end\n end", "def destroy\n @item = @user.items.find(params[:id])\n @item.destroy\n\n\n respond_to do |format|\n format.html { redirect_to user_items_path(@user) }\n format.json { head :no_content }\n end\n end", "def destroy\n raise \"Permission denied\" if (RemoveItemOrderTask.roles & @permissions).empty?\n OrderItem.transaction do\n item = @order.items.find(params[:id])\n item.destroy\n task_complete({ :data => { :product_id => item.product.id, :item_id => item.id } },\n RemoveItemOrderTask, [RemoveItemOrderTask])\n end\n redirect_to :back\n end", "def destroy(item)\n raise StandardError unless @mode == :update\n @attached.delete(item)\n @remove_file.puts(XML.generate({ :id => item.is_a?(String) ? item : item.id }, false))\n end", "def grocery_item_deleter(grocery_list, item)\n grocery_list.delete(item)\n grocery_list\nend", "def user_delete_item\n @item = Item.find_by_id(params[:id])\n if @item.auction_flag\n #@auction = Auction.find(@item.auction_id)\n #@auction.destroy\n redirect_to item_path(@item),:notice => \"You can't delete this item, because its auctioned and it has a bidder\"\n\n else\n @item.destroy\n redirect_to(:action => 'user_items_list')\n end\n\n end", "def destroy\n @costs_for_item.destroy\n end", "def destroy\n @user_address_book_item = UserAddressBookItem.find(params[:id])\n @user_address_book_item.destroy\n end", "def destroy\n @item.destroy\n return success_item_destroy\n end", "def delete_item(item)\n @get_items.delete(item)\n end", "def destroy\n AlbumOwnership.find_by({album_id: @album.id, user_id: current_user.id}).destroy\n end", "def destroy\n @item.destroy\n redirect_to items_url, notice: \"This item was removed from the system.\"\n end", "def destroy\n @book_item.destroy\n redirect_to user_path\n end", "def drop_item\n @order.order_items.find(params[:id]).destroy\n\n refresh\n end", "def destroy\n @orden_item.destroy\n respond_to do |format|\n format.html { redirect_to orden_items_url, notice: 'Orden item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy_owner!\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\towner.delete if owner\n\tend", "def remove_item(item)\n @items.delete(item)\n end", "def removeHandgunItem _obj, _args\n \"_obj removeHandgunItem _args;\" \n end", "def destroyItem(id)\n item = List.find(id)\n item.destroy\n end", "def remove_owner(user)\n user = User.get_user(user, client)\n response = client.delete \"/owner/#{user.jid}/?actor_token=#{CGI.escape client.system_token}\"\n if response.success?\n true\n else\n raise APIException.new(response.body)\n end\n end", "def unwatch_item\n\t\t# determine watcher, item to watch\n\t\t@watcher = current_user\n @watching = Item.find(params[:id]) \n exist = Watch.find(:first, :conditions => {:watcher_id => @watcher.id, :item_id => @watching.id})\n\t\t# if it exists\n if exist\n\t\t\t# delete relationship\n exist.destroy\n\t\t\t# show pop up regarding watch success\n gflash :success => \"You are no longer watching #{@watching.name}!\"\n else\n\t\t\t# show pop up regarding watch error\n gflash :error => \"You are already not following #{@watching.name}!\"\n end\n redirect_to :controller => 'items', :action => 'show', :id => @watching.id\t\n end", "def destroy\n @item = current_user.items.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to items_url }\n format.json { head :no_content }\n end\n end", "def delete(o); removeObject o end", "def remove_item\n @parent.remove_item(self)\n end", "def release_quantity_of_item(item, quantity)\r\n if self.items.include?(item)\r\n item.quantity -= quantity\r\n end\r\n end", "def destroy\n \n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to user_path(current_user.id) }\n format.json { head :ok }\n end\n end", "def destroy\n super\n parent.unlist_item(@sym)\n end", "def remove_item(id:)\n order.items.destroy(id)\n end", "def destroy\n @item.destroy\n redirect_to my_account_url, notice: 'Item was successfully destroyed.'\n end", "def destroy\r\n @item = Item.find(params[:id])\r\n @item.destroy\r\n redirect_to items_url\r\n end", "def delete_item(item)\r\n @list.delete(item)\r\n end", "def destroy\n user = @item.user\n @item.destroy\n respond_to do |format|\n format.html { redirect_to user_path(user) }\n format.json { head :no_content }\n end\n end", "def destroy\n @item.destroy\n head :no_content\n end", "def destroy\n @item = item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(budget_items_url) }\n format.xml { head :ok }\n end\n end", "def remove_item\n\tsaved = current_user.saved\n\titem = saved.items.find(params[:item])\n saved.items.delete(item)\n redirect_to :back\n\tend", "def delete_item\n\nend", "def destroy\n @reward_owner.destroy\n @reward_owners = RewardOwner.all\n end", "def destroy\n @release_item.destroy\n respond_to do |format|\n format.html { redirect_to release_items_url, notice: 'Release item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def removeItem _obj, _args\n \"_obj removeItem _args;\" \n end", "def destroy\n @item.destroy\n redirect_to root_path\n end", "def remove(purchase)\n entry = find_item(purchase)\n destroy(entry) if entry\n end", "def destroyed(item)\n bowline.destroyed(\n name, \n item.id\n ).call\n end", "def revoke!\n self.used = true\n self.save\n end", "def purge_items\n purge(@nodename)\n end", "def destroy\n destroied_user = current_user\n\n aimlicensecontainer = destroied_user.aim_license_container\n aimlicensecontainer.destroy\n\n likelicensecontainer = destroied_user.like_license_container\n likelicensecontainer.destroy\n\n gotlicensecontainer = destroied_user.got_license_container\n gotlicensecontainer.destroy\n\n super\n end", "def destroy\n @item.destroy\n redirect_to items_path, notice: 'Item was successfully destroyed.'\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to private_items_user_path(@user), notice: t('.notice') }\n format.json { head :no_content }\n end\n end", "def destroy\n @billable_item = BillableItem.find(params[:id])\n\n respond_to do |format|\n if @billable_item.destroy\n format.html { redirect_to billable_items_url,\n notice: (crud_notice('destroyed', @billable_item) + \"#{undo_link(@billable_item)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { redirect_to billable_items_url, alert: \"#{@billable_item.errors[:base].to_s}\".gsub('[\"', '').gsub('\"]', '') }\n format.json { render json: @billable_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @item.destroy\n redirect_to items_url, notice: 'Item was successfully destroyed.'\n #head :no_content\n end", "def delete!(item)\n SidekiqUniqueJobs::Job.add_digest(item)\n SidekiqUniqueJobs::Locksmith.new(item).delete!\n end", "def destroy\n requires :ip\n remove(:release => true)\n end", "def remove_registration_item(reg_item)\n unless reg_item.nil? || !has_expense_item?(reg_item)\n # registrant_expense_items.system_managed.find_by(expense_item_id: reg_item.id).destroy\n # use `.to_a` here so that we can use `mark_for_destruction` and it will be destroy on save\n item_to_remove = registrant_expense_items.to_a.find { |rei| rei.system_managed? && rei.expense_item == reg_item}\n item_to_remove.mark_for_destruction\n end\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to budget_path(params[:budget_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n response = current_user.unfollow_item(params[:id])\n redirect_to items_path\n end", "def withdraw_player_bid(player)\n self.bids.find_by(name: player).destroy\n end", "def destroy\n @item.destroy\n redirect_to items_url, notice: 'Item was successfully destroyed.'\n end", "def delete_item(db, item_name, current_user)\r\n db.execute(\"DELETE FROM items WHERE item_name = ? AND user_id = ?\", [item_name, current_user])\r\nend", "def remove_item(user, item)\n before = get_item_count\n self.items.delete(item)\n after = get_item_count\n (before-after-1).times do\n user.add_to_list(item)\n end\n end", "def destroy\n @license.destroy\n end", "def destroy\n @tag_item.destroy\n end", "def destroy\n @item.destroy\n respond_to do |format|\n format.html { redirect_to user_items_url(current_user) }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_thing.destroy\n end", "def remove_item(id)\n return nil if self.class.mode == :sandbox\n\n query = { \"type\" => \"delete\", \"id\" => id.to_s, \"version\" => Time.now.to_i }\n doc_request query\n end", "def delete_item(access_token)\n @client.item.remove(access_token)\n end", "def delete(item)\n SidekiqUniqueJobs::Job.add_digest(item)\n SidekiqUniqueJobs::Locksmith.new(item).delete\n end", "def delete_from(grocery, item)\n grocery.delete(item)\n grocery\nend", "def destroy\n @item ||= Item.find_by_id_or_name(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to(items_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def destroy\n @item = @deal.items.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to (deal_items_path(@deal)) }\n format.json { head :no_content }\n end\n end", "def destroy\n @reserve.destroy\n #flash[:notice] = t('reserve.reservation_was_canceled')\n\n if @reserve.manifestation.is_reserved?\n if @reserve.item\n retain = @reserve.item.retain(User.find(1)) # TODO: システムからの送信ユーザの設定\n if retain.nil?\n flash[:message] = t('reserve.this_item_is_not_reserved')\n end\n end\n end\n\n respond_to do |format|\n format.html { redirect_to reserves_url, :notice => t('controller.successfully_deleted', :model => t('activerecord.models.reserve')) }\n format.json { head :no_content }\n end\n end", "def destroy\n item = @item.name\n @item.deleted = true\n @item.deleted_at = Time.now\n @item.save\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: \"#{item} was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy; delete end", "def trash_object(items, waste_container: 'Biohazard Waste')\n set_locations(items, location: waste_container)\n tab = create_location_table(items)\n show do\n title 'Properly Dispose of the following items:'\n table tab\n end\n items.each { |item| item.mark_as_deleted }\n end", "def delete( item )\n LOG.debug \"#{self} is attempting to delete #{item.name} (#{item})\"\n @lock.synchronize do\n @registry.delete( item.name )\n LOG.debug \"Deleted #{item.name} (#{item}) from #{self}.\" \n end\n notify_observers(:delete, item)\n end", "def remove_item(olist, item)\n olist.delete(item) \n olist\nend", "def remove_item(item)\n return unless @items.key? item\n\n @items.delete item\n @version += 1\n end", "def remove!\n self.class.removed(item)\n end", "def destroy\n @item = @client.items.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.html { redirect_to items_url, notice: 'Item was successfully removed from Inventory.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.85387784", "0.789855", "0.71152526", "0.7090574", "0.6851771", "0.68334115", "0.6792848", "0.6687587", "0.66385573", "0.64041644", "0.63915133", "0.6359432", "0.6359343", "0.6342233", "0.63086724", "0.62975305", "0.62655383", "0.62579817", "0.62361425", "0.6233602", "0.62299794", "0.62196136", "0.6210945", "0.6202898", "0.61682045", "0.6166387", "0.61563915", "0.61475897", "0.61279523", "0.61121184", "0.6096569", "0.60953957", "0.60884917", "0.6085487", "0.60438406", "0.60362667", "0.6036005", "0.6024875", "0.6019994", "0.6014988", "0.60136735", "0.6012587", "0.60122234", "0.6005953", "0.6003519", "0.60005504", "0.5997322", "0.59881955", "0.5976113", "0.59719604", "0.5970137", "0.5968579", "0.59630203", "0.594808", "0.5940825", "0.5938964", "0.59386593", "0.5931541", "0.5928193", "0.5916193", "0.5912703", "0.5909111", "0.5905331", "0.58995855", "0.58958066", "0.589562", "0.5884194", "0.5866047", "0.5863143", "0.5858643", "0.5857854", "0.5857292", "0.5853071", "0.5847206", "0.5845988", "0.5838835", "0.58367616", "0.58239454", "0.58092505", "0.580805", "0.58075196", "0.58013725", "0.58009094", "0.5800834", "0.5799935", "0.57991874", "0.5796229", "0.5796007", "0.579383", "0.5791507", "0.57904935", "0.57820904", "0.5777244", "0.5776354", "0.57733804", "0.57728857", "0.5771537", "0.5770728", "0.5767557", "0.57652026" ]
0.8555008
0
deletes chosen item, raises error if trader can not delete item
def delete_item(item_id, log = true) item = Item.by_id(item_id) fail if item.nil? fail unless self.can_delete?(item) item.owner.release_item(item) item.delete ItemDeleteActivity.create(self, item).log if log end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deleted(item)\n end", "def delete_item(item)\n @chores.delete(item)\n end", "def delete_item(item_id)\n raise \"implemented in subclass\"\n end", "def delete(id)\n @item = Item.find_by_id(id)\n \n begin\n item.destroy!\n say 'Item Deleted'\n rescue StandardError => e\n say e.message\n end\n end", "def delete_item(item)\n @get_items.delete(item)\n end", "def delete_item\n\nend", "def item_delete(delete_item)\n @items.delete_if {|e| e.description == delete_item.capitalize}\n conf_message(delete_item, \"removed\")\n end", "def remove_item\n if !@question.many_answers && @item.ok && @question.items.count > 1\n # No more good answer\n # We put one in random to true\n @item.destroy\n @item2 = @question.items.last\n @item2.ok = true\n @item2.save\n flash[:info] = \"Vous avez supprimé une réponse correcte : une autre a été mise correcte à la place par défaut.\"\n else\n @item.destroy\n end\n redirect_to question_manage_items_path(params[:question_id])\n end", "def grocery_item_deleter(grocery_list, item)\n grocery_list.delete(item)\n grocery_list\nend", "def delete_item(item)\r\n @list.delete(item)\r\n end", "def delete_file\n unless $list_Item.curselection.empty?\n idx = $list_Item.curselection\n idx = idx[0]\n $bucket_item = $bucket_items[idx]\n ok_delete = Tk.messageBox('type' => 'okcancel',\n 'icon' => 'warning',\n 'title' => 'Delete Bucket',\n 'message' => 'Delete item?')\n if ok_delete == 'ok'\n begin\n $s3.bucket($bucket).objects(prefix: $bucket_item).batch_delete!\n $item_text.delete('1.0','end')\n $save_file_button.state = 'disabled'\n $delete_file_button.state = 'disabled'\n $item_public_read.state = 'disabled'\n $item_public_write.state = 'disabled'\n rescue => e\n Tk.messageBox('type' => 'ok',\n 'icon' => 'error',\n 'title' => 'Delete File',\n 'message' => \"Cannot Delete File #{e}\")\n end\n end\n end\n end", "def delete\n \t@item = Item.find(params[:id])\n \t@item.destroy\n \tredirect_to :action => 'index'\n\tend", "def delete_item(db, item_name, current_user)\r\n db.execute(\"DELETE FROM items WHERE item_name = ? AND user_id = ?\", [item_name, current_user])\r\nend", "def delete\n\n\t\tloop do\n\t\t\tprint \"\\n\\t\\tEnter product Id: \"\n\t\t\t@choice_delete=gets.to_i\n\t\t\tbreak if @choice_delete>0 and @choice_delete<@count+1\n\t\t\tputs \"\\n\\n\\t\\tInvalid Id!!!...Enter Correct\"\n\t\tend\n\n\t\tprint \"\\n\\n\\tAre you Sure want to delete this item(y/n)?: \" \n\t\toption=gets.chomp\n\n\t\tif option==\"y\" or option==\"Y\"\n\t#delete product from shoping card\n\t\t\t\tstatement7=@connection.prepare(\"delete from inline_products where p_id=? and card_no=?\")\n\t\t\t\tstatement7.execute(@choice_delete,@card_no)\n\t\t\t\tputs \"\\n\\n\\t\\tRecorde successfully deleted....\"\n\t\t#call delete-more method\n\t\t\t\tdelete_more\n\t\telsif option==\"n\" or option==\"N\"\n\t\t\t\tdelete_more\n\t\telse\n\t\t\tputs \"\\n\\n\\t\\tInvalid Choice!!!...Try again\"\n\t\t#call delete method\n\t\t\tdelete\n\t\tend\n\t\t\n\tend", "def destroy\n @item.destroy\n return success_item_destroy\n end", "def remove_item\n\n end", "def delete(item)\n !!@data.delete(item)\n end", "def user_delete_item\n @item = Item.find_by_id(params[:id])\n if @item.auction_flag\n #@auction = Auction.find(@item.auction_id)\n #@auction.destroy\n redirect_to item_path(@item),:notice => \"You can't delete this item, because its auctioned and it has a bidder\"\n\n else\n @item.destroy\n redirect_to(:action => 'user_items_list')\n end\n\n end", "def delete(id)\n item = Item.find(id)\n item.class == Item ? item.delete : item\n end", "def delete(index)\n todo = @items.delete_at(index.to_i-1)\n save\n todo\n end", "def delete\n \n end", "def remove_item\n\tsaved = current_user.saved\n\titem = saved.items.find(params[:item])\n saved.items.delete(item)\n redirect_to :back\n\tend", "def remove_last_item_from_items_collected_at_desk\n $items_collected.delete($items_collected.last)\n# returns user to previous task of choosing item from desk\n desk_options\nend", "def delete_item(list,item)\n list.delete(item)\nend", "def delete_item(list,item)\n list.delete(item)\nend", "def delete(key)\n\t\titem = Item.find(key.to_i)\n\t\titem.delete\n\t\tflash[:danger] = \"Item(s) deleted\"\n\tend", "def delete_item(list,item)\n\tlist.delete(item)\nend", "def delete_item(users)\n print_item(users)\n print \"What is the name of the user you wish to delete their item?\".green\n person = gets.chomp\n users.each do |user|\n if user[:user] == person\n print \"What's the name of the item you wish to delete there partner?\".yellow\n name = gets.chomp\n print \"WARNING!! Are you sure you want to delete it?(y/n)\".red\n confirm = gets.chomp\n if confirm == \"y\"\n user[:item].delete(name) \n puts \"Deleting #{name}...\".red.bold.underline\n else \n puts \"delete aborted!\"\n end\n sleep(2)\n print_item(users)\n end\n end\nend", "def delete_item(list, item)\n list.delete(item)\nend", "def destroy\n item = findItem\n if item.update_column(:trash, \"1\")\n render json: {data:item}, status: :ok\n else\n render json: {data:item}, status: :unprocessable_entity\n end\n end", "def destroy\n\n in_order = OrderItem.find_by(item_id: @item.id)\n\n\n if in_order\n flash[:error] = \"Item cannot be deleted. There is a pending order with this item\"\n # redirect_back (fallback_location: root_path)\n redirect_back(fallback_location: root_path)\n else\n success = @item.destroy\n flash[:success] = \"Item successfully deleted.\"\n redirect_back(fallback_location: root_path)\n end\n\n end", "def delete\n @@all_items.delete(@id)\n end", "def del_item(list, item_to_del)\n list.delete(item_to_del)\nend", "def destroy\n @item.destroy!\n end", "def drop_item\n @order.order_items.find(params[:id]).destroy\n\n refresh\n end", "def deleteItem\n\t\tif @public_id\n\t\t\tCloudinary::Uploader.destroy(@public_id)\n\t\tend\n\tend", "def delete_item(db, id)\n db.execute(\"DELETE FROM todolist WHERE id=?\", [id])\nend", "def delete_item(list,item)\n list.delete(item)\n list\nend", "def delete_item(list,item)\n list.delete(item)\n list\nend", "def delete_item(list, item)\n list.delete(item)\n list\nend", "def delete_item(list, item)\n list.delete(item)\n list\nend", "def delete_item\n puts \"Which item you want to delete? (give the index)\"\n item_to_delete = gets.chomp.to_i\n $list.delete_at(item_to_delete - 1)\nend", "def delete_item\n item_id = params[\"item_id\"]\n\n item = TextItem.find_by_id(item_id)\n item = Image.find_by_id(item_id) if item.nil?\n item = Collection.find_by_id(item_id) if item.nil?\n render_json :status => :not_found, :messages => \"Could not find the item with id #{item_id}.\" and return if item.nil?\n\n if item.class == Collection\n if params[\"id\"].nil?\n render_json :status => :bad_request, :messages => \"Can't delete a collection reference without providing the parent collection id. Please use the longer url for item deletion.\" and return\n end\n collection = Collection.find_by_id(params[\"id\"])\n else\n collection = Ownership.find_by_item_id(item_id).parent\n end\n;\n render_json :status => :not_found, :messages => \"Could not find parent collection for the item.\" and return if (collection.nil?)\n render_json :status => :forbidden, :messages => \"The user is not allowed to delete from this collection.\" and return if (!collection.delete?(@user, @client))\n\n collection.delete_item(item_id)\n render_json :entry => {} and return\n end", "def destroy\n raise \"Permission denied\" if (RemoveItemOrderTask.roles & @permissions).empty?\n OrderItem.transaction do\n item = @order.items.find(params[:id])\n item.destroy\n task_complete({ :data => { :product_id => item.product.id, :item_id => item.id } },\n RemoveItemOrderTask, [RemoveItemOrderTask])\n end\n redirect_to :back\n end", "def delete_item(list, item)\n\tdel_list = list.delete(item)\nend", "def delete(item, list)\n\tlist.delete(item)\nend", "def destroyItem(id)\n item = List.find(id)\n item.destroy\n end", "def delete item_number\n index = item_number - 1\n if index_exists? index, @items\n @items.delete_at index\n else\n raise UdaciListErrors::IndexExceedsListSize, \"List item #{index + 1} does not exist in the UdaciList list\"\n end\n end", "def delete(item)\n if @items.include?(item)\n @items.delete_at(item.id)\n true\n else\n false\n end\n end", "def delete_item(id)\n record \"/todos/delete_item/#{id}\"\n end", "def delete\n \n end", "def delete_item(list, item)\n\tlist.delete(item)\n\tlist\nend", "def destroy\n @rentable_item.destroy\n end", "def destroy\n @pick_item.destroy\n respond_to do |format|\n format.html { redirect_to pick_items_url, notice: '删除成功.' }\n format.json { head :no_content }\n end\n end", "def clear_item(delete_item)\n @items.empty?? conf_message(delete_item, \"does not exist\") : item_delete(delete_item)\n end", "def destroy\n item = @item.name\n @item.deleted = true\n @item.deleted_at = Time.now\n @item.save\n\n respond_to do |format|\n format.html { redirect_to items_url, notice: \"#{item} was successfully deleted.\" }\n format.json { head :no_content }\n end\n end", "def delete_item(list, item)\n del_list = list.delete(item)\nend", "def delete\n end", "def delete_item(barcode)\n\t# open a connection\n\tdb = open_connection\n\tbegin # try to query the database\n\t\tdb.query(\"DELETE FROM #{$db_name}.#{$db_table_name} WHERE Barcode = #{barcode}\")\n\trescue # catch any errors\n\t\tabort \"Unable to delete barcode. Are you sure it exists?\"\n\tend\n\tputs \"Item deleted successfully!\"\nend", "def remove_item(inventory, prompt, categories, search_results, results_printable_array)\r\n \r\n # Asks user to choose which item they'd like to remove\r\n chosen_item = choose_item('light_red', prompt, search_results, results_printable_array)\r\n\r\n # Check if user wants to save changes\r\n remove = prompt.yes?(\"Are you sure you want to remove '#{chosen_item['name'].colorize(:light_red)} from your inventory'?\")\r\n case remove\r\n when true\r\n inventory.delete(chosen_item)\r\n puts \"You have removed #{chosen_item['name']}.\".colorize(:light_red)\r\n when false\r\n puts \"You have not removed #{chosen_item['name']}.\".colorize(:light_green)\r\n end\r\n\r\n end", "def delete_line_item(table)\r\n if table_exists?(table)\r\n print_table(table)\r\n puts \"please choose the id number of the line you'd like to delete.\"\r\n id = get_valid_id(table)\r\n delete = (\"DELETE FROM #{table} WHERE id = #{id}\")\r\n @db.execute(delete)\r\n end\r\n end", "def destroy\r\n @item = Item.find(params[:id])\r\n @item.destroy\r\n redirect_to items_url\r\n end", "def remove_item(item)\n\t$grocery_list.delete(item)\n\tp \"You crossed off #{item} from your list.\"\nend", "def delete_item(grocery_list, item)\ngrocery_list.delete(item)\np grocery_list\n\nend", "def remove_an_item(code_item_to_delete)\n to_do_list.delete_at(code_item_to_delete)\n end", "def destroy\n @item.destroy\n redirect_to items_url, notice: \"This item was removed from the system.\"\n end", "def destroy\n authorize! :edit, @item\n @item.destroy\n redirect_to items_path\n end", "def delete(index)\n if index.between?(1, @items.count)\n @items.delete_at(index - 1)\n else\n raise UdaciListErrors::IndexExceedsListSize,\n \"item '#{index}' does not exist\"\n end\n end", "def delete_item(item)\n unless item.nil?\n @items.delete(item.to_s.downcase)\n end\n @items\n end", "def destroy\n item = Todo.find(params[\"id\"])\n begin\n item.destroy\n redirect_to(:action => \"list\")\n rescue ActiveRecord::ActiveRecordError\n render :text => \"Couldn't destroy item\" \n end\n end", "def brief_vendor_del_item\n brief = Brief.find(params[:brief_id])\n brief_vendor = brief.brief_vendors.find_by_org_id(params[:vendor_id])\n item = brief_vendor.items.find_by_parent_id(params[:item_id])\n\n item.destroy\n\n redirect_to(cheil_brief_vendor_items_url(params[:brief_id],params[:vendor_id])) \n end", "def delete(item, count = 0)\n conn.lrem key, count, item\n end", "def delete_tweet( list_name, owner, author, text, submitted )\n puts \"in delete \" + author + \" \" + list_name + \" \" + text + \" \" + submitted.to_s\n if list_name[0] == 64 # @ we don't want this in list names\n puts(\"Error @ sign in list name. Can't delete someone elses list.\")\n return false\n end\n \n #Created a list but no more items\n if text == \"\"\n #Can't delete if no text. use delete_list\n return false\n end\n \n @list = List.find( :first, \n :conditions => { :name => list_name,\n :owner => owner } )\n if not @list\n #Error can't delete can't find list TODO\n return false\n end\n \n #Check if the item exists, since we assume the messages\n #come in chronological order, we can just break when\n #we find something.\n @item = Item.find( :first,\n :conditions => { :author => author,\n :text => text } ) \n \n if @item == nil and owner == author\n @item = Item.find( :first,\n :conditions => { :text => text } ) \n end\n \n if @item == nil\n @item = Item.find( :first,\n :conditions=> [\"author = ? and text like ?\", author, text + \"%\"] ) \n end\n \n if @item == nil and owner == author\n @item = Item.find( :first,\n :conditions=> [\"text like ?\", text + \"%\"] )\n end\n \n #Clean up this search by using the submit time and the list name or ID TODO\n #TODO really need to check submit time to make sure it's the same message\n if @item\n if @item.deleted\n puts \"error item already deleted\"\n return true\n else\n puts \"deleting item\"\n @item.deleted = true\n @item.save\n return false\n end\n else\n puts \"error can't find item to delete\"\n #Error, can't find the item so don't delete\n end\n \n return false\n end", "def remove\n if @item.quantity == 1\n @item.destroy!\n else\n @item.decrement(:quantity)\n @item.save!\n end\n\n refresh\n end", "def delete_item(list_item)\n @list.delete(list_item)\n @list\n end", "def delete_item(list,item)\n list.delete(item)\n return list\nend", "def delete\n end", "def destroy\n\t\t@item.destroy\n\t\thead :no_content\n\tend", "def destroy\n @trivia_item = Trivia.find(params[:id])\n @trivia_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(trivia_items_url) }\n format.xml { head :ok }\n end\n end", "def delete_from(grocery, item)\n grocery.delete(item)\n grocery\nend", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def destroy\n @itemtipo.destroy\n\n head :no_content\n end", "def destroy\n set_proposed_item\n calculate_saving\n \n\n @proposed_item.destroy\n respond_to do |format|\n format.html { redirect_to @budget, notice: 'Proposed item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete; raise ActiveRecord::ReadOnlyRecord; end", "def destroy\n Todoable.client.delete(path)\n list.items.delete(self)\n true\n end", "def destroy\n @order_item_option = OrderItemOption.find(params[:id])\n @order_item_option.destroy\n\n head :no_content\n end", "def remove_item(id:)\n order.items.destroy(id)\n end", "def delete(index)\n save do\n items.delete_at(index.to_i-1)\n end\n end", "def delete_item (grocery, item_name)\n grocery.delete(item_name)\n display_list(grocery)\n end", "def delete_item(access_token)\n @client.item.remove(access_token)\n end", "def delete\n end", "def destroy\n @item = option_model.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n #@food_item automatically set to FoodItem.find(params[:id])\n\n @food_item.destroy\n\n respond_to do |format|\n if request.xhr?\n format.html { render partial: 'shared/undo_button', locals: {version_id: @food_item.versions.last.id}}\n else\n format.html { redirect_to food_items_url, notice: 'Food item deleted successfully'}\n end\n format.json { head :no_content }\n end\n end", "def test_delete\n ir = ItemRepository.new('./data/items_tiny.csv')\n assert_equal 1367, ir.collection.length\n ir.delete(263396013)\n actual = ir.collection.length\n expected = 1366\n assert_equal expected, actual\n end", "def remove_item(item)\n box.all(\"table tbody tr\")[item].find(\".danger\").click\n end" ]
[ "0.72942626", "0.7277605", "0.71380806", "0.7057933", "0.70311725", "0.7027778", "0.69744664", "0.68943083", "0.6868107", "0.684921", "0.6798211", "0.6694011", "0.6674505", "0.6674079", "0.66614825", "0.66524804", "0.6644929", "0.6620526", "0.6614372", "0.66004586", "0.6589608", "0.65835965", "0.65742934", "0.65687734", "0.65687734", "0.6561347", "0.6534981", "0.6526232", "0.65229034", "0.65188086", "0.65152866", "0.6507649", "0.6501223", "0.649244", "0.6488861", "0.6478385", "0.64594156", "0.6449441", "0.6449441", "0.64343345", "0.64343345", "0.6427468", "0.6412028", "0.64020276", "0.6400588", "0.6399901", "0.6393165", "0.6384443", "0.63809603", "0.6375135", "0.6372821", "0.6362338", "0.6361956", "0.636043", "0.6354698", "0.6353042", "0.634009", "0.63346535", "0.6333845", "0.63289785", "0.63222533", "0.632122", "0.6317779", "0.6317553", "0.63121426", "0.63065606", "0.630546", "0.630032", "0.6288352", "0.62869096", "0.6285483", "0.627794", "0.6275401", "0.626279", "0.62621987", "0.625475", "0.62512547", "0.62468475", "0.6243217", "0.6241294", "0.6240591", "0.6240591", "0.6240591", "0.6240591", "0.6240591", "0.6240591", "0.6240591", "0.6238971", "0.6233948", "0.62325567", "0.6213231", "0.62129766", "0.62116486", "0.6208855", "0.62022674", "0.61985236", "0.6197416", "0.61939526", "0.61879003", "0.6186443", "0.61855555" ]
0.0
-1
confirm a previously prepared purchase
def confirm_purchase(purchase) purchase.confirm end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confirm!\n return false if purchased?\n confirmed!\n end", "def successful_purchase_response\n end", "def confirm!\n confirm_integration product_payload\n variants_payload.each { |key, v| confirm_integration v }\n end", "def confirmation\n @merchant = @current_merchant\n @order = Order.find_by(id: params[:id])\n\n check_merchant\n end", "def confirm!\n no_stock_of = self.order_items.select(&:validate_stock_levels)\n unless no_stock_of.empty?\n raise Shoppe::Errors::InsufficientStockToFulfil, :order => self, :out_of_stock_items => no_stock_of\n end\n \n run_callbacks :confirmation do\n # If we have successfully charged the card (i.e. no exception) we can go ahead and mark this\n # order as 'received' which means it can be accepted by staff.\n self.status = 'received'\n self.received_at = Time.now\n self.save!\n\n self.order_items.each(&:confirm!)\n\n # Send an email to the customer\n deliver_received_order_email\n end\n \n # We're all good.\n true\n end", "def confirm_order\n end", "def purchase\n response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)\n transactions.create!(:action => \"purchase\", :amount => price_in_cents, :response => response)\n #UserMailer.ordered(\"google.com\", response.params.to_s, User.find(cart.user_id), cart).deliver\n cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end", "def confirm\n\n\t\tprint \"\\n\\n\\tAre you Sure want to purchase this product(y/n)?: \" \n\t\t\n\t\toption=gets.chomp\n\n\t\tif option==\"y\" or option==\"Y\"\n\t\t\n\t\tloop do\n\t\t\tprint \"\\n\\n\\t\\tEnter Your Name: \"\n\t#get user name\n\t\t\t@name=gets.chomp\n\t#check validation for name\n\t\tbreak if @name=~ /^[A-Z a-z]+$/ and @name.length>2 and @name.length<31\n\t\t\tputs \"\\n\\n\\t\\tInvalid Name!!!...Enter Correct\"\n\t\tend\n\n\t\tloop do\n\t\t\tprint \"\\n\\n\\t\\tEnter Your Address: \"\n\t#get user address\n\t\t\t@address=gets.chomp\n\t#check validation for address\n\t\tbreak if@address.length>10 and @address.length<51\n\t\t\tputs \"\\n\\n\\t\\tInvalid Address!!!...Enter full Correct address(minimum 10 character)\"\n\t\tend\n\t\t\n\t\tloop do\n\t\t\tprint \"\\n\\n\\t\\tEnter Your Mobile No.: \"\n\t#get mobile number\n\t\t\t@mobile=gets.chomp\n\t#check validation for mobile\n\t\tbreak if @mobile=~ /\\d{10}/ and @mobile.length<11\n\t\t\tputs \"\\n\\n\\t\\tInvalid Mobile No!!!...Enter Correct\"\n\t\tend\n\t#insert values into users \n\t\t\tstatement8=@connection.prepare(\"insert into users values(?,?,?,?)\")\n\t\t\tstatement8.execute(@user_id,@name,@address,@mobile)\n\t\t\t@connection.commit\n\t#call order method\n\t\t\torder\n\t\t\t\n\t\telsif option==\"n\" or option==\"N\"\n\t#call delete_entry method\n\t\t\t\tdelete_entry\n\t\t\t\texit -1\n\t\telse\n\t\t\tputs \"\\n\\n\\t\\tInvalid Choice!!!...Try again\"\n\t#call confirm method\n\t\t\tconfirm\n\t\tend\n\n\tend", "def confirm\n @payment_gateway = @order.payment_gateway_class.new(order: @order)\n if @payment_gateway.collect_payment?\n head :bad_request\n else\n @order.complete!\n head :ok\n end\n end", "def confirm_object(confirmation_datetime)\n return self if not self.confirmable?\n \n self.is_confirmed = true \n self.confirmed_at = confirmation_datetime\n self.save \n \n self.post_confirm_update_stock_mutation\n # self.post_confirm_update_price_mutation \n \n # po_detail =self.purchase_order_detail\n # po_detail.pending_receival -= self.quantity \n po_detail = self.purchase_order_detail \n po_detail.execute_receival( self.quantity ) \n end", "def confirm_all_pending_purchases\r\n self.pending_purchases.each{|purchase| purchase.confirm}\r\n end", "def confirm!\n self.pending = false\n self.save\n self.createDebts\n end", "def confirm\n order = current_order || raise(ActiveRecord::RecordNotFound)\n order.payments.create!(\n {\n source: Spree::PaypalExpressCheckout.create(\n {\n token: params[:token],\n payer_id: params[:PayerID],\n payment_id: params[:paymentId]\n }\n ),\n amount: sprintf(\"%0.02f\", order.total),\n payment_method: payment_method\n }\n )\n order.next\n if order.complete?\n flash.notice = Spree.t(:order_processed_successfully)\n flash[:order_completed] = true\n session[:order_id] = nil\n redirect_to completion_route(order)\n else\n redirect_to checkout_state_path(order.state)\n end\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 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 confirm!\n @@api.post(endpoint: self.endpoint + ['confirm'])\n end", "def confirm\n\n end", "def purchase\n response = process_purchase\n transactions.create!(:action => \"purchase\", :amount => package.reserved_upgrade_price, :response => response)\n if response.success?\n package.paid!\n UserMailer.package_summary(package).deliver\n end\n\n # First part is success (true/false), second error message\n [response.success?, response.params[\"message\"] ]\n end", "def after_purchase(order)\n self.consumed = true\n # send confirmation email to admin and to user, #person.send_email already delays\n notify_admins\n notify_backer\n save!\n\n MixpanelEvent.track(\n person_id: person_id,\n event: 'Create Order',\n checkout_method: order.checkout_method.class.name,\n product: \"team_payin\",\n amount: amount,\n team_id: team.id,\n member: team.person_is_member?(person)\n )\n end", "def confirm_for_fulfillment\n\n\t\t\tresult = PrintfulAPI.request( :POST, \"/orders/#{self.id}/confirm\", {} )\n\n\t\t\tself.load_data( result )\n\n\t\t\treturn true\n\n\t\tend", "def purchase\n begin\n ActiveRecord::Base.transaction do\n @user.coin_credit -= @product.price\n requested_detail = @product.details.available.first\n requested_detail.available = false # makes the detail unavailable\n requested_detail.save!\n @user.save!\n @user.purchased_details << requested_detail # adds the detail to purchased_details of the user\n @purchased_detail = requested_detail\n end\n true\n rescue => e\n Rails.logger.error e\n @user.reload\n @user.errors.add(:base, :purchase_problem)\n false\n end\n end", "def confirm\n # resets sessions to clear the current cart once the order has been confirmed\n session[:order_id] = nil\n end", "def purchase\n purchase = @gateway.purchase(amount, @card, options)\n @result[:message] = purchase.message\n purchase.success?\n end", "def purchase\n response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)\n transactions.create!(:action => \"purchase\", :amount => price_in_cents, :response => response)\n #cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end", "def confirm\n end", "def confirm\n end", "def confirm_payment\n\t\tif @shipping_order.transacted\n\t\t\tredirect_to(:back)\n\t\telse\n\t\t\tif @shipping_order.update(\n\t\t\t\tstatus: 'Started'\n\t\t\t)\n\t\t\t\tconfirm_shipping_payment\n\t\t\telse\n\t\t\t\tflash[:error] = t('errors.messages.not_saved')\n\t\t\t\tredirect_to(:back)\n\t\t\tend\n\t\tend\n\tend", "def update\n purchase = Purchase.find_by(invoice_id: params[:invoice_id])\n if params[:purchase].present? && purchase.update_attributes(purchase_params)\n purchase.confirm!\n PurchaseMailer.confirmed_payment(purchase).deliver_now\n redirect_to checkout_success_path(purchase.invoice_id)\n else\n flash[:alert] = 'Você deve fazer o upload do recibo de pagamento!'\n redirect_to checkout_transfer_path(purchase.invoice_id)\n end\n end", "def update\n purchase = Purchase.find_by(invoice_id: params[:invoice_id])\n if params[:purchase].present? && purchase.update_attributes(purchase_params)\n purchase.confirm!\n PurchaseMailer.confirmed_payment(purchase).deliver_now\n redirect_to checkout_success_path(purchase.invoice_id)\n else\n flash[:alert] = 'Você deve fazer o upload do recibo de pagamento!'\n redirect_to checkout_transfer_path(purchase.invoice_id)\n end\n end", "def return_item\n items = self.see_purchases.map do |merchandise|\n {name: merchandise.name, merch_id: merchandise.id}\n end\n merch = TTY::Prompt.new.select(\"Here is a list of your purchases. What would you like to return?\",items)\n purchase = self.specific_purchase(merch)\n purchase.destroy \n puts \"your item has been refunded!\"\n restock = self.select_merchandise(merch)\n restock.update(inventory: restock.inventory + 1)\n end", "def test_purchase_and_void_for_check\n assert purchase = @gateway.purchase(1000, @check, @options)\n assert_success purchase\n assert_approved purchase\n \n assert void = @gateway.void(purchase.authorization, @options)\n assert_success void\n assert_approved void\n end", "def confirm\n if @account.offload_billing?\n @current_subscription = @account.stripe_subscription.current_subscription\n end\n\n case @service\n when 'vps', 'vps_with_os'\n plan = params[:plan]\n plan_struct = VirtualMachine.plans['vps'][plan]\n\n @billing_amount = plan_struct['mrc']\n @code = 'VPS'\n @code_obj = ServiceCode.find_by(name: @code)\n\n @service_title = if @service == 'vps_with_os'\n VirtualMachine.os_display_name_from_code($CLOUD_OS, params[:os]) + ' VPS'\n else\n 'Generic VM'\n end\n\n @billing_amount_pro_rated = pro_rated_total(@billing_amount)\n\n @stripe_price_id = @account.offload_billing? ? $STRIPE_PRODUCTS['vps'][plan] : \"\"\n\n @pending_service = @account.services.create(\n pending: true,\n service_code: @code_obj,\n title: @service_title,\n billing_interval: 1,\n billing_amount: @billing_amount,\n stripe_price_id: @stripe_price_id\n )\n\n unless @account.offload_billing?\n @pending_invoice = @account.create_pro_rated_invoice!(\n @code, @service_title, @billing_amount_pro_rated, pending: true\n )\n end\n when 'metal'\n raise\n when 'thunder'\n raise\n when 'bgp'\n @billing_amount = 10.00\n @code = 'BANDWIDTH'\n @code_obj = ServiceCode.find_by(name: @code)\n @service_title = \"BGP Session (ASN #{params[:asn]})\"\n @billing_amount_pro_rated = pro_rated_total(@billing_amount)\n\n @stripe_price_id = @account.offload_billing? ? $STRIPE_PRODUCTS['bgp'] : \"\"\n\n @pending_service = @account.services.create(\n pending: true,\n service_code: @code_obj,\n title: @service_title,\n billing_interval: 1,\n billing_amount: @billing_amount,\n stripe_price_id: @stripe_price_id,\n description: \"Pending provisioning by ARP Networks staff.\\n\\nWe thank you for your patience!\"\n )\n\n unless @account.offload_billing?\n @pending_invoice = @account.create_pro_rated_invoice!(\n @code, @service_title, @billing_amount_pro_rated, pending: true\n )\n end\n when 'backup'\n raise\n end\n\n @services = [@pending_service].compact\n @invoices = [@pending_invoice].compact\n\n @enable_pending_view = true\n\n session[:service_to_enable] = @service\n session[:pending_service_ids] = @services.map(&:id)\n session[:pending_invoice_ids] = @invoices.map(&:id)\n end", "def redsys_confirm\n logger.info \"==== REDSYS#CONFIRM ==== order##{params[:order_id]} params# #{params.inspect}\"\n @order ||= Spree::Order.find_by_number!(params[:order_id])\n if check_signature\n unless @order.payments.any?(&:completed?)\n payment_upgrade\n @order.updater.update_payment_total\n end\n @order.next\n if @order.completed?\n flash.notice = Spree.t(:order_processed_successfully)\n flash[:order_completed] = true\n session[:order_id] = nil\n redirect_to completion_route(@order)\n else\n flash[:error] = @order.errors.full_messages.join(\"\\n\")\n redirect_to checkout_state_path(@order.state) and return\n end\n else\n flash[:alert] = Spree.t(:spree_gateway_error_flash_for_checkout)\n redirect_to checkout_state_path(@order.state)\n end\n end", "def test_purchase_successful\n response = @gateway.setup_purchase(100, @options)\n\n assert_success response\n\n assert_equal '1234567890123456', response.transaction['purchaseID']\n assert_equal '0020', response.params['AcquirerTrxRes']['Acquirer']['acquirerID']\n assert_not_nil response.service_url, \"Response should contain a service url for payment\"\n\n # now authorize the payment, issuer simulator has completed the payment\n response = @gateway.capture(response.transaction['transactionID'])\n\n assert_success response\n assert_equal 'Success', response.transaction['status']\n assert_equal 'DEN HAAG', response.transaction['consumerCity']\n assert_equal \"Hr J A T Verf\\303\\274rth en/of Mw T V Chet\", response.transaction['consumerName']\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 send messages\"\n redirect_to user_conversations_path(current_user.id)\n else\n flash[:error] = \"Your payment was not success. Check your card information.\"\n redirect_to user_conversations_path(current_user.id)\n end\n rescue\n flash[:error] = \"Your payment was not success. Check your card information.\"\n redirect_to user_conversations_path(current_user.id)\n end\n end", "def purchase\n #@cart = Cart.find(self.cart_id)\n #cart.update_attribute(:purchased_at, Time.now)\n if cart.tip && cart.tip > 0\n @amount = price_in_cents + tax_in_cents + tip_in_cents\n else\n @amount = price_in_cents + tax_in_cents\n end\n @transaction = transactions.first\n #response = GATEWAY.purchase((price_in_cents + tax_in_cents), credit_card,\n # purchase_options)\n\n response = GATEWAY.capture((@amount), @transaction.authorization)\n @transaction.update_attributes(:action => \"capture\",\n :amount => (@amount), :response => response)\n\n #cart.update_attribute(:purchased_at, Time.now) if response.success?\n # SWITCH TO ABOVE WHEN LIVE.\n ######## remove when live. ########\n #GATEWAY.void(response.authorization, purchase_options)\n ## uncomment when live\n response.success?\n end", "def test_successful_purchase\n skip\n @gateway.expects(:ssl_post).returns(successful_purchase_response)\n\n assert response = @gateway.purchase(@amount, @credit_card, @options)\n assert_instance_of\n assert_success response\n\n # Replace with authorization number from the successful response\n assert_equal '', response.authorization\n assert response.test?\n end", "def purchase\n\n response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)\n \n #create_card_transaction(action: \"purchase\", amount: price_in_cents, response: response)\n \n #@registration.update_attribute(:purchased_at, Time.now) if response.success?\n #response.success?\n end", "def paid\n\t\tif params[:confirm].to_i == 1\n\t\t\tif @order.armor_enabled?\n\t\t\t\t@order.api_testing_set_to_paid\n\t\t\telse #is a prepay order\n\t\t\t\t@order.prepay_mark_as_paid\n\t\t\tend\n\t\t\tif @order.errors.any?\n\t\t\t\tflash.now[:notice] = @order.errors.full_messages\n\t\t\telse\n\t\t\t\t@success = true\n\t\t\t\tsleep(5) if @order.armor_enabled? #pause to allow update of status from webhook if armor\n\t\t\tend\n\t\tend\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to order_url(@order) }\n\t\t\tformat.js\n\t\tend\n\tend", "def confirm\n # quantity picked by user.\n quantity = params['quantity']\n\n new_order_id = nil\n\n # when order owner require more quantity than the user ability\n if @order.quantity.to_i > quantity.to_i\n new_order = current_user.orders.new(owner: @order.owner, quantity: quantity, status: 'in_progress')\n\n new_order_id = new_order.id if new_order.save\n\n @order.update(quantity: @order.quantity - quantity.to_i, status: 'pending')\n else\n @order.update(status: 'in_progress')\n end\n\n # return the newly created order id, otherwise return the original order id\n render json: {id: new_order_id || @order.id}, status: :ok\n end", "def confirm\n @order = Order.new(params[:order])\n session[:order]= params[:order]\n @companyIdToSell = params[:companyIdToSell] if params[:companyIdToSell] \n @user = User.find(current_user.id)\n unless @order.valid?\n render :action => 'new'\n end\n# flash[:notice] = \"Card information invalid!!\"\n end", "def express_checkout_complete \n paypal_token = params[:token] \n @prize = Prize.find_by_paypal_token(paypal_token, :conditions => [\"paypal_state = 'purchase_setup'\"]) \n @details = gateway.details_for(paypal_token) \n \n if !@details.success?\n #paypal has reported error back to our system\n paypal_error(@details) \n else \n \n #might want to add to debug\n logger.info \"Customer name: #{@details.params['name']}\" \n logger.info \"Customer e-mail: #{@details.params['payer']}\" \n \n @response = gateway.purchase( \n amount_in_cents(@prize.paypal_prizecost), \n :token => @details.params['token'], \n :payer_id => @details.params['payer_id'] \n )\n \n if !@response.success? \n paypal_error(@response) \n else \n @prize.update_attributes(\n :paypal_state => 'closed',\n :paypal_amount => @response.params['gross_amount'] \n ) \n \n #send to prize confirmation page \n end #!@response.success? \n end #!@details.success?\nend", "def after_confirmation\n Transfer.create(\n receiver: self,\n amount: 1_000.0,\n source_currency: 'USD',\n target_currency: 'USD',\n exchange_rate: 1.0,\n status: Transfer::SUCCESS\n )\n super\n end", "def success\n authorize! :view_sofort_thankyou_page, @order\n @address = @order.address\n @product = @order.product.decorate\n return render 'signup/orders/show' if @order.confirmed?\n transaction = ::Sofort::FinishTransaction.new(@order)\n transaction.run do\n @order.status = :paid\n @order.confirm\n return render 'signup/orders/show'\n end\n # customer opens success-page, but transaction is not complete\n flash.now[:notice] = t(:transaction_no_confirmation)\n render 'signup/orders/show'\n end", "def purchase\n\t\t\n\t\tif self.inventory >= 1\n\t\t\t#reduce inventory by 1 then save to db\n\t\t\tself.inventory = self.inventory - 1\n\t\t\tself.save\n\t\t\t#successful purchase, return true\n\t\t\tself.show\n\t\t\treturn true\n\t\tend\n\t\t\n\t\t#unsuccessful purchase, return false\n\t\treturn false\n\tend", "def paypal_confirm\n @token, @payer_id = params[:token], params[:PayerID]\n if @token and @payer_id\n @details = EXPRESS_GATEWAY.details_for(@token)\n\n if @details.success?\n @address = \"#{@details.address['company']} #{@details.address['address1']} #{@details.address['address2']} #{@details.address['city']} #{@details.address['state']} #{@details.address['zip']} #{@details.address['country']}\"\n @cart.update_attributes! :name => @details.name,\n :address => @address,\n :email => @details.email,\n :phone => @details.contact_phone,\n :instructions => @details.message\n else\n flash[:error] = \"could not perform EXPRESS_GATEWAY.details\"\n redirect_to :controller=>:store, :action=>:error\n end\n else\n flash[:error] = \"could not find token or payer id\"\n redirect_to :controller=>:store, :action=>:error\n end\n end", "def failed_purchase_response\n end", "def thank_you\n user = session[:user]\n user.zip = params[:zip]\n \n start_date = Date.today\n start_date += 61\n \n response = create_autorrecuring_subscription(start_date, user, params[:card_number], params[:month], params[:year], \n params[:cvc], params[:card_type], params[:city], params[:state],\n params[:billing_address_1], params[:billing_address_2])\n if response.success?\n session[:errors] = nil\n session[:user] = nil\n user.arb_subscription_id = response.subscription_id\n user.arb_status = AuthorizeNet::ARB::Subscription::Status::ACTIVE\n user.billing_information_id = user.add_billing_information(params[:fullname], params[:billing_address_1] ,\n params[:billing_address_2], params[:city], params[:state],\n params[:zip]).id\n user.save\n else\n puts \"Failed to make purchase. \" + response.response_reason_code + \" - \" + response.response_reason_text\n user.errors.clear()\n user.errors.add(:transaction, response.response_reason_text)\n session[:errors] = user.errors\n redirect_to admin_signup_step3_path\n end \n\n \n end", "def purchase_one\n product = Product.find(params[:id])\n company = Company.first\n if product[:inventory_count] > 0\n if product.decrement!(:inventory_count)\n total = company[:money] + product[:price]\n\n company.update_!(money: total)\n render json: {\n status: :ok,\n message: 'Successfully bought'\n }.to_json\n else\n render json: {\n status: :internal_server_error,\n message: 'Error purchasing product'\n }\n end\n else\n render json: {\n status: :ok,\n message: 'Item is no longer available'\n } \n end\n end", "def attemp_buying\n\n end", "def confirm\n \tGoCardless.confirm_resource params\n \trender \"gocardless/success\"\nrescue GoCardless::ApiError => e\n \trender :text => \"Could not confirm new subscription. Details: #{e}\"\nend", "def test_successful_purchase_with_emv_credit_card_in_us\n assert response = @gateway.purchase(@amount, @emv_credit_cards[:us], @options)\n assert_success response\n assert_equal 'charge', response.params['object']\n assert response.params['paid']\n assert_match CHARGE_ID_REGEX, response.authorization\n end", "def purchased # Thank You!\n @order = if params[:id].present?\n Effective::Order.find(params[:id])\n elsif current_user.present?\n Effective::Order.purchased_by(current_user).first\n end\n\n if @order.blank?\n redirect_to(effective_orders.my_purchases_orders_path) and return\n end\n\n EffectiveOrders.authorized?(self, :show, @order)\n\n redirect_to(effective_orders.order_path(@order)) unless @order.purchased?\n end", "def resend_confirmation_instructions; end", "def final_confirmation\n if session[:all_free_shipping]\n carrier = \"Free Shipping\"\n method = \"Free Shipping\"\n else\n order_id = params[:order][:id]\n carrier = params[:order][:carrier]\n method = params[:order][:shipping_method]\n end\n\n coupon_code = session[:coupon]\n\n @cart = find_cart\n @order = session[:order]\n\n @order.set_freight_ship_to session[:ship_to]\n @order.set_freight_options session\n\n if valid_coupon_code?(coupon_code, @order.totalize_items)\n @order.coupon = coupon_code\n end\n\n @order.carrier = carrier\n @order.taxes = round(@cart.totalize_products * state_tax(@order.billing_state)).to_f\n @order.shipping_method = shipping_method(method)\n @order.shipping_approx = shipping_approx(@order.carrier, method)\n session[:order] = @order\n end", "def order_confirmation (user, cart, product, customer, pickup)\n @user = user\n @cart = cart\n @product = product\n @customer = customer\n @pickup = pickup\n\n mail to: user.email, subject: \"A new order has been placed\"\n end", "def purchase(_money, _credit_card, _options = {})\n ActiveMerchant::Billing::Response.new(true, 'PayUIn Gateway: Forced success', {}, test: test?)\n end", "def test_reference_purchase\n assert response = @gateway.purchase(10000, @credit_card, @options)\n assert_approved response\n assert_success response\n assert response.test?\n assert_not_nil pn_ref = response.authorization\n \n # now another purchase, by reference\n assert response = @gateway.purchase(10000, pn_ref)\n assert_approved response\n assert_success response\n assert response.test?\n end", "def external_unconfirm\n if not self.transaction_source_id.nil? \n self.errors.add(:generic_errors, \"Can't modify the automated generated transaction\")\n return self \n end\n \n self.is_confirmed = false \n if self.save\n self.update_affected_accounts_due_to_un_confirmation\n end\n end", "def paypal_success\n @token, @payer_id = params[:token], params[:payer_id]\n if request.post? and @token and @payer_id\n @result = EXPRESS_GATEWAY.purchase(cart.total_cents, {:ip => request.remote_ip, :token => @token, :payer_id => @payer_id})\n if @result.success?\n @cart.source = :paypal\n send_emails\n mark_completed :forget => true\n render :action => \"success\" \n else\n flash[:error] = \"could not perform EXPRESS_GATEWAY.purchase\"\n redirect_to :controller=>:store, :action=>:error\n end\n else\n flash[:error] = \"could not find token or payer id\"\n redirect_to :controller=>:store, :action=>:error\n end\n end", "def confirm_account\n confirm\n end", "def after_redeem() end", "def confirm\n elements=CartItem.where(:cart_id=>current_user.cart.id)\n\n # if there are no items in the cart, the order will not be placed\n if elements.length==0\n redirect_to carts_path, :notice => \"EMPTY CART!!!\"\n end\n\n # Checks to see if any item in the cart is low in stock. If so, abort. If not, update the sales, and stock quantity of the items\n out_of_stock_items=Item.check_validity(elements)\n\n # This actually checks if any items are below stock\n if out_of_stock_items.length!=0\n redirect_to carts_path, :notice => Item.show_low_stock_message(out_of_stock_items)\n else\n # Save the changes in sales and stocks.\n Item.save_sales(elements)\n #after all the validations are processed, the pre-place order view will be rendered\n @item_list=CartItem.where(:cart_id => current_user.cart.id)\n end\n end", "def return\n notify = ActiveMerchant::Billing::Integrations::Paypal::Notification.new(request.raw_post)\n @order = ::Order.find_by_number(notify.item_id)\n if notify.acknowledge\n begin\n redirect_to thank_you_order_url(@order)\n rescue => e\n redirect_to '/'\n end\n end\n end", "def test_successful_purchase_with_emv_credit_card_in_uk\n assert response = @gateway.purchase(@amount, @emv_credit_cards[:uk], @options)\n assert_success response\n assert_equal 'charge', response.params['object']\n assert response.params['paid']\n assert_match CHARGE_ID_REGEX, response.authorization\n end", "def confirm_finaldelivery\n @con=Packages.confirm_finaldelivery(cookies[:user_id])\n end", "def confirm\n DB.session do |db|\n self.executed = true\n save\n end\n end", "def test_purchase_and_credit_for_check_with_differing_amounts\n assert purchase = @gateway.purchase(10000, @check, @options)\n assert_success purchase\n assert_approved purchase\n \n assert void = @gateway.credit(500, purchase.authorization, @options)\n assert_success void\n assert_not_equal 'Approved', void.message\n end", "def purchase\r\n redirect_to \"http://www.1shoppingcart.com/app/javanof.asp?MerchantID=31593&ProductID=3257357\"\r\n end", "def sell_confirmed\n end", "def test_purchase_cancel\n response = @gateway.setup_purchase(200, @options)\n\n assert_success response\n # now try to authorize the payment, issuer simulator has cancelled the payment\n response = @gateway.capture(response.transaction['transactionID'])\n\n assert_failure response\n assert_equal 'Cancelled', response.transaction['status'], 'Transaction should cancel'\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 confirmation\n end", "def purchase_events_new_card_couple\n token = params[:stripeToken]\n @number = params[:number].to_i\n coupon = params[:coupon]\n cost = params[:cost]\n\n if update_card_and_purchase(token, @number, cost, coupon)\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n # if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n # end \n flash[:success] = \"Thank you! You have purchased #{@number} VoiceGems Pages.\"\n redirect_to current_user\n else\n redirect_to existing_couple_purchase_select_path({:peu => {:number => @number }, :coupon => coupon})\n end \nend", "def complete_paypal(token, payer_id)\n response = payment_method.paypal.purchase(total_amount_in_cents, {:token => token, :payer_id => payer_id, :description => description, :currency => self.currency})\n transaction_gid = response.params['transaction_id']\n options = { operation: 'purchase',\n params: response.params,\n success: response.success?,\n data: {},\n transaction_gid: transaction_gid }\n self.payment_transactions.create!(options)\n\n if response.success?\n if response.params['payment_status'] == 'Completed'\n self.purchase\n self.amount = response.params['gross_amount'].to_f - response.params['fee_amount'].to_f - response.params['tax_amount'].to_f\n save\n end\n else\n errors.add(:payment_method, \"PayPal Error: #{response.message}\")\n false\n end\n end", "def amazon_postfill\n unless params[:callerReference].blank?\n @order = Order.postfill!(params)\n end\n # \"A\" means the user cancelled the preorder before clicking \"Confirm\" on Amazon Payments.\n if params['status'] != 'A' && @order.present?\n redirect_to :action => :share, :uuid => @order.uuid\n else\n redirect_to root_url\n end\n end", "def checkout\n response = @payment.setup_purchase(:ip => request.remote_ip,\n :description => \"Donation\",\n :return_url => confirm_paypal_url(@payment),\n :cancel_return_url => paymentform_url,\n :no_shipping => 1,\n :items => [{ :name => \"Donation to #{@cause.name}\",\n :number => 1,\n :quantity => 1,\n :amount => @payment.amount * 100 }])\n redirect_to @payment.redirect_url_for(response.token)\n end", "def join_purchase\n @purchase_response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)\n @purchase_response.success?\n end", "def purchase(total)\n @price_in_cents = total\n response = process_purchase\n transactions.create!(:action => \"purchase\", :amount =>@price_in_cents, :response => response)\n #cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end", "def test_successful_purchase_without_account_set_up_and_repeat_payments\n response = @gateway.purchase(@amount, @mastercard, @params)\n assert_success response\n assert response.authorization.to_s.split(';')[2].blank?\n end", "def test_successful_purchase_and_declined_cancellation_anda\n omit\n credit_card = credit_card('6031998427187914', month: '12', year: '2024',\n verification_value: '111', first_name: 'Santiago', last_name: 'Navatta')\n\n purchase = @gateway.purchase(@amount, credit_card, @options)\n assert_success purchase\n\n assert void = @gateway.void(purchase.authorization, @cancel_options)\n assert_failure void\n end", "def confirm_receieved(shipment)\n open_shipment(shipment)\n confirm_received.click\n confirm.click\n end", "def paypal\n if params[:token]\n if @subscription.complete_paypal(params[:token])\n if admin_user_pending?\n redirect_to activate_path(@user.activation_code)\n else\n flash[:notice] = 'Your billing information has been updated'\n redirect_to :action => \"billing\"\n end\n else\n render :action => 'billing'\n end\n else\n redirect_to :action => \"billing\"\n end\n end", "def purchase\n if express_token.include?(\"paykey=AP\")\n\n else\n\n #processes payment for express payment and on site with credit card.\n response = process_purchase\n #creates a transaction to store info from express payment and paywith Credit card\n transactions.create!(:action => \"purchase\", :amount => price_in_cents, :response => response)\n #cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end\n end", "def buyer_confirmed\n end", "def purchase_action\n # from cart\n if params[:product_id] == '0'\n @items = session[:cart]\n @purchase = Purchase.new(bill_address_id: params[:bill_address_id], ip: IPAddr.new(request.remote_ip).to_i)\n @purchase.save\n @items.each do |item|\n @purchase_products = PurchaseProduct.new(purchase_id: @purchase.id, product_id: item['product'], quantity: item['quantity'])\n @purchase_products.save\n stock_minus(item['product'], item['quantity'])\n end\n # via product page\n else\n @purchase = Purchase.new(bill_address_id: params[:bill_address_id], ip: IPAddr.new(request.remote_ip).to_i)\n if @purchase.save\n @purchase_products = PurchaseProduct.new(purchase_id: @purchase.id, product_id: params[:product_id], quantity: session[:quantity])\n @purchase_products.save\n stock_minus(params[:product_id], session[:quantity])\n else\n render 'purchase_show'\n end\n end\n # Send email\n UserMailer.purchase_email(@purchase).deliver\n session[:purchased_item] = params[:product_id]\n redirect_to purchase_success_path\n end", "def confirm_delivery\n @delivery = Delivery.find_by_id params[:delivery_id]\n # add some defensive programming.. current user has role admin, and current_user is indeed belongs to the company \n @delivery.confirm( current_user ) \n @delivery.reload\n end", "def paypal_return\r\n user_id = params[:user_id]\r\n @user = User.find(user_id)\r\n session[:user_id] = @user[:id]\r\n session[:user_email] = @user[:email]\r\n #render :text => params \r\n if Purchase.exists?(params[:id])\r\n redirect_to(:action=>'order_confirmed/'+params[:id].to_s)\r\n else\r\n flash[:notice] = I18n.t 'event.purchase.pur_can'\r\n redirect_to(:controller => 'home', :action=>'index') \r\n end \r\n end", "def confirmation\n key = request.headers[\"Authorization\"]\n format_token(key)\n\n @pet = Pet.find_by(api_key: key)\n @request = Request.find_by(pet_id: @pet.id)\n\n if params[\"request\"] == \"success\"\n @request.update(body: nil, schedule: nil)\n\n add_feeding(@pet)\n\n update_current_supply(@pet)\n end\n\n render :nothing => true\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 confirm_checkout\n system 'clear'\n CoffeeMan.stay_logo\n choice = self.prompt.select(\"Are you done\") do |menu|\n menu.choice \"Yes\", -> {checkout}\n menu.choice \"No\", -> {view_cart}\n end\n end", "def confirm_checkout\n lineItems = LineItem.find_all_by_user_id(current_user.id)\n if(lineItems)\n @transaction = Transaction.create(:buyer_id => current_user.id)\n user = current_user\n baddress = params[:address]\n bzipcode = params[:zipcode]\n if(!baddress || !bzipcode || baddress.length <=0 || bzipcode.length <=0)\n redirect_to cart_checkout_path, :notice => 'Please enter the address' #TODO: This notice should appear on page\n elsif (!params[:card][:user_id] || params[:card][:user_id].length<=0)\n redirect_to cart_checkout_path, :notice => 'Please select a credit card for payment'\n else\n if(params[:saddress] && params[:szipcode] && params[:saddress].length>0 && params[:szipcode].length == 5 )\n @saddress = params[:saddress]\n @szipcode = params[:szipcode]\n else\n @saddress= baddress\n @szipcode = bzipcode\n end\n\n\n @confirmed_items = \"\"\n @unavailable_items = \"\"\n @orders = []\n if @transaction.save\n lineItems.each do |lineItem|\n if(lineItem.line_item_type==9)\n order = Order.new\n item = Item.find(lineItem.item_id)\n auction = Auction.find_by_id(lineItem.auction_id)\n if(auction.state==1)\n auction.update_attribute(:state,2)\n order.billing_address = baddress + bzipcode\n order.shipping_address = @saddress + @szipcode\n order.item_quantity = lineItem.quantity\n order.price = Auction.find_by_item_id(lineItem.item_id).bid_amount\n order.total_price = Auction.find_by_item_id(lineItem.item_id).bid_amount * lineItem.quantity\n order.transaction_id = @transaction.id\n order.seller_id = item.user_id\n order.buyer_id = current_user.id\n order.item_id = item.id\n order.state = 0\n\n if(!order.save)\n redirect_to \"back\", :notice => \"Error creating order, or contact administrator with this message\"\n else\n @orders.push(order)\n @confirmed_items = @confirmed_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n NotifyUser.order_confirmation(user,@confirmed_items,@orders).deliver\n lineItem.destroy\n end\n end\n\n end\n\n\n if(lineItem.line_item_type==0)\n order = Order.new\n item = Item.find(lineItem.item_id)\n if(lineItem.quantity<=item.availability)\n order.billing_address = baddress + bzipcode\n order.shipping_address = @saddress + @szipcode\n order.item_quantity = lineItem.quantity\n order.price = item.price\n order.total_price = Float(item.price) * lineItem.quantity\n order.transaction_id = @transaction.id\n order.seller_id = item.user_id\n order.buyer_id = current_user.id\n order.item_id = item.id\n order.state = 0\n\n if(order.save)\n item.sold_count += lineItem.quantity\n item.availability -= lineItem.quantity\n item.save\n @orders.push(order)\n @confirmed_items = @confirmed_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n NotifyUser.order_confirmation(user,@confirmed_items,@orders).deliver\n lineItem.destroy\n else\n redirect_to :back, :notice => \"Error creating order, verify your inputs or contact administrator with this message\"\n end\n else\n @unavailable_items = @unavailable_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n end\n end\n end\n end\n end\n #redirect_to :action => 'index', :controller => 'orders'\n else\n redirect_to :back, :notice => 'Unknown processing error. Please verify your orders' #TODO: Cart screen\n end\n end", "def handle_purchase\n if saved_change_to_state == %w(draft purchased)\n seller.increase_balance(payment.amount)\n end\n end", "def test_purchase_and_credit_for_check\n assert purchase = @gateway.purchase(1000, @check, @options)\n assert_success purchase\n assert_approved purchase\n \n assert void = @gateway.credit(1000, purchase.authorization, @options)\n assert_success void\n assert_approved void\n end", "def confirm_transaction_message(transaction)\n return unless transaction.instance_of?(Transaction)\n\n if transaction.seller_confirmed && transaction.buyer_confirmed?\n 'Transaction successful!'\n else\n 'Please wait for the other party to confirm transaction.'\n end\n end", "def call!\n verify!\n if valid?\n CandyCheck::PlayStore::ProductPurchases::ProductPurchase.new(@response[:result])\n else\n CandyCheck::PlayStore::VerificationFailure.new(@response[:error])\n end\n end", "def do_purchase\n user.purchases.create!(\n amount_in_cents: purchase_amount,\n employee_id: purchase_params.dig(:employee_id),\n qty: purchase_params.dig(:qty).to_i,\n venue_id: purchase_params.dig(:venue_id),\n tap_id: purchase_params.dig(:tap_id),\n description: purchase_params.dig(:description)\n )\n end", "def activate\n \n @event = Event.find(params[:act][:event_id])\n @event.purchase_type = 'p'\n @event.save\n\n current_user.decrement(:purchased_events)\n current_user.save\n\n redirect_to @event, notice: \"Thank you for activating the Event Page for #{@event.title}. You will now have permanent access to this page.\"\n\nend", "def before_submit_purchased!\n end", "def confirm\n @order.confirm_notes = params[:order][:confirm_notes]\n @order.approx_cost = (@order.approx_cost.to_f * 100.0).floor\n @order.confirm\n \n if @order.confirm_notes.present? \n OrderNote.create(:message => @order.confirm_notes, :order_id => @order.id, :author_id => @order.assigned_to.id) rescue nil \n end\n\n @order.approx_cost = (@order.approx_cost.to_f / 100.0).floor\n \n render 'status'\n end" ]
[ "0.80120355", "0.71839976", "0.7034328", "0.69552207", "0.69417167", "0.6840967", "0.68290037", "0.68160766", "0.67721665", "0.67500556", "0.67412174", "0.67292356", "0.6726638", "0.67259914", "0.66930574", "0.666647", "0.662746", "0.6584693", "0.65668005", "0.65359044", "0.6531388", "0.6528035", "0.64911985", "0.6474291", "0.6454053", "0.6454053", "0.6431154", "0.64084166", "0.64084166", "0.63918614", "0.63868105", "0.6360303", "0.63437986", "0.633668", "0.63287044", "0.6323111", "0.6312454", "0.6296513", "0.6295516", "0.6283225", "0.6282028", "0.6276283", "0.6274434", "0.6273471", "0.62703836", "0.62686884", "0.6267502", "0.62646633", "0.62519574", "0.623929", "0.62293583", "0.62197", "0.6216291", "0.62109804", "0.6208488", "0.62061673", "0.6197722", "0.61947477", "0.61806923", "0.6176969", "0.617369", "0.61672515", "0.61609584", "0.61609375", "0.61531806", "0.6147761", "0.6142889", "0.6140318", "0.6139918", "0.61388206", "0.61348647", "0.6129056", "0.61231303", "0.6122929", "0.6117228", "0.6113816", "0.6112273", "0.6109935", "0.6100793", "0.6098157", "0.60962796", "0.6095305", "0.6094832", "0.6082804", "0.6076093", "0.6063791", "0.6054598", "0.6047742", "0.6045579", "0.6044836", "0.60281175", "0.602378", "0.60185254", "0.60134995", "0.6009984", "0.60097224", "0.5999836", "0.5987493", "0.59867996", "0.59846526" ]
0.8436574
0
confirms all pending purchases
def confirm_all_pending_purchases self.pending_purchases.each{|purchase| purchase.confirm} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def confirm!\n self.pending = false\n self.save\n self.createDebts\n end", "def confirm_purchase(purchase)\r\n purchase.confirm\r\n end", "def confirm!\n return false if purchased?\n confirmed!\n end", "def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end", "def confirm!\n no_stock_of = self.order_items.select(&:validate_stock_levels)\n unless no_stock_of.empty?\n raise Shoppe::Errors::InsufficientStockToFulfil, :order => self, :out_of_stock_items => no_stock_of\n end\n \n run_callbacks :confirmation do\n # If we have successfully charged the card (i.e. no exception) we can go ahead and mark this\n # order as 'received' which means it can be accepted by staff.\n self.status = 'received'\n self.received_at = Time.now\n self.save!\n\n self.order_items.each(&:confirm!)\n\n # Send an email to the customer\n deliver_received_order_email\n end\n \n # We're all good.\n true\n end", "def pending!(purchase)\n post(purchase, \"#{collection_path}/pending\")\n end", "def pending!(purchase)\n post(purchase, \"#{collection_path}/pending\")\n end", "def confirm!\n confirm_integration product_payload\n variants_payload.each { |key, v| confirm_integration v }\n end", "def confirm_order\n end", "def delete_pending(purchase)\r\n self.pending_purchases.delete(purchase)\r\n end", "def confirm\n\n\t\tprint \"\\n\\n\\tAre you Sure want to purchase this product(y/n)?: \" \n\t\t\n\t\toption=gets.chomp\n\n\t\tif option==\"y\" or option==\"Y\"\n\t\t\n\t\tloop do\n\t\t\tprint \"\\n\\n\\t\\tEnter Your Name: \"\n\t#get user name\n\t\t\t@name=gets.chomp\n\t#check validation for name\n\t\tbreak if @name=~ /^[A-Z a-z]+$/ and @name.length>2 and @name.length<31\n\t\t\tputs \"\\n\\n\\t\\tInvalid Name!!!...Enter Correct\"\n\t\tend\n\n\t\tloop do\n\t\t\tprint \"\\n\\n\\t\\tEnter Your Address: \"\n\t#get user address\n\t\t\t@address=gets.chomp\n\t#check validation for address\n\t\tbreak if@address.length>10 and @address.length<51\n\t\t\tputs \"\\n\\n\\t\\tInvalid Address!!!...Enter full Correct address(minimum 10 character)\"\n\t\tend\n\t\t\n\t\tloop do\n\t\t\tprint \"\\n\\n\\t\\tEnter Your Mobile No.: \"\n\t#get mobile number\n\t\t\t@mobile=gets.chomp\n\t#check validation for mobile\n\t\tbreak if @mobile=~ /\\d{10}/ and @mobile.length<11\n\t\t\tputs \"\\n\\n\\t\\tInvalid Mobile No!!!...Enter Correct\"\n\t\tend\n\t#insert values into users \n\t\t\tstatement8=@connection.prepare(\"insert into users values(?,?,?,?)\")\n\t\t\tstatement8.execute(@user_id,@name,@address,@mobile)\n\t\t\t@connection.commit\n\t#call order method\n\t\t\torder\n\t\t\t\n\t\telsif option==\"n\" or option==\"N\"\n\t#call delete_entry method\n\t\t\t\tdelete_entry\n\t\t\t\texit -1\n\t\telse\n\t\t\tputs \"\\n\\n\\t\\tInvalid Choice!!!...Try again\"\n\t#call confirm method\n\t\t\tconfirm\n\t\tend\n\n\tend", "def resend_confirmation_instructions\n pending_any_confirmation do\n send_confirmation_instructions\n end\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 confirm_finaldelivery\n @con=Packages.confirm_finaldelivery(cookies[:user_id])\n end", "def confirm_order\n @check = Ticket.where(table: session[:table_id]).last\n if @check.nil?\n puts(\"ticket not created yet!\")\n return\n end\n @items = OrderItem.where(:ticket_id => @check.id)\n @check.update(:subtotal => 0)\n\t # Add item totals\n\t comp = 0\n @items.each do |orderItem|\n menu_item = Menuitem.find_by(id: orderItem.item)\n @check.update(:subtotal => (@check.subtotal + menu_item.price))\n\t\tunless orderItem.compitem.nil?\n\t\t\tcomp = comp + orderItem.compitem.amount\n\t\tend\n end\n\n\t \n\t # check reward points\n\t if current_guestaccount\n\t\t # check points\n\t\t if current_guestaccount.points > 4\n\t\t\t @check.update(:subtotal => (@check.subtotal - 10.00))\n\t\t\t @check.update(:points => true)\n\t\t end\n\t\t # check birthday\n\t\t if (current_guestaccount.birthday.month == Time.now.month &&\n\t\t\t current_guestaccount.birthday.day == Time.now.day)\n\t\t\t @check.update(:birthday => true)\n\t\t end\n\t end\n\t \n\t # check birthday discount\n\t if @check.birthday\n\t\t @check.update(:subtotal => (@check.subtotal - 10.00))\n\t end\n\t \n\t # check coupon\n\t if @check.coupon\n\t\t @check.update(:subtotal => (@check.subtotal - 10.00))\n\t end\n\n\t #adjust subtotal for comp\n\t @check.update(:subtotal => (@check.subtotal - comp))\n unless @check.compticket.nil? \n @check.update(:subtotal => (@check.subtotal - @check.compticket.amount))\n end\n\n\t # subtotal cannot be negative\n\t if @check.subtotal < 0\n\t\t @check.update(:subtotal => 0)\n\t end\n\n\t # calculate tax\n\t @check.update(:tax => (@check.subtotal * 0.0825))\n\t \n\t unless @check.gratuity.nil?\n\t\t @check.update(:total => (@check.subtotal + @check.tax + @check.gratuity))\n\t else\n\t @check.update(:total => (@check.subtotal + @check.tax))\n\t end\n end", "def confirmation\n @merchant = @current_merchant\n @order = Order.find_by(id: params[:id])\n\n check_merchant\n end", "def resend_confirmation_instructions; end", "def confirm(args)\n ack_or_nack, delivery_tag, multiple = *args\n loop do\n tag = @unconfirmed.pop(true)\n break if tag == delivery_tag\n next if multiple && tag < delivery_tag\n\n @unconfirmed << tag # requeue\n rescue ThreadError\n break\n end\n return unless @unconfirmed.empty?\n\n ok = ack_or_nack == :ack\n @unconfirmed_empty.push(ok) until @unconfirmed_empty.num_waiting.zero?\n end", "def sell_confirmed\n end", "def send_free_confirmation\n send_free_message(\"confirmation\")\n end", "def confirm_withdrawals\n current_user.pretransactions.each do |p|\n withdraw_result = Operation.confirm_withdraw(p.transaction_id, p.user_id, p.user_pin, p.amount)\n # Cuando el retiro es exitoso, el webservice regresa un mensaje indicando el balance actual\n if withdraw_result.eql? \"Your current balance is now\"\n if Operation.create!(:to_user_id => p.user_id, \n :from_user_id => p.from_user,\n :op_type => \"withdraw\",\n :amount => p.amount, \n :after_balance => (current_user.points - p.amount),\n :description => p.description)\n update_user_points(p.user)\n update_user_points(User.find(p.from_user))\n p.destroy\n end\n end\n end\n end", "def sell_pending\n end", "def pending_any_confirmation; end", "def confirm\n if status == :pending_confirmation and\n not charges.select { |charge| charge.status == :done }.empty?\n transaction do\n self.status = :confirmed\n self.save\n # Assign available stock\n assign_available_stock if SystemConfiguration::Variable.get_value('booking.assignation.automatic_resource_assignation', 'false').to_bool\n # Create newsfeed\n ::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',\n action: 'confirm_booking',\n identifier: self.id.to_s,\n description: BookingDataSystem.r18n.t.confirmed_booking)\n end\n send_booking_confirmation_notifications\n else\n p \"Could not confirm booking #{id} #{status}\"\n end\n \n self\n end", "def pending!\n return false if purchased?\n\n assign_attributes(status: :pending)\n self.addresses.clear if addresses.any? { |address| address.valid? == false }\n save!\n\n if send_payment_request_to_buyer?\n after_commit { send_payment_request_to_buyer! }\n end\n\n true\n end", "def confirm\n @payment_gateway = @order.payment_gateway_class.new(order: @order)\n if @payment_gateway.collect_payment?\n head :bad_request\n else\n @order.complete!\n head :ok\n end\n end", "def confirm_object(confirmation_datetime)\n return self if not self.confirmable?\n \n self.is_confirmed = true \n self.confirmed_at = confirmation_datetime\n self.save \n \n self.post_confirm_update_stock_mutation\n # self.post_confirm_update_price_mutation \n \n # po_detail =self.purchase_order_detail\n # po_detail.pending_receival -= self.quantity \n po_detail = self.purchase_order_detail \n po_detail.execute_receival( self.quantity ) \n end", "def add_to_pending(purchase)\r\n self.pending_purchases.push(purchase)\r\n end", "def redsys_confirm\n logger.info \"==== REDSYS#CONFIRM ==== order##{params[:order_id]} params# #{params.inspect}\"\n @order ||= Spree::Order.find_by_number!(params[:order_id])\n if check_signature\n unless @order.payments.any?(&:completed?)\n payment_upgrade\n @order.updater.update_payment_total\n end\n @order.next\n if @order.completed?\n flash.notice = Spree.t(:order_processed_successfully)\n flash[:order_completed] = true\n session[:order_id] = nil\n redirect_to completion_route(@order)\n else\n flash[:error] = @order.errors.full_messages.join(\"\\n\")\n redirect_to checkout_state_path(@order.state) and return\n end\n else\n flash[:alert] = Spree.t(:spree_gateway_error_flash_for_checkout)\n redirect_to checkout_state_path(@order.state)\n end\n end", "def confirm\n order = current_order || raise(ActiveRecord::RecordNotFound)\n order.payments.create!(\n {\n source: Spree::PaypalExpressCheckout.create(\n {\n token: params[:token],\n payer_id: params[:PayerID],\n payment_id: params[:paymentId]\n }\n ),\n amount: sprintf(\"%0.02f\", order.total),\n payment_method: payment_method\n }\n )\n order.next\n if order.complete?\n flash.notice = Spree.t(:order_processed_successfully)\n flash[:order_completed] = true\n session[:order_id] = nil\n redirect_to completion_route(order)\n else\n redirect_to checkout_state_path(order.state)\n end\n end", "def confirm!\n if status == :pending_confirmation\n transaction do\n update(:status => :confirmed)\n # Assign available stock\n assign_available_stock if SystemConfiguration::Variable.get_value('booking.assignation.automatic_resource_assignation', 'false').to_bool\n # Create newsfeed\n ::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',\n action: 'confirm_booking',\n identifier: self.id.to_s,\n description: BookingDataSystem.r18n.t.confirmed_booking)\n end\n send_booking_confirmation_notifications\n end\n self\n end", "def confirm_delivery\n if @order.complete!\n # update the owner with the refilled boxes\n owner = @order.owner # e.g. node\n current_quantity = owner.current_quantity # e.g. node current quantity\n owner.update(current_quantity: current_quantity + @order.quantity)\n\n render json: {}, status: :ok\n else\n render json: {errors: @order.errors.messages}, status: :bad_request\n end\n end", "def confirm\n\n end", "def do_pending \n make_activation_code\n ClaimingMailer.deliver_confirmation_request(self) if self.email && self.activation_code\n end", "def confirm!\n @@api.post(endpoint: self.endpoint + ['confirm'])\n end", "def confirm_checkout\n lineItems = LineItem.find_all_by_user_id(current_user.id)\n if(lineItems)\n @transaction = Transaction.create(:buyer_id => current_user.id)\n user = current_user\n baddress = params[:address]\n bzipcode = params[:zipcode]\n if(!baddress || !bzipcode || baddress.length <=0 || bzipcode.length <=0)\n redirect_to cart_checkout_path, :notice => 'Please enter the address' #TODO: This notice should appear on page\n elsif (!params[:card][:user_id] || params[:card][:user_id].length<=0)\n redirect_to cart_checkout_path, :notice => 'Please select a credit card for payment'\n else\n if(params[:saddress] && params[:szipcode] && params[:saddress].length>0 && params[:szipcode].length == 5 )\n @saddress = params[:saddress]\n @szipcode = params[:szipcode]\n else\n @saddress= baddress\n @szipcode = bzipcode\n end\n\n\n @confirmed_items = \"\"\n @unavailable_items = \"\"\n @orders = []\n if @transaction.save\n lineItems.each do |lineItem|\n if(lineItem.line_item_type==9)\n order = Order.new\n item = Item.find(lineItem.item_id)\n auction = Auction.find_by_id(lineItem.auction_id)\n if(auction.state==1)\n auction.update_attribute(:state,2)\n order.billing_address = baddress + bzipcode\n order.shipping_address = @saddress + @szipcode\n order.item_quantity = lineItem.quantity\n order.price = Auction.find_by_item_id(lineItem.item_id).bid_amount\n order.total_price = Auction.find_by_item_id(lineItem.item_id).bid_amount * lineItem.quantity\n order.transaction_id = @transaction.id\n order.seller_id = item.user_id\n order.buyer_id = current_user.id\n order.item_id = item.id\n order.state = 0\n\n if(!order.save)\n redirect_to \"back\", :notice => \"Error creating order, or contact administrator with this message\"\n else\n @orders.push(order)\n @confirmed_items = @confirmed_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n NotifyUser.order_confirmation(user,@confirmed_items,@orders).deliver\n lineItem.destroy\n end\n end\n\n end\n\n\n if(lineItem.line_item_type==0)\n order = Order.new\n item = Item.find(lineItem.item_id)\n if(lineItem.quantity<=item.availability)\n order.billing_address = baddress + bzipcode\n order.shipping_address = @saddress + @szipcode\n order.item_quantity = lineItem.quantity\n order.price = item.price\n order.total_price = Float(item.price) * lineItem.quantity\n order.transaction_id = @transaction.id\n order.seller_id = item.user_id\n order.buyer_id = current_user.id\n order.item_id = item.id\n order.state = 0\n\n if(order.save)\n item.sold_count += lineItem.quantity\n item.availability -= lineItem.quantity\n item.save\n @orders.push(order)\n @confirmed_items = @confirmed_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n NotifyUser.order_confirmation(user,@confirmed_items,@orders).deliver\n lineItem.destroy\n else\n redirect_to :back, :notice => \"Error creating order, verify your inputs or contact administrator with this message\"\n end\n else\n @unavailable_items = @unavailable_items + \" \" + item.name+\"(\"+lineItem.quantity.to_s+\")\"\n end\n end\n end\n end\n end\n #redirect_to :action => 'index', :controller => 'orders'\n else\n redirect_to :back, :notice => 'Unknown processing error. Please verify your orders' #TODO: Cart screen\n end\n end", "def confirm\n # resets sessions to clear the current cart once the order has been confirmed\n session[:order_id] = nil\n end", "def buyer_confirmed\n end", "def confirm_products_order\n unless @current_admin.is_super_admin\n unless @current_admin.privilages.include? '3'\n flash[:error]=\"You are not authorized to navigate to this page \"\n redirect_to admin_index_path\n return\n end\n end\n @users_sales=Array.new\n @customers_sales=Array.new\n @sales=Sale.where(\"is_delivered='f'\")\n\n @sales.each do |sale|\n if sale.customer\n @customers_sales.push(sale)\n else\n @users_sales.push(sale)\n end\n end\n puts \"user sale count:#{@users_sales.length}\"\n puts \"customer sale count:#{@customers_sales.length}\"\n end", "def external_unconfirm\n if not self.transaction_source_id.nil? \n self.errors.add(:generic_errors, \"Can't modify the automated generated transaction\")\n return self \n end\n \n self.is_confirmed = false \n if self.save\n self.update_affected_accounts_due_to_un_confirmation\n end\n end", "def confirm\r\n # Change user status to active\r\n update(status: :active)\r\n # Update all pending company_roles to active\r\n company_roles.update_all(status: 1)\r\n NotifyMailer.welcome_mail(self).deliver_later\r\n super\r\n end", "def confirm\n elements=CartItem.where(:cart_id=>current_user.cart.id)\n\n # if there are no items in the cart, the order will not be placed\n if elements.length==0\n redirect_to carts_path, :notice => \"EMPTY CART!!!\"\n end\n\n # Checks to see if any item in the cart is low in stock. If so, abort. If not, update the sales, and stock quantity of the items\n out_of_stock_items=Item.check_validity(elements)\n\n # This actually checks if any items are below stock\n if out_of_stock_items.length!=0\n redirect_to carts_path, :notice => Item.show_low_stock_message(out_of_stock_items)\n else\n # Save the changes in sales and stocks.\n Item.save_sales(elements)\n #after all the validations are processed, the pre-place order view will be rendered\n @item_list=CartItem.where(:cart_id => current_user.cart.id)\n end\n end", "def confirm_for_fulfillment\n\n\t\t\tresult = PrintfulAPI.request( :POST, \"/orders/#{self.id}/confirm\", {} )\n\n\t\t\tself.load_data( result )\n\n\t\t\treturn true\n\n\t\tend", "def order_confirmation(buyer)\n @order = Order.last\n @buyer = buyer\n\n mail to: @buyer, subject: \"Order Completed!\", cc: \"foodbylags@gmail.com\"\n end", "def final_confirmation\n if session[:all_free_shipping]\n carrier = \"Free Shipping\"\n method = \"Free Shipping\"\n else\n order_id = params[:order][:id]\n carrier = params[:order][:carrier]\n method = params[:order][:shipping_method]\n end\n\n coupon_code = session[:coupon]\n\n @cart = find_cart\n @order = session[:order]\n\n @order.set_freight_ship_to session[:ship_to]\n @order.set_freight_options session\n\n if valid_coupon_code?(coupon_code, @order.totalize_items)\n @order.coupon = coupon_code\n end\n\n @order.carrier = carrier\n @order.taxes = round(@cart.totalize_products * state_tax(@order.billing_state)).to_f\n @order.shipping_method = shipping_method(method)\n @order.shipping_approx = shipping_approx(@order.carrier, method)\n session[:order] = @order\n end", "def confirm_delivery\n @delivery = Delivery.find_by_id params[:delivery_id]\n # add some defensive programming.. current user has role admin, and current_user is indeed belongs to the company \n @delivery.confirm( current_user ) \n @delivery.reload\n end", "def confirm\n end", "def confirm\n end", "def resend_receipt\n @order = Order.find(params[:id])\n #@order.cleanup_successful\n # Send success message\n @order.deliver_receipt\n redirect_to :action => 'show', :id => @order.id\n end", "def proposed_purchases\n PurchaseRequest.find(:all,:conditions => {\n :purchase_requester_id => self.id \n })\n end", "def pay\n\t\titems=get_all_items_in_cart\n\t\tto_be_removed=Array.new\n\t\titems.each do |cart_item|\n\t\t\titem=Item.find(cart_item.fetch(\"table\").fetch(\"cart_item_id\"))\n\t\t\tif item.quantity<cart_item.fetch(\"table\").fetch(\"count\")\n\t\t\t\tflash[:notice] = \"inventory not enough for item: #{item.name}\"\n\t\t\t\tredirect_to :controller => \"cart\", :action => \"index\"\n\t\t\tend\n\t\t\titem.quantity-=cart_item.fetch(\"table\").fetch(\"count\")\n\t\t\titem.save\n\t\t\ttrans=Transaction.new({user_id: User.current_user.id, item_id: item.id, quantity: cart_item.fetch(\"table\").fetch(\"count\"), cost: item.price})\n\t\t\ttrans.save\n\t\t\tto_be_removed.append(item)\n\t\tend\n\t\tto_be_removed.each do |rm_item|\n\t\t\tremove_from_cart(rm_item)\n\t\tend\n\n\t\tflash[:notice] = \"Congratulations! Payment successful!\"\n\n\t\t#flash[:notice] = \"Transaction was completed successfully!!\"\n\n\t\tredirect_to :controller => \"categories\", :action => \"index\"\n\tend", "def confirmarCotizMesExp\n GeneradorCorreoMailer.confirmarCotizMesExp\n end", "def delivery_settings_confirm\n # get delivery preferences\n @delivery_preferences = DeliveryPreference.find_by_user_id(current_user.id)\n @delivery_preferences.update(settings_confirmed: true)\n \n # redirect back to settings so user sees it's now complete\n redirect_to delivery_settings_path\n \n end", "def confirm\n @cart = Cart.find(params[:id])\n user = User.new(params[:user])\n @message = \"\\n\"\n order = \"\"\n @cart.basket_items.each do |item|\n order = order + \"#{item.product.name}\\t\\t #{item.quantity}ks\\t#{item.quantity * item.price}Kč\\n\"\n end\n \n @message = @message + order\n \n if params[:delivery] == \"poštou\"\n # check address\n @message = @message + \"Poštovné\\t\\t \\t100.0Kč\\n\"\n @message = @message + \"Celkem\\t\\t\\t \\t#{@cart.total_price+100}Kč\\n\\n\"\n @message = @message + \"Částku #{@cart.total_price+100} (včetně 100Kč za poštovné) odešli na:\\n\"\n @message = @message + \"účet č. 1014681489/6100\\nvariabilní symbol: #{params[:id]}\\n\\nZásilka ti poté bude odeslána na adresu:\\n\"\n address = user.name + \" \" + user.surname + \"\\n\" + user.street + \"\\n\" + user.zipCode + \" \" + user.city\n @message = @message + address\n @message = @message + \"\\n\\nZboží pro Tebe bude rezervováno po dobu 7 dní.\"\n else\n # check email valid?\n if user.email == \"\"\n flash[:alert]=\"emailová adresa je chybně zadaná\"\n redirect_to :action => 'show'\n return\n end\n @message = @message + \"Celkem\\t\\t\\t \\t#{@cart.total_price}Kč\\n\\n\"\n \n @message = @message + \"Díky za objednávku. Na uvedeném emailu (#{user.email}) Tě budeme kontaktovat.\"\n end\n \n @message = @message + \"\\n\\nNejsme plátci DPH.\\nV případě jakýchkoli nesrovnalostí nás neváhej kontaktovat na emailu info@tumatemate.cz.\\n\\nDěkujeme za objednávku.\"\n # control email\n mail = ActionMailer::Base.mail(:from => \"tumatemate\", :to => user.email, :subject => \"[Maté]: objednávka #{params[:id]}\".encode(\"UTF-8\"), :body => @message.encode(\"UTF-8\"))\n mail.deliver\n # checkout email\n checkout = \"Košík číslo: #{@cart.id}\\n\\n\"\n checkout = checkout + order + \"\\n\"\n if !address.nil?\n checkout = checkout + address + \"\\n\"\n end\n checkout = checkout + \"email: \" + user.email + \"\\n\\n\"\n checkout = checkout + params[:message] + \"\\n\"\n \n checkoutMail = ActionMailer::Base.mail(:from => \"tumatemate\", :to => \"gimli@matfyz.cz, uhlirt@seznam.cz\", :subject => \"[Maté]: objednávka #{params[:id]}\".encode(\"UTF-8\"), :body => checkout.encode(\"UTF-8\"))\n checkoutMail.deliver\n \n session[:cart_id] = nil\n end", "def confirm_payment\n\t\tif @shipping_order.transacted\n\t\t\tredirect_to(:back)\n\t\telse\n\t\t\tif @shipping_order.update(\n\t\t\t\tstatus: 'Started'\n\t\t\t)\n\t\t\t\tconfirm_shipping_payment\n\t\t\telse\n\t\t\t\tflash[:error] = t('errors.messages.not_saved')\n\t\t\t\tredirect_to(:back)\n\t\t\tend\n\t\tend\n\tend", "def purchase\n @order = current_order\n @order_items = @order.order_items\n @order_items.each do |item|\n new_inventory = Product.find(item.product_id).inventory_count - item.quantity\n Product.update(item.product_id, inventory_count: new_inventory)\n end\n @order_items.destroy_all\n end", "def pay_all_bills\n #self.appointments.update_all(cost: 0)\n self.appointments.each {|a| a.paid}\n end", "def resend_confirmation_email\n current_user.resend_confirmation_instructions\n respond_to do |format|\n format.html {redirect_to purchase_orders_path, notice: \"Confirmation Email has been re-sent\"}\n end\n end", "def send_confirmation_instructions; end", "def activate\n deactivate_ids = @decline_items.to_a.collect(&:id)\n user_ids = Set.new\n @items.each do |item|\n next if deactivate_ids.include?(item.id)\n item_params = params[\"item_#{item.id}\"]\n item.attributes = item_params if item_params\n logger.info \" [ + ] #{item.id} - #{item_params}\"\n item.activate! if !@testing\n user_ids << item.user_id\n end\n @decline_items.to_a.each { |item|\n logger.info \" [ x ] #{item.id}\"\n item.decline! if !@testing\n user_ids << item.user_id\n }\n if auth_user.is_a?(Parent) and auth_user.account_confirmed\n clean_pending_item_notifications!( user_ids )\n end\n update_user_data!( user_ids )\n\n if !auth_user.account_confirmed\n if ::Users::Notifications::NeedsAccountConfirm.where(recipient_user_id: auth_user.id).empty?\n ::Users::Notifications::NeedsAccountConfirm.create(sender_user_id: Admin.cubbyshop_admin.id, recipient_user_id: auth_user.id)\n if request.headers['X-App-Name'].eql? 'kidstrade-ios'\n ::NotificationMail.create_from_mail(Admin.cubbyshop_admin.id, auth_user.id, UserMailer.account_confirmation_available(auth_user))\n end\n ::Jobs::VerifyAccountReminder.new(auth_user.id).enqueue!\n end\n end\n\n flash[:notice] = 'Items activated successfully'\n respond_to do |format|\n format.html {\n if !auth_user.account_confirmed\n redirect_to :account_confirmation\n else\n render 'approve_confirmed', layout: 'markup'\n end\n }\n format.js\n format.json { render json: {success: true, item_count: @items.size} }\n end\n end", "def pending_confirmation_sales_orders\n self.sales_orders.joins(:client).where(:is_confirmed => false, :is_canceled => false )\n end", "def send_confirmation_request\n send_confirmation_email\n send_confirmation_notification\n end", "def resend_confirmation\n return unless request.post?\n if current_user.activated_at\n flash.now[:error] = \"Your account has already been activated.\"\n else\n UserNotifier.deliver_signup_notification(current_user)\n flash.now[:notice] = \"Your confirmation email has been re-sent\"\n render :action => 'index'\n end\n end", "def do_pending\n make_activation_code\n # send the user an email with an activation code\n UserMailer.deliver_signup_notification(self)\n end", "def can_be_unconfirmed?\n \n if self.purchase_receival_entries.count != 0\n self.errors.add(:generic_errors, \"Tidak bisa unconfirm karena sudah ada penerimaan barang\")\n return false \n end\n \n if self.purchase_return_entries.count != 0 \n self.errors.add(:generic_errors, \"Tidak bisa unconfirm karena sudah ada pengembalian barang\")\n return false\n end\n\n \n \n reverse_adjustment_quantity = -1*quantity \n \n final_item_quantity = item.pending_receival + reverse_adjustment_quantity\n final_warehouse_item_quantity = warehouse_item.pending_receival + reverse_adjustment_quantity\n \n if final_item_quantity < 0 or final_warehouse_item_quantity < 0 \n msg = \"Tidak bisa unconfirm karena akan menyebabkan jumlah #{item.name} pending receival menjadi #{final_item_quantity} \" + \n \" dan jumlah item gudang menjadi :#{final_warehouse_item_quantity}\"\n self.errors.add(:generic_errors, msg )\n return false \n end\n \n return true \n end", "def send_reconfirmation_instructions\n end", "def paypal\n if params[:token]\n if @subscription.complete_paypal(params[:token])\n if admin_user_pending?\n redirect_to activate_path(@user.activation_code)\n else\n flash[:notice] = 'Your billing information has been updated'\n redirect_to :action => \"billing\"\n end\n else\n render :action => 'billing'\n end\n else\n redirect_to :action => \"billing\"\n end\n end", "def awaiting_confirmation\n @awaiting_confirmation ||= []\n end", "def attemp_buying\n\n end", "def send_to_paypal\n @cart = find_cart\n @order = session[:order]\n dump_cart_items(@order, @cart)\n Postoffice.deliver_new_order(@order, current_user.email)\n clear_session\n end", "def show\n @order_items = current_order.order_items\n \n @order_items.ids.each do |id| \n @order_item = OrderItem.find(id)\n @order_item.purchased = true\n @order_item.user_id = current_user.id\n @order_history = OrderHistory.new\n @order_history.update_attribute(:product_id,@order_item.product_id)\n @order_history.update_attribute(:user_id,current_user.id)\n @order_history.update_attribute(:unit_price,@order_item.unit_price)\n @order_history.update_attribute(:quantity,@order_item.quantity)\n @order_history.update_attribute(:order_id,@order_item.order_id)\n @order_history.update_attribute(:total_price,@order_item.total_price)\n @order_history.save\n @order_item.destroy\n end\n #mail is sent to user after every successful purchase\n ApplicationMailer.send_cart_mail(current_user).deliver\n end", "def send_confirmation\n reply 'confirmation'\n end", "def send_confirmation_email\n\t\tRentersConfirmationJob.perform_later self\n OwnersConfirmationJob.perform_later self\n\tend", "def order_confirmation (user, cart, product, customer, pickup)\n @user = user\n @cart = cart\n @product = product\n @customer = customer\n @pickup = pickup\n\n mail to: user.email, subject: \"A new order has been placed\"\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 send_purchase_confirmation_email\n return if @user.blank?\n\n send_mail_response = pepo_campaign_obj.send_transactional_email(\n @user.email, GlobalConstant::PepoCampaigns.purchase_confirmation, {})\n\n send_purchase_confirmation_email_via_hooks if send_mail_response['error'].present?\n end", "def confirm\n DB.session do |db|\n self.executed = true\n save\n end\n end", "def after_cancel\n restock_items!\n\n #TODO: make_shipments_pending\n Spree::OrderMailer.cancel_email(self).deliver\n Spree::OrderMailer.cancel_email_retailer(self).deliver\n unless %w(partial shipped delivered).include?(shipment_state)\n self.payment_state = 'credit_owed'\n end\n end", "def checkout\n self.product.in_cart_count -= self.count\n self.product.purchase(count)\n self.purchased!\n\n self.save!\n end", "def confirm!\n self.confirmation_token = nil\n self.confirmed_at = Time.now.utc\n save(:validate => false)\n end", "def execute_transaction\n if valid? && @sender.balance > amount && @status == \"pending\"\n @sender.balance -= amount\n @receiver.balance += amount\n @status = \"complete\"\n else\n reject\n end\n end", "def return_item\n items = self.see_purchases.map do |merchandise|\n {name: merchandise.name, merch_id: merchandise.id}\n end\n merch = TTY::Prompt.new.select(\"Here is a list of your purchases. What would you like to return?\",items)\n purchase = self.specific_purchase(merch)\n purchase.destroy \n puts \"your item has been refunded!\"\n restock = self.select_merchandise(merch)\n restock.update(inventory: restock.inventory + 1)\n end", "def payment\n @orders = current_user.orders.all\n @orders.map do |order|\n order.update_attribute(:paid, true)\n order.save \n end\n redirect_to products_path\n end", "def update_snack_queue\n\n order_ids = params[:undelivered_order_ids]\n cart_ids = params[:cart_ids]\n @subscription_id = params[:subscription_id]\n\n orders = []\n @all_carts_full = Cart.is_carts_full?(cart_ids)\n\n if @all_carts_full\n\n order_ids.each do |key, order_id|\n orders.push(order_id)\n order = Spree::Order.where(id: order_id).first\n cart = Cart.where(id: cart_ids[key.to_i]).first\n order_line_items = cart.get_line_items_for_order\n order.pack_line_items(order_line_items, current_user.id, \"USD\", request.remote_ip)\n order.update_total_and_item_total\n #cart.destroy\n end\n\n order = Spree::Order.where(id: order_ids[\"0\"]).first\n result = queue_update_mail_params(order)\n VeganMailer.snack_queue_update_mail(result).deliver\n\n else\n\n end #end of complete if condition.\n end", "def send_confirmation\n send_message(\"confirmation\")\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 purchase\n response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)\n transactions.create!(:action => \"purchase\", :amount => price_in_cents, :response => response)\n #UserMailer.ordered(\"google.com\", response.params.to_s, User.find(cart.user_id), cart).deliver\n cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end", "def destroy_pending_mandates\n @user.mandates.where(slimpay_order_state: Mandate::SLIMPAY_ORDER_WAITING).first.try(:destroy)\n @user.update_attributes(payment_mode: 'cb')\n redirect_to :back\n end", "def commit_orders\r\n orders = @customer.open_orders.find_all_by_synchronized( false )\r\n sales_id = \"\"\r\n orders.each do |o| sales_id += \"'#{o.sales_id}', \" end \r\n @store_user.my_account_log(@customer,\"Commit Sales Order Updates: #{sales_id}\")\r\n\r\n if orders.empty? || ERP::SalesOrder.commit_orders( orders )\r\n flash.now[:message] = \"All changes have been commited.\"\r\n else\r\n flash.now[:message] = \"Operation Failed.\"\r\n end\r\n end", "def confirm_account\n confirm\n end", "def order_shipped(order)\n @order = order\n\n mail(to: @order.user.email , subject: 'Order Confirmation')\n end", "def confirm\n if @account.offload_billing?\n @current_subscription = @account.stripe_subscription.current_subscription\n end\n\n case @service\n when 'vps', 'vps_with_os'\n plan = params[:plan]\n plan_struct = VirtualMachine.plans['vps'][plan]\n\n @billing_amount = plan_struct['mrc']\n @code = 'VPS'\n @code_obj = ServiceCode.find_by(name: @code)\n\n @service_title = if @service == 'vps_with_os'\n VirtualMachine.os_display_name_from_code($CLOUD_OS, params[:os]) + ' VPS'\n else\n 'Generic VM'\n end\n\n @billing_amount_pro_rated = pro_rated_total(@billing_amount)\n\n @stripe_price_id = @account.offload_billing? ? $STRIPE_PRODUCTS['vps'][plan] : \"\"\n\n @pending_service = @account.services.create(\n pending: true,\n service_code: @code_obj,\n title: @service_title,\n billing_interval: 1,\n billing_amount: @billing_amount,\n stripe_price_id: @stripe_price_id\n )\n\n unless @account.offload_billing?\n @pending_invoice = @account.create_pro_rated_invoice!(\n @code, @service_title, @billing_amount_pro_rated, pending: true\n )\n end\n when 'metal'\n raise\n when 'thunder'\n raise\n when 'bgp'\n @billing_amount = 10.00\n @code = 'BANDWIDTH'\n @code_obj = ServiceCode.find_by(name: @code)\n @service_title = \"BGP Session (ASN #{params[:asn]})\"\n @billing_amount_pro_rated = pro_rated_total(@billing_amount)\n\n @stripe_price_id = @account.offload_billing? ? $STRIPE_PRODUCTS['bgp'] : \"\"\n\n @pending_service = @account.services.create(\n pending: true,\n service_code: @code_obj,\n title: @service_title,\n billing_interval: 1,\n billing_amount: @billing_amount,\n stripe_price_id: @stripe_price_id,\n description: \"Pending provisioning by ARP Networks staff.\\n\\nWe thank you for your patience!\"\n )\n\n unless @account.offload_billing?\n @pending_invoice = @account.create_pro_rated_invoice!(\n @code, @service_title, @billing_amount_pro_rated, pending: true\n )\n end\n when 'backup'\n raise\n end\n\n @services = [@pending_service].compact\n @invoices = [@pending_invoice].compact\n\n @enable_pending_view = true\n\n session[:service_to_enable] = @service\n session[:pending_service_ids] = @services.map(&:id)\n session[:pending_invoice_ids] = @invoices.map(&:id)\n end", "def confirm!\n update(confirmed_at: Time.now.utc, status: :confirmed)\n end", "def paid\n\t\tif params[:confirm].to_i == 1\n\t\t\tif @order.armor_enabled?\n\t\t\t\t@order.api_testing_set_to_paid\n\t\t\telse #is a prepay order\n\t\t\t\t@order.prepay_mark_as_paid\n\t\t\tend\n\t\t\tif @order.errors.any?\n\t\t\t\tflash.now[:notice] = @order.errors.full_messages\n\t\t\telse\n\t\t\t\t@success = true\n\t\t\t\tsleep(5) if @order.armor_enabled? #pause to allow update of status from webhook if armor\n\t\t\tend\n\t\tend\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to order_url(@order) }\n\t\t\tformat.js\n\t\tend\n\tend", "def confirm\n # quantity picked by user.\n quantity = params['quantity']\n\n new_order_id = nil\n\n # when order owner require more quantity than the user ability\n if @order.quantity.to_i > quantity.to_i\n new_order = current_user.orders.new(owner: @order.owner, quantity: quantity, status: 'in_progress')\n\n new_order_id = new_order.id if new_order.save\n\n @order.update(quantity: @order.quantity - quantity.to_i, status: 'pending')\n else\n @order.update(status: 'in_progress')\n end\n\n # return the newly created order id, otherwise return the original order id\n render json: {id: new_order_id || @order.id}, status: :ok\n end", "def send_booking_confirmation_notifications\n\n notify_manager_confirmation\n notify_customer\n \n end", "def send_payment_and_dispose!\n mturk_bonus_assignment(self.mturk_assignment_id, self.mturk_worker_id)\n mturk_approve_assignment(self.mturk_assignment_id)\n self.update_attributes(:paid_at => Time.now)\n dispose_hit_on_mturk(self.mturk_hit_id) #we can also delete it on mturk, tidy up\n end", "def complete_paypal(token, payer_id)\n response = payment_method.paypal.purchase(total_amount_in_cents, {:token => token, :payer_id => payer_id, :description => description, :currency => self.currency})\n transaction_gid = response.params['transaction_id']\n options = { operation: 'purchase',\n params: response.params,\n success: response.success?,\n data: {},\n transaction_gid: transaction_gid }\n self.payment_transactions.create!(options)\n\n if response.success?\n if response.params['payment_status'] == 'Completed'\n self.purchase\n self.amount = response.params['gross_amount'].to_f - response.params['fee_amount'].to_f - response.params['tax_amount'].to_f\n save\n end\n else\n errors.add(:payment_method, \"PayPal Error: #{response.message}\")\n false\n end\n end", "def confirm_bank\n # Set active_tab to use in view filters\n session[:active_tab] = \"banks-tab\"\n\n client_payment_ids = params[:bank_confirm][:client_payments_ids].split(\",\")\n client_payments = ClientPayment.where(id: client_payment_ids)\n invoices = []\n bills = []\n client_payments.each do |cp|\n invoice = cp.invoice\n bill = cp.bill\n cp.update_column(:confirmation_date, Time.now)\n invoice.update_column(:invoice_status_id, InvoiceStatus::CHARGED)\n invoices << invoice\n if bill.invoice_status_id < invoice.invoice_status_id\n bill.update_column(:invoice_status_id, invoice.invoice_status_id)\n bills << bill\n end\n end\n Sunspot.index [bills, invoices, client_payments]\n Sunspot.commit\n redirect_to client_payments_path + \"#tab_banks\", notice: \"Cobros domicilados confirmados sin incidencias\"\n end", "def resend_confirmation_email\n WEPAY.call('/user/resend_confirmation', self.wepay_access_token, {\n email_message: 'Thank you for signing up with WeCrowd. In order to process payments, you will need to confirm your email address and set a secure payment password. Click the \"confirm\" button below to begin.'\n })\n end" ]
[ "0.7165871", "0.710431", "0.6915711", "0.671638", "0.66638136", "0.65216666", "0.65216666", "0.6379331", "0.6322846", "0.630819", "0.63065654", "0.62531257", "0.6160262", "0.6138251", "0.61300164", "0.6119833", "0.6099496", "0.6082478", "0.6058828", "0.60534346", "0.60512286", "0.6049387", "0.60439736", "0.60399234", "0.6037058", "0.6023298", "0.59993404", "0.59925944", "0.5988285", "0.59707105", "0.5965579", "0.59649885", "0.5954187", "0.5953715", "0.59508", "0.5939584", "0.59275585", "0.5922982", "0.5921036", "0.591306", "0.5900124", "0.58903706", "0.5869333", "0.5861444", "0.5835549", "0.5831759", "0.58276874", "0.58276874", "0.5814182", "0.58054614", "0.5797222", "0.5788125", "0.5774517", "0.57705706", "0.576062", "0.57358104", "0.5729574", "0.57265353", "0.57192785", "0.5706389", "0.5698124", "0.56971604", "0.56693524", "0.5657599", "0.56429666", "0.56395227", "0.56394917", "0.56382126", "0.5629816", "0.56231356", "0.56215316", "0.5612153", "0.5610907", "0.5609686", "0.5600073", "0.5599813", "0.5598008", "0.5597562", "0.5595798", "0.5591678", "0.5587344", "0.55867404", "0.55806106", "0.5579221", "0.5579013", "0.5578581", "0.55766153", "0.55684185", "0.5556686", "0.55489707", "0.5548714", "0.5547952", "0.554173", "0.554138", "0.5530895", "0.55281806", "0.5526189", "0.5525344", "0.5520525", "0.5512981" ]
0.87315136
0
add purchase to user's pending purchases list
def add_to_pending(purchase) self.pending_purchases.push(purchase) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_to_purchases(purchase_record)\n @purchases << purchase_record\n end", "def pending!(purchase)\n post(purchase, \"#{collection_path}/pending\")\n end", "def pending!(purchase)\n post(purchase, \"#{collection_path}/pending\")\n end", "def do_purchase\n user.purchases.create!(\n amount_in_cents: purchase_amount,\n employee_id: purchase_params.dig(:employee_id),\n qty: purchase_params.dig(:qty).to_i,\n venue_id: purchase_params.dig(:venue_id),\n tap_id: purchase_params.dig(:tap_id),\n description: purchase_params.dig(:description)\n )\n end", "def purchase\n begin\n ActiveRecord::Base.transaction do\n @user.coin_credit -= @product.price\n requested_detail = @product.details.available.first\n requested_detail.available = false # makes the detail unavailable\n requested_detail.save!\n @user.save!\n @user.purchased_details << requested_detail # adds the detail to purchased_details of the user\n @purchased_detail = requested_detail\n end\n true\n rescue => e\n Rails.logger.error e\n @user.reload\n @user.errors.add(:base, :purchase_problem)\n false\n end\n end", "def mark_as_purchased!(current_user: nil)\n purchase!(skip_buyer_validations: true, email: false, skip_quickbooks: true, current_user: current_user)\n end", "def delete_pending(purchase)\r\n self.pending_purchases.delete(purchase)\r\n end", "def create\n purchase = @order.purchases.first(:conditions => {\n :purchasable_id => params[:purchase][:purchasable_id],\n :purchasable_type => params[:purchase][:purchasable_type]\n })\n\n if purchase\n purchase.quantity += params[:purchase][:quantity].to_i\n purchase.save\n else\n @order.purchases << Purchase.new(params[:purchase])\n @order.save\n end\n\n if params[:redirect_to]\n flash[:success] = %{#{params[:purchase][:name]} has been added to your order. <a href=\"/order/purchases\">Proceed to checkout</a>.} unless params[:hide_flash]\n redirect_to params[:redirect_to]\n else\n redirect_to order_purchases_path\n end\n end", "def purchase(purchase_amount)\n @total += purchase_amount\n format_money(@total)\n end", "def purchase\n response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)\n transactions.create!(:action => \"purchase\", :amount => price_in_cents, :response => response)\n #UserMailer.ordered(\"google.com\", response.params.to_s, User.find(cart.user_id), cart).deliver\n cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end", "def purchase_for(user)\n return nil if !available? or user.nil?\n order = Order.create ticket: self, user: user\n order\n end", "def purchases\n @orders = Order.all.where(buyer: current_user).order(\"created_at DESC\")\nend", "def add_purchase(post)\n post[:capture] = 'Y'\n end", "def confirm_all_pending_purchases\r\n self.pending_purchases.each{|purchase| purchase.confirm}\r\n end", "def purchase(total)\n @price_in_cents = total\n response = process_purchase\n transactions.create!(:action => \"purchase\", :amount =>@price_in_cents, :response => response)\n #cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end", "def pending_purchase_order\n @pending_purchase_order_cache || @pending_purchase_order_cache = if self.purchase_orders\n self.purchase_orders.select(&:pending?).last unless self.purchase_orders.empty?\n end\n end", "def update_inventory\n self.order_items.each { |item| item.variant.add_pending_to_customer }\n end", "def add_purchase(customer_id, product_id)\n item = DirectedEdge::Item.new(@database, \"customer#{customer_id}\")\n item.link_to(\"product#{product_id}\")\n item.save\n end", "def create\n @purchase = Purchase.new purchase_attributes\n if @purchase.save\n @ok = true\n renewed = Purchase.find_by_id params[:renewed_id]\n if renewed\n renewed.users.each do |u|\n u.purchase_id = @purchase.id\n u.save\n Notification.send_to(\n u.id,\n I18n.t('notifications.account.renewed.title'),\n I18n.t('notifications.account.renewed.message', :expiration_date => TimeConvert.to_string(@purchase.expiration_date)),\n ''\n )\n end\n renewed.expiration_date = Time.zone.now\n renewed.save\n end\n else\n @ok = false\n @errors = @purchase.errors.messages.keys\n @errors << :ssn_code if @errors.include?(:base)\n end\n end", "def purchase\n response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)\n transactions.create!(:action => \"purchase\", :amount => price_in_cents, :response => response)\n #cart.update_attribute(:purchased_at, Time.now) if response.success?\n response.success?\n end", "def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end", "def buy\n user = User.find_by_guid(params[:id])\n if user\n user.dollaz -= params[:price].to_i\n PlayerInventory.create(pid: user.id, item_id: params[:item].id)\n user.save!\n render nothing:true, notice: \"Item bought!\"\n else\n render nothing:true, notice: \"Error: unable to purchase item\"\n end\n end", "def create\n @purchase = current_user.purchases.build(params[:purchase])\n\n respond_to do |format|\n if @purchase.save\n Notifications.new_purchase(@purchase).deliver\n format.html { redirect_to @purchase, notice: 'Purchase was successfully created.' }\n format.json { render json: @purchase, status: :created, location: @purchase }\n else\n format.html { render action: \"new\" }\n format.json { render json: @purchase.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_basket\n if Basket.exists?(user_id: params[:user_id], book_id: params[:book_id])\n @basket = Basket.find_by(user_id: params[:user_id], book_id: params[:book_id])\n @basket.increment!(:amount)\n else\n Basket.create(user_id: params[:user_id], book_id: params[:book_id], amount: 1)\n end\n redirect_to my_basket_path(params[:user_id])\n end", "def create\n @purchase = Purchase.new(purchase_params)\n @purchase.update_associations(current_user, @vendor)\n # @purchase.vendor = @vendor\n # @purchase.added_by = current_user.id\n # @purchase.invoice.user = @purchase.user = current_user\n @purchase.state = \"ordered\"\n respond_to do |format|\n if @purchase.save\n format.html { redirect_to purchase_path(@purchase), notice: 'Purchase was successfully created.' }\n format.json { render action: 'show', status: :created, location: @purchase }\n else\n format.html { render action: 'new' }\n format.json { render json: @purchase.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @purchases = current_user.profile.purchases.new(purchases_params)\n\n respond_to do |format|\n if @purchases.save\n format.html { redirect_to purchases_url, notice: 'Purchase created with success.' }\n format.json { render :show, status: :created, location: @purchases }\n else\n format.html { render :new }\n format.json { render json: @purchases.errors, status: :unprocessable_entity }\n end\n end\n end", "def push_transactions\n AirdropMint.push_transactions_for_pending_rewards(user)\n end", "def purchase(item_price)\n @total += item_price\n total\n end", "def create\n @title = \"Bakery Market | Purchase Credits\"\n @google_fonts = \"Josefin+Slab|Dancing+Script|Lato\"\n @stylesheet = \"users\"\n @order = Order.new(params[:order])\n if params[:id] < 4.to_s\n @service_plan = ServicePlan.find(params[:id])\n else\n @service_plan = ServicePlan.find(3)\n end\n @order.service_plan_id = @service_plan.id\n @order.ip_address = request.remote_ip\n @order.user_id = current_user.id\n if @order.save\n if @order.purchase(@service_plan.id)\n @meals_remaining = current_user.meals_remaining + @service_plan.meals_included\n @total_credits_purchased = current_user.total_credits_purchased + @service_plan.meals_included\n current_user.update_attributes(:meals_remaining => @meals_remaining, :total_credits_purchased => @total_credits_purchased)\n flash[:notice] = \"Thanks for your order. You're all set.\"\n redirect_to root_url\n UserMailer.purchase_complete(current_user, @service_plan).deliver\n else\n render :action => \"failure\"\n end\n else\n render :action => \"new\"\n end\n end", "def after_purchase(order)\n self.consumed = true\n # send confirmation email to admin and to user, #person.send_email already delays\n notify_admins\n notify_backer\n save!\n\n MixpanelEvent.track(\n person_id: person_id,\n event: 'Create Order',\n checkout_method: order.checkout_method.class.name,\n product: \"team_payin\",\n amount: amount,\n team_id: team.id,\n member: team.person_is_member?(person)\n )\n end", "def pending!\n return false if purchased?\n\n assign_attributes(status: :pending)\n self.addresses.clear if addresses.any? { |address| address.valid? == false }\n save!\n\n if send_payment_request_to_buyer?\n after_commit { send_payment_request_to_buyer! }\n end\n\n true\n end", "def buy_item(user, item)\r\n if(self.has_enough_money(item) and user.has_item(item))\r\n self.get_item(user, item)\r\n self.pay_amount(user, item.get_price)\r\n else\r\n #transaction not possible\r\n end\r\n end", "def purchased usr\n Listing.where(\"listings.status not in (?)\", closed_arr(false)).joins(:invoices)\n .where(\"invoices.buyer_id = ? AND invoices.status = ?\", usr.id, 'paid').uniq\n end", "def handle_purchase\n if saved_change_to_state == %w(draft purchased)\n seller.increase_balance(payment.amount)\n end\n end", "def purchases\n # Our .select method on the line below does all the work of the 6 lines with the .each method\n # But remember that either way works just fine\n Purchase.all.select { |purchase| purchase.user == self }\n\n # purchases = []\n # Purchase.all.each do |purchase|\n # if purchase.user == self\n # purchases << purchase\n # end\n # end\n end", "def confirm_purchase(purchase)\r\n purchase.confirm\r\n end", "def purchase_params\n params.require(:purchase).permit(:cost, :user_id, :group_id, :receipt_photo, item_ids: [] )\n end", "def add_to_cart\n @cart = current_user.carts.find_or_create_by(completed: false)\n @line_item = @cart.line_items.find_or_create_by(product_id: params[:product_id])\n @line_item.update quantity: @line_item.quantity + 1\n end", "def purchase\n\n response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)\n \n #create_card_transaction(action: \"purchase\", amount: price_in_cents, response: response)\n \n #@registration.update_attribute(:purchased_at, Time.now) if response.success?\n #response.success?\n end", "def purchase_item(item, seller_id, buyer_id)\n seller = User.new(seller_id)\n buyer = User.new(buyer_id)\n @conn.watch([\"market\", buyer.id]) do\n fund = @conn.hget(buyer.id, \"fund\")\n price = @conn.zscore(\"market\", seller.item_id(item))\n\n if price && price <= fund.to_i\n @conn.multi do |multi|\n multi.hincrby(buyer.id, \"fund\", -price.to_i)\n multi.hincrby(seller.id, \"fund\", price.to_i)\n multi.zrem(\"market\", seller.item_id(item))\n multi.sadd(buyer.inventory_id, item)\n end\n else\n @conn.unwatch\n end\n end\n end", "def my_purchases\n @orders = Effective::Order.deep.purchased_by(current_user)\n EffectiveOrders.authorized?(self, :index, Effective::Order.new(user: current_user))\n end", "def add_pending_to_customer(num = 1)\n ### don't lock if we have plenty of stock.\n if low_stock?\n # If the stock is low lock the inventory. This ensures\n inventory.lock!\n self.inventory.count_pending_to_customer = inventory.count_pending_to_customer.to_i + num.to_i\n inventory.save!\n else\n sql = \"UPDATE inventories SET count_pending_to_customer = (#{num} + count_pending_to_customer) WHERE id = #{self.inventory.id}\"\n ActiveRecord::Base.connection.execute(sql)\n end\n end", "def mark_paid(user)\n event_user = event_user(user)\n event_user.paid_at = Time.now\n event_user.save\n end", "def add_pending_to_customer(num = 1)\n ### don't lock if we have plenty of stock.\n if low_stock?\n # If the stock is low lock the inventory. This ensures\n inventory.lock!\n self.inventory.count_pending_to_customer = inventory.count_pending_to_customer.to_i + num.to_i\n inventory.save!\n else\n sql = \"UPDATE inventories \n SET count_pending_to_customer = (#{num} + count_pending_to_customer) \n WHERE id = #{self.inventory.id}\"\n ActiveRecord::Base.connection.execute(sql)\n end\n end", "def paid_signup(user)\n DelayedKiss.alias(user.full_name, user.email)\n DelayedKiss.record(user.email, 'Sent Paid Signup Email')\n @user = user\n mail to: user.email, subject: \"You've Upgraded to our Business Pro plan!\"\n end", "def add_buys(count)\n update_attributes(buys: buys + count)\n end", "def sell_pending\n end", "def create_as_pending\n self.purchase_state = EffectiveOrders::PENDING\n\n self.skip_buyer_validations = true\n self.addresses.clear if addresses.any? { |address| address.valid? == false }\n\n return false unless save\n\n send_payment_request_to_buyer! if send_payment_request_to_buyer?\n true\n end", "def add_transaction(database, user_id)\n\t# Ask user for item name\n\tputs \"Enter name of purchase ('q' to quit):\"\n\titem = gets.chomp\n\tif item == \"q\"\n\t\treturn\n\tend\n\t# Ask user for quantity of item\n\tputs \"Enter quantity of purchase ('q' to quit):\"\n\t# We only want digits stored in these columns\n\tquantity = gets.chomp\n\tif quantity == \"q\"\n\t\treturn\n\telse\n\t\tquantity = quantity.gsub(/[^\\d\\.]/, '').to_f\n\tend\n\t# Ask user for cost of item\n\tputs \"Enter cost of purchase ('q' to quit):\"\n\tcost = gets.chomp\n\tif cost == \"q\"\n\t\treturn\n\telse\n\t\tcost = cost.gsub(/[^\\d\\.]/, '').to_f\n\tend\n\t# Record date as current date\n\tdate = Time.new.utc\n\t# Insert the information into the purchases table of the database\n\tdatabase.execute(\n\t\t\"INSERT INTO purchases (item, quantity, cost, date, login_id)\n\t\tVALUES ('#{item}', '#{quantity}', '#{cost}', '#{date}', '#{user_id}');\"\n\t\t)\nend", "def payment\n @orders = current_user.orders.all\n @orders.map do |order|\n order.update_attribute(:paid, true)\n order.save \n end\n redirect_to products_path\n end", "def approve_items(with_product)\n items = InventoryItem.where(name: name, unit_id: unit_id, category_id: category_id).where(\"type is null and product_id is null\").where(\"id <> ?\", id)\n items << self\n items.each do |item|\n item.name = \"#{with_product.name} \"#(#{with_product.unit_name})\"\n item.unit_id = with_product.unit_id\n item.product_id = with_product.id\n item.save(:validate => false)\n end\n end", "def add_transaction\r\n\r\n if(@type == :purchase)\r\n if(@product.stock == 0)\r\n begin\r\n raise OutOfStockError, \"OutOfStockError: '#{@product.title}' is out of stock\"\r\n rescue => error\r\n puts error\r\n end\r\n\r\n else\r\n modifiy_transactions\r\n edit_stock({new_purchase: true })\r\n @customer.transactions << self\r\n\r\n end\r\n else\r\n modifiy_transactions\r\n edit_stock({return_purchase: true})\r\n\r\n end\r\n end", "def create\n # You maybe want to log this notification\n notify = Paypal::Notification.new request.raw_post\n \n # Split the item_id\n account_id = notify.item_id\n \n @user = User.find account_id\n\n if notify.acknowledge\n # Make sure you received the expected payment!\n if notify.complete? and 9.99 == Decimal.new( params[:mc_gross] ) and notify.type == \"subscr_payment\"\n # All your bussiness logic goes here\n @user.premium = true\n @user.valid_till = Date.today + 1.month\n @user.save\n render :nothing => true\n end\n end\n end", "def add_loyalty(user_id)\n\n if !self.product_group_id.nil?\n\n product_group = ProductGroup.find(product.product_group_id)\n\n loyalty = product_group.loyalties.first\n\n loyalty_card = LoyaltyCard.by_loyalty(loyalty.id).by_user(user_id).where('is_won != 1').first\n\n if loyalty_card.nil? \n new_loyalty_card = LoyaltyCard.new\n new_loyalty_card.loyalty_id = loyalty.id\n new_loyalty_card.user_id = user_id\n new_loyalty_card.count = 1\n new_loyalty_card.save\n else\n loyalty_card.count += 1\n if loyalty_card.count == loyalty.win_count\n loyalty_card.is_won = true\n end\n loyalty_card.save\n end\n else\n p 'No Loyalty added.'\n end\n\n end", "def add_item (title, price, quantity = 1)\n # adds purchase price to total\n @total += price * quantity\n # Adds proper quanity of item to cart\n count = 0\n while count < quantity\n @items << title\n count += 1\n end\n # keeps track of last_added item\n @last_transaction[:item] = title\n @last_transaction[:price] = price\n @last_transaction[:quantity] = quantity\n\n end", "def purchase(trip, attributes = {})\n e = Expense.new(attributes)\n e.purchaser = self\n e.trip = trip\n e.save\n e\n end", "def purchase(trip, attributes = {})\n e = Expense.new(attributes)\n e.purchaser = self\n e.trip = trip\n e.save\n e\n end", "def purchase(id)\n response = Shippo::API.post(\"#{url}/#{CGI.escape(id)}/purchase\")\n self.from(response)\n end", "def buy(item, quantity)\r\n if quantity < item.quantity\r\n item_to_buy = item.split(quantity)\r\n else\r\n item_to_buy = item\r\n end\r\n seller = item_to_buy.owner\r\n seller.sell(item_to_buy)\r\n item_to_buy.owner = self\r\n self.remove_credits(item_to_buy.price * quantity)\r\n item_to_buy.deactivate\r\n Marketplace::Activity.create(Activity.ITEM_BOUGHT, item, \"#{item.name} has been bought by #{self.name}\")\r\n Marketplace::Activity.create(Activity.USER_BOUGHT_ITEM, self, \"#{self.name} bought #{item.name}\")\r\n #delete the history in the description log, except the newest entry\r\n item_to_buy.clean_description_log\r\n item_to_buy.clean_comments\r\n item_to_buy\r\n end", "def purchase(params)\n name = params[:customer]\n timestamp = params[:timestamp]\n amount = params[:amount]\n msg = \"\"\n #Nil check for mandatory fields\n if name.nil? || timestamp.nil? || amount.nil?\n msg = \"Customer name, amount or timestamp can't be blank\"\n puts \"Exception in User::purchase:: #{msg}\"\n return {\"status\" => STATUS_CODES[\"bad_request\"], \"result\" => msg}\n end\n unless show_registered_user({:name => name}).present?\n msg = \"User is not registered, kindly register first\"\n puts \"Exception in User::purchase:: #{msg}\"\n return {\"status\" => STATUS_CODES[\"bad_request\"], \"result\" => msg}\n end\n begin\n reward = avail_reward(timestamp, amount)\n index = @@usr_reward_array.find_index{|um| um[\"name\"] == name}\n\n @@usr_reward_array[index][\"reward\"] += reward\n @@usr_reward_array[index][\"purchase_count\"] += 1\n msg = \"Order placed successfully\"\n return {\"status\" => STATUS_CODES[\"success\"], \"result\" => msg}\n rescue Exception => e\n msg = \"Error in processing event, #{e.message}\"\n puts \"Exception in User::purchase:: #{msg}\"\n return {\"status\" => STATUS_CODES[\"error\"], \"result\" => msg}\n end \n end", "def bill\n wallet = self.subscriber.default_wallet\n transaction = wallet.transactions.build(\n date: Time.now,\n expence: self.calculate_amount,\n description: self.plan.name\n ).save\n billing = self.billings.build(\n amount: wallet.total,\n description: \"Test\"\n ).save\n wallet.transactions.pending.update_all billing_id: billing\n end", "def create \n\t\tcarted_products = current _user.\n\t\tcarted_products.where(status: \"carted\")\n\n\t\tcarted_products.each do |carted_products|\n\t\t\tsum += (carted_product.product.product.price\n\t\t\t* carted_product.quantity)\n\t\tend \n\n\t\ttax =subtotal * 0.09\n\t\ttotal = subtotal + tax \n\n\t\torder = Order.create(user_id: current_user_id ,subtotal: subtotal, tax: tax,\n\t\t\ttotal: total)\n\n\t\tcarted_products.update_all (status: \"purchased\",order_id:\"order_id\")\n\n\t\tflash [success:] = \"Order succesfully created\" \n\t\tredirect_to \"/orders/#{order.id}\"\n\tend", "def activate\n deactivate_ids = @decline_items.to_a.collect(&:id)\n user_ids = Set.new\n @items.each do |item|\n next if deactivate_ids.include?(item.id)\n item_params = params[\"item_#{item.id}\"]\n item.attributes = item_params if item_params\n logger.info \" [ + ] #{item.id} - #{item_params}\"\n item.activate! if !@testing\n user_ids << item.user_id\n end\n @decline_items.to_a.each { |item|\n logger.info \" [ x ] #{item.id}\"\n item.decline! if !@testing\n user_ids << item.user_id\n }\n if auth_user.is_a?(Parent) and auth_user.account_confirmed\n clean_pending_item_notifications!( user_ids )\n end\n update_user_data!( user_ids )\n\n if !auth_user.account_confirmed\n if ::Users::Notifications::NeedsAccountConfirm.where(recipient_user_id: auth_user.id).empty?\n ::Users::Notifications::NeedsAccountConfirm.create(sender_user_id: Admin.cubbyshop_admin.id, recipient_user_id: auth_user.id)\n if request.headers['X-App-Name'].eql? 'kidstrade-ios'\n ::NotificationMail.create_from_mail(Admin.cubbyshop_admin.id, auth_user.id, UserMailer.account_confirmation_available(auth_user))\n end\n ::Jobs::VerifyAccountReminder.new(auth_user.id).enqueue!\n end\n end\n\n flash[:notice] = 'Items activated successfully'\n respond_to do |format|\n format.html {\n if !auth_user.account_confirmed\n redirect_to :account_confirmation\n else\n render 'approve_confirmed', layout: 'markup'\n end\n }\n format.js\n format.json { render json: {success: true, item_count: @items.size} }\n end\n end", "def proposed_purchases\n PurchaseRequest.find(:all,:conditions => {\n :purchase_requester_id => self.id \n })\n end", "def purchase(money, creditcard, options = {})\n post = {}\n add_invoice(post, options)\n add_creditcard(post, creditcard) \n add_address(post, creditcard, options) \n add_customer_data(post, options)\n add_duplicate_window(post)\n \n commit('SALE', money, post)\n end", "def buy_new_item(item_to_buy, quantity, account)\n return false if item_to_buy.auction\n preowner = item_to_buy.owner\n\n if (Integer(item_to_buy.price*quantity) > self.credits and item_to_buy.currency == \"credits\") or Integer(item_to_buy.quantity)<quantity\n Activity.log(account, \"item_bought_failure\", item_to_buy, self)\n Activity.log(account, \"item_sold_failure\", item_to_buy, preowner)\n return false\n end\n\n\n if !item_to_buy.wishlist_users.empty? and item_to_buy.quantity == quantity and !item_to_buy.permanent\n item_to_buy.wishlist_users.each {|trader| trader.remove_from_wishlist(item_to_buy); item_to_buy.wishlist_users.delete(trader)}\n end\n\n Holding.ship_item(item_to_buy, item_to_buy.owner, self, quantity)\n Activity.log(account, \"item_bought_success\", item_to_buy, self)\n Activity.log(account, \"item_sold_success\", item_to_buy, preowner)\n Mailer.item_sold(preowner.e_mail, \"Hi #{preowner.name}, \\n #{self.name} bought your Item #{item_to_buy.name}.\n Please Contact him for completing the trade. His E-Mail is: #{self.e_mail}\")\n\n return true\n end", "def purchase(amount, options={})\n adjust_and_save(amount.abs * -1, :purchase, options)\n end", "def index\n @purchases=current_user.purchases\n end", "def add_user!( user, update_user = true )\n puts \"add_user\"\n unless @users.include?( user )\n @users << user\n user.add_badge!( self, false ) if update_user\n end\n return @users\n end", "def add_to_wishlist(product)\n wishlist.products << product unless wishlist.products.include?(product)\n wishlist.save\n end", "def add_to_queue!(user)\n $redis.lpush(self.class.redis_key_for_user(user), to_redis_object)\n end", "def app_store_block_in_app_purchases=(value)\n @app_store_block_in_app_purchases = value\n end", "def my_purchases\n @listings = Listing.joins(:purchase).merge(Purchase.where(user_id: current_user.id)).page(params[:page]).per(30)\n end", "def buy_requested_item(request, item)\r\n self.overlay.delete_item_request(request.id)\r\n item.price = request.price #The prize given in the request is relevant.\r\n buy(item, true)\r\n end", "def send_new_purchase_email(user)\n @user = user\n mail( :to => @user.email,\n :subject => 'Thank you for your purchase!')\n end", "def save_to_inventory\n @user = User.find(params[:id])\n @item = Item.find(1)\n @user.items.push(@item)\n end", "def index\n @purchases = current_user.purchases\n end", "def buyEvent\n client.arecord_user_action_on_item('buy', getUser, getCart) \n end", "def confirm!\n self.pending = false\n self.save\n self.createDebts\n end", "def billing!\n ready! && save!\n end", "def purchase_show\n if params[:product_id] == '0'\n @items = session[:cart]\n else\n @items = []\n @items << { 'product' => params[:product_id], 'quantity' => session[:quantity] }\n end\n @sum = 0\n @count = 0\n @items.each do |item|\n product = Product.find(item['product'])\n @sum += product.price * item['quantity'].to_i\n @count += item['quantity'].to_i\n end\n @address = BillAddress.find(params[:bill_address_id])\n @user = current_user\n end", "def join_purchase\n @purchase_response = GATEWAY.purchase(price_in_cents, credit_card, purchase_options)\n @purchase_response.success?\n end", "def add_to_receipt(item)\n balance = item.is_a?(Array) ? item[2] ? item[2].to_i <=> 0 : 0 : 0\n if @marw_queue.empty? || @marw_queue.all? { |receipt| \n receipt.closed || balance != receipt.balance }\n label = (balance == 0 ? marw_label_default : (balance > 0 ? \n MARW_CONFIGURATION[:vocab_gain_label] : MARW_CONFIGURATION[:vocab_lose_label]))\n show_receipt_window(label, [], balance)\n end\n @marw_queue.reverse.each { |receipt| \n if !receipt.closed && receipt.balance == balance\n receipt.item_array.push(item) \n break\n end\n }\n end", "def buy(amount)\n @bought_amount += amount if amount_remaining >= amount\n end", "def create\r\n @cart_item = CartItem.new(cart_item_params)\r\n @cart_item.user = current_user\r\n\r\n if is_enough && @cart_item.save\r\n @cart_item.buy # pre-emtively \"buys\" the item to save it from other users\r\n flash[:notice] = \"Item was added to cart!\"\r\n else\r\n flash[:danger] = \"Item could not be added to cart!\"\r\n end\r\n redirect_to products_path\r\n end", "def add_units(qty)\n qty.to_i.times do\n #create item\n item = supply_items.new\n item.status = SupplyItem::STATUS_AVAILABLE\n item.save\n end\n end", "def purchase_one\n product = Product.find(params[:id])\n company = Company.first\n if product[:inventory_count] > 0\n if product.decrement!(:inventory_count)\n total = company[:money] + product[:price]\n\n company.update_!(money: total)\n render json: {\n status: :ok,\n message: 'Successfully bought'\n }.to_json\n else\n render json: {\n status: :internal_server_error,\n message: 'Error purchasing product'\n }\n end\n else\n render json: {\n status: :ok,\n message: 'Item is no longer available'\n } \n end\n end", "def process_with_payu\n process_purchase\n end", "def set_pending\n item = SharedItem.find_by(name: params[:name], user_id: current_user.id, pending: false)\n if item\n item.update(pending: true)\n redirect_to current_user\n else\n redirect_to current_user, notice: \"Item could not be found.\"\n end\n end", "def set_purchase\n @purchase = current_resource_owner.purchases.find(params[:id])\n end", "def create\n if current_user.product_name == 'gold'\n redirect_to root_path\n end \n\n @order = current_user.orders.build(order_params)\n\n respond_to do |format|\n if @order.save\n \n if order_params[:product] == '$25 - Gold Plan'\n add_pin = 100\n plan = 'gold'\n else\n add_pin = 25\n plan = 'silver'\n end\n \n #Increase User pin on successfully payment recevied\n user = User.find(current_user.id)\n user.allowed_pins += add_pin\n user.product_name = plan\n user.save()\n\n format.html { redirect_to edit_user_registration_path, notice: 'Your Payment successfully received.' }\n # format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n # format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def createAndPurchase(auth_obj, txid, includeDeliveryCommitment=nil, \n extraHdrs=nil, overwrite=true)\n hdrs = { PBShipping::txid_attrname => txid }\n if extraHdrs != nil\n hdrs.update(extraHdrs) \n end\n if includeDeliveryCommitment == nil\n params = { :includeDeliveryCommitment => false } \n else\n params = { :includeDeliveryCommitment => includeDeliveryCommitment } \n end \n api_sig = \"post/shipments\"\n api_version = PBShipping::get_api_version(api_sig)\n api_path = \"/shipments\"\n json_resp = PBShipping::api_request(\n auth_obj, :post, api_version, api_path, hdrs, params, self)\n if overwrite == true \n self.update(json_resp)\n self\n else\n Shipment.new(json_resp)\n end\n end", "def deduct_wallet\n user = User::find(self.user_id)\n user.budget -= self.pending_money\n user.save\n\n self.pending_money = 0\n self.save\n end", "def create\n if current_user.present?\n Item.transaction do\n item = Item.find(params[:item_id].to_i)\n if item.remain <= 0\n #如果已被抢完,提示投资下一期\n flash[:info] = \"该期已投完,请投资下一期\"\n elsif item.remain > params[:amount].to_i\n #如果还没被抢完,可以抢,创建一条抢投记录,更新期数的已投和剩余的人次数\n if current_user.available.blank?\n flash[:info] = \"请先注册并充值\"\n elsif current_user.cash_flows.count == 1 && current_user.cash_flows.first.cash_flow_description == Dict::CashFlowDescription.prize\n flash[:info] = \"注册红包仅可用于投标\"\n elsif current_user.available >= params[:amount].to_i\n numbers = item.number_array.sample(params[:amount].to_i)\n order = ProductOrder.create_for(current_user, params[:item_id].to_i, params[:amount].to_i, numbers.join(\" \"))\n already = item.already + params[:amount].to_i\n remain = item.remain - params[:amount].to_i\n number_array = item.number_array - numbers\n item.update_already_remain(already, remain, number_array)\n flash[:info] = \"参与成功!\"\n else\n flash[:info] = \"您的账户余额不足,请充值\"\n end\n elsif item.remain <= params[:amount].to_i\n if current_user.available.blank?\n flash[:info] = \"请先注册并充值\"\n elsif current_user.available > params[:amount].to_i\n #如果已最后剩余的被抢完,除了更新记录外,还要创建新的一期,及开奖\n numbers = item.number_array\n order = ProductOrder.create_for(current_user, params[:item_id].to_i, item.remain, numbers.join(\" \"))\n already = item.already + item.remain\n remain = item.remain - item.remain\n number_array = item.number_array - numbers\n item.update_already_remain(already, remain, number_array)\n #更新产品信息\n item_product = item.product\n item_product.already += 1\n item_product.remain -= 1\n item_product.save\n #生成新的期数\n not_finish_product = Product.where(\"already != numbers\").order(\"weight desc\").first\n if not_finish_product.present?\n Item.create(product_id: not_finish_product.id, already: 0, remain: not_finish_product.total_price, number_array: (10000001..(10000000+not_finish_product.total_price)).to_a)\n end\n flash[:info] = \"参与成功!\"\n else\n flash[:info] = \"您的账户余额不足,请充值\"\n end\n end\n end\n else\n flash[:info] = \"请先登录\"\n end\n redirect_to :actions => \"index\"\n end", "def create\n @group = Group.find(params[:group_id])\n @purchase = @group.purchases.build(purchase_params)\n @purchase.user = current_user\n if @purchase.make_purchase(purchase_params[:item_ids])\n redirect_to group_purchase_path(@group, @purchase), notice: 'purchase was successfully created!'\n else\n render action: 'new'\n end\n end", "def settle_item_purchase(seller, buyer, item)\n seller.credits += item.price + Integer((item.price * SELL_BONUS).ceil)\n buyer.credits -= item.price\n end", "def purchase_params\n params.require(:purchase).permit(:amount, :description, :event_id, :user_id)\n end", "def purchase\n response = GATEWAY.purchase(self.price * 100, credit_card)\n transactions.create!(:price => self.price, :response => response)\n self.transaction_number = response.subscription_id if response.respond_to? :subscription_id\n self.status = response.success?\n create_transaction if self.status\n self.save\n end", "def purchase_events_new_stripe_customer\n token = params[:stripeToken]\n @number = params[:number].to_i\n coupon = params[:coupon]\n cost = params[:cost]\n\n if create_customer_and_purchase_existing_user(token, @number, cost, coupon) # this is almost like create_customer_purchase, except have flash.nows in that helper\n #if the customer had a coupon, update that coupon to be inactive, and attach customer's user id to it\n # if !coupon.blank?\n # redeem_single_use_coupon(coupon)\n # end \n redirect_to current_user\n else\n redirect_to existing_user_purchase_path\n end \n\nend", "def test_add_existing_user\n billcoin = BillCoin::new\n user = 'NewUser'\n billcoin.user_totals['NewUser'] = 0\n billcoin.add_user user\n assert_includes billcoin.user_totals.keys, user\n assert_equal 1, billcoin.user_totals.count\n end" ]
[ "0.7393064", "0.6969941", "0.6969941", "0.67944", "0.6484065", "0.6417725", "0.6390281", "0.6367429", "0.62931055", "0.62603235", "0.6224885", "0.6166776", "0.6166744", "0.60608613", "0.59752727", "0.5958694", "0.59393317", "0.5899517", "0.589537", "0.58802223", "0.58519614", "0.5840029", "0.58365077", "0.5802405", "0.57960886", "0.5794628", "0.57673854", "0.57529306", "0.57482225", "0.572824", "0.5726135", "0.57237095", "0.5721236", "0.57192385", "0.5692311", "0.56852347", "0.56801796", "0.5670593", "0.565623", "0.56387866", "0.5638283", "0.5635242", "0.56199825", "0.5615531", "0.5611447", "0.5606873", "0.5604417", "0.5598228", "0.55889", "0.5588077", "0.5568742", "0.5551796", "0.55517834", "0.5534864", "0.5533137", "0.552477", "0.552477", "0.55208373", "0.5519311", "0.55056643", "0.5505504", "0.55005896", "0.54995286", "0.5493708", "0.5491526", "0.5489343", "0.548637", "0.5479027", "0.5477932", "0.54735667", "0.54703957", "0.54672706", "0.54605365", "0.5459956", "0.5457268", "0.5454112", "0.54510266", "0.54507464", "0.5450321", "0.54489785", "0.5441335", "0.54409736", "0.54385114", "0.5435979", "0.5426463", "0.5420477", "0.5418752", "0.5415962", "0.54126424", "0.5401526", "0.5401397", "0.540018", "0.5396079", "0.5394838", "0.5387221", "0.5386689", "0.53858876", "0.5384933", "0.53848135", "0.5383527" ]
0.8696216
0
delete purchase from user's pending purchases list
def delete_pending(purchase) self.pending_purchases.delete(purchase) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_purchase_order_items\n purchase_order_items.destroy_all\n end", "def destroy\n @purchase_list.destroy\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n if current_user == @purchase.user\n @purchase.destroy\n end\n redirect_to \"/products\"\n end", "def remove(purchase)\n entry = find_item(purchase)\n destroy(entry) if entry\n end", "def destroy\n @purchase_order.destroy\n end", "def destroy\n @wish_list = WishList.find(params[:wish_list_id])\n @item = @wish_list.items.find(params[:item_id])\n\n if @item.purchased_by == current_user\n @item.purchased_by = nil\n @item.save\n else\n flash[:alert] = \"You do not have permission to unpurchase this Item.\"\n end\n head 200\n end", "def destroy\n # Prevents unauthorized access by other users\n if current_user.id != @purchase.user_id\n flash[:notice] = \"You don't have permission to view that page!\"\n redirect_to current_user\n return\n end\n @purchase.destroy\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase = @customer.purchases.find(params[:id])\n if @purchase.destroy\n render status: 200, json: { message: \"Purchase deleted.\" }\n else\n render status: 500, json: { message: \"Purchase could not be deleted.\" }\n end\n end", "def destroy_cascade(current_user_id)\n self.current_user_id = current_user_id\n purchases = Purchase.where(\"product_id=#{id}\")\n purchases.each do |purchase|\n purchase.destroy_cascade(current_user_id)\n end\n destroy\n end", "def after_destroy(purchase)\n if purchase.store_id\n shopping = Shopping.add(\n purchase.user_id,\n purchase.store_id,\n ShoppingSource::Purchase)\n shopping.decrement_purchases_count\n end\n\n if purchase.fb_action_id && \n purchase.fb_action_id != FBSharing::Underway\n\n ProcessingQueue.push(\n DistributionManager,\n :delete_story,\n purchase.fb_action_id,\n purchase.user.access_token)\n end\n\n if purchase.tweet_id && \n purchase.tweet_id != TWSharing::Underway\n\n ProcessingQueue.push(\n DistributionManager,\n :delete_tweet,\n purchase.tweet_id,\n purchase.user)\n end\n\n if purchase.tumblr_post_id && \n purchase.tumblr_post_id != TumblrSharing::Underway\n\n ProcessingQueue.push(\n DistributionManager,\n :delete_tumblr_post,\n purchase.tumblr_post_id,\n purchase.user)\n end\n end", "def destroy\n @purchase.destroy\n\n head :no_content\n end", "def confirm_purchase(purchase)\r\n purchase.confirm\r\n end", "def remove!(donation_or_purchase)\n log = {}\n donation_or_purchase.line_items.each do |line_item|\n inventory_item = InventoryItem.find_by(storage_location: id, item_id: line_item.item_id)\n if (inventory_item.quantity - line_item.quantity) <= 0\n inventory_item.destroy\n else\n inventory_item.update(quantity: inventory_item.quantity - line_item.quantity)\n end\n log[line_item.item_id] = \"-#{line_item.quantity}\"\n end\n log\n end", "def remove_user_from_quick_invoicing\n company.saved_invoice_users.delete(User.find(params[:user_id]))\n\n head :ok\n end", "def confirm_all_pending_purchases\r\n self.pending_purchases.each{|purchase| purchase.confirm}\r\n end", "def destroy\n @purchase_order.record_activity(:delete, current_user, \"Deleted PO\")\n @purchase_order.destroy\n respond_to do |format|\n\n format.html { redirect_to purchase_orders_url, notice: \"Purchase Order #{@purchase_order.po_id} has been deleted.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to(purchases_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @purchase = Purchase.find(params[:purchase_id])\n @purchase_item = @purchase.purchase_items.find(params[:id])\n @purchase_item.destroy\n\n respond_to do |format|\n format.html { redirect_to purchase_path(@purchase) }\n format.json { head :no_content }\n end\n end", "def deduct_wallet\n user = User::find(self.user_id)\n user.budget -= self.pending_money\n user.save\n\n self.pending_money = 0\n self.save\n end", "def destroy\n @purchase_requisition = PurchaseRequisition.find(params[:id])\n id = 0\n if @purchase_requisition.destroyable?\n\n destinatarios = []\n\n destinatarios << @purchase_requisition.creator_id if @purchase_requisition.creator\n destinatarios << @purchase_requisition.buyer_id if @purchase_requisition.buyer\n\n @purchase_requisition.requisition_entries.each do |re|\n destinatarios << re.responsible_id if re.responsible\n end\n\n mail = UserMailer.pr_delete_email( current_user,destinatarios ,@purchase_requisition )\n send_email(mail, destinatarios)\n\n @purchase_requisition.requisition_entries.each do |re|\n re.delete\n end\n id = @purchase_requisition.id\n @purchase_requisition.destroy\n else\n #@purchase_requisition.errors[:base] << \"This person is invalid because ...\"\n redirect_to(purchase_requisitions_url, :alert => 'Imposible eliminar SC debido a los estatus de las partidas.')\n return\n end\n\n respond_to do |format|\n format.html { redirect_to purchase_requisitions_url, :alert => \"SC # \" + id.to_s + \" eliminada.\".html_safe }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_purchases_url) }\n format.xml { head :ok }\n end\n end", "def destroy_pending_mandates\n @user.mandates.where(slimpay_order_state: Mandate::SLIMPAY_ORDER_WAITING).first.try(:destroy)\n @user.update_attributes(payment_mode: 'cb')\n redirect_to :back\n end", "def terminate\n result = Cybersource.unstore(\";#{subscription_id}\",:order_id => \"#{order_id}\")\n if result.success == true\n self.update_attributes({:state => \"delete\", :note => \"User Requested Deletion\"})\n end\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :ok }\n end\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :ok }\n end\n end", "def void_pending_purchase_orders\n self.purchase_orders.select(&:pending?).each {|o| o.void}\n end", "def pending!(purchase)\n post(purchase, \"#{collection_path}/pending\")\n end", "def pending!(purchase)\n post(purchase, \"#{collection_path}/pending\")\n end", "def destroy\n @delivery = Delivery.find(params[:id])\n order = Order.find(@delivery.order_id)\n order.order_items.each do |order_item|\n ordered_item = OrderedItem.find_by sale_item_id: order_item.sale_item_id\n a = SaleItem.find(order_item.sale_item_id)\n a.amount += order_item.quantity\n a.save\n User.find(SaleItem.find(order_item.sale_item_id).user_id).ordered_items.find(ordered_item.id).destroy\n ordered_item.destroy\n end\n @delivery.destroy\n respond_to do |format|\n format.html { redirect_to profile_url, notice: 'Order was successfully canceled.' }\n format.json { head :no_content }\n end\n end", "def end_donorship_With(other_user)\n self.active_donorship.destroy\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchases.destroy\n respond_to do |format|\n format.html { redirect_to purchases_url, notice: 'Purchase deleted with success.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id]) or raise ActiveRecord::RecordNotFound\n auctions = Auction.find_all_by_seller_id(@user)\n purchases = Auction.find_all_by_buyer_id(@user)\n unless auctions.size > 0\n unless purchases.size > 0\n @user.destroy\n flash[:notice] = \"Deleted user.\"\n else \n flash[:error] = \"#{@user.name} has made one or more purchases and cannot be deleted.\"\n end\n else \n flash[:error] = \"#{@user.name} has created one or more auctions and cannot be deleted.\"\n end\n redirect_to users_url\n end", "def deactivate\r\n items = Marketplace::Database.instance.items_by_user(self)\r\n items.each{ |item| item.deactivate }\r\n\r\n buy_orders = Marketplace::Database.instance.buy_orders_by_user(self)\r\n buy_orders.each{ |buy_order| buy_order.delete }\r\n\r\n Marketplace::Database.instance.add_deactivated_user(self)\r\n Marketplace::Database.instance.delete_user(self)\r\n Marketplace::Activity.create(Activity.USER_DEACTIVATE, self, \"#{self.name} has been deactivated\")\r\n end", "def destroy\n @item_delivery.record_activity(:delete, current_user, \"Deleted PO Delivery\")\n po = @item_delivery.purchase_order\n @item_delivery_id = @item_delivery.id\n @item_delivery.destroy\n respond_to do |format|\n format.html { redirect_to purchase_order_path(po) }\n format.json { head :no_content }\n format.js\n end\n end", "def delete(user_id, id)\n request(:delete, \"/users/#{user_id}/payments/#{id}.json\")\n end", "def destroy\n raise \"Permission denied\" if (RemoveItemOrderTask.roles & @permissions).empty?\n OrderItem.transaction do\n item = @order.items.find(params[:id])\n item.destroy\n task_complete({ :data => { :product_id => item.product.id, :item_id => item.id } },\n RemoveItemOrderTask, [RemoveItemOrderTask])\n end\n redirect_to :back\n end", "def delete\n DB.exec(\"DELETE FROM users WHERE id = #{@id};\")\n # DB.exec(\"DELETE FROM checkouts WHERE user_id = #{@id};\") --> delete books from users checkout history, but does not delete the books from the database??\n end", "def delete_release_in_user_wantlist(username, release_id)\n authenticated? do\n query_and_build \"users/#{username}/wants/#{release_id}\", {}, :delete\n end\n end", "def destroy\n @repurchase = Repurchase.find(params[:id])\n @repurchase.destroy\n\n respond_to do |format|\n format.html { redirect_to repurchases_url }\n format.json { head :no_content }\n end\n end", "def destroy\n current_user.selecteditems.destroy_all\n redirect_to display_cart_user_path(current_user.id)\n end", "def deletependingbooking(user)\n body = JSON.parse(HTTParty.get('https://firestore.googleapis.com/v1beta1/projects/'+ENV[\"FIREBASE\"]+'/databases/(default)/documents/bookings').body)\n list = body[\"documents\"]\n\n for el in list\n # pending booking\n if el[\"fields\"][\"user\"][\"stringValue\"] == user.email and el[\"fields\"][\"active\"][\"booleanValue\"]\n name = el[\"name\"]\n city = el[\"fields\"][\"city\"][\"stringValue\"]\n park = el[\"fields\"][\"park\"][\"stringValue\"]\n lockHash = el[\"fields\"][\"lockHash\"][\"stringValue\"]\n\n # free locker\n new_body = JSON.parse(HTTParty.get('https://firestore.googleapis.com/v1beta1/projects/'+ENV[\"FIREBASE\"]+'/databases/(default)/documents/cities/'+hash_code(city).to_s+'/parks/'+hash_code(city+park).to_s+'/lockers/'+lockHash).body)\n \n new_body.delete(\"createTime\") #useless field\n new_body.delete(\"updateTime\") #useless field\n new_body[\"fields\"][\"user\"][\"stringValue\"] = '\"\"'\n new_body[\"fields\"][\"available\"][\"booleanValue\"] = true\n new_body[\"fields\"][\"open\"][\"booleanValue\"] = false\n \n HTTParty.patch('https://firestore.googleapis.com/v1beta1/projects/'+ENV[\"FIREBASE\"]+'/databases/(default)/documents/cities/'+hash_code(city).to_s+'/parks/'+hash_code(city+park).to_s+'/lockers/'+lockHash, \n body: JSON.generate(new_body), headers: {\"Content-Type\": \"application/json\"} )\n\n # delete booking\n HTTParty.delete('https://firestore.googleapis.com/v1beta1/'+name)\n end\n end\n end", "def purge_payments\n payments.only_deleted.delete_all\n end", "def destroy\n @purchase.destroy\n respond_to do |format|\n format.html { redirect_to purchase_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @shop_purchase = Shop::Purchase.find(params[:id])\n @shop_purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to shop_purchases_url }\n format.json { head :ok }\n end\n end", "def purge\n @user.destroy\n redirect_to admin_users_path\n end", "def destroy\n @purchase.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def mark_as_purchased!(current_user: nil)\n purchase!(skip_buyer_validations: true, email: false, skip_quickbooks: true, current_user: current_user)\n end", "def add_to_pending(purchase)\r\n self.pending_purchases.push(purchase)\r\n end", "def remove(params, userid)\n id = params[\"product_id\"]\n db = connect()\n result = db.execute(\"DELETE FROM ProduCart WHERE product_id = ? AND user_id = ?\",id,userid)\n end", "def release(account, merchant, transaction_id)\n delete \"/#{CGI::escape(account)}/transactions/#{transaction_id}\" + \"?merchant=#{merchant}\"\n expect_status! 'CANCELLED'\n end", "def destroy\n @group = Group.find(params[:group_id])\n @purchase.destroy\n redirect_to group_purchases_path(@group)\n end", "def destroy\n @purchase_order_item = PurchaseOrderItem.find(params[:id])\n @purchase_order_item.destroy\n\n respond_to do |format|\n format.html { redirect_to purchase_order_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n @purchase.destroy\n respond_to do |format|\n\n format.html { redirect_to purchases_url }\n format.json { head :no_content }\n end\n\n end", "def auto_delete_receipts\n #get user id from params or as a method parameter\n user = params[:id]\n\n user.receipts.each do |receipt|\n #check if receipt is three months old\n receipt.remove_receiptFile!\n receipt.save\n #end\n end\n end", "def process_receipt_user\n raise LogicViolation unless changes[:status][0] == 'pending'\n\n if status_changed?(to: 'declined')\n ReceiptUser.find_by(receipt_id: reference_id, user_id: user_id).destroy\n end\n end", "def destroy\n @purchase.destroy\n respond_to do |format|\n format.html { redirect_to purchases_url, notice: t(\"activerecord.models.purchase\") + t(\"messages.successfully_destroyed\") }\n format.json { head :no_content }\n end\n end", "def unconfirm_user(user)\n confirmed_interpreter_requests.find_by(user_id: user.id).destroy\n end", "def destroy\n @customer_purchase.destroy\n respond_to do |format|\n format.html { redirect_to customer_purchases_url, notice: 'Customer purchase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @auto_bill_payment.destroy\n redirect_to account_auto_bill_payments_url, notice: 'Auto bill payment was successfully destroyed.'\n end", "def destroy\n # find ALL servings associated with this purchase and delete them\n all_servings = Serving.where(purchase_id: @purchase.id)\n puts \"all servings associated with this purchase: #{all_servings}\"\n all_servings.destroy_all\n puts \"deleted servings\"\n @purchase.destroy\n puts \"deleted purchase\"\n render json: {status: 204, purchase: @purchase}\n end", "def delete_user_todos\n user = self.id\n Todo.where({\"user_id\" => user}).delete_all\n end", "def unsubscribe(user, target)\n user.personal_subscriptions.where(target_id: target.id, target_type: target.class).destroy_all\n end", "def destroy\n @purchase.destroy\n respond_to do |format|\n format.html { redirect_to purchases_url, notice: 'Purchase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase.destroy\n respond_to do |format|\n format.html { redirect_to purchases_url, notice: 'Purchase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase.destroy\n respond_to do |format|\n format.html { redirect_to purchases_url, notice: 'Purchase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase.destroy\n respond_to do |format|\n format.html { redirect_to purchases_url, notice: 'Purchase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase_item_status = PurchaseItemStatus.find(params[:id])\n @purchase_item_status.destroy\n\n respond_to do |format|\n format.html { redirect_to purchase_item_statuses_url }\n format.json { head :no_content }\n end\n end", "def purchase\n @order = current_order\n @order_items = @order.order_items\n @order_items.each do |item|\n new_inventory = Product.find(item.product_id).inventory_count - item.quantity\n Product.update(item.product_id, inventory_count: new_inventory)\n end\n @order_items.destroy_all\n end", "def destroy\n Order.where(id: params[:id], user: current_user).first.destroy!\n redirect_to action: 'index'\n end", "def delete_all\n my_trans = Transaction.find_all_by_user_id(current_user.id)\n my_trans.each do |trans|\n trans.destroy\n end\n\n redirect_to transactions_url\n end", "def destroy\n \t@user = User.find(params[:user_id])\n \t@item = @user.items.find(params[:id])\n \t@item.destroy\n \tredirect_to @user\n \tend", "def destroy\n @purchase.destroy\n respond_to do |format|\n format.html { redirect_to purchases_url, notice: 'Transaction was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def dequeues (user)\n raise IllegalStateTransitionError unless user_state[user] == :queued\n # remove request and change user's state\n Request.destroy(user.request.id)\n user_state[user] = :idle\n self.save\n check_rep\n end", "def destroy\n @purchase = Purchase.find(params[:id])\n @purchase.destroy\n\n respond_to do |format|\n format.html { redirect_to(purchase_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n # Удаляем подписки\n @subscriptions = Subscription.where(email: current_user.email)\n @subscriptions.each do |subscription|\n subscription.destroy\n end\n\n super\n end", "def delete_user_account\n # delete their favorites before deleting user\n # list_to_delete = Favorite.where(user_id:current_user.id)\n binding.pry\n User.all.destroy(current_user.id)\n puts \"Your account have been removed! I will never tell, xoxo\"\n end", "def unstore(billing_id)\n delete_customer_profile(:customer_profile_id => billing_id)\n end", "def destroy\n user = @order.user\n user.active = false\n user.save\n\n @order.destroy\n respond_to do |format|\n format.html { redirect_to orders_url, notice: 'Comanda excluída com sucesso.' }\n format.json { head :no_content }\n end\n end", "def delete\r\n Marketplace::Database.instance.call_users(self)\r\n Marketplace::Database.instance.delete_user(self)\r\n ImageUploader.delete_image(self.picture, settings.root) if self.picture != nil\r\n items = Marketplace::Database.instance.items_by_user(self)\r\n items.each{ |item| item.delete }\r\n end", "def remove_quantity_promotions\n if @basket_item.type == \"PurchasingItem\"\n using_promotions_count = UsingPromotion.where(basket_id: @basket_item.basket_id)\n .group(:promotion_id)\n .count\n using_promotions_count.each do | promotion_id, cnt |\n promotion = Promotion.find(promotion_id)\n item_cnt = BasketItem.where(basket_id: @basket_item.basket_id,\n item_id: @basket_item.item_id)\n .count - 1\n if promotion.item_id == @basket_item.item_id &&\n cnt * promotion.item_quantity > item_cnt\n UsingPromotion.where( basket_id: @basket_item.basket_id,\n promotion_id: promotion.id)\n .first\n .destroy\n end\n end\n end\n end", "def remove_from_basket\n @basket = Basket.find_by(user_id: params[:user_id], book_id: params[:book_id])\n @basket.destroy\n redirect_to my_basket_path(params[:user_id])\n end", "def call(_obj, args, _ctx)\n cart = ShoppingCart.find_by(user_id: args[:user_id])\n product = Product.find_by(product_id: args[:product_id])\n item = CartItem.find_by(product_id: args[product_id])\n cart.cart_items.delete(item)\n cart.total_cost -= product.price * item.quantity + product.shipping\n cart.save\n cart\n end", "def destroy\n @payment.destroy\n end", "def destroy\n @payment.destroy\n end", "def destroy\n @analytics_purchase.destroy\n respond_to do |format|\n format.html { redirect_to analytics_purchases_url, notice: 'Analytics purchase was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def unassign\n @budget_item_id = params[:budget_item_id]\n @userid = params[:user_id]\n @projectid = params[:id]\n BudgetItemUser.where(:user_id => @userid ,:budget_item_id => @budget_item_id ).destroy_all\n redirect_to(:controller => 'budget_items' ,:action => 'getProjectMembers' ,:budget_item_id => @budget_item_id , :project_id => @projectid)\n end", "def delete_user\n client.delete(user)\n end", "def destroy\n @purchase.destroy\n respond_to do |format|\n\n format.html { redirect_to sell_list_path, notice: '주문이 삭제되었습니다.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @purchase_bill.destroy\n\n respond_to do |format|\n format.html { redirect_to(purchase_bills_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @billing_option.destroy\n @billing_options = BillingOption.all\n end", "def delete_item(db, item_name, current_user)\r\n db.execute(\"DELETE FROM items WHERE item_name = ? AND user_id = ?\", [item_name, current_user])\r\nend", "def destroy\n @purchase_request.destroy\n respond_to do |format|\n format.html { redirect_to purchase_requests_url, notice: 'Purchase request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_an_appointment(user)\n Appointment.where(user_id: user.id).last.destroy\n end", "def remove_subscription\n buyer = @current_user\n customer_id = buyer.stripe_customer_id\n customer = Stripe::Customer.retrieve(customer_id)\n subscription.delete\n render json: { message: 'Unsubscribed succesfully' }, status: 200\n end", "def delete\n LineItem.delete_for_order(order_id)\n CreditCardTransaction.remove_references_to_order(order_id)\n super\n end" ]
[ "0.7128409", "0.69421244", "0.6914868", "0.69054824", "0.67975605", "0.66891444", "0.6648817", "0.6601199", "0.652107", "0.6518998", "0.65046024", "0.64683145", "0.64472157", "0.6365561", "0.6346627", "0.6293252", "0.62929934", "0.6292903", "0.62905794", "0.6240558", "0.6187515", "0.6187396", "0.61802715", "0.6179869", "0.6179869", "0.6176126", "0.61501044", "0.61501044", "0.61456037", "0.61294615", "0.6125737", "0.6125737", "0.6125737", "0.6125737", "0.6125737", "0.61110675", "0.61057657", "0.60962605", "0.6084969", "0.6069656", "0.598506", "0.5982088", "0.5962887", "0.59526294", "0.5951192", "0.59382665", "0.59352726", "0.59203017", "0.5916837", "0.5915132", "0.5914541", "0.5911419", "0.59016705", "0.5895937", "0.5887557", "0.5849106", "0.5847819", "0.58465356", "0.58451563", "0.5841839", "0.58410496", "0.5829432", "0.582641", "0.58097225", "0.5808385", "0.5806013", "0.58009624", "0.5793412", "0.5793412", "0.5793412", "0.5793412", "0.5786871", "0.57859766", "0.57832336", "0.5779666", "0.57725376", "0.57677823", "0.5762317", "0.5744579", "0.5744112", "0.5739285", "0.5730686", "0.57187355", "0.5708439", "0.5702555", "0.5699678", "0.56980926", "0.5696073", "0.5696073", "0.5692", "0.5691284", "0.5691195", "0.56878376", "0.5670526", "0.5668069", "0.5663685", "0.5660731", "0.56600964", "0.5657845", "0.56465125" ]
0.85486287
0
returns true if an user is allowed to edit
def can_edit?(item) item.editable_by?(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_edit?(user)\n user == current_user\n end", "def can_edit?(user)\n (self.user == user) || !!(user && user.admin?)\n end", "def can_edit?\n allows_current_user_access_to? :edit\n end", "def can_edit?(user)\n return user == self.user || user.has_role?(:admin)\n end", "def can_edit?(obj)\n return true if obj.user_id == user_id || is_admin?\n false\n end", "def can_edit?(user)\n user == self.user\n end", "def can_edit?(user)\n !!(user && (user.admin? || users.include?(user)))\n end", "def can_edit?(user)\n\n 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 user_can_edit?\n current_user == @list.user\n end", "def can_edit\n return current_user && (current_user.id == Integer(params[:id]) || current_user.is_admin)\n end", "def can_edit?(user)\n user && self.creator_id == user.id\n end", "def can_edit_user?(user)\n if self.has_role?('superuser')\n return true\n elsif !self.has_role?('admin')\n return false\n end\n return !(user.has_role?('superuser') || user.has_role?('admin'))\n end", "def canEdit?(user=current_user,owner=nil)\n return false if user.nil?\n return true if user.name == owner.name\n return true if self.isAdmin?(user)\n false\n end", "def user_can_edit(user)\n if (self.editor == user) or self.book.project.owner == user or user.id == 1 then\n return true\n else\n return false\n end\n end", "def can_edit?\n object.editable_by?(current_user)\n end", "def mayEdit? ( other_user )\n if ( (not other_user.valid?) or ( other_user.is_a?(User) == false ) )\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n # d \"basic check failed\"\n # d other_user.type\n # d \"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\"\n return false\n end\n user = getUser()\n if ( other_user == user )\n return true\n end\n if ( ( self.public_policy == Dfile::PP_MAYEDIT ) )\n return true\n end\n if self.special_users\n special = self.special_users[other_user.id.to_s]\n if special\n if ( ( special == Dfile::PP_MAYEDIT ) )\n return true\n end\n end\n end\n return false\n end", "def can_edit?(user)\n if user.nil?\n false\n else\n if self.admins.map(&:downcase).include?(user.email.downcase)\n return true\n else\n self.user_in_group_share?(user, 'Edit')\n end\n end\n end", "def can_edit?(current_user_id)\n\t\tif User.find(current_user_id) == creator\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def can_edit(user)\n unless user.nil?\n user.admin? || ((user.id == user_id) && (updated_at < 5.minutes.ago)) #TODO add to Configuration class\n else\n false\n end\n end", "def can_edit?(user)\n user.nil? ? false : self.admins.include?(user.email)\n end", "def can_edit?\n can_write? && (account_is_owner? || account_is_collaborator?)\n end", "def can_edit?(user)\n course.can_edit? user\n end", "def editable_by_user?(user)\n begin\n (user && (user.id == 1)) or # by root\n (allow_editing == 99) or # it's public editable\n (allow_editing == 0 and author and author.user == user) or # it's the author\n (allow_editing == 1 and user ) or # it's editable by any registered user\n (allow_editing == 2 and user.functions.include?(restricted_to_function_id)) # user is member of function\n rescue\n false\n end\n end", "def can_edit?(p)\n return false if p.blank?\n\n p.user_id == self.id \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 authorized_to_edit?(recipe)\n current_user == recipe.user\n end", "def editable? usr\r\n (seller?(usr) || pixter?(usr) || usr.has_role?(:admin)) || usr.has_role?(:support)\r\n end", "def can_be_modified_by?( user )\n return false if ( user.restricted? )\n return true if ( user.admin? )\n return self.active\n end", "def edit\n authorize! :update, @user\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 'Message'\n record.created_by == current_user.id # messages can only be edited by their creators\n else true # everyone can edit anything else\n end\n end", "def can_edit? record\n return true if current_user.admin?\n case record.class.to_s\n when 'TypusUser'\n record.id == current_user.id\n else\n true # record.user_id == current_user.id # created_by\n end\n end", "def user_can_edit\n unless logged_in? and can_edit?\n respond_with_error(\n \"You must have editor permissions to edit this content.\", \n root_path)\n end\n end", "def permitted?\n Article.can_edit?(@user)\n end", "def editable_by?(user)\n \tuser && user == owner\n\tend", "def can_edit\n return @can_edit\n end", "def can_edit?(user)\n Article.can_edit?(user)\n end", "def can_edit?(someone)\n owner_id.to_s == someone.id.to_s\n end", "def can_edit?\n head(:forbidden) unless current_user.review_space_admin? || @space.editable_by?(current_user)\n end", "def edit_authorized(current_user)\n return self.user_id == current_user.id\n end", "def edit_authorized(current_user)\n return self.user_id == current_user.id\n end", "def can_edit\n producer.admin?(user) || group_admin?\n end", "def permitted?(user)\n Article.can_edit?(user)\n end", "def can_edit_admin?\n return false unless is_admin? && !is_last_admin?\n true\n end", "def edit_login?(user)\r\n # Editable if the user is an admin OR\r\n # the user is editing his own settings\r\n edit_profile?(user) || self == user\r\n end", "def editable_by?(user)\n\t\tuser && user == author\n\tend", "def can_edit_users?\n ['reseller', 'admin'].include?(session[:usertype]) or session[:acc_user_manage].to_i == 2\n end", "def editable\n if scope && scope[:user_id] && object.user_id == scope[:user_id]\n return true\n else\n return false\n end\n end", "def editable\n if scope && scope[:user_id] && object.user_id == scope[:user_id]\n return true\n else\n return false\n end\n end", "def can_edit_admin_objects?\n in_role?('admin', 'super-user', 'releng') # pm?\n end", "def can_edit?\n return !@energy_usage.approved? || current_user.manager? \n end", "def allows?(action, user)\n case action.to_sym\n when :view then user.may_edit or user == self\n when :edit then user.may_authorize or user == self\n else false\n end\n end", "def can_edit(user)\n\t\tif user\n\t\t\tcan_edit = user.courses.include?(self)\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend", "def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end", "def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end", "def editable_by?(usr)\n (usr == user && usr.allowed_to?(:edit_own_time_entries, project)) || usr.allowed_to?(:edit_time_entries, project)\n end", "def accountant_allow_edit(permission)\n return accountant_right(permission) == 2\n end", "def editable_by?(user_id)\n user_id = user_id.id if user_id.is_a?(User)\n has_role(user_id, :editor)\n end", "def authorized_to_edit?(post)\n post.user == current_user\n end", "def authorized_to_edit?(post)\n post.user == current_user\n end", "def can_edit?(user)\n return true if check_creator(user)\n return true if user.any_role?('editor', 'manager')\n return true if !self.content_permissions.by_user(user).blank?\n return true if self.parent && self.parent.can_add_content?(user)\n false\n end", "def authorizes_to_edit_user_admin_field?(user, options = {})\n user.admin? && user.id != options[:user_id]\n end", "def can_edit?(obj)\n can_do?(:edit, obj)\n end", "def edited_by?(user)\n lecture.edited_by?(user)\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 can_modify_user?(user_id)\n\t\trole == 'admin' || id.to_s == user_id.to_s\n\tend", "def can_edit?(required_role)\n \n perm = current_user.permissions.select { |p| p.role.name == required_role}[0]\n \n @readonly= perm.nil? ? false : perm.readOnly?\n \n end", "def can_modify_user?(user_id)\n \trole == 'Admin' || id.to_s == user_id.to_s\n \tend", "def editable_by?(user)\n user && self.user_id == user.id\n end", "def editable_by?(user)\n user && self.user_id == user.id\n end", "def can_edit?(object)\n false\n end", "def can_modify_user?(user_id)\n role == 'admin' || id.to_s == user_id.to_s\n end", "def can_modify_user?(user_id)\n role == 'admin' || id.to_s == user_id.to_s\n end", "def editable_by?(user)\n return true unless has_limited_editors?\n\n (editor_roles & user.alchemy_roles).any?\n end", "def editable_by?(user)\n\t \t# user && user == owner\n\t user == user\n \tend", "def can_edit?(user)\n group.can_edit?(user) # only let admins of a group edit an event\n end", "def editable?(user)\n\n return false if user.nil?\n\n return (user.admin?(User::AUTH_ADDRESSBOOK) or self.owner_id == user.id)\n end", "def editable_by?(user)\n if self.status == :private\n self.user == user || self.featurings.map(&:user).include?(user)\n elsif status == :temporary\n true # XXX FIXME SECURITY HOLE RIGHT HERE: ANY USER CAN MODIFY TEMP SONGS FIXME\n elsif status == :public\n false\n end\n end", "def update?\n user_is_owner? || user_is_admin?\n end", "def update?\n user_is_owner_or_admin?\n end", "def update?\n user_is_owner_or_admin?\n end", "def update?\n user_is_owner_or_admin?\n end", "def edit\n authorize @user_information\n end", "def update?\n user_is_owner_or_admin?\n end", "def edit\n enforce_update_permission(@user)\n end", "def can_edit?(project)\n current_user.id == project.created_by\n end", "def edit\n authorize! :edit, @user, :id => current_user.id\n end", "def show_edit_link?\n @user && @user.admin\n end", "def update?\n user.admin?\n end", "def can_edit_document?(doc = nil)\r\n if self.current_user == self.effective_user\r\n return true\r\n end\r\n\r\n if current_proxy_roles and current_proxy_roles.any?{ |i| [Sys::UserRelation::REL_CANCELARIA, Sys::UserRelation::REL_JUSTICE].include?(i) }\r\n return true\r\n end\r\n\r\n return false\r\n end", "def reseller_allow_edit(permission)\n return reseller_right(permission) == 2\n end", "def edited_by?(user)\n return true if editors.include?(user)\n false\n end", "def can_edit?(item)\n item.editable_by?(self)\n end", "def editable?\n admin?\n end", "def user_permitted_to_edit(item)\n item.user == current_user \n end", "def can_be_modified_by?( user )\n if ( user.admin? )\n true\n elsif ( user.manager? )\n ( user.id == self.user.id ) or ( not self.committed )\n else\n ( user.id == self.user.id ) and ( not self.committed )\n end\n end", "def can_edit?\n return false unless @document\n can?(:edit, @document.resource)\n end", "def can_edit?\n return false unless @document\n can?(:edit, @document.resource)\n end" ]
[ "0.89824325", "0.89695275", "0.89458466", "0.8923159", "0.88882214", "0.8879104", "0.88332", "0.88221055", "0.88102555", "0.88102555", "0.88102555", "0.86176544", "0.85845137", "0.8525991", "0.8524973", "0.84765583", "0.84514827", "0.844656", "0.8439928", "0.8433217", "0.84004986", "0.83960974", "0.83923733", "0.8305487", "0.81622124", "0.8141943", "0.8138302", "0.8103133", "0.8083461", "0.80559915", "0.8035963", "0.8011483", "0.7997661", "0.79872954", "0.798212", "0.7978897", "0.7975274", "0.79717004", "0.79580235", "0.79579747", "0.7947049", "0.79337394", "0.79337394", "0.7932217", "0.79306084", "0.79240763", "0.7919784", "0.7916583", "0.79068714", "0.78855526", "0.78855526", "0.7884576", "0.7883348", "0.7882809", "0.7879629", "0.78718376", "0.78718376", "0.78718376", "0.7862502", "0.7861456", "0.7853253", "0.7853253", "0.78335154", "0.78273284", "0.78143734", "0.7814004", "0.7810329", "0.77710843", "0.7770473", "0.77684295", "0.7755631", "0.7755631", "0.7752433", "0.7739332", "0.7739332", "0.7732424", "0.77313375", "0.7719407", "0.7716333", "0.7714163", "0.7704784", "0.76872826", "0.76872826", "0.76872826", "0.7658468", "0.765699", "0.7647925", "0.7643636", "0.76416266", "0.7625807", "0.7615023", "0.7599044", "0.7597104", "0.75790864", "0.7568912", "0.7556298", "0.75170374", "0.75168395", "0.75048673", "0.75048673" ]
0.7631594
89
returns true if user is allowed to buy item
def can_buy?(item) item.buyable_by?(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_buy?(item)\n item.buyable_by?(self)\n end", "def check_buyable\n raise PermissionDeniedError, \"出品したアイテムはサポートできません\" if @item.owner?(current_user)\n end", "def test_can_buy_org_item\n user = User.named(\"user\")\n org = Organization.named(\"org\")\n\n item = org.propose_item(\"Item\", 20, :fixed, nil, nil)\n item.activate\n\n assert(user.can_buy?(item))\n\n user.work_on_behalf_of(org)\n assert(!user.on_behalf_of.can_buy?(item))\n end", "def item_usable?\r\n user.usable?(item) && item_effects_valid?\r\n end", "def item_usable?\n user.usable?(item) && item_effects_valid?\n end", "def buy_item(item)\r\n if !item.active || item.price > self.credits\r\n false\r\n else\r\n seller = item.owner\r\n price = item.price\r\n\r\n seller.give_credits(price)\r\n self.take_credits(price)\r\n seller.remove_item(item)\r\n self.add_item(item)\r\n item.active = false\r\n true\r\n end\r\n end", "def can_request_purchase?\n true # TODO: Should this be !virginia_borrower? ?\n end", "def bought?\n # paym\n end", "def can_user_buy_photos?(user)\n return true if who_can_buy == WHO_EVERYONE\n return true if who_can_buy == WHO_OWNER && user && admin?(user.id)\n return true if who_can_buy == WHO_VIEWERS && user && can_view_or_not_private?(user.id)\n\n return false\n end", "def buy_item(user, item)\r\n if(self.has_enough_money(item) and user.has_item(item))\r\n self.get_item(user, item)\r\n self.pay_amount(user, item.get_price)\r\n else\r\n #transaction not possible\r\n end\r\n end", "def enable?(item)\n CookingManager.quantity(item) > 0\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 checkout_allowed?\n order_items.count > 0\n end", "def may_purchase?(_company)\n false\n end", "def chargeable? listing\n listing.seller?(@user) && listing.new? \n end", "def can_activate?(item)\r\n item.activatable_by?(self)\r\n end", "def buy_item(item_to_buy, user)\r\n fail \"only users can buy items in behalve of an organisation\" if (user.organisation)\r\n fail \"only users that are part of #{self.name} can buy items for it\" unless (is_member?(user))\r\n fail \"would exceed #{user.email}'s organisation limit for today\" unless within_limit_of?(item_to_buy, user)\r\n fail \"not enough credits\" if item_to_buy.price > self.credits\r\n fail \"Item not in System\" unless (DAOItem.instance.item_exists?(item_to_buy.id))\r\n\r\n old_owner = item_to_buy.owner\r\n\r\n #Subtracts price from buyer\r\n self.credits = self.credits - item_to_buy.price\r\n #Adds price to owner\r\n old_owner.credits += item_to_buy.price\r\n #decreases the limit of the buyer\r\n @member_limits[user.email].spend(item_to_buy.price) unless self.limit.nil? || is_admin?(user)\r\n\r\n item_to_buy.bought_by(self)\r\n end", "def item_can_use?(item)\n return false unless item.is_a?(RPG::Item)\n return false if item_number(item) == 0\n if $game_temp.in_battle\n return item.battle_ok?\n else\n return item.menu_ok?\n end\n end", "def buy\n if @product.price <= @user.coin_credit # Checks whether the user has enough coin_credit or not\n purchase\n else\n @user.errors.add(:coin_credit, :not_enough_credit)\n false\n end\n end", "def purchased?\n state == \"purchased\" or stolen == true\n end", "def buy_item(item, log = true)\n seller = item.owner\n\n if seller.nil?\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"item_no_owner\" #Item does not belong to anybody\n elsif self.credits < item.price\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"not_enough_credits\" #Buyer does not have enough credits\n elsif !item.active?\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"buy_inactive_item\" #Trying to buy inactive item\n elsif !seller.items.include?(item)\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item, false).log if log\n return false, \"seller_not_own_item\" #Seller does not own item to buy\n end\n\n seller.release_item(item)\n\n TradingAuthority.settle_item_purchase(seller, self, item)\n\n item.deactivate\n self.attach_item(item)\n\n item.notify_change\n\n Analytics::ItemBuyActivity.with_buyer_item_price_success(self, item).log if log\n\n return true, \"Transaction successful\"\n end", "def check_item_condition?\n # disallow usage if item button disabled\n return false if !$game_system.item_button\n # disallow usage\n item_condition = false\n # if using direct hotkeys\n if BlizzABS::Config::DIRECT_HOTKEYS\n # check direct hotkeys\n item_condition = self.item_hotkeys?\n # if item button pressed\n elsif Input.trigger?(Input::Item)\n # allow usage\n item_condition = true\n end\n # return result\n return item_condition\n end", "def item_owner?\n unless user_signed_in? && !current_user.items.find_by(id: params[:id]).nil?\n flash.alert = \"You are not authorized to access that!\"\n redirect_to root_path\n end\n end", "def can_activate?(item)\n item.activatable_by?(self)\n end", "def should_i_buy?(item)\n !!list[item.to_sym]\n end", "def enable?(item)\n item && item.price > 0\n end", "def enable?(item)\n return (item.price > 0)\n end", "def can_buy_drug?(price, qty)\n wallet > (price * qty) \n end", "def can_supply?\n payment_received? || payment_on_account?\n end", "def enable?(item)\n return false if item.nil?\n return false unless has_recipebook?\n return false if item.tocrafting_gold_fee > $game_party.gold\n return false if $game_party.item_max?(item)\n return false unless have_tools?(item)\n return false unless have_actors?(item)\n return true if item.ingredient_list.empty?\n return have_ingredients?(item)\n end", "def enable?(item)\n true#$game_party.usable?(item)\n end", "def has_item?(item)\n return true if drops_item?(item)\n return true if can_steal_item?(item)\n false\n end", "def can_buy()\n event = Event.find_by(id: self.event_id)\n if Time.now > event.start_date then\n halt msg: 'can_buy() fail' \n false\n else\n true\n end\n end", "def purchased?(product)\n purchase_items.exists?(product_id: product.id)\n end", "def request_permitted?(item)\n true\n end", "def can_modify_shops?\n return self.admin_user? || self.vendor_user?\n end", "def purchasing?\n auction.buy_it_now_price == amount\n end", "def user_buying_unsigned?\n if session[:cart_id]\n cart = Cart.find_by(id: session[:cart_id])\n # if current and devise the user just logged\n # and only gets session cart, if there is cart_offers in it\n devise_controller? && current_user && cart&.cart_offers.present?\n else\n # if session has not cart_id, the user just logged out\n false\n end\n end", "def buy_new_item(item_to_buy, quantity, account)\n return false if item_to_buy.auction\n preowner = item_to_buy.owner\n\n if (Integer(item_to_buy.price*quantity) > self.credits and item_to_buy.currency == \"credits\") or Integer(item_to_buy.quantity)<quantity\n Activity.log(account, \"item_bought_failure\", item_to_buy, self)\n Activity.log(account, \"item_sold_failure\", item_to_buy, preowner)\n return false\n end\n\n\n if !item_to_buy.wishlist_users.empty? and item_to_buy.quantity == quantity and !item_to_buy.permanent\n item_to_buy.wishlist_users.each {|trader| trader.remove_from_wishlist(item_to_buy); item_to_buy.wishlist_users.delete(trader)}\n end\n\n Holding.ship_item(item_to_buy, item_to_buy.owner, self, quantity)\n Activity.log(account, \"item_bought_success\", item_to_buy, self)\n Activity.log(account, \"item_sold_success\", item_to_buy, preowner)\n Mailer.item_sold(preowner.e_mail, \"Hi #{preowner.name}, \\n #{self.name} bought your Item #{item_to_buy.name}.\n Please Contact him for completing the trade. His E-Mail is: #{self.e_mail}\")\n\n return true\n end", "def validate_item_results?\n if @item.user.private\n authenticate_user!\n if !current_user.subscribed_to(@item.user)\n return false\n end\n end\n return true\n end", "def acceptable_by?(user)\n return false if !resource.new? or user.is_user? or \n ((chat = resource.chat) and !chat.has_user?(user))\n amount = resource.amount\n if limit = LIMITS[user.role.name]\n amount <= limit and (!resource.deposit_type? or user.wallet.has_amount?(amount))\n else \n (!resource.deposit_type? or user.wallet.has_amount?(amount))\n end\n end", "def shares_available_for_purchase?\n if Stock.all.find_by(id: trade.stock_id).shares_available < trade.num_shares\n return false\n else\n return true\n end\n end", "def buy\n user = User.find_by_guid(params[:id])\n if user\n user.dollaz -= params[:price].to_i\n PlayerInventory.create(pid: user.id, item_id: params[:item].id)\n user.save!\n render nothing:true, notice: \"Item bought!\"\n else\n render nothing:true, notice: \"Error: unable to purchase item\"\n end\n end", "def licensed_by?(context)\n if context.guest?\n false\n else\n accepted_licenses.exists?(user_id: context.user_id, state: [nil, 'active'])\n end\n end", "def buy\n if self.inventory_count == 0\n return false\n else\n # for now, decrementing the inventory count when purchasing a product will do\n self.decrement!(:inventory_count)\n # in the future, could return a receipt number, etc.\n return true\n end\n end", "def within_limit_of?(item, user)\r\n @member_limits.fetch(user.email).has_resources_for?(item.price)\r\n end", "def user_may_view_item?\n @pcp_item.pcp_step.released? || @pcp_item.pcp_step.in_commenting_group?\n end", "def can_auction?(_company)\n true\n end", "def can_activate?\n self.authorize_payment\n end", "def buyEvent\n client.arecord_user_action_on_item('buy', getUser, getCart) \n end", "def can_sell?\n inventory.any? { |inv| inv.price > 0 }\n end", "def create?\n @current_user.permission('Currency', :clerk)\n end", "def can_buy_beer?(person)\nend", "def current_item_enabled?\n return true\n end", "def can_equip?(item, slot)\n item.allowed_slot == slot && items.include?(item)\n end", "def enable?(item)\n return true\n end", "def enable?(item)\n return true\n end", "def acceptable_by?(user)\n return false unless user.has_role?(:admin, user.unit)\n resource.pending?\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 enable?(item)\n true\n end", "def enable?(item)\n true\n end", "def current_user_owns?(item)\n \t!item.nil? && current_user.is_a?(User) && (item.is_a?(User) ? current_user == item : current_user.is_author_of?(item)) \n end", "def enable?(item)\n end", "def current_item_enabled?\n true\n end", "def has_discounts?\n rpg_shop.permit_sales\n end", "def user_meets_criteria?(user)\n user.credits > 0\n end", "def can_supply?(required)\n total_on_hand >= required || backorderable?\n end", "def merchant?\n self.user_type == 'Merchant'\n end", "def below_user_limit?(user, additional_items)\n if purchase_limit == 0\n true\n else\n current_count = current_count(user, additional_items)\n current_count < purchase_limit\n end\n end", "def items_to_check\n User.not_admins\n end", "def buy_item\n merchant = Merchant.find(params[:merchant_id])\n item = merchant.determine_item(params.keys.second, params.values.second )\n \n # potions run differently since a user can have multiple of the item, so it checks if it is a potion\n if Merchant.is_potion?(item)\n response = merchant.buy_potion(item, merchant.get_character_from_game)\n flash[:notice] = response\n redirect_to user_character_path(current_user, merchant.get_character_from_game) \n \n # if not it runs the normal buy method \n else \n response = merchant.buy_item(item, merchant.get_character_from_game)\n flash[:notice] = response\n redirect_to user_character_path(current_user, merchant.get_character_from_game) \n end\n end", "def is_owner?(item)\n current_user_id == item.user_id\n end", "def is_purchasing_credit?\n sku_type.to_s == Product::SKU_TYPE_PURCHASING_CREDIT && self.internal?\n end", "def buy?(buyer)\r\n if buyer.credits < self.price or not self.active or buyer == self.owner\r\n false\r\n return\r\n end\r\n owner.credits += self.price\r\n buyer.credits -= self.price\r\n self.owner.remove_owned(self)\r\n self.owner = buyer \r\n buyer.add_owned(self)\r\n self.active = false\r\n true \r\n end", "def can_cash?\n self.capture_and_cash\n end", "def permission_required \n render_403 unless admin? || @item.is_editable_by?(current_user)\n end", "def fulfilled?\n user.donations.active.count >= quantity\n end", "def create\r\n @cart_item = CartItem.new(cart_item_params)\r\n @cart_item.user = current_user\r\n\r\n if is_enough && @cart_item.save\r\n @cart_item.buy # pre-emtively \"buys\" the item to save it from other users\r\n flash[:notice] = \"Item was added to cart!\"\r\n else\r\n flash[:danger] = \"Item could not be added to cart!\"\r\n end\r\n redirect_to products_path\r\n end", "def enable?(item)\n if item.is_a?(RPG::Item)\n return true if !item.key_item?\n elsif item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)\n return true\n else\n return false\n end\n end", "def enable?(item); true; end", "def enable?(item)\n return false if item.nil?\n return true\n end", "def enable?(item)\n return false if item.nil?\n return true\n end", "def available?\n self.active == true and self.quantity_available > 0\n end", "def create?\n @current_user.permission('Bid', :clerk)\n end", "def add_user_allowed?\n client_token_sale_detail = ClientTokenSaleDetail.get_from_memcache(@client_id)\n\n return error_with_identifier('token_sale_ended',\n 'um_u_c_aua_1'\n ) if client_token_sale_detail.has_registration_ended?\n\n success\n end", "def is_permitted_for?( user )\n ( user.id == self.user.id ) or ( user.privileged? )\n end", "def show?\n @current_user.permission('Currency', :guest)\n end", "def cart_item_check\n cart_item = current_end_user.cart_items\n unless cart_item.exists?\n redirect_to items_path\n end\n end", "def item_quantity_sufficient?(request, item_name)\n\t\titem = Item.find_by(:unique_name => item_name)\n\t\titem.quantity - request.quantity >= 0\n\tend", "def checkout_allowed?\n line_items.count > 0\n end", "def is_permitted_for?( user )\n return true if user.privileged?\n\n # User is restricted. User can only see this object if it\n # has at least one task associated with it and at least one\n # of those associated tasks appears in the user's permitted\n # task list, so check the intersection of the two arrays.\n\n return ( self.tasks & user.tasks ).length > 0\n end", "def can_sell_drug?(drug)\n drug.can_be_sold?\n end", "def can_block?(user)\n active? && (approved? || (pending? && self.friend == user))\n end", "def enable?(item)\n item.enabled?\n end", "def enable?(item)\n item.enabled?\n end", "def money_approved?\n true\n end", "def actions_available?(user)\n actions_allowable?(user)\n end", "def must_buy_train?(entity)\n must_buy_power?(entity)\n end", "def allow?(item)\n @whitelist.include?(item) || !@blacklist.include?(item)\n end", "def embargoed?(user)\n if user.nil?\n embargo_active?\n else\n # must not be viewable by current user & embargoed to be true\n !can_view?(user) && embargo_active?\n end\n end" ]
[ "0.83556855", "0.80316854", "0.7427995", "0.7392608", "0.7370311", "0.72309196", "0.7112417", "0.7045148", "0.7044457", "0.6986249", "0.69859576", "0.69794226", "0.69610906", "0.69420904", "0.6913748", "0.6912129", "0.6909094", "0.6885142", "0.68847775", "0.6845791", "0.6844808", "0.68361443", "0.6823565", "0.6810529", "0.6784403", "0.67624736", "0.6751147", "0.6698344", "0.6693375", "0.6663567", "0.66559124", "0.66417015", "0.66401136", "0.6615057", "0.6605462", "0.6592383", "0.65922534", "0.6592152", "0.65780425", "0.65681076", "0.65670377", "0.65630573", "0.65628344", "0.65511763", "0.65484595", "0.653995", "0.65321887", "0.6519498", "0.6506673", "0.6489182", "0.6471245", "0.6467597", "0.64494807", "0.64442575", "0.6436069", "0.6425564", "0.6425564", "0.6415894", "0.64003867", "0.6381194", "0.6381194", "0.6377268", "0.63710773", "0.6337147", "0.6331351", "0.6326199", "0.63256764", "0.6323328", "0.6312884", "0.6298614", "0.6290722", "0.6289442", "0.6281375", "0.627926", "0.62759733", "0.6272422", "0.626908", "0.6266003", "0.62484425", "0.6245681", "0.62416923", "0.62406266", "0.6234451", "0.62274784", "0.62196004", "0.62040347", "0.6192252", "0.6185246", "0.6184703", "0.6179253", "0.61699057", "0.6164119", "0.61619157", "0.61618674", "0.61618674", "0.6151017", "0.6150018", "0.6147248", "0.61421394", "0.6140977" ]
0.8416713
0
returns true if user is allowed to activate an item
def can_activate?(item) item.activatable_by?(self) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_activate?(item)\n item.activatable_by?(self)\n end", "def activated?\n self.user && self.user.activated?\n end", "def can_activate?\n self.person && self.person_match? && self.has_not_expired?\n end", "def can_activate?\n self.person && self.email_match?\n end", "def can_activate?\n self.authorize_payment\n end", "def can_authorize?(user, a)\n user != self and may_authorize and\n (abilities | ADMIN_TASKS).include?(a)\n end", "def can_activate?\n self.sender && self.email_match?\n end", "def activated?\n activation_token && activation_token.confirmed?\n end", "def action_allowed?\n current_user_has_ta_privileges?\n end", "def action_allowed?\n current_user_has_ta_privileges?\n end", "def is_active?\n # Alternatively in the future we may have\n # a role which is considered a non-active role\n true\n end", "def active?\n activated == true\n end", "def enable?(item)\n return true\n end", "def enable?(item)\n return true\n end", "def activated_current_user?\n unless current_user.activated?\n flash[:warning] = \"please activate your account first\"\n redirect_to help_path(anchor: 'activation')\n end\n end", "def approved?\n activated_at || activation_code\n end", "def enable?(item)\n true\n end", "def enable?(item)\n true\n end", "def enable?(item)\n end", "def item_usable?\r\n user.usable?(item) && item_effects_valid?\r\n end", "def can_be_modified_by?( user )\n return false if ( user.restricted? )\n return true if ( user.admin? )\n return self.active\n end", "def allows?(action, user)\n case action.to_sym\n when :view then user.may_edit or user == self\n when :edit then user.may_authorize or user == self\n else false\n end\n end", "def item_usable?\n user.usable?(item) && item_effects_valid?\n end", "def activate\n deactivate_ids = @decline_items.to_a.collect(&:id)\n user_ids = Set.new\n @items.each do |item|\n next if deactivate_ids.include?(item.id)\n item_params = params[\"item_#{item.id}\"]\n item.attributes = item_params if item_params\n logger.info \" [ + ] #{item.id} - #{item_params}\"\n item.activate! if !@testing\n user_ids << item.user_id\n end\n @decline_items.to_a.each { |item|\n logger.info \" [ x ] #{item.id}\"\n item.decline! if !@testing\n user_ids << item.user_id\n }\n if auth_user.is_a?(Parent) and auth_user.account_confirmed\n clean_pending_item_notifications!( user_ids )\n end\n update_user_data!( user_ids )\n\n if !auth_user.account_confirmed\n if ::Users::Notifications::NeedsAccountConfirm.where(recipient_user_id: auth_user.id).empty?\n ::Users::Notifications::NeedsAccountConfirm.create(sender_user_id: Admin.cubbyshop_admin.id, recipient_user_id: auth_user.id)\n if request.headers['X-App-Name'].eql? 'kidstrade-ios'\n ::NotificationMail.create_from_mail(Admin.cubbyshop_admin.id, auth_user.id, UserMailer.account_confirmation_available(auth_user))\n end\n ::Jobs::VerifyAccountReminder.new(auth_user.id).enqueue!\n end\n end\n\n flash[:notice] = 'Items activated successfully'\n respond_to do |format|\n format.html {\n if !auth_user.account_confirmed\n redirect_to :account_confirmation\n else\n render 'approve_confirmed', layout: 'markup'\n end\n }\n format.js\n format.json { render json: {success: true, item_count: @items.size} }\n end\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def is_activated?\n self.activation_token.nil?\n end", "def active_for_authentication? \n super && approved? \n end", "def editable_by_user?\n %w(new paid).include?(self.state)\n end", "def active_for_authentication?\n # User is approved when harp_id is assigned.\n # Approved flag is set programmatically when harp_id is set by an admin.\n super && is_approved?\n end", "def enable?(item)\n item.enabled?\n end", "def enable?(item)\n item.enabled?\n end", "def active_for_authentication?\n super && approved?\n end", "def user_can_edit?\n current_user == @list.user\n end", "def activate\n @user.activate! if @user.pending?\n redirect_to root_url\n end", "def activatable?\n token = activation_token\n !!(token && !token.expired? && !token.confirmed?)\n end", "def show?\n user.active?\n end", "def can?\n current_user\n end", "def approve?\n user && user.able_to?(:moderate_any_forum, record.forum)\n end", "def active_for_authentication?\n super && self.approved?\n end", "def user_active?\n\t\treturn true if teacher? && !activated\n\tend", "def enabled?\n user.present?\n end", "def current_item_enabled?\n return true\n end", "def user_permitted_to_edit(item)\n item.user == current_user \n end", "def active_for_authentication? \n super && is_approved? \n end", "def enable?(item)\n return false if item.nil?\n return true\n end", "def enable?(item)\n return false if item.nil?\n return true\n end", "def is_active(user)\n user.status_id != 0\n end", "def enable?(item); true; end", "def can_access?\n allows_current_user_access_to? :access\n end", "def activate\n begin\n thing = PermissionsManager.activate_thing(current_user, activate_params)\n rescue Exceptions::NoPermissionError\n render json: {}, status: 403\n return\n rescue Exceptions::AlreadyActivatedError\n render json: {}, status: 400\n return\n rescue Exceptions::NoAuth\n render json: {}, status: 401\n return\n end\n render json: { 'thing': thing }, status: 200\n end", "def activate\n user = User.find_by_username params[:username]\n if user && user.activation == params[:activation]\n user.activation = \"ACTIVATION_ACTIVE\"\n user.save()\n render status: 200, json: {error: false}\n else\n render status: 403, json: {error: true}\n end\n end", "def active?\n !expired? && !revoked?\n end", "def can_edit?(item)\r\n item.editable_by?(self)\r\n end", "def user_active?(feature, user)\n rollout.active?(feature, user)\n end", "def active_for_authentication? \n \tsuper && approved?\n \t\n\tend", "def allow_access\n !@current_user.nil?\n end", "def can_user_access?(user)\n if user.is_account_holder_or_administrator? || self.is_user_tagged_to_team?(user)\n true\n else\n false\n end\n end", "def current_item_enabled?\n true\n end", "def is_permitted_for?( user )\n return true if user.privileged?\n\n # User is restricted. User can only see this object if it\n # has at least one task associated with it and at least one\n # of those associated tasks appears in the user's permitted\n # task list, so check the intersection of the two arrays.\n\n return ( self.tasks & user.tasks ).length > 0\n end", "def authorize?(user)\n user && user.admin?\n end", "def authorize?(user)\n user && user.moderator?\n end", "def show?\n @current_user.permission('Bid', :guest)\n end", "def is_user_admin?\n user_active && user_active.permission_level == 2\n end", "def acceptable_by?(user)\n return false unless user.has_role?(:admin, user.unit)\n resource.pending?\n end", "def can_edit?\n return !@energy_usage.approved? || current_user.manager? \n end", "def item_owner?\n unless user_signed_in? && !current_user.items.find_by(id: params[:id]).nil?\n flash.alert = \"You are not authorized to access that!\"\n redirect_to root_path\n end\n end", "def can_edit?(item)\n item.editable_by?(self)\n end", "def can_request?(user)\n self.is_active &&\n self.is_visible &&\n user.is_captain? &&\n ! self.teams.include?(user.team) &&\n ! self.is_finished?\n end", "def read_permitted?\n return (acting_user.administrator? || true)\n end", "def active?\n # the existence of an activation code means they have not activated yet\n activation_code.nil?\n end", "def can_buy?(item)\r\n item.buyable_by?(self)\r\n end", "def check_buyable\n raise PermissionDeniedError, \"出品したアイテムはサポートできません\" if @item.owner?(current_user)\n end", "def access action\n\t\tif current_user\n \treturn true\n else\n \treturn false\n end\n\n\tend", "def current_user_owns?(item)\n \t!item.nil? && current_user.is_a?(User) && (item.is_a?(User) ? current_user == item : current_user.is_author_of?(item)) \n end", "def activate\n @activated = true\n self.activated_at = Time.now.utc\n self.activation_code = nil\n self.make_admin_if_first_user\n save(false)\n end", "def can_block?(user)\n active? && (approved? || (pending? && self.friend == user))\n end", "def show?\n @current_user.permission('Commodity', :guest)\n end", "def actions_available?(user)\n actions_allowable?(user)\n end", "def test_can_buy_org_item\n user = User.named(\"user\")\n org = Organization.named(\"org\")\n\n item = org.propose_item(\"Item\", 20, :fixed, nil, nil)\n item.activate\n\n assert(user.can_buy?(item))\n\n user.work_on_behalf_of(org)\n assert(!user.on_behalf_of.can_buy?(item))\n end", "def is_pending_activation?\n ! self.activated? and self.verification_key ? true : false\n end", "def can_access?(user)\n user == self.user\n end", "def is_allowed_to_edit?(person)\n if person.id == item_owner.id && status.eql?(\"pending_owner\")\n return true\n elsif person.id != item_owner.id && status.eql?(\"pending_reserver\")\n return true\n end\n return false \n end", "def require_activation?\n !self.enabled? and !self.activation_code.blank?\n end", "def update_permitted?\n\t\tacting_user.administrator?\n\tend", "def active_for_authentication?\n super && activation_status == true\nend", "def can_approve?(target)\n is_staff? && target && target.active? && !target.approved?\n end", "def can_buy?(item)\n item.buyable_by?(self)\n end", "def manage?\n super || (@user && @user.is_curator?)\n end", "def enable?(item)\n true#$game_party.usable?(item)\n end", "def can_accept?\n !self.new_record? && self.active? && !!self.kase && self.kase.active?\n end", "def can_access user\n return self.users.include? user\n end", "def write_permitted?\n return (acting_user.administrator? || users.member?(acting_user))\n end", "def permitted?\n appctrl_not_permitted() if ( @current_user.restricted? )\n end", "def approved?\n (status == ConfigCenter::User::APPROVED)\n end" ]
[ "0.8513891", "0.7573564", "0.7317395", "0.71086276", "0.7026378", "0.70057917", "0.6754494", "0.6717668", "0.67154217", "0.67154217", "0.6700493", "0.66995585", "0.66611975", "0.66611975", "0.66450006", "0.66209126", "0.6610475", "0.6610475", "0.6592199", "0.657829", "0.6574061", "0.6562751", "0.6561612", "0.65608096", "0.65554434", "0.65554434", "0.65554434", "0.65554434", "0.65554434", "0.65554434", "0.65554434", "0.6543434", "0.6527263", "0.6516214", "0.6508731", "0.65079945", "0.65079945", "0.65023124", "0.64981544", "0.6496239", "0.64961684", "0.649573", "0.64932954", "0.64918655", "0.6490819", "0.6487504", "0.6477239", "0.64719063", "0.6453025", "0.6450477", "0.64446867", "0.6443554", "0.6435001", "0.64334786", "0.6432075", "0.6428191", "0.6424985", "0.64232165", "0.64215094", "0.6416256", "0.64028734", "0.63975745", "0.6393763", "0.6392815", "0.6392636", "0.6383659", "0.63809466", "0.63803494", "0.6369467", "0.63676363", "0.63634443", "0.6360761", "0.6358923", "0.6358037", "0.63567275", "0.63555354", "0.6345591", "0.6343902", "0.6337714", "0.63364923", "0.6326996", "0.6324725", "0.6320901", "0.6318051", "0.63178414", "0.6316095", "0.63138545", "0.6311326", "0.6310721", "0.63016033", "0.6300467", "0.6298558", "0.6296152", "0.62916845", "0.62905794", "0.62894684", "0.6284519", "0.6278007", "0.6277557", "0.62768227" ]
0.85580724
0
returns the system user as a string
def to_s "#{self.name}, #{self.credits}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def username\n if @username.nil?\n if os_type(:nice, :not_extended) == 'Solaris'\n @username = @platform.exec(\"/usr/ucb/whoami\").strip\n else\n @username = @platform.exec(\"whoami\").strip\n end\n end\n \n @username\n end", "def current_user\n `whoami`.strip\nend", "def username\n if @user.nil?\n @user = JavaSystem.getProperty(\"user.name\")\n end\n\n @user\n end", "def current_user_name_or_id\n require 'etc' if !defined?(Etc)\n begin\n user = Etc.getpwuid(Process.uid)\n rescue ArgumentError\n user = nil\n end\n if user\n return user.name\n else\n return \"##{Process.uid}\"\n end\n end", "def user\n @user ||= ENV[\"USER\"].presence || Utils.safe_popen_read(\"/usr/bin/whoami\").chomp\n end", "def user\n @user ||= ENV[\"USER\"].presence || Utils.safe_popen_read(\"/usr/bin/whoami\").chomp\n end", "def getuid\n\t\trequest = Packet.create_request('stdapi_sys_config_getuid')\n\t\tresponse = client.send_request(request)\n\t\treturn response.get_tlv_value(TLV_TYPE_USER_NAME)\n\tend", "def user\n return ENV['USER']\n end", "def get_uname\n `uname -a`\n end", "def system_name\n self.login\n end", "def get_local_user\n return ENV['USER'] || ENV['USERNAME']\n end", "def sys\n return `uname -n`.chomp\n end", "def cmd_getuid(*args)\n print_line(\"Server username: #{client.sys.config.getuid}\")\n end", "def hubssolib_get_user_name\n user = self.hubssolib_current_user\n user ? user.user_real_name : nil\n end", "def uname\n shell(%w[uname])\n end", "def username\n ENV['USER']\n end", "def system_user\n # By convention, the first user is always the system user.\n User.find_by_id(1)\n end", "def string_username\n CaseInsensitiveString.str(current_user.getUsername())\n end", "def get_full_name(user)\n begin\n Etc.getpwnam(\"#{user}\")[\"gecos\"].chomp\n # or with dscl\n # %x(dscl /Search -read /Users/#{user} dsAttrTypeNative:cn).split.drop(1).join(\" \") \n rescue Exception => e\n end\n \n end", "def user\n return Etc.getlogin\n end", "def to_s\n \"#{user}@#{host}\"\n end", "def whoami\n @whoami ||= Etc.getpwuid(Process.uid).name\n end", "def user\n ENV['SERVER_USER']\n end", "def uname\n `uname -a`\n end", "def get_os\n line = Cocaine::CommandLine.new('uname')\n output = line.run\n\n output.chomp.downcase.intern\n end", "def get_username()\n username_gitconfig = %x(git config user.name).strip\n username_passwd = Etc.getpwnam(Etc.getlogin).gecos.gsub(/ - SBP.*/,'')\n\n username = username_gitconfig unless username_gitconfig.nil?\n username = username_passwd if username.empty?\n username\n end", "def full_name\n name = `finger $USER 2> /dev/null | grep Login | colrm 1 46`.chomp\n name.empty? ? \"John Doe\" : name.squish\n end", "def full_name\n name = `finger $USER 2> /dev/null | grep Login | colrm 1 46`.chomp\n name.present? ? name.squish : \"John Doe\"\n end", "def current_user\n select_value(<<~SQL.squish, \"SCHEMA\")\n SELECT SYS_CONTEXT('userenv', 'session_user') FROM dual\n SQL\n end", "def to_str\n @passwd.name\n end", "def echo_user\n return find_user.to_s\n end", "def to_s\n @passwd.name\n end", "def user\n datastore['POP2USER']\n end", "def guess_remote_user\n result = if Rails.env.development?\n # No kerberos so fudge it\n User.fake_devel_user.short_name\n else\n # This is defined in application_controller\n remote_user\n end\n\n # Probably doesn't matter, but let's ensure we always return\n # a non-empty string to prevent any possible weirdness...\n result.present? ? result : 'user'\n end", "def admin_username\n vm.os_profile.admin_username\n end", "def username\n chef_account.try(:username).to_s\n end", "def get_current_user_name\n return @name if @name\n name = get_current_user_meta\n name = name['query']['userinfo']['name'] if name\n\n name\n end", "def current_user\n # We just do a 'basename' on the principal to give back a sane value\n # here.\n user_name = Http::UrlUtil.split_path(current_principal)[1]\n\n user_name\n end", "def to_s\n return user.name\n end", "def process_username(pid)\n uid = File.stat(\"/proc/#{pid}\").uid\n File.foreach('/etc/passwd').each do |line|\n if line.split(':')[2] == \"#{uid}\"\n return line.split(':')[0]\n end\n end\n end", "def to_s\n \"#{username}\"\n end", "def os_user\n @os_user\n end", "def username\n ENV['DESK_USERNAME']\n end", "def package_user(val = NULL)\n if null?(val)\n @package_user || \"root\"\n else\n @package_user = val\n end\n end", "def package_user(val = NULL)\n if null?(val)\n @package_user || 'root'\n else\n @package_user = val\n end\n end", "def get_userid()\n user_info = call_myspace_api(:user_info, :v1_json => true)\n user_info['userId'].to_s\n end", "def current_owner(options = {})\n if platform_family? 'windows'\n return \"#{::ENV['COMPUTERNAME']}\\\\None\" unless Pathname.new(install_dir).exist?\n\n require 'chef/win32/security'\n security_descriptor = Chef::ReservedNames::Win32::Security.get_named_security_info(install_dir)\n return security_descriptor.owner if options[:sid]\n security_descriptor.owner.account_name\n elsif Pathname.new(install_dir).exist?\n Etc.getpwuid(Pathname.new(install_dir).stat.uid).name\n end\n end", "def to_s\n str = \"#{@user}\\@#{@host}:#{@name}\"\n return str\n end", "def get_system_user\n User.where('first_name = ? AND last_name = ?', 'system', 'user').first\n end", "def get_useremail()\n email = nil\n git_user_email = %x(git config user.email).strip\n email = git_user_email if git_user_email\n email\n end", "def whoami\n self.class.to_s\n end", "def user(username, realname, invisible = true)\n raw \"USER #{username} #{invisible ? 8 : 0} * :#{realname}\\r\\n\"\n end", "def get_userid()\r\n user_info = @context.call_myspace_api(:user_info, :v1_json => true)\r\n user_info['userId'].to_s\r\n end", "def current_user_name\n logged_in? ? (user_name(current_user_id) || current_user_id) : nil\n end", "def username\n \"administrator\"\n end", "def user_display_name\n return @user_display_name\n end", "def user_display_name\n return @user_display_name\n end", "def user_display_name\n return @user_display_name\n end", "def username\n self['default_rhlogin']\n end", "def get_user(username)\n Chef::Log.info username\n user = @node[:users][username]\n Chef::Log.info user.inspect\n user\nend", "def to_s\n username\n end", "def to_s\n username\n end", "def get_client_id( socket )\n # UNIX socket return effective UID/GID for connected client\n euid, _ = socket.getpeereid\n\n # Find record in /etc/passwd\n user_info = Etc.getpwuid euid\n\n return \"#{user_info.name} (#{user_info.gecos})\"\n end", "def name_of(user)\n user.to_s\n end", "def login_user_name\n user_name.tr('.', '')\n end", "def getusername()\r\n return getvalue(SVTags::USER_ID)\r\n end", "def ssh_user(arg=nil)\n set_or_return(:ssh_user, arg, :kind_of => String)\n end", "def to_s\n @username.to_s\n end", "def name\n system_name\n end", "def deployed_by\n username = nil\n\n scm = fetch(:scm, nil)\n\n if scm\n if scm.to_sym == :git\n username = `git config user.name`.chomp\n username = nil if $? != 0 || username.strip == ''\n end\n end\n\n username || `whoami`.chomp\n end", "def to_s\n if user\n \"#{user}@#{host}:#{path[1..-1]}\"\n else\n \"#{host}:#{path[1..-1]}\"\n end\n end", "def user_name\n self.user.login\n end", "def user_name\n self.user.login\n end", "def to_str\n [\"#{user}:#{passwd}\"].pack('m').tr(\"\\n\", '')\n end", "def user_name\n @user_name ||= InchCI::ProjectUID.new(uid).user_name\n end", "def userinfo\n if @user.nil?\n nil\n elsif @password.nil?\n @user\n else\n @user + ':' + @password\n end\n end", "def key\n return \"#{user}\"\n end", "def os\n return `uname -s`.chomp\n end", "def user_name\n decode_string_member(:user_name)\n end", "def name\r\n\t\t@usr_name\r\n\tend", "def name\r\n\t\t@usr_name\r\n\tend", "def get_user_name_not_null\n user = User.first(:id => self.user_id )\n return user.login if user\n return \"anon\"\n end", "def user_name\n read_attribute('user_name') || \"anonymous\"\n end", "def current_user_screen_name\n session[:user_info][\"nickname\"]\n end", "def _user_name(kh)\n @connection.comm.sender_name(kh) || 'unknown_user'\nend", "def unix_uid; end", "def full_name\n (@session[:current_user_details] || {})[:description]\n end", "def user_name\n\t\tobject.user.full_name \n\tend", "def system_user\n User.find_by_name(\"DanbooruBot\") || User.admins.first\n end", "def to_s\n username \n end", "def user_name\n @options[:user_name] ||= @options[:repository].config['pivotal.full-name'] || @options[:repository].config['user.name']\n end", "def to_s\n\t\tself.name.present? ? \"#{self.name} ( #{self.user} )\" : \"#{self.user}\" ;\n\tend", "def system_name\n self.name\n end", "def uid_to_username(uid)\n uid = Integer(uid)\n Etc.getpwuid(uid).name\n end", "def prompt_user\n \"[#{`whoami`.chomp}]\".green\nend", "def uid\n \"#{Socket.gethostname}-#{Process.pid}-#{thread_id}\"\n end", "def to_s\n\t\tself.name.present? ? \"#{self.name}\" : \"#{self.user}\" ;\n\tend", "def user_name\n user ? user.name : ''\n end", "def user_name\n user ? user.name : ''\n end", "def user_name\n user ? user.name : ''\n end", "def user_name\n user ? user.name : ''\n end" ]
[ "0.76619476", "0.7593824", "0.7580131", "0.75659436", "0.7537774", "0.7537774", "0.73637843", "0.7309964", "0.7252067", "0.7183811", "0.71215916", "0.7020186", "0.7012508", "0.69794655", "0.69579184", "0.6932179", "0.6868921", "0.686678", "0.6831591", "0.68000525", "0.67917883", "0.6778499", "0.6756488", "0.67350817", "0.66929185", "0.6649239", "0.66454583", "0.6637424", "0.6633032", "0.6629642", "0.66211945", "0.6613919", "0.6578028", "0.6572133", "0.6566819", "0.65125644", "0.648052", "0.647472", "0.6470519", "0.64656657", "0.64621145", "0.6455971", "0.64487183", "0.6446996", "0.64176464", "0.6417499", "0.64162105", "0.6404816", "0.63888437", "0.638618", "0.63793826", "0.6371385", "0.63693905", "0.6351541", "0.63508254", "0.63475716", "0.63475716", "0.63475716", "0.6340844", "0.6334959", "0.63325185", "0.63325185", "0.6331564", "0.6328982", "0.6328465", "0.6323255", "0.63213164", "0.63138115", "0.63105106", "0.6310193", "0.63037336", "0.62937003", "0.62937003", "0.62894475", "0.6283577", "0.6281822", "0.627954", "0.62786776", "0.62723905", "0.62581193", "0.62581193", "0.62555397", "0.62500703", "0.62485516", "0.62393093", "0.62222654", "0.6214055", "0.62062055", "0.6202738", "0.6182803", "0.61465085", "0.6135047", "0.61239177", "0.6123441", "0.61232686", "0.6121215", "0.61196846", "0.61161596", "0.61161596", "0.61161596", "0.61161596" ]
0.0
-1
sends a certain amount of money from the user/org to a another user/org. Raises TradeException if operation failed
def transfer_credits_to(receiver, amount) fail if receiver.nil? raise TradeError, "NOT_ENOUGH_CREDITS " unless self.credits >= amount self.credits -= amount receiver.credits += amount end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_money(amount)\n fail unless amount >= 0\n self.credits += amount\n end", "def transfer(amount, other)\n @balance -= amount\n other.balance += amount\n puts \"#{@owner} your balance will be #{@balance} after the transfering to #{other.owner}\"\n end", "def pay_amount(user, amount)\r\n if(self.credits>= amount)\r\n self.credits= self.credits-amount\r\n user.receive_credits(amount)\r\n else\r\n return 'suddenly you dont have enough money'\r\n end\r\n end", "def transfer_logic(receiver_id, amount)\n receiver = User.find(receiver_id)\n sender = current_user\n sender.credits -= amount\n receiver.credits += amount\n sender.save\n receiver.save\n login(sender)\n end", "def send_money_to(receiver, amount)\n fail if receiver.nil?\n return false unless self.credits >= amount\n\n self.credits -= amount\n receiver.send_money(amount)\n\n fail if self.credits < 0\n\n true\n end", "def transfer_funds()\n vendor = Portfolio.find(self.seller_id)\n customer = Portfolio.find(self.buyer_id)\n amount = self.transaction_cost\n customer.balance -= amount\n vendor.balance += amount\n \n Transactor.transaction do \n raise \"Transaction of funds failed!\" unless customer.save && vendor.save\n end\n end", "def buy(amount)\n @bought_amount += amount if amount_remaining >= amount\n end", "def deposit(user, amount)\n user.with_lock do\n user.my_wallet.balance += amount.to_f\n user.my_wallet.save!\n end\n end", "def social_money_send\n parms = params.require(:sendMoney).permit(:accountid, :amount, :currency, :message, :global)\n social_money_send_internal(parms[:amount], parms[:message], parms[:global], parms[:accountid], parms[:currency])\n end", "def add_money\n\t\t# get current user's money\n \t@user = current_user\n\t\t@money = @user.money\n\t\t# get refill limit\n\t\t@allowed = @user.money_refill\n\n\t\t# if limit has not been reached, add money to account\n\t\tif @allowed > 0\n\t\t\t@user.money = @money + 1000\n\t\t\t@user.money_refill = @allowed - 1\n\t\t\t@user.save\n\t\t\tgflash :success => \"Money Successfully Transferred to your account!\"\n\t\t\tredirect_to :action => 'profile', :username => @user.login\n\t\telse\n\t\t\t# otherwise flash pop up regarding depleted money reserve\n\t\t\tgflash :error => \"You have depleted your money reserve.\"\n\t\t\tredirect_to :action => 'profile', :username => @user.login\n\t\tend\n end", "def run_transfer_of(amount)\n self.balance += amount\n end", "def transfer(amount,to,memo=nil)\n client.post(transaction_url,{:amount=>amount,:to=>to,:memo=>memo}) if client\n end", "def sell_at_any_cost(percent_decrease = 0.3)\n market_name = @market_name\n open_orders_url = get_url({ :api_type => \"market\", :action => \"open_orders\", :market => market_name })\n open_orders = call_secret_api(open_orders_url)\n #cancel all orders\n if open_orders.size > 0\n open_orders.each do |open_order|\n cancel_order_url = get_url({ :api_type => \"market\", :action => \"cancel_by_uuid\", :uuid => open_order[\"OrderUuid\"] })\n call_secret_api(cancel_order_url)\n end\n end\n # call sell bot again with lower profit\n sell_order = sell_bot(percent_decrease)\nend", "def send_money_to(receiver, amount, note=nil)\n debits.create!(receiver: receiver, amount: amount, note: note)\n end", "def spend(amount)\r\n @spend += amount\r\n end", "def give_back_money\n if(@transaction.sender)\n @transaction.sender.balance += @transaction.amount\n @transaction.sender.save\n \n end\n\n if(@transaction.receiver)\n @transaction.receiver.balance -= Monetize.parse(convert(Money.new(@transaction.amount,findCurrency(@transaction.sender_id,@transaction.receiver_id,'sent')), @transaction.receiver.currency)).fractional\n @transaction.receiver.save\n end\n end", "def sell(amount)\n tokens_sold = amount.to_f\n\n @token_reserve += tokens_sold\n new_ether_reserve = @konst / @token_reserve\n\n ether = @ether_reserve - new_ether_reserve\n price = sprintf(\"%0.4f\", ether / tokens_sold)\n log \"You get #{ether} ether for #{tokens_sold} tokens, price #{price}\" # This is where we send ETH to the seller\n\n @ether_reserve = new_ether_reserve\n output\n\n return ether\n end", "def transfer_to_stakeholders_account params\n Notifyer.print( 'Stake#transfer_to_stakeholders_account' , params: params ) if Rails.env.development?\n \n \n begin\n order_item = Shop::OrderItem.cached_find( params[:order_item_id] )\n params[:application_fee] = Admin.digiramp_fees( params[:amount] )\n\n \n # sending transfers with same sender and recipient will fail\n begin\n send_micro_transaction params\n rescue => e\n errored('Stake#transfer_to_stakeholders_account', e ) unless Rails.env.development?\n Notifyer.print( 'Stake#transfer_to_stakeholders_account' , \"Not sending money to origin account\" ) if Rails.env.development?\n end\n \n update_income params\n\n rescue => e\n errored('Stake#transfer_to_stakeholders_account', e )\n end \n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def sell_to(player, amount = cost)\n\t\t\tamount = amount.to_int\n\t\t\tif player.balance < amount\n\t\t\t\tplayer.game.log '[%s] Unable to buy %s! (short of cash by £%d)' % [ player.name, @name, ( amount - player.balance ) ]\n\t\t\t\tfalse\n\t\t\telse\n\t\t\t\tif @owner\n\t\t\t\t\tTransaction.new(to: @owner, from: player, amount: amount.to_i, reason: 'property trade')\n\t\t\t\t\tplayer.game.log '[%s] Sold %s%s to %s for £%d (new balance: £%d)' % [ @owner.name, @name, (is_mortgaged? ? ' (mortgaged)' : ''), player.name, amount, @owner.balance ]\n\t\t\t\t\t@owner.remove_property(self)\n\t\t\t\telse\n\t\t\t\t\tTransaction.new(to: player.game.bank, from: player, amount: amount.to_i, reason: 'property purchase')\n\t\t\t\t\tplayer.game.log '[%s] Purchased %s%s for £%d (new balance: £%d)' % [ player.name, @name, (is_mortgaged? ? ' (mortgaged)' : ''), amount, player.balance ]\n\t\t\t\tend\n\n\t\t\t\tplayer.add_property(self)\n\t\t\t\t@owner = player\n\t\t\tend\n\t\tend", "def transfer(amount, address)\n amount = cast_amount(amount)\n raise Mobius::Client::Error::InsufficientFunds if app_balance < amount\n submit_tx { |operations| operations << payment_op(amount, dest: address, src: user_keypair) }\n rescue Faraday::ClientError => err\n handle(err)\n end", "def transfer_funds_to(amount, target)\n self.balance -= amount\n target.balance += amount\n Account.transaction do\n raise \"Transaction Failed\" unless self.save && target.save && self.balance >0\n end\n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def withdraw!(amount, destination_account_id, dedupe_id = SecureRandom.uuid)\n data = {\n amount: amount,\n destination_account_id: destination_account_id,\n dedupe_id: dedupe_id,\n }\n\n response = Monzo.client.put(\"/pots/#{@id}/withdraw\", data)\n parsed_response = parse_response(response)\n update_self(parsed_response)\n end", "def deposit(money_to_deposit)\n @balance += money_to_deposit\n end", "def sell_stock(user)\n quote = Stock.stock_quote(Stock.all.find(self.stock_id).symbol)\n sell_trade = Trade.create(status: \"pending\", investor_id: user.id, num_shares: self.num_shares,\n stock_price: quote.delayed_price, bought_sold: \"In progress\", stock_id: self.stock_id, date: Date.today)\n sell_trade.purchase_price = quote.delayed_price * sell_trade.num_shares\n user.deposit_funds(sell_trade.purchase_price)\n original_order = Trade.all.find(self.id)\n original_order.bought_sold = \"sold\"\n original_order.save\n sell_trade.bought_sold = \"sell order\"\n sell_trade.status = \"completed\"\n sell_trade.save\n puts \"\\nCongratulations! You have successfully sold #{sell_trade.num_shares} shares of #{quote.company_name}\"\n end", "def send_money(params)\n fail ArgumentError, 'Hash is expected as params' unless params.is_a?(Hash)\n fail ArgumentError, 'String is expected as :amount' unless params[:amount].is_a?(String)\n fail ArgumentError, 'String is expected as :address' unless params[:address].is_a?(String)\n fail ArgumentError, 'Invalid amount format' unless params[:amount] =~ /^\\d+\\.\\d+$/\n fail ArgumentError, 'Invalid address format' unless params[:address] =~ /^[A-Za-z0-9]+$/\n Cubits.connection.post(\n '/api/v1/send_money',\n amount: params[:amount], address: params[:address]\n )\n end", "def withdraw!(amount, address)\n if amount >= 1000\n fail(FilthyRichError.new(\"#withdraw! take bitcoin amount as parameter (you are trying to withdraw #{amount} BTC\"))\n else\n post('/api/1/generic/bitcoin/send_simple', :amount_int => intify(amount, :btc), :address => address)['trx']\n end\n end", "def put_money(amount, player)\n if amount > player.money\n amount = player.money\n end\n if amount + player.in_pot_current > self.high_bet # if player is new high bet (bets more than current highest)\n self.high_bet = amount + player.in_pot_current\n self.high_better = player.location\n end\n player.money -= amount # puts money in correct places and takes from player's pot\n player.in_pot_current += amount\n player.in_pot_hand += amount\n self.pot += amount\n player.save\n self.save\n end", "def deposit(money)\n @balance += money\nend", "def sell_quote\n\t\tresult = money_quote('ask', btc_float2int(1.0))\n\t\treturn result['amount']\n\tend", "def sell(counterparty, amount)\n tokens = amount.to_f\n ether, @token_reserve, @ether_reserve = trade(tokens, @token_reserve, @ether_reserve)\n price = sprintf(\"%0.4f\", ether / tokens)\n log \"#{counterparty.name} gets #{ether} ether for #{tokens} tokens, price #{price}\" # This is where we send ETH to the seller\n counterparty.ether += ether\n counterparty.tokens -= tokens\n output\n return ether\n end", "def send_credits\n @users = User.all\n receiving_user = User.find(params[:id])\n amount_sent = user_params[:credit].to_i\n sending_updated_credits = current_user.credit - amount_sent\n receiving_updated_credits = receiving_user.credit + amount_sent\n if current_user.update_attributes(credit: sending_updated_credits)\n receiving_user.update_attributes(credit: receiving_updated_credits)\n @transaction = Transaction.create(from: current_user.id, to: params[:id], amount: amount_sent)\n flash[:notice] = \"Sucessfully sent #{amount_sent} credits to #{receiving_user.email}\"\n redirect_to users_url\n else \n flash[:errors] = ['Not enough credits, please add more']\n redirect_to users_url\n end \n end", "def deposit(amount)\n @balance += amount\n @balance\n end", "def deposit(money)\n self.balance = (self.balance + money)\n end", "def deposit(amount_of_money)\n return @balance + amount_of_money\n end", "def do_buy(number)\r\r\n $game_party.lose_currency(@gold_window.currency, number * buying_price)\r\r\n $game_party.gain_item(@item, number)\r\r\n end", "def buy(amount)\n ether = amount.to_f\n\n @ether_reserve += ether\n new_token_reserve = @konst / @ether_reserve\n\n tokens_bought = @token_reserve - new_token_reserve\n price = sprintf(\"%0.4f\", ether / tokens_bought)\n log \"You get #{tokens_bought} tokens for #{ether} ether, price #{price}\" # this is where we would transfer tokens to the buyer\n\n @token_reserve = new_token_reserve\n output\n\n return tokens_bought\n end", "def deposit(amount)\n @balance = @balance + amount\n end", "def transfer(from_, to, amount)\n eth_sendTransaction(from: from_, to: to, value: amount)\n end", "def transfer(amount, destination_account, options={})\n process('transfer', amount, options) do |gw|\n gw.transfer(amount.cents, destination_account, options)\n end\n end", "def call!\n account_from.update_balance!(side: :-, amount: amount)\n account_to.update_balance!(side: :+, amount: amount)\n end", "def transact(sender:, value:, to:)\n sender_account = find_account(sender)\n raise VMError.new(\"balance not enough\") if sender_account.balance < value\n add_touched_account(sender)\n add_touched_account(to)\n state.add_balance(sender, -value)\n state.add_balance(to, value)\n end", "def deposit(amount, *args)\n do_transaction :deposit, amount, *args\n end", "def transfer(to_account, amount)\n to_acc = Account.find_by(id: to_account)\n\n if to_acc.nil?\n self.errors.add(\"Transaction denied! Cannot get data of account.\")\n return\n end\n\n if self.balance<amount\n self.errors.add(\"Transaction denied! Insufficient ballance to cover transfer amount.\")\n return\n end\n\n Transaction.transfer(self.id, to_account, amount, \"A2A\")\n end", "def withdraw(amount)\n amount += TRANSACTION_FEE\n super(amount)\n end", "def withdraw(amount)\n amount += TRANSACTION_FEE\n super(amount)\n end", "def transfer( amount:, to:, from: )\n\t\tself.log.info \"%s --{%0.6f𝓩}--> %s\" % [ from, amount, to ]\n\t\tamount = normalize_amount( amount )\n\n\t\traise \"No such wallet #{to}\" unless self.wallets.include?( to )\n\t\traise \"No such wallet #{from}\" unless self.wallets.include?( from )\n\t\traise \"Can't transfer to same wallet #{to}\" if to == from\n\t\traise \"Wallet #{from} doesn't contain enough to cover #{amount}\" unless\n\t\t\tself.wallet_has_at_least?( from, amount )\n\n\t\tself.add_transaction( amount: amount, to: to, from: from )\n\t\tself.log.info \"transfer complete.\"\n\tend", "def add_money_to_wallet\n puts \"\\n-----------------------\".colorize(:blue)\n puts \"How much more money do you want to add?\".colorize(:red)\n print \"> $\"\n new_money = gets.to_i\n @player.wallet += new_money\n puts \"Your wallet now has: $#{@player.wallet}\".colorize(:blue)\n end", "def withdraw(amount, *args)\n do_transaction :withdrawal, amount, *args\n end", "def close_account\n stocks_qty = self.stocks.group(:stock_symbol).sum(:stock_qty)\n total_amount = 0 # sets variable total_amount to 0\n # iterates through each stock owned by the user, pulls the current price from the stock table\n ## and muplies it by the quantity of stocks owned by user\n stocks_qty.each do |key, value| \n total_amount += (find_stock(key).current_price * value)\n end\n self.update(balance: self.balance += total_amount) # adds the total amount to the users balance\n self.trades.destroy_all # removes all associated trades for that user from the trades table\n puts \"Your account has been closed and funds have been transferred to your account, your current balance is $#{self.balance.round(2)}\" # displays users net worth\n end", "def dispense(amount)\n @balance = @balance - amount\n puts \"hey I gave you #{amount}\"\n end", "def deposit(name, amount)\n find_account(name)[:balance] += amount\n end", "def sell_bot(percent_decrease = 0.1)\n market_name = @market_name\n currency = @currency\n low_24_hr, last_price, ask_price = get_market_summary(market_name)\n sell_price = last_price - percent_decrease*last_price\n get_balance_url = get_url({ :api_type => \"account\", :action => \"currency_balance\", :currency => currency })\n balance_details = call_secret_api(get_balance_url)\n sell_price = \"%.8f\" % sell_price\n if balance_details and balance_details[\"Available\"] and balance_details[\"Available\"] > 0.0\n p [market_name, last_price, balance_details[\"Available\"], sell_price]\n sell_limit_url = get_url({ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price })\n puts \"Selling coin...\".yellow\n p [{ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price }]\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt = 1\n while cnt <= 3 and order_placed and order_placed[\"uuid\"].nil? #retry\n puts \"Retry #{cnt} : Selling coin...\".yellow\n sleep(1) # half second\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt += 1\n end\n p [order_placed, \"Sell #{balance_details[\"Available\"]} of #{market_name} at #{sell_price}\"]\n else\n puts \"Insufficient Balance\".red\n end\nend", "def owes_amount\n loans=@loans\n net_worth=@net_worth\n @balance = net_worth-loans\n print \"the balance is : \",balance,\"\\n\"\n is_developer_solvent?\n end", "def transfer(amount, *args)\n do_transaction :transfer_out, amount, *args\n end", "def give_coins(token, amount)\n raise 'Only Game or action resolvers should call this method' if token != @action_token\n @coins += amount\n end", "def deposit(amount)\n self.balance = (self.balance + amount).round(2)\n self.save!\n end", "def deposit(cash)\n @balance += cash\n end", "def raise_bet(amount)\r\n puts \"\\n%33s\\n\" % \"Player ##{player_id+1} raised $#{amount}.\"\r\n @table.add_player_bet(self, @table.current_bet + amount)\r\n end", "def recv_money(money)\n @money += money\n return money\n end", "def transfer_to(account, amount)\n # `account.name` is accessing the name of the account we are transfering to\n debit amount, \"Transfer to #{account.name}\"\n account.credit amount, \"Transfer from #{@name}\"\n end", "def deduct_wallet\n user = User::find(self.user_id)\n user.budget -= self.pending_money\n user.save\n\n self.pending_money = 0\n self.save\n end", "def withdraw!(amount)\n amount = -amount if amount > 0\n add_transaction(amount)\n\n balance\n end", "def buy_sell_bot(percent_increase = 0.05, chunk = 0.004, prepump_buffer = 0.5, profit = 0.2, splits = 2, no_of_retries = 10)\n market_name = @market_name\n currency = @currency\n low_24_hr, last_price, ask_price = get_market_summary(market_name)\n total_spent = 0.0\n p [low_24_hr, last_price, ask_price]\n if last_price < (1.0 + prepump_buffer)*low_24_hr #last_price is smaller than 50% increase since yerterday\n order = buy_chunk(last_price, market_name, percent_increase, chunk)\n buy_price = last_price + last_price * percent_increase\n counter = 0\n while counter < no_of_retries\n get_balance_url = get_url({ :api_type => \"account\", :action => \"currency_balance\", :currency => currency })\n balance_details = call_secret_api(get_balance_url)\n p balance_details\n if balance_details and balance_details[\"Available\"] and balance_details[\"Available\"] > 0.0 # available coins present\n qty = balance_details[\"Available\"]/splits\n splits.times do |i|\n qty += (balance_details[\"Available\"].to_i % splits) if (i-1 == splits)\n sell_price = buy_price + buy_price * (profit * (i+1))\n sell_price = \"%.8f\" % sell_price\n sell_limit_url = get_url({ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => qty, :rate => sell_price })\n puts \"Selling coin...\".yellow\n p [{ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => qty, :rate => sell_price }]\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt = 1\n while cnt <= 3 and order_placed and order_placed[\"uuid\"].nil? #retry\n puts \"Retry #{cnt} : Selling coin...\".yellow\n sleep(1) # half second\n order_placed = call_secret_api(sell_limit_url)\n puts (order_placed and !order_placed[\"uuid\"].nil? ? \"Success\".green : \"Failed\".red)\n cnt += 1\n end\n p [order_placed, \"Sell #{qty} of #{market_name} at #{sell_price}\"]\n end\n break\n end\n counter += 1\n sleep(0.5)\n end\n end\nend", "def transfer_funds\n @organizer = Organizer.find(params[:id])\n @amount = raw_price(params[:amount])\n @current = raw_price(params[:current])\n\n if params[:amount].nil?\n @status = \"danger\"\n @message_status = \"Você não especificou um valor\"\n return\n end\n\n @bank_account_active_id = @organizer.marketplace.bank_account_active.own_id\n if @bank_account_active_id.nil?\n @status = \"danger\"\n @message_status = \"Você não tem nenhuma conta bancária ativa no momento\"\n else\n if @amount <= @current\n bank_transfer_data = {\n \"amount\" => @amount,\n \"transferInstrument\" => {\n \"method\" => \"BANK_ACCOUNT\",\n \"bankAccount\" => {\n \"id\" => @bank_account_active_id,\n }\n }\n }\n response_transfer = RestClient.post(\"#{Rails.application.secrets[:moip_domain]}/transfers\", bank_transfer_data.to_json, :content_type => :json, :accept => :json, :authorization => \"OAuth #{@organizer.marketplace.token}\"){|response, request, result, &block|\n case response.code\n when 401\n @status = \"danger\"\n @message_status = \"Você não está autorizado a realizar esta transação\"\n @response_transfer_json = JSON.load response\n when 400\n @status = \"danger\"\n @message_status = \"Não foi possíel realizar a transferência\"\n @response_transfer_json = JSON.load response\n when 200\n @status = \"danger\"\n @message_status = \"Não foi possível realizar a transferência\"\n @response_transfer_json = JSON.load response\n when 201\n @status = \"success\"\n @message_status = \"Solicitação de transferência realizada com sucesso\"\n @response_transfer_json = JSON.load response\n MarketplaceMailer.transfer(@organizer, friendly_price(@response_transfer_json[\"amount\"]), l(@response_transfer_json[\"updatedAt\"].to_datetime, format: '%d de %B de %Y as %Hh%M')).deliver_now\n else\n @activation_message = \"Não conseguimos resposta do MOIP para a transferência soliticata, verifique os dados novamente.\"\n @activation_status = \"danger\"\n @response_transfer_json = JSON.load response\n end\n }\n else\n @status = \"danger\"\n @message_status = \"Você não tem fundos suficientes para realizar esta transferência\"\n end\n end\n\n end", "def buy_item(item_to_buy, user)\r\n fail \"only users can buy items in behalve of an organisation\" if (user.organisation)\r\n fail \"only users that are part of #{self.name} can buy items for it\" unless (is_member?(user))\r\n fail \"would exceed #{user.email}'s organisation limit for today\" unless within_limit_of?(item_to_buy, user)\r\n fail \"not enough credits\" if item_to_buy.price > self.credits\r\n fail \"Item not in System\" unless (DAOItem.instance.item_exists?(item_to_buy.id))\r\n\r\n old_owner = item_to_buy.owner\r\n\r\n #Subtracts price from buyer\r\n self.credits = self.credits - item_to_buy.price\r\n #Adds price to owner\r\n old_owner.credits += item_to_buy.price\r\n #decreases the limit of the buyer\r\n @member_limits[user.email].spend(item_to_buy.price) unless self.limit.nil? || is_admin?(user)\r\n\r\n item_to_buy.bought_by(self)\r\n end", "def deposit (amount, account)\n if account == \"checking\"\n @checking_account_balance += amount\n elsif account == \"saving\"\n @saving_account_balance += amount\n else\n puts \"No account was selected\"\n end\n end", "def give_shnack_credit(creditor_id, amount)\n @creditor = User.find(creditor_id)\n creditor.account_credit = creditor.account_credit + amount\n end", "def place_offer(proposer, amount)\n\t\t\tif proposer.balance >= amount\n\t\t\t\tsell_to(proposer, amount) if @owner.decide(:consider_proposed_trade, game: @owner.game, player: @owner, proposer: proposer, property: self, amount: amount).is_yes?\n\t\t\tend\n\t\tend", "def execute_transaction\n#each transfer can only happen once\n if valid? && sender.balance > amount && self.status == \"pending\"\n receiver.balance += amount\n sender.balance -= amount\n self.status = \"complete\"\n else\n#rejects a transfer if the sender doesn't have a valid account\n reject_transfer\n end\n end", "def deposit(amount)\n if (balance < 10000) && (balance + amount >= 10000)\n @balance += amount\n else\n @balance += amount\n @transactions -= 1\n end\n end", "def deposit(amt)\n @bank_acct += amt\n puts \"Your balance is #{@bank_acct}.\"\n end", "def buy\n user = User.find_by_guid(params[:id])\n if user\n user.dollaz -= params[:price].to_i\n PlayerInventory.create(pid: user.id, item_id: params[:item].id)\n user.save!\n render nothing:true, notice: \"Item bought!\"\n else\n render nothing:true, notice: \"Error: unable to purchase item\"\n end\n end", "def deposit(deposit_amount)\n self.balance += deposit_amount\n end", "def buy_item(user, item)\r\n if(self.has_enough_money(item) and user.has_item(item))\r\n self.get_item(user, item)\r\n self.pay_amount(user, item.get_price)\r\n else\r\n #transaction not possible\r\n end\r\n end", "def activemerchant_amount\n (amount * 100).to_i\n end", "def perform(user_id, currency, amount)\n\t\t# Do something later\n\t\tActionCable.server.broadcast \"user#{user_id}\",\n\t\t\tfunction_call: 'transaction',\n\t\t\tcurrency: currency,\n\t\t\tamount: amount\n\n\tend", "def add_stock_to_user(userid, sellerid, stockid, amount)\n\n user_stock_relation = get_user_data('relation_user_stock', userid)\n seller_stock_relation = get_user_data('relation_user_stock', sellerid)\n\n seller_stock_relation.each do |relation|\n if relation['stockid'] == stockid\n if relation['amount'] - amount < 0\n return -1\n end\n end\n end\n\n user_has_stock = false\n user_stock_relation.each do |relation|\n if relation['stockid'] == stockid\n user_has_stock = true\n break\n end\n end\n\n if user_has_stock\n $db.execute('UPDATE relation_user_stock SET amount = amount + ? WHERE stockid = ? AND userid = ?', amount, stockid, userid)\n else\n $db.execute('INSERT INTO relation_user_stock (userid, stockid, amount) VALUES (?, ?, ?)', userid, stockid, amount)\n end\n\n $db.execute('UPDATE relation_user_stock SET amount = amount - ? WHERE stockid = ? AND userid = ?', amount, stockid, sellerid)\n return 0\n end", "def exchange_to(other_currency)\n self.class.bank.exchange(self, other_currency)\n end", "def withdraw(amount)\n @balance = @balance - amount\n end", "def transferMoneyFromCard\n results1 = postTransaction(@current_user[\"id\"], @current_user[\"id\"], params[:money]) # create initial state\n transact = results1.parsed_response # transact object to get the id in the rest of the process\n if results1.code == 201\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"initial\", 0)\n resultsGet = HTTParty.get(\"http://192.168.99.104:3003/credit_card?id=\"+params[:cardId].to_s)\n userA = (resultsGet[\"user_id\"])\n if userA != (@current_user[\"id\"])\n renderError(\"Forbidden\",403,\"current user has no access\")\n return -1\n else\n if (resultsGet[\"amount\"]<(params[:money]).to_i)\n renderError(\"Bad Request\", 400, \"The credit card do not have enough money\")\n else\n actualMoney=checkMoneyUser(userA)\n newMoneyUser=(actualMoney[\"money\"]).to_f + (params[:money]).to_i\n newMoneyCard=resultsGet[\"amount\"].to_i - (params[:money]).to_i\n optionsCd = {\n :body => {\"amount\": newMoneyCard}.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n resultCd = HTTParty.put(\"http://192.168.99.104:3003/credit_cards?id=\"+params[:cardId].to_s, optionsCd)#subtract money from card\n if resultCd.code == 204\n logUpdateCard(params[:cardId], newMoneyCard, 0)\n results2 = updateTransaction(\"pending\", transact[\"id\"])# put pending state\n if results2.code == 204\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"pending\", 0)\n else\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results4.parsed_response, status: results4.code\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n end\n else\n ##########ERROR EN UPDATE A TARJETA###### Se devuelve el dinero a la tarjeta, state incomplete\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: resultCd.parsed_response, status: resultCd.code\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n end\n resultUs = updateMoney(newMoneyUser, userA.to_s) #add money to user\n if resultUs.code == 204\n logUpdateMoney(userA.to_s, newMoneyUser, 0)\n results3 = updateTransaction(\"complete\", transact[\"id\"])# put complete state\n if results3.code == 204\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"complete\", 0)\n subject = \"Transferencia de tarjeta de credito\"\n content = \"Has recibido una transferencia de la cuenta \" + params[:cardId].to_s + \" por valor de $\" + (params[:money]).to_s\n createNotification(@current_user[\"id\"],subject, content, @current_user_notification_key)\n head 201 # transaction created and state complete\n else\n ##########ERROR EN UPDATE TRANSACCION (complete)###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n #le quita al que recibe\n undoUpdateMoney(params[:userid], newMoneyUser.to_f , newMoneyUser.to_f - (params[:money]).to_i)\n #le pone dinero de nuevo a la tarjeta\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results3.parsed_response, status: results3.code\n ##########ERROR EN UPDATE TRANSACCION (complete)###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n end\n else\n ##########ERROR EN UPDATE MONEY###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n #le quita al que recibe\n undoUpdateMoney(params[:userid], newMoneyUser.to_f , newMoneyUser.to_f - (params[:money]).to_i)\n #le pone dinero de nuevo a la tarjeta\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: resultUs.parsed_response, status: resultUs.code\n ##########ERROR EN UPDATE MONEY###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n end\n end\n end\n else\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"incomplete\", 1)\n end\n render json: results1.parsed_response, status: results1.code\n end\n end", "def withdraw(amount)\n @balance -= amount\n end", "def withdraw(amount)\n @balance -= amount\n end", "def deposit(deposit_amount)\n self.balance += deposit_amount\n end", "def transfer(to, amount, options={})\n options = {:limits => [\n PiggyBankAccount::MIN_AMOUNT_TO_TRANSFER_IN_CENTS,\n PiggyBankAccount::MAX_AMOUNT_TO_TRANSFER_IN_CENTS\n ]}.symbolize_keys.merge(options)\n\n amount = amount.abs\n min_amount = if options[:limits].is_a?(Array) && options[:limits].first.is_a?(Money)\n Money.new(1, amount.currency) + options[:limits].first - Money.new(1, amount.currency)\n else\n Money.new((options[:limits] || [0, 0]).first || 0, amount.currency)\n end\n max_amount = if options[:limits].is_a?(Array) && options[:limits].last.is_a?(Money)\n Money.new(1, amount.currency) + options[:limits].last - Money.new(1, amount.currency)\n else\n Money.new((options[:limits] || [0, 0]).last || 0, amount.currency)\n end\n\n return Response.new(false, amount, :transfer, :description => I18n.t('activerecord.errors.messages.transfer_greater_or_equal_to') % {\n :count => min_amount.format\n }) if options[:limits] && amount < min_amount\n return Response.new(false, amount, :transfer, :description => I18n.t('activerecord.errors.messages.transfer_less_or_equal_to') % {\n :count => max_amount.format\n }) if options[:limits] && amount > max_amount\n return Response.new(false, amount, :transfer, :description => I18n.t('activerecord.errors.messages.transfer_destination_invalid')) unless to.is_a?(PiggyBankAccount)\n return Response.new(false, amount, :transfer, :description => I18n.t('activerecord.errors.messages.transfer_self_exclusion')) if to == self\n \n options.delete(:limits)\n result = nil\n transaction do\n I18n.switch_locale(self.owners_locale) do\n result = self.withdraw(amount, options.merge(\n :fee => false,\n :description => TRANSFER_MESSAGE.t % {\n :from_type => self.owner.class.human_name, :from_name => self.owners_name,\n :to_type => to.owner.class.human_name, :to_name => to.owners_name,\n :amount => amount.convert_to(self.currency).format, :original => amount.format}))\n end\n if result.success?\n I18n.switch_locale(to.owners_locale) do\n result = to.deposit(amount, options.merge(:description => TRANSFER_MESSAGE.t % {\n :from_type => self.owner.class.human_name, :from_name => self.owners_name,\n :to_type => to.owner.class.human_name, :to_name => to.owners_name, \n :amount => amount.convert_to(to.currency).format, :original => amount.format}))\n end\n end\n end\n if result.success?\n Response.new(true, amount, :transfer, :description => result.message)\n else\n result\n end\n end", "def add_to_balance\n self.user.balance += self.price\n self.user.save\n end", "def transfer(other_client)\n volume = @options[:volume]\n transfer_btc(volume, other_client)\n end", "def sell(btc_int_value, price_per_btc = nil)\n\t\tprice_per_btc = sell_quote if price_per_btc == nil\n\t\tusd_int_value = btc_int2float(btc_int_value) * price_per_btc\n\t\ttransaction(:btc, -btc_int_value, :spent)\n\t\ttransaction(:usd, +usd_int_value, :earn)\n\t\ttransaction(:usd, -usd_int_value * fee, :fee)\n\t\tcommit_transactions\n\tend", "def place_bet(amount)\n @total_money -= amount\n end", "def transfer(amount, destination_account, options={})\n process('transfer', amount) do |gw|\n gw.transfer(amount, destination_account, options)\n end\n end", "def update_value(quantity)\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# quantity == crypto value NOT USD\n\t\t# debugger\n\n\t\tif quantity > 0\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# BUY \n\t\t\tself.total_value = self.total_value + quantity\t\t\t# increment wallet value by quantity\n\t\telse \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t# SELL\n\t\t\tself.total_value = self.total_value + quantity\t\t\t# quantity is Negative!! so adding, will decrement\n\t\tend\n\n\t\tsave!\n\tend", "def withdraw(amount)\n raise ArgumentError.new \"You have run out of transactions\" if @transactions == 0\n if balance < 10000\n puts \"You cannot make any more transactions until you are over $10,000\"\n elsif balance - amount < 10000\n amount += 100\n @balance -= amount\n @transactions -= 1\n else\n @balance -= amount\n @transactions -= 1\n end\n end", "def buy\n outcome_id = params[:outcome_id]\n outcome = Outcome.find(outcome_id)\n\n if outcome.market.is_closed\n flash[:error] = \"Market is closed\"\n return redirect_to outcome.market \n end\n \n current_position = outcome.position_for_user(current_user)\n\n share_count = (params.include? :buy_share_count) ? params[:buy_share_count].to_i : 10\n\n if share_count < 0\n flash[:error] = \"Invalid share count\"\n return redirect_to outcome.market \n end\n\n total_shares = share_count\n if outcome.shares_available < share_count\n flash[:error] = \"There are not enough shares available\"\n return redirect_to outcome.market \n end\n\n if ! current_position.nil?\n total_shares += current_position.total_user_shares\n end\n \n current_price = outcome.buy_price(share_count)\n \n position = Position.new(\n :outcome => outcome, \n :user => current_user, \n :delta_user_shares => share_count,\n :delta_user_account_value=> -1 * share_count * current_price,\n :total_user_shares => total_shares,\n :direction => :buy,\n :outcome_price => current_price\n )\n \n if position.save\n logger.info \"Created position: \" + position.to_s\n current_user.cash = current_user.cash + position.delta_user_account_value\n current_user.save\n flash[:message] = \"Buy successful -- %.2f shares @ $%.2f cost %.2f\" % \n [position.delta_user_shares, position.outcome_price, -1 * position.delta_user_account_value]\n\n outcome.market.had_sale(position)\n outcome.market.save\n \n clear_caches(outcome)\n redirect_to outcome.market\n else\n flash[:error] = position.errors\n \n redirect_to outcome.market\n end\n \n end", "def sell_all_bot(profit_rate = 0.2)\n markets_url = get_url({ :api_type => \"public\", :action => \"markets\" })\n markets = call_api(markets_url)\n expected_worth = 0.0\n markets.each do |market|\n currency = market[\"MarketCurrency\"]\n base_currency = market[\"BaseCurrency\"]\n market_name = market[\"MarketName\"]\n if market[\"IsActive\"] and base_currency == \"BTC\"\n get_balance_url = get_url({ :api_type => \"account\", :action => \"currency_balance\", :currency => currency })\n balance_details = call_secret_api(get_balance_url)\n if balance_details[\"Available\"] and balance_details[\"Available\"] > 0.0 #purchased coins\n orders_history_url = get_url({ :api_type => \"account\", :action => \"market_orders_history\", :market => market_name })\n orders_history = call_secret_api(orders_history_url)\n net_value = 0.0\n orders_history.each do |order|\n net_value += order[\"Price\"] if order[\"OrderType\"] == \"LIMIT_BUY\"\n net_value -= order[\"Price\"] if order[\"OrderType\"] == \"LIMIT_SELL\"\n end\n if net_value > 0 # buys are more, we need to get more than this net value by selling available coins\n sell_price = (net_value + net_value*profit_rate)/balance_details[\"Available\"]\n sell_price = \"%.8f\" % sell_price\n sell_limit_url = get_url({ :api_type => \"market\", :action => \"sell\", :market => market_name, :quantity => balance_details[\"Available\"], :rate => sell_price })\n order_placed = call_secret_api(sell_limit_url)\n p [order_placed, \"for #{market_name} at #{sell_price}\"]\n end\n expected_worth += (net_value + net_value*profit_rate)\n end\n end\n end\n p [\"Expected Worth=\", expected_worth]\nend" ]
[ "0.7407845", "0.6859771", "0.68348825", "0.68243057", "0.6739805", "0.6675821", "0.6639141", "0.6617399", "0.6584416", "0.6527296", "0.65162516", "0.6511019", "0.64488953", "0.6440366", "0.6419267", "0.64138186", "0.64058757", "0.63811177", "0.635775", "0.635775", "0.63569605", "0.6355964", "0.6348885", "0.6332963", "0.63324875", "0.63316494", "0.63316494", "0.63316494", "0.63268673", "0.63179237", "0.6310386", "0.63009936", "0.6286987", "0.6252781", "0.6247955", "0.62386364", "0.6226115", "0.62223464", "0.62199813", "0.6212214", "0.62100863", "0.62014", "0.61959577", "0.61925155", "0.61821556", "0.61757654", "0.616679", "0.6142245", "0.61412746", "0.61387396", "0.6128986", "0.6128986", "0.6121175", "0.61082363", "0.6105405", "0.6095024", "0.60945016", "0.6087036", "0.6078023", "0.6075342", "0.6074872", "0.6063471", "0.6051904", "0.6044872", "0.6038573", "0.6028379", "0.60247445", "0.6020598", "0.60150284", "0.60108304", "0.6006558", "0.6006408", "0.5986518", "0.59863627", "0.5986317", "0.59800583", "0.5973781", "0.5972129", "0.59635556", "0.5961112", "0.59586763", "0.5954472", "0.5946187", "0.59385145", "0.59323066", "0.5922193", "0.5916185", "0.5911468", "0.5909608", "0.59079903", "0.5896873", "0.5892832", "0.58902097", "0.5879874", "0.58774185", "0.5875191", "0.5874066", "0.5872394", "0.5864003", "0.58597696" ]
0.66593105
6
save time for item page
def acknowledge_item_properties! self.open_item_page_time = Time.now end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(item_description)\n @description = item_description\n @completed_status = false\n @created_time = Time.now.strftime(\"%H:%M\") #Time now\n @due_time = (Time.now + 18000).strftime(\"%H:%M\") # TIme now = 5hrs\n end", "def get_time\n @time = Time.now.strftime(\"%H:%M:%S \")\n render \"store/date\"\n #render partial: \"store/date\"\n end", "def get_enqueue_time\n return Time.parse(self.item[:get_item_response][:item][:listing_details][:end_time]).localtime - Time.now - 300 \n end", "def add_timestamp\n @item.timestamp = @bib.fetched.to_s if @bib.fetched\n end", "def story_time\n touch(@@detailsheader)\n sleeper(30)\n end", "def give_time\n @time = Time.now.strftime(\" %H:%M:%S \")\n\n render :partial => 'shared/time_portion'\n end", "def time\n request :public, :get, :time\n end", "def time\n super\n end", "def time; end", "def time; end", "def time; end", "def time; end", "def time; end", "def time; end", "def time; end", "def time; end", "def time; end", "def last_used_item(); $game_temp.last_used_item; end", "def set_time_table_item\n @time_table_item = TimeTableItem.find(params[:id])\n end", "def now\n cache\n end", "def modify_time(); @modify_time ||= Time.now; end", "def start_time\n item_hash.deep_find([:listing_details, :start_time])\n end", "def time\n end", "def time_to_show\n \n end", "def time\n @time\n end", "def create_time(); @create_time; end", "def end_time\n item_hash.deep_find([:listing_details, :end_time])\n end", "def action_by_admin\n @current_time = Home.last_cut_off_time.first\n end", "def last_modified_at(page)\n Gtn::ModificationTimes.obtain_time(page['path'])\n end", "def time\n\n end", "def show_time\n\n end", "def time_compare(create_time, expire_time, item, item_elem)\n time_left = expire_time - Time.now\n hours = ((time_left)/3600).to_i\n minutes = minutes = (time_left/60 - hours * 60).to_i\n if time_left > 0\n return \"<p><strong>This is your #{item}, and you have #{hours} hours, #{minutes} minutes left if you want to edit it. Just click on the #{item_elem}, and you can change it right here! Basic HTML tags and emoji are permitted.</strong></p>\".html_safe\n else\n return \"<p><strong>This is your #{item}, but your time period for editing it has expired.</strong></p>\".html_safe\n end\n end", "def show\n @question = Question.find(params[:id])\n @question.start_time = Time.now\n @question.save\n\n end", "def store_interest_update\n self.last_interest_update = Time.now\n end", "def setPageTimer\n\t\t@pageTimer= Time.now.to_i+ @pageTimeOut\n\t\treturn OK\n\tend", "def now\n cache\n end", "def now\n cache\n end", "def just_saw\n\t\t\t@last_seen = Time.now\n\t\tend", "def visit!\n self.duration = [(Time.now - self.updated_at).to_i, 15 * 30].min # if user stay on page more than 15 min\n self.visits += 1\n self.save!\n end", "def time\r\n\t\t@usr_time\r\n\tend", "def load_time\n @time_counter = Time.new.to_i\n end", "def edit_time_left(item)\n diff = Time.now - item.updated_at\n expire_rate = APP_CONFIG[:edit_expiration_in_minutes].to_i\n return expire_rate > 0 ? expire_rate - (diff.to_i / 60) : nil\n end", "def time\n return @time\n end", "def restore_times; end", "def restore_times; end", "def save_file\n\tcounter = 1;\n\ttime = Time.now.strftime(\"%d/%m/%Y\")\n\treport_file_puts \"\"\n\treport_file_puts \"Title of saved TodoList: #{@title}\"\n\treport_file_puts \"Save time: #{time}\"\n\treport_file_puts \"----------------------------\"\n\t\t@items.each do |item|\n\n\t\treport_file_puts \"#{counter.to_s} #{item.description} Completion status: #{item.completed_status.to_s}\"\n\t\tcounter +=1;\t\n\tend\t\nend", "def utime=(*) end", "def update\n\t\t\t@last_run = Time.new\n\t\tend", "def last_edited_time\n begin\n $redis.hget 'last_edit:instrument', self.id\n rescue\n nil\n end\n end", "def item=(item)\n @item = item\n refresh\n end", "def setTime(time)\n\t\t@time = time\n\tend", "def current_item\n shoping_cart.most_recent_item\nend", "def time\n set_function_and_argument(:time, nil)\n end", "def atime() end", "def atime() end", "def used\n update(last_used: DateTime.now)\n end", "def send_time\n\t\t self.created_at.strftime(\"%Y-%m-%d %H:%M:%d\")\n\t\tend", "def new_price_time\n indexes = Quote.get_indexes\n message = '| S&P 500: ' + indexes[1]['LastTrade'] +\n ' ' + indexes[1]['Change'] + ' , Nasdaq: ' +\n indexes[0]['LastTrade'] + ' ' + indexes[0]['Change'] +\n# ' | Refresh in: ' + (3600 - ('%.0f' % (Time.now - Stock.last.updated_at).to_s).to_i).to_s + ' secs'\n ' | Prices are ' + '%.0f' % (Time.now - Stock.last.updated_at).to_s + ' secs old'\n npt = Hash.new\n npt['time_next'] = message\n render :json => npt\n \n end", "def get_current_time\n current_time = Time.strptime((page.find('.ytp-time-current').text),\"%H:%S\")\n return current_time\nend", "def touch!\n @created = Time.now.to_i\n end", "def log_page(page)\n time = Time.now\n content = page.output.gsub /::time::/ do\n \"<time datetime='#{time.utc.iso8601}'>#{time.localtime.strftime('%Y-%m-%d %H:%M:%s')}</time>\"\n end\n \n file = page.destination page.site.config['destination']\n File.open(file, 'w') { |f| f.write content }\n end", "def acknowledge_item_properties!\n self.open_item_page_time = Time.now\n end", "def productionTime\n\tself.item.base_blueprint.productionTime\nend", "def cooking_time\n end", "def time\n params['time']\n end", "def bookmark_time\n @ole.BookmarkTime\n end", "def time\n Time.now.to_f\n end", "def page_load=(seconds); end", "def timestamp; end", "def timestamp; end", "def timestamp; end", "def timestamp; end", "def timestamp; end", "def timestamp; end", "def addtime\n \n end", "def times\n MustachePanel.times.map do |key, value|\n { :key => key, :value => value }\n end\n end", "def setTime\n\t\t\t@time=0\n\tend", "def time\n (published_at || created_at).try :in_time_zone\n end", "def time\n Time.now.strftime(\"%Y/%m/%d %H:%M:%S\")\n end", "def store_last_etm_page\n render_not_found && return unless @interface.current_tab\n\n tab_key = @interface.current_tab.key\n sidebar_key = @interface.try(:current_sidebar_item).try(:key)\n slide_key = @interface.try(:current_slide).try(:short_name)\n\n Current.setting.last_etm_page =\n play_url(tab_key, sidebar_key, slide_key)\n end", "def new_item\n pause(item_delay) if item_delay\n self[:index] = nil\n self[:value] = nil\n end", "def expires_now; end", "def ebay_time\n\t\t@caller.make_shop_call 'GeteBayTime'\n\tend", "def after_update(page)\n expire_cache_for(page)\n end", "def slideshow_time\n end", "def create_time=(time)\n @create_time = time\n update_times\n end", "def time=(new_time)\n @time = new_time\n end", "def save_items(rss_id)\n feed_publication_date = Feed.where(\"rss_link_id = ?\", rss_id).maximum(:publication_date)\n @data[:items].each do |item|\n puts \"^\" * 50\n puts item[:publication_date]\n puts Time.parse(item[:publication_date])\n # if feed_publication_date.present? ? (Time.parse(item[:publication_date]) > feed_publication_date) : true\n params = {\n :title => item[:title],\n :description => ActionController::Base.helpers.strip_tags(item[:description]),\n :link => item[:link],\n :author => item[:author],\n :publication_date => item[:publication_date],\n :media_contents => item[:media_contents],\n :media_description => item[:media_description],\n :media_credit => item[:media_credit],\n :keywords => item[:keywords].join(\",\"),\n :rss_link_id => rss_id\n }\n f = Feed.new(params)\n if f.save\n activity = Activity.new({:action => \"Create\", :parent_id => rss_id, :parent_type => \"RssLink\", :data => params}) \n activity.save\n puts \"*\" * 50\n #puts \"Title: \" + item[:title]\n #puts \"Description: \" + item[:description]\n #puts \"Link: \" + item[:link]\n puts \"dc:creator: \" + item[:author] if item[:author]\n #puts \"pubDate: \" + item[:publication_date]\n puts \"media:content : \" + item[:media_contents].inspect if item[:media_contents] \n puts \"media:description : \" + item[:media_description] if item[:media_description]\n puts \"media:credit : \" + item[:media_credit] if item[:media_credit]\n puts \"keywords : \" + item[:keywords].inspect if item[:keywords]\n end\n # end\n end\n end", "def analyze_listing formatted_time\n return unless @stats[RECORDS_LISTING_KEY]\n @stats[RECORDS_LISTING_KEY].each do |action|\n action.save(formatted_time,nil)\n end\n end", "def location_time\n loc_time = Menu.new(\"What would you like to do with movie time/theatre slots?\")\n loc_time.add_menu_item({key_user_returns: 1, user_message: \"Create a new theatre/time slot.\", \n do_if_chosen: \"create/location_time\", parameters:[LocationTime, \"location_time\"]})\n loc_time.add_menu_item({key_user_returns: 2, user_message: \"Update a theatre/time slot.\", \n do_if_chosen: \"update/location_time\", parameters:[LocationTime, \"location_time\"]})\n loc_time.add_menu_item({key_user_returns: 3, user_message: \"Show me theatre/time slot.\", \n do_if_chosen: \"show/location_time\", parameters:[LocationTime, \"location_time\"]})\n loc_time.add_menu_item({key_user_returns: 4, user_message: \"Delete a theatre/time slot.\", \n do_if_chosen: \"delete/location_time\", parameters:[LocationTime, \"location_time\"]})\n loc_time.add_menu_item({key_user_returns: 5, user_message: \"Return to main menu.\", do_if_chosen: \"home\"})\n loc_time \n end", "def after_update(playlist)\n if playlist.god_like == true\n expires_page(:controller => :main, :page => :index)\n expires_page(:controller => :main, :page => :radio)\n #expires_page(:controller => :main, :page => :track)\n end\n end", "def clock_in_time\n \tself.created_at.strftime(\"%H:%M %p\")\n end", "def report_time time\n end", "def expire_time(key)\n @store[key].expires_at\n end", "def start_time\n session[:start_time] ||= (Time.now).to_s\nend", "def after_update\n #If trip_report is on the front page then expire the front page trip reports fragment\n if @trip_report.created_at >= TripReport.order('created_at DESC').limit(9)[-1].created_at\n expire_fragment(:controller => 'main', :action => 'index', :part => 'trips_and_albums')\n end\n expire_fragment(:controller => 'main', :action => 'updated', :part => 'trips_and_albums')\n expire_fragment(:controller=>\"trip_reports\", :action=>\"show\", :id => @trip_report, :part => \"description_#{@trip_report.id}\")\n \n after_save()\n end", "def knows_item_properties?(item)\r\n !(self.open_item_page_time < item.edit_time)\r\n end", "def time=(value)\n @time = value\n end", "def start_time; end", "def wash\n @last_wash = Time.now\n end" ]
[ "0.62111086", "0.61838603", "0.6096088", "0.5926099", "0.59230864", "0.59115034", "0.59008425", "0.58849764", "0.5861833", "0.5861833", "0.5861833", "0.5861833", "0.5861833", "0.5861833", "0.5861833", "0.5861833", "0.5861833", "0.58504725", "0.5848829", "0.58429843", "0.5821672", "0.58121717", "0.5809473", "0.5785532", "0.5784603", "0.5736278", "0.5733458", "0.5654363", "0.56332016", "0.5627813", "0.5624241", "0.5619104", "0.5612925", "0.56116736", "0.5607679", "0.5602921", "0.5602921", "0.56009597", "0.5600286", "0.5599851", "0.5593264", "0.5582855", "0.5562938", "0.5533956", "0.5533956", "0.5525585", "0.5519582", "0.5518496", "0.5507854", "0.550176", "0.54943115", "0.54813254", "0.5470851", "0.5470394", "0.5470394", "0.54678994", "0.5460886", "0.5455265", "0.5455136", "0.5451198", "0.5448835", "0.5446673", "0.54423696", "0.54412615", "0.54281425", "0.54171723", "0.53801614", "0.5376639", "0.53747934", "0.53747934", "0.53747934", "0.53747934", "0.53747934", "0.53747934", "0.53741217", "0.53720117", "0.53682804", "0.53603005", "0.53601867", "0.53561497", "0.53532624", "0.53530157", "0.5349138", "0.5347837", "0.53413004", "0.53351194", "0.53343666", "0.53291243", "0.53276014", "0.5327311", "0.5325514", "0.53222066", "0.53194207", "0.530852", "0.5308117", "0.53072506", "0.5298531", "0.52956915", "0.52865666", "0.5285885" ]
0.5755125
25
returns true when user is aware of latest changes to item, false otherwise
def knows_item_properties?(item) !(self.open_item_page_time < item.edit_time) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def updated?\n updater && author != updater\n end", "def stale?\n unlocked? and item.has_attribute?(:updated_at) and updated_at < item.updated_at\n end", "def notified? \n \titem = Item.find(item_id)\n \tif(item.expired? == true && notifiy == false)\n \t\treturn false\n \telse\n \t\treturn true\n \tend\n end", "def has_changes?\n @has_updated || @has_created\n end", "def being_modified?(item)\n state_group(item) == :edit\n end", "def update?\n if @w_up_to_date && true #all up_to_date-caches!!!\n @up_to_date = true\n return @up_to_date\n end\n false\n end", "def user_access_controls_updated?\n if @latest_user_access_control != Admin::UserAccessControl.latest_update\n @latest_user_access_control = Admin::UserAccessControl.latest_update\n else\n false\n end\n end", "def has_changes?\n @has_changed_the_db\n end", "def any_updates?\n change_history.size > 1\n end", "def any_updates?\n change_history.size > 1\n end", "def stale_approval?\n ActsAsApprovable.stale_check? and update? and stale?\n end", "def changed?\n if update_type == :no_change\n false\n else\n true\n end\n end", "def fresh?(user)\n if user.real?\n last_viewed_at = MockView.last_viewed_at(self, user)\n !last_viewed_at || (self.updated_at > last_viewed_at)\n else\n false\n end\n end", "def up_to_date?\n lu = latest_stored_update\n\n if !lu && !@prev_latest_update\n # They match if both nil\n true\n elsif lu && @prev_latest_update && (lu - @prev_latest_update).abs < 2\n # Consider them a match if they are within 2 seconds of one another,\n # accounting for the difference between Rails and DB times\n true\n elsif @prev_latest_update.nil?\n # The remembered value was nil, so let the caller know this\n self.prev_latest_update = lu\n nil\n else\n # There was no match\n self.prev_latest_update = lu\n false\n end\n end", "def updateable?\n return true if @cursor == STOP\n now = Time.now\n @last_update ||= now\n now - @last_update > UPDATE_DELAY\n end", "def updatable?\n sir_item.sir_entries.last.id == id\n end", "def changed_notably?\n if @is_touch && changes_in_latest_version.empty?\n true\n else\n super\n end\n end", "def updated?\n false\n end", "def can_update?\n object.updatable_by?(current_user)\n end", "def should_notify?\n self.created_at == self.updated_at\n end", "def recent?\n (!self.available_on.nil? && self.available_on >= self.class.recent_on && self.available_on < self.class.new_on)\n end", "def changed?\r\n @changed\r\n end", "def check_for_changes\n publish = false\n activity_columns = ['exercise_minutes', 'exercise_steps']\n points_columns = ['exercise_points', 'behavior_points']\n columns_to_check = activity_columns + points_columns\n columns_to_check.each{|column|\n if self.send(column).to_i != self.send(column + \"_was\").to_i\n publish = true\n if points_columns.include?(column)\n #self.team_member_update\n end\n end\n }\n\n # check for changed exercise activities\n eas = self.exercise_activities.collect{|ea|ea.id}\n ras = self.user.recent_activities(true)\n new_ras = eas.reject{ |ea| ras.include?(ea) }\n if !new_ras.empty?\n publish = true\n end\n\n if publish\n u = self.user\n u.attach('stats', u.stats())\n $redis.publish('userUpdated', u.as_json.to_json)\n end\n end", "def can_make_changes?\n if not is_in_admin_mode?\n for obj in @name.namings + @name.observations\n if obj.user_id != @user.id\n return false\n end\n end\n end\n return true\n end", "def content_changed?\n changed? && changes.keys != ['is_current']\n end", "def updatable\n can_update?\n end", "def updated?() updated.present?; end", "def knows_item_properties?(item)\n !(self.open_item_page_time < item.edit_time)\n end", "def change_item_set?\n self.change_item\n end", "def will_record_after_update?\n on = @record.paper_trail_options[:on]\n on.nil? || on.include?(:update)\n end", "def updated?\n self.connected && self.updated\n end", "def updated?\n return @_updated\n end", "def can_update?\n asset_event_type.active && transam_asset.replacement_status_type_id != ReplacementStatusType.find_by(name: 'Pinned').id\n end", "def modified?\n @modified\n end", "def change?\n updated? || deleted?\n end", "def dirty?\n @changes && @changes.size > 0\n end", "def modified?\n\t\treturn self.status == 'M'\n\tend", "def user_roles_updated?\n @latest_user_role != Admin::UserRole.latest_update\n end", "def modified?\r\n @modified\r\n end", "def modified?\n !items.nil? && items.any?{|item| item_modified?(0, item: item)}\n end", "def updated?\n !ignore? && !removed? && mtime != File.mtime(path)\n end", "def was_reactivated?\n return false if self.status == 1 || self.version == 1\n VestalVersions::Version.find_by_versioned_id(self.id).modifications.has_key?('status')\n end", "def changed? \n @changed == true\n end", "def after_update\n true\n end", "def up_to_date?\n return not_covered.count > 0 ? false : true\n end", "def changed?\n changes.changed?\n end", "def updateable?\n false\n end", "def _active_remote_track_changes?\n @_active_remote_track_changes != false\n end", "def checked_for_updates\n @@checked_for_updates\n end", "def has_updates?\n self['newUpdatesFlag']\n end", "def self_update?(user)\n self.is_self_audit? && self.is_self_auditor?(user)\n end", "def editable?\n if self.is_latest_version? && self.quote_status == 0\n true\n else\n false\n end\n end", "def changed?\n @changed\n end", "def manually_added?\n if credit_note_items.size == 1\n return true if credit_note_items.first.source_type == 'User'\n end\n false\n end", "def dirty?\n @changes.length > 0\n end", "def editable_by?(user)\n if self.status == :private\n self.user == user || self.featurings.map(&:user).include?(user)\n elsif status == :temporary\n true # XXX FIXME SECURITY HOLE RIGHT HERE: ANY USER CAN MODIFY TEMP SONGS FIXME\n elsif status == :public\n false\n end\n end", "def published?\n published_at && published_at == edited_at\n end", "def published?\n published_at && published_at == edited_at\n end", "def changed?\n\t\treturn self.changed_reason ? true : false\n\tend", "def modified?\n @modified\n end", "def modified?\n @modified\n end", "def changed?\n @changed\n end", "def able_to_set_updated_at?\n !frozen? && !timeless? && (new_record? || changed?)\n end", "def sticky?\n revision.stickied == 1\n end", "def updated?\n command.success?\n end", "def updated?(new_payload)\n payload != new_payload\n end", "def ever_tracked?\n !!last_tracked_at\n end", "def changed?\n true\n end", "def changed?\n !!@changed\n end", "def can_be_modified?\n self.offerings.each do |o|\n return false if o.can_be_deleted? == false\n end\n return true\n end", "def has_changes_to_save?\n mutations_from_database.any_changes?\n end", "def recently_activated?\n @activated\n end", "def updatable?\n true\n end", "def modified?\n\t\t@modified\n\tend", "def updated_as_aggregated?\n !!@updated_as_aggregated\n end", "def can_update?\n if [\"approved\"].include? state\n false\n else\n true\n end\n end", "def update?\n owner?\n end", "def modified?\n\t\treturn @dirty ? true : false\n\tend", "def update_available?()\n update_info != \"\"\n end", "def item_modified? idx, item: nil\n return false if items.nil?\n item ||= items[idx]\n item.has_key?(:ori_data) || item[:status] == :deleted\n end", "def has_changed?\n updated_at > 8.hours.ago\n end", "def is_login_save?(user)\n\t\tuser.changed? && user.changed.length == 2 && user.changed.include?(\"updated_on\") && user.changed.include?(\"last_login_on\")\n\tend", "def recently_changed_email?\n @change_email\n end", "def update?\n true\n end", "def fresh_at?(time)\n time >= updated_at\n end", "def fetch_saved?\n super and available_quantity_changed?\n end", "def requires_update?\n\t\tif @twitter_account.new_record? || @twitter_account.name.nil?\n\t\t\treturn true\n\t\tend\n\n\t\treturn Time.now - @twitter_account.updated_at > 60 * CACHE_DURATION\n\tend", "def modifiable?\n !(self.complete? || self.ready_to_post?)\n end", "def update?\n return true if event_planner? || super_admin?\n\n my_record? && !registration_closed?\n end", "def backlist?\n (!self.available_on.nil? && self.available_on < self.class.recent_on)\n end", "def recently_activated?\n @just_activated\n end", "def need_update?\n return true unless @lastread\n @lastread < File::stat(@path).mtime\n end", "def recently_activated?\n @activated\n end", "def recently_activated?\n @activated\n end", "def recently_activated?\n @activated\n end", "def recently_activated?\n @activated\n end", "def recently_activated?\n @activated\n end", "def recently_activated?\n @activated\n end", "def recently_activated?\n @activated\n end", "def recently_activated?\n @activated\n end" ]
[ "0.72555524", "0.7141727", "0.7061713", "0.7020555", "0.691659", "0.68981385", "0.6887284", "0.6882717", "0.68728644", "0.68728644", "0.6866883", "0.6841455", "0.6839733", "0.6826875", "0.6818973", "0.67970276", "0.6792768", "0.6774203", "0.6762768", "0.6711058", "0.6681324", "0.6673418", "0.66610193", "0.6655338", "0.66547376", "0.66494095", "0.664447", "0.6638683", "0.66338986", "0.66327786", "0.6620701", "0.6616636", "0.6616177", "0.6613232", "0.66061807", "0.66019654", "0.6600841", "0.6593936", "0.65896946", "0.6586872", "0.65796435", "0.6551373", "0.6547585", "0.65466696", "0.6539231", "0.65371054", "0.6534442", "0.65319693", "0.6526773", "0.65267444", "0.65198404", "0.6512003", "0.6505387", "0.65020937", "0.6500671", "0.6490158", "0.6489223", "0.6489223", "0.64714223", "0.6470734", "0.6470734", "0.64697564", "0.6461244", "0.6458875", "0.6447212", "0.64399564", "0.64351535", "0.64271647", "0.642637", "0.6424879", "0.6420448", "0.6417172", "0.6412832", "0.6410977", "0.6407609", "0.64051485", "0.6402565", "0.6399348", "0.6393647", "0.6393585", "0.6385053", "0.6380821", "0.6378164", "0.6367944", "0.6364181", "0.6360611", "0.6358665", "0.6357934", "0.6354812", "0.6349536", "0.63450253", "0.6342879", "0.6340449", "0.6340449", "0.6340449", "0.6340449", "0.6340449", "0.6340449", "0.6340449", "0.6340449" ]
0.6660707
23
AUCTION CODE NOT BY TEAM 6, made by TEAM 4 during Intermezzo! We are not responsible for auction design We just made their code match Ruby method name conventions because at the beginning they it was all JavaStyle code .
def bid(item, amount) if can_bid?(item, amount) previous_winner = item.current_winner previous_max_bid = item.highest_bid.nil? ? 0 : item.bidders[previous_winner] item.bidders[self] = amount # reduce money if user is new winner, otherwise nothing happens current_winner = item.current_winner current_max_bid = item.bidders[current_winner] previous_winner.credits += previous_max_bid unless previous_winner.nil? current_winner.credits -= current_max_bid #Do not always send mail for demo purposes =begin if !previous_winner.nil? && previous_winner != current_winner # we got a new winner Security::MailDispatcher.send_new_winner_mail(previous_winner.email, item) unless [nil, ""].include?(previous_winner.email) end =end else raise TradeError, "INVALID_BID" #Bid is too small or already exists or user doesn't have enough money. end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def jack_handey; end", "def koan_4\nend", "def silly_adjective; end", "def buzzword; end", "def buzzword; end", "def koan_3\nend", "def ninety_nine_bottles_of_beer\nend", "def ninety_nine_bottles_of_beer\nend", "def ninety_nine_bottles_of_beer\nend", "def king_richard_iii; end", "def method_12475663\n\nend", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def code; end", "def unusual_sport; end", "def strain; end", "def hey_hey; end", "def method_731(base); end", "def sic_code; end", "def as_you_like_it_quote; end", "def who_we_are\r\n end", "def sharp; accidental; end", "def code\n '202'\n end", "def two_word_name; end", "def code_of_conduct; end", "def winter_paralympics_sport; end", "def bizet; end", "def romeo_and_juliet; end", "def anchored; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def method_name; end", "def code_point; end", "def gluck_italian; end", "def bellini; end", "def cobasysprog\n end", "def method_name\n\n end", "def method_name\n\n end", "def method_name\n\n end", "def old_method\n \"old improved method\"\nend", "def half_wind_abbreviation; end", "def suivre; end", "def mambo_no_5; end", "def marvin_quote; end", "def how_it_works\r\n end", "def abbreviation; end", "def abbreviation; end", "def abbreviation; end", "def abbreviation; end", "def p15\n\t\nend", "def upc_a; end", "def my955; end", "def soft_ace\n # softy method refactor for when an ace is played\nend", "def beautify; end", "def beautify; end", "def codes; end", "def three_word_name; end", "def yoda; end", "def health_benefit; end", "def custom; end", "def custom; end", "def schubert; end", "def code_point=(_); end", "def romeo_and_juliet_quote; end", "def invention; end", "def exchange_code; end", "def secret_method_2 # :nodoc:\n end", "def cardinal_abbreviation; end", "def king_richard_iii_quote; end", "def winter_olympics_sport; end", "def in_law; end", "def aon; end", "def ibu; end", "def appraisals; end", "def appraisals; end", "def mozart_german; end", "def method_name\n end", "def superweening_adorningly(counterstand_pyrenomycetales)\n end", "def food_and_drink; end", "def formation; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end", "def method; end" ]
[ "0.7063156", "0.66484076", "0.6564346", "0.65059173", "0.65059173", "0.6502689", "0.64307857", "0.64307857", "0.64307857", "0.6387483", "0.6289124", "0.62881607", "0.62881607", "0.62881607", "0.62881607", "0.62881607", "0.62881607", "0.62881607", "0.6231263", "0.6219352", "0.6204085", "0.62004846", "0.61897284", "0.6151408", "0.61492133", "0.61452127", "0.6142763", "0.6106402", "0.6104005", "0.60803634", "0.6062283", "0.6034828", "0.60333043", "0.60211945", "0.60211945", "0.60211945", "0.60211945", "0.60211945", "0.60211945", "0.60211945", "0.60211945", "0.60211945", "0.60211945", "0.60211945", "0.60211945", "0.6008503", "0.6006751", "0.6002128", "0.5997668", "0.59913945", "0.59913945", "0.59913945", "0.59883", "0.598813", "0.59868914", "0.5980892", "0.59770995", "0.5976168", "0.5975069", "0.5975069", "0.5975069", "0.5975069", "0.5970496", "0.59620553", "0.5949279", "0.59475416", "0.5925804", "0.5925804", "0.592469", "0.5919321", "0.5913694", "0.5910191", "0.5907043", "0.5907043", "0.59049046", "0.5901539", "0.5889386", "0.5876039", "0.58739245", "0.5873223", "0.58578974", "0.5838639", "0.58331406", "0.5829713", "0.58255744", "0.5825509", "0.58218753", "0.58218753", "0.58186865", "0.58168215", "0.5808976", "0.57978255", "0.57675445", "0.57553595", "0.57553595", "0.57553595", "0.57553595", "0.57553595", "0.57553595", "0.57553595", "0.57553595" ]
0.0
-1
checks whether trader already has a similar item in his inventory
def check_for_equal_item(name, price, description, item_not_to_compare = nil) index = items.index {|x| x.name.eql?(name) and x.price.eql?(price) and x.description.eql?(description) and x != item_not_to_compare} return items[index] unless index == nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trade_item_with_party(new_item, old_item)\n return false if new_item && !$game_party.has_item?(new_item)\n temp = UI_MSG::ITEM\n UI_MSG.const_set(:ITEM, false)\n $game_party.gain_item(old_item, 1)\n $game_party.lose_item(new_item, 1)\n UI_MSG.const_set(:ITEM, temp)\n return true\n end", "def trade_item_with_party(new_item, old_item)\n return false if new_item && !$game_party.has_item?(new_item)\n $game_party.force_gain_item(old_item, 1)\n $game_party.force_gain_item(new_item, -1)\n return true\n end", "def has_item(item)\n inventory.each_with_index do |couple, index|\n return index if couple.first.name.casecmp(item.to_s).zero?\n end\n return\n end", "def has_item_by_object(item)\n inventory.each_with_index do |couple, index|\n if (couple.first == item)\n return index\n end\n end\n return -1\n end", "def has_item_by_object(item)\n inventory.each_with_index do |couple, index|\n if (couple.first == item)\n return index\n end\n end\n return -1\n end", "def drops_item?(item)\n items = drop_items.map {|drop_item| drop_item.item}\n items.include? item\n end", "def sell(item, count)\n wanted = Hash.new\n wanted[item] = count\n if total_inventory[item] >= wanted[item]\n return true\n elsif total_inventory[item] < wanted[item]\n then false\n else\n \"Error\"\n end\n end", "def interesting_item?(item)\n item.rack_id == rack_id\n end", "def line_item_items_exist_in_inventory\n self.line_items.each do |line_item|\n next unless line_item.item\n inventory_item = self.from.inventory_items.find_by(item: line_item.item)\n if inventory_item.nil?\n errors.add(:inventory,\n \"#{line_item.item.name} is not available \" \\\n \"at this storage location\")\n end\n end\n end", "def already_exist?\n item = Item.find(order_item_params[:item_id])\n\n exist = false\n \n current_order.order_items.each do |order_item|\n if order_item.item.id == item.id\n exist = true\n end\n end\n\n return exist\n end", "def has_item?(item)\n return true if drops_item?(item)\n return true if can_steal_item?(item)\n false\n end", "def item_stocking?(item)\n item_stocking_items.include?(item)\n end", "def worn_or_wielded? item\n object = @inventory.find item\n return false if object.nil?\n\n pos = position_of object\n\n return false if object.nil?\n\n if [:left_wield, :right_wield, :dual_wield].include? pos\n return \"You will need to unwield #{object.name} first.\"\n else\n return \"You will need to remove #{object.name} first.\"\n end\n end", "def sell(item, quantity)\n if total_inventory.has_key?(item) && quantity < total_inventory[item]\n @vendors.each do |vendor|\n if vendor.inventory.has_key?(item)\n if vendor.inventory[item] >= quantity\n vendor.inventory[item] -= quantity\n else\n vendor.inventory[item] -= quantity\n diff = vendor.inventory[item].abs\n vendor.inventory[item] = 0\n @vendors.each do |vendor|\n if vendor.inventory.has_key?(item)\n if vendor.inventory[item] != 0\n require \"pry\"\n binding.pry\n vendor.inventory[item] - diff\n end\n end\n end\n end\n end\n end\n return true\n else\n return false\n end\n end", "def pick_up(item_name)\n if current_room.has_item(item_name)\n item = current_room.items.find { |thing| thing.name == item_name }\n @player.add_to_inventory(item)\n current_room.remove_one(item)\n else\n puts \"Sorry, that item is not in this room. Try again.\"\n end\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 contain_item?(id)\n return item_quantity(id) > 0\n end", "def similarly_purchased_item(item = nil)\n if item.present?\n # first we have to determine if this is a stuffed_animal or if this\n # is an accessory\n other_line_items = []\n if item.class.name == \"StuffedAnimal\"\n other_line_items = LineItem.where(stuffed_animal_id: item.id)\n else\n other_line_items = LineItem.where(accessory: item.id)\n end\n\n # extract an array of similar items\n similar_items = self.other_products_purchased item, other_line_items\n\n # take a random sampling of 1 item\n similar_items.sample(1)\n end\n end", "def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end", "def food_trucks_that_sell(desired_item)\n food_truck_list = []\n @food_trucks.each do |food_truck|\n food_truck.inventory.each do |item|\n if item.first.name == desired_item.name\n food_truck_list << food_truck\n end\n end\n end\n food_truck_list\n end", "def take(item_name)\n if current_room.npc && current_room.npc.has_item(item_name)\n npc_item = item_to_take(item_name)\n @player.add_to_inventory(npc_item)\n # this just doesn't seem to remove the item from NPC inventory no matter what I do :(\n current_room.npc.remove_from_inventory(npc_item)\n else\n puts \"Sorry, that item isn't here.\"\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 has_item_by_string(name)\n inventory.each_with_index do |couple, index|\n if (name.casecmp(couple.first.name) == 0)\n return index\n end\n end\n return -1\n end", "def has_item_by_string(name)\n inventory.each_with_index do |couple, index|\n if (name.casecmp(couple.first.name) == 0)\n return index\n end\n end\n\n return -1\n end", "def vendors_that_sell(query_item)\n @vendors.find_all do |vendor|\n vendor.inventory.keys.include?(query_item)\n end\n end", "def use_item_by_object(item, e)\n index = has_item_by_object(item)\n if (index != -1)\n actual_item = inventory[index].first\n actual_item.use(e)\n if actual_item.consumable then remove_item(actual_item) end\n else\n print \"What?! You don't have THAT!\\n\\n\"\n end\n end", "def contains?(item)\n @items_set.include?(item.to_s)\n end", "def no_duplicate_items_in_vouch_list\n vouch_list = wish_list.user.vouch_list_primary\n return if vouch_list.nil?\n\n if vouch_list.vouch_items.find_by_business_id(self.business_id).present?\n errors.add(:vouch_list, \"already contains item \\\"#{self.business.name}\\\".\")\n end\n end", "def stocked?\n inventory_item.present?\n end", "def have_enough_items_to_trade?\n fetch_inventory\n\n is_valid = true\n\n max_avaliable_quantity = @offer[:records].map {|x|\n [x.item_name.to_sym ,x.quantity]}.to_h\n\n @offer[:items].each do |item, quantity|\n if quantity > max_avaliable_quantity[item.to_sym]\n is_valid = false\n add_error(:offer, :items, {item.to_sym =>\n \"Not enough items, only #{max_avaliable_quantity[item.to_sym]} available\"})\n end\n end\n\n max_avaliable_quantity = @for[:records].map {|x|\n [x.item_name.to_sym ,x.quantity]}.to_h\n\n @for[:items].each do |item, quantity|\n if quantity > max_avaliable_quantity[item.to_sym]\n is_valid = false\n add_error(:for, :items, {item.to_sym =>\n \"Not enough items, only #{max_avaliable_quantity[item.to_sym]} available\"})\n end\n end\n is_valid\n end", "def is_tie?\n if gladiators[0].weapon == gladiators[1].weapon\n @gladiators = []\n return true\n end\n return false\n end", "def has_inventory?\n inventory_count > 0\n end", "def has_inventory?\n inventory_count > 0\n end", "def item_matches?(checked_item)\n if item_based?\n item == checked_item\n else\n checked_item.tags.include? tag\n end\n end", "def duplicate_vote_check?(snack_item)\n session[:voted_for].include?(snack_item)\n end", "def pick_up(item)\n\n puts \"in pick_up item = #{item}\"\n puts \"equipped_weapon #{equipped_weapon}\"\n\n # binding.pry\n\n if (CAPACITY - items_weight) >= item.weight\n @items << item\n\n # binding.pry\n if item.class == PlasmaCannon || item.class == Laser\n # binding.pry\n self.equipped_weapon = item\n end\n\n true\n\n else\n false\n end\n\n end", "def next_item\n if (player.location.inventory.length > @index)\n @item = player.location.inventory[@index]\n game.messages << \"Do you want to pick up #{@item}? Y/N\"\n else\n game.change_state(Map.new)\n end\n end", "def test_nameItem\n f = ItemFilter.new(\"name\", \"Potion\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 1\n end", "def unequip_item(item)\n pair = @outfit.detect { |type, value| value.name.casecmp(item.to_s).zero? }\n if pair\n # On a successful find, the \"detect\" method always returns\n # an array of length 2; thus, the following line should not fail.\n item = pair[1]\n item.unequip(self)\n add_item(item)\n else\n print NOT_EQUIPPED_ERROR\n end\n end", "def should_i_buy?(item)\n !!list[item.to_sym]\n end", "def item_usable?\n return false unless @item\n return @actor ? @actor.usable?(@item) : $game_player.usable?(@item)\n end", "def has_ordered?(item_to_check)\n if item_to_check.class == Item\n @order.any? {|item| item.name == item_to_check.name}\n else \n false\n end \nend", "def include?(item)\n return false if item == nil\n return false unless item.is_a?(RPG::EquipItem)\n return false if @slot_id < 0\n return false if item.etype_id != @actor.equip_slots[@slot_id]\n return @actor.equippable?(item)\n end", "def include?(item)\r\n $game_party.usable?(item)\r\n end", "def has_item?(item, include_equip = false)\n if item_number(item) > 0\n return true\n end\n if include_equip\n for actor in members\n return true if actor.equips.include?(item)\n end\n end\n return false\n end", "def useItem?\n # to make sure duplicates are not registered at the beginning\n Input.update\n # render bitmap for item use confirmation\n bitmap = @sprites[\"confirm\"].bitmap\n bitmap.clear; bmp = pbBitmap(@path + @confirmImg)\n bitmap.blt(0, 0, bmp, bmp.rect)\n icon = pbBitmap(GameData::Item.icon_filename(@ret))\n bitmap.blt(20, 30, icon, icon.rect)\n # draw text\n drawTextEx(bitmap, 80, 12, 364, 3, GameData::Item.get(@ret).description, @baseColor, Color.new(0, 0, 0, 32))\n # select confirm message as target\n @sprites[\"sel\"].target(@sprites[\"confirm\"])\n # animate in\n 8.times do\n # slide panels into screen\n @sprites[\"confirm\"].x += @viewport.width/8\n @sprites[\"cancel\"].x += @viewport.width/8\n if @pocket\n # fade out panels\n for i in 0...@pocket.length\n @items[\"#{i}\"].opacity -= 32\n end\n end\n for i in 0...4\n @sprites[\"pocket#{i}\"].opacity -= 64 if @sprites[\"pocket#{i}\"].opacity > 0\n end\n # animate bottom items moving off screen\n @sprites[\"pocket4\"].y += 10 if @sprites[\"pocket4\"].y < @sprites[\"pocket4\"].ey + 80\n @sprites[\"pocket5\"].y += 10 if @sprites[\"pocket5\"].y < @sprites[\"pocket5\"].ey + 80\n @sprites[\"name\"].x -= @sprites[\"name\"].width/8\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # ensure pocket name is off screen\n @sprites[\"name\"].x = -@sprites[\"name\"].width\n index = 0; oldindex = 0\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n # start the main input loop\n loop do\n @sprites[\"#{choice}\"].src_rect.y += 1 if @sprites[\"#{choice}\"].src_rect.y < 0\n # process directional input\n if Input.trigger?(Input::UP)\n index -= 1\n index = 1 if index < 0\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n elsif Input.trigger?(Input::DOWN)\n index += 1\n index = 0 if index > 1\n choice = (index == 0) ? \"confirm\" : \"cancel\"\n end\n # process change in index\n if index != oldindex\n oldindex = index\n pbSEPlay(\"EBDX/SE_Select1\")\n @sprites[\"#{choice}\"].src_rect.y -= 6\n @sprites[\"sel\"].target(@sprites[\"#{choice}\"])\n end\n # confirmation and cancellation input\n if Input.trigger?(Input::C)\n pbSEPlay(\"EBDX/SE_Select2\")\n break\n elsif Input.trigger?(Input::B)\n @scene.pbPlayCancelSE()\n index = 1\n break\n end\n Input.update\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # animate exit\n 8.times do\n @sprites[\"confirm\"].x -= @viewport.width/8\n @sprites[\"cancel\"].x -= @viewport.width/8\n @sprites[\"pocket5\"].y -= 10 if index > 0\n @sprites[\"sel\"].update\n @scene.animateScene\n @scene.pbGraphicsUpdate\n end\n # refresh old UI (swap cursor to target)\n self.refresh\n # return output\n if index > 0\n @ret = nil\n return false\n else\n @index = 0 if @index == 4 && GameData::Item.get(@lastUsed).id_number == 0\n return true\n end\n end", "def unit_item_ok\n return refresh_items if @unit_item_list.tb_unit.nil?\n @unit_item_list.activate\n return if (item = @unit_item_list.item).nil?\n @unit_item_list.tb_unit.lose_item(item, 1) \n TactBattleManager.rm_unit_item(@actor.id, item)\n $game_party.gain_item(item, 1)\n refresh_items\n end", "def pick_up(item)\n return false if items_weight + item.weight > MAX_WEIGHT\n\n @equipped_weapon = item if item.is_a?(Weapon)\n @items << item\n end", "def test_nameArmor\n f = ArmorFilter.new(\"name\", \"Leather Shield\")\n new_list = @baseItems.find_all{|x| f.apply(x)}\n return new_list.size == 1\n end", "def inInventory?(book)\n\t\tbooks.include?(book)\n\tend", "def find_match_and_decrement_available(line_item)\n gs = Orders::LineItemPresenter.new(line_item).global_sku\n if rii = ReturnInventoryItem.where([\"upc= ? and active = true and available > 0\", gs&.id]).first\n rii.available -= 1\n rii.save\n elsif gs\n #do this check since global skus are jacked up and can't be trusted\n gs = GlobalSku.where(\n style_number: gs.style_number,\n product_name: gs.product_name,\n size: gs.size,\n color_id: gs.color_id,\n customisation_id: gs.customisation_id,\n height_value: gs.height_value,\n product_id: gs.product_id,\n ).first\n\n if rii = ReturnInventoryItem.where([\"upc = ? and active = true and available > 0\", gs&.id]).first\n rii.available -= 1\n rii.save\n end\n end\n rii\n end", "def item_ok?\n return true if MAP_ITEM_ID == 0\n $game_party.has_item?($data_items[MAP_ITEM_ID])\n end", "def buy_new_item(item_to_buy, quantity, account)\n return false if item_to_buy.auction\n preowner = item_to_buy.owner\n\n if (Integer(item_to_buy.price*quantity) > self.credits and item_to_buy.currency == \"credits\") or Integer(item_to_buy.quantity)<quantity\n Activity.log(account, \"item_bought_failure\", item_to_buy, self)\n Activity.log(account, \"item_sold_failure\", item_to_buy, preowner)\n return false\n end\n\n\n if !item_to_buy.wishlist_users.empty? and item_to_buy.quantity == quantity and !item_to_buy.permanent\n item_to_buy.wishlist_users.each {|trader| trader.remove_from_wishlist(item_to_buy); item_to_buy.wishlist_users.delete(trader)}\n end\n\n Holding.ship_item(item_to_buy, item_to_buy.owner, self, quantity)\n Activity.log(account, \"item_bought_success\", item_to_buy, self)\n Activity.log(account, \"item_sold_success\", item_to_buy, preowner)\n Mailer.item_sold(preowner.e_mail, \"Hi #{preowner.name}, \\n #{self.name} bought your Item #{item_to_buy.name}.\n Please Contact him for completing the trade. His E-Mail is: #{self.e_mail}\")\n\n return true\n end", "def attach_item(item)\r\n equal_item = self.check_for_equal_item(item.name,item.price,item.description)\r\n if equal_item == nil\r\n self.items << item\r\n item.owner = self\r\n item.deactivate\r\n else\r\n equal_item.quantity += item.quantity\r\n equal_item.deactivate\r\n item.delete\r\n end\r\n end", "def ==(other_item)\n \t@id == other_item.id\n end", "def cant_counter_item(current)\n return (self.actor? and not $game_party.item_can_use?(current)) if current.numeric?\n for item_id in current\n return false if $game_party.item_can_use?(item_id) or not self.actor?\n end\n return true\n end", "def buy_item(item)\r\n if !item.active || item.price > self.credits\r\n false\r\n else\r\n seller = item.owner\r\n price = item.price\r\n\r\n seller.give_credits(price)\r\n self.take_credits(price)\r\n seller.remove_item(item)\r\n self.add_item(item)\r\n item.active = false\r\n true\r\n end\r\n end", "def same_survivor?\n if @offer[:survivor_id].to_i == @for[:survivor_id].to_i\n add_error(:for, :survivor_id, \"not allowed to trade with self\")\n return true\n end\n\n return false\n end", "def check_for_new_items\n @new_queue.each do |item|\n matches = @previous_queue.select { |match| same_item(item, match) }\n unless matches.any?\n @new_items.push(created_at: item.created_at, service_id: item.service_id, open: true)\n end\n end\n end", "def include?(item)\n item_hash = item.hash\n\n index = item_hash & @mask\n return true if match? @table, index, item_hash, item\n\n index = item_hash.hash & @mask\n return true if match? @table, index, item_hash, item\n\n return false if @spill.empty?\n\n i = @spill.to_iter 3\n while i.next\n return true if match? @spill, i.index, item_hash, item\n end\n\n false\n end", "def pick_up(item)\n expected_weight = items_weight + item.weight\n if expected_weight <= 250\n item.is_a?(Weapon) ? @equipped_weapon = item : items << item \n else\n return false\nend\nend", "def item_can_use?(item)\n return false unless item.is_a?(RPG::Item)\n return false if item_number(item) == 0\n if $game_temp.in_battle\n return item.battle_ok?\n else\n return item.menu_ok?\n end\n end", "def can_equip?(item, slot)\n item.allowed_slot == slot && items.include?(item)\n end", "def item_exists?(name)\n items.detect { |item| item.name == name }\n end", "def must_have_no_duplicate_products\n seen = []\n items.each do |item|\n if seen.include?(item.product.uuid) then\n errors.add(:items, \"cannot have duplicate products\")\n else\n seen << item.product.uuid\n end\n end\n end", "def sufficient_quantity_present?(item_quantities)\n all_items_present = true\n not_sufficient_item = nil\n item_quantities.each do |ingredient_name, quantity|\n if !@ingredients[ingredient_name] || @ingredients[ingredient_name] < quantity\n all_items_present = false\n not_sufficient_item = ingredient_name\n break\n end\n end\n return all_items_present, not_sufficient_item\n end", "def test_nameUsableItem\n f = UsableItemFilter.new(\"name\", \"Potion\")\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 1\n end", "def check_duplicate_shelfmark\n @dups = ItemsLibraryLocation.find(:all, \n :conditions => [ \"shelfmark = ? AND item_id != ?\", \n params[:search], params[:item_id].blank? ? \"-1\" : params[:item_id] ])\n render :inline => \"<%= @dups.length>0 ? '<div class=''warn''>Warning: shelfmark already in use.</div>' : '' %>\"\n end", "def all_items(item)\r\n result = false\r\n\r\n if(self.items.size > 0)\r\n self.items.each {|val|\r\n if (val.get_name == item.get_name )\r\n return true\r\n else\r\n result = false\r\n end\r\n }\r\n else\r\n result = false\r\n end\r\n\r\n return result\r\n end", "def use_item_by_string(name, e)\n index = has_item_by_string(name)\n if (index != -1)\n actual_item = inventory[index].first\n actual_item.use(e)\n remove_item(actual_item) if actual_item.consumable\n else\n print \"What?! You don't have THAT!\\n\\n\"\n end\n end", "def remove_item(item, amount)\n # Check if the Entity already has that item\n # in the inventory. If so, just decrease\n # the amount.\n @inventory.each_with_index do |couple, index|\n if (couple.first == item)\n couple.second -= amount\n if (couple.second <= 0)\n @inventory.delete_at(index)\n end\n return\n end\n end\n end", "def remove_item(item)\n if !@item\n log(\"Nothing is equipped in that EquipSlot.\")\n return\n end\n if @item != item\n log(\"Item being removed from EquipSlot is not the same as already equipped item.\")\n return\n end\n @item = nil if @item == item\n return\n end", "def match?(line_item)\n @variant_ids.include?(line_item.variant.id)\n end", "def item_effects_valid?\r\n item_target_actors.any? do |target|\r\n target.item_test(user, item)\r\n end\r\n end", "def same_ids?(item_ids)\n all_item_ids.sort == item_ids.sort\n end", "def has_this_item?(item_id)\n item_id.blank? ? true : self.delivered_items.map(&:item_id).include?(item_id)\n end", "def has_this_item?(item_id)\n item_id.blank? ? true : self.delivered_items.map(&:item_id).include?(item_id)\n end", "def buy_item (item, character)\n \n if item.inventory == nil \n if character.gold >= item.cost\n item_transaction(item, character)\n \"you bought #{item.name}!\"\n else\n \"you don't have enough money\"\n end\n else\n \"Your character already has this item in their invetory\"\n end\n end", "def test_attackItem\n f = ItemFilter.new(\"attack\", true)\n new_list = @usableItems.find_all{|x| f.apply(x)}\n return new_list.size == 9\n end", "def items_by_trader(trader)\n @items.values.select { |value| value.owner==trader }\n end", "def eql?(other)\n items == other.items\n end", "def add_item(item)\n if @item\n log(\"Item is already equipped in EquipSlot.\")\n return\n end\n @item = item\n return\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 use_item(item, entity)\n index = has_item(item)\n if index\n actual_item = inventory[index].first\n actual_item.use(self, entity)\n remove_item(actual_item) if actual_item.consumable\n else\n print NO_SUCH_ITEM_ERROR\n end\n end", "def keep_item?(item)\n keep_all? or interesting_item?(item)\n end", "def shared_inventory\n @weapons + @armors + items_to_obj\n end", "def same_suit?(other)\n @suit == other.suit\n end", "def match?(line_item)\n @product_ids.include?(line_item.variant.product.id)\n end", "def item_effects_valid?\n item_target_actors.any? do |target|\n target.item_test(user, item)\n end\n end", "def can_sell?\n inventory.any? { |inv| inv.price > 0 }\n end", "def has_different_point_values?\n offer_value = Inventory.evaluate_items(@offer[:items])\n for_value = Inventory.evaluate_items(@for[:items])\n if offer_value != for_value\n add_error(:for, :items,\n \"Invalid Offer, the items offered and received do not worth the same\")\n true\n else false; end\n end", "def duplicate?\n\t\tarchetype != self\n\tend", "def check_for_dup(answer,database)\n\n is_dup = false\n\n database.each do |d|\n if answer == d.name\n is_dup = true\n end\n end\n\n return is_dup\nend", "def check_cart item\n \tcheck = false\n \t#Doc tat ca san pham trong cart session\n \tsession[\"cart\"].each do |x|\n \t\t#So sanh ID product voi ID product trong gio hang\n \t\tif x['id'] == item[:id]\n \t\t\tx['quantity'] = x['quantity'] + 1\n \t\t\tx['total'] = x['price'] * x['quantity']\n \t\t\treturn\n \t\tend\n \tend\n \tsession[\"cart\"].push(item)\n end", "def find_some_trades(items)\n item_count = items.count\n route_count = 0\n items_in_all_routes = 0\n items_that_get_saved = 0\n while items.count > 1\n # puts \"ITEMSCOUNT = #{items.count}\"\n items = prune(items)\n # puts \"ITEMSCOUNT AFTER PRUNE = #{items.count}\"\n items_with_new_owners=[]\n items.each do |item|\n if item.new_owner\n next\n end\n #puts \"items_with_new_owners size = #{items_with_new_owners.size}\"\n #never looping past first item. so route is always true. \n \troute = find_trade(item, items)\n \tif route.count > 2 and route.first == route.last\n route_count +=1\n items_in_all_routes += route.count -1\n #-1 to adjust for index starting at 0. -1 more because 1st and last item in route is the same. only need to set owner and delete it once.\n \t\t#each item in a route now has a new owner which is the current owner of the previous item in the route\n 0.upto(route.length-2) do |i|\n \t\t\tpossession = Possession.find(route[i+1])\n puts \"POSSESSION #{i+1} IN ROUTE #{route_count}: #{possession.name}\"\n \t\t\tpossession.new_owner = route[i].user.id\n \t\t\tpossession.save\n items_that_get_saved +=1\n #puts \"Route[i] = #{route[i].name}\"\n \t\t\t#items.delete(route[i])\n items_with_new_owners << route[i]\n #puts \"and if i try to call the deleted item?\"\n # p items.include?(route[i])\n \t\tend\n #break\n \tend\n end\n items_with_new_owners.each do |item|\n puts \"deleting item: #{item.name}\"\n # puts \"item count before delete = #{items.size}\"\n # puts \"Does items include item? #{items.include?(item)}\"\n items.delete(item)\n # puts \"item count after delete = #{items.size}\"\n end\n if item_count == items.count\n break\n else\n item_count = items.count\n end\n end\n puts \"ROUTE COUNT = #{route_count}\"\n puts \"ITEMS IN ROUTES = #{items_in_all_routes}\"\n puts \"ITEMS THAT GET SAVED = #{items_that_get_saved}\"\n end", "def create_items_page?\n items_shortcut != inventory_shortcut\n end", "def add_item(item, amount)\n # Check if the Entity already has that item\n # in the inventory. If so, just increase\n # the amount.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n # If not already in the inventory, push a Couple.\n @inventory.push(Couple.new(item, amount))\n end", "def ==(another_item)\n self.description == another_item.description &&\n self.quantity == another_item.quantity &&\n self.amount == another_item.amount &&\n self.additional_data == another_item.additional_data &&\n self.expire == another_item.expire\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 wear(item, position = nil)\n result = @equipment.check_position(item, position)\n\n if result\n self.output(result)\n return false\n end\n\n result = @equipment.wear(item, position)\n\n if result\n @inventory.remove(item)\n true\n else\n false\n end\n end" ]
[ "0.6481306", "0.645586", "0.63714516", "0.63661486", "0.63661486", "0.6328455", "0.63275975", "0.62222743", "0.61834425", "0.61536324", "0.6120706", "0.6105216", "0.60374576", "0.60334563", "0.6033018", "0.5976975", "0.59376866", "0.5921286", "0.59120154", "0.5909201", "0.5908516", "0.58998495", "0.5871916", "0.5855788", "0.5840001", "0.58351034", "0.58137375", "0.5802291", "0.57982683", "0.579467", "0.57945496", "0.5789563", "0.5789563", "0.57863945", "0.57834876", "0.5767174", "0.5764374", "0.57561296", "0.5755914", "0.57539624", "0.5740389", "0.5738035", "0.57256436", "0.57234514", "0.56994814", "0.5682368", "0.5657717", "0.56522584", "0.56434333", "0.56325495", "0.56053144", "0.5604447", "0.5581841", "0.5579697", "0.55789214", "0.55778515", "0.5574829", "0.5572342", "0.5560526", "0.5557432", "0.55356425", "0.55273783", "0.5525227", "0.55221725", "0.5512564", "0.5501989", "0.5500041", "0.54877776", "0.5474475", "0.54715186", "0.545617", "0.5451393", "0.5450963", "0.5450243", "0.54276717", "0.5427366", "0.5427366", "0.5424103", "0.54220444", "0.5418564", "0.54158443", "0.5411537", "0.54091036", "0.5407919", "0.53985924", "0.53958243", "0.5382621", "0.5378121", "0.5377208", "0.5375364", "0.5373002", "0.53714186", "0.53705865", "0.5368143", "0.5366424", "0.53642064", "0.5362171", "0.5360009", "0.5359826", "0.5339155" ]
0.60371816
13
returns the trader found by name
def by_name(name) return User.by_name(name) if User.exists?(name) Organization.by_name(name) if Organization.exists?(name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_loader(name)\n @loaders.each do |loader|\n return loader if loader.name == name\n end\n end", "def trader; end", "def lister(name)\n lister_class = @listers.find do |lister|\n lister.name == name\n end\n \n if lister_class\n lister_class\n else\n raise \"Cannot find lister '#{name}'\"\n end\n end", "def passage_from_name(name)\n @passages.find {|e| e.name == name}\n end", "def find_by_name(name)\n self.transitions.find {|t| t.name == name}\n end", "def get(name)\n @all.find { |e| e.name == name.to_s || e.name == \"#{name}_engine\" }\n end", "def get_thermostat_by_name(name)\n get_thermostat_list[name]\n end", "def get_sr_by_name(name)\n sr_ref = xapi.SR.get_by_name_label(name)\n if sr_ref.empty? or sr_ref.nil?\n ui.error \"SR name #{h.color( name ) } not found\"\n return nil\n end\n sr = xapi.SR.get_record( sr_ref )\n end", "def by_name( name )\n available.each { |addon| return addon if addon['filename'] == name }\n return nil\n end", "def find_by_name name\n name = CGI.escape name.downcase.gsub(/\\s/, '')\n DynamicModel.new perform_request api_url \"summoners/by-name/#{name}\"\n end", "def find_by_name name\n name = CGI.escape name.downcase.gsub(/\\s/, '')\n DynamicModel.new perform_request api_url \"summoners/by-name/#{name}\"\n end", "def summoner_by_name(name)\n\t\t\tencoded_name = HTMLEntities.new.encode name\n\t\t\tsummoner = Demacia::Summoner.new(@entry_point+\"summoner/by-name/\"+encoded_name+@api_suffix, @region)\n\t\tend", "def find_script(name)\n\t\tfound = nil\n\t\t@handlers_list[:other].each do |script|\n\t\t\tif script.name == name\n\t\t\t\tfound = script\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\tfound\n\tend", "def get_next_for(name)\n factories[name].get_next_object\n end", "def get_sr_by_name(name)\n sr_ref = xapi.SR.get_by_name_label(name)[0]\n if sr_ref.empty? || sr_ref.nil?\n ui.error \"SR name #{h.color(name) } not found\"\n return nil\n end\n sr_ref\n end", "def find name\n object = objects.find { |o| o.name == name.to_s }\n end", "def find_by_name(name)\n end", "def player_by_name name\n @players.select {|p| p.name == name}.first\n end", "def locate_train(name)\r\n stations.each { |station|\r\n if station.train.to_s.include? name\r\n return station\r\n end\r\n }\r\n end", "def lookup_engine (engine_name)\n e = get_participant_map.lookup_participant engine_name\n return e if e\n get_engine\n end", "def fetcher\n @_fetcher ||= TspotFetcher.new(name)\n end", "def find_by_name(name)\n find_by('name', name)\n end", "def _get_task_by_name(task_name)\n @tasks.each do |t|\n return t if t.name == task_name\n end\n raise \"Unknown Task!\" # couldn't find it. boo.\n end", "def find_by_name(name)\n types[name]\n end", "def table_for_name(name)\n if(! defined? name)\n return DataTable.new;\n end\n\n if(! @tables.has_key?(name))\n return DataTable.new;\n end\n\n @tables[name];\n end", "def find_object(name); end", "def getHose(name)\n @gang.tributaries.detect { |x| x.pool_name == name }\n end", "def next_scene(scene_name)\n return @@scenes[scene_name]\n end", "def get(name)\n name = camelize(name) if name.downcase == name\n begin\n Object.const_get(name)\n rescue NameError\n nil\n end\n end", "def find_drink_by_name(drink_name)\n return @drinks_stock.find { |drink| drink.name == drink_name }\n end", "def reader_name\n self[:reader_name].read_string\n end", "def class_by_name name\n # http://stackoverflow.com/questions/14070369/how-to-instantiate-class-from-name-string-in-rails\n Object.const_get name.to_s\n\n end", "def find_token_by_name(name)\n self.tokens.where(name: name.to_s).first\n end", "def through_name\n @loader.name\n end", "def get_plugin(name); Ricer::Plugin.by_name(name); end", "def name\n names.first\n end", "def next_scene(scene_name)\n\t\tval = @@scenes[scene_name]\n\t\treturn val\n\tend", "def summoner_by_name(summoner_name)\n summoner_names = array_options(summoner_name)\n summoner_name = summoner_names.first\n raise ArgumentError, 'invalid summoner name' if summoner_names.size != 1\n\n summoners_by_name(summoner_name)[summoner_name.downcase]\n end", "def target(name)\n target = targets.find { |target| target.name == name }\n abort \"The target named #{name} not found.\" if target.nil?\n return target\n end", "def get_test(test_name)\n Test.where(test_name: test_name).first\n end", "def name\n\t\treturn self.names.first\n\tend", "def get_agent(name)\r\n ag = Agent.find_by_name1(name)\r\n ag = Agent.find_by_name2(name) if not ag\r\n ag = Agent.find_by_name3(name) if not ag\r\n if ag\r\n @log.debug \"found agent #{ag.to_s} with email:#{ag.email1} from name #{name}\" \r\n else\r\n @log.warn \"Could not find agent from name #{name}\"\r\n end\r\n return ag\r\n end", "def get(name)\n lookup(key(name.to_s))\n end", "def find_by_name(name)\n return nil unless name.present?\n names.select {|e| e == name}\n end", "def get(name)\n name.downcase!\n parts = name.split('::')\n name = name.to_sym\n\n @mutex.synchronize do\n object = @objects[name]\n unless object || @objects.include?(name)\n @directories.each do |directory|\n path = File.join(directory, @subdir, *parts) + '.rb'\n next unless File.exists?(path)\n object = load_file(parts.last, path)\n break\n end\n # Set even if not found to record misses\n @objects[name] = object\n end\n object\n end\n end", "def resource_klass(name)\n eval('RedboothRuby::' + camelize(name)) rescue nil\n end", "def get_renderer(name)\n begin\n class_name = name.to_s.capitalize.to_sym\n renderer = ::Hyde::Renderers.const_get(class_name)\n rescue NameError\n renderer = nil\n end\n renderer\n end", "def get_by_name(name)\n network=connection.lookup_network_by_name(name)\n return network\n # new(:raw => network)\n end", "def set_trader\n @trader = Trader.find(params[:id])\n end", "def find_model(name)\n @models[name.to_s.downcase.to_sym]\n end", "def find(name)\n instances.find { |instance| instance.name == (name) }\n end", "def find_flow name\n @flows.select { |f| f.name == name }.first\n end", "def find(name)\n m = match(name)\n m.count == 1 ? m[0] : nil\n end", "def name\n names.first\n end", "def get_table(name)\r\n raise('Do not call this method from a server instance!') if server?\r\n raise(ArgumentError, 'Table name must be a symbol!') unless \\\r\n name.is_a?(Symbol)\r\n raise('Table not found!') unless table_exists?(name)\r\n\r\n if @table_hash.has_key?(name)\r\n return @table_hash[name]\r\n else\r\n @table_hash[name] = \\\r\n KBTable.create_called_from_database_instance(self, name, \r\n File.join(@path, name.to_s + @ext))\r\n return @table_hash[name]\r\n end\r\n end", "def name\n names[0]\n end", "def next_scene(scene_name)\n scene = @@scenes[scene_name]\n return scene\n end", "def best_match(name)\n matches = Name.with_correct_spelling.where(search_name: name)\n return matches.first if matches.any?\n\n matches = Name.with_correct_spelling.where(text_name: name)\n accepted = matches.reject(&:deprecated)\n matches = accepted if accepted.any?\n nonsensu = matches.reject { |match| match.author.start_with?(\"sensu \") }\n matches = nonsensu if nonsensu.any?\n matches.first\n end", "def tier\n @tier_cache || self.tiers[0]\n end", "def find_planet_by_name(planet_name)\n # instance_of_planet = @planets.find { |planet| planet.name.downcase == planet.name.downcase}\n @planets.each do |planet|\n if planet.name == planet_name\n return planet\n end\n end\n end", "def get_resource(name)\n resource = Resource.new\n resource.name = name\n resource.get_resource\n yield resource.resource if block_given?\n resource\n end", "def asset(name:)\n self[:assets].select { |asset| asset[:name] =~ /#{name}/ }.first\n end", "def find_transition_by_name(name)\n _transitions = find_all_transitions_by_name(name)\n\n # the result shouldn't be ambiguous\n if _transitions.size > 1\n raise AmbiguousNetQueryResult.new(__method__, place_id, _transitions)\n end\n\n return _transitions.first\n end", "def find_drink(drink_name)\n Drink.find_by(name: drink_name)\n end", "def first()\n @tiers.each do |tier|\n unless tier.empty?()\n return tier[0]\n end\n end\n \n return nil\n end", "def by_name(summoner_names)\n neated_param = neat_params(summoner_names)\n summoners = get(resource_path_by_name(neated_param), @version)\n summoners.map do |summoner|\n RiotGamesApi::LOL::Model::Summoner::Summoner.new(summoner.last)\n end\n end", "def get_table(table)\n raise \"Pool #{self} does not have table #{table}\" unless has_table? table\n\n @tables.select{|tb| tb.to_s == table}.first\n end", "def find(name)\n list[name]\n end", "def name; termid;end", "def recipe_instance(recipe_name) \n Recipe.find_by name: recipe_name\n end", "def friendly_model_reader(name_or_klass)\n name_or_klass = friendly_model_name(name_or_klass) if name_or_klass.is_a?(Class)\n :\"load_#{name_or_klass}\"\n end", "def find(name)\n Template.find(name)\n end", "def fetch_type name\n exercises = []\n data.exercises.each do |exe|\n if exe.target === name\n exercises.push(exe.name)\n end\n end\n exercises\n end", "def find_planet_by_name(target_planet)\n planets.select { |planet| return planet if planet.name.upcase == target_planet.upcase }\n end", "def klass_for(name)\n @comparators ? @comparators[name] : nil\n end", "def get_trainer_uri(name, team_uri)\n if name.include?(',')\n name = name.split(',').reverse.join(' ')\n end\n name = name.strip\n sparql = \"SELECT DISTINCT ?trainer_uri ?team_uri\n WHERE {\n ?trainer_uri <http://xmlns.com/foaf/0.1/name> \\\"#{name}\\\"@en .\n ?trainer_uri <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/SoccerManager> .\n ?trainer_uri <http://dbpedia.org/ontology/coach> <#{team_uri}> .\n ?trainer_uri <http://dbpedia.org/property/birthDate> ?birth_date .\n FILTER(?birth_date > \\\"19000101\\\"^^xsd:date)\n }\"\n solutions = DBPEDIA.query sparql\n result = case solutions.count\n when 0 # fallback\n sparql = \"SELECT DISTINCT ?trainer_uri ?team_uri\n WHERE {\n ?trainer_uri <http://xmlns.com/foaf/0.1/name> \\\"#{name}\\\"@en .\n ?trainer_uri <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://dbpedia.org/ontology/SoccerManager> .\n ?trainer_uri <http://dbpedia.org/property/birthDate> ?birth_date .\n FILTER(?birth_date > \\\"19000101\\\"^^xsd:date)\n }\"\n solutions = DBPEDIA.query sparql\n solutions.first\n when 1\n solutions.first\n else\n solutions.first\n end\n result.trainer_uri.to_s if result\n end", "def read(name, &block)\n reader = readers[name]\n\n if block\n yield(reader)\n else\n reader\n end\n end", "def find(name); end", "def find_student(name)\n\t\tstudents.each do |student|\n\t\t\tif student.name == name\n\t\t\t\treturn student\n\t\t\tend\n\t\tend\n\tend", "def find_by_name(planet)\n @planets.each do |item|\n if item.name.downcase == planet.downcase\n return item\n end\n end\n return false\n end", "def outputter_class_for(name)\n self.class.outputters[name].first\n end", "def find_player(name)\n for footballer in @players\n return footballer if @players.include?(name)\n end\n end", "def find_by_name(name)\n find do |event|\n event.job_class_name == name.to_s\n end\n end", "def find_roll name, options = {}\n return if on_the_menu? name\n\n # return specific source roll if specified in the menu\n #\n if source = options[:source]\n require_roll name, File.join(source, name.to_s)\n return\n\n # look through the sources for the first roll that matches.\n # sources are listed in the menu in order of priority\n else\n @sources.each do |source|\n if path = source.rolls[name]\n require_roll name, path\n return\n end\n end\n end\n\n # no roll was found\n Yuyi.say \"You ordered the '#{name}' roll off the menu, but we are fresh out...\", :type => :fail\n Yuyi.say 'Check your menu to make sure a source with your roll is listed.', :type => :warn\n Yuyi.say\n end", "def typekit_model_text_from_name(name)\n if text = available_typekits[name]\n return *text\n else \n raise OroGen::TypekitNotFound, \"#{client} has no typekit called #{name}\"\n end\n end", "def get_policy_by_name(policy_name)\n policy_id = get_policy_id_by_name(policy_name)\n request.get({ path: \"/policies/#{policy_id}\", headers: headers })\n end", "def fetch(name); end", "def party(str)\n Party.where(name: str).first\nend", "def find_by_name(name)\n Discovery.find_by_name(name)\n end", "def get_target(name)\n t = Param.get(:targets)\n (t && t.kind_of?(Hash)) ? t[name.to_s.to_sym] : nil\n end", "def find_first(name)\n object = build(name)\n object.retrieve\n end", "def find_planet_by_name(name_used)\n @planets.each do |planet|\n if (name_used).upcase == (planet.name).upcase\n return planet\n end\n end\n end", "def get_trains_by_type(train_class)\n @trains.select { |train| train.class == train_class }\n end", "def get_trains_by_type(train_class)\n @trains.select { |train| train.class == train_class }\n end", "def find_planet_by_name(planet_name)\n planet_instance = @planets.find {|planet| planet.name.downcase == planet_name.downcase}\n return planet_instance\n\n # what does this return? the planet name if there's such a match?\n # it returns the corresponding instance of Planet that has all the states\n # q: what should method do if there is no planet with the given name? error, tell them to type in another planet?\n # q : wht should your method do if there are multiple planets with the given name?\n end", "def get_resource(ty, nm)\n o = self.send \"#{ty}s\".to_sym\n o.detect {|r| r.name == nm }\n end", "def _read type, name\n result = @elasticsupport.client.search index: _index_for(type), type: type.to_s, q: \"name:#{name}\"\n result[\"hits\"][\"hits\"][0] rescue nil\n end", "def find_right_script_lineage_by_name(name)\n lineage = @right_api_client.right_scripts(:filter => [\"name==#{name}\"]).index\n if lineage.length == 0\n raise Exception::RightScriptNotFound.new(\"No RightScripts with the name (#{name}) were found.\")\n end\n lineage\n end", "def part_by_name(name)\n mbr.part.select { |i| i.name == name }.first\n end", "def use(name)\n model.repository.by_name(name)\n end", "def use(name)\n model.repository.by_name(name)\n end" ]
[ "0.632402", "0.6290499", "0.59771174", "0.5910349", "0.5657011", "0.5621896", "0.55718124", "0.5558965", "0.5515383", "0.54553074", "0.54553074", "0.5386797", "0.536628", "0.53463763", "0.5308552", "0.5274393", "0.52408075", "0.5218273", "0.5216964", "0.52148116", "0.5209624", "0.52023476", "0.5191463", "0.5185911", "0.5185665", "0.51421654", "0.513053", "0.5126527", "0.51228994", "0.510841", "0.510804", "0.51076746", "0.510126", "0.50992805", "0.50872123", "0.50856555", "0.50527084", "0.50442374", "0.50434536", "0.50423914", "0.50396323", "0.5024817", "0.5012772", "0.5009404", "0.50028324", "0.49863324", "0.49852967", "0.49791977", "0.4977388", "0.49765465", "0.497486", "0.49736282", "0.4971596", "0.49589422", "0.49543062", "0.49501917", "0.49439844", "0.4929191", "0.49284664", "0.49281827", "0.49161547", "0.4909308", "0.49092016", "0.49052694", "0.4904307", "0.49042824", "0.49036548", "0.48989528", "0.48978668", "0.48926368", "0.48910075", "0.48903334", "0.48896673", "0.4889536", "0.48797777", "0.4865598", "0.48630515", "0.48612103", "0.4853495", "0.48346967", "0.4826918", "0.48257202", "0.4822662", "0.48217258", "0.48188192", "0.4814724", "0.48079756", "0.48016906", "0.4798882", "0.47944474", "0.47918543", "0.47810385", "0.47699368", "0.47699368", "0.47675762", "0.47603598", "0.4760118", "0.47568867", "0.47561824", "0.47513255", "0.47513255" ]
0.0
-1
returns true if the system includes a certain trader with the name specified
def exists?(name) User.exists?(name) || Organization.exists?(name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def includes_recipe?(recipe_name)\n run_list.include?(recipe_name)\n end", "def include?(name); end", "def pbTrainerCheck(tr_type, tr_name, max_battles, tr_version = 0)\r\n return true if !$DEBUG\r\n # Check for existence of trainer type\r\n pbTrainerTypeCheck(tr_type)\r\n tr_type_data = GameData::TrainerType.try_get(tr_type)\r\n return false if !tr_type_data\r\n tr_type = tr_type_data.id\r\n # Check for existence of trainer with given ID number\r\n return true if GameData::Trainer.exists?(tr_type, tr_name, tr_version)\r\n # Add new trainer\r\n if pbConfirmMessage(_INTL(\"Add new trainer variant {1} (of {2}) for {3} {4}?\",\r\n tr_version, max_battles, tr_type.to_s, tr_name))\r\n pbNewTrainer(tr_type, tr_name, tr_version)\r\n end\r\n return true\r\nend", "def include?(name)\n includes?(name)\n end", "def has_tasker?(exid, name)\n\n #return false if RESERVED_NAMES.include?(name)\n\n d = Flor.domain(exid)\n\n !! (\n @unit.loader.tasker(d, 'ganger') ||\n @unit.loader.tasker(d, 'tasker') ||\n @unit.loader.tasker(d, name))\n end", "def treasurer?\n ASF::AuthGroup.find('treasurer').members.include? self\n end", "def includes_recipe?(recipe)\n # todo expand roles?\n self.run_list.include?(\"#{recipe}\")\n end", "def trade?\n type == \"trade\"\n end", "def taumaturgic?\n has_feature?(:taumaturgic)\n end", "def performer_yes?\n\t \t\tperformer == \"yes\"\n\t\tend", "def Check_Driver_Installed(name)\n\tdriver_installed = false\n\tDir.foreach(File.dirname(Dir.getwd)){|fn| if fn == \"driverInstallLog.txt\"\n\t\t\t\t\t\t\t\t\t\t\t\t#puts fn\n\t\t\t\t\t\t\t\t\t\t\t\tfile = File.open(\"..\\\\driverInstallLog.txt\",\"r\")\n\t\t\t\t\t\t\t\t\t\t\t\tfile.each{|line| if line.include? name\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tdriver_installed = true\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t end\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t end\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\n\treturn driver_installed\nend", "def can_afford?(name)\n Era::TBUnit.makable?(name)\n end", "def include?(name)\n self.each { |c| return true if (c == name) }\n false\n end", "def active_trainer?\n\t\t\tTrainer.find_by(user_id: current_user.id.to_i).active\n\t\tend", "def activated?\n loaded = Gem.loaded_specs[name]\n loaded && loaded.version == version\n end", "def has_typekit?(name)\n available_typekits.has_key?(name)\n end", "def trainer_battle?\n !@names[1].empty?\n end", "def has_primo_as_external_system?\n @record.external_system.eql?(\"primo\")\n end", "def include?(teleport)\n return false if !teleport.discovered && !CSCA::TELE::SHOW_UNDISCOVERED\n return true if @category == :all\n return true if @category == teleport.type\n return false\n end", "def tooling?\n true\n end", "def performer_is_in_owner_performers?(owner)\n owner.performers.include? @performer\n end", "def software_installed?(name)\n result = execute_with_result('type', name)\n result and /\\A(#{name})(.)+(#{name})$/.match(result).to_a.count >= 3\n end", "def require_check?\n\t\t[\"cheque\"].include?(tag_name.downcase)\n\tend", "def trains_containing(car)\n @trains.find_all do |train|\n train.cargo.keys.include?(car)\n end\n end", "def include?(name)\n @manifest.to_h.key?(name.to_sym)\n end", "def rech_bonus?\n has_feature?(:esper_recharger)\n end", "def plugin? name\n self.class.plugins.include? name\n end", "def installer_AdobeUberInstaller?\n installer_type == \"AdobeUberInstaller\"\n end", "def include?(name)\n !!find_by_name(name)\n end", "def library?\n sort == ::LIBRARY\n end", "def rust?(train, purchased_train)\n train.rusts_on == purchased_train.sym ||\n (train.obsolete_on == purchased_train.sym && @depot.discarded.include?(train))\n end", "def check_availability_of_passenger_wagons\n @trains.each do |train|\n train.each do |element|\n if element.class != Symbol\n return false if element.wagons.any? && element.type == 'passenger'\n end\n end\n end\n end", "def fulfills_prereq?( prereq )\n\t\t@includes.each do |i|\n\t\t\tif i == prereq\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\trecurse = NERO_Skill.lookup(i)\n\t\t\t\tif recurse.is_a? NERO_Skill and recurse.fulfills_prereq?(prereq)\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend", "def exists?\n ! Tainers::API.get_by_name(name).nil?\n end", "def grant_training_skill?\n GRANT_TRAINING_SKILL.include?(self.name)\n end", "def kaiser_enabled?\n cpu_flags.include? 'kaiser'\n rescue\n raise 'Could not determine KAISER status'\n end", "def has_name?(name)\n names.include?(name)\n end", "def has_torch?\n self.items.has_key? :torch\n end", "def can_rent_truck?\n !license.expired? && age >= 60 && license.to_drive_truck?\n end", "def use?\n inclusively { enabled? && needed? }\n end", "def enabled?\n REAPERS.include?(reaper)\n end", "def origen_core?\n name.to_s.symbolize == :origen_core\n end", "def knows?(name)\n false\n end", "def supported?(name); end", "def service?(service)\n taxes.include?(service.to_s.upcase)\n end", "def instrumentalists?\n true\n end", "def recipe?(recipe_name)\n run_list.include?(recipe_name) || Array(self[:recipes]).include?(recipe_name)\n end", "def main_stress?\n any? do |syl|\n syl.main_stress?\n end\n end", "def tradeable?\n @tradeable\n end", "def standard?\n STANDARD_CAPABILITIES.include?(@name)\n end", "def is_include?(code,systems)\n # Ensures systems is an array.\n systems = [*systems]\n # Check for each system.\n return systems.any? do |system|\n code.is_a?(Array) && (code[0] == :command) &&\n (code[1][1] == \"include\") &&\n (code[2][1][1] == system)\n end\n end", "def include?(filename)\n \n end", "def require_company?\n !!(self.brand && self.brand.name.to_s.match(/studer/i))\n end", "def addable?(name)\n if name_li(name).exists?\n self.button(:title=>\"Request connection with #{name}\").present?\n else\n puts \"\\n#{name} isn't in the results list. Check your script.\\nThis may be a false negative.\\n\"\n return false\n end\n end", "def boring?(line)\n contains?(line, 'temp' ) or contains?(line, 'recycler' )\nend", "def is_scraper? name\n name.include? '::'\n end", "def haveLitterMate?(name, type, has_multiple: false)\n @kittencfg_semaphore.synchronize {\n matches = []\n _shortclass, _cfg_name, cfg_plural, _classname = MU::Cloud.getResourceNames(type)\n if @kittens[cfg_plural]\n @kittens[cfg_plural].each { |kitten|\n if kitten['name'].to_s == name.to_s or\n kitten['virtual_name'].to_s == name.to_s or\n (has_multiple and name.nil?)\n if has_multiple\n matches << kitten\n else\n return kitten\n end\n end\n }\n end\n if has_multiple\n return matches\n else\n return false\n end\n }\n end", "def proprietary?\n include?(\"AOL\") || include?(\"NETSCAPE\") || include?(\"NOVONYX\") || include?(\"SUN\") || include?(\"MMP\")\n end", "def is_brand? brand\n Handset.is_brand? request.user_agent, brand\n end", "def enabled_by_feature?(name = nil)\n if !name\n !!feature\n else\n if feature.class == Array\n feature.each do |f|\n if f == name\n return true\n end\n end\n false\n else\n feature == name\n end\n end\n end", "def enabled_by_feature?(name = nil)\n if !name\n !!feature\n else\n if feature.class == Array\n feature.each do |f|\n if f == name\n return true\n end\n end\n false\n else\n feature == name\n end\n end\n end", "def system_load_ok?\n true\n end", "def include?(str)\n @name.index(str) >= 0\n end", "def arv?\n arvs = [\"Stavudine Lamivudine\", \"Stavudine Lamivudine Nevirapine\", \"Efavirenz\", \"Zidovudine Lamivudine\", \"Nevirapine\", \"Abacavir\", \"Didanosine\", \"Lopinavir Ritonavir\", \"Didanosine\", \"Tenofovir\"]\n return arvs.include?(self.concept.name)\n end", "def already_init?\n terraform = \"#{@mod.cache_dir}/.terraform\"\n provider = Dir.glob(\"#{terraform}/**{,/*/**}/*\").find do |path|\n path.include?(\"terraform-provider-\")\n end\n !!provider\n end", "def agent?\n true\n end", "def have_transmission_header?\n self.class.have_transmission_header?\n end", "def enable?(teleport)\n return false if teleport.nil? || !teleport.discovered\n return false unless teleport.item.nil? || $game_party.has_item?($data_items[teleport.item])\n return false if @actor.mp < teleport.mp\n return true\n end", "def lxd_transport_selected?\r\n instance.transport.is_a? Kitchen::Transport::Lxd\r\n end", "def supports?(feature_name)\n features.key? feature_name\n end", "def loaded?(name)\n plugins.any? { |plugin| plugin.name == name }\n end", "def require_manager_name?\n !!(self.registered_download.require_manager_name?)\n end", "def try_require(name)\n require(\"travis-custom-deploy/transfer/#{name.downcase}\")\n true\n end", "def is_shifter?\n sentiment_modifier == 'shifter'\n end", "def is_known\n TargetsXML.has_target(@name)\n end", "def target_hk_enabled?(target_name, timeout = 10)\n\n counter = get_tlm_cnt(\"#{target_name.upcase}\", \"#{target_name.upcase + HK_PACKET_SUFFIX}\")\n wait_check_expression(\"get_tlm_cnt(\\\"#{target_name.upcase}\\\", \\\"#{target_name.upcase + HK_PACKET_SUFFIX}\\\") > #{counter}\", timeout) \n end", "def needs_transcript?(tscripts=self.transcripts_alone)\n unfinished_tasks = self.unfinished_tasks\n basic_transcript_tasks = unfinished_tasks.select{|t| t.type == \"Tasks::TranscribeTask\"}\n premium_transcript_tasks = unfinished_premium_transcribe_tasks\n\n if tscripts.size == 0 and !has_basic_transcribe_task_in_progress?(basic_transcript_tasks) and !has_premium_transcribe_task_in_progress?(premium_transcript_tasks)\n return true\n end\n\n return false\n end", "def tranch_available?\n current_tranch_open? and previous_tranch_all_sold_out_or_operated?\n end", "def active?\n self.class.active_names.include?(@name)\n end", "def feature_provided?(name)\n if name.suffix?(\".rb\") or name.suffix?(LIBSUFFIX)\n return loaded? name\n elsif name.suffix? \".so\"\n # This handles cases like 'require \"openssl.so\"' on\n # platforms like OS X where the shared library extension\n # is not \".so\".\n return loaded?(name[0..-4] + LIBSUFFIX)\n else\n return true if loaded?(name + \".rb\")\n return loaded?(name + LIBSUFFIX)\n end\n\n return false\n end", "def is_sles?\n return !!@name.match(/^sles-.*$/)\n end", "def tax_included?(price_base)\n send(\"included_in_#{price_base}\".to_sym)\n end", "def addable?(name)\n if name_link(name).exists?\n self.button(:title=>\"Request connection with #{name}\").present?\n else\n puts \"\\n#{name} isn't in the results list. Check your script.\\nThis may be a false negative.\\n\"\n return false\n end\n end", "def registered_traveler?\n registered? && traveler?\n end", "def include?(name)\n ! self[name].nil?\n end", "def uses_reaction? file\n @reactions_files.include? file\n end", "def has_plugin?(name)\n true\n end", "def trinket_item?(options)\n options[:slot] == 'trinket'\n end", "def acts_like?(duck)\r\n respond_to? \"acts_like_#{duck}?\"\r\n end", "def googlemerchant?\n Object.const_defined?('TradoGooglemerchantModule') ? true : false\n end", "def is_a_row_for_this_integration_required?(specified_pacticipant_names, consumer_name)\n specified_pacticipant_names.include?(consumer_name)\n end", "def has_premium_transcripts?\n self.id.match(/_(business|enterprise|premium)_/) or self.id.match(/_(monthly|yearly)/) or self.is_community?\n end", "def activated?\n @activated ||=\n begin\n loaded = Gem.loaded_specs[name]\n loaded && loaded.version == version\n end\n end", "def territorial_core?\n @node[\"territorial_core\"]\n end", "def vendor?\n !vendor.empty?\n end", "def legal? class_name = nil, race = nil\n\t\tif @character != nil\n\t\t\tclass_name = @character.character_class.to_s if class_name == nil\n\t\t\trace = @character.race.to_s if race == nil\n\t\tend\n\t\tif @skill.prohibits != nil\n\t\t\tif @skill.prohibits.include?(race) or @skill.prohibits.include?(class_name)\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\treturn true\n\tend", "def include?(key)\n @driver.include?(key)\n end", "def is_a?(name)\n\ttarget = Units.parse_symbol(name)\n\t(target && @units.include?(target[:base])) || super(name)\n end", "def client_support_for?(mechanism_name)\n Gsasl.gsasl_client_support_p(@context, mechanism_name) == 1\n end", "def can_sell_train?(train)\n owner = train.owner\n return true unless railway?(owner)\n return true if owner == @qlb\n return true unless train_is_train?(train)\n\n if owner == @nwe && train.distance < 2\n true # nwe will always have a train besides a 1T\n elsif owner == @nwe\n owner.trains.count { |t| train_is_train?(t) && t.distance > 1 } > 1\n else\n owner.trains.count { |t| train_is_train?(t) } > 1\n end\n end", "def trader; end" ]
[ "0.5888238", "0.5787151", "0.5757915", "0.5697748", "0.5591588", "0.5573237", "0.5568156", "0.55568385", "0.55483603", "0.5478202", "0.54692006", "0.54633176", "0.5462344", "0.54104614", "0.54025984", "0.53912944", "0.53881776", "0.5381641", "0.53653157", "0.5353985", "0.5345904", "0.5342234", "0.5340149", "0.5333701", "0.53328276", "0.5320975", "0.5310618", "0.53058875", "0.52885026", "0.5287893", "0.52727526", "0.5268205", "0.5261629", "0.52541375", "0.52303696", "0.5222541", "0.5220725", "0.52194196", "0.5216687", "0.52038616", "0.5202896", "0.52010065", "0.5193058", "0.51898617", "0.5182153", "0.5163528", "0.51602083", "0.5155211", "0.51541865", "0.51536626", "0.5153037", "0.5147124", "0.5142651", "0.5138697", "0.5136846", "0.51364994", "0.51336014", "0.51331484", "0.5132913", "0.51307446", "0.51307446", "0.5124677", "0.51242465", "0.51199067", "0.51172256", "0.5116937", "0.51072675", "0.5103423", "0.51013374", "0.5094663", "0.5090542", "0.5086043", "0.50856686", "0.5080915", "0.5080604", "0.5076882", "0.5070015", "0.5054094", "0.5052723", "0.50516564", "0.50470555", "0.5045245", "0.50441074", "0.5041438", "0.50323564", "0.50314045", "0.50239503", "0.50237185", "0.5023579", "0.5018442", "0.5018396", "0.5015284", "0.50148267", "0.50126725", "0.5012068", "0.5010557", "0.50089973", "0.5005779", "0.5002472", "0.500163", "0.49939013" ]
0.0
-1
make display delay in seconds
def delay(frame) (frame*40).to_i.times {Graphics.update} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redisplay_delay\r\n 20\r\n end", "def delay(seconds); end", "def delay(seconds); end", "def delay\n sleep(2)\n end", "def delay(seconds)\n sleep(seconds)\n end", "def delay; end", "def delay; end", "def delay; end", "def delay_time\n end", "def delay\n \"%3d days %2d hours %2d minutes %2d seconds\" % distance_of_time_as_array( timestamp_device, timestamp_server)\n end", "def update\r\n # タイマー作動中なら可視に設定\r\n self.visible = $game_system.timer_working\r\n # タイマーを再描画する必要がある場合\r\n if $game_system.timer / 60 != @total_sec # Graphics.frame_rate\r\n # トータル秒数を計算\r\n @total_sec = $game_system.timer / 60#Graphics.frame_rate\r\n # タイマー表示用の文字列を作成\r\n min = @total_sec / 60\r\n sec = @total_sec % 60\r\n # タイマーを描画\r\n self.text = sprintf(\"%02d:%02d\", min, sec)\r\n end\r\n end", "def delay\n @delay ||= 600\n end", "def delay\n puts \"Delaying ...\"\n sleep 1\n end", "def delay_1() sleep(3) end", "def sleep(dur=0) end", "def timer\n seconds = (@panel_input % 100) % 60\n minutes = @panel_input / 100 + (@panel_input % 100) / 60\n \"%02<mm>d:%02<ss>d\" .% mm: minutes, ss: seconds\n end", "def delay\n sleep(rand / 100)\n end", "def pause(seconds)\n sleep seconds\n end", "def delay_time=(seconds)\n end", "def puttime\n if gameover?\n return\n end\n setpos(TIMELINE,0)\n addstr( (Time.now.to_i - @start).to_s + \" sec\")\n end", "def wfs_delay\r\n\t\t10\r\n\tend", "def delay! seconds\n @delay_received << seconds\n end", "def short_display_time\n\t\tself.timestamp.strftime(\"%b %d %-l:%M %p\") + (self.is_full? ? \" (Waitlist)\" : \"\")\n\tend", "def giveUp(timeDelay)\n @delayTime = timeDelay.abs.to_i\n @timerField = NSTextField.alloc.initWithFrame([[0, 0], [40, 20]])\n .tap do |obj| # origin will be set later\n obj.bordered = false\n obj.drawsBackground = false\n obj.font = NSFont.fontWithName('Menlo Bold', size: 12) # mono-spaced\n obj.editable = false\n obj.selectable = false\n obj.alignment = NSTextAlignmentCenter\n obj.toolTip = 'time remaining'\n end unless defined?(@timerField)\n end", "def half_refresh\n contents.clear_rect(24, 0, contents_width - 24, line_height)\n draw_text(24, 0, contents_width - 24, line_height, $game_system.playtime_s, 2)\n end", "def set_delay(delay)\n @delay = delay\n end", "def display_sleep\n @property_hash['displaysleep']\n end", "def seconds() self end", "def delay\n @delay || initial_delay\n end", "def puttime\n return if gameover?\n\n setpos(TIMELINE, 0)\n addstr(\"#{Time.now.to_i - @start} sec\")\n end", "def show_time\n\n end", "def delay_me\n\t\tsleep(10.0) # sleep for 10 seconds between queries\n\tend", "def dot_and_sleep(interval)\n print('.')\n sleep(interval)\n end", "def show_time(string)\n return unless string && timing?\n\n if @@message_callback\n @@message_callback.call(:info, string)\n else\n $stderr.puts \"#{GREEN}#{string}#{RESET}\"\n end\n end", "def delay_ms(ms)\n @delay_ms = ms\n end", "def timer; end", "def timer; end", "def timer; end", "def timer; end", "def show\n @begin = @timed_form.begin\n @countdown_remaining = @timed_form.begin\n \n a = @begin.split(\":\")\n @minutes = a[0].to_i\n @seconds= a[1].to_i\n @time_seconds = -(@minutes * 60 + @seconds) + 600\n @time_format = Time.at(@time_seconds).utc.strftime(\"%M:%S\")\n end", "def countdown_with_sleep(number)\n # Use the stack overflow post linked in the lesson to figure out how to establish a wait time between print statements\nend", "def display_countdown\n end_time = Time.now + @interval\n until Time.now > end_time\n print \"#{time_remaining(end_time)}\\r\"\n sleep 1\n end\n puts \"#{pomodoro_status} -- POSTED at #{current_time}\"\n end", "def update_timer(str)\n hc_timer_label.text = str\n end", "def time_to_show\n \n end", "def draw_playtime(x, y, width, align)\n hour = @total_sec / 60 / 60\n min = @total_sec / 60 % 60\n sec = @total_sec % 60\n time_string = sprintf(\"%02d:%02d:%02d\", hour, min, sec)\n self.contents.font.color = normal_color\n self.contents.draw_text(x, y, width, WLH, time_string, 2)\n end", "def delay_display_call(*args)\n @update_to_call << args\n end", "def wait_animation\n sleep 0.8\n end", "def finish_round\n display(\"\\n\\n ---------------- TIME TO SETTLE ---------------- \\n\\n\")\n end", "def delay\n if @delay_den != 0\n @delay_num/@delay_den\n else\n @delay_num/100\n end\n end", "def default_delay\n 0.seconds\n end", "def countdown_display_before_restart_in_minutes\n return @countdown_display_before_restart_in_minutes\n end", "def sleep(n)\n Kernel.sleep(n)\n end", "def delay\n @delay || initial_delay\n end", "def show_wait_spinner(fps=10)\n chars = %w[| / - \\\\]\n delay = 1.0/fps\n iter = 0\n spinner = Thread.new do\n while iter do # Keep spinning until told otherwise\n print chars[(iter+=1) % chars.length]\n sleep delay\n print \"\\b\"\n end\n end\n yield.tap{ # After yielding to the block, save the return value\n iter = false # Tell the thread to exit, cleaning up after itself…\n spinner.join # …and wait for it to do so.\n } # Use the block's return value as the method's\n end", "def sleep_after(seconds)\n write_bytes(27, 56, seconds)\n end", "def sleep\n sleep_after(0)\n end", "def reset_times_after_display\n @@resets_after_display = true\n end", "def sleep_time\n 60\n end", "def draw s, delay = nil\n puts s # note if s is array, it is joined with \"\\n\"\n if delay\n puts \"wait #{delay}\"\n end\n puts \"update\"\n $stdout.flush\nend", "def pause wait_time\r\n command 'pause', wait_time\r\n end", "def loading_effect(n = 3, opts = {})\n delay = opts[:delay] || 0.3\n symbol = opts[:symbol] || '.'\n 1.upto(n) do\n print symbol\n sleep delay\n end\n nil\n end", "def delay(duration_in_milliseconds)\n append_to_script \"delay \\\"#{duration_in_milliseconds}\\\"\"\n end", "def wait_animation(message, time_seconds)\n print message\n print \" [ ]\"\n STDOUT.flush\n time_seconds.downto(1) do\n 1.upto(4) do |i|\n next_output = \"\\b\\b\\b\\b\\b\\b\\b\"\n case\n when i % 4 == 0\n next_output += \"[ = ]\"\n when i % 3 == 0\n next_output += \"[ = ]\"\n when i % 2 == 0\n next_output += \"[ = ]\"\n else\n next_output += \"[ = ]\"\n end\n\n print next_output\n STDOUT.flush\n sleep(0.25)\n end\n end\n # remove loading animation\n print \"\\b\\b\\b\\b\\b\\b\\bRefreshing...\"\n STDOUT.flush\n puts\n end", "def wfs_delay\n\t\t30\n\tend", "def sub_delay _value, _abs=0\n send_cmd(\"sub_delay #{_value} #{_abs}\")\n end", "def show_start\n @start_time = Time.now\n puts TTY::Box.frame(self.class.name,\n \"Start : #{@start_time}\",\n width: TTY::Screen.width, padding: 1,\n border: { left: false, right: false })\n end", "def tv_sec() end", "def loader(body, time)\n pastel = Pastel.new\n spinner = TTY::Spinner.new(pastel.blue(\":spinner :text :spinner \"), format: :dots_2)\n spinner.auto_spin\n if !time.nil?\n time.downto(0) do |sec|\n spinner.update(text: \"#{body} (Est. #{sec}s)\")\n sleep(1)\n end\n else\n spinner.update(text: \"#{body}\")\n end\n spinner\nend", "def with_timing(caption)\n start_time = Time.now\n print caption.to_s\n yield\n puts \"(#{(Time.now - start_time).duration})\"\n end", "def wait_for_seconds\n\t\tsleep(1 * rand + 1)\n\tend", "def sleep_if_set\n config[:sleep].to_i.times do\n print '.'\n sleep 1\n end\n end", "def display_time(secs)\n [[60, :s], [60, :m], [9999, :h]].map do |count, name|\n if secs > 0\n secs, n = secs.divmod(count)\n\n \"#{n.to_i}#{name}\" unless n.to_i == 0\n end\n end.compact.reverse.join(' ')\n end", "def on_timer(evt)\n offset = @mc.tell\n # Will be -1 if nothing is loaded\n if offset >= 0\n @slider.value = offset\n offset_secs = offset / 1000 \n @st_pos.label = \"%i:%02d\" % [ offset_secs / 60, offset_secs % 60 ]\n else\n @st_pos.label = \"\"\n end\n end", "def show_time(duration)\n time_taken = Time.at(duration).utc\n time_taken.strftime('%-H hours, %-M Minutes and %-S seconds')\n end", "def click_delay(seconds = 0)\n sleep(ENV['MIN_CLICK_DELAY'].to_i + seconds) if ENV['DO_CLICK_DELAY'] == \"true\"\n end", "def init_text\n puts 'Iniciando programa'\n print '.'\n sleep(0.3)\n print '.'\n sleep(0.3)\n print '.'\n print \"\\n\"\nend", "def delay(time)\n @context.backend.delay(time)\n end", "def sleep\n #sleeps\n puts \"*sleeps*\"\n end", "def delay=(value)\n\t\t\t@delay = value\n\t\tend", "def delay=(value)\n\t\t\t@delay = value\n\t\tend", "def show!\n Spi.begin do |s|\n s.clock(@spi_hz)\n s.write(START_FRAME + @led_frames + @end_frame)\n end\n end", "def display_time(total_seconds) \n days = total_seconds / 86400\n hours = (total_seconds / 3600) - (days * 24)\n minutes = (total_seconds / 60) - (hours * 60) - (days * 1440)\n seconds = total_seconds % 60\n \n display = ''\n display_concat = ''\n if days > 0\n display = display + display_concat + \" #{days}d\"\n display_concat = ' '\n end\n if hours > 0 || days > 0\n display = display + display_concat + \" #{hours}h\"\n display_concat = ' '\n end\n if days == 0 && (minutes > 0 || hours > 0)\n display = display + display_concat + \" #{minutes}m\"\n display_concat = ' '\n end\n if hours == 0 && days == 0 && minutes < 5\n display = display + display_concat + \" #{seconds}s\"\n end\n display\n end", "def page_delay\n if $TESTWISE_PAGE_DELAY && $TESTWISE_PAGE_DELAY.to_i > 0 && $TESTWISE_PAGE_DELAY.to_i < 100\n sleep $TESTWISE_PAGE_DELAY.to_i\n end \n end", "def intro\nputs\"You are sent to prison for a crime you are not responsable, but soon a path is showing up...\"\nsleep (5)\nend", "def display_time(total_seconds)\n total_seconds = total_seconds.to_i\n\n days = total_seconds / 86400\n hours = (total_seconds / 3600) - (days * 24)\n minutes = (total_seconds / 60) - (hours * 60) - (days * 1440)\n seconds = total_seconds % 60\n\n display = ''\n display_concat = ''\n\n if days > 0\n display = display + display_concat + \"#{days}d\"\n display_concat = ' '\n end\n\n if hours > 0 || display.length > 0\n display = display + display_concat + \"#{hours}h\"\n display_concat = ' '\n end\n\n if minutes > 0 || display.length > 0\n display = display + display_concat + \"#{minutes}m\"\n display_concat = ' '\n end\n\n display = display + display_concat + \"#{seconds}s\"\n display\nend", "def splay\n return unless Puppet[:splay]\n return if splayed?\n\n time = rand(Integer(Puppet[:splaylimit]) + 1)\n Puppet.info \"Sleeping for #{time} seconds (splay is enabled)\"\n sleep(time)\n @splayed = true\n end", "def snooze(t)\n sleep(t)\n end", "def show(ticks = 0)\n draw\n (ticks || 0).times do |tick|\n update\n draw\n end\n end", "def page_delay(seconds = ENV['MIN_PAGE_DELAY'].to_i)\n sleep(seconds) if ENV['DO_PAGE_DELAY'] == \"true\"\n end", "def delay milliseconds\n\n # Do nothing with zero delay\n return if milliseconds == 0.0\n\n # Apply delay to all subtitles\n @subtitles.each do | subtitle |\n subtitle.delay milliseconds\n end\n end", "def intro\n clear_screen\n print \"Today is \"\n puts Time.now\n sleep(2)\n puts\"\\nYou are travelling by motorcycle on a dirt road in Thailand, when all of a sudden you swerve and hit a ditch. Knocking yourself unconcious...\\n\\n\"\n sleep (5)\nend", "def initial_dealing_time\r\n\tdelay_time_of_card(@players.count - 2, 1)\r\n end", "def speed\n render_start = Time.monotonic\n yield\n num = (Time.monotonic - render_start) * 1000\n if num > 1000\n '%s sec' % (num/1000).round(2)\n else\n '%s ms' % num.round(1)\n end\n end", "def pause(p)\n \tsleep p\n \tputs\nend", "def display_message!(*lines)\n display_message(*lines)\n sleep 0.01 until message_drawn?\n end", "def count_down(pause_seconds, pre_txt='', post_txt='')\n count = pause_seconds\n max_len = count.to_s.size\n while count > 0\n $stdout.printf(\"...#{pre_txt}%#{max_len}d#{post_txt}\", count)\n sleep(1)\n $stdout.write(\"\\r\")\n count -= 1\n end\n $stdout.printf(\"...#{pre_txt}%#{max_len}d#{post_txt}\\n\", 0)\n end", "def pause; end", "def show_time=(show=false)\n @@show_time = show\n end", "def wfs_delay\n 2\n end", "def delay(x=1) \n current_time = Time.now.to_i\n while Time.now.to_i - current_time < x \n\tend\nend" ]
[ "0.817539", "0.7338207", "0.7338207", "0.7234594", "0.72319514", "0.70718074", "0.70718074", "0.70718074", "0.6912656", "0.6888546", "0.68167716", "0.67870784", "0.666166", "0.6615868", "0.658306", "0.64956176", "0.64712447", "0.6469668", "0.63935375", "0.6328195", "0.6229597", "0.62249994", "0.6214636", "0.6194727", "0.6135165", "0.6132041", "0.613074", "0.61253333", "0.6114117", "0.6112239", "0.60917467", "0.60892516", "0.60827875", "0.60701483", "0.6067773", "0.6063445", "0.6063445", "0.6063445", "0.6063445", "0.60595834", "0.60422516", "0.6032763", "0.6026297", "0.60084105", "0.60079527", "0.6006235", "0.600324", "0.5998477", "0.59949404", "0.5989461", "0.59845805", "0.59712225", "0.59646994", "0.59574544", "0.5950479", "0.594722", "0.59369135", "0.5933143", "0.592293", "0.59176165", "0.59131235", "0.59113723", "0.5904794", "0.5893766", "0.5891638", "0.5887409", "0.5881921", "0.58737165", "0.58686787", "0.5864255", "0.58629775", "0.58599967", "0.58523816", "0.5850068", "0.5843523", "0.58301526", "0.5825934", "0.5807792", "0.5799176", "0.5799176", "0.57883584", "0.5788356", "0.57845265", "0.57837903", "0.57754105", "0.5772548", "0.57580775", "0.5752592", "0.57519466", "0.5746458", "0.57366234", "0.5736238", "0.57355136", "0.5733715", "0.5724655", "0.5723355", "0.5713892", "0.57131165", "0.5694577", "0.5693847" ]
0.63839656
19
GET /moneyboxes GET /moneyboxes.json
def index @moneyboxes = Moneybox.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @cashboxes = Cashbox.all\n end", "def list_all_tenantcircles_for_a_version_box(args = {}) \n get(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args)\nend", "def list_all_aos_version_boxes(args = {}) \n get(\"/aosversions.json/aosversionbox\", args)\nend", "def get_coins\n get(\"/getcoins\")\n end", "def set_moneybox\n @moneybox = Moneybox.find(params[:id])\n end", "def index\n @boxes = Box.order(:start_time).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boxes }\n end\n end", "def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end", "def index\n @cashbox = Cashbox.all\n end", "def index\n @boxes = Box.all.order(created_at: :desc).page params[:page]\n end", "def index\n @inboxes = Inbox.all\n @inboxes = @inboxes.select { |x| x.umkm_id == params[:umkm_id].to_i }\n render json: {items: @inboxes}\n end", "def index\n @budgets = Budget.find_owned_by current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @budgets }\n end\n end", "def show\n @money = Money.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @money }\n end\n end", "def list_coins\n endpoint = \"#{HOST}/v1/cryptocurrency/map\"\n get(endpoint)\n end", "def index\n @bills = Bill.all_cached\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bills }\n end\n end", "def index\n @referenceboxes = Referencebox.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @referenceboxes }\n end\n end", "def destroy\n @moneybox.destroy\n respond_to do |format|\n format.html { redirect_to moneyboxes_url }\n format.json { head :no_content }\n end\n end", "def contracts\n\t\t@user = User.find_by_username(params[:profile_id])\n\t\tif !@user.present?\n\t\t\tredirect_to root_path\n\t\tend\n\n\t\tcontracts = []\n\t\tif current_admin.present? || (current_user.meets_contract_preferences?(@user) && !@user.is_blocking_user?(current_user))\n\t\t\t(@user.posted_contracts.where(status: \"Open\") + @user.posted_bounties.where(status: \"Open\")).each do | c |\n\t\t\t\tcontracts << {\n\t\t\t\t\t:id => c.id,\n\t\t\t\t\t:start=> c.start_date_time,\n\t\t\t\t\t:end=> c.end_date_time,\n\t\t\t\t\t:title=> \"$#{c.price_in_dollars}\",\n\t\t\t\t\t:type => c.contract_type\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\t\trender :json => contracts\n\tend", "def index\n @boxscores = @game.boxscores\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boxscores }\n end\n end", "def index\n @boxes = Box.by_filter(params.slice(:gender, :size)).active.page(params[:page]).per(12)\n @charity = Charity.where(:status => \"active\").first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boxes }\n end\n end", "def index\n @contracts = Contract.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contracts }\n end\n end", "def show\n @box = Box.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @box }\n end\n end", "def get_aos_version_box_by_id(args = {}) \n get(\"/aosversions.json/aosversionbox/#{args[:aosVersionBoxId]}\", args)\nend", "def index\n # @inboxes = current_account.try(:inboxes) || Inbox.all \n @account_inboxes = current_account.account_inboxes.page(params[:page]).per(6)\n end", "def getbalance(args={})\n {\n :method=> \"GetBalances\"\n }.to_json\n end", "def bills(options = {})\n get('/bills', options)\n end", "def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend", "def get_aos_version_box_by_name(args = {}) \n get(\"/aosversions.json/aosversionbox/name/#{args[:aosVersionBoxName]}\", args)\nend", "def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend", "def balances()\n request(\"#{@base_url}/account/getbalances\")\n end", "def budgets\n # https://developer.xero.com/documentation/api/budgets\n # if you are having issues in adding the accounting.budgets.read scope, get in touch => api@xero.com\n @budgets = xero_client.accounting_api.get_budgets(current_user.active_tenant_id).budgets\n @budget = xero_client.accounting_api.get_budget(current_user.active_tenant_id, @budgets.sample.budget_id).budgets\n end", "def index\n @items = Item.all\n @budget = Budget.find params[:budget_id]\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end\n end", "def index\n @mint_coins = @coin.mint_coins\n\n @mint_coins_by_grouping = group_mint_coins(@mint_coins)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @mint_coins }\n end\n end", "def index\n @bills = @dwelling.bills\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bills }\n end\n end", "def balances(id)\n get(\"/accounts/#{id}/balances\")\n end", "def index\n @page_count, @contracts = Locomotive::Contract.paginated(:page => (params[:page] || 1).to_i)\n display @contracts\n end", "def index\n get_contracts\n end", "def index\n render json: @user.contracts, each_serializer: ContractSerializer\n end", "def balance\n rest.get(:getbalance)['data']\n end", "def index\n @baskets = Basket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @baskets }\n end\n end", "def index\n get_budgets\n end", "def index\n @bitcoins = Bitcoin.all\n end", "def index\n @petty_cash_expenses = PettyCashExpense.all\n render json: @petty_cash_expenses\n end", "def cashbox_params\n params[:cashbox]\n end", "def cashbox_params\n params[:cashbox]\n end", "def index\n @boxes_count = Rails.cache.fetch('/boxes/count') do\n Box.all.count\n end\n\n search = \"(b:Box)-[]->(r:Room)\"\n request = ActiveGraph::Base.new_query.match(search)\n\n cache_key = \"/boxes/data/\" + Digest::SHA1.hexdigest(@where_string + @sort_string + @skip.to_s + @limit.to_s)\n @boxes = request.where(@where_string)\n .order(@sort_string)\n .skip(@skip)\n .limit(@limit)\n .pluck('b, r')\n .collect do |result| {\n id: result[0].id,\n name: result[0].name,\n room_id: result[1].id,\n room_name: result[1].name\n }\n end\n\n # Для фильтрации\n @boxes_list = request.order('b.name').pluck('distinct b')\n @rooms = request.order('r.name').pluck('distinct r')\n end", "def index\n @orders = Order.all.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 10)\n @cart = current_cart\n @user = current_user\n params[:box_id] = @box_id\n @order = Order.new(box_id: params[:box_id])\n lastBox = Box.last.id\n @box = Box.find(params = lastBox)\n end", "def index\n @utilized_bitcoin_wallets = UtilizedBitcoinWallet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @utilized_bitcoin_wallets }\n end\n end", "def index\n @article_boxes = ArticleBox.all\n end", "def show\n @box = Box.find(params[:id])\n @user = @box.user\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @box }\n end\n end", "def index\n # TODO: implement filters\n @budgets = Budget.order(\"budgets.starts_at DESC, budgets.number ASC\")\n .page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n #format.select2 { render json: { items: budgets.map(&:to_select2_json), total: @budgets.count} }\n #format.json { render json: @budgets }\n end\n end", "def show\n @box_score = BoxScore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @box_score }\n end\n end", "def index\n @bills = Bill.all\n \n respond_with @bills, represent_with: Billit::BillPageRepresenter\n end", "def coins\n\t\tres = {}\n\t\tuser = User.find_by_token(params[:token])\n\t\tif user\n\t\t\tres[:status] = \"0\"\n\t\t\tres[:coins] = user.coins\n\t\telse\n\t\t\tres[:status] = \"1\"\n\t\tend\n\t\trender json: res\n\tend", "def index\n @cryptocurrencies = Cryptocurrency.all\n\n require 'net/http'\n require 'json'\n\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_crypto = JSON.parse(@response)\n\n @profit_loss = 0\n end", "def index\n render json: Bill.all\n end", "def index\n @call_boxes = CallBox.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @call_boxes }\n end\n end", "def mailboxes_list\n get \"mailboxes\"\n end", "def index\n @cryptostables = Cryptostable.all\n\n require 'uri'\n require 'net/http'\n require 'openssl'\n\n @url = \"https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?CMC_PRO_API_KEY=#{ENV.fetch('CRYPTO')}&start=1&limit=500\"\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_cryptos = JSON.parse(@response)\n @profit_loss = 0\n end", "def show\n @boxscore = @game.boxscores.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boxscore }\n end\n end", "def index\n @boxes = Box.order('id DESC').paginate(page: params[:page], per_page: 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boxes }\n format.csv { render csv: boxes_scoped, filename: \"Cajas #{Date.today}\" }\n end\n end", "def getnettotals\n @api.request 'getnettotals'\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 index\n @promotion_boxes = PromotionBox.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @promotion_boxes }\n end\n end", "def index\n @box_contents = BoxContent.all\n end", "def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end", "def index\n @deposit_types = DepositType.all\n @abs_deposit_types = JSON.parse(Redis.current.get(\"deposit_types\"))\n end", "def index\n @budgets = Budget.all\n end", "def get_inboxes_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: InboxControllerApi.get_inboxes ...'\n end\n if @api_client.config.client_side_validation && !opts[:'size'].nil? && opts[:'size'] > 100\n fail ArgumentError, 'invalid value for \"opts[:\"size\"]\" when calling InboxControllerApi.get_inboxes, must be smaller than or equal to 100.'\n end\n\n allowable_values = [\"ASC\", \"DESC\"]\n if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])\n fail ArgumentError, \"invalid value for \\\"sort\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/inboxes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?\n query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?\n query_params[:'excludeCatchAllInboxes'] = opts[:'exclude_catch_all_inboxes'] if !opts[:'exclude_catch_all_inboxes'].nil?\n query_params[:'before'] = opts[:'before'] if !opts[:'before'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['*/*'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<InboxDto>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['API_KEY']\n\n new_options = opts.merge(\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 => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: InboxControllerApi#get_inboxes\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @core_stock_bills = Core::StockBill.find_mine(params).paginate(page: params[:page])\n end", "def index\n @inboxes = current_user.inboxes\n end", "def fetch_meli_boxes!(filters={})\n puts \"# AccountSyncWorker.fetch_meli_boxes! filters: #{filters}\"\n query_meli_boxes filters do |partial_orders, data, opts|\n puts \"# AccountSyncWorker.fetch_meli_boxes! opts: #{opts}\"\n add_to_collection partial_orders, opts\n ##\n # TODO\n # Enqueue collection instead of adding to collection\n # enqueue_meli_query opts\n ##\n end\n end", "def index\n @invoices = @user.invoices.all\n render json: @invoices, status: :ok\n end", "def show\n @currencies = CryptocurrenciesService.new.get_top\n end", "def index\n @contracts = Contract\n .where(customer_id: @customer.id)\n .order(:created_at)\n .page params[:page]\n\n respond_to do |format|\n format.html {}\n format.js { render json: @contracts.to_json }\n format.json { render json: @contracts.to_json }\n end\n\n end", "def sentbox \n add_breadcrumb \"Sentbox\"\n\n @sentbox = current_user.mailbox.sentbox.page(params[:page])\n\n respond_with(@sentbox)\n end", "def vault_objects(vault_id)\n request_get(\"/vault/#{vault_id}\")\n end", "def index\n @banks = Bank.all\n render json: @banks\n end", "def index\n @holders = Holder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @holders }\n end\n end", "def get_currency_balance_all_using_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CurrencyBalanceApi.get_currency_balance_all_using_get ...'\n end\n # resource path\n local_var_path = '/currency_balance'\n\n # query parameters\n query_params = {}\n query_params[:'wallet_id'] = opts[:'wallet_id'] if !opts[:'wallet_id'].nil?\n query_params[:'currency_id'] = opts[:'currency_id'] if !opts[:'currency_id'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'order_by'] = opts[:'order_by'] if !opts[:'order_by'].nil?\n query_params[:'ascending'] = opts[:'ascending'] if !opts[:'ascending'].nil?\n query_params[:'get_latest'] = opts[:'get_latest'] if !opts[:'get_latest'].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']\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 => 'PageCurrencyBalanceResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CurrencyBalanceApi#get_currency_balance_all_using_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n respond_to do |format|\n format.html # index.html.erb (no data required)\n f = find_budgets\n format.ext_json { render :json => f.to_ext_json(:class => :budget, \n :count => f.length,\n :methods=>[:total_budget_costs,:total_budget_invoices,:total_budget_pricings],\n :include=>{:user=>{:only=>\"login\"}}) }\n \n end\n end", "def index\n @bill_cargos = @bill.bill_cargos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bill_cargos }\n end\n end", "def market_data\n endpoint = \"#{HOST}/v1/cryptocurrency/listings/latest\"\n get(endpoint)\n end", "def index\n results = []\n if params[:bbox]\n results = VAFacility.query(bbox: params[:bbox], type: params[:type], services: params[:services])\n end\n resource = Common::Collection.new(::VAFacility, data: results)\n resource = resource.paginate(pagination_params)\n render json: resource.data,\n serializer: CollectionSerializer,\n each_serializer: VAFacilitySerializer,\n meta: resource.metadata\n end", "def index\n # this whole process is updating the users coins with the currnet price from the api. pulls the users coins and if a coin matches then update the price in usd. and return the coin.\n coins = HTTParty.get(BASE_URL) # this will bring back the top 100 coins in an array\n user_coins = current_user.coins\n user_coins.each do |coin|\n res_coin = coins.find { |c| c['id'] == coin.cmc_id }\n coin.update(price: res_coin['price_usd']) if res_coin \n end \n render json: current_user.coins # if we don't authenticate_user before then we cant user current_user. it is a built in devise function\n end", "def index\n\n @debtors = Debtor.all\n\n render json: @debtors\n end", "def index\n @collections = Collection.all.order(\"created_at DESC\")\n @total = @collections.sum(:amount)\n @balance = (10000 - @total)\n end", "def show_coins_list\n coins_list(coins)\n end", "def get_accounts()\n http_get(accounts_url)\n end", "def index\n @bill_quorums = BillQuorum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bill_quorums }\n end\n end", "def post_boxes\n Easybill::Api::PostBoxes\n end", "def index\n #@cashflows = Cashflow.all\n @cashflows = Cashflow.paginate(:page => params[:page], :per_page => 10)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cashflows }\n end\n end", "def show\n @inbox = Inbox.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inbox }\n end\n end", "def index\n @vaults = Vault.all\n end", "def update\n respond_to do |format|\n if @moneybox.update(moneybox_params)\n format.html { redirect_to @moneybox, notice: 'Moneybox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @moneybox.errors, status: :unprocessable_entity }\n end\n end\n end", "def recount_money\n @team = Team.find(params[:id])\n @money = get_money_array(@team, params[:amount].to_f, params[:fromDate], params[:toDate])\n \n respond_to do |format|\n format.json {\n render json: @money\n }\n end\n end", "def index\n @cryptocurrencies = Cryptocurrency.all\n require 'net/http'\n require 'json'\n @url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?start=1&limit=100&CMC_PRO_API_KEY=8e364003-38f2-410d-81af-9166deca3a6f'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @array1 = JSON.parse(@response).to_a\n @array2 = @array1[1].to_a\n @lookup_crypto = @array2[1].to_a\n @profit_loss = 0\n end", "def index\n @bank_accounts = BankAccount.all\n render :json => @bank_accounts.to_json\n end", "def index\n @accounts = current_user.person.blackberry_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def index\n\t\t@accounts = Account.all\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @accounts }\n\t\tend\n\tend", "def show\n @stats_money_transaction = Stats::MoneyTransaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stats_money_transaction }\n end\n end" ]
[ "0.6577376", "0.6549823", "0.65441465", "0.64175475", "0.63030446", "0.62492555", "0.6243145", "0.6115511", "0.6090706", "0.60815036", "0.60267776", "0.6010496", "0.5971386", "0.59683895", "0.59509456", "0.58704364", "0.5822551", "0.58150595", "0.581109", "0.5799254", "0.57789403", "0.5769665", "0.5756227", "0.5751485", "0.5729457", "0.5719559", "0.56710213", "0.56579864", "0.56534034", "0.56483597", "0.5632616", "0.56075925", "0.56015223", "0.56007713", "0.5593902", "0.5585702", "0.5584126", "0.5580511", "0.5574022", "0.5565635", "0.55645925", "0.55410624", "0.5528091", "0.5528091", "0.5523398", "0.5519129", "0.55156153", "0.5512356", "0.5504025", "0.54879546", "0.5482697", "0.54791176", "0.54741126", "0.5469348", "0.5454546", "0.54543066", "0.54505813", "0.544925", "0.5437334", "0.5426865", "0.54204077", "0.54146546", "0.54076725", "0.54022586", "0.5399863", "0.53919035", "0.5379687", "0.5374756", "0.53589076", "0.5336963", "0.53369594", "0.53320265", "0.5320364", "0.5318428", "0.5315607", "0.5312396", "0.5307029", "0.5304774", "0.5301603", "0.530109", "0.52949315", "0.52948576", "0.52912635", "0.52894986", "0.52854264", "0.52804506", "0.52783376", "0.52755404", "0.52741826", "0.5273081", "0.5266161", "0.5263418", "0.526096", "0.5255411", "0.52526015", "0.5246506", "0.5235895", "0.5225885", "0.52248853", "0.52248454" ]
0.7581377
0
GET /moneyboxes/1 GET /moneyboxes/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @moneyboxes = Moneybox.all\n end", "def set_moneybox\n @moneybox = Moneybox.find(params[:id])\n end", "def show\n @money = Money.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @money }\n end\n end", "def index\n @money = Money.all\n require 'net/http'\n require 'json'\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_money = JSON.parse(@response)\n end", "def list_all_tenantcircles_for_a_version_box(args = {}) \n get(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args)\nend", "def index\n @cashboxes = Cashbox.all\n end", "def list_all_aos_version_boxes(args = {}) \n get(\"/aosversions.json/aosversionbox\", args)\nend", "def get_coins\n get(\"/getcoins\")\n end", "def get_aos_version_box_by_id(args = {}) \n get(\"/aosversions.json/aosversionbox/#{args[:aosVersionBoxId]}\", args)\nend", "def show\n @box = Box.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @box }\n end\n end", "def get_aos_version_box_by_name(args = {}) \n get(\"/aosversions.json/aosversionbox/name/#{args[:aosVersionBoxName]}\", args)\nend", "def index\n @boxes = Box.order(:start_time).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boxes }\n end\n end", "def index\n @cashbox = Cashbox.all\n end", "def index\n @budgets = Budget.find_owned_by current_user\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @budgets }\n end\n end", "def destroy\n @moneybox.destroy\n respond_to do |format|\n format.html { redirect_to moneyboxes_url }\n format.json { head :no_content }\n end\n end", "def index\n @inboxes = Inbox.all\n @inboxes = @inboxes.select { |x| x.umkm_id == params[:umkm_id].to_i }\n render json: {items: @inboxes}\n end", "def index\n @bills = Bill.all_cached\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bills }\n end\n end", "def index\n @boxes = Box.all.order(created_at: :desc).page params[:page]\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 show\n @box = Box.find(params[:id])\n @user = @box.user\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @box }\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 index\n @referenceboxes = Referencebox.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @referenceboxes }\n end\n end", "def index\n @contracts = Contract.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contracts }\n end\n end", "def list_coins\n endpoint = \"#{HOST}/v1/cryptocurrency/map\"\n get(endpoint)\n end", "def show\n @mint_coin = @coin.mint_coins.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @mint_coin }\n end\n end", "def getbalance(args={})\n {\n :method=> \"GetBalances\"\n }.to_json\n end", "def show\n @climb = Climb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @climb }\n end\n end", "def show\n @box_score = BoxScore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @box_score }\n end\n end", "def index\n @boxscores = @game.boxscores\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boxscores }\n end\n end", "def index\n @boxes = Box.by_filter(params.slice(:gender, :size)).active.page(params[:page]).per(12)\n @charity = Charity.where(:status => \"active\").first\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boxes }\n end\n end", "def new\n @box = Box.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @box }\n end\n end", "def show\n @boxscore = @game.boxscores.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @boxscore }\n end\n end", "def create\n @account = Account.new\n # data = params[:moneybox]\n @account.name = params[:name]\n\n respond_to do |format|\n if @moneybox.save\n format.html { redirect_to @moneybox, notice: 'Moneybox was successfully created.' }\n format.json { render action: 'show', status: :created, location: @moneybox }\n else\n format.html { render action: 'new' }\n format.json { render json: @moneybox.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @money = Money.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @money }\n end\n end", "def show\n @referencebox = Referencebox.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @referencebox }\n end\n end", "def index\n @orders = Order.all.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 10)\n @cart = current_cart\n @user = current_user\n params[:box_id] = @box_id\n @order = Order.new(box_id: params[:box_id])\n lastBox = Box.last.id\n @box = Box.find(params = lastBox)\n end", "def show\n @stats_money_transaction = Stats::MoneyTransaction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @stats_money_transaction }\n end\n end", "def new\n @box = Box.new\n @box.items.build\n\n respond_to do |format|\n format.html # new.html.haml\n format.json { render json: @box }\n end\n end", "def index\n @bitcoins = Bitcoin.all\n end", "def index\n @cryptocurrencies = Cryptocurrency.all\n\n require 'net/http'\n require 'json'\n\n @url = 'https://api.coinmarketcap.com/v1/ticker/'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_crypto = JSON.parse(@response)\n\n @profit_loss = 0\n end", "def show\n @inbox = Inbox.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @inbox }\n end\n end", "def show\n @bet = Bet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bet }\n end\n end", "def index\n @bills = @dwelling.bills\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bills }\n end\n end", "def index\n @baskets = Basket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @baskets }\n end\n end", "def update\n respond_to do |format|\n if @moneybox.update(moneybox_params)\n format.html { redirect_to @moneybox, notice: 'Moneybox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @moneybox.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @money_receipt = MoneyReceipt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @money_receipt }\n end\n end", "def show\n @contract = Contract.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contract }\n end\n end", "def index\n # TODO: implement filters\n @budgets = Budget.order(\"budgets.starts_at DESC, budgets.number ASC\")\n .page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n #format.select2 { render json: { items: budgets.map(&:to_select2_json), total: @budgets.count} }\n #format.json { render json: @budgets }\n end\n end", "def contracts\n\t\t@user = User.find_by_username(params[:profile_id])\n\t\tif !@user.present?\n\t\t\tredirect_to root_path\n\t\tend\n\n\t\tcontracts = []\n\t\tif current_admin.present? || (current_user.meets_contract_preferences?(@user) && !@user.is_blocking_user?(current_user))\n\t\t\t(@user.posted_contracts.where(status: \"Open\") + @user.posted_bounties.where(status: \"Open\")).each do | c |\n\t\t\t\tcontracts << {\n\t\t\t\t\t:id => c.id,\n\t\t\t\t\t:start=> c.start_date_time,\n\t\t\t\t\t:end=> c.end_date_time,\n\t\t\t\t\t:title=> \"$#{c.price_in_dollars}\",\n\t\t\t\t\t:type => c.contract_type\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\t\trender :json => contracts\n\tend", "def index\n @mint_coins = @coin.mint_coins\n\n @mint_coins_by_grouping = group_mint_coins(@mint_coins)\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @mint_coins }\n end\n end", "def index\n get_contracts\n end", "def balance\n rest.get(:getbalance)['data']\n end", "def index\n get_budgets\n end", "def coins\n\t\tres = {}\n\t\tuser = User.find_by_token(params[:token])\n\t\tif user\n\t\t\tres[:status] = \"0\"\n\t\t\tres[:coins] = user.coins\n\t\telse\n\t\t\tres[:status] = \"1\"\n\t\tend\n\t\trender json: res\n\tend", "def cashbox\n return @cashbox if @cashbox.present?\n return nil unless has_money_program?\n @cashbox = self.accounts.where(:program_id => money_program.id, :is_money => true).first\n end", "def show\n @bill = Bill.find(params[:id])\n\n render json: @bill\n end", "def show\n @user_box_record = UserBoxRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_box_record }\n end\n end", "def bills(options = {})\n get('/bills', options)\n end", "def show\n @budget = Budget.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n # format.json { render json: @budget }\n end\n end", "def balances(id)\n get(\"/accounts/#{id}/balances\")\n end", "def index\n render json: Bill.all\n end", "def cashbox_params\n params[:cashbox]\n end", "def cashbox_params\n params[:cashbox]\n end", "def index\n @cryptostables = Cryptostable.all\n\n require 'uri'\n require 'net/http'\n require 'openssl'\n\n @url = \"https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?CMC_PRO_API_KEY=#{ENV.fetch('CRYPTO')}&start=1&limit=500\"\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @lookup_cryptos = JSON.parse(@response)\n @profit_loss = 0\n end", "def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend", "def index\n render json: @user.contracts, each_serializer: ContractSerializer\n end", "def index\n @cryptocurrencies = Cryptocurrency.all\n require 'net/http'\n require 'json'\n @url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?start=1&limit=100&CMC_PRO_API_KEY=8e364003-38f2-410d-81af-9166deca3a6f'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @array1 = JSON.parse(@response).to_a\n @array2 = @array1[1].to_a\n @lookup_crypto = @array2[1].to_a\n @profit_loss = 0\n end", "def index\n @utilized_bitcoin_wallets = UtilizedBitcoinWallet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @utilized_bitcoin_wallets }\n end\n end", "def show\n @currency = Currency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @currency }\n end\n end", "def index\n @coins = Coin.all\n render \"index.json.jbuilder\"\n end", "def show\n @box = Box.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @box }\n end\n end", "def show\n @currencies = CryptocurrenciesService.new.get_top\n end", "def show\n coin = Coin.find(params[:id]) \n require 'net/http'\n url = url = \"https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=#{coin.coin_api_id}&order=market_cap_desc&per_page=100&page=1&sparkline=false&price_change_percentage=1h\"\n request = URI.parse(url)\n response = Net::HTTP.get_response(request)\n crypto_hash = JSON.parse(response.body)\n coin.image = crypto_hash[0]['image']\n coin.current_price = crypto_hash[0]['current_price']\n coin.price_change_percentage_1h_in_currency = crypto_hash[0]['price_change_percentage_1h_in_currency']\n coin.high_24h = crypto_hash[0]['high_24h']\n coin.low_24h = crypto_hash[0]['low_24h']\n coin.total_volume = crypto_hash[0]['total_volume']\n coin.market_cap = crypto_hash[0]['market_cap']\n coin.market_cap_rank = crypto_hash[0]['market_cap_rank']\n coin.circulating_supply = crypto_hash[0]['circulating_supply']\n\n # Serializer\n # render json: CoinSerializer.new(coin)\n render json: coin\n end", "def set_cashbox\n @cashbox = Cashbox.find(params[:id])\n end", "def set_cashbox\n @cashbox = Cashbox.find(params[:id])\n end", "def set_cashbox\n @cashbox = Cashbox.find(params[:id])\n end", "def show\n @time_balance = TimeBalance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @time_balance }\n end\n end", "def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end", "def show\n load_budget\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @budget }\n end\n end", "def index\n # @inboxes = current_account.try(:inboxes) || Inbox.all \n @account_inboxes = current_account.account_inboxes.page(params[:page]).per(6)\n end", "def show\n @bloom = Bloom.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bloom }\n end\n end", "def index\n @budgets = Budget.all\n end", "def get_box(id)\n return @boxes[id]\n end", "def index\n @page_count, @contracts = Locomotive::Contract.paginated(:page => (params[:page] || 1).to_i)\n display @contracts\n end", "def show\n @cryptocurrencies = Cryptocurrency.all\n require 'net/http'\n require 'json'\n @url = 'https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?start=1&limit=100&CMC_PRO_API_KEY=8e364003-38f2-410d-81af-9166deca3a6f'\n @uri = URI(@url)\n @response = Net::HTTP.get(@uri)\n @array1 = JSON.parse(@response).to_a\n @array2 = @array1[1].to_a\n @show_crypto = @array2[1].to_a\n end", "def index\n @petty_cash_expenses = PettyCashExpense.all\n render json: @petty_cash_expenses\n end", "def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend", "def budgets\n # https://developer.xero.com/documentation/api/budgets\n # if you are having issues in adding the accounting.budgets.read scope, get in touch => api@xero.com\n @budgets = xero_client.accounting_api.get_budgets(current_user.active_tenant_id).budgets\n @budget = xero_client.accounting_api.get_budget(current_user.active_tenant_id, @budgets.sample.budget_id).budgets\n end", "def index\n @bill_cargos = @bill.bill_cargos\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bill_cargos }\n end\n end", "def show\n @box_score_entry = BoxScoreEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @box_score_entry }\n end\n end", "def index\n @call_boxes = CallBox.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @call_boxes }\n end\n end", "def checkMoneyUser(id)\n results = HTTParty.get(\"http://192.168.99.101:4051/users/get_money?id=\" + id.to_s)\n return results\n end", "def index\n @deposit_types = DepositType.all\n @abs_deposit_types = JSON.parse(Redis.current.get(\"deposit_types\"))\n end", "def new\n @bill = Bill.new\n @user = User.find(session[:user_id])\n @enterprise = Enterprise.find(@user.enterprise_id)\n @contracts = Contract.find_by_enterprise_id(@enterprise.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bill }\n end\n end", "def show\n @mailbox = Mailbox.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mailbox }\n end\n end", "def index\n # this whole process is updating the users coins with the currnet price from the api. pulls the users coins and if a coin matches then update the price in usd. and return the coin.\n coins = HTTParty.get(BASE_URL) # this will bring back the top 100 coins in an array\n user_coins = current_user.coins\n user_coins.each do |coin|\n res_coin = coins.find { |c| c['id'] == coin.cmc_id }\n coin.update(price: res_coin['price_usd']) if res_coin \n end \n render json: current_user.coins # if we don't authenticate_user before then we cant user current_user. it is a built in devise function\n end", "def new\n @boxtype = Boxtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @boxtype }\n end\n end", "def index\n @holders = Holder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @holders }\n end\n end", "def load_tickets(page_number)\n begin\n conn = Faraday.new\n conn.basic_auth(@credentials[:username], @credentials[:password])\n response = conn.get(\"https://jackiesun2.zendesk.com/api/v2/tickets.json?page=#{page_number}\")\n raise StandardError if response.status.to_i >= 400 \n @zendesk_tickets = JSON.parse(response.body, symbolize_names: true)\n rescue \n puts \"This path is incorrect, please check again\"\n exit\n end \n end", "def show\n @player_box_score = PlayerBoxScore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @player_box_score }\n end\n end", "def index\n @bills = Bill.all\n \n respond_with @bills, represent_with: Billit::BillPageRepresenter\n end" ]
[ "0.736724", "0.6672739", "0.6480729", "0.64327234", "0.6415882", "0.64104277", "0.63878334", "0.6286464", "0.6254037", "0.6202156", "0.6179334", "0.61311936", "0.6058122", "0.60506576", "0.59938073", "0.59689903", "0.5932825", "0.589672", "0.5885079", "0.58766013", "0.5853696", "0.5852921", "0.5805717", "0.57348657", "0.5716654", "0.5706794", "0.56909454", "0.5674689", "0.56711715", "0.5661878", "0.56489253", "0.56436396", "0.5636732", "0.56341714", "0.5631073", "0.56295264", "0.5590579", "0.5585747", "0.5583649", "0.55832624", "0.55741304", "0.55661744", "0.5565589", "0.5558032", "0.55575705", "0.5546022", "0.5544436", "0.5527739", "0.5522562", "0.55065393", "0.5504866", "0.5499265", "0.5490268", "0.54898053", "0.54883915", "0.54852194", "0.5479376", "0.5476022", "0.5467832", "0.5466599", "0.5465627", "0.54547167", "0.54547167", "0.54536784", "0.5451398", "0.5449134", "0.5446806", "0.5444508", "0.5439633", "0.5438141", "0.5430859", "0.54283184", "0.5427786", "0.5424946", "0.5424946", "0.5424946", "0.54078686", "0.5401758", "0.53982735", "0.5389757", "0.5387234", "0.5384668", "0.5379831", "0.5373331", "0.5372471", "0.5369729", "0.5367082", "0.53481007", "0.5343972", "0.5341319", "0.5339646", "0.5335215", "0.53238", "0.53167987", "0.53167105", "0.53017294", "0.5296933", "0.5294696", "0.52904576", "0.5288529", "0.52837384" ]
0.0
-1
POST /moneyboxes POST /moneyboxes.json
def create @account = Account.new # data = params[:moneybox] @account.name = params[:name] respond_to do |format| if @moneybox.save format.html { redirect_to @moneybox, notice: 'Moneybox was successfully created.' } format.json { render action: 'show', status: :created, location: @moneybox } else format.html { render action: 'new' } format.json { render json: @moneybox.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @moneyboxes = Moneybox.all\n end", "def set_moneybox\n @moneybox = Moneybox.find(params[:id])\n end", "def create\n @box = current_user.boxes.build(params[:box])\n @box.status = 'draft'\n\n respond_to do |format|\n if current_user.address.blank?\n flash[:notice] = \"Please provide your address before posting a box\"\n format.html { redirect_to new_box_path }\n format.json { render :json => {:edit_url => new_box_path} }\n elsif @box.save\n format.html { redirect_to edit_box_path(@box), notice: 'Great, now please add pictures and item details below.' }\n format.json { render :json => {:box => @box, :url => box_path(@box), :edit_url => edit_box_path(@box)}, status: :created, location: @box }\n else\n format.html { render action: \"new\" }\n format.json { render :json => {:errors => @box.errors}, status: :unprocessable_entity }\n end\n end\n end", "def create\n @box = Box.new(box_params)\n\n respond_to do |format|\n if @box.save\n format.html { redirect_to @box, notice: 'Box was successfully created.' }\n format.json { render :show, status: :created, location: @box }\n else\n format.html { render :new }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @box = Box.new(params[:box])\n\n respond_to do |format|\n if @box.save\n format.html { redirect_to @box, notice: 'Box was successfully created.' }\n format.json { render json: @box, status: :created, location: @box }\n else\n format.html { render action: \"new\" }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cashbox = Cashbox.new(cashbox_params)\n\n respond_to do |format|\n if @cashbox.save\n format.html { redirect_to @cashbox, notice: 'Cashbox was successfully created.' }\n format.json { render :show, status: :created, location: @cashbox }\n else\n format.html { render :new }\n format.json { render json: @cashbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cashbox = Cashbox.new(cashbox_params)\n\n respond_to do |format|\n if @cashbox.save\n format.html { redirect_to @cashbox, notice: 'Cashbox was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cashbox }\n else\n format.html { render action: 'new' }\n format.json { render json: @cashbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @moneybox.destroy\n respond_to do |format|\n format.html { redirect_to moneyboxes_url }\n format.json { head :no_content }\n end\n end", "def create\n if !owner_of_box?\n forbidden('You can not revert the box.')\n elsif @box.revert\n render json: @box, status: :created\n else\n bad_request\n end\n end", "def box_params\n params.require(:box).permit(:name, :description, :position, :closed, :price, :status, :favorite, :tags, :manual_variation, \n # Providers\n :meli_order_id,\n # Assosiations\n :account_id, :customer_id, :dashboard_id, :user_id)\n end", "def create\n @boxtype = Boxtype.new(params[:boxtype])\n\n respond_to do |format|\n if @boxtype.save\n format.html { redirect_to @boxtype, notice: 'Boxtype was successfully created.' }\n format.json { render json: @boxtype, status: :created, location: @boxtype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @boxtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend", "def create\n @money = Money.new(money_params)\n\n respond_to do |format|\n if @money.save\n format.html { redirect_to @money, notice: 'Money was successfully created.' }\n format.json { render :show, status: :created, location: @money }\n else\n format.html { render :new }\n format.json { render json: @money.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_aos_version_box(args = {}) \n post(\"/aosversions.json/aosversionbox\", args)\nend", "def create\n @box = Box.new(box_params)\n @box.user = current_user\n\n respond_to do |format|\n if @box.save\n format.html { redirect_to @box, notice: I18n.t('box.created') }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @article_box = ArticleBox.new(article_box_params)\n\n respond_to do |format|\n if @article_box.save\n format.html { redirect_to @article_box, notice: 'Article box was successfully created.' }\n format.json { render :show, status: :created, location: @article_box }\n else\n format.html { render :new }\n format.json { render json: @article_box.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @box = Box.new\n @box.items.build\n\n respond_to do |format|\n format.html # new.html.haml\n format.json { render json: @box }\n end\n end", "def dropbox_post(url, headers: {}, payload: nil)\n raise ArgumentError, \"missing keyword: payload\" unless payload\n\n require \"net/https\"\n require \"uri\"\n\n headers = {\n \"Authorization\" => \"Bearer #{config[\"token\"]}\",\n \"Content-Type\" => \"application/json\"\n }.merge(headers)\n\n unless payload.nil? || payload.is_a?(String)\n payload = JSON.generate(payload)\n end\n\n uri = URI.parse(url)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == \"https\"\n\n http.post(uri.path, payload, headers).tap do |response|\n log { \"POST #{url}\" }\n\n unless payload.nil? || payload.is_a?(String)\n log { \" PAYLOAD --> #{payload}\" }\n end\n\n log { \" RESPONSE --> #{response.body}\" }\n\n return yield response\n end\n end", "def create\n @box = Box.new(params[:box])\n @box.user = current_user\n \n\n respond_to do |format|\n if @box.save\n format.html { redirect_to(@box, :notice => 'Box was successfully created.') }\n format.xml { render :xml => @box, :status => :created, :location => @box }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @box.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_money!(json)\n put_inside!(money_from_json(json))\n end", "def create\n @box_request_abuse_type = BoxRequestAbuseType.new(box_request_abuse_type_params)\n\n respond_to do |format|\n if @box_request_abuse_type.save\n format.html { redirect_to @box_request_abuse_type, notice: 'Box request abuse type was successfully created.' }\n format.json { render :show, status: :created, location: @box_request_abuse_type }\n else\n format.html { render :new }\n format.json { render json: @box_request_abuse_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @box = Box.new(box_params)\n if @box.save\n redirect_to @box, notice: \"Box was successfully created.\"\n else\n render :new\n end\n end", "def create\n budget = Budget.find(contract_params[:budget_id])\n @contract = Contract.new_by_budget(contract_params, budget)\n respond_to do |format|\n if @contract.save\n contract = Contract.find(@contract.id)\n budget.update(state: Budget.states[:approved], contract: @contract)\n format.html { redirect_to contract, notice: 'El contrato se creó correctamente.' }\n format.json { render :show, status: :created, location: @contract }\n else\n format.html { render :new }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def cashbox_params\n params[:cashbox]\n end", "def cashbox_params\n params[:cashbox]\n end", "def cashbox_params\n params.try(:[], :data).require(:attributes).permit(:name)\n end", "def create\n @money = current_user.money.build(params[:money])\n # @money = Money.new(params[:money])\n\n respond_to do |format|\n if @money.save\n format.html { redirect_to @money, notice: 'Money was successfully created.' }\n format.json { render json: @money, status: :created, location: @money }\n else\n format.html { render action: \"new\" }\n format.json { render json: @money.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @quote_box = QuoteBox.new(params[:quote_box])\r\n\r\n respond_to do |format|\r\n if @quote_box.save\r\n format.html { redirect_to @quote_box, notice: 'Quote box was successfully created.' }\r\n format.json { render json: @quote_box, status: :created, location: @quote_box }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @quote_box.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def account_params\n params.require(:account).permit(:name, :value, moneybox_attributes: [:summary, :percentage])\n end", "def box_params\n params.require(:box).permit(:name, :description)\n end", "def commit_safebox(safebox_params)\n handle_error { sendsecure_connection.post(\"/api/v2/safeboxes.json\", safebox_params) }\n end", "def post_boxes\n Easybill::Api::PostBoxes\n end", "def cash_collection_params\n params.require(:cash_collection).permit(:office_id, :amount, :tenant_id)\n end", "def create\n @box_score = BoxScore.new(params[:box_score])\n\n respond_to do |format|\n if @box_score.save\n format.html { redirect_to @box_score, notice: 'Box score was successfully created.' }\n format.json { render json: @box_score, status: :created, location: @box_score }\n else\n format.html { render action: \"new\" }\n format.json { render json: @box_score.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n\t\t@box = Box.new(box_params)\r\n\t\tif @box.valid? && @box.photo?\r\n\t\t\tclient = kaltura_setup\r\n\t\t\tentry_id = kaltura_upload(box_params[:barcode], box_params[:photo], client)\r\n\r\n\t\t\t@box.photo = entry_id\r\n\t\tend\r\n\r\n\t\trespond_to do |format|\r\n\t\t\tif @box.save\r\n\t\t\t\tformat.html { redirect_to @box, notice: 'Box was successfully created.' }\r\n\t\t\t\tformat.json { render :show, status: :created, location: @box }\r\n\t\t\telse\r\n\t\t\t\tif @box.photo != nil\r\n\t\t\t\t\t@box.photo = nil\r\n\t\t\t\t\t@box.errors[:photo] = \"Please select the image again\"\r\n\t\t\t\tend\r\n\t\t\t\tformat.html { render :new }\r\n\t\t\t\tformat.json { render json: @box.errors, status: :unprocessable_entity }\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def create\n @cardbox = current_user.cardboxes.new(params[:cardbox])\n\n respond_to do |format|\n if @cardbox.save\n format.html { redirect_to(@cardbox, :notice => _('Der Karteikasten wurde angelegt.')) }\n format.xml { render :xml => @cardbox, :status => :created, :location => @cardbox }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cardbox.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @boxscore = @game.boxscores.build(params[:boxscore])\n\n respond_to do |format|\n if @boxscore.save\n format.html { redirect_to game_boxscores_path(@game_id), notice: 'Boxscore was successfully created.' }\n format.json { render json: @boxscore, status: :created, location: @boxscore }\n else\n format.html { render action: \"new\" }\n format.json { render json: @boxscore.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @moneybox.update(moneybox_params)\n format.html { redirect_to @moneybox, notice: 'Moneybox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @moneybox.errors, status: :unprocessable_entity }\n end\n end\n end", "def recount_money\n @team = Team.find(params[:id])\n @money = get_money_array(@team, params[:amount].to_f, params[:fromDate], params[:toDate])\n \n respond_to do |format|\n format.json {\n render json: @money\n }\n end\n end", "def new\n @box = Box.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @box }\n end\n end", "def buyTickets\n nt1 = Integer(params[:nt1])\n nt2 = Integer(params[:nt2])\n nt3 = Integer(params[:nt3])\n\n # Checks if the user deserves a free ticket\n promo = (nt1 + nt2 + nt3) >= 10? 1 : 0;\n\n ActiveRecord::Base.transaction do\n # type 1 tickets with promotion\n (nt1 + promo).times do\n Ticket.create(\n ticket_type: 1,\n uuid: SecureRandom.uuid,\n user_id: params[:id])\n end\n\n #type 2 tickets\n nt2.times do\n Ticket.create(\n ticket_type: 2,\n uuid: SecureRandom.uuid,\n user_id: params[:id])\n end\n\n #type 3 tickets\n nt3.times do\n Ticket.create(\n ticket_type: 3,\n uuid: SecureRandom.uuid,\n user_id: params[:id])\n end\n end\n\n render json: {\n :status => 0,\n :msg => :ok}\n end", "def create\n @box = Box.new(box_params)\n #If there any boxes at that location already, update them instaed of making a new one\n if Box.where(x: @box.x, y: @box.y).count > 0\n if @box.color == 0\n #To make a white box, just delete the box that's there\n Box.where(x: @box.x, y: @box.y).delete_all\n else\n #Otherwise, switch existing box to new box's color\n Box.where(x: @box.x, y: @box.y).first.update(color: @box.color)\n end\n respond_to do |format|\n format.html { redirect_to @box, notice: 'Box was successfully updated.' }\n format.json { render json: @box.color }\n end\n else\n #If there's no box, save the new box\n respond_to do |format|\n if @box.save\n format.html { redirect_to @box, notice: 'Box was successfully created.' }\n format.json { render json: @box.color }\n else\n format.html { render :new }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create_vault(**args)\n request_post('/vault', **args)\n end", "def create\n @call_box = CallBox.new(params[:call_box])\n\n respond_to do |format|\n if @call_box.save\n format.html { redirect_to([@layer, @call_box], :notice => 'Call box was successfully created.') }\n format.xml { render :xml => @call_box, :status => :created, :location => @call_box }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @call_box.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @tipmoney = Tipmoney.new(tipmoney_params)\n\n respond_to do |format|\n if @tipmoney.save\n format.html { redirect_to @tipmoney, notice: 'Tipmoney was successfully created.' }\n format.json { render :show, status: :created, location: @tipmoney }\n else\n format.html { render :new }\n format.json { render json: @tipmoney.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contract = Contract.new(contract_params)\n @contract.daily_premium_prices.push(params[:daily_premium_prices])\n\n respond_to do |format|\n if @contract.save\n # format.html { redirect_to @contract, notice: 'Contract was successfully created.' }\n format.json { render :show, status: :created, location: @contract }\n else\n format.html { render :new }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @promotion_box = PromotionBox.new(params[:promotion_box])\n\n respond_to do |format|\n if @promotion_box.save\n flash[:notice] = 'PromotionBox was successfully created.'\n format.html { redirect_to admin_promotion_boxes_path }\n format.xml { render :xml => @promotion_box, :status => :created, :location => @promotion_box }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @promotion_box.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n redirect_to new_bet_path and return if params[:bet][:amount].blank? #if nothing is entered, try again\n\n @line = Line.find(session[:line_id])\n redirect_to lines_path and return if @line.event.started?\n\n @bet = Bet.new(:line_id => session[:line_id], :portfolio_id => session[:portfolio_id], :amount => params[:bet][:amount])\n\n respond_to do |format|\n if @bet.save\n #deduct -> working here\n @portfolio = Portfolio.find(session[:portfolio_id])\n @current_balance = @portfolio.cash\n @portfolio.update_attributes(:cash => @current_balance - params[:bet][:amount].to_i)\n \n format.html { redirect_to @bet, notice: 'Bet was successfully created.' }\n format.json { render json: @bet, status: :created, location: @bet }\n else\n# format.html { render action: \"new\" } #my deletion\n format.html { render \"new\" }\n format.json { render json: @bet.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @box_content = BoxContent.new(box_content_params)\n\n respond_to do |format|\n if @box_content.save\n format.html { redirect_to @box_content, notice: 'Box content was successfully created.' }\n format.json { render :show, status: :created, location: @box_content }\n else\n format.html { render :new }\n format.json { render json: @box_content.errors, status: :unprocessable_entity }\n end\n end\n end", "def buy_params\n params.require(:buy).permit(:user_id, :box_id)\n end", "def new\n @money = Money.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @money }\n end\n end", "def createItemOfList\n results1 = checkUser(params[:target_account]) #userid user to give the money\n if results1.code == 200\n parameters={user_id: (@current_user[\"id\"]).to_i, description: (params[:description]), date_pay: params[:date_pay], cost: params[:cost], target_account: params[:target_account], state_pay:params[:state_pay]}\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n results = HTTParty.post(\"http://192.168.99.101:4055/lists\", options)\n if results.code == 201\n head 201\n else\n render json: results.parsed_response, status: results.code\n end\n elsif results1.code == 404\n renderError(\"Not Found\", 404, \"The resource does not exist\")\n end\n end", "def postContractProvision( contract_id)\n params = Hash.new\n params['contract_id'] = contract_id\n return doCurl(\"post\",\"/contract/provision\",params)\n end", "def create\n @box_score_entry = BoxScoreEntry.new(params[:box_score_entry])\n\n respond_to do |format|\n if @box_score_entry.save\n format.html { redirect_to @box_score_entry, :notice => 'Box score entry was successfully created.' }\n format.json { render :json => @box_score_entry, :status => :created, :location => @box_score_entry }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @box_score_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def balance_post(addrs, opts = {})\n data, _status_code, _headers = balance_post_with_http_info(addrs, opts)\n data\n end", "def send_money(params)\n fail ArgumentError, 'Hash is expected as params' unless params.is_a?(Hash)\n fail ArgumentError, 'String is expected as :amount' unless params[:amount].is_a?(String)\n fail ArgumentError, 'String is expected as :address' unless params[:address].is_a?(String)\n fail ArgumentError, 'Invalid amount format' unless params[:amount] =~ /^\\d+\\.\\d+$/\n fail ArgumentError, 'Invalid address format' unless params[:address] =~ /^[A-Za-z0-9]+$/\n Cubits.connection.post(\n '/api/v1/send_money',\n amount: params[:amount], address: params[:address]\n )\n end", "def create\n @user = current_user\n @cart = current_cart\n @box = current_user.boxes.last.id\n @order = current_user.orders.build(order_params)\n \n @amount = 500\n \n\n respond_to do |format|\n if @order.save\n \n @user.incre(:user_calories, @order.total_calories)\n @user.incre(:user_proteins, @order.total_proteins)\n @user.incre(:user_carbs, @order.total_carbs)\n @user.incre(:user_water, @order.total_water)\n @user.incre(:user_land, @order.total_land)\n @user.incre(:user_carbon, @order.total_carbon)\n @user.incre(:user_lives, @order.total_lives)\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n format.js\n format.html { redirect_to @order, notice: 'Order was successfully placed. See what you saved.' }\n format.json { render :show, status: :created, location: @order }\n else\n @cart = current_cart\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tickets = []\n params[:quantity].to_i.times do\n @ticket = Ticket.new(params[:ticket])\n @ticket.viber = current_viber\n @tickets << @ticket\n end\n\n respond_to do |format|\n if @tickets.map(&:save)\n format.html { redirect_to @ticket, notice: 'Your ticket(s) are booked.' }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @box = Box.new(params[:box])\n\n catalog = current_user.catalogs.find(@box.catalog_id)\n if catalog.nil?\n raise 'Catalog does not exist'\n end\n\n respond_to do |format|\n if @box.save\n format.html { redirect_to catalog_path(@box.catalog), :notice => 'Box was successfully created.' }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def index\n @cashboxes = Cashbox.all\n end", "def create\n @stats_money_transaction = Stats::MoneyTransaction.new(params[:stats_money_transaction])\n\n respond_to do |format|\n if @stats_money_transaction.save\n format.html { redirect_to @stats_money_transaction, notice: 'Money transaction was successfully created.' }\n format.json { render json: @stats_money_transaction, status: :created, location: @stats_money_transaction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @stats_money_transaction.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_bill(params)\n build_header_auth('/bills', API_VERSION_1, 'POST')\n build_request()\n p_hash = {}\n p_hash[\"bill\"] = {\"identifier\" => params['id'],\n \"amount_cents\" => params['amount_cents'],\n \"bill_template_id\" => params['bill_template_id'],\n \"memo\" => params['memo'],\n \"content\" => params['content'],\n \"recurring\" => params['recurring'],\n \"customer_id\" => params['customer_id'],\n \"date\" => params['date']}\n req_body = p_hash.to_json.to_s\n request = Net::HTTP::Post.new(@uri.request_uri)\n @header.each do |name, value|\n request[name] = value\n end\n # request.each do |name, value|\n # puts name+\" : \"+value\n # end\n request.set_body_internal(req_body)\n response = @http.request(request)\n # response.body = JSON.parse(response.body)\n return response\n end", "def create_bepaid_bill\n # Don't touch real web services during of test database initialization\n return if Rails.env.test?\n\n user = self\n\n bp = BePaid::BePaid.new Setting['bePaid_baseURL'], Setting['bePaid_ID'], Setting['bePaid_secret']\n\n amount = user.monthly_payment_amount\n\n #amount is (amoint in BYN)*100\n bill = {\n request: {\n amount: (amount * 100).to_i,\n currency: 'BYN',\n description: 'Членский взнос',\n email: 'jekhor@gmail.com',\n notification_url: 'https://hackerspace.by/admin/erip_transactions/bepaid_notify',\n ip: '127.0.0.1',\n order_id: '4444',\n customer: {\n first_name: 'Cool',\n last_name: 'Hacker',\n },\n payment_method: {\n type: 'erip',\n account_number: 444,\n permanent: 'true',\n editable_amount: 'true',\n service_no: Setting['bePaid_serviceNo'],\n }\n }\n }\n req = bill[:request]\n req[:email] = user.email\n req[:order_id] = user.id\n req[:customer][:first_name] = user.first_name\n req[:customer][:last_name] = user.last_name\n req[:payment_method][:account_number] = user.id\n\n begin\n res = bp.post_bill bill\n logger.debug JSON.pretty_generate res\n rescue => e\n logger.error e.message\n logger.error e.http_body if e.respond_to? :http_body\n user.errors.add :base, \"Не удалось создать счёт в bePaid, проверьте лог\"\n end\n end", "def create\n megam_rest.post_accounts(to_hash)\n end", "def new\n @boxtype = Boxtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @boxtype }\n end\n end", "def test_create_transaction\n params = {\n bank_transaction: {\n bank_account_id: 1,\n date: Time.local(2012, 4, 16),\n amount: 55\n }\n }\n\n post '/api/banks/1/transactions', params\n data = ActiveSupport::JSON.decode last_response.body\n\n assert last_response.successful?\n assert_match('application/json', last_response.content_type)\n assert BankTransaction.find(data['id'])\n end", "def tombstone_timehold_params\n params.require(:tombstone_timehold).permit(:tombstoneJSON, :permanent, :rating)\n end", "def create\n @budget = Budget.new(params[:budget])\n\n respond_to do |format|\n if @budget.save\n format.html { redirect_to budgets_path }\n format.json { render json: @budget, status: :created, location: @budget }\n else\n format.html { render action: \"new\" }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @box_score_entry = BoxScoreEntry.new(box_score_entry_params)\n\n respond_to do |format|\n if @box_score_entry.save\n format.html { redirect_to @box_score_entry, notice: 'Box score entry was successfully created.' }\n format.json { render action: 'show', status: :created, location: @box_score_entry }\n else\n format.html { render action: 'new' }\n format.json { render json: @box_score_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def postContractCreate( entity_id, user_id, payment_provider, basket, billing_period, source, channel, campaign, referrer_domain, referrer_name, flatpack_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['user_id'] = user_id\n params['payment_provider'] = payment_provider\n params['basket'] = basket\n params['billing_period'] = billing_period\n params['source'] = source\n params['channel'] = channel\n params['campaign'] = campaign\n params['referrer_domain'] = referrer_domain\n params['referrer_name'] = referrer_name\n params['flatpack_id'] = flatpack_id\n return doCurl(\"post\",\"/contract/create\",params)\n end", "def create\n @bill = Bill.new(params[:bill])\n @user = User.find(session[:user_id])\n @enterprise = Enterprise.find(@user.enterprise_id)\n @contracts = Contract.find_by_enterprise_id(@enterprise.id)\n\n respond_to do |format|\n if @bill.save\n # Update all energy goals related to this bill\n updateEnergyGoals(@bill)\n format.html { redirect_to @contracts, notice: 'Bill was successfully created.' }\n format.json { render json: @bill, status: :created, location: @bill }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n budgets = update_budgets(params[:budgets])\n\n render json: budgets, status: :ok\n end", "def create\n @trust_money = TrustMoney.new(trust_money_params)\n\n respond_to do |format|\n if @trust_money.save\n format.html { redirect_to @trust_money, notice: 'Trust money was successfully created.' }\n format.json { render :show, status: :created, location: @trust_money }\n else\n format.html { render :new }\n format.json { render json: @trust_money.errors, status: :unprocessable_entity }\n end\n end\n end", "def box_params\n params.require(:box).permit(:name, :parent_id, :depth, :attachment)\n end", "def create\n @budget = Budget.new(params[:budget])\n\n respond_to do |format|\n if @budget.save\n format.html { redirect_to @budget, notice: 'Budget was successfully created.' }\n format.json { render json: @budget, status: :created, budget: @budget }\n else\n format.html { render action: \"new\" }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def settle\n \n\n if params[\"code\"]\n auth_code = params[\"code\"]\n end \n url = \"https://api.venmo.com/v1/oauth/access_token\"\n @response = HTTParty.post(url, :query => {:client_id => '1916', :client_secret => 'eGcyNHaysfbFGZ6xkMffUw3gGrKFzksG', :code => auth_code})\n user = @response[\"user\"]\n @access_token = @response[\"access_token\"]\n @refresh_token = @response[\"refresh_token\"]\n @email = params[:email]\n @amount = params[:amount]\n \n url = \"https://api.venmo.com/v1/payments\"\n @amount = HTTParty.post(url, :query => { \"access_token\" => @access_token, :email => @email, :amount => @amount, :note => 'PayUp'})\n redirect_to bets_path\n end", "def create\n @transfer = Transfer.new(transfer_params)\n respond_to do |format|\n if !params[:transfer][:items].nil?\n total = 0\n params[:transfer][:items].each do |f| \n item = Item.where([\"id = #{f}\"]).first\n total += item.amount\n end\n account = Account.where([\"id = #{@transfer.account_id}\"]).first\n new_total = account.amount - total\n if new_total > 0 \n if @transfer.save\n account.update(amount: new_total)\n params[:transfer][:items].each do |f| \n Item.where([\"id = #{f}\"]).first.update(transfer_id: @transfer.id)\n end\n \n format.html { redirect_to accounts_path, notice: \"Transfer was successfully created.\" }\n format.json { render :show, status: :created, location: @transfer }\n end\n else\n format.html { redirect_to budgets_url, notice: \"The account hasn't got enough money\"}\n format.json { render json: @transfer.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\n @films_box = FilmsBox.new(params[:films_box])\n\n respond_to do |format|\n if @films_box.save\n format.html { redirect_to @films_box, notice: 'Films box was successfully created.' }\n format.json { render json: @films_box, status: :created, location: @films_box }\n else\n format.html { render action: \"new\" }\n format.json { render json: @films_box.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_box_record = UserBoxRecord.new(params[:user_box_record])\n @user_box_record.machine_id = Box.find(params[:user_box_record][:box_id]).machine_id\n \n respond_to do |format|\n if @user_box_record.save\n @user_box_record.update_current_box_record\n\n format.html { redirect_to @user_box_record, notice: '進出記錄建立成功.' }\n format.json { render json: @user_box_record, status: :created, location: @user_box_record }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_box_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project = Project.find(params[:project_id])\n @bidder_amount = @project.bidder_amounts.create(bidder_amount_params)\n\n respond_to do |format|\n if @bidder_amount.save\n format.html { redirect_to @project, notice: 'Bidder amount was successfully created.' }\n format.json { render :show, status: :created, location: @bidder_amount }\n else\n format.html { render :new }\n format.json { render json: @bidder_amount.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @tombstone_timehold = TombstoneTimehold.new(tombstone_timehold_params)\n\n respond_to do |format|\n if @tombstone_timehold.save\n format.html { redirect_to @tombstone_timehold, notice: 'Tombstone timehold was successfully created.' }\n format.json { render :show, status: :created, location: @tombstone_timehold }\n else\n format.html { render :new }\n format.json { render json: @tombstone_timehold.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bill = Bill.new(params[:bill])\n #@bill = Bill.new(params[:id])\n # @bill.items.build\n #3.times { @bill.items.build }\n #@bill.items.build\n @bill.created_at = Time.now \n\n respond_to do |format|\n if @bill.save\n format.html { redirect_to new_bill_path, notice: 'Bill was successfully created.' }\n #format.json { render json: '/bills/new', status: :created, location: @bill }\n #format.html #index.html.erb\n #format.json { render json: @bill }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @bill = current_user_or_guest.bills.new(bill_params)\n\n respond_to do |format|\n if @bill.save\n format.html { redirect_to(@bill, notice: t('bill.created')) }\n format.xml { render xml: @bill, status: :created, location: @bill }\n format.xml { render json: @bill, status: :created, location: @bill }\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @bill.errors, status: :unprocessable_entity }\n format.xml { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def box_params\n params.require(:box).permit(:grade, :reading_level, :description, :contents)\n end", "def post_checkouts(checkouts)\n _post(\"checkouts\", \"checkouts\" => checkouts)\n end", "def submit_order()\n\tputs \"Submitting order\"\n\tdata = create_order()\n\tresponse = request_post(\"/api/order\", data)\n\tputs response.body\nend", "def create\n @bill = Bill.new(bill_params)\n\n if @bill.save\n render json: @bill, status: :created, location: @bill\n else\n render json: @bill.errors, status: :unprocessable_entity\n end\n end", "def new\n @money_transaction = MoneyTransaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @money_transaction }\n end\n end", "def add(params)\n headers = {\n 'Cookie' => @context[:koha_rest_api_cookie],\n 'Content-Type' => 'application/json'\n }\n\n http = Net::HTTP.new(\"xkoha\", 8081)\n uri = URI(intranet(:koha_rest_api) + \"holds\")\n res = http.post(uri, params.to_json, headers)\n expect(res.code).to eq(\"201\"), \"got unexpected #{res.code} when adding hold.\\nResponse body: #{res.body}\"\n res.body\n end", "def create\n @payout = Payout.new(price: current_user.credit, user_id: current_user.id)\n ti_ids = TaskInstance.where('status = ? AND user_id = ?', :finished, current_user.id).select(:id)\n ti_ids.each do |ti|\n ti.update(status: :paid)\n end\n @payout.task_instances = ti_ids\n\n respond_to do |format|\n if @payout.save\n current_user.update(credit: 0)\n format.html { redirect_to @payout, notice: 'Payout was successfully created.' }\n format.json { render action: 'show', status: :created, location: @payout }\n else\n format.html { render action: 'new' }\n format.json { render json: @payout.errors, status: :unprocessable_entity }\n end\n end\n end", "def money_params\n params.require(:money).permit(:symbol, :user_id, :cost_per, :amount_owned)\n end", "def create\n @cash_collection = CashCollection.new(cash_collection_params)\n\n respond_to do |format|\n if @cash_collection.save\n format.html { redirect_to @cash_collection, notice: 'Cash collection was successfully created.' }\n format.json { render :show, status: :created, location: @cash_collection }\n else\n format.html { render :new }\n format.json { render json: @cash_collection.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @game = Game.find(params[:game_id])\n @boxscore = @game.boxscores.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @boxscore }\n end\n end", "def create\n @bill = Bill.new(bill_params)\n @bill.user_id = current_user.id\n @user = current_user\n @accounts = Account.where(user_id: current_user.id)\n @bill.amount = @bill.amount_string.to_f\n\n respond_to do |format|\n if @bill.save\n format.html { redirect_to account_path(@bill.account_id), notice: 'Bill was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bill }\n else\n format.html { render action: 'new' }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def box_params\n params.fetch(:box, {}).permit(:name, :room)\n end", "def create\n @bill_quorum = BillQuorum.new(params[:bill_quorum])\n\n respond_to do |format|\n if @bill_quorum.save\n format.html { redirect_to @bill_quorum, notice: 'Bill Quorum was successfully created.' }\n format.json { render json: @bill_quorum, status: :created, location: @bill_quorum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bill_quorum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @budget = Budget.new(budget_params)\n respond_to do |format|\n if @budget.save\n \n if !params[:budget][:items].nil?\n params[:budget][:items].each do |f| \n Item.where([\"id = #{f}\"]).first.update(budget_id: @budget.id)\n end\n end\n \n format.html { redirect_to budgets_path, notice: \"Budget was successfully created.\" }\n format.json { render :show, status: :created, location: @budget }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @contract = Contract.new(params[:contract])\n\n @valid = @contract.valid?\n @privat_spaces = []\n\n privat_json = params[:privat_spaces]\n privat_json.each do |privat_space|\n ps = PrivatSpace.new(privat_space)\n next if ps.empty?\n @valid = false unless ps.valid?\n @privat_spaces << ps\n end\n if @privat_spaces.empty?\n ps = PrivatSpace.new(privat_json.first)\n @valid = false unless ps.valid?\n @privat_spaces << ps\n end\n if @valid\n tour_price = @contract.tour_price\n tour_price = 12345.678 if tour_price == 'NaN'\n @price = tour_price\n @sign = Utils.generate_sign(@price)\n PrivatSpacesMailer.send_manager_privat_spaces(@contract, @privat_spaces).deliver\n end\n session[:contract] = @contract\n session[:privat_spaces] = @privat_spaces\n end", "def index\n @boxes = Box.order(:start_time).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @boxes }\n end\n end", "def assign_tenant_circles_to_an_aos_version_box(args = {}) \n body_put(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args[:array_of_ids])\nend" ]
[ "0.62224865", "0.6189699", "0.6116553", "0.6081428", "0.60730594", "0.6062627", "0.59471655", "0.5901364", "0.58348054", "0.580331", "0.5766668", "0.5752638", "0.5741719", "0.57053983", "0.5652516", "0.5641717", "0.5632716", "0.559753", "0.5586972", "0.55226356", "0.5512933", "0.54985934", "0.5440959", "0.54224175", "0.54224175", "0.5420376", "0.5415969", "0.5405972", "0.5401147", "0.53843915", "0.53582424", "0.53369164", "0.53284675", "0.53179747", "0.52969337", "0.527209", "0.5267921", "0.5266426", "0.5240395", "0.5239396", "0.5224917", "0.5214305", "0.52127695", "0.52014786", "0.51943374", "0.517499", "0.517239", "0.5164555", "0.5163997", "0.51626474", "0.5158367", "0.5150246", "0.5149928", "0.51431835", "0.5128846", "0.51217467", "0.5117301", "0.5114756", "0.51114595", "0.5108856", "0.510572", "0.5098302", "0.50980604", "0.5098013", "0.5090061", "0.5074135", "0.50665003", "0.5052436", "0.50501794", "0.5047523", "0.50455415", "0.5038307", "0.50299364", "0.5013229", "0.50129056", "0.50097185", "0.50063205", "0.50051194", "0.49968663", "0.4993571", "0.4990047", "0.49890286", "0.49819726", "0.49811208", "0.49712387", "0.49673578", "0.49661598", "0.49618503", "0.49605894", "0.49574372", "0.4956992", "0.49548805", "0.49535528", "0.49507305", "0.4947168", "0.4935888", "0.49337825", "0.49299797", "0.49282238", "0.49277723" ]
0.65258867
0
PATCH/PUT /moneyboxes/1 PATCH/PUT /moneyboxes/1.json
def update respond_to do |format| if @moneybox.update(moneybox_params) format.html { redirect_to @moneybox, notice: 'Moneybox was successfully updated.' } format.json { head :no_content } else format.html { render action: 'edit' } format.json { render json: @moneybox.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @box = Box.find(params[:id])\n\n respond_to do |format|\n if @box.update_attributes(params[:box])\n format.html { redirect_to @box, notice: 'Box was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @box = Box.find(params[:id])\n authorize! :edit, @box\n\n respond_to do |format|\n @box.update_attributes(params[:box])\n @box.status = 'active'\n if @box.save\n format.html { redirect_to @box, notice: 'Box was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @box.update(box_params)\n format.html { redirect_to @box, notice: 'Box was successfully updated.' }\n format.json { render :show, status: :ok, location: @box }\n else\n format.html { render :edit }\n format.json { render json: @box.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cashbox.update(cashbox_params)\n format.html { redirect_to @cashbox, notice: 'Cashbox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cashbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cashbox.update(cashbox_params)\n format.html { redirect_to @cashbox, notice: 'Cashbox was successfully updated.' }\n format.json { render :show, status: :ok, location: @cashbox }\n else\n format.html { render :edit }\n format.json { render json: @cashbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @box = Box.find(params[:id])\n\n respond_to do |format|\n if @box.update_attributes(params[:box])\n #format.html { redirect_to(@box, :notice => 'Box was successfully updated.') }\n format.html {redirect_to my_boxes_path}\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @box.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @box = Box.find(params[:id])\n \n respond_to do |format|\n if @box.update_attributes(params[:box])\n format.html { redirect_to(@box.project, :notice => 'Module was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @box.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @call_box = CallBox.find(params[:id])\n\n respond_to do |format|\n if @call_box.update_attributes(params[:call_box])\n format.html { redirect_to([@layer, @call_box], :notice => 'Call Box was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @call_box.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 @money = Money.find(params[:id])\n\n respond_to do |format|\n if @money.update_attributes(params[:money])\n format.html { redirect_to @money, notice: 'Money was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @money.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @box = current_user.boxes.find(params[:id])\n\n respond_to do |format|\n if @box.update_attributes(params[:box])\n format.html { redirect_to catalog_path(@box.catalog), :notice => 'Box was successfully updated.' }\n else\n format.html { render :action => \"edit\" }\n end\n end\n end", "def set_moneybox\n @moneybox = Moneybox.find(params[:id])\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n respond_to do |format|\n if @box.update(box_params)\n format.html { redirect_to @box, notice: I18n.t('box.updated') }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n contract = Contract.find_by_id(params[:id])\n (head :unauthorized unless contract) and return\n \n # try to update the attributes\n if contract.update_attributes(edit_contract_params)\n render json: contract\n else\n render json: { errors: contract.error.full_messages}\n end\n end", "def update\n budgets = update_budgets(params[:budgets])\n\n render json: budgets, status: :ok\n end", "def update\n respond_to do |format|\n if @money.update(money_params)\n format.html { redirect_to @money, notice: 'Money was successfully updated.' }\n format.json { render :show, status: :ok, location: @money }\n else\n format.html { render :edit }\n format.json { render json: @money.errors, status: :unprocessable_entity }\n end\n end\n end", "def updateMoney(money, id)\n parameters={money: money}\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/update_money?id=\" + id.to_s , options)\n return results\n end", "def update\n @boxscore = @game.boxscores.find(params[:id])\n \n\n respond_to do |format|\n if @boxscore.update_attributes(params[:boxscore])\n format.html { redirect_to game_boxscores_url(@game), notice: 'Boxscore was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @boxscore.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @box_score = BoxScore.find(params[:id])\n\n respond_to do |format|\n if @box_score.update_attributes(params[:box_score])\n format.html { redirect_to @box_score, notice: 'Box score was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @box_score.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bet = Bet.find(params[:id])\n @line = @bet.line\n redirect_to lines_path and return if @line.event.started?\n current_bet_size = @bet.amount\n @portfolio = @bet.portfolio\n current_balance = @portfolio.cash\n\n respond_to do |format|\n if @bet.update_attributes(params[:bet])\n @portfolio.update_attributes(:cash => current_balance + current_bet_size - params[:bet][:amount].to_i)\n\n format.html { redirect_to @bet, notice: 'Bet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @box_content.update(box_content_params)\n format.html { redirect_to @box_content, notice: 'Box content was successfully updated.' }\n format.json { render :show, status: :ok, location: @box_content }\n else\n format.html { render :edit }\n format.json { render json: @box_content.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @quote_box = QuoteBox.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @quote_box.update_attributes(params[:quote_box])\r\n format.html { redirect_to @quote_box, notice: 'Quote box 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: @quote_box.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n resource.update(deposit_contract_params)\n respond_with client, resource\n end", "def update\n respond_to do |format|\n puts \"article_box_params:#{article_box_params}\"\n puts \"article_box_params.class:#{article_box_params.class}\"\n if @article_box.update(article_box_params)\n format.html { redirect_to @article_box, notice: 'Article box was successfully updated.' }\n format.json { render :show, status: :ok, location: @article_box }\n else\n format.html { render :edit }\n format.json { render json: @article_box.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(update_params)\n format.html { redirect_to_leaf_notice(UPDATE_SUCCESS) }\n format.json { render :show, status: :ok, location: @contract }\n else\n unprocessable_response(format)\n end\n end\n end", "def update\n @mailbox = Mailbox.find(params[:id])\n\n respond_to do |format|\n if @mailbox.update_attributes(params[:mailbox])\n format.html { redirect_to mailboxes_path, notice: 'Mailbox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mailbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cardbox = current_user.cardboxes.find(params[:id])\n\n respond_to do |format|\n if @cardbox.update_attributes(params[:cardbox])\n format.html { redirect_to(@cardbox, :notice => _('Der Karteikasten wurde geändert')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cardbox.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @films_box = FilmsBox.find(params[:id])\n\n respond_to do |format|\n if @films_box.update_attributes(params[:films_box])\n format.html { redirect_to @films_box, notice: 'Films box was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @films_box.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @feedbox = Feedbox.find(params[:id])\n\n respond_to do |format|\n if @feedbox.update_attributes(params[:feedbox])\n format.html { redirect_to @feedbox, notice: 'Feedbox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feedbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bet = Bet.find(params[:id])\n\n respond_to do |format|\n if @bet.update_attributes(params[:bet])\n format.html { redirect_to @bet, notice: 'Bet was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bet.errors, status: :unprocessable_entity }\n end\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 @box_score_entry = BoxScoreEntry.find(params[:id])\n\n respond_to do |format|\n if @box_score_entry.update_attributes(params[:box_score_entry])\n format.html { redirect_to @box_score_entry, :notice => 'Box score entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @box_score_entry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @mint_coin = @coin.mint_coins.find(params[:id])\n\n respond_to do |format|\n if @mint_coin.update_attributes(params[:mint_coin])\n format.html { redirect_to coin_mint_coins_url([@coin]), :notice => 'Mint coin was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @mint_coin.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bowl = Bowl.find(params[:id])\n \n # set bowl modify time\n @bowl.modified = Time.now\n \n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n \n Rails.logger.info \"Updating Bowl Contents\"\n \n # remove all contents for this bowl and add new\n @bowl.contents.delete_all(\"bowl_id=\" + @bowl.id)\n \n params.keys.each do |param|\n if param.start_with?(\"input_\") and (params[param] != \"\") \n @bowl.contents.create(:bowl_id => @bowl.id, :dryfruit_id => param[6, 2], :quantity => params[param]) \n end\n end\n\n format.html { redirect_to bowls_path, :notice => 'Bowl was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @bowl.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @gearbox.update(gearbox_params)\n format.html { redirect_to @gearbox, notice: 'Gearbox was successfully updated.' }\n format.json { render :show, status: :ok, location: @gearbox }\n else\n format.html { render :edit }\n format.json { render json: @gearbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n @contract = Contract.find(params[:id])\n\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract }\n else\n format.html { render :edit }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @inbox = Inbox.find(params[:id])\n\n respond_to do |format|\n if @inbox.update_attributes(params[:inbox])\n format.html { redirect_to @inbox, notice: 'Inbox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, contract: @contract }\n else\n format.html { render :edit }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @climb = Climb.find(params[:id])\n\n respond_to do |format|\n if @climb.update_attributes(params[:climb])\n format.html { redirect_to @climb, notice: 'Climb was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @climb.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contact_box.attributes = params[:contact_box]\n \n respond_to do |format|\n if @contact_box.save(:user => current_user)\n format.html { render 'admin/shared/update' }\n format.xml { head :ok }\n else\n format.html { render :template => 'admin/shared/edit', :locals => { :record => @contact_box }, :status => :unprocessable_entity }\n format.xml { render :xml => @contact_box.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @promotion_box = PromotionBox.find(params[:id])\n\n respond_to do |format|\n if @promotion_box.update_attributes(params[:promotion_box])\n flash[:notice] = 'PromotionBox was successfully updated.'\n format.html { redirect_to admin_promotion_boxes_path }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @promotion_box.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @player_box_score = PlayerBoxScore.find(params[:id])\n\n respond_to do |format|\n if @player_box_score.update_attributes(params[:player_box_score])\n format.html { redirect_to @player_box_score, notice: 'Player box score was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @player_box_score.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contract = Contract.find(params[:id])\n\n respond_to do |format|\n if @contract.update_attributes(params[:contract])\n format.html { redirect_to @contract.lead, notice: 'Contract was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sugar_bag = SugarBag.find(params[:id])\n\n respond_to do |format|\n if @sugar_bag.update_attributes(params[:sugar_bag])\n format.html { redirect_to @sugar_bag, notice: 'Sugar bag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sugar_bag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract }\n else\n format.html { render :edit }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract }\n else\n format.html { render :edit }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract }\n else\n format.html { render :edit }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract }\n else\n format.html { render :edit }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract }\n else\n format.html { render :edit }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract }\n else\n format.html { render :edit }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract }\n else\n format.html { render :edit }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @contract.update(contract_params)\n format.html { redirect_to @contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract }\n else\n format.html { render :edit }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @budget = Budget.find(params[:id])\n\n respond_to do |format|\n if @budget.update_attributes(params[:budget])\n format.html { redirect_to @budget, notice: 'Budget was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @budget = Budget.find(params[:id])\n\n respond_to do |format|\n if @budget.update_attributes(params[:budget])\n format.html { redirect_to @budget, notice: 'Budget was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @box_score_entry.update(box_score_entry_params)\n format.html { redirect_to @box_score_entry, notice: 'Box score entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @box_score_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @budget = Budget.find(params[:id])\n\n respond_to do |format|\n if @budget.update_attributes(params[:budget])\n format.html { redirect_to @budget, notice: 'Budget was successfully updated.' }\n # format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n # format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @bill_quorum = BillQuorum.find(params[:id])\n\n respond_to do |format|\n if @bill_quorum.update_attributes(params[:bill_quorum])\n format.html { redirect_to @bill_quorum, notice: 'Bill Quorum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bill_quorum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @system_contract.update(system_contract_params)\n format.html { redirect_to @system_contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @system_contract }\n else\n format.html { render :edit }\n format.json { render json: @system_contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @budget.update(budget_params)\n Item.where([\"budget_id = #{params[:id]}\"]).update_all(budget_id: nil)\n if !params[:budget][:items].nil?\n params[:budget][:items].each do |f| \n Item.where([\"id = #{f}\"]).first.update(budget_id: params[:id])\n end\n end\n format.html { redirect_to budgets_path, notice: \"Budget was successfully updated.\" }\n format.json { render :show, status: :ok, location: @budget }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @budget.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @asterisk_voicemail_box.update(asterisk_voicemail_box_params)\n format.html { redirect_to @asterisk_voicemail_box, notice: 'Asterisk voicemail box was successfully updated.' }\n format.json { render :show, status: :ok, location: @asterisk_voicemail_box }\n else\n format.html { render :edit }\n format.json { render json: @asterisk_voicemail_box.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @lightbox = Lightbox.find(params[:id])\n\n respond_to do |format|\n if @lightbox.update_attributes(params[:lightbox])\n format.html { redirect_to @lightbox, notice: 'Lightbox was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @lightbox.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user_box_record = UserBoxRecord.find(params[:id])\n @user_box_record.machine_id = Box.find(params[:user_box_record][:box_id]).machine_id\n\n respond_to do |format|\n if @user_box_record.update_attributes(params[:user_box_record])\n @user_box_record.update_current_box_record\n\n format.html { redirect_to @user_box_record, notice: '進出記錄更新成功.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_box_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n respond_to do |format|\n if @ticketbill.update(ticketbill_params)\n format.html { redirect_to @ticketbill, notice: 'Ticketbill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticketbill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @money_receipt = MoneyReceipt.find(params[:id])\n\n respond_to do |format|\n if @money_receipt.update_attributes(params[:money_receipt])\n format.html { redirect_to @money_receipt, notice: 'Money receipt was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @money_receipt.errors, status: :unprocessable_entity }\n end\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 @contract = Contract.find(params[:id])\n\n respond_to do |format|\n if @contract.update_attributes(params[:contract])\n format.html { redirect_to(\"/contractview\", :notice => 'Contract was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contract.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @bill = Bill.find(params[:id])\n\n if @bill.update(params[:bill])\n head :no_content\n else\n render json: @bill.errors, status: :unprocessable_entity\n end\n end", "def update\n @bill = current_user_or_guest.bills.find(params[:id])\n\n respond_to do |format|\n if @bill.update_attributes(bill_params)\n format.html { redirect_to(@bill, notice: t('bill.updated')) }\n format.xml { head :ok }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @bill.errors, status: :unprocessable_entity }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @tipmoney.update(tipmoney_params)\n format.html { redirect_to @tipmoney, notice: 'Tipmoney was successfully updated.' }\n format.json { render :show, status: :ok, location: @tipmoney }\n else\n format.html { render :edit }\n format.json { render json: @tipmoney.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end", "def assign_tenant_circles_to_an_aos_version_box(args = {}) \n body_put(\"/aosversions.json/aosversionbox/circles/#{args[:aosVersionBoxId]}\", args[:array_of_ids])\nend", "def UpdateTicket params = {}\n \n APICall(path: 'tickets.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n respond_to do |format|\n if @climb.update(climb_params)\n format.html { redirect_to @climb, notice: 'Climb was successfully updated.' }\n format.json { render :show, status: :ok, location: @climb }\n else\n format.html { render :edit }\n format.json { render json: @climb.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bill = Bill.find(params[:id])\n\n respond_to do |format|\n if @bill.update_attributes(params[:bill])\n format.html { redirect_to @bill, notice: 'Bill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @bill = Bill.find(params[:id])\n\n respond_to do |format|\n if @bill.update_attributes(params[:bill])\n format.html { redirect_to @bill, notice: 'Bill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\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 @bill.type_of_bill_id = 1\n respond_to do |format|\n if @bill.update(bill_params)\n format.html { redirect_to bills_url, notice: 'Счет успешно обновлен.' }\n format.json { render :show, status: :ok, location: @bill }\n log(current_user.id,\"Обновил счет\",\"\")\n else\n format.html { render :edit }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def update\n respond_to do |format|\n if @bounty.update(bounty_params)\n format.html { redirect_to @bounty, notice: 'Bounty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bounty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bet.update(bet_params)\n format.html { redirect_to @bet, notice: 'Bet was successfully updated.' }\n format.json { render :show, status: :ok, location: @bet }\n else\n format.html { render :edit }\n format.json { render json: @bet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bet.update(bet_params)\n format.html { redirect_to @bet, notice: 'Bet was successfully updated.' }\n format.json { render :show, status: :ok, location: @bet }\n else\n format.html { render :edit }\n format.json { render json: @bet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bet.update(bet_params)\n format.html { redirect_to @bet, notice: 'Bet was successfully updated.' }\n format.json { render :show, status: :ok, location: @bet }\n else\n format.html { render :edit }\n format.json { render json: @bet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @bill.update_attributes(params[:bill])\n format.html { redirect_to bill_path(@bill), notice: 'Bill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @bill.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contract = Contract.find(params[:id])\n\n respond_to do |format|\n if @contract.update_attributes(params[:contract])\n flash[:notice] = 'Contract was successfully updated.'\n format.html { redirect_to(@contract) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @contract.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :edit, Bill\n respond_to do |format|\n if @bill.update(bill_params)\n format.html { redirect_to bills_path, notice: 'Bill was successfully updated.' }\n format.json { render :show, status: :created, location: @bill }\n else\n format.html { render :edit }\n format.json\n end\n end\n end", "def update\n respond_to do |format|\n if @invoice.invoice_type == InvoiceType.deposit\n if @invoice.update(invoice_params)\n @balance_invoice = @invoice.project.balance_invoice\n @balance_invoice.amount = @invoice.project.price - @invoice.amount\n @balance_invoice.save!\n format.html { redirect_to @invoice, notice: 'Invoice was successfully updated.' }\n format.json { render :show, status: :ok, location: @invoice }\n else\n format.html { render :edit }\n end\n else\n if @invoice.amount != invoice_params[:amount]\n format.html { redirect_to @invoice, error: 'Balance Price Can Not Be Updated On Its Own' }\n end\n if @invoice.update(invoice_params)\n format.html { redirect_to @invoice, notice: 'Invoice was successfully updated.' }\n end\n end\n end\n end", "def update\r\n @bill = Bill.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @bill.update_attributes(params[:bill])\r\n format.html { redirect_to @bill, only_path: true, notice: 'Bill 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: @bill.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n if @bet.update(bet_params)\n head :no_content # renders empty response\n else\n render json: @bet.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @betum.update(betum_params)\n format.html { redirect_to @betum, notice: 'Betum was successfully updated.' }\n format.json { render :show, status: :ok, location: @betum }\n else\n format.html { render :edit }\n format.json { render json: @betum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @contract = Contract.find(params[:id])\n @units = Unit.unsold(params[:tower_id])\n respond_to do |format|\n if @contract.update_attributes(params[:contract])\n format.html { redirect_to tower_contract_path(@contract.unit.tower, @contract), notice: 'Contract was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def update\n @bloom = Bloom.find(params[:id])\n\n respond_to do |format|\n if @bloom.update_attributes(params[:bloom])\n format.html { redirect_to @bloom, notice: 'Bloom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bloom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # too many issues trying to do strong parametesr.\n # TODO: implement strong params in the future\n params = request.parameters\n\n if !params.has_key?(:invoice_items) then\n flash[:error] = \"No items to update in invoice #{invoice.id}\"\n head status: :precondition_failed\n return\n end\n\n invoice = Invoice.find(params[:id])\n\n #just try to update the damn thing\n params[:invoice_items].each_pair do |key,value|\n InvoiceItem.find(key).update_attributes(value)\n end\n\n invoice.update_attribute(:total_billing, invoice.generate_total_billing)\n # update status\n if invoice.total_billing.zero? then\n invoice.update_attribute(:status, Invoice.statuses[\"settled\"])\n else\n invoice.update_attribute(:status, Invoice.statuses[\"outstanding\"])\n end\n\n flash[:notice] = \"Invoice #{invoice.id} updated\"\n render json: {message:\"Invoice #{invoice.id} updated\", invoice:invoice}, status: :ok\n end", "def set_cashbox\n @cashbox = Cashbox.find(params[:id])\n end", "def set_cashbox\n @cashbox = Cashbox.find(params[:id])\n end" ]
[ "0.68441975", "0.65989393", "0.657906", "0.65616673", "0.64943945", "0.6387296", "0.63081044", "0.62886214", "0.62861", "0.6283163", "0.6246032", "0.62444025", "0.62130284", "0.61920047", "0.61198187", "0.6110951", "0.6061957", "0.6053636", "0.60061836", "0.6005279", "0.59672827", "0.59268796", "0.58799434", "0.58410394", "0.58260334", "0.58246154", "0.58177185", "0.5786577", "0.57544756", "0.5752177", "0.57418627", "0.57357484", "0.5729115", "0.57089597", "0.5707083", "0.57006705", "0.56928134", "0.56890917", "0.56890357", "0.56603694", "0.56600523", "0.56534857", "0.56489694", "0.56428903", "0.5641678", "0.56406873", "0.56337595", "0.5629465", "0.5629465", "0.5629465", "0.5629465", "0.5629465", "0.5629465", "0.5629465", "0.5629465", "0.56240064", "0.56240064", "0.5613017", "0.5605882", "0.55946773", "0.5592915", "0.55879915", "0.5570194", "0.55641955", "0.5563713", "0.55622727", "0.55509186", "0.55506843", "0.55487406", "0.5546875", "0.5544645", "0.5535591", "0.55206096", "0.5513244", "0.5502055", "0.55013686", "0.54876816", "0.54846543", "0.54846543", "0.5483302", "0.547582", "0.54739696", "0.5462513", "0.54606336", "0.54606336", "0.54606336", "0.54573417", "0.5456183", "0.54495573", "0.5449535", "0.5443371", "0.5440664", "0.543357", "0.54260266", "0.54239374", "0.54239374", "0.54196763", "0.54137856", "0.5407939", "0.5407939" ]
0.72163934
0
DELETE /moneyboxes/1 DELETE /moneyboxes/1.json
def destroy @moneybox.destroy respond_to do |format| format.html { redirect_to moneyboxes_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @cashbox.destroy\n respond_to do |format|\n format.html { redirect_to cashbox_index_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cashbox.destroy\n respond_to do |format|\n format.html { redirect_to cashboxes_url, notice: 'Cashbox was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @box = Box.find(params[:id])\n @box.destroy\n\n respond_to do |format|\n format.html { redirect_to boxes_url }\n format.json { head :ok }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def boxing_delete\n base_delete(params, \"Boxing\")\n end", "def destroy\n @box = Box.find(params[:id])\n @box.destroy\n respond_to do |format|\n format.html { redirect_to(my_boxes_path) }\n format.xml { head :ok }\n end\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 @call_box = CallBox.find(params[:id])\n @call_box.destroy\n\n respond_to do |format|\n format.html { redirect_to(layer_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @inbox = Inbox.find(params[:id])\n @inbox.destroy\n\n respond_to do |format|\n format.html { redirect_to inboxes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @money.destroy\n respond_to do |format|\n format.html { redirect_to money_index_url, notice: 'Money was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n raise 'Yet not implemented'\n @cardbox = current_user.cardboxes.find(params[:id])\n @cardbox.destroy\n\n respond_to do |format|\n format.html { redirect_to(cardboxes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n #binding.pry\n @balance = Balance.find(params[:id])\n @balance.destroy\n respond_to do |format|\n format.html { redirect_to balances_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @box = current_user.boxes.find(params[:id])\n @catalog = @box.catalog\n @box.destroy\n\n respond_to do |format|\n format.html { redirect_to catalog_path(@catalog), :notice => 'Box destroyed' }\n end\n end", "def destroy\n @budget = Budget.find(params[:id])\n @budget.destroy\n\n respond_to do |format|\n format.html { redirect_to budgets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @budget = Budget.find(params[:id])\n @budget.destroy\n respond_to do |format|\n format.html { redirect_to budgets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @stats_money_transaction = Stats::MoneyTransaction.find(params[:id])\n @stats_money_transaction.destroy\n\n respond_to do |format|\n format.html { redirect_to stats_money_transactions_url }\n format.json { head :ok }\n end\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def destroy\n cancel_contract!\n render json: { success: true }, status: :ok\n end", "def destroy\n @item = Item.find(params[:id])\n @item.destroy\n\n respond_to do |format|\n format.html { redirect_to budget_path(params[:budget_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @asterisk_voicemail_box.destroy\n respond_to do |format|\n format.html { redirect_to asterisk_voicemail_boxes_url, notice: 'Asterisk voicemail box was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @climb = Climb.find(params[:id])\n @climb.destroy\n\n respond_to do |format|\n format.html { redirect_to climbs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #Todo: \n # update user current box record when record deleted\n\n @user_box_record = UserBoxRecord.find(params[:id])\n @user_box_record.destroy\n\n respond_to do |format|\n format.html { redirect_to user_box_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mailbox = Mailbox.find(params[:id])\n @mailbox.destroy\n\n respond_to do |format|\n format.html { redirect_to mailboxes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract = Contract.find(params[:id])\n @contract.destroy\n\n respond_to do |format|\n format.html { redirect_to(contracts_url) }\n format.xml { head :ok }\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\r\n @bill = Bill.find(params[:id])\r\n @bill.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to bills_url, only_path: true }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @promotion_box = PromotionBox.find(params[:id])\n @promotion_box.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_promotion_boxes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @bloom = Bloom.find(params[:id])\n @bloom.destroy\n\n respond_to do |format|\n format.html { redirect_to blooms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if params[:id] =~ /\\d+/\n @budget = Budget.find(params[:id])\n ActiveRecord::Base.connection.execute(\"delete from budget_products where budget_id = #{params[:id]}\")\n @budget.destroy\n end\n \n respond_to do |format|\n format.html { redirect_to budgets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bitcoin.destroy\n respond_to do |format|\n format.html { redirect_to bitcoins_url, notice: 'Bitcoin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract = Contract.find(params[:id])\n @contract.destroy\n\n respond_to do |format|\n format.html { redirect_to contracts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @mint_coin = @coin.mint_coins.find(params[:id])\n @mint_coin.destroy\n\n respond_to do |format|\n format.html { redirect_to coin_mint_coins_url([@coin]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @box_content.destroy\n respond_to do |format|\n format.html { redirect_to box_contents_url, notice: 'Box content was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract = Contract.find(params[:id])\n @contract.destroy\n\n respond_to do |format|\n format.html { redirect_to tower_contracts_path(@tower) }\n format.json { head :no_content }\n end\n end", "def destroy\n check_admin\n @time_balance = TimeBalance.find(params[:id])\n @time_balance.destroy\n\n respond_to do |format|\n format.html { redirect_to time_balances_url }\n format.json { head :ok }\n end\n end", "def destroy\n @bill = Bill.find(params[:id])\n @bill.destroy\n\n respond_to do |format|\n format.html { redirect_to bills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bill = Bill.find(params[:id])\n @bill.destroy\n\n respond_to do |format|\n format.html { redirect_to bills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bill = Bill.find(params[:id])\n @bill.destroy\n\n respond_to do |format|\n format.html { redirect_to bills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @box_score = BoxScore.find(params[:id])\n @box_score.destroy\n\n respond_to do |format|\n format.html { redirect_to box_scores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n \n begin\n destroy_item(Account, params[:id], params[:lock_version])\n render :response => :DELETE\n rescue Exception => e\n @error = process_exception(e)\n render :response => :error\n end\n end", "def destroy\n @bet = Bet.find(params[:id])\n @bet.destroy\n\n respond_to do |format|\n format.html { redirect_to bets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bet = Bet.find(params[:id])\n @bet.destroy\n\n respond_to do |format|\n format.html { redirect_to bets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @article_box.destroy\n respond_to do |format|\n format.html { redirect_to article_boxes_url, notice: 'Article box was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @box = Box.find(params[:id])\n authorize! :destroy, @box\n\n @box.destroy\n\n respond_to do |format|\n format.html { redirect_to boxes_url }\n format.js\n end\n end", "def destroy\n @system_contract.destroy\n respond_to do |format|\n format.html { redirect_to system_contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_contract.destroy\n respond_to do |format|\n format.html { redirect_to admin_contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @films_box = FilmsBox.find(params[:id])\n @films_box.destroy\n\n respond_to do |format|\n format.html { redirect_to films_boxes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @amount = Amount.find(params[:id])\n @amount.destroy\n\n respond_to do |format|\n format.html { redirect_to(amounts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @az_bill = AzBill.find(params[:id])\n @az_bill.destroy\n\n respond_to do |format|\n format.html { redirect_to(az_bills_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'Contract was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @budget.destroy\n\n respond_to do |format|\n format.html { redirect_to budgets_url, notice: 'Budget was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bill.destroy\n\n respond_to do |format|\n format.html { redirect_to bills_path }\n format.json { head :no_content }\n end\n end", "def destroy\n # @bill_quorum = BillQuorum.find(params[:id])\n @bill_quorum.destroy\n\n respond_to do |format|\n format.html { redirect_to bill_quorums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :edit, Bill\n @bills.map(&:destroy)\n respond_to do |format|\n format.html { redirect_to bills_path, notice: 'Bill was successfully destroyed.' }\n format.json { render json: { data: [] } }\n end\n end", "def destroy\n @credito = Credito.find(params[:id])\n @credito.destroy\n\n respond_to do |format|\n format.html { redirect_to creditos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @budget.destroy\n respond_to do |format|\n format.html { redirect_to budgets_url, notice: 'Budget was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @budget.destroy\n respond_to do |format|\n format.html { redirect_to budgets_url, notice: 'Budget was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @budget.destroy\n respond_to do |format|\n format.html { redirect_to budgets_url, notice: 'Budget was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @coinrate.destroy\n respond_to do |format|\n format.html { redirect_to exchanges_path, notice: 'La cotizacion se ha eliminado con exito.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gearbox.destroy\n respond_to do |format|\n format.html { redirect_to gearboxes_url, notice: 'Gearbox was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cash_balance.destroy\n respond_to do |format|\n format.html { redirect_to cash_balances_url, notice: 'Cash balance was successfully destroyed.' }\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 @budget.destroy\n respond_to do |format|\n format.html { redirect_to budgets_url, notice: \"Budget was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @contract.destroy\n respond_to do |format|\n format.html { redirect_to contracts_url, notice: 'El contrato se eliminó correctamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bill.destroy\n respond_to do |format|\n format.html { redirect_to bills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bill.destroy\n respond_to do |format|\n format.html { redirect_to bills_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bagtype = Bagtype.find(params[:id])\n @bagtype.destroy\n\n respond_to do |format|\n format.html { redirect_to bagtypes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @bill = Bill.find(params[:id])\n @bill.destroy\n\n respond_to do |format|\n format.html { redirect_to(bills_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end", "def destroy\n @balance = Balance.find(params[:id])\n @balance.destroy\n\n respond_to do |format|\n format.html { redirect_to(balances_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @feedbox = Feedbox.find(params[:id])\n @feedbox.destroy\n\n respond_to do |format|\n format.html { redirect_to feedboxes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @money = Money.find(params[:id])\n @money.destroy\n\n redirect_to :controller => 'money', :action => 'list'\n end", "def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end", "def destroy\n @budget_item = BudgetItem.find(params[:id])\n @budget_item.destroy\n\n respond_to do |format|\n format.html { redirect_to(budget_items_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @addbalance.destroy\n respond_to do |format|\n format.html { redirect_to addbalances_url, notice: 'Addbalance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n \n keystone.delete_tenant(keystone.get_tenant(params[:id])[:id])\n\n respond_to do |format|\n format.html { redirect_to tenants_url }\n format.json { head :ok }\n end\n end", "def destroy\n @balance_bill = BalanceBill.find(params[:id])\n @balance_bill.updated_user = current_user.login_name\n @balance_bill.destroy\n\n respond_to do |format|\n format.html { redirect_to balance_bills_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @money_receipt = MoneyReceipt.find(params[:id])\n @money_receipt.destroy\n\n respond_to do |format|\n format.html { redirect_to money_receipts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @our_coin = OurCoin.find(params[:id])\n @our_coin.destroy\n\n respond_to do |format|\n format.html { redirect_to our_coins_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @boxscore = @game.boxscores.find(params[:id])\n @boxscore.destroy\n\n respond_to do |format|\n format.html { redirect_to @game }\n format.json { head :no_content }\n end\n end", "def destroy\n @account_balance.destroy\n respond_to do |format|\n format.html { redirect_to account_balances_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bill = Bill.find(params[:id])\n \n @bill.destroy\n\n respond_to do |format|\n format.html { redirect_to(bills_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @therapy_budget.destroy\n respond_to do |format|\n format.html { redirect_to therapy_budgets_url, notice: 'Therapy budget was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cabinet = Cabinet.find(params[:id])\n @cabinet.destroy\n\n respond_to do |format|\n format.html { redirect_to cabinets_url }\n format.json { head :ok }\n end\n end", "def destroy\n @contract_service.destroy\n respond_to do |format|\n format.html { redirect_to contract_services_url, notice: 'Contract service was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @mycoin.destroy\n respond_to do |format|\n format.html { redirect_to mycoins_url, notice: 'Mycoin was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @climb_datum = ClimbDatum.find(params[:id])\n @climb_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to climb_data_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7229852", "0.7117079", "0.70890284", "0.7074077", "0.6972092", "0.69267416", "0.67843646", "0.66681075", "0.66362035", "0.66166526", "0.6606855", "0.6599356", "0.6599271", "0.6522575", "0.651303", "0.65083313", "0.6485756", "0.64824367", "0.6472177", "0.6461107", "0.6459967", "0.6458539", "0.64516896", "0.64505476", "0.6442257", "0.6431083", "0.64280355", "0.6426644", "0.64236677", "0.64186406", "0.6413904", "0.6408958", "0.64089304", "0.6396716", "0.6390298", "0.6387109", "0.6375002", "0.6375002", "0.6375002", "0.6373424", "0.63711053", "0.63657767", "0.63657767", "0.63596433", "0.63462853", "0.6339566", "0.6328892", "0.63271916", "0.63249713", "0.6321858", "0.6321107", "0.6321107", "0.6321107", "0.6321107", "0.6321107", "0.6321107", "0.6321107", "0.6321107", "0.6321107", "0.6321107", "0.6321107", "0.6321107", "0.6320445", "0.62941223", "0.6294007", "0.62937915", "0.62834543", "0.62818086", "0.62783676", "0.62783676", "0.62783676", "0.6277934", "0.62772745", "0.62763935", "0.6275806", "0.62736124", "0.62725896", "0.62712467", "0.62712467", "0.6264553", "0.6263251", "0.62570375", "0.6252633", "0.6245818", "0.6244651", "0.62423366", "0.623141", "0.6229481", "0.62291306", "0.62290215", "0.62263006", "0.6221434", "0.621844", "0.6217841", "0.61995995", "0.61977965", "0.6193682", "0.6192153", "0.6191108", "0.61883336" ]
0.7852458
0
Use callbacks to share common setup or constraints between actions.
def set_moneybox @moneybox = Moneybox.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
GET /albums/1 GET /albums/1.json
def show @album = Album.find(params[:id]) @output = "<div ><br><table class='entries'><br><tr>" 10.times { |i| @output.concat("<th></th>") } @output.concat("</tr></tr>") irc = 0 @album.photos.each do |photo| irc += 1 @output.concat( "<td><div class='thumbnail'><a href='/photos/show?id=".concat(photo.id.to_s) ) @output.concat( "'><img class='icons' src='/images/".concat(photo.path) ) @output.concat( "/".concat(photo.image)) @output.concat( "' /></a></div></td>\n") if irc == 10 irc = 0 @output.concat( "</tr>\n<tr>" ) end end @output.concat( "</tr>\n</table>\n</div>" ) # respond_to do |format| # format.html # show.html.erb #format.json { render json: @album } # end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def album\n album = Album.find(params[:id])\n render json: album\n end", "def get_album album_id\n get(\"/albums/#{album_id}\")\n end", "def index\n @albums = Album.all\n render json: @albums\n end", "def albums\n if params[:artist_id]\n albums = Artist.find(params[:artist_id]).albums\n else\n albums = Album.all\n end\n render json: albums\n end", "def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @albums }\n end\n end", "def index\n @albums = @user.albums\n end", "def show\n @albums = Artist.find(params[\"id\"]).albums\n end", "def show\n @album = Album.find(params[:id])\n @albums_count = Album.count\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end", "def get_albums(url)\n # should return albums\n # List of Hashes\n \n # must implement \n # - custom site parser\n end", "def show\n @album = Album.where(id: params[:id]).first\n if @album\n render json: @album, status: 200\n else\n return_not_found \n end\n end", "def get_albums(person_id, params={})\n @restv9.get_albums(person_id,params)\n end", "def show\n @album = Album.find(params[:id])\n render json: AlbumSerializer.new(@album)\n end", "def artist_albums(artist, options = {})\n get \"artists/#{artist}/albums\", options\n end", "def show\n @album = Album.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end", "def index\n @album = Album.find(params[:album_id])\n @photos = @album.photos.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @photos }\n end\n end", "def show\r\n @album = Album.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @album }\r\n end\r\n end", "def index\n @albums = @user.albums\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end", "def index\n\t\t@albums = Album.all\n\tend", "def show\n @user_album = UserAlbum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_album }\n end\n end", "def show\n \n @album = @user.albums.find(params[:id])\n\n respond_to do |format|\n \n format.html # show.html.erb\n format.js { render 'show'}\n format.json { render json: @album }\n end\n end", "def index\n @albums = current_user.albums\n end", "def albums\n @albums ||= response.albums.uniq(&:name)\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = @artist.albums.all.page(params[:page] || 1).per(18)\n end", "def index\n @albums = current_user.albums.page(params[:page]).per(10)\n end", "def show\n @albumm = Albumm.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @albumm }\n end\n end", "def show\n @photo = Photo.find(params[:id])\n\t@album = Album.find(@photo.album_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end", "def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend", "def albums(options={})\n call_pageable('library.getalbums', :albums, Album, {:user => @user.name}.merge(options))\n end", "def find_album_by_id(client, album_id)\n client.api(:album, :show, album_id)\nend", "def index\n @pictures = @album.pictures #JRD111115\n\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @pictures}\n end\n end", "def album(album_id_or_url, options = {})\n options = make_options(:album_id, album_id_or_url, options)\n get(options)\n end", "def new\n @album = current_user.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def show\n @album_owned = AlbumOwned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album_owned }\n end\n end", "def index\n if params[:album_id]\n @artists = Album.resolve(params[:album_id]).artist\n else\n @artists = Artist.order(:name)\n end\n\n render json: @artists\n end", "def index\n @galleries_albums = Galleries::Album.all\n end", "def show\n @album = Album.find_by_slug(params[:album_id])\n @album_item = @album.album_items.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album_item }\n end\n end", "def show\r\n @photo = Photo.find(params[:id])\r\n\r\n @albums = Album.all\r\n @albums_map = {}\r\n @albums.each do |album| \r\n @albums_map[album.TITLE] = album.ID\r\n end\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @photo }\r\n end\r\n end", "def show\n album = Album.includes(:album_images).find(params[:id])\n return_hash = album.attributes\n return_hash['album_images'] = album.album_images\n render json: return_hash\n end", "def show\n @user = User.find(@artist.user_id)\n @albums = @artist.albums\n end", "def index\n @albums = Album.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @albums.to_json }\n format.xml { render xml: @albums.to_xml }\n end\n end", "def show\n if !session[:access_token]\n redirect_to :controller => 'sessions', :action => 'connect'\n end\n\n pmocampo = \"30792403\"\n client = Instagram.client(:access_token => session[:access_token])\n \n @user = client.user(pmocampo)\n \n @album = Album.find(params[:id])\n @photos = client.user_recent_media(pmocampo)\n @photos = @photos.select {|p| p.tags.include?(@album.tag)}\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end", "def top_albums(tag)\n get(:standard, {:method => \"tag.getTopAlbums\", :tag => tag})\n end", "def show\n\t\t@album = Album.find(params[:id])\n\tend", "def index\n @albums = current_account.albums.find(:all, :order => 'position')\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end", "def albums( options=nil )\n params = default_params.merge( \n :method => 'smugmug.albums.get',\n :heavy => 1\n ) \n\n params = params.merge( options ) if( options )\n xml = RestClient.post BASE, params\n \n Smile::Album.from_xml( xml, session_id )\n rescue\n nil\n end", "def index\n @albums = Album.page(params[:page]).per(10).order(created_at: :desc)\n\n respond_to do |format|\n format.html\n format.json { render json: @albums.to_json }\n format.xml { render xml: @albums.to_xml }\n end\n end", "def show\n @album = Album.find(params[:id])\n @potential_songs = Song.where(:artist_id => @album.artist.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end", "def index\r\n @photos = Photo.all\r\n\r\n @albums = Album.all\r\n @albums_map = {}\r\n @albums.each do |album| \r\n @albums_map[album.TITLE] = album.ID\r\n end\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @photos }\r\n end\r\n end", "def index\n params[:q]||={:s => \"name asc\"}\n unless current_user.admin.present?\n @albums = current_user.albums\n end\n @q = @albums.search(params[:q])\n @albums = @q.result.page(params[:page]).limit(params[:per_page]||10)\n end", "def resource\n\t\t@album\n\tend", "def index\n unless @user = User.first(:conditions => {:id => params[:user_id].to_i})\n redirect_to(root_url)\n return\n end\n \n @photo_albums = @user.photo_albums \n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @photo_albums }\n end\n end", "def index\n @band = Band.find(params[:band_id])\n @albums = @band.albums\n end", "def top_albums(artist)\n get(:standard, {:method => \"artist.getTopAlbums\", :artist => artist})\n end", "def show\n @album = Album.find(params[:id]) #find takes one id\n render :show\n end", "def index\n @user = User.find(params[:id])\n raise \"not found\" if @user.blank? \n @albums = @user.albums.all(:order => :title)\n rescue\n redirect_to root_url, :notice => \"Can't find this user.\"\n end", "def picasa_albums(options = {})\n return [] unless current_user.has_provider_auth('google')\n PicasaPhoto.picasa_request_with_refresh(current_user.picasa_identity) do\n goog = GooglePhotosApi.new( current_user.picasa_identity.token )\n goog.albums[\"albums\"]\n end\n end", "def show\n @album2photo = Album2photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album2photo }\n end\n end", "def top_albums(user, options={})\n get(:standard, {:method => \"user.getTopAlbums\", :user => user}.merge(options))\n end", "def show\n respond_to do |format|\n format.html { redirect_to action: 'edit', id: @album.id }\n format.json do\n render json: { rows: (@album.nil? ? [] : [@album.marshall]),\n status: (@album.nil? ? 404 : 200),\n total: (@album.nil? ? 0 : 1) }\n end\n end\n end", "def index\n authorize! :read, Album\n \n @albums = Album.order(\"created_at DESC\").paginate(:page => params[:page], :per_page => 10)\n end", "def info(options={})\n get(:standard, {:method => \"album.getInfo\"}.merge(options))\n end", "def index\n @item_albums = ItemAlbum.all\n end", "def show\n @picture = @album.pictures.find(params[:id]) #JRD111115\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @picture}\n end\n end", "def new\n @group = Group.find(params[:group_id])\n @album = @group.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def album\n\t\talbums == nil ? nil : albums.first\n\tend", "def show\n # Pull the selected photo album.\n @photo_tag = PhotoTag.find(params[:id])\n\n respond_to do |format|\n format.json do\n render json: @photo_tag\n end\n end\n end", "def album_tracks(album, options = {})\n get \"albums/#{album}/tracks\", options\n end", "def index\r\n jump_to(\"/albums/list/#{session[:account_id]}\")\r\n end", "def index\n @albums = Album.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end", "def index\n @private_albums = PrivateAlbum.all\n end", "def index\n @images = @album.images.all\n end", "def index\n @albums = Album.where(\"group_id = ?\", params[:group_id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.js\n format.json { render json: @albums }\n end\n end", "def new\r\n\r\n @album = Album.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @album }\r\n end\r\n end", "def show\n @album = Album.find(params[:id])\n if @album.artist != nil\n @songs = get_songs_from_album @album.artist.name, @album.name\n @song_list = []\n if @songs\n @songs.each do |song|\n entry = Hash.new\n entry['rank'] = song['rank']\n entry['title'] = song['name']\n entry['artist'] = @album.artist.name\n song_in_db = lookup_song song['name'], @album.artist.name\n if song_in_db != nil\n entry['available'] = true\n entry['song_id'] = song_in_db.id\n else\n entry['available'] = false\n end\n entry['duration'] = seconds_to_duration(song['duration'].to_i)\n @song_list << entry\n end\n end\n @album_cover = get_album_cover @album.artist.name, @album.name\n @description = get_description_from_album @album.artist.name, @album.name\n end\n\n @songs = [] if @songs == nil\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end", "def picasa_albums(user, picasa_user_id=nil)\n return [] unless user.picasa_identity\n picasa = user.picasa_client\n user_data = picasa.user(picasa_user_id) \n albums = []\n unless user_data.nil?\n user_data.albums.select{|a| a.numphotos.to_i > 0}.each do |a|\n albums << {\n 'aid' => a.id,\n 'name' => a.title,\n 'cover_photo_src' => a.thumbnails.first.url\n }\n end\n end\n return albums\n end", "def index\n @interior_albums = InteriorAlbum.all\n end", "def show\n @photo = @allbum.photos.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @photo }\n end\n end", "def albums\n link :top_albums, :Album, name\n end", "def get_albums\n sql = \"SELECT * FROM albums WHERE artist_id = $1\"\n values = [@id]\n albums_data = SqlRunner.run(sql, values)\n albums = albums_data.map { |albums_data| Album.new(albums_data)}\n return albums\n end", "def image_list\n @images = Picture.where(album_id: params[:album_id])\n respond_to do |format|\n format.json { render json: @images.to_json(methods: [:path])}\n end\n end", "def set_album\n begin\n @album = Album.find(params[:id])\n rescue ActiveRecord::RecordNotFound => e\n render :json => {error: 'record not found'}, status: :not_found\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def show\n @album = current_account.albums.find(params[:id])\n @page_title = @album.name\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @album }\n end\n end", "def show\n @photos = @album.photos.includes(:album).page(params[:page])\n\n respond_to do |format|\n format.html do\n @page = @site.pages.find_by_name 'albums'\n @pages = @site.pages\n end\n format.js {}\n end\n end", "def fetch_album(args)\n search = AlbumFetch.new(args)\n response = APIRequest.post(search.query, Configuration.instance.api_url(@format))\n parse_response(response)\n end", "def index\n @pictures = @album.pictures.all\n end", "def show\n song = Song.find(params[:id])\n render json: song.to_json(only: [:id, :title, :artist], methods: :path, include: {category: {only: [:id, :name]}})\n end", "def albums( params={} )\n albums = get_connections(\"albums\", params)\n return map_connections albums, :to => Facebook::Graph::Album\n end", "def albums( params={} )\n albums = get_connections(\"albums\", params)\n return map_connections albums, :to => Facebook::Graph::Album\n end", "def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end", "def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end" ]
[ "0.8010893", "0.79601175", "0.7838933", "0.76931643", "0.7598457", "0.7579601", "0.7575355", "0.75562096", "0.75089633", "0.7500134", "0.74333906", "0.7426798", "0.7391768", "0.73389864", "0.7287336", "0.7271081", "0.72389615", "0.7209903", "0.7200635", "0.7192762", "0.719262", "0.7190189", "0.71899974", "0.7189037", "0.7189037", "0.7189037", "0.7189037", "0.7189037", "0.7189037", "0.7189037", "0.7189037", "0.7174694", "0.71160007", "0.7078915", "0.7077601", "0.70660496", "0.7058713", "0.7049489", "0.70435", "0.7025857", "0.70171344", "0.70086575", "0.6976009", "0.69755596", "0.697138", "0.69670695", "0.6944127", "0.6941958", "0.69266605", "0.68857", "0.68773973", "0.68753034", "0.6860878", "0.68499345", "0.6849906", "0.68468356", "0.68297654", "0.6786572", "0.67595285", "0.67595005", "0.6749892", "0.67452264", "0.6735612", "0.67324764", "0.6729119", "0.67173696", "0.6716952", "0.67097074", "0.6707279", "0.67051023", "0.6698686", "0.66937566", "0.66767585", "0.66571563", "0.6642816", "0.6640607", "0.6622478", "0.6604973", "0.6604935", "0.659947", "0.65925467", "0.6589441", "0.6587322", "0.65821093", "0.657914", "0.6577139", "0.6574047", "0.6572037", "0.65698504", "0.6569401", "0.6568482", "0.6568482", "0.6557697", "0.65519524", "0.6551283", "0.6549354", "0.65431345", "0.651043", "0.651043", "0.6497524", "0.6497524" ]
0.0
-1
GET /albums/new GET /albums/new.json
def new @album = Album.new respond_to do |format| format.html # new.html.erb #format.json { render json: @album } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @album = current_user.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def new\r\n\r\n @album = Album.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @album }\r\n end\r\n end", "def new\n @album = current_account.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def new\n @album = Album.new\n @title = \"new\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @album }\n format.js {}\n end\n end", "def new\n @albumm = Albumm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @albumm }\n end\n end", "def new\n @album = Album.find_by_slug(params[:album_id])\n @album_item = AlbumItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album_item }\n end\n end", "def new\n @group = Group.find(params[:group_id])\n @album = @group.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def new\n @user_album = UserAlbum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_album }\n end\n end", "def new\n @album = Album.find(params[:album_id])\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @album = Album.find(params[:album_id])\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @photo }\n end\n end", "def new\n \n @album = @user.albums.new\n respond_to do |format|\n format.js { render 'new' }\n format.html # show.html.erb\n end\n end", "def new\n @photo = Photo.new\n @photo.album_id = params[:album_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @album_owned = AlbumOwned.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album_owned }\n end\n end", "def new\n @photo = Photo.new\n @albums = Album.where('user_id=?',session[:user_id]).latest\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = @allbum.photos.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @album = Album.new\n @photo = @album.photos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @album = Album.new\n render :new\n end", "def new\n @album = Album.new\n end", "def new\n @album = Album.new\n end", "def new\r\n @photo = Photo.new\r\n \r\n if params[:id] != nil\r\n @album = Album.find(params[:id])\r\n if @album != nil\r\n @photo.ALBUM_ID = @album.ID\r\n end\r\n end\r\n\r\n @albums = Album.all\r\n @albums_map = {}\r\n @albums.each do |album| \r\n @albums_map[album.TITLE] = album.ID\r\n end\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @photo }\r\n end\r\n end", "def new\r\n @album = Album.new\r\n end", "def new\n @album2photo = Album2photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album2photo }\n end\n end", "def new\n @album = Album.new\n\n 3.times do\n @album.tracks.build\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def new \n @album = Album.new(params[:album])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def new\n @photo = Photo.new\n\t@albums = Album.find_all_by_twit_id(params[:view_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @album = Album.new\n 1.upto(3) { @album.photos.build }\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def create\n @album = current_user.albums.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'You created a #Album. Now share your #album around the internets' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @Album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @album = Album.new\n @album.album_photos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json do\n render json: { rows: (@album.nil? ? [] : [@album.marshall]),\n status: (@album.nil? ? 404 : 200),\n total: (@album.nil? ? 0 : 1) }\n end\n end\n end", "def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend", "def new\n @album_genre = AlbumGenre.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album_genre }\n end\n end", "def new\n @photo = Photo.new\n\n render json: @photo\n end", "def new\n @photoalbum = Photoalbum.new\n end", "def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render action: 'show', status: :created, location: @album }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def album\n album = Album.find(params[:id])\n render json: album\n end", "def create\n @album = current_user.albums.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'El album a sido creado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\talbum = Album.create(album_params)\n\n\t\tif !album.errors.any?\n\t\t\trender json: album\n\t\telse\n\t\t\trender json: {message: \"Error occurred\"}\n\t\tend\n\tend", "def new\n @photoalbum = Photoalbum.new\n @agendaitems = Agendaitem.order(\"date DESC\").limit(\"50\")\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photoalbum }\n end\n end", "def new\n @photo_album = PhotoAlbum.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @photo_album }\n end\n end", "def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end", "def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end", "def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end", "def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end", "def new\n @photo_library = PhotoLibrary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo_library }\n end\n end", "def create\n @album = current_account.albums.new(params[:album])\n\n respond_to do |format|\n if @album.save\n flash[:notice] = 'album was successfully created.'\n format.html { redirect_to( :action => 'edit', :id => @album.id) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @photo_album = PhotoAlbum.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @photo_album }\n end\n end", "def create\n @album = current_user.albums.build(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n if !@album\n @album = current_user.albums.find(params[:id])\n end\n @track = Track.new\n end", "def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @song }\n end\n end", "def new\n @song = Song.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @song }\n end\n end", "def new\n @artists = Artist.find(:all)\n @features = Feature.find(:all)\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to action: 'index', notice: 'Album was successfully created.' }\n format.json { render action: 'index', status: :created, location: @album }\n else\n format.html { render action: 'index' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @album = Album.new\n @images = Image.all(:conditions => {:album_id => nil})\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def create\n @album = Album.new(allowed_params_album)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @album = Album.new\n @artists = Artist.all\n end", "def new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @music }\n end\n end", "def new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @music }\n end\n end", "def new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @music }\n end\n end", "def new\n @gallery = Gallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @gallery }\n end\n end", "def new\n @gallery = Gallery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @gallery }\n end\n end", "def new\n @song = Song.new\n @song.verses.build\n @song.regions.build\n\n @kinds = Kind.all()\n @regions = Region.all()\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end", "def new\n @photo = Photo.new\n \n\tif params[:album_id]\n\t\t$album = Album.find(params[:album_id])\n\tend\n\t\n\trender :layout => false\n end", "def new\n @song = @playlist.songs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @song }\n end\n end", "def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: \"Album was successfully created.\" }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.find(params[:album_id])\n @photo = @album.photos.new(params[:photo])\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to album_photo_path(@album,@photo), :notice => 'Photo was successfully created.' }\n format.json { render :json => @photo, :status => :created, :location => @photo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n \n @palbum = Palbum.new\n\n \n end", "def create\n @album = Album.new(album_params)\n if @album.save\n redirect_to albums_path\n else \n render 'new'\n end\n end", "def new\n @artist = Artist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @artist }\n end\n end", "def create\n @photo = Photo.new(photo_params)\n @albums = get_current_albums\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to photos_url, notice: 'Фотография была успешно добавлена.' }\n format.json { render action: 'show', status: :created, location: @photo }\n else\n format.html { render action: 'new' }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = current_user.albums.build(params[:album])\n if @album.save\n flash[:notice] = 'Album was successfully created.'\n redirect_to(album_pictures_path(@album))\n else\n render :action => \"new\"\n end\n end", "def new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @music }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to group_url(@album.group), notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n respond_to do |format|\n if @user.albums << @album\n flash[:notice] = 'Album was successfully created.'\n format.html { redirect_to user_albums_path(@user) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n @album.user = current_user\n if @album.save\n format.html { redirect_to artist_album_path(@artist,@album), notice: 'album was successfully created.' }\n format.json { render action: 'show', status: :created, location: artist_album_path(@artist,@album) }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @music = Music.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @music }\n end\n \n end", "def new\n @user = current_user\n @customer = @user.customers.find(params[:customer_id])\n @album = @customer.albums.find(params[:album_id])\n @photo = @album.photos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end" ]
[ "0.8188497", "0.7981985", "0.7981985", "0.78127694", "0.7684331", "0.7587475", "0.7581201", "0.75649863", "0.7560995", "0.7540411", "0.7529835", "0.7486769", "0.7486765", "0.7453004", "0.7450529", "0.7412938", "0.7363582", "0.73290324", "0.7294751", "0.72580093", "0.72580093", "0.7252051", "0.7232258", "0.7199472", "0.7171097", "0.7119019", "0.7097473", "0.709051", "0.7069173", "0.7045207", "0.7045207", "0.7045207", "0.7038625", "0.7027273", "0.7027273", "0.7027273", "0.7027273", "0.7008472", "0.6976435", "0.6965229", "0.6918216", "0.6907318", "0.6877059", "0.68763506", "0.68584526", "0.6855001", "0.6839048", "0.6837797", "0.68220377", "0.68220377", "0.68220377", "0.68220377", "0.6816629", "0.67984563", "0.67935264", "0.67935264", "0.67926586", "0.6779142", "0.6773305", "0.67603713", "0.67603713", "0.67477125", "0.67377687", "0.6720057", "0.6716053", "0.6711633", "0.6708883", "0.6708883", "0.6708883", "0.66938645", "0.66938645", "0.66865367", "0.6681564", "0.6672112", "0.6670919", "0.6669238", "0.66659284", "0.665224", "0.6649685", "0.66451925", "0.66402704", "0.6636019", "0.66300654", "0.66300654", "0.66300654", "0.66300654", "0.66300654", "0.66300654", "0.66300654", "0.66300654", "0.66300654", "0.66300654", "0.66300654", "0.66300654", "0.6629788", "0.66267514", "0.6625163", "0.6602343", "0.6567532", "0.6564905" ]
0.78804016
3
POST /albums POST /albums.json
def create @album = Album.new(params[:album]) respond_to do |format| if @album.save #Dir.chdir("public/images") Dir.mkdir(@album['directory']) flash[:notice] = 'Album was successfully created.' #flash[:notice] = Dir.pwd format.html { redirect_to @album } #format.json { render json: @album, status: :created, location: @album } else format.html { render action = "new" } #format.json { render json: @album.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend", "def create\n @album = current_user.albums.build(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = current_user.albums.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'El album a sido creado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = current_user.albums.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'You created a #Album. Now share your #album around the internets' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @Album.errors, status: :unprocessable_entity }\n end\n end\n end", "def album\n album = Album.find(params[:id])\n render json: album\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to action: 'index', notice: 'Album was successfully created.' }\n format.json { render action: 'index', status: :created, location: @album }\n else\n format.html { render action: 'index' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\talbum = Album.create(album_params)\n\n\t\tif !album.errors.any?\n\t\t\trender json: album\n\t\telse\n\t\t\trender json: {message: \"Error occurred\"}\n\t\tend\n\tend", "def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: \"Album was successfully created.\" }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n respond_to do |format|\n if @user.albums << @album\n flash[:notice] = 'Album was successfully created.'\n format.html { redirect_to user_albums_path(@user) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render action: 'show', status: :created, location: @album }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @album = current_user.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def create\n @album = current_user.albums.build(params[:album])\n if @album.save\n flash[:notice] = 'Album was successfully created.'\n redirect_to(album_pictures_path(@album))\n else\n render :action => \"new\"\n end\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to group_url(@album.group), notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n ActiveRecord::Base.transaction do\n @album = Album.create!(album_params)\n # 画像登録数が多くなるUIになったらSQLの負荷を減らすためにactiverecord-importを入れる\n # https://github.com/zdennis/activerecord-import\n params[:urls].each do |image_url|\n AlbumImage.create!(album_id: @album.id, url: image_url)\n end\n end\n\n render json: @album\n end", "def create\n @album_ownership = AlbumOwnership.new\n @album_ownership.album = @album\n @album_ownership.user = current_user\n\n unless @album_ownership.save\n render json: @album_ownership.errors, status: :unprocessable_entity\n end\n end", "def create\n @album = Album.new(allowed_params_album)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = current_user.albums.build(album_params)\n \n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @user_album = UserAlbum.new(params[:user_album])\n\n respond_to do |format|\n if @user_album.save\n format.html { redirect_to @user_album, notice: 'User album was successfully created.' }\n format.json { render json: @user_album, status: :created, location: @user_album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = current_account.albums.new(params[:album])\n\n respond_to do |format|\n if @album.save\n flash[:notice] = 'album was successfully created.'\n format.html { redirect_to( :action => 'edit', :id => @album.id) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def albums\n if params[:artist_id]\n albums = Artist.find(params[:artist_id]).albums\n else\n albums = Album.all\n end\n render json: albums\n end", "def index\n @albums = Album.all\n render json: @albums\n end", "def create\n @album = Album.new(album_params)\n respond_to do |format|\n if @album.save\n flash[:success] = 'The album was successfully created.'\n format.html { redirect_to albums_path }\n format.json { render json: { rows: [@album.marshall], status: 200, total: 1 } }\n else\n @albums = Album.all\n notice = \"An error occured while creating the album. #{@album.errors.full_messages.to_sentence}.\"\n flash[:error] = notice\n format.html { render action: 'index', alert: notice }\n format.json { render json: { errors: @album.errors, status: :unprocessable_entity } }\n end\n end\n end", "def create\n\t\tAlbum.create({\n\t\t\tname: params[:name]\n\t\t\t})\n\t\tredirect_to albums_path\n\tend", "def create\n respond_to do |format|\n @album.user = current_user\n if @album.save\n format.html { redirect_to artist_album_path(@artist,@album), notice: 'album was successfully created.' }\n format.json { render action: 'show', status: :created, location: artist_album_path(@artist,@album) }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @group = Group.find(params[:group_id])\n @album = @group.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def create\n @album = Album.new(album_params)\n @album.user_id = current_user.id\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album erfolgreich erstellt.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n\n not_blank_photos = @album.photos.select do |photo|\n ! photo.title.blank?\n end\n @album.photos = not_blank_photos\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render action: 'show', status: :created, location: @album }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @album = Album.new(params[:album])\n \n respond_to do |format|\n if @album.save\n flash[:notice] = 'Album was successfully created.'\n format.html { redirect_to(@album) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n if @album.save\n redirect_to albums_path\n else \n render 'new'\n end\n end", "def index\n @albums = @user.albums\n end", "def albums( options=nil )\n params = default_params.merge( \n :method => 'smugmug.albums.get',\n :heavy => 1\n ) \n\n params = params.merge( options ) if( options )\n xml = RestClient.post BASE, params\n \n Smile::Album.from_xml( xml, session_id )\n rescue\n nil\n end", "def new\n @album = Album.new\n\n 3.times do\n @album.tracks.build\n end\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def create\n @galleries_album = Galleries::Album.new(galleries_album_params)\n @galleries_album.user = current_user\n respond_to do |format|\n if @galleries_album.save\n format.html { redirect_to @galleries_album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @galleries_album }\n else\n format.html { render :new }\n format.json { render json: @galleries_album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album_owned = AlbumOwned.new(params[:album_owned])\n\n respond_to do |format|\n if @album_owned.save\n format.html { redirect_to @album_owned, notice: 'Album owned was successfully created.' }\n format.json { render json: @album_owned, status: :created, location: @album_owned }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album_owned.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.find(params[:album_id])\n @photo = @album.photos.new(params[:photo])\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to album_photo_path(@album,@photo), :notice => 'Photo was successfully created.' }\n format.json { render :json => @photo, :status => :created, :location => @photo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @photoalbum = Photoalbum.new(params[:photoalbum])\n\n respond_to do |format|\n if @photoalbum.save\n format.html { redirect_to edit_photoalbum_path @photoalbum, notice: 'Photoalbum was successfully created.' }\n format.json { render json: @photoalbum, status: :created, location: @photoalbum }\n else\n format.html { render 'new' }\n format.json { render json: @photoalbum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.find_by_slug(params[:album_id])\n @album_item = @album.album_items.create(params[:album_item])\n\n respond_to do |format|\n if @album_item.save\n format.html { redirect_to @album, notice: 'Album item was successfully created.' }\n format.json { render json: @album_item, status: :created, location: @album_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @album.destroy\n render json: @album\n end", "def create\n @albumm = Albumm.new(params[:albumm])\n\n respond_to do |format|\n if @albumm.save\n format.html { redirect_to @albumm, notice: 'Albumm was successfully created.' }\n format.json { render json: @albumm, status: :created, location: @albumm }\n else\n format.html { render action: \"new\" }\n format.json { render json: @albumm.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n \n respond_to do |format|\n images = [params[:images]].flatten\n @album.images << Image.find(images) unless images[0].nil?\n \n if @album.save\n format.html { redirect_to(albums_path, :notice => 'Album was successfully created.') }\n format.xml { render :xml => albums_path, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @albums = Album.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @albums }\n end\n end", "def create\n @photo = Photo.new(photo_params)\n @albums = get_current_albums\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to photos_url, notice: 'Фотография была успешно добавлена.' }\n format.json { render action: 'show', status: :created, location: @photo }\n else\n format.html { render action: 'new' }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n \n respond_to do |format|\n if @album.save\n flash[:notice] = 'Album was successfully created.'\n format.html { redirect_to(@album) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def to_api_json\n Jbuilder.encode do |json|\n json.albums do\n json.array! @albums do |album|\n json.call(album, :name, :uuid)\n json.set!(:artist, album.artist_name)\n json.set!(:artist_twitter_screen_name, twitter_screen_name(album))\n json.set!(:thumbnail_url, album.image || album.thumbnail)\n json.set!(:release_date, album.release_date.in_time_zone.to_i)\n json.set!(:release_date_string, album.release_date.to_s)\n json.set!(:age, album.anniversary.count)\n json.set!(:day_of_week, album.anniversary.current.strftime('%A'))\n json.set!(:anniversary, album.anniversary.current.in_time_zone.to_i)\n json.set!(:anniversary_string, album.anniversary.current.to_s)\n json.set!(:review_link, album.link)\n json.set!(:rating, album.rating)\n json.set!(:generated_fun_fact_description, album.generated_fun_fact_description)\n json.set!(:fun_fact_description, album.fun_fact_description)\n json.set!(:fun_fact_source, album.fun_fact_source)\n json.set!(:link, \"/albums/#{album.slug}\")\n json.set!(:update, \"/v1/admin/albums/#{album.id}\")\n end\n end\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def new\r\n\r\n @album = Album.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @album }\r\n end\r\n end", "def create\n authorize! :create, Album\n @album = Album.new(album_params)\n @album.user_id = current_user.id\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to edit_admin_album_path(@album.id), notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t@album = Album.find(params[:album_id])\n \t@photo = @album.photos.create!(params[:photo])\n \tredirect_to @album, :notice => 'Photo created'\n end", "def create\n redirect_to new_album_path, alert: \"You have to select at least one artist.\" and return if params[:album][:album_artists].size == 1 && params[:album][:album_artists][0].empty? # TODO: Find a better way to do this, it does not play nicely with json and xml\n @album = Album.new(album_params)\n album_artists\n album_cover if params[:search_online]\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n format.xml { render xml: @album, status: :created }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n format.xml { render xml: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def artist_albums(artist, options = {})\n get \"artists/#{artist}/albums\", options\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n flash[:notice] = 'Album was successfully created.'\n format.html { redirect_to(@album) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @photo = Photo.new(params[:photo])\n @photo.user_id=session[:user_id]\n @photo.album_id= params[:photo][:album_id]\n respond_to do |format|\n if @photo.save\n format.html { redirect_to @photo, notice: 'Photo was successfully created.' }\n format.json { render json: @photo, status: :created, location: @photo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n new_album = Album.new\n new_album.title = params[:title]\n new_album.artist = params[:artist]\n new_album.year = params[:year]\n new_album.album_art = params[:album_art]\n new_album.save\n end", "def create\n @band = Band.find(params[:band_id])\n @album = Band.find(params[:band_id]).albums.build(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to new_band_album_song_path(@album.band.id, @album.id), notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Albumi loomine õnnestus.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @album = Album.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @album }\n end\n end", "def new\n @album = Album.new\n @photo = @album.photos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def create_album(name, description=nil)\n body = {}\n body['name'] = name\n body['description'] = description\n post(\"/albums\", body: body, code: 201 )\n end", "def new\n \n @album = @user.albums.new\n respond_to do |format|\n format.js { render 'new' }\n format.html # show.html.erb\n end\n end", "def new\n @user_album = UserAlbum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_album }\n end\n end", "def create\n @song = Song.new(song_params)\n\n respond_to do |format|\n if @song.save\n album_id = params[\"album\"]\n \n if not album_id.nil?\n album = Album.find_by(id: album_id)\n if not album.nil?\n album.songs << @song\n album.save\n\n artist = album.artist\n\n if not artist.nil?\n artist_id = artist.id\n if not artist_id.nil?\n artist.songs << @song\n artist.save\n end\n end\n end\n end\n\n format.html { redirect_to @song, notice: 'Song was successfully created.' }\n format.json { render :show, status: :created, location: @song }\n else\n format.html { render :new }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end", "def create \n \n respond_to do |format|\n @photo_album = current_user.photo_albums.build(params[:photo_album])\n if @photo_album.save\n flash[:notice] = 'Новый альбом создан.'\n format.html {\n # if current_user.photo_albums.size > 1\n # redirect_to(@photo_album)\n # else\n redirect_to(new_photo_path)\n # end\n }\n format.xml { render :xml => @photo_album, :status => :created, :location => @photo_album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @photo_album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @album = @student.albums.new(album_params)\n authorize @album\n if @album.save\n redirect_to new_album_photo_path(@album), notice: 'Album was successfully created.'\n else\n render :new\n end\n end", "def album_tracks(album, options = {})\n get \"albums/#{album}/tracks\", options\n end", "def create\n @album = Pagealbum.new(album_params)\n @images=album_params[:images_attributes].values.map {|x| Image.new(x)} rescue []\n\n respond_to do |format|\n if @album.save\n page=Page.first\n page.albums << @album\n format.html { redirect_to my_album_page_path(id: @album.id), notice: \"Pagealbum was successfully created.\" }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @album = Album.find(params[:id])\n @albums_count = Album.count\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @album }\n end\n end", "def upload\n @album = Album.find( params[:album_id].to_i)\n end", "def create\n @interior_album = InteriorAlbum.new(interior_album_params)\n\n respond_to do |format|\n if @interior_album.save\n format.html { redirect_to @interior_album, notice: 'Interior design album was successfully created.' }\n format.json { render :show, status: :created, location: @interior_album }\n else\n format.html { render :new }\n format.json { render json: @interior_album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @album = Album.new(:account_id => session[:account_id])\r\n \r\n @album.name = params[:album_name]\r\n @album.description = params[:album_description]\r\n if @album.save\r\n return jump_to(\"/albums/#{@album.id}/upload\")\r\n else\r\n flash.now[:error_msg] = \"操作失败, 再试一次吧\"\r\n end\r\n \r\n render(:action => \"new\")\r\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def index\n @albums = Album.all\n end", "def new\n @album = current_account.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def new_album(set_albumName, params = {})\n params = { :cmd => 'new-album', :set_albumName => set_albumName }.merge(params)\n send_request(params)\n end", "def albums\n @albums ||= response.albums.uniq(&:name)\n end", "def new\n @albumm = Albumm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @albumm }\n end\n end", "def new\n @photo = Photo.new\n @photo.album_id = params[:album_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @album = Album.new\n 1.upto(3) { @album.photos.build }\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def get_album album_id\n get(\"/albums/#{album_id}\")\n end", "def create\n @albumsix = Albumsix.new(albumsix_params)\n\n respond_to do |format|\n if @albumsix.save\n format.html { redirect_to @albumsix, notice: 'Albumsix was successfully created.' }\n format.json { render :show, status: :created, location: @albumsix }\n else\n format.html { render :new }\n format.json { render json: @albumsix.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @albums = current_user.albums\n end", "def set_album\n if token = album_token\n @album = Album.find_or_create_by(token: token)\n else\n @album = Album.find_by(uuid: params[:id])\n end\n end", "def create\n \n @album = @user.albums.new(params[:album])\n \n if @album.save\n flash[:notice] = 'User was successfully created.'\n if params[:album][:avatar].blank?\n redirect_to @album\n else\n \n render :action => 'cropping'\n end\n else\n render :action => 'new'\n end\n end", "def show\n @album = Album.find(params[:id])\n render json: AlbumSerializer.new(@album)\n end", "def create_album\n @other_user=@login_user\n @albums = @login_user.albums\n @album = Album.new(:name=>params[:album][:name], :user_id=>@login_user.id, :share_type => 0)\n @notice = @album.save ? \"Album created successfully.\": activerecord_error_list(@album.errors)\n\n respond_to do |format|\n format.js\n end\n end", "def create\n @private_album = PrivateAlbum.new(private_album_params)\n\n respond_to do |format|\n if @private_album.save\n format.html { redirect_to @private_album, notice: 'Private album was successfully created.' }\n format.json { render action: 'show', status: :created, location: @private_album }\n else\n format.html { render action: 'new' }\n format.json { render json: @private_album.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @albums = Pagealbum.all.joins(:pagehavingalbums)\n redirect_to \"/beautyvip/create_album\"\n end", "def index\n @albums = @user.albums\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @albums }\n end\n end" ]
[ "0.7753841", "0.728448", "0.72349143", "0.7196897", "0.7180527", "0.7081311", "0.7081311", "0.7081311", "0.7004145", "0.7004145", "0.69842875", "0.6973087", "0.69712293", "0.6958873", "0.694998", "0.69284946", "0.6897242", "0.68912", "0.6847369", "0.6824543", "0.6823664", "0.68061423", "0.68012935", "0.6784101", "0.6782813", "0.674645", "0.67402464", "0.67040956", "0.66482157", "0.66153574", "0.6601745", "0.65922624", "0.6586504", "0.6576589", "0.6576109", "0.657462", "0.65721107", "0.6570726", "0.65067923", "0.65046936", "0.64870083", "0.6477017", "0.64684826", "0.64666224", "0.64650136", "0.64649326", "0.64489126", "0.6448912", "0.64015096", "0.6387147", "0.6387147", "0.63823193", "0.63819504", "0.63566107", "0.63556784", "0.6352572", "0.63235146", "0.6317156", "0.631415", "0.6309794", "0.6292605", "0.6280553", "0.6275303", "0.6272577", "0.6268659", "0.6267505", "0.6238164", "0.62260014", "0.62216544", "0.6217772", "0.6209893", "0.62082225", "0.62064403", "0.61911774", "0.61879885", "0.6185215", "0.61835957", "0.61835957", "0.61835957", "0.61835957", "0.61835957", "0.61835957", "0.61835957", "0.61835957", "0.6179274", "0.61777055", "0.6156733", "0.6156675", "0.61564595", "0.61550194", "0.61517054", "0.6144048", "0.61417013", "0.61367935", "0.61345124", "0.6125238", "0.61249995", "0.61193806", "0.6118831", "0.61176455" ]
0.6240188
66
PUT /albums/1 PUT /albums/1.json
def update @album = Album.find(params[:id]) respond_to do |format| if @album.update_attributes(params[:album]) flash[:notice] = 'Album was successfully updated.' format.html { redirect_to @album } format.json { head :no_content } else format.html { render action = "edit" } # format.json { render json: @album.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @album = current_user.albums.find(params[:id])\n\n respond_to do |format|\n if @Album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @Album.errors, status: :unprocessable_entity }\n end\n end\n end", "def album\n album = Album.find(params[:id])\n render json: album\n end", "def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n ActiveRecord::Base.transaction do\n @album.update!(name: params[:name])\n @album.album_images.destroy_all\n # 画像登録数が多くなるUIになったらSQLの負荷を減らすためにactiverecord-importを入れる\n # https://github.com/zdennis/activerecord-import\n params[:urls].each do |image_url|\n AlbumImage.create!(album_id: @album.id, url: image_url)\n end\n end\n\n render json: @album\n end", "def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @album = current_account.albums.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n flash[:notice] = 'album was successfully updated.'\n format.html { redirect_to(@album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: \"Album was successfully updated.\" }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_albums\n url = 'https://stg-resque.hakuapp.com/albums.json'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n albums = JSON.parse(response)\n\n albums.each do |album|\n Album.create!(album.except('id'))\n end\nend", "def update\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to album_url(@album), notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @album = Album.find(params[:id])\n \n respond_to do |format|\n if @album.update_attributes(params[:album])\n @album.images.clear\n @album.images << Image.find([params[:images]].flatten)\n @album.save!\n format.html { redirect_to(albums_path, :notice => 'Album was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @album = Album.find(album_params[:id])\n respond_to do |format|\n if @album.update_attributes(album_params)\n flash[:success] = 'The album was successfully updated.'\n format.html { redirect_to edit_album_url(@album.id) }\n format.json { render json: { rows: [@album.marshall], status: 200, total: 1 } }\n else\n base = 'Failed to save the album. '\n flash[:error] = 'An error occured while updating the album.'\n format.html { render action: 'edit', alert: base + @album.errors.full_messages.to_sentence + '.' }\n format.json { render json: { errors: @album.errors, status: :unprocessable_entity } }\n end\n end\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'El album a sido actualizado satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @song.update(song_params)\n album_id = params[\"album\"]\n \n if not album_id.nil?\n album = Album.find_by(id: album_id)\n if not album.nil?\n album.songs << @song\n album.save\n\n artist = album.artist\n\n if not artist.nil?\n artist_id = artist.id\n if not artist_id.nil?\n artist.songs << @song\n artist.save\n end\n end\n end\n end\n \n format.html { redirect_to @song, notice: 'Song was successfully updated.' }\n format.json { render :show, status: :ok, location: @song }\n else\n format.html { render :edit }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @album = Album.find(params[:id])\n if @album.update(album_params)\n flash[:success] = 'Album updated successfully.'\n path = albums_path\n else\n flash[:error] = 'Problem updating album.'\n path = root_path\n end\n redirect_to path\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def update_album(person_id,album_id, caption, location='', privacy='Everyone')\n @restv9.update_album(person_id,album_id, caption, location, privacy)\n end", "def update\n \n @album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to album_photo_path(@album,@photo), :notice => 'Photo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_album\n begin\n @album = Album.find(params[:id])\n rescue ActiveRecord::RecordNotFound => e\n render :json => {error: 'record not found'}, status: :not_found\n end\n end", "def update\n authorize! :update, @album\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to edit_admin_album_path(@album.id), notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @albums = get_current_albums\n respond_to do |format|\n if @photo.update(photo_params)\n format.html { redirect_to photos_url, notice: 'Фотография была успешно обновлена.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @album.update(allowed_params_album)\n format.html { redirect_to @album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to artist_album_url(@artist,@album), notice: 'album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @track_file = TrackFile.find(params[:id])\n\n if @track_file.update(track_file_params)\n @album = Album.find(@track_file.track.album.id)\n render json: @album\n else\n render json: @track_file.errors.full_messages, status: 422\n end\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def destroy\n @album.destroy\n render json: @album\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to band_albums_path(@album.band.id), notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @album }\n else\n format.html { render :edit }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user_album = UserAlbum.find(params[:id])\n\n respond_to do |format|\n if @user_album.update_attributes(params[:user_album])\n format.html { redirect_to @user_album, notice: 'User album was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_album.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_album\n @album = current_user.albums.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:album_id])\n end", "def set_album\n @album = Album.find(params[:album_id])\n end", "def update\n @photo = Photo.find(params[:id])\n @photo.user_id=session[:user_id]\n @photo.album_id= params[:photo][:album_id]\n respond_to do |format|\n if @photo.update_attributes(params[:photo])\n format.html { redirect_to @photo, notice: 'Photo was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_album\n @album = Admin::Album.find(params[:id])\n end", "def set_album\n @album = Admin::Album.find(params[:id])\n end", "def update\n respond_to do |format|\n if @albumone.update(albumone_params)\n format.html { redirect_to @albumone, notice: 'Albumone was successfully updated.' }\n format.json { render :show, status: :ok, location: @albumone }\n else\n format.html { render :edit }\n format.json { render json: @albumone.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @album = Album.find(params[:id])\n\n if @album.update(album_params)\n flash[:success] = \"Album updated!\"\n redirect_to albums_path\n else\n render 'edit'\n end\n end", "def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to(@album, :notice => 'Album was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n authorize @album\n if @album.update(album_params)\n redirect_to @album, notice: 'Album was successfully updated.'\n else\n render :edit\n end\n end", "def update\n respond_to do |format|\n if @album.update(album_params)\n format.html { redirect_to @album, notice: 'アルバム情報を更新しました。' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_album\n @album = Album.find_by(id: params[:id])\n end", "def update\n @image = @album.images.find(params[:id])\n @image.update(image_params)\n redirect_to album_path(@image.album.id)\n end", "def update\n respond_to do |format|\n if @galleries_album.update(galleries_album_params)\n format.html { redirect_to @galleries_album, notice: 'Album was successfully updated.' }\n format.json { render :show, status: :ok, location: @galleries_album }\n else\n format.html { render :edit }\n format.json { render json: @galleries_album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n format.html { redirect_to @album, notice: 'Albumi uuendamine õnnestus' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n flash[:notice] = 'Album was successfully updated.'\n format.html { redirect_to(@album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n flash[:notice] = 'Album was successfully updated.'\n format.html { redirect_to(@album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def updateartists\n @album = Album.find(params[:id])\n album_param = params[:albums]\n @album.artists.delete_all \n album_param[:artists].each do |artist_id|\n artist = Artist.find(artist_id)\n @album.artists << artist \n end \n respond_to do |format|\n format.html { redirect_to(:action => :show) }\n format.xml { head :ok }\n end \n end", "def update\n @album = Album.find_by_id_and_user_id(params[:id], @user)\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n flash[:notice] = 'Album was successfully updated.'\n format.html { redirect_to user_albums_path(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_album\n @album = Album.includes(:photos, :shares).find(params[:id])\n end", "def albums\n if params[:artist_id]\n albums = Artist.find(params[:artist_id]).albums\n else\n albums = Album.all\n end\n render json: albums\n end", "def update\n respond_to do |format|\n if @item_album.update(item_album_params)\n format.html { redirect_to @item_album, notice: 'Item album was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_album }\n else\n format.html { render :edit }\n format.json { render json: @item_album.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_album\n if token = album_token\n @album = Album.find_or_create_by(token: token)\n else\n @album = Album.find_by(uuid: params[:id])\n end\n end", "def update\n @album_owned = AlbumOwned.find(params[:id])\n\n respond_to do |format|\n if @album_owned.update_attributes(params[:album_owned])\n format.html { redirect_to @album_owned, notice: 'Album owned was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @album_owned.errors, status: :unprocessable_entity }\n end\n end\n end", "def album=(v)\n if @album != v\n @needs_commit = true\n @album = v\n end\n end", "def upload\n @album = Album.find( params[:album_id].to_i)\n end", "def destroy\n\n @album = @user.albums.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n expire_fragment :action_suffix => 'homepage_albums'\n flash[:notice] = 'Album was successfully updated.'\n format.html { redirect_to(@album) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_album\n # create an instance variable that can be accessed in\n # every action.\n @album = Album.find(params[:album_id])\n end", "def set_album_photo\n @album_photo = AlbumPhoto.find(params[:id])\n @album = Admin::Album.find(params[:album_id])\n end", "def update\n respond_to do |format|\n if @album_photo.update(album_photo_params)\n format.html { redirect_to @album_photo, notice: 'Album photo was successfully updated.' }\n format.json { render :show, status: :ok, location: @album_photo }\n else\n format.html { render :edit }\n format.json { render json: @album_photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(name, artist, year, genre)\n self.name = name.length > 0 ? name : self.name\n self.artist = artist.length > 0 ? artist : self.artist\n self.year = year.length > 0 ? year : self.year\n self.genre = genre.length > 0 ? genre : self.genre\n @@albums[self.id] = Album.new(self.name, self.artist, self.year, self.genre, self.id)\n end", "def to_api_json\n Jbuilder.encode do |json|\n json.albums do\n json.array! @albums do |album|\n json.call(album, :name, :uuid)\n json.set!(:artist, album.artist_name)\n json.set!(:artist_twitter_screen_name, twitter_screen_name(album))\n json.set!(:thumbnail_url, album.image || album.thumbnail)\n json.set!(:release_date, album.release_date.in_time_zone.to_i)\n json.set!(:release_date_string, album.release_date.to_s)\n json.set!(:age, album.anniversary.count)\n json.set!(:day_of_week, album.anniversary.current.strftime('%A'))\n json.set!(:anniversary, album.anniversary.current.in_time_zone.to_i)\n json.set!(:anniversary_string, album.anniversary.current.to_s)\n json.set!(:review_link, album.link)\n json.set!(:rating, album.rating)\n json.set!(:generated_fun_fact_description, album.generated_fun_fact_description)\n json.set!(:fun_fact_description, album.fun_fact_description)\n json.set!(:fun_fact_source, album.fun_fact_source)\n json.set!(:link, \"/albums/#{album.slug}\")\n json.set!(:update, \"/v1/admin/albums/#{album.id}\")\n end\n end\n end\n end", "def destroy\n @album = current_user.albums.find(params[:id])\n @Album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def index\n @albums = @user.albums\n end", "def update\n\n artist_id = update_artist_exist_or_new(params[:artist_name])\n\n album_id = update_album_exist_or_new(params[:album_name], params[:genre], artist_id)\n\n respond_to do |format|\n\n @song.album_id = album_id\n a = @song.album\n a.artist_id = artist_id\n a.save\n\n if @song.update(song_params)\n format.html { redirect_to @song, notice: 'Song was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @song.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @album = current_user.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def update\n respond_to do |format|\n if @albumsix.update(albumsix_params)\n format.html { redirect_to @albumsix, notice: 'Albumsix was successfully updated.' }\n format.json { render :show, status: :ok, location: @albumsix }\n else\n format.html { render :edit }\n format.json { render json: @albumsix.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @album.update(album_params)\n redirect_to @album, notice: 'Альбом успешно изменён.'\n else\n render :edit\n end\n end", "def set_album_photo\n @album_photo = AlbumPhoto.find(params[:id])\n end", "def update\n @album = Album.find(params[:id])\n\n respond_to do |format|\n if @album.update_attributes(params[:album])\n #flash[:notice] = 'Article was successfully updated.'\n format.html { redirect_to :album=>@album, :action=>\"edit\", :id=>@album.album_id }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @albums = Album.all\n render json: @albums\n end" ]
[ "0.68898857", "0.6792222", "0.6670106", "0.6660307", "0.6606993", "0.6606993", "0.65957916", "0.6580667", "0.6580667", "0.6580667", "0.6578174", "0.6538606", "0.6499689", "0.64891946", "0.64501524", "0.64501524", "0.64501524", "0.6420907", "0.64052725", "0.64043105", "0.6369847", "0.6366644", "0.6366644", "0.6366644", "0.6366644", "0.6366644", "0.63589895", "0.63472664", "0.6343624", "0.63364565", "0.63087296", "0.6280683", "0.6277798", "0.6277227", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6268728", "0.6237141", "0.62362003", "0.6230971", "0.6218395", "0.61938375", "0.61938375", "0.61928034", "0.61843884", "0.61843884", "0.61810344", "0.61761594", "0.61747956", "0.61664546", "0.6152592", "0.6138999", "0.61200213", "0.6118861", "0.6114816", "0.6104679", "0.6104679", "0.6103069", "0.6093274", "0.6091521", "0.60629386", "0.6040827", "0.60354453", "0.60283536", "0.60055417", "0.6001441", "0.59923804", "0.59554076", "0.59470516", "0.58988774", "0.58888197", "0.5885509", "0.58835185", "0.5883205", "0.58821416", "0.58759713", "0.5870056", "0.58631283", "0.5855444", "0.58535284", "0.5853146", "0.5849648" ]
0.63631684
26
DELETE /albums/1 DELETE /albums/1.json
def destroy @album = Album.find(params[:id]) @album.destroy # Dir.chdir("public/images") Dir.delete(@album['directory']) respond_to do |format| format.html { redirect_to albums_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n\n @album = @user.albums.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n render json: @album\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :ok }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album = current_user.albums.find(params[:id])\n @Album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @albums = Album.all\n @album = Album.find(params[:id])\n @album.destroy\n \n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { render json: { status: 200 } }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \t@album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :ok }\n end\n end", "def destroy\n @album = current_account.albums.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @user_album = UserAlbum.find(params[:id])\n @user_album.destroy\n\n respond_to do |format|\n format.html { redirect_to user_albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photoalbum = Photoalbum.find(params[:id])\n @photoalbum.destroy\n\n respond_to do |format|\n format.html { redirect_to photoalbums_url }\n format.json { head :ok }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album erfolgreich gelöscht.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: \"Album was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'El album a sido removido satisfactoriamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n# @album = Album.find(params[:id])\n# @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @private_album.destroy\n respond_to do |format|\n format.html { redirect_to private_albums_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n\t@album = Album.find(@photo.album_id)\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to album_path(@album) }\n format.json { head :ok }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to user_albums_path(@user) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @album = Album.find(params[:id])\r\n @album.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to user_albums_path(session[:user_id]),:notice => \"Your Album has been successfully Deleted\" }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n album=@photo.album\n @photo.destroy\n save_to_json\n respond_to do |format|\n format.html { redirect_to album_path(album), notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_album album_id\n delete(\"/albums/#{album_id}\", code: 204)\n end", "def destroy\n @photo = Photo.find(params[:id])\n @album = @photo.album\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_album_url(@album) }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n redirect_to root_url\n end", "def destroy\n @albumone.destroy\n respond_to do |format|\n format.html { redirect_to albumones_url, notice: 'Albumone was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n respond_to do |format|\n format.html { redirect_to albums_url, notice: \"Pagealbum was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @albumm = Albumm.find(params[:id])\n @albumm.destroy\n\n respond_to do |format|\n format.html { redirect_to albumms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @galleries_album.destroy\n respond_to do |format|\n format.html { redirect_to galleries_albums_url, notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @album = @photo.album_id\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to album_photos_path, notice: \"Photo was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @item_album.destroy\n respond_to do |format|\n format.html { redirect_to(:back) }\n format.json { head :no_content }\n end\n end", "def destroy\n @albumsix.destroy\n respond_to do |format|\n format.html { redirect_to albumsixes_url, notice: 'Albumsix was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo_album.destroy\n\n respond_to do |format|\n format.html { redirect_to(photo_albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @album_owned = AlbumOwned.find(params[:id])\n @album_owned.destroy\n\n respond_to do |format|\n format.html { redirect_to album_owneds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album_item = AlbumItem.find(params[:id])\n @album_item.destroy\n\n respond_to do |format|\n format.html { redirect_to album_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n @album = @photo.album\n\n respond_to do |format|\n format.html { redirect_to @album, notice: \"写真を削除しました。\" }\n format.json { head :ok }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(@album) }\n format.xml { head :ok }\n end\n end", "def destroy\n @photo_album = PhotoAlbum.find(params[:id])\n @photo_album.destroy\n\n respond_to do |format|\n format.html { redirect_to(photo_albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @album_photo.destroy\n respond_to do |format|\n format.html { redirect_to album_photos_url, notice: 'Album photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n alb=@photo.album\n @photo.destroy\n respond_to do |format|\n format.html { redirect_to alb, notice: 'Фотография успешно удалена.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @albumfife.destroy\n respond_to do |format|\n format.html { redirect_to albumfives_url, notice: 'Albumfive was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album = Album.find(params[:id])\n \n album_path = ALBUMS_ROOT + @album.name\n if(File.exists?(album_path))\n FileUtils.remove_dir(album_path)\n end\n\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n # authorize\n authorize! :delete, @album\n @album.destroy\n \n render nothing:true\n flash[:notice] = 'Xóa album thành công.'\n end", "def destroy\n @foto_album = FotoAlbum.find(params[:id])\n @foto_album.destroy\n\n respond_to do |format|\n format.html { redirect_to(foto_albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @albumseven.destroy\n respond_to do |format|\n format.html { redirect_to albumsevens_url, notice: 'Albumseven was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n respond_to do |format|\n if @album.destroy\n format.html { redirect_to artist_albums_url, notice: 'album was successfully destroyed.' }\n format.json { head :no_content }\n else\n format.html { render action: 'delete' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @album2photo = Album2photo.find(params[:id])\n @album2photo.destroy\n\n respond_to do |format|\n format.html { redirect_to album2photos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @interior_album.destroy\n respond_to do |format|\n format.html { redirect_to interior_albums_url, notice: 'Interior design album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @albumfour.destroy\n respond_to do |format|\n format.html { redirect_to albumfours_url, notice: 'Albumfour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete()\n sql = \"DELETE FROM albums\n WHERE id = $1;\"\n values = [@id]\n SqlRunner.run( sql, values )\n end", "def destroy\n @album_follow.destroy\n respond_to do |format|\n format.html { redirect_to album_follows_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n redirect_to albums_url, notice: 'Альбом успешно удалён.'\n end", "def destroy\n\t\t# binding.pry\n\t\t@useralbum.destroy_all\n\t\tredirect_to user_albums_path\n \tend", "def destroy\n @photo = @allbum.photos.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to allbum_photos_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @album.destroy\n flash[:notice] = 'Album was successfully removed.'\n redirect_to(albums_url)\n end", "def destroy\n @album = Album.find(params[:id])\n @album.images.clear\n @album.save!\n @album.destroy\n Image.all(:conditions => {:album_id => params[:id]}).each do |x| \n x.album_id = nil\n x.save\n end\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @user = current_user\n @customer = @user.customers.find(params[:customer_id])\n @album = @customer.albums.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @photo.destroy\n\n render :json => true\n end", "def destroy\n @private_album_image.destroy\n respond_to do |format|\n format.html { redirect_to private_album_images_url }\n format.json { head :no_content }\n end\n end", "def destroy\n AlbumOwnership.find_by({album_id: @album.id, user_id: current_user.id}).destroy\n end", "def destroy\n @album_information.destroy\n respond_to do |format|\n format.html { redirect_to album_informations_url, notice: 'Album information was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_album\n @album = Album.find(params[:id])\n @album.destroy\n \n respond_to do |format|\n format.js\n end\n end", "def destroy\n @artist.destroy_songs\n @artist.albums.destroy_all\n @artist.destroy\n respond_to do |format|\n format.html { redirect_to artists_url, notice: 'Artist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @palbum = Palbum.find(params[:id])\n @palbum.destroy\n \n end", "def destroy\n @album = @track.album\n @track.destroy\n redirect_to album_tracks_url(@album)\n end", "def destroy\n @album.destroy\n @activity = PublicActivity::Activity.find_by(trackable_id: (params[:id]), trackable_type: controller_path.classify)\n @activity.destroy\n respond_to do |format|\n format.html { redirect_to band_albums_url(@album.band.id), notice: 'Album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find( params[:id])\n @album = @photo.album\n if @photo.destroy\n if params[:bucket_id]\n redirect_to bucket_album_path( params[:bucket_id], @album )\n else\n redirect_to @album\n end\n else\n redirect_to @photo\n end\n end", "def destroy\n @album = Album.find(params[:album_id])\n @photo = @album.photos.find(params[:id])\n @comments = @photo.comments.all\n @comments.each do |cmt|\n cmt.destroy\n end\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to album_path(@album) }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to user_album_photos_url(@user, @album) }\n format.xml { head :ok }\n end\n end", "def delete\n sql = \"DELETE FROM albums WHERE id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\nend", "def destroy\n @album_pub.destroy\n respond_to do |format|\n format.html { redirect_to album_pubs_url, notice: 'Album pub was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n unless editable(current_user, @album.user)\n redirect_back fallback_location: root_path, alert: '削除権限がありません。'\n return\n end\n @album.destroy\n\n respond_to do |format|\n format.html { redirect_to albums_url, notice: 'アルバムを削除しました' }\n format.json { head :ok }\n end\n end", "def destroy\n @album_genre = AlbumGenre.find(params[:id])\n @album_genre.destroy\n\n respond_to do |format|\n format.html { redirect_to album_genres_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @wedding_album.destroy\n respond_to do |format|\n format.html { redirect_to wedding_albums_url, notice: 'Wedding album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @album_listing.destroy\n respond_to do |format|\n format.html { redirect_to album_listings_url, notice: 'Album listing was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @favorite_album.destroy\n respond_to do |format|\n format.html { redirect_to favorite_albums_url, notice: 'Favorite album was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @picture = @album.pictures.find(params[:id]) #JRD111115\n @picture.destroy\n respond_to do |format|\n format.html { redirect_to album_pictures_url(@album), notice: 'Picture was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo = Photo.find(params[:id])\n gallery = @photo.gallery\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to gallery_path(gallery) }\n format.json { head :no_content }\n end\n end", "def destroy\n @photo.destroy\n respond_to do |format|\n format.html { redirect_back fallback_location: @photo.album, notice: 'Photo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @album = Album.find(params[:album_id])\n @image = @album.images.find(params[:id])\n @image.destroy\n redirect_to album_path(@image.album.id), notice: \"The image #{@image.name} has been deleted.\"\n end", "def destroy\n @album = Album.find(params[:id])\n @album.destroy\n expire_fragment :action_suffix => 'homepage_albums'\n\n respond_to do |format|\n format.html { redirect_to(albums_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @musica.audios.purge\n @musica.destroy\n respond_to do |format|\n format.html { redirect_to musicas_url, notice: 'Álbum apagado com sucesso!' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to photos_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.801051", "0.79122156", "0.7840477", "0.77915406", "0.77915406", "0.77915406", "0.77915406", "0.77915406", "0.7785304", "0.7780388", "0.7775917", "0.77713436", "0.77632475", "0.77632475", "0.77632475", "0.7684608", "0.7640788", "0.7640206", "0.76009154", "0.7557025", "0.75467694", "0.754556", "0.754556", "0.754556", "0.754556", "0.7542386", "0.752702", "0.7499952", "0.7499952", "0.7499952", "0.7499952", "0.74923575", "0.7473925", "0.745713", "0.7453086", "0.7441748", "0.7432717", "0.74241966", "0.740804", "0.740734", "0.7402739", "0.7400599", "0.73883563", "0.7375271", "0.7359508", "0.7351968", "0.7349126", "0.733627", "0.73284274", "0.7318021", "0.73037946", "0.730107", "0.7288504", "0.7287806", "0.72454154", "0.7213201", "0.7207476", "0.7203538", "0.720169", "0.71851456", "0.71678424", "0.7157683", "0.7132293", "0.7116471", "0.7114639", "0.71000147", "0.7087597", "0.70812315", "0.70593905", "0.7039737", "0.70346594", "0.7022105", "0.701625", "0.6952559", "0.6939667", "0.69383836", "0.69328195", "0.6927591", "0.69084555", "0.6903124", "0.6884039", "0.68836343", "0.6882491", "0.6863932", "0.6799133", "0.67975944", "0.6787477", "0.6779844", "0.67683417", "0.6759638", "0.67548805", "0.6750414", "0.6749929", "0.67497134", "0.6745255", "0.6701014", "0.66926056", "0.66847914", "0.66363126", "0.66154945" ]
0.71876234
59
GET /suggested_ages GET /suggested_ages.json
def index @suggested_ages = SuggestedAge.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_suggested_age\n @suggested_age = SuggestedAge.find(params[:id])\n end", "def suggested_age_params\n params.require(:suggested_age).permit(:name)\n end", "def index_by_age_sorted_by_price\n @age = Age.find(params[:age_id])\n @gifts = @age.gifts\n render json: @gifts, include: :ages, status: :ok\n end", "def suggested_people\n SuggestedPeople.people(@api_key, @https)\n end", "def index_by_age\n @age = Age.find(params[:age_id])\n @gifts = @age.gifts\n render json: @gifts, include: :ages, status: :ok\n end", "def teachers\n url = drop_url_version + \"/count/teacherAssociations/#{params['edorg_id']}/teachers\"\n begin\n entities = RestClient.get(url, get_header)\n entities = JSON.parse(entities)\n rescue => e\n logger.info(\"Could not get ed orgs for #{entities} because of #{e.message}\")\n end\n \n respond_to do |format|\n format.json { render json: entities }\n end\n end", "def show\n @gage = Gage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gage }\n end\n end", "def update\n respond_to do |format|\n if @suggested_age.update(suggested_age_params)\n format.html { \n flash[:notice] = 'La edad sugerida se actualizó satisfactoriamente.'\n redirect_to suggested_ages_path\n }\n format.json { render :show, status: :ok, location: @suggested_age }\n else\n format.html { render :edit }\n format.json { render json: @suggested_age.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n order = sortable_column_order, \"gage_number desc\"\n @gages = Gage.paginate page: params[:page], order: order, per_page: 50\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gages }\n end\n end", "def predictions\n raise \"Err\"\n buyer_suggestions = PropertyBuyer.suggest_buyers(params[:str]).select([:id, :name, :image_url]).limit(20)\n render json: buyer_suggestions, status: 200\n end", "def create\n @suggested_age = SuggestedAge.new(suggested_age_params)\n\n respond_to do |format|\n if @suggested_age.save\n format.html { \n flash[:notice] = 'La edad sugerida se creó satisfactoriamente.'\n redirect_to suggested_ages_path\n }\n format.json { render :show, status: :created, location: @suggested_age }\n else\n format.html { render :new }\n format.json { render json: @suggested_age.errors, status: :unprocessable_entity }\n end\n end\n end", "def ratings\n Birdman::Requester.get(\"movies/#{id}/ratings\")\n end", "def index\n @recommendeds = Recommended.all\n end", "def index_by_user\n @gifts = @current_user.gifts\n render json: @gifts, include: :ages, status: :ok\n end", "def badges\n get(\"user/#{user_id}/badges.json\")\n end", "def earned(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"]\n end", "def suggested_people(lang)\n request('/suggestedPeople', {body: {languages: lang}})\n end", "def recommendations\n\t @recommendations = Restaurant.find(params[:id]).recommendations\n\t \n\t respond_to do |format|\n\t\t format.html # recommendations.html.erb\n\t \t format.json { render json: @recommendations.to_json(except: [ :created_at, :updated_at ]) }\n\t end\n end", "def index\n @suggestions = Suggestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @suggestions }\n end\n end", "def show\n @recommendation = Recommendation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recommendation }\n end\n end", "def show\n @article = Article.find(params[:id])\n @rating = Rating.new\n \n #limited to first 5\n @related_articles = @article.find_related_tags.limit(5)\n \n @ratings = @article.ratings\n @quality = quality_avg(@ratings)\n @interest = interest_avg(@ratings)\n @readagain = readagain_avg(@ratings)\n @words = get_words(@ratings)\n \n \n \n @title = \"Specialties of the Day\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @article }\n end\n end", "def index_single_gift\n render json: @gift, include: :ages, status: :ok\n end", "def index\n @recommended_links = RecommendedLink.all\n\n render json: @recommended_links\n end", "def show\n @earned_award = EarnedAward.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @earned_award }\n end\n end", "def recommend_a_place\n # 1- Find the person we are giving the recommendation to (determined by the user_id)\n # 2- Calculate the total VALUE that each place has for that given user (algorithm)\n # 3- Sort by value the array of recommended places\n # 4- Return the data for the user and the array of recommended places in the specified format \n if params[:user_id]\n @person = User.find(params[:user_id])\n else \n wrong_user_id = true\n end\n \n unless wrong_user_id\n # The algorithm to calculate the total VALUE of each place returns an array of arrays, where the 1st element is the value\n # of the place which is in the 2nd element.\n array_values_places = calculate_value_of_places(@person)\n @sorted_array_values_places = array_values_places.sort_by { |e| e[0] }.reverse\n\n respond_to do |format|\n if wrong_user_id\n format.json { render :json => { :status => \"Error\", :response => {} }}\n else\n format.json { render :file => \"places/recommend_a_place.json.erb\", :content_type => 'application/json' }\n end\n end\n end \n \n end", "def index\n @drugs = Drug.all\n # @permitted_drugs = Drug.permitted.alphabetical.all\n # @prohibited_drugs = Drug.prohibited.alphabetical.all\n # @restricted_drugs = Drug.restricted.alphabetical.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drugs }\n end\n end", "def index\n @garnishes = Garnish.where(\"LOWER(name) like ?\", \"%#{params[:q] ? params[:q].downcase : ''}%\").paginate(:page => params[:page], :per_page => 198).order(:name)\n respond_to do |format|\n format.html\n format.json {render :json => @garnishes.map(&:attributes)}\n end\n end", "def index\n @votes = @proposal.votes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @votes }\n end\n end", "def suggestions\n response.try(:[], \"suggest\").try(:[], @suggest_key).try(:[], request_params[:q]).try(:[], \"suggestions\") || []\n end", "def index\n @practices = Practice.order(\"practice_name\").paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @practices }\n end\n end", "def list_suggestvenues(id)\n get(\"lists/#{id}/suggestvenues\").suggestedVenues\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 recommended\n @users = popular_users\n\n all_plucked_tags_photo_ids = []\n @tags = popular_tags.map do |tag|\n current_tag_photo_ids = tag.photo_ids\n all_plucked_tags_photo_ids += current_tag_photo_ids[0..7]\n [tag.name, current_tag_photo_ids[0..7]]\n end\n\n @photos = Photo\n .includes(:tags, :likers, :author)\n .where(id: all_plucked_tags_photo_ids)\n\n render :recommended\n end", "def show\n @target_age = TargetAge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @target_age }\n end\n end", "def upvoted\n suggestions = Suggestion.includes(:place).joins(:votes).where(\"votes.direction = 1 AND votes.user_id = ?\", session[:user_id])\n render json: suggestions.to_json(:include => [:place])\n end", "def index\n @teachers = Teacher.order(:tea_no).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @teachers }\n end\n end", "def index\n @guides = Guide.page(1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: {:guides => @guides.as_json} }\n end\n end", "def list\n\t\t# see also as_json overrides in the models\n\t\trender json: load_suggestions(suggestion_params[:avatar_id])\t\t \n end", "def index\n @recent = Highfive.recent.approved\n @leaders = User.leaders\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @highfives }\n end\n end", "def meals\n get(\"/user/#{@user_id}/meals.json\")\n end", "def suggestions\n suggest_response['suggest'].values.first[q]['suggestions']\n .uniq { |s| s['term'].downcase }\n .sort_by { |s| (-s['weight']) * 100 + s['term'].length }\n .take(5)\n end", "def new\n @suggestion = Suggestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @suggestion }\n end\n end", "def show\n @available_improvements = params[:available_improvements]\n end", "def show\n if params[:yelp_rating] && params[:google_rating] && params[:foursquare_rating]\n @ratings = {:yelp_rating => params[:yelp_rating], :foursquare_rating => params[:foursquare_rating], :google_rating => params[:google_rating], :weighted_rating => params[:weighted_rating]}\n end\n @social = {:yelp_id => params[:yelp_id], :foursquare_id => params[:foursquare_id], :google_id => params[:google_id]}\n if params[:google_id]\n @google_place = Restaurant.get_place_from_google params[:google_id]\n @google_reviews = @google_place.reviews\n @google_images = []\n @google_reviews.each do |review|\n str = review.author_url.to_s\n google_plus_id = str[24..-1]\n request = \"https://www.googleapis.com/plus/v1/people/\" + \"#{google_plus_id}\" + \"?fields=image&key=AIzaSyB8fUZUPNYIWKwz6Nss-Hu7J_2VUjFSOWA\"\n response = HTTParty.get(request)\n result = JSON.parse(response.body)\n\n if result[\"image\"]\n @google_images << result[\"image\"][\"url\"]\n else\n @google_images << nil\n end\n end\n\n end\n @yelp_reviews = Restaurant.get_restaurant_reviews_from_yelp params[:yelp_id]\n @foursquare_tips = Restaurant.get_venue_tips_from_foursquare params[:foursquare_id]\n \n @friend_recommendations = Recommendation.get_friend_recommedation_by_restaurant(params[:google_id], @registered_friends)\n end", "def popular\n @posts = Post.all.includes(:user, :endorsements, :advices).limit(15).sort_by {|x| x.endorsements.length}.reverse!\n\n render json: @posts\n end", "def show\n @rating_alt = Rating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rating_alt }\n end\n end", "def show\n @advocacy = Advocacy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advocacy }\n end\n end", "def trends_available\n get(\"/trends/available.json\")\n end", "def review\n @t = T\n @t = @t.paginate :page => params[:page], :per_page => params[:per_page]\n @data = @t.meanings\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @t }\n end\n end", "def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend", "def restaurant_suggestions\n match_key = Riddle.escape(params[:key]).split(' ').join('* ') + '*'\n begin\n suggestions = Restaurant.search(match_key,{:limit=>20,:match_mode => :extended,\n :ignore_errors=>true,:populate=>true,:retry_stale=>true})\n rescue Exception\n suggestions = []\n end\n response = []\n suggestions.each{|d| response << {:value=>d.id,:label=>d.name}}\n render :json=>response.to_json\n end", "def show\n @recommend = Recommend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recommend }\n end\n end", "def show\n @prefer = Prefer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prefer }\n end\n end", "def index\n @proposals = listing.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end", "def index\n @meal_ratings = MealRating.all\n end", "def available_trends\n get(\"/trends/available.json\")\n end", "def show\n @needed_good = NeededGood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @needed_good }\n end\n end", "def index\n @garrages = Garrage.all\n end", "def index\n @ideas = Idea.all\n\n render json: @ideas\n end", "def rating(food)\n url = 'https://thereportoftheweek-api.herokuapp.com/reports'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n result = JSON.parse(response)\n puts result[7]['product']\n \n end", "def index\n @talk_suggestions = TalkSuggestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talk_suggestions }\n end\n end", "def votes(options = {})\n get('/votes', options)\n end", "def show\n @judgement = Judgement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @judgement }\n end\n end", "def show\n @judgement = Judgement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @judgement }\n end\n end", "def index\n @goal_rewards = user.goal_rewards\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goal_rewards }\n end\n end", "def show\n @skill_suggestion = SkillSuggestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill_suggestion }\n end\n end", "def people\n Birdman::Requester.get(\"movies/#{id}/people\")\n end", "def highest_averages\n @averages = Matchup.joins(:cornbowler).\n select(\"cornbowlers.name AS cornbowler_name, COUNT(*) AS count, AVG(matchups.final_score) AS average_score\").\n where(\"final_score IS NOT NULL\").\n group(\"cornbowler_name\").\n order(\"average_score DESC, cornbowler_name ASC\").\n limit(25)\n @averages_with_rank = object_hash_with_rank(@averages, :average_score)\n\n respond_to do |format|\n format.html # highest_averages.html.erb\n format.json { render json: @averages }\n end\n end", "def show\n @hospital_suggestion = HospitalSuggestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hospital_suggestion }\n end\n end", "def show\n compile_reviews(@gamer.id)\n scores = Gamer.compute_ratings(@reviews)\n Gamer.compute_overall_rating(scores)\n update_scores(scores, @gamer)\n render json: {gamer: @gamer, reviews: @reviews}\n end", "def index\n @ideas = current_user.ideas.page(params[\"page\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end", "def list_ideas\n json_out(Idea.all)\n end", "def list_ideas\n json_out(Idea.all)\n end", "def list_ideas\n json_out(Idea.all)\n end", "def show\n @related_desires = Desire.tagged_with(@desire.tags).excludes(id: @desire.id).desc(:created_at).limit(9)\n #TODO incorrect sorting\n @solutions = @desire.solutions.desc(:score, :created_at).page(params[:page]).per(ITEMS_PER_PAGE_FEW) #.uniq{|s| s.identity} #.to_a.reject{|s| s.item.blank? || s.item.get_image_url.blank?}\n\n @modes = [\"solutions\", \"comments\"]\n set_mode(:personal_mode, @modes, params[:mode], \"solutions\")\n\n #votes = @solutions.inject([]){|memo, s| memo | s.votes }.sort{|x, y| y.created_at <=> x.created_at}\n #@my_vote = votes.select{|v| v.voter_id == current_user.id.to_s}.first if current_user\n\n #dummy ojbect for new_solution_field\n #dummy = Solution.new\n #if @solutions.empty?\n # @solutions += [dummy]\n #else\n # @solutions = @solutions.each_slice(8).inject([]){|memo, group| memo + (group << dummy)}\n #end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @desire }\n end\n end", "def index\n @proposals = Proposal.all\n\n render json: @proposals\n end", "def index\n @ideas = Idea.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end", "def index\n @proposals = current_user.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end", "def show\n @team_rating = TeamRating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team_rating }\n end\n end", "def index\n @ideas = Idea.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end", "def badges(id)\n get(\"users/#{id}/badges\")\n end", "def suggest\n tags = Tag.where('tags.name LIKE ?', \"#{params[:q]}%\").limit(10).order(:name)\n\n render json: {\n results: tags.map { |tag|\n {\n id: tag.name,\n text: \"#{tag.name} (#{tag.count})\"\n }\n },\n }\n end", "def recommendations\n check_preference_setup \n check_last_played_time\n add_personality_recommendations\n\n @recommendations\n end", "def index\n @photos = Photo.find_with_reputation(:votes, :all, order: 'votes desc')\n @photos = Kaminari.paginate_array(@photos).page(params[:page]).per(4)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @photos }\n end\n end", "def new\n @gage = Gage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gage }\n end\n end", "def swagger \n critiq_rating + like_rating\n end", "def show\n @suggestion = Suggestion.new\n @suggestion.game = Game.find_by_slug(params[:id])\n @suggestion.user = current_user\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @suggestion }\n end\n end", "def show\n @goal_reward = GoalReward.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal_reward }\n end\n end", "def show\n @reviews = @dog.reviews\n @rating = Review.get_average_rating(@dog)\n end", "def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend", "def dosages\n @formulation = (params[:formulation] || '')\n drug = Drug.find_by_name(@formulation) rescue nil\n render :text => \"No matching drugs found for #{params[:formulation]}\" and return unless drug\n\n @frequency = (params[:frequency] || '')\n\n # Grab the 10 most popular dosages for this drug\n amounts = []\n amounts << \"#{drug.dose_strength}\" if drug.dose_strength \n orders = DrugOrder.where({:drug_inventory_id => drug.id, :frequency => @frequency}).order(\"count(*)\").group(\"drug_inventory_id, dose\").limit(10)\n orders.each {|order|\n amounts << \"#{order.dose}\"\n } \n amounts = amounts.flatten.compact.uniq\n render plain: \"<li>\" + amounts.join(\"</li><li>\") + \"</li>\"\n end", "def badges(options={})\n get('/user_badge', options)\n end", "def index\n @collection = current_user.collections.find(params[:collection_id]) \n @recommenders = @collection.recommenders.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recommenders }\n end\n end", "def index\n @idea = Idea.find(params[:idea_id])\n #@idea_ratings = IdeaRating.all\n end", "def show\n @talk_suggestion = TalkSuggestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @talk_suggestion }\n end\n end", "def show\n @article = Article.includes(:categories).find(params[:id])\n @related_articles = @article.get_most_related_articles(3)\n\n @rating = Rating.new if @article.rateable?\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @article }\n end\n end", "def show\n @deed = Deed.find(params[:id])\n @deed_score = DeedVote.group('deed_id').sum(:votes, :conditions =>['deed_id = ?', params[:id]])\n render :json => @deed.attributes.merge(@deed_score)\n #render json: @deed\n end", "def index\n @pagy, @gists = pagy(@user.gists.accessible_by(current_ability))\n end", "def show\n @drug = Drug.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drug }\n end\n end", "def index\n @guides = Guide.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: @guides }\n end\n end" ]
[ "0.64890534", "0.617056", "0.58913225", "0.58588105", "0.5774988", "0.57044846", "0.5673096", "0.5631754", "0.55987513", "0.5589724", "0.55795664", "0.55722576", "0.5570519", "0.5561018", "0.5551909", "0.55376065", "0.55047417", "0.54952925", "0.5468958", "0.5448533", "0.5438863", "0.54084426", "0.5396569", "0.5392788", "0.538902", "0.5381208", "0.53533816", "0.5325109", "0.530314", "0.5301122", "0.5297415", "0.5295679", "0.5277782", "0.5265814", "0.5263753", "0.52610576", "0.5257866", "0.52572006", "0.5252476", "0.5251022", "0.5249046", "0.52415556", "0.523377", "0.52319354", "0.5227574", "0.5227061", "0.52269125", "0.5217009", "0.5214703", "0.5205318", "0.5203252", "0.5201293", "0.5199826", "0.5190905", "0.5184357", "0.51813513", "0.51778215", "0.5177682", "0.51759726", "0.51756847", "0.51745754", "0.51731306", "0.51675105", "0.51675105", "0.51445794", "0.51436573", "0.5141803", "0.5141154", "0.5136308", "0.51354915", "0.51339144", "0.51231307", "0.51231307", "0.51231307", "0.51206946", "0.51201135", "0.51053864", "0.5104154", "0.5104081", "0.5102733", "0.5099765", "0.50928414", "0.50911355", "0.5090386", "0.5090315", "0.50852054", "0.50823724", "0.50810325", "0.5077007", "0.50769323", "0.5067867", "0.5066018", "0.50641817", "0.5061616", "0.50575167", "0.50507575", "0.5049118", "0.5048648", "0.5048608", "0.5048297" ]
0.7210646
0
GET /suggested_ages/1 GET /suggested_ages/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @suggested_ages = SuggestedAge.all\n end", "def set_suggested_age\n @suggested_age = SuggestedAge.find(params[:id])\n end", "def suggested_age_params\n params.require(:suggested_age).permit(:name)\n end", "def show\n @gage = Gage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gage }\n end\n end", "def index_by_age\n @age = Age.find(params[:age_id])\n @gifts = @age.gifts\n render json: @gifts, include: :ages, status: :ok\n end", "def index_by_age_sorted_by_price\n @age = Age.find(params[:age_id])\n @gifts = @age.gifts\n render json: @gifts, include: :ages, status: :ok\n end", "def update\n respond_to do |format|\n if @suggested_age.update(suggested_age_params)\n format.html { \n flash[:notice] = 'La edad sugerida se actualizó satisfactoriamente.'\n redirect_to suggested_ages_path\n }\n format.json { render :show, status: :ok, location: @suggested_age }\n else\n format.html { render :edit }\n format.json { render json: @suggested_age.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @suggested_age = SuggestedAge.new(suggested_age_params)\n\n respond_to do |format|\n if @suggested_age.save\n format.html { \n flash[:notice] = 'La edad sugerida se creó satisfactoriamente.'\n redirect_to suggested_ages_path\n }\n format.json { render :show, status: :created, location: @suggested_age }\n else\n format.html { render :new }\n format.json { render json: @suggested_age.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @recommendation = Recommendation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recommendation }\n end\n end", "def show\n @earned_award = EarnedAward.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @earned_award }\n end\n end", "def show\n @target_age = TargetAge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @target_age }\n end\n end", "def ratings\n Birdman::Requester.get(\"movies/#{id}/ratings\")\n end", "def earned(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"]\n end", "def index_single_gift\n render json: @gift, include: :ages, status: :ok\n end", "def index\n order = sortable_column_order, \"gage_number desc\"\n @gages = Gage.paginate page: params[:page], order: order, per_page: 50\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @gages }\n end\n end", "def show\n @rating_alt = Rating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rating_alt }\n end\n end", "def show\n @advocacy = Advocacy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advocacy }\n end\n end", "def show\n @prefer = Prefer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @prefer }\n end\n end", "def badges\n get(\"user/#{user_id}/badges.json\")\n end", "def index_by_user\n @gifts = @current_user.gifts\n render json: @gifts, include: :ages, status: :ok\n end", "def show\n @needed_good = NeededGood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @needed_good }\n end\n end", "def index\n @recommendeds = Recommended.all\n end", "def new\n @suggestion = Suggestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @suggestion }\n end\n end", "def show\n @article = Article.find(params[:id])\n @rating = Rating.new\n \n #limited to first 5\n @related_articles = @article.find_related_tags.limit(5)\n \n @ratings = @article.ratings\n @quality = quality_avg(@ratings)\n @interest = interest_avg(@ratings)\n @readagain = readagain_avg(@ratings)\n @words = get_words(@ratings)\n \n \n \n @title = \"Specialties of the Day\"\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @article }\n end\n end", "def show\n @judgement = Judgement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @judgement }\n end\n end", "def show\n @judgement = Judgement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @judgement }\n end\n end", "def recommendations\n\t @recommendations = Restaurant.find(params[:id]).recommendations\n\t \n\t respond_to do |format|\n\t\t format.html # recommendations.html.erb\n\t \t format.json { render json: @recommendations.to_json(except: [ :created_at, :updated_at ]) }\n\t end\n end", "def show\n @recommend = Recommend.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recommend }\n end\n end", "def show\n @goal_reward = GoalReward.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @goal_reward }\n end\n end", "def predictions\n raise \"Err\"\n buyer_suggestions = PropertyBuyer.suggest_buyers(params[:str]).select([:id, :name, :image_url]).limit(20)\n render json: buyer_suggestions, status: 200\n end", "def new\n @gage = Gage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gage }\n end\n end", "def show\n @drug = Drug.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @drug }\n end\n end", "def teachers\n url = drop_url_version + \"/count/teacherAssociations/#{params['edorg_id']}/teachers\"\n begin\n entities = RestClient.get(url, get_header)\n entities = JSON.parse(entities)\n rescue => e\n logger.info(\"Could not get ed orgs for #{entities} because of #{e.message}\")\n end\n \n respond_to do |format|\n format.json { render json: entities }\n end\n end", "def recommend_a_place\n # 1- Find the person we are giving the recommendation to (determined by the user_id)\n # 2- Calculate the total VALUE that each place has for that given user (algorithm)\n # 3- Sort by value the array of recommended places\n # 4- Return the data for the user and the array of recommended places in the specified format \n if params[:user_id]\n @person = User.find(params[:user_id])\n else \n wrong_user_id = true\n end\n \n unless wrong_user_id\n # The algorithm to calculate the total VALUE of each place returns an array of arrays, where the 1st element is the value\n # of the place which is in the 2nd element.\n array_values_places = calculate_value_of_places(@person)\n @sorted_array_values_places = array_values_places.sort_by { |e| e[0] }.reverse\n\n respond_to do |format|\n if wrong_user_id\n format.json { render :json => { :status => \"Error\", :response => {} }}\n else\n format.json { render :file => \"places/recommend_a_place.json.erb\", :content_type => 'application/json' }\n end\n end\n end \n \n end", "def show\n @hospital_suggestion = HospitalSuggestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hospital_suggestion }\n end\n end", "def index\n @suggestions = Suggestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @suggestions }\n end\n end", "def suggested_people\n SuggestedPeople.people(@api_key, @https)\n end", "def show\n @team_rating = TeamRating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team_rating }\n end\n end", "def index\n @votes = @proposal.votes\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @votes }\n end\n end", "def index\n @recommended_links = RecommendedLink.all\n\n render json: @recommended_links\n end", "def index\n @garnishes = Garnish.where(\"LOWER(name) like ?\", \"%#{params[:q] ? params[:q].downcase : ''}%\").paginate(:page => params[:page], :per_page => 198).order(:name)\n respond_to do |format|\n format.html\n format.json {render :json => @garnishes.map(&:attributes)}\n end\n end", "def show\n @meal_preference = MealPreference.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meal_preference }\n end\n end", "def index\n @drugs = Drug.all\n # @permitted_drugs = Drug.permitted.alphabetical.all\n # @prohibited_drugs = Drug.prohibited.alphabetical.all\n # @restricted_drugs = Drug.restricted.alphabetical.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drugs }\n end\n end", "def rating(food)\n url = 'https://thereportoftheweek-api.herokuapp.com/reports'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n result = JSON.parse(response)\n puts result[7]['product']\n \n end", "def meals\n get(\"/user/#{@user_id}/meals.json\")\n end", "def index\n @guides = Guide.page(1)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: {:guides => @guides.as_json} }\n end\n end", "def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend", "def show\n @skill_suggestion = SkillSuggestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skill_suggestion }\n end\n end", "def show\n @early_pregnancy = EarlyPregnancy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @early_pregnancy }\n end\n end", "def show\n @personnage = Personnage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @personnage }\n end\n end", "def new\n @earned_award = EarnedAward.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @earned_award }\n end\n end", "def index\n @recent = Highfive.recent.approved\n @leaders = User.leaders\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @highfives }\n end\n end", "def index\n @meal_ratings = MealRating.all\n end", "def show\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @practice }\n end\n end", "def show\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @practice }\n end\n end", "def show\n @participant_rating = ParticipantRating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant_rating }\n end\n end", "def show\n @recommendation = Recommendation.find(params[:id])\n end", "def show\n compile_reviews(@gamer.id)\n scores = Gamer.compute_ratings(@reviews)\n Gamer.compute_overall_rating(scores)\n update_scores(scores, @gamer)\n render json: {gamer: @gamer, reviews: @reviews}\n end", "def show\n if params[:yelp_rating] && params[:google_rating] && params[:foursquare_rating]\n @ratings = {:yelp_rating => params[:yelp_rating], :foursquare_rating => params[:foursquare_rating], :google_rating => params[:google_rating], :weighted_rating => params[:weighted_rating]}\n end\n @social = {:yelp_id => params[:yelp_id], :foursquare_id => params[:foursquare_id], :google_id => params[:google_id]}\n if params[:google_id]\n @google_place = Restaurant.get_place_from_google params[:google_id]\n @google_reviews = @google_place.reviews\n @google_images = []\n @google_reviews.each do |review|\n str = review.author_url.to_s\n google_plus_id = str[24..-1]\n request = \"https://www.googleapis.com/plus/v1/people/\" + \"#{google_plus_id}\" + \"?fields=image&key=AIzaSyB8fUZUPNYIWKwz6Nss-Hu7J_2VUjFSOWA\"\n response = HTTParty.get(request)\n result = JSON.parse(response.body)\n\n if result[\"image\"]\n @google_images << result[\"image\"][\"url\"]\n else\n @google_images << nil\n end\n end\n\n end\n @yelp_reviews = Restaurant.get_restaurant_reviews_from_yelp params[:yelp_id]\n @foursquare_tips = Restaurant.get_venue_tips_from_foursquare params[:foursquare_id]\n \n @friend_recommendations = Recommendation.get_friend_recommedation_by_restaurant(params[:google_id], @registered_friends)\n end", "def show\n @suggestion = Suggestion.new\n @suggestion.game = Game.find_by_slug(params[:id])\n @suggestion.user = current_user\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @suggestion }\n end\n end", "def show\n @gender ={1=>\"female\",2=>\"male\"} \n @age ={1=>\"16-24 years\",2=>\"25-34 years\", 3=>\"35-44 years\", 4=>\"45-54 years\", 5=>\"55-64 years\", 6=>\"65-74 years\", 7=>\"75 years or over\"}\n @post = Post.approved.find(params[:id])\n respond_with(@post)\n end", "def show\n @paragraph_rating = ParagraphRating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paragraph_rating }\n end\n end", "def show\n @advance = Advance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advance }\n end\n end", "def show\n @school_rating = SchoolRating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @school_rating }\n end\n end", "def index\n @teachers = Teacher.order(:tea_no).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @teachers }\n end\n end", "def index\n @proposals = listing.proposals\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @proposals }\n end\n end", "def review\n @t = T\n @t = @t.paginate :page => params[:page], :per_page => params[:per_page]\n @data = @t.meanings\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @t }\n end\n end", "def show\n @suggestion = Suggestion.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @suggestion }\n format.json { render :json => @suggestion.to_json(:only => nil) }\n end\n end", "def show\n @talk_suggestion = TalkSuggestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @talk_suggestion }\n end\n end", "def show\n @available_improvements = params[:available_improvements]\n end", "def badges(id)\n get(\"users/#{id}/badges\")\n end", "def show\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @familiar }\n end\n end", "def show\n @good = Good.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @good }\n end\n end", "def index\n @idea = Idea.find(params[:idea_id])\n #@idea_ratings = IdeaRating.all\n end", "def show\n @achievment = Achievment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @achievment }\n end\n end", "def show\n @study = Study.find(params[:id]) \n @gpa = @study.progresses.where('stage = 3').select(\"AVG(score) AS gpa\").first.gpa\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @study }\n end\n end", "def index\n @goal_rewards = user.goal_rewards\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goal_rewards }\n end\n end", "def index\n @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 show\n @article = Article.includes(:categories).find(params[:id])\n @related_articles = @article.get_most_related_articles(3)\n\n @rating = Rating.new if @article.rateable?\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @article }\n end\n end", "def new\n\t\t@recommendation = Recommendation.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.json { render json: @recommendation }\n\t\tend\n\tend", "def new\n @drug = Drug.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @drug }\n end\n end", "def index\n @practices = Practice.order(\"practice_name\").paginate(:page => params[:page], :per_page => 20)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @practices }\n end\n end", "def people\n Birdman::Requester.get(\"movies/#{id}/people\")\n end", "def show\n @nugget = Nugget.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @nugget }\n end\n end", "def suggested_people(lang)\n request('/suggestedPeople', {body: {languages: lang}})\n end", "def show\n @rating = Rating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rating }\n end\n end", "def show\n @rating = Rating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rating }\n end\n end", "def show\n @rating = Rating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rating }\n end\n end", "def new\n @skill_suggestion = SkillSuggestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skill_suggestion }\n end\n end", "def show\n @title = \"View Team Challenge Score\"\n @challenge_grade = ChallengeGrade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @challenge_grade }\n end\n end", "def index\n @ideas = Idea.all\n\n render json: @ideas\n end", "def new\n @prefer = Prefer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prefer }\n end\n end", "def index\n @garrages = Garrage.all\n end", "def show\n @lesson_learned = LessonLearned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson_learned }\n end\n end", "def show\n @getadvice = Getadvice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @getadvice }\n end\n end", "def show\n @grade = Grade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @grade }\n end\n end", "def fetch_books(term)\n response = RestClient.get(\"https://www.googleapis.com/books/v1/volumes?q=#{term}\")\n\n JSON.parse(response.body)\nend", "def index\n @ideas = Idea.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end", "def show\n\n \t\t\trespond_with @penalty\n\n \t\tend", "def show\n @collection = current_user.collections.find(params[:collection_id]) \n @recommender = @collection.recommenders.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @recommender }\n end\n end", "def show\n @adv = Advantage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @adv }\n end\n end" ]
[ "0.7099652", "0.67179596", "0.6148087", "0.60026646", "0.5952918", "0.5890401", "0.58126235", "0.5792887", "0.5769358", "0.5689199", "0.56374407", "0.5620202", "0.5611857", "0.5598545", "0.55929244", "0.5569114", "0.55652297", "0.5563592", "0.556017", "0.5532992", "0.5529653", "0.5522039", "0.5507763", "0.54985034", "0.5488422", "0.5488422", "0.54838234", "0.5473329", "0.54686505", "0.54624224", "0.54573596", "0.54247475", "0.5423236", "0.5403585", "0.5397307", "0.53910077", "0.5382908", "0.53777665", "0.5375607", "0.53532", "0.53478956", "0.53434217", "0.53365785", "0.5333178", "0.5331868", "0.5324141", "0.5321398", "0.53199583", "0.529929", "0.52891827", "0.5288415", "0.5287753", "0.5282517", "0.52773494", "0.52773494", "0.52629006", "0.52580684", "0.5248342", "0.5243049", "0.5241478", "0.5236309", "0.52310485", "0.5224603", "0.52201134", "0.52191895", "0.5216132", "0.521595", "0.5215487", "0.520982", "0.520614", "0.52046865", "0.520031", "0.5195897", "0.51951313", "0.51943845", "0.5190986", "0.5190041", "0.5189109", "0.51884604", "0.51828206", "0.51813436", "0.51803434", "0.5178758", "0.51781607", "0.51780367", "0.517758", "0.517758", "0.517758", "0.51734525", "0.5167109", "0.51659775", "0.5165562", "0.51646334", "0.51609474", "0.5155045", "0.5153611", "0.5150734", "0.5141893", "0.51392287", "0.51388675", "0.51382303" ]
0.0
-1
POST /suggested_ages POST /suggested_ages.json
def create @suggested_age = SuggestedAge.new(suggested_age_params) respond_to do |format| if @suggested_age.save format.html { flash[:notice] = 'La edad sugerida se creó satisfactoriamente.' redirect_to suggested_ages_path } format.json { render :show, status: :created, location: @suggested_age } else format.html { render :new } format.json { render json: @suggested_age.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suggested_age_params\n params.require(:suggested_age).permit(:name)\n end", "def set_suggested_age\n @suggested_age = SuggestedAge.find(params[:id])\n end", "def index\n @suggested_ages = SuggestedAge.all\n end", "def update\n respond_to do |format|\n if @suggested_age.update(suggested_age_params)\n format.html { \n flash[:notice] = 'La edad sugerida se actualizó satisfactoriamente.'\n redirect_to suggested_ages_path\n }\n format.json { render :show, status: :ok, location: @suggested_age }\n else\n format.html { render :edit }\n format.json { render json: @suggested_age.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recommended = Recommended.new(recommended_params)\n\n respond_to do |format|\n if @recommended.save\n format.html { redirect_to @recommended, notice: 'Recommended was successfully created.' }\n format.json { render :show, status: :created, location: @recommended }\n else\n format.html { render :new }\n format.json { render json: @recommended.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ingredient_suggestion = IngredientSuggestion.new(ingredient_suggestion_params)\n\n respond_to do |format|\n if @ingredient_suggestion.save\n format.html { redirect_to @ingredient_suggestion, notice: 'Ingredient suggestion was successfully created.' }\n format.json { render :show, status: :created, location: @ingredient_suggestion }\n else\n format.html { render :new }\n format.json { render json: @ingredient_suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @suggestion = Suggestion.new(suggestion_params)\n\n if @suggestion.save\n render :show, status: :created, location: @suggestion\n else\n render json: @suggestion.errors, status: :unprocessable_entity\n end\n end", "def create\n @lesson = Lesson.new(lesson_params)\n @lesson.profile = current_user.profile\n @lesson.subject_list.add(params[:subject_list], parse: true)\n @lesson.code_concept_list.add(params[:code_concept_list], parse: true)\n @lesson.grade_list.add(params[:grade_list], parse: true) \n @lesson.level = params[:lesson][:level].to_i\n @suggested_lessons = params[:lesson][:suggested_lessons]\n respond_to do |format|\n if @lesson.save\n @suggested_lessons.each do |sug_lesson|\n SuggestedLesson.create(lesson_id: @lesson.id, suggested_lesson_id: sug_lesson.to_i)\n end\n format.html { redirect_to @lesson, notice: 'Lesson was successfully created.' }\n format.json { render :show, status: :created, location: @lesson }\n else\n format.html { render :new }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def judge_params\n params.require(:judge).permit(:name, :recommendation, :details, :judicial_district)\n end", "def create\n @lesson = Lesson.new(lesson_params)\n @lesson.profile = current_user.profile\n @lesson.subject_list.add(params[:lesson][:subject_list], parse: true)\n @lesson.code_concept_list.add(params[:lesson][:code_concept_list], parse: true)\n # @lesson.grade_list.add(params[:grade_list], parse: true) \n @lesson.level = params[:lesson][:level].to_i\n @suggested_lessons = params[:lesson][:suggested_lessons]\n respond_to do |format|\n if @lesson.save\n if @suggested_lessons.present?\n @suggested_lessons.each do |sug_lesson|\n SuggestedLesson.create(lesson_id: @lesson.id, suggested_lesson_id: sug_lesson.to_i)\n end\n end\n format.html { redirect_to @lesson, notice: 'Lesson was successfully created.' }\n format.json { render :show, status: :created, location: @lesson }\n else\n format.html { render :new }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def suggestion_params\n params.require(:suggestion).permit(:name, :votes, :foursquare_id, :user_id, :visited)\n end", "def create\n\n ### This one works. \n # @work = Work.friendly.find(params[:work_id])\n # @suggestion = @work.suggesteds.build(suggestion_params)\n # @suggestion.suggester_ip = request.remote_ip\n # @suggestion.user = current_user if current_user\n # respond_to do |format|\n # if @suggestion.save\n # format.html { redirect_to @work\n # flash[:success] = \"Your tag suggestion has been added!\" }\n # format.json { render json: @suggestion, status: :created, location: @suggestion } \n # else\n # format.html { redirect_to @work\n # flash[:warning] = \"Suggesting the suggestion failed. Probably either because you had weird characters in there, or the suggestion exists already.\" }\n # format.json { render json: @suggestion.errors, status: :unprocessable_entity }\n # end\n # end\n\n # This one parses the incoming suggestion(s). AND IT WORKS TOO. \n @work = Work.friendly.find(params[:work_id])\n suggestions = params[:suggested][:suggestion].split(',')\n @i = 0\n if current_user\n @current_user_id = current_user.id \n else \n @current_user_id = nil \n end\n\n suggestions.each do |s, index|\n new_suggestion = @work.suggesteds.build(\n suggester_ip: request.remote_ip,\n user_id: @current_user_id,\n suggestion: s)\n if new_suggestion.save\n @i += 1\n end \n if @i == suggestions.count\n @suggestions_saved = true\n else \n @suggestions_saved = false\n end\n end\n respond_to do |format|\n if @suggestions_saved\n format.html { redirect_to @work \n flash[:info] = \"Success.\"}\n format.json { }\n else\n format.html { redirect_to @work \n flash[:danger] = \"Suggested tags must be unique.\"}\n format.json { }\n end\n end \n end", "def create\n @seeker = Seeker.new(seeker_params)\n @seeker.user_id = User.find(session[:user_id]).uid\n @seeker.skill_list.add(params[:seeker][:skill_list].to_s.downcase, parse: true)\n\n respond_to do |format|\n if @seeker.save\n format.html { redirect_to root_path, notice: 'Seeker was successfully created.' }\n format.json { render action: 'show', status: :created, location: @seeker }\n else\n format.html { render action: 'new' }\n format.json { render json: @seeker.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @age_tracker = AgeTracker.new(age_tracker_params)\n\n respond_to do |format|\n if @age_tracker.save\n format.html { redirect_to @age_tracker, notice: 'Age tracker was successfully created.' }\n format.json { render :show, status: :created, location: @age_tracker }\n else\n format.html { render :new }\n format.json { render json: @age_tracker.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @suggestion = Suggestion.new(suggestion_params)\n respond_to do |format|\n if @suggestion.save\n format.html { redirect_to @suggestion, notice: 'Thank you for your suggestion!' }\n format.json { render :show, status: :created, location: @suggestion }\n else\n format.html { render :new }\n format.json { render json: @suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @gage = Gage.new(params[:gage])\n\n respond_to do |format|\n if @gage.save\n format.html { redirect_to @gage, notice: 'Gage was successfully created.' }\n format.json { render json: @gage, status: :created, location: @gage }\n else\n format.html { render action: \"new\" }\n format.json { render json: @gage.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @suggestion = Suggestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @suggestion }\n end\n end", "def suggestion_params\n params.require(:suggestion).permit(:author, :thoughts)\n end", "def new\n @advicepost = Advicepost.new\n #set user id attribute\n @advicepost.advisor_id = current_advisor.id\n @advicepost.status = \"Submitted\"\n \n @rating = Rating.new\n @rating.score = 0\n @rating.advisor_id = current_advisor.id\n @rating.rating_select = nil\n \n @advisor = Advisor.find(:first, :conditions => {:id=>current_advisor.id})\n @advisor.status = params[:status]\n @advisor.tokenID = params[:tokenID]\n @advisor.refundTokenID = params[:refundTokenID]\n @advisor.save\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advicepost }\n end\n end", "def destroy\n @suggested_age.destroy\n respond_to do |format|\n format.html { \n flash[:notice] = 'La edad sugerida se eliminó satisfactoriamente.'\n redirect_to suggested_ages_path\n }\n format.json { head :no_content }\n end\n end", "def effort_rating_params\n params.require(:effort_rating).permit(:rating, :opportunity_id)\n end", "def suggestion_params\n params.require(:suggestion).permit(:title, :date_created, :user_id)\n end", "def create\n @suggested_category = SuggestedCategory.new(suggested_category_params)\n\n respond_to do |format|\n if @suggested_category.save\n format.html { redirect_to @suggested_category, notice: 'Suggested category was successfully created.' }\n format.json { render :show, status: :created, location: @suggested_category }\n else\n format.html { render :new }\n format.json { render json: @suggested_category.errors, status: :unprocessable_entity }\n end\n end\n end", "def predictions\n raise \"Err\"\n buyer_suggestions = PropertyBuyer.suggest_buyers(params[:str]).select([:id, :name, :image_url]).limit(20)\n render json: buyer_suggestions, status: 200\n end", "def idea_rating_params\n params.require(:idea_rating).permit(:idea_id, :crit_id, :user_id, :rating, :rating_text)\n end", "def create \n @idea = Idea.new(idea_params)\n @idea.user_id = current_user.id\n @idea.save!\n if params[:idea][:tags]\n params[:idea][:tags].each do |new_tag|\n tag_title = new_tag[:title]\n tag = Tag.find_by title: tag_title\n if tag.present?\n tag.used = tag.used + 1\n tag.save!\n else\n tag = Tag.new\n tag.title = tag_title.downcase\n tag.used = 1 \n tag.save!\n end\n @idea.tags << tag\n end\n end\n Notification.generate(current_user, @idea)\n Notification.push(@idea) \n render json: @idea.to_json(include: [{user: {only: [:name, :id, :image_url]}}, {comments: {include: {user: {only: [:name, :image_url]}}}}], methods: [:voted])\n end", "def eaten_params\n params.require(:eaten).permit(:food_id, :portion_factor, :date)\n end", "def meal_rating_params\n params.require(:meal_rating).permit(:meal_posting_id, :user_id, :comment, :rating)\n end", "def rider_params\n params.require(:rider).permit(:name, :description, :status, :code_name, \n :reference_id, :tag_list, :premium, :amount, :maximum_cover_age)\n end", "def improvement_params\n params.require(:improvement).permit(:title, :category, :content, :user_id, :status_id, :responsible_id)\n end", "def servingguide_params\n params.require(:servingguide).permit(:usercategory_id, :age, :veg, :fruit, :grain, :meat, :milk, :additional_serve)\n end", "def update\n @suggested_lessons = params[:lesson][:suggested_lessons]\n @suggested_lessons.each do |sug_lesson|\n SuggestedLesson.create(lesson_id: @lesson.id, suggested_lesson_id: sug_lesson.to_i)\n end\n respond_to do |format|\n if @lesson.update(lesson_params)\n format.html { redirect_to @lesson, notice: 'Lesson was successfully updated.' }\n format.json { render :show, status: :ok, location: @lesson }\n else\n format.html { render :edit }\n format.json { render json: @lesson.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n final_set = []\n params['doctors_review'].permit!\n doctors_id = params['doctors_review']['doctors_id']\n specialties_id = DoctorsSpecialty.where(doctors_id: doctors_id).first\n .specialties_id\n specialty = Specialty.find(specialties_id)\n unless specialties_id.nil?\n params['doctors_review']['specialties_id'] = specialties_id\n end\n @doctors_reviews = DoctorsReview.new(params['doctors_review'])\n if @doctors_reviews.save\n rating = params['doctors_review']['rating']\n unless rating.nil?\n all_reviews = DoctorsReview.where(specialties_id: specialties_id)\n .where('rating >= ?', rating).order('rating')\n all_reviews&.each do |review|\n doctor = Doctor.find(review['doctors_id'])\n recommendations = { specialty: specialty.name,\n doctor: doctor.name,\n rating: review.rating,\n comments: review.comments\n }\n final_set << recommendations\n end\n end\n final_set\n else\n @doctors_reviews.errors.full_messages\n end\n end", "def create\n @suggestion = Suggestion.new(params[:suggestion])\n\n respond_to do |format|\n if @suggestion.save\n format.js\n else\n format.html { render action: \"new\" }\n format.json { render json: @suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def suggestion_params\n params.require(:suggestion).permit(:name, :author, :ISBN, :Description, :status)\n end", "def create\n @rating = Rating.new(params[:rating])\n facebook_id = params[:rating][:user_id]\n @user = User.find_by_facebook_id(facebook_id)\n @rating.user_id = @user.id\n dish = Dish.find(params[:rating][:dish_id]) \n @rating.dish_id = dish.id \n \n respond_to do |format|\n if @rating.save\n if @rating.value == 1\n dish.upvotes += 1\n else\n dish.downvotes += 1\n end\n dish.save\n format.html { redirect_to @rating, notice: 'Rating was successfully created.' }\n format.json { render json: @rating, status: :created, location: @rating }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rating.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @reputation = Reputation.new(reputation_params)\n\n respond_to do |format|\n if @reputation.save\n format.html { redirect_to @reputation, notice: 'Reputation was successfully created.' }\n format.json { render :show, status: :created, location: @reputation }\n else\n format.html { render :new }\n format.json { render json: @reputation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @recommendation = Recommendation.new(recommendation_params)\n respond_to do |format|\n if @recommendation.save\n format.html { redirect_to @recommendation, notice: \"Recommendation was successfully created.\" }\n format.json { render :show, status: :created, location: @recommendation }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @recommendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @idea_rating = IdeaRating.new(idea_rating_params)\n\n respond_to do |format|\n if @idea_rating.save\n format.html { redirect_to @idea_rating, notice: (I18n.t :act_create) }\n format.json { render :show, status: :created, location: @idea_rating }\n else\n format.html { render :new }\n format.json { render json: @idea_rating.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @rating_alt = Rating.new(params[:rating_alt])\n\n respond_to do |format|\n if @rating_alt.save\n format.html { redirect_to @rating_alt, notice: 'Rating was successfully created.' }\n format.json { render json: @rating_alt, status: :created, location: @rating_alt }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rating_alt.errors, status: :unprocessable_entity }\n end\n end\n end", "def nudge_params\n params.require(:nudge).permit(:nudge_token, :user_id, :pet_id, :group_id, :response)\n end", "def create\n @book_recommendation = BookRecommendation.new(book_recommendation_params)\n\n respond_to do |format|\n if @book_recommendation.save\n format.html { redirect_to @book_recommendation, notice: 'Book recommendation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @book_recommendation }\n else\n format.html { render action: 'new' }\n format.json { render json: @book_recommendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def search_suggestions_params\n params.require(:SearchSuggestion).permit(:popularity, :term )\n end", "def recommendation_params\n params.require(:recommendation).permit(\n :address,\n :email,\n :capacity,\n :communication,\n :department,\n :habits,\n :institution,\n :maturity,\n :motivation,\n :name,\n :personality,\n :rating,\n :recommendation,\n :responsibility,\n :title,\n :years,\n )\n end", "def ingredient_suggestion_params\n params.require(:ingredient_suggestion).permit(:item)\n end", "def new_idea\n if user_signed_in?\n @idea = Idea.new()\n @idea.subject = params[:new_idea_subject]\n @idea.description = params[:new_idea_description]\n @idea.category_id = params[:new_idea_category_id]\n @idea.yae_votes = 1\n @idea.nay_votes = 0\n @idea.rank = @idea.calculate_rank\n @idea.user_id = current_user.id\n @idea.save\n \n @vote = IdeaVote.new()\n @vote.user_id = current_user.id\n @vote.idea_id = @idea.id\n @vote.vote = 'yae'\n @vote.save\n \n respond_to do |format|\n format.json { render :json => @idea, :status => :created, :location => @idea }\n end\n end\n end", "def create\n idea = Idea.find_by_id(params[:idea_id])\n user_rating = UserRating.new(params[:rating])\n user_rating.rating_id = params[:rating_id]\n user_rating.user_id = current_user.id\n\n if user_rating.save\n saved_rating = UserRating.where('rating_id' => params[:rating_id])\n\n if saved_rating.size != 0\n rating = Rating.find_by_id(params[:rating_id])\n average_rating = 0\n\n saved_rating.each do |sr|\n average_rating = average_rating.to_i + sr.value.to_i\n end\n\n if current_user.provider == 'twitter' && current_user.facebook_share\n current_user.twitter.update(\"I've rated an idea on #Idearator ! available on: \" + root_url + \"ideas/\" + idea.id.to_s) rescue Twitter::Error\n end\n\n rating.value = average_rating.to_f / saved_rating.size.to_f\n rating.save\n end\n\n respond_to do |format|\n format.html { redirect_to idea, :notice => 'Your rating has been saved successfully!' }\n format.js\n end\n else\n respond_to do |format|\n format.html { redirect_to idea, :alert => 'Your rating has not been saved, please retry!' }\n format.js\n end\n end\n end", "def create\n @recommendation = Recommendation.new\n\n respond_to do |format|\n if @recommendation.save\n format.html { redirect_to @recommendation, notice: 'Recommendation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @recommendation }\n else\n format.html { render action: 'new' }\n format.json { render json: @recommendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @people_term = PeopleTerm.new(people_term_params)\n\n respond_to do |format|\n if @people_term.save\n format.html { redirect_to @people_term, notice: 'People term was successfully created.' }\n format.json { render :show, status: :created, location: @people_term }\n else\n format.html { render :new }\n format.json { render json: @people_term.errors, status: :unprocessable_entity }\n end\n end\n end", "def recommendation_params\n params.require(:recommendation).permit(:name, :detail, :rating)\n end", "def new\n @skill_suggestion = SkillSuggestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skill_suggestion }\n end\n end", "def create\n vote = Vote.new\n @idea = Idea.find(params[:id])\n @idea.votes << vote\n @idea.save\n vote.save\n current_user.votes << vote\n current_user.save\n respond_to do |format|\n format.html\n format.js {}\n end\n end", "def create\n @suggest = Suggest.new(suggest_params)\n @suggest.user_id= current_user.id\n @suggest.suggest_user=current_user.nickname\n\n respond_to do |format|\n if @suggest.save\n format.html { redirect_to @suggest, notice: 'Suggest was successfully created.' }\n format.json { render :show, status: :created, location: @suggest }\n else\n format.html { render :new }\n format.json { render json: @suggest.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @earned_award = EarnedAward.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @earned_award }\n end\n end", "def create\n @skill_suggestion = SkillSuggestion.new(params[:skill_suggestion])\n\n respond_to do |format|\n if @skill_suggestion.save\n format.html { redirect_to @skill_suggestion, notice: 'Skill suggestion was successfully created.' }\n format.json { render json: @skill_suggestion, status: :created, location: @skill_suggestion }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skill_suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @effort_rating = @opportunity.effort_ratings.new(effort_rating_params)\n\n respond_to do |format|\n if @effort_rating.save\n @opportunity.effort_rating = @opportunity.effort_ratings.average(:rating)\n @opportunity.save\n format.html { redirect_to @opportunity, notice: 'Effort rating was successfully created.' }\n format.json { render :show, status: :created, location: @effort_rating }\n else\n format.html { render :new }\n format.json { render json: @opportunity.errors, status: :unprocessable_entity }\n end\n end\n end", "def rating_params\n params.require(:rating).permit(\"food\", \"drinks\", \"talks\", \"vibe\")\n end", "def new\n @judgement = Judgement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @judgement }\n end\n end", "def postage_params\n params.require(:postage).permit(:name, :postage_germany, :postage_austria, :postage_swiss, :postage_europe_with_eu, :postage_europe_without_eu, :postage_world_wide)\n end", "def create\n @garrage = Garrage.new(garrage_params)\n @garrage.user_id = current_user.id\n\n respond_to do |format|\n if @garrage.save\n format.html { redirect_to garrage_stuffs_path(@garrage), notice: 'Garrage was successfully created.' }\n format.json { render :show, status: :created, location: @garrage }\n else\n format.html { render :new }\n format.json { render json: @garrage.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n p = prediction_params\n\n p[:tags] = [p[:tags]]\n puts \"BLAH\"\n puts p\n @prediction = current_user.predictions.create(p)\n respond_to do |format|\n if @prediction.save\n format.html { redirect_to action: 'index' }\n format.json { render action: 'show', status: :created, location: @prediction }\n else\n format.html { render action: 'new' }\n format.json { render json: @prediction.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @judgement = Judgement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @judgement }\n end\n end", "def create\n @rating_answer = RatingAnswer.new(rating_answer_params)\n\n respond_to do |format|\n if @rating_answer.save\n format.html { redirect_to @rating_answer, notice: 'Rating answer was successfully created.' }\n format.json { render :show, status: :created, location: @rating_answer }\n else\n format.html { render :new }\n format.json { render json: @rating_answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def age_tracker_params\n params.require(:age_tracker).permit(:name, :age)\n end", "def searchsuggestion_params\n params.require(:searchsuggestion).permit(:term, :popularity)\n end", "def create\n @fragrance = Fragrance.find(params[:fragrance_id])\n @rating = Rating.new(rating_params)\n @rating.user = @current_user\n @rating.fragrance = @fragrance\n\n if @rating.save\n render json: @rating, status: :created\n else\n render json: @rating.errors, status: :unprocessable_entity\n end\n end", "def create_interest_params\n params.permit(:yelp_id, :interests => [:min_seats, :max_seats, :datetime])\n end", "def create\n @rating_reason = RatingReason.new(rating_reason_params)\n\n respond_to do |format|\n if @rating_reason.save\n format.html { redirect_to @rating_reason, notice: 'Rating reason was successfully created.' }\n format.json { render :show, status: :created, location: @rating_reason }\n else\n format.html { render :new }\n format.json { render json: @rating_reason.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @blog_recommendation = Blog::Recommendation.new(blog_recommendation_params)\n\n respond_to do |format|\n if @blog_recommendation.save\n format.html { redirect_to @blog_recommendation, notice: 'Recommendation was successfully created.' }\n format.json { render :show, status: :created, location: @blog_recommendation }\n else\n format.html { render :new }\n format.json { render json: @blog_recommendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @target_age = TargetAge.new(params[:target_age])\n\n respond_to do |format|\n if @target_age.save\n format.html { redirect_to @target_age, notice: 'Target age was successfully created.' }\n format.json { render json: @target_age, status: :created, location: @target_age }\n else\n format.html { render action: \"new\" }\n format.json { render json: @target_age.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_friend_guesses\n self.destroy_existing_guesses\n\n @guessed_users = {}\n @guessed_users.default = 0\n self.collect_friend_guesses(@guessed_users)\n\n @suggested_users = @guessed_users\n @suggested_users.each_key do |user_id|\n @suggested_users[user_id] = 1\n end\n self.calculating_final_scores(@guessed_users, @suggested_users)\n\n @min_num = [50, @suggested_users.size].min\n @final_suggestions = @suggested_users.sort{|a,b| a[1] <=> b[1]}[0..@min_num]\n \n @final_suggestions.each do |element|\n self.friend_guesses.create(:guess_id => element[0])\n end\n end", "def create\n @advancement = Advancement.new(params[:advancement])\n\n respond_to do |format|\n if @advancement.save\n format.html { redirect_to @advancement, notice: 'Advancement was successfully created.' }\n format.json { render json: @advancement, status: :created, location: @advancement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @advancement.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @earned_award = EarnedAward.new(params[:earned_award])\n\n respond_to do |format|\n if @earned_award.save\n format.html { redirect_to @earned_award, notice: 'Earned award was successfully created.' }\n format.json { render json: @earned_award, status: :created, location: @earned_award }\n else\n format.html { render action: \"new\" }\n format.json { render json: @earned_award.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @judgement = Judgement.new(params[:judgement])\n\n respond_to do |format|\n if @judgement.save\n format.html { redirect_to @judgement, notice: 'Judgement was successfully created.' }\n format.json { render json: @judgement, status: :created, location: @judgement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @judgement.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @judgement = Judgement.new(params[:judgement])\n\n respond_to do |format|\n if @judgement.save\n format.html { redirect_to @judgement, notice: 'Judgement was successfully created.' }\n format.json { render json: @judgement, status: :created, location: @judgement }\n else\n format.html { render action: \"new\" }\n format.json { render json: @judgement.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_demonstrator_params\n params.require(:practical_ids).permit(:sam_student_id, practical_ids: [])\n end", "def create\n\n reviews = []\n params[:scores].keys.each{ |name|\n score = params[:scores][name]\n peer_review = PeerReview.new(name:name, score:score, miniproject_id:params[:project][:id])\n peer_review.save\n reviews << peer_review\n }\n\n render json: reviews\n\n end", "def create\n @recommendation = Recommendation.new(recommendation_params)\n @submission = Submission.find_by_user_id(current_user.id)\n @recommendation.submission_id = @submission.id\n\n respond_to do |format|\n if @recommendation.save\n RecommendationRequestMailer.recommendation_request(@recommendation).deliver\n format.html { redirect_to dashboard_home_path, notice: 'Recommendation was successfully created.' }\n format.json { render :show, status: :created, location: @recommendation }\n else\n format.html { render :new }\n format.json { render json: @recommendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def recommended_params\n params.require(:recommended).permit(:name)\n end", "def hunters_improvement_params\n params.require(:hunters_improvement)\n .permit(:hunter_id, :improvement_id, :improvable, improvable: [])\n end", "def new\n @drug = Drug.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @drug }\n end\n end", "def rapper_params\n params.require(:rapper).permit(:name, :age)\n end", "def create\n @suggestion = Suggestion.new(params[:suggestion])\n\t\t@suggestion.suggester_id = params[:suggestion][:suggester_id]\n\t\t@suggestion.suggest_to_id = params[:suggestion][:suggest_to_id]\n\n\t\tif params[:book_id]\n\t\t\t@suggestion.book_id = params[:suggestion][:book_id]\n\t\tend\n\n\t\tif params[:job_id]\n \t@suggestion.job_id = params[:suggestion][:job_id]\n\t\tend\n\n\t\t@suggest_to = Person.find(@suggestion.suggest_to_id)\n\n respond_to do |format|\n if @suggestion.save\n flash[:notice] = \"Suggestion was successfully sent to #{@suggest_to.name}.\"\n format.html { redirect_to(@suggestion) }\n format.xml { render :xml => @suggestion, :status => :created, :location => @suggestion }\n\t\t\t\tformat.js\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @suggestion.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.js\n end\n end\n end", "def add_review\n UsersQuest.update(params[:id], params.require(:quest).permit(:review))\n quest = Quest.find(params[:id])\n\n if params[:quest][:points] == \"1\"\n quest.bounty_points += 10\n quest.save\n end\n if params[:quest][:points] == \"2\"\n quest.bounty_points += 20\n quest.save\n end\n if params[:quest][:points] == \"3\"\n quest.bounty_points += 30\n quest.save\n end\n if params[:quest][:points] == \"4\"\n quest.bounty_points += 40\n quest.save\n end\n if params[:quest][:points] == \"5\"\n quest.bounty_points += 50\n quest.save\n end\n redirect_to quest_path(quest.id)\n end", "def create\n @suggestion = Suggestion.new(params[:suggestion])\n flash[:notice] = 'Thank you for your feedback. ' if @suggestion.save\n respond_with(@suggestion, location: root_url)\n end", "def suggestion_params\n params.require(:suggestion).permit(:document_id, :text, :status, :person_id)\n end", "def create\n @defense = Defense.new(defense_params)\n\n respond_to do |format|\n if @defense.save\n format.html { redirect_to @defense, notice: 'Defense was successfully created.' }\n format.json { render :show, status: :created, location: @defense }\n else\n format.html { render :new }\n format.json { render json: @defense.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @puntuation = Puntuation.new(puntuation_params)\n\n respond_to do |format|\n if @puntuation.save\n @voted_contribution = Contribution.find(@puntuation.contribution_id)\n @voted_contribution.increment!(:puntuation, 1)\n format.html { redirect_to :back }\n format.json { render :show, status: :created, location: @puntuation }\n else\n format.html { render :new }\n format.json { render json: @puntuation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @engagement = current_user.engagements.new(engagement_params_with_school)\n if @engagement.save\n render :show, status: :created, location: api_v2_engagement_url(@engagement)\n else\n puts @engagement.errors.full_messages\n render json: @engagement.errors, status: :unprocessable_entity\n end\n end", "def suggestion_params\n params.require(:suggestion).permit(:subject, :content, :observation, :user_id, :revised)\n end", "def new\n @talk_suggestion = TalkSuggestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talk_suggestion }\n end\n end", "def food_review_params\n params.require(:food_review).permit(:food_id, :user_id, :title, :body, :rating)\n end", "def create\n @learner = Learner.new(learner_params)\n\n respond_to do |format|\n if @learner.save\n format.html { head :created, content_type: \"text/html\" }\n format.json { head :created, location: @order }\n else\n format.html { head :bad_request, content_type: \"text/html\" }\n format.json { head :bad_request }\n end\n end\n end", "def create\n @suggestion = Suggestion.new(suggestion_params)\n @suggestion.person_id = current_person.id\n\n respond_to do |format|\n if @suggestion.save\n format.html { redirect_to [@document, @suggestion], notice: 'Suggestion was successfully created.' }\n format.json { render :show, status: :created, location: @suggestion }\n else\n format.html { render :new }\n format.json { render json: @suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def meal_params\n params.require(:meal).permit(:address, :title, :description,\n :max_people, :date, :place, :tags, :image).tap do |meal|\n meal[:tags] = meal[:tags].split(',').map(&:strip)\n end\n end", "def create\n @advocacy = Advocacy.new(params[:advocacy])\n\n respond_to do |format|\n if @advocacy.save\n format.html { redirect_to @advocacy, notice: 'Advocacy was successfully created.' }\n format.json { render json: @advocacy, status: :created, location: @advocacy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @advocacy.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_review\n UsersQuest.update(params[:id], params.require(:quest).permit(:review))\n redirect_to quest_path(params[:id])\n end", "def creat_disciplineage(json)\n # need for Age select\n age_range = json[\"age_group\"].split(\"-\")\n min_age = age_range[0].to_i\n # save query in vars for join Dicipline with Age\n ag = AgeRange.find_by_min_age(min_age)\n ge = Gender.find_by_sex(json[\"gender\"])\n di = Discipline.find_by_name_and_gender_id(json[\"disciplin\"],ge.id)\n # Creat new entry\n disag = DisciplineAge.new()\n di.discipline_ages << disag\n ag.discipline_ages << disag\nend", "def legs2_params\n params.require(:legs2).permit(:exercise, :reps, :sets)\n end", "def new\n @gage = Gage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gage }\n end\n end" ]
[ "0.6687431", "0.62753564", "0.6156147", "0.59321713", "0.5755394", "0.55906904", "0.54308695", "0.5430047", "0.54174876", "0.539183", "0.539162", "0.53759205", "0.53399396", "0.53324497", "0.5327658", "0.5311165", "0.53110087", "0.5286432", "0.52847314", "0.5279038", "0.5253165", "0.5230932", "0.5226254", "0.52211875", "0.5220243", "0.52175045", "0.5214577", "0.521179", "0.5208452", "0.52035064", "0.51956517", "0.5194182", "0.51931393", "0.5187173", "0.51854056", "0.5171625", "0.517115", "0.5167581", "0.5165861", "0.5148406", "0.5142414", "0.51382524", "0.51330787", "0.5131559", "0.5131004", "0.5130819", "0.51197314", "0.51159054", "0.5110211", "0.5108018", "0.51046866", "0.51032984", "0.51018685", "0.5100562", "0.5100114", "0.50972885", "0.5096082", "0.5092825", "0.50813985", "0.5078553", "0.5078551", "0.50763166", "0.50759244", "0.50699735", "0.50698453", "0.5063833", "0.5054536", "0.5051767", "0.50517565", "0.50458944", "0.5044624", "0.5035366", "0.50273156", "0.5027158", "0.5027158", "0.502446", "0.50239885", "0.502389", "0.5020863", "0.50175947", "0.5017492", "0.5015973", "0.50156987", "0.5015377", "0.5014577", "0.50145", "0.5011835", "0.5010082", "0.5009021", "0.5003328", "0.4999342", "0.49952546", "0.4994691", "0.49936196", "0.4992657", "0.49911606", "0.49884546", "0.49853736", "0.49845162", "0.4980901" ]
0.6861874
0
PATCH/PUT /suggested_ages/1 PATCH/PUT /suggested_ages/1.json
def update respond_to do |format| if @suggested_age.update(suggested_age_params) format.html { flash[:notice] = 'La edad sugerida se actualizó satisfactoriamente.' redirect_to suggested_ages_path } format.json { render :show, status: :ok, location: @suggested_age } else format.html { render :edit } format.json { render json: @suggested_age.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_suggested_age\n @suggested_age = SuggestedAge.find(params[:id])\n end", "def update\n @gage = Gage.find(params[:id])\n\n respond_to do |format|\n if @gage.update_attributes(params[:gage])\n format.html { redirect_to @gage, notice: 'Gage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @gage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recommended.update(recommended_params)\n format.html { redirect_to @recommended, notice: 'Recommended was successfully updated.' }\n format.json { render :show, status: :ok, location: @recommended }\n else\n format.html { render :edit }\n format.json { render json: @recommended.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recommend_recommend_other = Recommend::RecommendOther.find(params[:id])\n\n respond_to do |format|\n if @recommend_recommend_other.update_attributes(params[:recommend_recommend_other])\n format.html { redirect_to @recommend_recommend_other, notice: 'Recommend other was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recommend_recommend_other.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @book_recommendation.update(book_recommendation_params)\n format.html { redirect_to @book_recommendation, notice: 'Book recommendation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book_recommendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ingredient_suggestion.update(ingredient_suggestion_params)\n format.html { redirect_to @ingredient_suggestion, notice: 'Ingredient suggestion was successfully updated.' }\n format.json do\n render :nothing => true, :status => 200\n # render :show, status: :ok, location: @ingredient_suggestion\n end\n else\n format.html { render :edit }\n format.json { render json: @ingredient_suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end", "def update\n respond_to do |format|\n if @suggest.update(suggest_params)\n format.html { redirect_to @suggest, notice: 'Suggest was successfully updated.' }\n format.json { render :show, status: :ok, location: @suggest }\n else\n format.html { render :edit }\n format.json { render json: @suggest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n debugger\n if @best_practice.update(best_practice_params)\n format.html { redirect_to @best_practice, notice: 'Best practice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @best_practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recommendation = Recommendation.find(params[:id])\n\n respond_to do |format|\n if @recommendation.update_attributes(params[:recommendation])\n format.html { redirect_to @recommendation, notice: 'Recommendation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recommendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @needed_good = NeededGood.find(params[:id])\n\n respond_to do |format|\n if @needed_good.update_attributes(params[:needed_good])\n format.html { redirect_to @needed_good, notice: 'Good was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @needed_good.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @age_tracker.update(age_tracker_params)\n format.html { redirect_to @age_tracker, notice: 'Age tracker was successfully updated.' }\n format.json { render :show, status: :ok, location: @age_tracker }\n else\n format.html { render :edit }\n format.json { render json: @age_tracker.errors, status: :unprocessable_entity }\n end\n end\n end", "def suggested_age_params\n params.require(:suggested_age).permit(:name)\n end", "def update\n if @gift.user == @current_user\n if @gift.update(gift_params)\n render json: @gift, include: :ages\n else\n render json: @gift.errors, status: :unprocessable_entity\n end\n else\n render json: { errors: \"not authorized\" }, status: :unauthorized\n end\n end", "def update\n @feat = @person.feats.find(params[:id])\n level_old = @person.level\n\n if params[:feat][:completed] == '1'\n @feat.complete\n else\n @feat.uncomplete\n end\n sign = params[:feat][:completed] == '1' ? '+': '-'\n \n has_leveled = @person.level > level_old\n\n respond_to do |format|\n format.json { render :json => {\n :xpGained => \"#{sign}#{@feat.xp}\",\n :xpTotal => @person.xp,\n :next_level_ratio => @person.next_level_ratio,\n :extra_life => @person.level_to_string,\n :has_leveled => has_leveled,\n :completed => @feat.completed,\n :streak => @feat.calculate_streak}}\n \n end\n\n end", "def update\n @interesting = Interesting.find(params[:id])\n\n respond_to do |format|\n if @interesting.update_attributes(params[:interesting])\n format.html { redirect_to @interesting, notice: 'Interesting was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interesting.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @suggestion = Suggestion.find(params[:id])\n\n respond_to do |format|\n if @suggestion.update_attributes(params[:suggestion])\n format.html { redirect_to @suggestion, notice: 'Suggestion was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipe.allergies.destroy_all\n params[:recipe][:allergy].each do |key,value|\n if value[\"name\"] == \"1\"\n allergy = Allergy.find(key)\n @recipe.allergies << allergy\n end\n end\n\n if params[:recipe][:concentrate] == '1' || params[:recipe][:recipe_category_id] == RecipeCategory.find_by(name: \"Concentrates\").id\n @recipe.concentrate = true\n else\n @recipe.concentrate = false\n end\n\n respond_to do |format|\n if @recipe.update(recipe_params)\n @allergies = Allergy.all\n format.html { redirect_to @recipe, notice: 'Recipe was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe }\n else\n @allergies = Allergy.all\n format.html { render :edit }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meal_preference = MealPreference.find(params[:id])\n\n respond_to do |format|\n if @meal_preference.update_attributes(params[:meal_preference])\n format.html { redirect_to @meal_preference, notice: 'Meal preference was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meal_preference.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @person = Person.find(params[:id])\n # @person.pct_complete = @person.requirement_progress\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, :notice => 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n ingredient.update(ingredient_params)\n render json: ingredient\n end", "def update\n @early_pregnancy = EarlyPregnancy.find(params[:id])\n\n respond_to do |format|\n if @early_pregnancy.update_attributes(params[:early_pregnancy])\n format.html { redirect_to @early_pregnancy, notice: 'Early pregnancy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @early_pregnancy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @interested = Interested.find(params[:id])\n\n respond_to do |format|\n if @interested.update_attributes(params[:interested])\n format.html { redirect_to @interested, notice: 'Interested was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @interested.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recommend = Recommend.find(params[:id])\n\n respond_to do |format|\n if @recommend.update_attributes(params[:recommend])\n format.html { redirect_to @recommend, notice: 'Recommend was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recommend.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @budget_approver.update(budget_approver_params)\n format.html { redirect_to @budget_approver, notice: 'Budget approver page was successfully updated.' }\n format.json { render :show, status: :ok, location: @budget_approver }\n else\n format.html { render :edit }\n format.json { render json: @budget_approver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @prefer = Prefer.find(params[:id])\n\n respond_to do |format|\n if @prefer.update_attributes(params[:prefer])\n format.html { redirect_to @prefer, notice: 'Prefer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @prefer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @good = Good.find(params[:id])\n\n respond_to do |format|\n if @good.update_attributes(params[:good])\n format.html { redirect_to :action => \"index\" }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @good.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @gift_given.update(gift_given_params)\n format.html { redirect_to @gift_given, notice: 'Gift given was successfully updated.' }\n format.json { render :show, status: :ok, location: @gift_given }\n else\n format.html { render :edit }\n format.json { render json: @gift_given.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @opt10075.update(opt10075_params)\n format.html { redirect_to @opt10075, notice: 'Opt10075 was successfully updated.' }\n format.json { render :show, status: :ok, location: @opt10075 }\n else\n format.html { render :edit }\n format.json { render json: @opt10075.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n attributes = recommendation_params\n if not attributes[:liked].nil?\n rec = Recommendation.find_by(id:params[:id])\n if rec && current_user.id == rec.user_id\n rec.update(recommendation_params)\n render json:rec, status:200\n else\n render json:{errors:\"Invalid recommendation_id\"},status:422\n end\n else\n render json:{errors:\"must provide liked param\"}, status:400\n end\n end", "def update\n @rating_alt = Rating.find(params[:id])\n\n respond_to do |format|\n if @rating_alt.update_attributes(params[:rating_alt])\n format.html { redirect_to @rating_alt, notice: 'Rating was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rating_alt.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @meal.update(meal_params)\n format.html { redirect_to @meal, notice: 'Meal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \t\t@interested = Interested.find(params[:id])\n\n \t\trespond_to do |format|\n \t\t\tif @interested.update_attributes(params[:interested])\n \t\t\tformat.html { redirect_to @interested, notice: 'Interested was sucessfully updated.' }\n \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: @interested.error, status: :unprocessable_entity }\n \t\t\tend\n \t\tend\n \tend", "def update\n @target_age = TargetAge.find(params[:id])\n\n respond_to do |format|\n if @target_age.update_attributes(params[:target_age])\n format.html { redirect_to @target_age, notice: 'Target age was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @target_age.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @familiar = Familiar.find(params[:id])\n\n respond_to do |format|\n if @familiar.update_attributes(params[:familiar])\n format.html { redirect_to @familiar, notice: 'Familiar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @familiar.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recommendation.update(recommendation_params)\n format.html { redirect_to @recommendation, notice: \"Recommendation was successfully updated.\" }\n format.json { render :show, status: :ok, location: @recommendation }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @recommendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if( get_seeker_id = params[:id] )\n @seeker.skill_list = params[:seeker][:skill_list].to_s.downcase\n respond_to do |format|\n if @seeker.update(seeker_params)\n format.html { redirect_to root_path, notice: 'Seeker was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @seeker.errors, status: :unprocessable_entity }\n end\n end\n else\n permission_denied \"You_do_no_own_this_profile\"\n end\n end", "def update\n @advocacy = Advocacy.find(params[:id])\n\n respond_to do |format|\n if @advocacy.update_attributes(params[:advocacy])\n format.html { redirect_to @advocacy, notice: 'Advocacy was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @advocacy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @personnage = Personnage.find(params[:id])\n\n respond_to do |format|\n if @personnage.update_attributes(params[:personnage])\n format.html { redirect_to @personnage, notice: 'Personnage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @personnage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @suggested_business.update(suggested_business_params)\n format.html { redirect_to @suggested_business, notice: 'Suggested business was successfully updated.' }\n format.json { render :show, status: :ok, location: @suggested_business }\n else\n format.html { render :edit }\n format.json { render json: @suggested_business.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n params[:examination][:usesOfDrug_ids] ||= []\n params[:examination][:resistancesToDrug_ids] ||= []\n params[:examination][:mutation_ids] ||= []\n @examination = Examination.find(params[:id])\n\n respond_to do |format|\n if @examination.update_attributes(params[:examination])\n format.html { redirect_to @examination, notice: 'Examination was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @examination.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @meal = Meal.find(params[:id])\n\n respond_to do |format|\n if @meal.update_attributes(params[:meal])\n format.html { redirect_to @meal, notice: 'Meal was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recommend_recommend_tag = Recommend::RecommendTag.find(params[:id])\n\n respond_to do |format|\n if @recommend_recommend_tag.update_attributes(params[:recommend_recommend_tag])\n format.html { redirect_to @recommend_recommend_tag, notice: 'Recommend tag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recommend_recommend_tag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @growth.update(growth_params)\n format.html { redirect_to @growth, notice: 'Growth was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @growth.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @advancement = Advancement.find(params[:id])\n\n respond_to do |format|\n if @advancement.update_attributes(params[:advancement])\n format.html { redirect_to @advancement, notice: 'Advancement was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @advancement.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @change_suggestion = ChangeSuggestion.find(params[:id])\n\n respond_to do |format|\n if @change_suggestion.update_attributes(params[:change_suggestion])\n format.html { redirect_to @change_suggestion, notice: 'Change suggestion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @change_suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @review = Review.find(params[:id])\n @review.update(review_params)\n render json: @review\n end", "def update\n @golfer = Golfer.find(params[:id])\n\n respond_to do |format|\n if @golfer.update_attributes(params[:golfer])\n format.html { redirect_to @golfer, notice: 'Golfer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @golfer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # if @bonus.update(bonus_params)\n # render :show, status: :ok, location: @bonus\n # else\n # render json: @bonus.errors, status: :unprocessable_entity\n # end\n end", "def update\n @idea = Idea.find(params[:id])\n respond_with(@idea) do |format|\n if @idea.update_attributes(params[:idea])\n format.json { render json: @idea, status: :created, location: @idea }\n else\n format.json { render json: @idea.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @badge = Badge.find(params[:id])\n\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @earned_award = EarnedAward.find(params[:id])\n\n respond_to do |format|\n if @earned_award.update_attributes(params[:earned_award])\n format.html { redirect_to @earned_award, notice: 'Earned award was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @earned_award.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @allergen_and_favorite_aliment.update(allergen_and_favorite_aliment_params)\n flash[:success] = 'Preference was successfully updated.' \n format.html {redirect_to action:\"index\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @allergen_and_favorite_aliment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @proposal = listing.proposals.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end", "def update\n @drug = Drug.find(params[:id])\n\n respond_to do |format|\n if @drug.update_attributes(params[:drug])\n format.html { redirect_to @drug, notice: 'Drug was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @drug.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @proposal = Proposal.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(update_params)\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @garrage.update(garrage_params)\n format.html { redirect_to @garrage, notice: 'Garrage was successfully updated.' }\n format.json { render :show, status: :ok, location: @garrage }\n else\n format.html { render :edit }\n format.json { render json: @garrage.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @adopter = Adopter.find(params[:id])\n\n if @adopter.update(adopter_params)\n head :no_content\n else\n render json: @adopter.errors, status: :unprocessable_entity\n end\n end", "def update\n @moose = Moose.find(params[:id])\n\n respond_to do |format|\n if @moose.update_attributes(params[:moose])\n format.html { redirect_to @moose, notice: 'Moose was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @moose.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @feeling = Feeling.find(params[:id])\n\n respond_to do |format|\n if @feeling.update_attributes(params[:feeling])\n format.html { redirect_to @feeling, notice: 'Feeling was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @feeling.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @adv = Advantage.find(params[:id])\n\n respond_to do |format|\n if @adv.update_attributes(params[:advantage])\n format.html { redirect_to @adv, notice: 'Advantage was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @adv.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @collection = current_user.collections.find(params[:collection_id]) \n @recommender = @collection.recommenders.find(params[:id])\n\n respond_to do |format|\n if @recommender.update_attributes(params[:recommender])\n format.html { redirect_to collection_recommenders_path(@collection), notice: 'Recommender was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recommender.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recommend_recommend_ptag = Recommend::RecommendPtag.find(params[:id])\n\n respond_to do |format|\n if @recommend_recommend_ptag.update_attributes(params[:recommend_recommend_ptag])\n format.html { redirect_to @recommend_recommend_ptag, notice: 'Recommend ptag was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recommend_recommend_ptag.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @people_term.update(people_term_params)\n format.html { redirect_to @people_term, notice: 'People term was successfully updated.' }\n format.json { render :show, status: :ok, location: @people_term }\n else\n format.html { render :edit }\n format.json { render json: @people_term.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n remedy = Remedy.find(params[:id])\n remedy.update(remedy_params)\n # render json: {remedyupdated: remedy}\n end", "def update\n @person = Person.find(params[:id]) \n respond_to do |format|\n if @person.update(person_params)\n format.json { render json: @person, status: :ok }\n else\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @allergy = Allergy.find(params[:id])\n\n respond_to do |format|\n if @allergy.update_attributes(params[:allergy])\n format.html { redirect_to(@allergy, :notice => 'Allergy was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @allergy.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @proposal = Proposal.find(params[:id])\n\n respond_to do |format|\n if @proposal.update_attributes(params[:proposal])\n format.html { redirect_to @proposal, notice: 'Proposal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @proposal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_signage\n @nugget = Nugget.find(params[:id])\n @nugget.unset_editable_time\n\n respond_to do |format|\n if @nugget.update_attributes(params[:nugget])\n @nugget.signage_review!\n\n # JAH - Jan 7 2014\n # There used to be a state here to \"review\" signage that isn't\n # necessary. Ergo we're going to transition the nugget immediately\n # from signage_review to signage_approve to move it further along.\n @nugget.signage_approve!\n\n format.html { redirect_to jobboard_path, notice: 'Read Signage Job completed.' }\n format.json { head :no_content }\n else\n format.html { redirect_to jobboard_path, error: 'Something went wrong. Job not completed.' }\n format.json { render json: @nugget.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n if @practice.update_attributes(params[:practice])\n format.html { redirect_to @practice, notice: 'Practice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @effort_rating.update(effort_rating_params)\n format.html { redirect_to @effort_rating, notice: 'Effort rating was successfully updated.' }\n format.json { render :show, status: :ok, location: @effort_rating }\n else\n format.html { render :edit }\n format.json { render json: @effort_rating.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n if @practice.update_attributes(params[:practice])\n format.html { redirect_to @practice, notice: 'Practice was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @measured_ingredient.update(measured_ingredient_params)\n format.html { redirect_to @measured_ingredient, notice: 'Measured ingredient was successfully updated.' }\n format.json { render :show, status: :ok, location: @measured_ingredient }\n else\n format.html { render :edit }\n format.json { render json: @measured_ingredient.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @judge.update(permitted_attributes(Judge))\n format.html { redirect_to @judge, notice: I18n.t('controllers.updated', model: Judge.model_name.human) }\n format.json { render :show, status: :ok, location: @judge }\n else\n format.html { render :edit }\n format.json { render json: @judge.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @good_guy.update(good_guy_params)\n format.html { redirect_to @good_guy, notice: 'Good guy was successfully updated.' }\n format.json { render :show, status: :ok, location: @good_guy }\n else\n format.html { render :edit }\n format.json { render json: @good_guy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recommendation = Recommendation.find(params[:id])\n @users=User.all\n @products=Product.all\n @occasions=Occasion.all\n respond_to do |format|\n if @recommendation.update_attributes(params[:recommendation])\n format.html { redirect_to occasion_path(@recommendation.occasion_id) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recommendation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end", "def update\n @offering = Offering.find(params[:id])\n\n respond_to do |format|\n if @offering.update_attributes(params[:offering])\n format.html { redirect_to @offering, notice: 'Oferta atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @offering.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person_interest = PersonInterest.find(params[:id])\n\n respond_to do |format|\n if @person_interest.update_attributes(params[:person_interest])\n format.html { redirect_to @person_interest, notice: 'Person interest was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @person_interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @alley.update_attributes(params[:alley])\n format.html { redirect_to @alley, notice: 'Bahn erfolgreich geändert.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n end\n end\n end", "def update\n respond_to do |format|\n if @learner.update(learner_params)\n format.html { redirect_to @learner, notice: 'Learner was successfully updated.' }\n format.json { head :ok, location: @learner }\n else\n format.html { render :edit }\n format.json { render json: @learner.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @getadvice = Getadvice.find(params[:id])\n\n respond_to do |format|\n if @getadvice.update_attributes(params[:getadvice])\n format.html { redirect_to @getadvice, notice: 'Getadvice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @getadvice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @shop_bonus_offer = Shop::BonusOffer.find(params[:id])\n\n respond_to do |format|\n if @shop_bonus_offer.update_attributes(params[:shop_bonus_offer])\n format.html { redirect_to @shop_bonus_offer, notice: 'Bonus offer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shop_bonus_offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @grade = Grade.find(params[:id])\n\n if @grade.update(grade_params)\n head :no_content\n else\n render json: @grade.errors, status: :unprocessable_entity\n end\n end", "def update\n @agency = Agency.find(params[:id])\n\n if @agency.update(agency_params)\n #head :no_content\n render json: @agency, status: :accepted, location: @agency #sera? status accepted? \n else\n render json: @agency.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @refugee.update(refugee_params)\n format.html { redirect_to @refugee, notice: 'Refugee was successfully updated.' }\n format.json { render :show, status: :ok, location: @refugee }\n else\n format.html { render :edit }\n format.json { render json: @refugee.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @skill_suggestion = SkillSuggestion.find(params[:id])\n\n respond_to do |format|\n if @skill_suggestion.update_attributes(params[:skill_suggestion])\n format.html { redirect_to @skill_suggestion, notice: 'Skill suggestion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @skill_suggestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @indication_for_meal.update(indication_for_meal_params)\n format.html { redirect_to @indication_for_meal, notice: 'Indication for meal was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @indication_for_meal.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @good.update(good_params)\n format.html { redirect_to @good, notice: 'Good was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @good.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @animal.update(animal_params)\n respond_with(@shelter)\n end", "def update\n respond_to do |format|\n if @allergy.update(allergy_params)\n format.html { redirect_to @allergy, notice: t('allergies.update_success') }\n format.json { render :show, status: :ok, location: @allergy }\n else\n format.html { render :edit }\n format.json { render json: @allergy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @go_term_enrichment = GoTermEnrichment.find(params[:id])\n\n respond_to do |format|\n if @go_term_enrichment.update_attributes(params[:go_term_enrichment])\n format.html { redirect_to @go_term_enrichment, notice: 'Go term enrichment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @go_term_enrichment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @guide_taxon.update(params[:guide_taxon])\n format.html { redirect_to @guide_taxon, notice: 'Guide taxon was successfully updated.' }\n format.json { render :json => @guide_taxon.as_json(:root => true, :methods => [:html]) }\n else\n format.html do\n load_data_for_edit\n render action: \"edit\"\n end\n format.json { render json: @guide_taxon.errors.full_messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n @persona = Persona.find(params[:id])\n \n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.json { head :ok }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n @foaf.interests.clear\n\n if(foaf_params.has_key?(:interests_attributes))\n interest_ids = foaf_params[:interests_attributes].split(\",\").map { |s| s.to_i }\n interest_ids.each do |i|\n @foaf.interests << Interest.find(i)\n #@foaf.update(Interest.find(i))\n end\n \n end\n\n respond_to do |format|\n if @foaf.update(name: foaf_params[:name], work: foaf_params[:work], \n slug: foaf_params[:slug], birthday: foaf_params[:birthday])\n format.html { redirect_to @foaf, notice: 'Foaf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @foaf.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n respond_to do |format|\n if @cage.update_attributes(params[:cage])\n format.json { head :no_content }\n else\n format.json { render json: @cage.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.64502907", "0.6194011", "0.61906266", "0.60452795", "0.6040802", "0.60342443", "0.60311645", "0.6014141", "0.60067177", "0.5993743", "0.59886533", "0.5961253", "0.59359497", "0.59280133", "0.5927895", "0.5898095", "0.58975756", "0.5894361", "0.5892792", "0.5889187", "0.58876735", "0.58850896", "0.58627796", "0.58551896", "0.5849739", "0.5849048", "0.583633", "0.5827587", "0.58275104", "0.58185697", "0.581702", "0.5814044", "0.5811441", "0.58102894", "0.5804297", "0.5797758", "0.579684", "0.5794553", "0.5793419", "0.5792039", "0.57883656", "0.57883066", "0.5784695", "0.5784054", "0.578204", "0.578102", "0.5779596", "0.5776128", "0.57736564", "0.57635224", "0.5761203", "0.5758973", "0.5753833", "0.5752732", "0.57483697", "0.5741481", "0.5739289", "0.5736828", "0.5735293", "0.5731214", "0.5729593", "0.5726638", "0.5722204", "0.5719834", "0.5718936", "0.5716694", "0.5714732", "0.5711944", "0.57076114", "0.57012993", "0.56944555", "0.5692022", "0.56915313", "0.5689131", "0.5680044", "0.5679687", "0.56793743", "0.5677552", "0.56721246", "0.5670169", "0.56685305", "0.56674945", "0.5666274", "0.56658083", "0.56647915", "0.56637084", "0.56633615", "0.56598544", "0.5657117", "0.5657075", "0.5653318", "0.5653144", "0.56528276", "0.56523967", "0.56482387", "0.5646012", "0.56455797", "0.5645083", "0.5642468", "0.56420463" ]
0.7048096
0
DELETE /suggested_ages/1 DELETE /suggested_ages/1.json
def destroy @suggested_age.destroy respond_to do |format| format.html { flash[:notice] = 'La edad sugerida se eliminó satisfactoriamente.' redirect_to suggested_ages_path } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @gage = Gage.find(params[:id])\n @gage.destroy\n\n respond_to do |format|\n format.html { redirect_to gages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @advocacy = Advocacy.find(params[:id])\n @advocacy.destroy\n\n respond_to do |format|\n format.html { redirect_to advocacies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @goody = Goody.find(params[:id])\n @goody.destroy\n\n respond_to do |format|\n format.html { redirect_to goodies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @adv = Advantage.find(params[:id])\n @adv.destroy\n\n respond_to do |format|\n format.html { redirect_to administration_advantages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @earned_award = EarnedAward.find(params[:id])\n @earned_award.destroy\n\n respond_to do |format|\n format.html { redirect_to earned_awards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recommended.destroy\n respond_to do |format|\n format.html { redirect_to recommendeds_url, notice: 'Recommended was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @target_age = TargetAge.find(params[:id])\n @target_age.destroy\n\n respond_to do |format|\n format.html { redirect_to target_ages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @drug = Drug.find(params[:id])\n @drug.destroy\n\n respond_to do |format|\n format.html { redirect_to drugs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @allergen_and_favorite_aliment.destroy\n respond_to do |format|\n format.html { redirect_to allergen_and_favorite_aliments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @advancement = Advancement.find(params[:id])\n @advancement.destroy\n\n respond_to do |format|\n format.html { redirect_to advancements_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goal_reward = GoalReward.find(params[:id])\n @goal_reward.destroy\n\n respond_to do |format|\n format.html { redirect_to goal_rewards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recommendation.destroy\n respond_to do |format|\n format.html { redirect_to recommendations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @explaination = Explaination.find(params[:id])\n @explaination.destroy\n\n respond_to do |format|\n format.html { redirect_to explainations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @suggest.destroy\n respond_to do |format|\n format.html { redirect_to suggests_url, notice: 'Suggest was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @personnage = Personnage.find(params[:id])\n @personnage.destroy\n\n respond_to do |format|\n format.html { redirect_to personnages_url }\n format.json { head :no_content }\n end\n end", "def delete\n @guide = Guide.find(params[:id])\n @guide.destroy\n respond_to do |format|\n format.html { redirect_to guides_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @helocagree = Helocagree.find(params[:id])\n @helocagree.destroy\n\n respond_to do |format|\n format.html { redirect_to(helocagrees_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @needed_good = NeededGood.find(params[:id])\n @needed_good.destroy\n\n respond_to do |format|\n format.html { redirect_to needed_goods_url }\n format.json { head :no_content }\n end\n end", "def delete_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by_id(params[:pathway_id])\n suggested_pathway.destroy\n render json: suggested_pathway\n end", "def destroy\n @recommendation = Recommendation.find(params[:id])\n @recommendation.destroy\n\n respond_to do |format|\n format.html { redirect_to recommendations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recommendation = Recommendation.find(params[:id])\n @recommendation.destroy\n\n respond_to do |format|\n format.html { redirect_to recommendations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @best_practice.destroy\n respond_to do |format|\n format.html { redirect_to best_practices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @prefer = Prefer.find(params[:id])\n @prefer.destroy\n\n respond_to do |format|\n format.html { redirect_to prefers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to badges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recommend_recommend_other = Recommend::RecommendOther.find(params[:id])\n @recommend_recommend_other.destroy\n\n respond_to do |format|\n format.html { redirect_to recommend_recommend_others_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dog_expense.destroy\n respond_to do |format|\n format.html { redirect_to dog_expenses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aliquotum = Aliquotum.find(params[:id])\n @aliquotum.destroy\n\n respond_to do |format|\n format.html { redirect_to aliquota_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meal_dish.destroy\n respond_to do |format|\n format.html { redirect_to meal_dishes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @appreciation.destroy\n respond_to do |format|\n format.html { redirect_to appreciations_url, notice: 'Appreciation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sondage.destroy\n respond_to do |format|\n format.html { redirect_to sondages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @representante_athlete = Representante::Athlete.find(params[:id])\n @representante_athlete.destroy\n\n respond_to do |format|\n format.html { redirect_to representante_athletes_url, notice: 'Atleta apagado com sucesso' }\n format.json { head :no_content }\n end\n end", "def destroy\n @award = Award.find(params[:id])\n @award.destroy\n\n respond_to do |format|\n format.html { redirect_to awards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gauge = Gauge.find(params[:id])\n @gauge.destroy\n\n respond_to do |format|\n format.html { redirect_to gauges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rating_alt = Rating.find(params[:id])\n @rating_alt.destroy\n\n respond_to do |format|\n format.html { redirect_to rating_alts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @three60.destroy\n respond_to do |format|\n format.html { redirect_to edit_admin_good_url(@good, anchor: \"three60\") }\n format.json { head :no_content }\n end\n end", "def destroy\n @meal.destroy\n\n respond_to do |format|\n format.html { redirect_to meals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @adoption_dog.destroy\n respond_to do |format|\n format.html { redirect_to adoption_dog_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @award = Award.find(params[:id])\n @award.destroy\n\n respond_to do |format|\n format.html { redirect_to awards_url }\n format.json { head :ok }\n end\n end", "def destroy\n @ingredient_suggestion.destroy\n respond_to do |format|\n format.html { redirect_to ingredient_suggestions_url, notice: 'Ingredient suggestion was successfully destroyed.' }\n format.json do\n # head :no_content\n render :nothing => true, :status => 200\n end\n end\n end", "def destroy\n @theader.destroy\n respond_to do |format|\n format.html { redirect_to offices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meal = Meal.find(params[:id])\n @meal.destroy\n\n respond_to do |format|\n format.html { redirect_to meals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @idea_rating.destroy\n respond_to do |format|\n format.html { redirect_to idea_ratings_url, notice: (I18n.t :act_delete) }\n format.json { head :no_content }\n end\n end", "def destroy\n @herald.destroy\n respond_to do |format|\n format.html { redirect_to heralds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meal_rating.destroy\n respond_to do |format|\n format.html { redirect_to meal_ratings_url }#, notice: 'Meal rating was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @drug_test = DrugTest.find(params[:id])\n @drug_test.destroy\n\n respond_to do |format|\n format.html { redirect_to drug_tests_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @practice.destroy\n respond_to do |format|\n format.html { redirect_to practices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @immigrant = Immigrant.find(params[:id])\n @immigrant.destroy\n\n respond_to do |format|\n format.html { redirect_to immigrants_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @diet_dish.destroy\n respond_to do |format|\n format.html { redirect_to diet_dishes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @kid.destroy\n respond_to do |format|\n format.html { redirect_to kids_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @advartisment.destroy\n respond_to do |format|\n format.html { redirect_to advartisments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @alley.destroy\n\n respond_to do |format|\n format.html { redirect_to alleys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gpath = Gpath.find(params[:id])\n @gpath.destroy\n\n respond_to do |format|\n format.html { redirect_to gpaths_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cage.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end", "def destroy\n @food = Food.find(params[:id])\n @food.destroy\n\n respond_to do |format|\n format.html { redirect_to foods_url }\n format.json { head :ok }\n end\n end", "def destroy\n @interesting = Interesting.find(params[:id])\n @interesting.destroy\n\n respond_to do |format|\n format.html { redirect_to interestings_url }\n format.json { head :ok }\n end\n end", "def destroy\n meal = Meal.find(params[:id])\n meal.destroy\n respond_to do |format|\n format.html { redirect_to meals_url, notice: 'Meal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @achievment.destroy\n respond_to do |format|\n format.html { redirect_to achievments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqdifficulty.destroy\n respond_to do |format|\n format.html { redirect_to reqdifficulties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @drug = Drug.find(params[:id])\n @drug.destroy\n\n respond_to do |format|\n format.html { redirect_to(drugs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ingredients_name = IngredientsName.find(params[:id])\n @ingredients_name.destroy\n\n respond_to do |format|\n format.html { redirect_to ingredients_names_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @percentual_gordura.destroy\n respond_to do |format|\n format.html { redirect_to percentual_gorduras_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gatha.destroy\n respond_to do |format|\n format.html { redirect_to gathas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @recommendation.destroy\n respond_to do |format|\n format.html { redirect_to recommendations_url, notice: 'Recommendation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @recommendation.destroy\n respond_to do |format|\n format.html { redirect_to recommendations_url, notice: \"Recommendation was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n compute.delete_flavor(params[:id])\n \n\n respond_to do |format|\n format.html { redirect_to flavors_path }\n format.json { head :ok }\n end\n end", "def destroy\n @api_v1_reward.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_rewards_url, notice: 'Reward was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @talent = Talent.find(params[:id])\n @talent.destroy\n\n respond_to do |format|\n format.html { redirect_to talents_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @measured_ingredient.destroy\n respond_to do |format|\n format.html { redirect_to measured_ingredients_url, notice: 'Measured ingredient was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_interview = Interview.find(params[:id])\n @admin_interview.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_interviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @familiar = Familiar.find(params[:id])\n @familiar.destroy\n\n respond_to do |format|\n format.html { redirect_to familiars_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @apprentice = Apprentice.find(params[:id])\n @apprentice.destroy\n\n respond_to do |format|\n format.html { redirect_to apprentices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hoge = Hoge.find(params[:id])\n @hoge.destroy\n\n respond_to do |format|\n format.html { redirect_to hoges_url }\n format.json { head :ok }\n end\n end", "def destroy\n @getadvice = Getadvice.find(params[:id])\n @getadvice.destroy\n\n respond_to do |format|\n format.html { redirect_to getadvices_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @g_anewby.destroy\n respond_to do |format|\n format.html { redirect_to g_anewbies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @garply.destroy\n respond_to do |format|\n format.html { redirect_to garplies_url, notice: 'Garply was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @female_shot_put.destroy\n respond_to do |format|\n format.html { redirect_to female_shot_puts_url, notice: 'Female shot put was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @talent = Talent.find(params[:id])\n @talent.destroy\n\n respond_to do |format|\n format.html { redirect_to talents_url }\n format.json { head :ok }\n end\n end", "def destroy\n @my_exam = MyExam.find(params[:id])\n @my_exam.destroy\n\n respond_to do |format|\n format.html { redirect_to my_exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @therapy_budget.destroy\n respond_to do |format|\n format.html { redirect_to therapy_budgets_url, notice: 'Therapy budget was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rating.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @red.destroy\n respond_to do |format|\n format.html { redirect_to reds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @award.destroy\n respond_to do |format|\n format.html { redirect_to awards_url, notice: 'Award was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ingredient = Ingredient.find(params[:id])\n @ingredient.destroy\n\n respond_to do |format|\n format.html { redirect_to ingredients_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goldmeasure.destroy\n respond_to do |format|\n format.html { redirect_to goldmeasures_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @grm_dog = GrmDog.find(params[:id])\n @grm_dog.destroy\n\n respond_to do |format|\n format.html { redirect_to grm_dogs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @improvement.destroy\n respond_to do |format|\n format.html { redirect_to improvements_path, notice: 'Tarefa foi apagada com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if @diet.destroy\n head :no_content, status: 200\n else\n render json: @diet.errors, status: 405\n end\n end", "def destroy\n @humanidades3 = Humanidades3.find(params[:id])\n @humanidades3.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades3s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @taxon_determination.destroy\n respond_to do |format|\n format.html { redirect_to taxon_determinations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @agency.update_attribute(:status, 'N')\n respond_to do |format|\n format.html { redirect_to agencies_url, notice: 'Agency was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @early_pregnancy = EarlyPregnancy.find(params[:id])\n @early_pregnancy.destroy\n\n respond_to do |format|\n format.html { redirect_to early_pregnancies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @intention = Intention.find(params[:id])\n @intention.destroy\n\n respond_to do |format|\n format.html { redirect_to intentions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @great.destroy\n respond_to do |format|\n format.html { redirect_to greats_url, notice: 'Great was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @criterion_grade.destroy\n respond_to do |format|\n format.html { redirect_to criterion_grades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @adherent.destroy\n respond_to do |format|\n format.html { redirect_to adherents_url, notice: 'Adherent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.6958503", "0.6870441", "0.67324245", "0.67225105", "0.6712022", "0.66936725", "0.668789", "0.66814315", "0.6667803", "0.6658467", "0.6640429", "0.66345865", "0.66145176", "0.66112804", "0.65976185", "0.65950966", "0.6594942", "0.65878034", "0.6583884", "0.657517", "0.65729266", "0.6572255", "0.65674734", "0.6557586", "0.6547409", "0.6546456", "0.6546333", "0.6536221", "0.6531704", "0.6526645", "0.65164137", "0.6516408", "0.6515223", "0.65148044", "0.651416", "0.6512633", "0.65082884", "0.6508284", "0.649775", "0.6485725", "0.6480582", "0.64793855", "0.6479106", "0.6477834", "0.64706194", "0.64661616", "0.64659476", "0.64656186", "0.6457458", "0.6457224", "0.64531016", "0.6452766", "0.6451333", "0.6449296", "0.6447039", "0.64449936", "0.64384395", "0.64384395", "0.64285964", "0.6428004", "0.64271677", "0.64262635", "0.64260364", "0.64247614", "0.6424697", "0.6423038", "0.64200956", "0.6419559", "0.6419555", "0.64108187", "0.6409039", "0.6406887", "0.6406825", "0.6401632", "0.64007366", "0.63968754", "0.6391753", "0.6388632", "0.6387195", "0.6386028", "0.6384351", "0.63825214", "0.6379372", "0.63732034", "0.6370404", "0.6369925", "0.636862", "0.63669014", "0.6365715", "0.63627577", "0.6360152", "0.63592225", "0.6359207", "0.63591975", "0.63587636", "0.63568777", "0.63568205", "0.63547575", "0.635397", "0.6353021" ]
0.7465402
0
Use callbacks to share common setup or constraints between actions.
def set_suggested_age @suggested_age = SuggestedAge.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 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 setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def 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 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 startcompany(action)\n @done = true\n action.setup\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 setup\n #implement in subclass;\n end", "def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def 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 shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def suggested_age_params params.require(:suggested_age).permit(:name) 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
Given an array of numbers and a target number, write a function to check if two numbers in the list sum equal to the target number. You should ask / they may ask solve before looking at this. (select to view) What if the list is sorted? Can you do it without using additional memory?
def two_number_sum array, n array.sort! reverse_index = array.size - 1 index = 0 while index >= reverse_index if array[index] + array[reverse_index] > n reverse_index -= 1 elsif array[index] + array[reveres_index] < n index += 1 else puts "#{array[index]} + #{array[reverse_index]}" index += 1 end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ok_two_sum(arr, target)\n sorted = quick_sort(arr)\n\n arr.each do |el|\n b_target = target - el\n return true if b_search(arr, b_target)\n end\n false\nend", "def okay_two_sum?(arr, target)\n arr.sort!\n\n arr.select! { |el| el < target }\n\n arr.each { |el| arr.include?(target - el) ? (return true) : next }\n false\nend", "def okay_two_sum?(array, target)\n array.sort!\n (1...array.length).each do |idx|\n return true if array[idx-1] + array[idx] == target\n end\n false\nend", "def okay_two_sum?(arr, target)\n # arr.sort.bsearch(target)\n # arr.combination(2).any? { |el,el2| return true if el + el2 == target }\n\n sorted = arr.sort\n (0...sorted.lentgh-1).each do |i|\n if arr[i] + arr[i+1] == target \n return true \n end \n end \nend", "def is_sum_of_any_two(target, numbers)\n for index1 in 0...numbers.length - 1\n for index2 in index1 + 1...numbers.length\n if (numbers[index1] + numbers[index2]) == target\n return true\n end\n end\n end\n false\nend", "def nums(target, *array)\n\tarray.each_with_index do |a, x|\n\t\tarray.each_with_index do |b, y|\n\t\t\tif x > y\n\t\t\t\tif a + b == target\n\t\t\t\t\treturn true\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\n\treturn false\nend", "def okay_two_sum?(arr, target)\n arr.sort!\n pairs = arr.combination(2)\n pairs.any? { |pair| pair.sum == target }\nend", "def okay_two_sums?(arr, target)\n arr.sort!\n\n arr.each do |num|\n return true if b_search?(arr, (target - num))\n end\n false\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort\n until sorted.empty?\n num = sorted.first\n sorted = sorted.drop(1)\n return true if sorted.bsearch { |el| target - num <=> el }\n end\n false\nend", "def okay_two_sum(arr, target)\n #O(n)\n arr.sort!\n i = 0\n j = arr.length - 1\n while i < j\n sum = arr[i] + arr[j]\n return true if sum == target\n if sum < target\n i += 1\n else\n j -= 1\n end\n end\n false\nend", "def okay_two_sum?(arr, target) # => [0,1,5,7] \n sorted = qs(arr)\n\n (0...sorted.length-1).each do |i|\n return true if sorted[i] + sorted[i + 1] == target\n end\n\n false\nend", "def okay_two_sum?(arr, target)\n sorted = quick_sort(arr)\n\n arr.each_with_index do |el, idx|\n p current = target - el\n bruh = bsearch(arr, current)\n next if bruh == idx\n return true unless bruh.nil?\n end\n\n return false\nend", "def two_sum(array, target)\n\n !!array.uniq.combination(2).detect { |a, b| a + b == target }\nend", "def okay_two_sum?(arr, target_sum)\n sorted = arr.sort\n sorted.each_with_index do |num, idx|\n num2 = target_sum - num\n next if num2 == num\n return true if b_search(sorted, num2) \n end\n false\nend", "def hardcore_two_sum?(arr, target)\n nums = {}\n arr.each{ |n| nums[n] = n }\n\n nums.each do |n,_|\n needed = target - n\n return true if !nums[needed].nil? && nums[needed] != n\n end\n\n false\nend", "def okay_two_sum(arr, target)\n sorted_arr = arr.sort\n while sorted_arr.any?\n partner = target - sorted_arr.pop\n return true if b_search(sorted_arr, partner)\n end\n\n false\nend", "def okay_two_sum?(arr, target)\n\n arr = arr.sort!\n\n i = 0\n j = arr.length - 1\n\n while i < j\n sum = arr[i] + arr[j]\n if sum < target\n i += 1\n elsif sum > target\n j -=1\n else\n return true\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort\n\n lowest = 0\n highest = arr.length - 1\n\n while lowest != highest\n return true if sorted[lowest] + sorted[highest] == target\n if sorted[lowest] + sorted[highest] > target \n highest -= 1\n elsif sorted[lowest] + sorted[highest] < target\n lowest += 1 \n end \n end \n false\nend", "def two_sum?(array, target_sum)\n array_hash = {}\n array.each do |el|\n array_hash[el] = true\n end\n\n array.each_with_index do |el|\n next if target_sum - el == el\n return true if array_hash[target_sum - el]\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n sorted = arr.sort\n (0...sorted.length).each do |i|\n (i + 1...sorted.length).each do |j|\n return true if sorted[i] + sorted[j] == target_sum\n break if sorted[i] + sorted[j] > target_sum\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort\n arr.each_index do |i|\n to_find = target - arr[i]\n sub_arr = arr[0...i] + arr[i + 1..-1]\n return true if sub_arr.bsearch { |x| x == to_find }\n end\n false\nend", "def two_sum?(arr, target_sum) \n hash = Hash.new(0)\n arr.each do |num|\n hash[num] = 1 \n end \n\n arr.each do |num|\n num2 = target_sum - num\n next if num2 == num\n next if hash[num2].nil?\n return true if hash[num2] == 1\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n\narr.sort!\n\nreturn false if arr[-1] < target_sum\n\ni = 0\ni += 1 until arr[i] > target_sum\n\nresult = []\nnew_arr = arr[0...i]\n(0...new_arr.length - 1).each do |i|\n (i+1...new_arr.length).each do |j|\n result << new_arr[i] + new_arr[j]\n end\n end\n result.include?(target_sum)\n\nend", "def bad_two_sum?(arr, target)\n sums = []\n arr.each_index do |i|\n (i+1...arr.length).each do |j|\n sums << arr[i] + arr[j]\n end\n end\n sums.include?(target)\nend", "def two_sum?(arr, target)\n s1 = Set.new \n arr.each_with_index do |el, idx|\n return true if s1.include?(target-el)\n s1.add(el)\n end\n false\nend", "def two_sums?(arr, target)\n # number_count = Hash.new(0)\n #\n # arr.each do |num|\n # number_count[num] += 1\n # end\n #\n # arr.each do |num|\n # other_num = target - num\n # number_count[num] -= 1\n # return true if number_count.include?(other_num) && number_count[other_num] > 0\n # end\n #\n # false\n set = Set.new(arr)\n arr.each do |num|\n set.delete(num)\n return true if set.include?(target - num)\n end\n false\nend", "def two_sum?(arr, target_sum)\n hash = Hash.new(0)\n arr.each_with_index do |num, idx|\n hash[num] = idx\n end\n arr.each_with_index do |num, idx|\n return true if hash.has_key?(target_sum - num) && idx != hash[target_sum - num]\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n arr.sort!\n i, j = 0, arr.length - 1\n\n until i == j\n this_sum = arr[i] + arr[j]\n return true if this_sum == target_sum\n this_sum < target_sum ? i += 1 : j -= 1\n end\n\n false\nend", "def okay_two_sum?(arr, target)\n sorted_arr = arr.sort\n sorted_arr.each.with_index do |el, idx|\n target_pair = target - el\n if sorted_arr[idx+1..-1].bsearch{|n| n >= target_pair } == target_pair\n p target_pair\n return true\n end\n end\n false\nend", "def two_sum?(arr, target_sum)\n debugger\n complements = {}\n\n arr.each do |el|\n return true if complements[target_sum - el]\n complements[el] = true\n end\n\n false\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort\n (0...arr.length).each do |idx|\n diff = target - arr[idx]\n return true if arr.include?(diff) && idx != arr.index(diff)\n end\n false\nend", "def okay_two_sum(arr, target)\n sorted = arr.sort\n sorted.each do |el|\n diff = target - el\n v = sorted.bsearch { |x| x == diff }\n return true unless v.nil?\n end\n \n false\nend", "def okay_two_sum?(arr, target_sum)\n sorted = arr.sort\n sorted.each_with_index do |num, idx|\n target = target_sum - num\n return true if binary_search(sorted, target, num)\n end\n false\nend", "def okay_two_sum?(arr, target)\n arr.sort!\n\n lhs = 0\n rhs = arr.length - 1 \n\n while lhs < rhs\n total = arr[lhs] + arr[rhs]\n if total > target\n rhs -= 1\n elsif total < target\n lhs += 1\n elsif total == target\n return true\n end\n\n end\n\n return false\nend", "def bad_two_sum?(arr, target)\n found = false\n arr.each_with_index do |a, l|\n arr.each_with_index do |b, n|\n next if l == n\n found = true if arr[l] + arr[n] == target\n end\n end\n found\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort \n arr.each_with_index do |el, idx|\n new_arr = arr[0...idx]+arr[idx+1..-1]\n result = my_bs(new_arr, target-el)\n return true if result\n end\n false\nend", "def two_sum(array, target)\n found = Hash.new(false)\n goal = nil\n\n array.each do |el|\n goal = (target - el).abs\n return true if found[goal] && goal + el == target\n found[el] = true\n end\n\n false\nend", "def two_sum?(arr, target)\n hash = Hash.new { |h, k| h[k] = 0}\n arr.each do |el|\n hash[el] += 1\n end\n\n arr.each do |el|\n hash2 = hash.dup\n hash2[el] -= 1\n return true if hash2[target - el] > 0\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n arr.sort!\n arr.each do |el|\n target = target_sum - el\n return true if !binary_search(arr, target).nil?\n end\n false\nend", "def two_sum?(arr, target_sum)\n hash = Hash.new\n\n arr.each do |el|\n hash[el] = el\n end\n\n arr.each do |el|\n target = target_sum - el\n return false if target == el\n return true if hash.key?(target)\n end\n\n false\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort\n arr.each do |ele|\n pivot = ele\n return true if binary_search(arr, (target - pivot))\n # pivot + num = target / first element\n end\n false\nend", "def ok_two_sum?(arr, target)\n new_array = arr.sort\n\n bsearch(new_array, target)\n\n\n arr.each do |el|\n return true if bsearch(arr, target - el)\n end\n false\nend", "def okay_two_sum?(arr, target)\n sorted_arr = arr.sort\n sorted_arr.each do |el|\n search_val = target - el\n return true if sorted_arr.bsearch {|x| x == search_val && x!= el}\n end\n false\nend", "def okay_two_sum?(arr, target)\r\n arr = arr.sort #n log n\r\n i, j = 0, arr.length - 1 #2\r\n\r\n while j > i #n\r\n curr_sum = arr[i] + arr[j]\r\n if curr_sum > target\r\n j -= 1\r\n elsif curr_sum < target\r\n i += 1\r\n else\r\n return true\r\n end\r\n end\r\n false\r\nend", "def okay_two_sum?(arr, target)\n arr.each do |el|\n return true if arr.bsearch { |x| x == (target - el) && x != el }\n end\n false\nend", "def bad_two_sum?(arr, target_sum)\n arr.size.times do |start|\n (start + 1...arr.size).each do |stop|\n return true if arr[start] + arr[stop] == target_sum\n end\n end\n false\nend", "def okay_two_sum?(arr, target_sum) # worst case O(N^2), average case O(n log n)\n sorted = arr.sort\n\n arr2 = []\n sorted.each do |num|\n arr2 << target_sum - num\n end\n\n arr2.each_with_index do |num, i| # O(n log n)\n result = sorted.bsearch { |x| x == num }\n if sorted.index(num) == i\n next\n end\n return true if result\n end\n\n false\nend", "def bad_two_sum?(array, target)\n array.each.with_index do |el1, idx1|\n array.each.with_index do |el2, idx2|\n if el1 + el2 == target && idx2 > idx1\n return true \n end\n end\n end\n false \nend", "def bad_two_sum?(arr, target)\n arr.each_with_index do |num1, idx1| #O(n)\n arr.each_with_index do |num2, idx2| #O(n)\n return true if idx2 > idx1 && num1 + num2 == target #O(1)\n end\n end\n false\nend", "def okay_two_sum?(array, target)\n sorted = array.sort\n addends = []\n\n (0..target/2).each do |addend|\n addends << addend\n end\n # debugger\n\n addends.each do |addend|\n debugger\n if bsearch(sorted, addend)\n # debugger\n return true if bsearch(sorted, target-addend)\n end\n end\n false\nend", "def arr_sum(arr, target)\n 0.upto(arr.size - 2) do |idx1|\n 1.upto(arr.size - 1) do |idx2|\n return true if arr[idx1] + arr[idx2] == target && idx2 > idx1\n end\n end\n false\nend", "def bad_two_sum?(arr, target)\n (0...(arr.length - 1)).each do |idx1|\n ((idx1 + 1)...arr.length).each do |idx2|\n return true if arr[idx1] + arr[idx2] == target\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n arr = arr.sort #n log n\n (0...arr.length).each do |i| #n\n search = bsearch(arr, target-arr[i]) # log n\n return true unless search.nil?\n end #n log n\n false\nend", "def okay_two_sum?(arr, target)\n\n arr.each do |ele1| # O(n)\n # debugger\n found = arr.bsearch do |ele2|\n # debugger\n (target - ele1) == ele2\n end\n return true unless found.nil? || arr.index(found) == arr.index(ele1)\n end\n false\nend", "def bad_two_sum?(arr, target)\n (0...arr.length).each do |idx1|\n return true if arr[idx1] == target\n (idx1+1...arr.length).each do |idx2|\n return true if (arr[idx1] + arr[idx2]) == target\n end\n end\n false\nend", "def two_sum?(arr, target)\n h = Hash.new\n arr.each_with_index do |val, i|\n h[val] = i\n end\n\n arr.each_index do |i|\n to_find = target - arr[i]\n return true if h[to_find] && h[to_find] != i\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n sorted_arr = arr.sort\n (0...sorted_arr.length).each do |i|\n next if i+1 == sorted_arr.length\n return true if sorted_arr[i] + sorted_arr[i+1] == target_sum\n end\n\n return false\nend", "def two_sum?(arr, target_sum)\n (0...arr.length).each do |i|\n (0...arr.length).each do |j|\n next if i == j\n return true if arr[i] + arr[j] == target_sum\n end\n end\n\n false\nend", "def okay_two_sum?(arr, target_sum)\n sorted_arr = quick_sort(arr)\n (0...sorted_arr.length - 1).each do |i|\n return true if sorted_arr[i] + sorted_arr[i + 1] == target_sum\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n arr.sort!\n arr.each_with_index do |el, idx|\n diff = target_sum - el\n other_idx = bsearch(arr, diff)\n next if idx == other_idx\n return true unless other_idx.nil?\n end\n false\nend", "def bad_two_sum?(arr, target_sum)\n arr.each_with_index do |o_el, o_idx|\n arr.each_with_index do |i_el, i_idx|\n next if o_idx == i_idx\n return true if o_el + i_el == target_sum\n end\n end\n false\nend", "def check_sum(array, target)\n\nend", "def bad_two_sum?(arr, target_sum) \n arr.each_with_index do |num, idx|\n arr.each_with_index do |num2, idx2|\n next if idx2 == idx\n return true if num2 + num == target_sum\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n i = 0\n j = arr.length - 1\n\n while i < j\n if arr[i] + arr[j] == target\n return true\n elsif arr[i] + arr[j] < target\n i += 1\n else\n j -= 1\n end \n end\n false\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort # n log n => quicksort => is nlogn DOMINANT\n sorted.each_with_index do |num, i| # => O(n)\n # return true if sorted[i] + sorted[-1 - i] == target\n return true if sorted[i + 1 .. - 1].bsearch {|number| target - num <=> number} # => O(log(n))\n # ASK TA ABOUT BSEARCH\n # bsearch {|ele| pivot <=> ele}\n end\n false\nend", "def okay_two_sum?(arr, target)\n\n arr.sort\n i = 0 \n j = arr.length\n until arr[i] + arr[j] == target || i == arr.length - 1\n return true \n end\n\n return false\n \n\nend", "def okay_two_sum_a?(arr, target_sum)\n arr = arr.sort\n i, j = 0, arr.length - 1\n\n while i < j\n case (arr[i] + arr[j]) <=> target_sum\n when 0\n return true\n when -1\n i += 1\n when 1\n j -= 1\n end\n end\n\n false\nend", "def bad_two_sum?(arr, target)\n (0...arr.length).each do |i|\n (i+1...arr.length).each do |j|\n return true if arr[i] + arr[j] == target\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n sorted = arr.sort #O(nlogn)\n idx_1 = 0\n idx_2 = arr.length - 1\n\n until idx_2 == idx_1 # O(n)\n if sorted[idx_1] + sorted[idx_2] > target\n idx_2 -= 1\n elsif sorted[idx_1] + sorted[idx_2] == target\n return true\n elsif sorted[idx_1] + sorted[idx_2] < target\n idx_1 += 1\n end\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n i = 0 \n j = arr.length - 1 \n arr = arr.sort \n\n while i < j \n if arr[i] + arr[j] == target_sum \n return true \n elsif arr[i] + arr[j] > target_sum\n j -= 1 \n else \n i += 1 \n end\n end\n false \nend", "def two_sum?(arr, target)\n sum_hash = {}\n\n arr.each do |el|\n sum_hash[el] = (target-el)\n return true if sum_hash[target-el]\n end\n\n false\nend", "def good_two_sum?(arr, target)\n counter_hash = Hash.new(0)\n arr.each do |el|\n counter_hash[el] += 1\n end\n\n arr.each do |el|\n search_val = target - el\n if counter_hash[search_val] && search_val==el\n return true if counter_hash[search_val] >= 2\n elsif counter_hash[search_val] > 0\n return true\n end\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n arr.sort!\n arr.each do |el|\n return true if arr.bsearch { |x| x >= (target_sum - el)}\n end\n false\nend", "def two_sum_v3?(arr, target) \n hash = Hash.new\n arr.each { |ele| hash[ele] = ele } #o(n)\n arr.each do |ele| #o(n)\n search_value = target - ele\n return true if !hash[search_value].nil? && hash[search_value] != ele\n end\n false\nend", "def okay_two_sum?(array,target_sum)\n array_sorted = array.sort\n i = 0\n j = array.length - 1\n\n until i == j\n sum = array_sorted[i] + array_sorted[j]\n return true if sum == target_sum\n if sum < target_sum\n i += 1\n elsif sum > target_sum\n j -= 1\n end\n end\n false\nend", "def two_sum?(arr,target)\n hash = Hash.new(0)\n arr.each do |el|\n hash[el] += 1\n difference = target - el\n if el == difference\n return true if hash[difference] > 1\n else\n return true if hash[difference] > 0\n end\n end\n false\nend", "def two_sum1?(arr, target_sum)\n sorted_arr = arr.sort\n length = arr.length - 1\n\n mid = arr.length / 2\n\n if mid < target_sum\n (0...mid).any? { |i| arr[i] + arr[i+1] == target_sum }\n else\n (mid...length).any? { |i| arr[i] + arr[i+1] == target_sum }\n end\nend", "def bad_two_sum?(arr, target_sum)\n arr.each_with_index do |num1, i|\n arr[i..-1].each do |num2|\n next if num1 == num2\n\n return true if (num1 + num2) == target_sum\n end\n end\n\n false\nend", "def bad_two_sum?(arr, target)\n arr.each_with_index do |num1,idx1|\n i = idx1 + 1\n while i < arr.length\n return true if num1 + arr[i] == target\n i+=1\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n\n arr = arr.sort\n i, j = 0, arr.length - 1\n\n while i < j \n case (arr[i] + arr[j]) <=> target\n when 0\n return true\n when -1\n i += 1\n when 1\n j -= 1\n end\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n array = arr.sort #n log n\n i1 = 0\n i2 = array.length-1\n while i1 < i2\n case array[i1] + array[i2] <=> target_sum\n when 0\n return true\n when -1\n i1 += 1\n when 1\n i2 -= 1\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n return false if arr.size < 2\n sum = arr.first + arr.last\n if sum > target\n arr.pop\n okay_two_sum?(arr, target)\n elsif sum < target\n arr.shift\n okay_two_sum?(arr, target)\n else\n true\n end\nend", "def two_sum?(arr, target_sum)\n h = Hash.new(0)\n\n arr.each { |num| h[num] += 1 }\n\n h.each do |key, v|\n subtarget = target_sum - key\n if h[subtarget] != 0 && (subtarget != key || (subtarget == key && v > 1))\n return true \n # if subtarget == key\n # return true if v > 1\n # end\n # return true\n end \n end\n false\n\nend", "def two_sum?(arr, target)\n hash = {}\n arr.each do |el|\n if hash[target - el]\n return true\n end\n hash[el] = true\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n sorted = arr.sort\n\n arr.each_with_index do |el, i|\n complement = target_sum - el\n\n if bsearch(arr[(i + 1)..-1], complement)\n return true\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n arr.each_with_index do |el,idx|\n if bi_search(arr[idx+1..-1], target, el)\n return true\n end\n end\n false\nend", "def okay_two_sum?(arr, target)\n small = arr.select {|el| el < target}\n small.each_with_index do |e, i|\n sub_el = target - e \n # arr.delete(sub_el)\n return true if small.include?(sub_el) && small[i] != sub_el\n \n end\n false \n \n \nend", "def two_sum?(array, target_sum)\n matches = {}\n array.each do |num|\n return true if matches.has_key?(target_sum - num)\n matches[num] = 1\n end\n false\nend", "def okay_two_sum(array, target_sum)\n array.sort\n i = 0\n j = array.length - 1\n while i < j\n case (array[i] + array[j]) <=> target_sum\n when -1\n i += 1\n when 0\n return true\n when 1\n j -= 1\n end\n end\n false\nend", "def bad_two_sum?(arr, target)\n\n arr.each.with_index do |x, idx|\n arr.each.with_index do |y, idy|\n if idx == idy\n next\n else\n if (x + y) == target\n return true\n end\n end\n end\n end\n\n return false\n\nend", "def can_sum(target_sum, numbers)\n return true if target_sum == 0 # 0 can be generated by taking no numbers from the array\n return false if target_sum < 0\n\n for num in numbers\n remainder = target_sum - num\n return true if can_sum(remainder, numbers) == true\n end\n\n return false\nend", "def bad_sum?(arr, target)\n\n (0...arr.length).each do |idx|\n (idx + 1...arr.length).each do |jdx|\n return true if arr[idx] + arr[jdx] == target\n end\n end\n false\nend", "def two_sum?(arr, target_sum)\n\n hash = {}\n arr.each_with_index do |i,idx|\n hash[i] = idx\n end\n arr.each_with_index do |j, idx2|\n return true if hash.has_key?(target_sum - j) && hash[target_sum-j] != idx2\n end\n false\n\nend", "def two_sum(array, target)\n arr_a = array.pop()\n var = false \n array.each { |x| \n return true if arr_a + x == target\n }\n return false \nend", "def bad_two_sum?(arr, target_sum)\n (0...arr.length - 1).each do |i|\n (i + 1..arr.length - 1).each do |j|\n return true if arr[i] + arr[j] == target_sum\n end\n end\n false\nend", "def two_sum(arr, target)\r\n a = arr.sort\r\n low = 0\r\n high = arr.length - 1\r\n while(low < high)\r\n sum = arr[low] + arr[high]\r\n if sum == target\r\n return true\r\n elsif(sum < target)\r\n low += 1\r\n else\r\n high -= 1\r\n end\r\n end\r\n return false\r\nend", "def sorting_two_sum(array, target)\n arr = array.sort\n arr.each_with_index do |int, idx|\n search_array = array[0...idx] + array[(idx + 1)..-1]\n return true if search_array.bsearch { |x| x == target - int }\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n sorted = arr.sort\n\n low, high = 0, arr.length - 1\n until low >= high\n case sorted[low] + sorted[high] <=> target_sum\n when -1\n low += 1\n when 0\n return true\n when 1\n high -= 1\n end\n end\n false\nend", "def okay_two_sum?(arr, target_sum)\n new_arr = arr.sort\n i = 0\n j = arr.length - 1\n while i < j \n if (arr[i] + arr[j] ) == target_sum\n return true\n elsif \n (arr[i] + arr[j] ) > target_sum\n j -= 1\n else\n i += 1\n end\n \n \n end\n false\nend", "def two_sum?(array, target)\n #O(n)\n hash = Hash.new(0)\n i = 1\n array.each do |ele|\n hash[ele] = i \n i += 1\n end\n hash.each_key do |k|\n return true if hash.has_key?(target - k) && hash[k] != hash[target - k]\n end\n false \nend", "def okay_two_sum?(nums, target)\n output = []\n i = 0\n j = nums.length - 1\n \n while i != j\n sum = nums[i] + nums[j]\n\n if sum == target\n output << [i, j]\n end \n\n if sum <= target\n i += 1\n else\n j -= 1\n end\n end\n\n output\nend" ]
[ "0.812872", "0.8014042", "0.7991881", "0.79207283", "0.79196185", "0.79155", "0.7909621", "0.7899482", "0.78901523", "0.78825253", "0.78772056", "0.7875436", "0.78481394", "0.78456914", "0.78445363", "0.7835107", "0.78241056", "0.7814977", "0.780704", "0.7805164", "0.77891034", "0.7789071", "0.7785955", "0.7773992", "0.77664506", "0.7765122", "0.77544665", "0.77519983", "0.7748863", "0.7748691", "0.7748675", "0.7746406", "0.77445096", "0.7737524", "0.77335095", "0.77321786", "0.7724806", "0.7722634", "0.77204156", "0.7715172", "0.77108264", "0.7701118", "0.76955026", "0.76825947", "0.7669383", "0.7668215", "0.7666577", "0.76648784", "0.7660477", "0.7660058", "0.7659508", "0.7658811", "0.76533484", "0.76497877", "0.7646337", "0.76378906", "0.7634985", "0.76339805", "0.7630061", "0.7622888", "0.76226383", "0.7622579", "0.7621987", "0.76214623", "0.7610885", "0.7596338", "0.7592509", "0.7591031", "0.7590868", "0.75853175", "0.7584816", "0.7584215", "0.7578899", "0.75776386", "0.7575421", "0.75738096", "0.7573755", "0.75716364", "0.7565846", "0.7556376", "0.7555546", "0.7553173", "0.75460386", "0.7545412", "0.75404215", "0.7539549", "0.7529817", "0.75280786", "0.75246805", "0.7523496", "0.75162673", "0.75117034", "0.7505931", "0.7501025", "0.74998045", "0.7496778", "0.74918675", "0.7491186", "0.74902725", "0.74897224", "0.74857295" ]
0.0
-1
Remove the nonpath compontents in the path_info (eg. the application context, which is naughtily passed in via the path_info)
def identifier_from_path @identifier_from_path ||= request.path_info.each_with_object({}) do | (key, value), hash| case value when String, Symbol, Numeric hash[key] = value end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_path_info(path_info)\n parts = path_info.split(PATH_SEPS)\n\n clean = []\n\n # Walk over each part of the path\n parts.each do |part|\n # Turn `one//two` or `one/./two` into `one/two`.\n next if part.empty? || part == \".\"\n\n if part == \"..\"\n # Turn `one/two/../` into `one`\n clean.pop\n else\n # Add simple folder names to the clean path.\n clean << part\n end\n end\n\n # If the path was an absolute path (i.e. `/` or `/one/two`),\n # add `/` to the front of the clean path.\n clean.unshift \"/\" if parts.empty? || parts.first.empty?\n\n # Join all the clean path parts by the path separator.\n ::File.join(*clean)\n end", "def unescaped_path\n path_info.split(/(%25|%2F)/i).each_slice(2).map { |v, m| CGI.unescape(v) << (m || '') }.join('')\n end", "def clean_path(path)\n if path\n (path[0] != '/' ? path.insert(0, '/') : path).gsub(/\\/{2,}/, '/')\n end\n end", "def sanitize_path(path); end", "def sanitize_path\n gsub(/[\\/: ]/,'_')\n end", "def clean_path(path)\n path.sub(/^\\//,'')\n end", "def remove_leading_slash(path); end", "def sanitize_path(path)\n path.gsub(/\\.\\.(?=$|\\/)/, '') unless path.nil?\n end", "def sanitize_path(path)\n # joining (e.g. `foo + \"/\" + bar`)\n path = path.gsub(%r{^/+}, \"/\")\n\n # remove leading and trailing slash\n path.sub(%r{^/}, \"\").sub(%r{/$}, \"\")\n end", "def implied_path\n clean_path(@request.path.dup)\n end", "def prepare(path)\n path.delete_prefix('/').gsub(%r{//}, '/').gsub(%r{/+\\z}, '')\n end", "def path_without_name_and_ref(path); end", "def real_path(path)\n clean(path, :path)\n end", "def unslashed(path)\n path.sub! /\\/$/, '' if path.end_with? '/'\n return path\n end", "def cleanpath(path)\n Pathname.new(path).cleanpath.to_s\n end", "def sanitize_path(path)\n # joining (e.g. `foo + \"/\" + bar`)\n path = path.gsub(/^\\/+/, '/')\n\n # remove leading and trailing slash\n return path.sub(/^\\//, '').sub(/\\/$/, '')\n end", "def unmatched_path\n path = unescaped_path\n path[0,0] = '/' if (path[0] != '/' && matched_path[-1] == '/') || path.empty?\n path\n end", "def normalize_path(path); end", "def normalize_path(path); end", "def path_without_name_and_ref(path)\n Jekyll.sanitized_path theme.root, path.split(\"/\").drop(1).join(\"/\")\n end", "def sanitize_path(path)\n if path.nil? || path.empty?\n \"\"\n else\n path.gsub(SANITIZATION_REGEX, \"\")\n end\n end", "def path_without_extentions\n path[/^[^.]+/]\n end", "def raw_path_info\n ((servlet_request = @env['java.servlet_request']) &&\n raw_path_info_from_servlet_request(servlet_request)) || path_info\n end", "def cleanup_paths(*paths)\n #.gsub(%r{#{@locations[:root]}/#{@locations[:root]}}, @locations[:root])\n paths.join('/').gsub(/[\\/]{2,}/,'/')\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 parse_context(path)\n path.chop! if path[-1] == '/'\n if path =~ %r{^/(.+)$}\n $1\n else\n ''\n end\n end", "def clean_path(component)\n component.to_s.gsub(/[^a-zA-Z0-9\\-_]/, '_')\n end", "def filtered_path; end", "def unnormalize_path(p)\n p[1] == 58 ? p[2, p.size] : p\n end", "def current_path_without_locale(path)\n locale_pattern = /^(\\/)(en|sv)?(\\/)?(.*)$/\n path.gsub(locale_pattern, '\\1\\4')\n end", "def format_path(path)\n path.blank? ? '' : path.gsub(%r{^/+}, '')\n end", "def scrub_path(p)\n np = \"\"\n for i in 0..(p.size-1)\n c = p[i]\n if c == '/'\n c = '\\\\'\n end\n np += c\n end\n np\nend", "def strip_base(env)\n stripped = nil\n req_path = env['REQUEST_PATH']\n stripped = req_path[@base_path.length..-1]\n end", "def sanitize_path(path)\n newpath = path.gsub(/\\/+/, '/')\n while newpath.gsub!(%r{([^/]+)/\\.\\./?}) { |match|\n $1 == '..' ? match : ''\n } do end\n newpath.gsub(%r{/\\./}, '/').sub(%r{/\\.\\z}, '/')\n end", "def path_to_remove(path)\n if aug.match(path).size == 1\n path\n elsif !aug.match(path + \"[1]\").empty?\n path + \"[1]\"\n else\n raise \"Unknown augeas path #{path}\"\n end\n end", "def normalize_path(path)\n path.sub(%r{^/}, '').tr('', '')\n end", "def cleanpath(path)\n path = Pathname.new(path) unless path.is_a?(Pathname)\n pathname(path.cleanpath.to_s)\n end", "def raw_path_info_from_servlet_request(servlet_request)\n # servlet spec decodes the path info, we want an unencoded version\n # fortunately getRequestURL is unencoded, but includes extra stuff - chop it off\n sb = servlet_request.getRequestURL.toString\n # chomp off the proto, host and optional port\n sb = sb.gsub(URL_UP_TO_URI, \"\")\n\n # chop off context path if one is specified - not sure if this is desired behaviour\n # but conforms to servlet spec and then remove the search part\n if servlet_request.getContextPath == \"\"\n sb\n else\n sb.gsub(URL_CHUNK, \"\")\n end.gsub(URL_SEARCHPART, \"\")\n end", "def skip_clean? path\n true\n end", "def clean_path(path)\n\t\t\tif @posix_support\n\t\t\t\treturn path\n\t\t\telse\n\t\t\t\treturn path.gsub(/\\//,'\\\\')\n\t\t\tend\n\t\tend", "def clean_path(x)\n ip = url_unescape(x)\n ip.gsub!(/^#{Regexp.escape(root_uri_path)}/, '') if root_uri_path\n ip\n end", "def clean_path(directory)\n directory.gsub(/\\/\\//, '/')\n end", "def clean_path(path)\n parts = []\n parts = path.split SEPS\n clean = []\n parts.each do |part|\n next if part.empty? || part == '.'\n part == '..' ? clean.pop : clean << part\n end\n @path = File.join(*clean)\n end", "def cleanpath_aggressive\n path = @path\n names = []\n pre = path\n while r = chop_basename(pre)\n pre, base = r\n case base\n when '.'\n when '..'\n names.unshift base\n else\n if names[0] == '..'\n names.shift\n else\n names.unshift base\n end\n end\n end\n if File.basename(pre).include? '/'\n names.shift while names[0] == '..'\n end\n Path.new(prepend_prefix(pre, File.join(*names)))\n end", "def check_path_for_danger_to_remove path\n absolute_path = File.expand_path(path).strip \n if absolute_path.blank? || absolute_path == '/'\n raise \"Removing '#{absolute_path}' is too dangerous.\"\n end\n end", "def ignore_path_prefix_cms(context={})\n %w(/p/order/payment-gateway /p/order/pay /p/myorder /p/activity)\n end", "def path_without_ext\n @path_without_ext ||= path.chomp(ext)\n end", "def safe_path(path)\n path.gsub(\"/\", \"^^\")\n end", "def fix_path(path)\n if path.count('?') > 1\n return path.gsub('?', '&').sub('&', '?')\n else\n return path\n end\n end", "def strip_regex_from(value)\n value.gsub(/^\\/|\\/$/,'')\n end", "def normalize_path(url); end", "def normalize_path(url); end", "def cleanup_pathname(path)\n return CGI.unescape(path).gsub(@music_root, '').gsub(%r{file:/+}, '').gsub(%r{^/+}, '')\n end", "def cleanpath\n path = @path\n names = []\n pre = path\n while r = chop_basename(pre)\n pre, base = r\n case base\n when '.'\n when '..'\n names.unshift base\n else\n if names[0] == '..'\n names.shift\n else\n names.unshift base\n end\n end\n end\n if /#{SEPARATOR_PAT}/o =~ File.basename(pre)\n names.shift while names[0] == '..'\n end\n self.class.new(prepend_prefix(pre, File.join(*names)))\n end", "def normalized_request_path(request)\n path = request.path.gsub(%r{/+}, '/').sub(%r{/$}, '')\n path.empty? ? '/' : path\n end", "def sanitize_opts_of_endpoint_data(opts, path)\n opts.delete_if {|k,v| path.match(/:#{k}(\\/|$)/) }\n end", "def unescape_path(path); end", "def strip_locale_uri(path)\n path.to_s.gsub(/\\/(en|da|no|sv)/i, \"\")\n end", "def normalized_request_path(path)\n if path == \"/\"\n path\n else\n path.chomp(\"/\")\n end\n end", "def normalize_path(path)\n path = \"/#{path}\"\n path.squeeze!('/')\n path.sub!(%r{/+\\Z}, '')\n path = '/' if path == ''\n path\n end", "def ignore_path_prefix_breadcrumb(context={})\n %w(/p/order/payment-gateway /p/order/pay /p/myorder /p/activity)\n end", "def sanitizeFilePath(path)\n path = path.gsub(/[^-a-z A-Z0-9_.\\/]/, '_').split(\"/\").map { |part|\n part.sub(/^\\.+/, '_').sub(/\\.+$/, '_')\n }.join('/')\nend", "def remove_dot_from_path(path)\n path.strip.split('/').reject { |dir| dir == '.' }\nend", "def normalize_req_path(req_path)\n # 1) Decode the req_path with URI::decode\n req_path = URI::decode(req_path)\n # 2) Strip first\n req_path = req_path.strip\n # 3) Remove first slash \n req_path = req_path[1..-1] if req_path[0,1]=='/'\n # 4) Remove last slash\n req_path = req_path[0..-2] if req_path[req_path.length-1,1]=='/'\n req_path\n end", "def path_debase(aPath, aBase)\n\t\t\t\taBase = append_slash(aBase)\n\t\t\t\taPath = remove_slash(aPath) unless aPath=='/'\n\t\t\t\taPath[0, aBase.length]==aBase ? aPath[aBase.length, aPath.length-aBase.length] : aPath\n\t\t\tend", "def normalize_path(path)\n path = \"/#{path}\"\n path.squeeze!('/')\n path.sub!(%r{/+\\Z}, '')\n path = '/' if path == ''\n path\n end", "def clean_path(*args)\n path = File.join(args.to_a.compact)\n Pathname.new(path).cleanpath.to_s\n end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def sanitized_path(base_directory, questionable_path); end", "def only_path(url)\n URI.parse(url).tap {|uri|\n uri.scheme = nil\n uri.host = nil\n uri.port = nil\n }.to_s\n end", "def sanitize_path(path)\n I18n.transliterate(path).scan(/\\w+/).join('_')\n end", "def sanitize_path path\n require 'pathname'\n dot = Pathname.new('.').expand_path\n\n path.reject do |item|\n path = Pathname.new(item).expand_path\n is_reject = nil\n relative = nil\n begin\n relative = path.relative_path_from(dot).to_s\n rescue ArgumentError\n # On Windows, sometimes crosses different drive letters.\n is_reject = true\n else\n is_reject = relative.start_with? '..'\n end\n is_reject\n end\n end", "def test_clean\n # Standard stuff\n assert_equal('/a/b/c', Pathname.new('/a/b/c').cleanpath)\n assert_equal('b/c', Pathname.new('./b/c').cleanpath)\n assert_equal('a', Pathname.new('a/.').cleanpath) # ***\n assert_equal('a/c', Pathname.new('a/./c').cleanpath)\n assert_equal('a/b', Pathname.new('a/b/.').cleanpath) # ***\n assert_equal('.', Pathname.new('a/../.').cleanpath) # ***\n assert_equal('/a', Pathname.new('/a/b/..').cleanpath)\n assert_equal('/b', Pathname.new('/a/../b').cleanpath)\n assert_equal('d', Pathname.new('a/../../d').cleanpath) # ***\n\n # Edge cases\n assert_equal('', Pathname.new('').cleanpath)\n assert_equal('.', Pathname.new('.').cleanpath)\n assert_equal('..', Pathname.new('..').cleanpath)\n assert_equal('/', Pathname.new('/').cleanpath)\n assert_equal('/', Pathname.new('//').cleanpath)\n\n assert_non_destructive\n end", "def fix_path(path)\n\t\t\tpath ||= \"\"\n\t\t\tpath = \"/#{path}\" unless path.start_with?(\"/\")\n\t\t\tpath = \"#{path}gitcommits.atom\" if path.end_with?(\"/\")\n\t\t\treturn path\n\t\tend", "def ignore_path_prefix_cms(context={})\n %w(/media/photo)\n end", "def clean_path path\n Sprout::System.create.clean_path path\n end", "def cleanpath_aggressive\n # cleanpath_aggressive assumes:\n # * no symlink\n # * all pathname prefix contained in the pathname is existing directory\n return Path::Name.create([],@absolute,@trail) if path.empty?\n absolute = absolute?\n trail = trail?\n names = []\n @path.each {|name|\n next if name == '.'\n if name == '..'\n if names.empty?\n next if absolute\n else\n if names.last != '..'\n names.pop\n next\n end\n end\n end\n names << name\n }\n return Path::Name.new(absolute ? '/' : '.') if names.empty?\n #path = []\n #path << '' if absolute\n #path.concat(names)\n Path::Name.create(names, absolute) #, trail)\n end", "def fix_path(path)\n path_segments = path.split(\"/\")\n \"/\" + path_segments[1] + \"/act_\" + path_segments[2]\n end", "def remove_path(file_path)\n\t\tfile_path.reverse.split(\"/\", 2)[0].reverse\n\tend", "def path_with_tags(tags = requested_tags)\n clean_path( path_without_tags + '/' + tags.uniq.compact.sort.map(&:clean_title).to_param )\n end", "def cleaned_relative_path\n @cleaned_relative_path ||=\n relative_path[0..-extname.length - 1]\n .sub(collection.relative_directory, \"\")\n .gsub(%r!\\.*\\z!, \"\")\n end", "def clean_up\n pathname.delete if pathname.exist?\n end", "def unc? path\n path.start_with? DOUBLE_SLASH\n end", "def normalize_path(path)\n normalized = Rex::Text.to_ascii(path).downcase\n normalized.gsub!(/[\\x00]*/, '') #delete padding\n normalized.gsub!(/\\\\x([0-9a-f]{2})/i, '') # delete hex chars\n\n normalized\n end", "def trim(path)\n path.to_s.sub(/^\\/*/, \"\")\n end", "def skip_paths; end", "def cleanpath(consider_symlink=false)\n if consider_symlink\n cleanpath_conservative\n else\n cleanpath_aggressive\n end\n end", "def facebook_path_scrub(url)\n return url.gsub('facebook/', '').gsub('/facebook', '')\n end", "def relativize_path(path)\n path.to_s.gsub(/^\\/?#{Regexp.escape(root_path.to_s)}\\/?/, '')\n end", "def sanitize_file_path(entry)\n parts = entry.name.split(File::SEPARATOR)\n parts.shift\n parts.join(File::SEPARATOR)\n end", "def path_to_displayed_path(path)\n path.gsub(/___[\\d_]+/, '')\n end", "def format_from_path\n\n return \"\" if path_info.nil? or path_info !~ /[.]/\n \n format = path_info.split(\".\").last\n \n if format =~ /[\\w+\\/]/\n format = format.split(\"/\")[0]\n end\n \n format\n end", "def slash_strip identifier\n /\\A\\/(.+)\\/\\Z/ =~ identifier and $1\n end", "def ignore_path_prefix_language(context={})\n %w(/p/order/payment-gateway /p/order/pay /p/myorder /p/activity)\n end", "def ignore_path_prefix_language(context={})\n %w(/media/photo)\n end", "def fix_api_path(path)\n path.gsub(/^\\/api/,'')\n end", "def __extra_path\n nil\n end" ]
[ "0.71762913", "0.6885928", "0.6716323", "0.6564095", "0.6539877", "0.6502877", "0.6493856", "0.64874", "0.6482505", "0.6471732", "0.64251405", "0.64216", "0.64189816", "0.63800365", "0.63728887", "0.6354283", "0.63109547", "0.6241099", "0.6241099", "0.62384945", "0.6236761", "0.6216061", "0.61998504", "0.6197866", "0.6182348", "0.6181992", "0.61787874", "0.61723953", "0.61660093", "0.6154635", "0.6142195", "0.6121436", "0.6111451", "0.61048543", "0.6104003", "0.60858077", "0.60441613", "0.6024521", "0.594251", "0.5941521", "0.5906392", "0.58975524", "0.5883669", "0.5856517", "0.5849225", "0.58389854", "0.58256507", "0.5819226", "0.5785961", "0.57679904", "0.57591033", "0.57591033", "0.57217085", "0.5707012", "0.5706701", "0.57021976", "0.56902575", "0.5671962", "0.5668612", "0.5665145", "0.5659422", "0.56527513", "0.5645594", "0.56369525", "0.56276506", "0.5618515", "0.5616582", "0.56070495", "0.56070495", "0.56070495", "0.56070495", "0.56070495", "0.56070495", "0.5604806", "0.5602234", "0.5584005", "0.55769306", "0.55616236", "0.5548319", "0.5539133", "0.5524803", "0.5520528", "0.5514448", "0.54970783", "0.5492151", "0.5469675", "0.54600376", "0.5443725", "0.54284924", "0.5420695", "0.5414637", "0.54087675", "0.5406156", "0.5404458", "0.53517675", "0.5348527", "0.5338594", "0.5336387", "0.53360003", "0.5327056", "0.5325649" ]
0.0
-1
See comments for base_url in lib/pact_broker/doc/controllers/app.rb
def ui_base_url request.env["pactbroker.base_url"] || "" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def base_url\n # Using the X-Forwarded headers in the UI can leave the app vulnerable\n # https://www.acunetix.com/blog/articles/automated-detection-of-host-header-attacks/\n # Either use the explicitly configured base url or an empty string,\n # rather than request.base_url, which uses the X-Forwarded headers.\n env[\"pactbroker.base_url\"] || \"\"\n end", "def base_url\n context[:base_url] || \"/\"\n end", "def baseurl; end", "def base_url_path; end", "def base_url\n self.class.base_url\n end", "def app_url\n url\n end", "def base_url\n return url\n end", "def base_url\n self.class.base_url\n end", "def base_url\n service.base_url\n end", "def baseurl=(_arg0); end", "def app_root; end", "def _base_url\n r = @_request\n scheme = r.scheme\n port = r.port\n \"#{scheme}://#{r.host}#{\":#{port}\" unless DEFAULT_PORTS[scheme] == port}\"\n end", "def base_url_path=(_arg0); end", "def base_url\n \"http://#{@host}:#{@port}\"\n end", "def app_path\n res = send_request_cgi({\n # default.a.get( check\n 'uri' => normalize_uri(target_uri.path, 'js', 'app.js'),\n\t 'method' => 'GET'\n })\n\n if res && res.code == 200 && res.body =~ /baseURL/\n data = res.body\n #word = data.scan(/\"#{string_to_split}\"\\] = \"([\\S\\s]*?)\"/)\n base_url = data.scan(/baseURL: '\\/([\\S\\s]*?)'/)[0]\n print_status(\"baseURL: #{base_url}\")\n return base_url\n else\n fail_with(Failure::NotVulnerable, 'baseURL not found!')\n end\n end", "def raplet_base_url\n \"#{request.scheme}://#{request.host}:#{request.port}\"\n end", "def base_url\n \"#{scheme}://#{host}\"\n end", "def base_url\n @base_url||=@options['base_url']\n end", "def base_url\n @is_sub_env_specific ? \"#{GlobalConstant::CompanyApi.root_url}#{GlobalConstant::Environment.url_prefix}/api/\"\n : \"#{GlobalConstant::CompanyApi.root_url}api/\"\n end", "def base_url\n if ENV['BASE_URL']\n ENV['BASE_URL']\n else\n 'https://beam.pro/'\n end\n end", "def set_base_url\n $base_url = (ENV['base_url'].nil? || ENV['base_url'].empty?) ? CONFIG['default_base_url'] : ENV['base_url']\nend", "def base_url\n BASE_URL.dup % [\"%s\", \"%s\", @api_key, \"%s\"] \n end", "def base_url\n GlobalConstant::Base.cms[:url] + \"api/preview/\"\n end", "def base_url\n GlobalConstant::CompanyOtherProductUrls.kit_root_url\n end", "def application_root; end", "def app_url\n return @app_url\n end", "def base_uri\t\t\t\n\t\tURI.parse( \"http://\" + @factory.site_name + \".\" + @factory.api_host_base + @path )\n\tend", "def base_path\n super.concat '/services'\n end", "def api_base_url; @opts[:api_base_url]; end", "def base_url\n base_href || url\n end", "def baseURL\n Rails.env.development? ? GeventAnalysis::Application::CONSTS[:dev_host] : GeventAnalysis::Application::CONSTS[:app_host]\n end", "def base_url\n self.mode == 'production' ? Ebay::Search::Api::PRODUCTION_URL : Ebay::Search::Api::SANDBOX_URL\n end", "def base_url\n @client.instance_variable_get(:@base_url)\n end", "def basepath; end", "def app; @app; end", "def base_path\n \"/api/v1\"\n end", "def get_base_path()\n return TembooSession.get_base_path + \"/choreos\"\n end", "def base_url\n GlobalConstant::Base.aml_config[:search][:base_url]\n end", "def base_uri\n if mode == 'sandbox'\n @base_uri = 'https://sandbox.fundamerica.com/api/'\n else\n @base_uri = 'https://apps.fundamerica.com/api/'\n end\n end", "def base_url_for(page)\n \"#{request.path}#{model.framework.prefix}/#{page}\"\n end", "def base_path\n self.class.base_path\n end", "def set_base_url\n uri = URI.parse(@page_url)\n @base_url = \"#{uri.scheme}://#{uri.host}\"\n end", "def base_web_url(artefact)\n if [\"production\", \"test\"].include?(ENV[\"RACK_ENV\"])\n public_web_url\n else\n Plek.current.find(artefact.rendering_app || artefact.owning_app)\n end\n end", "def api_root\n root_url << '/api'\n end", "def base_url\n @base_url || ENV.fetch(\"BOOKINGSYNC_URL\", \"https://www.bookingsync.com\")\n end", "def app_url\n ENV['APP_URL']\nend", "def base_path\n @base_path || self.class.base_path\n end", "def set_base_url(url)\n base_url = url\n end", "def with_base_url(base_url)\n @url_prefix = base_url\n self\n end", "def base_path\n Settings.forms_api_benefits_intake.url\n end", "def base_uri\n @base_uri\n end", "def app_root_url\n root_url(host: Rails.configuration.x.app_host)\n end", "def base_url\n @url.to_s.split('?').first\n end", "def endpoint_url\n # @@api_base + @request.endpoint\n ApiBase + @endpoint\n end", "def generate_base_urls \n set_scheme\n if(ENV['ENVIRONMENT']=='sandbox')\n @base_url = @sandbox + @bbc_domain \n @static_base_url = @static_sandbox + @bbc_domain\n elsif (ENV['ENVIRONMENT']=='live' && ENV['WWW_LIVE']=='false')\n @base_url = @www_prefix.chop + @bbc_domain\n @static_base_url = @static_prefix.chop + @bbci_domain\n @open_base_url = @open_prefix.chop + @bbc_domain\n elsif (ENV['ENVIRONMENT'].split('.')[0].include? 'pal') #address specific box\n @base_url = \"#{scheme}://#{ENV['ENVIRONMENT']}\" \n else\n @base_url = @www_prefix + ENV['ENVIRONMENT'] + @bbc_domain\n @static_base_url = @static_prefix + ENV['ENVIRONMENT'] + @bbci_domain\n @static_base_url = @static_prefix.chop + @bbci_domain if ENV['ENVIRONMENT'] == 'live'\n @open_base_url = @open_prefix + ENV['ENVIRONMENT'] + @bbc_domain\n end\n proxy = ENV['http_proxy'] || ENV['HTTP_PROXY'] \n @proxy_host = proxy.scan(/http:\\/\\/(.*):80/).to_s if proxy\n end", "def api_base_url(environment)\n GlobalConstant::KycApiBaseDomain.get_base_domain_url_for_environment(environment)\n end", "def generate_base_uri request, set=nil\n b_uri= uri request.env['REQUEST_URI'].to_s[0..-request.env['PATH_INFO'].length]\n @base_uri = b_uri if set\n b_uri\n end", "def index_page\n config && config.web_base\n end", "def base_url\n \"http#{configuration[:secure] ? 's' : ''}://#{configuration[:api_url]}/v#{configuration[:api_version]}\"\n end", "def base_url\n \"http#{configuration[:secure] ? 's' : ''}://#{configuration[:api_url]}/v#{configuration[:api_version]}\"\n end", "def base_href\n '/api/v1'\n end", "def base_url(info)\n main_url(info[:booking])\n end", "def paginable_base_url(page = 1)\n return url_for(@paginable_path_params.merge({ controller: @paginable_params[:controller],\n action: @paginable_params[:action], page: page }))\n end", "def base_path # rubocop:disable Rails/Delegate\n chip_api.base_path\n end", "def url_for_main; end", "def url_for_main; end", "def app_path\n \"#{root}/app\"\n end", "def app_path\n \"#{root}/app\"\n end", "def root_url\n '.'\n end", "def http_url\n context[:http_url] || context[:base_url]\n end", "def paginable_base_url(page = 1)\n @args = @args.with_indifferent_access\n url_params = @paginable_path_params.merge(\n controller: @args[:controller],\n action: @args[:action],\n page: page\n )\n url_for(url_params)\n end", "def base_url\n \"https://api.beezup.com/\"\n end", "def api_url(url = '')\n configuration.api_base + url\n end", "def url\n sprintf(\"%s/%s\",\n ::Configuration.instance.handles[:base_url],\n self.handle)\n end", "def api_url\n base_url.concat api_query_parameter\n end", "def api_url\n base_url.concat api_query_parameter\n end", "def api_url\n @api_url ||= URI.parse(\"#{super}?#{URI.encode_www_form(query_params)}\")\n end", "def base_uri\n \"#{self.class.base_uri}/#{name}\"\n end", "def base_url(id = \"\", action = nil)\n route = base_route + \"/\" + id.to_s\n if action.present?\n route += \"/\" + action\n end\n route\n end", "def app_uri\n @app_uri ||=\n @rack_context.getInitParameter('app.root') ||\n @rack_context.getInitParameter('rails.root') ||\n '/WEB-INF'\n end", "def base_uri\n \"#{api}/provider\"\n end", "def base_path\n if debug\n \"/#{debug_prefix}/\"\n else\n \"/#{digest_prefix}/\"\n end\n end", "def api_base_path\n 'https://messaging.bandwidth.com/api/v2'\n end", "def api_base_path\n \"/lol/platform/#{api_version}\"\n end", "def url\n \"#{Rails.configuration.baseurl}#{creator_path(self)}\"\n end", "def url\n @url = \"#{@http_mode}://#{self.config.servers[0]}\"\n @url << \"/#{self.config.context}\" if(!self.config.context.empty?)\n #self.config.log.debug_msg(\"Request base URL: #{@url}\")\n @url\n end", "def base_url\n ENV.fetch(\"FREEFEED_BASE_URL\")\n end", "def base_uri(value)\n @config[:base_uri] = value\n end", "def getBaseURL\r\n\t\t \t\t\treturn @@baseURL+\"portal/\"+String(portalId)+\"/\";\r\n\t\t \t\tend", "def base_url\n File.join(host, path)\n end", "def root_url\n url '/'\n end", "def build_url(action)\n \"#{@base_url}#{action}\"\n end", "def url\n raise \"Implement in child class\"\n end", "def set_base_url(url)\r\n @http_client.base_url = url\r\n end", "def base_url\n URI::HTTPS.build(host: @server, port: @port, path: @api)\n end", "def root_url\n \"#{@env['rack.url_scheme']}://#{@env['HTTP_HOST']}\"\n end", "def config; Rails.application.config.action_controller; end", "def make_url(apipath)\n @base_url + \"/api/open-v1.0/\" + apipath\n end", "def initialize()\n print 'Base URL: ', @@base_url\n end", "def base_url=(url)\n @base_url = url\n Prov.base_url=url\n end" ]
[ "0.73768973", "0.7365687", "0.71546173", "0.7089082", "0.701406", "0.7009818", "0.697468", "0.6877361", "0.68367034", "0.68036413", "0.6803307", "0.6749636", "0.67450804", "0.67395866", "0.66945314", "0.6660361", "0.6650225", "0.6573239", "0.6567789", "0.6558564", "0.65317833", "0.6521026", "0.6491626", "0.6484279", "0.6474885", "0.64703697", "0.64658535", "0.64426154", "0.64358974", "0.64346445", "0.642587", "0.6412273", "0.640991", "0.6356802", "0.6355761", "0.6355637", "0.6353653", "0.63493526", "0.63410133", "0.6320507", "0.630628", "0.6278304", "0.62756675", "0.6266868", "0.6263573", "0.6236804", "0.6233758", "0.62320024", "0.62196046", "0.6219583", "0.6208854", "0.6208778", "0.6199603", "0.61914414", "0.61903644", "0.6178626", "0.6164036", "0.6162467", "0.614434", "0.614434", "0.6138683", "0.6131594", "0.611212", "0.6109597", "0.60937953", "0.60937953", "0.6090717", "0.6090717", "0.60898066", "0.6087094", "0.6081882", "0.60566884", "0.60476685", "0.60423386", "0.60395545", "0.60395545", "0.6029022", "0.6026655", "0.60202885", "0.60193026", "0.59932786", "0.59932643", "0.5983295", "0.5969332", "0.59628606", "0.59625864", "0.5952634", "0.59409213", "0.59397984", "0.5939607", "0.5933599", "0.5931493", "0.5930209", "0.5924513", "0.5923069", "0.59202117", "0.59168005", "0.59134376", "0.5906312", "0.5892995" ]
0.7721294
0
We only use utf8 so leave encoding as it is
def encode(body) body end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def force_default_encoding; end", "def default_encoding\n Encoding::UTF_8\n end", "def utf8\n self.encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '?')\n end", "def to_utf8!; replace(to_utf8); end", "def ignore_encoding_error; end", "def suppress_encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def default_encoding; end", "def default_encoding; end", "def clean\n self.encode!('UTF-8', :invalid => :replace, :undef => :replace, replace: '')\n end", "def process_encoding(source)\n source.force_encoding(Encoding::UTF_8)\n end", "def encoding(encoding); end", "def force_utf8(buf) \n buf.force_encoding('ISO-8859-1').encode('UTF-8', 'UTF-8', replace: nil) \n end", "def force_to_utf8(text)\n ActiveSupport::Multibyte::Unicode.tidy_bytes(text)\n end", "def fix_utf_errors\n self.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode('UTF-8', 'UTF-16')\n end", "def encoding\n Encoding::UTF_8\n end", "def encoding\n Encoding::UTF_8\n end", "def force_utf32; end", "def force_utf32; end", "def force_utf32; end", "def transcode(str)\n str.force_encoding('UTF-8')\nend", "def charset\n 'UTF8'\n end", "def meta_encoding; end", "def meta_encoding; end", "def force_encoding(*); self; end", "def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend", "def set_encoding(text)\n unless text.encoding.name == \"UTF-8\"\n text = text.encode(\"UTF-8\", \n invalid: :replace, \n undef: :replace, \n replace: \"\"\n )\n end\n end", "def safe_encode_utf8(text)\n text.force_encoding('ASCII-8BIT').encode(\"UTF-8\", :invalid => :replace, :undef => :replace, :universal_newline => true)\nend", "def fix_utf8\n str = force_encoding(\"UTF-8\")\n return str if str.valid_encoding?\n\n str.encode(\"UTF-8\", \"binary\",\n invalid: :replace, undef: :replace, replace: \"\")\n end", "def z_fix_charset\n Iconv.iconv('UTF-8', 'UTF-8', self).first.to_s\n end", "def encodings; end", "def force_encoding(enc)\n end", "def utf8_safe\n encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n end", "def force_default_encoding=(_arg0); end", "def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend", "def force_encoding(*args) settings.force_encoding(*args) end", "def fix_encoding(str)\n str.force_encoding(Encoding.default_external) if str.respond_to?(:force_encoding)\n str\nend", "def convert_encoding(content); end", "def charset; end", "def charset; end", "def charset; end", "def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end", "def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def charset\n 'utf-8'\n end", "def force_utf8_encoding(msg)\n msg.respond_to?(:force_encoding) && msg.encoding.name != 'UTF-8' ? msg.force_encoding('UTF-8') : msg\nend", "def meta_encoding=(encoding); end", "def meta_encoding=(encoding); end", "def set_encoding\n Encoding.default_external = Encoding::UTF_8\n Encoding.default_internal = Encoding::UTF_8\n nil\n end", "def external_encoding()\n #This is a stub, used for indexing\n end", "def utf8(string)\n string.force_encoding(Encoding::UTF_8)\n end", "def utf8\n c = self.class\n if String.method_defined? :force_encoding\n replace c.new(map(&:utf8))\n else\n self\n end\n end", "def fix_encoding\n self.title = EncodingManager.fix_encoding self.title\n self.url = EncodingManager.fix_encoding self.url\n self.author = EncodingManager.fix_encoding self.author\n self.content = EncodingManager.fix_encoding self.content\n self.summary = EncodingManager.fix_encoding self.summary\n self.guid = EncodingManager.fix_encoding self.guid\n end", "def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend", "def found_encoding; end", "def found_encoding; end", "def encoding_found; end", "def encoding_found; end", "def encoding\n\t'ISO-8859-1'\nend", "def internal_encoding()\n #This is a stub, used for indexing\n end", "def utf8(string)\n string.force_encoding('utf-8') unless string.nil?\n end", "def isutf8;\tKconv.isutf8(self) end", "def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end", "def test_encoded_in_change_out\n doc = Document.new( @encoded )\n doc.xml_decl.encoding = \"UTF-8\"\n assert_equal(\"UTF-8\", doc.encoding)\n REXML::Formatters::Default.new.write( doc.root, out=\"\" )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @not_encoded.b, out )\n char = XPath.first( doc, \"/a/b/text()\" ).to_s\n char.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( \"ĉ\".b, char )\n end", "def contents_convert_utf8\n @publication.title = @publication.title ? @publication.title.force_encoding('UTF-8') : \"\"\n @publication.abstract = @publication.abstract ? @publication.abstract.force_encoding('UTF-8') : \"\"\n @publication.contents = @publication.contents ? @publication.contents.force_encoding('UTF-8') : \"\"\n end", "def to_utf8; convert_format(ASCII8BIT, UTF8); end", "def enc_utf8\n\n @@enc_utf8 ||= \n ( Encoding.find( \"utf-8\" ) or raise \"No utf-8 encoding found (?!)\" )\nend", "def force_utf8(buf)\n return buf if buf.valid_encoding?\n buf.force_encoding('ISO-8859-1').encode('UTF-8', 'UTF-8', replace: nil)\n end", "def utf8_enforcer_tag; end", "def encoding=(enc); end", "def clean_utf\n attribute_names.each do |field|\n next unless self[field]\n next unless self[field].is_a? String\n next if field=='password_digest'\n self[field] = self[field].encode(\"UTF-8\",:invalid=>:replace,:undef=>:replace,:replace=>\"\")\n end\n end", "def encoding_line; end", "def protect_encoding(x)\n x.encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n end", "def toutf8; Kconv.toutf8(self) end", "def encoding\n # noop?\n end", "def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend", "def test_encoding\n assert_equal 'UTF-8', @conn.encoding\n end", "def test_encoding\n assert_equal \"UTF-8\", @conn.encoding\n end", "def charset=(_); end", "def force_encoding(string)\n string.force_encoding(encoding)\n end", "def default_encoding=(_arg0); end" ]
[ "0.7801877", "0.7774677", "0.77638423", "0.77203697", "0.7693535", "0.7692788", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75883067", "0.75790507", "0.75790507", "0.75684965", "0.7515694", "0.7505178", "0.7476426", "0.7470449", "0.7460365", "0.7447467", "0.7447467", "0.74147457", "0.74147457", "0.74147457", "0.73997283", "0.7391507", "0.7384631", "0.7384631", "0.73708874", "0.7352174", "0.7297655", "0.7292617", "0.72810704", "0.72805774", "0.7246851", "0.72224724", "0.72062063", "0.71932775", "0.71877474", "0.71614844", "0.7158644", "0.7158532", "0.71546596", "0.71546596", "0.71546596", "0.71473163", "0.71473163", "0.7145883", "0.7145883", "0.71451914", "0.71451914", "0.71451914", "0.71451914", "0.71451914", "0.71350884", "0.7130331", "0.71272725", "0.71272725", "0.71226436", "0.71204406", "0.7114525", "0.7113985", "0.71139777", "0.71121275", "0.70978034", "0.70978034", "0.7090921", "0.7090921", "0.70663345", "0.705832", "0.7056663", "0.70565593", "0.70548767", "0.70545524", "0.70505464", "0.70378506", "0.7035991", "0.7028223", "0.6984272", "0.6972105", "0.6965183", "0.6962798", "0.69620955", "0.6960476", "0.6952926", "0.69391924", "0.69368124", "0.6930376", "0.6914689", "0.6909371", "0.6881768" ]
0.0
-1
Not necessarily an existing integration
def integration if consumer_specified? && provider_specified? OpenStruct.new(consumer: consumer, provider: provider) else nil end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def integration_name; end", "def integration\n @integration\n end", "def integrate!\n raise NotImplementedError.new\n end", "def integrations; end", "def integrations; end", "def missing; end", "def integration_path(integration)\n \"spec/integration/#{integration}\"\nend", "def integration_test?\n # checks for the existance of a method only found in integration tests\n defined?(post_via_redirect)\n end", "def integration_test()\n return [\"all\"]\n end", "def coupled?\n false\n end", "def set_integration\n @integration = Integration.find(params[:id])\n end", "def set_integration\n @integration = Integration.find(params[:id])\n end", "def from_api?; false end", "def isolated; end", "def isolated; end", "def instrumentalists?\n true\n end", "def coupled?\n true\n end", "def new_session\n IntegrationSession.new\n end", "def implemented_in; end", "def one_gradable_ex_only\n end", "def missing?; end", "def support\n raise \"Not implemented\"\n end", "def integration_test?\n defined?(follow_redirect!)\n end", "def initialize(integration)\n @integration = integration\n @references = [ ]\n end", "def unconfigured?\n self.subscription == :unconfigured\n end", "def plugin_installed?(name)\n raise \"Not Implemented\"\n end", "def commence\n raise NotImplementedError\n end", "def autorun?\n fail NotImplementedError\n end", "def ignored?()\n #This is a stub, used for indexing\n end", "def service; raise NotImplementedError; end", "def isolated?; end", "def isolated?; end", "def vendor; end", "def set_integration\n begin\n @integration = Integration.find(params[:id])\n rescue Exception => e\n Services::Slog.exception e\n flash[:notice] = \"Sorry, <i class=\\\"icon-shuffle\\\"></i> couldn't find the integration identified by <em>#{params[:id]}</em>.\"\n redirect_to :controller => \"templates\", :action => \"index\"\n end\n end", "def spam?( env ); raise NotImplementedError; end", "def missing?; false; end", "def hidden_apis; end", "def activated?\n raise NotImplementedError\n end", "def activated?\n raise NotImplementedError\n end", "def api_only; end", "def api_only; end", "def api_only; end", "def exclude_from_registry; end", "def execute(method_name, params, integration_url)\n item = Spree::Integration.available_vendors_integrations(self.vendor).select {|i| i[:integration_key] == self.integration_key}.first\n available_methods = self.method(\"#{self.integration_key}_methods\").call\n if available_methods.fetch(method_name.to_sym, false)\n self.method(\"#{self.integration_key}_#{method_name}\").call(params, integration_url)\n else\n { url: \"#{integration_url}/edit\", flash: { error: 'Unauthorized integration method' }}\n end\n end", "def implementation; end", "def implementation; end", "def macro; raise NotImplementedError; end", "def macro; raise NotImplementedError; end", "def macro; raise NotImplementedError; end", "def included_interfaces; end", "def configured?; false; end", "def integration_name\n @integration_name ||= begin\n name = self.name.split('::').last\n name.gsub!(/([A-Z]+)([A-Z][a-z])/, '\\1_\\2')\n name.gsub!(/([a-z\\d])([A-Z])/, '\\1_\\2')\n name.downcase!\n name.to_sym\n end\n end", "def integrate!\n UI.section(integration_message) do\n XCConfigIntegrator.integrate(target, native_targets)\n\n remove_obsolete_script_phases\n add_pods_library\n add_embed_frameworks_script_phase\n remove_embed_frameworks_script_phase_from_embedded_targets\n add_copy_resources_script_phase\n add_check_manifest_lock_script_phase\n add_user_script_phases\n add_on_demand_resources\n end\n end", "def running\n fail 'not impl.'\n end", "def external; end", "def provider; end", "def wrapper; end", "def check_integrands_before_run\n if integrands.count > 0\n integrands(:joins => :experiments).each do |integrand|\n raise(StandardError, \"Integrands must be run first\") unless integrand.experiment.has_run_successfully?\n end\n end\n end", "def interface; end", "def interface; end", "def api; end", "def api; end", "def missed?; end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def integration_test?\n defined?(post_via_redirect)\n end", "def backend; end", "def ab_not_showing(_experiment, _identity)\n raise \"Not implemented\"\n end", "def registration_required?\n not hosted?\nend", "def registration_required?\n not hosted?\nend", "def support\n end", "def deduplicate_integrations(integrations)\n integrations\n .group_by{ | integration| [integration.consumer_id, integration.provider_id] }\n .values\n .collect { | duplicate_integrations | duplicate_integrations.find(&:required?) || duplicate_integrations.first }\n end", "def is_stub?\n is_registered == false\n end", "def distracted?\n false\n end", "def already_reported; end", "def already_reported; end", "def plugin_id; end", "def external?\n false\n end", "def uncovered\n return true\n end", "def integrate!\n UI.section(integration_message) do\n target_installation_result.non_library_specs_by_native_target.each do |native_target, spec|\n add_embed_frameworks_script_phase(native_target, spec)\n add_copy_resources_script_phase(native_target, spec)\n add_on_demand_resources(native_target, spec) if spec.app_specification?\n UserProjectIntegrator::TargetIntegrator.create_or_update_user_script_phases(script_phases_for_specs(spec), native_target)\n end\n add_copy_dsyms_script_phase(target_installation_result.native_target)\n add_copy_xcframeworks_script_phase(target_installation_result.native_target)\n UserProjectIntegrator::TargetIntegrator.create_or_update_user_script_phases(script_phases_for_specs(target.library_specs), target_installation_result.native_target)\n end\n end", "def internal?; end", "def integrated\n File.exist?(gemfile)\n end", "def available; end", "def available; end", "def standalone_discovered; self; end", "def standalone_discovered; self; end", "def parent_api; end", "def parent_api; end", "def integration_params\n params.require(:integration).permit(:identifier, :title, :help, :payload, :memory)\n end", "def integrate!\n return if native_targets.empty?\n UI.section(integration_message) do\n add_xcconfig_base_configuration\n add_pods_library\n add_copy_resources_script_phase\n add_check_manifest_lock_script_phase\n user_project.save\n end\n end", "def integration_test?\n # The post_via_redirect method is available only in integration tests.\n defined?(post_via_redirect)\n end", "def integration_test?\n Rails.env.test? && defined?(Cucumber::Rails)\n end", "def call_squadron; end", "def private; end", "def inspec\n nil\n end", "def ayah_init\r\n ayah = AYAH::Integration.new(\"d5fbcc5d5d32f645158e72fc00b55eea205b13b4\", \"3969dc9a22c5378abdfc1d576b8757a8638b16d7\")\r\n end", "def issn; end" ]
[ "0.7420807", "0.7124254", "0.6791569", "0.661722", "0.661722", "0.5888167", "0.5796363", "0.5697063", "0.56926394", "0.55801815", "0.5578326", "0.5578326", "0.55775416", "0.5544825", "0.5544825", "0.554074", "0.5468669", "0.5468576", "0.54601115", "0.5449964", "0.54396534", "0.54253525", "0.5420535", "0.5357427", "0.5349575", "0.53288066", "0.5316252", "0.53055894", "0.5296099", "0.5295519", "0.52922726", "0.52922726", "0.5287563", "0.52860755", "0.5286035", "0.5272282", "0.52709246", "0.5270923", "0.5270923", "0.5261367", "0.5261367", "0.5261367", "0.5257366", "0.5254834", "0.5250956", "0.5250956", "0.5248975", "0.5248975", "0.5248975", "0.5240238", "0.523719", "0.5226004", "0.5221448", "0.5221072", "0.5217775", "0.5200138", "0.5187333", "0.51825887", "0.51813823", "0.51813823", "0.51751584", "0.51751584", "0.51736265", "0.516135", "0.516135", "0.516135", "0.516135", "0.516135", "0.516135", "0.516135", "0.5158426", "0.5157712", "0.5154263", "0.5154263", "0.5154252", "0.51473594", "0.5146811", "0.5141764", "0.51400316", "0.51400316", "0.51400226", "0.51386684", "0.51372737", "0.5136973", "0.51234627", "0.5122933", "0.51201266", "0.51201266", "0.51188374", "0.51188374", "0.511494", "0.511494", "0.5114537", "0.51091737", "0.5108722", "0.510098", "0.5097882", "0.5096384", "0.50952643", "0.50945944", "0.509163" ]
0.0
-1
Ensure we have valid JSON if a JSON body is required OR if a body has been provided
def content_type_is_json_but_invalid_json_provided? content_type_json? && ((request_body_required? || any_request_body?) && invalid_json?) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_json(json)\n JSON(json)\n #NOTE: Rescuing TypeError too in case json is not a String\n rescue ::JSON::ParserError, TypeError\n nil\n end", "def format_body(body, json)\n if json && !body.is_a?(String) && !body.nil?\n body.to_json\n elsif body.is_a?(String) || body.nil?\n body\n else\n raise TaskHelper::Error.new(\n 'body must be a String when json_endpoint is false',\n 'http_request/body-type-error'\n )\n end\n end", "def ensure_json_request\n return if params[:format] == 'json' || request.headers['Accept'] =~ /json/\n head :not_acceptable\n end", "def valid_body?\n request.feedback.body && valid_json?(request.feedback.body)\n end", "def ensure_json_request\n return render_message({status:ERR_STATUS,responseMessage: NOT_ACCEPTABLE_MESSAGE, responseCode: NOT_ACCEPTABLE }) unless request.format == :json\n end", "def ensure_json_content_type\n request.headers['Content-Type'] =~ /application\\/json/\n end", "def validate_format\n data = JSON.decode(data) if data.class == Hash\n JSON.parse(data) && nil if data.present?\n rescue JSON::ParserError\n nil\n end", "def validate_format\n JSON.parse(content) && nil if content\n rescue JSON::ParserError => err\n err.message\n end", "def validate_format\n JSON.parse(content) && nil if content\n rescue JSON::ParserError => err\n err.message\n end", "def valid_json?(json)\n begin\n JSON.parse(json)\n return true\n rescue Exception => e\n return false\n end\n end", "def valid_json?(json)\n begin\n JSON.parse(json)\n return true\n rescue Exception => e\n return false\n end\n end", "def valid?(json:)\n return false unless json.present?\n\n json[:type].present? && json[:identifier].present?\n end", "def valid_json?(json)\n JSON.parse(json)\n true\n rescue JSON::ParserError\n false\n end", "def valid?\n unless @json.class == Hash\n return false\n end\n\n unless @json['method'].class == String\n return false\n end\n\n unless @json['params'].class == Array\n return false\n end\n\n return true\n end", "def valid_json?(json)\n begin\n JSON.parse(json)\n return true\n rescue JSON::ParserError => e\n return false\n end\n end", "def parse_body(body)\n if body\n if body.is_a?(Hash)\n body\n else\n begin\n data = JSON.parse(body)\n data\n rescue JSON::ParserError\n {}\n end\n end\n else\n {}\n end\nend", "def valid_json(json)\n JSON.parse(json)\n return true\n rescue JSON::ParserError => e\n return false\n end", "def valid?(json: {})\n json.present? && json[:license_ref].present? && json[:start_date].present?\n end", "def parse_body\n return unless body.is_a?(String)\n JSON.parse(body)\n rescue\n # not a valid json body\n nil\n end", "def assert_valid_json(res)\n require 'json'\n assert_content_type res, \"application/json\"\n begin\n JSON.parse(res.body)\n rescue JSON::ParserError => e\n flunk build_message(\"\", \"String <?> is not valid JSON. The Parser Error was: #{e.message}\", res.body)\n end\n end", "def valid_json?( json )\n begin\n JSON.parse( json )\n return true\n rescue JSON::ParserError => error\n @logger.error(\"json parse error: #{error}\") if @debug\n return false\n end\n end", "def validate_json data\n JSON::Validator.fully_validate(\"schema.json\", data)\n end", "def api_body(obj)\n obj = obj.as_json unless obj.is_a?(String)\n # noinspection RubyMismatchedArgumentType\n obj.is_a?(Hash) ? reject_blanks(obj) : obj\n end", "def json_params\n begin\n JSON.parse(request.body.read)\n rescue\n halt 400, serialize_error('Invalid JSON.')\n end\n end", "def malformed_request?\n from_json\n @coffee.nil? || @order.nil?\n end", "def json_body\n\t\t\t@json_body ||=\n\t\t\t\tbegin\n\t\t\t\t\tJSON.parse(req_body)\n\t\t\t\trescue JSON::ParserError\n\t\t\t\t\tnil\n\t\t\t\tend\n\t\tend", "def wrong_params?\n if has_not_mandatory_params?\n render json: { message: \"Wrong data params\" }, status: 400\n end\n end", "def ensure_hash(params)\n case params\n when String then params.present? ? ensure_hash(JSON.parse(params)) : {}\n when Hash, ActionController::Parameters then params\n when nil then {}\n else raise ArgumentError, \"Unexpected parameter: #{params}\"\n end\n end", "def body_hash_required?\n false\n end", "def is_json? (string_to_validate)\n \t\t\tbegin\n\t\t !!JSON.parse(string_to_validate)\n\t\t rescue\n\t\t false\n\t\t end \t\t\t\n \t\tend", "def is_json?(json)\n begin\n JSON.parse(json)\n return true\n rescue Exception => e\n return false\n end\nend", "def validate\n @errors = JSON::Validator.fully_validate(\n schema, params,\n errors_as_objects: true\n )\n @errors.empty?\n end", "def parse_questions(body)\n if body\n begin\n JSON.parse(body)\n rescue JSON::ParseError\n nil\n end\n else\n nil\n end\nend", "def parse_json(body)\n JSON.parse(body)\n rescue JSON::ParserError\n {}\n end", "def json_input?\n return request.content_type == 'application/json'\n end", "def valid_json?(string)\n !!JSON.parse(string)\n rescue JSON::ParserError\n false\n end", "def check_request_format\n unless request.content_type == 'application/json'\n error = ErrorSerializer.serialize({ format: \"Invalid request format. Only JSON requests are supported.\" })\n render json: error, status: :unsupported_media_type\n end\n end", "def json_body\n @json_body ||= Response.prepare_json_object(JSON.parse(body))\n end", "def read_json_body\n if params['mail'] || params['Type']\n @data = params\n else\n @data = ActiveSupport::JSON.decode(request.body)\n end\n end", "def valid_json(string) \n\tJSON.parse(string) \n\treturn true \n\trescue JSON::ParserError \n\treturn false \nend", "def valid?\n\t\t\t\t((request.format.symbol == :json) || (params[\"format\"] != nil && params[\"format\"] == \"json\")) && params[\"email\"]\n\t\t\tend", "def parse_body\n begin\n @body_content || JSON.parse( @body_buffer )\n rescue => e\n @error = e.message\n false\n end\n end", "def params_validation\n errors = validate_params(params)\n return json_response(errors, :unprocessable_entity) if errors.present?\n end", "def check_json_api_headers\n unless request.headers[\"Content-Type\"] && request.headers[\"Content-Type\"].\n include?(\"application/vnd.api+json\")\n return render json: \"\", status: :unsupported_media_type\n end\n\n unless request.headers[\"Accept\"] &&\n request.headers[\"Accept\"].include?(\"application/vnd.api+json\")\n return render json: \"\", status: :not_acceptable\n end\n end", "def from_json\n return nil unless okay?\n\n require \"json\"\n\n JSON.parse(body)\n end", "def validate_json(jsonData, jsonSchemaString, list=false)\n schemaVer = :draft3\n jsonObj = MultiJson.load(jsonData)\n jsonSchema = MultiJson.load(jsonSchemaString)\n assert(\n JSON::Validator.validate(jsonSchema, jsonObj, :list => list, :version => schemaVer),\n JSON::Validator.fully_validate(jsonSchema, jsonObj, :list => list, :version => schemaVer, :validate_schema => true).to_s\n )\n end", "def expect_req_body(request, params)\n request.with do |r|\n if r.body\n expect(JSON.parse(r.body)).to include(params.deep_stringify_keys)\n else\n expect(params).to be_nil\n end\n end\nend", "def geo_json_valid?\n geo_data = RGeo::GeoJSON.decode(params.to_json)\n if !geo_data.blank?\n return true\n else\n json_response(nil, :unprocessable_entity, :invalid_geojson_type)\n return false\n end\n end", "def missing_parameters(object)\n render json: object, status: 422\n end", "def use_json_body?\n @use_json_body ||= Mihari.config.webhook_use_json_body\n end", "def validate_content_type!\n return if request.content_type == \"application/json\"\n return if request.get? && request.content_type == \"text/plain\"\n return if !request.get? && request.content_type == \"application/x-www-form-urlencoded\"\n\n raise ActionController::BadRequest, \"Invalid content type\"\n end", "def parse_json_payload\n if request.content_type =~ /application\\/.*json/i\n json = JSON.parse(request.body.read)\n params.merge!(json)\n end\n ensure\n request.body.rewind\n end", "def validate_endpoint_response\n begin\n return if response.nil?\n res = JSON.parse(response)\n \n if res[\"code\"].present?\n errors.add(:response, 'response code must have value of data type integer') if !res[\"code\"].is_a? Integer\n else\n errors.add(:response, \"response code can't be blank\") \n end\n\n if res[\"headers\"].present?\n isValid = true\n res[\"headers\"].each do | key, value |\n isValid = (value.instance_of? String)? true : false\n errors.add(:response, \"response headers attributes: #{key} must have value of data type string\") if !isValid\n end\n end\n\n if res[\"body\"].present?\n isValid = true\n isValid = (res[\"body\"].instance_of? String)? true : false\n errors.add(:response, \"response body value must be of data type string\") if !isValid \n end\n rescue JSON::ParserError => e\n errors[response.to_s] << \"is not valid JSON\" \n end\n end", "def require_hash!\n @obj.is_a?(Hash) || handle_error(nil, :invalid_type, \"expected hash object in #{param_name(nil)} but received array object\")\n end", "def check_org_unit_data_validity(org_unit_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Type Name Code Parents),\n 'properties' => {\n 'Type' => { 'type' => 'integer' },\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'Parents' => {\n 'type' => 'array',\n 'items' => { 'type' => 'integer', 'minItems' => 1 }\n }\n }\n }\n JSON::Validator.validate!(schema, org_unit_data, validate_schema: true)\nend", "def validate(json)\n errors = ValidationErrors.new\n\n if validate(json, errors)\n errors\n else\n nil\n end\n end", "def test_validate_required_param_test()\n # Parameters for the API call\n model = Validate.from_hash(APIHelper.json_deserialize(\n '{\"name\":\"farhan\",\"field\":\"QA\"}'\n ))\n option = '...'\n\n # Perform the API call through the SDK function\n result = @controller.validate_required_parameter(model, option: option)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n\n # Test whether the captured response is as we expected\n refute_nil(result)\n expected_body = JSON.parse(\n '{\"passed\":true}'\n )\n received_body = JSON.parse(@response_catcher.response.raw_body)\n assert(TestHelper.match_body(expected_body, received_body, check_values: true))\n end", "def validate_as_json(response)\n JSON.parse(response)\n rescue JSON::NestingError\n raise Client::Error::InvalidResponseContent, 'Too deep response'\n rescue JSON::ParserError\n raise Client::Error::InvalidResponseContent, 'Unexpected response'\n rescue JSON::MissingUnicodeSupport\n raise Client::Error::InvalidResponseContent, 'Invalid character in response'\n rescue JSON::UnparserError\n raise Client::Error::InvalidResponseContent, 'Unable to parse response'\n rescue JSON::JSONError\n raise Client::Error::InvalidResponseContent, 'Invalid response'\n end", "def form_must_be_string\n errors[:form] << 'must be a json string' unless form_is_string\n end", "def form_must_be_string\n errors[:form] << 'must be a json string' unless form_is_string\n end", "def body\n json? ? handle_json : handle_raw\n end", "def check_course_template_updated_data_validity(course_template_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Name Code),\n 'properties' => {\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' }\n }\n }\n JSON::Validator.validate!(schema, course_template_data, validate_schema: true)\nend", "def json_error(*args, &block)\n json = json_plain(*args)\n json[0].should.be.false\n if block_given? \n yield json[1]\n end\n json[1]\n end", "def parse_content_body\n if put_or_post? && request.content_type.include?(\"application/json\")\n body_params = request.body.read\n parsed = body_params && body_params.length >= 2 ? JSON.parse(body_params) : nil\n params.merge!(parsed)\n end\n end", "def check_course_template_data_validity(course_template_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Name Code Path ParentOrgUnitIds),\n 'properties' => {\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'Path' => { 'type' => 'string' },\n 'ParentOrgUnitIds' => {\n 'type' => 'array',\n 'items' => { 'type' => 'integer', 'minItems' => 1 }\n }\n }\n }\n JSON::Validator.validate!(schema, course_template_data, validate_schema: true)\nend", "def validate(json)\n schema_key = Resolver.get_schema_key json\n data = Resolver.get_data json\n schema = lookup_schema schema_key\n JSON::Validator.validate!(schema, data)\n end", "def json_request?\n request.format.json?\n end", "def json_request?\n request.format.json?\n end", "def json_request?\n request.format.json?\n end", "def json_request?\n request.format.json?\n end", "def json_request?\n request.format.json?\n end", "def ensure_hash(ambiguous_param)\n return {} if ambiguous_param.blank?\n\n case ambiguous_param\n when String\n ensure_hash(JSON.parse(ambiguous_param))\n when Hash, ActionController::Parameters\n ambiguous_param\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def parsed_body(opts = {})\n if @body && @headers['content-type'] && @headers['content-type'].include?('application/json')\n JSON.parse(\n @body,\n opts,\n )\n end\n end", "def json_request?\n request.format.json?\n end", "def parsed_body\n request_media_type = request.media_type\n unless request_media_type =~ /\\S/\n fallback = true\n request_media_type = supported_media_types.first\n end\n case request_media_type\n when 'application/json'\n begin\n return JSON.parse(request_body)\n rescue JSON::ParserError\n if fallback\n t_key = 'app.errors.request.body_parse_fallback_json'\n default = \"Error encountered attempting to parse the request body. No Content-Type was specified and parsing as JSON failed. Supported media types are %{supported_media_types}. JSON parser error: %{error_class}: %{error_message}\"\n else\n t_key = 'app.errors.request.body_parse_indicated_json'\n default = \"Error encountered attempting to parse the JSON request body: %{error_class}: %{error_message}\"\n end\n message = I18n.t(t_key,\n :default => default,\n :error_class => $!.class,\n :error_message => $!.message,\n :supported_media_types => supported_media_types.join(', ')\n )\n errors = {'json' => [message]}\n halt_error(400, errors)\n end\n else\n if supported_media_types.include?(request_media_type)\n # :nocov:\n raise NotImplementedError, \"handling request body with media type #{request_media_type} not implemented\"\n # :nocov:\n end\n logger.error \"received Content-Type of #{request.content_type.inspect}; halting with 415\"\n message = I18n.t('app.errors.request.content_type',\n :default => \"Unsupported Content-Type of %{content_type} given for the request body. Supported media types are %{supported_media_types}\",\n :content_type => request.content_type,\n :supported_media_types => supported_media_types.join(', ')\n )\n errors = {'Content-Type' => [message]}\n halt_error(415, errors)\n end\n end", "def check_updated_course_data_validity(course_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Name Code StartDate EndDate IsActive),\n 'properties' => {\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'StartDate' => { 'type' => %w(string null) },\n 'EndDate' => { 'type' => %w(string null) },\n 'IsActive' => { 'type' => 'boolean' }\n }\n }\n JSON::Validator.validate!(schema, course_data, validate_schema: true)\nend", "def check_org_unit_updated_data_validity(org_unit_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Identifier Name Code Path Type),\n 'properties' => {\n 'Identifier' => { 'type' => 'string' },\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'Path' => { 'type' => 'string' },\n 'Type' => {\n 'required' => %w(Id Code Name),\n 'properties' => {\n 'Id' => { 'type' => 'integer' },\n 'Code' => { 'type' => 'string' },\n 'Name' => { 'type' => 'string' }\n }\n }\n }\n }\n JSON::Validator.validate!(schema, org_unit_data, validate_schema: true)\nend", "def is_json?(content)\n if content.present?\n sanitized_content = content.gsub(/\\n/, '') # remove newlines that may break this check\n chars = [sanitized_content[0], sanitized_content[sanitized_content.size - 1]]\n chars == %w({ }) || chars == %w([ ])\n else\n false\n end\n end", "def json?\n content_type == \"application/json\"\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n ambiguous_param.present? ? ensure_hash(JSON.parse(ambiguous_param)) : {}\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n ambiguous_param.present? ? ensure_hash(JSON.parse(ambiguous_param)) : {}\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def ensure_hash(ambiguous_param)\n case ambiguous_param\n when String\n if ambiguous_param.present?\n ensure_hash(JSON.parse(ambiguous_param))\n else\n {}\n end\n when Hash, ActionController::Parameters\n ambiguous_param\n when nil\n {}\n else\n raise ArgumentError, \"Unexpected parameter: #{ambiguous_param}\"\n end\n end", "def validate_text(text)\n response = RestClient.post \"#{BASE_URI}/?out=json\", text, HEADERS\n @json = JSON.parse(response.body)\n @errors = retrieve_errors\n end", "def read_post_data(body)\n raw_data = body.read\n halt 403, 'NO DATA' if raw_data.empty?\n begin\n JSON.parse(raw_data)\n rescue JSON::ParserError\n halt 403, \"BAD DATA:\\n#{raw_data}\"\n end\n end", "def expect_json_content\n expect(content_type).to eq('application/json')\n end", "def parse_body(str)\n begin\n data = JSON.parse(str)\n if data.key?('initials') and data.key?('score')\n data\n else\n nil\n end\n rescue JSON::ParserError\n nil\n end\nend", "def check_format\n redirect_to root_url unless params[:format] == 'json' || request.headers[\"Accept\"] =~ /json/\n end", "def json_request?()\n request.format.json?\n end" ]
[ "0.71599287", "0.7132338", "0.6883168", "0.6831633", "0.67973024", "0.6708845", "0.66111934", "0.64998543", "0.64998543", "0.6497647", "0.6497647", "0.6452888", "0.6445513", "0.6441618", "0.6435888", "0.64142275", "0.641292", "0.6410751", "0.6361437", "0.63413286", "0.63217723", "0.6256336", "0.6228837", "0.61820436", "0.61563843", "0.61473435", "0.6116661", "0.6111695", "0.61028546", "0.6091562", "0.6027265", "0.60179305", "0.60160464", "0.6008608", "0.5995797", "0.5970823", "0.5936387", "0.590778", "0.5880945", "0.5842376", "0.58400667", "0.5832968", "0.5827564", "0.58083314", "0.5798253", "0.5764686", "0.57626545", "0.5760953", "0.5743628", "0.5740015", "0.5738441", "0.5724646", "0.5712637", "0.5670556", "0.5668174", "0.56654584", "0.56610256", "0.56603855", "0.5650117", "0.5650117", "0.56467646", "0.56340206", "0.5613133", "0.56029546", "0.5584761", "0.557416", "0.55643183", "0.55643183", "0.55643183", "0.55643183", "0.55643183", "0.5561095", "0.55593556", "0.5557519", "0.55529773", "0.55486953", "0.5544279", "0.55204684", "0.55125344", "0.5510679", "0.5510679", "0.5508416", "0.5508416", "0.5508416", "0.5508416", "0.5508416", "0.5508416", "0.5508416", "0.5508416", "0.5508416", "0.5508416", "0.5508416", "0.5508416", "0.5508416", "0.5505669", "0.550136", "0.5490987", "0.54838264", "0.548134", "0.5474298" ]
0.7447415
0
TODO rename to put_to_create_supported, otherwise it sounds like it's a policy issue Not a Webmachine method. This is used by security policy code to identify whether a PUT to a non existing resource can create a new object.
def put_can_create? false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_create?(obj)\n false\n end", "def can_create?(obj)\n false\n end", "def patch_can_create?\n false\n end", "def http_method_modifies_resource?\n ['PUT','POST','PATCH'].include?(method.to_s.upcase)\n end", "def should_fail_to_create(key, value, error, message)\n # Create and update are identical; both use PUT\n should_fail_to_change(key, value, error, message, false, true)\n end", "def can_create?\n allows_current_user_access_to? :create\n end", "def can_create\n raise ActionController::RoutingError 'Forbidden' if current_user.nil? || cannot?(:write, :posts)\n true\n end", "def create_method\n :http_put\n end", "def create_method\n :http_put\n end", "def auth_create_filter\n if not self.class.allowed_to_create\n false\n else\n true\n end\n end", "def create\n # Can't create a resource that is not dirty and doesn't have serial keys\n return false if new_record? && !dirty? && !model.key.any? { |p| p.serial? }\n # set defaults for new resource\n properties.each do |property|\n next if attribute_loaded?(property.name)\n property.set(self, property.default_for(self))\n end\n\n return false unless repository.create([ self ]) == 1\n\n @repository = repository\n @new_record = false\n\n repository.identity_map(model).set(key, self)\n\n true\n end", "def put?\r\nHTTP_METHOD_LOOKUP[request_method] == :put\r\nend", "def create?\n record.resourceable.owner == user || user.is?(:admin)\n end", "def check_permissions\n authorize! :create, Product\n end", "def authorize_create!(change_set:)\n if change_set.append_id.present?\n authorize! :update, query_service.find_by(id: Array(change_set.append_id).first)\n else\n authorize! :create, resource_class\n end\n end", "def support_save_and_duplicate?(resource:)\n resource.class.supports_save_and_duplicate? && params[:controller] == resource.class.name.underscore.pluralize\n end", "def create?\n true\n end", "def create?\n true\n end", "def create?\n true\n end", "def create?\n true\n end", "def create?\n true\n end", "def create?\n true\n end", "def create?\n true\n end", "def enforce_new_permissions(opts={})\n enforce_create_permissions(opts)\n end", "def update?\n existing && !destroyable? && acceptable_id?\n end", "def create?\n false\n end", "def new?\n !exists?\n end", "def create?\n name == :create\n end", "def create_permitted?\n acting_user.signed_up?\n end", "def create_permitted?\n acting_user.signed_up?\n end", "def create_access_check\n permission_check('create')\n end", "def create_access_check\n permission_check('create')\n end", "def create_access_check\n permission_check('create')\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 create?\n return true\n end", "def creating?\n Graphiti.context[:namespace] != :update\n end", "def update?\n create?\n end", "def update?\n create?\n end", "def update?\n create?\n end", "def update?\n create?\n end", "def permitted?; end", "def replace?\n !existing && !destroyable? && !attributes.blank?\n end", "def enforce_new_permissions(opts={})\n #Call the HullAccessControlsEnforcement method for checking create/new permissions\n enforce_create_permissions\n end", "def enforce_new_permissions(opts={})\n #Call the HullAccessControlsEnforcement method for checking create/new permissions\n enforce_create_permissions\n end", "def allow_to_add_new_entity?(opts ={})\n registered?\n end", "def create\n validate_save_and_respond(change_set_class.new(resource_class.new), :new)\n end", "def check_resource_semantics!; end", "def create_method\n :put_json\n end", "def create?\n @current_user.permission('Bid', :clerk)\n end", "def can_set_write_concern?\n !sharded? || !scram_sha_256_enabled?\nend", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def allow_new_records?\n self.permissions['new']\n end", "def can_create_opinion_note?\n allow! if permission_action.subject == :opinion_note\n end", "def create?\n return true\n end", "def create?\n return true\n end", "def authorized_for_create?\n current_user.is_admin\n end", "def modified_existing?\n false\n end", "def _create\n true\n end", "def valid?(*args)\n super(:create)\n end", "def create_attempted?\n create_attempted\n end", "def create\n @property_hash[:ensure] = :present\n self.class.resource_type.validproperties.each do |property|\n if val = resource.should(property)\n @property_hash[property] = val\n end\n end\n end", "def canCreate?(user=current_user)\n return false if user.nil?\n true\n end", "def enforce_create_permissions(opts={})\n logger.debug(\"Enforcing create permissions\")\n if !can? :create, ActiveFedora::Base.new\n raise Hydra::AccessDenied.new \"You do not have sufficient privileges to create a new document.\"\n end\n end", "def check_permissions\n authorize! :create, CargoManifest\n end", "def creating?\n dest_obj.new_record?\n end", "def check_permissions\n authorize! :create, Employee\n end", "def new?\n create?\n end", "def new?\n create?\n end", "def new?\n create?\n end", "def new?\n create?\n end", "def new?\n create?\n end", "def can_write?(resource)\n scope_name = resource.class.to_s.downcase.pluralize\n self.send(\"writable_#{scope_name}\").where(\"`permissions`.resource_type = ? AND `permissions`.resource_id = ?\", resource.class.to_s, resource.id).exists?\n end", "def can_create?(doc_type)\n self.can_access?(doc_type)\n end", "def api_behavior(error)\n if resourceful? && put?\n display resource, :status => :ok\n else\n super\n end\n end", "def creatable?(fields=false)\n modifiable? :create, fields\n end", "def only_create!\n self.operation = :only_create\n end", "def batch_create_authorized?(record = nil)\n authorized_for?(:crud_type => :create)\n end", "def create?\n create = self[:create]\n return create unless create.nil?\n options.fetch 'create', false\n end", "def resource?\n true\n end", "def write_data_permitted?\n return write_permitted?\n end", "def supports_create_or_replace_view?\n false\n end", "def create\n Puppet.debug(self.class.to_s.split('::').last + ': Calling create method :')\n\n response, status_code, headers = Puppet::Provider::Cudawaf.post('SecurityPolicy', message(resource), {})\n\n if status_code == 201\n @property_hash.clear\n return response, status_code, headers\n else\n raise(self.class.to_s.split('::').last + ': Not able to create the security policy. Please check the security policy api parameters')\n end\n end", "def define_eccept\n if current_user.info.id == @resource.id || can_manage_has_one(current_user.info, @resource, Info)\n true\n else\n redirect_to root_path\n end\n end", "def supports_create_or_replace_view?\n true\n end", "def new?\n\t\tcreate?\n\tend", "def created?\n @data[:status_code] == '201'\n end", "def create?\n @current_user.permission('Fdp', :clerk)\n end", "def has_edit_permission?\n persisted?\n end", "def api_behavior\n if post?\n display resource, :status => :created\n # render resource instead of 204 no content\n elsif put? || delete?\n display resource, :status => :ok\n else\n super\n end\n end", "def allowed?() raise NotImplementedError end", "def permitted_create_params\n fail NotImplementedError\n end", "def post_is_create?\n\t\ttrue\n\tend", "def create?\n @current_user.permission('Ration', :clerk)\n end", "def resource_saved?\n resource.save unless resource.validation_attempted?\n resource.saved?\n end", "def exists?\n begin\n url_for(:resources_resource, credentials, id).head\n true\n rescue RestClient::Forbidden\n true\n rescue RestClient::ResourceNotFound\n false\n end\n end", "def create?\n @current_user.permission('Donor', :clerk)\n end" ]
[ "0.712357", "0.712357", "0.7070993", "0.6593049", "0.6552015", "0.62096786", "0.6202629", "0.60856044", "0.60856044", "0.6028774", "0.5995979", "0.5974593", "0.5965384", "0.59235704", "0.589666", "0.58952254", "0.5871741", "0.5871741", "0.5871741", "0.5871741", "0.5871741", "0.5871741", "0.5871741", "0.5836691", "0.5819068", "0.580663", "0.5790237", "0.5754942", "0.57417566", "0.57417566", "0.5722654", "0.5722654", "0.5722654", "0.57136625", "0.5708799", "0.56775004", "0.5671016", "0.5671016", "0.5671016", "0.5671016", "0.5661761", "0.5656874", "0.56446093", "0.56446093", "0.5636674", "0.562636", "0.5625596", "0.5616697", "0.5591917", "0.5591464", "0.55792314", "0.55792314", "0.55792314", "0.55792314", "0.55792314", "0.557774", "0.5574874", "0.55660456", "0.55660456", "0.5565852", "0.5565701", "0.55612427", "0.55452317", "0.55401266", "0.55341256", "0.55313826", "0.55291563", "0.5528384", "0.55273056", "0.5519679", "0.551486", "0.551486", "0.551486", "0.551486", "0.551486", "0.55092007", "0.5504686", "0.5499177", "0.5493554", "0.54880077", "0.5484402", "0.5475063", "0.5458435", "0.5456596", "0.5448751", "0.5447407", "0.5446454", "0.5445375", "0.54444754", "0.5441928", "0.5421009", "0.54036725", "0.5400307", "0.5396703", "0.53952473", "0.5392312", "0.53903943", "0.53792286", "0.5378435", "0.5376977" ]
0.7974128
0
TODO rename to patch_to_create_supported, otherwise it sounds like it's a policy issue Not a Webmachine method. This is used by security policy code to identify whether a PATCH to a non existing resource can create a new object.
def patch_can_create? false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_create?(obj)\n false\n end", "def can_create?(obj)\n false\n end", "def put_can_create?\n false\n end", "def http_method_modifies_resource?\n ['PUT','POST','PATCH'].include?(method.to_s.upcase)\n end", "def can_create?\n allows_current_user_access_to? :create\n end", "def creation?\n self.diff['attributes']['new'] && !self.diff['attributes']['old']\n end", "def patch?\r\nHTTP_METHOD_LOOKUP[request_method] == :patch\r\nend", "def should_fail_to_create(key, value, error, message)\n # Create and update are identical; both use PUT\n should_fail_to_change(key, value, error, message, false, true)\n end", "def patch\n req.patch?\n end", "def create?\n true\n end", "def create?\n true\n end", "def create?\n true\n end", "def create?\n true\n end", "def create?\n true\n end", "def create?\n true\n end", "def create?\n true\n end", "def create\n if @patch_method_used.nil?\n super_create\n else\n @patch_method_used = nil\n end\n end", "def create?\n false\n end", "def create?\n record.resourceable.owner == user || user.is?(:admin)\n end", "def auth_create_filter\n if not self.class.allowed_to_create\n false\n else\n true\n end\n end", "def enforce_new_permissions(opts={})\n enforce_create_permissions(opts)\n end", "def create?\n return true\n end", "def modified_existing?\n false\n end", "def creatable?(fields=false)\n modifiable? :create, fields\n end", "def allow_new_records?\n self.permissions['new']\n end", "def create_attempted?\n create_attempted\n end", "def create?\n return true\n end", "def create?\n return true\n end", "def create?\n name == :create\n end", "def can_create_opinion_note?\n allow! if permission_action.subject == :opinion_note\n end", "def enforce_new_permissions(opts={})\n #Call the HullAccessControlsEnforcement method for checking create/new permissions\n enforce_create_permissions\n end", "def enforce_new_permissions(opts={})\n #Call the HullAccessControlsEnforcement method for checking create/new permissions\n enforce_create_permissions\n end", "def update?\n create?\n end", "def update?\n create?\n end", "def update?\n create?\n end", "def update?\n create?\n end", "def creating?\n Graphiti.context[:namespace] != :update\n end", "def patch_valid?\n validate(false).empty?\n end", "def create?\n @current_user.permission('Fdp', :clerk)\n end", "def new?\n create?\n end", "def new?\n create?\n end", "def new?\n create?\n end", "def new?\n create?\n end", "def new?\n create?\n end", "def supports_comments_in_create?\n false\n end", "def supports_comments_in_create?\n false\n end", "def can_create\n raise ActionController::RoutingError 'Forbidden' if current_user.nil? || cannot?(:write, :posts)\n true\n end", "def create?\n @current_user.permission('FdpContact', :clerk)\n end", "def new?\n !exists?\n end", "def create_access_check\n permission_check('create')\n end", "def create_access_check\n permission_check('create')\n end", "def create_access_check\n permission_check('create')\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def creating?\n state == :CREATING\n end", "def create?\n @current_user.permission('Ration', :clerk)\n end", "def post_is_create?\n\t\ttrue\n\tend", "def check_resource_semantics!; end", "def new?\n\t\tcreate?\n\tend", "def create?\n @current_user.permission('Donor', :clerk)\n end", "def creatable_by?(user)\n true\n end", "def enforce_create_permissions(opts={})\n logger.debug(\"Enforcing create permissions\")\n if !can? :create, ActiveFedora::Base.new\n raise Hydra::AccessDenied.new \"You do not have sufficient privileges to create a new document.\"\n end\n end", "def canCreate?(user=current_user)\n return false if user.nil?\n true\n end", "def can_ever_create_works?\n !creatable_works.empty?\n end", "def can_create_issue\n issue = Issue.new(issue_attributes)\n issue.author = self.author\n issue.parent_issue_id = self.parent_issue_id\n issue.allow_to_create_in_closed_structure = true if Redmine::Plugin.all.map(&:id).include?(:redmine_closed_issues_structure)\n unless issue.valid?\n copy_errors_from(issue)\n end\n end", "def patchable?\n available? && loaded? && compatible?\n end", "def _create\n true\n end", "def create?\n create = self[:create]\n return create unless create.nil?\n options.fetch 'create', false\n end", "def modification?\n !self.creation? && !self.destruction?\n end", "def created?\n @data[:status_code] == '201'\n end", "def create_permitted?\n acting_user.signed_up?\n end", "def create_permitted?\n acting_user.signed_up?\n end", "def create\n # Can't create a resource that is not dirty and doesn't have serial keys\n return false if new_record? && !dirty? && !model.key.any? { |p| p.serial? }\n # set defaults for new resource\n properties.each do |property|\n next if attribute_loaded?(property.name)\n property.set(self, property.default_for(self))\n end\n\n return false unless repository.create([ self ]) == 1\n\n @repository = repository\n @new_record = false\n\n repository.identity_map(model).set(key, self)\n\n true\n end", "def patched?\n @patched\n end", "def patched?\n @patched\n end", "def patched?\n @patched\n end", "def patched?\n @patched\n end", "def patched?\n @patched\n end", "def editing_supported?\n !(is_multivalued? || is_resource?)\n end", "def new?\n raise NotImplementedError\n end", "def creation_allowed?\n show_programme_box? && Programme.can_create?\n end", "def can_create?(doc_type)\n doc_type.eql?(\"comments\")\n end", "def create\n validate_save_and_respond(change_set_class.new(resource_class.new), :new)\n end", "def resource?\n true\n end", "def update?\n existing && !destroyable? && acceptable_id?\n end", "def can_create?(doc_type)\n self.can_access?(doc_type)\n end", "def creation_allowed_only?\n creation_allowed? && !(\n programme_administrator_logged_in? ||\n Programme.site_managed_programme.present?\n )\n end", "def creatable_without_user\n false\n end", "def valid_data_on_creation?\n valid_data_on_creation\n end", "def authorized_for_create?\n current_user.is_admin\n end", "def create?\n @current_user.permission('Bid', :clerk)\n end", "def support_save_and_duplicate?(resource:)\n resource.class.supports_save_and_duplicate? && params[:controller] == resource.class.name.underscore.pluralize\n end", "def only_create!\n self.operation = :only_create\n end", "def supports_create_or_replace_view?\n false\n end", "def allowed_to_create_apps\n return @allowed_to_create_apps\n end", "def can_create_comment?(post); true; end", "def is_comment_creation?\n request.post? && request.request_parameters['comment'].present?\n end", "def creating?\n dest_obj.new_record?\n end" ]
[ "0.7045069", "0.7045069", "0.66991454", "0.6512275", "0.61496884", "0.6131855", "0.608308", "0.60082823", "0.598155", "0.594934", "0.594934", "0.594934", "0.594934", "0.594934", "0.594934", "0.594934", "0.59413767", "0.59257287", "0.59175366", "0.590046", "0.5866973", "0.5852465", "0.5831067", "0.582882", "0.5772907", "0.57512647", "0.57490504", "0.57490504", "0.5739956", "0.5724427", "0.5720077", "0.5720077", "0.5679972", "0.5679972", "0.5679972", "0.5679972", "0.56775916", "0.56746566", "0.56637955", "0.5663552", "0.5663552", "0.5663552", "0.5663552", "0.5663552", "0.5663044", "0.5663044", "0.5661162", "0.5651813", "0.5619791", "0.5612378", "0.5612378", "0.5612378", "0.5604724", "0.5604724", "0.5604724", "0.5604724", "0.5604724", "0.5595833", "0.5595711", "0.55936044", "0.558623", "0.5575759", "0.5565708", "0.55620694", "0.55601156", "0.5540569", "0.5530669", "0.5515121", "0.55116105", "0.55049986", "0.55035144", "0.5454889", "0.5440355", "0.5440355", "0.5439141", "0.54354686", "0.54354686", "0.54354686", "0.54354686", "0.54354686", "0.5420315", "0.54139006", "0.5411477", "0.54101825", "0.54031324", "0.5390506", "0.5385308", "0.5377874", "0.5372703", "0.537191", "0.5362413", "0.5354212", "0.5352724", "0.53463334", "0.53459454", "0.5340066", "0.53377587", "0.5337636", "0.5332676", "0.5322452" ]
0.81165093
0
Test 5: User clicks "Show me how" links on Post and Profile pages, verify redirect
def test_05_1_show_me_how_TC_24406 profileLogin $browser.goto($patch_note) $help_post_note.when_present.click sleep 4 $browser.window(:title, /Post a Note/).use do begin assert $browser.text.include?("Post a Note") rescue => e puts e puts "J1_T5.1: FAILED! User unable to navigate to zendesk." end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_00090_homepage_open_q_conv_link\n @browser.wait_until { @home_page.open_questions_widget.present? }\n @browser.wait_until { @home_page.open_questions_widget.posts.size > 0 }\n\n # verify the title link would redirect to conversation page.\n q_title = @home_page.open_questions_widget.posts[0].title\n @home_page.open_questions_widget.posts[0].click_title_link\n @browser.wait_until { @convdetail_page.conv_detail.present? }\n assert_equal @convdetail_page.conv_title.when_present.text, q_title, \"title doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.open_questions_widget.posts.size > 0 }\n\n # verify avatar link would redirect to profile page\n @home_page.open_questions_widget.posts[0].click_avatar\n @browser.wait_until { @profile_page.profile_page.present? }\n author_name = @profile_page.profile_page_author_name_betaon.when_present.text\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.open_questions_widget.posts.size > 0 }\n\n # verify author link would redirect to profile page\n @home_page.open_questions_widget.posts[0].click_author_link\n @browser.wait_until { @profile_page.profile_page.present? }\n assert_equal @profile_page.profile_page_author_name_betaon.when_present.text, author_name, \"Author doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.open_questions_widget.posts.size > 0 }\n\n # verify topic link would redirect to the correct topic page\n post_in_topic = @home_page.open_questions_widget.posts[0].in_topic_link.when_present.text\n\n @home_page.open_questions_widget.posts[0].click_topic_link\n @browser.wait_until { @topicdetail_page.topic_filter.present? }\n assert_equal @topicdetail_page.topic_title.when_present.text, post_in_topic, \"Title doesn't match\"\n end", "def test_00140_homepage_featured_q_widget_conv_links\n @browser.wait_until { @home_page.featured_q_widget.present? }\n @browser.wait_until { @home_page.featured_q_widget.posts.size > 0 }\n\n # verify the title link would redirect to conversation page.\n q_title = @home_page.featured_q_widget.posts[0].title\n @home_page.featured_q_widget.posts[0].click_title_link\n @browser.wait_until { @convdetail_page.conv_detail.present? }\n assert_equal @convdetail_page.conv_title.when_present.text, q_title, \"title doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_q_widget.posts.size > 0 }\n\n # verify avatar link would redirect to profile page\n @home_page.featured_q_widget.posts[0].click_avatar\n @browser.wait_until { @profile_page.profile_page.present? }\n author_name = @profile_page.profile_page_author_name_betaon.when_present.text\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_q_widget.posts.size > 0 }\n\n # verify author link would redirect to profile page\n @home_page.featured_q_widget.posts[0].click_author_link\n @browser.wait_until { @profile_page.profile_page.present? }\n assert_equal @profile_page.profile_page_author_name_betaon.when_present.text, author_name, \"Author doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_q_widget.posts.size > 0 }\n\n # verify topic link would redirect to the correct topic page\n post_in_topic = @home_page.featured_q_widget.posts[0].in_topic_link.when_present.text\n\n @home_page.featured_q_widget.posts[0].click_topic_link\n @browser.wait_until { @topicdetail_page.topic_filter.present? }\n assert_equal @topicdetail_page.topic_title.when_present.text, post_in_topic, \"Title doesn't match\"\n end", "def test_ID_25843_edit_profile_what_i_love_about_your_town\n login_as_user1\n go_to_edit_profile_page\n verify_little_more_about_my_community\n verify_text_can_be_entered_saved_on_about_my_community\n end", "def test_ID_25843_edit_profile_what_i_love_about_your_town\n login_as_user1\n go_to_edit_profile_page\n verify_little_more_about_my_community\n verify_text_can_be_entered_saved_on_about_my_community\n end", "def test_02_normaluser_clickall_links()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 01 ----------------------\"\n\t\tverifyAboutUsLinks()\n\t\tverifySignupLoginLinks()\n\t\tlogin(\"normaluser@aol.com\", \"123456\")\n\t\tverifyHeaderLinks()\n\t\tverifyFooterLinks()\n\t\tverifyMyAccountLinks()\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 01 --------------------------\"\n\tend", "def check_own_page(u)\n login_as(u, scope: :user)\n check_profile_enabled(u)\n\n # Can access profile page from menu bar\n visit root_path\n assert page.has_link?('Your Profile', href: user_path(u))\n end", "def test_ID_25842_edit_profile_a_little_more_about_me\n login_as_user1\n go_to_edit_profile_page\n verify_little_more_about_me_text_optional\n verify_text_can_be_entered_saved_on_little_more_about_me\n end", "def test_ID_25842_edit_profile_a_little_more_about_me\n login_as_user1\n go_to_edit_profile_page\n verify_little_more_about_me_text_optional\n verify_text_can_be_entered_saved_on_little_more_about_me\n end", "def test_reviewer_home\n\n post('index', {}, {})\n assert_response(:success)\n assert_template('tracker/index')\n \n post('index', {}, lee_hweng_session)\n assert_response(:success)\n assert_template('tracker/reviewer_home')\n\n #follow_redirect\n #assert_no_tag :content => \"POST Placement Review\"\n\n end", "def test_home_page_redirects\n \n post('admin_home', {}, {})\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n \n post('reviewer_home', {}, {})\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n \n post('manager_home', {}, {})\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n \n post('pcb_admin_home', {}, {})\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n \n post('designer_home', {}, {})\n assert_redirected_to(:controller => 'tracker', :action => 'index')\n \n end", "def test_switch_views_last_viewed_profile\r\n\r\n recipient_profile_url = PropertiesReader.get_recipient_profile_url\r\n\r\n @place_holder.login_goto_profile(recipient_profile_url)\r\n\r\n @place_holder.add_to_or_view_on_graph('to switch to graph view')\r\n\r\n @place_holder.go_to_profiles_view\r\n\r\n # Verify that the profile displayed is the one that was last viewed\r\n @place_holder.assert_actual_url(recipient_profile_url, 'switching the view from graph to profile displays the last viewed profile')\r\n\r\n # Navigate to a different profile using a hyperlink given on this profile page (to verify that last viewed (i.e. this location)) profile is displayed when the view is switched to 'Profile'\r\n begin\r\n\r\n assert_fail_message = 'navigating to a different profile'\r\n # TODO this is not a functional verification, it is just to make sure that the following assertion is valid\r\n exp_location_profile_displayed = PropertiesReader.get_exp_location_navigated_to\r\n\r\n address_text_to_click_on = PropertiesReader.get_address_text_to_click_on\r\n @place_holder.nav_via_hyperlink_assert_url(address_text_to_click_on, exp_location_profile_displayed, assert_fail_message)\r\n\r\n # To test the switching between the views, switch to graph view first (i.e. this new profile is added on to the graph)\r\n @place_holder.add_to_or_view_on_graph('after navigating to a different profile')\r\n\r\n # Switch to profile view to verify which profile is displayed\r\n @place_holder.go_to_profiles_view\r\n\r\n # Verify that the most recently viewed profile is the one that the switching between perspective takes to\r\n @place_holder.assert_actual_url(exp_location_profile_displayed, 'switching to the profile view after adding a different profile to the graph takes to the most recently viewed profile')\r\n\r\n end\r\n\r\n end", "def test_ID_25890_published_posts_02\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n $profile_published.when_present().click\n sleep 5\n verify_text \"Your Posts\",\"Drafts\", \"Scheduled\", \"Published\"\n assert $profile_published.exists?\n assert $count_of_published.exists?\n end", "def test_profile_url_redirects\r\n\r\n @place_holder.login_with_proper_credentials\r\n\r\n @place_holder.logout_using_gear_icon\r\n\r\n exp_https_url = PropertiesReader.get_exp_https_login_url\r\n #Verify the redirection to the secure login takes place after signing out\r\n @place_holder.assert_actual_url(exp_https_url, 'Not redirected to HTTPS login page after signing out using gear icon')\r\n\r\n @place_holder.go_to(PropertiesReader.get_recipient_profile_url)\r\n sleep(1)\r\n\r\n @place_holder.assert_actual_url(exp_https_url, 'Attempting to access a profile using profile URL after signing out using gear icon does not redirect to the HTTPS login page')\r\n\r\n end", "def test_ID_25890_published_posts_01\n login_as_user1\n go_to_edit_profile_page\n $profile_your_posts.click\n sleep 5\n publish_post_if_not_found(\"Sports\",\"Basketball\")\n end", "def verifyStoryAdminLinks()\n\t\n\tputs \"************** START: Verify PRO page Links ****************\"\n\t\n\tputs \"Step 1 : Click on EditPage link on the Story page.\"\n\t$browser.click \"link=Edit Page\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"The Basics\")\n\t\tputs \"Step 1 is Passed. User has reached the EditPage screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1 is Failed. User had failed to reach EditPage screen.\"\n\t\t$verification_errors << $!\n\tend\n\n\tputs \"Step 2 : Click on Thumbnail link on the Story page.\"\n\t$browser.click \"link=Thumbnail\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Current Thumbnail\")\n\t\tputs \"Step 2 is Passed. User has reached the Thumbnail screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 is Failed. User had failed to reach Thumbnail screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 3 : Click on Matching Grants link on the Story page.\"\n\t$browser.click \"link=Matching Grants\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Grantor\")\n\t\tputs \"Step 3 is Passed. User has reached the Matching Grants screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 is Failed. User had failed to reach Matching Grants screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 4 : Click on Promote link on the Story page.\"\n\t$browser.click \"link=Promote\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Or get a donation button to put on your website\")\n\t\tputs \"Step 4 is Passed. User has reached the Promote screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 4 is Failed. User had failed to reach Promote screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 5 : Click on DonateAnywhere link on the Story page.\"\n\t$browser.click \"link=DonateAnywhere\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"DonateAnywhere\")\n\t\tputs \"Step 5 is Passed. User has reached the DonateAnywhere screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 5 is Failed. User had failed to reach DonateAnywhere screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 6 : Click on Donations link on the Story page.\"\n\t$browser.click \"link=Donations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Donations Listing\")\n\t\tputs \"Step 6 is Passed. User has reached the Donations screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 6 is Failed. User had failed to reach Donations screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"************** END: Verify PRO page Links ****************\"\n\t\nend", "def verifyStoryAdminLinks()\n\t\n\tputs \"************** START: Verify PRO page Links ****************\"\n\t\n\tputs \"Step 1 : Click on EditPage link on the Story page.\"\n\t$browser.click \"link=Edit Page\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"The Basics\")\n\t\tputs \"Step 1 is Passed. User has reached the EditPage screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1 is Failed. User had failed to reach EditPage screen.\"\n\t\t$verification_errors << $!\n\tend\n\n\tputs \"Step 2 : Click on Thumbnail link on the Story page.\"\n\t$browser.click \"link=Thumbnail\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Current Thumbnail\")\n\t\tputs \"Step 2 is Passed. User has reached the Thumbnail screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 is Failed. User had failed to reach Thumbnail screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 3 : Click on Matching Grants link on the Story page.\"\n\t$browser.click \"link=Matching Grants\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Grantor\")\n\t\tputs \"Step 3 is Passed. User has reached the Matching Grants screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 is Failed. User had failed to reach Matching Grants screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 4 : Click on Promote link on the Story page.\"\n\t$browser.click \"link=Promote\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Or get a donation button to put on your website\")\n\t\tputs \"Step 4 is Passed. User has reached the Promote screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 4 is Failed. User had failed to reach Promote screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 5 : Click on DonateAnywhere link on the Story page.\"\n\t$browser.click \"link=DonateAnywhere\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"DonateAnywhere\")\n\t\tputs \"Step 5 is Passed. User has reached the DonateAnywhere screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 5 is Failed. User had failed to reach DonateAnywhere screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 6 : Click on Donations link on the Story page.\"\n\t$browser.click \"link=Donations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Donations Listing\")\n\t\tputs \"Step 6 is Passed. User has reached the Donations screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 6 is Failed. User had failed to reach Donations screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"************** END: Verify PRO page Links ****************\"\n\t\nend", "def url_contains_post_info\r\n expect(on_page(BloggyBluesShowPost).current_url) == \"localhost:8080/BloggyBlues/bloggyblues/show/\"\r\n end", "def verifyStoryAdminLinks()\n\t\n\tputs \"************** START: Verify PRO page Links ****************\"\n\t\n\tputs \"Step 1 : Click on EditPage link on the Story page.\"\n\t$browser.click \"link=Edit\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Tell Your Story\")\n\t\tputs \"Step 1 is Passed. User has reached the EditPage screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1 is Failed. User had failed to reach EditPage screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 3 : Click on Matching Grants link on the Story page.\"\n\t$browser.click \"link=Matching Grants\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Set Up a Matching Grant\")\n\t\tputs \"Step 3 is Passed. User has reached the Matching Grants screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 is Failed. User had failed to reach Matching Grants screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\t\n\tputs \"Step 6 : Click on Donations link on the Story page.\"\n\t$browser.click \"link=Donations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Donations Listing\")\n\t\tputs \"Step 6 is Passed. User has reached the Donations screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 6 is Failed. User had failed to reach Donations screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"************** END: Verify PRO page Links ****************\"\n\t\nend", "def test_nav_between_profiles\r\n\r\n recipient_profile_url = PropertiesReader.get_recipient_profile_url\r\n @place_holder.login_goto_profile(recipient_profile_url)\r\n\r\n # Verify navigation to and back from location page\r\n begin\r\n\r\n # Verify navigation to the location page\r\n assert_fail_message = 'Clicking on the location of this profile takes to the expected URL'\r\n @place_holder.nav_via_hyperlink_assert_url(PropertiesReader.get_address_text_to_click_on, PropertiesReader.get_exp_location_navigated_to, assert_fail_message)\r\n\r\n # Click on the browser back button and verify that the user is navigated back to the original profile page\r\n back_nav_assert_fail_msg = 'Clicking on the back button from the location page does not take to the expected URL'\r\n @place_holder.browser_go_back_assert_url(recipient_profile_url, back_nav_assert_fail_msg)\r\n\r\n end\r\n\r\n # Verify navigation to and back from phone number page\r\n begin\r\n\r\n # Verify navigation to the address page\r\n assert_fail_message = 'Clicking on the phone number of this profile takes to the expected URL'\r\n @place_holder.nav_via_hyperlink_assert_url(PropertiesReader.get_phone_number_text_to_click_on, PropertiesReader.get_exp_phone_navigated_to, assert_fail_message)\r\n\r\n # Click on the browser back button and verify that the user is navigated back to the original profile page (the following navigations rely being on this pag)\r\n back_nav_assert_fail_msg = 'Clicking on the back button from the phone number page does not take to the expected URL'\r\n @place_holder.browser_go_back_assert_url(recipient_profile_url, back_nav_assert_fail_msg)\r\n\r\n end\r\n\r\n # Verify navigation to and back from Tax ID page\r\n begin\r\n\r\n # Verify navigation to the Tax ID page\r\n assert_fail_message = 'Clicking on the Tax ID of this profile takes to the expected URL'\r\n @place_holder.nav_via_hyperlink_assert_url(PropertiesReader.get_tax_id_text_to_click_on, PropertiesReader.get_exp_tax_id_navigated_to, assert_fail_message)\r\n\r\n # Click on the browser back button and verify that the user is navigated back to the original profile page (the following navigations rely being on this pag)\r\n back_nav_assert_fail_msg = 'Clicking on the back button from the Tax ID page does not take to the expected URL'\r\n @place_holder.browser_go_back_assert_url(recipient_profile_url, back_nav_assert_fail_msg)\r\n\r\n end\r\n\r\n # Verify navigation to and back from Provider page\r\n begin\r\n\r\n # Verify navigation to the Provider page\r\n assert_fail_message = 'Clicking on the Provider of this takes to the expected URL'\r\n provider_link_text_to_click_on = PropertiesReader.get_provider_link_text_to_click_on\r\n @place_holder.nav_via_hyperlink_assert_url(provider_link_text_to_click_on, PropertiesReader.get_exp_provider_navigated_to, assert_fail_message)\r\n\r\n # Click on the browser back button and verify that the user is navigated back to the original profile page (the following navigations rely being on this pag)\r\n back_nav_assert_fail_msg = 'Clicking on the back button from the Tax ID page does not take to the expected URL'\r\n @place_holder.browser_go_back_assert_url(recipient_profile_url, back_nav_assert_fail_msg)\r\n\r\n end\r\n\r\n end", "def test_ID_25890_published_posts_02\n login_as_user1\n go_to_edit_profile_page\n $profile_your_posts.click\n sleep 5\n $profile_published.when_present(60).click\n verify_text \"test_ID_25890_published_posts\",\"Your Posts\",\"Drafts\", \"Scheduled\", \"Published\",\"Submitted Drafts \",\"Published\"\n verify_elements_on_published_post \"test_ID_25890_published_posts\"\n end", "def test_guest_access_to_userland_gives_login_screen\n get '/in/index'\n assert last_response.redirect?\n follow_redirect!\n\n assert last_request.url.ends_with?(\"/login\")\n assert last_response.ok?\n assert last_response.body.include?('Login to continue') \n end", "def test_should_flag_ON_INIT_PAGE_NEXT_when_clicking_next_on_valid_init_page\n post :init, :user=>{:first_name=>field_first_name, :last_name=>field_last_name}, :commit=>:next\n #assert_redirected_to :action=>second_page\n assert assigns['on_init_page_next']\n end", "def test_00171_homepage_featured_review_widget\n @browser.wait_until { @home_page.featured_r_widget.present? }\n @browser.wait_until { @home_page.featured_r_widget.posts.size > 0 }\n\n # verify the title link would redirect to conversation page.\n q_title = @home_page.featured_r_widget.posts[0].title\n @home_page.featured_r_widget.posts[0].click_title_link\n @browser.wait_until { @convdetail_page.conv_detail.present? }\n assert_equal @convdetail_page.conv_title.when_present.text, q_title, \"title doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_r_widget.posts.size > 0 }\n\n # verify avatar link would redirect to profile page\n @home_page.featured_r_widget.posts[0].click_avatar\n @browser.wait_until { @profile_page.profile_page.present? }\n author_name = @profile_page.profile_page_author_name_betaon.when_present.text\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_r_widget.posts.size > 0 }\n\n # verify author link would redirect to profile page\n @home_page.featured_r_widget.posts[0].click_author_link\n @browser.wait_until { @profile_page.profile_page.present? }\n assert_equal @profile_page.profile_page_author_name_betaon.when_present.text, author_name, \"Author doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_r_widget.posts.size > 0 }\n\n # verify topic link would redirect to the correct topic page\n post_in_topic = @home_page.featured_r_widget.posts[0].in_topic_link.when_present.text\n\n @home_page.featured_r_widget.posts[0].click_topic_link\n @browser.wait_until { @topicdetail_page.topic_filter.present? }\n assert_equal @topicdetail_page.topic_title.when_present.text, post_in_topic, \"Title doesn't match\"\n end", "def test_ID_25841_edit_profile_i_am_a_optional\n login_as_user1\n go_to_edit_profile_page\n verify_i_am_a_text_optional\n verify_text_can_be_entered_saved_on_i_am_a\n end", "def test_03_storyadmin_clickall_links()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 02 ----------------------\"\n\t\tlogin(\"orgadmin@aol.com\", \"123456\")\n\t\tverifyHeaderLinks()\n\t\tverifyFooterLinks()\n\t\tverifyMyAccountLinks()\n\t\tverifyNPOAdminLinks(\"Minnesota Community Foundation\")\n\t\t#~ searchProject(\"RazooTrunkFirefoxPRO20 of Minnesota Community Foundation\")\n\t\t#~ verifyStoryAdminLinks()\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 02 --------------------------\"\n\tend", "def test_ID_25841_edit_profile_i_am_a_optional\n login_as_user1\n go_to_edit_profile_page\n verify_i_am_a_text_optional\n verify_text_can_be_entered_saved_on_i_am_a_textfield\n end", "def test01_LI2_view_contributor\n\t\t$browser.goto($patch_login)\n\t\tloginDirectory\n\t\t$browser.goto($patch_directory_listing)\n\t\t$directory_top.fire_event(\"onclick\")\n\t\t\n\t\tsleep 5\n\t\tbegin\n\t\tassert assert $browser.text.include? \"Recent Activity\"\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"LI2_view_contributor: FAILED! Unable to view top contributor profile.\"\n\t\tend\n\tend", "def test_ID_25835_edit_profile_desc\n login_as_user1\n go_to_edit_profile_page\n verify_elements_left_nav \"test_ID_25835_edit_profile_desc\"\n verify_elements_on_edit_profile \"test_ID_25835_edit_profile_desc\"\n end", "def test_redirect_url_match\n process :redirect_external\n assert @response.redirect?\n assert @response.redirect_url_match?(\"rubyonrails\")\n assert @response.redirect_url_match?(/rubyonrails/)\n assert !@response.redirect_url_match?(\"phpoffrails\")\n assert !@response.redirect_url_match?(/perloffrails/)\n end", "def test_profile_url_redirects\r\n\r\n login_with_proper_credentials\r\n\r\n logout_using_gear_icon\r\n\r\n #Verify the redirection to the secure login takes place after signing out\r\n lynx_assert_actual_url(EXPECTED_HTTPS_URL, 'Not redirected to HTTPS login page after signingout using gear icon')\r\n\r\n $browser.goto(PROFILE_TO_ACCESS_AFTER_LOGOUT)\r\n sleep(1)\r\n\r\n lynx_assert_actual_url(EXPECTED_HTTPS_URL, 'Attempting to access a profile using profile URL after signing out using gear icon does not redirect to HTTPS login page')\r\n\r\n end", "def test_NeedHelpLink\n\n loginpage = Hudl_Login_Page.new @@driver\n\n loginpage.ClickNeedHelp()\n\n end", "def test_member_account\n get \"/account\"\n assert_redirected_to \"http://www.example.com/person_session/new\"\n follow_redirect!\n login :person_session => { :login => 'bob.jones', :password => 'secret' }\n assert_redirected_to \"http://www.example.com/account\"\n follow_redirect!\n assert_redirected_to \"http://www.example.com/people/#{@member.id}/edit\"\n\n get \"/account\"\n assert_redirected_to \"http://www.example.com/people/#{@member.id}/edit\"\n\n get \"/people/#{@member.id}/account\"\n assert_redirected_to \"http://www.example.com/people/#{@member.id}/edit\"\n\n get \"/people/account\"\n assert_redirected_to \"http://www.example.com/people/#{@member.id}/edit\"\n\n another_member = Person.create!.id\n get \"/people/#{another_member}/account\"\n assert_redirected_to \"http://www.example.com/people/#{another_member}/edit\"\n follow_redirect!\n assert_redirected_to unauthorized_path\n\n get \"/logout\"\n get \"/account\"\n login :person_session => { :login => 'admin@example.com', :password => 'secret' }\n assert_redirected_to \"http://www.example.com/account\"\n follow_redirect!\n assert_redirected_to \"http://www.example.com/people/#{@administrator.id}/edit\"\n\n get \"/people/#{@member.id}/account\"\n assert_redirected_to \"http://www.example.com/people/#{@member.id}/edit\"\n\n get \"/people/account\"\n assert_redirected_to \"http://www.example.com/people/#{@administrator.id}/edit\"\n\n get \"/people/#{another_member}/account\"\n assert_redirected_to \"http://www.example.com/people/#{another_member}/edit\"\n\n get \"/people/#{@administrator.id}/account\"\n assert_redirected_to \"http://www.example.com/people/#{@administrator.id}/edit\"\n \n put \"/people/#{@administrator.id}\"\n assert_redirected_to \"http://www.example.com/people/#{@administrator.id}/edit\" \n end", "def test_navigation_logged_in\n authorize @valid_user\n get :index\n assert_tag \"a\", :content => /Logout/,\n :attributes => { :href => \"/user/logout\"}\n assert_no_tag \"a\", :content => /Register/\n assert_no_tag \"a\", :content => /Login/\n end", "def should_have_correct_static_pages_links\n visit root_path\n\tclick_link \"About\"\n\tpage.should have_selector 'title', text: 'About'\n\tclick_link \"Home\"\n\tclick_link \"Sign up now!\"\n\tpage.should have_selector 'title', text: 'Sign up'\n\tclick_link \"pbook\"\n\tpage.should have_selector 'title', text: 'PammBook'\nend", "def verifyNPOAdminLinks(story_name)\n\t\n\tputs \"************** START: Verify ORG page Links ****************\"\n\t\n\tputs \"Step 1 : Click on MY NPO link at the Header.\"\n\t$browser.click \"link=My NPO\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(story_name)\n\t\tputs \"Step 1 is Passed. User has reached the MY NPO screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1 is Failed. User had failed to reach MY NPO screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 2 : Click on EditPage link on the Story page.\"\n\t$browser.click \"link=Edit Page\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"The Basics\")\n\t\tputs \"Step 2 is Passed. User has reached the EditPage screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 is Failed. User had failed to reach EditPage screen.\"\n\t\t$verification_errors << $!\n\tend\n\n\tputs \"Step 3 : Click on Thumbnail link on the Story page.\"\n\t$browser.click \"link=Thumbnail\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Current Thumbnail\")\n\t\tputs \"Step 3 is Passed. User has reached the Thumbnail screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 is Failed. User had failed to reach Thumbnail screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 4 : Click on Matching Grants link on the Story page.\"\n\t$browser.click \"link=Matching Grants\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Grantor\")\n\t\tputs \"Step 4 is Passed. User has reached the Matching Grants screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 4 is Failed. User had failed to reach Matching Grants screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 5 : Click on NPO Details link on the Story page.\"\n\t$browser.click \"link=NPO Details\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Charity Logo:\")\n\t\tputs \"Step 5 is Passed. User has reached the NPO Details screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 5 is Failed. User had failed to reach NPO Details screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 6 : Click on Promote link on the Story page.\"\n\t$browser.click \"link=Promote\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Or get a donation button to put on your website\")\n\t\tputs \"Step 6 is Passed. User has reached the Promote screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 6 is Failed. User had failed to reach Promote screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 7 : Click on DonateAnywhere link on the Story page.\"\n\t$browser.click \"link=DonateAnywhere\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"DonateAnywhere\")\n\t\tputs \"Step 7 is Passed. User has reached the DonateAnywhere screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 7 is Failed. User had failed to reach DonateAnywhere screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 8 : Click on Donations link on the Story page.\"\n\t$browser.click \"link=Donations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Donations Listing\")\n\t\tputs \"Step 8 is Passed. User has reached the Donations screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 8 is Failed. User had failed to reach Donations screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 9 : Click on Donations link on the Story page.\"\n\t$browser.click \"link=Disbursements\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Disbursements\")\n\t\tputs \"Step 9 is Passed. User has reached the Disbursements screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 9 is Failed. User had failed to reach Disbursements screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\t# ------------------------------ Global Admin Links -----------------------------\n\tbegin \n\t\tassert $browser.is_element_present(\"link=Data Sources\")\n\t\tputs \"Step 10 : Click on Create Data Sources link on the Story page.\"\n\t\t$browser.click \"link=Data Sources\"\n\t\t$browser.wait_for_page_to_load \n\t\tbegin\n\t\t\tassert $browser.is_text_present(\"Razoo Admin Area\")\n\t\t\tputs \"Step 10 is Passed. User has reached the Data Sources screen successfully.\"\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 10 is Failed. User had failed to reach Data Sources screen.\"\n\t\t\t$verification_errors << $!\n\t\tend\n\t\tputs \"Step 11 : Click on Create Audits link on the Story page.\"\n\t\t$browser.click \"link=Audits\"\n\t\t$browser.wait_for_page_to_load \n\t\tbegin\n\t\t\tassert $browser.is_text_present(\"PATRIOT Act\")\n\t\t\tputs \"Step 11 is Passed. User has reached the Audits screen successfully.\"\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 11 is Failed. User had failed to reach Audits screen.\"\n\t\t\t$verification_errors << $!\n\t\tend\n\trescue\n\t\tputs \"Step 10 & 11 : I don't have access to view Data Sources and Audit links.\"\n\tend\n\t# ------------------------------ Global Admin Links -----------------------------\n\t\n\tputs \"Step 12 : Click on Create Project link on the Story page.\"\n\t$browser.click \"link=Create Project\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"The Basics\")\n\t\tputs \"Step 12 is Passed. User has reached the Create Project screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 12 is Failed. User had failed to reach Create Project screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"************** END: Verify ORG page Links ****************\"\n\nend", "def verifyNPOAdminLinks(story_name)\n\t\n\tputs \"************** START: Verify ORG page Links ****************\"\n\t\n\tputs \"Step 1 : Click on MY NPO link at the Header.\"\n\t$browser.click \"link=My NPO\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(story_name)\n\t\tputs \"Step 1 is Passed. User has reached the MY NPO screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1 is Failed. User had failed to reach MY NPO screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 2 : Click on EditPage link on the Story page.\"\n\t$browser.click \"link=Edit Page\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"The Basics\")\n\t\tputs \"Step 2 is Passed. User has reached the EditPage screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 is Failed. User had failed to reach EditPage screen.\"\n\t\t$verification_errors << $!\n\tend\n\n\tputs \"Step 3 : Click on Thumbnail link on the Story page.\"\n\t$browser.click \"link=Thumbnail\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Current Thumbnail\")\n\t\tputs \"Step 3 is Passed. User has reached the Thumbnail screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 is Failed. User had failed to reach Thumbnail screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 4 : Click on Matching Grants link on the Story page.\"\n\t$browser.click \"link=Matching Grants\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Grantor\")\n\t\tputs \"Step 4 is Passed. User has reached the Matching Grants screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 4 is Failed. User had failed to reach Matching Grants screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 5 : Click on NPO Details link on the Story page.\"\n\t$browser.click \"link=NPO Details\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Charity Logo:\")\n\t\tputs \"Step 5 is Passed. User has reached the NPO Details screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 5 is Failed. User had failed to reach NPO Details screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 6 : Click on Promote link on the Story page.\"\n\t$browser.click \"link=Promote\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Or get a donation button to put on your website\")\n\t\tputs \"Step 6 is Passed. User has reached the Promote screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 6 is Failed. User had failed to reach Promote screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 7 : Click on DonateAnywhere link on the Story page.\"\n\t$browser.click \"link=DonateAnywhere\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"DonateAnywhere\")\n\t\tputs \"Step 7 is Passed. User has reached the DonateAnywhere screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 7 is Failed. User had failed to reach DonateAnywhere screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 8 : Click on Donations link on the Story page.\"\n\t$browser.click \"link=Donations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Donations Listing\")\n\t\tputs \"Step 8 is Passed. User has reached the Donations screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 8 is Failed. User had failed to reach Donations screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 9 : Click on Disbursements link on the Story page.\"\n\t$browser.click \"link=Disbursements\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Disbursements\")\n\t\tputs \"Step 9 is Passed. User has reached the Disbursements screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 9 is Failed. User had failed to reach Disbursements screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\t# ------------------------------ Global Admin Links -----------------------------\n\tbegin \n\t\tassert $browser.is_element_present(\"link=Data Sources\")\n\t\tputs \"Step 10 : Click on Create Data Sources link on the Story page.\"\n\t\t$browser.click \"link=Data Sources\"\n\t\t$browser.wait_for_page_to_load \n\t\tbegin\n\t\t\tassert $browser.is_text_present(\"Razoo Admin Area\")\n\t\t\tputs \"Step 10 is Passed. User has reached the Data Sources screen successfully.\"\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 10 is Failed. User had failed to reach Data Sources screen.\"\n\t\t\t$verification_errors << $!\n\t\tend\n\t\tputs \"Step 11 : Click on Create Audits link on the Story page.\"\n\t\t$browser.click \"link=Audits\"\n\t\t$browser.wait_for_page_to_load \n\t\tbegin\n\t\t\tassert $browser.is_text_present(\"PATRIOT Act\")\n\t\t\tputs \"Step 11 is Passed. User has reached the Audits screen successfully.\"\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 11 is Failed. User had failed to reach Audits screen.\"\n\t\t\t$verification_errors << $!\n\t\tend\n\trescue\n\t\tputs \"Step 10 & 11 : I don't have access to view Data Sources and Audit links.\"\n\tend\n\t# ------------------------------ Global Admin Links -----------------------------\n\t\n\tputs \"Step 12 : Click on Create Project link on the Story page.\"\n\t$browser.click \"link=Create Project\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"The Basics\")\n\t\tputs \"Step 12 is Passed. User has reached the Create Project screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 12 is Failed. User had failed to reach Create Project screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"************** END: Verify ORG page Links ****************\"\n\nend", "def test_redirect_url\n common_opts = {}\n if user_is_in_proper_account?\n Rails.application.routes.url_helpers.workplace_start_path(common_opts.merge({success: true, refresh: true}))\n elsif UserSession.find\n Rails.application.routes.url_helpers.workplace_failure_path(common_opts.merge({network: params[:network], wrong_network: true}))\n else\n Rails.application.routes.url_helpers.identity_provider_path(common_opts.merge({network: params[:network], fb_workplace_network: false}))\n end\n end", "def follow_redirect?; end", "def test_ID_25889_current_drafts_04\n login_as_user1\n go_to_edit_profile_page\n $profile_your_posts.click\n sleep 5\n verify_post_and_draft_count_updated_after_draft_posted\n end", "def go_to_helpdesk_page\n edit_user_link.click\n helpdesk_link.click\n end", "def test_page_security\n # A public page\n get '/home'\n assert_response :success\n # An administrator page\n get '/admin'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n \n get '/admin'\n assert_response :success\n end", "def redirects; end", "def verifyNPOAdminLinks(story_name)\n\t\n\tputs \"************** START: Verify ORG page Links ****************\"\n\t\n\tputs \"Click on MY NPO link at the Header.\"\n\tbegin \n\t\tassert $browser.is_element_present(\"link=My nonprofit\")\n\t\t$browser.click \"link=My nonprofit\"\n\t\t$browser.wait_for_page_to_load \n\t\tbegin\n\t\t\tassert $browser.is_text_present(story_name)\n\t\t\tputs \"Step 1 is Passed. User has reached the MY NPO screen successfully.\"\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 1 is Failed. User had failed to reach MY NPO screen.\"\n\t\tend\n\trescue\n\t\t$browser.click \"link=My nonprofits\"\n\t\t$browser.wait_for_page_to_load\n\t\tbegin\n\t\t\tassert $browser.is_text_present(\"News Feed\")\n\t\t\tputs \"Step 1 is Passed. User has reached the Account screen successfully.\"\n\t\t\t$browser.click \"link=Harvard College\"\n\t\t\t$browser.wait_for_page_to_load\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 1 is Failed. User had failed to reach Account screen.\"\n\t\tend\n\tend \n\tsleep 5\n\tputs \"Step 2 : Click on EditPage link on the Story page.\"\n\t$browser.click \"link=Edit\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Tell Your Story\")\n\t\tputs \"Step 2 is Passed. User has reached the EditPage screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 is Failed. User had failed to reach EditPage screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 4 : Click on Matching Grants link on the Story page.\"\n\t$browser.click \"link=Matching Grants\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Matching Grant\")\n\t\tputs \"Step 4 is Passed. User has reached the Matching Grants screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 4 is Failed. User had failed to reach Matching Grants screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 8 : Click on Donations link on the Story page.\"\n\t$browser.click \"link=Donations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Donations Listing\")\n\t\tputs \"Step 8 is Passed. User has reached the Donations screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 8 is Failed. User had failed to reach Donations screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\t# ------------------------------ Global Admin Links -----------------------------\n\tbegin \n\t\tassert $browser.is_element_present(\"link=Razoo Admins\")\n\t\tputs \"Step 10 : Click on Create Data Sources link on the Story page.\"\n\t\t$browser.click \"link=Data Sources\"\n\t\t$browser.wait_for_page_to_load \n\t\tbegin\n\t\t\tassert $browser.is_text_present(\"Razoo Admin Area\")\n\t\t\tputs \"Step 10 is Passed. User has reached the Data Sources screen successfully.\"\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 10 is Failed. User had failed to reach Data Sources screen.\"\n\t\t\t$verification_errors << $!\n\t\tend\n\t\tputs \"Step 11 : Click on Create Audits link on the Story page.\"\n\t\t$browser.click \"link=Audits\"\n\t\t$browser.wait_for_page_to_load \n\t\tbegin\n\t\t\tassert $browser.is_text_present(\"PATRIOT Act\")\n\t\t\tputs \"Step 11 is Passed. User has reached the Audits screen successfully.\"\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 11 is Failed. User had failed to reach Audits screen.\"\n\t\t\t$verification_errors << $!\n\t\tend\n\trescue\n\t\tputs \"Step 10 & 11 : I don't have access to view Data Sources and Audit links.\"\n\tend\n\t# ------------------------------ Global Admin Links -----------------------------\n\n\t\n\tputs \"************** END: Verify ORG page Links ****************\"\n\nend", "def test_login\n get \"my/page\"\n assert_redirected_to \"/login?back_url=http%3A%2F%2Fwww.example.com%2Fmy%2Fpage\"\n log_user('jsmith', 'jsmith')\n\n get \"my/account\"\n assert_response :success\n assert_template \"my/account\"\n end", "def check_redirect(proj)\n visit opening_path(proj)\n assert_text 'You must be logged in to view job openings.'\n assert page.has_css?('title', text: full_title('User Login'), visible: false)\n assert page.has_css?('h1', text: 'User Login')\n end", "def test_ID_25839_edit_profile_home_patch\n login_as_user1\n go_to_edit_profile_page\n verify_users_default_town_name_displayed_as_home_patch \"test_ID_25835_edit_profile_desc\" , \"Bellmore Patch\"\n verify_hometown_change_is_saved \"Bellmore Patch\",\"Garden City Patch\"\n end", "def test_ID_25839_edit_profile_home_patch\n login_as_user1\n go_to_edit_profile_page\n verify_users_default_town_name_displayed_as_home_patch \"test_ID_25835_edit_profile_desc\" , \"Bellmore Patch\"\n verify_hometown_change_is_saved \"Bellmore Patch\",\"Garden City Patch\"\n end", "def redirect_ok; end", "def redirect_ok; end", "def test_00130_profilepage_check_activity_feed_link\n @profile_page.goto_profile\n @browser.wait_until { @profile_page.profile_activity_item.present? }\n\n @browser.wait_until { @profile_page.question_list_in_activity_pane.activity_list.size > 0 }\n activity_card = @profile_page.question_list_in_activity_pane.activity_list[0]\n conv = activity_card.conv_title\n activity_card.click_conv_link\n\n @browser.wait_until { @convdetail_page.convdetail.present? }\n assert @convdetail_page.convdetail.text.include? conv\n end", "def should_see_facebook_login_button\n expect(page).to have_link(\"fb_login_btn\")\n end", "def verifyAboutUsLinks()\n\t\n\tputs \"************** START: Verify AboutUs Links ****************\"\n\t\n\tputs \"Step 1 : Click on AboutRazoo Link at the Footer.\"\n\t$browser.click \"link=About Razoo\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Razoo Overview\")\n\t\tputs \"Step 1 is Passed. User has reached the AboutRazoo screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1 is Failed. User had failed to reach the About Razoo screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 2 : Click on Overview Link in AboutRazoo screen.\"\n\t$browser.click \"link=Overview\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Donate. Fundraise. Connect.\")\n\t\tputs \"Step 2 is Passed. User has reached the Overview screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 is Failed. User had failed to reach the Overview screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 3 : Click on CloserLook Link in AboutRazoo screen.\"\n\t$browser.click \"link=A Closer Look\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"A Closer Look\")\n\t\tputs \"Step 3 is Passed. User has reached the CloserLook screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 is Failed. User had failed to reach the CloserLook screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 4 : Click on OurTeam Link in AboutRazoo screen.\"\n\t$browser.click \"link=Our Team\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Razoo is a vibrant social enterprise with an accomplished, fun, and diverse team.\")\n\t\tputs \"Step 4 is Passed. User has reached the OurTeam screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 4 is Failed. User had failed to reach the CloserLook screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 5 : Click on Careers Link in AboutRazoo screen.\"\n\t$browser.click \"link=Careers\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Careers at Razoo\")\n\t\tputs \"Step 5 is Passed. User has reached the Careers screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 5 is Failed. User had failed to reach the Careers screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 6 : Click on PressCoverage Link in AboutRazoo screen.\"\n\t$browser.click \"link=Press Coverage\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Razoo often appears in both local and national press in recognition of our innovative website and approach to online giving and fundraising.\")\n\t\tputs \"Step 6 is Passed. User has reached the PressCoverage screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 6 is Failed. User had failed to reach the PressCoverage screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 7 : Click on ContactUs Link in AboutRazoo screen.\"\n\t$browser.click \"link=Contact Us\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Contact Us\")\n\t\tputs \"Step 7 is Passed. User has reached the ContactUs screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 7 is Failed. User had failed to reach the ContactUs screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 8 : Click on AtGlance Link in AboutRazoo screen.\"\n\t$browser.click \"link=At A Glance\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"What We Offer - At A Glance\")\n\t\tputs \"Step 8 is Passed. User has reached the AtGlance screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 8 is Failed. User had failed to reach the AtGlance screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 9 : Click on ForIndividuals Link in AboutRazoo screen.\"\n\t$browser.click \"link=For Individuals\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Razoo For Individuals\")\n\t\tputs \"Step 9 is Passed. User has reached the ForIndividuals screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 9 is Failed. User had failed to reach the ForIndividuals screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 10 : Click on ForNonProfits Link in AboutRazoo screen.\"\n\t$browser.click \"link=For Nonprofits\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Razoo For Nonprofits\")\n\t\tputs \"Step 10 is Passed. User has reached the ForNonProfits screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 10 is Failed. User had failed to reach the ForNonProfits screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 11 : Click on ForFoundations Link in AboutRazoo screen.\"\n\t$browser.click \"link=For Foundations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Razoo For Foundations\")\n\t\tputs \"Step 11 is Passed. User has reached the ForFoundations screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 11 is Failed. User had failed to reach the ForFoundations screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 12 : Click on ForCorporations Link in AboutRazoo screen.\"\n\t$browser.click \"link=For Corporations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Razoo For Corporations\")\n\t\tputs \"Step 12 is Passed. User has reached the ForCorporations screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 12 is Failed. User had failed to reach the ForCorporations screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 13 : Click on SuccessStories Link in AboutRazoo screen.\"\n\t$browser.click \"link=Success Stories\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Success Stories\")\n\t\tputs \"Step 13 is Passed. User has reached the SuccessStories screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 13 is Failed. User had failed to reach the SuccessStories screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 14 : Click on BestValue Link in AboutRazoo screen.\"\n\t$browser.click \"link=The Best Value\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"The Best Value\")\n\t\tputs \"Step 14 is Passed. User has reached the BestValue screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 14 is Failed. User had failed to reach the BestValue screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 15 : Click on EFT Link in AboutRazoo screen.\"\n\t$browser.click \"link=EFT\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"EFT Authorization Form for Nonprofits\")\n\t\tputs \"Step 15 is Passed. User has reached the EFT screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 15 is Failed. User had failed to reach the EFT screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 16 : Click on DonateAnywhere Link in AboutRazoo screen.\"\n\t$browser.click \"link=DonateAnywhere Widget\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"The DonateAnywhere Widget\")\n\t\tputs \"Step 16 is Passed. User has reached the DonateAnywhere screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 16 is Failed. User had failed to reach the DonateAnywhere screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 17 : Click on EDP Link in AboutRazoo screen.\"\n\t$browser.click \"link=Enhanced Donation Processing\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Enhanced Donation Processing\")\n\t\tputs \"Step 17 is Passed. User has reached the EDP screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 17 is Failed. User had failed to reach the EDP screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 18 : Click on Tips Link in AboutRazoo screen.\"\n\t$browser.click \"link=Introducing Tips\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"tips\")\n\t\tputs \"Step 18 is Passed. User has reached the Tips screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 18 is Failed. User had failed to reach the Tips screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 19 : Click on Blog Link in AboutRazoo screen.\"\n\t$browser.click \"link=Blog on Razoo Impact\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Razoo Impact\")\n\t\tputs \"Step 19 is Passed. User has reached the Blog screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 19 is Failed. User had failed to reach the Blog screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 20 : Click on HowDonationsWork Link in AboutRazoo screen.\"\n\t$browser.click \"link=How Donations Work\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"How Donations Work\")\n\t\tputs \"Step 20 is Passed. User has reached the HowDonationsWork screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 20 is Failed. User had failed to reach the HowDonationsWork screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 21 : Click on FundraisingIdeas Link in AboutRazoo screen.\"\n\t$browser.click \"link=Fundraising Ideas\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Fundraising Ideas\")\n\t\tputs \"Step 21 is Passed. User has reached the FundraisingIdeas screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 21 is Failed. User had failed to reach the FundraisingIdeas screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 22 : Click on SetUpFR Link in AboutRazoo screen.\"\n\t$browser.click \"link=How to Setup a Fundraiser\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Create a Fundraising Page\")\n\t\tputs \"Step 22 is Passed. User has reached the SetUpFR screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 22 is Failed. User had failed to reach the SetUpFR screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 23 : Click on MakeYourPageGreat Link in AboutRazoo screen.\"\n\t$browser.click \"link=Make Your Page Great\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Make Your Page Great\")\n\t\tputs \"Step 23 is Passed. User has reached the MakeYourPageGreat screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 23 is Failed. User had failed to reach the MakeYourPageGreat screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 24 : Click on SharePromote Link in AboutRazoo screen.\"\n\t$browser.click \"link=Share and Promote Your Page\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Share and Promote your page\")\n\t\tputs \"Step 24 is Passed. User has reached the SharePromote screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 24 is Failed. User had failed to reach the SharePromote screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 25 : Click on Logos Link in AboutRazoo screen.\"\n\t$browser.click \"link=Logos\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"We've collected a few logos for your use.\")\n\t\tputs \"Step 25 is Passed. User has reached the SharePromote screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 25 is Failed. User had failed to reach the SharePromote screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 26 : Click on OurHomepage Link in AboutRazoo screen.\"\n\t$browser.click \"link=Get Featured on Our Homepage\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Getting Featured on Razoo\")\n\t\tputs \"Step 26 is Passed. User has reached the OurHomepage screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 26 is Failed. User had failed to reach the OurHomepage screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 27 : Click on FAQIndividuals Link in AboutRazoo screen.\"\n\t$browser.click \"link=FAQs for Individuals\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"FAQs for Individuals\")\n\t\tputs \"Step 27 is Passed. User has reached the FAQIndividuals screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 27 is Failed. User had failed to reach the FAQIndividuals screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 28 : Click on FAQNonProfits Link in AboutRazoo screen.\"\n\t$browser.click \"link=FAQs for Nonprofits\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"FAQs for Nonprofits\")\n\t\tputs \"Step 28 is Passed. User has reached the FAQNonProfits screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 28 is Failed. User had failed to reach the FAQNonProfits screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 29 : Click on Security Link in AboutRazoo screen.\"\n\t$browser.click \"link=Security\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Security and Privacy\")\n\t\tputs \"Step 29 is Passed. User has reached the Security screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 29 is Failed. User had failed to reach the Security screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 30 : Click on Privacy Link in AboutRazoo screen.\"\n\t$browser.click \"link=Privacy\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"The Razoo.com Privacy Policy\")\n\t\tputs \"Step 30 is Passed. User has reached the Privacy screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 30 is Failed. User had failed to reach the Privacy screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 31 : Click on TOU Link in AboutRazoo screen.\"\n\t$browser.click \"link=Terms of Use\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"The Razoo.com Terms of Use\")\n\t\tputs \"Step 31 is Passed. User has reached the TOU screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 31 is Failed. User had failed to reach the TOU screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"************** END: Verify AboutUs Links ****************\"\n\nend", "def test_index\n get :index\n \n assert_redirected_to :action => :unread\n end", "def test_grader_that_has_active_report_cant_take_on_another_report\n login_as :sean\n post :auto_assign\n assert_redirected_to :controller => :home, :action=>:index\n end", "def verifyMyAccountLinks()\n\t\n\tputs \"************** START: Verify MyAccount Links ****************\"\n\t\n\tputs \"Step 1 : Verify all the links under My Account screen.\"\n\t$browser.click \"//img[@alt='Your profile picture']\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Your Account on Razoo\")\n\t\tputs \"Step 1.1 : User has reached the Account page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.1 : User had failed to reach the Account page.\"\n\t\t$verification_errors << $!\n\tend\n\t$browser.click \"link=Edit Profile\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Edit My Profile\")\n\t\tputs \"Step 1.2 : User has reached the EditMyProfile page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.2 : User had failed to reach the EditMyProfile page.\"\n\t\t$verification_errors << $!\n\tend\n\t$browser.click \"link=My Donations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Start donating\")\n\t\tputs \"Step 1.3 : User has reached the My Donations page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.3 : User had failed to reach the My Donations page.\"\n\t\t$verification_errors << $!\n\tend\n\t$browser.click \"link=Account Settings\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Change your login information\")\n\t\tputs \"Step 1.4 : User has reached the Account Settings page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.4 : User had failed to reach the Account Settings page.\"\n\t\t$verification_errors << $!\n\tend\n\tbegin\n\t\tassert $browser.is_element_present(\"link=My Saved Cards\")\n\t\t$browser.click \"link=My Saved Cards\"\n\t\t$browser.wait_for_page_to_load \n\t\tbegin\n\t\t\tassert $browser.is_text_present(\"My Credit Cards\")\n\t\t\tputs \"Step 1.5 : User has reached the My Saved Card page successfully.\"\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 1.5 : User had failed to reach the My Saved Card page.\"\n\t\t\t$verification_errors << $!\n\t\tend\n\trescue\n\t\t$verification_errors << $!\n\t\tputs \"Step 1.5 : My Saved card link is not available for this User.\"\n\tend\n\t\n\tputs \"************** END: Verify MyAccount Links ****************\"\n\t\nend", "def when_i_submit_bad_url\n given_i_am_signed_in\n # shouldn't get to the stage of finding\n submit_url 'http://thisisspam.com/fake-viagra.html'\nend", "def test_view\n # Test a non-existent user\n get :view, :params => { :display_name => \"unknown\" }\n assert_response :not_found\n\n # Test a normal user\n user = create(:user)\n get :view, :params => { :display_name => user.display_name }\n assert_response :success\n assert_select \"div#userinformation\" do\n assert_select \"a[href^='/user/#{ERB::Util.u(user.display_name)}/history']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/traces']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/diary']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/account']\", 0\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']\", 0\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']\", 0\n assert_select \"a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']\", 0\n end\n\n # Test a user who has been blocked\n blocked_user = create(:user)\n create(:user_block, :user => blocked_user)\n get :view, :params => { :display_name => blocked_user.display_name }\n assert_response :success\n assert_select \"div#userinformation\" do\n assert_select \"a[href^='/user/#{ERB::Util.u(blocked_user.display_name)}/history']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/traces']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/diary']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/diary/comments']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/account']\", 0\n assert_select \"a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(blocked_user.display_name)}/blocks_by']\", 0\n assert_select \"a[href='/blocks/new/#{ERB::Util.u(blocked_user.display_name)}']\", 0\n end\n\n # Test a moderator who has applied blocks\n moderator_user = create(:moderator_user)\n create(:user_block, :creator => moderator_user)\n get :view, :params => { :display_name => moderator_user.display_name }\n assert_response :success\n assert_select \"div#userinformation\" do\n assert_select \"a[href^='/user/#{ERB::Util.u(moderator_user.display_name)}/history']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/traces']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/diary']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/diary/comments']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/account']\", 0\n assert_select \"a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks']\", 0\n assert_select \"a[href='/user/#{ERB::Util.u(moderator_user.display_name)}/blocks_by']\", 1\n assert_select \"a[href='/blocks/new/#{ERB::Util.u(moderator_user.display_name)}']\", 0\n end\n\n # Login as a normal user\n session[:user] = user.id\n\n # Test the normal user\n get :view, :params => { :display_name => user.display_name }\n assert_response :success\n assert_select \"div#userinformation\" do\n assert_select \"a[href^='/user/#{ERB::Util.u(user.display_name)}/history']\", 1\n assert_select \"a[href='/traces/mine']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/diary']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/account']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']\", 0\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']\", 0\n assert_select \"a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']\", 0\n end\n\n # Login as a moderator\n session[:user] = create(:moderator_user).id\n\n # Test the normal user\n get :view, :params => { :display_name => user.display_name }\n assert_response :success\n assert_select \"div#userinformation\" do\n assert_select \"a[href^='/user/#{ERB::Util.u(user.display_name)}/history']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/traces']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/diary']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/diary/comments']\", 1\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/account']\", 0\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/blocks']\", 0\n assert_select \"a[href='/user/#{ERB::Util.u(user.display_name)}/blocks_by']\", 0\n assert_select \"a[href='/blocks/new/#{ERB::Util.u(user.display_name)}']\", 1\n end\n end", "def test_00160_homepage_featured_b_widget\n # # @browser.execute_script(\"window.scrollBy(0,8000)\")\n # @browser.wait_until { @home_page.home_featured_blog.present? }\n # assert @home_page.home_featured_blog.present?\n # assert @home_page.home_featured_b_desc.present?\n @browser.wait_until { @home_page.featured_b_widget.present? }\n @browser.wait_until { @home_page.featured_b_widget.posts.size > 0 }\n\n # verify the title link would redirect to conversation page.\n q_title = @home_page.featured_b_widget.posts[0].title\n @home_page.featured_b_widget.posts[0].click_title_link\n @browser.wait_until { @convdetail_page.conv_detail.present? }\n assert_equal @convdetail_page.conv_title.when_present.text, q_title, \"title doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_b_widget.posts.size > 0 }\n\n # verify avatar link would redirect to profile page\n @home_page.featured_b_widget.posts[0].click_avatar\n @browser.wait_until { @profile_page.profile_page.present? }\n author_name = @profile_page.profile_page_author_name_betaon.when_present.text\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_b_widget.posts.size > 0 }\n\n # verify author link would redirect to profile page\n @home_page.featured_b_widget.posts[0].click_author_link\n @browser.wait_until { @profile_page.profile_page.present? }\n assert_equal @profile_page.profile_page_author_name_betaon.when_present.text, author_name, \"Author doesn't match\"\n\n @home_page.navigate_in\n @browser.wait_until { @home_page.featured_b_widget.posts.size > 0 }\n\n # verify topic link would redirect to the correct topic page\n post_in_topic = @home_page.featured_b_widget.posts[0].in_topic_link.when_present.text\n\n @home_page.featured_b_widget.posts[0].click_topic_link\n @browser.wait_until { @topicdetail_page.topic_filter.present? }\n assert_equal @topicdetail_page.topic_title.when_present.text, post_in_topic, \"Title doesn't match\"\n end", "def atest_ID_25891_scheduled_posts_02\n login $user_1_email, $master_password\n go_to_edit_profile_page\n $profiles_your_posts.click\n sleep 5\n go_to_scheduled_tab_on_your_post_page\n verify_text \"Your Posts\",\"Current Drafts\", \"Scheduled Posts\", \"Published Posts\", \"Scheduled\"\n assert $profile_edit_post.exists?\n assert $profile_delete.exists?\n assert $count_of_scheduled.exists?\n end", "def test_00070_add_feild_as_show_feild\n first_name = @c.users[user_for_test].name.split(' ')[0]\n # set first name feild as not show\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {0 => false }\n # admin can't see first name feild\n @profile_page.goto_profile\n url = @browser.url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert !(@profile_page.profile_page_author_name_betaon.text.include? first_name)\n # user2 can't see first name feild\n @login_page.about_login(\"regular_user2\", \"logged\")\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert !(@profile_page.profile_page_author_name_betaon.text.include? first_name)\n\n # set first name feild as show\n @login_page.about_login(\"network_admin\",\"logged\")\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {0 => true, 2 => false }\n # admin can't see first name feild]\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)\n # user2 can't see first name feild\n @login_page.about_login(\"regular_user2\", \"logged\")\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (!@profile_page.profile_page_author_name_betaon.text.include? first_name)\n\n # set first name feild as public\n @login_page.about_login(\"network_admin\",\"logged\")\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {0 => true, 2 => true }\n # admin can see first name feild\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)\n # user2 can see first name feild\n @browser.goto url\n @browser.wait_until { @profile_page.profile_page_author_name_betaon.present? }\n assert (@profile_page.profile_page_author_name_betaon.text.include? first_name)\n ensure\n # set first name feild as public\n @login_page.about_login(\"network_admin\",\"logged\")\n @admin_profile_page.navigate_in\n @admin_profile_page.custom_profile_feild \"First Name\", {2 => true }\n end", "def verify_landing_page\n @higgs.page_title_present?('Puppet Enterprise Installer')\n @higgs.link_present?('email the CEO.')\n @higgs.select_link(\"Let's get started\")\n @higgs.page_title_present?('Puppet Enterprise Installer - Choose your deployment')\n end", "def test_p1_00010_profilepage_profile_option\n if !@profilepage.profile_activity.present?\n @profilepage.goto_profile\n end\n if @profilepage.profile_pic_modal.present?\n @profilepage.profile_pic_cancel_button.click\n @browser.wait_until($t) { !@profilepage.profile_pic_modal.present? }\n end\n \t@profilepage.check_profile_in_user_dropdown\n \tassert @profilepage.profile_link.present? \n @profilepage.newline\n end", "def test_pending_request\n get '/goldberg/users/list'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n assert_match /goldberg\\/users\\/list/, response.redirected_to\n end", "def test_offers\r\n get :offers, :id => 5072\r\n assert_response 301\r\n assert_redirected_to '/Ear-Force-X2-Wireless-Headphones-for-Xbox-reviews'\r\n end", "def test05_LI2_repost_review\n\t\t$browser.goto($patch_login)\n\t\tloginDirectory\n\t\t$browser.goto($patch_directory_listing)\n\t\t\n\t\t\n\t\t\n\tend", "def test_04_razooglobaladmin_clickall_links()\n\t\t\n\t\tputs \"---------------------- START OF SCENARIO 03 ----------------------\"\n\t\tlogin(\"srajkumar.here@gmail.com\", \"razoo1\")\n\t\tverifyNPOAdminLinks(\"FRIENDS OF NEVADA ORGANICS ORG\")\n\t\tlogout()\n\t\tputs \"---------------------- END OF SCENARIO 03 --------------------------\"\n\tend", "def should_have_correct_static_pages_links\n\tvisit root_path\n\tclick_link \"About\"\n\tpage.should have_selector 'title', text: full_title('About Us')\n\tclick_link \"Help\"\n\tpage.should have_selector 'title', text: full_title('Help')\n\tclick_link \"Contact\"\n\tpage.should have_selector 'title', text: full_title('Contact')\n\tclick_link \"Home\"\n\tclick_link \"Sign up now!\"\n\tpage.should have_selector 'title', text: full_title('Sign up')\n\tclick_link \"social app\"\n\tpage.should have_selector 'title', text: 'Social App'\nend", "def test_shold_not_show_to_guest\n sign_out :user\n get :show\n assert_response :redirect\n end", "def test_ID_25837_edit_profile_name\n login_as_user1\n go_to_edit_profile_page\n verify_user_name_populated \"Jame Smith\"\n end", "def test_click_base\n page = @mech.get(\"http://google.com/tc_base_link.html\")\n page = page.links.first.click\n assert @mech.visited?(\"http://localhost/index.html\")\n end", "def test_action_security\n # A public action\n get '/goldberg/auth/login'\n assert_response :success\n # An administrator action\n get '/goldberg/users/list'\n assert_redirected_to_login\n\n form_login('admin', 'admin')\n\n get '/goldberg/users/list'\n assert_response :success\n end", "def test_should_get_edit\n login_as(:john)\n get :edit, :id => 1\n assert_response :redirect\n end", "def test_should_get_edit\n login_as(:john)\n get :edit, :id => 1\n assert_response :redirect\n end", "def verifyMyAccountLinks()\n\t\n\tputs \"************** START: Verify MyAccount Links ****************\"\n\t\n\tputs \"Step 1 : Verify all the links under My Account screen.\"\n\t$browser.click \"myAccountHeaderLink\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"My Account\")\n\t\tputs \"Step 1.1 : User has reached the Account page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.1 : User had failed to reach the Account page.\"\n\t\t$verification_errors << $!\n\tend\n\t$browser.click \"link=Edit My Profile\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Edit My Profile\")\n\t\tputs \"Step 1.2 : User has reached the EditMyProfile page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.2 : User had failed to reach the EditMyProfile page.\"\n\t\t$verification_errors << $!\n\tend\n\t$browser.click \"link=My Donations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Start donating\")\n\t\tputs \"Step 1.3 : User has reached the My Donations page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.3 : User had failed to reach the My Donations page.\"\n\t\t$verification_errors << $!\n\tend\n\t$browser.click \"link=Account Settings\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Change your login information\")\n\t\tputs \"Step 1.4 : User has reached the Account Settings page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.4 : User had failed to reach the Account Settings page.\"\n\t\t$verification_errors << $!\n\tend\n\tbegin\n\t\tassert $browser.is_element_present(\"link=My Saved Cards\")\n\t\t$browser.click \"link=My Saved Cards\"\n\t\t$browser.wait_for_page_to_load \n\t\tbegin\n\t\t\tassert $browser.is_text_present(\"My Credit Cards\")\n\t\t\tputs \"Step 1.5 : User has reached the My Saved Card page successfully.\"\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 1.5 : User had failed to reach the My Saved Card page.\"\n\t\t\t$verification_errors << $!\n\t\tend\n\trescue\n\t\t$verification_errors << $!\n\t\tputs \"Step 1.5 : My Saved card link is not available for this User.\"\n\tend\n\t\n\tputs \"************** END: Verify MyAccount Links ****************\"\n\t\nend", "def verifyMyAccountLinks()\n\t\n\tputs \"************** START: Verify MyAccount Links ****************\"\n\t\n\tputs \"Step 1 : Verify all the links under My Account screen.\"\n\t$browser.click \"myAccountHeaderLink\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"My Account\")\n\t\tputs \"Step 1.1 : User has reached the Account page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.1 : User had failed to reach the Account page.\"\n\t\t$verification_errors << $!\n\tend\n\t$browser.click \"link=Edit My Profile\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Edit My Profile\")\n\t\tputs \"Step 1.2 : User has reached the EditMyProfile page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.2 : User had failed to reach the EditMyProfile page.\"\n\t\t$verification_errors << $!\n\tend\n\t$browser.click \"link=My Donations\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Start donating\")\n\t\tputs \"Step 1.3 : User has reached the My Donations page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.3 : User had failed to reach the My Donations page.\"\n\t\t$verification_errors << $!\n\tend\n\t$browser.click \"link=Account Settings\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Change your login information\")\n\t\tputs \"Step 1.4 : User has reached the Account Settings page successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1.4 : User had failed to reach the Account Settings page.\"\n\t\t$verification_errors << $!\n\tend\n\tbegin\n\t\tassert $browser.is_element_present(\"link=My Saved Cards\")\n\t\t$browser.click \"link=My Saved Cards\"\n\t\t$browser.wait_for_page_to_load \n\t\tbegin\n\t\t\tassert $browser.is_text_present(\"My Credit Cards\")\n\t\t\tputs \"Step 1.5 : User has reached the My Saved Card page successfully.\"\n\t\trescue Test::Unit::AssertionFailedError\n\t\t\tputs \"Step 1.5 : User had failed to reach the My Saved Card page.\"\n\t\t\t$verification_errors << $!\n\t\tend\n\trescue\n\t\t$verification_errors << $!\n\t\tputs \"Step 1.5 : My Saved card link is not available for this User.\"\n\tend\n\t\n\tputs \"************** END: Verify MyAccount Links ****************\"\n\t\nend", "def test_redirection_location\n process :redirect_internal\n assert_equal 'http://test.host/nothing', @response.redirect_url\n\n process :redirect_external\n assert_equal 'http://www.rubyonrails.org', @response.redirect_url\n end", "def test_00090_about_page_edit_banner_button_for_admin\n @aboutpage.about_login(\"regular\", \"logged\")\n if !@aboutpage.about_widget.present?\n @aboutpage.goto_about_page\n end\n assert @aboutpage.about_edit.present?\n @aboutpage.newline\n end", "def test_logged_in_user_access_to_userland_approved\n # first log in\n post '/login', { :username => GOOD_USERNAME, :password => GOOD_PASSWORD }\n\n # then specifically request the index page in userland\n get '/in/index'\n assert last_response.ok?\n assert last_response.body.include?('You are logged in as') \n assert last_response.body.include?(GOOD_USERNAME) \n end", "def test_00020_profilepage_profile_page\n @profile_page.goto_profile\n @browser.wait_until { @profile_page.profile_activity_item.present? }\n\n assert_all_keys({\n :profile_page => @profile_page.profile_page.present?,\n :profile_username_match => @c.users[user_for_test].name == @profile_page.user_name,\n :work_info => @profile_page.profile_workinfo_line.present?,\n :profile_img => @profile_page.profile_img.present?,\n :profile_edit_button => @profile_page.profile_edit_button.present?,\n :profile_activity_item => @profile_page.profile_activity_item.present?,\n :topnav_home => @profile_page.topnav_home.present?,\n :topnav_topic => @profile_page.topnav_topic.present?,\n :topnav_product => @profile_page.topnav_product.present?,\n :topnav_about => @profile_page.topnav_about.present?,\n :topnav_search => @profile_page.topnav_search.present?,\n :topnav_logo => @profile_page.topnav_logo.present?,\n # :browser_title => (@browser.title == \"#{@c.users[user_for_test].name}'s Profile\"),\n })\n \n #TODO\n @profile_page.profile_avatar_img.when_present.hover\n @profile_page.profile_avatar_camera.when_present\n assert @profile_page.profile_avatar_camera.present?\n # comment below assert since it is invisible when no bio\n # assert @profile_page.profile_bioinfo_line.present? \n end", "def test_rename_page_name\n cache_page(TEST_PAGE_LINK)\n \n login_editor_integrated\n new_name = 'Renamed Page'\n new_name_link = 'renamed_page'\n content = 'This is a renamed page'\n \n post url_for(:controller => 'wiki', :action => 'save', :link => TEST_PAGE_LINK, :author => 'Test Author', :content => content, :page_name => new_name)\n assert_no_errors \n follow_redirect!\n assert_no_errors\n assert_page_cached(TEST_PAGE_LINK) \n assert_page_not_cached(new_name_link) \n end", "def test_login_friendly_url_forwarding\n user = { :screen_name => @valid_user.screen_name,\n :remember_me => \"0\",\n :password => @valid_user.password\n }\n friendly_url_forwarding_aux(:login, :profile, user)\n end", "def check_another_user(url, session:)\n session.visit(url)\n marys_draft = NameDescription.last\n assert(session.has_link?(href: name_description_path(marys_draft.id)))\n session.first(:link, href: name_description_path(marys_draft.id)).click\n assert_flash_error(session: session)\n end", "def assert_redirected_to_sam(options={})\n assert_response :redirect\n sam_url = signup_url(options)\n assert_equal(sam_url, redirect_to_url)\n end", "def test_login_logout_elsewhere\n @user.goto Sage::Test::Server.billingboss.url + '/caslogout' # ensure starting logged out even is single sign out isn't working\n $test_ui.agree('start. continue?', true) if @debug\n @user.goto Sage::Test::Server.billingboss.url\n $test_ui.agree('home page. continue?', true) if @debug\n\n assert_click_goto_bb_and_click_login(@user, @debug)\n\n assert_cas_login(@user, @debug)\n\n # @debug = true\n $test_ui.agree('clicked login on cas. continue?', true) if @debug\n\n #Note: existing user will see a successful login message\n assert_logged_in_on_bb(@user)\n\n # assert_match sbb_create_profile_url, @user.url(), \"Does not see create profile page after logging in without profile. Actual URL is \" + @user.url\n\n #Other users will see their created profile page.\n #assert_match sbb_users_url + \"/users/\" + @user.user.username, @user.url(), \"Does not see logged in page after logging in. Actual URL is \" + @user.url\n\n\n # @user.goto_sbb_my_profile_url\n #should be redirect to the login page\n\n assert_logout_elsewhere_logsout_bb(@user, @debug)\n end", "def test_redirect\n get :index\n assert_redirected_to :action => \"login\", :controller => \"main\"\n assert_not_equal \"\", flash[:login_notice]\n end", "def profile\n self.profilelink.click\n end", "def test_bounce_not_logged_in\n get :panel\n assert_redirected_to :controller => \"users\", :action => \"login\"\n end", "def test_redirection\n process :redirect_internal\n assert @response.redirect?\n\n process :redirect_external\n assert @response.redirect?\n\n process :nothing\n assert !@response.redirect?\n end", "def redirect_ok=(follow); end", "def test_should_index_redirect_to_list\n get :index\n assert_redirected_to :action=>'list'\n end", "def test_redirect_logged_in\n # log in\n admin = users(:olm_admin_1)\n post :login, :user_login => admin.user_name, :user_password => 'asfd'\n assert_redirected_to :action => \"index\"\n\n # try to go to login page when logged in\n get :login\n assert_redirected_to :action => \"index\"\n end", "def assert_redirected_to(page_name)\n assert_match(/#{Goldberg.settings.send(page_name).url}$/,\n response.redirected_to)\n end", "def test_p1_00010_aboutpage\n @aboutpage.goto_about_page\n \tassert @browser.body.present?\n assert @aboutpage.about_widget.present?\n @abouturl = @browser.url\n @aboutpage.newline\n end", "def atest_ID_25835_edit_profile_desc\n login_as_user1\n go_to_edit_profile_page\n verify_elements_on_edit_profile \"test_ID_25835_edit_profile_desc\"\n end", "def test_02_comment_on_post_as_guest\n end", "def click(link); end", "def test_send_invoice_flow_with_click_go_there_now_link\n api_token, current_url, token_url = initiate_send_invoice('signup', nil)\n session_successfully_create_user(api_token, current_url) do |user|\n user.edit_user_gateways!\n html = Hpricot(user.response.body)\n assert_not_nil html.at('#beanstream-go-there-now-link')\n assert '/beanstream_help.html', html.at('#beanstream-go-there-now-link')['href'] \n end\n end", "def verifySignupLoginLinks()\n\t\n\tputs \"************** START: Verify SignUp Login Links ****************\"\n\tputs \"Step 1 : Click on Sign Up Link at the Header.\"\n\t$browser.click \"link=Sign up\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Create an account on Razoo\")\n\t\tputs \"Step 1 is passed. User has reached the Sign Up screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1 is Failed. User had failed to reach the Sign Up screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 2 : Click on Login Link in the Sign up screen.\"\n\t$browser.click \"link=Log In\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Log in\")\n\t\tputs \"Step 2 is passed. User has reached the Login screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 is Failed. User had failed to reach the Login screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 3 : Click on Forgot Password Link in the Login screen.\"\n\t$browser.click \"link=exact:Forgot login details?\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Reset Your Password\")\n\t\tputs \"Step 3 is passed. User has reached the Reset Your Password screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 is Failed. User had failed to reach the Reset Your Password screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"************** END: Verify SignUp Login Links ****************\"\nend", "def verifySignupLoginLinks()\n\t\n\tputs \"************** START: Verify SignUp Login Links ****************\"\n\tputs \"Step 1 : Click on Sign Up Link at the Header.\"\n\t$browser.click \"link=Sign up\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Create an account on Razoo\")\n\t\tputs \"Step 1 is passed. User has reached the Sign Up screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1 is Failed. User had failed to reach the Sign Up screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 2 : Click on Login Link in the Sign up screen.\"\n\t$browser.click \"link=Log In\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Log in\")\n\t\tputs \"Step 2 is passed. User has reached the Login screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 is Failed. User had failed to reach the Login screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 3 : Click on Forgot Password Link in the Login screen.\"\n\t$browser.click \"link=exact:Forgot login details?\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Reset Your Password\")\n\t\tputs \"Step 3 is passed. User has reached the Reset Your Password screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 is Failed. User had failed to reach the Reset Your Password screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"************** END: Verify SignUp Login Links ****************\"\nend", "def verifySignupLoginLinks()\n\t\n\tputs \"************** START: Verify SignUp Login Links ****************\"\n\tputs \"Step 1 : Click on Sign Up Link at the Header.\"\n\t$browser.click \"link=Sign up\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Create an account on Razoo\")\n\t\tputs \"Step 1 is passed. User has reached the Sign Up screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 1 is Failed. User had failed to reach the Sign Up screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 2 : Click on Login Link in the Sign up screen.\"\n\t$browser.click \"link=Log in\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Log in\")\n\t\tputs \"Step 2 is passed. User has reached the Login screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 2 is Failed. User had failed to reach the Login screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"Step 3 : Click on Forgot Password Link in the Login screen.\"\n\t$browser.click \"link=exact:Forgot login details?\"\n\t$browser.wait_for_page_to_load \n\tbegin\n\t\tassert $browser.is_text_present(\"Reset Your Password\")\n\t\tputs \"Step 3 is passed. User has reached the Reset Your Password screen successfully.\"\n\trescue Test::Unit::AssertionFailedError\n\t\tputs \"Step 3 is Failed. User had failed to reach the Reset Your Password screen.\"\n\t\t$verification_errors << $!\n\tend\n\t\n\tputs \"************** END: Verify SignUp Login Links ****************\"\nend" ]
[ "0.68827313", "0.68318945", "0.6793401", "0.6793401", "0.6739242", "0.67050105", "0.6621171", "0.6621171", "0.66067725", "0.6565344", "0.6562046", "0.6546416", "0.64884603", "0.6480746", "0.6463968", "0.6463968", "0.6454605", "0.6429782", "0.6425806", "0.6416103", "0.64132535", "0.640767", "0.6370311", "0.63658416", "0.63642246", "0.62852335", "0.6268083", "0.62491286", "0.62265974", "0.62218636", "0.62204355", "0.61849684", "0.6163814", "0.61615545", "0.61453146", "0.61453146", "0.61407775", "0.6120409", "0.6119961", "0.61100304", "0.6091912", "0.606757", "0.6045468", "0.60452026", "0.60396856", "0.6039227", "0.6039227", "0.6037819", "0.6037819", "0.60306513", "0.6021435", "0.60161364", "0.6003932", "0.59800947", "0.597922", "0.59636414", "0.59589654", "0.5957513", "0.5952454", "0.59406346", "0.59331596", "0.5925737", "0.59169286", "0.5912316", "0.5906807", "0.5903995", "0.59039253", "0.590386", "0.58995986", "0.58992606", "0.5897016", "0.5873889", "0.5873889", "0.5872861", "0.5872861", "0.58691406", "0.5856711", "0.5854611", "0.5848073", "0.5843733", "0.58291507", "0.5815658", "0.58116055", "0.5808663", "0.58078676", "0.5790862", "0.5782065", "0.5780495", "0.57762223", "0.5774194", "0.5763741", "0.5761117", "0.57564366", "0.5756413", "0.57524586", "0.57497925", "0.5736355", "0.5735988", "0.5735988", "0.5733044" ]
0.65168864
12
Converts the string to a boolean "true".to_bool => true "false".to_bool => false
def to_bool return false if self.downcase == "false" return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_bool(str)\n str = str.to_s.downcase\n return true if str == 'yes' or str == 'true' or str == 'on'\n return true if str.to_i > 0\n return false\n end", "def to_boolean(string)\n string == 'true'\nend", "def to_boolean(str)\n str == 'true'\nend", "def to_bool(questionable_string)\n\tbool = true\n\tunless questionable_string == \"true\"\n\t\tbool = false\n\tend\n\tbool\nend", "def bool_from_str(s)\n raise exc unless valid_bool_str?(s)\n case s\n when *FALSE_STRS\n false\n else\n true\n end\n end", "def str_to_bool(str)\n if str.size > 0 and str[0].chr == '!'\n command = str[1, str.length]\n value = `#{command}`\n else\n value = str\n end\n\n case value.downcase.strip\n when \"false\", \"0\", \"nil\", \"\", \"no\", \"off\"\n nil\n when \"true\", \"1\", \"yes\", \"on\"\n true\n when /\\n/\n value.strip.split(/\\n+/)\n else\n value\n end\n end", "def str_to_bool(str)\n if str.size > 0 and str[0].chr == '!'\n command = str[1, str.length]\n value = `#{command}`\n else\n value = str\n end\n\n case value.downcase.strip\n when \"false\", \"0\", \"nil\", \"\", \"no\", \"off\"\n nil\n when \"true\", \"1\", \"yes\", \"on\"\n true\n else\n value\n end\n end", "def string_to_boolean(string)\n case string\n when /^(true|t|yes|y|1)$/i then true\n when /^(false|f|no|n|0)$/i then false\n else raise \"Cannot convert string to boolean: #{string}\"\n end\nend", "def to_boolean(str)\n !(str == 'false' || str == '0')\nend", "def to_bool\n return true if ['true', '1', 'yes', 'on', 't'].include? self\n return false if ['false', '0', 'no', 'off', 'f'].include? self\n return false\n end", "def to_bool\n dc = to_s.downcase\n\n if TRUE_WORDS.include?(dc)\n true\n elsif FALSE_WORDS.include?(dc)\n false\n end\n end", "def to_bool str\r\n ActiveRecord::Type::Boolean.new.type_cast_from_user(str)\r\n end", "def to_bool(value)\n value.to_s.downcase == 'true' ? true : false\n end", "def convert_string_to_bool(value)\n case value\n when \"true\"\n true\n when \"false\"\n false\n when Array\n value.map { |elem| convert_string_to_bool(elem) }\n when Hash\n value.each do |key, elem|\n value[key] = convert_string_to_bool(elem)\n end\n value\n else\n value\n end\n end", "def to_boolean\r\n\t !!(self.to_s =~ /^(true|t|yes|y|1)$/i)\r\n\tend", "def convert_str_to_boolean(str)\n str == \"y\" ? true : false\nend", "def to_boolean(val)\n val && (val.to_s.match(/(true|t|yes|y|1)$/i) != nil)\n end", "def convert_to_boolean(val)\n return val if val.is_a?(TrueClass) || val.is_a?(FalseClass)\n val = val.to_s.clean\n return nil if val.blank?\n if val.match?(/\\A(false|f|n|no)\\z/i)\n false\n elsif val.match?(/\\A(true|t|y|yes)\\z/i)\n true\n end\n end", "def to_boolean\n # SECURE: BNS 2012-10-09: But may behave oddly for multi-line input\n return true if self == true || self =~ (/^(true|t|yes|y|1)$/i)\n return false if self == false || self.nil? || self =~ (/^(false|f|no|n|0)$/i)\n fail ArgumentError, \"invalid value for Boolean: \\\"#{self}\\\"\"\n end", "def value_is_boolean?(string)\n return %w[true false yes no y n].include?(string.downcase)\n end", "def parse_boolean_value(value)\n value.to_s.downcase == 'true'\n end", "def to_boolean(value)\n [\"true\", \"1\", \"yes\"].include?(value.to_s) ? true : false\n end", "def string_to_bool(value)\n return false if value.nil? || value.casecmp('no').zero?\n return true if value.casecmp('yes').zero?\n value # if it doesn't match anything\n end", "def to_boolean(value)\n [\"true\", \"1\", \"yes\"].include?(value.to_s) ? true : false\n end", "def to_boolean(string)\r\n if string.downcase == 'y'\r\n string = true\r\n elsif string.downcase == 'n'\r\n string = false\r\n end\r\nend", "def to_boolean(value)\n case value\n when :true, 'true'\n true\n else\n false\n end\n end", "def convert_to_boolean(input)\n case input\n when false, 0, '0', 'false', 'no', nil then false\n else\n true\n end\n end", "def to_bool(value)\n ActiveModel::Type::Boolean.new.cast(value.to_s.strip)\n end", "def coerce_str_to_bool(*keys)\n coerce(*keys){ |str_bool| (str_bool == 'on' || str_bool == 'true')}\n end", "def parse_bool() true end", "def to_boolean\n if ['true', 'True', 'TRUE', '1'].include?(self)\n return true\n else\n return false\n end\n end", "def to_bool\n is_a?(::TrueClass) || self == :true || self == :yes || self == :on\n end", "def parse_boolean(string)\n case string.strip\n when \"Yes\"\n true\n when \"No\"\n false\n end\nend", "def convert_to_boolean(value)\n if value == \"yes\"\n true\n else\n false\n end\nend", "def value_to_boolean(value)\n return value if value==true || value==false\n case value.to_s.downcase\n when \"true\", \"t\", \"1\" then true\n else false\n end\n end", "def test_string_should_convert_into_boolean\n ['true', 'True', 'TRUE', '1'].each do |x|\n assert x.to_boolean\n end\n assert !\"false\".to_boolean \n end", "def to_bool(strict = true)\n return false if blank? || self =~ /(false|f|no|n|0)$/i\n\n if strict\n return true if self =~ /(true|t|yes|y|1)$/i\n raise ArgumentError, \"invalid value for Boolean: \\\"#{self}\\\"\"\n else\n return true\n end\n end", "def boolean(value)\n value.strip =~ /^(y|t)$/i ? true : false\n end", "def true_string?(field)\n field == 'true' || field == true\n end", "def to_bool\n str = if @target.respond_to?(:empty?)\n @target\n else\n @target.to_s\n end\n return @target != 0 if @target.is_a? Numeric\n return true if @target == true || str =~ /(true|t|yes|y)$/i\n bm = BlankMatcher.new(@target)\n return false if @target == false || bm.blank? || str =~ /(false|f|no|n)$/i\n raise(ArgumentError, \"invalid value for Boolean: \\\"#{@target}\\\"\")\n end", "def normalize(boolean_str)\n\t\t\tTrue.include?(boolean_str) ? (:true) : (:false)\n\t\tend", "def to_bool\n %w(true t yes y on 1).include?(self.downcase)\n end", "def parse_bool() false end", "def parse_bool() false end", "def convert(value)\n case value.to_s\n when /^(yes|y|t(rue)?|1)$/i\n return true\n when /^(no|n|f(alse)?|0)$/i\n return false\n else\n fail TypeError, \"Expected boolean type, got #{value}\"\n end\n end", "def boolean\n Util.from_bytes :boolean, value\n end", "def convert_to_boolean(variable)\n\tif variable == \"y\"\n\t\tvariable = TRUE\n\telsif variable == \"n\"\n\t\tvariable = FALSE\n\tend\nend", "def bool?(b)\n not ['true', 'false'].index(b.to_s).nil?\n end", "def parse_bool(bool_param)\n bool_param.try(:to_bool) || (bool_param.try(:to_i) == 1)\n end", "def truthy?(string)\n string.to_s.casecmp('true').zero?\nend", "def truthy?(string)\n string.to_s.casecmp('true').zero?\nend", "def coerce_boolean(value, options = {})\n return if options[:allow_nil] && (value.nil? || value == \"\")\n return false if value.to_s.strip == \"false\"\n !!value && !coerce_string(value, :allow_nil => false).strip.empty?\n end", "def convert_booleans(value)\n if [\"true\", \"false\"].include?(value)\n value = (value == \"true\")\n else\n value\n end\n end", "def to_bool(value, default = false)\n return default if value.nil?\n return value if value.is_a?(TrueClass) || value.is_a?(FalseClass)\n !!(value =~ /^(true|t|yes|y|1)$/i)\n end", "def _boolinze(val)\n return true if ['true', '1'].include?(val)\n return false if ['false', '0'].include?(val)\n val\n end", "def parse_to_true_false_string(only_yes = false)\n raise MissingValueError.new(var: var) if vals.empty?\n raise TooManyValuesError.new(var: var) if vals.length > 1\n val = vals.first\n return \"TRUE\" if /^(1|yes|true)$/i.match?(val)\n return \"FALSE\" if /^(0|no|false)$/i.match?(val) && !only_yes\n raise BadYesError.new(var: var, val: val) if only_yes\n raise BadBooleanError.new(var: var, val: val)\n end", "def to_booly\n unless self.to_booly?\n raise TypeError.new(\"#{self} cannot be converted to TrueClass or FalseClass\")\n end\n\n return true if self == \"true\" || (self.to_f? && self.to_f > 0)\n false\n end", "def parse_to_true_false_string(only_yes = false)\n raise MissingValueError.new(var: var) if vals.empty?\n raise TooManyValuesError.new(var: var) if vals.length > 1\n\n val = vals.first\n return \"TRUE\" if /^(1|yes|true)$/i.match?(val)\n return \"FALSE\" if /^(0|no|false)$/i.match?(val) && !only_yes\n raise BadYesError.new(var: var, val: val) if only_yes\n\n raise BadBooleanError.new(var: var, val: val)\n end", "def bool_conv(value)\n value == HEX_FALSE ? false : true\n end", "def truthy?(str)\n return true if str == true || str =~ (/^(true|t|yes|y|1)$/i)\n return false if str == false || str.blank? || str =~ (/^(false|f|no|n|0)$/i)\n end", "def to_boolean(default = nil)\n return true if ['true', '1', 'yes', 'on', 't'].include? self\n return false if ['false', '0', 'no', 'off', 'f'].include? self\n return default\n end", "def result\n val = value.sub(/^boolean-/, '')\n val.casecmp(\"true\").zero?\n end", "def boolean_to_string(b)\n if b \n \"true\"\n else\n \"false\"\n end\nend", "def bool(val)\n case val.to_s.downcase\n when 'y', 'yes', 'on', 't', 'true'\n true\n when 'n', 'no', 'off', 'f', 'false'\n false\n else\n nil\n end\nend", "def cast_to_boolean(input)\n ActiveRecord::Type::Boolean.new.type_cast_from_user(input)\n end", "def truthy?\n case strip.downcase\n when \"1\", \"true\", \"yes\", \"on\", \"enabled\", \"affirmative\"\n true\n else\n false\n end\n end", "def true?(obj)\n obj.to_s.downcase == \"true\"\n end", "def boolean?\n proc do |o|\n o.is_a? String and o.is_b?\n end\n end", "def bool_to_word bool\n if bool == \"true\"\n \"Yes\"\n else\n \"No\"\n end\nend", "def bool_to_string(value)\n return 'yes' if value == true\n return 'no' if value == false\n value # if it doesn't match anything\n end", "def booleanish_to_boolean(arguments, ddl)\n arguments.keys.each do |key|\n if ddl[:input].keys.include?(key)\n if ddl[:input][key][:type] == :boolean\n arguments[key] = true if arguments[key] == \"true\"\n arguments[key] = true if arguments[key] == \"yes\"\n arguments[key] = true if arguments[key] == \"1\"\n arguments[key] = false if arguments[key] == \"false\"\n arguments[key] = false if arguments[key] == \"no\"\n arguments[key] = false if arguments[key] == \"0\"\n end\n end\n end\n rescue\n true\n end", "def is_bool input\n !!input == input\nend", "def to_boo string\n\t\tActiveRecord::Type::Boolean.new.cast(string)\n\tend", "def value_to_boolean(value)\n if value.is_a?(String) && value.empty?\n nil\n else\n TRUE_VALUES.include?(value)\n end\n end", "def value_to_boolean(value)\n if value.is_a?(String) && value.blank?\n nil\n else\n TRUE_VALUES.include?(value)\n end\n end", "def valid_bool_str?(str)\n BOOL_STRS.include?(str)\n end", "def convert_to_boolean(value)\n value != 'no'\n end", "def is_bool(value) #method\n if value == 'verdadero' || value == 'falso'\n true\n else\n false\n end\n end", "def object_to_boolean(value)\n return [true, 'true', 1, '1', 'T', 't'].include?(value.class == String ? value.downcase : value)\n end", "def to_bool() true end", "def boolString(value)\n if value == \"0\"\n return \"false\"\n else\n return \"true\"\n end\n end", "def boolean_to_string(b)\n if true\n \"true\"\n else\n \"false\"\n end\nend", "def to_cli_boolean(value)\n case value\n when true\n :true\n else\n :false\n end\n end", "def convert_boolean_strings\n %i{ambiguous_ref_bases use_all_contigs include_low_hmes polyploidy}.each do | symbol |\n if @options.key?(symbol)\n @options[symbol] = @options[symbol] == 'false' ? false : true\n end\n end\n end", "def boolean_to_string(b)\n return b.to_s\nend", "def to_b\n return true if self =~ BOOLEAN_REGEX\n false\n end", "def to_bool\n true\n end", "def parse_enabled_bool\n bool_string = @params[:enabled]\n return true if bool_string == true || bool_string =~ /(true|t|yes|y|1|True)$/i\n return false if bool_string == false ||\n bool_string.blank? ||\n bool_string =~ /(false|f|no|n|0|False)$/i\n end", "def test_boolean_parses_true_string\n bc, ctx = compile 'true'\n ci = mkci bc, ctx\n assert ci.run\n end", "def coerce_bool(value)\n case value\n when nil, false then false\n when Numeric then !value.zero?\n else\n true\n end\n end", "def to_bool\n true\n end", "def is_true?\n [true, \"true\", 1, \"1\", \"T\", \"t\"].include?(\n self.value.class == String ? self.value.downcase : self.value\n )\n end", "def bool_to_sym(bool)\n bool == true ? :true : :false\n end", "def bool_to_sym(bool)\n bool == true ? :true : :false\n end", "def read_bool\n read_word == \"true\"\n end", "def boolean?\n !to_bool.nil?\n end", "def to_boolean\n inner_html == 'true'\n end", "def config_boolean_true?(boolean_field)\n data[boolean_field].to_i == 1\n end", "def to_bool\n if (self.to_bool == 1)\n puts \"TRUE\"\n elsif (self.to_bool == 0)\n puts \"FALSE\"\n elsif (self.to_bool == -1)\n puts \"NaN\"\n end\nend", "def true?(obj)\n [\"true\",\"1\"].include? obj.to_s.downcase\n end" ]
[ "0.86649567", "0.8543993", "0.85295564", "0.82630265", "0.8242424", "0.81943107", "0.81917495", "0.8149654", "0.8077559", "0.80358285", "0.79957235", "0.79891443", "0.7987769", "0.7974454", "0.7953322", "0.790496", "0.7868229", "0.78168315", "0.7782671", "0.77438676", "0.7672776", "0.7662353", "0.76557744", "0.76401293", "0.7609284", "0.7588303", "0.7552406", "0.74175704", "0.74043715", "0.73253274", "0.7314096", "0.7278896", "0.72489595", "0.7247486", "0.7226453", "0.7216871", "0.7204152", "0.71631515", "0.7149777", "0.71398187", "0.7106866", "0.7052935", "0.70528173", "0.70528173", "0.70383406", "0.7029947", "0.7028023", "0.7019908", "0.7014944", "0.7005145", "0.7005145", "0.700286", "0.6998883", "0.6998268", "0.6995733", "0.6991963", "0.6985743", "0.6966208", "0.694818", "0.6941156", "0.6940097", "0.6906119", "0.69043493", "0.6898767", "0.6855685", "0.6847998", "0.6812435", "0.67717934", "0.6767873", "0.67496073", "0.6742973", "0.67387646", "0.67185944", "0.67173177", "0.66701216", "0.66398615", "0.66219383", "0.6602667", "0.6601331", "0.6595607", "0.6591361", "0.6571669", "0.65630203", "0.6558983", "0.65518385", "0.65505624", "0.65264004", "0.6516084", "0.6512981", "0.6506669", "0.64914274", "0.64538425", "0.64527273", "0.64527273", "0.6452017", "0.6443587", "0.64412355", "0.6438905", "0.6415543", "0.6411564" ]
0.788407
16
Applies all configuration settings. This is done by the Auth system after it has been configured but before it processes any requests.
def configure! begin configuration.apply! rescue NameError puts puts "WARNING: #{$!.message}" puts puts "This happened while trying to configure Sparkly Authentication." puts "You should verify that /config/initializers/sparkly_authentication.rb" puts "is set up properly. It could be that you just haven't created the" puts "model yet. If so, this error will disappear when the model exists." puts if ENV['AUTH_BACKTRACE'] puts $!.backtrace else puts "(Run with AUTH_BACKTRACE=true to see a full bactrace.)" end puts end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def config_setup\n [\n Project,\n Affiliate,\n Employee,\n EmployeeSession,\n Ldaper,\n User,\n UserSession,\n Company,\n Admin\n ].each do |model|\n unless model.respond_to?(:original_acts_as_authentic_config)\n model.class_attribute :original_acts_as_authentic_config\n end\n model.original_acts_as_authentic_config = model.acts_as_authentic_config\n end\n end", "def reset_configuration!\n @configuration = Auth::Configuration.new\n end", "def initialize_auth\n @conf[:use_user_pool_cache] = false\n end", "def setup()\n @configuration = {}\n @configuration.merge!(defaults)\n @configuration\n end", "def configure\n load_configuration\n verify_configuration\n end", "def configure\n super()\n syncer_klass.configure(settings) if syncer_klass\n end", "def configure\n load_all_configs \n end", "def apply(config)\n config.debug = debug?\n config.fde = fde? if config.fde?\n config.homedir = homedir if homedir\n config.logfile = logfile if logfile\n config.login = login if login\n config.token = token if token\n config.pretend = pretend?\n config.profile = profile?\n config.future_parser = future_parser?\n config.report = report?\n config.graph = graph?\n config.srcdir = srcdir if srcdir\n config.stealth = stealth?\n config.user = user if user\n config.color = color?\n\n config\n end", "def configure\n end", "def setup\n # this method gets called before *each* omniauth endpoint call, so try to avoid logging when we're returning from\n # oauth'ing\n unless stored_register_redirect\n reg_redirect = params[:r]\n reg_redirect ||= request.referer if params[:ot] && (params[:ot] == \"far\") # facebook auth referral\n store_register_redirect(reg_redirect)\n end\n\n unless stored_auth_redirect\n auth_redirect = params[:r]\n auth_redirect ||= root_path if params[:state] && (params[:state] == 'w')\n store_auth_redirect(auth_redirect)\n end\n\n remember_remember_me\n remember_signup_flow_scope\n remember_signup_flow_type\n remember_signup_flow_origin_type\n remember_signup_flow_destination\n remember_signup_flow_network\n render :text => \"Setup complete.\", :status => 404\n end", "def apply_config_settings\n with_setting(:purgedirs) do |purgedirs|\n logger.warn(\"The purgedirs key in r10k.yaml is deprecated. It is currently ignored.\")\n end\n\n with_setting(:cachedir) do |cachedir|\n R10K::Git::Cache.settings[:cache_root] = cachedir\n end\n\n with_setting(:forge) do |forge_settings|\n R10K::Util::SymbolizeKeys.symbolize_keys!(forge_settings)\n proxy = forge_settings[:proxy]\n if proxy\n R10K::Forge::ModuleRelease.settings[:proxy] = proxy\n end\n\n baseurl = forge_settings[:baseurl]\n if baseurl\n R10K::Forge::ModuleRelease.settings[:baseurl] = baseurl\n end\n end\n\n with_setting(:git) do |git_settings|\n R10K::Util::SymbolizeKeys.symbolize_keys!(git_settings)\n provider = git_settings[:provider]\n if provider\n R10K::Git.provider = provider.to_sym\n end\n\n if git_settings[:private_key]\n R10K::Git.settings[:private_key] = git_settings[:private_key]\n end\n\n if git_settings[:username]\n R10K::Git.settings[:username] = git_settings[:username]\n end\n end\n end", "def bootstrap\n\n if (self.csrf_token.nil?)\n csrf!\n end\n\n #\n # First need developer token\n #\n if (self.developer_token.nil?)\n config!\n end\n\n #\n # Need to login too\n #\n if (self.access_token.nil?)\n login!\n end\n end", "def load_configuration\n if self.config_file && File.exists?(self.config_file)\n configure_with_config_file\n else\n self.config_by = :environment\n super\n end\n\n # respect autorun and log_level env vars regardless of config method\n self.autorun = detect_autorun\n self.log_level = :info if log_level.blank?\n self.log_level = ENV['LIBRATO_LOG_LEVEL'] if ENV['LIBRATO_LOG_LEVEL']\n end", "def set_config\n @me = current_user\n @profile = Profile.find_by user_id: current_user.id\n @preference = Preference.find_by user_id: current_user.id\n end", "def configure\n yield settings\n end", "def auth_process\n\t\tif @auth_file.authorization.nil?\n \t\t\tmake_auth\n\t\telse\n\t\t\t@client.authorization = @auth_file.authorization\n\t\tend\n\tend", "def auth_settings\n {\n }\n end", "def auth_settings\n {\n }\n end", "def auth_settings\n {\n }\n end", "def setup(settings = {})\n @config = defaults.merge(settings)\n end", "def configure\n # Consumer details come from registering an app at https://dev.twitter.com/\n # Once you have consumer details, use \"ebooks auth\" for new access tokens\n self.consumer_key = 't9g6TgrUYsZ4R5aeArsM2C36G' # Your app consumer key\n self.consumer_secret = 'olto6fNhfZz0CZwtx4uaFFpoyW88KG4LZnuaMFtWkvhgWq3897' # Your app consumer secret\n\n # Users to block instead of interacting with\n self.blacklist = ['']\n\n # Range in seconds to randomize delay when bot.delay is called\n self.delay_range = 1..6\n\t\n\t@userinfo = {}\n end", "def configure\n # do nothing\n end", "def post_configure\n # noop\n end", "def setup_all\n setup_all_options\n save_validate_user { setup_successfull }\n end", "def configure\n yield settings\n end", "def reconfigure(overrides={})\n config.merge!(overrides)\n self\n end", "def default_configuration!\n # Overwriting Sinatra defaults\n set :app_file, caller_files.first || $0 # Assume app file is first caller\n set :environment, Padrino.env\n set :raise_errors, true if development?\n set :logging, false # !test?\n set :sessions, true\n set :public, Proc.new { Padrino.root('public', self.uri_root) }\n # Padrino specific\n set :uri_root, \"/\"\n set :reload, development?\n set :app_name, self.to_s.underscore.to_sym\n set :default_builder, 'StandardFormBuilder'\n set :flash, defined?(Rack::Flash)\n set :authentication, false\n # Padrino locale\n set :locale_path, Proc.new { Dir[File.join(self.root, \"/locale/**/*.{rb,yml}\")] }\n set :auto_locale, false\n # Plugin specific\n set :padrino_mailer, defined?(Padrino::Mailer)\n set :padrino_helpers, defined?(Padrino::Helpers)\n end", "def save\r\n SystemConfig.set :auth, to_h, true\r\n end", "def apply_overrides\n\t\tself.synchronize do\n\t\t\traise LocalJumpError, \"can't be called re-entrantly\" if self.overridden_settings\n\t\t\tself.overridden_settings = self.gather_current_settings\n\t\tend\n\n\t\tself.log_hosts_to_affect.each do |host|\n\t\t\thost.logger.restore_settings( self.settings )\n\t\tend\n\tend", "def configure\n # Users to block instead of interacting with\n self.blacklist = ['mcamargo1997']\n\n # Range in seconds to randomize delay when bot.delay is called\n self.delay_range = 1..6\n\n @userinfo = {}\n @botinfo = {\n ENV[\"BOT_NAME_1\"] => BotInfo.new(ENV[\"BOT_NAME_1\"]),\n ENV[\"BOT_NAME_2\"] => BotInfo.new(ENV[\"BOT_NAME_2\"])\n }\n end", "def start_configuration\n post \"/setup/api/configure\", password_hash\n end", "def prepare_for_configuration \n # clear_base_directory\n make_base_directory\n copy_misc_templates\n copy_custom_monitors\n store_keys_in_file\n Script.save!(self)\n # not my favorite...\n copy_ssh_key\n before_configuration_tasks\n end", "def configure\n self.configuration ||= AllscriptsApi::Configuration.new\n yield(configuration)\n end", "def apply_overrides\n\t\tself.synchronize do\n\t\t\traise LocalJumpError, \"can't be called re-entrantly\" unless\n\t\t\t\t@overridden_settings.empty?\n\t\t\t@overridden_settings = self.gather_current_settings\n\t\tend\n\n\t\tLoggability.log_hosts.each do |key, host|\n\t\t\thost.logger.restore_settings( self.settings )\n\t\tend\n\tend", "def setup(config={})\n if block_given?\n yield(self.config.dup)\n end\n # merge new settings\n self.configure(config)\n end", "def apply_owncloud_configuration\n calculate_trusted_domains\n calculate_dbhost\n owncloud_config_update\n save_owncloud_node_configuration\n end", "def configure\n self.configuration ||= Configuration.new\n\n yield(configuration) if block_given?\n \n configuration.validate!\n\n setup if configuration.enabled?\n end", "def configure(credentials)\n credentials.each { |key, val| self.send(\"#{key}=\", val) }\n self\n end", "def reconfig\n KEYS_AND_QUESTIONS.each do |key, question|\n ask_question_and_force_update_config(question, key)\n end\n config_update_success\n end", "def configure\n yield(configuration) if block_given?\n\n self.logger = configuration.logger\n\n # remove :// from scheme\n configuration.scheme.sub!(/:\\/\\//, '')\n\n # remove http(s):// and anything after a slash\n configuration.host.sub!(/https?:\\/\\//, '')\n\n # Add leading and trailing slashes to base_path\n configuration.base_path = \"\" if configuration.base_path == \"/\"\n end", "def configure(config={})\n config.each do |(key, val)|\n self.config[key] = val\n end\n end", "def prepare\n reset\n\n yield self if block_given?\n\n # Since the OAuth flow is performed by the browser, we'll need to boot\n # the Sinatra app instead of just stubbing the app with WebMock...\n boot_once\n\n OmniAuth::Strategies::Icalia.instances.each do |strategy|\n strategy.options.client_options.tap do |options|\n options.site = url\n options.token_url = \"#{url}/oauth/token\"\n options.authorize_url = \"#{url}/oauth/authorize\"\n end\n end\n end", "def apply_config(config)\n if !config.is_a?(Array)\n config = [config]\n end\n config.each do |entry|\n pub = PubControlClient.new(entry['uri'])\n if entry.key?('iss')\n pub.set_auth_jwt({'iss' => entry['iss']}, entry['key'])\n end\n @clients.push(pub)\n end\n end", "def settings\n\t\tcheck_if_myself\n\t\t@user = current_user\n\tend", "def configure; end", "def configure(root_config)\n super(root_config)\n end", "def initialize( custom_config = {} )\n config = config_file.merge custom_config\n config = symbolize_keys config\n\n config[:username] = config[:api_key] if config[:api_key]\n config[:headers] ||= {}\n config[:request] ||= {}\n config[:response] ||= {}\n\n config[:headers][:accept] ||= \"application/hal+json\"\n\n # Copy the config into this Configuration instance.\n config.each { |k, v| self[k] = v }\n\n super()\n\n configure_user_agent\n configure_cache\n\n validate\n end", "def apply_cap_config(config_binding)\n roles.each do |role, user|\n config_binding.eval(\"role #{role.inspect}, #{user.inspect}\")\n end\n variables.each do |name, val|\n config_binding.eval(\"set #{name.inspect}, #{val.inspect}\")\n end\n end", "def configure opts\n configuration.merge!(opts)\n end", "def reset_to_defaults!\n @allowlist_regexp = nil\n @custom_http_auth_scheme = UnsetString.new(\"custom_http_auth_scheme\")\n @env_var_to_hold_api_client_primary_key = NonNullString.new(\"env_var_to_hold_api_client_primary_key\",\"STITCHES_API_CLIENT_ID\")\n @env_var_to_hold_api_client= NonNullString.new(\"env_var_to_hold_api_client\",\"STITCHES_API_CLIENT\")\n @max_cache_ttl = NonNullInteger.new(\"max_cache_ttl\", 0)\n @max_cache_size = NonNullInteger.new(\"max_cache_size\", 0)\n @disabled_key_leniency_in_seconds = ActiveSupport::Duration.days(3)\n @disabled_key_leniency_error_log_threshold_in_seconds = ActiveSupport::Duration.days(2)\n end", "def configure( config )\n\t\tself.log.notice \"Configuring a dispatcher for '%s' from '%s': child server %d\" %\n\t\t\t[ Apache.request.server.hostname, config.name, Process.pid ]\n\n # Configure any modules that have mixed in Configurability\n\t\tif defined?( Apache )\n\t\t\trequire 'apache/logger'\n\t\t\tConfigurability.logger = Logger.new( Apache::LogDevice.new )\n\t\t\tConfigurability.logger.formatter = Apache::LogFormatter.new\n\t\telse\n\t\t\tConfigurability.reset_logger\n\t\tend\n\n \tConfigurability.configure_objects( config )\n\tend", "def apply_filter_config\r\n exec(\r\n 'require_once(\"shaper.inc\");',\r\n 'require_once(\"filter.inc\");',\r\n 'filter_configure_sync();'\r\n )\r\n end", "def update_all_config\n @admin.updateConfiguration\n end", "def sync_configuration\n end", "def reset_config\n configure do |config|\n config.provider = :payu\n\n # payu configuration\n config.pos_id = 999\n config.pos_auth_key = 'pos_auth_key'\n config.key1 = 'key1'\n config.key2 = 'key2'\n\n config.test_mode = false\n end\n end", "def setup\n yield(application_config)\n end", "def set_config\n redirect\n end", "def configure(conf)\n super\n end", "def configure(root_config)\n super(root_config)\n end", "def configure\n\t\t\tyield configuration\n\t\tend", "def configure\n reset unless @configured\n yield self\n @configured = true\n self\n end", "def init_settings\n merge_in_user_settings(copy_hash(DEFAULT_SETTINGS))\n end", "def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend", "def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend", "def apply_cap_config(config_binding)\n roles.each do |role, user|\n config_binding.eval(\"role #{role.inspect}, #{user.inspect}\")\n end\n variables.each do |name, val|\n config_binding.eval(\"set #{name.inspect}, #{val.inspect}\")\n end\n end", "def process_keys\n if (!config.keys.nil? && !config.keys.empty?)\n config.keys = [config.keys].flatten.compact.collect do |key|\n process_key(key)\n end\n end\n\n if (!config.proxy_keys.nil? && !config.proxy_keys.empty?)\n config.proxy_keys = [config.proxy_keys].flatten.compact.collect do |proxy_key|\n process_key(proxy_key)\n end\n end\n end", "def handle_request( request, &block )\n\t\tself.log.debug \"[:auth] Wrapping request in auth with a %p\" % [ self.auth_provider ]\n\n\t\trequest.auth_provider = self.auth_provider\n\t\tself.authenticate_and_authorize( request )\n\n\t\tsuper\n\tend", "def setup_attributes\n setup_location_header\n # TODO: Should setup_content_length_header?\n setup_status_and_body\n end", "def setup\n yield(configuration)\n end", "def configure(settings = {})\n defaults.merge(settings).each do |key, value|\n set key, value\n end\n end", "def auth_settings\n {\n 'basicAuth' =>\n {\n type: 'basic',\n in: 'header',\n key: 'Authorization',\n value: basic_auth_token\n },\n 'bearerAuth' =>\n {\n type: 'bearer',\n in: 'header',\n key: 'Authorization',\n value: \"Bearer #{access_token}\"\n },\n }\n end", "def apply_default_config\n return unless DEFAULT_CONFIG.is_a?(Hash)\n DEFAULT_CONFIG.each do |k, v|\n apply_config(k, v)\n end\n end", "def configure(c)\n c.merge!(@passed_config)\n end", "def preinitialize_on_first_load(input_document, form_names)\n remedy_context = ArsModels::Context.new(\n :server => get_info_value(input_document, 'server'),\n :username => get_info_value(input_document, 'username'),\n :password => get_info_value(input_document, 'password'),\n :port => get_info_value(input_document, 'port'),\n :prognum => get_info_value(input_document, 'prognum'),\n :authentication => get_info_value(input_document, 'authentication')\n )\n\n # Build up a new configuration\n if @disable_caching\n @config = {\n #:properties => properties,\n :context => remedy_context,\n :forms => form_names.inject({}) do |hash, form_name|\n hash.merge!(form_name => ArsModels::Form.find(form_name, :context => remedy_context))\n end\n }\n else\n @@config = {\n #:properties => properties,\n :context => remedy_context,\n :forms => form_names.inject({}) do |hash, form_name|\n hash.merge!(form_name => ArsModels::Form.find(form_name, :context => remedy_context))\n end\n }\n end\n end", "def configure(c)\n # passed config\n c.merge!(@passed_config)\n end", "def configure\n yield self\n end", "def configure\n yield self\n\n self\n end", "def preconfigure\n yield(configuration.configured_options)\n end", "def configure\n yield(self)\n end", "def set_encryption_attributes\n @sorcery_config.encryption_provider.stretches = @sorcery_config.stretches if @sorcery_config.encryption_provider.respond_to?(:stretches) && @sorcery_config.stretches\n @sorcery_config.encryption_provider.join_token = @sorcery_config.salt_join_token if @sorcery_config.encryption_provider.respond_to?(:join_token) && @sorcery_config.salt_join_token\n @sorcery_config.encryption_provider.pepper = @sorcery_config.pepper if @sorcery_config.encryption_provider.respond_to?(:pepper) && @sorcery_config.pepper\n end", "def configure\n yield self\n validate_credentials!\n validate_endpoint!\n self\n end", "def setup_common_controller_configuration(is_called_during_reload: false)\n # by default, the erb root incorrectly uses __FILE__ and it picks up the wrong directory\n # we need to correct that here\n erb_root = File.dirname(self.class._file)\n logger.debug(\"Setting erb root to #{erb_root}\")\n self.class.set(:root, erb_root)\n\n # /dashboard_erb and /dashboard_erb/ should route the same\n logger.debug(\"Turning off strict paths\")\n self.class.set(:strict_paths, false)\n\n # enable access to the session in this class\n logger.debug(\"Enabling sessions\")\n self.class.enable(:sessions)\n\n # TODO: This should be removed once it's used in production\n # By setting a seed here, the session will persist across server restarts\n # which is extremely useful for development\n if ENV[\"RACK_ENV\"] == \"development\"\n self.class.set(:session_secret, \"DEVELOPMENT_ENV_FASTLANE_CI\")\n end\n\n # TODO: use session pool for server-side storage\n # generate a secret too\n # see http://sinatrarb.com/intro.html#Using%20Sessions\n # use Rack::Session::Pool, :expire_after => 2592000\n # use Rack::Protection::RemoteToken\n # use Rack::Protection::SessionHijacking\n\n # TODO: Ideally we figure out how to get this working, but for now things work\n # unless is_called_during_reload\n # enable_resource_reloading(file_path: self.class._file) {\n # logger.debug(\"Doing my thing\")\n # setup_common_controller_configuration(is_called_during_reload: true)\n # }\n # end\n end", "def auth_settings\n {\n 'apikey' =>\n {\n type: 'api_key',\n in: 'header',\n key: 'api-key',\n value: api_key_with_prefix('api-key')\n },\n 'userid' =>\n {\n type: 'api_key',\n in: 'header',\n key: 'user-uid',\n value: api_key_with_prefix('user-uid')\n },\n }\n end", "def configure\n yield configuration\n end", "def configure\n yield configuration\n end", "def configure\n yield configuration\n end", "def configure\n yield configuration\n end", "def set_settings(args)\n XingApi::Client.configure do |config|\n config.consumer_key = args[:consumer_key]\n config.consumer_secret = args[:consumer_secret]\n config.oauth_token = args[:oauth_token]\n config.oauth_token_secret = args[:oauth_token_secret]\n end\n end", "def autofill_from_config\n self.pid ||= Config.credentials[:PID] if self.respond_to?(:pid=)\n self.pak ||= Config.credentials[:PAK] if self.respond_to?(:pak=)\n \n # Note: URLs are optional fields, but prefilling from config anyway\n self.cancel_url ||= Config.endpoints[:cancel] if self.respond_to?(:cancel_url=)\n self.success_url ||= Config.endpoints[:success] if self.respond_to?(:success_url=)\n self.failure_url ||= Config.endpoints[:failure] if self.respond_to?(:failure_url=)\n end", "def configure\n\t\t\tyield self\n\t\tend", "def configure\n\t\t\tyield self\n\t\tend", "def configure(settings = {})\n abstract_method\n end", "def after_config_update(*_)\n config[:parameters] ||= Smash.new\n config[:compile_parameters] ||= Smash.new\n config[:apply_stack] ||= []\n config[:apply_mapping] ||= Smash.new\n stack_name = arguments.first\n content = load_file_for(stack_name)\n process_information_hash(content, [])\n nil\n end", "def setup\n FileUtils.cp(VALID_CONFIG_JSON_ORIG, CONFIG_JSON)\n @config = Thermoserver::Configuration.new\n @api_key = @config.api_key\n end", "def configure\n yield(config)\n end", "def apply_grip_config(config)\n if !config.is_a?(Array)\n config = [config]\n end\n config.each do |entry|\n if !entry.key?('control_uri')\n next\n end\n client = PubControlClient.new(entry['control_uri'])\n if entry.key?('control_iss')\n client.set_auth_jwt({'iss' => entry['control_iss']}, entry['key'])\n end\n super_add_client(client)\n end\n end", "def configure\n @mauth_client = ::MAuth::Client.new(mauth_config)\n\n @connection = Faraday.new do |builder|\n builder.use MAuth::Faraday::MAuthClientUserAgent, \"MediTAF Mauth Client Adapter\"\n builder.use MAuth::Faraday::RequestSigner, :mauth_client => @mauth_client\n builder.use MAuth::Faraday::ResponseAuthenticator, :mauth_client => @mauth_client if mauth_config[:authenticate_response]\n builder.use FaradayMiddleware::ParseJson, content_type: /\\bjson$/\n builder.use FaradayMiddleware::ParseXml, content_type: /\\bxml$/\n builder.adapter Faraday.default_adapter\n end\n end", "def configure_global(properties)\n log.header 'Configure'\n Configuration.set(properties)\n end", "def reset!\n @apps = {}\n @default_params = {}\n @basic_auth = nil\n end", "def configure\n yield(self)\n end" ]
[ "0.62537414", "0.6008304", "0.5816012", "0.58047295", "0.57726765", "0.57332164", "0.5732247", "0.5719787", "0.56987303", "0.56964314", "0.5689174", "0.56471246", "0.56466436", "0.5646281", "0.56186295", "0.5608729", "0.5585525", "0.5585525", "0.5585525", "0.5547935", "0.5543197", "0.5532284", "0.55298007", "0.5528957", "0.5523063", "0.54888934", "0.54652894", "0.54641044", "0.54640865", "0.5462015", "0.545423", "0.5438676", "0.54261833", "0.54188293", "0.54052997", "0.5401747", "0.539101", "0.5367494", "0.5363792", "0.5354787", "0.53409153", "0.5331402", "0.5322133", "0.5319811", "0.53132606", "0.53065836", "0.5304184", "0.5298002", "0.52930415", "0.5291367", "0.5284234", "0.5284207", "0.5283396", "0.5274189", "0.5264146", "0.52532864", "0.5246792", "0.52343005", "0.5228606", "0.5221795", "0.52171636", "0.5215759", "0.5215731", "0.5215731", "0.52140266", "0.5212528", "0.5211943", "0.5211535", "0.5210279", "0.52081704", "0.5202142", "0.519987", "0.51915985", "0.5191132", "0.5189593", "0.51815367", "0.51751745", "0.51679385", "0.51635337", "0.51538897", "0.5151073", "0.5141829", "0.5134511", "0.51312804", "0.51312804", "0.51312804", "0.51312804", "0.5129521", "0.5126885", "0.51266795", "0.51266795", "0.5122445", "0.5120881", "0.51203346", "0.51128185", "0.51054347", "0.5096156", "0.509064", "0.508538", "0.50851977" ]
0.58370614
2
Useful for cleaning up after tests, but probably not much else.
def reset_configuration! @configuration = Auth::Configuration.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleanup!; end", "def cleanup!; end", "def cleanup; end", "def cleanup; end", "def cleanup; end", "def cleanup; end", "def cleanup\n end", "def cleanup\n end", "def cleanup\n end", "def cleanup\n end", "def cleanup\n end", "def cleanup\n end", "def cleanup\n end", "def cleanup\r\n end", "def cleanup\n end", "def cleanup\n end", "def cleanup!\n # This method may be left unimplemented if that is applicable\n end", "def cleanup\n true\n end", "def cleanup\n\tend", "def cleanup\n\tend", "def cleanup\n true\nend", "def clean_up\n end", "def clean_up\n end", "def teardown; end", "def teardown; end", "def cleanup\n # override and do something appropriate\n end", "def teardown\r\n end", "def teardown\n # if necessary\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n end", "def teardown\n # empty\n end", "def tear_down; end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def teardown\n\n end", "def do_cleanup; \"\" end", "def teardown\n # Empty\n end", "def teardown\n # Empty\n end", "def teardown\n FakeFS::FileSystem.clear # wipe file system for new test\n end", "def teardown\n\tend", "def teardown\n\tend", "def clean_up\n puts \"Run the following commands to clean up your test data:\"\n puts \"oc delete pv --all\"\n puts \"oc delete pvc --all\"\n puts \"Deleting temporary test files\"\n `rm -rf #{$templates_path}/*`\nend", "def cleanup_hook; end", "def teardown\n\t\t# Do nothing\n\tend", "def teardown\n\t\t# Do nothing\n\tend", "def teardown\n\t\t# Do nothing\n\tend", "def teardown!\n\n end", "def clean_up\n FileUtils.rm_rf @temp_root\n end", "def teardown\n # Do nothing\n end", "def teardown\n # Do nothing\n end", "def teardown\n end", "def teardown\n end", "def teardown\r\n # Do nothing\r\n end", "def teardown\r\n # Do nothing\r\n end", "def teardown\r\n # Do nothing\r\n end", "def teardown\r\n # Do nothing\r\n end", "def teardown\r\n # Do nothing\r\n end", "def teardown\r\n # Do nothing\r\n end", "def teardown\r\n # Do nothing\r\n end", "def teardown\r\n # Do nothing\r\n end", "def teardown\r\n # Do nothing\r\n end", "def teardown\r\n # Do nothing\r\n end", "def on_cleanup(unit); end", "def teardown\n @mem.mem_clear\n end", "def teardown\n # Do nothing\n end", "def bootstrap_cleanup\n end", "def teardown\n\t\t\t\t# Do nothing\n\t\tend", "def after_teardown; end" ]
[ "0.8593671", "0.8593671", "0.85142034", "0.85142034", "0.85142034", "0.85142034", "0.84191006", "0.84191006", "0.84191006", "0.84191006", "0.8401564", "0.8401564", "0.8401564", "0.81836903", "0.817005", "0.817005", "0.8081445", "0.79804903", "0.7960377", "0.7960377", "0.7878262", "0.78089696", "0.78089696", "0.77918994", "0.77918994", "0.76220095", "0.76194876", "0.7612062", "0.7595843", "0.7595843", "0.7595843", "0.7595843", "0.7595843", "0.7595843", "0.7595843", "0.7595843", "0.7582566", "0.7582566", "0.7582566", "0.7582566", "0.7582566", "0.7582566", "0.7582566", "0.7582566", "0.7582566", "0.7582566", "0.7582566", "0.7582566", "0.7582566", "0.7535618", "0.7533458", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.7475111", "0.74645644", "0.74643946", "0.74643946", "0.7441068", "0.74289316", "0.74289316", "0.7426608", "0.74115723", "0.7405848", "0.7405848", "0.7405848", "0.74019456", "0.7401565", "0.73882025", "0.73882025", "0.7386307", "0.7386307", "0.73563665", "0.73563665", "0.73563665", "0.73563665", "0.73563665", "0.73563665", "0.73563665", "0.73563665", "0.73563665", "0.73563665", "0.7356082", "0.73373634", "0.73120755", "0.72816724", "0.7276706", "0.7262297" ]
0.0
-1
A Fibonacci sequence is a list of numbers that begins with 0 and 1, and each subsequent number is the sum of the previous two. For example, the first seven Fibonacci numbers are: 0 1 1 2 3 5 8 Write a method that will return the nth number of the sequence. The syntax is easy, getting your head around the algorithm is the challenge. Write the sequence on a piece of paper first and think about the steps you take for each number. Translate this to pseudocode and then to ruby. Difficulty: 6/10 Example: nthFibonacci(0) > 0 nthFibonacci(3) > 2 nthFibonacci(6) > 8 Check your solution by running the tests: ruby tests/11_fibonacci_test.rb
def nthFibonacci (n) # Your code here fArr = [] a = 0 b = 1 if n == 0 fArr << 0 elsif n == 1 fArr << 0 elsif n > 1 fArr << 0 while fArr.size < n+1 do fArr << b a,b = b,a+b end end return fArr[n] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nthFibonacci (n)\n \n if n == 0\n return 0\n end\n\n i = 0\n\n sequence = Array.new\n\n sequence.push(i)\n\n i += 1\n\n sequence.push(i)\n\n while i < n do\n sequence[i+1] = (sequence[-1]) + (sequence[-2])\n\n i += 1\n end\n\n sequence[-1]\nend", "def nthFibonacci (n)\r\n num = n.to_i\r\n fibonacci_sequence = Array.new\r\n case num\r\n when 0 \r\n fibonacci_sequence << 0\r\n when 1\r\n fibonacci_sequence << [0,1]\r\n else\r\n fibonacci_sequence[0] = 0\r\n fibonacci_sequence[1] = 1\r\n i = 1\r\n while i < num\r\n i+= 1\r\n fibonacci_sequence[i] = fibonacci_sequence[i-1] + fibonacci_sequence[i-2] \r\n end\r\n end\r\n return fibonacci_sequence\r\nend", "def nth_fibonacci(n)\n return 0 if n == 1\n sequence = [1]\n (n - 2).times do\n current_number, last_number = sequence.last(2)\n sequence << current_number + (last_number || 0)\n end\n\n sequence.last\nend", "def nthFibonacci(n)\r\n if n == 1\r\n return 1\r\n\r\n elsif n == 2\r\n return 1\r\n\r\n else n > 2\r\n n = nthFibonacci(n-1) + nthFibonacci(n-2)\r\n end\r\nend", "def fibonacci_number(n)\n #define nth Fibonacci term\n fibonacci_lst=[0,1] #F1=1,F2=1\n for i in 2..n\n fibonacci_lst[i]=fibonacci_lst[i-1]+fibonacci_lst[i-2]\n end\n return fibonacci_lst[n]\nend", "def nth_fibonacci(n) \n if n == 1\n return 0\n elsif n == 2\n return 1\n end\n return nth_fibonacci(n-1) + nth_fibonacci(n-2)\nend", "def fib (n)\n # return appropriate starter values if n is 0 or 1\n if n == 0 \n return 0\n elsif n == 1\n return 1\n end\n # set up initial constants\n prevNum = 0\n currNum = 1\n # Loop through fibonacci numbers, starting at index 2.\n 2.upto(n) do\n nextNum = prevNum + currNum\n prevNum = currNum\n currNum = nextNum\n end\n return currNum\nend", "def iterative_nth_fib(n)\n return 1 if n <= 2\n a = 1\n b = 1\n i = 3\n while i <= n\n new_a = b\n b = a + b\n a = new_a\n i += 1\n end\n b\nend", "def fibonacci(n)\n if n == 0\n 0\n elsif n == 1\n 1\n else\n before_previous = 0\n previous = 1\n actual = nil\n (2..n).each do\n actual = previous + before_previous\n before_previous = previous\n previous = actual\n end\n actual\n end\nend", "def fib(n)\n # edge cases:\n if n < 0\n raise Exception, 'Index was negative. No such thing as a negative index in a series.'\n elsif n == 0 || n == 1\n return n\n end\n\n # we'll be building the fibonacci series from the bottom up\n # so we'll need to track the previous 2 numbers at each step\n prev_prev = 0\n prev = 1\n current = prev + prev_prev\n\n # since we already initialized up to the 2nd number in the series\n # we take n - 2 steps ahead to reach n (.times is exclusive)\n (n - 1).times do\n current = prev + prev_prev\n prev_prev = prev\n prev = current\n end\n\n current\nend", "def fibonacci(n)\n raise ArgumentError, \"n must be an integer greater than 0\" unless n && n >= 0\n current = 0\n one_before = 0\n two_before = 0\n i = 0\n while i <= n\n if i == 1\n current = 1\n else\n two_before = one_before\n one_before = current\n current = one_before + two_before\n end\n i += 1\n end\n return current\nend", "def fibonacci_sequence index\n if index == 0 || index == 1\n return index\n else\n return fibonacci_sequence(index - 2) + fibonacci_sequence(index - 1)\n end\nend", "def nth_fibonacci(n)\n result = [0,1]\n\n for i in 1..n-1\n result[i+1] = result[i] + result[i-1]\n end\n\n return result[n]\nend", "def get_nth_fib(n)\n if n == 0 || n == 1\n return 0\n elsif n == 2\n return 1\n else\n return get_nth_fib(n-1) + get_nth_fib(n-2)\n end\n\nend", "def fibs (n) #Non-recursive\n\n\t# n = number of Fibonacci sequence members.\n\t# 0, 1, 1, 2, 3, 5, 8, 13, ..\t\n\tfib_seq = []\n\t(0..n).each do |i|\n\t\tif i == 0\n\t\t\tfib_seq << 0\n\t\telsif i == 1\n\t\t\tfib_seq << 1\n\t\telse\n\t\t\tfib_seq << fib_seq[i-2] + fib_seq[i-1]\n\t\tend\n\tend\n\tfib_seq\nend", "def fibonacci(how_many_numbers)\n fibonacci_sequence = []\n count = 0\n while count < how_many_numbers\n if count == 0\n fibonacci_sequence << 0\n count += 1\n elsif count == 1\n fibonacci_sequence << 1\n count += 1\n else\n fibonacci_sequence << fibonacci_sequence[-1] + fibonacci_sequence[-2]\n count += 1\n end\n end\n fibonacci_sequence\nend", "def fibonaci(n)\n\tfi= [1, 1]\n\t(n-1).times do\n\t\tfi << fi[1]+fi.shift\n\tend\n\treturn fi[0]\nend", "def fibonacci(n)\n if n == 0 || n == 1\n return n\n end\n\n first = 0\n second = 1\n current = 1\n\n while n > 2\n first = second\n second = current\n current = first + second\n n -= 1\n end\n\n return current\nend", "def fibonacci(n)\n raise ArgumentError if n == nil || n < 0 || n.class != Integer\n return n if n < 2\n\n if n >= 2\n current_value= 0\n previous_value = 1\n next_value = 0\n number = n - 1\n\n number.times do \n next_value = current_value + previous_value \n current_value = previous_value \n previous_value = next_value\n end\n end\n \n return next_value\nend", "def fibonacci(n)\n \n return 'not valid' if n <= 0\n arr = [0,1,1]\n return arr[n-1] if n <= 3\n\n initial_number = 0\n next_number = 1\n i = 2\n\n\n \n \n while i < n \n sum = initial_number + next_number \n initial_number = next_number\n next_number = sum\n i += 1\n end\n return sum \n\nend", "def fibonacci_sequence(n)\n counter = 1\n fib_sum = 1\n previous = [1]\n if n == 1 || n == 2\n return 1\n else \n until counter == n - 1\n previous << fib_sum\n fib_sum += previous[counter - 1] \n counter += 1\n end\n return fib_sum\n end\nend", "def fibonacci(n)\r\n if n == 0\r\n return 0\r\n elsif n == 1\r\n return 1\r\n else\r\n return fibonacci(n-1) + fibonacci(n-2)\r\n end\r\nend", "def fibonacci(n)\n # raise NotImplementedError\n raise ArgumentError if n < 0 || n == nil #error if negative\n\n i = 0\n fib_array = [0, 1] #all fibonacci sequences begin with 0 and 1\n until fib_array.length == n+1 #until the correct index is reached\n fib_array.push fib_array[i] + fib_array[i+1]\n i += 1\n end\n return fib_array[n] #return number at requested index\nend", "def nthFibonacci (n)\r\n # Your code here\r\n f = [0, 1, 1, 2, 3, 5, 8]\r\n if n < 7\r\n return f[n]\r\n end\r\n\r\n t = 6\r\n fn = 8\r\n\r\n while t < n\r\n fn = (fn * PHI).round(0)\r\n t += 1\r\n end\r\n\r\n return fn\r\nend", "def nthFibonacci(n)\r\n fibonacci = []\r\n a = 0 \r\n b = 1\r\n\r\n while n >= fibonacci.length\r\n fibonacci.push(a)\r\n fibonacci.push(b)\r\n a = a + b\r\n b = a + b\r\n end\r\n return fibonacci[n]\r\nend", "def fibonacci(n)\n fibb = []\n fibb[0], fibb[1], fibb[2] = 0, 1, 1\n (3).upto(n) do |i|\n fibb[i] = fibb[i - 2] + fibb[i - 1]\n end\n fibb[n]\n end", "def get_fibonacci(num)\n f = [0,1]\n for i in (2..num)\n f << (f[-1] + f[-2])\n end\n if num == 0\n f = 0\n end\n f[-1]\nend", "def fibonacci(n)\n if n.nil?\n raise ArgumentError.new(\"Invalid\")\n elsif n < 0\n raise ArgumentError.new(\"Invalid\")\n end\n\n return 0 if n == 0\n\n num_one = 0\n num_two = 1\n fib_n = 1\n\n count = n - 1\n\n count.times do\n fib_n = num_one + num_two\n num_one = num_two\n num_two = fib_n\n end\n\n return fib_n\nend", "def find_fib_nth(n)\n if n == 0\n 1\n elsif n == 1\n 1\n else\n return (find_fib_nth(n - 2) + find_fib_nth(n - 1))\n end\nend", "def fibonacci(n)\n return 0 if n == 1\n return 1 if n == 2\n return fibonacci(n-1)+fibonacci(n-2)\nend", "def get_nth_fib(n)\n if n == 2\n return 1\n elsif n == 1\n return 0\n else\n return get_nth_fib(n - 1) + get_nth_fib(n - 2)\n end\nend", "def fibonacci(n)\n first = 0\n second = 1\n current = 1\n\n raise ArgumentError.new(\"n must be a positve number\") if n.nil? || n < 0\n return n if n == 0 || n == 1\n\n while n > 2\n first = second\n second = current\n current = first + second\n n -= 1\n end\n\n return current\nend", "def fibonacci(n)\n return 1 if n <= 2\n num1, num2 = [1, 1]\n index = 2\n while n > index\n running_total = num1 + num2\n num1, num2 = num2, running_total\n n -= 1\n end\n running_total\nend", "def q9_fibonacci(num)\n f1 = 0\n f2 = 1\n (num-1).times {|_|\n tmp = f2\n f2 += f1 \n f1 = tmp\n }\n f2\nend", "def fibonacci(n)\n if n == 0\n 1\n elsif n == 1\n 1\n else\n fibonacci(n-2) + fibonacci(n-1)\n end\nend", "def fibonacci\n\tresults, first, second, current = 0, 1, 2, 2\n\twhile current <= 4000000\n\t\tif current % 2 == 0\n\t\t\tresults += current\n\t\tend\n\t\tcurrent = first + second\n\t\tfirst, second = second, current\n\tend\n\treturn results\nend", "def nthFibonacci (n)\r\n # Your code here\r\n a = 0\r\n b = 1\r\n n.times do\r\n temp = a\r\n a = b\r\n b = temp + b\r\n end\r\n return a\r\nend", "def fibonacci_iterative(n)\n return 0 if n == 0\n fib_sequence = [0,1]\n index = 1\n until n == index\n fib_sequence << fib_sequence[index] + fib_sequence[index-1]\n index += 1\n end\n fib_sequence.last\nend", "def fib(n)\n return 1 if n <= 2\n \n fib_index = 3\n a, b = 1, 1\n \n while fib_index <= n\n c = a + b\n a = b\n b = c\n fib_index += 1\n end\n \n c\nend", "def fibonacci (n)\r\n def calculation(n)\r\n a = 0\r\n b = 1\r\n\r\n # Compute Fibonacci number in the desired position.\r\n n.times do\r\n temp = a\r\n a = b\r\n # Add up previous two numbers in sequence.\r\n b = temp + b\r\n end\r\n\r\n return a\r\n\r\n end \r\n\r\n fib_results = []\r\n\r\n n.times do |n|\r\n\r\n result = calculation(n)\r\n fib_results << result\r\n end \r\n\r\n return fib_results\r\n\r\nend", "def fib(number)\n sequence = [0,1]\n number.times {sequence << sequence[-1] + sequence[-2]}\n sequence[-1]\n return sequence\nend", "def iterative_fib(num)\r\n a = 0\r\n b = 1\r\n\r\n num.to_i.times do\r\n temp = a\r\n a = b\r\n # Add up previous two numbers in sequence\r\n b = temp + b\r\n end\r\n\r\n return b\r\nend", "def fibonacci_given(nth)\n return 1 if nth <= 2\n fibonacci_given(nth - 1) + fibonacci_given(nth - 2)\nend", "def fibonacci(n)\n seq = [0,1]\n i = 2\n while i <= n\n seq << (seq[i-1] + seq[i-2])\n i+=1\n end\n return seq[n]\nend", "def fibonacci2(n)\n return 0 if n == 0\n return 1 if n == 1 || n == 2\n last = 0\n lastlast = 1\n current = 0\n n.times do\n current = last + lastlast\n lastlast = last\n last = current\n end\n current\nend", "def fibonacci(n)\n fib1 = 0\n fib2 = 0\n fib = 0\n\n (1..n).each do |num|\n if num <= 2\n fib = 1\n fib1 = 1\n fib2 = 1\n else\n fib1 = fib2\n fib2 = fib\n fib = fib1 + fib2\n end\n end\n\n fib\nend", "def fibonacci(num)\n fib_nums = []\n (0...num).each do |i|\n if i == 0 || i == 1\n fib_nums << 1\n next\n end\n fib_nums << fib_nums[i-2] + fib_nums[i-1]\n end\n return fib_nums\nend", "def fibonacci n\n first = 0\n second = 1\n n.times do\n third = first + second\n first = second\n second = third\n end\n first\nend", "def fibonacci3\n return 0 if n == 0\n return 1 if n == 1 || n == 2 || n == -1\n sequence = [0, 1, 1]\n loop do\n sequence << (sequence[-1] + sequence[-2])\n break if sequence.length > n.abs\n end\n n > 0 ? sequence[-1] : n.even? ? -(sequence[-1]) : sequence[-1]\nend", "def fibonacci(n)\n if n == 1 || n == 2\n 1\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\nend", "def fib(n) \n if n == 0\n return 0\n else\n\tfib_0 = 0\n\tfib_1 = 1\n\t(1..(n-1)).each do \n\t\ttemp = fib_0\n\t\tfib_0 = fib_1\n\t\tfib_1 = temp + fib_1\n\t\t\n\tend\n\treturn fib_1\n end\nend", "def fibo(n)\n\n first = 0\n second = 1\n total = 0\n\n (1...n).each do\n total = first + second\n first = second\n second = total\n end\n return total\nend", "def fibonacci(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(n)\n fibonacci_num = 0\n prior_num = 0\n current_num = 1\n\n if !n || n < 0\n raise ArgumentError\n elsif n == 0 || n == 1\n return n\n else \n (n-1).times do\n fibonacci_num = prior_num + current_num\n prior_num = current_num\n current_num = fibonacci_num\n end\n return current_num\n end\nend", "def fibonacci(n)\n if n == nil || n < 0\n raise ArgumentError\n elsif n == 0\n return 0\n elsif n == 1\n return 1\n end\n\n first = 0\n second = 1\n\n index = 1\n while index < n\n holder = first + second\n first = second\n second = holder\n index += 1\n end\n return holder\nend", "def fibonacci(n)\n if n == 0 or n == 1\n return n\n else\n return fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fibonacci(n)\n raise ArgumentError, \"Not an integer larger than 0\" if !n || n < 0\n\n fib_array = [0, 1]\n i = 0\n\n if n == 0\n return 0\n elsif n == 1\n return 1\n else\n until i == (n - 1)\n fib_array << fib_array[i] + fib_array[i + 1]\n i += 1\n end\n end\n return fib_array[n]\nend", "def fib(n)\n if n == 0\n return 0\n elsif n == 1\n return 1\n end\n\n last = 1\n next_to_last = 0\n i = 2\n\n while i <=n\n cur_fib = last + next_to_last\n next_to_last = last\n last = cur_fib\n i +=1\n end\n return cur_fib\nend", "def iter_fib(n)\n return n if n == 0 || n == 1\n\n two_before = 0\n one_before = 1\n\n for i in 2..n\n current = two_before + one_before\n two_before = one_before\n one_before = current\n end\n one_before\nend", "def fibonacci_number(i)\n if i == 1 || i == 2\n 1\n else\n fibonacci_number(i - 1) + fibonacci_number(i - 2)\n end\nend", "def fibonacci(n)\n if n <= 2\n 1\n else\n fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fibo_nth(n)\n puts \"computing fibo for n=#{n}\" if @debug\n\n case n\n when 0 then 0\n when 1 then 1\n else fibo_nth(n-2) + fibo_nth(n-1)\n end\nend", "def fib (x)\n y = x-2\nfib_sequence = y.times.inject(%5B0,1%5D) do |a, idx|\n a << a[-2] + a[-1]\nend", "def fibonacci\n @sequence = [1,1]\n x = 0\n while (@sequence[x+1] < 4e+6)\n @sequence << @sequence[x] + @sequence[x+1]\n x += 1\n end\n even? x\nend", "def nth_fib(x)\n arr = [0,1]\n count = 1\n while count < x\n next_val = arr[-1] + arr[-2]\n arr = [arr[-1], next_val]\n count += 1\n end\n puts next_val\n # puts \"The weird algorithm from Hackerank comes to: #{next_val % (10**8 + 7)}\"\n end", "def fibonacci number\n sequence = []\n a = 1\n b = 1\n while true\n sequence << b\n newa = b\n b = a+b\n a = newa\n break if b > number\n end\n sequence\nend", "def fibonacci(nth)\n return 1 if nth <= 2\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend", "def fibonacci(nth)\n return 1 if nth <= 2\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend", "def fibonacci(nth)\n return 1 if nth <= 2\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend", "def fibonacci(nth)\n return 1 if nth <= 2\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend", "def fibonacci(n)\n n = fibonacci( n - 1 ) + fibonacci( n - 2 ) if n > 1\n n\nend", "def fibonacci(n)\n result = []\n i = 1\n while i <= n\n if i == 1 || i == 2\n result << 1\n else\n result << result[i - 3] + result[i - 2]\n end\n i += 1\n end\n result.last\nend", "def gen_fibs3\n fibs = [0,1]\n n = 10\n a,b = 0,1\n (n-1).times do\n a,b = b,a+b\n fibs << b\n end\n fibs\nend", "def fib(n)\n if n == 0 || n == 1\n return n\n end\n\n number1 = 0\n number2 = 1\n number3 = 0\n\n (2..n).each do |index|\n number3 = number1 + number2\n number1 = number2\n number2 = number3\n end\n\n return number3\nend", "def fibonacci(n)\n\tif n == 0 || n == 1\n\t\treturn 1\n\telse\n\t\treturn fibonacci(n-1) + fibonacci(n-2)\n\tend\nend", "def fibonacci(n)\n\treturn 0 if n == 0\n\treturn 1 if n == 1\n\tfibonacci(n-1) + fibonacci(n-2)\nend", "def fibonacci(n)\n return 1 if n == 1\n return 1 if n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend", "def fibonacci(nth)\n return 1 if nth <= 2\n\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend", "def regular_fib(sequence)\n first = 0\n second = 1\n if sequence == 0\n puts \"total = 0\"\n end\n sequence.times do \n total = first + second\n puts \"total(#{total}) = #{first} + #{second}\"\n first = second\n second = total\n end \nend", "def fibonacci(n)\n if n < 2\n n\n else\n fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fibonacci(n)\n if n <= 1\n return n\n else\n return fibonacci(n - 1) + fibonacci(n - 2)\n end\nend", "def fibonacci(n)\n return [0,1].take(n) if n <= 2\n fib_seq = fibonacci(n-1)\n last_ele = fib_seq[-1] + fib_seq[-2]\n fib_seq << last_ele\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n \n\n fib(n - 1) + fib(n - 2)\nend", "def nthFibonacci (n)\n # Your code here \nend", "def fibonacci(number)\r\n if number < 2\r\n number\r\n else\r\n fibonacci(number - 1) + fibonacci(number - 2)\r\n end\r\nend", "def fib(n)\n\n fib_array = []\n first = 0\n second = 1\n\n if n == 0\n fib_array << nil\n elsif n == 1\n fib_array << 0\n else\n fib_array << 0\n fib_array << 1\n if n >= 3\n (3..n).each do # Due to the zero index of\n # Ruby, we use 3 here to represent the\n # numbers after 0, 1, 1\n\n next_number = (first + second)\n first = second\n fib_array << second = next_number\n\n end\n end\n end\n return fib_array\n\nend", "def fibonacci_last(n)\n return 1 if n <= 2\n n1, n2 = [1, 1]\n 3.upto(n) { n1, n2 = [n2, n1 + n2] }\n n2.to_s.chars[-1].to_i\nend", "def fibonacci(integer)\n fibs = [1, 1]\n (integer - 2).times do |num|\n fibs << fibs[num] + fibs[num + 1]\n end\n fibs.last\nend", "def fibonacci(n)\n if n < 3\n 1\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\nend", "def fibonacci(integer)\n x = 2\n sequence = [1, 1]\n until x == integer\n last = sequence[0] + sequence[1]\n first = sequence[1]\n sequence[1] = last\n sequence[0] = first\n x += 1\n end\n\n sequence.last\nend", "def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend", "def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend", "def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend", "def fibonacci(number)\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend", "def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n return 1 if n == 2\n # return 2 if n == 3\n fib(n - 1) + fib(n - 2)\nend", "def fib_iterative(n)\n\tnum = 0\n\tnext_num = 1\n\tpositions = 1..n\n\tpositions.each do |position|\n\t\tnum = next_num\n\t\tnext_num = next_num + num\n\tend\n\tretun num\nend", "def fibonacciIterative(n)\n\ti = 1\n\tfib = 1\n\tprev_one = 1\n\tprev_two = 0\n\twhile i<n\n\t\tfib = prev_one + prev_two\n\t\tprev_two = prev_one\n\t\tprev_one = fib\n\t\ti+=1\n\tend\n\treturn fib\nend", "def fib n\n if n == 0\n 0\n elsif n == 1\n 1\n else\n fib(n-2) + fib(n-1)\n end\nend", "def fib(number)\n if number == 0\n 0\n elsif number == 1\n 1\n else\n test= fib(number-1) + fib(number-2)\n puts \"adding number #{number-1} and #{number-2} = #{test}\"\n test\n end\nend", "def show_fib(n)\n return 0 if n == 0\n return 1 if n == 1\n show_fib(n-1) + show_fib(n-2)\nend" ]
[ "0.8714323", "0.84712553", "0.8459169", "0.8453728", "0.83955956", "0.83687186", "0.8356863", "0.8319983", "0.8306515", "0.82503283", "0.82440555", "0.8229246", "0.8225465", "0.81880456", "0.8179822", "0.81740445", "0.81654406", "0.81647575", "0.8158253", "0.8151678", "0.81510967", "0.8143928", "0.8142707", "0.8137582", "0.8135223", "0.8130561", "0.8120033", "0.81125283", "0.81119895", "0.8104129", "0.8089622", "0.8077919", "0.8061849", "0.8061272", "0.8059851", "0.805438", "0.80511546", "0.80396384", "0.8037752", "0.8034764", "0.8032141", "0.802261", "0.8022524", "0.8021044", "0.8018911", "0.8009158", "0.8007722", "0.8005433", "0.8004675", "0.8002125", "0.8001061", "0.7994319", "0.7988586", "0.7984943", "0.79819643", "0.79811984", "0.79802936", "0.7979297", "0.79791206", "0.7976625", "0.79746836", "0.79726595", "0.79703784", "0.79653525", "0.79495674", "0.7947633", "0.79457474", "0.79457474", "0.79457474", "0.79457474", "0.79442364", "0.7940349", "0.7939344", "0.79390806", "0.79385775", "0.7938245", "0.79370415", "0.7927449", "0.79261714", "0.7921575", "0.79211456", "0.79179186", "0.791713", "0.79161483", "0.79113585", "0.79112333", "0.7908574", "0.79047763", "0.789834", "0.78902787", "0.7888646", "0.7888646", "0.7888646", "0.7888646", "0.7888434", "0.7886615", "0.78850806", "0.78844017", "0.78827155", "0.7881793" ]
0.81505847
21
Get list of dishes and their price.
def extract_menu(html_str: "") doc = Nokogiri::HTML(html_str) menu = [] name = nil price = nil doc.css(DISH_CONTAINER).each do |dish| name = dish.css(DISH_NAME)&.text&.strip price = dish.css(DISH_PRICE)&.text&.strip unless name&.empty? || price&.empty? then menu << [ name.dup, price.dup ] end end menu.sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prices(id, where)\n Price.find(:all, :conditions=>\"dish_id=#{id} and freezer='#{where}'\")\n end", "def all_prices\n request :public, :get, :price\n end", "def fetch\n Abacos.prices_available.map do |s|\n {\n id: s[:codigo_produto],\n code_abacos: s[:codigo_produto_pai],\n price: s[:preco_tabela],\n promotional_price: s[:preco_promocional],\n protocolo_preco: s[:protocolo_preco]\n }\n end\n end", "def list_dish_notify\n rs = []\n dish_list = []\n dish_list_id = []\n minus_total = 0\n # byebug\n @id.each do |od_id|\n od = OrderDetail.find od_id\n minus_total += (od.quantity_not_serve * od.price)\n dish = Dish.find od.dish.id\n unless dish_list_id.index dish.id\n dish_list_id << dish.id\n rs << Dishes::Serializer.new(dish)\n end\n # byebug\n end\n # begin\n # ActiveRecord::Base.transaction do\n # order = OrderDetail.find(@id.first).order\n # order.update(total: order.total - minus_total)\n # end\n # rescue StandardError => error\n # puts \"Error - list_dish_notify\"\n # end\n # byebug\n rs\n end", "def prices (currency='TWD')\n get '/prices/' + currency\n end", "def prices_for(artno, at = Date.today)\n discounts_for(artno, at).sort_by(&:price)\n end", "def prices\n Excursion.all.each do |excursion|\n excursion.price \n end\n end", "def list_products\n @products.map { |p| \"#{p.name} costs £#{p.price / 100.round(2)}\" }\n end", "def get_price(page)\n web_object = page.css(\"a.price\")\n price_coin = [] #stocke les donnees dans nouvel array\n web_object.each { |link| puts price_coin << link[\"data-usd\"] }\n return price_coin\n end", "def special_prices\n prices\n end", "def index\n @dishes = Dish.all\n end", "def index\n @dishes = Dish.all\n end", "def index\n @dishes = Dish.all\n end", "def monies\n products.map(&:price)\n end", "def show\n @dishes = Dish.all\n end", "def discounts\n @discounts ||= [product.dig(:discounts, :item)].flatten(1).compact\n end", "def index\n @dialer_prices = DialerPrice.all\n end", "def show\n @dishes = @chef.dishes\n end", "def get_prices\n\n pricing_column = col_right.div(:class, 'a-span7').divs(:class, 'a-row')\n num_rows = pricing_column.size\n i = 0\n\n while i < num_rows do\n begin\n\n column_title = pricing_column[i].h3.inner_html ## \"Kindle Edition\"\n if column_title == 'Kindle Edition'\n @kindle_price = pricing_column[i + 1].span(:class, 's-price').inner_html\n end\n\n if column_title == 'Paperback'\n @paperback_price = pricing_column[i + 1].span(:class, 's-price').inner_html\n end\n\n rescue Watir::Exception::UnknownObjectException\n # Just do nothing -- we'll advance and try again\n end\n\n i += 1\n end\n end", "def discounts\n @discounts ||= hash[\"Discounts\"].map { |d| Merchant::Discount.new d }\n end", "def index\n @dishes = @restaurant.dishes\n end", "def index\n @dishes = @chef.dishes\n end", "def get_all_price\n page = Nokogiri::HTML(open(\"https://coinmarketcap.com/all/views/all/\")) # ça ouvre la page web coinmarket et enregistre dans la variable page \n noko_o = page.xpath(\"//tbody/tr/td/a[@class='price']\") #je prends la page web coinmarket de la variable page et je lui extrait les prix de chaque currencies et je les stock dans la variable noko_o\n currencies_price = noko_o.map { |n| n.text.delete_prefix('$').to_f} # c'est un array qui contient la variable noko_o dont on a extrait les prix , dont on retire le symbole $ \n puts currencies_price # affiche mon tableau currencies sans le symbole $ \n\treturn currencies_price #je récupère tous les prix des monnaies \nend", "def disc(id)\n get(\"/catalog/titles/discs/#{id.to_s}\")\n end", "def show\n @order = Order.find(params[:id])\n @order_dishes = @order.order_dishes.includes(:dish).order(\"order_dishes.time\")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end", "def index\n @diet_dishes = DietDish.all\n end", "def index\n @plate = Plate.find(@plate_id)\n @dishes_products = DishesProduct.where(plate_id:@plate_id)\n end", "def scrapp_prices\n\tpage = get_page\n\tcrypto_prices = page.xpath('//*[@class=\"price\"]')\n\tcrypto_prices_array = []\n\tcrypto_prices.each do |price|\n\t\tcrypto_prices_array << price.text[1..-1].to_f\n\tend\n\treturn crypto_prices_array\nend", "def format_rations\n @daily_rations.map do |e|\n [ e.dish_id,\n e.dish.title,\n e.dish.price,\n e.quantity ]\n end\n end", "def list_price\n support_product_number = type == 'hw' ? 'HA104A' : 'HA107A'\n year1 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 1, :option_number => option_number)\n year3 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 3, :option_number => option_number)\n year4 = PricingDbHpPrice.option_price(:product_number => support_product_number, :year => 4, :option_number => option_number)\n @list_price = [(year4 - year3)/BigDecimal(\"12.0\"), (year3 - year1)/BigDecimal(\"24.0\")].max\n end", "def get_prices(noko)\n prices_str = noko.css('div#prices').children.to_s.strip\n prices = Sanitize.clean(prices_str)\n .gsub(/We're Sorry/, '')\n .gsub(/Inventory Restriction/, '')\n .gsub(/Inventory Failure/, '')\n .gsub('Success!', '')\n .gsub(/\\s+/, ' ')\n .strip\n price_points = prices.split(/\\s\\|\\s/)\n prices_array = []\n price_points.each do |price|\n size = price.match /\\d+(oz|cl)/\n dollars = price.match(/\\$\\d+\\.*\\d*/).to_s.sub('$', '')\n crowler = price.match ' Crowler'\n size = size.to_s + crowler.to_s\n p = {size: size, cost: dollars}\n prices_array.push p\n end\n prices_array\n end", "def get_cup_price_data\r\n prices = Array.new\r\n self.price_of_coffees.all.each do |p|\r\n price = Array.new\r\n # X-Wert ist Zeitstempel, ab wann der Tassenpreis gültig ist (für Highcharts unformatiert in ms seit 1970, UTC) => Addiere 1 Stunden für Zeitzone Berlin\r\n x_value = p.date.to_time.to_i * 1000 + (1000 * 60 * 60)\r\n price.append(x_value)\r\n # Y-Value ist der Preis\r\n y_value = p.price.to_f\r\n price.append(y_value)\r\n prices.append(price)\r\n end\r\n prices\r\n end", "def index\n @admin_dishes = Admin::Dish.all\n end", "def price\n response[\"price\"]\n end", "def index\n @list_prices = ListPrice.all\n end", "def cash_prices(params = {})\n scope 'default'\n get('prices/cash', params)\n end", "def index\n @tag_dishes = TagDish.all\n end", "def desserts\n self.dessert_ingredients.map {|di| di.dessert}\n end", "def index\n @meal_dishes = MealDish.all\n end", "def get_prices_for(product_name)\n prices = []\n page = Mechanize.new.get(url(product_name)) rescue nil\n return prices unless page.present? && page.body.present?\n\n doc = Nokogiri::HTML(page.body)\n \n doc.css(\".a-fixed-left-grid-inner\").each do |item|\n prices << item.at_css(\".s-price\").try(:text)\n end if doc.present?\n\n prices.compact\n end", "def index\n @inchicken_dishes = InchickenDish.all\n end", "def new_prices\n # Since everything is relative to USD, we don't need to fetch it.\n commodities\n .reject { |c| c == \"USD\" }\n .reduce(existing_prices) do |db, c|\n # `|` is a shortcut for merge\n db | prices_for_symbol(c, start_date: start_date, end_date: end_date)\n .map { |x| price_string_from_result(x, symbol: c) }\n end\n end", "def dailies_avg_prices\n @item = EveItem.friendly.find( params[ :item_id ] )\n\n\t\traise \"Should be called only for base item : #{@item.inspect}\" unless @item.base_item\n\n\t\t@title = DAILIES_AVG_PRICES_TITLE + view_context.link_to( @item.name, item_path( @item ) ) + ' ' + view_context.print_total_cost_for_items( @item )\n\t\t@meta_title = DAILIES_AVG_PRICES_TITLE + @item.name\n\n\t\t@meta_content = 'The price of a basic item is computed over a weekly average of the price each day.'\n\n @dailies_details = @item.weekly_price_details.where(trade_hub_id: params[:trade_hub_id]).order( 'day DESC' ).paginate( :page => params[:page] )\n end", "def cars_sorted_by_price\n @inventory.sort_by { |car| car.total_cost }\n end", "def get_prices\n prices = html_open_url.css(\"a.price\")\n price_array = put_in_array(prices)\n price_array.each do |i| \n i.delete!('$')\n sprintf(\"%.2f\", i.to_f) \n end\n return price_array\nend", "def index\n @prices = authorized_scope(venue.prices).includes(:courts)\n if params[:day].present?\n day = params[:day].to_s\n raise WrongActionError unless Price::WEEKDAYS.map(&:to_s).include?(day)\n @prices = @prices.where(\"#{day}\": true)\n end\n\n # TODO: filter ones by sport, so it doesn't render golf prices when looking for tennis\n\n @prices = @prices.uniq\n end", "def fetch_market_prices(ids)\n rescue_metrics_down_with({}, stat_timeout) do\n scatter_gather_batch(ids) do |ids_slice|\n raw = JSON.parse(resource['product_stats'].post(:ids => ids_slice))\n # Preserve misses, which are a nil stat\n hashmap(raw) {|stat| stat && MarketPrice.new(stat)}\n end\n end\n end", "def below_price\n puts \"Enter your budget\"\n p = gets.chomp \n dish = RestaurantDish.find_by(price: p.to_i ).dish_id\n\n pp \"You can afford a \" + (Dish.find_by(id: dish).name) \n\n\nend", "def get_price\n item_prc_1\n end", "def get_disputes(opts = {})\n data, _status_code, _headers = get_disputes_with_http_info(opts)\n data\n end", "def price( items )\n self.parser.price(items)\n end", "def index\n @restaurant = Restaurant.find(restaurant_id)\n @dishes = Dish.where(restaurant_id: restaurant_id).all\n end", "def sales_price\n Dowstore.priceMarkup(commodity.price,0,2)\n end", "def add_dish(list_of_dishes)\n list_of_dishes.each do |dish, qty|\n ordering.add(dish, qty)\n end\n end", "def prices\n return @prices unless @prices.nil?\n\n base_price = @random.int(90..110)\n formula = Formula.create(@pattern, base_price, @random)\n @prices = formula.exec\n end", "def price\n hash[\"Price\"]\n end", "def display_price\n\t variations = self.variations.find(:all, :order => \"price ASC\")\n\t if variations.size == 0\n\t return self.price\n\t else\n\t low_price = variations[0].price\n\t high_price = variations[variations.size-1].price\n if low_price == high_price\n return low_price\n else\n return [low_price, high_price]\n end\n end\n end", "def price_fluc\n # return nil when current price is unavailable\n return nil if kindle_price == -1\n\n price_changes = prices(:order => [:retrieved_at.desc])\n\n # defensive code, this case is incorrect\n return nil if price_changes.empty?\n\n if price_changes.length == 1 # only 1 price, no fluc\n []\n else\n [price_changes[1], price_changes[0]]\n end\n end", "def total_duties_price\n hash[\"TotalDutiesPrice\"]\n end", "def format_rations_with_days\n @daily_rations.map do |e|\n [ e.dish_id,\n e.dish.title,\n e.dish.price,\n e.quantity,\n e.daily_menu.day_number ]\n end\n end", "def index\n @prices = Price.all\n end", "def index\n @prices = Price.all\n end", "def get_list\r\n Butterfly::Scraper.scrape_chairs\r\n @chairs = Butterfly::Chair.all\r\n end", "def product_price_list\n $tracer.trace(__method__)\n #unit_test_no_generate: product_price_list, section.with.className(\"product_buy\").find.tr; GameStopMobileProductDetailPriceList\n return GameStopMobileProductDetailPriceList.new(\n ToolTag.new(section.with.className(\"product_buy\").find.tr, __method__, self), self)\n end", "def getDiscs(types)\n\tdiscs = Array.new\n\n\t@discs_doc.elements.each('acda-discs/disc') { |elem|\n\t\tdisc = parseDisc(elem, types)\n\t\tdiscs.push disc\n\t}\n\n\tdiscs\nend", "def request_raw_prices\n Ds::Pim::Api.get_product_offering_prices @offering_id # Array\n end", "def index\n @discs = Disc.all\n end", "def stock\n sql = \"SELECT * FROM cars\n WHERE shop_id = $1\"\n value = [@id]\n cars = SqlRunner.run(sql, value)\n result = cars.map{|car| Car.new(car)}\n return result\n end", "def market_data\n endpoint = \"#{HOST}/v1/cryptocurrency/listings/latest\"\n get(endpoint)\n end", "def price_disc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::PriceDisc::PriceDiscRequestBuilder.new(@path_parameters, @request_adapter)\n end", "def index\n @dishes = Dish.all\n @dish = Dish.new\n end", "def get_prices(brand)\n\t prices = []\n\t $products_hash[\"items\"].each do |item|\n\t item[\"purchases\"].each do |purchase|\n \t if verify_brand?(brand, item)\n \t prices << purchase[\"price\"]\n \t end\n \t end\n\t end\n\t prices\n\tend", "def show\n @store = Store.find(params[:store_id])\n @dish_discount = @store.dish_discounts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dish_discount }\n end\n end", "def index\n @discounts_products = DiscountsProduct.all\n end", "def index\n @cryptocurrency_prices = CryptocurrencyPrice.all\n end", "def index\n @dish_ratings = DishRating.all\n end", "def cours\n\n\trequire 'nokogiri'\n\trequire 'open-uri'\n\n\tnam= []\n\txprice= []\n\thash_cours={}\n\n# Fetch and parse HTML document\n\tdoc = Nokogiri::HTML(open('https://coinmarketcap.com/all/views/all/'))\n\n\n\tdoc.search('td.no-wrap.currency-name > a').each do |link|\n \t\tnam << link.content\n\tend\n\n\n\n\tdoc.css('a[class=price]').each do |link|\n \t\txprice << link.content\n\tend\n\n\thash_cours=[nam.zip(xprice)]\n\nreturn hash_cours\nend", "def dark_trader\n\n url = 'https://coinmarketcap.com/all/views/all/'\n unparsed_page = HTTParty.get(url)\n parsed_page = Nokogiri::HTML(unparsed_page.body)\n cryptos = []\n crypto_listings = parsed_page.css('tr.cmc-table-row') #crypto_listings.count => 200 | we get an array af 200 elements\n crypto_listings.each do |crypto_listing|\n crypto = {\n crypto_listing.css('a.cmc-table__column-name--symbol').text =>\n crypto_listing.css('td.cmc-table__cell--sort-by__price').text.gsub('$','').gsub(',', '').to_f\n }\n cryptos << crypto\n end\n return cryptos\nend", "def vendor_prices(card_name, set_name=nil)\n request_params = {p: card_name, v: 8} # Default to the maximum of 8 results\n request_params[:s] = set_name unless set_name.to_s.strip.empty?\n response = get('/pv.asmx/p', request_params)\n @logger.info(\"RESPONSE #{response}\") if @logger\n raise response['error']['message'] if response['error']\n return response['prices']\n end", "def scrap(item)\n items = []\n html_file = open(\"https://www.etsy.com/fr/search/clothing?q=#{item}\")\n html_doc = Nokogiri::HTML(html_file)\n html_doc.search('.card-meta').each do |title|\n item_name = title.search(\".card-title\")[0].text.strip\n item_price = title.search(\".currency\")[0].text.to_f\n items << {name: item_name, price: item_price}\n end\n return items.first(10)\nend", "def listCandies()\n @shelves.each { |shelf|\n shelf.getCandies.each{ |candy|\n puts candy.getName\n }\n }\n end", "def share_prices\n stock_market.market.first\n end", "def index\n # @prices = Price.where(name:['木瓜(元/公斤)','蘿蔔(元/公斤)','香菇(太空包)乾(元/公斤)']).order(:name)\n @prices = Price.order(:name)\n #get_json\n end", "def index\n @fuel_prices = FuelPrice.all\n end", "def price(options)\n request :public, :get, :price, options\n end", "def real_time_quote\n response = Unirest.get(\"http://www.24hgold.com/english/gold_silver_prices_charts.aspx/GetLastValue?sCurrency=USD\", \n headers: { \"Content-Type\" => \"application/json\" }, \n parameters: { :age => 23, :foo => \"bar\" })\n \n response.code # Status code\n response.headers # Response headers\n response.body # Parsed body\n response.raw_body # Unparsed body\n gold_silver_price = JSON.parse(response.raw_body)\n #puts \"from service: \" + gold_silver_price.to_s\n gold_price = gold_silver_price[\"d\"][1][0] + gold_silver_price[\"d\"][1][2..7].gsub(\",\",\".\") \n silver_price = gold_silver_price[\"d\"][6].gsub(/\\s+/,\"\").gsub(\",\",\".\")\n puts gold_price\n #puts silver_price\n [::Forecasting::Quote::from_symbol_and_price(\"GOLD\",gold_price),::Forecasting::Quote::from_symbol_and_price(\"SILVER\",silver_price)]\n end", "def details(skip: 0, take: nil, **opts)\n take_now = (take && take <= MAX_PER_REQUEST) ? take : MAX_PER_REQUEST\n take_later = take - take_now if take\n skip_later = skip + take_now\n\n items = Operations::Prices.new(settings)\n .call(skip: skip, take: take_now, **opts)\n\n return items if (items.count < take_now) || take_later&.zero?\n items + details(skip: skip_later, take: take_later, **opts)\n end", "def dishes_needed\n dishes_requested = host.dishes\n dishes_needed = []\n dishes_requested.each do |dish|\n dishes_needed << dish if dish.user_id == host.id\n end\n end", "def sitting_costs\n [cost_per_night, remote_price].compact\n end", "def index\n @dji_prices = DjiPrice.all.order(\"date desc\").paginate(:page => params[:page], :per_page => 15)\n end", "def index\n @store = Store.find(params[:store_id])\n @dish_discounts = @store.dish_discounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dish_discounts }\n end\n end", "def fetch\n items_distributed = fetch_items_distributed\n\n # Inject the \"onhand\" data\n items_distributed.map! do |item|\n item_name = item[:name]\n\n below_onhand_minimum = if current_onhand_quantities[item_name] && current_onhand_minimums[item_name]\n current_onhand_quantities[item_name] < current_onhand_minimums[item_name]\n end\n\n item.merge({\n current_onhand: current_onhand_quantities[item_name],\n onhand_minimum: current_onhand_minimums[item_name],\n below_onhand_minimum: below_onhand_minimum\n })\n end\n\n items_distributed.sort_by { |item| -item[:distributed] }\n end", "def index\n @vehicle_prices = VehiclePrice.all\n end", "def price\n @price\n end", "def price\n @price\n end", "def show\n @shop_fb_credit_offer = Shop::FbCreditOffer.find(params[:id])\n\n @prices = []\n\n JSON.parse(@shop_fb_credit_offer.prices).each do |o|\n @prices << o\n end\n\n respond_to do |format|\n format.html { render layout: 'empty' }\n format.json { render json: @shop_fb_credit_offer }\n end\n end", "def get_price_entires_by_gateway_id(gateway_id)\r\n valid_id?(gateway_id)\r\n url = CLX.paths[:gateway] + '/' + gateway_id.to_s + '/price'\r\n @http_client.get(url)\r\n end", "def pricing\n request('pricing', :get)\n end", "def random_drink\n # result = open(\"https://www.thecocktaildb.com/api/json/v1/1/random.php\")\n\n def get_json(url)\n respond = RestClient.get(url)\n JSON.parse(respond)\n end\n\n def get_ingredient\n drink_listing = []\n drink_data = get_json(\"https://www.thecocktaildb.com/api/json/v1/1/random.php\")['drinks'].each {|drink, ingr|ingr}.map {|name| name.values}\n\n drink_name = drink_data[0][1]\n drink_type = drink_data[0][21...35]\n drink_type = drink_type.reject do |data|\n data.empty?\n end.join(\", \")\n \"Your drink is a '#{drink_name}' and it is made from #{drink_type}\"\n # \"It is #{drink_type}\"\n # drink_listing\n end\n puts get_ingredient\n #option to save it to a list???\nend", "def get_value_of_shelf\n value = DATABASE.execute(\"SELECT price, quantity FROM products WHERE shelf_id = #{@id}\")\n \n value.each do |x|\n shelf_value += x[:quantity] * x[:price]\n end\n shelf_value\n end", "def print_client_total\n puts \"Total of all stocks held: \"\n # odd = stocks.select.each_with_index { |str, i| i.even? } \n # puts stocks.price\n # puts Hash[*stock_splits = stocks.map { |x| x.to_s.split(' ') }]\n # puts Hash[*stocks]\n end" ]
[ "0.65727437", "0.62177855", "0.620673", "0.6099644", "0.6045481", "0.60226953", "0.59932965", "0.5928427", "0.5899748", "0.58992505", "0.5818574", "0.5818574", "0.5818574", "0.58117384", "0.57902557", "0.5782728", "0.57309794", "0.56644607", "0.56474084", "0.5611582", "0.56084216", "0.56004757", "0.5594043", "0.55693465", "0.55546445", "0.5537956", "0.5520214", "0.551785", "0.55038583", "0.5500736", "0.5489932", "0.54867953", "0.5477225", "0.54675007", "0.5426913", "0.5411108", "0.54017913", "0.53970724", "0.5370156", "0.5367551", "0.53665817", "0.53562593", "0.53512585", "0.5347706", "0.5336715", "0.53234226", "0.5318975", "0.5312078", "0.5281342", "0.526996", "0.52671444", "0.52597076", "0.5241688", "0.52368027", "0.52258754", "0.52237797", "0.5220917", "0.52189183", "0.52147233", "0.5212187", "0.52085876", "0.52085876", "0.52039224", "0.5189496", "0.51851463", "0.5177229", "0.5171967", "0.5165655", "0.5153423", "0.51368636", "0.5136195", "0.5132383", "0.5130861", "0.51205915", "0.51153564", "0.51118046", "0.51093036", "0.51086825", "0.5106465", "0.51030535", "0.5090592", "0.50878865", "0.50829124", "0.50807136", "0.50759107", "0.5071308", "0.50684017", "0.50620735", "0.5059771", "0.5056019", "0.5047775", "0.50350904", "0.5033286", "0.50237274", "0.50237274", "0.5023474", "0.5019913", "0.5006799", "0.5004418", "0.5003446", "0.5001957" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_chart @chart = Chart.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 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 setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def 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 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 startcompany(action)\n @done = true\n action.setup\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 setup\n #implement in subclass;\n end", "def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def 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 shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
Only allow a trusted parameter "white list" through.
def chart_params params.require(:chart).permit(:name, :birth_date, :is_female) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def allowed_params\n ALLOWED_PARAMS\n end", "def expected_permitted_parameter_names; end", "def param_whitelist\n [:role, :title]\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def permitted_params\n []\n end", "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def filtered_parameters; end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n [:rating, :review]\n end", "def valid_params?; end", "def permitted_params\n declared(params, include_missing: false)\n end", "def permitted_params\n declared(params, include_missing: false)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def filter_parameters; end", "def filter_parameters; end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def check_params; true; end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def list_params\n params.permit(:name)\n end", "def check_params\n true\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def additional_permitted_params\n []\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end", "def allow_params_authentication!; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end", "def quote_params\n params.permit!\n end", "def list_params\n params.permit(:list_name)\n end", "def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end", "def all_params; end", "def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end", "def source_params\n params.require(:source).permit(all_allowed_params)\n end", "def user_params\n end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def params; end", "def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end", "def permitted_params\n @wfd_edit_parameters\n end", "def user_params\r\n end", "def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end", "def params_permit\n params.permit(:id)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def filter_params\n params.permit(*resource_filter_permitted_params)\n end", "def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end", "def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend", "def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end", "def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def argument_params\n params.require(:argument).permit(:name)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end", "def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end", "def parameters\n nil\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end", "def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end", "def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end" ]
[ "0.7121987", "0.70541996", "0.69483954", "0.6902367", "0.6733912", "0.6717838", "0.6687021", "0.6676254", "0.66612333", "0.6555296", "0.6527056", "0.6456324", "0.6450841", "0.6450127", "0.6447226", "0.6434961", "0.64121825", "0.64121825", "0.63913447", "0.63804525", "0.63804525", "0.6373396", "0.6360051", "0.6355191", "0.62856233", "0.627813", "0.62451434", "0.6228103", "0.6224965", "0.6222941", "0.6210244", "0.62077755", "0.61762565", "0.61711127", "0.6168448", "0.6160164", "0.61446255", "0.6134175", "0.6120522", "0.6106709", "0.60981655", "0.6076113", "0.60534036", "0.60410434", "0.6034582", "0.6029977", "0.6019861", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.6019158", "0.60184896", "0.60157263", "0.6005857", "0.6003803", "0.60012573", "0.59955895", "0.5994598", "0.5993604", "0.5983824", "0.5983166", "0.5977431", "0.597591", "0.5968824", "0.5965953", "0.59647584", "0.59647584", "0.59566855", "0.59506303", "0.5950375", "0.59485626", "0.59440875", "0.5930872", "0.5930206", "0.5925668", "0.59235454", "0.5917905", "0.59164816", "0.5913821", "0.59128743", "0.5906617", "0.59053683", "0.59052664", "0.5901591", "0.58987755", "0.5897456", "0.58970183", "0.58942604" ]
0.0
-1
Repo branches repo String Returns Array of String
def branches(repo) api.branches(repo).index_by(&:name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def branch_list\n raw_branches = `cd #{project_repo_path} && git branch -r`\n branches = raw_branches.split(/\\n/)\n return branches\n end", "def all_branches\n %x( git branch ).gsub!('*', '').gsub!(' ', '').split(\"\\n\")\nend", "def branches\n client.branches(repo)\n end", "def git_branches(git)\n array = Array.new\n body = raw_file(http_uri + git)\n body.scan(/\" title=\".*>(.*)<\\/a><\\/li>/) do |branch|\n array << branch\n end\n array.flatten\n end", "def get_repository_project_branches(repoName)\n self.log(INFO, repoName, \"Searching for project branches...\")\n branches = []\n b=`git branch -r`\n b.each_line do |remoteBranch|\n remoteBranch.gsub!(/\\n/, \"\")\n if remoteBranch =~ /origin\\/project/\n localBranch = \"#{remoteBranch}\"\n localBranch.slice! \"origin/\"\n branches << localBranch.strip! || localBranch\n end\n end\n self.log(INFO, repoName, \"Project branches found : #{branches}\")\n self.log(INFO, repoName, \"Done.\")\n return branches\n end", "def local_branches(repo_path)\n result = []\n `(cd \"#{repo_path}\" && git branch | cut -c3-)`.split(\"\\n\").each do |branch|\n result << branch unless `(cd #{repo_path} && git log -1 --pretty=full #{branch})` =~ /git-svn-id:/\n end\n result\n end", "def all_branches\n @branches ||= git_call('branch -a').split(\"\\n\").collect { |s| s.strip }\n end", "def list\n Dir.chdir @root do\n cmd = \"git branch\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n return stdout.split.map { |s|\n # Remove trailing/leading whitespace and astericks\n s.sub('*', '').strip\n }.reject { |s|\n # Drop elements created due to trailing newline\n s.size == 0\n }\n end\n end", "def branches\n @branches ||= get(\"/repos/show/#{owner.login}/#{name}/branches\")['branches'].map do |name, head|\n Branch.new(connection, \n :name => name,\n :head => head,\n :repo => self\n )\n end\n end", "def get_branch_names(repo)\n repo.heads.collect(&:name)\n end", "def branches\n @branches = config.fetch('branches', ['master'])\n end", "def branches\n @branches = config.fetch('branches', ['master'])\n end", "def ls_branches\n working_branches = get_branches\n if working_branches.empty?\n $stdout.puts \"No branches\"\n exit\n end\n working_branches.map.with_index { |branch, idx| \"#{idx}. #{branch}\" }\nend", "def remote_branches\n @rugged_repository.branches.each_name(:remote).sort\n end", "def list\n Rugged::Branch.each_name(@git, :local).to_a\n end", "def get_target_branches\n unless @target_branches\n fetch_all\n base = @config['branches']['production']\n allowed_branches = @config['branches'].values\n allowed_branches << @config['prefixes']['release'] if @config['prefixes']['release']\n banned_branches = ['HEAD']\n target_branches = `git branch -r origin/#{base} | grep -ie '\\\\(#{allowed_branches.join(\"\\\\|\")}\\\\)' | grep -iv '\\\\(#{banned_branches.join(\"\\\\|\")}\\\\)' | sed -e 's/origin\\\\///g'`\n @target_branches = target_branches.split(\"\\n\").map{|a| a.gsub(/\\s+/, \"\")}\n end\n @target_branches\n end", "def refs\n select_branches(git.grit.refs)\n end", "def branches\n @branch_heads.keys\n end", "def repo_elements\n elements = @url.gsub('https://github.com/', '').split('/').compact.map(&:strip)\n end", "def remote_branches\n @remote_branches ||= @project.branches.remote.map(&:full)\n end", "def fetch_branches\n refs = @github_client.fetch_refs(@repo_user,@repo_name) \n branch_refs = filter_branch_refs refs \n branch_refs = fetch_and_set_dates(branch_refs)\n branch_refs = sort_by_date(branch_refs) \n branches(branch_refs)\n end", "def branches\n zombie_check\n pattern = self.class.branch_pattern(:name => @name)\n @repo.branches.select{ |b| b.name =~ pattern }\n end", "def build_branch_list\n local_branches = `git branch`.split(' ')\n active_branch_index = local_branches.index('*')\n\n local_branches.reject { |i| i == '*' }.map.with_index do |b, i|\n BranchModel.new(b, i == active_branch_index)\n end\n end", "def retrieve_branch_details(branches)\n\t\tdetails = []\n\t\tIO.popen(\"-\", \"r+\") do |io|\n\t\t\tif io.nil?\n\t\t\t\targs = [ \"show\", \"--pretty=format:%H\\t%d\\t%ct\\t%cr\\t%an\\t%s\", *branches ]\n\t\t\t\targs << \"--\"\n\t\t\t\texec \"git\", *args\n\t\t\telse\n\t\t\t\twhile l = io.gets\n\t\t\t\t\tnext unless l =~ /^[a-z0-9]{40}/\n\t\t\t\t\thash, refs, time, rtime, author, subject = * l.chomp.split(/\\t/)\n\t\t\t\t\trefs.gsub!(/^\\s*\\(|\\)\\s*$/, '')\n\n\t\t\t\t\trefs.split(/\\s*,\\s*/).each do |ref|\n\t\t\t\t\t\tis_remote = ref[%r{refs/remotes}]\n\t\t\t\t\t\tref.gsub!(%r{refs/(remotes|heads)/}, '')\n\t\t\t\t\t\tdetails.push Ref.new(hash, ref, time.to_i, rtime, author, subject)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tdetails\n\tend", "def branches\n @branches ||= build_branches\n end", "def branches\n object.branches.map { |b| b.id }\n end", "def all_branches\n git(\"branch --all\")\n end", "def remote_branches(remote)\n run(\"git branch -r\").split(\"\\n\")\n .map { |r| r.chomp.gsub(/^\\s+/, \"\") }\n .select { |r| r[remote] && ! r[\"HEAD\"] }\n .map { |r| r.gsub(\"#{remote}/\", \"\") }\n end", "def get_commits(repo, branch)\n # Downcase the strings\n repo.downcase!\n branch.downcase!\n\n # Make sure we're ending with a trailing / on the repo\n repo << '/' unless repo[repo.size - 1] == '/'\n\n # The full path for a call is:\n # https://api.github.com/repos/avalonmediasystem/avalon/commits/master/\n # The user may or may not have called with the /commits/ part since we don't\n # specifically require it\n # Determine if it is present, add it if it is not\n commits = 'commits/'\n last_char_pos = repo.size\n repo << commits unless repo[last_char_pos - commits.size..last_char_pos - 1] == commits\n\n # Use Rest Client to call the Github API and return it as JSON\n api_call = repo + branch\n resp = rest_client_get(api_call)\n return JSON.parse(resp) unless resp.nil?\n end", "def branches(repo, options = {})\n paginate \"#{Repository.path repo}/branches\", options\n end", "def revlist\n (`git rev-list --all`).split(\"\\n\")\n end", "def merge_branches\n Array(Configuration.merge_branch(deploy_type))\n end", "def branches\n Git::Branches.new(self)\n end", "def repo_commits(repos)\n repos_commits = []\n repos.each do |repo|\n repos_commits << HTTParty.get(repo[\"commits_url\"].gsub(\"{/sha}\", \"\"))[0]\n end\n repos_commits\nend", "def repoSlug()\n return ENV['HOMEBREW_PIPELINE_FORMULA_REPO'].split('/')\n end", "def create_branches(repo)\n @branch_names.collect {|branch_name| \n Branch.new(branch_name ,Grit::Commit.find_all(repo, branch_name).sort_by { |k| k.authored_date}.reverse)}\n end", "def local_branches\n @local_branches ||= begin\n branches = []\n if not git.branches.local.empty?\n branches << git.branches.local.select{ |b| b.current }[0].name\n branches << git.branches.local.select{ |b| not b.current }.map{ |b| b.name }\n end\n branches.flatten\n end\n end", "def branches(user_name, repo_name, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless (user? && repo?)\n normalize! params\n\n response = get_request(\"/1.0/repositories/#{user}/#{repo.downcase}/branches/\", params)\n return response unless block_given?\n response.each { |el| yield el }\n end", "def branch(group:nil)\n case group\n when :remote\n flag = \"-r\"\n when :all\n flag = \"-a\"\n when nil, :local\n flag = \"\"\n end\n\n `git branch #{flag}`.lines.map do |line|\n fields = line.split\n\n if fields.first['*']\n fields[1].strip\n else\n fields.first.strip\n end\n end\nend", "def static_list_repositories\n %w[https://github.com/iwc-workflows/sars-cov-2-variation-reporting.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-artic-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-ont-artic-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-se-illumina-wgs-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-wgs-variant-calling.git\n https://github.com/iwc-workflows/parallel-accession-download.git\n https://github.com/iwc-workflows/sars-cov-2-consensus-from-variation.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-artic-ivar-analysis.git\n https://github.com/iwc-workflows/fragment-based-docking-scoring.git\n https://github.com/iwc-workflows/protein-ligand-complex-parameterization.git\n https://github.com/iwc-workflows/gromacs-mmgbsa.git\n https://github.com/iwc-workflows/gromacs-dctmd.git].map { |r| { 'clone_url' => r }}\n end", "def repos\n pry(Git::Multi.repositories)\nend", "def fetch_commit_hash_list()\n `git rev-list --all --reverse`.strip.split(/\\n/)\nend", "def find_repos( datasets )\n repos = []\n datasets.each do |dataset|\n league_key = dataset[0]\n league = Writer::LEAGUES[ league_key ]\n pp league\n path = league[:path]\n\n ## use only first part e.g. europe/belgium => europe\n repos << path.split( %r{[/\\\\]})[0]\n end\n pp repos\n repos.uniq ## note: remove duplicates (e.g. europe or world or such)\nend", "def test_branches_all\n branches = @lib.branches_all\n assert(branches.size > 0)\n assert(branches.select { |b| b[1] }.size > 0) # has a current branch\n assert(branches.select { |b| /\\//.match(b[0]) }.size > 0) # has a remote branch\n assert(branches.select { |b| !/\\//.match(b[0]) }.size > 0) # has a local branch\n assert(branches.select { |b| /master/.match(b[0]) }.size > 0) # has a master branch\n end", "def project_names\n repositories.map { |s| s.match(/[^\\/]*$/)[0] }\n end", "def branches\n if ancestor_ids.empty? then\n nil\n else\n read_attribute(self.base_class.structure_column).to_s.split(',')\n end\n end", "def repo_to_uri(repo)\n\tif @bigboy.key?(repo.to_sym)\n\t\tif @bigboy[repo.to_sym].is_a?(Array)\n\t\t\tputs \"\\nThe URIs for \" + \"#{ARGV[0]}\".red + \" are: \"\n\t\t\t@bigboy[repo.to_sym].each { |n| puts n.green }\n\t\telse\n\t\t\tputs \"\\nThe URI for \" + \"#{ARGV[0]} \".red + \"is \" + \" #{@bigboy[repo.to_sym]}\".green\n\t\tend\n\telse\n\t\tputs \"\\nSorry, I can't find that repo.\".magenta\n\tend\nend", "def get_all_commits_in_repo\n @branches.collect(&:commits).flatten.sort_by { |k| k.authored_date }.reverse\n end", "def list\n @repos\n end", "def recent_branches_fast\n\t\trefs = []\n\t\trefs.concat Pathname.glob(dot_git + 'refs/heads/**/*')\n\t\trefs.concat Pathname.glob(dot_git + 'refs/remotes/**/*')\n\n\t\tbranches = refs.reject {|r| r.directory? }.sort_by {|r| r.mtime }.last(@opts[:max_num]).map {|r|\n\t\t\tref = r.read.chomp\n\t\t\tif name = ref[/ref: (.+)/, 1]\n\t\t\t\tbegin\n\t\t\t\t\t(dot_git + name).read.chomp\n\t\t\t\trescue\n\t\t\t\t\t`git rev-parse #{name}`.chomp\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tref\n\t\t\tend\n\t\t}\n\t\tretrieve_branch_details(branches)\n\tend", "def get_branches\n xml = call(:branches).parsed_response\n xml.css('branches branch').map { |b| Branch.new(b, self) }\n end", "def get_merged(br)\n __branches \"-l --merged #{br}\"\nend", "def branch_targets\n []\n end", "def files_in branch:\n array_output_of(\"git ls-tree -r --name-only #{branch}\")\nend", "def ref_names(repo)\n refs(repo).map do |ref|\n ref.sub(%r{^refs/(heads|remotes|tags)/}, \"\")\n end\n end", "def branches(type = :master, dir = Dir.pwd, _options = {})\n FalkorLib::Git.config(\"gitflow.branch.#{type}\", dir)\n #confs[type.to_sym]\n end", "def list_repo(repo_id)\n response = HTTParty.get(\n GIT_BASE_URL + 'projects/' + repo_id.to_s,\n :headers => {\n 'PRIVATE-TOKEN' => GIT_TOKEN\n }\n )\n Rails.logger.info \"Git server response (list repo): #{response}\"\n return response['content']\n end", "def branch\n %x[cd #{repo_path};git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}].chomp\n end", "def find_branch(repo_slug, pattern)\n list = `git ls-remote --heads --sort=version:refname https://github.com/#{repo_slug} #{pattern}`\n list.split(\"\\n\")\n .map { |line| line.sub(%r{[0-9a-f]+\\trefs/heads/}, '').chomp }\n .last # Latest ref found, in \"version:refname\" semantic order\n end", "def get_repos\n\t\trepo_list = []\n\t\tparsed_config = begin\n\t\t\tYAML.load(File.open(@path_to_config_yml))\n\t\trescue ArgumentError => e\n \t\t\tputs \"Could not parse YAML: #{e.message}\"\n\t\tend\n\t\tparsed_config['sections'].each do |section|\n\t\t\trepo_list.push(section['repository']['name'].gsub(/\\w*-?\\w*\\//,''))\n\t\tend\n\t\trepo_list.sort\n\tend", "def find_branch(repo, branch)\n name, num = branch.split('-')\n\n variations = [ branch, \"#{name}#{num}\", \"#{name}_#{num}\" ]\n\n branches = %x( cd #{repo} ; git branch --list ).gsub('*', '').split(\"\\n\")\n branches.each do |b|\n b.strip!\n variations.each do |v|\n return b if (b == v)\n end\n end\n\n return nil\nend", "def git_remotes\n @git_remotes ||= (File.read(git_directory / :config).scan(/\\s*url\\s*=\\s*(.*)\\n/).flatten.collect do |url|\n case url\n when %r{(github.com)[:/](.+)/(.+)/?\\.git$} then [$3, \"GitHub\", \"http://#$1/#$2/#$3\", \"http://#$1\"]\n when %r{(codaset.com)[:/](.+)/(.+)?\\.git$} then [$3, \"Codaset\", \"http://#$1/#$2/#$3\", \"http://#$1\"]\n when %r{(gitorious.org)[:/](.+)/.+/?\\.git$} then [$2, \"Gitorious\", \"http://#$1/#$2\", \"http://#$1\"]\n end\n end).compact\n end", "def repos\n @client.repos.all.collect(&:clone_url)\n end", "def repos\n api.repos.map(&:to_hash)\n end", "def remotes\n select_branches(git.grit.remotes)\n end", "def branches\n if ancestor_ids.empty? then\n nil\n else\n read_attribute(self.base_class.ancestry_column).to_s.split(',')\n end\n end", "def branches(*nodes)\n branches = []\n nodes = [changelog.tip] if nodes.empty?\n # for each node, find its first parent (adam and eve, basically)\n # -- that's our branch!\n nodes.each do |node|\n t = node\n # traverse the tree, staying to the left side\n # node\n # / \\\n # parent1 parent2\n # .... ....\n # This will get us the first parent. When it's finally NULL_ID,\n # we have a root -- this is the basis for our branch.\n loop do\n parents = changelog.parents_for_node t\n if parents[1] != NULL_ID || parents[0] == NULL_ID\n branches << [node, t, *parents]\n break\n end\n t = parents.first # get the first parent and start again\n end\n end\n \n branches\n end", "def branches; end", "def determine_branch_name(repo)\n name = \"\"\n repo.branches.each do |branch|\n if branch.head?\n name = branch.name\n break\n end\n end\n return name\nend", "def get_repo_status\n args = {:clone => CONFIG[\"local\"][\"clone\"]}\n st = `#{Templates.status(args)}`\n current_branch = st.split(\"\\n\")[0][3..-1].split(\"...\")[0]\n modified_files = st.split(\"\\n\")[1..-1].join(\"\\n\")\n [current_branch, modified_files]\n end", "def get_tags\n @logger.info(\"#{__method__}: Getting tags from git\")\n output = `cd #{@conf.clone_path} && git tag`\n tags = output.split(\"\\n\")\n tags.each do |t|\n @logger.debug(\"#{__method__}: #{t}\")\n end\n tags\n end", "def get_list\n @list_of_repos\n end", "def filter_branch_refs(refs)\n refs.select do |r|\n ref_name = r[\"ref\"]\n ref_name.start_with? \"refs/heads\"\n end\n end", "def all_repos\n\t\tif GitHosting.multi_repos?\n\t\t repositories\n\t\telse\n\t\t [ repository ].compact\n\t\tend\n\t end", "def get_branch_name\r\n\tputs IO.popen('git branch --no-abbrev').read.slice(2..-1)\r\nend", "def list\n if today?\n commits = commits_today(repo, branch)\n elsif yesterday?\n commits = commits_yesterday(repo, branch)\n elsif this_week?\n commits = commits_this_week(repo, branch)\n elsif last_week?\n commits = commits_last_week(repo, branch)\n elsif this_month?\n commits = commits_this_month(repo, branch)\n elsif after && before\n commits = commits_between(repo, branch, after, before)\n elsif after\n commits = commits_after(repo, branch, after)\n elsif before\n commits = commits_before(repo, branch, before)\n else\n commits = all_commits(repo, branch)\n end\n\n write_json(commits.map(&:to_h))\n end", "def branches_containing_commit(commit_ref); end", "def branches_containing_commit(commit_ref); end", "def repository_names\n list_repos\n .select { |repo| repo[\"name\"] =~ regexp }\n .map { |repo| repo[\"name\"] }\n end", "def name()\n unless @repo_addr\n fn = @@fname\n bn = @@bname\n return [fn, bn]\n else\n return ['', '']\n end\n end", "def team_repositories\n team_profiles.map(&:repositories).flatten\n end", "def git_refs()\n # This glob pattern matches recursively so we will find a branch named\n # something like 'feature/subfeature/the-cool-feature'.\n # TODO: get remotes also\n git_dir = git_git_dir()\n\n locals = Dir.glob(File.join(git_dir, 'refs', 'heads', '**', '*')).select do |f|\n !File.directory? f\n end.map do |f|\n {\n 'name' => f.split('/refs/heads/')[1],\n 'hash' => File.open(f).read().rstrip\n }\n end\n\n remotes = Dir.glob(File.join(git_dir, 'refs', 'remotes', '**', '*')).select do |f|\n !File.directory?(f) and !f.end_with? \"/HEAD\"\n end.map do |f|\n {\n 'name' => f.split('/refs/remotes/')[1],\n 'hash' => File.open(f).read().rstrip\n }\n end\n\n locals + remotes\nend", "def recent_branches_strict\n\t\tbranches = `git branch -a`.gsub!(/^\\*?\\s+|\\(no branch\\)\\s*/, \"\").split(/\\n/).map {|i|\n\t\t\ti.split(/ -> /)[0]\n\t\t}\n\t\tretrieve_branch_details(branches)\n\tend", "def get_repo_paths\n\t\t\tpaths = {}\n\t\t\tpathspec = read_command_output( 'hg', 'paths' )\n\t\t\tpathspec.split.each_slice( 3 ) do |name, _, url|\n\t\t\t\tpaths[ name ] = url\n\t\t\tend\n\t\t\treturn paths\n\t\tend", "def pullFromGitRemotes(branch)\n remotes = `git remote`.split(\"\\n\")\n remotes.each do |remote|\n remote.chomp!\n UI.important(\"Pulling #{branch} from remote: #{branch}\\\"\")\n sh(\"git pull --no-edit #{remote} #{branch}\")\n end\nend", "def extract_branches(decorate, remove_head = true)\n return [] if decorate.blank?\n decorate.strip[1...-1].split(', ').\n reject { |b| remove_head && b == 'HEAD' || b =~ /^tag:\\s/ }\n end", "def all_repos\n if GitHosting.multi_repos?\n repositories\n else\n [ repository ].compact\n end\n end", "def rev_list(*treeishs)\n return treeishs if treeishs.empty?\n sandbox {|git,w,i| git.run('', :rev_list, '', {}, treeishs).split(\"\\n\") }\n end", "def refs(repo)\n repo.refs_hash[id]\n end", "def branch_from_repo_url(repo_url)\n if repo_url =~ /#\\S+[^\\/]/\n @branch = repo_url.split('#')[1]\n else\n @branch = 'master'\n end\n end", "def ostree_branches(id)\n criteria = {:type_ids => [Runcible::Extensions::OstreeBranch.content_type]}\n unit_search(id, criteria).map { |i| i['metadata'].with_indifferent_access }\n end", "def fetch_refs(repo_user,repo_name)\n uri = URI(API_BASE_URL+ \"/repos/#{repo_user}/#{repo_name}/git/refs\")\n body = response_body(uri)\n \n if body.instance_of? Array\n body\n elsif body.key?('message') && body['message'].downcase == \"not found\"\n raise \"Unable to fetch #{uri}\" \n else\n puts \"WARNING unexpected body = #{body}\"\n [] \n end\n end", "def github_repo\n # GitHub allows underscores, hyphens and dots in repo names\n # but only hyphens in user/organisation names (as well as alphanumeric).\n repository_url.scan(/:([A-Za-z0-9-]+\\/[\\w.-]+)\\.git$/).join\n end", "def fetch_svn_urls()\n urls = bot.config['svn_urls']\n commits = []\n urls.each do |url_str|\n begin\n @log.info \"checking #{url_str} for new commits...\"\n\n # https://username:password@svn.host.com:8080/svn/path/in/repo/\n url = Addressable::URI.parse(url_str)\n\n xmldata = `svn log --username #{url.user} --password #{url.password} --xml -v --limit 15 #{url.omit(:user, :password)}`\n doc = REXML::Document.new(xmldata)\n \n doc.elements.inject('log/logentry', commits) do |commits, element|\n commits.push({:url => url}.merge(parse_entry_info(element)))\n end\n\n rescue Exception => e\n @log.error \"error connecting to svn: #{e.message}\"\n end\n end\n return commits\n end", "def branches *path\n return enum_for(:branches, *path) unless block_given?\n self.each_pair do |k,v|\n if k.slice(0, path.size) == path\n sub_key = k - k.slice(0,path.size)\n v = proxy?(v) ? v.deproxy : v\n yield sub_key[0], v unless sub_key.size != 1\n end\n end\n end", "def branch_name\n $repo.current_branch\n end", "def extract_branch_args(branch_args_str)\n branch_args_str.gsub(/\\[|\\]|\\\"/, \"\").split(\", \").map do |elm|\n elm.start_with?(\":\") ? elm.delete(\":\").to_sym : elm.to_i\n end\n end", "def acquire_repo_list\n set_auth\n set_github_repo_name\n repo_list = []\n (@github.repos.list org: GITHUB_ORG).each do |l|\n repo_list << l[:name]\n end\n repo_list\nend", "def combine_multiple_repos_issues\n\t\tall_tagged_issues_array = []\n\t\trepos = ENV[ \"GIT_ISSUES_REPO\" ]\n\t\trepos = repos.split(' ')\n\t\t\n\t\trepos.each do | a |\n\t\t\trepos_issues = get_issues( a, ENV[ \"GIT_LABEL\" ] )\n\t\t\tall_tagged_issues_array.push( repos_issues ).flatten!\n\t\tend\n\t\t\n\t\treturn all_tagged_issues_array\n\tend", "def get_repos project_id\n $logger.info \"Getting repos\"\n\n # from the bitbucket api\n rest_endpoint = \"/rest/api/1.0/projects/#{PROJECT_ID}/repos\"\n\n http = Net::HTTP.new(BASE_GIT_URL, BASE_GIT_PORT)\n repos_request = Net::HTTP::Get.new(\"/rest/api/1.0/projects/#{PROJECT_ID}/repos?limit=1000\")\n repos_request.basic_auth GIT_USER, GIT_PASSWORD\n repos_response = http.request(repos_request)\n repos_response.value\n\n # https://confluence.atlassian.com/bitbucket/what-is-a-slug-224395839.html\n repos_body = JSON.parse(repos_response.body)\n repos = repos_body['values'].map { |v| v['slug'] }\n\n $logger.info \"Found repos #{repos}\"\n\n return repos\nend" ]
[ "0.7788227", "0.74197316", "0.7348036", "0.7294212", "0.7220462", "0.72154063", "0.71461535", "0.71119773", "0.68253976", "0.67720544", "0.6686774", "0.6686774", "0.66657984", "0.6659355", "0.6600116", "0.65570086", "0.6509384", "0.6502099", "0.648939", "0.648908", "0.6470959", "0.63390255", "0.633283", "0.63198024", "0.6314079", "0.6259763", "0.62408453", "0.62326884", "0.61891085", "0.61811197", "0.61211216", "0.60955864", "0.6087239", "0.60541815", "0.6033366", "0.6025908", "0.6018428", "0.6017616", "0.6005376", "0.59801185", "0.5975936", "0.596695", "0.59507513", "0.5936712", "0.59324604", "0.590811", "0.5899168", "0.58891976", "0.58867675", "0.5877579", "0.5859338", "0.5854633", "0.5854509", "0.5837214", "0.5823366", "0.5820081", "0.5814461", "0.5792333", "0.5790583", "0.57617944", "0.57534695", "0.57398987", "0.5733853", "0.5705379", "0.5701514", "0.56975126", "0.5697064", "0.5694228", "0.5671393", "0.5664754", "0.56493825", "0.56478417", "0.5626837", "0.5613093", "0.56096554", "0.55901796", "0.5588677", "0.5587314", "0.5567564", "0.55675155", "0.5563434", "0.5563196", "0.5562837", "0.5555585", "0.55307835", "0.55285144", "0.55103475", "0.5491005", "0.54904443", "0.5451048", "0.54429775", "0.5439642", "0.5437993", "0.543069", "0.5430339", "0.54292506", "0.542445", "0.5424133", "0.54217416", "0.5416066" ]
0.74186575
2
Repo default branch repo String Returns String
def default_branch(repo) api.repository(repo).default_branch end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def default_branch(remote)\n remote_url = `git config remote.#{Shellwords.escape remote}.url`.chomp\n repo_name = begin\n URI.parse(remote_url).path[1..-5]\n rescue ::URI::InvalidURIError\n remote_url.split(':', 2).last[0..-5]\n end\n\n if File.basename(repo_name).end_with? '.github.io'\n 'master'\n else\n 'gh-pages'\n end\n end", "def default_branch\n @default_branch ||= Nokogiri::HTML(open(branches_url)).at_css('tr.base td.name h3').text.strip.chomp\n rescue OpenURI::HTTPError => err\n raise GithubMetadata::RepoNotFound, err.to_s\n end", "def repo_name\n return unless @url\n @repo_name ||= Octokit::Repository.from_url(@url).to_s.chomp('.git')\n end", "def branch_name\n $repo.current_branch\n end", "def repo_name\n # the repo is the last part of the path\n return self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1] if !self.cmd_opt.empty?\n end", "def branch\n %x[cd #{repo_path};git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}].chomp\n end", "def default_repository\n ::RightGit::Git::Repository.new('.', DEFAULT_REPO_OPTIONS)\n end", "def repo_name(repo)\n name = nil\n case repo\n when 'stable'\n name = 'omnibus-stable-local'\n when 'current'\n name = 'omnibus-current-local'\n when nil # pass through\n else\n raise \"#{repo} not supported. must be current or stable\"\n end\n name\nend", "def repo_name\n if self.is_git?\n return self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1] if !self.cmd_opt.empty?\n elsif self.is_hg?\n return self.cmd_opt.split(\" \")[1].split(\"/\")[-1] if !self.cmd_opt.empty?\n end\n end", "def determine_branch_name(repo)\n name = \"\"\n repo.branches.each do |branch|\n if branch.head?\n name = branch.name\n break\n end\n end\n return name\nend", "def repository_name\n Repository.context.any? ? Repository.context.last.name : default_repository_name\n end", "def default_branch\n branch_name = `git symbolic-ref --short refs/remotes/origin/HEAD \\\n | sed 's@^origin/@@'`.strip\n if branch_name.empty?\n $stderr.puts \"Repository configuration error\"\n $stderr.puts \"Missing reference to refs/remotes/origin/HEAD\"\n $stderr.puts \"Run\"\n $stderr.puts\n $stderr.puts \" git remote set-head origin <default branch>\"\n $stderr.puts\n $stderr.puts \"where <default branch> is the default branch name\"\n $stderr.puts \"(typically `main`, `master`, or `trunk`)\"\n $stderr.puts \"and then rerun the command\"\n exit(1)\n end\n @default_branch ||= branch_name\n end", "def full_name repo\n \"#{repo.owner.login}/#{repo.name}\"\n end", "def github_repo\n # GitHub allows underscores, hyphens and dots in repo names\n # but only hyphens in user/organisation names (as well as alphanumeric).\n repository_url.scan(/:([A-Za-z0-9-]+\\/[\\w.-]+)\\.git$/).join\n end", "def branch_name\n @branch_name ||= ENV['GIT_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.chomp\n end", "def repo_name\n unless @repo_name\n url = config[\"remote.#{name}.url\"]\n raise GitProcessError.new(\"There is no #{name} url set up.\") if url.nil? or url.empty?\n uri = Addressable::URI.parse(url)\n @repo_name = uri.path.sub(/\\.git/, '').sub(/^\\//, '')\n end\n @repo_name\n end", "def discover_default_branch\n names = branch_names\n\n return if names.empty?\n\n return names[0] if names.length == 1\n\n if rugged_head\n extracted_name = Ref.extract_branch_name(rugged_head.name)\n\n return extracted_name if names.include?(extracted_name)\n end\n\n if names.include?('master')\n 'master'\n else\n names[0]\n end\n end", "def get_default_repo\n\t\t\tENV[ \"M2_REPO\" ] || File.join( Dir.home, \".m2\", \"repository\" )\n\t\tend", "def repo\n if @repo == NRSER::NO_ARG\n @repo = QB::Repo.from_path root_path\n end\n \n @repo\n end", "def github_repo\n build.repo_name.delete_prefix(\"github_\").tr(\"_\", \"/\")\n end", "def get_repo_url\n repo_url = ENV['MXNET_GLUON_REPO'] || DEFAULT_REPO\n repo_url += '/' if repo_url[-1] != '/'\n repo_url\n end", "def repo_path\n @config.get_value('GIT_REPO_ROOT')\n end", "def branch\n (@options[:branch] || 'master').to_s\n end", "def branch\n (@options[:branch] || 'master').to_s\n end", "def default_branch\n config.deploy_branch\n end", "def discover_default_branch\n now_head = Ref.extract_branch_name(rugged_head.name)\n return now_head if now_head.to_s != \"\"\n\n names = local_branch_names\n if names.length == 0\n nil\n elsif names.include?(\"master\")\n \"master\"\n else\n names.first\n end\n end", "def gitreponame\n g = Git.open(Dir.pwd)\n control_repo = g.config('remote.origin.url').to_s\n control_repo = control_repo.split('/')\n control_repo = control_repo[-1].chomp.split('.')\n control_repo = control_repo[0]\n output = \"\\\"control_repo\\\": \" + '\"' + control_repo + '\",'\n puts output\nend", "def component_repo(cmp)\n component(cmp).fetch('repo', \"#{CONF_DEFAULT_BASE_REPO}/#{cmp}.git\")\nend", "def component_repo(cmp)\n component(cmp).fetch('repo', \"#{CONF_DEFAULT_BASE_REPO}/#{cmp}.git\")\nend", "def repo_name\n @repo_name ||= InchCI::ProjectUID.new(uid).repo_name\n end", "def branch\n 'refs/heads/master'\nend", "def github_repo\n arguments['repo'] || [stage.project.organization.name, stage.project.name].join('/')\n end", "def branch_from_repo_url(repo_url)\n if repo_url =~ /#\\S+[^\\/]/\n @branch = repo_url.split('#')[1]\n else\n @branch = 'master'\n end\n end", "def derive_branch_name\n @config[:git][:branch] == 'preview' ? preview_branches.last : @config[:git][:branch]\n end", "def repoSlug()\n return ENV['HOMEBREW_PIPELINE_FORMULA_REPO'].split('/')\n end", "def github_repo\n self.github_url&.gsub(\"https://github.com/\", \"\")\n end", "def git_repo_name\n path = File.expand_path(File.dirname(__FILE__))\n # the path looks like /repos/bender.git/hooks\n path.split(%r{/})[-2]\nend", "def repo\n read_attribute(:repo).presence || self.original_repo\n end", "def repository_name\n @repository_name ||= \"#{project_name}-boshrelease\"\n end", "def base_sha\n default_branch = client.repo(repo)[:default_branch]\n branches.find { |branch| branch[:name] == default_branch }[:commit][:sha]\n end", "def get_repo_name(repo_id)\n repo_name = client.repository(repo_id).name\n rescue Octokit::NotFound\n \"not available\"\n end", "def branch_remote_name(branch_name)\n `git config branch.#{branch_name}.remote`.strip\n end", "def repo_github_path\n descrip = %x{git remote -v}.match(/^.+git@github\\.com:(.+\\/.+)\\.git/)\n raise \"Could not find a Github remote\" if descrip.nil?\n descrip[1]\n end", "def current_branch\n return @branch unless @branch.blank?\n @branch = case @svninfo.url\n when /trunk/ then \"trunk\"\n when /branches\\/private\\/([^\\/]+)/ then $1\n when /branches\\/([^\\/]+)/ then $1\n when /tags\\/([^\\/]+)/ then $1\n else @config_source[\"branch\"]\n end \n @branch || \"unkown\"\n end", "def current_branch\n hg('branch').to_s.strip\n end", "def initial_ref\n %x[git rev-parse #{branch}].chomp\nend", "def get_branch \n branch = case @os_svninfo['URL']\n when /trunk/ then \"trunk\"\n when /branches\\/private\\/([^\\/]+)/ then $1\n when /branches\\/([^\\/]+)/ then $1\n when /patches\\/([^\\/]+)/ then $1\n when /tags\\/([^\\/]+)/ then $1\n else fail(\"Can't determine which branch I'm operating on\")\n end\n branch\n end", "def gitrepo(repo, name, ref = 'master')\n mod name.split('/').join('-'),\n :git => \"https://#{repo}/#{name}.git\",\n :ref => ref\nend", "def get_repo(repo)\n\t\treturn self.fetch(\"repos/#{repo}\")\n\tend", "def get_branch_name\r\n\tputs IO.popen('git branch --no-abbrev').read.slice(2..-1)\r\nend", "def repo_name\n if @vcs == 'gitlab'\n @data['project']['name']\n elsif @vcs == 'tfs'\n @data['resource']['repository']['name']\n else\n @data['repository']['name']\n end\n end", "def branch\n `git rev-parse --abbrev-ref HEAD`.strip.presence\n rescue\n nil\n end", "def github_repo_name path\n origin = remote_origin_url path\n\n if origin == \"\"\n raise NotGitHubRepo.new \"No remote origin URL: #{path}\"\n end\n\n clone_url = parse_url origin\n\n if clone_url.host.downcase != \"github.com\"\n raise NotGitHubRepo.new \"Not a GitHub repo: #{path}\"\n end\n\n chop_extension chop_leading_slash clone_url.path\n end", "def repo_name(activity)\n activity.parameters[:repo_name] || activity.parameters[:repository_name]\n end", "def repo\n settings.repo\n end", "def repo_path\n if !self.cmd_opt.empty?\n self.fake_path = repo_name\n # real path is something like /jupiler_home/repositories/username/repo_name\n self.real_path = Settings.jup_sh.home + '/' +\n self.username_from_cmd + \"/\" +\n self.fake_path\n return self.real_path\n end\n end", "def repository_name(item)\n repo = repository_value(item) and EmmaRepository.pairs[repo]\n end", "def source_repo\n \"#{@user}/#{@repo}\"\n end", "def repo\n options[:repo]\n end", "def get_publish_branch()\n return ENV['DOCS_PUBLISH_REPO_BRANCH'] || PUBLISH_REPO_BRANCH_DEFAULT\n end", "def repo_path\n DeliveryGolang::Helpers.repo_path(node)\n end", "def branch\n case @vcs\n when 'github'\n if @data.key? 'ref'\n @data['ref'].sub('refs/heads/', '')\n else\n @data['repository']['default_branch']\n end\n when 'gitlab'\n @data['ref'].sub('refs/heads/', '')\n when 'bitbucket-server'\n @data['changes'][0]['refId'].sub('refs/heads/', '')\n when 'bitbucket'\n return @data['push']['changes'][0]['new']['name'] unless deleted?\n\n @data['push']['changes'][0]['old']['name']\n when 'stash'\n @data['refChanges'][0]['refId'].sub('refs/heads/', '')\n when 'tfs'\n @data['resource']['refUpdates'][0]['name'].sub('refs/heads/', '')\n end\n end", "def get_git_branch()\n return `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e \"s/* \\\\(.*\\\\)/\\\\1/\"`.strip\nend", "def get_current_branch_from_git\n %x{ git rev-parse --abbrev-ref HEAD }.chomp\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def path\n \"repos/#{@user}/#{name}\"\n end", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{branch}\"\n branch\nend", "def current_branch\n repo.branches.find(&:head?)\n end", "def current_branch\n %x(git branch | grep '*' | cut -d' ' -f2).chomp\nend", "def github(name, ref = 'master')\n gitrepo \"github.com\", name, ref\nend", "def url_of_git_repo(remote_name)\n `git config remote.#{remote_name}.url`.strip\n end", "def repo_path\n @repo_path ||= Pathname.new(Dir.pwd).descend { |p| break p if (p + '.git').directory? }\n end", "def repo_root; end", "def get_repo(project)\n return 'https://github.com/NuCivic/' + project\n end", "def repo\n settings.site_repo \n end", "def repo_url(path = \"\")\n if @repo.url\n url = URI::parse(@repo.url)\n url.path = (url.path + \"/\" + path).gsub(%r'//+', '/')\n url.to_s\n else\n compose_url \"/svc/repo\", @repo.name, path\n end\n end", "def branch_name\n `git name-rev --name-only HEAD`.strip\n end", "def repo_dir; end", "def branch\n return git_fork_config.branch\n end", "def getProjectName()\n\tcurl = 'git config --local remote.origin.url|sed -n \"s#.*/\\([^.]*\\)\\.git#\\1#p\"'\n\tresult = `#{curl}`\n\treturn result.strip()\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n logger.info \"Deploying branch #{branch}\"\n branch\nend", "def repository_identifier\n \"#{gitolite_repository_name}.git\"\n end", "def parse_repo\n matches = @source_url.match @github_regexp\n return unless matches\n owner = matches[:owner]\n name = matches[:name]\n \"#{owner}/#{name}\"\n end", "def git_project_name\n Pkg::Util.in_project_root do\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{GIT} config --get remote.origin.url\")\n stdout.split('/')[-1].chomp(\".git\").chomp\n end\n end", "def repo_path(node)\n node['delivery_builder']['repo'] || File.expand_path('..', __dir__)\n end", "def select_repo\n remote_urls = %x(git remote -v 2> /dev/null | awk '{print $2}' | uniq).split(\"\\n\")\n remote_urls << (I18n.t :other, scope: :negroku)\n\n question = I18n.t :choose_repo_url, scope: :negroku\n selected_idx = Ask.list question, remote_urls\n\n if selected_idx == remote_urls.length - 1\n question = I18n.t :type_repo_url, scope: :negroku\n Ask.input question\n else remote_urls[selected_idx] end\n end", "def repository_base_url(result)\n if result['slug'] && AppConfig[:use_human_readable_urls]\n url = \"repositories/\" + result['slug']\n else\n url = result['uri']\n end\n\n return url\n end", "def branch(group:nil)\n case group\n when :remote\n flag = \"-r\"\n when :all\n flag = \"-a\"\n when nil, :local\n flag = \"\"\n end\n\n `git branch #{flag}`.lines.map do |line|\n fields = line.split\n\n if fields.first['*']\n fields[1].strip\n else\n fields.first.strip\n end\n end\nend", "def url_or_git\n @url || @git || @svn\n end", "def repository_display\n if ENV['EAD'].present?\n if File.directory?(Rails.root.join(ENV['EAD']))\n return ENV['EAD'].split(\"\\/\")[-1]\n else\n return ENV['EAD'].split(\"\\/\")[-2]\n end\n end\n end", "def branchname\n @branchname ||= self.branch.name\n end", "def gitolite_repository_name\n if (parent_path = get_full_parent_path).empty?\n project.identifier\n else\n File.join(parent_path, project.identifier)\n end\n end", "def abspath\n \"#{repo_base_path}/#{self.git_repo_path}\"\n end", "def determine_branch_or_tag_name(repo)\n name = \"\"\n type = :none\n\n # first check if repo is in detached HEAD state\n if repo.head_detached?\n # check if current commit has a tag\n repo.tags.each do |tag|\n if tag.target.oid == repo.head.target_id\n name = tag.name\n type = :tag\n break\n end\n end\n\n # check if we got a tag name, otherwise it's a wild commit\n if type == :none\n name = repo.head.target_id[0..7]\n type = :commit\n end\n else\n # HEAD is not detached, so we are in a branch\n name = $branch_name\n type = :branch\n end\n\n return { name: name, type: type }\nend" ]
[ "0.75469035", "0.7525122", "0.7379428", "0.7341523", "0.7315713", "0.7303584", "0.7209377", "0.70735836", "0.7045799", "0.703733", "0.70351595", "0.6949105", "0.69330627", "0.69186383", "0.6903201", "0.6899998", "0.68956953", "0.68951356", "0.68821067", "0.6851813", "0.68187857", "0.6809393", "0.68025756", "0.68025756", "0.6782889", "0.6770012", "0.676551", "0.6748085", "0.6748085", "0.6719191", "0.67085916", "0.67085505", "0.67073345", "0.66877955", "0.6659849", "0.66241115", "0.6619468", "0.6564775", "0.65586907", "0.6555137", "0.6524849", "0.65168136", "0.65156233", "0.6510595", "0.647714", "0.6475488", "0.6468982", "0.6464402", "0.6463197", "0.6460932", "0.64231193", "0.6412256", "0.640933", "0.6404365", "0.6401238", "0.6394026", "0.6394", "0.6382906", "0.63782847", "0.63655674", "0.63638085", "0.6352585", "0.63431484", "0.6335176", "0.63220364", "0.63220364", "0.63220364", "0.63220364", "0.63220364", "0.63220364", "0.6316666", "0.63118863", "0.63118863", "0.6290571", "0.62820137", "0.62769866", "0.62735647", "0.62621045", "0.6257282", "0.6248339", "0.62383443", "0.6236854", "0.6234021", "0.62278205", "0.6225401", "0.6221051", "0.62178236", "0.62103415", "0.62026304", "0.62004894", "0.62000746", "0.61970073", "0.61790675", "0.6174233", "0.6173128", "0.6164457", "0.61629343", "0.61537474", "0.6147378", "0.61326796" ]
0.7686027
0
Repo branch latest commit sha repo String branch String (optional) Returns String
def recent_revision(repo, branch = nil) branch ||= default_branch(repo) api.branch(repo, branch).commit.sha end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_branch_sha\n cmd = \"git ls-remote '#@repo_url' | awk '/#@branch/ {print $1}'\"\n puts cmd\n @branch_sha ||= %x[#{cmd}].chomp\n raise 'Could not get branch sha!' unless $?.success?\n @branch_sha\n end", "def newest_svn_commit_on_branch(repo_path, branch)\n `(cd \"#{repo_path}\" && git rev-list -n1 #{branch} --grep=git-svn-id:)`.strip\n end", "def last_commit_sha(branch = @base_branch)\n if branch\n commits(@repo, branch, page: 1, per_page: 1)[0]['sha']\n else\n raise ArgumentError, 'Branch must be specified'\n end\n end", "def commit_hash(branch_or_tag = nil)\n version = 'HEAD'\n working_dir do\n version = git 'rev-parse', branch_or_tag || 'HEAD'\n end\n version.strip\n end", "def branch\n %x[cd #{repo_path};git symbolic-ref HEAD 2>/dev/null | awk -F/ {'print $NF'}].chomp\n end", "def commit_hash(branch_or_tag = nil)\n git 'rev-parse', branch_or_tag || 'HEAD'\n end", "def commit_hash(branch_or_tag = nil)\n @version = git 'rev-parse', branch_or_tag || 'HEAD'\n end", "def find_branch(repo_slug, pattern)\n list = `git ls-remote --heads --sort=version:refname https://github.com/#{repo_slug} #{pattern}`\n list.split(\"\\n\")\n .map { |line| line.sub(%r{[0-9a-f]+\\trefs/heads/}, '').chomp }\n .last # Latest ref found, in \"version:refname\" semantic order\n end", "def get_branch_name\r\n\tputs IO.popen('git branch --no-abbrev').read.slice(2..-1)\r\nend", "def latest_commits_from_repo(username, repo_name, author: nil, branch: nil)\n branch ||= default_branch_for_repo(username, repo_name)\n\n doc = doc_from_url(\n github_url_from_username(username) + \"/#{repo_name}/commits/#{branch}?author=#{author}\"\n )\n\n commit_list = doc.css(GITHUB_COMMITS_COMMIT_ITEM_SELECTOR)\n\n commit_list.map do |commit_node|\n copy_to_clipboard_btn = commit_node.search('button.zeroclipboard-button').first\n\n sha = copy_to_clipboard_btn.attributes['data-clipboard-text'].value\n\n sha\n end\nend", "def last_commit(branch_name)\n @rugged_repository.branches[branch_name].target\n end", "def get_latest_lib_branch(rel_branch, repo)\n ver_fields=rel_branch.split('.')\n major_minor=ver_fields[0] + '.' + ver_fields[1]\n\n total_branches=`git ls-remote #{repo} | grep #{major_minor}`\n max_sub_minor_int = 0\n max_sub_minor_str = \"00\"\n total_branches.split('\\n').each do |line|\n subminor = line.split(major_minor)[-1].split('.')[-1]\n subminor_int = subminor.to_i\n if (subminor_int >= max_sub_minor_int)\n max_sub_minor_int = subminor_int\n max_sub_minor_str = subminor\n end\n end\n\n (major_minor + '.' + max_sub_minor_str).chomp!\nend", "def git_last_commit(host, git_repo_path)\n sha_regex = /commit (\\w{40})/\n\n return sha_regex.match(git_on(host, 'log', git_repo_path).stdout)[1]\nend", "def current_branch\n Dir.chdir @root do\n cmd = \"git rev-parse --abbrev-ref HEAD\"\n stdout, stderr, status = Open3.capture3 cmd\n if status != 0\n case stderr\n when /unknown revision/\n raise Error, \"could not determine branch of repo with no commits\"\n when /Not a git repository/\n raise NotARepositoryError\n else\n raise Error, stderr\n end\n end\n return stdout.strip\n end\n end", "def branch\n `git rev-parse --abbrev-ref HEAD`.strip.presence\n rescue\n nil\n end", "def determine_branch_name(repo)\n name = \"\"\n repo.branches.each do |branch|\n if branch.head?\n name = branch.name\n break\n end\n end\n return name\nend", "def branch_name\n $repo.current_branch\n end", "def last_commit(branch, filename)\n lc = @repo.log(branch, filename, {:n => 1})\n lc.empty? ? nil : lc.first\n end", "def sha commit_message\n cmd = \"git reflog --grep-reflog='commit\"\n cmd += ' (initial)' if commit_message == 'Initial commit'\n cmd += \": #{commit_message.strip}' --format='%H'\"\n result = ''\n %w[developer developer_secondary].each do |user|\n next unless result.empty?\n in_repository(user) { result = output_of cmd }\n end\n result\nend", "def human_friendly_branch_information\n return git_fork_config.branch if git_fork_config.branch.to_s.length > 0\n return sha[0...7]\n end", "def base_sha\n default_branch = client.repo(repo)[:default_branch]\n branches.find { |branch| branch[:name] == default_branch }[:commit][:sha]\n end", "def entry_name_from_branch(commit_hash)\n Git::Parser.branch_of_commit(commit_hash).tr('-', ' ')\n end", "def find_branch(repo, branch)\n name, num = branch.split('-')\n\n variations = [ branch, \"#{name}#{num}\", \"#{name}_#{num}\" ]\n\n branches = %x( cd #{repo} ; git branch --list ).gsub('*', '').split(\"\\n\")\n branches.each do |b|\n b.strip!\n variations.each do |v|\n return b if (b == v)\n end\n end\n\n return nil\nend", "def find_commit_for_svn_rev(repo_path, svn_rev, base_branch)\n `(cd \"#{repo_path}\" && git rev-list #{base_branch} --grep=\"git-svn-id:.*@#{svn_rev}\")`.strip\n end", "def get_git_branch()\n return `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e \"s/* \\\\(.*\\\\)/\\\\1/\"`.strip\nend", "def get_commits(repo, branch)\n # Downcase the strings\n repo.downcase!\n branch.downcase!\n\n # Make sure we're ending with a trailing / on the repo\n repo << '/' unless repo[repo.size - 1] == '/'\n\n # The full path for a call is:\n # https://api.github.com/repos/avalonmediasystem/avalon/commits/master/\n # The user may or may not have called with the /commits/ part since we don't\n # specifically require it\n # Determine if it is present, add it if it is not\n commits = 'commits/'\n last_char_pos = repo.size\n repo << commits unless repo[last_char_pos - commits.size..last_char_pos - 1] == commits\n\n # Use Rest Client to call the Github API and return it as JSON\n api_call = repo + branch\n resp = rest_client_get(api_call)\n return JSON.parse(resp) unless resp.nil?\n end", "def branch_name\n `git name-rev --name-only HEAD`.strip\n end", "def git_commit(repo, sha, options = {})\n get \"#{Repository.path repo}/git/commits/#{sha}\", options\n end", "def get_branch \n branch = case @os_svninfo['URL']\n when /trunk/ then \"trunk\"\n when /branches\\/private\\/([^\\/]+)/ then $1\n when /branches\\/([^\\/]+)/ then $1\n when /patches\\/([^\\/]+)/ then $1\n when /tags\\/([^\\/]+)/ then $1\n else fail(\"Can't determine which branch I'm operating on\")\n end\n branch\n end", "def branch_from_repo_url(repo_url)\n if repo_url =~ /#\\S+[^\\/]/\n @branch = repo_url.split('#')[1]\n else\n @branch = 'master'\n end\n end", "def branch_remote_name(branch_name)\n `git config branch.#{branch_name}.remote`.strip\n end", "def commit\n\t$VP.join('.git/refs/heads/master').read[0..8] rescue nil\nend", "def from_commit_sha\n from_sha = nil\n last_commit = nil\n ActiveRecord::Base.connection_pool.with_connection do \n last_commit = RepoCommit.where(supplier_project_repo_id: @repo.id).order(:full_date).first\n end\n from_sha = last_commit.sha if last_commit\n end", "def branch\n case @vcs\n when 'github'\n if @data.key? 'ref'\n @data['ref'].sub('refs/heads/', '')\n else\n @data['repository']['default_branch']\n end\n when 'gitlab'\n @data['ref'].sub('refs/heads/', '')\n when 'bitbucket-server'\n @data['changes'][0]['refId'].sub('refs/heads/', '')\n when 'bitbucket'\n return @data['push']['changes'][0]['new']['name'] unless deleted?\n\n @data['push']['changes'][0]['old']['name']\n when 'stash'\n @data['refChanges'][0]['refId'].sub('refs/heads/', '')\n when 'tfs'\n @data['resource']['refUpdates'][0]['name'].sub('refs/heads/', '')\n end\n end", "def fetch_commit(repo_user,repo_name,sha)\n uri = URI(API_BASE_URL+ \"/repos/#{repo_user}/#{repo_name}/git/commits/#{sha}\")\n body = response_body(uri)\n if body.key?('message') && body['message'].downcase == \"not found\"\n raise \"Unable to fetch #{uri}\" \n else\n body\n end\n end", "def parse_branch(es_branch)\n es_branch.chomp.split('/').last\nend", "def get_last_sha repo, issue\n response = @@connection.get do | request |\n request.url \"repos/#{repo}/pulls/#{issue}\"\n request.headers['Authorization'] = \"token #{@@token}\"\n end\n\n return nil if response.env[:status] != 200\n\n body = MultiJson.load(response.env[:body])\n return body['head']['sha']\n end", "def current_branch\n %x(git branch | grep '*' | cut -d' ' -f2).chomp\nend", "def branch\n @branch ||= `git branch 2> /dev/null`[/\\*\\s(.+)$/, 1]\n end", "def branch\n 'refs/heads/master'\nend", "def branch_name\n @branch_name ||= ENV['GIT_BRANCH'] || `git rev-parse --abbrev-ref HEAD`.chomp\n end", "def get_branch(status = `git status`)\n branch = nil\n if match = Regexp.new(\"^# On branch (.*)\").match(status)\n branch = match[1]\n end\nend", "def fetch_revision(commit)\n `git rev-parse #{commit}`.tr(\"\\n\", '')\n end", "def get_latest_release(project, bin)\n api_url = \"https://api.github.com/repos/#{project}/releases/latest\"\n data = URI.parse(api_url).read\n obj = JSON.parse(data)\n version = obj[\"name\"]\n sha_url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}.sha256\"\n sha = URI.parse(sha_url).read\n url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}\"\n sha256 = sha.split(\" \").first\n\n return url, sha256, version\nend", "def find_svn_rev_for_commit(repo_path, commit)\n `(cd \"#{repo_path}\" && git svn find-rev #{commit})`.strip\n end", "def head_path\n \"#{path}/refs/heads/#{branch}\"\n end", "def initial_ref\n %x[git rev-parse #{branch}].chomp\nend", "def line_uri\n branch.commit_uri.chomp(\"commit/$commit\")\n end", "def github_url\n \"http://github.com/280north/cappuccino/commit/#{sha1}\"\n end", "def commit_sha commit_message\n output_of \"git log --grep='#{commit_message}' --format='%h' -1\"\nend", "def branch\n (@options[:branch] || 'master').to_s\n end", "def branch\n (@options[:branch] || 'master').to_s\n end", "def get_substrate_commit(client, ref)\n cargo = TOML::Parser.new(\n Base64.decode64(\n client.contents(\n ENV['GITHUB_REPOSITORY'],\n path: 'Cargo.lock',\n query: { ref: ref.to_s }\n ).content\n )\n ).parsed\n cargo['package'].find { |p| p['name'] == 'sc-cli' }['source'].split('#').last\nend", "def source_branch\n git_call('branch').chomp.match(/\\*(.*)/)[0][2..-1]\n end", "def git_current_commit_sha\n `git rev-parse HEAD`\n end", "def current_branch\n hg('branch').to_s.strip\n end", "def git_checkout branch\n if branch==false\n return \"true\"\n else\n return \"git checkout -b branch origin/#{branch}\"\n end\n end", "def derive_branch_name\n @config[:git][:branch] == 'preview' ? preview_branches.last : @config[:git][:branch]\n end", "def git_sha_for(path)\n website.git_repository.git_sha path\n end", "def commit_date(sha)\n return unless git_repo? && sha\n Licensed::Shell.execute(\"git\", \"show\", \"-s\", \"-1\", \"--format=%ct\", sha)\n end", "def get_current_branch_from_git\n %x{ git rev-parse --abbrev-ref HEAD }.chomp\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{branch}\"\n branch\nend", "def rev_parse(ref)\n commit = git \"rev-parse #{ref}^{commit}\", :path => @full_path\n commit.chomp\n rescue R10K::ExecutionFailure => e\n logger.error \"Could not resolve ref #{ref.inspect} for git repo #{@full_path}\"\n raise\n end", "def last_commit(js_name)\n sha1 = `git log --pretty=%H -1 #{js_name}` \nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n logger.info \"Deploying branch #{branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def current_git_branch\n branch = `git symbolic-ref HEAD 2> /dev/null`.strip.gsub(/^refs\\/heads\\//, '')\n puts \"Deploying branch #{red branch}\"\n branch\nend", "def branch(group:nil)\n case group\n when :remote\n flag = \"-r\"\n when :all\n flag = \"-a\"\n when nil, :local\n flag = \"\"\n end\n\n `git branch #{flag}`.lines.map do |line|\n fields = line.split\n\n if fields.first['*']\n fields[1].strip\n else\n fields.first.strip\n end\n end\nend", "def branch(repo, branch, options = {})\n get \"#{Repository.path repo}/branches/#{branch}\", options\n end", "def git_sha(length = 40)\n Pkg::Util.in_project_root do\n stdout, _, _ = Pkg::Util::Execution.capture3(\"#{GIT} rev-parse --short=#{length} HEAD\")\n stdout.strip\n end\n end", "def git_ref\n `git rev-parse --short HEAD`.strip\nend", "def recent_builds_branch(branch, params)\n CircleCi.request(@conf, \"/project/#{username}/#{project}/tree/#{branch}\", params).get\n end", "def parse_branch(es_branch)\n es_branch.chomp.split(/-|\\//).last\nend", "def recent_builds_branch(branch, params = {})\n CircleCi.request(conf, \"#{base_path}/tree/#{branch}\", params).get\n end", "def commit\n @commit ||= $repo.log.object(@rev || 'master').path(@name).first\n end", "def cache_repository_revision\n logger.info cache_repository_path.inspect\n File.exists?(cache_repository_path) ? `cd #{cache_repository_path} && git rev-parse --short #{branch}`.strip : \"<em>uncached</em>\".html_safe\n end", "def head_path\n \"#{git_path}/refs/heads/#{branch}\"\n end", "def commit(repo, sha, options = {})\n get \"#{Repository.path repo}/commits/#{sha}\", options\n end", "def get_base_tree_for_branch(oauth_token, head_sha)\n client = Octokit::Client.new(access_token: oauth_token)\n client.commit(full_repo_name, head_sha)[:commit][:tree][:sha]\n end", "def get_commit_log(last_version)\n range = \"v#{last_version}...\"\n `git log #{range} --no-merges --pretty=format:'%H\\t%s\\t%aN\\t%ad'`.chomp\nend", "def determine_submodule_sha\n stdout.out_success \"\\nFirst, I'll determine the sha for the HEAD of branch: '#{settings['target_submodule_target_branch']}' for the submodule to be updated.\"\n stdout.out_success 'With that known, I can determine if a given repo is \"Up to Date\" for that particular submodule.'\n submodule_head_sha = get_sha_for_branch_origin_head\n stdout.out_success(\"\\nDetermined [#{settings['target_submodule_name']}]'s branch [#{settings['target_submodule_target_branch']}]'s HEAD sha to be: #{submodule_head_sha}\")\n submodule_head_sha\n end", "def branch\n return git_fork_config.branch\n end", "def latest\n if !@resource.value(:revision) && (branch = on_branch?)\n branch\n else\n @resource.value(:revision)\n end\n end", "def repo_name\n # the repo is the last part of the path\n return self.cmd_opt.gsub(\"'\",\"\").split(\"/\")[-1] if !self.cmd_opt.empty?\n end", "def git_repo_name\n path = File.expand_path(File.dirname(__FILE__))\n # the path looks like /repos/bender.git/hooks\n path.split(%r{/})[-2]\nend", "def scm_version(ref)\n return nil unless File.exist?(git_dir)\n\n version = `git --git-dir=#{safe_git_dir} describe --tags #{ref}`\n\n if $CHILD_STATUS.to_i.positive?\n # HEAD is not a tagged version, get the short SHA1 instead\n version = `git --git-dir=#{safe_git_dir} show #{ref} --format=format:\"%h\" -s`\n else\n # HEAD is a tagged version, if version is prefixed with \"v\" it will be stripped off\n version.gsub!(/^v/, \"\")\n end\n\n version.strip!\n rescue RuntimeError\n nil\n end", "def current_branch\n repo.branches.find(&:head?)\n end", "def last_commit\n\tresp = github_api(\"commits\")\n\tresp[0]\nend", "def release_hashref\n @release_hashref ||= `git rev-parse HEAD`.chomp\n end", "def getMatchGitBranch(org_id)\n conf = loadIOSConfigFile(org_id)\n return conf['match_git_branch']\nend", "def branch(environment)\n env_path = File.join(@path, \"config/deploy/#{environment}.rb\")\n content = File.read(env_path)\n content.match(REGEX_BRANCH)[1]\n end", "def get_tarball_url(branch)\n puts \"tarballing #{branch}\"\n @github.archive_link(GITHUB_REPO, ref: branch)\n end", "def git_sha_tag\n sha_regexp = /g([0-9a-f]+)$/\n match = sha_regexp.match(git_describe)\n match ? match[1] : nil\n end", "def current_branch\n ref = Rugged::Reference.lookup(@git, 'HEAD').resolve\n if not ref.branch?\n raise Error, \"Not currently on a branch.\"\n end\n ref.name.split('/').last\n end", "def commit(project, sha)\n get(\"/projects/#{project}/repository/commits/#{sha}\")\n end" ]
[ "0.7826191", "0.7736685", "0.75227183", "0.74715585", "0.74659103", "0.71925575", "0.70658815", "0.7027959", "0.7015534", "0.6977012", "0.6944701", "0.6882885", "0.68038183", "0.67691964", "0.67566174", "0.67430663", "0.67346936", "0.67108744", "0.67099273", "0.6691325", "0.6676824", "0.6660505", "0.6657732", "0.6656815", "0.6655337", "0.66535866", "0.65891606", "0.6576225", "0.6562589", "0.65323454", "0.6527349", "0.64965326", "0.64809746", "0.64728636", "0.6452355", "0.6444266", "0.64312595", "0.6422709", "0.64205515", "0.64142525", "0.6406463", "0.64045656", "0.63526696", "0.6330267", "0.63244885", "0.6314516", "0.6312414", "0.63082224", "0.63050425", "0.63034856", "0.6299341", "0.6299341", "0.6295922", "0.629233", "0.62899876", "0.62894905", "0.6287248", "0.6280743", "0.62722737", "0.6268515", "0.6266188", "0.6261184", "0.6261184", "0.6256049", "0.6248528", "0.6241026", "0.6227617", "0.6227617", "0.6227617", "0.6227617", "0.6227617", "0.6227617", "0.62200093", "0.62082285", "0.6173797", "0.6172933", "0.61687005", "0.61659247", "0.61565834", "0.61233026", "0.61147624", "0.608858", "0.6088188", "0.6081724", "0.60657406", "0.6065331", "0.60548156", "0.60351026", "0.6024597", "0.6013759", "0.6004757", "0.6004748", "0.5990309", "0.59884775", "0.59592056", "0.59535223", "0.59533805", "0.59521425", "0.59458065", "0.5944567" ]
0.70099175
9
Create repo hooks repo String endpoint String Yields hook_id Integer
def add_hooks(repo, endpoint) hook = api.create_hook( repo, 'web', { url: endpoint, secret: ENV['GITHUB_SECRET_TOKEN'] }, { events: %w(push pull_request), active: true, } ) yield hook.id rescue Octokit::UnprocessableEntity => error raise unless error.message.include? 'Hook already exists' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_hook!\n hook = client.create_hook(\n full_name,\n 'web',\n {\n url: Constants::HOOK_URL,\n content_type: 'json'\n },\n {\n events: ['release'],\n active: true\n }\n )\n\n self.github_hook_id = hook.id\n end", "def create_hook(lesson)\n client = github_client lesson.user\n resp = client.repos.hooks.create(*hook_params(lesson.owner, lesson.name))\n lesson.hook = resp.id\n rescue Github::Error::ServiceError => e\n Rails.logger.error 'Unable to create hook. Error was %s' % e\n end", "def create_hook(repository, callback_url)\n return unless self.class.enable_hook?\n hook = client.create_hook(repository.full_name, 'web',\n {url: callback_url, content_type: 'json'},\n events: ['push'], active: true)\n yield hook if block_given?\n hook\n rescue Octokit::UnprocessableEntity => e\n if e.message.include? 'Hook already exists'\n true\n else\n raise\n end\n end", "def make_hooks(*args)\r\n make :hook, *args\r\n end", "def get_hook_list(installation_id, repository_name, local_client)\n hook_list = Array.new\n\n begin\n results = local_client.hooks(repository_name, :accept => \"application/vnd.github.machine-man-preview+json\")\n\n # Search for all service hooks on a repository\n results.each do |hook|\n if hook.name != 'web'\n replacement = $service_replacement_list[hook.name]\n hook_list.push({id: hook.id, hook_name: hook.name, replacement: replacement})\n end\n end\n rescue => err\n puts err\n end\n\n hook_list\nend", "def create_webhook(repo, config = {}, options = {})\n opts = options.dup\n opts[:config] = config\n raise Octokit::MissingKey unless config.key? :url\n\n post \"#{Repository.path repo}/hooks\", opts\n end", "def add_hook_for_server_check target, project_name, branch = 'master', log: '/tmp/log', host: 'http://localhost'\n File.open \"#{target}/hooks/post-receive\", 'w' do |file|\n file.write <<-HOOK\n#!/bin/bash\n\nwhile read oldrev newrev refname\ndo\n branch=$(git rev-parse --symbolic --abbrev-ref $refname)\n if [ \"$branch\" == \"#{branch}\" ]; then\n echo \"curl -X PATCH '#{host}/api/projects/#{project_name}/#{branch}'\" >>\"#{log}\"\n curl -X PATCH \"#{host}/api/projects/#{project_name}/#{branch}\" >>\"#{log}\" 2>&1 &\n fi\ndone\n HOOK\n file.chmod 0755\n end\n true\n end", "def set_hook\n @project = Project.find(params[:project_id])\n @new_repo_name = params[:repo_name]\n @new_user_name = params[:user_name]\n\n @is_linked = false\n json_repos = {}\n begin\n json_repos = JSON.parse(@project.repo_name)\n rescue \n end\n json_repos.each do |j|\n if j[\"repo\"] == @new_repo_name\n @is_linked = true\n end\n end\n\n if @is_linked\n @old_repo_name = @new_repo_name\n Project.delete_hooks(@project, @new_user_name, @new_repo_name ) \n else\n Project.change_repo_name(@project, @new_repo_name, @new_user_name)\n Project.create_hook(@project, @new_repo_name, @new_user_name)\n end\n #respond_with @project\n end", "def hook(id)\n get(\"/hooks/#{id}\")\n end", "def create\n @hook = Hook.new(params[:hook])\n @hook.save\n respond_with(@hook)\n end", "def setup_git_hooks\n # repos to be hook'ed\n return unless @ebcommon.git_hook_repos\n\n # source\n plugin_hooks_dir = File.expand_path File.join(File.dirname(__FILE__), '..', 'files', 'git_hooks')\n git_hooks = Dir.entries(plugin_hooks_dir).select {|f| !File.directory? f}\n\n @env[:ui].info 'Copying over git commit hooks...'\n @ebcommon.git_hook_repos.each do |repo_path|\n # repo\n repo_dir = File.join @ebcommon.git_hook_root_dir, repo_path, '.git'\n next unless File.directory? repo_dir\n\n # create repo hooks dir if needed\n target_hooks_dir = File.join repo_dir, 'hooks'\n unless File.directory? target_hooks_dir\n @env[:ui].info \"Creating #{target_hooks_dir} directory...\"\n FileUtils.mkdir target_hooks_dir\n end\n\n # copy source hooks to repo\n git_hooks.each do |hook|\n @env[:ui].success \"Copying over git hook: #{hook} to #{target_hooks_dir}\"\n source = File.join plugin_hooks_dir, hook\n FileUtils.cp source, target_hooks_dir\n end\n end\n end", "def regenerate_git_repository\n logger.info `curl --user #{CONFIG[Rails.env][\"git_user_pass\"]} https://api.bitbucket.org/1.0/repositories/ --data name=#{CONFIG[Rails.env][:repo_prefix]}-#{self.uuid} --data is_private=true`\n\n sleep 1\n\n logger.info `mkdir #{directory}\n cp -r #{template_directory}/* #{directory}\n cp config/book_gitignore #{directory}/.gitignore\n cd #{directory}\n git init\n git remote add origin #{CONFIG[Rails.env][\"git\"]}/#{CONFIG[Rails.env][:repo_prefix]}-#{self.uuid}.git`\n\n input_files = \"\"\n self.texts.order(\"-position DESC\").each do |text|\n text.to_file\n input_files << \"\\\\input{#{text.short_filename}}\\n\"\n end\n\n input_text = File.join(directory,'INPUTS.tex')\n File.open(input_text,'w') {|io| io.write(input_files) }\n\n input_commands = File.join(directory,'fichatecnica.sty')\n File.open(input_commands,'w') {|io| io.write(self.book_data.to_file) }\n\n logger.info `cd #{self.directory}\n git add .\n git commit -a -m \"regenerate git repository from database\"\n git push -u origin master`\n\n logger.info \"regenerate git repository from database for book, id #{self.id}\"\n\n end", "def update_hooks\n hook_url = \"https://your.domain/jira/gitlab_hook\"\n\n gl_api_endpoint = 'https://gitlab.your.domain/api/v3'\n gl_admin_token = 'xxxxxxxxxxxxxxxxxxxx'\n\n gl = Jk::Gitlabz.new(gl_api_endpoint, gl_admin_token)\n\n # Added our custom push hook url to each repo\n gl.get_project_name_id_hash().each { |repo, proj_id|\n gl.add_hook_to_proj(proj_id, hook_url)\n }\nend", "def hook_path; end", "def with_sample_new_rgithook(&block)\n in_sample_repo do |repo|\n @rgithook = ::RGitHook::RGitHook.new(repo)\n yield @rgithook\n end\n end", "def setup\n @commit_data = {\n :id => \"a-real-deal-id-#{get_iterator}\",\n :commit_message => 'Creating Git Resource',\n :author_name => 'Collin',\n :author_email => 'collin@quickleft.com',\n :attributes => \"{ \\\"title\\\" : \\\"test #{get_iterator}\\\" }\",\n :rendered => \"<h1>Test #{get_iterator}</h1>\"\n }\n @commit_sha = Regulate::Git::Interface.save(@commit_data)\n end", "def hooks_file\n gitpusshuten_root + '/hooks.rb'\n end", "def hooks\n fetch_or_create_hooks.dup.freeze\n end", "def create\n display 'Create a new Unfuddle repository'\n \n repo = Unfuddle::Resources::Repository.create(\n :repository => {\n :title => ask('Name', :required => true),\n :abbreviation => ask('Slug', :required => true),\n :system => 'git',\n :projects => {\n :project => {\n :id => 24468 \n }\n }\n }\n )\n end", "def hook_name; end", "def webhooks_create_with_http_info(owner, repo, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: WebhooksApi.webhooks_create ...\"\n end\n # verify the required parameter 'owner' is set\n if @api_client.config.client_side_validation && owner.nil?\n fail ArgumentError, \"Missing the required parameter 'owner' when calling WebhooksApi.webhooks_create\"\n end\n # verify the required parameter 'repo' is set\n if @api_client.config.client_side_validation && repo.nil?\n fail ArgumentError, \"Missing the required parameter 'repo' when calling WebhooksApi.webhooks_create\"\n end\n # resource path\n local_var_path = \"/webhooks/{owner}/{repo}/\".sub('{' + 'owner' + '}', owner.to_s).sub('{' + 'repo' + '}', repo.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\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(opts[:'data'])\n auth_names = ['apikey']\n data, status_code, headers = @api_client.call_api(:POST, 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 => 'RepositoryWebhook')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: WebhooksApi#webhooks_create\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def hook\n @project = Project.find(params[:id])\n c = JSON.parse(params[:payload])\n\n @project.do_hook(c)\n\n #respond 200\n end", "def repo; end", "def repo; end", "def repo; end", "def repo; end", "def webhooks_create(owner, repo, opts = {})\n data, _status_code, _headers = webhooks_create_with_http_info(owner, repo, opts)\n return data\n end", "def create\n # Create an empty repo in memory\n repo = Repo.new\n \n # Var. 1) Github Repo posted to \"/addrepo?url=\"\n if params[:url]\n url = params[:url]\n # Strip url of leading or trailing whitespace\n # Gsub part of url that is not nescessary\n ident = url.gsub(\"https://github.com/\", \"\").strip\n \n # Split repo ident\n repo.owner = ident.split(\"/\")[0]\n repo.name = ident.split(\"/\")[1]\n repo.ident = ident\n end\n \n # Var. 2) Github Repo is being added by posting to \"/repo\" through form\n if params[:repo]\n # Remove leading and trialing whitespace\n repo.owner = params[:repo][:owner].strip\n repo.name = params[:repo][:name].strip\n repo.ident = repo.owner + \"/\" + repo.name\n end\n \n respond_to do |format|\n if Repo.find_by_ident(repo.ident).nil?\n # Repo is not yet listed\n if repo.save # Check if validations pass\n # Validations passed\n if Repo.init_repo(repo.id)\n # Repo could be found on Github\n format.html { redirect_to repo, notice: \"Success! You added '#{repo.owner}/#{repo.name}' successfully. Thanks for helping to improve this site! You might tag this repo!!!\" }\n else\n # Repo could not be found on Github and was deleted\n format.html { redirect_to root_url, notice: \"Sorry. I could not find '#{repo.owner}/#{repo.name} on github. Spelled everything correctly?\"}\n end\n # Repo validation fails while performing initialization\n format.html { redirect_to root_url, notice: \"Repo validation failed. Please mail our team with details how you managed to get this error.\"}\n else\n # Validation failed\n format.html { redirect_to root_url, notice: \"Sorry, I could not recognize a repo owner and name in there. My bad.\" }\n end\n \n else\n # Repo already listed \n repo = Repo.find_by_ident(repo.ident) \n format.html { redirect_to repo, notice: \"Double success! '#{repo.owner}/#{repo.name}' is listed already. Checkout the tags below and refine them to do some good for your fellow human programmers. Thanks!\"}\n end\n end\n end", "def create_standalone_remote_tag tag_name\n in_secondary_repository do\n run 'git checkout -b temp'\n run 'touch a.txt'\n run 'git add -A'\n run 'git commit -m \"temp\"'\n run \"git tag -a #{tag_name} -m '#{tag_name}'\"\n run 'git push --tags'\n end\nend", "def create_rgithook_instance\n # This is not really a rgithook_instance ;-P\n ::RGitHook::RGitHook.stubs(:parse_path).with(@repo).returns(@repo)\n ::RGitHook::Runner.stubs(:new).with(@repo).returns(@runner)\n @runner.stubs(:load).with('hooks_file')\n ::RGitHook::RGitHook.any_instance.stubs(:hooks_file).returns('hooks_file')\n ::RGitHook::RGitHook.new(@repo)\n end", "def test_get_tags\n post '/repos', {:name => GIT_REPO}\n post \"/repos/#{GIT_REPO}.git/branches/master/files\", {:name => \"myfile.txt\", :data => \"Hello There\", :encoding => \"utf-8\", :user => \"Rune Madsen\", :email => \"rune@runemadsen.com\", :message => \"My First Commit\"}\n sha = JSON.parse(last_response.body)[\"commit_sha\"]\n post \"/repos/#{GIT_REPO}.git/tags\", {:tag => \"version1\", :message => \"hello\", :sha => sha, :type => \"commit\", :user => \"Rune Madsen\", :email => \"rune@runemadsen.com\"}\n get \"/repos/#{GIT_REPO}.git/tags\"\n end", "def gitrepo(repo, name, ref = 'master')\n mod name.split('/').join('-'),\n :git => \"https://#{repo}/#{name}.git\",\n :ref => ref\nend", "def repo_make(name)\n path = repo_path(name)\n path.mkpath\n Dir.chdir(path) do\n Pod::Executable.capture_command!('git', %w(init))\n Pod::Executable.capture_command!('git', %w(checkout -b main))\n repo_make_readme_change(name, 'Added')\n Pod::Executable.capture_command!('git', %w(add .))\n Pod::Executable.capture_command!('git', %w(commit -nm Initialized.))\n end\n path\n end", "def create_repository request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_create_repository_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def create_repository_from_template(repo, name, options = {})\n options.merge! :name => name\n options = ensure_api_media_type(:template_repositories, options)\n post \"#{Repository.path repo}/generate\", options\n end", "def create_ips_repo\n shellout!(\"pkgrepo create #{repo_dir}\")\n log.info(log_key) { \"Created IPS repo: #{repo_dir}\" }\n end", "def create(project_name, repo_name, description) ; end", "def create_git_tag\n assignment_repository.write do |git|\n git.add_tag git_tag\n end\n end", "def create\n @commit = Commit.new\n\n #walker = Rugged::Walker.new(@repo)\n #\n #walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE) # optional\n #\n #walker.push('HEAD')\n #walker.each { |c| \n # @commit = Commit.new(sha: c.oid, description:c.message,\n # author: c.author[:name], commit_date: c.author[:time])\n # @commit.save\n #}\n #walker.reset\n\n respond_to do |format|\n format.html { redirect_to @commit, notice: 'Commit was successfully created.' }\n format.json { render :show, status: :created, location: @commit }\n end\n end", "def action_create\n\n install_prerequisites\n\n node.set['pedant'][new_resource.variant]['etc_dir'] = new_resource.config_dir\n\n directory new_resource.config_dir do\n owner new_resource.user\n group new_resource.group\n mode \"0755\"\n recursive true\n end\n\n source_dir = \"#{new_resource.checkout_dir}/#{new_resource.variant}\"\n\n git new_resource.variant do\n destination source_dir\n repository \"git@github.com:opscode/#{new_resource.variant}.git\"\n revision new_resource.revision\n user new_resource.git_user\n end\n\n node.set['pedant'][new_resource.variant]['dir'] = \"/srv/#{new_resource.variant}\"\n\n link node['pedant'][new_resource.variant]['dir'] do\n to source_dir\n end\n\n template \"#{new_resource.config_dir}/pedant_config.rb\" do\n source new_resource.config_template\n owner new_resource.user\n group new_resource.group\n mode \"0644\"\n variables(new_resource.variables)\n end\n\n execute \"bundle install\" do\n cwd node['pedant'][new_resource.variant]['dir']\n # user \"opscode\"\n end\n\nend", "def create_repos\n response = HTTParty.get('https://api.github.com/orgs/' + org_name + '/repos')\n data = response.parsed_response\n data.each {|repo| github_repos.create(name: repo['name'], github_id: repo['id'])}\n end", "def repo=(_arg0); end", "def repo=(_arg0); end", "def repo=(_arg0); end", "def repo=(_arg0); end", "def find_all(repo, options = {})\n refs = []\n already = {}\n Dir.chdir(repo.path) do\n files = Dir.glob(prefix + '/**/*')\n files.each do |ref|\n next if !File.file?(ref)\n id = File.read(ref).chomp\n name = ref.sub(\"#{prefix}/\", '')\n commit = Commit.create(repo, :id => id)\n if !already[name]\n refs << self.new(name, commit)\n already[name] = true\n end\n end\n\n if File.file?('packed-refs')\n File.readlines('packed-refs').each do |line|\n if m = /^(\\w{40}) (.*?)$/.match(line)\n next if !Regexp.new('^' + prefix).match(m[2])\n name = m[2].sub(\"#{prefix}/\", '')\n commit = Commit.create(repo, :id => m[1])\n if !already[name]\n refs << self.new(name, commit)\n already[name] = true\n end\n end\n end\n end\n end\n\n refs\n end", "def add_git_facts\n # see if we're in a git repo. first, we need a directory that exists\n dir = @path.expand_path.ascend.find {|p| p.directory? }\n \n Dir.chdir(dir) do\n root_result = Cmds.new \"git rev-parse --show-toplevel\"\n \n unless root_result.ok?\n @result.in_git_repo = false\n @result.is_git_root = false\n return\n end\n \n @result.in_git_repo = true\n \n git = @result.git = Result.new\n git.root = Pathname.new root_result.out.chomp\n @result.is_git_root = @path == git.root\n \n user = git.user = Result.new\n \n ['name', 'email'].each {|key|\n user[key] = begin\n Cmds.chomp! \"git config user.#{ key }\"\n rescue\n end\n }\n \n git.origin = begin\n Cmds.chomp! \"git remote get-url origin\"\n rescue\n end\n \n match = GITHUB_SSH_URL_RE.match(git.origin) ||\n GITHUB_HTTPS_URL_RE.match(git.origin)\n \n git.is_github = !! match\n \n return unless match\n \n git.owner = match['owner']\n git.name = match['name']\n git.full_name = \"#{ git.owner }/#{ git.name }\"\n \n if true == @args['github_api']\n github = git.github = Result.new\n github.api_url = \"https://api.github.com/repos/#{ git.owner }/#{ git.name }\"\n \n response = Net::HTTP.get_response URI(github.api_url)\n \n if response.is_a? Net::HTTPSuccess\n # parse response body and add everything to github result\n parsed = JSON.parse response.body\n parsed.each {|k, v| github[k] = v}\n else\n # assume it's private if we failed to find it\n github.private = true\n end\n \n end\n end\n end", "def initialize_repo\n puts \"starting to initialize repo: '#{self.ident}' finished successfully.\"\n self.update_repo\n end", "def create_local_tag tag_name\n run \"git tag -a #{tag_name} -m '#{tag_name}'\"\nend", "def service_rpc(rpc)\n if content_type_matches?(rpc)\n input = read_body\n\n @res = Rack::Response.new\n @res.status = 200\n @res[\"Content-Type\"] = \"application/x-git-%s-result\" % rpc\n @res.finish do\n command = \"git #{rpc} --stateless-rpc #{@repo_dir}\"\n IO.popen(command, File::RDWR) do |pipe|\n pipe.write(input)\n while !pipe.eof?\n block = pipe.read(16) # 16B at a time\n @res.write block # steam it to the client\n end\n end\n end\n else\n not_allowed\n end\n end", "def create_trigger(hook_id:, project_id:, trigger_body:)\n url = \"#{@base_url}/vapid/webhooks/hooks/#{hook_id}/triggers?project_id=#{project_id}\"\n res = HTTParty.post(url, body: trigger_body.to_json, headers: procore_headers(token: @customer_info[:token], company_id: @customer_info[:company_id]) ) # returns HTTParty object {code, response}\n if res.code == 201\n res\n else\n raise StandardError.new({message: 'Error Creating Hook', data: res})\n end \n end", "def get(user_name, repo_name, hook_id, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n _validate_presence_of hook_id\n normalize! params\n\n get_request(\"/repos/#{user}/#{repo}/hooks/#{hook_id}\", params)\n end", "def create_remote_tag tag_name\n in_secondary_repository do\n create_local_tag tag_name\n run 'git push --tags'\n end\nend", "def rest__create\n # setup needed data\n module_name = ret_non_null_request_params(:module_name)\n namespace = ret_request_param_module_namespace?()\n config_agent_type = ret_config_agent_type()\n project = get_default_project()\n\n # local_params encapsulates local module branch params\n opts_local_params = (namespace ? { namespace: namespace } : {})\n local_params = local_params(:component_module, module_name, opts_local_params)\n\n opts_create_mod = Opts.new(\n config_agent_type: ret_config_agent_type()\n )\n\n module_repo_info = ComponentModule.create_module(project, local_params, opts_create_mod)[:module_repo_info]\n\n # only when creating via import-git command\n git_url = ret_request_params(:module_git_url)\n\n unless git_url.empty?\n add_git_url(project.model_handle(:repo_remote), module_repo_info[:repo_id], git_url)\n end\n\n rest_ok_response module_repo_info\n end", "def new\n @hook = Hook.new\n respond_with(@hook)\n end", "def create_repo(name)\n response = Faraday.post \"https://api.github.com/user/repos\", {name: \"#{name}\" }.to_json, {'Authorization'=>\"token #{self.access_token}\", 'Accept' => 'application/json'}\n end", "def github_repo(access_token, api_endpoint, repo)\n client = Octokit::EnterpriseAdminClient.new :access_token => access_token :api_endpoint => api_endpoint\n client.repo repo \n end", "def create\n url = repo_params[:html_url]\n params = Repo.get_repo(url, current_user)\n if params == nil\n redirect_to :back, notice: 'Error with API access token.'\n return\n end\n if params == -1\n redirect_to :back, alert: 'Repo already exists' and return\n end\n\n params[:user_id] = current_user.id\n @repo = Repo.new(params)\n\n respond_to do |format|\n if @repo.save\n format.html { redirect_to @repo, notice: 'Repo was successfully created.' }\n format.json { render :show, status: :created, location: @repo }\n else\n format.html { render :new }\n format.json { render json: @repo.errors, status: :unprocessable_entity }\n end\n end\n end", "def git\n\tend", "def hooks\n # ???\n end", "def perform(autobuild_id)\n autobuild = Autobuild.find(autobuild_id)\n webhook_secret = SecureRandom.hex(20)\n autobuild.update(webhook_secret: webhook_secret)\n\n if autobuild.code_repo_type == 'github'\n linked_app = autobuild.github_linked_app\n access_token = linked_app.access_token\n client = Octokit::Client.new(access_token: access_token)\n\n resp = client.create_hook(\n autobuild.code_repo_name,\n 'web',\n {\n url: \"https://#{ENV['DOMAIN_NAME']}/github/webhooks/#{autobuild.id}\",\n content_type: 'json',\n secret: webhook_secret\n },\n {\n events: ['push', 'pull_request'],\n active: true\n })\n elsif autobuild.code_repo_type == 'gitlab'\n linked_app = autobuild.gitlab_linked_app\n access_token = linked_app.access_token\n code_repo_name = autobuild.code_repo_name\n\n # TODO: Should probably use a client\n Gitlab.endpoint = \"https://gitlab.com/api/v4\"\n Gitlab.private_token = access_token\n\n begin\n user = Gitlab.user\n rescue Gitlab::Error::Unauthorized => e\n refresh_gitlab_access_token(linked_app)\n access_token = linked_app.access_token\n Gitlab.private_token = access_token\n user = Gitlab.user\n end\n\n user_id = user[\"id\"]\n\n # TODO: Rename code_repo_name to full_repo_name\n repo_name = code_repo_name.split(\"/\").last\n projects = Gitlab.get(\"/users/#{user_id}/projects?search=#{repo_name}\")\n project = projects.to_a.find { |p| p[\"name\"] == repo_name }\n response = Gitlab.add_project_hook(\n project.id,\n \"https://#{ENV['DOMAIN_NAME']}/gitlab/webhooks/#{autobuild.id}\",\n {\n push_events: 1,\n tag_push_events: 1,\n token: webhook_secret\n }\n )\n autobuild.update(webhook_config: response.to_h)\n end\n end", "def new_embed\n definitions = files.map do |f|\n path = f[0].split(\"/\")[8..-1].join(\"/\")\n line = f[1]\n \"[`#{path}#L#{line}`](#{GITHUB_URL}/tree/#{GIT_VERSION}/lib/#{path}#L#{line})\"\n end.join(\"\\n\")\n\n Discordrb::Webhooks::Embed.new(\n color: 0xff0000,\n url: github_pages_url,\n title: \"[View on Git Docs]\",\n description: definitions,\n footer: {text: \"discordrb v#{Discordrb::VERSION}@#{GIT_VERSION}\", icon_url: RUBY_TACO},\n ).tap { |e| yield e if block_given? }\n end", "def git_data(options = {})\n @git_data ||= ApiFactory.new 'GitData', options\n end", "def create\n processor = Mailgun::WebHook::Processor.new(mailgun_params, self)\n processor.on_unhandled_mailgun_events = self.class.on_unhandled_mailgun_events!\n processor.run!\n block_given? ? yield : head(:ok)\n end", "def repo1\n addons = Addon.where(\"lower(repos.name) = ?\", params[:repo_name].downcase)\n render json: to_v1_repo_hashes(addons)\n end", "def create(*args)\n params = args.extract_options!\n normalize! params\n filter! VALID_REPO_OPTIONS + %w[ org ], params\n assert_required_keys(%w[ name ], params)\n\n # Requires authenticated user\n post_request(\"/1.0/repositories/\", DEFAULT_REPO_OPTIONS.merge(params))\n end", "def process_repos\n url_template = if @options.preview\n 'https://api.github.com/search/issues?q=is:pr+repo:cockpit-project/REPO+label:release-note'\n else\n 'https://api.github.com/search/issues?q=is:pr+repo:cockpit-project/REPO+label:release-note+is%3Aclosed'\n end\n tags_template = 'https://api.github.com/repos/cockpit-project/REPO/tags'\n\n @repos.map do |repo|\n # Grab relevant issues for the repo\n url = url_template.sub('REPO', repo)\n\n # Process versions\n url_tags = tags_template.sub('REPO', repo)\n versions = get_json(url_tags).map { |tag| tag['name'].to_i }.sort\n # Set the Cockpit version from the first repo (which is always Cockpit)\n @cockpit_version ||= versions.last + @increment\n\n notes = get_json(url)['items']\n .map { |issue| format_issue(issue, repo) }\n\n process_meta(repo, versions) unless notes.empty?\n\n notes\n end\nend", "def get_repo(repo_id)\n response=client.extensions.repository.retrieve_with_details(repo_id)\n code=response.code\n body=response.body\n case code\n when 200\n repo=JSON.parse(body.to_json)\n type = repo[\"notes\"][\"_repo-type\"]\n #puts repos\n repo_data=nil\n case type\n when REPO_TYPE_RPM\n yum_distributor = repo[\"distributors\"].select{ |d| d[\"distributor_type_id\"] == 'yum_distributor'}[0]\n yum_importer = repo[\"distributors\"].select{ |d| d[\"distributor_type_id\"] == 'yum_importer'}[0]\n distributor = nil\n if yum_distributor\n distributor = {\n :auto_publish => yum_distributor[\"auto_publish\"],\n :last_publish => yum_distributor[\"last_publish\"],\n :config => yum_distributor[\"config\"]\n }\n end\n importer = nil\n if yum_importer\n importer = {\n :last_sync => yum_importer[\"last_sync\"],\n :config => yum_importer[\"config\"]\n }\n end\n\n repo_data={\n :id => repo[\"id\"],\n :name => repo[\"display_name\"],\n :description => repo[\"description\"],\n :content_unit_counts => repo[\"content_unit_counts\"],\n :type => REPO_TYPE_RPM,\n :last_unit_removed => repo[\"last_unit_removed\"],\n :last_unit_added => repo[\"last_unit_added\"],\n :distributor => distributor,\n :importer => importer,\n }\n #puts repos\n when REPO_TYPE_PUPPET\n puppet_distributor = repo[\"distributors\"].select{ |d| d[\"distributor_type_id\"] == 'puppet_distributor'}[0]\n distributor =nil\n if puppet_distributor\n distributor = {\n :auto_publish => puppet_distributor[\"auto_publish\"],\n :last_publish => puppet_distributor[\"last_publish\"],\n :config => puppet_distributor[\"config\"]\n }\n end\n repo_data={\n :id => repo[\"id\"],\n :name => repo[\"display_name\"],\n :description => repo[\"description\"],\n :content_unit_counts => repo[\"content_unit_counts\"],\n :type => REPO_TYPE_PUPPET,\n :last_unit_removed => repo[\"last_unit_removed\"],\n :last_unit_added => repo[\"last_unit_added\"],\n :distributor => distributor\n }\n else\n end\n repo_data\n else\n raise \"Exception: cannot get repository detail: response code :#{code}\"\n end\n end", "def create_repo\n Rugged::Repository.init_at(repo_path, :bare).tap do |repo|\n repo.remotes.create('origin', \"git@github.com:#{project.gh_path}\")\n repo.remotes.add_fetch_refspec('origin', GITHUB_PULLS_REFSPEC)\n end\n end", "def build_repo repo_path, file_structure\n file_structure.each do |entry|\n add_file entry\n end\n end", "def test(user_name, repo_name, hook_id, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n _validate_presence_of hook_id\n normalize! params\n\n post_request(\"/repos/#{user}/#{repo}/hooks/#{hook_id}/test\", params)\n end", "def register_webhook\n\t\t\t\t\trequire \"open-uri\"\n\t\t\t\t\trequire \"net/http\"\n\t\t\t\t\trequire \"openssl\"\n\n\t\t\t\t\turi = URI.parse(\"#{self.add_on.jive_url}/api/core/v3/webhooks\")\n\t\t\t\t\thttp = Net::HTTP.new(uri.host, uri.port)\n\t\t\t\t\thttp.use_ssl = true\n\t\t\t\t\t#http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n\t\t\t\t\trequest = Net::HTTP::Post.new(uri.request_uri)\n\n\t\t\t\t\trequest[\"Content-Type\"] = \"application/json\"\n\t\t\t\t\trequest[\"Authorization\"] = \"Bearer #{self.oauth_token.access_token}\"\n\n\t\t\t\t\tbody = {\n\t\t\t\t\t\t\"callback\" => self.callback,\n\t\t\t\t\t\t\"object\" => self.object,\n\t\t\t\t\t}\n\t\t\t\t\tbody[\"events\"] = self.events if !self.events.to_s.empty?\n\n\t\t\t\t\trequest.body = body.to_json\n\n\t\t\t\t\tresponse = http.request(request)\n\n\t\t\t\t\t# Need 2XX status code\n\t\t\t\t\tif !response.code.to_i.between?(200, 299)\n\t\t\t\t\t\terrors[:base] << \"#{request.inspect} => #{response.body}\"\n\t\t\t\t\t\treturn false\n\t\t\t\t\tend\n\n\t\t\t\t\tjson_body = JSON.parse(response.body)\n\n\t\t\t\t\tself.webhook_id = json_body[\"id\"]\n\n\t\t\t\t\ttrue\n\t\t\t\tend", "def git_init\n @repo = Rugged::Repository.init_at repo_path.to_s\n @index = repo.index\n end", "def github_fetch_tags\n tags = []\n page_i = 0\n count_pages = calculate_pages(@client, \"tags\", {})\n\n iterate_pages(@client, \"tags\") do |new_tags|\n page_i += PER_PAGE_NUMBER\n print_in_same_line(\"Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\")\n tags.concat(new_tags)\n end\n print_empty_line\n\n if tags.count == 0\n Helper.log.warn \"Warning: Can't find any tags in repo. \\\nMake sure, that you push tags to remote repo via 'git push --tags'\"\n else\n Helper.log.info \"Found #{tags.count} tags\"\n end\n # tags are a Sawyer::Resource. Convert to hash\n tags.map { |resource| stringify_keys_deep(resource.to_hash) }\n end", "def hook(id, params={})\n\t\t\t\tparams[:self] = self\n\t\t\t\tself.class.hooks.execute id, params\n\t\t\tend", "def repo_init\n git :init\n end", "def hook_url\n \"#{beef_url_str}#{hook_file_path}\"\n end", "def create\n @repo = GitRepository.create(path: '/a/path')\n @commit = GitCommit.create(object_hash: params[:hash], git_repository: @repo)\n respond_to do |format|\n format.html { render html: @commit.object_hash }\n format.json { render json: @commit }\n end\n end", "def create\n final_params = repository_params\n languages = Language.where(name: repository_params[:languages])\n final_params[:languages] = languages\n \n @repository = Repository.new(final_params)\n @uri = URI(@repository.repo_location)\n @repository.secret_path = SecureRandom.hex.to_s + @uri.path.split(\"/\").last.to_s\n @secret_path_to_clone_to = @repository.secret_path\n \n respond_to do |format|\n if @repository.save\n Git.clone(@uri, @secret_path_to_clone_to, :path => Rails.root.join(\"storage\", \"repositories\"))\n format.html { redirect_to @repository, notice: 'Repository was successfully created.' }\n format.json { render :show, status: :created, location: @repository }\n else\n format.html { render :new }\n format.json { render json: @repository.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize(user = nil, api_token = nil, repo_name = \"cookie_monster\") \n if user.nil?\n puts \"No user provided, getting from git config\"\n user = `git config --get github.user`.chomp\n end\n\n if api_token.nil?\n puts \"No API token provided, getting from git config\"\n api_token = `git config --get github.token`.chomp\n end\n\n\n @user = user.chomp # chomp in case user passes in bad data\n @api_token = api_token.chomp # chomp in case user passes in bad data\n @repo_name = repo_name\n\n # Authenticated client\n #@client = Octopussy::Client.new({:login => @user, :token => @api_token})\n\n # Location of local git repository. Necessary for pushing to Github.\n # Put it in .cloud_path so it doesn't conflict with anything\n @git_dir_path = File.expand_path(\"~/.cloud_path/\" + @repo_name)\n\n create_repo\n create_git_dir\n \n # For whatever reason, Repository.find raises Octopi::NotFound when\n # we've just created the repository in this run of the script.\n # Possibly a caching error.\n begin\n repo = Repository.find(:user => @user, :repo => @repo_name)\n rescue Octopi::NotFound\n puts \"Repository not found. Probably just created repository, please\"\n puts \"run this script again.\"\n exit 0\n end\n end", "def hooks\n @hooks = Hook.all\n end", "def create_pr\n ErrorEmittingExecutor.execute(\"hub pull-request -f -m '#{COMMIT_DESCRIPTION}'\")\nend", "def create\n repo = Repo.find(params[:repo_id])\n\n label_name = params[:label_name].downcase\n \n respond_to do |format|\n format.html { \n # Which ActsAsTaggableOn Context do we want to tag?\n if params[\"add_label\"]\n repo.label_list << label_name\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\"\n elsif params[\"remove_label\"]\n repo.label_list << label_name\n repo.label_list.delete(label_name)\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\"\n elsif params[\"add_framework\"]\n repo.framework_list << label_name\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n elsif params[\"remove_framework\"]\n repo.framework_list << label_name\n repo.framework_list.delete(label_name)\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n elsif params[\"add_language\"]\n repo.language_list << label_name\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n elsif params[\"remove_language\"]\n repo.language_list << label_name\n repo.language_list.delete(label_name)\n repo.save\n redirect_to :back, notice: \"Tagging action succeeded.\" \n else\n #no particular action wish was send along\n redirect_to :back, notice: \"Tagging action did not succeed. Please mail my creators that I did not receive instruction where to put this tag or label.\" \n end \n }\n end\n end", "def hook_type_name; end", "def github(name, ref = 'master')\n gitrepo \"github.com\", name, ref\nend", "def add(hash, opts = {})\n uuid = opts[:id] || SecureRandom.uuid\n thash = Treet::Hash.new(hash)\n repos[uuid] = thash.to_repo(\"#{root}/#{uuid}\", opts.merge(:repotype => repotype))\n end", "def hook\n if Bot.exists?(params[:id])\n JobDaemon.enqueue(JobDaemons::BotJob.new(params[:id].to_i, 'onHook', [request.method, hook_params]))\n render json: {status: 'ok'}, status: :ok\n else\n render json: {status: 'ng'}, status: :not_found\n end\n end", "def create\n processor = Mandrill::WebHook::Processor.new(params, self)\n processor.on_unhandled_mandrill_events = self.class.on_unhandled_mandrill_events!\n processor.run!\n head(:ok)\n end", "def set_hook\n @hook = Hook.find(params[:id])\n end", "def call_hook(hook, context={})\n template = context[:controller].instance_variable_get('@template')\n returning [] do |response|\n hls = hook_listeners(hook)\n if hls.any?\n hls.each {|listener| response << listener.send(hook, template)}\n end\n end\n end", "def tags\n @tags ||= ApiFactory.new 'GitData::Tags'\n end", "def add_hook(url)\n post(\"/hooks\", :body => {:url => url})\n end", "def git_init\n @repo = Rugged::Repository.init_at(repo_path.to_s)\n @index = repo.index\n end", "def create_custom_repositories(existing:, custom:)\n return existing if custom.nil? || custom[:repositories_attributes].nil?\n\n existing = existing.to_h\n custom[:repositories_attributes].each do |_id, hash|\n next if hash[:uri].nil? || hash[:name].nil?\n\n repo = Repository.find_by(uri: hash[:uri])\n hash[:info] = '{\"types\": [],\"subjects\": []}' if repo.nil?\n repo = Repository.create(hash) if repo.nil?\n existing[repo.id.to_s] = { id: repo.id } unless repo.nil?\n end\n existing\n end", "def hooks\n @hooks ||= []\n end", "def create(*args)\n arguments(args, required: [:owner, :repo]) do\n assert_required :tag_name\n end\n\n post_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases\",\n arguments.params)\n end", "def generate_zipped_code(langs)\n Dir.mktmpdir \"service-version-#{id}-code\" do |swagger_codegen_output_dir|\n with_spec_in_tmp_file do |spec_tmp_file|\n langs.each do |lang|\n lang_dir = File.join(swagger_codegen_output_dir, lang)\n Dir.mkdir lang_dir\n swagger_codegen spec_tmp_file.path, lang, lang_dir\n end\n end\n output_zip_name = \"#{organization.name}-#{name}-r#{version_number}-#{langs.join('__')}.zip\"\n with_tmp_file(output_zip_name) do |tmp_zip_file|\n ZipFileGenerator.new(swagger_codegen_output_dir, tmp_zip_file.path).write\n new_object = codegen_bucket.objects.build(output_zip_name)\n new_object.content = open(tmp_zip_file.path)\n new_object.acl = :public_read\n new_object.save\n return new_object.url\n end\n end\n end", "def repository_created(identifier, vendor, url)\n project = Project.find_by_identifier(identifier)\n # Do not create the repository if the project has already one\n return 0 unless project && project.repository.nil?\n logger.debug \"Repository for #{project.name} was created\"\n repository = Repository.factory(vendor, :project => project, :url => url)\n repository.save\n repository.id || 0\n end", "def github_post\n {\n \"create\" => ->(release) { start_deployment(release) },\n \"update_status\" => ->(release) { update_deployment(release) }\n }\n end", "def get_repository_template(name)\n %Q(\n @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.\n @prefix rep: <http://www.openrdf.org/config/repository#>.\n @prefix sr: <http://www.openrdf.org/config/repository/sail#>.\n @prefix sail: <http://www.openrdf.org/config/sail#>.\n @prefix sys: <http://www.openrdf.org/config/repository#> .\n @prefix ns: <http://www.openrdf.org/config/sail/native#>.\n\n _:#{name}{\n [] a rep:Repository ;\n rep:repositoryID \"#{name}\" ;\n rdfs:label \"Metadata and Annotations for #{name} collection\" ;\n rep:repositoryImpl [\n rep:repositoryType \"openrdf:SailRepository\" ;\n sr:sailImpl [\n sail:sailType \"openrdf:NativeStore\" ;\n ns:tripleIndexes \"spoc,posc\"\n ]\n ].\n }\n {\n _:#{name} a sys:RepositoryContext .\n }\n )\n end" ]
[ "0.66037405", "0.64660376", "0.6086982", "0.58305615", "0.577721", "0.57249194", "0.5651576", "0.55900484", "0.55421305", "0.545491", "0.5410556", "0.54031986", "0.5331591", "0.52813524", "0.5265054", "0.52487266", "0.522663", "0.5203098", "0.51766807", "0.5162217", "0.5120931", "0.50710446", "0.5051913", "0.5051913", "0.5051913", "0.5051913", "0.50290287", "0.5021697", "0.50210714", "0.5015358", "0.4994924", "0.49901983", "0.4981446", "0.4976618", "0.4955514", "0.49518657", "0.49296293", "0.49189538", "0.49034372", "0.4886517", "0.48423254", "0.48313144", "0.48313144", "0.48313144", "0.48313144", "0.4824229", "0.48196214", "0.48194525", "0.4809542", "0.48069313", "0.48065743", "0.48052984", "0.47904766", "0.4789776", "0.47892404", "0.47822028", "0.4782104", "0.4773557", "0.47705555", "0.47633526", "0.47597718", "0.47574738", "0.47490996", "0.47449145", "0.47438017", "0.47366828", "0.47341612", "0.47079125", "0.4707512", "0.47047698", "0.46967897", "0.46958193", "0.46954206", "0.4683476", "0.4682575", "0.46818012", "0.4679605", "0.46784732", "0.46771812", "0.46737257", "0.46592897", "0.4656298", "0.4654499", "0.46464422", "0.46419367", "0.46413594", "0.46410787", "0.46399295", "0.4636049", "0.46359816", "0.46311143", "0.4628216", "0.46280923", "0.4625447", "0.46226627", "0.46216607", "0.46202374", "0.46166337", "0.4605984", "0.4601897" ]
0.69875586
0
Remove repo hooks repo String hook_id Integer
def remove_hooks(repo, hook_id) api.remove_hook(repo, hook_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_hook!\n client.remove_hook(full_name, github_hook_id)\n\n self.github_hook_id = nil\n end", "def delete_hook(id)\n delete(\"/hooks/#{id}\")\n end", "def delete(user_name, repo_name, hook_id, params={})\n _update_user_repo_params(user_name, repo_name)\n _validate_user_repo_params(user, repo) unless user? && repo?\n _validate_presence_of hook_id\n normalize! params\n\n delete_request(\"/repos/#{user}/#{repo}/hooks/#{hook_id}\", params)\n end", "def delete_commit_hook(book_id)\n book = Book.find(book_id)\n if repo_exists?(book.repo_id) && client.scopes.include?(\"admin:repo_hook\")\n # No need for error handling because this function returns false if it fails.\n removed = client.remove_hook(book.repo_id, book.hook_id)\n if removed\n book.update(hook_id: nil)\n else\n return false\n end\n end\nend", "def remove_plugin_hooks(id)\n Hooks::Menu.remove_plugin_hooks(id)\n Hooks::View.remove_plugin_hooks(id)\n end", "def remove(name)\n if hook = by_name(name)\n hook.destroy!\n end\n end", "def delete_webhook(repo, hook_id, options = {})\n boolean_from_response :delete, \"#{Repository.path repo}/hooks/#{hook_id}\", options\n end", "def remove_service_hook(repository, user)\n client = Octokit::Client.new(:oauth_token => user.github_oauth_token)\n client.unsubscribe_service_hook(\"#{repository.owner_name}/#{repository.name}\", 'Travis')\n rescue Octokit::UnprocessableEntity => e\n # we might want to improve this for logging purposes\n raise ServiceHookError, 'error unsubscribing from the GitHub push event'\n end", "def remove_hook(event, hook)\r\n return unless hooks.has_key?(event.to_s)\r\n hook = hook.to_s unless hook.respond_to?(:call)\r\n hooks[event.to_s].delete(hook)\r\n end", "def remove_hook(method_name, hook)\n hooks[method_name].delete(hook)\n end", "def unlink_github\n @project = Project.find(params[:project_id])\n Project.delete_hooks(@project) \n @project.github_token = nil\n @project.github_user = nil\n @project.repo_name = nil\n @project.save\n redirect_to boards_project_path(@project)\n end", "def remove_repo!\n chocolatey_package('chefdk') { action :remove }\n end", "def delete_lib(repo_id)\n curl_delete(\"#{self.host}/api2/repos/#{repo_id}/\").body_str\n end", "def remove\n working_repo.remove tree\n end", "def discard_repo\n @handler.discard\n end", "def remove_team_repo(id, owner, repo)\n boolean_request :delete, \"/teams/#{id}/repos/#{owner}/#{repo}\"\n end", "def delete_hook(name, hook_function_name)\n @hooks[name] ||= {}\n @hooks[name].delete(hook_function_name)\n end", "def remove_webhook(project_id_or_key, webhook_id)\n delete(\"projects/#{project_id_or_key}/webhooks/#{webhook_id}\")\n end", "def uninstall\n git_dir = GitDir.new(File.expand_path(\".\"))\n raise NotGitDirectoryError unless git_dir.is_git_directory?\n raise NoPostCommitExistError unless git_dir.has_post_commit_hook?\n\n git_dir.delete_post_commit\n puts 'Gitstagram properly uninstalled from this Git repository.'\n end", "def delete_hooks(event_name)\n @hooks[event_name] = []\n end", "def clear_hooks(event = nil)\r\n if event\r\n hooks.delete(event.to_s) if hooks.has_key?(event.to_s)\r\n return\r\n end\r\n\r\n hooks.clear\r\n nil\r\n end", "def remove_hook_at(method_name, hook_index)\n hooks[method_name].delete_at(hook_index)\n end", "def destroy\n @repo = Repository.find(params[:id])\n\n\t\t#REMOVE FILE FROM FILE SYSTEM AND DO A GIT commit\n\t\tif(FileUtils.rm(params[:path]))\n\t\t\t@git = GitHelper.init(@repo.path, current_user.email, current_user.name)\n\t\t\tGitHelper.commitAll(@git, \"Removed file :: #{params[:path]}\")\n\t\tend\n end", "def delete_hook(event_name, hook_name)\n @hooks[event_name] ||= []\n deleted_callable = nil\n\n @hooks[event_name].delete_if do |current_hook_name, callable|\n if current_hook_name == hook_name\n deleted_callable = callable\n true\n else\n false\n end\n end\n deleted_callable\n end", "def unsubscribe_service_hook(repo, service_name)\n topic = \"https://github.com/#{Repository.new(repo)}/events/push\"\n callback = \"github://#{service_name}\"\n unsubscribe(topic, callback)\n true\n end", "def clear_hooks\n @hook_objects = []\n end", "def destroy\n FileUtils.rm_r(@repository.path)\n end", "def delete_managed_repository\n OpenProject::Revisions::Git::GitoliteWrapper.logger.info(\"User '#{User.current.login}'\n has removed repository '#{repository_identifier}'\")\n\n repository_data = {\n name: gitolite_repository_name,\n absolute_path: managed_repository_path,\n relative_path: repository_identifier\n }\n OpenProject::Revisions::Git::GitoliteWrapper.update(:delete_repositories, [repository_data])\n end", "def delete_github_repo_file\n # commit\n commit_to_github(@repo, post_params)\n end", "def destroy\n @hook = Hook.find(params[:id])\n @hook.destroy\n respond_with(@hook)\n end", "def delete_webhook(id)\n make_json_api_request :delete, \"v2/#{account_id}/webhooks/#{id}\"\n end", "def delete_draft(filename)\n sh \"git rm #{filename}\" if `git ls-files #{filename}` != ''\n File.delete(filename) if File.exist?(filename)\n\n nil\nend", "def cli_uninstall(executable_path)\n puts \"Trying to remove hook symlinks…\"\n puts\n \n uninstall(executable_path) do |hook_executable_file|\n puts \"Removing `#{hook_executable_file}`\"\n end\n\n puts\n puts \"Plugin `#{name}` uninstalled.\"\n\n exit\n end", "def remove_repo!\n homebrew_cask('chefdk') { action :uninstall }\n end", "def webhooks_delete(owner, repo, identifier, opts = {})\n webhooks_delete_with_http_info(owner, repo, identifier, opts)\n return nil\n end", "def delete_webhooks_by_name room_name, hook_name\n # We can't delete webhooks by name; we have to use IDs. First we look up\n # the IDs, then we use them to delete the hooks.\n webhooks_response = self.get_webhooks room_name\n webhooks = webhooks_response.parsed_response['items']\n webhooks_to_delete = webhooks.find_all { |wh| wh['name'] == hook_name }\n webhooks_to_delete.each do |webhook|\n self.delete_webhook_by_id room_name, webhook['id']\n end\n end", "def cleanup_hook; end", "def remove\n unrealize\n remove_from_dependencies\n remove_from_dependents\n end", "def reset_hooks\n @hooks = nil\n end", "def delete_post_commit\n file_path = @path + '/.git/hooks/post-commit'\n if File.exists? file_path\n File.delete file_path\n end\n end", "def remove(repos)\n @repositories.remove(repos)\n\n repositories\n end", "def delete_without_hooks( object )\n\n @without_hooks = true\n\n return_value = delete( object )\n \n @without_hooks = false\n\n return return_value\n\n end", "def user_cleaned_hook(hook_data)\n unsubscribe_hook(hook_data)\n end", "def unregister_hooks(*names)\n # Load a timeout if one is given\n names.delete(nil)\n timeout = nil\n if names and names[0].is_a?(Numeric) then\n timeout = names[0].to_f\n names = names[1..-1]\n end\n\n # Then unhook things\n @hooks_mutex.synchronize{\n names.each{|name|\n $log.debug \"Unregistering hook: #{name}...\"\n hook = @hooks.delete(name)\n\n mod = hook[:module]\n @modules[mod][:hooks].delete(name) \n cleanup_module(mod, timeout)\n }\n }\n end", "def remove_github_readonly_refs(repo_local)\n file_lines = ''\n\n FileUtils.rm_rf(File.join(repo_local.repo.path, 'refs', 'pull'))\n\n IO.readlines(File.join(repo_local.repo.path, 'packed-refs')).map do |line|\n file_lines += line unless !(line =~ /^[0-9a-fA-F]{40} refs\\/pull\\/[0-9]+\\/(head|pull|merge)/).nil?\n end\n\n File.open(File.join(repo_local.repo.path, 'packed-refs'), 'w') do |file|\n file.puts file_lines\n end\nend", "def off(uid, target_class)\n target_repository = @repository[@type][target_class]\n result = uid\n\n target_repository.global_hooks_data.each do |on|\n global_hooks = target_repository.global_hooks_data[on]\n index = global_hooks.find_index { |hook| hook.uid == uid }\n\n if index\n global_hooks.delete_if { |hook| hook.uid == uid }\n else\n result = nil\n end\n end\n\n result\n end", "def remove(repos)\n @list.delete_if { |e| [repos].flatten.include? e }\n self\n end", "def delete(id)\n _params = {:id => id}\n return @master.call 'webhooks/delete', _params\n end", "def set_hook\n @project = Project.find(params[:project_id])\n @new_repo_name = params[:repo_name]\n @new_user_name = params[:user_name]\n\n @is_linked = false\n json_repos = {}\n begin\n json_repos = JSON.parse(@project.repo_name)\n rescue \n end\n json_repos.each do |j|\n if j[\"repo\"] == @new_repo_name\n @is_linked = true\n end\n end\n\n if @is_linked\n @old_repo_name = @new_repo_name\n Project.delete_hooks(@project, @new_user_name, @new_repo_name ) \n else\n Project.change_repo_name(@project, @new_repo_name, @new_user_name)\n Project.create_hook(@project, @new_repo_name, @new_user_name)\n end\n #respond_with @project\n end", "def remove_github_readonly_refs(repo_local)\n file_lines = ''\n\n FileUtils.rm_rf(File.join(repo_local.repo.path, 'refs', 'pull'))\n\n IO.readlines(File.join(repo_local.repo.path, 'packed-refs')).map do |line|\n file_lines += line if (line =~ %r{^[0-9a-fA-F]{40} refs/pull/[0-9]+/(head|pull|merge)}).nil?\n end\n\n File.open(File.join(repo_local.repo.path, 'packed-refs'), 'w') do |file|\n file.puts file_lines\n end\nend", "def destroy\n @git_repo = GitRepo.find(params[:id])\n @git_repo.destroy\n\n respond_to do |format|\n format.html { redirect_to(git_repos_url) }\n format.xml { head :ok }\n end\n end", "def del_file( file_path )\n\n path_to_dot_git = File.join( @git_folder_path, \".git\" )\n git_rm_cmd = \"git --git-dir=#{path_to_dot_git} --work-tree=#{@git_folder_path} rm #{file_path}\"\n log.info(x) { \"[git] file remove command => #{git_rm_cmd}\" }\n %x[#{git_rm_cmd}];\n log.info(x) { \"[git] has removed #{file_path} from repo and working copy.\" }\n\n end", "def remove_repository(name)\n system(\"#{gitlab_shell_user_home}/gitlab-shell/bin/gitlab-projects rm-project #{name}.git\")\n end", "def remove_hook(res)\n print_debug \"[PROXY] Removing beef hook from page if present\"\n res.body.gsub!(%r'<script.*?http.*?exploit.js.*?</script>', '')\n end", "def delete_repository(snippet)\n return unless snippet.repository_exists?\n\n snippet.repository.remove\n snippet.repository.expire_exists_cache\n rescue StandardError => e\n logger.error(message: \"Snippet Migration: error deleting repository. Reason: #{e.message}\", snippet: snippet.id)\n end", "def rm_submods\n # rm git modules\n `rm -rf .gitmodules`\n\n puts colorBlue(\"removing submodule: #{self.submods}\")\n `rm -rf #{self.submods}/.git`\n\n `git rm --cached #{self.submods}`\n end", "def removeItemFromBackpack _obj, _args\n \"_obj removeItemFromBackpack _args;\" \n end", "def remove_moved_files\n scan_for_merges.each do |file|\n if File.amp_lexist?(@repo.working_join(file))\n UI.debug(\"removing #{file}\")\n File.unlink(@repo.working_join(file))\n end\n end\n end", "def remove(plugin); end", "def remove(name)\n path = repository_path(name)\n File.exists?(path) && FileUtils.rm_rf(path) && true\n end", "def remove_from_storage(id)\n\t\traise \"[FATAL] Storage directory not set\" if Repository.data_dir.nil?\n\n\t\tremove_file(id)\n\tend", "def hook(id)\n get(\"/hooks/#{id}\")\n end", "def remove_aggregation_proxies_from_solr\n query = ActiveFedora::SolrQueryBuilder.construct_query_for_rel(proxyIn: id, has_model: Proxy.to_class_uri)\n ActiveFedora::SolrService.instance.conn.delete_by_query(query, params: {'softCommit' => true})\n end", "def delete_all repos\n unless repos\n raise \"required repository name\"\n end\n repos = @login + '/' + repos unless repos.include? '/'\n list_files(repos).each { |obj|\n delete repos, obj[:id]\n }\n end", "def remove_library(lib)\n lib = lib.to_s\n\n @libraries[:start].delete lib\n @libraries[:sub_session].delete lib\n @libraries[:autoload].reject!{|_,e,| e == lib }\n @libraries[:thread].each{ |_,libs| libs.delete lib }\n @libraries[:late].delete lib\n @libraries[:late_thread].each{ |_,libs| libs.delete lib }\n\n @lib_hooks.delete lib\n end", "def remove_library(lib)\n lib = lib.to_s\n\n @libraries[:start].delete lib\n @libraries[:sub_session].delete lib\n @libraries[:autoload].reject!{|_,e,| e == lib }\n @libraries[:thread].each{ |_,libs| libs.delete lib }\n @libraries[:late].delete lib\n @libraries[:late_thread].each{ |_,libs| libs.delete lib }\n\n @lib_hooks.delete lib\n end", "def remove(rm_path)\n\t\t# ver si hacer el git remove aca o dejarlo antes del sync como esta ahora\n\t\tif(File.ftype(rm_path) == 'directory')\n\t\t\tFileUtils.remove_dir(rm_path)\n\t\telse\n\t\t\tFileUtils.remove_file(rm_path)\n\t\tend\n\tend", "def removeBackpack _args\n \"removeBackpack _args;\" \n end", "def remove(path)\n obj = self\n chdir do\n super \n obj.git.rm({}, '-f', '-r', path)\n end\n end", "def del_pr_branch(upstream, pr)\n `git checkout #{upstream}`\n `git branch -D #{pr_fix}#{pr}`\n end", "def unassociate_from_repo(repo_id, filters)\n criteria = {:type_ids => [content_type]}\n criteria[:filters] = filters\n Runcible::Extensions::Repository.new(self.config).unassociate_units(repo_id, criteria)\n end", "def delete_repository_file(project_id, options = {})\n delete \"/projects/#{project_id}/repository/files\", options\n end", "def update_webhook(repo, hook_id, options = {})\n patch \"#{Repository.path repo}/hooks/#{hook_id}\", options\n end", "def delete_repository(payload)\n path = repository_path(payload)\n if(File.exists?(path))\n warn \"Deleting repository directory: #{path}\"\n FileUtils.rm_rf(path)\n true\n else\n false\n end\n end", "def delete(id)\n FileUtils.rm_r File.join(DOTDIR, id)\n end", "def add_hooks(repo, endpoint)\n hook = api.create_hook(\n repo,\n 'web',\n {\n url: endpoint,\n secret: ENV['GITHUB_SECRET_TOKEN']\n },\n {\n events: %w(push pull_request), active: true,\n }\n )\n\n yield hook.id\n rescue Octokit::UnprocessableEntity => error\n raise unless error.message.include? 'Hook already exists'\n end", "def unlink_local_clone?(type,module_name,version=nil)\n Response.wrap_helper_actions() do\n local_repo_dir = local_repo_dir(type,module_name,version)\n git_dir = \"#{local_repo_dir}/.git\"\n if File.directory?(git_dir)\n FileUtils.rm_rf(git_dir)\n end\n end\n end", "def clear(name)\n @hooks[name] = {}\n end", "def remove_references(options)\n \t# just got to remove the assigned_pics Tree hash\n \tPictureandmeta.delete_event(self)\n end", "def remove_entity_snapshot(id)\n entities.where(:id => id).update(:snapshot => nil)\n end", "def metasmoke_push_hook\n Rails.cache.delete_matched %r{code_status/.*##{CurrentCommit}}\n end", "def clear_event_hooks(event_name)\n @hooks[event_name.to_s] = []\n end", "def destroy\n clear_cached_vars\n Regulate::Git::Interface.delete({\n :id => id,\n :commit_message => commit_message || \"Deleting resource #{title}\",\n :author_name => author_name,\n :author_email => author_email\n })\n end", "def destroy_all\n repositories.each {|name, repo| repo.destroy}\n end", "def del_pr_branch(upstream, pr)\n `git checkout #{upstream}`\n `git branch -D PR-#{pr}`\n end", "def git_prune\n mysystem('git prune')\n end", "def remove\n return unless confirm_command\n\n args.each do |name|\n messages = nil\n if name.start_with? \"HEROKU_POSTGRESQL_\"\n name = name.chomp(\"_URL\").freeze\n end\n action(\"Removing #{name} on #{app}\") do\n messages = addon_run { heroku.uninstall_addon(app, name, :confirm => app) }\n end\n display(messages[:attachment]) if messages[:attachment]\n display(messages[:message]) if messages[:message]\n end\n end", "def destroy\n @repo = Repo.find(params[:id])\n @repo.destroy\n\n respond_to do |format|\n format.html { redirect_to(repos_url) }\n format.xml { head :ok }\n end\n end", "def remove_dotgithub_files(repo)\n local_dir_files('docs/').each do |file|\n basename = File.basename(file)\n path = File.join '.github/', basename\n repo.delete_file(path) if repo.file_exists?(path)\n end\n end", "def delete_public_lib(repo_id)\n curl_delete(\"#{self.host}/api2/repos/#{repo_id}/public/\").body_str\n end", "def delete_dataset_in_github\n begin\n jekyll_service.delete_dataset_in_github\n rescue Octokit::NotFound\n Rails.logger.info \"Repository does not exist\"\n end\n end", "def delete_dataset_in_github\n begin\n jekyll_service.delete_dataset_in_github\n rescue Octokit::NotFound\n Rails.logger.info \"Repository does not exist\"\n end\n end", "def uninstall (bundleId)\n execute(:uninstall, bundleId)\n end", "def destroy\n @repo.destroy\n respond_to do |format|\n format.html { redirect_to repos_url }\n format.json { head :no_content }\n end\n end", "def prune\n sandbox {|git,w,i| git.prune }\n self\n end", "def step_remove_fixes(step,\n target)\n Log.log_info('Flrtvc step : ' + step.to_s + ' (target=' + target + ')')\n nim_lpp_source_resource = get_flrtvc_name(:NIM_res, target)\n begin\n Log.log_info('Removing efixes on ' + target)\n returned = Nim.perform_efix_uninstallation(target, nim_lpp_source_resource)\n if returned\n Log.log_info('End removing efixes on ' + target)\n else\n Log.log_err('Issue while removing efixes on ' + target)\n end\n rescue StandardError => e\n Log.log_err('Exception e=' + e.to_s)\n end\n end", "def uninstall(app_id)\n runcmd 'uninstall', app_id\n end", "def forget_removed\n action = branch_merge ? :remove : :forget\n working_changeset.deleted.each do |file|\n act action, file unless target_changeset[file]\n end\n\n unless branch_merge\n working_changeset.removed.each do |file|\n forget file unless target_changeset[file]\n end\n end\n end", "def removeHandgunItem _obj, _args\n \"_obj removeHandgunItem _args;\" \n end", "def delete_webhook\n # find the next sprint using that webhook, and recreate webhook in that sprint.user's name\n # delete webhook if no other sprint is using that webhook\n if webhook\n webhook.sprints.count > 1 ? webhook.sprints.where.not(user: user)[0].post_webhook : webhook.destroy\n end\n user.delete_wh_by_sprint(self)\n end" ]
[ "0.7973188", "0.7442817", "0.7292757", "0.6857257", "0.6805585", "0.6790555", "0.6790454", "0.6635315", "0.6573217", "0.64184344", "0.6323295", "0.63057613", "0.629042", "0.6259226", "0.62513006", "0.62237173", "0.62119156", "0.61896896", "0.61869967", "0.6150687", "0.60772604", "0.60380065", "0.59874463", "0.5938696", "0.5842066", "0.5830641", "0.5751177", "0.569212", "0.5663874", "0.56585807", "0.56269145", "0.560905", "0.56021404", "0.55499333", "0.5503517", "0.5498146", "0.5483286", "0.5476782", "0.54500777", "0.5440382", "0.5430995", "0.5416767", "0.539607", "0.53495294", "0.5349472", "0.5348084", "0.53315014", "0.5316415", "0.5315345", "0.5304047", "0.52843714", "0.5258707", "0.5247397", "0.52442676", "0.5236779", "0.5233332", "0.52171457", "0.5215517", "0.5213763", "0.5209384", "0.52075326", "0.51905245", "0.5189817", "0.51672435", "0.5163521", "0.5163282", "0.51609486", "0.51543903", "0.5148489", "0.5144148", "0.51402617", "0.513391", "0.5126094", "0.51242024", "0.51115596", "0.5111229", "0.5110972", "0.51106244", "0.5103479", "0.50846285", "0.5078877", "0.50771624", "0.50762933", "0.50690293", "0.5068269", "0.5053731", "0.50492394", "0.5047014", "0.50383466", "0.50363225", "0.5015282", "0.5015282", "0.5013253", "0.5004476", "0.50040513", "0.50007457", "0.49978268", "0.49885875", "0.4988533", "0.49871597" ]
0.8837115
0
All repos for access_token Returns Array of Hash
def repos api.repos.map(&:to_hash) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_repos\n # using oauth token to increase limit of request to github api to 5000\n client = Octokit::Client.new :access_token => self.github_token\n (client.repositories self.github_name, {:type => 'all'}).map do |repo|\n repo.full_name\n end\n end", "def get_all_user_repos\n user = User.find_by(uuid: params[:uuid])\n\n client = Octokit::Client.new(:access_token => user.password)\n repo_list = []\n client.repositories(:user => user.gh_username).each { |repo|\n repo_list.push(repo.name)\n }\n render :json => {:repos => repo_list}\n end", "def acquire_repo_list\n set_auth\n set_github_repo_name\n repo_list = []\n (@github.repos.list org: GITHUB_ORG).each do |l|\n repo_list << l[:name]\n end\n repo_list\nend", "def list\n @repos\n end", "def get_my_repos\n repos = []\n\n (1..get_total_repo_pages_count.to_i).each do |index|\n get_json( \"#{ GITHUB_USER_REPOS_URL }?per_page=100&page=#{ index }\" ).each do |item|\n repos << item[ 'full_name' ]\n end\n end\n\n return repos\nend", "def all\n repos = self.class.load_json(repos_url)\n repos.map! { |repo| self.class.filter_repo_info(repo) }\n self.class.slice_in(repos, 3)\n end", "def list_repositories\n JSON.parse(request(:get, ''))\n end", "def get_repo_names github_username , git_token\n\n Rails.cache.fetch(\"#{self.id}/repo_names\", expires_in: 6.hours) do\n repo_names = Array.new\n github = Github.new :oauth_token => git_token\n\n github.repos.list.body.each do |repo|\n if github_username == repo[\"owner\"][\"login\"]\n repo_names << { :user=>github_username ,:repo=>repo[\"name\"]}\n end\n end\n\n orgs_names = Array.new\n github.orgs.list.each do |org|\n orgs_names << org[\"login\"]\n end\n\n orgs_names.each do |oname|\n url = \"orgs/\"+oname+\"/repos\"\n \n github.get_request(url,Github::ParamsHash.new({})).each do |orepo|\n if oname == orepo[\"owner\"][\"login\"]\n repo_names << { :user=>oname ,:repo=>orepo[\"name\"]}\n end\n end\n end\n repo_names\n end\n end", "def list_all_registered_repos\n data, code = get_json(@all_repos_path)\n return data,code\n end", "def get_repo_users\n repo_users = Array.new\n github = Github.new :oauth_token => github_token\n\n github.repos.list.body.each do |repo|\n repo_users << repo[\"owner\"][\"login\"]\n end\n\n repo_users\n end", "def index\n @orgs ||= Github::Org.orgs(\n current_user_github_access_token,\n current_github_username\n )\n end", "def search_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # search repos using user query\n repos = @client.search_repositories(\"ember\")\n\n @json = repos.items.map do |repo|\n nhash = repo.to_hash\n nhash\n end\n\n respond_to do |format|\n format.json {\n render json: @json.to_json, status: 200\n }\n end\n end", "def get_list\n @list_of_repos\n end", "def get_repo_list(token, user)\n query = %{\n query ($user: String!, $cursor: String) {\n user(login: $user) {\n repositories(first: 100, after: $cursor) {\n edges {\n node {\n name\n owner {\n login\n }\n }\n }\n pageInfo {\n hasNextPage\n endCursor\n }\n }\n }\n }\n }\n\n vars = { user: user, cursor: nil }\n\n repos = []\n\n loop do\n result = Github.query(token, query, vars)\n repos += result.dig(\"data\", \"user\", \"repositories\", \"edges\") || []\n break unless result.dig(\"data\", \"user\", \"repositories\", \"pageInfo\", \"hasNextPage\")\n vars[:cursor] = result.dig(\"data\", \"user\", \"repositories\", \"pageInfo\", \"endCursor\")\n end\n\n repos.map { |e| { owner: e.dig(\"node\", \"owner\", \"login\"), name: e.dig(\"node\", \"name\") } }\nend", "def repos\n client.repos({}, query: { sort: \"asc\" })\n end", "def list_repos\n repos = []\n end_cursor = nil\n\n data = get_repos(end_cursor)\n repos = repos + data.fetch(\"nodes\")\n next_page = data.dig(\"pageInfo\", \"hasNextPage\")\n end_cursor = data.dig(\"pageInfo\", \"endCursor\")\n\n while next_page do\n data = get_repos(end_cursor)\n repos = repos + data.fetch(\"nodes\")\n next_page = data.dig(\"pageInfo\", \"hasNextPage\")\n end_cursor = data.dig(\"pageInfo\", \"endCursor\")\n end\n\n repos.reject { |r| r.dig(\"isArchived\") || r.dig(\"isDisabled\") }\n end", "def repositories\n response = self.class.get('/repositories').body\n JSON.parse(response)\n end", "def repos\n @repos ||= get(\"/repos/show/#{login}\")['repositories'].map { |r| Repo.new(connection, r) }\n end", "def get_repos\n @api.list_repositories\n end", "def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end", "def get_repos project_id\n $logger.info \"Getting repos\"\n\n # from the bitbucket api\n rest_endpoint = \"/rest/api/1.0/projects/#{PROJECT_ID}/repos\"\n\n http = Net::HTTP.new(BASE_GIT_URL, BASE_GIT_PORT)\n repos_request = Net::HTTP::Get.new(\"/rest/api/1.0/projects/#{PROJECT_ID}/repos?limit=1000\")\n repos_request.basic_auth GIT_USER, GIT_PASSWORD\n repos_response = http.request(repos_request)\n repos_response.value\n\n # https://confluence.atlassian.com/bitbucket/what-is-a-slug-224395839.html\n repos_body = JSON.parse(repos_response.body)\n repos = repos_body['values'].map { |v| v['slug'] }\n\n $logger.info \"Found repos #{repos}\"\n\n return repos\nend", "def github_projects\n Rails.cache.fetch(\"/users/#{self.id}/github_projects\", :expires_in => 1.day) {\n gh = Github.new(authentications.where(:provider => 'github').first.provider_token)\n gh.repos\n }\n end", "def list\n @connection.get('/user/repos').map do |repo_data|\n Rails.logger.info \"listing repos\"\n GitHubApi::Repo.new(self, repo_data)\n end\n end", "def cache_all_repos_for_user\n raise InvalidToken unless test_authentication\n repos = []\n repos += get_user_repos\n get_user_orgs.each do |org|\n repos += get_org_repos( org['login'] )\n end\n File.open(@cache_file, 'w') do |f|\n f.write repos.to_json\n end\n repos\n end", "def find_repositories\n @repos = GithubApi.call :repos\n end", "def index\n @repos = @user.repos.includes(:user)\n render json: to_json(@repos)\n end", "def repos\n @repos ||= (user_repos + org_repos).flatten\n end", "def get_repositories\n get(\"#{url_base}/repositories?#{dc}\")[\"data\"]\n end", "def repos(config_hash)\n if config_hash[\"organizations\"]\n repos = []\n config_hash[\"organizations\"][\"orgs\"].each do |org|\n # grab all the full repo names in this org. If no type is specified use public and also skip the forks\n # we also skip anything in the blacklist array\n repos << github.org_repos(org, type: config_hash[\"organizations\"][\"type\"] || \"public\")\n .collect { |x| x[\"full_name\"] unless x[\"fork\"] || x[\"archived\"] || (config_hash[\"organizations\"][\"blacklist\"] && config_hash[\"organizations\"][\"blacklist\"].include?(x[\"full_name\"])) }\n end\n repo_list = repos.flatten.compact.sort # return a single sorted array w/o nils\n puts \"Based on the provided org(s) (#{config_hash[\"organizations\"][\"orgs\"].join(',')}) managing the following repos: #{repo_list.join(', ')}\"\n repo_list\n elsif config_hash[\"repositories\"]\n config_hash[\"repositories\"]\n else\n puts \"Config does not include either 'repositories' or 'organizations' sections. Cannot continue!\"\n exit!\n end\nend", "def repos\n @repos ||= OY.repos\n end", "def team_repositories\n team_profiles.map(&:repositories).flatten\n end", "def repos\n @client.repos.all.collect(&:clone_url)\n end", "def all_repos\n\t\tif GitHosting.multi_repos?\n\t\t repositories\n\t\telse\n\t\t [ repository ].compact\n\t\tend\n\t end", "def get_repos\n begin\n @repos ||= github_api_setup.repos.list\n rescue Exception => e\n logger.error \"Github #get_repos error #{e}\"\n end\n end", "def user_repos\n @repos = @github.repos.list user: params[:username]\n render json: @repos\n end", "def get_repos\n\t\trepo_list = []\n\t\tparsed_config = begin\n\t\t\tYAML.load(File.open(@path_to_config_yml))\n\t\trescue ArgumentError => e\n \t\t\tputs \"Could not parse YAML: #{e.message}\"\n\t\tend\n\t\tparsed_config['sections'].each do |section|\n\t\t\trepo_list.push(section['repository']['name'].gsub(/\\w*-?\\w*\\//,''))\n\t\tend\n\t\trepo_list.sort\n\tend", "def repo_commits(repos)\n repos_commits = []\n repos.each do |repo|\n repos_commits << HTTParty.get(repo[\"commits_url\"].gsub(\"{/sha}\", \"\"))[0]\n end\n repos_commits\nend", "def get_app_repositories\n json_response = @client.list_installation_repos\n\n repository_list = []\n if json_response.count > 0\n json_response[\"repositories\"].each do |repo|\n repository_list.push(repo[\"full_name\"])\n end\n else\n puts json_response\n end\n\n repository_list\nend", "def repos_languages_data(git_user)\n allRepos = []\n github = Github.new oauth_token: current_employee.github_account.oauth_token\n myRepos = github.repos.list user: git_user\n myRepos.each do |repo|\n repo_languages = github.repos.languages git_user, repo.name\n repoHash = repo_languages.to_hash\n repoHash[\"name\"] = repo.name\n repoHash[\"created_at\"] = repo.created_at\n repoHash[\"updated_at\"] = repo.updated_at\n allRepos.push(repoHash.symbolize_keys!)\n end\n allRepos\n end", "def collected_repo_keys\n self.repos.collect { |repo| repo.repo_key }\n end", "def get_repos\n\t\t@repos = Repo.all\n\tend", "def org_repos\n @org_repos ||= (\n talk 'org repos'\n logins = orgs.map { |org| org[:login] }\n\n logins.map do |login|\n talk \"repos for #{login}\"\n client.organization_repositories login.to_s\n end.flatten\n )\n end", "def fetch_syncables\n gh_client.repos.list.select{|repo| repo.permissions.admin}.map(&:full_name)\n end", "def travis_repos\n x = $travis_conn.get 'owner/ropenscibot/repos'\n x.travis_raise\n return MultiJson.load(x.body)\nend", "def repos\n pry(Git::Multi.repositories)\nend", "def all_repos\n if GitHosting.multi_repos?\n repositories\n else\n [ repository ].compact\n end\n end", "def projects\n @projects ||= begin\n http = Net::HTTP.new(API_HOST, API_PORT)\n http.use_ssl = true\n http.ca_file = (Twigg.root + 'files' + 'github.pem').to_s\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n uri = ORG_REPOS_ENDPOINT % Config.github.organization\n headers = { 'Authorization' => \"token #{Config.github.token}\" }\n\n [].tap do |names|\n begin # loop: page through project list\n request = Net::HTTP::Get.new(uri, headers)\n response = http.request(request)\n raise \"Bad response #{response.inspect}\" unless response.is_a?(Net::HTTPOK)\n names.concat JSON[response.body].map { |repo| repo['name'] }\n uri = parse_link(response['Link'])\n end until uri.nil?\n end\n end\n end", "def scopes_for(token)\n token = token.github_oauth_token if token.respond_to? :github_oauth_token\n scopes = GH.with(token: token.to_s) { GH.head('user') }.headers['x-oauth-scopes'] if token.present?\n scopes &&= scopes.gsub(/\\s/,'').split(',')\n Array(scopes).sort\n rescue GH::Error\n []\n end", "def index\n @git_hub_repos = GitHubRepo.all\n end", "def orgs\n @orgs ||= begin\n client.organizations.map(&:login)\n rescue Octokit::Unauthorized, Faraday::ConnectionFailed\n []\n end\n end", "def repos\n ReposAPI.new(self)\n end", "def repositories\n octokit.repositories('zold-io').map { |json| json['full_name'] }\n end", "def get_github_repos_already_cloned\n repos = Array.new\n\n configatron.dir.children.each do |repo_name|\n if repo_name.directory?\n begin\n repo = Github.repos.get(\n user: ENV['GITHUB_ACCOUNT'],\n oauth_token: ENV['GITHUB_API_TOKEN'],\n repo: repo_name.basename.to_s\n )\n rescue Exception => e\n puts \"\\n#{e}\"\n next\n end\n repos << repo if repo.fork\n end\n end # configatron.dir.children.each do |repo_name|\n\n return repos\nend", "def available_projects_list\n uri = \"#{@api_url}?access_token=#{@access_token}\"\n get uri\n end", "def repositories\n\t\t\telems = []\n\t\t\tget_resource_link(:datacenterrepositories, \"datacenterRepositories\", \"datacenterRepository\").each do |data|\n\t\t\t\telems << Repository.new(data)\n\t\t\tend\n\t\t\telems\n\t\tend", "def index\n @repos = Repo.all\n end", "def gl_repos\n all_repos.select{|x| x.is_a?(Repository::Git)}\n end", "def find_repos(user)\n user.repos\n end", "def index\n @repositories = policy_scope(Repository)\n @team_repositories = Repository\n .joins(namespace: { team: :users })\n .where(\"users.id = :user_id\", user_id: current_user.id)\n @other_repositories = @repositories - @team_repositories\n @team_repositories_serialized = API::Entities::Repositories.represent(\n @team_repositories,\n current_user: current_user,\n type: :internal\n ).to_json\n @other_repositories_serialized = API::Entities::Repositories.represent(\n @other_repositories,\n current_user: current_user,\n type: :internal\n ).to_json\n end", "def repositories\n client.repositories(user_repo, @options)\n end", "def get_list_shared_libraries\n JSON.parse(curl_get(\"shared-repos/\").body_str)\n end", "def get_repos_by_orga(orga) \n\t\treturn self.fetch(\"repos?owner_name=#{orga}\")\n\tend", "def get_repos\n\t\tif current_user.nil?\n\t\t\t@repos = Repo.where(:user_id => nil)\n\t\telse\n\t\t\t@repos = current_user.repos\n\t\tend\n\tend", "def index\n repos = CodeburnerUtil.get_repos\n\n render(:json => { \"count\": repos.length, \"results\": repos })\n end", "def repositories\n # TODO : merge with current data\n load_repos\n end", "def list_repo(repo_id)\n response = HTTParty.get(\n GIT_BASE_URL + 'projects/' + repo_id.to_s,\n :headers => {\n 'PRIVATE-TOKEN' => GIT_TOKEN\n }\n )\n Rails.logger.info \"Git server response (list repo): #{response}\"\n return response['content']\n end", "def get_repo_details\n user = User.find_by(uuid: params[:uuid])\n client = Octokit::Client.new(:access_token => user.password)\n repo_map = {}\n client.repository(:user => user.gh_username, :repo => params[:repo_name]).each { |detail|\n repo_map[detail[0]] = detail[1]\n }\n repo_map['languages'] = client.languages(:user => user.gh_username, :repo => params[:repo_name]).map{ |langArray|\n langArray[0]\n }\n render :json => repo_map\n end", "def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end", "def find_repos\n @current_user ||= User.find(session[:user_id]) if session[:user_id]\n @client = Octokit::Client.new(:access_token => @current_user.token)\n\n # get user input from API\n user_input_string = request.params[:_json]\n input_arr = user_input_string.gsub(/\\s+/, \"\").split(\",\")\n\n # search repos using user input\n repoids = input_arr.map do |input|\n repo = @client.repository(input)\n \"#{repo.to_hash[:id]}\"\n end\n\n # Save user search input and repos to UserPreference\n @current_user.UserPreference.search_input = user_input_string\n @current_user.UserPreference.repos = repoids.join(\",\")\n @current_user.UserPreference.save\n\n respond_to do |format|\n format.json {\n render json: repoids.to_json, status: 200\n }\n end\n end", "def all\n return @raw_repos unless @raw_repos.empty?\n return [Template.root.basename.to_s] if Template.project?\n Template.root.join(Meta.new({}).repos_dir).children.map do |path|\n path.basename.to_s\n end\n\n rescue Errno::ENOENT\n then raise(\n Error::RepoNotFound\n )\n end", "def static_list_repositories\n %w[https://github.com/iwc-workflows/sars-cov-2-variation-reporting.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-artic-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-ont-artic-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-se-illumina-wgs-variant-calling.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-wgs-variant-calling.git\n https://github.com/iwc-workflows/parallel-accession-download.git\n https://github.com/iwc-workflows/sars-cov-2-consensus-from-variation.git\n https://github.com/iwc-workflows/sars-cov-2-pe-illumina-artic-ivar-analysis.git\n https://github.com/iwc-workflows/fragment-based-docking-scoring.git\n https://github.com/iwc-workflows/protein-ligand-complex-parameterization.git\n https://github.com/iwc-workflows/gromacs-mmgbsa.git\n https://github.com/iwc-workflows/gromacs-dctmd.git].map { |r| { 'clone_url' => r }}\n end", "def repos(show_commits = false)\n response = @github.repos.list(user: 'siakaramalegos', sort: 'updated', direction: 'desc', page: 1, per_page: 10)\n repos = response.body\n\n repos.each_with_index do |repo, index|\n puts '-' * 80\n date_string = repo.updated_at\n date = DateTime.parse(date_string).to_date\n puts \"(#{index + 1}) #{repo.name}: #{repo.description} (updated: #{date.stamp('12/30/99')})\"\n\n if show_commits\n repo_commits = @github.repos.commits.list('siakaramalegos', repo.name, page: 1, per_page: 10).body\n\n repo_commits.each do |c|\n date_string = c.commit.author.date\n date = DateTime.parse(date_string).to_date\n puts \" #{c.commit.message} (#{date.stamp('12/30/99')})\"\n end\n end\n end\n puts '-' * 80\n repos\n end", "def list\n @connection.get('/user/orgs').map do |org_data|\n GitHubApi::Org.new(self, org_data)\n end\n end", "def list_repos(org_login)\n @connection.get(\"/orgs/#{org_login}/repos\").map do |repo_data|\n GitHubApi::Repo.new(@connection.repos, repo_data)\n end\n end", "def repos(opts={ push: false, details: false, orgs: true })\n repos = @client.repositories.map {|repo| parse_repo repo}\n @client.organizations.each do |org|\n repos += @client.organization_repositories(org.login).map {|repo| parse_repo repo}\n end\n repos.reject! {|repo| !repo[:push]} if opts[:push]\n repos.map { |repo| repo[:full_name] } unless opts[:details]\n end", "def pull_requests repo\n name = full_name repo\n \n %w[open closed].reduce([]) do |memo, state|\n memo | octokit.pulls(name, state, :per_page=>100)\n end\n end", "def get_all_commits_in_repo\n @branches.collect(&:commits).flatten.sort_by { |k| k.authored_date }.reverse\n end", "def repo_files\n @vault.sys.auths.select { |_,v| v.type == 'approle' }\n .keys\n .inject([]) { |acc, elem| acc + role_files(elem) }\n end", "def structure_repo_ids\n default_struct_map['contents'].map { |content| content['contents'].map { |content| content['repo_id'] } }.flatten\n end", "def user_repos\n @user_repos ||= (\n talk 'user repos'\n client.repos\n )\n end", "def repo_files\n @vault.sys.auths.select { |_,v| v.type == 'ldap' }\n .keys\n .inject([]) { |acc, elem| acc + group_files(elem) }\n end", "def list_files repos\n raise \"required repository name\" unless repos\n res = HTTPClient.get_content(\"https://github.com/#{repos}/downloads\", {\n \"login\" => @login,\n \"token\" => @token\n })\n Nokogiri::HTML(res).xpath('id(\"manual_downloads\")/li').map do |fileinfo|\n obj = {\n :description => fileinfo.at_xpath('descendant::h4').text.force_encoding('BINARY').gsub(/.+?\\xe2\\x80\\x94 (.+?)(\\n\\s*)?$/m, '\\1'),\n :date => fileinfo.at_xpath('descendant::p/time').attribute('title').text,\n :size => fileinfo.at_xpath('descendant::p/strong').text,\n :id => /\\d+$/.match(fileinfo.at_xpath('a').attribute('href').text)[0]\n }\n anchor = fileinfo.at_xpath('descendant::h4/a')\n obj[:link] = anchor.attribute('href').text\n obj[:name] = anchor.text\n obj\n end\n end", "def index\n if (params[:search]) && (params[:search].empty? == false) \n urlformated = URI.encode(params[:search])\n uri = URI.parse(\"https://api.github.com/legacy/repos/search/#{urlformated}\")\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = (uri.scheme == 'https')\n \n \n request = Net::HTTP::Get.new(uri.request_uri)\n \n res = http.request(request)\n response = JSON.parse(res.body)\n \n\n repository = response['repositories'].map {|rd|\\\n GithubRepository.new( rd['owner'], rd['name'],\\\n rd['description'], rd['language'], rd['url'])} \n \n @github_repositories = repository\n else\n @github_repositories = nil\n end \n end", "def repositories_to_fetch\n # Find all .git Repositories - Ignore *.wiki.git\n repos = Dir.glob(\"#{@config['git']['repos']}/*/*{[!.wiki]}.git\")\n\n # Build up array of NOT ignored repositories\n delete_path = []\n @config['ignore'].each do |ignored|\n path = File.join(@config['git']['repos'], ignored)\n delete_path += repos.grep /^#{path}/\n repos.delete(delete_path)\n end\n\n return repos - delete_path\n\n end", "def repositories_with_pull_requests(reponames = [])\n repositories = []\n page = 1\n loop do\n repositories_in_page = load_repos_in_page(page)\n break if repositories_in_page.empty?\n repositories.concat(repositories_in_page)\n page += 1\n end\n repositories.select! { |repo| reponames.include?(repo.name) } unless reponames.empty?\n repositories.select!(&:any_pull_requests?)\n repositories\n end", "def get_all_commits(repo)\n all_commits = []\n page = 0\n page_size = 10\n commits = repo.commits('master', page_size, page)\n while commits.length > 0\n all_commits = all_commits + commits\n page = page + page_size\n commits = repo.commits('master', page_size, page)\n end\n return all_commits\nend", "def show\n user= params[:user]\n repo= params[:repo]\n puts user\n puts repo\n url = BASE_URL + \"repos/\" + user + \"/\" + repo + \"/collaborators\"+ \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n # url = BASE_URL + \"repos/rails/rails/collaborators\"\n # url = BASE_URL + \"repositories\"\n @repo = JSON.parse(open(url).read)\n @results = []\n\n\n @repo.each do |doc|\n ids = doc['login']\n url_people = BASE_URL + \"users/\" + ids + \"?client_id=e24305f14f7f9a67c465&client_secret=604015f905f6207ec29f3661b952397663d58347\"\n @results << JSON.parse(open(url_people).read)\n end\n\n end", "def index\n @git_hub_accounts = GitHubAccount.all\n end", "def get_repo_list(ssh: false)\n CSV.generate do |csv|\n self.groupings.includes(:group).each do |grouping|\n group = grouping.group\n data = [group.group_name, group.repository_external_access_url]\n data << group.repository_ssh_access_url if ssh\n csv << data\n end\n end\n end", "def keys\n authorized_keys = []\n if team.present?\n log \"Got Github Team '#{team.name}' for Org '#{@org}'\"\n\n members = team_members(team.id)\n\n members.each do |member|\n log(\"Getting Member...#{member.login}\")\n\n keys = keys_for(member.login)\n\n # Can't get the real email address without logging in as that user\n email = \"#{member.login}@github.com\"\n\n keys.each do |key|\n authorized_keys << [key[:key], email]\n end\n end\n else\n log(\"No '#{@team_name}' team for '#{@org}' found\")\n log(teams.inspect)\n end\n authorized_keys\n end", "def get_overview(repo_ids)\n result = {}\n repo_ids.each do |repo_id|\n result[repo_id] = JSON.parse(@redis.get('overview_' + repo_id), symbolize_names: true)\n end\n result\n end", "def github_fetch_tags\n tags = []\n page_i = 0\n count_pages = calculate_pages(@client, \"tags\", {})\n\n iterate_pages(@client, \"tags\") do |new_tags|\n page_i += PER_PAGE_NUMBER\n print_in_same_line(\"Fetching tags... #{page_i}/#{count_pages * PER_PAGE_NUMBER}\")\n tags.concat(new_tags)\n end\n print_empty_line\n\n if tags.count == 0\n Helper.log.warn \"Warning: Can't find any tags in repo. \\\nMake sure, that you push tags to remote repo via 'git push --tags'\"\n else\n Helper.log.info \"Found #{tags.count} tags\"\n end\n # tags are a Sawyer::Resource. Convert to hash\n tags.map { |resource| stringify_keys_deep(resource.to_hash) }\n end", "def github_logins\n pull_request_commits.select(&:author).map(&:author).map(&:login).uniq\n end", "def index\n @jira_repos = JiraRepo.all\n end", "def index\n @repositories = current_user.repositories\n respond_to do |format|\n format.html { redirect_to session_url }\n format.json { render json: @repositories }\n end\n end", "def get_commits(username)\n author = username\n year_commit_list = []\n total_commit_count = 0\n\n ### Using 'github_api' gem for fetching names out of GET request to api.github.com\n repos_names = @github.repos.list(user: author).map {|repo| repo[:name]}\n\n repos_names.each_with_index do |repo_name, index|\n ### Using 'github_api' gem for fetching stats, for particular user and repository name, which is taken from 'repos_names' array\n commits = @github.repos.stats.participation(user: author, repo: repo_name)\n owner_commits_count = 0\n if commits[:owner]\n owner_commits_count = commits[:owner].inject(0) {|memo, i| memo + i}\n end\n ### Counting all commits for a year(for current repository) just for owner\n year_commit_list << \"#{index+1})#{repo_name} - #{owner_commits_count}\"\n ### Counting total number of commits for specific user, for all his public repositories withing a year period\n total_commit_count += owner_commits_count\n end\n\n puts \"Owner name: #{author}\"\n puts \"----------------------\"\n year_commit_list.each {|item| puts item}\n puts \"----------------------\"\n puts \"Total for a year: #{total_commit_count} commits\"\n puts \"----------------------\"\nend", "def watched_repos\n @repos ||= get(\"/repos/watched/#{login}\")['repositories'].map { |r| Repo.new(connection, r) }\n end", "def get_user_repos(username) # :yields: JSON\n uri=URI.parse(@@uri_builder.user_repos_url(username,@@app_token))\n http=HttpHandler.initiate_http(uri)\n begin\n response=HttpHandler.get_response(http,uri)\n rescue ArgumentError\n puts \"Request failed with code: #{response.code}\"\n else\n @@responseStatus=true\n return response\n end\n end", "def get_public_repos(user_name)\n get(\"/users/#{user_name}/repos\")\n end", "def get_all_tags\n print \"Fetching tags...\\r\" if @options[:verbose]\n\n check_github_response { github_fetch_tags }\n end" ]
[ "0.72552896", "0.7195828", "0.7124684", "0.71223515", "0.7069559", "0.700496", "0.69649553", "0.6962621", "0.6920793", "0.6894719", "0.6890018", "0.68424547", "0.683883", "0.68136215", "0.6794929", "0.67660946", "0.6756994", "0.67404073", "0.670515", "0.6693565", "0.659786", "0.6563928", "0.65629345", "0.65370774", "0.6527478", "0.6491877", "0.64735276", "0.6430372", "0.642931", "0.64268726", "0.64199775", "0.6395212", "0.6356356", "0.63560313", "0.6344184", "0.6325407", "0.63173956", "0.62840176", "0.6281907", "0.6254678", "0.6243131", "0.6235949", "0.62296164", "0.62023664", "0.61884695", "0.61434734", "0.61420155", "0.61374265", "0.61038214", "0.609536", "0.6083429", "0.6082459", "0.60690147", "0.60688287", "0.60357726", "0.60226077", "0.60134315", "0.6013278", "0.60089624", "0.5989027", "0.5987717", "0.5983509", "0.598168", "0.5978251", "0.59729475", "0.59664166", "0.59365475", "0.59343815", "0.58902735", "0.588416", "0.58754015", "0.5874684", "0.58723134", "0.58715165", "0.5863602", "0.58567834", "0.5819769", "0.5813184", "0.5793748", "0.5773402", "0.57537484", "0.575206", "0.5728594", "0.57082754", "0.57071686", "0.5700096", "0.5698536", "0.56853163", "0.56805295", "0.5678067", "0.5677143", "0.567632", "0.5660304", "0.56594974", "0.56510633", "0.5649849", "0.5649766", "0.56480426", "0.5644185", "0.56420636" ]
0.7971248
0
Returns organizations where user is admin
def own_organizations api.org_memberships.select { |org| org[:role] == "admin"} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def organizations_by_user(user)\n @organizations.values.select { |org| org.is_member?(user) }\n end", "def active_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper).flatten\n end", "def admins\n app_users.select(&:admin?)\n end", "def all_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper(false)).flatten\n end", "def admins\n contributors.where(admin: true)\n end", "def active_admins\n admins.select { |admin| circle.has_active_user?(admin) }\n end", "def active_admins\n admins.select {|admin| circle.has_active_user?(admin) }\n end", "def managed_organizations\n if has_role?(:org_admin)\n org_ids = roles.where(name: Role::NAMES[:org_admin]).first.ref_ids\n Organization.in(id: org_ids)\n else\n []\n end\n end", "def index\n @admins_organizations = Organization.all\n end", "def other_administrators\n Administrator.where.not(['id = ? or is_super = ?',self.id, true]).order(:organisation).map {\n |t| ['%{org}: %{lname} %{name}'%{org: t.organisation, lname: t.info.last_name, name: t.info.name},t.id]\n }\n end", "def admin_index\n authorize User\n @users = current_user.org.users.includes(:roles)\n end", "def admin_organization_stats\n get_admin_stats \"orgs\"\n end", "def administrators\n members.where(memberships: { role: 'admin' })\n end", "def list_organizations\r\n Organization.organizations_by_user(self)\r\n end", "def admin_of?(organization)\n organizations.where(id: organization).exists?\n end", "def admins\n User.where(id: memberships.admin.pluck(:user_id)).all\n end", "def admins\n # Use the where clause to return users who have admin column set to true (false by default)\n board_members.where(is_admin: true)\n end", "def administrators\n adminrole = Role.find(:first, :conditions => \"#{self.class.primary_key}=#{self.id} AND name='Administrator'\")\n adminrole ?\n adminrole.users.select{|u| u.company==self} : nil\n end", "def index\n redirect_to :root unless current_user.is_admin?\n @organizations = Organization.all\n end", "def set_visible_orgs\n @visible_orgs ||= Organization.find_by_user(logged_in_user.username)\n end", "def get_admins\n\t\t@sm = Member.where(society_id: self.id)\n\t\t@admins = []\n\t\t@sm.each do |m|\n\t\t #if is an admin, add to array\n\t\t if m.admin then @admins << User.find_by_id(m.user_id) end\n\t\tend\n\t\treturn @admins\n end", "def project_administrators\n people_with_the_role(Seek::Roles::PROJECT_ADMINISTRATOR)\n end", "def project_administrators\n people_with_the_role(Seek::Roles::PROJECT_ADMINISTRATOR)\n end", "def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end", "def set_admins_organization\n @admins_organization = Organization.find(params[:id])\n end", "def orgadmin_user\n unless current_user.orgadmin?\n flash_org_admin_rights\n redirect_to(root_path)\n end\n end", "def current_user_oganizations\n endpoint = '/api/user/orgs'\n @logger.debug(\"Getting current user organizations (GET #{endpoint})\") if @debug\n get(endpoint)\n end", "def index\n @employees = User.where(admin: true)\n end", "def get_admins_by_id\n return filter_by_id(get_admins)\n end", "def admins\n [self.user.email, self.study_shares.can_edit, User.where(admin: true).pluck(:email)].flatten.uniq\n end", "def admins\n [self.user.email, self.user_annotation_shares.can_edit, User.where(admin: true).pluck(:email)].flatten.uniq\n end", "def admin_organizations_with_protocols\n Organization.authorized_for_identity(@id).joins(:sub_service_requests)\n end", "def orgs\n client.organizations\n end", "def is_organization_admin?\n #self.is_head?\n level >= USER_LEVELS[\"organization_admin\"] && level <= USER_LEVELS[\"system_admin\"]\n end", "def admin_for_companies\n get(\"/organizationalEntityAcls?q=roleAssignee&role=ADMINISTRATOR&state=APPROVED&count=100\")\n end", "def admin\n @admin_users = User.where(isAdmin:true).where(isApproved:true).paginate(:page => params[:admin_users_page], :per_page => 10)\n end", "def admin?\n Site.where(:memberships => { '$elemMatch' => { :account_id => self._id, :role => :admin } }).count > 0\n end", "def organizations_with_access(access_type = ACCESS_STATES[:RESTRICTED])\n subscribed_organizations.includes(teams: :subscriptions).where(\"subscriptions.access_type = ?\", access_type)\n end", "def index\n authorize Admin\n @admins = User.find_by_sql([\"select * from users where role = ?\",2])\n end", "def admin_organization\n\t if admin && organization_id==nil\n\t \terrors.add(:organization_id, \"Event organizers must select the organization they belong to.\")\n\t end\n\tend", "def viewable_by(user, organization)\n group_ids = user.organization_group_ids(organization)\n joined = all.left_joins(roles: %i[users_roles groups_roles])\n joined.where(UsersRole.arel_table[:user_id].eq(user.id)).or(\n joined.where(GroupsRole.arel_table[:group_id].in(group_ids)),\n ).distinct # because of left joins\n end", "def admins\n ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Admin)\n end", "def require_organization_admin_user\n require_admin_user\n unless current_user.is_god?\n if params[:organization_id] && (params[:organization_id].to_i != current_user.organization_id)\n redirect_back_or_default('/')\n false\n end\n end\n end", "def contacts\n @employees = User.where(admin: true)\n end", "def admin()\n @data[\"access\"][\"user\"][\"roles\"].each do |role|\n if role[\"name\"].eql?(\"admin\")\n return true\n end\n end\n return false\n end", "def organizations\n self.organization_ids.map do |uid|\n MnoEnterprise::Organization.find_by(uid: uid)\n end\n end", "def only_for_admins\n raise ActiveRecord::RecordNotFound unless current_user.has_role? :admin\n end", "def user_admin\n user_role.in? [\"Department Admin\",\"College Admin\",\"Tech User\"] if user_role\n end", "def admin?\n c_user = current_user\n not c_user.nil? and c_user.group==\"admin\"\n end", "def is_admin? oid\n admins.include? oid\n end", "def owner_and_coowners\n vals = Role.access_values_for(:creator).concat(Role.access_values_for(:administrator))\n User.joins(:roles).where(\"roles.plan_id = ? AND roles.access IN (?)\", self.id, vals)\n end", "def orgs\n @orgs ||= begin\n client.organizations.map(&:login)\n rescue Octokit::Unauthorized, Faraday::ConnectionFailed\n []\n end\n end", "def admin?\n Site.where(memberships: { '$elemMatch' => { account_id: self._id, role: :admin } }).count > 0\n end", "def list_org\n @users = User.where(organization: true)\n\n render \"list_org\"\n end", "def get_project_administrators(project_id_or_key)\n get(\"projects/#{project_id_or_key}/administrators\")\n end", "def admin?(user)\n user.role_names.include?('cmsadmin')\n end", "def find_organizations\n Organization.all\n end", "def orgs(enterprise = 'default')\n @api.orgs enterprise\n end", "def group_admins\n group.blank? ? [] : group.has_admins\n end", "def get_admins\n self._get_reviewers(\"admin\")\n end", "def index\n # Get page number\n page = params[:page].nil? ? 1 : params[:page]\n\n if current_user.admin?\n @organizations = Organization.all.paginate(page: page, per_page: PAGE_COUNT)\n else\n if current_user.organization\n redirect_to current_user.organization\n else\n redirect_to new_organization_path\n end\n end\n end", "def get_user_organizations(user_id)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n\n get \"#{users_path}/#{user_id}/organizations\"\n end", "def organizations(org_list = nil)\n if org_list\n return org_list if dashboard_type == 'template'\n org_list.to_a.select { |e| organization_ids.include?(e.uid) || organization_ids.include?(e.id) }\n else\n MnoEnterprise::Organization.where('uid.in' => organization_ids).to_a\n end\n end", "def is_admin?(user)\r\n self.admins.one? { |email, admin| email == user.email }\r\n end", "def index\n @user_organizations = UserOrganization.all\n end", "def list_scope_admins(scope = {})\n role = find_role_by_name(\"admin\")\n list_scope_assigned_users(scope.merge(role: role))\n end", "def administrator?\n immortal? or groups.find_by_administrators true\n end", "def admin?(user = nil)\n membership = Membership.find_by group_id: id, user_id: user.id,\n role: 'admin'\n return false if membership.nil?\n membership.user_id == user.id\n end", "def admin_of(group)\n current_user.is_admin?(group)\n end", "def user_admin?(login, repo, settings)\n user_in_group?(login, repo, settings, 'repo_to_admin_teams')\n end", "def set_filtered_organizations\n scope = current_user.organizations.includes(:assignments, :group_assignments).filter_by_search(@query)\n\n scope = case @current_view_mode\n when \"Archived\" then scope.archived\n when \"Active\" then scope.not_archived\n else scope\n end\n\n @organizations = scope\n .order_by_sort_mode(@current_sort_mode)\n .order(:id)\n .page(params[:page])\n .per(12)\n end", "def organisers\n org = []\n organiser_ids = self.listings.map {|listing| listing.organiser_id}\n User.all.select do |user|\n if organiser_ids.any?(user.id)\n org << user\n end\n end\n org.uniq\n end", "def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end", "def admin\n check_admin_without_render(current_user)\n @users = User.find(:all, :order => \"updated_at\", :conditions => [\"junk is NOT NULL\", ])\n end", "def current_organization_users\n endpoint = '/api/org/users'\n @logger.debug(\"Getting organization users (GET #{endpoint})\") if @debug\n get(endpoint)\n end", "def admin?(&block)\n if @sso_groups.include?(\"Admin\") || @user.role_id >= 2\n concat(capture(&block))\n end\n end", "def admin\n [\"true\",\"1\"].include?(query[\"admin\"])\n end", "def user_project_admin?\n project = Project.getActive\n admin_emails = project[:data]['adminEmails']\n admin_emails.include?(current_user.email) &&\n (\n !current_user.user_role ||\n current_user.user_role.name != 'admin'\n )\n end", "def admins\n group_users(admins_join_table)\n end", "def admin?\n roles.all.map(&:title).include?(\"admin\")\n end", "def admin_user\n @current_user.admin?\n end", "def get_organizations\n params = {\n 'method' => :get,\n 'command' => '/org'\n }\n\n response, headers = send_request(params)\n orgs = response.css('OrgList Org')\n\n results = {}\n orgs.each do |org|\n results[org['name']] = org['href'].gsub(\"#{@api_url}/org/\", \"\")\n end\n results\n end", "def index\n authorize Admin\n @admins = initialize_grid(Admin.where(\"id != ?\", current_admin.id).order('id desc'), per_page: 10)\n end", "def list_cloud_resource_admins\n domain = domains(name: Rails.configuration.cloud_admin_domain).first\n return [] unless domain\n project =\n projects(\n domain_id: domain.id,\n name: Rails.configuration.cloud_admin_project,\n ).first\n return [] unless project\n list_scope_resource_admins(\n { project_id: project.id },\n \"cloud_resource_admin\",\n )\n end", "def index\n @organization_accounts = OrganizationAccount.all.sort_by(&:organization_name).reverse\n \n if user_signed_in? && current_user.admin?\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organization_accounts }\n end\n else\n redirect_to root_path\n end\n end", "def admin_user\n #redirect_to(root_url) unless\n current_user.admin || current_user.super_admin?# || top_layer_administrator\n end", "def list_ccadmins\n domain = domains(name: Rails.configuration.cloud_admin_domain).first\n return [] unless domain\n list_scope_admins(domain_id: domain.id)\n end", "def fetch_admins\n admin_objs = Admin.not_deleted.where(default_client_id: @client_id).order({id: :desc}).all\n admin_objs.each do |admin|\n @admin_user_count += 1\n @curr_page_data << {\n id: admin.id,\n name: admin.name,\n email: admin.email,\n status: admin.status,\n role: admin.role\n }\n end\n\n @can_invite_new_user = (@admin.role == GlobalConstant::Admin.super_admin_role && @admin_user_count < 20) ? true : false\n end", "def owners\n get_user_with_role(:owner)\n end", "def can_be_administered_by?(user = User.current_user)\n return false unless user\n user.is_admin? || user.is_project_administrator?(self) || user.is_programme_administrator?(programme)\n end", "def administrators\n @users = User.admin.search_sort_paginate(params)\n end", "def user_is_admin?\n ALLOWED_USERS.include? current_user.email\n end", "def managers\n course_enrollments.where(course_roles: { can_manage_course: true }).\n map(&:user)\n end", "def index\n @user_admins = UserAdmin.all\n end", "def get_organization_and_check_permission\n @organization = current_user.is_cesia? ? ::Organization.find(params[:id]) : current_organization\n authorize @organization\n end", "def read_all(user_guid)\n organizations_list = []\n orgs_list = @client.organizations\n\n orgs_list.each do |org|\n owner = org.managers.find { |manager| manager.guid == user_guid }\n billing = org.billing_managers.find { |billing| billing.guid == user_guid }\n auditor = org.auditors.find { |auditor| auditor.guid == user_guid }\n\n if owner || billing || auditor\n organizations_list << Organization.new(org.name, 0, org.users.count, org.guid, false)\n end\n end\n\n organizations_list.sort! { |first_org, second_org| first_org.name.downcase <=> second_org.name.downcase }\n end", "def local_admins\n\tlist_of_users_tocheck = []\n\tfor x in Dir.entries(\"/Users\")\n\t\tif !x.start_with?(\".\")\n\t\t\tlist_of_users_tocheck.push(x)\n\t\tend\n\tend\n\n\tlocaladmins = []\n\tfor x in list_of_users_tocheck\n\t\tif `dsmemberutil checkmembership -U #{x} -G admin 2>/dev/null`.chomp == \"user is a member of the group\"\n\t\tlocaladmins.push(x)\n\t\tend\n\tend\n\tputs \"Local Admins:\"\n\treturn localadmins\nend", "def admin_labs\n self.roles.where(name: \"admin\", resource_type: \"Lab\")\n end", "def admin?\n isAdmin = false ; \n self.role.each { |r|\n if r.name == 'Administrator'\n isAdmin = true\n end\n \n }\n return isAdmin\n end", "def index\n if current_user.admin?\n @users = User.all\n end\n \n end" ]
[ "0.73870474", "0.7298261", "0.72521496", "0.7235908", "0.72211736", "0.71670115", "0.71518266", "0.70152676", "0.69716513", "0.69662064", "0.69344085", "0.6912834", "0.68772995", "0.6868512", "0.68435663", "0.67940855", "0.6750358", "0.6749135", "0.6709109", "0.66911966", "0.668162", "0.66214603", "0.66214603", "0.66030794", "0.65936834", "0.6523456", "0.6496385", "0.64811814", "0.64793223", "0.6440178", "0.64315987", "0.6394707", "0.6383138", "0.63774866", "0.63652664", "0.63566417", "0.63285565", "0.6302059", "0.625888", "0.625726", "0.62531984", "0.6238221", "0.6237804", "0.62118876", "0.6211833", "0.6201378", "0.6200182", "0.61595917", "0.61589575", "0.6154664", "0.6147165", "0.61437964", "0.6134646", "0.6117979", "0.61103296", "0.6096442", "0.60918766", "0.60798687", "0.606961", "0.60648555", "0.6056027", "0.6045318", "0.60438454", "0.6039638", "0.6032596", "0.60244256", "0.6021934", "0.6016739", "0.6014121", "0.6009933", "0.59724176", "0.5970553", "0.5966334", "0.59633", "0.5939104", "0.59344965", "0.59342515", "0.59217584", "0.5900612", "0.58973974", "0.58936054", "0.5891023", "0.5885227", "0.58809966", "0.5875547", "0.58702296", "0.5864815", "0.58617485", "0.5850465", "0.58498544", "0.5844212", "0.58435684", "0.58417475", "0.5838351", "0.58294487", "0.58237034", "0.58231235", "0.582296", "0.58199203", "0.5818983" ]
0.7852174
0
Computes the total value of all Bitcoin inputs
def total_input @inputs.inject(:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_coin_total\n @coins.map(&:value).reduce { |sum, num| sum += num }\n end", "def compute_total_value\n @value= @net_price * @count\n end", "def total_in\n @total_in ||= self.in.inject(0){ |m, input|\n m + (input.coinbase? ? total_out : (input.get_prev_out.try(:value) || 0))\n }\n end", "def total\n @state[0]*VALUES[0] + @state[1]*VALUES[1] + @state[2]*VALUES[2] + @state[3]*VALUES[3] + @state[4]*VALUES[4]\n end", "def calculate_sum\n 1000000000000\n end", "def total_coins_value\n json_response({:total_coins_value => @total_coins_val, :status => true, :message => 'calculated'})\n end", "def total(x)\n sum = 0\n\tx.each do |i|\n\t\tsum += i\n\tend\n\treturn sum\nend", "def total ( numbers )\r\n\r\n\treturn numbers.reduce(:+);\r\n\r\nend", "def total\n result = 0\n (1..3).each do |n|\n v = eval \"cost_\" + n.to_s\n result += v.to_f\n end\n result\n end", "def total(input_array)\n\tn = 0\n\tinput_array.each do |x|\n\t\tn += x\n\tend\n\treturn n\nend", "def total(numbers)\n return numbers.reduce(:+)\nend", "def total_output\n @outputs.inject(:+)\n end", "def total(prices)\n amount = 0\n prices.each do |price|\n amount += price\n end\n amount\nend", "def total(prices)\n amount = 0\n prices.each do |price|\n amount += price\n end\n amount\nend", "def total(numbers)\n result = 0\n numbers.each { |x| result += x }\n return result\nend", "def calcular_total hash\n p hash.inject(0) { |sum, tuple| sum += tuple[1] }\n end", "def total(numbers)\n numbers.reduce(:+)\nend", "def total (number)\n sum = 0\n number.each do | x |\n sum += x\n end\n return sum\nend", "def total(a)\n\ta.reduce(:+)\nend", "def sums_all_elements(input)\n input.inject(:+)\n end", "def total_value\n @quantity * @price_per_share\n end", "def total(list)\n list.reduce(:+)\nend", "def for_sum(input)\n output = 0\n input.each do |el|\n output += el\n end\n output\nend", "def total(list)\n\tans = 0\n\tlist.each do |num|\n\t\tans = num + ans\n\tend\nend", "def total\n Float(@values.values.reduce(:+))\n end", "def total(list)\n\tsum = 0\n\tlist.each { |x| sum+=x }\nend", "def value()\n total = self.unique_transactions().values.inject(0, &:+)\n\n self.counts.values.each do |a|\n total += a[\"total\"]\n end\n\n total\n end", "def total\n total = 0\n @products.values.each do |price|\n total += price\n end\n total += (0.075 * total).round(2)\n end", "def sum; end", "def tx_value_in(tx)\n return 0 if tx.is_coinbase?\n value = 0\n tx.inputs.each do |txin|\n txout = @storage.output_for_outpoint(txin.prev_out, txin.prev_out_index)\n value += txout.value\n end\n return value\n end", "def total(arr)\n output = 0\n arr.each do |x|\n output += x\n end\n output\nend", "def total(numbers)\n\tsum = 0\n\tnumbers.each do |x|\n\t\tsum += x.to_f\n\tend\n\treturn sum\nend", "def total(arr)\n\t output = 0\n\t arr.each do |x|\n\t output += x\n\t end\n\t output\nend", "def total(arr)\n\t output = 0\n\t arr.each do |x|\n\t output += x\n\t end\n\t output\nend", "def total (number)\n\tsum = 0\n\tnumber.each do |x| \n\t\tsum = sum + x\n\tend\n\treturn sum\nend", "def total\n sum = 0\n 64.times do |counter|\n sum += (2**counter)\n end\n sum\n end", "def running_total\n sum = 0.00\n @items.each { |item| sum += item[\"price\"] }\n return sum\n end", "def total(numbers)\n\tnumbers.inject(:+)\nend", "def compute_total(type)\n list = capture_amounts(type)\n generate_total(list)\n end", "def total(numbers)\n sum = 0\n numbers.each { |num| sum += num }\n sum\nend", "def total_base_price\n tickets.map(&:base_price).sum\n end", "def total_price\n total = 0\n self.transactions.each do |t|\n total += t.price\n end\n total\n end", "def total(nums)\r\n\ttotal = 0\r\n\r\n\tnums.each do |i|\r\n\t\ttotal += i\r\n\tend\r\n\treturn total\r\nend", "def total(numbers)\n total = 0\n numbers.each do |num|\n total += num\n end\n\n return total\nend", "def total\n # extracts all of the values from the hash and sums them up\n cost = @products.values.sum\n # add 7.5% tax and round to two decimal places\n return (cost * 1.075).round(2)\n end", "def total(list)\n\n p list.reduce(:+)\n \nend", "def sum(num, total) => total += num", "def total(num)\n sum = 0\n num.each do |x|\n sum = sum + x\n end\n return sum\nend", "def total\n # TODO: implement total\n if products.length == 0\n return 0\n end\n ((@products.values.sum)*1.075).round(2)\n end", "def sum_all()\n values = [700, 44, 10, 1, -4, 0, 44, 1001, 88]\n sum = 0\n values.each do |i|\n sum += i\n end\n p sum\nend", "def total\n return 0 if @products.empty?\n total = (@products.sum { |name, price| price } * 1.075).round(2)\n return total\n end", "def total(array)\n sum = 0\n array.each {|x| sum += x}\n return sum\nend", "def total\n sum = 0\n\n @four_result.each do |result|\n sum += result\n end\n @six_result.each do |result|\n sum += result\n end\n @eight_result.each do |result|\n sum += result\n end\n @ten_result.each do |result|\n sum += result\n end\n @twelve_result.each do |result|\n sum += result\n end\n @twenty_result.each do |result|\n sum += result\n end\n @percentile_result.each do |result|\n sum += result\n end\n\n sum\n end", "def checksum(nums, initial_val)\n sum = initial_val\n nums.each do |val|\n sum += val\n end\n sum\nend", "def sum(list)\n\ttotal = 0\n list.each { |ele| total += ele }\n total\nend", "def inputed_value\n Inventory.in_check(self.id).remote_s.sum(\"result_value\").to_f\n end", "def total(num)\n sum = 0\n num.each do |int|\n sum = sum + int\n end\n return sum\nend", "def total_value\r\n return 0 if self.value.nil?\r\n self.value + self.expenses.includes(:expense).map{ |e|\r\n (e.quantity || 0) * (e.expense.signed_price || 0)\r\n }.sum\r\n end", "def total\n @sum = @products.values.inject(0, :+)\n @total = @sum + (@sum * 0.075).round(2)\n return @total\n end", "def total(array)\n sum = 0\n array.each { |i| sum += i}\n return sum\nend", "def total(array)\n sum = 0\n array.each do |x|\n sum += x\nend\nsum\nend", "def total\n conv_price_single * conv_quantity\n end", "def total_value_usd\n @quantity * price_in_usd\n end", "def total(list)\n sum = 0\n for i in list\n sum += i\n end\n sum\nend", "def fees\n total_input - total_output\n end", "def total\n add_products = 0\n @products.each_value do |cost|\n add_products += cost\n end\n total = (add_products + (add_products * 0.075)).round(2)\n return total\n end", "def balance\n sum = 0\n @money.each do |k, v|\n sum += k * v\n end\n sum\n end", "def total(array)\n\tsum = 0\n\tarray.each { |x| sum += x }\t\n\tsum\nend", "def get_Total()\n \t return @outputs[\"Total\"]\n \tend", "def return_sum\n @money = 0\n @transactions.each do |t|\n if t.get_action == 'buy'\n @money = @money + t.get_value\n elsif t.get_action == 'sell'\n @money = @money - t.get_value\n end\n end\n total_value_of_shares - @money\n end", "def total(array)\n \tsum = 0\n \tarray.each do |num|\n sum += num\n end\t\n return sum\n end", "def total_value_of_shares\n total_number_of_shares * @current_value\n end", "def get_total_mined\n call_blockchain_api('totalbc').to_f\n end", "def total(array)\n sum = 0\n array.each { |i| sum += i }\n return sum\nend", "def total; end", "def total\n total = @products.map do |product, price|\n price\n end\n\n return (total.sum * 1.074).round(2)\n end", "def items_value_calc(items)\n value = 0\n\n items.each do |item|\n value += item[:value]\n end\n\n value\n end", "def total_amount\n \t amount = 0\n \t operation_items.each do | oi |\n \t\tamount = amount + oi.amount\n end\n amount\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(array)\n sum = 0\n array.each do |x|\n sum = sum + x\n end\n sum\nend", "def total\n sum = 0\n subtotal = @products.values\n subtotal.each do |price|\n sum += price.to_f\n end\n\n total = (sum * 1.075).round(2)\n return total\n end", "def total (array)\n\tsum=0\n\tarray.each do |n| sum += n\n\tend\n\treturn sum\nend", "def total (array)\n\tsum = 0\n\n\tarray.each {|x| sum = sum + x}\n\treturn sum\nend", "def total (array)\n total = 0\n array.each do |i|\n total += i\nend\nreturn total\nend", "def total_cost\n lifter_membership.reduce(0){ |total, pay| \n total + pay.cost}\n end", "def total(array)\n\tsum = 0\n\tarray.each do |x|\n\t\tsum = sum + x\n\tend\n\tsum\nend", "def total\n if @products == {}\n return 0 \n else\n m = 0\n @products.values.each do |v|\n m += v\n end\n\n sum = (m + (m * 0.075)).round(2)\n return sum\n end\n end", "def total\n if @products.length == 0\n return 0\n else\n total = @products.values.reduce(:+)\n total*= 1.075 #Tax\n total = total.round(2)\n return total\n end\n end", "def compute_sum(numbers)\n sum = 0\n numbers.each do |number|\n sum += number\n end\n return sum\nend", "def compute_sum(numbers)\n sum = 0\n numbers.each do |number|\n sum += number\n end\n return sum\nend", "def total (array)\n sum = 0\n array.each do |i|\n sum + i\n end\n return sum\nend", "def total\n roll_all.reduce(&:+)\n end", "def total(array)\n\ttotal = 0\n\tarray.each do |x|\n\t\ttotal += x\n\tend\n\treturn total\nend", "def total\n sum(:total)\n end", "def total array\n\tsum = 0\n\tarray.each do |x|\n\t\tsum = sum + x\n\tend\n\treturn sum\nend", "def sum\n reduce(0, &:+)\n end", "def total_sum\n rows.collect(&:sum_with_vat).sum\n end", "def value\n @contents.reduce(0){|sum,pizza| sum + pizza.price }\n end", "def total(array)\n sum = 0\n array.each{ |x| sum += x }\nend", "def total(array)\n sum = 0\n array.each{ |x| sum += x }\nend" ]
[ "0.7600391", "0.7212935", "0.7142149", "0.7000208", "0.697509", "0.68985397", "0.6883535", "0.68800914", "0.6854406", "0.6835453", "0.67933196", "0.6783961", "0.67829865", "0.67808646", "0.6757314", "0.67529774", "0.67269516", "0.6686949", "0.66571903", "0.6654099", "0.6643681", "0.66352975", "0.6633165", "0.6631894", "0.66310155", "0.6630713", "0.6628239", "0.6623448", "0.659998", "0.65950716", "0.6595031", "0.65806234", "0.6568459", "0.6568459", "0.6564309", "0.65632766", "0.65619975", "0.655162", "0.65418416", "0.6539226", "0.64984524", "0.6481659", "0.64806855", "0.64608216", "0.6460439", "0.6460291", "0.6459052", "0.64501613", "0.6447815", "0.64448535", "0.64406145", "0.64316", "0.6430732", "0.64287627", "0.6427235", "0.64228463", "0.64150244", "0.6409974", "0.6408953", "0.64055556", "0.64047533", "0.64036596", "0.6403562", "0.63972837", "0.6397131", "0.6389899", "0.6388664", "0.63862205", "0.6385748", "0.638048", "0.63775605", "0.6375467", "0.63714415", "0.6370636", "0.63680845", "0.63627803", "0.63618463", "0.6357805", "0.63570386", "0.63552684", "0.63508", "0.6348399", "0.6346022", "0.63366324", "0.6335465", "0.6334735", "0.6333836", "0.6331399", "0.63312125", "0.63312125", "0.6331068", "0.6329472", "0.63290006", "0.63285226", "0.63209385", "0.63204455", "0.6319604", "0.6319041", "0.63189566", "0.63189566" ]
0.7518649
1
Computes the total value of all Bitcoin outputs
def total_output @outputs.inject(:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_coin_total\n @coins.map(&:value).reduce { |sum, num| sum += num }\n end", "def compute_total_value\n @value= @net_price * @count\n end", "def total_coins_value\n json_response({:total_coins_value => @total_coins_val, :status => true, :message => 'calculated'})\n end", "def get_Total()\n \t return @outputs[\"Total\"]\n \tend", "def value()\n total = self.unique_transactions().values.inject(0, &:+)\n\n self.counts.values.each do |a|\n total += a[\"total\"]\n end\n\n total\n end", "def total\n @state[0]*VALUES[0] + @state[1]*VALUES[1] + @state[2]*VALUES[2] + @state[3]*VALUES[3] + @state[4]*VALUES[4]\n end", "def total_in\n @total_in ||= self.in.inject(0){ |m, input|\n m + (input.coinbase? ? total_out : (input.get_prev_out.try(:value) || 0))\n }\n end", "def total\n result = 0\n (1..3).each do |n|\n v = eval \"cost_\" + n.to_s\n result += v.to_f\n end\n result\n end", "def total\n sum = 0\n\n @four_result.each do |result|\n sum += result\n end\n @six_result.each do |result|\n sum += result\n end\n @eight_result.each do |result|\n sum += result\n end\n @ten_result.each do |result|\n sum += result\n end\n @twelve_result.each do |result|\n sum += result\n end\n @twenty_result.each do |result|\n sum += result\n end\n @percentile_result.each do |result|\n sum += result\n end\n\n sum\n end", "def calculate_sum\n 1000000000000\n end", "def total(arr)\n output = 0\n arr.each do |x|\n output += x\n end\n output\nend", "def total\n sum = 0\n 64.times do |counter|\n sum += (2**counter)\n end\n sum\n end", "def total(arr)\n\t output = 0\n\t arr.each do |x|\n\t output += x\n\t end\n\t output\nend", "def total(arr)\n\t output = 0\n\t arr.each do |x|\n\t output += x\n\t end\n\t output\nend", "def total(x)\n sum = 0\n\tx.each do |i|\n\t\tsum += i\n\tend\n\treturn sum\nend", "def total ( numbers )\r\n\r\n\treturn numbers.reduce(:+);\r\n\r\nend", "def calcular_total hash\n p hash.inject(0) { |sum, tuple| sum += tuple[1] }\n end", "def value()\n total = 0\n\n self.counts.values.each do |a|\n total += a[\"total\"]\n end\n\n total\n end", "def total_value\n @quantity * @price_per_share\n end", "def return_sum\n @money = 0\n @transactions.each do |t|\n if t.get_action == 'buy'\n @money = @money + t.get_value\n elsif t.get_action == 'sell'\n @money = @money - t.get_value\n end\n end\n total_value_of_shares - @money\n end", "def sum_all()\n values = [700, 44, 10, 1, -4, 0, 44, 1001, 88]\n sum = 0\n values.each do |i|\n sum += i\n end\n p sum\nend", "def total\n total = 0\n @products.values.each do |price|\n total += price\n end\n total += (0.075 * total).round(2)\n end", "def total_input\n @inputs.inject(:+)\n end", "def total(numbers)\n result = 0\n numbers.each { |x| result += x }\n return result\nend", "def running_total\n sum = 0.00\n @items.each { |item| sum += item[\"price\"] }\n return sum\n end", "def total\n Float(@values.values.reduce(:+))\n end", "def total\n # extracts all of the values from the hash and sums them up\n cost = @products.values.sum\n # add 7.5% tax and round to two decimal places\n return (cost * 1.075).round(2)\n end", "def total(prices)\n amount = 0\n prices.each do |price|\n amount += price\n end\n amount\nend", "def total(prices)\n amount = 0\n prices.each do |price|\n amount += price\n end\n amount\nend", "def total (number)\n sum = 0\n number.each do | x |\n sum += x\n end\n return sum\nend", "def total\n total = @products.map do |product, price|\n price\n end\n\n return (total.sum * 1.074).round(2)\n end", "def total (number)\n\tsum = 0\n\tnumber.each do |x| \n\t\tsum = sum + x\n\tend\n\treturn sum\nend", "def totalValueIn(outCoin)\n\t\tbtcToOut = 1 / outCoin.exchangeRate()\n\t\n\t\tbtcValue = self.totalValueBTC()\n\t\toutValue = btcValue * btcToOut\n\t\t\n\t\treturn outValue\n\tend", "def total(input_array)\n\tn = 0\n\tinput_array.each do |x|\n\t\tn += x\n\tend\n\treturn n\nend", "def total(numbers)\n\tsum = 0\n\tnumbers.each do |x|\n\t\tsum += x.to_f\n\tend\n\treturn sum\nend", "def total(list)\n\tsum = 0\n\tlist.each { |x| sum+=x }\nend", "def total(list)\n\tans = 0\n\tlist.each do |num|\n\t\tans = num + ans\n\tend\nend", "def tx_value_in(tx)\n return 0 if tx.is_coinbase?\n value = 0\n tx.inputs.each do |txin|\n txout = @storage.output_for_outpoint(txin.prev_out, txin.prev_out_index)\n value += txout.value\n end\n return value\n end", "def total_value_of_shares\n total_number_of_shares * @current_value\n end", "def total\n roll_all.reduce(&:+)\n end", "def total(numbers)\n return numbers.reduce(:+)\nend", "def balance\n sum = 0\n @money.each do |k, v|\n sum += k * v\n end\n sum\n end", "def total_price\n total = 0\n self.transactions.each do |t|\n total += t.price\n end\n total\n end", "def value\n @contents.reduce(0){|sum,pizza| sum + pizza.price }\n end", "def for_sum(input)\n output = 0\n input.each do |el|\n output += el\n end\n output\nend", "def get_Amount()\n \t return @outputs[\"Amount\"]\n \tend", "def total_value_usd\n @quantity * price_in_usd\n end", "def total; end", "def compute_total(type)\n list = capture_amounts(type)\n generate_total(list)\n end", "def total\n sum = 0\n subtotal = @products.values\n subtotal.each do |price|\n sum += price.to_f\n end\n\n total = (sum * 1.075).round(2)\n return total\n end", "def total\n @sum = @products.values.inject(0, :+)\n @total = @sum + (@sum * 0.075).round(2)\n return @total\n end", "def total\n add_products = 0\n @products.each_value do |cost|\n add_products += cost\n end\n total = (add_products + (add_products * 0.075)).round(2)\n return total\n end", "def total\n return (@listOfItem.inject(0){|sum,e| sum += e.total}).round_to(2)\n end", "def total\n # TODO: implement total\n if products.length == 0\n return 0\n end\n ((@products.values.sum)*1.075).round(2)\n end", "def total\n return 0 if @products.empty?\n total = (@products.sum { |name, price| price } * 1.075).round(2)\n return total\n end", "def sum_bets() \n\t\t@sum = 0\n\t\t#loop through players array\n\t\tfor i in 0...@num_players\n\t\t\t@sum += @players[i].bet\n\t\tend\n\t\treturn @sum\n\tend", "def cost \n\n \ttotal=@costItems.reduce(0) do |sum,hm|\n \t\tsum+=hm \n end\n puts total\n end", "def get_total_mined\n call_blockchain_api('totalbc').to_f\n end", "def tx_value_out(tx)\n value = 0\n tx.outputs.each do |txout|\n value += txout.value\n if !valid_money_range(txout.value) || !valid_money_range(value)\n raise TxValidationError, \"CTransaction::GetValueOut() : value out of range\"\n end\n end\n value\n end", "def live_bets_total\n (self.live_bets.map {|bet| bet.amount }).sum\n end", "def compute_total_and_print()\n @total_price=0\n $final_price_list.each do |element| \n @total_price = @total_price + element\n end\n @total_sales_tax=0\n $sales_tax_list.each do |element|\n @total_sales_tax = @total_sales_tax + element\n end\n puts \"Sales Tax : #{@total_sales_tax.round(2)}\"\n puts \"Total : #{@total_price.round(2)}\"\nend", "def sum; end", "def total\n (@products.values.sum * 1.075).round(2)\n end", "def total\n if @products.empty?\n return 0\n else\n total = (@products.values.sum * 1.075).round(2)\n end\n return total\n end", "def total\n if @products == {}\n return 0 \n else\n m = 0\n @products.values.each do |v|\n m += v\n end\n\n sum = (m + (m * 0.075)).round(2)\n return sum\n end\n end", "def total\n total_cost = 0\n \n # Summing up the product cost\n @products.each do |item, cost|\n total_cost += cost\n end\n \n # Calculate a 7.5% tax\n total_order_cost = total_cost * 1.075\n \n # Rounding the result to two decimal places\n return total_order_cost.round(2)\n end", "def total\n array = @products.values\n if array != []\n tally = array.reduce(:+)\n tally += (0.075 * tally)\n return tally.round(2)\n else\n return 0\n end\n end", "def total\n total = (@products.values.sum) * 1.075\n return total.round(2)\n end", "def total\n product_total = 0\n subtotal = 0\n @products.each_value do |prices|\n subtotal += prices\n end\n product_total = (subtotal * 0.075).round(2)+ subtotal\n return product_total\n\n end", "def total\n if @products.length == 0\n return 0\n else\n total = @products.values.reduce(:+)\n total*= 1.075 #Tax\n total = total.round(2)\n return total\n end\n end", "def total(array)\n sum = 0\n array.each {|x| sum += x}\n return sum\nend", "def total(array)\n \tsum = 0\n \tarray.each do |num|\n sum += num\n end\t\n return sum\n end", "def total array\n\tsum = 0\n\tarray.each do |x|\n\t\tsum = sum + x\n\tend\n\treturn sum\nend", "def total_sum\n rows.collect(&:sum_with_vat).sum\n end", "def total(numbers)\n numbers.reduce(:+)\nend", "def total_value_cents\n total_benefits_value\n end", "def total(array)\n\tsum = 0\n\tarray.each { |x| sum += x }\t\n\tsum\nend", "def total_value\r\n return 0 if self.value.nil?\r\n self.value + self.expenses.includes(:expense).map{ |e|\r\n (e.quantity || 0) * (e.expense.signed_price || 0)\r\n }.sum\r\n end", "def total(numbers)\n total = 0\n numbers.each do |num|\n total += num\n end\n\n return total\nend", "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\n\t\tprices = line_items.map {|li| li.price}\n\t\tprices.reduce(0) {|it0, it1| it0+it1}\n\tend", "def total\n conv_price_single * conv_quantity\n end", "def calculate_total\n sub_total = 0\n\n if size\n sub_total += Config.booths[size][:price]\n end\n\n self.add_ons.each do |add_on|\n sub_total += add_on.total\n end\n sub_total += industries.length * 35000\n sub_total += fees.pluck(:amount).reduce(0, &:+)\n\n self.total = sub_total\n self.balance = total - payments.paid.map(&:amount_paid).reduce(0, &:+)\n self\n end", "def total(numbers)\n sum = 0\n numbers.each { |num| sum += num }\n sum\nend", "def total (array)\n\tsum=0\n\tarray.each do |n| sum += n\n\tend\n\treturn sum\nend", "def total(array)\n sum = 0\n array.each do |x|\n sum += x\nend\nsum\nend", "def total(a)\n\ta.reduce(:+)\nend", "def total_benefits_value\n benefits.map{|b| b.total_value_cents}.reduce(:+).to_i\n end", "def total(array)\n\ttotal = 0\n\tarray.each do |x|\n\t\ttotal += x\n\tend\n\treturn total\nend", "def total(array)\n sum = 0\n array.each { |i| sum += i}\n return sum\nend", "def total(nums)\r\n\ttotal = 0\r\n\r\n\tnums.each do |i|\r\n\t\ttotal += i\r\n\tend\r\n\treturn total\r\nend", "def run_total(array)\n sum = 0\n array.map { |num| sum += num }\nend", "def total(array_to_total)\n\t# Declare new sum variable and set to zero\n\tsum = 0\n\t# For each member of array_to_total, add to the sum variable\n\tarray_to_total.each do |x|\n\t\tsum += x\n\tend\n\t# Return the sum variable\n\treturn sum\nend", "def total (array)\n\tsum = 0\n\n\tarray.each {|x| sum = sum + x}\n\treturn sum\nend", "def total\n sum(:total)\n end", "def total(list)\n list.reduce(:+)\nend", "def total (array)\n total = 0\n array.each do |i|\n total += i\nend\nreturn total\nend", "def total(num)\n sum = 0\n num.each do |x|\n sum = sum + x\n end\n return sum\nend", "def total_cost\n lifter_membership.reduce(0){ |total, pay| \n total + pay.cost}\n end", "def opcion4(inventario)\n sum = 0\n inventario.each do |llave,valor|\n sum += valor\n end\n \n puts \"El stock total de la tienda es: #{sum}\"\nend" ]
[ "0.75860184", "0.7155013", "0.7079803", "0.6996463", "0.6787966", "0.6787147", "0.67832524", "0.6652126", "0.66318303", "0.66152173", "0.6614591", "0.66003776", "0.65509325", "0.65509325", "0.65394974", "0.6536221", "0.65268594", "0.65208703", "0.6513868", "0.647227", "0.6468779", "0.64674544", "0.6465587", "0.64408445", "0.6424293", "0.6407757", "0.639458", "0.6383388", "0.6381995", "0.63797915", "0.6333076", "0.6332429", "0.6320844", "0.63156545", "0.63038844", "0.6298206", "0.6293202", "0.62897503", "0.6288802", "0.6288402", "0.6287862", "0.6273412", "0.62716043", "0.6266618", "0.6264702", "0.62631613", "0.6254577", "0.6252498", "0.6249102", "0.6248608", "0.6241359", "0.6235468", "0.6229105", "0.6224032", "0.62224424", "0.6211619", "0.620724", "0.6204458", "0.61952585", "0.6190013", "0.6180033", "0.61696255", "0.6160699", "0.61578774", "0.6156875", "0.61514795", "0.6150191", "0.6147018", "0.6136461", "0.61356163", "0.61323947", "0.6122867", "0.61225677", "0.6118436", "0.6112986", "0.6112148", "0.61105233", "0.6107539", "0.6106757", "0.6106648", "0.61063045", "0.6105794", "0.61047864", "0.6104509", "0.6102452", "0.6101604", "0.61014503", "0.60998267", "0.6095723", "0.6088056", "0.608473", "0.6080401", "0.6078936", "0.6078165", "0.6072072", "0.6068908", "0.60618865", "0.6059198", "0.6059033", "0.60533494" ]
0.7608338
0
Computes the fees paid for the transaction
def fees total_input - total_output end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total_fee\n fee + fee2 + fee3 + fee4\n end", "def fees\n @fees ||= {\n \"insurance_fee\" => (commission * ASSURANCE_SHARE).round(0),\n \"assistance_fee\" => (ASSISTANCE_COST * rental.duration).round(0)\n }.tap { |fees| fees[\"drivy_fee\"] = commission - fees.values.inject(:+) }\n end", "def fee\n (amount * 0.005) if amount\n end", "def fees(period = (Time.now.beginning_of_month - 1).beginning_of_month .. (Time.now.beginning_of_month - 1).end_of_month)\n subscription_payments.where({ :created_at => period }).collect(&:affiliate_amount).sum\n end", "def pvcycle_total_fees\n pvcycle_membership_fee + pvcycle_contribution_fee\n end", "def calculate_fee\n cost = (shooter.current_member? or join_psac) ? 15 : 20\n has_shooter = persisted? ? match.has_more_than_one_shooter?(shooter) : match.has_shooter?(shooter)\n if has_shooter\n cost = 3\n self.squad = 5\n end\n if join_psac\n cost += 30\n end\n self.fee = cost\n end", "def calculate_fee_pounds\n calculate_fee / PENCE_IN_POUND\n end", "def fulfillment_fee\n\t line_items.inject(0.0) {|charge, line_item| charge = charge + (line_item.fulfillment_fee)}\n end", "def fee\n @fee || DEFAULT_FEE\n end", "def trading_fee\n return exchange_trading_fee if exchange_trading_fee > 0\n system_calculated_trading_fee\n end", "def fulfillment_fee\n begin\n if variant.product_costs.where(:retailer_id => self.order.retailer_id).first.fulfillment_fee > 0\n variant.product_costs.where(:retailer_id => self.order.retailer_id).first.fulfillment_fee * quantity\n else\n self.order.retailer.fulfillment_fee * quantity\n end\n rescue\n begin\n self.order.retailer.fulfillment_fee * quantity\n rescue\n 0.0\n end\n end\n end", "def fee_cents\n (fee.to_f * 100.0).round\n end", "def fees(period = (Time.now.beginning_of_month - 1).beginning_of_month .. (Time.now.beginning_of_month - 1).end_of_month)\n subscription_payments.all(:conditions => { :created_at => period }).collect(&:affiliate_amount).sum \n end", "def calculate_fee_amount base_amount\n (base_amount * SITE_FEE_PERCENTAGE).round(2)\n end", "def insurance_fee\n (COMMISSION_RATE * INSURANCE_PART_RATE * price).round\n end", "def fee\n params['amount_fee']\n end", "def donated_amount\n self.fees.purchased.sum(:amount).to_f\n end", "def calculate(t, fraud, type)\r\n#\t\tpp \"1\"\r\n\t\treturn 0.0 if type == 'billable' && self.bid_fee #if this fee is a bid fee and we are not looking at the bid fees then return 0, else continue on\r\n\t#\tpp \"2\"\r\n \t\r\n \tfee = self.fixed if self.price_type == 'F'\r\n \r\n fee = (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min).at_most(self.max) if self.price_type == 'V' #calculate the fee\r\n \r\n return fee if self.sign == '>=' && self.threshold == 0 #if there is no threshold to worry about get out quick...this is what happens the majority of the time\r\n\t\r\n\t\t#if we get here we know we are dealing with a variable fee\r\n\t\t#puts (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min)\r\n\t#\tfee = (self.fixed + (t.amount * self.percent) + (fraud == '1' ? self.fraud : 0)).at_least(self.min).at_most(self.max) #calculate the fee\r\n\t#\tpp fee\r\n\t#\tpp \"3\"\r\n\t#\treturn fee if self.sign == '>=' && self.threshold == 0 #if there is no threshold to worry about get out quick...this is what happens the majority of the time\r\n\t\t\r\n\t\t#otherwise we need to determine the sign and threshold before we can return\r\n\t\tcase self.sign\r\n\t\t\twhen '>'\r\n\t\t\t #pp \">\"\r\n\t\t\t\treturn fee if t.amount > self.threshold\r\n\t\t\twhen '>='\r\n\t\t\t #pp \">=\"\r\n\t\t\t\treturn fee if t.amount >= self.threshold\r\n\t\t\twhen '<'\r\n\t\t\t #pp \"<\"\r\n\t\t\t\treturn fee if t.amount < self.threshold\r\n\t\t\twhen '<='\r\n\t\t\t #pp \"<=\"\r\n\t\t\t\treturn fee if t.amount <= self.threshold\r\n\t\t\telse\r\n\t\t\t #pp \"4\"\r\n\t\t\t\treturn 0.0\r\n\t\tend\r\n\t\t\r\n\t\t#if we get here then we have no idea what to do so just return 0\r\n\t\treturn 0.0\r\n\tend", "def amount_paid\n accepted_payments.sum(:amount).to_f\n end", "def compute_fee(fee_rate: DEFAULT_FEE_RATE)\n self.class.compute_fee(self.data.bytesize, fee_rate: fee_rate)\n end", "def total_non_insured_fees\n total_fee - total_insured_fees\n end", "def total\n (amount + fee) if amount\n end", "def charge_fee\r\n\t\tif_member = Participant.find_by(participantID: participantID)\r\n\t\tif_course = Course.find_by(courseID: courseID)\r\n\t\t\r\n\t\tif if_course != nil && if_member != nil\r\n\t\t\tearlyBirdTime = if_course.startDate.months_ago(1)\r\n\t\t\tif if_member.expirydate > Date.today\r\n\t\t\t\tif Date.today >= earlyBirdTime && Date.today < if_course.startDate\r\n\t\t\t\t\treturn if_course.earlybirdPrice\r\n\t\t\t\telse\r\n\t\t\t\t\treturn if_course.memberPrice\r\n\t\t\t\tend\r\n\t\t\telse\r\n\t\t\t\treturn if_course.nonmemberPrice\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def tot_deposits_made\n Rails.logger.debug(\"*** tot_deposits_made\")\n # note cannot use database sum because big_deposit is not native to database\n dep_result = 0.0\n EmployeeBenefit.where(\n \"employee_id = ? and eff_month = ? and eff_year = ? and deposited_at IS NOT NULL\",\n self.employee_id.to_s,\n self.eff_month.to_s,\n self.eff_year.to_s\n ).each do |eb|\n dep_result += round_money(eb.deposit)\n end\n Rails.logger.debug(\"*** dep_result: #{dep_result.inspect}\")\n return dep_result\n end", "def remaining_funds()\n films = self.find_films_for_each_customer()\n film_fees = films.map{|film| film.price}\n combined_fees = film_fees.sum\n return @funds - combined_fees\n end", "def final_total\n fees = [ticket_fees_in_cents, delivery_fee_in_cents].sum\n reductions = [reduction_code_credit_total].sum\n\n discounted_total + fees - reductions\n end", "def apply_fees\n remove_fees\n unless waive_fees\n #CHALKLE\n self.chalkle_gst_number = Finance::CHALKLE_GST_NUMBER\n self.chalkle_fee = course.chalkle_fee_no_tax\n self.chalkle_gst = course.chalkle_fee_with_tax - chalkle_fee\n \n self.processing_fee = course.processing_fee\n self.processing_gst = course.processing_fee*3/23\n self.processing_fee = course.processing_fee-self.processing_gst\n\n #TEACHER FEE\n if provider_pays_teacher?\n self.teacher_fee = 0\n self.teacher_gst = 0\n else\n if fee_per_attendee?\n self.teacher_fee = course.teacher_cost\n elsif flat_fee?\n confirmed_booking_count = course.bookings.fees_not_waived.paid.confirmed.count\n if confirmed_booking_count > 0\n self.teacher_fee = course.teacher_cost / confirmed_booking_count\n else\n self.teacher_fee = course.teacher_cost\n end\n end\n end\n\n #TEACHER TAX\n if course.teacher.present? && course.teacher.tax_registered?\n self.teacher_gst_number = course.teacher.tax_number\n self.teacher_gst = teacher_fee*3/23\n self.teacher_fee = teacher_fee-teacher_gst\n else\n self.teacher_gst = 0\n self.teacher_gst_number = nil\n end\n\n #PROVIDER\n self.provider_fee = course.provider_fee\n if provider.tax_registered?\n self.provider_gst_number = provider.tax_number\n self.provider_gst = course.provider_fee*3/23\n self.provider_fee = self.provider_fee-self.provider_gst\n else\n self.provider_gst_number = nil\n self.provider_gst = 0\n end\n\n #adjust in case calc_cost is not course cost, should only happen if flat_fee\n difference = course.cost - calc_cost\n if difference != 0\n self.provider_fee = course.provider_fee + difference\n if provider.tax_registered?\n self.provider_gst_number = provider.tax_number\n self.provider_gst = course.provider_fee*3/23\n self.provider_fee = self.provider_fee-self.provider_gst\n else\n self.provider_gst_number = nil\n self.provider_gst = 0\n end\n end\n\n #adjust in case payment has been made already\n difference = cost - calc_cost\n if difference != 0\n #adjust processing_fee\n self.processing_fee = cost * course.provider_plan.processing_fee_percent\n self.processing_gst = self.processing_fee*3/23\n self.processing_fee = self.processing_fee-self.processing_gst\n\n #reset difference to adjust for processing_fee changes\n difference = cost - calc_cost\n\n #if payment exists then adjust provider fee to ensure the payment amount matches calc_cost\n adjustment_for_provider = difference\n adjustment_for_teacher = 0\n\n if provider_fee+provider_gst+difference < 0\n #if adjusted provider_fee is negative then deduct that negative amount from teacher_fee and make provider_fee 0\n adjustment_for_teacher = provider_fee+provider_gst+difference \n self.provider_fee = 0\n self.provider_gst = 0\n else\n self.provider_fee = provider_fee+provider_gst+adjustment_for_provider\n if provider.tax_registered?\n self.provider_gst = provider_fee*3/23\n self.provider_fee = provider_fee - provider_gst\n end\n end\n \n if adjustment_for_teacher != 0\n self.teacher_fee = teacher_fee+teacher_gst+adjustment_for_teacher\n if course.teacher.present? && course.teacher.tax_registered?\n self.teacher_gst = teacher_fee*3/23\n self.teacher_fee = teacher_fee-teacher_gst\n end\n end\n end\n end\n cost\n end", "def host_fee\n (total - net_rate).round(2)\n end", "def update_fee\n\t\tmoney_info = money_info()\n\t\t@fee = money_info['Trade_Fee'] / 100.0\n\tend", "def document_fee\n 0\n end", "def retrieve_fees\n return if stripe_charge_id.nil?\n\n transaction = Stripe::BalanceTransaction.retrieve(stripe_charge.balance_transaction)\n return if transaction.nil?\n\n self.fee = transaction.fee / 100.0\n self.received_amount = transaction.net / 100.0\n save\n end", "def total_paid\n self.user_expenses.reduce(0) { |sum, user_expense| user_expense.paid + sum }\n end", "def fixed_fee_quantity\n qty = billing_frequency.total_months\n sub_starting_at = subscriber.starting_at\n sub_ending_at = subscriber.ending_at\n if self.reading_type_id == ReadingType::RETIRADA && !self.reading_date.blank?\n sub_ending_at = self.reading_date.to_date\n end\n bp_billing_starting_date = billing_period.billing_starting_date\n bp_billing_ending_date = billing_period.billing_ending_date\n begin\n if sub_starting_at > bp_billing_starting_date && sub_starting_at < bp_billing_ending_date\n # Subscriber registerd during the period\n # qty = (bp_billing_ending_date - sub_starting_at).to_i.days.seconds / 1.month.seconds\n qty = ((bp_billing_ending_date - sub_starting_at).days.seconds / 1.month.seconds).round\n end\n if (!sub_ending_at.nil?) && (sub_ending_at > bp_billing_starting_date && sub_ending_at < bp_billing_ending_date)\n # Subscriber withdrawn during the period\n qty = ((sub_ending_at - bp_billing_starting_date).days.seconds / 1.month.seconds).round\n end\n rescue\n qty = billing_frequency.total_months\n end\n return qty\n end", "def fees\n raise Sibit::NotSupportedError, 'Btc.com doesn\\'t provide recommended fees'\n end", "def transaction_fee\n Money.new(-WITHDRAWAL_FEE_IN_CENTS, self.currency)\n end", "def paid_sum\n paid = Money.new(0, 'USD')\n paid += @paid_splits.inject(Money.new(0, 'USD')){ |memo, split| memo + split.sum } if @paid_splits.present?\n paid\n end", "def node_fee(fee_base_msat, fee_proportional_millionths, amount_to_forward)\n fee_base_msat + (amount_to_forward * fee_proportional_millionths) / 1000000\n end", "def fee_as_percentage\n (merchant.fee * 100).to_i\n end", "def fees(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/fees\", options).body)\n fees = response.key?('fees') ? response['fees'] : []\n fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }\n end", "def fees(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/fees\", options).body)\n fees = response.key?('fees') ? response['fees'] : []\n fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }\n end", "def fees(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/fees\", options).body)\n fees = response.key?('fees') ? response['fees'] : []\n fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }\n end", "def total_affiliate_fee\n total = 0.0\n @lines.each {|line| total += (line.li_aff_fee * line.li_qty) }\n total\n end", "def assistance_fee\n ROADSIDE_ASSISSTANCE_FEE_PER_DAY * duration\n end", "def current_payment_fee\n payment.try(:current_fee) || 0\n end", "def compute_unit_rental_price\n per_time_fee + per_mileage_fee\n end", "def charged_fee(amount)\n (amount * merchant.fee)\n end", "def get_processing_fee\n @invoice.amount ? CalcTotal::get_processing_fee(@invoice.amount).round(2) : 0.0\n end", "def total_paid\n payments.collect{|i| i.total_amount or i.calculate_total_amount}.sum + credit_notes.collect{|i| i.total_amount or i.calculate_total_amount}.sum\n end", "def total_amount_passed_to_field_worker\n # it is assumed that the setup fee is deducted from loan disbursement \n total_amount_passed = BigDecimal(\"0\")\n self.membership_to_receive_loan_disbursement.each do |glm|\n glp = glm.group_loan_product \n total_amount_passed += glp.loan_amount - glp.setup_payment_amount\n end\n \n return total_amount_passed\n end", "def order_fee extra_fee=false, bitcoin=false\n fee = APPLICATION_FEE\n fee += FAIL_FEE if extra_fee\n number = bitcoin ? bitcoin_amount : price\n ((number.to_f * fee) * 100.0).to_i\n end", "def total_funds\n self.collect{ |cs| cs.amount.to_f}.inject(0, :+)\n end", "def application_fee\n self[:application_fee] || (unit_price * (COMMISSION_RATE / 100) + TRANSACTION_COST / 100).round(2) || BigDecimal(0)\n end", "def fees\n raise Sibit::NotSupportedError, 'Blockchair doesn\\'t implement fees()'\n end", "def pay_entry_fee(entry_fee)\n # if the guest has enough cash for entry_fee\n if @cash >= entry_fee\n # decrement guest cash by entry_fee\n @cash -= entry_fee\n # update guest entry_paid to true\n update_entry_paid()\n end\n end", "def sum_attorney_fees\n (invoice_lines.sum(:total_attorney_fee)).round(2)\n end", "def profit\n total_before_tax - total_cost\n end", "def profit\n total_before_tax - total_cost\n end", "def total_payment\r\n checks.inject(0.00){|sum, check| sum += check.check_amount.to_f}\r\n end", "def payment_amount\n convert_email_to_user && save\n return override_cost if override_cost.present?\n\n event&.get_cost(member: user&.present?)\n end", "def check_paid\n self.paid_amount = 0\n self.paid = false\n payments.each do |payment|\n self.paid_amount += payment.amount\n end\n \n if self.paid_amount - self.gross_amount >= 0\n self.paid = true\n end\n end", "def total_funds\n self.funding_rounds.sum {|fr| fr.investment}\n end", "def profit\n revenue - total_costs\n end", "def calculate_fee\n Application::courses_fee(course_selections_count > 1 ? :multiple : :single)\n end", "def univ_fee_amount_to_charge()\n raise \"not a university\" if ! university\n payments.select(&:good?).empty? ? payments.first.amount : university.subscription_charge_for_n(univ_dvd_rate)\n end", "def total_funds\n #binding.pry\n funding_rounds.map{|fr| fr.investment}.sum\n end", "def subtotal\n fees = [ticket_fees_in_cents].sum\n\n discounted_total + fees\n end", "def add_money\n @total += fee\n end", "def total_funds\n total = 0\n num_funding_rounds.each do |round| \n total += round.investment\n end\n total\n end", "def value_paid\n self.sale.bitcoin_payments.select{|x| x.confirmations >= 6}.map{|x| x['value']}.sum\n end", "def get_convenience_fee\n @invoice.amount ? CalcTotal::get_convenience_fee(sales_price).round(2) : 0.0\n end", "def final_amount\n amount_paid - discount_value - discount_percent\n end", "def state_fulfillment_fee\n adjustments.eligible.where(:label => 'Additional State Fulfillment Fee').first.amount rescue 0.0\n end", "def profit\n return 0.0 unless self.deliverables.size > 0\n \n # Covers fixed and percentage profit though the +profit+ method being overloaded on the Deliverable types\n return self.deliverables.collect(&:profit).delete_if { |d| d.blank?}.inject { |sum, n| sum + n } || 0.0\n end", "def total_insured_fees\n services.select{|i| i[:btype] && i[:btype] < CASH_BILLING}.sum{|s| s[:fee]} rescue 0\n end", "def calculate_trial_debt\n\n\t\tsales_tax = self.country.sales_tax\n\t\tday_number = Time.now.day\n \tmonth_number = Time.now.month\n \tmonth_days = Time.now.days_in_month\n\n\t\tdebt_proportion = (month_days - day_number + 1).to_f/month_days.to_f\n\n\t\t#debt = self.plan.plan_countries.find_by(country_id: self.country.id).price.to_f * debt_proportion * ( 1 + sales_tax)\n\t\tdebt = self.company_plan_setting.base_price * self.computed_multiplier * debt_proportion * (1 + sales_tax)\n\n\t\treturn debt\n\n\tend", "def fee\n\tparams['mc_fee']\n end", "def total_funds\n self.pledges.collect do |pledge|\n pledge.amount\n end.sum\n end", "def unpaid_amount\n gross_amount - paid_amount\n end", "def total_funds\n my_rounds.map{|rounds| rounds.investment}.sum\n end", "def calculate_pay(trip_cost)\n return trip_cost >= TRIP_FEE ? (trip_cost - TRIP_FEE) * 0.80 : 0.0\n end", "def fee\n params['mc_fee']\n end", "def fee\n params['mc_fee']\n end", "def pay(amount_paid)\n remaining_total = @total - amount_paid\n if remaining_total == remaining_total.abs\n puts \"Your new total is $#{currency(remaining_total)}.\"\n @total -= amount_paid\n else\n change_due = remaining_total.abs\n puts \"Your change is $#{currency(change_due)}.\"\n @total = 0.0\n end\n end", "def outstanding_payment_amount\n (total - amount_paid).round(2)\n end", "def add_fees\n @proposal.fees.each do |bank_account, amounts_by_category|\n amounts_by_category.each do |category, amount|\n category_for_key = category&.downcase&.gsub(' ', '_') || 'none'\n run_task \"add_fees_#{bank_account}_#{category_for_key}\" do\n if transaction = add_fee_transaction(bank_account, amount, category)\n current_state[:transaction_id] = transaction['BankTransactionID']\n end\n end\n end\n end\n end", "def second_payment_sum\n total_sum - first_payment_sum\n end", "def unpaid_amount\n draft ? nil : gross_amount - paid_amount\n end", "def debt_payment\n loan_proceeds = 0\n debt_rate * loan_proceeds\n end", "def compute_fee_for_transaction(tx, fee_rate)\n # Return mining fee if set manually\n return fee if fee\n # Compute fees for this tx by composing a tx with properly sized dummy signatures.\n simulated_tx = tx.dup\n simulated_tx.inputs.each do |txin|\n txout_script = txin.transaction_output.script\n txin.signature_script = txout_script.simulated_signature_script(strict: false) || txout_script\n end\n return simulated_tx.compute_fee(fee_rate: fee_rate)\n end", "def calculate_seller_amount base_amount, fee_amount\n (base_amount - fee_amount).round(2)\n end", "def total_funds\n investments = self.funding_rounds.map do |funding_round|\n funding_round.investment\n end\n investments.sum\n end", "def unpaid_worked_days_amount_for(project)\n self.unpaid_worked_days_for(project) * self.rate\n end", "def payment\n payment = 0\n transactions = finance_transactions\n unless transactions.nil?\n transactions.each do |t|\n payment += t.amount\n end\n end\n payment\n end", "def amount_owed\n invoice_total - total_amount_paid\n end", "def pay_targeted_invoices_first!\n payments.each do |pm|\n if pm.invoice\n @remaining_amounts[pm.invoice.fy_year] ||= Hash.new(0)\n if pm.invoice.canceled?\n @remaining_amounts[pm.invoice.fy_year][pm.invoice.object_type] += pm.amount\n else\n paid_amount = [[pm.amount, pm.invoice.missing_amount].min, 0].max\n pm.invoice.increment!(:paid_amount, paid_amount)\n @remaining_amounts[pm.invoice.fy_year][pm.invoice.object_type] += pm.amount - paid_amount\n end\n else\n @remaining_amount += pm.amount\n end\n end\n end", "def total_raised\n payments.inject(0) { |sum, p| sum + p.amount.to_f }\n end", "def fee\n @ipn['mc_fee']\n end", "def calculate_fee(transaction, params = {})\n amount = transaction.base_amount\n\n if @interchange\n use_payment_source = params[:use_payment_source].to_s == 'true' #todo: better pattern here?\n if use_payment_source\n payment_source = transaction.payor.payment_source_for_type(@payment_service.payment_type)\n bin = payment_source&.get_data_field(:bin)\n else\n card = params[:card_number]\n bin = card ? card[0..5] : nil\n end\n\n if bin.present?\n data = estimate_fee(amount, bin)\n fee = data[:estimated_fee]\n else\n # returns a range when card prefix not provided\n fee_range(amount) # note, returns an array with low/high range when params are missing\n end\n else\n apply_rate(amount)\n end\n end", "def cf\n\t\tself.buy ? (-self.amount-self.fee) : (self.amount - self.fee)\n\tend", "def has_paid (driver, person, amount)\n # debt - amount\n end" ]
[ "0.7749463", "0.74608964", "0.7358724", "0.7254256", "0.7245168", "0.7217393", "0.7161691", "0.7154761", "0.70849466", "0.70822394", "0.7076584", "0.7061791", "0.7057174", "0.696606", "0.6962604", "0.69495636", "0.6942314", "0.6904392", "0.68831974", "0.6873501", "0.6846851", "0.6845054", "0.68337595", "0.6819573", "0.681777", "0.68082756", "0.6787361", "0.6781118", "0.6780105", "0.6761241", "0.67610544", "0.67404455", "0.6731628", "0.6726286", "0.6711262", "0.6697181", "0.669204", "0.66248435", "0.66222185", "0.66222185", "0.66222185", "0.6615778", "0.6601764", "0.65881205", "0.6586208", "0.6583494", "0.6576946", "0.6574772", "0.6570202", "0.6569373", "0.6566905", "0.6562177", "0.656056", "0.65523857", "0.6552276", "0.65519315", "0.65519315", "0.65487814", "0.6540421", "0.6510041", "0.64553803", "0.64543724", "0.64374435", "0.6436442", "0.64105105", "0.63943416", "0.63943034", "0.6372782", "0.6363559", "0.6360425", "0.63557005", "0.6355672", "0.6350845", "0.6335655", "0.63136035", "0.6311565", "0.6309807", "0.63086724", "0.63029975", "0.6301137", "0.62932223", "0.62932223", "0.62923914", "0.62878615", "0.6284016", "0.6271427", "0.62582713", "0.6255319", "0.6248618", "0.62472534", "0.62464", "0.62411916", "0.6238004", "0.6225052", "0.6206859", "0.6205749", "0.6196603", "0.6196022", "0.61886346", "0.6186105" ]
0.78017414
0
Public: Provides all anagrams for a given word. === Parameter(s) +text+ +String+: The text to anagram. === Return Value +Array+: A list of anagrams. rubocop: disable MethodLength, UnderscorePrefixedVariableName
def anagram(text) head, tail = [], text.split('') stack = [[head, tail]] result = [] while stack.size > 0 head, tail = stack.pop if tail.size.zero? result << head else tail.each_with_index do |_, i| _tail = tail.dup curr = _tail.delete_at(i) _head = head.dup _head << curr stack << [_head, _tail] end end end result.tap { |r| r.map! { |p| p.join('') }.uniq! } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def anagrams\n word.anagram.words.pluck(:text) - [word.text]\n end", "def anagrams(word)\n EpicAnagram.find_anagrams(word)\n end", "def anagrams(word, words)\n # TODO: check if \"words\" has anagrams of \"word\" and return them in an array\nend", "def find_anagrams( words )\r\n\tif words.empty?\r\n\t\tresult = []\r\n\telse\r\n\t\tresult = []\r\n\t\tsource = words[0]\r\n\t\twords.each do |w|\r\n\t\t\tif are_anagrams?( source, w )\r\n\t\t\t\tresult << w\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\t\r\n\treturn result\r\nend", "def anagrams(word, words)\n sorted_test_word = word.chars.sort.join\n sorted_words = words.map do |word|\n word.chars.sort.join\n end\n\n anagram_locations = sorted_words.map.with_index do |word, index|\n if word == sorted_test_word\n index\n end\n end.compact\n # sorted_words.keep_if.with_index {|word, index| word == sorted_test_word}\n anagrams = []\n anagram_locations.each do |location|\n anagrams << words[location]\n end\n anagrams\nend", "def group_anagrams(words)\n if words.length == 0\n return []\n end\n\n sorted_words = words.map { |word|\n word.split(\"\").sort().join(\"\")\n }\n indices = (Array.new(words.length) { |i| i }).sort { |a, b| sorted_words[a] <=> sorted_words[b] }\n\n result = []\n current_anagram_group = []\n current_anagram = sorted_words[indices[0]]\n\n indices.each { |index|\n word = words[index]\n sorted_word = sorted_words[index]\n\n if sorted_word == current_anagram\n current_anagram_group << word\n next\n end\n\n result << current_anagram_group\n current_anagram_group = [word]\n current_anagram = sorted_word\n }\n result << current_anagram_group\nend", "def match(array) #takes in an array of possible anagrams\n anagrams = []\n \n # iterate over array of words\n array.each do |word|\n # compare each word of array to OG word \n # determine if word is anagram\n if word.chars.sort == @word.chars.sort\n anagrams << word\n end\n end\n anagrams #return all matches/ empty array if no matches exist\n end", "def anagrams(word, words)\n word = word.chars.sort\n words.select{|x| x.chars.sort == word}\nend", "def combine_anagrams(words)\n anagrams = []\n available_words = words\n words.each do |e|\n group = []\n temp_words = []\n anagram_invariant = e.downcase.chars.sort.join\n available_words.each do |i|\n test = i.downcase.chars.sort.join\n if test == anagram_invariant\n group.push(i)\n else\n temp_words.push(i)\n end\n end\n if(!group.empty?)\n anagrams.push(group)\n end\n available_words = temp_words\n end\n return anagrams\nend", "def combine_anagrams(words)\r\n # <YOUR CODE HERE>\r\n # create a hash to store the anagrams and return arrays of the hash\r\n h = Hash.new \r\n words.each {|x|\r\n key = x.downcase.split(//).sort.join\r\n if h.has_key? key then\r\n a = h[key]\r\n h[key] = a.push(x)\r\n else\r\n h[key]= [x]\r\n end\r\n }\r\n return_array = Array.new\r\n # TODO Figure out how to build an array of arrays\r\n h.each_key {|x| return_array.push (h[x])}\r\n return return_array\r\nend", "def search_for (word)\n\n chars = word.split(\"\")\n all_words = chars.permutation(chars.size).map{|_chars|\n _chars.join \"\"\n }\n\n anagrams = []\n all_words.each do |w|\n anagrams.push w if @word_list[w]\n end\n\n return anagrams\n end", "def combine_anagrams(words)\n words_hash = Hash.new{ |hash, key| hash[key] = [] }\n words.each { |word| word_key = word.downcase.chars.sort.join; words_hash[word_key] = words_hash[word_key] << word; }\n words_list = Array.new()\n words_hash.keys.each { |key| words_list << words_hash[key] }\n return words_list\nend", "def anagrams(word, words)\n words.select { |w| w.chars.sort == word.chars.sort }\nend", "def anagrams(word)\n\n dictionary = File.open(\"enable.txt\").read.split(\"\\n\")\n\n dictionary_array = word.chars.to_a\n matches = dictionary_array.permutation(word.length).to_a\n\n my_anagrams = []\n matches.each do |i|\n matches = i.join\n if dictionary.include?(matches)\n \tmy_anagrams.push(matches) \n end\n end\n my_anagrams.delete(word)\n\n return my_anagrams.sort_by(&:downcase)\nend", "def anagram(str)\n\n raise \"Require string input\" unless str.is_a?(String)\n\n anagrams = []\n\n dict = [\"RETOOL\", \"ROOTLE\", \"TOOLER\", \n \"PLAY\", \"VIKING\"]\n \n dict.each do |word|\n anagrams << word if word.split(\"\").sort == str.upcase.split(\"\").sort\n end\n\n return anagrams\n\n\n end", "def anagrams(word)\n dictionary = File.readlines(Dir.pwd << \"/enable.txt\").map { |word| word.chomp }\n anagrams = []\n\n word = word.split(\"\")\n word.permutation.to_a.each do |possible_perm|\n anagrams << possible_perm.join.upcase if dictionary.include?(possible_perm.join)\n end\n anagrams\nend", "def anagrams_for(word, array)\n #Pasar la palabra a minuscula para que sea igual\n word.downcase!\n #Arreglo vacio para meter los que sean anagramas\n arr = []\n #Separar la palabra en su forma canonica\n cano = word.chars.sort\n #iterar dentro de cada palabra del array\n array.each do |dicc|\n #crear una variable donde pase la palabra del array a su forma canonica\n word_cano = dicc.chars.sort\n #si la palabra es igual a la palabra del array\n #Ya las 2 en su forma canonica\n if cano == word_cano\n #mete la palabra a el array\n arr << dicc\n #De lo contrario deja el array igual\n else\n arr\n end\n end\n #Regresar el array lleno si habia palabras\n #o vacio si no las encontro\n arr\nend", "def combine_anagrams(words)\n anagrams = Hash.new()\n words.each do |word|\n letters = word.downcase.gsub(/[^a-z]/, \"\").split(\"\").sort.join\n anagrams[letters] = Array.new unless anagrams.include?(letters)\n anagrams[letters] << word\n end\n anagrams.values\nend", "def combine_anagrams(words)\n anagram_group = Hash.new([])\n words.each {|word| anagram_group[word.downcase.split(//).sort.join] += [word]}\n return anagram_group.values\nend", "def combine_anagrams_method2(words)\n\ttemp1 = Array.new\n\ttemp1 = words.clone\t# making a deep copy of the input \n\tanagram = Array.new\t\n\ti = 0\n\twhile i < temp1.length\t\t\t\n\t\tcount = 0 # count the number of anagrams of a particular string say \"cars\"\n\t\tfor j in i+1..(temp1.length - 1)\n\t\t\tif temp1[i].downcase.chars.sort.join == temp1[j].downcase.chars.sort.join \n\t\t\t\tcount = count + 1\n\t\t\t\ttemp1[j],temp1[i+count] = temp1[i+count],temp1[j] # get all the anagrams to one place by swapping\n\t\t\tend\n\t\tend\n\t\tanagram.push([temp1[i..i+count]]) # pushing the array of anagrams into anagram array say [\"cars\", \"racs\", \"scar\"]\n\t\ti = i + count + 1\n\tend\n\t# printing each group\n\tfor i in 0..anagram.length-1\n\t\tprint \"anagram[\" + i.to_s + \"]: \" \n\t\tputs anagram[i]\n\tend\t\nend", "def grouped_anagrams(strings)\n return [] if strings.empty?\n\n anagram_hash = Hash.new()\n strings.each do |string|\n word_array = string.split(\"\").sort\n if anagram_hash.include?(word_array)\n anagram_hash[word_array] << string\n else\n anagram_hash[word_array] = [string]\n end\n end\n\n result = []\n anagram_hash.each do |key, value|\n result << value\n end\n return result\n\nend", "def combine_anagrams(words)\n\tanagrams_hash = {}\n\twords.map { |w| w.downcase.split(//).sort.join }.each_with_index do |w, i|\n\t\tif anagrams_hash[w].is_a?(Array)\n\t\t\tanagrams_hash[w].push i\n\t\telse\n\t\t\tanagrams_hash[w] = [i]\n\t\tend\n\tend\n\n\treturn anagrams_hash.map { |word, indexes| indexes.map { |index| words[index] } }\nend", "def get_anagrams(word)\n # FILL ME IN\n unless valid_word?(word)\n return \"Invalid input (string should only consist of letters).\"\n end\n counter = get_counts(word.downcase)\n if @anagrams.has_key?(counter) && @anagrams[counter].size() > 0\n return @anagrams[counter].to_a - [word.downcase]\n else\n return \"No anagrams found!\"\n end\n end", "def combine_anagrams(words)\r\n hash = Hash.new([])\r\n anagrams = []\r\n words.each do |word|\r\n keyword = word.downcase.chars.sort.join\r\n hash[keyword] += [word]\r\n end\r\n hash.each_value do |words|\r\n anagrams += [words]\r\n end\r\n return anagrams\r\nend", "def group_anagrams(words)\n anagrams = {}\n words.each { |word|\n sorted_word = word.split(\"\").sort().join(\"\")\n if anagrams.has_key?(sorted_word)\n anagrams[sorted_word] << word\n else\n anagrams[sorted_word] = [word]\n end\n }\n return anagrams.values()\nend", "def combine_anagrams(words=[])\n return [] if words.empty?\n hash = {}\n words.each do |word|\n anagram = word.downcase.split(\"\").sort.join(\"\")\n if hash[anagram].nil? then\n hash[anagram]=[word]\n else\n hash[anagram].push(word)\n end\n end\n return hash.values\nend", "def combine_anagrams(words)\n anagrams = []\n\n words.each { \n \t|word| \n \t\n\tsorted_word = word.downcase.chars.sort.join\n\n \t# controleer of het gesorteerde woord in 1 van de arrays in anagrams voor komt. \n \t# voeg hem toe aan de array met het overeenkomende anagram\n \t# anders voeg hem als nieuwe array toe aan anagrams\n \ttoegevoegd = false\n\n \t# for i in anagrams.length do |anagram_list|\n \tanagrams.map {\n \t\t|anagram_list|\n\n \t\tif sorted_word == anagram_list[0].downcase.chars.sort.join\n \t\t\tanagram_list << word\n\t\t\ttoegevoegd = true\t\n \t\tend\n \t}\n\n \tif toegevoegd == false\n \t\tanagrams << [word]\n \tend\n\n }\n\n anagrams\nend", "def combine_anagrams(words) \r\n anagrams = words.inject(Hash.new()) do |r, word|\r\n key = word.downcase.chars.sort.join\r\n r[key] ||=[]\r\n r[key] << word\r\n r\r\n end\r\n anagrams.values\r\nend", "def combine_anagrams(words)\r\n\tanagrams = words.group_by { |word| word.chars.sort }.values\t\r\nend", "def combine_anagrams(words)\n result = Hash.new\n words.each do |word|\n sw = word.downcase.split(//).sort\n if !result.has_key?(sw)\n result[sw] = Array.new\n end\n result[sw] << word\n end\n result.values\nend", "def combine_anagrams(words)\r\n\tanagrams = find_anagrams( words )\r\n\tif anagrams.empty?\r\n\t\tresult = []\r\n\telse\r\n\t\tnewWords = words - anagrams\r\n\t\tresult = [anagrams] + combine_anagrams(newWords)\r\n\tend\r\n\t\r\n\treturn result\r\n\t\r\nend", "def anagrams_for(word, array)\n array.find_all {|element| are_anagrams?(word, element)}\nend", "def combine_anagrams(words)\n\tnewlist = words.map {|each_word| each_word.split(//).\n\t\t\t\t\t\t\t\t\t\t\t\tsort.\n\t\t\t\t\t\t\t\t\t\t\t\tjoin.\n\t\t\t\t\t\t\t\t\t\t\t\tdowncase}\n\th = {}\n\tnewlist.each_index do |index| \n\t\tunless h.has_key?(newlist[index])\n\t\t\th[newlist[index]] = []\n\t\tend\n\t\th[newlist[index]] << words[index]\n\tend\n\tanagramlist = []\n\th.each { |key, val| anagramlist << h[key] }\n\treturn anagramlist\nend", "def anagrams(word, words)\n p words.select {|x| x.chars.sort == word.chars.sort }\nend", "def combine_anagrams(words)\n\ta = []\n\twords.each do |word|\n\t\tck = false\n\t\tfor i in 0..(a.length - 1)\n\t\t\t\n\t\t\tif (is_anagrams?(word, a[i][0]))\n\t\t\t\ta[i] = a[i] + [word]\n\t\t\t\tck = true\n\t\t\t\tbreak\t\t\t\t\t\n\t\t\tend\n\t\tend\n\t\tif (ck == false)\n\t\t\ta = a + [[word]]\n\t\tend\t\t\t\t\n\tend\n\treturn a\nend", "def combine_anagrams(words)\n return [] if words.nil?\n return [] if words.length == 0\n\n h = Hash[]\n words.each {|x|\n s = x.strip.downcase.chars.sort.join\n if !h.has_key?(s)\n h[s] = [x]\n else\n h[s].push(x)\n end\n }\n h.values\nend", "def grouped_anagrams(strings)\n return [] if strings.empty?\n anagram_hash = {}\n \n strings.each do |word|\n letters = word.split(\"\").sort.join(\"\")\n if anagram_hash[letters].nil?\n anagram_hash[letters] = [word]\n else\n anagram_hash[letters] << word\n end\n end\n return anagram_hash.values\nend", "def find_anagrams( target_word, list_of_words )\n anagrams = []\n list_of_words.each{ |element|\n if anagram_canonical_form(element) == anagram_canonical_form(target_word)\n anagrams << element\n end\n }\n return anagrams\nend", "def combine_anagrams(words)\n result = []\n words.each do |word|\n anagrams = words.find_all{|item| item.downcase.chars.sort.join == word.downcase.chars.sort.join }\n result.push(anagrams)\n end\n result.uniq\nend", "def anagrams(array)\n copy_array = array.dup\n result_array = []\n iteration_idx = 0\n until copy_array.empty?\n \n word = copy_array.pop\n next if word.nil?\n \n result_array << []\n result_array[iteration_idx] << word\n copy_array.each do |sub_word|\n next if sub_word.nil?\n if are_anagrams?(sub_word, word)\n result_array[iteration_idx] << sub_word\n idx = copy_array.index(sub_word)\n copy_array[idx] = nil\n end\n end\n \n iteration_idx += 1\n end\n \n result_array\nend", "def combine_anagrams(words)\n\th = Hash.new{|hash, key| hash[key] = Array.new;}\n\twords.each do |word| h[word.downcase.split(//).sort.join] << word end\n\th.values \nend", "def combine_anagrams(words)\n\n output = []\n \n words.each do |w|\n \n anag = []\n rest = []\n head = w.downcase.scan(/./).sort.join\n regexp = \"\\\\b\"+head+\"\\\\b\"\n \n words.each do |word|\n \n if Regexp.new(regexp,true) =~ word.downcase.scan(/./).sort.join\n anag = anag + [word]\n else\n rest = rest + [word] \n end\n \n end\n \n if not output.include? anag\n output << anag\n end\n\n end\n \n return output\n \nend", "def combine_anagrams(words)\n hash = {}\n anagrams = []\n\n words.each { |w| \n sorted = w.downcase.each_char.sort.join \n\n if (hash.has_key?(sorted))\n hash[sorted].push w\n else\n hash[sorted] = Array.new.push(w)\n end\n }\n\n hash.each_value { |v|\n anagrams.push v\n }\n\n return anagrams\nend", "def find_anagrams(base_word, word_list)\n word_list.select do |word|\n anagram?(base_word, word)\n end\nend", "def combine_anagrams(words) \n # for each word, sort the word to create the \n # signature for the anagrams\n anagram_groups = {}\n words.each do |w|\n key = w.downcase.chars.sort.join\n if anagram_groups[key].nil?\n anagram_groups[key] = [w]\n else\n anagram_groups[key].push(w)\n end\n end\n \n return anagram_groups.values\n\nend", "def combine_anagrams(words)\n\tsorted = Hash.new\n\tk=0\n\twords.each { |c| sorted[k]=c.downcase.chars.sort.join; k=k+1 }\n\tanagram = Array.new\n\ta = Array.new\n\tb = Array.new\n\ti=0\n\tsorted.invert.each { |w,y| a[i] = sorted.select { |k,v| v == w }.keys; a[i].each { |x| b << words[x] }; anagram << anagram[i].to_a + b.to_a ; b.clear; i=i+1 }\n\treturn anagram\nend", "def anagrams(string, array)\nend", "def combine_anagrams(words)\r\n buckets = Hash.new([])\r\n words.each do | item |\r\n key = item.downcase.chars.sort.join\r\n\r\n if buckets.has_key?(key)\r\n buckets[key] << item\r\n else\r\n buckets[key] = [item]\r\n end\r\n end\r\n\r\n output = Array.new;\r\n buckets.each do | key, value |\r\n output << value\r\n end\r\n return output\r\nend", "def combine_anagrams(words)\n\n\twords.group_by{|word| word.downcase.chars.sort}.values\n\t\nend", "def combine_anagrams(words)\n hash = Hash.new\n words.each {|w|\n if(hash[w.downcase.split(\"\").sort().join] == nil)\n hash[w.downcase.split(\"\").sort().join] = [] \n end\n hash[w.downcase.split(\"\").sort().join] << w\n }\n rList = []\n hash.each_value{|v|\n rList << v\n }\n return rList\n\nend", "def combine_anagrams(words)\r\n\th = Hash.new\r\n\twords.each do |a_word|\r\n\t\tkey = a_word.downcase.chars.sort.join\r\n\t\tputs key\r\n\t\tputs \"-------\"\r\n\t\tif h[key] == nil\r\n\t\t\th[key] = Array.new\r\n\t\tend\r\n\t\th[key].push(a_word)\r\n\tend\r\n\t\r\n\tr_a=Array.new\r\n\t\r\n\th.each do |key, list|\r\n\tr_a.push(list)\r\n\tend\r\n\treturn r_a\r\nend", "def combine_anagrams(words)\r\n words.group_by{|w| w.downcase.chars.sort.to_s}.values\r\nend", "def combine_anagrams(words)\n h = Hash.new()\n\n words.each do |word|\n lowercase_word = word.downcase\n sorted_lowercase_word = lowercase_word.chars.sort.join\n\n similar_words = h[sorted_lowercase_word]\n if not similar_words\n similar_words = []\n end\n similar_words << word\n h[sorted_lowercase_word] = similar_words\n\n end\n\n output = []\n h.each_value { |value| output << value }\n return output\nend", "def get_anagrams(word, dict)\n return nil if dict.empty?\n word_freq = char_freq(word)\n dict.select {|entry| anagrams?(word_freq, char_freq(entry))}.sort\nend", "def anagram(words)\n words_hash = {}\n\n words.each do |w1|\n sorted_word = w1.chars.sort\n\n if words_hash.has_key?(sorted_word)\n words_hash[sorted_word] << w1\n else\n words_hash[sorted_word] = [w1]\n end\n end\n\n words_hash.values\nend", "def anagrams(array_of_words)\n ana_hash = Hash.new { |hash, key| hash[key] = [] }\n array_of_words.each { |word| ana_hash[word.split(\"\").sort.join] << word }\n ana_hash.map { |key, list| list }.select { |list| list.size > 1 }\nend", "def combine_anagrams(words)\n#\n\n hash = {}\n words.each{ |word| \n key = word.downcase.split(//).sort\n hash[key] = (hash[key] || []) + [word]\n }\n ans = []\n hash.map{ |k, v|\n ans += v\n }\n ans\nend", "def find_anagrams(target_word, array_of_words)\n array_of_anagrams = []\n\n array_of_words.each do |member|\n if member.split(//).sort == target_word.split(//).sort\n array_of_anagrams.push(member)\n else\n next\n end\n end\n array_of_anagrams\nend", "def grouped_anagrams(strings)\n sorted_words = {}\n anagrams = []\n\n strings.each do |word|\n word_sorted = word.chars.sort.join\n if !sorted_words.keys.include?(word_sorted)\n # In the hashmap, the sorted word will point to the index in the outer array that the anagram should be placed.\n index = sorted_words.length\n sorted_words[word_sorted] = index\n anagrams[index] = [word]\n else\n # Add anagram to correct group.\n anagrams[sorted_words[word_sorted]].push(word)\n end\n end\n\n return anagrams\nend", "def combine_anagrams(words)\n groups = Hash.new\n words.each do |word|\n (groups[word.downcase.chars.sort.join] ||= []) << word\n end\n groups.flatten.values_at(* groups.flatten.each_index.select {|i| i.odd?})\nend", "def combine_anagrams(words)\n result = Array.new\n words.each do |i|\n anagrams = Array.new\n sorted = i.downcase.chars.sort.join\n words.each do |j|\n if j.downcase.chars.sort.join == sorted\n anagrams << j\n end\n end\n result << anagrams\n end\n return result.uniq\nend", "def anagrams(string)\n# enable.txt is a Scrabble dictionary provided/recommended by Viking Code School\n dictionary = File.readlines(\"enable.txt\")\n stringy = string.strip.downcase\n# by SORTing the letters of the source string and the dictionary words you can easily match the results to find anagrams\n testy = stringy.chars.sort.join\n anagrams = []\n dictionary.each do |word|\n word = word.strip\n if word.length == stringy.length\n check = word.chars.sort.join\n if testy == check\n anagrams << word\n end\n end\n end\n if anagrams == []\n puts \"No anagrams were found for #{stringy.upcase}\"\n else\n anagrams.delete_at(anagrams.index(stringy))\n puts \"The following anagrams were found for #{stringy.upcase}\"\n puts \"#{anagrams}\"\n end\nend", "def combine_anagrams(words)\n Array anagrams = []\n words.each {|x|\n flag = false\n anagrams.collect {|y|\n if x.downcase.chars.to_a.sort == y[0].downcase.chars.to_a.sort then\n y << x\n flag = true\n break\n end\n }\n unless flag; anagrams << [x] end \n }\n anagrams\nend", "def combine_anagrams(words)\r\n words.sort!{|a, b| a.length <=> b.length}\r\n letters = words.map{|w| w.downcase.split(//).sort}\r\n outp = Array.new \r\n prev_a = []\r\n for w in words\r\n if letters[words.index(w)] == prev_a\r\n outp[outp.length - 1].push(w)\r\n else\r\n outp.push([w])\r\n prev_a = letters[words.index(w)]\r\n end\r\n end\r\n return outp\r\nend", "def anagrams(string)\n # We take a string, split it into its characters, \n # put those characters in an array, get all permuations of the array,\n # and join each permutation into words.\n permutations = string.chars.to_a.permutation.map(&:join)\n\n # Then we select only permutations that are words, but not our starting word.\n permutations = permutations.select {|value| value != string and WORDS.include? value }\n\n return permutations\nend", "def combine_anagrams(words)\n\thashes = Hash.new(0)\n\twords.each do |x|\n\t\talpha_word = x.downcase.chars.sort.join\n\n\t\tif hashes[alpha_word] == 0\n\t\t\thashes[alpha_word] = [x]\n\t\telse\n\t\t\thashes[alpha_word] = hashes[alpha_word] << x\n\t\tend\n\tend\n\toutArray = Array.new\n\thashes.each do |key, value|\n\t\toutArray << value\n\tend\n\t\n\treturn outArray\nend", "def anagram_hash(input)\n list = {} # empty hash\n input.each do |word| # iterates over each word in the array\n add_word = word.chars.sort.join # sorts the anagrams\n list[add_word] ||= []\n list[add_word] << word\n end\n # list of all anagrams and words\n list.values\nend", "def combine_anagrams(words)\n\tresult = []\n\twords.each do |word|\n\t\ttemp_word = sort_letters(word)\n\t\tis_found = false\n\t\tresult.each do |grouped_array|\n\t\t\tif !false and sort_letters(grouped_array.last) == temp_word\n\t\t\t\tgrouped_array << word\n\t\t\t\tis_found = true\n\t\t\tend\n\t\tend\n\t\tresult << [word] if !is_found\n\tend\n\tresult\nend", "def combine_anagrams(words)\n outp = Hash.new;\n words.each{|w| idx = w.downcase.chars.to_a.sort.join; if outp[idx] == nil then outp[idx] = Array.new; end; outp[idx].push(w); };\n return outp.values ;\nend", "def combine_anagrams(words)\n\th = Hash.new {|hash, key| hash[key] = [] }\n\twords.each {|x|\n\t\th[x.downcase.split('').sort!.join] << x\n\t\t#p h\n\t}\n\treturn h.values\nend", "def combine_anagrams(words)\n @results = []\n word_bins = words.group_by { |word| word.length }\n word_bins.values.map { |sublist| \n sublist = sublist.zip(sublist)\n sublist.map { |wordpairs| wordpairs[0] = wordpairs[0].downcase.chars.sort.join }\n # collect unique keys for this sublist:\n keys = sublist.collect { |list| list[0] }.uniq\n # print \"keys: \", keys, \"\\n\"\n keys.each do |key| \n anagrams = sublist.collect { |list| list[0] == key ? list[1] : nil }\n anagrams.compact!\n @results << anagrams\n # print \"anagrams= \", anagrams, \"\\n\"\n end\n # print sublist.length, \": \", sublist, \"\\n\\n\" \n }\n # print \"final results: \", @results, \"\\n\"\n @results\nend", "def combine_anagrams(words)\r\n hash = Hash.new\r\n words.each{|w|\r\n key = w.downcase.chars.sort * \"\"\r\n if hash.has_key?(key)\n hash[key] += [w]\n else\n hash[key] = [w]\n end}\r\n return hash.values\r\nend", "def grouped_anagrams(strings)\n return [] if strings.length == 0\n \n hash = {}\n strings.each do |word|\n sorted_word = word.split(\"\").sort\n if hash[sorted_word]\n hash[sorted_word] << word\n end\n end\n final_anagrams = []\n hash.each do |k, v|\n anagrams << v\n end\n return final_anagrams\nend", "def grouped_anagrams(strings)\n res = []\n return res if strings.empty?\n hash = {}\n strings.each do |word|\n key = word.split(\"\").sort.join\n if hash[key]\n hash[key] << word\n else\n hash[key] == [word]\n end\n end\n hash.each do |k, v|\n res << v \n end\n return res\nend", "def combine_anagrams(words)\n anagrams = Hash.new([])\n for i in 0..(words.length - 1)\n anagram_found = false\n if (i == 0)\n anagrams[words[i]] = []\n end\n for j in 0..(i-1)\n# puts \"Comparing #{words[i]} and #{words[j]}\"\n anagram1 = merge_sort(words[i].downcase)\n anagram2 = merge_sort(words[j].downcase)\n# puts \"#{anagram1} #{anagram2}\"\n if (merge_sort(words[i].downcase) == merge_sort(words[j].downcase))\n# puts \"#{words[i]} and #{words[j]} are the same anagram.\"\n anagrams[words[j]] << words[i]\n anagram_found = true\n #puts \"anagrams: #{anagrams.to_s}\"\n break\n end\n end\n anagrams[words[i]] = [] unless (anagram_found)\n end\n\n # Convert hash to an array.\n anagrams_arr = hash_to_array(anagrams)\n return anagrams_arr\n #return anagrams\nend", "def detect_anagram(word, dictionary)\n letter_array = word.downcase.split(//)\n word_array = []\n letter_array.permutation(word.length){|word| word_array << word.join }\n word_array.select {|word| dictionary.include?(word)}\nend", "def combine_anagrams(words)\n words.group_by {|w| w.downcase.chars.sort {|a,b| a <=> b}.to_s}.values\nend", "def anagram(words)\n words_hash = {}\n\n words_hash = words.each_with_object(Hash.new []) do |word, hash|\n hash[word.chars.sort] += [word]\n end\n\n words_array = words_hash.flatten\n final_hash = []\n\n words_array.each_index do |index|\n final_hash << words_array[index] if index.odd?\n end\n\n return final_hash\nend", "def anagram(word)\n anagrams_array = %w(enlists google inlets banana)\n search = word.split('')\n search.sort!\n anagrams_array.each do |wordanna|\n new_word = wordanna.split('')\n new_word.sort!\n if search == new_word\n puts wordanna\n end\n end\nend", "def populate(words)\n # Create an array of words and normailze it: we delete all cr chars (\\r) and put all letters downcase\n words = words.downcase.delete(\"\\r\").split(\"\\n\")\n # The anagram words contain the same letters, so we can create an hash where the key is a common index,\n # and the value is an array of words with the same key\n self.words_hash = words.each_with_object(Hash.new []) do |word,hash|\n hash[create_index(word)] += [word]\n end\n end", "def combine_anagrams(words)\r\n\tswords = Array.new\r\n\tnoDups = Array.new\r\n\tgroupWords = Array.new\r\n\tanagrams = Array.new\r\n\twords.each {|word| swords << word.downcase.chars.sort.join}\r\n\tswords.each{|word| noDups << word unless !noDups.index(word).nil? }\r\n\tnoDups.each do|tword|\r\n\t\t\t\t\t\r\n\t\t\t\t\tgroupWords = Array.new\r\n\t\t\t\t\twords.each {|word| groupWords << word unless word.downcase.chars.sort.join != tword}\r\n\t\t\t\t\tanagrams << groupWords\r\n\t\t\t\tend\r\n\t\t\t\t\r\n\treturn anagrams\r\nend", "def anagram_finder(word, dictionary)\n\tag = []\ndictionary.each {|x| ag << x if word.split('').sort == x.split('').sort }\nag\nend", "def combine_anagrams(words)\n groups = []\n words.each { |word|\n inserted = false\n groups.each { |item|\n if word.isAnagram(item[0])\n item << word\n inserted = true\n end\n }\n if ! inserted\n list = []\n list << word\n groups << list\n end\n }\n return groups\nend", "def find_anagrams(word, dictionary)\n sort_chars = lambda{ |x| x.chars.sort.join }\n anagrams = Hash.new{|h,k| h[k] = [] }\n dictionary.each do |w|\n anagrams[sort_chars.call(w)] << w\n end\n return anagrams[sort_chars.call(word)]\nend", "def combine_anagrams(list_of_words)\n result = []\n list_of_words.each { | word |\n found = false \n for added_words in result\n if word.anagrams?(added_words[0])\n added_words << word\n puts \"==>#{added_words}\"\n found = true\n break \n end \n end\n #Add the new anagram group list\n if !found then result << [word] end\n }\n return result\nend", "def grouped_anagrams(strings)\n if strings.length == 0\n return []\n end\n\n anagram_hash = {}\n\n strings.each do |string|\n sorted_letters = string.split(\"\").sort.join\n if anagram_hash[sorted_letters]\n anagram_hash[sorted_letters] << string\n else\n anagram_hash[sorted_letters] = [string]\n end\n end\n return anagram_hash.values\nend", "def anagrams(array, string)\n dictionary = dictionary_hash(array)\n anagrams = []\n letters = string.chars.sort.join\n if dictionary.has_key?(letters)\n anagrams = dictionary[letters]\n end\n if anagrams.empty?\n \"No anagrams were found for #{string}\"\n else\n anagrams.each do |word|\n puts word\n end\n end\nend", "def grouped_anagrams(strings)\n\n hash = {}\n\n # take each word in 'strings' array ...\n strings.each do |word|\n # ... and split it into letters, alphabetize those letters, and join them back together: this produces a standardized string for words that are anagrams of each other ('ate', 'eat' => 'aet')\n letters = word.split(//).sort().join()\n \n # if the standardized string isn't already in the hash, add it as the key and an empty array as the value\n if hash[letters].nil?\n hash[letters] = []\n end\n\n # push the word to the array for the associated standardized string\n hash[letters] << word\n\n end\n\n # return the values (array of words that are anagrams) for each standardized string\n return hash.values\n\nend", "def my_anagram(type_array) \n #Create Hash container\n storage_hash = {} \n #Take given array argument and opperate on each element.\n #Anagrams are words that can be spelled using the same letters. Order inmaterial. \n\n #Split text into Array / Sort String.split(\"\") Array using Array.sort. / String.join \n #Iterate over array input\n\n type_array.each do |word|\n word_sorted = word.split(\"\").sort.join\n #Check to see if word sorted is already in container (storage_array)\n if storage_hash.has_key?(word_sorted)\n storage_hash[word_sorted].push(word)\n else\n #add the new unique storage key\n storage_hash[word_sorted] = [word]\n end\n end\n #Iterate threw your storage and print results\n storage_hash.each do |key, value|\n puts \"---#{key}----\"\n p value\n end\nend", "def combine_anagrams(words)\n\twords.collect do |w|\n\t\twords.find_all { |w2| w.split(//).sort.eql? w2.split(//).sort }.sort.uniq\n\tend.uniq\nend", "def grouped_anagrams(strings)\n return [] if strings.empty?\n\n #create empty hash\n hash = {}\n strings.each do |word|\n alphabet = word.chars.sort.join\n if !hash[alphabet]\n hash[alphabet]\n else\n hash[alphabet] = [word]\n end\n end\nend", "def combine_anagrams(words)\n\t[] unless words.empty?\n\tcombine = Hash.new\n\twords.each do |word|\n\t\tsorted = word.downcase.chars.sort.join\n\t\tif combine.has_key?(sorted)\n\t\t\tcombine[sorted] << word\n\t\telse\n\t\t\tcombine[sorted] = [word]\n\t\tend\t\n\tend\n\tcombine.values\nend", "def anagram(words)\r\n result = words.group_by { |word| word.chars.sort.join }\r\n result.each {|k, v| p v unless v.size == 1}\r\nend", "def all_anagrams(string)\n return [string] if string.length <= 1\n\n options = all_anagrams(string[1..-1])\n\n result = []\n\n options.each do |sub|\n string.length.times do |i|\n result << sub[0...i] + string[0] + sub[i..-1]\n end\n end\n\n result\nend", "def combine_anagrams(words)\n output = []\n if words.length == 0\n return output\n end\n words.each do |item|\n s_string = item.downcase.chars.sort.join.to_s\n temp_arry = []\n words.each do |scan|\n if s_string == scan.downcase.chars.sort.join.to_s\n temp_arry << scan\n end\n end\n if output.include?(temp_arry)\n #do nothing\n else\n output << temp_arry\n end\n end\n return output\nend", "def combine_anagrams(words)\n output_array = Array.new(0) #create a new output array\n words.each do |firstword| \n\ttemp_array = [] #create a temp array \n words.each do |nextword|\n\t\tif (nextword.downcase.split(//).sort == firstword.downcase.split(//).sort) #compare if two words are anagrams\n\t\t\ttemp_array.push(nextword) #if so, push nextword to array\n\t\tend\n end\n output_array.push(temp_array) #push word to output array, then move up\n end\n \n return output_array.uniq #output array\nend", "def grouped_anagrams(strings)\n # create an anagrams hash of arrays\n anagrams = {}\n # for each string, split the characters and sort them\n # join the characers, and test the hash keys\n # if the key already exists add it to the array of that key\n # if not create one\n strings.each do |word| \n sorted_word = word.split(//).sort.join\n if anagrams[sorted_word]\n anagrams[sorted_word] << word\n else\n anagrams[sorted_word] = [word]\n end\n end\n \n # return the arrays\n anagrams.values\nend", "def combine_anagrams(words)\n words_uniq = words.map{ |w| w.downcase.split(//).sort.join }.uniq\n words_uniq.map{ |wu| words.select{ |w| w.downcase.split(//).sort.join == wu }}\nend", "def anagrams_of(string)\n return [string[0]] if string.length == 1\n\n collection = []\n\n substring_anagrams = anagrams_of(string[1, string.length - 1])\n\n substring_anagrams.each do |substring_anagram|\n (0..substring_anagram.length).each do |index|\n copy = String.new(substring_anagram)\n collection << copy.insert(index, string[0])\n end\n end\n collection\nend", "def anagrams(str)\n return [str] if str.length < 2\n result = []\n first = str[0]\n prev_perms = anagrams(str[1..-1])\n prev_perms.each do |perm|\n (0...perm.length).each do |i|\n result << perm[0...i] + first + perm[i..-1]\n end\n end\n result\nend" ]
[ "0.7665324", "0.74199504", "0.73068136", "0.70580363", "0.6995782", "0.69932926", "0.6961988", "0.6936837", "0.6928857", "0.6917933", "0.6877611", "0.68688315", "0.68575066", "0.68531334", "0.68476975", "0.68437403", "0.6835636", "0.68129665", "0.6806273", "0.67977667", "0.67863876", "0.6768215", "0.67637724", "0.6760415", "0.67457104", "0.67367446", "0.6729595", "0.6721502", "0.6700678", "0.6678391", "0.66750985", "0.667437", "0.66719896", "0.6670214", "0.66466516", "0.66407055", "0.6633691", "0.66298074", "0.662961", "0.6624702", "0.66209835", "0.6618008", "0.6598686", "0.65936565", "0.6590161", "0.6581578", "0.6563964", "0.6562413", "0.6560608", "0.65420395", "0.6540145", "0.6538574", "0.6532379", "0.6529934", "0.65267915", "0.6521388", "0.6517463", "0.65146065", "0.6509887", "0.6506779", "0.65033615", "0.65032786", "0.650305", "0.6497835", "0.64909637", "0.6489619", "0.64838487", "0.6482724", "0.6481092", "0.64667577", "0.6466365", "0.6458876", "0.64578736", "0.6457001", "0.64541245", "0.64369833", "0.64366347", "0.64338565", "0.64237976", "0.642337", "0.6421993", "0.6417624", "0.64082277", "0.64066315", "0.6403121", "0.64022446", "0.63904566", "0.6386629", "0.6375646", "0.63633686", "0.63259006", "0.6319693", "0.6316055", "0.63091826", "0.63014656", "0.6300967", "0.63007295", "0.62988985", "0.62986946", "0.6280587" ]
0.70724434
3
rubocop: enable MethodLength, UnderscorePrefixedVariableName Public: Checks whether one word or phrase is an anagram of another. === Parameter(s) +phrase_one+ +String+: A word or phrase. +phrase_two+ +String+: A word or phrase that may be an anagram of +phrase_one+. === Return Value +Boolean+: True if one phrase is an anagram of the other, false otherwise.
def anagram?(phrase_one, phrase_two) phrase_one.split('').sort == phrase_two.split('').sort end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_anagram word1, word2\n \tpermute = permute_word(word1)\n \tpermute.each do |w|\n \t puts w.join\n \t if w.join.eql?(word2)\n \t \treturn true\n \t end\n \tend\n \treturn false\n end", "def are_anagrams?(word1, word2)\n #si las palabras son anagramas regresa true de lo contrario regresa false\n if canonical(word1) == canonical(word2) then true else false end\nend", "def anagram?\n chars1 = @input1.downcase.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '').split(\"\").sort\n chars2 = @input2.downcase.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '').split(\"\").sort\n if\n self.allwords?\n if\n chars1 == chars2\n return \"These words are anagrams!\"\n elsif\n self.antigrams?\n return \"These words are not anagrams but they are antigrams!\"\n elsif self.antigrams? == false\n return \"These words are neither anagrams nor antigrams!\"\n end\n else\n return \"You need to input actual words!\"\n end\n end", "def is_anagram(w1, w2)\n\tif w1.split(//).sort == w2.split(//).sort\n\t\treturn true\n\tend\n\treturn false\nend", "def is_anagram? a,b\n canonical(a) == canonical(b)\nend", "def first_anagram?(first_word, second_word)\n perms = first_word.chars.permutation\n\n perms.each do |perm|\n return true if perm.join == second_word\n end\n\n false\nend", "def is_anagram(w1, w2)\n\tw1.downcase.split(\"\").sort.join == w2.downcase.split(\"\").sort.join\nend", "def anagrams?(word1, word2)\n\tarr1 = word1.split(\"\")\n \tarr2 = word2.split(\"\")\n\n count = Hash.new(0)\n \tcount2 = Hash.new(0)\n\n \tarr1.each {|word| count[word] += 1}\n \tarr2.each {|word| count2[word] += 1}\n\n if count == count2\n return true\n else\n return false\n end\nend", "def anagram(string1, string2)\n puts \"Are #{string1} and #{string2} anagrams?\"\n if string1.length != string2.length\n return false\n else\n string1.length.times do |i|\n if !string2.include? string1[i] \n return false\n end\n end\n return true\n end\nend", "def anagram?(word)\n normalize(word) == normalize(@word)\n end", "def anagrams?(word1, word2)\n return char_count(word1) == char_count(word2)\nend", "def anagrams?(word1, word2)\n return char_count(word1) == char_count(word2)\nend", "def anagrams?(word1, word2)\n if word1.length != word2.length\n return false\n end\n word1.each_char do |ele|\n if !word2.include?(ele)\n return false\n end\n end\n return true\nend", "def anagrams?(word1, word2)\n\n # let's use hash count \n counter1 = Hash.new(0)\n\n word1.each_char do |char|\n counter1[char] += 1\n end \n \n counter2 = Hash.new(0)\n word2.each_char do |char|\n counter2[char] += 1\n end \n\n if counter1 == counter2\n return true \n end \n\n return false\nend", "def anagrams?(word1, word2)\n return char_count(word1) == char_count(word2)\nend", "def anagrams?(word1, word2)\n return char_count(word1) == char_count(word2)\nend", "def anagrams?(word1, word2)\n return char_count(word1) == char_count(word2)\nend", "def second_anagram?(word1, word2)\n return false if word1.length != word2.length\n word1.chars.each do |char1|\n word2.chars.each do |char2|\n if char1 == char2\n word1 = delete_char(word1, char1)\n word2 = delete_char(word2, char1)\n end\n end\n end\n\n word1.empty? && word2.empty?\nend", "def valid_anagram(str1, str2)\n str1 = str1.split('').sort\n str2 = str2.split('').sort\n if str1 == '' && str2 == ''\n true\n else\n str1 == str2\n end\nend", "def anagrams?(word1, word2)\n\treturn hashLetters(word1) == hashLetters(word2)\nend", "def anagram_bruteforce? (s1,s2)\n sp = StringPermutator.new\n return true if sp.permutations(s1).include? s2\n false\n end", "def anagrams?(word1, word2)\r\n return charCount(word1) == charCount(word2)\r\nend", "def is_anagram(s1, s2)\n\ts1 = s1.downcase.split('').sort\n\ts2 = s2.downcase.split('').sort\n\ts1 == s2 ? true : false \t \nend", "def third_anagram?(word1, word2)\n first = word1.chars.sort.join(\"\")\n second = word2.chars.sort.join(\"\")\n\n p first == second \nend", "def anagrams?(word1, word2)\n w1 = Hash.new(0)\n word1.each_char do |char|\n w1[char] += 1\n end\n w2 = Hash.new(0)\n word2.each_char do |char|\n w2[char] += 1\n end\n return w1 == w2\nend", "def anagram3(string, string2)\n(string.chars.sort.join == string2.chars.sort.join) ? true : false\nend", "def first_anagram?(string1, string2)\n all_anagrams(string1).include?(string2)\nend", "def anagrams?(word1, word2)\n\treturn char_count(word1) == char_count(word2)\n \nend", "def anagram?(s1, s2)\n\ts1_array = s1.split(\"\")\n\ts2_array = s2.split(\"\")\n\tif s1_array.sort == s2_array.sort\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def third_anagram?(first_word, second_word)\n first_word.chars.sort == second_word.chars.sort\nend", "def first_anagram?(word1, word2)\n permutations = word1.split('').permutation.to_a.map(&:join)\n permutations.include?(word2)\nend", "def are_anagrams(firstword, secondword)\n firstword.downcase.split(\"\").sort.join == secondword.downcase.split(\"\").sort.join\nend", "def anagram (str1, str2)\n # to downcase and remove non alphanumeric characters \n str1_hash = str_to_hash(str1.downcase.gsub(/(\\W)/, \"\"))\n str2_hash = str_to_hash(str2.downcase.gsub(/(\\W)/, \"\"))\n\n if str1_hash == str2_hash\n return true\n else\n return false\n end\n\nend", "def fourth_anagram?(first_word, second_word)\n first_hash = Hash.new(0)\n second_hash = Hash.new(0)\n\n first_word.chars.each { |char| first_hash[char] += 1 }\n second_word.chars.each { |char| second_hash[char] += 1 }\n\n first_hash == second_hash\nend", "def first_anagram?(str1, str2)\n all_anagrams(str1).include?(str2)\nend", "def anagrams?(str1, str2)\n return false unless str1.length == str2.length\n\n str1.each_char do |chr|\n return false unless str2.count(chr) == str1.count(chr)\n end\n\n true\nend", "def third_anagram?(first_word, second_word)\n first_word = first_word.chars.sort\n second_word = second_word.chars.sort\n\n first_word == second_word\nend", "def anagram?(a, b)\n return false unless a.length == b.length\n a.chars.sort == b.chars.sort\nend", "def anagram_3?(word1, word2)\n return false if word1.length != word2.length\n arr1, arr2 = word1.split(\"\").sort, word2.split(\"\").sort\n (0...word1.length).all? { |idx| arr1[idx] == arr2[idx] }\nend", "def fifth_anagram?(first_word, second_word)\n word_count = Hash.new(0)\n first_word.chars.each { |char| word_count[char] += 1 }\n second_word.chars.each { |char| word_count[char] -= 1 }\n\n word_count.all? {|_, val| val == 0}\nend", "def second_anagram?(str_1, str_2)\n words = str_2.chars\n str.each_char.with_index do |char, i|\nend\n\n# def first_anagram?(str_1, str_2)\n# hash_1 = Hash.new(0)\n# hash_2 = Hash.new(0)\n\n# str_1.each_char { |char| hash_1[char] += 1}\n# str_2.each_char { |char| hash_2[char] += 1}\n\n# hash_1 == hash_2\n# end\n\n# p first_anagram?(\"gizmo\", \"sally\") #=> false\n# p first_anagram?(\"elvis\", \"lives\") #=> true", "def fourth_anagram?(first_word, second_word)\n first_hash = Hash.new(0)\n second_hash = Hash.new(0)\n first_word.each_char do |char|\n first_hash[char] += 1\n end\n second_word.each_char do |char|\n second_hash[char] += 1\n end\n first_hash == second_hash\nend", "def is_anagram?(word)\n#try determining if they are composed of the same letters.\n word.chars.sort == @word.chars.sort\n end", "def anagrams?(a_string, another_string)\n # TODO: implement the obvious method to test if two words are anagrams\n puts a_string_sorted = clean(a_string.downcase.chars.sort.join)\n puts another_string_sorted = clean(another_string.downcase.chars.sort.join)\n a_string_sorted == another_string_sorted\nend", "def anagrams?(str_sym_or_int_1, str_sym_or_int_2)\n str_sym_or_int_1.to_s.downcase.delete(' ').split('').sort.join == str_sym_or_int_2.to_s.downcase.delete(' ').split('').sort.join\nend", "def str_anagram(str1, str2)\n if str1.chars.sort.join.downcase == str2.chars.sort.join.downcase\n puts true\n else\n puts false\n end\n end", "def fith_anagram?(str1, str2)\n hash = Hash.new(0)\n \n str1.each_char { |char| hash[char] += 1 }\n str2.each_char { |char| hash[char] += 1 }\n \n hash.values.all? { |v| v > 1 }\nend", "def are_anagrams?(str1, str2)\n # if different length, then can't possibly match\n return false if str1.length != str2.length\n\n str1_arr = str1.split('').sort\n str2_arr = str2.split('').sort\n 0.upto(str1_arr.length-1) do |i|\n return false if str1_arr[i] != str2_arr[i]\n end\n true\nend", "def anagram?(str1,str2)\r\n count = Hash.new(0)\r\n str1.each_char {|char| count[char] +=1}\r\n str2.each_char {|char| count[char] -=1}\r\n count.values.all?(0)\r\nend", "def anagram str1, str2\n str1.downcase.chars.sort.join == str2.downcase.chars.sort.join\nend", "def anagram_word?(test_word)\n sort_word(@word) == sort_word(test_word)\n end", "def contains_anagrams?\n @phrase.split().group_by{ |e| e.chars.sort }.select{ |k, v| v.size > 1 }.any?\n end", "def second_anagram?(string1, string2)\n s1char_arr = string1.chars\n s2char_arr = string2.chars\n return false if s1char_arr.length != s2char_arr.length\n s1char_arr.dup.each_with_index do |ch1, ind1|\n s2char_arr.dup.each_with_index do |ch2, ind2|\n if s1char_arr.include?(ch2)\n string1.delete!(ch2)\n string2.delete!(ch2)\n p string1\n p string2\n end\n end\n end\n\n string1.empty? && string2.empty?\nend", "def anagram?(a, b)\n a.chars.sort == b.chars.sort\nend", "def anagrams?(str1, str2)\n make_tally(str1) == make_tally(str2)\nend", "def third_anagram?(word_1, word_2)\n word_1.chars.sort == word_2.chars.sort\nend", "def bonus_anagram?(str1, str2)\n counts = Hash.new(0)\n\n str1.chars.each { |letter| counts[letter] += 1 }\n str2.chars.each { |letter| counts[letter] -= 1 }\n\n counts.values.all? { |value| value == 0 }\nend", "def anagram?(s1,s2)\n\ts1.chars.sort == s2.chars.sort\nend", "def second_anagram?(word1, word2)\n w1_copy = word1.dup\n w2_copy = word2.dup\n w1_copy.each_char do |ch1|\n w2_copy.each_char do |ch2|\n if ch1 == ch2\n w1_copy[w1_copy.index(ch1)] = \"\"\n w2_copy[w2_copy.index(ch2)] = \"\"\n end\n end\n end\n w1_copy.empty? && w2_copy.empty?\nend", "def anagrams?(s1, s2)\n return false if s1.downcase == s2.downcase\n \n a1 = s1.downcase.delete(' ').chars.sort\n a2 = s2.downcase.delete(' ').chars.sort\n\n a1 == a2\nend", "def not_better_by_much_anagram(string1, string2)\n hsh1 = Hash.new(0)\n hsh2 = Hash.new(0)\n\n string1.chars.each do |ch|\n hsh1[ch] +=1\n end\n\n string2.chars.each do |ch|\n hsh2[ch] +=1\n end\n\n return true if hsh1 == hsh2\n false\nend", "def anagrams(word1, word2)\n length = word1.length\n if word1.length == word2.length\n array = []\n while length>=0\n array.push(word1[length-1])\n length -= 1\n end\n length2 = word2.length\n while length2 >= 0\n if array.include?(word2[length2 - 1])\n length2 -= 1\n else\n return false\n end\n end\n return true\n else\n return false\n end\nend", "def second_anagram?(string1,string2)\n # byebug\n return false unless string1.length == string2.length\n\n chars1 = string1.chars\n chars2 = string2.chars\n\n chars1.each do |char|\n if chars2.include?(char)\n chars2.delete(char)\n end\n end\n\n return true if chars2.empty?\n\n false\nend", "def anagram? (s1, s2, algorithm = :anagram_algorithm_countcompare)\n case algorithm\n when :anagram_algorithm_checkoff\n return anagram_checkoff?(s1,s2)\n when :anagram_algorithm_sortcompare\n return anagram_sortcompare?(s1,s2)\n when :anagram_algorithm_bruteforce\n return anagram_bruteforce?(s1,s2)\n when :anagram_algorithm_countcompare\n return anagram_countcompare?(s1,s2)\n else\n raise ArgumentError.new('Unknown anagram algorithm selected ' + algorithm)\n end\n end", "def check_anagrams(first_words, second_words)\n first_words.each_with_index do |word, index|\n if word.split('').sort == second_words[index].split('').sort\n puts true\n else\n puts false\n end\n end\nend", "def first_anagram?(str1, str2)\r\n anagram_helper(str1).include?(str2) \r\n\r\nend", "def anagrams_maybe_better(string1, string2)\n return true if string1.chars.sort == string2.chars.sort\n false\nend", "def second_anagram?(first_word, second_word)\n (0...first_word.length).each do |idx1|\n letter_to_check = first_word[idx1]\n (0...second_word.length).each do |idx2|\n if second_word[idx2] == letter_to_check\n second_word.delete!(second_word[idx2])\n first_word.delete!(first_word[idx1])\n end\n end\n end\n return first_word == second_word\nend", "def anagrams?(word1, word2)\n\nend", "def anagrams?(word1, word2)\n\nend", "def second_anagram?(str1, str2)\n return false if str1.length != str2.length\n str1_copy = str1.dup\n str2_copy = str2.dup\n\n (0...str1.length).each do |i|\n if str2.include?(str1[i])\n str1_copy.delete!(str1[i])\n end\n end\n\n (0...str2.length).each do |i|\n if str1.include?(str2[i])\n str2_copy.delete!(str2[i])\n end\n end\n\n\n return true if str1_copy.empty? && str2_copy.empty?\n false\nend", "def third_anagram?(word1, word2)\n a, b = word1.split(''), word2.split('')\n\n a.sort == b.sort\nend", "def second_anagram?(str1, str2)\n str1.chars.each do |el|\n if str2.include?(el)\n str1 = str1.sub(el, \"\")\n str2 = str2.sub(el, \"\")\n end\n end\n\n str1.empty? && str2.empty?\nend", "def anagram?(string, string2)\n str_arr = string.chars\n answer_array = []\n (0...str_arr.length).each do |i|\n answer_array << str_arr.permutation(i).to_a\n end\n\n answer = answer_array.uniq.join\n answer.include?(string2)\nend", "def anagram?(x, y)\n x.chars.sort == y.chars.sort\nend", "def second_anagram?(word1, word2)\n split1, split2 = word1.chars, word2.chars\n\n idx = 0\n while idx < split1.length\n split2.each_with_index do |el2, idx2|\n if el2 == split1[idx]\n split1.delete_at(idx)\n split2.delete_at(idx2)\n idx = -1\n break\n end\n end\n idx += 1\n end\n return false unless split1.empty? && split2.empty?\n true\nend", "def second_anagram?(str, str2)\n\n return true if str.empty? && str2.empty?\n\n str = str.chars.sort.join\n str2 = str2.chars.sort.join\n\n if str[0] == str2[0]\n second_anagram?(str[1..-1], str2[1..-1])\n else\n return false\n end\n\nend", "def third_anagram?(word1, word2)\n split1= word1.chars.sort\n split2 = word2.chars.sort\n split1 == split2\nend", "def third_anagram?(second_string)\n self.chars.sort == second_string.chars.sort\n end", "def are_anagrams?( s1, s2 )\r\n\ttransformS1 = s1.downcase.split('').sort.join('')\r\n\ttransformS2 = s2.downcase.split('').sort.join('')\r\n\treturn transformS1 == transformS2\r\nend", "def anagrams_one_hash?(str1, str2)\n letter_count = Hash.new(0)\n str1.each_char { |char| letter_count[char] += 1 }\n str2.each_char { |char| letter_count[char] -= 1 }\n\n letter_count.each_value.all? { |val| val == 0 }\nend", "def third_anagram?(word1, word2)\n word1_chars = word1.split(\"\").sort\n word2_chars = word2.split(\"\").sort\n word1_chars == word2_chars\n\nend", "def anagram3(str1, str2)\n str1 = str1.downcase.chars.sort.join\n str2 = str2.downcase.chars.sort.join\n\n return str1 == str2\nend", "def first_anagram?(str1, str2)\n anagrams = str1.split(\"\").permutation.to_a \n anagrams.include?(str2.split(\"\"))\nend", "def second_anagram?(second_string)\n arr1 = self.chars\n arr2 = second_string.chars\n arr1.each_with_index do |let1,idx1|\n arr2.each_with_index do |let2,idx2|\n if let1 == let2\n arr1[idx1] = nil\n arr2[idx2] = nil\n end\n end\n end\n return true if arr1.compact.empty? && arr2.compact.empty?\n false\n end", "def slightly_better_by_much_anagram(string1, string2)\n hsh1 = Hash.new(0)\n\n string1.chars.each do |ch|\n hsh1[ch] += 1\n end\n\n string2.chars.each do |ch|\n hsh1[ch] -= 1\n end\n\n return true if hsh1.values.all? {|el| el == 0}\n false\nend", "def first_anagram(word1, word2) #the worst \r\n word1.chars.permutation.to_a.any? { |sub| sub.join == word2 } \r\nend", "def fourth_anagram?(s1, s2)\r\n string_hash(s1) == string_hash(s2)\r\nend", "def fourth_anagram?(str, str2)\n\n str_hash = hash_creator(str)\n str2_hash = hash_creator(str2)\n\n str_hash.each do |k,v|\n return false unless str2_hash.has_key?(k)\n if v != str2_hash[k]\n return false\n end\n end\n # true\n str2_hash.each do |k, v|\n return false unless str_hash.has_key?(k)\n if v != str_hash[k]\n return false\n end\n end\n\n return true\nend", "def fourth_anagram?(word_1, word_2) #O(n)\n count1 = Hash.new(0) \n word_1.each_char { |char| count1[char] += 1 }\n\n count2 = Hash.new(0) \n word_2.each_char { |char| count2[char] += 1 }\n\n count1 == count2\nend", "def fourth_anagram?(word1, word2)\n hash1 = Hash.new { |h, k| h[k] = 0 }\n hash2 = Hash.new { |h, k| h[k] = 0 }\n word1.chars.each do |char|\n hash1[char] += 1\n end\n word2.chars.each do |char|\n hash2[char] += 1\n end\n hash1 == hash2\nend", "def check_anagrams(s1, s2)\n return false if s1.length != s2.length\n s1.chars.sort == s2.chars.sort\nend", "def third_anagram?(string1, string2)\n chars1 = string1.chars.sort\n chars2 = string2.chars.sort\n\n chars1 == chars2\nend", "def anagramI?(str1, str2)\n anagrams = str1.split(\"\").permutation.to_a.map { |anagram| anagram.join(\"\") }\n anagrams.include?(str2)\nend", "def second_anagram?(str_1, str_2)\n str_1.each_char do |char|\n return false unless str_1.include?(str_2[0])\n str_2.chars.delete_at(str_2.index(char))\n end\n true\nend", "def first_anagram?(string1, string2) # space/time o(n!)\n string1.chars.to_a.permutation.map(&:join).include?(string2)\nend", "def fourth_anagram?(str1, str2)\n helper(str1) == helper(str2)\nend", "def bonus_anagram?(str1, str2)\r\n hash = Hash.new(0)\r\n str1.each_char { |char| hash[char] += 1 }\r\n str2.each_char do |char|\r\n if hash.has_key?(char) && hash[char] > 0\r\n hash[char] -= 1\r\n else\r\n return false\r\n end\r\n end\r\n true\r\nend", "def third_anagram?(str_1, str_2)\n str_1.chars.sort.join == str_2.chars.sort.join\nend", "def third_anagram?(word1, word2)\n word1.split(\"\").sort == word2.split(\"\").sort\nend" ]
[ "0.7999213", "0.77452654", "0.7714912", "0.7682446", "0.75966746", "0.7537825", "0.7522081", "0.7510409", "0.75014913", "0.7491602", "0.74911195", "0.74911195", "0.74685204", "0.7464296", "0.7457432", "0.7457432", "0.7457432", "0.74527305", "0.744779", "0.74465615", "0.7446324", "0.7436694", "0.74213964", "0.74029595", "0.7397865", "0.73909026", "0.7388447", "0.7387237", "0.7382866", "0.73780423", "0.7375401", "0.7374826", "0.73740125", "0.73660684", "0.736219", "0.7357259", "0.7344297", "0.7335548", "0.73351425", "0.7331623", "0.7312384", "0.72998834", "0.7293795", "0.7287438", "0.7277777", "0.72764534", "0.7274638", "0.7274618", "0.7258118", "0.7241347", "0.72385126", "0.7224339", "0.72194254", "0.72176343", "0.7208429", "0.72067565", "0.7198193", "0.71906316", "0.71882296", "0.71861154", "0.71859676", "0.7181995", "0.7178455", "0.7170793", "0.71596336", "0.71502674", "0.71502405", "0.7149881", "0.7144877", "0.7144877", "0.713842", "0.71312964", "0.7131062", "0.7122185", "0.7119354", "0.7113935", "0.71025896", "0.7102514", "0.70773506", "0.7075463", "0.70706886", "0.70688593", "0.70612574", "0.7058954", "0.705417", "0.70531684", "0.70516527", "0.70477843", "0.7046807", "0.7046212", "0.7040511", "0.7040265", "0.7034352", "0.7032173", "0.7025434", "0.7018551", "0.7015484", "0.70138013", "0.70033103", "0.7002952" ]
0.8612305
0
Public: Performs frequency analysis on the provided text. === Parameter(s) +text+ +String+: The text to analyze. === Return Value +Hash+: A hash representing the letter frequencies.
def frequency(text) text = text.downcase.gsub(/\s*/, '') chars = text.split('') freqs = Hash[('a'..'z').to_a.zip([0] * 26)] chars.each { |c| freqs[c] += 1 } freqs end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def word_frequency(text)\n norm_array = normalize(text).to_a\n freq = { }\n norm_array.each_with_object(Hash.new(0)){|key,hash| hash[key] += 1}\nend", "def word_freq(text)\n frequency = {}\n unique_words(text).each do |word|\n frequency[word] = 0\n end\n split_normalise(text).each do |word|\n frequency[word] += 1\n end\n frequency\nend", "def frequency_of_each_word(text)\n words = text.split(\" \")\n frequency = Hash.new(0)\n words.each { |word| frequency[word] += 1 }\n frequency\nend", "def letter_frequency(text)\n\n #create blank hash\n character_hash = Hash.new\n character_hash.default = 0\n\n #delete other characters\n text.delete! \"^a-zA-Z\"\n\n #all lower case\n text = text.downcase\n\n #turn string into array\n text_array = text.chars\n\n #move each letter to hash with number of times it appears in the array\n text_array.each do |letter|\n character_hash[letter] +=1\n end \n character_hash\n\n#sort hash in descending order unless values are the same, then sort alphabetically\n character_hash.sort do |(letter1, value1), (letter2, value2)|\n if value1 == value2\n letter1 <=> letter2\n else\n value2 <=> value1\n end\n end\n\nend", "def histogram(textString)\n\tfrequencies = Hash.new(0)\t\t# parameter defines the default value \n\twords = textString.split(\" \")\t\t\t# split string up into array of words\n\n\t# for each word, add it to hash, increasing frequency count (whose default was 0)\n\twords.each { |w| frequencies[w] += 1 } \n\tfrequencies = frequencies.sort_by {|a, b| b }\t# sort by hash values\n\tfrequencies.reverse!\t\t\t\t\t\t\t# make highest values first\n\n\tfrequencies.each { |word, frequency| puts word + \" \" + frequency.to_s }\nend", "def analyze_text(text)\n hash = Hash.new(Array.new)\n text_array = text.split(/\\s/)\n text_array.each_with_index do |word, i|\n break if i == (text_array.length - 1)\n hash[word] += [text_array[i + 1]]\n end\n hash\n end", "def analyze_raw(txt)\n stem_freq = {}\n stem_lead = {}\n \n returning Hash.new(0) do |dict|\n txt.downcase.split(/[\\s,;!\\?]+/).each do |w|\n # Apply some custom rejection conditions\n next if skip_word?(w)\n # strip non-words chars\n w.gsub!(/[\"\\(\\)\\.]+/, '')\n dict[w] += 1\n end\n\n # Peform stemming analysis\n dict.each do |w, freq|\n @stems[w] ||= @stemmer.stem(w)\n (stem_freq[@stems[w]] ||= {})[w] = freq\n end\n \n stem_freq.each_key do |stem|\n #puts \"Analyzing stem #{stem}\"\n total_freq = 0\n lead_freq = 0\n lead_word = \"\"\n \n #puts \"stems => #{stem_freq[stem].inspect}\"\n stem_freq[stem].each do |word, freq|\n total_freq += freq\n if freq > lead_freq\n lead_word = word\n lead_freq = freq\n end\n end\n #puts \"lead word => #{lead_word} (#{total_freq})\"\n stem_lead[lead_word] = total_freq\n end\n # Replace word frequency hash with leading stem frequency hash\n dict = stem_lead\n end\n end", "def frequency\n # normal string which has assigned all the alphabets\n name = 'abcdefghijklmnopqrstuvwxyz'\n # this line will first split 'name' string and then assign it to hash\n @letters = name.split('').reduce(@letters){|alphabet,count| alphabet[count] +=0; alphabet}\n # this will convert all the alphabets of 'str' to lower case\n @str = @str.downcase\n # this will remove special characters from the string and only allow lower case alphabets\n @str = @str.gsub(/[^a-z]/, '')\n # this will split the 'str' and assign the letters to hash and add 1 each time the letter appeared\n @letters = @str.split('').reduce(@letters){|alphabet,count| alphabet[count] +=1; alphabet}\n\n end", "def word_counts(text)\n\tword_list = text.split(WORD_SPLIT)\n\tcounts = Hash.new(0)\n\tword_list.each { |word| counts[word] += 1 }\n\treturn counts\nend", "def word_count(text)\n\tnew_text = text.split(\" \") #-->Use text.split to turn text into an array that breaks(splits) at each space.\n\t\n \tcounter = Hash.new(0) #-->Next create an empty hash for your results with count = Hash.new (0)\n\n \tnew_text.each {|word| counter[word] += 1} #-->Use a method that will take each word in the array\n\n \tputs counter #-->This will give us our results printed on the screen\nend", "def frequency\n counts = Hash.new(0)\n self.words.each { |word| counts[word] += 1 }\n counts\n end", "def each_word_count(text)\n word_counts = {}\n normalize(text).each do |word|\n word_counts[word] = 0 if !word_counts[word]\n word_counts[word] += 1\n end\n word_counts\nend", "def count_word_occurrences(text = '')\n count = {}\n text.encode(@encoding).downcase.split.each do |word|\n stemmed_word = (@skip_stemming) ? word : word.stem_porter\n unless stopwords.include? stemmed_word\n count[stemmed_word] = count[stemmed_word] ? count[stemmed_word] + 1 : 1\n end\n end\n count\n end", "def analyze_text(text)\n {\n :line_count => (text.split(/\\n/).last.chomp.empty? ? text.scan(/\\n/).count + 1 : text.scan(/\\n/).count),\n :character_count => text.length,\n :character_count_excluding_spaces => text.scan(/\\S/).length,\n :word_count => text.split(' ').length,\n :sentence_count => text.split(/[\\.?!]/).length,\n :paragraph_count => text.split(/\\n\\r/).length\n }\nend", "def count_frequencies(text, exclude)\n exclude = exclude.map(&:downcase)\n text_array = text.split(/[^\\w']/)\n frequencies = Hash.new(0)\n for word in text_array\n if not exclude.include?(word.downcase)\n frequencies[word.downcase] += 1\n end\n end\n return frequencies\nend", "def count_letters(input_string)\n letter = input_string.scan /\\w/\n freq = Hash.new(0)\n\n # this will create a histogram count for each letter\n letter.each do |letter|\n freq[letter] += 1\n end\n\n\n\n # output letter and count\n freq.each do |letter, count|\n puts letter + \" \" + count.to_s\n end\n\nend", "def substring(text, dictionary)\n\t\t\tfrequencies = Hash.new(0)\t\n\t\t\ttext.downcase! \n\t\t\tword = text.split(/\\W+/) #splits string to array at non-alphanumeric characters removing !! ?? etc\n\t\t\t\tword.each do |word | #iterate through the string.\n\t\t\t\t\tdictionary.each do |d| #within this iteration, iterate through the dictionary checking the word in the dictionary\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t#against the word in the string \n\t\t\t\t\t\tif\tword.include? d\n\t\t\t\t\t#if dictionary.include? word\n\t\t\t\t\t\tfrequencies[d] += 1\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\n\t\t\t\t\tend\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\tend\n\t\t\t\tputs frequencies\n\t\t\t\t\t\t\n\n\t\t\t#\tprint out frequencies hash \n\tend", "def charFreq(someFile)\ntext = \"\"\nFile.open(someFile, 'r') do |file|\n text = file.to_a.to_s.downcase.gsub(/[^a-z\\s]/, '')\nend\n\nfreq = {}\nchar = text.split(\"\")\nfreq = char.uniq.each{|c| freq[c] = char.count(c)}\n\ncounts = {}\nfor c in char \n if counts.key?(c)\n counts[c] += 1\n else \n counts[c] = 1\n end\nend \n\nprint(counts)\nend", "def alphabet_frequency string, letter\n decode_attempt = c_decode string, letter\n frequency_total_array = []\n $frequencies.each do |key, array|\n frequency_total_array.push((frequency_value(decode_attempt.split(\"\"), key) - $frequencies[key]).abs)\nend\nfrequency_total_array.inject(0, :+)\nend", "def calculate_frequencies(target_file)\n\tn_char=0.0\n\n\n\ttext=File.read(target_file)\n\n\t#creo l'hash delle lettere\n\thsh=Hash.new\n\tcode=97\n\twhile code<=122 do\n\t\thsh[code]=Occurrences.new(0,0.000)\n\t\tcode+=1\n\tend\n\t#conto le occorrenze delle lettere\n\ttext.each_byte {|c|\n\t\tif c>=97 and c<=122;\n\t\t\thsh[c].number+=1\n\t\t\tn_char+=1\n\t\tend\n\t}\n\t#creo le frequenze\n\thsh.each {|k, v|\n\t\tv[1]=v[0]/n_char\n\t\t#puts\"number:#{v[0]} - percentage:#{v[1]}\"\n\t}\n\t#print dei valori creati\n\t#i=0\n\t#hsh.each {|k, v| puts \"elemento #{i} ---> #{k} is #{v}\",\n\t#\ti+=1\n\t#}\n\treturn hsh;\nend", "def word_frequency(words)\n frequencies = Hash.new(0)\n words.each do |word|\n frequencies[word] += 1\n end\n frequencies\nend", "def word_frequency\n @word_use = Hash.new(0)\n words.each { |w| @word_use[w] += 1 }\n @word_use\n end", "def letter_frequency_x(s)\n s.downcase.chars.\n each_with_object(Hash.new(0)) {|c,h| h[c] += 1 if c !~ /[^a-z]/}.\n sort_by {|k,v| [-v,k]}\nend", "def string_frequency(string, hash)\n string.each_char do |char|\n hash[char]+=1\n end\n return hash\n end", "def score_text_two(text)\n txt = text.downcase\n txt_length = txt.length.to_f\n total_score = 0\n\n ALL_LETTERS.each_with_index do |l, i|\n l_freq = (txt.count(l) / txt_length) * 100\n total_score += (l_freq - CHAR_FREQ[i]).abs\n end\n\n space_ratio = txt.scan(/.\\s./).count / txt_length\n total_score += ((space_ratio * 100) - 14.0).abs\n\n return total_score\nend", "def test_function\n puts \"Please supply input\"\n text = gets.chomp\n words = text.split(\" \")\n\n frequencies = Hash.new(0)\n\n\n words.each do |word|\n frequencies[\"#{word}\"] += 1\n end\n\n\n frequencies = frequencies.sort_by do |k, v|\n frequencies[k] = v\n end\n frequencies.reverse!\n\n frequencies.each do |k,v|\n puts \"#{k} #{v.to_s}\"\n end\nend", "def letter_count(string)\n\tfrequency = Hash.new(0)\n\tstring.each_char do |i|\n\t\tfrequency[i] += 1 unless i == \" \"\n\tend\n\tfrequency\nend", "def process\n tokenize(text).each do |word|\n token = TfIdfSimilarity::Token.new word\n if token.valid?\n @term_counts[token.lowercase_filter.classic_filter.to_s] += 1\n end\n end\n @size = term_counts.values.reduce(:+)\n end", "def contar(texto)\n palavras = texto.split\n\n frequencies = Hash.new(0)\n\n palavras.each do |word|\n frequencies [word] += 1\n end\n\n frequencies = frequencies.sort_by do |wor, count|\n end\n frequencies.reverse!\n\n frequencies.each do |wor, count|\n puts wor + \" \" + count.to_s\n end\nend", "def substrings text,dictionary\n\ttext.downcase!\n\thash = {}\n\tdictionary.each do |word|\n\t\tcount = text.scan(word.downcase).length\n\t\thash[word] = count if count > 0\n\tend\n\thash\nend", "def count_summary(text)\n all = 0\n counts = Hash.new\n text.each_char do |ch|\n next if ch == ' '\n\n if !counts[ch] then\n counts[ch] = 1\n else\n counts[ch] += 1\n end\n\n all += 1\n end\n\n ARR.each do |ch|\n if ! counts[ch] then\n counts[ch] = 0\n end\n end\n counts\nend", "def count_words(s)\n\ts = s.downcase\n\ts.gsub!(/\\W+/,\" \")\n\ts = s.split(\" \")\n\tfreqs = Hash.new(0)\n\ts.each{ |word| freqs[word] += 1 }\n\treturn freqs\nend", "def frequent_letters(string)\n count = Hash.new(0)\n string.each_char { |char| count[char] += 1 }\n\n frequents = []\n count.each do |char, num|\n if num > 2\n frequents << char\n end\n end\n return frequents\nend", "def calculate_word_frequency\n # not a class method, it is used to poulate what are essentially properties on an instance of the class\n #word_frequency = @content.split(\" \").each_with_object(Hash.new(0)) {|word,count| count[word] +=1}\n word_frequency = Hash.new(0)\n #puts word_frequency\n @content.split.each do |word|\n word_frequency[word] += 1\n end\n\n\n @highest_wf_count = word_frequency.values.max\n @highest_wf_words = word_frequency.select { |word, freq| freq == @highest_wf_count }.keys\n @highest_wf_words\n\n end", "def count_frequencies s\n s.downcase.split(//).inject(Hash.new(0)) do |hash,item|\n hash[item] += 1\n hash\n end\n end", "def letter_counts(word)\n hash = Hash.new(0)\n word.each_char do |ch|\n hash[ch] += 1\n end\n hash\nend", "def word_instances(text)\n instances = Hash.new(0)\n normalized_words = normalize(text)\n unique(text).each do |word|\n instances[word] = normalized_words.count(word)\n end\n instances\nend", "def letter_counts(word)\n hsh = Hash.new(0)\n\n word.each_char { |ch| hsh[ch] += 1 }\n\n hsh\nend", "def letter_counts(word)\n hash = Hash.new(0)\n word.chars {|letter| hash[letter] += 1}\n hash\nend", "def frequencies\n analyzer = Frequency.call(\n dataset: dataset,\n stemming: stemming,\n block_size: window,\n last_block: :small_last,\n split_across: false,\n progress: ->(p) { progress&.call((p.to_f / 100.0 * 33.0).to_i) }\n )\n\n # Combine all the block hashes, summing the values\n total = analyzer.blocks.size.to_f\n\n base_frequencies = {}\n analyzer.blocks.each_with_index do |b, i|\n progress&.call((i.to_f / total * 16.0).to_i + 33)\n\n b.each_key do |k|\n base_frequencies[k] ||= 0\n base_frequencies[k] += 1\n end\n end\n\n # Get the frequencies of cooccurrence with the word in question\n joint_frequencies = {}\n pairs.each_with_index do |(word, word2_array), i|\n joint_frequencies[word] = {}\n\n analyzer.blocks.each_with_index do |b, j|\n if progress\n p = (i.to_f / pairs.size.to_f) +\n (1 / pairs.size.to_f) * (j.to_f / total.to_f)\n progress.call((p * 17.0).to_i + 49)\n end\n\n next unless b[word]&.>(0)\n\n if word2_array.empty?\n b.each_key do |k|\n joint_frequencies[word][k] ||= 0\n joint_frequencies[word][k] += 1\n end\n else\n word2_array.each do |w|\n if b.key?(w)\n joint_frequencies[word][w] ||= 0\n joint_frequencies[word][w] += 1\n end\n end\n end\n end\n end\n\n [base_frequencies, joint_frequencies, analyzer.blocks.size]\n end", "def score_text(txt)\n txt_length = txt.length.to_f\n total_score = 0\n\n e_ratio = txt.count('e') / txt_length\n t_ratio = txt.count('t') / txt_length\n a_ratio = txt.count('a') / txt_length\n o_ratio = txt.count('o') / txt_length\n i_ratio = txt.count('i') / txt_length\n\n space_ratio = txt.count(' ') / txt_length\n\n total_score += 1 if i_ratio > 0.01 && i_ratio < 0.10\n total_score += 2 if e_ratio > 0.10 && e_ratio < 0.20\n total_score += 2 if t_ratio > 0.08 && t_ratio < 0.26\n total_score += 2 if a_ratio > 0.07 && a_ratio < 0.20\n total_score += 2 if o_ratio > 0.05 && o_ratio < 0.20\n total_score += 4 if space_ratio > 0.1 && space_ratio < 0.4\n\n # capital_ratio = txt.scan(/[ABCDEFGHIOUT]/).count / txt_length\n # total_score += 4 if capital_ratio > 0 && capital_ratio < 0.2\n\n return total_score\nend", "def word_instances(text)\n instances = Hash.new(0)\n normalize(text).each do |word|\n instances[word] += 1\n end\n instances\nend", "def count_words\n # clean up string\n str = self.downcase.gsub(/[^a-z0-9\\s]/, '') # only keep letters, numbers, and whitespace\n str = str.gsub(/\\s+/m, ' ') # remove excess whitespace\n\n # add each word to the hash\n hash = Hash.new(0)\n str.split.each do |word|\n hash[word] += 1\n end\n\n hash\n end", "def letter_counts(word)\n count = Hash.new(0)\n word.each_char { |char| count[char] += 1}\n count\nend", "def get_word_freq\n speech_links = get_links_to_speeches\n word_freq = Hash.new(0)\n \n speech_links.each do |link|\n speech_page = link.click\n if (speech_obj = speech_page.at SPEECH_DIV_IDENTIFIER)\n speech = speech_obj.text\n words = speech.split(' ')\n words.each{ |word| word_freq[clean_str(word)] += 1 }\n end\n end\n\n word_freq.sort_by{ |x,y| y }.reverse\n end", "def text_commonality(text)\n probability_of_ngrams(common_ngrams_from_text(text))\n end", "def letter_counts(word)\n letters = word.split(\"\")\n letter_hash = Hash.new(0)\n letters.each {|char| letter_hash[char]+= 1}\n letter_hash\nend", "def letter_counts(word)\n answer = Hash.new(0)\n word.each_char { |chr| answer[chr] += 1 }\n answer\nend", "def word_count\n #need to modify regex to account for apostrophes\n text = (@text.gsub!(/\\W+|\\d/,' ').split(\" \"))\n word_count = Hash.new(0)\n text.each do |word|\n word = word.downcase\n word_count[word] +=1\n end\n word_count\n end", "def analysis\n @str = params[:text] ||= '解析対象の文字列'\n @words = Tag.counter(Tag.generate(@str))\n end", "def letter_counts(word) =\n word.chars.each_with_object(Hash.new(0)) { |c, counts| counts[c] += 1 }", "def count_words(str)\n\n frase = str.gsub!(/\\W|\\_\\d/,\" \").split(\" \")\n frase.each do |palabra|\n\n veces = frase.count(palabra)\n hash[palabra] = veces\n\n end\n hash\n\n\n\n end", "def letter_counts(word)\n letter_counts = Hash.new(0)\n\n word.split(\"\").each do |ele| \n letter_counts[ele] += 1\n end\n letter_counts\nend", "def analyze(text, analysis_params)\n request(:get, \"_analyze\") do |req|\n req.body = { text: text }.merge(analysis_params)\n end\n end", "def letter_counts(word)\n counter = Hash.new(0)\n word.chars.each do |x|\n counter[x] += 1\n end\n counter\nend", "def letter_counts(word)\n hash = {}\n word.chars.uniq.each {|char| hash[char] = word.count(char)}\n hash\nend", "def word_sizes(text)\n word_size = Hash.new(0)\n text.split.map do |word|\n word.delete \"^A-Za-z\"\n word_size[word.size] += 1\n end\n word_size\nend", "def text_probability(text)\n probability_of_ngrams(ngrams_from_text(text))\n end", "def freq\n @freq ||= begin\n # calculate ngram counts for the haystack\n counts = Hash.new(0)\n veach(\"Haystack\", @haystack) do |element|\n element.ngrams.each do |ngram|\n counts[ngram] += 1\n end\n end\n\n # turn counts into inverse frequencies\n map = Hash.new(1)\n total = counts.values.inject(&:+).to_f\n counts.each do |ngram, count|\n map[ngram] = ((total / count) * 10).round\n end\n map\n end\n end", "def count_occurance(text='')\n raise \"input must be instance of String\" unless text.is_a?(String)\n\n text_chunks = text.downcase.gsub(ONE_OR_TWO_WORDS_RE, '').gsub(NON_ALPHANUMERIC_AND_NON_DOT_RE, ' ').gsub(@stopwords.to_re, '').gsub(/\\./, '').split\n text_chunks.inject(Hash.new(0)) do |container, word|\n container[word] += 1; container\n end\n end", "def frequencies(chars)\n freq = Hash.new(0)\n chars.each do |char|\n freq[char] += 1\n end\n freq = freq.sort_by { |char, count| count } # order by highest frequency\n freq.reverse!\n freq = Hash[freq]\n return freq\nend", "def count_frequency(word_list)\n counts = Hash.new(0)\n for word in word_list\n counts[word] += 1\n end\n counts\nend", "def letter_counts(word)\n hashed = word.chars.map {|char| [char, word.count(char)]}.flatten\n return Hash[*hashed]\nend", "def count_words(string)\n#names=string.downcase.split(/\\W+/)\n#puts names\ncounts = Hash.new(0)\nstring.downcase.split(/\\W+/).each { |name| counts[name] += 1 }\nputs counts\nend", "def analyze(text)\n @markov.merge!(self.class.analyze(text, @num_prefix_words))\n end", "def calculate_term_frequencies\n results = []\n\n @tokenized_documents.each do |tokens|\n document_result = {}\n tokens[:words].each do |term, count|\n document_result[term] = (count/tokens[:total_count].to_f).round(6)\n end\n\n results << document_result\n end\n\n results\n end", "def analyze(text, analysis_params)\n request(:get, \"_analyze\", analysis_params) do |req|\n req.body = text\n end\n end", "def count_words(string)\r\n texts = string.split(\" \").map(&:downcase)\r\n result = texts.each_with_object(Hash.new (0)) {|item, hash| hash[item] += 1}\r\n result.each do |key, value|\r\n puts \"#{key} #{value}\"\r\nend\r\nend", "def count_words(string)\n hash = Hash.new(0)\n string.scan(/\\w+/).each {|t| hash[t.downcase] = hash[t.downcase] + 1}\n hash\nend", "def compute_freq_map(str)\n # OPTIMIZATION IDEA: Make this function also be able to determine if the curr_freq_map matches the last_freq_map\n freq_map = {}\n str.each_char do |char|\n if freq_map[char]\n freq_map[char] += 1\n else\n freq_map[char] = 1\n end\n end\n return freq_map\nend", "def letter_frequency(s)\n s.downcase.scan(/[a-z]/).group_by(&:itself).\n transform_values(&:size).sort_by {|k,v| [-v, k]}\nend", "def word_frequency(params={})\n # Set default options\n options = {\n tweets: [@statuses_count, 1000].min,\n include_rts: true,\n exclude_replies: true\n }\n\n # Combine the options the user has set\n options.merge!(params)\n\n result = {}\n\n # Get the tweets which will be in @timeline\n get_timeline(options[:tweets])\n\n # Go through each tweet in the timeline and match words only\n # [key] word => [value] number of times it is used\n @timeline.each do |tweet|\n tweet.text.split.each do |t|\n\n # Some matches come out as null so skip if they are nil\n word = t.downcase.match(/\\w(?<!\\d)[\\w'-]*/)\n next unless word\n word = word[0]\n\n # Check if word has been added to the result, increment count\n if result.has_key?(word)\n result[word] += 1\n else\n result[word] = 1\n end\n end\n end\n\n result = result.sort_by { |key, value| value }.reverse\n print_word_frequency(result)\n end", "def word_sizes2(string)\n frequency = Hash.new(0) #set the default value to 0\n string.split.each do |word| \n frequency[word.length] += 1\n end\n frequency\nend", "def create\n \t# ***** New ****\n\n \t@text = params[:text_inspection][:user_text]\n\n textins = TextInspection.new\n\n \t@freq_arr = textins.frequency(@text)\n\n # ***** New *****\n \t@word_count = @text.split(\" \").length\n\n \t@words_per_min = (@word_count / 275).ceil\n\n \trender 'result'\n\n \tend", "def word_sizes(text)\n word_size = Hash.new(0)\n words = text.split\n words.each { |word| word_size[word.size] += 1 }\n word_size\nend", "def frequencies(book)\n book.downcase!\n words = book.split\n word_frequency = {}\n words.each do |word|\n if WORDS.include?(word)\n if word_frequency.key?(word)\n word_frequency[word] += 1\n else\n word_frequency[word] = 1\n end\n end\n end\n word_frequency\nend", "def count_frequency(word_list)\n\tcounts = Hash.new(0)\n\tfor word in word_list\n\t\tcounts[word] += 1\n\tend\n\tcounts\nend", "def calculate_term_frequencies\n results = []\n \n @data.each do |document|\n document_result = {}\n \n document.each do |term|\n if document_result.key?(term)\n document_result[term] += 1.0\n else\n document_result[term] = 1.0\n end\n end\n \n # Normalize the count\n document_result.each_key do |term|\n document_result[term] /= document.size\n end\n \n results << document_result\n end\n \n results\n end", "def count_words(string) \n words_hash = Hash.new(0)\n string.downcase.gsub(/\\b/, '').split().each do |i| \n words_hash[i] += 1 \n end\n words_hash \nend", "def texts_score(text1, text2)\n words1 = text1.downcase.scan(/[a-zA-Z]+/) - noise_words\n words2 = text2.downcase.scan(/[a-zA-Z]+/) - noise_words\n common_words = words1 & words2\n p common_words\n common_words.length.to_f / (words1.length + words2.length)\n end", "def letter_counts(word)\nend", "def faster_frequent_words(text, k)\n # FasterFrequentWords(Text , k)\n # FrequentPatterns ← an empty set\n # FrequencyArray ← ComputingFrequencies(Text, k)\n # maxCount ← maximal value in FrequencyArray\n # for i ←0 to 4**k − 1\n # if FrequencyArray(i) = maxCount\n # Pattern ← NumberToPattern(i, k)\n # add Pattern to the set FrequentPatterns\n # return FrequentPatterns\n\n # Input: A string Text and an integer k.\n # Output: All most frequent k-mers in Text.\n\n # Sample Input:\n # ACGTTGCATGTCGCATGATGCATGAGAGCT\n # 4\n\n # Sample Output:\n # CATG GCAT\n\n frequent_patterns = []\n frequency_array = frequency_array(text, k)\n max_count = 0\n frequency_array.each {|count| max_count = count if count > max_count }\n (0..(4**k - 1)).each do |i|\n if frequency_array[i] == max_count\n pattern = number_to_pattern(i,k)\n frequent_patterns << pattern\n end\n end\n\n return frequent_patterns\n end", "def frequency(string,char)\n\t\tstring.count(char) / string.length.to_f\n\tend", "def frequent_letters(string)\n output = []\n count_table = Hash.new(0)\n\n string.each_char do |char|\n count_table[char] += 1\n if count_table[char] == 3\n output.push(char)\n end\n end\n\n return output\nend", "def frequency string\n $frequencies[string]\nend", "def initialize(text)\n @text = text.dup\n @paragraphs = text.split(/\\n\\s*\\n\\s*/)\n @sentences = Lingua::EN::Sentence.sentences(@text)\n @words = []\n @frequencies = {}\n @frequencies.default = 0\n @syllables = 0\n @complex_words = 0\n count_words\n end", "def count_words(str)\n\tstr.gsub!(/[\\b[^a-zA-Z ]]/, '')\n\tarr = str.downcase.split\n\thash = Hash.new(0)\n\tarr.each { |name| hash[name] += 1 }\n\treturn hash\nend", "def frequent_letters(string)\n frequent = []\n letters_count = Hash.new(0)\n\n string.each_char { | char | letters_count[char] += 1 }\n letters_count.each do | k, v |\n if v > 2\n frequent << k\n end\n end\n\n return frequent\nend", "def genFreqTable(string)\n freqTable = Hash.new\n string.split(\"\").each do |i| #loop through every character in the string\n if freqTable.has_key?(string[i]) #if key already exists\n freqTable[string[i]] += 1 #increments its frequency\n else\n freqTable[string[i]] = 1 #else its a new key so set its frequency to 1\n end\n end\n return freqTable\nend", "def duplicate_count(text)\n # create an array with properly formatted elements\n letters = text.downcase.split('')\n\n # make the hash deafult to 0 so that += will work correctly\n stats = Hash.new(0)\n\n # iterate over the array and count number of times each letter occur\n letters.each {|letter| stats[letter] += 1}\n\n # delete key-value pairs from the hash which occur only once\n stats.delete_if {|key, value| value == 1}\n\n # return the number of remaining key-value pairs\n return stats.values.count\nend", "def ioc(text)\n c = 26.0\n freqs = frequency(text)\n n = text.length\n\n f = freqs.values.reduce(0) { |a, e| a + (e * (e - 1)) }\n f / ((n * (n - 1)) / c)\n end", "def frequency(letter)\n\treturn $letter_frequency[:letter]\nend", "def count_letters_in_word(word)\n letters = Hash.new(0)\n word.chars.each { |letter| letters[letter] += 1 }\n letters\nend", "def frequencies\n $heap[:word_freqs] = {}\n $heap[:count] = 0 # we need because of operator order, see below\n # A little flavour of the real Forth style here...\n while $stack.length > 0\n # ...but the following line is not in style, because the \n # naive implementation would be too slow\n if $heap[:word_freqs].include? $stack.last\n # Increment the frequency, postfix style: f 1 +\n $stack.push $heap[:word_freqs][$stack.last] # push f\n $stack.push 1\n $stack.push $stack.pop + $stack.pop\n else\n $stack.push 1\n end\n # Load the updated freq back onto heap\n $heap[:count] = $stack.pop\n $heap[:word_freqs][$stack.pop] = $heap[:count] # can't write head[_][stack.pop] = stack.pop\n end\n # Push result onto the stack\n $stack.push $heap[:word_freqs]\n $heap[:word_freqs] = nil; $heap[:count] = nil # Don't need this variable\nend", "def count_words\n string = self.squish.downcase.gsub(/[^a-z0-9\\s]/i, '')\n string = string.split(\" \")\n words = Hash.new(0)\n string.each { |x|\n words[x] +=1;\n }\n return words\n end", "def frequent_letters(string)\n hash = Hash.new(0)\n results = []\n\n string.each_char do |char|\n hash[char] += 1\n end\n\n hash.each do |k, v|\n if v > 2\n results << k\n end\n end\n\n return results\nend", "def build_char_frequency_table(phrase)\n table = Array.new(26, 0)\n\n phrase.each_char do |char|\n x = get_char_number(char)\n if x != -1\n table[x] += 1\n end\n end\n\n table\nend", "def count_occurrences(array)\n frequncies = Hash.new(0)\n\n array.each do |word|\n frequncies[word] += 1\n end\n\n frequncies.each do |word, frequency|\n puts \"#{word} => #{frequency}\"\n end\nend", "def frequent_letters(string)\n hash = Hash.new(0)\n string.each_char { |char| hash[char] += 1 }\n\n frequent = []\n hash.each_key do |k|\n if hash[k] > 2\n frequent << k\n end\n end\n return frequent\nend", "def character_count(str)\n character_frequency = Hash.new(0)\n str.each_char do |char|\n character_frequency[char] += 1\n end\n return character_frequency\nend" ]
[ "0.731779", "0.72305524", "0.7139432", "0.70138705", "0.688126", "0.68060577", "0.67000073", "0.66217005", "0.64838266", "0.64221245", "0.63893574", "0.63296264", "0.62854445", "0.62699956", "0.62413496", "0.61716616", "0.61622936", "0.61328524", "0.61181974", "0.6044382", "0.6024063", "0.59610826", "0.59390944", "0.59032434", "0.5894262", "0.5890249", "0.5884508", "0.5869516", "0.585785", "0.57756424", "0.5749992", "0.57435215", "0.5736182", "0.5724801", "0.5722435", "0.57210314", "0.5718993", "0.5707549", "0.57023853", "0.5698208", "0.56965584", "0.56919986", "0.5687635", "0.56723297", "0.5671941", "0.5666495", "0.5664818", "0.5661473", "0.56556946", "0.56554663", "0.5650676", "0.5649756", "0.5648069", "0.5642624", "0.56326145", "0.5631837", "0.5627696", "0.56257915", "0.561149", "0.56014013", "0.5591115", "0.5557495", "0.5552993", "0.5538943", "0.55152744", "0.5514522", "0.55130744", "0.5507154", "0.55034685", "0.5491279", "0.5488765", "0.54771274", "0.54711384", "0.546945", "0.54574615", "0.54548115", "0.54540575", "0.5449201", "0.54482806", "0.5444118", "0.5435886", "0.5434143", "0.54276466", "0.5426947", "0.54257745", "0.54219985", "0.5414229", "0.5390836", "0.53904235", "0.53895515", "0.53847694", "0.5381259", "0.5379925", "0.533752", "0.5331328", "0.53276175", "0.5317407", "0.53159595", "0.5315042", "0.53070927" ]
0.81292146
0
Public: Calculates the index of coincidence for the given text (see Index_of_coincidence). === Parameter(s) +text+ +String+: The text to analyze. === Return Value +Float+: The index of coincidence for the text.
def ioc(text) c = 26.0 freqs = frequency(text) n = text.length f = freqs.values.reduce(0) { |a, e| a + (e * (e - 1)) } f / ((n * (n - 1)) / c) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def affected(text)\n occurrences = lines.each_index.select do |i|\n lines[i].start_with?(\"+\") && text.any? { |t| lines[i].include? t }\n end\n occurrences.map do |occ|\n lines[2..occ].reverse.find { |l| l.start_with? \"Index: \" }[7..]\n end\n end", "def text_commonality(text)\n probability_of_ngrams(common_ngrams_from_text(text))\n end", "def text_index(text)\n @model.documents.index do |document|\n document.text == text\n end\n end", "def text_index(text)\n @model.documents.index do |document|\n document.text == text\n end\n end", "def calculate(text)\n return 1 if text.blank?\n stripped_text = strip_tags(text).mb_chars.gsub('&#13;', '').gsub(/[^a-zA-ZA-Яа-я0-9]/, '')\n symbols_count = stripped_text.length\n [(symbols_count / READING_SPEED).ceil, 1].max\n end", "def classify(text)\n positive_value = 1\n neutral_value = 1\n negative_value = 1\n\n word = text.split(/\\W+/)\n word = word.drop(1) if word.first == ''\n word.each_with_index { |_, i|\n find_instances(word[i])\n positive_value *= ((((positive_polarity.to_f/positive_population.to_f).to_f) * ((positive_polarity).to_f))/word_pop)\n negative_value *= ((((negative_polarity.to_f/negative_population.to_f).to_f) * ((negative_polarity).to_f))/word_pop)\n neutral_value *= ((((neutral_polarity.to_f/neutral_population.to_f).to_f) * ((neutral_polarity).to_f))/word_pop)\n }\n total_counter(negative_value, neutral_value, positive_value)\n\n rescue => error\n puts error.backtrace\n\n end", "def diff(text)\n @diff ||= begin\n files = affected(text).uniq\n @raw.split(\"Index: \")\n .select { |i| files.any? { |f| i.start_with? f } }\n .map { |i| i.split \"\\n\" }\n .flatten\n end\n end", "def consonants(text)\n percent = text.consonants.length / text.length.to_f\n percent * @emphasis[:consonants]\n end", "def score_text(txt)\n txt_length = txt.length.to_f\n total_score = 0\n\n e_ratio = txt.count('e') / txt_length\n t_ratio = txt.count('t') / txt_length\n a_ratio = txt.count('a') / txt_length\n o_ratio = txt.count('o') / txt_length\n i_ratio = txt.count('i') / txt_length\n\n space_ratio = txt.count(' ') / txt_length\n\n total_score += 1 if i_ratio > 0.01 && i_ratio < 0.10\n total_score += 2 if e_ratio > 0.10 && e_ratio < 0.20\n total_score += 2 if t_ratio > 0.08 && t_ratio < 0.26\n total_score += 2 if a_ratio > 0.07 && a_ratio < 0.20\n total_score += 2 if o_ratio > 0.05 && o_ratio < 0.20\n total_score += 4 if space_ratio > 0.1 && space_ratio < 0.4\n\n # capital_ratio = txt.scan(/[ABCDEFGHIOUT]/).count / txt_length\n # total_score += 4 if capital_ratio > 0 && capital_ratio < 0.2\n\n return total_score\nend", "def detect(text)\n # Check dependency\n BioTCM::Databases::HGNC.ensure\n # Prepare symbol list\n unless @symbols\n @symbols = String.hgnc.symbol2hgncid.keys\n # Exclude symbol patterns\n @symbols.reject! { |sym| sym =~ @gene_regexp }\n end\n # Transform text\n (DEFAULT_TEXT_CHANGELIST + @text_changelist).each do |item|\n text.gsub!(item[0], item[1])\n end\n\n # Split sentences into words and eliminate redundancies\n rtn = text.split(/\\.\\s|\\s?[,:!?#()\\[\\]{}]\\s?|\\s/).uniq & @symbols\n # Return approved symbols\n @if_formalize ? rtn.formalize_symbol.uniq : rtn\n end", "def classify_with_score(text)\n (classifications(text).sort_by { |a| -a[1] })[0]\n end", "def text_probability(text)\n probability_of_ngrams(ngrams_from_text(text))\n end", "def similarity_score(classification, text)\n similarity_score_for_features(classification, features_of(text))\n end", "def text_similarity(text,other_model)\n other_model.text_commonality(text) / text_commonality(text)\n end", "def texts_score(text1, text2)\n words1 = text1.downcase.scan(/[a-zA-Z]+/) - noise_words\n words2 = text2.downcase.scan(/[a-zA-Z]+/) - noise_words\n common_words = words1 & words2\n p common_words\n common_words.length.to_f / (words1.length + words2.length)\n end", "def count_occurance(text='')\n raise \"input must be instance of String\" unless text.is_a?(String)\n\n text_chunks = text.downcase.gsub(ONE_OR_TWO_WORDS_RE, '').gsub(NON_ALPHANUMERIC_AND_NON_DOT_RE, ' ').gsub(@stopwords.to_re, '').gsub(/\\./, '').split\n text_chunks.inject(Hash.new(0)) do |container, word|\n container[word] += 1; container\n end\n end", "def score_text_two(text)\n txt = text.downcase\n txt_length = txt.length.to_f\n total_score = 0\n\n ALL_LETTERS.each_with_index do |l, i|\n l_freq = (txt.count(l) / txt_length) * 100\n total_score += (l_freq - CHAR_FREQ[i]).abs\n end\n\n space_ratio = txt.scan(/.\\s./).count / txt_length\n total_score += ((space_ratio * 100) - 14.0).abs\n\n return total_score\nend", "def get_word_occurence_index(word, sentence_index, word_sentence_index)\n word_occurence = 0\n i = 0\n \n while i<sentence_index\n word_occurence += @sentences[i].get_word_frequncy(word, nil)\n i += 1\n end\n \n word_occurence += @sentences[sentence_index].get_word_frequncy(word, word_sentence_index)\n return word_occurence\n end", "def find text\n preorder_traverse @fragment do |node|\n if node.text? then\n if not node.text.index(text).nil? then\n return node\n end\n end\n end\n end", "def lang_confidence(text)\n [detect(text)[\"responseData\"][\"language\"], detect(text)[\"responseData\"][\"confidence\"]]\n end", "def analyze_text(text)\n {\n :line_count => (text.split(/\\n/).last.chomp.empty? ? text.scan(/\\n/).count + 1 : text.scan(/\\n/).count),\n :character_count => text.length,\n :character_count_excluding_spaces => text.scan(/\\S/).length,\n :word_count => text.split(' ').length,\n :sentence_count => text.split(/[\\.?!]/).length,\n :paragraph_count => text.split(/\\n\\r/).length\n }\nend", "def _hashtag_reference_ranking(text, profile)\n hashtag_references = text.split(WORD_DELIMITER).find_all do |word|\n word.match(/^#/)\n end\n \n return 100 if hashtag_references.size == 0\n\n hashtag_references.inject(0) do |ranking, hashtag|\n ranking + (profile.hashtag_mentions.has_key?(hashtag) ? (100 / hashtag_references.size) : 0)\n end\n end", "def number_of_certifications(text)\n result = 0\n @certifications.each do |c|\n if text.downcase.include?(c)\n result += 1\n end\n end\n return result\nend", "def inclusion_score_for(str)\n n_gram_str, n = join_underscore(str)\n score = 0\n @text.split.each_cons(n) do |arr|\n text_to_compare = cleanup(arr.join('_')).downcase\n if score < (new_score = RubyFish::Jaro.distance(text_to_compare, n_gram_str.downcase))\n score = new_score\n end\n end\n score\n end", "def tokenize_text(text)\n data = Doc.new(text)\n featurize(data)\n classify(data)\n return data.segment\n end", "def score(text)\n text_array = text.split(\"\\n\")\n max_line_length = 0\n text_array.each { |l| max_line_length = l.length if l.length > max_line_length}\n score = 0\n text_array.each { |l|\n score += (max_line_length - l.length)**3\n }\n score\nend", "def analyze_text(text)\n hash = Hash.new(Array.new)\n text_array = text.split(/\\s/)\n text_array.each_with_index do |word, i|\n break if i == (text_array.length - 1)\n hash[word] += [text_array[i + 1]]\n end\n hash\n end", "def find(prepostion)\n\t\tpartial_search_kb = string_to_internal(preposition)\n\t\tpartial_search_kb.each do |sentence|\n\t\t\tind = @kb.index(sentence)\n\t\tend\n\t\treturn ind\n\tend", "def _word_count_ranking(text, profile)\n # Count the number of words in current text\n text_word_count = text.split(WORD_DELIMITER).size\n \n return 0 if text_word_count < 1 * profile.average_word_count / 3\n return 0 if text_word_count > 5 * profile.average_word_count / 3\n \n 100 - (100 * (text_word_count - profile.average_word_count).abs /\n (2 * profile.average_word_count / 3))\n end", "def contains_text(str)\n text.index(str)\n end", "def tokenize_text(text)\n data = Doc.new(text)\n featurize(data)\n classify(data)\n return data.segment\n end", "def count_word_combinations( text )\n combinations = @word_combinations_database.find_all{|v| text.index( v )}\n combinations.each{|combination|\n add_word( combination )\n }\n return combinations\n end", "def classify(text)\n scores = classification_scores(text)\n if scores.any?\n (scores.sort_by { |a| -a[1] })[0][0]\n else\n ''\n end\n end", "def sentence_score(hex_string) # rubocop:disable Metrics/MethodLength\n real_string = hex_to_chars(hex_string).chars\n real_string.map do |chr|\n case chr.ord\n when 33..64, 91..96, 123..127\n 0.5 # punctuation / numbers\n when 32, 65..90, 97..122\n 1\n else\n -2.5 # control characters\n end\n end.sum / real_string.length.to_f\nend", "def total_cost(text)\n text.split(\"\\n\").inject(0){ |acc, line| acc + line_cost(line) }\n end", "def score(text, stream_id)\n return [-1, {}] unless PerspectiveApi.enabled\n\n result = make_request(text, stream_id)\n Rails.logger.info(\"CommentAnalyzer: #{result}\")\n\n return handle_error(result) if result[\"error\"]\n\n [result[\"attributeScores\"][\"TOXICITY\"][\"summaryScore\"][\"value\"], result]\n end", "def extract(text, **options)\n tokens = tokenize(text)\n graph = PageRank.new(**@page_rank_options)\n classify(@graph_strategy, context: GraphStrategy).build_graph(tokens, graph)\n ranks = graph.calculate(**options)\n apply_rank_filters(ranks, tokens: tokens, original_text: text)\n end", "def classify(text)\n result, score = classify_with_score(text)\n result = nil if score < @threshold || score == Float::INFINITY if threshold_enabled?\n result\n end", "def analyze(text, analysis_params)\n request(:get, \"_analyze\") do |req|\n req.body = { text: text }.merge(analysis_params)\n end\n end", "def match(text)\n shift = 0\n result = []\n\n # Try to take previous element from cache, if .test() called before\n if (@__index__ >= 0 && @__text_cache__ == text)\n result.push(Match.createMatch(self, shift))\n shift = @__last_index__\n end\n\n # Cut head if cache was used\n tail = shift ? text.slice(shift..-1) : text\n\n # Scan string until end reached\n while (self.test(tail))\n result.push(Match.createMatch(self, shift))\n\n tail = tail.slice(@__last_index__..-1)\n shift += @__last_index__\n end\n\n if (result.length)\n return result\n end\n\n return nil\n end", "def text_search(target_string)\n\t\t# NOTE: always search all entities, not just the ones that are on screen\n\t\t# (not sure how you should let the user know that there are entities that have been found, but which are not currently on the screen)\n\t\ttext_objects = @space.entities.select{|x| x.is_a? ThoughtTrace::Text }\n\t\t\n\t\thighlight_mapping = \n\t\t\ttext_objects.map do |text|\n\t\t\t\ti = text.string.index target_string\n\t\t\t\t\n\t\t\t\t[text, i, i+target_string.size] if i\n\t\t\tend\n\t\thighlight_mapping.compact!\n\t\t\n\t\t\n\t\t\n\t\t# highlight the portions of the string the match the search query\n\t\tcolor = Gosu::Color.argb(0x99FF0000)\n\t\t\n\t\thighlight_mapping.each do |text, start_i, end_i|\n\t\t\t# NOTE: width_of_first may break for i=1, because it handles conversion weird. need to totally overhaul that\n\t\t\tax = text.width_of_first(start_i)\n\t\t\tbx = text.width_of_first(end_i)\n\t\t\t\n\t\t\theight = text[:physics].shape.height\n\t\t\toffset = height / 2\n\t\t\t\n\t\t\tp = text[:physics].body.p\n\t\t\ta = CP::Vec2.new(ax, offset) + p\n\t\t\tb = CP::Vec2.new(bx, offset) + p\n\t\t\t\n\t\t\tThoughtTrace::Drawing.draw_line(\n\t\t\t\t$window, a,b, \n\t\t\t\tcolor:color, thickness:height, line_offset:0.5, z_index:0\n\t\t\t)\n\t\tend\n\tend", "def sentiment_from_text text_content:\n # [START language_sentiment_text]\n # text_content = \"Text to run sentiment analysis on\"\n\n require \"google/cloud/language\"\n\n language = Google::Cloud::Language.language_service\n\n document = { content: text_content, type: :PLAIN_TEXT }\n response = language.analyze_sentiment document: document\n\n sentiment = response.document_sentiment\n\n puts \"Overall document sentiment: (#{sentiment.score})\"\n puts \"Sentence level sentiment:\"\n\n sentences = response.sentences\n\n sentences.each do |sentence|\n sentiment = sentence.sentiment\n puts \"#{sentence.text.content}: (#{sentiment.score})\"\n end\n # [END language_sentiment_text]\nend", "def _word_usage_ranking(text, profile)\n # The word list must be filtered of stop words, otherwise that might\n # affect our word usage rank incorrectly\n word_list = text.gsub(URL_REGEXP, '').split(WORD_DELIMITER).reject do |word|\n word.match(/^[@#]/) || profile.stop_words.member?(word.downcase)\n end\n\n return 100 if word_list.size == 0\n\n word_list.inject(0) do |ranking, word|\n ranking + (profile.dictionary.has_key?(word.downcase) ? (100 / word_list.size) : 0)\n end\n end", "def annotate_based_on_approximate_string_matching(text)\n # Generate queries from an input text\n build_opts = { min_tokens: @options[\"min_tokens\"],\n max_tokens: @options[\"max_tokens\"] }\n norm_opts = @pgr.get_string_normalization_options\n\n queries = @qbuilder.build_queries(text, build_opts, norm_opts)\n\n # Perform query expansion using both the PG and SimString DBs.\n ext_queries = @qbuilder.expand_queries(queries, @options[\"threshold\"], @ssr, @pgr)\n\n # Retrieve database entries\n results = @pgr.retrieve(ext_queries)\n\n # Applies post-processing methods\n if @options[\"top_n\"] > 0\n results = @pproc.get_top_n(results, @options[\"top_n\"])\n end\n results = @pproc.filter_based_on_simscore(results)\n results = @pproc.keep_last_one_for_crossing_boundaries(results)\n\n # Returns the results\n format_results(results)\n end", "def calculate\n @text.scan(\"#{@keyword}\").size\n end", "def closest_character_index(position)\n\t\t\t# Move caret into position\n\t\t\t# Try to get as close to the position of the cursor as possible\n\t\t\twidth = @font.width(@string, @height)\n\t\t\tx = @position.x\n\t\t\tmouse_x = $window.mouse.position_in_world.x\n\t\t\t\n\t\t\t# Figure out where mouse_x is along the continuum from x to x+width\n\t\t\t# Use that to guess what the closest letter is\n\t\t\t# * basically, this algorithm is assuming fixed width, but it works pretty well\n\t\t\tpercent = (mouse_x - x)/width.to_f\n\t\t\ti = (percent * (@string.length)).to_i\n\t\t\t\n\t\t\ti = 0 if i < 0\n\t\t\ti = @string.length if i > @string.length\n\t\t\t\n\t\t\treturn i\n\t\tend", "def calculate_distance(translated_text, answer)\n DamerauLevenshtein.distance(prepare(translated_text), prepare(answer))\n end", "def segment_citations(cite_text)\n marker_type = guess_marker_type(cite_text)\n unless marker_type == 'UNKNOWN'\n citations = split_unmarked_citations(cite_text)\n else\n citations = split_citations_by_marker(cite_text, marker_type)\n end\n return citations\n end", "def analyze(text, analysis_params)\n request(:get, \"_analyze\", analysis_params) do |req|\n req.body = text\n end\n end", "def analyze(text)\n @markov.merge!(self.class.analyze(text, @num_prefix_words))\n end", "def extrapolate(text)\n case @type\n when :prefix\n return text[@value.length..text.length]\n when :suffix\n return text[0..-@value.length-1]\n when :dual\n return text[@value[0].length..-@value[1].length-1]\n when :regex\n return self.match(text)\n end\n end", "def find_id(text)\n return [] if text.nil? || text == ''\n\n q = 0\n result = []\n text.chars.each_with_index do |c, _i|\n loop do\n node = @nodes[q]\n if (to_go_next = node.goto[c])\n q = to_go_next\n break\n end\n break if q.zero?\n\n q = node.failure\n end\n\n out = @nodes[q].out\n result.concat(out) unless out.empty?\n end\n\n result\n end", "def perform(text)\n # Returning no preposition in text if text is nil\n return message(0) unless text\n\n qnt = text.split # splitting text up into some words\n .keep_if { |word| preposition?(word) } # keeping only prepositions from all words in the text\n .count # counting how many prepositions there are\n return message(qnt)\n end", "def search(text, options)\n resp = create_request().get(build_index_search_url(text, options))\n raise_on_http_error(resp)\n return JSON.parse(resp.to_s)\n end", "def text text\n # Return the first element matching selector.\n # s.textContains(value)\n mobile :find, [ [ [3, text] ] ]\n end", "def _user_reference_ranking(text, profile)\n user_references = text.split(WORD_DELIMITER).find_all do |word|\n word.match(/^@/)\n end\n \n return 100 if user_references.size == 0\n\n user_references.inject(0) do |ranking, user|\n ranking + (profile.user_mentions.has_key?(user) ? (100 / user_references.size) : 0)\n end\n end", "def entrez_score(candidates, text, to_entrez = nil)\n code2entrez = {}\n candidates.each{|code, score|\n if to_entrez.is_a? Proc\n entrez = to_entrez.call(code)\n elsif to_entrez.is_a? Hash\n entrez = @to_entrez[code]\n else\n entrez = code\n end\n code2entrez[code] = entrez unless entrez.nil? \n }\n\n # Get all at once, better performance\n genes = Entrez.get_gene(code2entrez.values)\n\n code2entrez_genes = code2entrez.collect{|key, value| [key, genes[value]]}\n\n code2entrez_genes.collect{|p|\n [p[0], Entrez.gene_text_similarity(p[1], text)]\n }\n end", "def weight(text)\n weight = @emphasis[:multiplier]\n\n if text.length >= @emphasis[:long_words_threshold]\n weight *= @emphasis[:long_words]\n end\n\n if text[0,1] == text[0,1].upcase\n weight *= @emphasis[:upper_case]\n end\n\n weight += vowels(text)\n weight += consonants(text)\n weight\n end", "def count(text, check)\n i = 0\n count = 0\n while i < text.length\n if text[i] == check\n count +=1\n end\n i = i + 1\n end\n return count\nend", "def index_of_coincidence(matrix)\n\n matrix.inject([]) do |indices, row_letters|\n frequencies = letter_frequencies(row_letters)\n\n indices << (\"A\"..\"Z\").inject(0) { |a,v|\n x = frequencies[v]\n a += x*(x-1)\n a\n } / (row_letters.size * (row_letters.size - 1))\n end\n\nend", "def classify(text)\n classify_features(features_of(text)).last\n end", "def text_search(search_text, limit, offset)\n query_strategy.text_search(search_text, limit, offset)\n end", "def detect_dialog(text)\n if (match = text.match(/^([0-9]+),( |)([0-9]+)/))\n text = GameData::Text.get_dialog_message(match[1].to_i, match[3].to_i)\n end\n return text\n end", "def findTokenInText(theText, theToken, findAfter)\n\n\tif (findAfter == nil)\n\t\ttheOffset = theText.index(theToken);\n\telse\n\t\ttheOffset = theText.index(findAfter);\n\t\tif (theOffset != nil)\n\t\t\ttheOffset = theText.index(theToken, theOffset);\n\t\tend\n\tend\n\t\n\treturn theOffset;\n\nend", "def common_neighbours(str1, str2)\n pairs1 = get_bigrams(str1)\n pairs2 = get_bigrams(str2)\n union = pairs1.length + pairs2.length;\n hit_count = 0\n pairs1.each{ |pair1|\n pairs2.each{ |pair2|\n hit_count += 1 if pair1 == pair2\n }\n }\n #return (2.0 * hit_count) / union.to_f\n return ((2.0 * hit_count) / union.to_f) / [str1.length, str2.length].min.to_f # -1)\n end", "def word_instances(text)\n instances = Hash.new(0)\n normalize(text).each do |word|\n instances[word] += 1\n end\n instances\nend", "def analysis\n @str = params[:text] ||= '解析対象の文字列'\n @words = Tag.counter(Tag.generate(@str))\n end", "def detect_sentiment(text, language)\r\n\t\t\tlang = LANGUAGES[language] ? LANGUAGES[language] : \"eng\"\r\n\t\t\tquery_params = %(text=#{text}&lang=#{lang}).tr(\" \", \"+\")\r\n\t\t\turl = construct_target_url(:detectsentiment, query_params)\t\r\n\t\t\t\r\n\t\t\tURI.parse(url).read\r\n\t\tend", "def calculate_match_probability\n # two heuristics: \n # 1 is are their multiple words in term_text? if so, mark as probable\n # if not, does it match the anchor regexp? if so, mark as probable\n # else, mark as improbable\n \n # multiple words?\n anchor_regexp = \"(featuring|plus|the|presents|with|plus|and|\\,|\\&|[()]|\\/|\\:|\\-|^|$)\"\n nix_regexp = \"parking|\\svs\\.?\\s\" \n if artist_name=~/#{nix_regexp}/i\n self.match_probability=\"unlikely\"\n return nil\n end\n text=term_text.strip\n if text[\" \"]\n self.match_probability=\"likely\"\n return \"multpl\"\n end\n if artist_name=~/#{anchor_regexp}\\s*#{text}\\s*#{anchor_regexp}/i\n self.match_probability=\"likely\"\n return \"regexp\"\n end\n# if artist_name=~/#{anchor_regexp}\\s+?#{text}\\s+?#{anchor_regexp}/i\n# match_probability=\"likely\"\n# return \"regexp\"\n# end\n self.match_probability=\"unlikely\"\n return nil\n end", "def number_of_stats_skillz(text)\n result = 0\n @statistics_skillz.each do |s|\n if text.downcase.include?(s)\n result += 1\n end\n end\n return result\nend", "def predict(text)\n tokens = @tokenizer.tokenize(text)\n scores = {}\n\n @data.each_key do |label|\n scores[label] = probability_tokens_are_label(tokens, label)\n end\n\n scores\n end", "def estimated_timestamp_for(text)\n tweet_interval = recent_tweet_interval\n tweet = last_tweet\n current_sequence_nr = sequence_nr_for(tweet.text)\n expected_sequence_nr = sequence_nr_for(text)\n if (nr_of_tweets = expected_sequence_nr - current_sequence_nr) <= 0\n :already_tweeted\n elsif tweet_interval == :not_tweeting\n :not_tweeting\n else\n tweet.created_at + (nr_of_tweets * tweet_interval)\n end\n end", "def anomaly_score(text)\n -1 * similarity_score(text) / stddev_of_scores_of_training_set\n end", "def link_text_score(*args)\n rows, word_ids = args\n link_scores = rows.to_hash { |row| [ row[0], 0 ] }\n word_ids.each do |word_id|\n # TODO: replace with ActiveRecord\n @db.execute(\"select l.from_id, l.to_id from link_words w, link l where w.word_id = ? and w.link_id = l.rowid\", word_id.to_i).each do |from, to|\n if link_scores.has_key? to\n pr = @db.get_first_row(\"select score from page_rank where url_id = ?\", from.to_i)[0].to_f\n link_scores[to] += pr\n end\n end\n end\n \n max_score = link_scores.values.max\n link_scores.to_a.to_hash do |url, score|\n [ url, score / max_score ]\n end\n end", "def match(search)\n search_words = words(search)\n haystack_words = words(haystack)\n\n (\n search_words.count { |search_word| haystack_words.include? search_word } /\n search_words.count.to_f *\n 100\n ).round\n rescue ZeroDivisionError\n 0\n end", "def text_position\n end", "def to_offset(text, position); end", "def _match_count (substr, text)\n return 0 if (!text || !substr)\n\n count = 0\n offset = 0\n while (result = text.index(substr, offset))\n count += 1\n offset = result + 1\n end\n count\n end", "def accuracy_text\n acc = data.accuracy\n return text_get(11, 12) if acc == 0\n\n return acc.to_s\n end", "def guess_rank(text_name)\n TEXT_NAME_MATCHERS.find { |m| m.match?(text_name) }.rank\n end", "def improve(text)\n return Typogruby.improve(text.to_s)\n end", "def annotate_based_on_exact_string_matching(text)\n # Generate queries from an input text\n build_opts = { min_tokens: @options[\"min_tokens\"],\n max_tokens: @options[\"max_tokens\"] }\n norm_opts = @pgr.get_string_normalization_options\n queries = @qbuilder.build_queries(text, build_opts, norm_opts)\n\n # Retrieve the entries from PostgreSQL DB\n results = @pgr.retrieve( @qbuilder.change_format(queries) )\n\n # Apply post-processing methods\n if @options[\"top_n\"] > 0\n results = @pproc.get_top_n(results, @options[\"top_n\"])\n end\n results = @pproc.keep_last_one_for_crossing_boundaries(results)\n\n format_results(results)\n end", "def frequency(text)\n text = text.downcase.gsub(/\\s*/, '')\n chars = text.split('')\n freqs = Hash[('a'..'z').to_a.zip([0] * 26)]\n\n chars.each { |c| freqs[c] += 1 }\n\n freqs\n end", "def print_index\n\t\t#zet de index nr in text_index\n\t\ttext_index = \"Hello, Ruby.\".index /Ruby/\n\t\t#print text_index\n\t\tputs text_index\n\tend", "def get_dry_candidates(text)\n freq = Hash.new { |h, k| h[k] = 0 }\n text.each do |line|\n get_chunks(line).each do |chunk|\n freq[chunk] += 1\n end\n end\n freq.keys.reject { |chunk| freq[chunk] < @min_freq }\n end", "def isCensored?(orgtext)\n\t\t\tfound = []\n\t\t\tWORDS.each do |word|\n\t\t\t\ttext = orgtext\n\t\t\t\tmword = word[0]\n\t\t\t\tif !word[1]\n\t\t\t\t\t# no exact match\n\t\t\t\t\ttext = convertString(text)\n\t\t\t\t\tmword = convertString(mword)\n\t\t\t\tend\n\t\t\t\tfound.push(word[0]) if text.index(mword)\n\t\t\tend\n\t\t\treturn found\n\t\tend", "def common_ngrams_from_text(text)\n ngrams_from_text(text).select { |ngram| has_ngram?(ngram) }\n end", "def score(plaintext)\n score = 0\n @wordlist.each do |word|\n score += plaintext.scan(/\\b#{word}\\b/).count\n end\n return score\nend", "def find_language(text)\n @cc.find_language(Result, SpanInfo, text.encode(Encoding::UTF_8))\n end", "def number_of_honors(text)\n result = 0\n @honors.each do |h|\n if text.downcase.include?(h)\n result += 1\n end\n end\n return result\nend", "def train(category, text)\n hash = @categories[category.to_sym] ||= Hash.new(0)\n split(text).each{|word| hash[word] += 1 }\n end", "def text\n @text[range]\n end", "def index_of(sentence, letter)\n\tcounter=0\n\tsentence_split=sentence.split(//)\n\twhile counter<sentence.length\n\t\tcounter=counter+1\n\t\tif sentence_split[counter] == letter\n\t\t\treturn counter\n\t\tend\n\tend\n\t-1\nend", "def page_sentiment (positive, negative)\n totalwords = 0\n count = 0.0\n sentimentwords = 0.0\n if(@thewords)\n #This is the main loop, if each word is positive or negative in the document adjust variables accordingly.\n @thewords.each do |word|\n totalwords+= 1\n if positive.map(&:downcase).include? word[0].downcase\n # puts word[0]\n count +=word[1]\n sentimentwords +=word[1]\n elsif negative.map(&:downcase).include? word[0].downcase\n # puts word[0]\n count -=word[1]\n sentimentwords +=word[1]\n end\n end\n end\n ratio = count/sentimentwords\n if (ratio > 0.10)\n count = 1\n elsif (ratio < -0.10)\n count = -1\n else\n count = 0\n end\n return count\n end", "def word_count(text)\n\tnew_text = text.split(\" \") #-->Use text.split to turn text into an array that breaks(splits) at each space.\n\t\n \tcounter = Hash.new(0) #-->Next create an empty hash for your results with count = Hash.new (0)\n\n \tnew_text.each {|word| counter[word] += 1} #-->Use a method that will take each word in the array\n\n \tputs counter #-->This will give us our results printed on the screen\nend", "def relative_text_position(index)\n if at_end?(index)\n relative_end_position\n elsif relative_in_first_segment?(index)\n relative_in_first_segment(index)\n else\n relative_in_last_segment(index)\n end\n end", "def match_percentage incorrect, possible\n #Creates character arrays for both words\n incorrect_array = incorrect.split(\"\")\n possible_array = possible.split(\"\")\n\n #Hashes to hold count of each char\n incorrect_hash = Hash.new(0)\n possible_hash = Hash.new(0)\n\n #Counts the characters in each word\n incorrect_array.each do |char|\n incorrect_hash[char] += 1\n end\n possible_array.each do |char|\n possible_hash[char] += 1\n end\n \n ##Compares the two hashes and returns similarity as a decimal\n #The overall percentage and total characters, used to calculate final percentage\n overall_percentage = 0.to_f\n total_chars = [incorrect_hash.keys.length, possible_hash.keys.length].max\n #Iterates over the hash for the possible correction\n possible_hash.each do |chars|\n #Sets char to the actual character\n char = chars[0]\n #Sets value_possible to count in possible hash\n value_possible = chars[1]\n #Sets value_incorrect to count in incorrect hash\n value_incorrect = incorrect_hash[char]\n\n #If neither value is zero calcluates similarity and adds to overall_percentage, otherwise its 0\n if value_possible != 0 && value_incorrect != 0\n min = [value_possible, value_incorrect].min\n max = [value_possible, value_incorrect].max\n overall_percentage += (min.to_f / max.to_f)\n end\n end\n #Calculates similarity percentage and returns\n overall_percentage /= total_chars\n\n return overall_percentage * $lexicon[possible[0]][possible.length][possible]\nend", "def search_text(text)\n sets = @schemes.map do |scheme|\n scheme.find_all(text).uniq\n end\n sets.flatten.uniq\n end", "def geternode(text)\n #@prnode = Prnode.where(\"pgscore > 0\").first.pgnodename\n\n @prnodes = Prnode.select(:pgnodename)\n\n puts \"DEBUGHEeeeeeeeeeeeeeeee\"\n # puts @prnodes.inspect\n #[@prnodes.first.pgnodename, @prnodes.first.pgscore]\n\n FuzzyMatch.new(@prnodes).find(text)\n\n end", "def weightsCalc\n begin\n terms = $index.keys\n # Calculate inverted-idf for each term\n terms.each do |term|\n df = 0\n $index[term].each do |tf|\n df += tf[1]\n end\n # Get number of docs\n docs = $index[term].keys\n docs = docs.max\n idf = Math.log(df/docs.to_f, 10)\n $index[term][0] = idf\n end\n\n # For each term calculate the term-freq\n # Iterate over terms\n terms.each do |term|\n # Get all doc numbers for term\n docs = $index[term].keys\n # Iterate over doc numbers\n docs.each do |key|\n if key != 0\n val = $index[term][key]\n newVal = 0\n if val != 0\n newVal = 1 + Math.log($index[term][key], 10)\n end\n $index[term][key] = newVal\n end\n end\n end\n\n # Now calculate cosine normalized score for each term\n terms.each do |term|\n idf = $index[term][0]\n sum = 0\n $index[term].each do |weight|\n if weight[0] != 0\n #Gets weight and puts into divisor of cosine normalzing sum\n sum += weight[1]**2\n end\n end\n # Cosine sum is calculated\n consineDiv = Math.sqrt(sum)\n\n # Calculate cosine normalized weight for each doc\n $index[term].each do |weight|\n if weight[0] != 0\n #puts weight\n $index[term][weight[0]] = weight[1] / consineDiv.to_f\n end\n end\n\n # Calculate final score for each doc\n $index[term].each do |weight|\n if weight[0] != 0\n $index[term][weight[0]] = idf * weight[1]\n end\n end\n\n # Average score for each doc\n avgScore = 0\n $index[term].each do |weight|\n if weight[0] != 0\n avgScore += weight[1]\n end\n end\n\n # Put weight in index\n $index[term] = avgScore / $index[term].length.to_f\n end\n puts \"Weights calculated\"\n rescue\n puts \"Error calculating weights\"\n end\nend" ]
[ "0.6151377", "0.5956082", "0.5904203", "0.5904203", "0.5789559", "0.57890046", "0.5551213", "0.5531335", "0.5522033", "0.5488921", "0.5447444", "0.5418568", "0.54172283", "0.5332028", "0.5323192", "0.52985203", "0.5290097", "0.5173864", "0.51621234", "0.51189315", "0.5078153", "0.50428504", "0.50019765", "0.497662", "0.49360585", "0.49330154", "0.4923003", "0.49152666", "0.49144158", "0.48960516", "0.48918265", "0.4890825", "0.48464593", "0.48326555", "0.47747174", "0.4766985", "0.47519684", "0.47299963", "0.46974155", "0.46924716", "0.46827218", "0.46803355", "0.46789283", "0.4673792", "0.46645203", "0.46379122", "0.4636434", "0.46271664", "0.46231753", "0.46147776", "0.46109718", "0.46056038", "0.4592276", "0.45922416", "0.45841354", "0.4580453", "0.4576667", "0.45747694", "0.45688036", "0.4568468", "0.4556305", "0.45557585", "0.45321777", "0.45316955", "0.45143014", "0.4512834", "0.45102456", "0.44996813", "0.4494394", "0.44890243", "0.44853964", "0.4482899", "0.44813082", "0.44776264", "0.44770876", "0.44770816", "0.4462772", "0.44598955", "0.44590777", "0.44481558", "0.44389144", "0.4430914", "0.44267374", "0.44257605", "0.44249797", "0.44189757", "0.44180825", "0.44076514", "0.43960375", "0.439527", "0.4390842", "0.43835557", "0.4377855", "0.43734297", "0.43733793", "0.4372738", "0.43720496", "0.4371376", "0.4371258", "0.43665344" ]
0.5084836
20
Public: Calculates the percentage of text composed of vowels. (Y is not included as a vowel.) === Parameter(s) +text+ +String+: The text to analyze. === Return Value +Float+: The percentage comprising vowels.
def vowels(text) vowels = %w(A E I O U) chars = text.upcase.split('') vowel_count = 0 chars.each { |c| vowel_count += 1 if vowels.include? c } vowel_count.to_f / text.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vowels(text)\n percent = text.vowels.length / text.length.to_f\n percent * @emphasis[:vowels]\n end", "def score_text(txt)\n txt_length = txt.length.to_f\n total_score = 0\n\n e_ratio = txt.count('e') / txt_length\n t_ratio = txt.count('t') / txt_length\n a_ratio = txt.count('a') / txt_length\n o_ratio = txt.count('o') / txt_length\n i_ratio = txt.count('i') / txt_length\n\n space_ratio = txt.count(' ') / txt_length\n\n total_score += 1 if i_ratio > 0.01 && i_ratio < 0.10\n total_score += 2 if e_ratio > 0.10 && e_ratio < 0.20\n total_score += 2 if t_ratio > 0.08 && t_ratio < 0.26\n total_score += 2 if a_ratio > 0.07 && a_ratio < 0.20\n total_score += 2 if o_ratio > 0.05 && o_ratio < 0.20\n total_score += 4 if space_ratio > 0.1 && space_ratio < 0.4\n\n # capital_ratio = txt.scan(/[ABCDEFGHIOUT]/).count / txt_length\n # total_score += 4 if capital_ratio > 0 && capital_ratio < 0.2\n\n return total_score\nend", "def score_text_two(text)\n txt = text.downcase\n txt_length = txt.length.to_f\n total_score = 0\n\n ALL_LETTERS.each_with_index do |l, i|\n l_freq = (txt.count(l) / txt_length) * 100\n total_score += (l_freq - CHAR_FREQ[i]).abs\n end\n\n space_ratio = txt.scan(/.\\s./).count / txt_length\n total_score += ((space_ratio * 100) - 14.0).abs\n\n return total_score\nend", "def letter_percentages(string)\n lowercase = 0.0\n uppercase = 0.0\n neither = 0.0\n string.each_char do |char|\n if char.upcase == char && char.downcase == char\n neither += 1\n elsif char.downcase == char\n lowercase += 1\n else\n uppercase += 1\n end\n end\n\n l_perc = ((lowercase / string.size) * 100).round(2)\n u_perc = ((uppercase / string.size) * 100).round(2)\n n_perc = ((neither / string.size) * 100).round(2)\n\n { lowercase: l_perc, uppercase: u_perc, neither: n_perc }\nend", "def calculate_percentage(string) #def calculate_percentage(\"Aand\")\n characters = sanitize(string) #characters = sanitize(\"Aand\") --> {\"a\" => 2, \"n\" => 1, \"d\" => 1}\n characters.each do |letter, count| #|a, 2| |n, 1| |d,2|\n characters[letter] = count.to_f/string.length # 2/4 1/4 1/4\n end\nend", "def letter_percentages(string)\n percentages = { lowercase: 0.0, uppercase: 0.0, neither: 0.0 }\n\n string.chars.each do |char|\n if char.downcase!\n percentages[:uppercase] += 100.0/string.size\n elsif char.upcase!\n percentages[:lowercase] += 100.0/string.size\n else\n percentages[:neither] += 100.0/string.size\n end\n end\n\n percentages.transform_values! { |percent| percent.round(2) }\nend", "def calculate_percent(str, criteria)\n size = str.size.to_f\n percent = str.count(criteria)/size * 100\n percent.round(2)\nend", "def letter_percentages(str)\n hsh = { lowercase: 0, uppercase: 0, neither: 0 }\n\n str.chars.each do |elem|\n if elem =~ /[a-z]/\n hsh[:lowercase] += 1\n elsif elem =~ /[A-Z]/\n hsh[:uppercase] += 1\n else\n hsh[:neither] += 1\n end\n end\n hsh.transform_values! { |v| format('%.1f', v.fdiv(str.length) * 100).to_f }\nend", "def letter_percentages(string)\n low, up, non = [0, 0, 0]\n\n string.each_char do |chr|\n case chr\n when /[a-z]/ then low += 1\n when /[A-Z]/ then up += 1\n else non += 1\n end\n end\n\n convert = 100 / string.size.to_f\n low *= convert\n up *= convert\n non *= convert\n\n percentages = { lowercase: low, uppercase: up, neither: non}\nend", "def calculate(text)\n return 1 if text.blank?\n stripped_text = strip_tags(text).mb_chars.gsub('&#13;', '').gsub(/[^a-zA-ZA-Яа-я0-9]/, '')\n symbols_count = stripped_text.length\n [(symbols_count / READING_SPEED).ceil, 1].max\n end", "def parse(text)\n text.gsub(/[\\s%]/, '').strip.to_f\n end", "def count_vowels\n text.scan(/[aeoui]/).length\n end", "def letter_percentages(str)\n percentages = {}\n str_length = str.length.to_f\n\n percentages[:lowercase] = ((str.count('a-z') / str_length) * 100).round(1)\n percentages[:uppercase] = ((str.count('A-Z') / str_length) * 100).round(1)\n percentages[:neither] = 100 - percentages[:lowercase] - percentages[:uppercase]\n\n percentages\nend", "def percentage_of_passives\n calculator.percentage_of_passives\n end", "def percent\n self.scan(/./).join('%')\n end", "def percentage; end", "def letter_percentages(string)\n\n percent_hash = { lowercase: [], uppercase: [], neither: [] }\n counts = { lowercase: 0, uppercase: 0, neither: 0 }\n characters = string.chars\n\n counts[:lowercase] = characters.count { |ch| ch =~ /[a-z]/ }\n counts[:uppercase] = characters.count { |ch| ch =~ /[A-Z]/ }\n counts[:neither] = characters.count { |ch| ch =~ /[^A-Za-z]/ }\n\n percent_hash[:lowercase] = format(\"%0.2f\", (counts[:lowercase] / string.size.to_f) * 100)\n percent_hash[:uppercase] = format(\"%0.2f\", (counts[:uppercase] / string.size.to_f) * 100)\n percent_hash[:neither] = format(\"%0.2f\", (counts[:neither] / string.size.to_f) * 100)\n percent_hash\nend", "def percent_against\n (votes_against.to_f * 100 / (self.votes.size + 0.0001)).round\n end", "def letter_percentages(string)\n chars = string.split('')\n\n hash_of_percentages = { lowercase: 0.0, uppercase: 0.0, neither: 0.0}\n hash_of_percentages = calculate_chars(chars, hash_of_percentages)\n\n total_chars = chars.length\n hash_of_percentages = calculate_percentages(hash_of_percentages, total_chars)\n\n return hash_of_percentages\nend", "def count_vowels(word)\nend", "def letter_percentages(string)\n case_hash = { lowercase: 0, uppercase: 0, neither: 0 }\n\n string.each_char do |char|\n case\n when char =~ /[A-Z]/ then case_hash[:uppercase] += 1\n when char =~ /[a-z]/ then case_hash[:lowercase] += 1\n else case_hash[:neither] += 1\n end\n end\n\n characters = string.length.to_f\n case_hash.keys.each do |key|\n case_hash[key] /= characters\n case_hash[key] *= 100\n end\n\n case_hash\nend", "def letter_percentages(str)\n count_lowercase = 0\n count_uppercase = 0\n count_neither = 0\n\n str.each_char do |char|\n if %w(1 2 3 4 5 6 7 8 9 0).include?(char)\n count_neither += 1\n elsif ('A'..'Z').include?(char)\n count_uppercase += 1\n elsif ('a'..'z').include?(char)\n count_lowercase += 1\n else\n count_neither += 1\n end\n\n end\n\n percent_lowercase = (count_lowercase.to_f / str.length) * 100\n percent_uppercase = (count_uppercase.to_f / str.length) * 100\n percent_neither = (count_neither.to_f / str.length) * 100\n\n hsh = {\n lowercase: percent_lowercase,\n uppercase: percent_uppercase,\n neither: percent_neither\n }\nend", "def percent_of_word(word)\n @total_count = SubWordJoin.where(word: word).count\n puts @total_count\n sub_count = 0\n @sub = SubDriver.where(driver: self)\n @sub.each do |sub|\n sub_count += SubWordJoin.where(word: word, sub_driver: sub).count\n end\n\n percent = (sub_count.to_f/@total_count)*100\n return percent.round(2)\n\n end", "def letter_percentages(str)\n percentages = {}\n percentages[:lowercase] = (str.count('a-z').to_f / str.size) * 100\n percentages[:uppercase] = (str.count('A-Z').to_f / str.size) * 100\n percentages[:neither] = (str.count('^A-Za-z').to_f / str.size) * 100\n percentages\nend", "def percentage\n 0.0\n end", "def count_vowels(str)\n str.chars.map do |letter|\n if vowel? letter\n letter = 1\n else\n letter = 0\n end\n end.reduce(0, :+)\nend", "def text_probability(text)\n probability_of_ngrams(ngrams_from_text(text))\n end", "def percentages\n @_percentages ||= words.each_with_object({}) do |word_count, hash|\n hash[word_count.first] = percentage(word_count.last)\n end\n end", "def letter_percentages(string)\n letter_case_count = letter_case_count(string)\n result = {}\n letter_case_count.each do |type, num|\n result[type] = (num / letter_case_count.values.sum.to_f * 100).round(1)\n end\n result\nend", "def love(string1, string2)\n matches = string1.count(string2) #.count returns number of matches \n total = string1.length + string2.length #\n puts total/matches;\nend", "def num_vowels(str)\n # your code goes here\n str.downcase!\n str.count(\"aeiou\")\nend", "def count_vowels(string)\n string.downcase.count('aeiou')\nend", "def count_vowels(str)\n str.count(\"aeoui\")\nend", "def vowel_count(str)\n str.downcase.count('aeiou')\nend", "def classify(text)\n positive_value = 1\n neutral_value = 1\n negative_value = 1\n\n word = text.split(/\\W+/)\n word = word.drop(1) if word.first == ''\n word.each_with_index { |_, i|\n find_instances(word[i])\n positive_value *= ((((positive_polarity.to_f/positive_population.to_f).to_f) * ((positive_polarity).to_f))/word_pop)\n negative_value *= ((((negative_polarity.to_f/negative_population.to_f).to_f) * ((negative_polarity).to_f))/word_pop)\n neutral_value *= ((((neutral_polarity.to_f/neutral_population.to_f).to_f) * ((neutral_polarity).to_f))/word_pop)\n }\n total_counter(negative_value, neutral_value, positive_value)\n\n rescue => error\n puts error.backtrace\n\n end", "def num_vowels(str)\n str.count(VOWELS)\nend", "def formatPercentageValue(input)\n output = input.gsub(/\\(/, \"\")\n output.gsub!(/%\\)$/, \"\")\n return output\n end", "def ioc(text)\n c = 26.0\n freqs = frequency(text)\n n = text.length\n\n f = freqs.values.reduce(0) { |a, e| a + (e * (e - 1)) }\n f / ((n * (n - 1)) / c)\n end", "def vowel_count(string)\n\t\n\tstring.downcase.count \"aeiou\"\n\t\nend", "def VowelCount(str)\n str.count \"aeiou\" \nend", "def completion_percentage\n fields = %w(first_name last_name address postal_code city country birthday phone_number avatar.present? )\n sum_add = 100.0 / fields.count\n fields.inject(0) { |sum, field| sum + (field.split('.').inject(self) { |us, o| us.send(o) }.blank? ? 0 : sum_add) }.round.to_i\n end", "def letter_percentages(string)\n total_count = string.size\n character_hash = {}\n\n character_hash[:lowercase] = (string.count(\"a-z\").to_f / total_count) * 100\n character_hash[:uppercase] = (string.count(\"A-Z\").to_f / total_count) * 100\n character_hash[:neither] = (string.count(\"^a-zA-Z\").to_f / total_count) * 100\n\n character_hash\nend", "def vote_percentage(type)\n animals_votes = @db[\"select * from votes where animal_id in \\\n (select id from animals where type = '#{type}')\"]\n begin\n (animals_votes.count / @db[:votes].count.to_f * 100).round\n rescue FloatDomainError\n 50 # we have no data, it's 50:50\n end\n end", "def scorePlaintext(plaintext)\n #Check for legible characters first, lots of junk data will be returned so we\n #can score well just by looking for valid chars\n charCount = plaintext.scan(/[a-zA-Z0-9\\s]/).length\n \n #Search for punctuation\n punctCount = plaintext.scan(/[[:punct:]]/).length\n \n return charCount + punctCount\nend", "def Vowel_Count(string)\n a_count=0\n e_count=0\n i_count=0\n o_count=0\n u_count=0\n for pos in 0..string.length\n word=string[pos]\n if (word==\"a\")\n a_count = a_count+1\n elsif(word==\"e\")\n e_count = e_count+1\n elsif(word==\"i\")\n i_count = i_count+1\n elsif(word==\"o\")\n o_count = o_count+1\n elsif(word==\"u\")\n u_count = u_count+1\n end\n end\n puts \"Number of A = #{a_count}\"\n puts \"Number of E = #{e_count}\"\n puts \"Number of I = #{i_count}\"\n puts \"Number of O = #{o_count}\"\n puts \"Number of U = #{u_count}\"\nend", "def percent_fog_complex_words\n ( @complex_words.to_f / @words.length.to_f ) * 100\n end", "def percentage_of_votes\n if total_votes > 0\n 100 * (number_of_votes.to_f / total_votes.to_f)\n else\n 0\n end\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 _word_count_ranking(text, profile)\n # Count the number of words in current text\n text_word_count = text.split(WORD_DELIMITER).size\n \n return 0 if text_word_count < 1 * profile.average_word_count / 3\n return 0 if text_word_count > 5 * profile.average_word_count / 3\n \n 100 - (100 * (text_word_count - profile.average_word_count).abs /\n (2 * profile.average_word_count / 3))\n end", "def percentage\n \tamount / expense.cost\n end", "def averagestring(string)\n\tbytearray = string.bytes\n\treturn (bytearray.inject(:+).to_f/bytearray.length)\nend", "def texts_score(text1, text2)\n words1 = text1.downcase.scan(/[a-zA-Z]+/) - noise_words\n words2 = text2.downcase.scan(/[a-zA-Z]+/) - noise_words\n common_words = words1 & words2\n p common_words\n common_words.length.to_f / (words1.length + words2.length)\n end", "def count_vowels(s)\n\tp s.count('aeiou')\nend", "def percentage(percent, total)\n percent.to_f / total * 100\nend", "def _word_usage_ranking(text, profile)\n # The word list must be filtered of stop words, otherwise that might\n # affect our word usage rank incorrectly\n word_list = text.gsub(URL_REGEXP, '').split(WORD_DELIMITER).reject do |word|\n word.match(/^[@#]/) || profile.stop_words.member?(word.downcase)\n end\n\n return 100 if word_list.size == 0\n\n word_list.inject(0) do |ranking, word|\n ranking + (profile.dictionary.has_key?(word.downcase) ? (100 / word_list.size) : 0)\n end\n end", "def findFivtyPercent(input)\r\noutput=input/2\r\n# by default ruby returns the last calculated value. No need of return statement at this point\r\nreturn output\r\nend", "def weight(text)\n weight = @emphasis[:multiplier]\n\n if text.length >= @emphasis[:long_words_threshold]\n weight *= @emphasis[:long_words]\n end\n\n if text[0,1] == text[0,1].upcase\n weight *= @emphasis[:upper_case]\n end\n\n weight += vowels(text)\n weight += consonants(text)\n weight\n end", "def percent!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 29 )\n\n type = PERCENT\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 163:11: '%'\n match( 0x25 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 29 )\n\n end", "def proteinsPercent()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotalEnergy = 0.0\n\t\t\t\ttotalProteinsEnergy = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalEnergy += (plato.value.get_energia * grams.value) / 100\n\t\t\t\t\ttotalProteinsEnergy += (plato.value.get_energia_proteins * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn (totalProteinsEnergy * 100) / totalEnergy\n\t\t\tend", "def pourcentage\n @pourcentage ||= (nombre.to_f / analyse.all_mots.count).pourcentage\n end", "def vol_perc\n if match = @args[:props][\"volume\"].to_s.match(/(\\d+):\\s*([\\d\\.]+)%/)\n return match[2].to_i\n end\n \n raise \"Could not figure out the volume from properties: '#{@args[:props]}'.\"\n end", "def percent_for\n (votes_for.to_f * 100 / (self.votes.size + 0.0001)).round\n end", "def match_percentage incorrect, possible\n #Creates character arrays for both words\n incorrect_array = incorrect.split(\"\")\n possible_array = possible.split(\"\")\n\n #Hashes to hold count of each char\n incorrect_hash = Hash.new(0)\n possible_hash = Hash.new(0)\n\n #Counts the characters in each word\n incorrect_array.each do |char|\n incorrect_hash[char] += 1\n end\n possible_array.each do |char|\n possible_hash[char] += 1\n end\n \n ##Compares the two hashes and returns similarity as a decimal\n #The overall percentage and total characters, used to calculate final percentage\n overall_percentage = 0.to_f\n total_chars = [incorrect_hash.keys.length, possible_hash.keys.length].max\n #Iterates over the hash for the possible correction\n possible_hash.each do |chars|\n #Sets char to the actual character\n char = chars[0]\n #Sets value_possible to count in possible hash\n value_possible = chars[1]\n #Sets value_incorrect to count in incorrect hash\n value_incorrect = incorrect_hash[char]\n\n #If neither value is zero calcluates similarity and adds to overall_percentage, otherwise its 0\n if value_possible != 0 && value_incorrect != 0\n min = [value_possible, value_incorrect].min\n max = [value_possible, value_incorrect].max\n overall_percentage += (min.to_f / max.to_f)\n end\n end\n #Calculates similarity percentage and returns\n overall_percentage /= total_chars\n\n return overall_percentage * $lexicon[possible[0]][possible.length][possible]\nend", "def consonants(text)\n percent = text.consonants.length / text.length.to_f\n percent * @emphasis[:consonants]\n end", "def num_vowels(str)\n str.downcase.scan(/[aeiou]/).count\nend", "def percent()\n ''\n end", "def percentage_for(choice)\n vote_choice = self.send(choice)\n vote_choice > 0 ? (vote_choice.to_f / votes.count * 100) : 0 \n end", "def carbsPercent()\n\t\t\t\tplato = @alimentsList.head\n\t\t\t\tgrams = @gramsList.head\n\t\t\t\ttotalEnergy = 0.0\n\t\t\t\ttotalCarbsEnergy = 0.0\n\n\t\t\t\twhile plato != nil\n\t\t\t\t\ttotalEnergy += (plato.value.get_energia * grams.value) / 100\n\t\t\t\t\ttotalCarbsEnergy += (plato.value.get_energia_carbs * grams.value) / 100\n\n\t\t\t\t\tplato = plato.next\n\t\t\t\t\tgrams = grams.next\n\t\t\t\tend\n\n\t\t\t\treturn (totalCarbsEnergy * 100) / totalEnergy\n\t\t\tend", "def vowel_recognition input\n\tinput, count = input.split(\"\").map! {|x| x =~ /[a,e,i,o,u,A,E,I,O,U]/ ? x = 1 : x = 0 }, 0\n\tinput.each_with_index { |x, ind| x == 0 ? 0 : count += ((ind + 1) * (input.length - ind)) } \n\tp count\nend", "def vowel_recognition(s)\n (0...s.size).map {|i| s[i] =~ /[aeiou]/i ? (s.size - i) * (i + 1) : 0}.sum\nend", "def match_percentage(other_username)\n other_user = User.includes(:answers).find_by(username: other_username)\n my_total = 0\n my_running_total = 0\n their_total = 0\n their_running_total = 0\n\n if other_user\n mutual_answers(other_user).each do |answer_pair|\n mine = answer_pair.first\n theirs = answer_pair.last\n\n my_total += mine.importance\n their_total += theirs.importance\n\n if ids_checker(mine.acceptable_ids, theirs.chosen_ids)\n my_running_total += mine.importance\n end\n\n if ids_checker(theirs.acceptable_ids, mine.chosen_ids)\n their_running_total += theirs.importance\n end\n end\n\n if my_total == 0 || their_total == 0\n return 0\n end\n\n my_ratio = my_running_total.to_f / my_total\n their_ratio = their_running_total.to_f / their_total\n\n Math.sqrt(my_ratio * their_ratio) * 100\n else\n nil\n end\n end", "def parse_percentage_expression\n regex = /(?<percentage>-?[\\d.]+)% (?<operator>(off?|on)) (?<expr>.*$)/\n match = @expression.match(regex)\n\n if match\n operator = match.named_captures[\"operator\"]\n percentage = match.named_captures[\"percentage\"]\n expr = match.named_captures[\"expr\"]\n\n percentage_expr = \"#{expr} * #{percentage.to_f/100}\"\n\n case operator\n when 'of'\n @expression = percentage_expr\n when 'off'\n @expression = \"#{expr} - (#{percentage_expr})\"\n when 'on'\n @expression = \"#{expr} + (#{percentage_expr})\"\n end\n end\n end", "def sentence_score(hex_string) # rubocop:disable Metrics/MethodLength\n real_string = hex_to_chars(hex_string).chars\n real_string.map do |chr|\n case chr.ord\n when 33..64, 91..96, 123..127\n 0.5 # punctuation / numbers\n when 32, 65..90, 97..122\n 1\n else\n -2.5 # control characters\n end\n end.sum / real_string.length.to_f\nend", "def calc_eva(user, obj = nil)\n ex_attr_calc_eva(user,obj) - [user.hit-100,0].max\n end", "def percentage_abd\r\n\t\t\t\tall_survivors = Survivor.count()\r\n\t\t\t\tabd_survivors = Survivor.where(abducted: true).count\r\n\t\t\t\tpercentage = (abd_survivors.to_f/all_survivors.to_f) * 100\r\n\t\t\t\trender json: {status: 'SUCCESS', message:'Porcentagem de sobreviventes Abduzidos', percentage:percentage},status: :ok\r\n\t\t\tend", "def percent_answered\n percent_answered_int.to_s + \"%\"\n end", "def semantic_coverage\n num = 0\n den = 0\n @word_list.each do |word|\n num += word.analyzed_meaning.length\n den += word.meaning.length\n end\n num/den.to_f\n end", "def vote_percent\n Vote.percent(vote_cache)\n end", "def score(plaintext)\n score = 0\n @wordlist.each do |word|\n score += plaintext.scan(/\\b#{word}\\b/).count\n end\n return score\nend", "def grade_percentage\n # get the number of passing tests as a float\n passing_tests = tests.select { |test| test.test_status == \"passed\" }.length.to_f\n # get total number of all that students tests\n all_tests = tests.length.to_f\n # calculate their passing_tests as a % of their total tests\n passing_tests / all_tests * 100\n end", "def input_completed_percentage\n total_input_days = 0\n total_pending_input = 0\n self.users.each do |user|\n pending_input, input_days = user.pending_input\n total_pending_input += pending_input\n total_input_days += input_days\n end\n # If no users, then input is OK\n return 1 if total_input_days == 0\n ((total_input_days - total_pending_input) / total_input_days.to_f).round(2)\n end", "def rating\n return 0 if total_votes == 0\n (100 * self.yeses) / total_votes\n end", "def grade_percentage\n (self.passed_tests.length.to_f / self.tests.length * 100).round(2)\n end", "def anomaly_score(text)\n -1 * similarity_score(text) / stddev_of_scores_of_training_set\n end", "def gender_percentage(title, gender)\n gender_count = Legislator.where(gender: \"#{gender}\", title: \"#{title}\").count\n total_count = Legislator.where(title: \"#{title}\").count\n\n p gender_count\n p gender_count.percent_of(total_count).round(2)\nend", "def percent_passes; end", "def percent_passes; end", "def count_of_upper_case_vowels\n strings = @new_content.map(&:capitalize).join.scan(/[#{VOWELS}][^#{VOWELS}]*/)\n total = 0\n\n (1..strings.size - 1).each do |index|\n prev_string = strings[index - 1]\n next unless prev_string.match(/[#{CONSONANTS.upcase}]/).nil?\n char = strings[index][0]\n next unless capitalized?(char) || (capitalized?(prev_string[0]) && prev_string.size > 2)\n total += 1\n strings[index][0] = char.upcase\n end\n total\n end", "def vowel_count (str)\n sentence = str.downcase\n letters = sentence.split(\"\")\n count = 0\n vowels = %w{a e i o u}\n letters.each do |letter|\n if vowels.include?(letter) \n count += 1\n end\n end\n puts count\nend", "def calculate\n @text.scan(\"#{@keyword}\").size\n end", "def love_test(s, y)\n t = 0\n s = s.gsub(\" \", \"\")\n y = y.gsub(\" \", \"\")\n x = s.length + y.length\n s.split('').each { |c| y.split('').include?(c) ? t += 1 : nil }\n l = x / t\n puts l\nend", "def number_of_vowels(string)\r\n count = string.downcase.scan(/[aeiou]/).size\r\n \r\n case count\r\n when 1\r\n \"There is 1 vowel in this word\"\r\n when 0 \r\n \"There are no vowels in this word\"\r\n else\r\n \"There are #{count} number of vowels\"\r\n end\r\n \r\nend", "def VowelCount(str)\n str.scan(/[aeiouAEIOU]/).count\nend", "def vowelCount(str)\n\tcount = 0\n\tstr = str.split('').each{|x| count += 1 if(%(a e i o u).include?(x))}\n\treturn count\nend", "def text_commonality(text)\n probability_of_ngrams(common_ngrams_from_text(text))\n end", "def get_count(input)\n input.count('aeiou')\nend", "def VowelCount(str)\n count = 0\n \n str.each_char do |c|\n count += 1 if c =~ /[aeiou]/\n end\n \n return count\nend", "def VowelCount(str)\n\n # code goes here\n count = 0\n \n str.each_char do |letter|\n if letter =~ /[aeiou]/\n count += 1 \n end\n end\n \n return count\n \nend", "def pick_percentage\n self.score.to_f / Matchup.amount_finished.to_f\n end", "def improve(text)\n return Typogruby.improve(text.to_s)\n end" ]
[ "0.7840416", "0.6168757", "0.5833714", "0.5800462", "0.579222", "0.5754188", "0.5731221", "0.5709409", "0.5648014", "0.5631721", "0.561774", "0.5579635", "0.54964375", "0.54412633", "0.54007244", "0.5396063", "0.5382628", "0.5380566", "0.53674144", "0.5347461", "0.53446966", "0.53400934", "0.5338744", "0.5300052", "0.5263479", "0.5261976", "0.522826", "0.5223413", "0.5220265", "0.5210299", "0.5185495", "0.5166252", "0.5154758", "0.5151993", "0.5148388", "0.5144513", "0.51434624", "0.5141573", "0.5136021", "0.5133635", "0.5129994", "0.51295084", "0.5126826", "0.5089857", "0.5084182", "0.5074718", "0.50734365", "0.50685155", "0.50379586", "0.50308114", "0.5029419", "0.50119525", "0.49932802", "0.49917492", "0.4990003", "0.49848804", "0.49835637", "0.49791196", "0.49785036", "0.49688044", "0.49677747", "0.4967474", "0.49665362", "0.4961827", "0.49507257", "0.4939548", "0.4939283", "0.493768", "0.49251705", "0.49229786", "0.4903398", "0.4902036", "0.4902035", "0.4898115", "0.48963508", "0.48901692", "0.48891592", "0.48887384", "0.48842677", "0.48786643", "0.48606145", "0.4859966", "0.4855252", "0.48416054", "0.4840748", "0.4838562", "0.4838562", "0.48372462", "0.48224634", "0.48175874", "0.48135915", "0.48119828", "0.48083973", "0.480102", "0.47970825", "0.47900838", "0.47869912", "0.47855052", "0.47779903", "0.4772812" ]
0.71767694
1
Saves the incoming data report to be processed later
def create data_report = DataReport.new(data_report_params) # For now the worker is synchronous. Eventually it can be run asynchronously if data_report.save && report_worker.perform(data_report.id) render json: {}, status: :ok elsif data_report.errors.present render json: data_report.errors, status: :unprocessable_entity else render json: {}, status: :internal_server_error end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_report\n Report.transaction do\n report = Report.create(name: @name,\n start_date: @start_date,\n end_date: @end_date,\n type: @type,\n creator: User.current.id,\n renderer_type: 'PDF')\n\n values = save_report_values(report)\n\n { report: report, values: values }\n end\n end", "def save_report\n\n # Parse the result with Nokogiri\n response = connect\n\n # Add the column headers to the file\n write_column_headers\n\n # Append the first batch of data to the file\n write_batch_data\n\n # Save the token for successive calls\n token = \"&token=\" + response[:token] || \"\"\n\n # Loop until the end of the query\n until response[:is_finished] === \"true\"\n response = connect(token)\n write_batch_data\n end\n\n end", "def save_report\n report = Report.create(name: @name, start_date: @start_date,\n end_date: @end_date, type: @type,\n creator: User.current.id,\n renderer_type: 'PDF')\n\n values = save_report_values(report)\n\n { report: report, values: values }\n end", "def write_report\n\n end", "def save_file(input_obj)\n\t$report_file.write(input_obj)\nend", "def export_report\n @report.export_report\n end", "def export_report\n @report.export_report\n end", "def save\n pathname.open('w') { |file| file.write(data) }\n end", "def save!; File.write @path, @data end", "def save(path)\n CSV.open(path, \"w\") do |csv|\n csv << column_headers\n @data.each do |row|\n csv << row\n end\n end\n log.fine \"Report saved to #{path}\"\n end", "def _save_to_store\n self._warnings = []\n _commit_externals \n __pack.commit # TODO: need to add some error catching and roll back the external saves where needed\n end", "def save_output(data)\n ::File.open(datastore['OUTFILE'], 'wb') do |f|\n f.write(data)\n print_status(\"Saved results in #{datastore['OUTFILE']}\")\n end\n end", "def save_output(data)\n ::File.open(datastore['OUTFILE'], 'wb') do |f|\n f.write(data)\n print_status(\"Saved results in #{datastore['OUTFILE']}\")\n end\n end", "def save_all\n reports = to_h\n reports.each do |file, report|\n File.write(file, report)\n end\n\n reports.keys\n end", "def save_processed_data\n attachment.update(processed_data: json_parser.final_hash)\n end", "def save_report\n if request.post?\n if @case_report = CaseReport.find(params[:case_report][:id]) rescue false\n update\n else\n create\n end\n redirect_to report_link(@case_report)\n end\n end", "def save_report_values(report)\n @cohort_struct.values.collect do |value|\n puts \"Saving #{value.name} = #{value_contents_to_json(value.contents)}\"\n report_value = ReportValue.create(report: report,\n name: value.name,\n indicator_name: value.indicator_name,\n indicator_short_name: value.indicator_short_name,\n creator: User.current.id,\n description: value.description,\n contents: value_contents_to_json(value.contents))\n\n unless report_value.errors.empty?\n raise \"Failed to save report value: #{report_value.errors.as_json}\"\n end\n\n save_patients(report_value, value_contents_to_json(value).contents)\n\n report_value\n end\n end", "def save_report_values(report)\n @cohort_struct.values.collect do |value|\n puts \"Saving #{value.name} = #{value_contents_to_json(value.contents)}\"\n report_value = ReportValue.create(report: report,\n name: value.name,\n indicator_name: value.indicator_name,\n indicator_short_name: value.indicator_short_name,\n creator: User.current.id,\n description: value.description,\n contents: value_contents_to_json(value.contents))\n\n report_value_saved = report_value.errors.empty?\n unless report_value_saved\n raise \"Failed to save report value: #{report_value.errors.as_json}\"\n else\n save_patients(report_value, value_contents_to_json(value).contents)\n end\n\n report_value\n end\n end", "def saveReport()\n\t\tr = @connection.execute('<ReportSaveRequest session-id=\"' + @connection.session_id.to_s + '\">' + getXML().to_s + ' </ReportSaveRequest>')\n\t\tif(r.success)\n\t\t\t@config_id = r.attributes['reportcfg-id']\n\t\t\treturn true\n\t\tend\n\t\treturn false\n\tend", "def save # :nodoc:\n if @file\n File.open(SAVE_FILE, 'w') do |f|\n Marshal.dump(file, f)\n end\n else\n forget\n end\n end", "def save # :nodoc:\n if @file\n File.open(SAVE_FILE, 'w') do |f|\n Marshal.dump(file, f)\n end\n else\n forget\n end\n end", "def report\n \n end", "def save_data(data)\n\tend", "def save()\n File.write(@database_file, @data.to_json)\n end", "def save\n @data.map(&:save)\n end", "def save(data)\n raise \"Implement this in subclass\"\n end", "def save\n perform_save\n end", "def save_additional_data\n end", "def save(data)\n File.open(@local_file_path, \"wb\") {|file| file.write(data) }\n end", "def generate_and_save_sessions_report( provider, encounters, custom_filename = nil, params={}) #\n raise \"no entries\" if encounters.size == 0\n puts \"Producing report...\"\n clinic_sessions = Analyze.extract_clinic_sessions( encounters )\n\n friendly = Reports.friendly_filename( custom_filename || provider )\n filename_complete = \"report_billing_#{friendly}_#{ Time.now.strftime(\"%F\") }.html\"\n\n File.open(filename_complete , \"w:UTF-8\") do |file|\n file.write(Reports.session_efficiency(encounters, clinic_sessions, params).gsub(\"\\n\", \"\\r\\n\"))\n end\n puts \" Saved as #{ filename_complete }\"\n\n filename_complete_2 = \"report_sessions_#{friendly}_#{ Time.now.strftime(\"%F\") }.html\"\n\n File.open(filename_complete_2 , \"w:UTF-8\") do |file|\n file.write(Reports.session_details(clinic_sessions ).gsub(\"\\n\", \"\\r\\n\"))\n end\n puts \" Saved as #{ filename_complete_2 }\"\n\n\nend", "def save\n SAVE\n end", "def save\n File.open(SaveLocation, 'w') do |file|\n file.puts @value.join(\"\")\n file.puts @progress.join(\"\")\n file.puts @bad_guesses.join(\"\")\n end\n end", "def create_new_report!; end", "def create_new_report!; end", "def report_to_file(outfile)\n File.open(outfile, 'w') do |f|\n @report_history.each do |report|\n f.write report\n end\n end\n end", "def save!\n # Scrub some fields\n @data[\"installed\"].sort!\n @data[\"installed\"].uniq!\n\n # Save\n @path.open(\"w+\") do |f|\n f.write(JSON.dump(@data))\n end\n end", "def create_new_report!\n File.write(report_filename, report_title + report_body)\n end", "def write_report\n @manager.atomic_file(report_file) do |file|\n file.write(JSON.pretty_generate(get_status))\n end\n end", "def save\n end", "def save\n end", "def save\n File.open(@file, 'w') do |file|\n file.write(Psych.dump(@params))\n end\n @saved = true\n end", "def save_status(file_path)\n begin\n Pathname.new(file_path).open('wb') do |f|\n @saved_at = Fluent::Engine.now\n @saved_duration = @saved_at - @last_checked\n Marshal.dump({\n :counts => @counts,\n :saved_at => @saved_at,\n :saved_duration => @saved_duration,\n :aggregate => @aggregate,\n :count_key => @count_key,\n :patterns => @patterns,\n }, f)\n end\n rescue => e\n log.warn \"out_datacounter: Can't write store_file #{e.class} #{e.message}\"\n end\n end", "def save!\n end", "def save\n receipt = File.new(@save_path, 'w')\n receipt.write(render)\n receipt.close\n end", "def save_output\n\n end", "def report\n\t\tend", "def save_cached_data\n # open file for writing\n @file_handle = File.open(file_path, 'w')\n \n # write data string into file\n @file_handle << (@file_data_to_write.respond_to?(:read) ? @file_data_to_write.read : @file_data_to_write)\n \n # close file\n close_file\n \n end", "def save_cached_data\n # open file for writing\n @file_handle = File.open(file_path, 'w')\n \n # write data string into file\n @file_handle << (@file_data_to_write.respond_to?(:read) ? @file_data_to_write.read : @file_data_to_write)\n \n # close file\n close_file\n \n end", "def save_file\n\tcounter = 1;\n\ttime = Time.now.strftime(\"%d/%m/%Y\")\n\treport_file_puts \"\"\n\treport_file_puts \"Title of saved TodoList: #{@title}\"\n\treport_file_puts \"Save time: #{time}\"\n\treport_file_puts \"----------------------------\"\n\t\t@items.each do |item|\n\n\t\treport_file_puts \"#{counter.to_s} #{item.description} Completion status: #{item.completed_status.to_s}\"\n\t\tcounter +=1;\t\n\tend\t\nend", "def report; end", "def report; end", "def report; end", "def report; end", "def report; end", "def send_report_data\n render_type = RENDER_TYPES[@sb[:render_type].to_s]\n raise \"Render type #{@sb[:render_type]} is not supported\" unless render_type\n\n assert_privileges(\"render_report_#{render_type}\")\n\n return unless @sb[:render_rr_id]\n\n disable_client_cache\n result = MiqReportResult.find(@sb[:render_rr_id])\n\n filename = filename_timestamp(result.report.title, 'export_filename')\n send_data(result.get_generated_result(@sb[:render_type]),\n :filename => \"#{filename}.#{@sb[:render_type]}\",\n :type => \"application/#{@sb[:render_type]}\")\n\n result.destroy\n end", "def save\n now = Time.now\n\n data = {\n :id => @id,\n :desc => @desc,\n :ctime => Timestamp.dump(@ctime) || Timestamp.dump(now),\n :mtime => Timestamp.dump(now),\n :ppg_filename => @ppg_filename,\n }\n jobinfo.write(YAML.dump(data))\n end", "def record_save\n # Load mapinfo for map name\n mapinfos = load_data(\"Data/MapInfos.rxdata\")\n # Make the filename\n if Wep::Random_file_name and Wep::Modify_game_system\n filename = Wep::Game_version+\"-\"+$game_system.random_filename+\"-\"+Wep::Save_record_name\n else\n filename = Wep::Game_version+\"-\"+Wep::Save_record_name\n end\n estado = open(filename, \"a\")\n estado.write(\"------------------------------------------\\n\")\n estado.write(\"||||\"+Wep::Save_name+\" \"+($game_system.save_count+1).to_s+\"||||\")\n estado.write(\"\\n------------------------------------------\\n\") \n # Write time\n @total_sec = Graphics.frame_count / Graphics.frame_rate\n hour = @total_sec / 60 / 60\n min = @total_sec / 60 % 60\n sec = @total_sec % 60\n text = sprintf(\"%02d:%02d:%02d\", hour, min, sec)\n tiempo = \"\\nPlaytime: \"\n tiempo+= text\n estado.write(tiempo)\n # Write money\n money = \". Money: \"\n money += $game_party.gold.to_s\n estado.write(money)\n # Write actual map(and name)\n estado.write(\". Map: \"+$game_map.map_id.to_s+\" (\"+mapinfos[$game_map.map_id].name+\")\\n\")\n if Wep::Record_saves_actors\n if Wep::Record_saves_all_actors == false\n for actor in $game_party.actors\n estado.write(\"\\n\"+actor.name+\" (\"+$data_classes[actor.class_id].name+\") Nv\"+actor.level.to_s+\"\\n\")\n end\n else\n \n for i in 1...$data_actors.size\n estado.write(\"\\n\"+$game_actors[i].name+\" (\"+$data_classes[$game_actors[i].class_id].name+\") Nv\"+$game_actors[i].level.to_s+\"\\n\")\n end\n \n end\n end\n estado.write (\"\\n\")\n estado.close\n end", "def save_for_later\n add_graded_ptal_task_items\n @report.last_saved_by_grader_at = Time.now\n\n if @report.valid?\n @report.update_attributes!(params[:report])\n respond_to_ajax('save_for_later')\n else\n @report.graded_ptal_task_items += @temporarily_removed_task_items\n @errors = @report.errors.full_messages\n respond_to_ajax('save_for_later_error')\n end\n end", "def save; end", "def save; end", "def save; end", "def save; end", "def save; end", "def save; end", "def save; end", "def save; end", "def save\n write_properties\n notify(EVENT_SAVE, self)\n end", "def save\n perform_mapping\n unless self.errors[:data].present?\n self.record.save\n end\n end", "def save\n return if saved?\n self.saved = true\n original_path = interpolate_path(:original)\n stream.write_to(original_path)\n end", "def save_tracker_cache\n # These values should only be written if the audit has been successful!!\n # Best to write it back to a new file - then move the new file to the\n # original location (overwriting the original)\n return if @parent.ret_val == 3\n tracker_file = get_tracker_filename\n File.open(tracker_file + \".temp\", 'w') { |f|\n # First, save the initial timestamp and the current SOA serial\n f.puts(@initial_timestamp.to_s)\n f.puts(@last_soa_serial.to_s)\n # Now save the cache!!\n Status.strings.each {|s|\n status = s.downcase\n eval \"@cache.#{status}.each {|key, time|\n write_key_to_file(f, key.to_s, status, time[0], time[1])\n }\".untaint\n }\n\n }\n # Now move the .temp file over the original\n File.delete(tracker_file)\n File.rename(tracker_file+\".temp\", tracker_file)\n end", "def save_to(path)\n File.write(path, to_fdf)\n end", "def save_to(path); end", "def process\n save_as(:processed)\n end", "def save_report(project_name, hash)\n id = \"report-#{project_name}-#{Time.now.strftime(\"%Y%m%d-%H:%M:%S\")}.md\"\n puts \"Saving mirror report for project #{project_name} to #{id}\"\n File.open(File.join(reports_folder, id), 'w') { |f| f.write(Ow2mirror::Report.generate_mirror(hash)) }\n end", "def save!\n @data.map(&:save!)\n end", "def save\n end", "def save\n save_to_file(@output_file, @contents)\n end", "def report_data\n ReportMailer.report_data\n end", "def write_file_after_save(file_data_to_write=nil)\n # check if there are data to write\n return unless(@file_data_to_write)\n \n begin\n self.class.benchmark(\"\\033[36m\\033[1m\\033[4mFileStore\\033[0m Saving file for #{self.id}\") do\n # create data directory path\n FileUtils.mkdir_p(data_directory)\n \n if(@file_data_to_write.is_a?(DataPath))\n copy_data_file\n else\n save_cached_data\n end\n \n @file_data_to_write = nil\n end\n rescue Exception => e\n assit_fail(\"Exception on writing file #{self.location}: #{e}\")\n end\n\n end", "def write\n write_data\n end", "def savePerfLine\n\t\tline= @startTime.to_i.to_s+','+@dur.to_s+','+@urlLabel+','+@httpCode+','+@httpRes+',Test_'+@testNum.to_s+',text,'+@applRes+',1,1'\n\t\t@fHdl.puts line\n\t\t@dataSaved = true\n\tend", "def set_report\n end", "def save\n end", "def save\n #code\n end", "def save\n file_path = self.class.file_path(@save_id)\n File.open(file_path, 'w') { |file| \n bytes = file.write @items.inspect\n if bytes > 0\n puts \"saved to #{file_path}\"\n else\n puts \"save to #{file_path} failed\"\n end\n }\n end", "def report\n audit_store.to_h\n end", "def save; record.save; end", "def write_save_data(file)\r\n write_characters(file)\r\n write_frame(file)\r\n write_setup(file)\r\n write_data(file)\r\n end", "def report=(value)\n @report = value\n end", "def save\n raise NotImplementedError\n end", "def save\n prepare\n h = {}\n h[:title] = @title\n h[:sequence] = @sequence.map(&:export)\n outfile = File.join(@basedir, \"#{@name}.json\")\n File.open(outfile, 'w') do |f|\n f.write JSON.pretty_generate(h)\n end\n end", "def save\n domain_info_location = @domain_location + FILENAME\n text = \"== %s\\n\\n\" % Time.now\n text << @record.map{|key, val| \"- %s: %s\" % [key,val]}.join(\"\\n\")\n text << \"\\n\\n\"\n if domain_info_location.exist?\n domain_info_location.append(text)\n else\n domain_info_location.create(text)\n end\n end", "def writeData\n # Make the directory to store the RoadWaer data.\n File.makedirs(File.dirname($datafilename))\n $debugdata = $debugdata + \"makedir\\n\"\n\n # Open the file to append the registration data.\n file = File.open($datafilename, \"a\")\n $debugdata = $debugdata + \"open\\n\"\n # Write user data.\n file.puts($events.read.print)\n $debugdata = $debugdata + \"puts\\n\"\n # Make sure the output file is always closed.\n file.close\n $debugdata = $debugdata + \"close\\n\"\n\n $debugdata = $debugdata + value.local_path + \"\\n\"\n $debugdata = $debugdata + value.original_filename + \"\\n\"\n $debugdata = $debugdata + value.content_type + \"\\n\"\n true\n\n rescue\n false\nend", "def save\n timeout_retry(3, 3){\n write \"SAVE\\r\\n\"\n status_code_reply\n }\n end", "def save_status(file_path)\n begin\n Pathname.new(file_path).open('wb') do |f|\n @saved_at = Fluent::Engine.now\n @saved_duration = @saved_at - @last_checked\n Marshal.dump({\n :counts => @counts,\n :matches => @matches,\n :saved_at => @saved_at,\n :saved_duration => @saved_duration,\n :regexp => @regexp,\n :exclude => @exclude,\n :input_key => @input_key,\n }, f)\n end\n rescue => e\n log.warn \"out_grepcounter: Can't write store_file #{e.class} #{e.message}\"\n end\n end", "def store_wffile\n # verify if there is actually a file to be saved\n if @file_data\n # create the WORKFLOW_STORE Folder if it does not exist\n FileUtils.mkdir_p File.join WORKFLOW_STORE, \"#{id}\"\n # create the file and write the data to the file system\n File.open(workflow_filename, 'wb') do |f|\n f.write(@file_data.read)\n end\n # ensure that the data is only save once by clearing the cache after savig\n @file_data = nil\n end\n end", "def save\n super save\n end", "def save(data)\n self.results[:processed] += 1\n\n # Create an observation from the data\n f = self.observation_from_data(data)\n\n new_record = f.new_record?\n changed = f.changed?\n\n if not changed\n self.results[:skipped] += 1\n return f\n else\n # changes = f.changes\n # changes.each do |i, data|\n # data[0] = data[0].to_s\n # data[1] = data[1].to_s\n # end\n # Rails.logger.debug changes\n end\n\n if not f.save\n Rails.logger.debug \"Could not save observation. Errors: #{f.errors.messages}\"\n self.results[:failed] += 1\n return f\n end\n\n if new_record\n self.results[:created] += 1\n elsif changed\n self.results[:updated] += 1\n end\n\n return f\n end", "def save\n call_ok?(:slft_application, request_save) do |body|\n convert_back_office_hash(body)\n end\n end", "def save_record(record)\n record.save\n end", "def save_record(record)\n record.save\n end" ]
[ "0.73499906", "0.73174214", "0.72133553", "0.6940421", "0.68900687", "0.65710235", "0.65710235", "0.656499", "0.65590143", "0.6548167", "0.64839125", "0.64675695", "0.64675695", "0.6416997", "0.6404166", "0.6390809", "0.62898964", "0.6282825", "0.62324363", "0.6209965", "0.6209965", "0.6202573", "0.6188325", "0.6138087", "0.61146533", "0.60945946", "0.60787463", "0.60754097", "0.6071086", "0.605838", "0.6050507", "0.6047393", "0.6044154", "0.6044154", "0.60345715", "0.60210913", "0.6018747", "0.60182947", "0.59918463", "0.59918463", "0.5991673", "0.59823203", "0.59806013", "0.5971455", "0.59623045", "0.59510905", "0.59366584", "0.59366584", "0.592822", "0.59218884", "0.59218884", "0.59218884", "0.59218884", "0.59218884", "0.5915386", "0.5901805", "0.5896544", "0.5895938", "0.58950925", "0.58950925", "0.58950925", "0.58950925", "0.58950925", "0.58950925", "0.58950925", "0.58950925", "0.589435", "0.5887387", "0.58827347", "0.5878221", "0.58772117", "0.5866923", "0.5864672", "0.58643866", "0.58629435", "0.58605826", "0.5845934", "0.58380395", "0.58322966", "0.5832279", "0.5822827", "0.5819187", "0.5794491", "0.5783029", "0.57730407", "0.57615495", "0.57587504", "0.5751213", "0.57489675", "0.57454824", "0.57445985", "0.57377017", "0.5712588", "0.5688598", "0.56813365", "0.56801534", "0.56795466", "0.56784195", "0.5675422", "0.5675031", "0.5675031" ]
0.0
-1
The inline worker to migrate the data report
def report_worker @report_worker ||= DataReportWorker.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform\n\t\tbegin\n\t\t\tnext_run_at = Time.now + 30.minutes\n\t\t\tDataImporterWorker.perform_at(next_run_at)\n\t\t\tqds = QueryDataSource.find_all_by_enabled(true)\n\t\t\tqds.each do |q|\n\t\t\t\tQueryDataSourceWorker.perform_async(q.id)\n\t\t\tend\n\n\t\t\t#spree data source importer\n\t\t \tspree_data_sources = SpreeDataSource.find_all_by_enabled(true)\n\t\t \tspree_data_sources.each do |sds|\n\t\t\t\tSpreeDataSourceWorker.perform_async(sds.id)\n\t\t\tend\n\t\trescue Exception => e\n\t\t \tRails.logger.error e.to_s\n\t\t\tputs e.to_s\n\t\tend\n\tend", "def run\n schedule_data_reports\n end", "def do_work\n end", "def be_worker\n before_work\n super\n end", "def perform\n raise RuntimeError, \"Worker Implementations should override this\"\n end", "def process_in_background(column, worker=::CarrierWave::Workers::ProcessAsset)\n super\n (@@_carrierwave_process_in_background ||= {})[:\"#{column}\"] = worker\n end", "def upload\n EmailsWorker.async_process_backup_email(:id => self.id)\n end", "def run(worker_name)\n Parts::WithLocking.sql_comment = @short_description || @description\n @block.call(worker_name)\n ensure\n Parts::WithLocking.sql_comment = nil\n end", "def run\n start_time = Time.now\n\n setup\n\n importer_run.update_attributes( started_at: start_time,\n source_model: source_model.name,\n destination_model: destination_model.name,\n importer_version: VERSION )\n\n # get a total count of records to process, bail out if none are found\n count = base_query(false).count\n\n logger.info \"\"\n if count == 0\n logger.info \"no #{source_model.name.pluralize} to import, exiting\"\n return\n end\n\n logger.info \"Starting import from #{source_model.table_name} into #{destination_model.name}...\"\n\n # step through the records in batches\n (0..count).step(batch_size) do |offset|\n thread_pool.schedule do\n with_connections do\n batch_elapsed_time = Benchmark.realtime do\n logger.info \"Importing from #{source_model.table_name} into #{destination_model.name} (#{offset / batch_size + 1}/#{count / batch_size + 1})\"\n\n # wipe the slate from the last batch\n prepare_for_new_batch\n\n benchmarks[:source_db] << Benchmark.realtime do\n # grab this batch of records from source\n fetch_records(offset)\n end\n\n # bail if there aren't any\n next if records.empty?\n\n logger.info \" #{records.count} source records fetched in #{benchmarks[:source_db].last}s\"\n if source_order_by\n logger.info \" #{source_order_by}: from #{records.first.read_attribute(source_order_by)} to #{records.last.read_attribute(source_order_by)}\"\n end\n\n # process this batch of records\n process_batch(records)\n\n logger.info \" #{records.count} records processed in #{benchmarks[:processing].last}s\"\n\n insert_and_update_batch\n end\n logger.info \" batch processed in #{batch_elapsed_time}s\"\n end\n end\n end\n thread_pool.shutdown\n \n print_validation_errors\n\n logger.info \"-------------------------------------------------\"\n logger.info \"Processing: #{benchmarks[:processing].sum}s total, #{benchmarks[:processing].sum / count}s per record\"\n logger.info \"source Database: #{benchmarks[:source_db].sum}s total, #{benchmarks[:source_db].sum / count}s per record\"\n logger.info \"dest Database: #{benchmarks[:destination_db].sum}s total, #{benchmarks[:destination_db].sum / count}s per record\"\n logger.info \"Total: #{Time.now - start_time}s elapsed\"\n importer_run.update_attributes( completed_at: Time.now )\n rescue Exception => e\n importer_run.update_attributes( error_trace: \"#{e.class} - #{e.message}\\n#{e.backtrace.join(\"\\n\")}\" )\n raise e\n ensure\n importer_run.update_attributes( records_created: records_created,\n records_updated: records_updated,\n duration: ((Time.now - start_time) * 1000).round,\n validation_errors: validation_errors )\n end", "def sidekiq_enqueue\n ReminderDisplayWorker.perform_at(displayed_at, id)\n end", "def perform\n @worker.call\n @last_result\n end", "def perform\n \n end", "def perform_inline\n Karafka.monitor.notice(self.class, to_h)\n perform\n end", "def perform!\n super\n\n dump = \"echo '.dump' | #{sqlitedump_utility} #{path}\"\n\n pipeline = Pipeline.new\n dump_ext = \"sql\".dup\n\n pipeline << dump\n if model.compressor\n model.compressor.compress_with do |command, ext|\n pipeline << command\n dump_ext << ext\n end\n end\n\n pipeline << \"cat > '#{File.join(dump_path, dump_filename)}.#{dump_ext}'\"\n\n pipeline.run\n\n if pipeline.success?\n log!(:finished)\n else\n raise Error,\n \"#{database_name} Dump Failed!\\n\" + pipeline.error_messages\n end\n end", "def perform(report)\n generate_excel_file(report)\n end", "def publish_result_data\n end", "def perform!\n run_callbacks(:before_perform, self)\n self.class.upcoming_mailings\n .in_batches(of: self.class.batch_size)\n .each do |batch|\n run_callbacks(:on_perform, self, batch)\n batch.each(&:process!)\n end\n run_callbacks(:after_perform, self)\n nil\n end", "def run_job\n end", "def update_worker(worker, source, company, office, new, cctagene)\n # Look for auxiliary data (other tables)\n search_aux_data(source)\n if new\n #\n # Add new row data\n #\n # Init vars to generate worker_code\n first_name_wc = nil\n last_name_wc = nil\n first_name_wc = sanitize_string(source.cnomtra, true, true, false, false) unless source.cnomtra.blank?\n last_name_wc = sanitize_string(source.capetra, true, true, false, false) unless source.capetra.blank?\n # Assign data\n worker.organization_id = !@organization.blank? ? @organization.id : 1\n worker.first_name = sanitize_string(source.cnomtra, true, false, false, true) unless source.cnomtra.blank?\n worker.last_name = sanitize_string(source.capetra, true, false, false, true) unless source.capetra.blank?\n worker.fiscal_id = sanitize_string(source.cdni, true, false, false, false) unless source.cdni.blank?\n worker.borned_on = source.dfecnac unless source.dfecnac.blank?\n worker.street_type_id = @street_type.id unless @street_type.id.blank?\n worker.street_name = sanitize_string(source.cdircen, true, false, false, true) unless source.cdircen.blank?\n worker.street_number = sanitize_string(source.cnumcen, true, false, false, false) unless source.cnumcen.blank?\n worker.floor = sanitize_string(source.cpiso, true, false, false, false) unless source.cpiso.blank?\n worker.floor_office = sanitize_string(source.cpuerta, true, false, false, false) unless source.cpuerta.blank?\n worker.zipcode_id = @zipcode.id unless @zipcode.id.blank?\n worker.town_id = @zipcode.town_id unless @zipcode.town_id.blank?\n worker.province_id = @zipcode.province_id unless @zipcode.province_id.blank?\n worker.own_phone = phone(source.cpretel, source.ctelefono)\n worker.affiliation_id = sanitize_string(source.cnumseg, true, false, false, false) unless source.cnumseg.blank?\n worker.worker_type_id = @worker_type.id unless @worker_type.id.blank?\n worker.degree_type_id = @degree_type.id unless @degree_type.id.blank?\n #worker.company_id = company.id unless company.id.blank?\n #worker.office_id = office.id unless office.id.blank?\n #worker.department_id = @department.id unless @department.id.blank?\n #worker.professional_group_id = @professional_group.id unless @professional_group.id.blank?\n #worker.starting_at = source.dfecalta unless source.dfecalta.blank?\n #worker.issue_starting_at = source.dfecini unless source.dfecini.blank?\n worker.starting_at = source.dfecalta unless source.dfecalta.blank?\n #if !cctagene.nil?\n # worker.contribution_account_code = sanitize_string(cctagene, true, false, false, false)\n #else\n # worker.contribution_account_code = sanitize_string(source.csubcta, true, false, false, false) unless source.csubcta.blank?\n #end\n #worker.contract_type_id = @contract_type.id unless @contract_type.id.blank?\n #worker.collective_agreement_id = @collective_agreement.id unless @collective_agreement.id.blank?\n #worker.position = sanitize_string(source.cpuesto, true, false, false, true) unless source.cpuesto.blank?\n #worker.gross_salary = source.nbruto unless source.nbruto.blank?\n # Mandatory worker code\n if !first_name_wc.nil? && !last_name_wc.nil?\n worker.worker_code = generate_worker_code(last_name_wc, first_name_wc)\n end\n # Mandatory e-mail and user info\n if !source.cemail.blank?\n worker.email = source.cemail\n worker.user_id, worker.real_email = find_user_by_email(source.cemail)\n end\n else\n #\n # Update current row data (if applicable)\n #\n #-- Current worker first and last name, should not be updated\n #if !source.cnomtra.blank? && worker.first_name != source.cnomtra.gsub(/[^0-9A-Za-z ]/, '').titleize\n # worker.first_name = source.cnomtra.gsub(/[^0-9A-Za-z ]/, '').titleize\n #end\n #if !source.capetra.blank? && worker.last_name != source.capetra.gsub(/[^0-9A-Za-z ]/, '').titleize\n # worker.last_name = source.capetra.gsub(/[^0-9A-Za-z ]/, '').titleize\n #end\n #--\n if !source.cdni.blank? && worker.fiscal_id != sanitize_string(source.cdni, true, false, false, false)\n worker.fiscal_id = sanitize_string(source.cdni, true, false, false, false)\n end\n if !source.dfecnac.blank? && worker.borned_on != source.dfecnac\n worker.borned_on = source.dfecnac\n end\n if !@street_type.id.blank? && worker.street_type_id != @street_type.id\n worker.street_type_id = @street_type.id\n end\n if !source.cdircen.blank? && worker.street_name != sanitize_string(source.cdircen, true, false, false, true)\n worker.street_name = sanitize_string(source.cdircen, true, false, false, true)\n end\n if !source.cnumcen.blank? && worker.street_number != sanitize_string(source.cnumcen, true, false, false, false)\n worker.street_number = sanitize_string(source.cnumcen, true, false, false, false)\n end\n if !source.cpiso.blank? && worker.floor != sanitize_string(source.cpiso, true, false, false, false)\n worker.floor = sanitize_string(source.cpiso, true, false, false, false)\n end\n if !source.cpuerta.blank? && worker.floor_office != sanitize_string(source.cpuerta, true, false, false, false)\n worker.floor_office = sanitize_string(source.cpuerta, true, false, false, false)\n end\n if !@zipcode.id.blank? && worker.zipcode_id != @zipcode.id\n worker.zipcode_id = @zipcode.id\n worker.town_id = @zipcode.town_id\n worker.province_id = @zipcode.province_id\n end\n if !source.ctelefono.blank? && worker.own_phone != phone(source.cpretel, source.ctelefono)\n worker.own_phone = phone(source.cpretel, source.ctelefono)\n end\n if !source.cnumseg.blank? && worker.affiliation_id != sanitize_string(source.cnumseg, true, false, false, false)\n worker.affiliation_id = sanitize_string(source.cnumseg, true, false, false, false)\n end\n #-- Current worker company, office, department, progroup, contract, cagreement, degree & position\n #-- should not be updated\n #if !company.id.blank? && worker.company_id != company.id\n # worker.company_id = company.id\n #end\n #if !office.id.blank? && worker.office_id != office.id\n # worker.office_id = office.id\n #end\n #--\n #if !@department.id.blank? && worker.department_id != @department.id\n # worker.department_id = @department.id\n #end\n #if !@professional_group.id.blank? && worker.professional_group_id != @professional_group.id\n # worker.professional_group_id = @professional_group.id\n #end\n\n #if !@contract_type.id.blank? && worker.contract_type_id != @contract_type.id\n # worker.contract_type_id = @contract_type.id\n #end\n #if !@collective_agreement.id.blank? && worker.collective_agreement_id != @collective_agreement.id\n # worker.collective_agreement_id = @collective_agreement.id\n #end\n\n #if !@degree_type.id.blank? && worker.degree_type_id != @degree_type.id\n # worker.degree_type_id = @degree_type.id\n #end\n #if !source.cpuesto.blank? && worker.position != sanitize_string(source.cpuesto, true, false, false, true)\n # worker.position = sanitize_string(source.cpuesto, true, false, false, true)\n #end\n #if !source.dfecalta.blank? && worker.starting_at != source.dfecalta\n # worker.starting_at = source.dfecalta\n #end\n #if !source.dfecini.blank? && worker.issue_starting_at != source.dfecini\n # worker.issue_starting_at = source.dfecini\n #end\n if !source.dfecalta.blank? && worker.starting_at != source.dfecalta\n worker.starting_at = source.dfecalta\n end\n #if !cctagene.nil?\n # if worker.contribution_account_code != sanitize_string(cctagene, true, false, false, false)\n # worker.contribution_account_code = sanitize_string(cctagene, true, false, false, false)\n # end\n #else\n # if !source.csubcta.blank? && worker.contribution_account_code != sanitize_string(source.csubcta, true, false, false, false)\n # worker.contribution_account_code = sanitize_string(source.csubcta, true, false, false, false)\n # end\n #end\n #-- Current salary, should not be updated\n #if !source.nbruto.blank? && worker.gross_salary != source.nbruto\n # worker.gross_salary = source.nbruto\n #end\n end\n # Check out other mandatory default data\n if worker.fiscal_id.blank?\n worker.fiscal_id = worker.worker_code + \"0000\"\n end\n #if worker.contribution_account_code.blank?\n # worker.contribution_account_code = \"no_existe\"\n #end\n #if worker.starting_at.blank? && !source.dfecini.blank?\n # worker.starting_at = source.dfecini\n #end\n #if worker.issue_starting_at.blank? && !source.dfecalta.blank?\n # worker.issue_starting_at = source.dfecalta\n #end\n\n # Bye\n return worker\n end", "def store_in_background(column, worker=::CarrierWave::Workers::StoreAsset)\n send :after_save, :\"enqueue_#{column}_background_job\"\n \n class_eval <<-RUBY, __FILE__, __LINE__ + 1\n attr_accessor :process_upload\n \n def write_#{column}_identifier\n super() and return if process_upload\n self.#{column}_tmp = _mounter(:#{column}).cache_name\n end\n \n def store_#{column}!\n super() if process_upload\n end\n \n def enqueue_#{column}_background_job\n unless process_upload\n ::Delayed::Job.enqueue #{worker}.new(self.class, id, #{column}.mounted_as)\n end\n end\n RUBY\n end", "def notify\n MemberMailerWorker.perform_async(member_id: self.employer.id.to_s, job_order_id: self.id.to_s, perform: :send_invoice_to_employer)\n TeamMailerWorker.perform_async(job_order_id: self.id.to_s, perform: :send_new_job_order)\n\n end", "def write_worker\n @write_worker ||= WriteWorker.new(self)\n end", "def worker= w\n @worker = w\n end", "def export\n Log.run(:job_type => \"export\", :name => schedule_name, \n :file => filename, :export_id => id) do |log|\n exporter = MysqlExporter.new\n exporter.export_table self # pass current object to exporter\n end\n end", "def perform_work\n raise NotImplementedError\n end", "def set_worker\n @worker = current_admin.workers.find(params[:id])\n end", "def perform\n publish_scheduled\n end", "def store_in_background(column, worker=::CarrierWave::Workers::StoreAsset)\n super\n (@@_carrierwave_store_in_background ||= {})[:\"#{column}\"] = worker\n end", "def perform\n ### Destroy all ads where expiry is less than the current time\n Rails.logger.info(\"AdsExpiryWorker_STARTED\")\n expired_ads = PropertyAd.where(\"expiry_at < ?\", Time.now)\n expired_ads.each {|t| Rails.logger.info(\"AdsExpiryWorker_PROCESSING_#{ad.id}\") }\n expired_ads.destroy_all\n\n ### Send email to ads which are going to expire the next day\n ads_about_to_expire = PropertyAd.where(\"expiry_at < ?\", Time.now - 1.day)\n\n ads_about_to_expire.each do |ad|\n Rails.logger.info(\"AdsExpiryWorker_ABOUT_TO_EXPIRE_PROCESSING_STARTED_#{ad.id}\")\n udprn = ad.udprn\n details = PropertyDetails.details(ad.udprn)[:_source]\n vendor_email = details[:vendor_email]\n vendor_property_address = details[:address]\n if vendor_email\n template_data = { vendor_property_address: vendor_property_address }\n self.class.send_email(vendor_email, 'vendor_quote_lost_notify_agent', self.class.to_s, template_data)\n end\n Rails.logger.info(\"AdsExpiryWorker_ABOUT_TO_EXPIRE_PROCESSING_FINISHED_#{ad.id}\")\n end\n\n Rails.logger.info(\"AdsExpiryWorker_FINISHED\")\n\n end", "def perform\n # Do some work\n end", "def activity_worker\n worker = AWS::Flow::ActivityWorker.new(@domain.client, @domain, ACTIVITY_TASKLIST)\n worker.add_implementation(SwfActivityOne.new)\n worker.add_implementation(SwfActivityTwo.new)\n worker.add_implementation(SwfActivityThree.new)\n worker\n end", "def perform!\n super\n\n pipeline = Pipeline.new\n\n pipeline << pg_probackup_cmd\n\n pipeline.run\n if pipeline.success?\n log!(:finished)\n else\n raise Error, \"Backup failed!\\n\" + pipeline.error_messages\n end\n end", "def import\n Worker.import(params[:file])\n redirect_to tenant_workers_path(@tenant), notice: \"Worker list imported.\"\n end", "def worker_begin(worker)\n end", "def execute_job_ext(worker, args)\n pool = Sidekiq.redis_pool\n item = { 'class' => worker.class, 'args' => args }\n normalized_item = Sidekiq::Client.new(pool).send(:normalize_item, item)\n queue = normalized_item['queue']\n server_middleware = SidekiqUniqueJobs::Middleware::Server::UniqueJobs.new\n\n server_middleware.call(worker, normalized_item, queue, pool) do\n execute_job_orig(worker, args)\n end\n end", "def run!\n db_uri = URI.parse(@configuration.remote_db)\n @adapter = (Fixtural.adapter_for_uri db_uri).new(self, db_uri)\n # Actually connect to the database and figure out which tables we need\n # to download\n @adapter.connect()\n\n # Figure out the tables we need to download\n tables = compute_table_list()\n\n total = tables.length\n puts \"Downloading #{total.to_s} tables:\"\n\n # Setup the output store and the writer for the chosen output format\n output_store = @configuration.output_store\n output_writer_klass = Fixtural.output_writer_for_name @configuration.output_format\n\n tables.each_with_index do |table, index|\n progressbar = ProgressBar.create(\n format: \"- #{table} (#{(index+1).to_s}/#{total.to_s}) (%j%%)\"\n )\n extension = output_writer_klass.extension\n name = \"#{table}.#{extension}\"\n\n columns = get_columns table\n\n output_store.open(name) do |fd|\n writer = output_writer_klass.new fd, table, columns\n\n download_table table, writer, progressbar\n\n writer.done\n end\n end\n end", "def report\n # generate_report()\n ReportWorker.perform_async(\"07-01-2018\", \"08-01-2018\")\n render \\\n json: {status: 'SUCCESS', message:'REQUEST TO GENERATE A REPORT ADDED TO THE QUEUE'},\n status: :ok\n end", "def execute_work!\n save_receipts = event_store.with_transaction do\n pending_saves.map(&:call)\n end\n\n @pending_saves = []\n\n save_receipts.each do |reciept|\n message_bus.publish_events(reciept.id, reciept.klass, reciept.events,\n reciept.meta.merge(meta))\n end\n\n self\n end", "def perform!\n super\n\n pipeline = Pipeline.new\n dump_ext = 'sql'\n\n pipeline << mysqldump\n\n model.compressor.compress_with do |command, ext|\n pipeline << command\n dump_ext << ext\n end if model.compressor\n\n pipeline << \"#{ utility(:cat) } > \" +\n \"'#{ File.join(dump_path, dump_filename) }.#{ dump_ext }'\"\n\n pipeline.run\n if pipeline.success?\n log!(:finished)\n else\n raise Error, \"Dump Failed!\\n\" + pipeline.error_messages\n end\n end", "def work\n Bigquery.new(options).processa_tudo\n end", "def write(record)\n @worker.enqueue record\n end", "def call(_worker, job, _queue, _pool)\n job[\"args\"].map!(&:serialize)\n yield\n end", "def register_worker\n super\n\n puts \"Fifo Startup - Updating worker list\"\n manager.request_refresh\n end", "def send_report_data\n render_type = RENDER_TYPES[@sb[:render_type].to_s]\n raise \"Render type #{@sb[:render_type]} is not supported\" unless render_type\n\n assert_privileges(\"render_report_#{render_type}\")\n\n return unless @sb[:render_rr_id]\n\n disable_client_cache\n result = MiqReportResult.find(@sb[:render_rr_id])\n\n filename = filename_timestamp(result.report.title, 'export_filename')\n send_data(result.get_generated_result(@sb[:render_type]),\n :filename => \"#{filename}.#{@sb[:render_type]}\",\n :type => \"application/#{@sb[:render_type]}\")\n\n result.destroy\n end", "def run\n # Get the proper attachment_name from #to_sym\n @attachment_name = @attachment_name.to_sym\n # Contantize @instance_klass\n # And get the instance for @instance_id\n # Sling it into the process_job block\n process_job(@instance, @attachment_name) do\n # Act the fool\n @instance.send(@attachment_name).reprocess!\n @instance.send(\"#{@attachment_name}_processed!\")\n end\n end", "def mass_copier_batch(project_id, from_rfc5646_locale, to_rfc5646_locale)\n b = Sidekiq::Batch.new\n b.description = \"Project Translations Mass Copier #{project_id} (#{from_rfc5646_locale} -> #{to_rfc5646_locale})\"\n b.on :success, ProjectTranslationsMassCopier::Finisher, project_id: project_id\n b\n end", "def enqueue_pending_output; end", "def perform\n SiteConfig.set_pairwise_credentials(photocracy)\n earl = Earl.find(earl_id)\n\n # make HTTP request to pairwise to get export data\n url = URI.parse(\"#{APP_CONFIG[:API_HOST]}/exports/#{export_key}\")\n req = Net::HTTP::Get.new(url.path)\n # important to trigger basic HTTP Auth on pairwise\n req[\"Accept\"] = \"text/csv\"\n req.basic_auth Question.user, Question.password\n res = Net::HTTP.start(url.host, url.port) { |http| http.request(req) }\n if res.code != \"200\"\n raise \"Export URL returned response code of #{res.code} for #{url.to_s}\"\n end\n csvdata = res.body.force_encoding('UTF-8')\n\n # for creating zlibed CSV at the end\n zoutput = Zlib::Deflate.new\n znewcsv = ''\n\n earl.munge_csv_data(csvdata, type).each do |row|\n znewcsv << zoutput.deflate(row)\n end\n znewcsv << zoutput.finish\n zoutput.close\n\n export_id = Export.connection.insert(\"INSERT INTO `exports` (`name`, `data`, `compressed`) VALUES (#{Export.connection.quote(export_key)}, #{Export.connection.quote(znewcsv)}, 1)\".force_encoding('ASCII-8BIT'))\n Delayed::Job.enqueue DestroyOldExportJob.new(export_id), 20, 3.days.from_now\n url = \"/export/#{export_key}\"\n IdeaMailer.deliver_export_data_ready(email, url, photocracy)\n\n return true\n end", "def perform(id)\n store = Store.find(id)\n store.update_full_daily_reports\n puts \"Fully Updated daily reports for #{store.name}\"\n store.update_full_weekly_reports\n puts \"Fully Updated weekly reports for #{store.name}\"\n store.update_full_monthly_reports\n puts \"Fully Updated monthly reports for #{store.name}\"\n end", "def perform\n raise NotImplementedError, 'Implement this in a subclass'\n end", "def index\n @statsupdaters = Statsupdater.all\n DailyupdaterJob.perform_later\n end", "def perform\n track do\n runner.tick!\n @changes = Hash.new { |h, k| h[k] = Accumulator.new }\n\n @registry.each do |mapping|\n mapping.for_worker(self) do\n task(\"PROPAGATING RECORDS\", mapping) { propagate mapping }\n task(\"CLEANING RECORDS\", mapping) { clean mapping }\n task(\"COLLECTING CHANGES\", mapping) { collect mapping }\n task(\"UPDATING ASSOCIATIONS\", mapping) { associate mapping }\n end\n end\n\n # NOTE: We can only perform the synchronization after all record\n # changes have been aggregated, so this second loop is necessary.\n @registry.each do |mapping|\n mapping.for_worker(self) do\n task(\"APPLYING CHANGES\", mapping) { synchronize mapping }\n end\n end\n end\n end", "def workers!\n LambdaMail::Mailing::SendSpecialEmailMessageWorker.drain\nend", "def queue_job; end", "def run\n raise \"run() Not Implemented on worker #{self.class.name}\"\n end", "def perform(record)\n run(record, false)\n end", "def perform!\n super\n transfer!\n cycle!\n end", "def create_worker model, method, scope, options = {}\n options = options.with_indifferent_access\n model = model.to_s.camelize\n data = {method: method, model: model, method_args: options[:method_args], query: scope.to_sql, count: scope.count }\n worker_id = BatchActionsWorker.perform_async(data)\n worker_data = ( \n { id: worker_id, fields: fields_from_model_method(model, method) }\n .with_indifferent_access)\n .merge(data)\n workers.push(worker_data)\n end", "def perform\n ### All leads which were created 7 days ago and which have to be inspected for if the agent completed the mandatory attributes\n ### or not\n Rails.logger.info(\"LeadStatusUpdateWorker_STARTED\")\n leads = Agents::Branches::AssignedAgents::Lead.where.not(agent_id: nil).where(owned_property: false).where(expired: false).where('updated_at < ?', Agents::Branches::AssignedAgents::Lead::VERIFICATION_DAY_LIMIT.ago)\n #LeadStatusUpdateWorker.perform_in(10.minutes)\n\n leads.each do |lead|\n Rails.logger.info(\"LeadStatusUpdateWorker__STARTED__#{lead.id}\")\n udprn = lead.property_id\n details = PropertyDetails.details(udprn)[:_source]\n percent_completed = details[:percent_completed]\n \n ### Check the flag for mandatory details being completed or not\n if percent_completed.to_i < 100\n\n agent = lead.agent\n Rails.logger.info(\"LeadStatusUpdateWorker__LockAgentStarted__#{lead.id}_#{agent.id}\")\n ### Disassociate the agent from its properties and enquiries\n update_hash = { agent_id: nil }\n property_service = PropertyService.new(udprn)\n property_service.update_details(update_hash) rescue nil\n Event.unscope(where: :is_archived).where(udprn: udprn).update_all(agent_id: nil)\n\n ### Lock the agent so that new leads and quotes are not accessible for 30 days\n branch = agent.branch\n agent.update_attributes(locked: true, locked_date: Date.today)\n lead.expired = true\n lead.save!\n Rails.logger.info(\"LeadStatusUpdateWorker__LockAgentFinished__#{lead.id}_#{agent.id}\")\n\n ### Create a new lead for local branches\n property_service.create_lead_for_local_branches(branch.district, udprn, lead.vendor_id)\n\n else\n ### Else we shoot an email to the vendor to confirm about the details\n\n\n end\n Rails.logger.info(\"LeadStatusUpdateWorker__FINISHED__#{lead.id}\")\n\n end\n Rails.logger.info(\"LeadStatusUpdateWorker_FINISHED\")\n\n\n end", "def perform; end", "def perform; end", "def perform(*args)\n #leader with employees in user_ids\n #has attributes uid,user_ids,atten_rule\n\n opts = args.extract_options!\n\n yesterday = args[0] || Date.yesterday\n leaders = User.leaders_by_date(yesterday)\n #用于测试\n if opts[:leader_user_id]\n leaders = leaders.slice(opts[:leader_user_id]) #[leaders.detect { |e| e[0] == opts[:leader_user_id] }]\n end\n\n #puts leaders.inspect\n #构建邮件并发出去\n leaders.each do |leader_user_id,value|\n checkin_uids = value[\"user_ids\"]\n #发送邮件\n #TODO:是否还要保留checkin_uids?\n if checkin_uids.length > 0\n Task.create(\"F001\",leader_user_id,leader_user_id: leader_user_id,checkin_uids: checkin_uids.uniq.to_json,date: yesterday.to_s)\n Usermailer.daily_kaoqing(leader_user_id,uids: checkin_uids.uniq,date: yesterday.to_s).deliver_later\n puts \"sending daily mail #{leader_user_id} \"\n end\n end\n\n puts \"i am preforming\"\n end", "def do_work\n until @worker_input_queue.empty?\n @output_queue << yield(@worker_input_queue.pop)\n end\n end", "def post_process; end", "def perform\n @analysis = Analysis.find(@analysis_id)\n\n # get the analysis and report that it is running\n @analysis_job = AnalysisLibrary::Core.initialize_analysis_job(@analysis, @analysis_job_id, @options)\n\n # reload the object (which is required) because the subdocuments (jobs) may have changed\n @analysis.reload\n\n ids = []\n if @options[:data_points].empty?\n logger.info 'No datapoints were passed into the options, therefore checking which datapoints to run'\n\n # queue up the simulations\n @analysis.data_points.where(status: 'na').each do |dp|\n logger.info \"Adding #{dp.uuid} to simulations queue\"\n\n # TODO: move this method to the datapoint model\n ids << dp.submit_simulation\n end\n end\n\n logger.info \"Delayed Job ids are: #{ids}\"\n\n # Watch the delayed jobs to see when all the datapoints are completed.\n # I would really prefer making a chord or callback for this.\n until ids.empty?\n ids.each do |id|\n ids.delete(id) if Delayed::Job.find(id).nil?\n end\n\n # logger.info ids\n\n sleep 5\n end\n\n # TODO: Finalize the worker nodes\n\n rescue => e\n log_message = \"#{__FILE__} failed with #{e.message}, #{e.backtrace.join(\"\\n\")}\"\n logger.error log_message\n @analysis.status_message = log_message\n @analysis.save!\n ensure\n logger.info 'Finished running batchrun method'\n @analysis_job.end_time = Time.now\n @analysis_job.status = 'completed'\n @analysis_job.save!\n @analysis.reload\n @analysis.save!\n end", "def scraper_migrator\n puts \"\\n\\n#{\"=\"*40}STARTING INDEXER SCRAPER MIGRATOR: Migrates final sorted and scored Indexer Data to Core account based on Match Score and ranked by hierarchy. If two indexers have same match score, the priority goes to those with the order of matching url, then account name, then phone, then address pin.\\n\\n\"\n\n p1_indexers = Indexer.where(archive: false).where.not(\"clean_url_crm_ids = '{}'\")\n by_score(p1_indexers, :clean_url_crm_ids)\n\n p2_indexers = Indexer.where(archive: false).where.not(\"crm_acct_ids = '{}'\")\n by_score(p2_indexers, :crm_acct_ids)\n\n p3_indexers = Indexer.where(archive: false).where.not(\"crm_ph_ids = '{}'\")\n by_score(p3_indexers, :crm_ph_ids)\n\n p4_indexers = Indexer.where(archive: false).where.not(\"acct_pin_crm_ids = '{}'\")\n by_score(p4_indexers, :acct_pin_crm_ids)\n\n p5_indexers = Indexer.where(archive: false).where(\"clean_url_crm_ids = '{}'\").where(\"crm_acct_ids = '{}'\").where(\"crm_ph_ids = '{}'\").where(\"acct_pin_crm_ids = '{}'\")\n by_score(p5_indexers, :id, false)\n end", "def enqueue!\n QueryWorker.perform_async(query.id)\n end", "def analyze\n logger.info \"sending recording to worker\"\n RecordingWorker.async_analyze(:id => self.id)\n end", "def re_enqueue\n BulkImportWorker.perform_in(PERFORM_DELAY, @bulk_import.id)\n end", "def optimize_workflow\n end", "def perform\n options.clean_options!\n at(0, 100, t('common.progress_initializing'))\n\n user = User.find(options[:user_id])\n @dataset = user.datasets.active.find(options[:dataset_id])\n task = @dataset.analysis_tasks.find(options[:task_id])\n\n task.name = t('.short_desc')\n task.save\n\n analysis_type = (options[:analysis_type] || :mi).to_sym\n num_pairs = (options[:num_pairs] || 50).to_i\n focal_word = options[:word].mb_chars.downcase.to_s if options[:word]\n\n # Part of speech tagging requires the Stanford NLP\n if analysis_type == :pos && Admin::Setting.nlp_tool_path.blank?\n analysis_type = :mi\n end\n\n case analysis_type\n when :mi\n algorithm = t('.mi')\n column = t('.mi_column')\n klass = RLetters::Analysis::Collocation::MutualInformation\n when :t\n algorithm = t('.t')\n column = t('.t_column')\n klass = RLetters::Analysis::Collocation::TTest\n when :likelihood\n algorithm = t('.likelihood')\n column = t('.likelihood_column')\n klass = RLetters::Analysis::Collocation::LogLikelihood\n when :pos\n # :nocov:\n algorithm = t('.pos')\n column = t('.pos_column')\n klass = RLetters::Analysis::Collocation::PartsOfSpeech\n # :nocov:\n else\n fail ArgumentError, 'Invalid value for analysis_type'\n end\n\n analyzer = klass.new(\n @dataset,\n num_pairs,\n focal_word,\n ->(p) { at(p, 100, t('.progress_computing')) }\n )\n grams = analyzer.call\n\n # Save out all the data\n at(100, 100, t('common.progress_finished'))\n csv_string = CSV.generate do |csv|\n csv << [t('.header', name: @dataset.name)]\n csv << [t('.subheader', test: algorithm)]\n csv << ['']\n\n csv << [t('.pair'), column]\n grams.each do |w, v|\n csv << [w, v]\n end\n\n csv << ['']\n end\n\n # Write it out\n ios = StringIO.new(csv_string)\n file = Paperclip.io_adapters.for(ios)\n file.original_filename = 'collocation.csv'\n file.content_type = 'text/csv'\n\n task.result = file\n\n # We're done here\n task.finish!\n\n completed\n end", "def perform!\n end", "def process_data\n # do we want to force generation of everything?\n force_all = params[:force] if params.has_key?(:force)\n\n # lock it for a day\n current_user.last_clicked_process_data_button = DateTime.now\n current_user.save\n\n begin\n job_ids = force_all ? Organisation.bootstrap_all! : Organisation.bootstrap_owner_or_largest_org!\n\n flash[:success] = \"Success! #{job_ids.count} data tasks scheduled.\"\n render nothing: true, status: 202\n rescue\n flash[:danger] = \"There was an error, please try scheduling later.\"\n render nothing: true, status: 500\n end\n\n end", "def action_runner\n BawWorkers::Jobs::Analysis::Runner.new(\n BawWorkers::Config.original_audio_helper,\n BawWorkers::Config.analysis_cache_helper,\n BawWorkers::Config.logger_worker,\n BawWorkers::Config.worker_top_dir,\n BawWorkers::Config.programs_dir\n )\n end", "def work(&block)\n Celluloid::Logger.info \"Preparing work...\"\n self.working_code = block if block_given?\n end", "def run(runner, user_arguments)\r\n super(runner, user_arguments)\r\n\r\n #use the built-in error checking \r\n if not runner.validateUserArguments(arguments(), user_arguments)\r\n return false\r\n end\r\n\r\n # get sql, model, and web assets\r\n setup = OsLib_Reporting.setup(runner)\r\n model = setup[:model]\r\n sqlFile = setup[:sqlFile]\r\n web_asset_path = setup[:web_asset_path]\r\n\r\n # create an array of tables to loop through in erb file\r\n @tables = []\r\n\r\n # get general building information\r\n @tables << OsLib_Reporting.general_building_information_table(model,sqlFile,runner)\r\n\r\n # get space type breakdown table and pie chart\r\n @tables << OsLib_Reporting.output_data_space_type_breakdown_table(model,sqlFile,runner)\r\n\r\n # get end use table and pie chart\r\n @tables << OsLib_Reporting.output_data_end_use_table_pie_data(model,sqlFile,runner)\r\n\r\n # get end use by electricity table and pie chart\r\n @tables << OsLib_Reporting.output_data_end_use_electricity_table_pie_data(model,sqlFile,runner)\r\n\r\n # get end use by gas table and pie chart\r\n @tables << OsLib_Reporting.output_data_end_use_gas_table_pie_data(model,sqlFile,runner)\r\n\r\n # get end use table and pie chart\r\n @tables << OsLib_Reporting.output_data_energy_use_table_pie_data(model,sqlFile,runner)\r\n\r\n # get advisory messages table\r\n @tables << OsLib_Reporting.advisory_messages_table(model,sqlFile,runner)\r\n\r\n # get space type detail table\r\n @tables << OsLib_Reporting.output_data_space_type_details_table(model,sqlFile,runner)\r\n\r\n # todo - could be nice to add story summary, area per story, count of zones and spaces. Should list air loops on that story, or should air loop list stories it is used on\r\n\r\n # air loop summary\r\n @tables << OsLib_Reporting.output_data_air_loops_table(model,sqlFile,runner)\r\n\r\n # plant loop summary\r\n @tables << OsLib_Reporting.output_data_plant_loops_table(model,sqlFile,runner)\r\n\r\n # zone equipment summary\r\n @tables << OsLib_Reporting.output_data_zone_equipment_table(model,sqlFile,runner)\r\n\r\n # get fenestration data table\r\n @tables << OsLib_Reporting.fenestration_data_table(model,sqlFile,runner)\r\n\r\n # summary of exterior constructions used in the model for base surfaces\r\n @tables << OsLib_Reporting.surface_data_table(model,sqlFile,runner)\r\n\r\n # summary of exterior constructions used in the model for sub surfaces\r\n @tables << OsLib_Reporting.sub_surface_data_table(model,sqlFile,runner)\r\n\r\n # create table for service water heating\r\n @tables << OsLib_Reporting.water_use_data_table(model,sqlFile,runner)\r\n\r\n # todo - update this to be custom load table, ad user arg with default string of \"Elev\"\r\n # elevators from model\r\n #@tables << OsLib_Reporting.elevator_data_table(model,sqlFile,runner)\r\n\r\n # create table for exterior lights\r\n @tables << OsLib_Reporting.exterior_light_data_table(model,sqlFile,runner)\r\n\r\n #reporting final condition\r\n runner.registerInitialCondition(\"Gathering data from EnergyPlus SQL file and OSM model.\")\r\n\r\n # create excel file (todo - turn back on once support gem)\r\n #book = OsLib_Reporting.create_xls()\r\n #@tables.each do |table|\r\n # my_data = OsLib_Reporting.write_xls(table,book)\r\n #end\r\n #file = OsLib_Reporting.save_xls(book)\r\n\r\n # read in template\r\n html_in_path = \"#{File.dirname(__FILE__)}/resources/report.html.erb\"\r\n if File.exist?(html_in_path)\r\n html_in_path = html_in_path\r\n else\r\n html_in_path = \"#{File.dirname(__FILE__)}/report.html.erb\"\r\n end\r\n html_in = \"\"\r\n File.open(html_in_path, 'r') do |file|\r\n html_in = file.read\r\n end\r\n\r\n # configure template with variable values\r\n renderer = ERB.new(html_in)\r\n html_out = renderer.result(binding)\r\n\r\n # write html file\r\n html_out_path = \"./report.html\"\r\n File.open(html_out_path, 'w') do |file|\r\n file << html_out\r\n # make sure data is written to the disk one way or the other\r\n begin\r\n file.fsync\r\n rescue\r\n file.flush\r\n end\r\n end\r\n\r\n #closing the sql file\r\n sqlFile.close()\r\n\r\n #reporting final condition\r\n runner.registerFinalCondition(\"Generated #{html_out_path}.\")\r\n\r\n return true\r\n \r\n end", "def post_process\n end", "def run_bulk; end", "def work_data(job_handle, data)\n send_client :work_data, job_handle, data\n end", "def create\n data_report = DataReport.new(data_report_params)\n\n # For now the worker is synchronous. Eventually it can be run asynchronously\n if data_report.save && report_worker.perform(data_report.id)\n render json: {}, status: :ok\n elsif data_report.errors.present\n render json: data_report.errors, status: :unprocessable_entity\n else\n render json: {}, status: :internal_server_error\n end\n end", "def do_work\n raise NotImplementedError\n end", "def run\n\n # Gets possible data source(s)\n service(:sniffer).exec\n\n # Filters the data source(s) to extract the relevant only.\n service(:filter).exec\n\n # ETL\n context[:to_be_extracted].each_with_index do |ds, i|\n log.debug \"starting ETL, idx=#{i + 1}\"\n context[:extract] = ds\n service(:extractor).exec\n service(:transformer).exec\n service(:loader).exec\n end\n\n log.info 'Bye bye'\n end", "def perform\n track do\n reset!\n\n Restforce::DB::Registry.each do |mapping|\n run(\"CLEANING RECORDS\", Cleaner, mapping)\n run(\"ATTACHING RECORDS\", Attacher, mapping)\n run(\"PROPAGATING RECORDS\", Initializer, mapping)\n run(\"COLLECTING CHANGES\", Collector, mapping)\n end\n\n # NOTE: We can only perform the synchronization after all record\n # changes have been aggregated, so this second loop is necessary.\n Restforce::DB::Registry.each do |mapping|\n run(\"UPDATING ASSOCIATIONS\", Associator, mapping)\n run(\"APPLYING CHANGES\", Synchronizer, mapping)\n end\n end\n end", "def force_flush\n snapshot = lock { spans.shift(spans.size) }\n until snapshot.empty?\n batch = snapshot.shift(@batch_size).map!(&:to_span_data)\n result_code = @exporter.export(batch)\n report_result(result_code, batch)\n end\n end", "def queue_processing\n WebPageLocateWorker.perform_async(self.uuid)\n WebPageColorWorker.perform_async(self.uuid)\n end", "def on_backends_inline_process(event)\n count = event[:caller].send(:params_batch).to_a.size\n topic = event[:caller].topic.name\n time = event[:time]\n info \"Inline processing of topic #{topic} with #{count} messages took #{time} ms\"\n end", "def run\n self.report_type = :daily_tasks\n self.failures = []\n\n EmailSubmission.where(\n created_at: Date.yesterday...Date.current\n ).joins(:c100_application).find_each(batch_size: 25) do |record|\n reference_code = record.c100_application.reference_code\n\n find_failures(record, reference_code, COURT_EMAIL_TYPE)\n\n # Only if the applicant chose to receive a confirmation, otherwise\n # these emails are not sent and there is no need to do any check.\n find_failures(record, reference_code, USER_EMAIL_TYPE) if record.c100_application.receipt_email?\n end\n\n send_email_report if failures.any?\n end", "def perform_work\n logger.debug \"update_marc handing off to dor-services-app job for update to #{druid}\"\n object_client.update_marc_record\n\n # Since the actual update work is completed by dor-services-app in a job,\n # workflow logging (marking step completed or failed) is done there.\n LyberCore::ReturnState.new(status: :noop, note: 'Initiated update_marc_record API call.')\n end", "def execute()\n \n # Retrieve a single entry from KS_SRV_Helper form\n base_record = @@remedy_forms['KS_SRV_CustomerSurvey'].find_entries(\n :single,\n :conditions => [%|'CustomerSurveyInstanceId' = \"#{@parameters['Submission ID']}\" OR 'CustomerSurveyID' = \"#{@parameters['Submission ID']}\"|],\n :fields => :all\n )\n \n raise \"Unable to find KS_SRV_CustomerSurvey record with CustomerSurvey ID or instanceId of: #{@parameters['Submission ID']}\" if base_record.nil?\n \n\tif (@taskVersion == \"3\")\n\t#v3\n # Build the template record from the KS_SRV_CustomerSurvey record, which\n # includes the Template fields.\n\t template_record = Records::Template.new(base_record)\n \n # Build the template dataset mappings based on the KS_SRV_DataSet form\n # records for dataset specified on the current KS_SRV_CustomerSurvey\n # record.\n\n\t @dataset_hash = Records::TemplateDataSetMapping.find_all(\n\t\t :data_set => template_record.data_set\n\t\t).inject({}) do |hash, mapping_record|\n\t\t # Define the current KS_SRV_DataSet record's field_id as a Fixnum\n\t\t field_id = mapping_record.field_id.to_i\n\t\t # Retrieve the ArsModels::Field associated with the current\n\t\t # KS_SRV_CustomerSurvey field.\n\t\t mapping_field = Records::RequestBase.form.field_for(field_id)\n\t\t # Unless the field does not exist on the form, or the field is display only\n\t\t unless mapping_field.nil? || mapping_field.entrymode == \"DISPLAY_ONLY\"\n\t\t\t# Retrieve the value of the field on the KS_SRV_CustomerSurvey entry\n\t\t\tvalue = base_record[field_id]\n\t\t\t# Map the KS_SRV_DataSet record's field label value to the field value\n\t\t\thash[mapping_record.field_label] = value.respond_to?(:value) ? value.value : value\n\t\t end\n\t\t # Return the hash to continue injecting\n\t\t hash\n\t\tend\n\t\t puts(format_hash(\"Dataset Found: \", @dataset_hash)) if @debug_logging_enabled\n\t\n\telsif (@taskVersion == \"4\")\n\t \n\t template_record = Records::Template.new(base_record, :context => @@remedy_context)\n\t \n\t @dataset_hash = Records::TemplateDataSetMapping.find_all(\n\t\t :data_set => template_record.data_set, :context => @@remedy_context\n\t\t).inject({}) do |hash, mapping_record|\n\t\t # Define the current KS_SRV_DataSet record's field_id as a Fixnum\n\t\t field_id = mapping_record.field_id.to_i\n\t\t # Retrieve the ArsModels::Field associated with the current\n\t\t # KS_SRV_CustomerSurvey field.\n\t\t mapping_field = Records::RequestBase.form.field_for(field_id)\n\t\t # Unless the field does not exist on the form, or the field is display only\n\t\t unless mapping_field.nil? || mapping_field.entrymode == \"DISPLAY_ONLY\"\n\t\t\t# Retrieve the value of the field on the KS_SRV_CustomerSurvey entry\n\t\t\tvalue = base_record[field_id]\n\t\t\t# Map the KS_SRV_DataSet record's field label value to the field value\n\t\t\thash[mapping_record.field_label] = value.respond_to?(:value) ? value.value : value\n\t\t end\n\t\t # Return the hash to continue injecting\n\t\t hash\n\t\tend\n\t\tputs(format_hash(\"Dataset Found: \", @dataset_hash)) if @debug_logging_enabled\n\t\t\n\tend\n \n dataset_results = \"\" \n @dataset_hash.each_pair {|key, value|\n dataset_results << %|<result name=\"#{key}\">#{escape(value)}</result>|\n }\n \n <<-RESULTS\n <results>\n #{dataset_results}\n </results>\n RESULTS\n \n end", "def update_worker_item(worker, source, company, office, new, cctagene)\n # Dont't need to look for auxiliary data, already done at update_worker\n if new\n #\n # Add new item data\n #\n worker.company_id = company.id unless company.id.blank?\n worker.office_id = office.id unless office.id.blank?\n worker.department_id = @department.id unless @department.id.blank?\n worker.professional_group_id = @professional_group.id unless @professional_group.id.blank?\n worker.starting_at = source.dfecini unless source.dfecini.blank?\n worker.issue_starting_at = source.dfecant unless source.dfecant.blank?\n worker.contract_type_id = @contract_type.id unless @contract_type.id.blank?\n worker.collective_agreement_id = @collective_agreement.id unless @collective_agreement.id.blank?\n worker.position = sanitize_string(source.cpuesto, true, false, false, true) unless source.cpuesto.blank?\n if !cctagene.nil?\n worker.contribution_account_code = sanitize_string(cctagene, true, false, false, false)\n else\n worker.contribution_account_code = sanitize_string(source.csubcta, true, false, false, false) unless source.csubcta.blank?\n end\n else\n #\n # Update current item data (if applicable)\n #\n #-- Current worker_item company, office, department, progroup & position\n #-- should not be updated\n if !@contract_type.id.blank? && worker.contract_type_id != @contract_type.id\n worker.contract_type_id = @contract_type.id\n end\n if !@collective_agreement.id.blank? && worker.collective_agreement_id != @collective_agreement.id\n worker.collective_agreement_id = @collective_agreement.id\n end\n if !source.dfecini.blank? && worker.starting_at != source.dfecini\n worker.starting_at = source.dfecini\n end\n if !source.dfecant.blank? && worker.issue_starting_at != source.dfecant\n worker.issue_starting_at = source.dfecant\n end\n if !cctagene.nil?\n if worker.contribution_account_code != sanitize_string(cctagene, true, false, false, false)\n worker.contribution_account_code = sanitize_string(cctagene, true, false, false, false)\n end\n else\n if !source.csubcta.blank? && worker.contribution_account_code != sanitize_string(source.csubcta, true, false, false, false)\n worker.contribution_account_code = sanitize_string(source.csubcta, true, false, false, false)\n end\n end\n end\n # Check out other mandatory default data\n if worker.contribution_account_code.blank?\n worker.contribution_account_code = \"no_existe\"\n end\n if worker.starting_at.blank? && !source.dfecalta.blank?\n worker.starting_at = source.dfecalta\n end\n if worker.issue_starting_at.blank? && !source.dfecini.blank?\n worker.issue_starting_at = source.dfecini\n end\n\n # Reset default auxiliary data\n set_defaults\n # Bye\n return worker\n end", "def run_and_transform; end", "def run_data_miner!\n data_miner_script.start\n end", "def add_worker\n FiberWorker.new(@entity, self)\n end", "def load_sample_data(skip = {})\n Sidekiq::Client.push(\n 'class' => SampleDataWorker,\n 'queue' => 'imports',\n 'args' => [self.id, skip]\n )\n end", "def save_to_server!\n DownloadWorker.perform_async(self.id)\n end", "def perform!\n super\n\n pipeline = Pipeline.new\n\n pipeline << mysql\n\n pipeline.run\n if pipeline.success?\n log!(:finished)\n else\n raise Error, \"Execution Failed!\\n\" + pipeline.error_messages\n end\n end", "def perform!\n transfer!\n cycle!\n end", "def perform!\n transfer!\n cycle!\n end", "def perform(hashid, content)\n logger.debug \"\\n\\n------- StatementWorker: perform start -------\\n\\n\"\n logger.debug \"#{content}\\n\\n\"\n\n\n text_statement = \"I agree that \" + content.gsub(\"'\", %q(\\\\\\'))\n convert = MiniMagick::Tool::Convert.new\n # convert << \"\\(\"\n # convert << \"app/assets/images/weagreethat.png\"\n # convert << \"-size\"\n # convert << \"900x880\"\n # convert << \"-extent\"\n # convert << \"900x880\"\n # convert << \"-font\"\n # convert << \"helvetica\"\n # convert << \"-weight\"\n # convert << \"900\"\n # convert.gravity (\"NorthWest\")\n # convert << \"caption:\" + text_statement\n # convert << \"-composite\"\n # convert << \"\\)\"\n # convert << \"app/assets/images/weagreethat_text.png\"\n # convert.gravity (\"Center\")\n # convert << \"-composite\"\n # convert << \"public/assets/images/\" + statement.hashid + \".png\"\n\n if Rails.env.development?\n font = 'helvetica-bold'\n elsif Rails.env.production?\n font = 'Nimbus-Sans-L-Bold'\n end\n\n\n # new version\n convert << '-page'\n convert << '0x0'\n convert << 'app/assets/images/weagreethat.png'\n convert << '-page'\n convert << '+12+10'\n convert << '-size'\n convert << '888x500'\n convert << '-font'\n convert << \"#{font}\"\n convert << \"caption:#{text_statement}.\"\n convert << '-layers'\n convert << 'mosaic'\n convert << \"#{Rails.root.join('tmp')}/#{hashid}.png\"\n\n Rails.logger.debug convert.command\n convert.call #=> `convert input.jpg -resize 100x100 -negate output.jpg`\n\n # https://guides.rubyonrails.org/v5.2.0/active_storage_overview.html\n # statement.statement_image.attach(\"public/assets/images/\" + statement.hashid + \".png\")\n # https://blog.capsens.eu/how-to-use-activestorage-in-your-rails-5-2-application-cdf3a3ad8d7\n Statement.find(hashid).statement_image.attach(io: File.open(\"#{Rails.root.join('tmp')}/#{hashid}.png\"), filename: \"#{hashid}.png\")\n end", "def generate\n GenerateInvoiceJob.perform_later\n end" ]
[ "0.5945893", "0.57572097", "0.5681698", "0.5650164", "0.5566229", "0.556445", "0.5547763", "0.55165744", "0.54743725", "0.5434695", "0.541954", "0.5393376", "0.5349002", "0.5316676", "0.530394", "0.527761", "0.52651745", "0.5207843", "0.5198338", "0.5193809", "0.51920885", "0.5153386", "0.5146743", "0.5141682", "0.51394635", "0.5138147", "0.513155", "0.5124401", "0.5120811", "0.5116674", "0.51130825", "0.5112535", "0.5109431", "0.5099518", "0.5098943", "0.50832254", "0.50815606", "0.5076692", "0.5076662", "0.5075947", "0.50705075", "0.506562", "0.50655156", "0.5064885", "0.50596154", "0.50505084", "0.50492686", "0.5046077", "0.50456583", "0.5044127", "0.5040073", "0.5032835", "0.50317585", "0.5023196", "0.5021882", "0.50214916", "0.50056416", "0.49989027", "0.4989276", "0.4981426", "0.4981426", "0.49798474", "0.49754918", "0.4970631", "0.497056", "0.49632597", "0.49577153", "0.4953914", "0.49506322", "0.4945839", "0.49452114", "0.49451897", "0.4943798", "0.4943672", "0.49428827", "0.4927601", "0.49268597", "0.49263984", "0.49250922", "0.4921051", "0.4920083", "0.49185973", "0.4918158", "0.49179116", "0.49135357", "0.49109137", "0.49106082", "0.49041036", "0.49024355", "0.49018696", "0.4899591", "0.48978224", "0.4895085", "0.48929146", "0.4892297", "0.48887345", "0.48786095", "0.48786095", "0.48720944", "0.48715743" ]
0.61501044
0
Offset and scale vertice coordinates for map rendering
def map_vertices(mult = 1) vertices.map do |v| ((v - game_map.offset) * game_map.zoom * mult).to_a end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_display_pos(x, y)\n @display_x = (x + @map.width * 256) % (@map.width * 256)\n @display_y = (y + @map.height * 256) % (@map.height * 256)\n @parallax_x = x\n @parallax_y = y\n end", "def untransformed_vector(v)\r\n v.map{|x| x/@zoom }\r\n end", "def cal_pos\n x, y = map_location(@grid_x, @grid_y)\n x += @tile_size/2\n y += @tile_size/2\n [x,y]\n end", "def update_position\n case @picture.info[:map_mode]\n when 1\n self.x = -$game_map.display_x * 32 + @picture.xo\n self.y = -$game_map.display_y * 32 + @picture.yo\n when 2\n self.x = -$game_map.display_x * 32\n self.y = -$game_map.display_y * 32\n else\n self.x = self.y = 0\n end\n self.z = @picture.info[:z] ? @picture.info[:z] : 100\n end", "def transformed(p)\r\n (0..1).map do |i|\r\n (p[i] - @old_center[i])*@zoom + (@center[i] - @old_center[i])*@zoom + @old_center[i]\r\n end\r\n end", "def transform \n \n @pixel_location = get_pixel_points \n puts \"px loc : #{@pixel_location}\"\n \n while @pixel_location.size != 0 \n transform_pixel_points(@pixel_location)\n @pixel_location.shift\n @pixel_location.shift\n end\n end", "def translate_pos(given)\n Zif.add_positions(Zif.position_math(:mult, given, zoom_factor), pos)\n end", "def translate_pos(given)\n Zif.add_positions(Zif.position_math(:mult, given, zoom_factor), pos)\n end", "def draw_map\n draw_map_cells($map.x, $map.y)\n end", "def scale_and_translate(outline, width, height, scale, location)\r\n tr = Geom::Transformation.scaling(height * scale, height * scale,0)\r\n outline.collect!{|pt|\r\n pt.transform!(tr)\r\n pt[0] = pt[0] + width * scale - height * scale if pt[0] > height * scale/2\r\n pt\r\n }\r\n tr = Geom::Transformation.translation([location[0] * scale, location[1] * scale])\r\n outline.collect{|pt| pt.transform(tr)}\r\n end", "def recalculate!(scale)\n neighbor = @coordinate.zoom_to(zoom - 1)\n parent = neighbor.container\n\n col_shift = 2 * (neighbor.column - parent.column)\n row_shift = 2 * (neighbor.row - parent.row)\n\n @offset.x -= scale * tile_width * col_shift\n @offset.y -= scale * tile_height * row_shift\n @coordinate = parent\n end", "def center(x, y)\n max_x = ($game_map.width - 20) * 128\n max_y = ($game_map.height - 15) * 128\n $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max\n $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max\n end", "def center_map( map , venue, zoom = 12) \n map.center_zoom_init( venue.coordinates , zoom ) #rescue false # venue.coordinates\n end", "def snap_offset\n @y += @off_y / 32\n @x += @off_x / 32\n @real_x = @x * 128\n @real_y = @y * 128\n @off_y = 0#@off_y % 32\n @off_x = 0#@off_x % 32\n end", "def untransformed(p)\r\n (0..1).map do |i|\r\n (p[i] - @old_center[i])/@zoom + (@old_center[i] - @center[i]) + @old_center[i]\r\n end\r\n end", "def coordinate_region_with_map_view(map_view, center_coordinate, zoom_level)\n\n # clamp lat/long values to appropriate ranges\n center_coordinate.latitude = [[-90.0, center_coordinate.latitude].max, 90.0].min\n center_coordinate.longitude = center_coordinate.longitude % 180.0\n\n # convert center coordiate to pixel space\n center_pixel_x = self.longitude_to_pixel_space_x(center_coordinate.longitude)\n center_pixel_y = self.latitude_to_pixel_space_y(center_coordinate.latitude)\n\n # determine the scale value from the zoom level\n zoom_exponent = 20 - zoom_level\n zoom_scale = 2 ** zoom_exponent\n\n # scale the map’s size in pixel space\n map_size_in_pixels = map_view.bounds.size\n scaled_map_width = map_size_in_pixels.width * zoom_scale\n scaled_map_height = map_size_in_pixels.height * zoom_scale\n\n # figure out the position of the left pixel\n top_left_pixel_x = center_pixel_x - (scaled_map_width / 2)\n\n # find delta between left and right longitudes\n min_lng = self.pixel_space_x_to_longitude(top_left_pixel_x)\n max_lng = self.pixel_space_x_to_longitude(top_left_pixel_x + scaled_map_width)\n longitude_delta = max_lng - min_lng\n\n # if we’re at a pole then calculate the distance from the pole towards the equator\n # as MKMapView doesn’t like drawing boxes over the poles\n top_pixel_y = center_pixel_y - (scaled_map_height / 2)\n bottom_pixel_y = center_pixel_y + (scaled_map_height / 2)\n adjusted_center_point = false\n if top_pixel_y > MERCATOR_OFFSET * 2\n top_pixel_y = center_pixel_y - scaled_map_height\n bottom_pixel_y = MERCATOR_OFFSET * 2\n adjusted_center_point = true\n end\n\n # find delta between top and bottom latitudes\n min_lat = self.pixel_space_y_to_latitude(top_pixel_y)\n max_lat = self.pixel_space_y_to_latitude(bottom_pixel_y)\n latitude_delta = -1 * (max_lat - min_lat)\n\n # create and return the lat/lng span\n span = MKCoordinateSpanMake(latitude_delta, longitude_delta)\n region = MKCoordinateRegionMake(center_coordinate, span)\n # once again, MKMapView doesn’t like drawing boxes over the poles\n # so adjust the center coordinate to the center of the resulting region\n if adjusted_center_point\n region.center.latitude = self.pixel_space_y_to_latitude((bottom_pixel_y + top_pixel_y) / 2.0)\n end\n\n region\n end", "def scale_vertex(vertex, options = {})\n offset = options[:offset] || [0,0]\n [(vertex[0]+offset[0])*14/9, (vertex[1]+offset[1])*20+5]\n end", "def scale(factor_x, factor_y, around_x, around_y, &rendering_code); end", "def center\n @vbuffer.buffer.min(1).to_a.zip(@vbuffer.buffer.max(1).to_a).map {|min,max| min + ((max-min)/2).abs }\n end", "def calc_vertices\n @worksheet.position_object( @params[:start_col],\n @params[:start_row],\n @params[:x_offset],\n @params[:y_offset],\n @params[:width],\n @params[:height]\n )\n end", "def update_zoom\n @effectus_old_zoom_x = @picture.zoom_x\n @effectus_old_zoom_y = @picture.zoom_y\n self.zoom_x = @effectus_old_zoom_x / 100.0\n self.zoom_y = @effectus_old_zoom_y / 100.0\n end", "def loc\r\n { x: @mapx,\r\n y: @mapy }\r\n end", "def compute_position\n # The negative and the ninety are the fudge to compensate for our map.\n lat = @latitude_radians = radians(-@latitude)\n long = @longitude_radians = radians(@longitude + 90)\n radius = $app.globe.diameter / 2.0 - 23\n @x = radius * cos(lat) * sin(long)\n @y = radius * sin(lat)\n @z = radius * cos(lat) * cos(long)\n end", "def viewport_offset\n @viewport_offset ||= {x: part_layout.x.to_i, y: part_layout.y.to_i}\n end", "def update_zvect\n return unless GTBS::PROJECTILE_CAM\n zvect = Math::sin(@index/@div.to_f)\n $game_map.set_display_pos($game_map.display_x, @base_y - (zvect * @high/2))\n end", "def update_classic\n @equip_icon.zoom_x += 0.2 if @equip_icon.zoom_x < 2.0\n @equip_icon.zoom_y += 0.2 if @equip_icon.zoom_y < 2.0\n @scroll_icon.zoom_x += 0.2 if @scroll_icon.zoom_x < 2.0\n @scroll_icon.zoom_y += 0.2 if @scroll_icon.zoom_y < 2.0\n end", "def get_map_pos(scr_x, scr_y)\n return Vector.new((scr_x + @cam.x) / @tile_size.x, (scr_y + @cam.y) / @tile_size.y) unless @isometric\n\n # Gets the position transformed to isometric coordinates\n v = get_isometric_position scr_x, scr_y\n\n # divides by the square size to find the position in the matrix\n Vector.new((v.x * @inverse_square_size).to_i, (v.y * @inverse_square_size).to_i)\n end", "def _cell_zoom\r\n @x = params[:x]\r\n @y = params[:y]\r\n @otu = Otu.find(params[:otu_id])\r\n @chr = Chr.find(params[:chr_id])\r\n @confidences = @proj.confidences\r\n @mx = Mx.find(params[:mx_id])\r\n end", "def to_chipmunk\n\t\tself.normalize!\n\t\t@points.collect { |point| vec2(point[0] - self.center_x, point[1] - self.center_y) }\n\tend", "def axis_inches axis, tile, pixel\n @offset[axis] + tile*@tile_interval[axis] + pixel*@scale[axis]\n end", "def axis_inches axis, tile, pixel\n @offset[axis] + tile*@tile_interval[axis] + pixel*@scale[axis]\n end", "def mapx\n return $game_map.events[@id].real_x * 32\n end", "def y_offset; end", "def x_offset; end", "def vector\n\t\treturn [(end_lng - start_lng), (end_lat - start_lat)]\n\tend", "def draw_map_position(x, y)\n contents.fill_rect(x, y, 3, 3, Color.new(255, 0, 0))\n end", "def screen_position_relative_to(px,py,xi,yi,sextx,sexty)\n tx = @wrapped_surface.tile_x\n ty = @wrapped_surface.tile_y\n xoff = offset_from_screen(xi*tx, px, sextx)\n yoff = offset_from_screen(yi*ty, py, sexty)\n [xoff,yoff]\n end", "def tile_offset index\n\t\t\t@unit_size * index\n\t\tend", "def view_offset\n @position + Moon::Vector3[@view.position, 0]\n end", "def set_screen_factors(lat_min, lat_max, lon_min, lon_max)\n @x_factor = 0\n @y_factor = 0\n # TODO add a border\n x_range = lon_max.to_f - lon_min.to_f\n @x_factor = (x_range * MAP_SCALE) / (SCRATCH_MAX_X - SCRATCH_MIN_X)\n y_range = lat_max.to_f - lat_min.to_f\n @y_factor = (y_range * MAP_SCALE) / (SCRATCH_MAX_Y - SCRATCH_MIN_Y)\n # TODO don't skew the map, figure on one factor and use accordingly\n end", "def center(x, y)\n # Recalculate the screen center based on the new resolution.\n max_x = ($game_map.width - $game_map.tile_size[0]) * 128\n max_y = ($game_map.height - $game_map.tile_size[1]) * 128\n $game_map.display_x = [0, [x * 128 - CENTER_X, max_x].min].max\n $game_map.display_y = [0, [y * 128 - CENTER_Y, max_y].min].max\n end", "def zoom\n end", "def pos(tilew, tileh, hmul, x,y)\n r = $map[y] || []\n my = 0\n tile = \"grass\"\n if r.is_a?(Array)\n my = r[x] || 0\n else\n # I apply a factor of 0.7 here, as pure\n # integer multiples of the tile height looks\n # odd. In a proper map representation I may\n # make the height much more granular.\n my = r[x*2].to_i * hmul.to_f * 0.7\n tile = $tiletypes[r[x*2+1]]\n end\n return (x-y)*tilew + 600, -(x+y)*tileh +540 + my*tileh, my, tile\nend", "def update_placement\n self.x = (Graphics.width - self.width) / 2\n self.y = (Graphics.height - self.height) / 2\n end", "def svg_coord(row, col)\n\t\t[col*10 + 5, row*10 + 5]\n\tend", "def coordinates\n return 166, 72\n end", "def index\n @map_bounds = [20, 20]\n @current_position = [0,0]\n @map = []\n @spots_around = [[-1, 0], [1, 0], [0, -1], [0, 1]]\n create_initial_map\n generate_map\n end", "def location(x, y, w, h)\n return x - w/2, y + 20\n end", "def latlng_to_pixel_xy(lat,lng,level_of_detail)\n\n latitude = safe_val(lat,MIN_LATITUDE,MAX_LATITUDE)\n longitude = safe_val(lng,MIN_LONGITUDE,MAX_LONGITUDE)\n\n x = (longitude + 180 ) / 360 \n sin_latitude = sin( latitude * PI_PREC / 180, DECIMAL_PREC)\n y = 0.5 - log(1 + sin_latitude, DECIMAL_PREC) / (1 - sin_latitude ) / 4 * PI_PREC\n\n map_size_level = map_size(level_of_detail) \n pixel_x = safe_val(x * map_size_level + 0.5, 0, map_size_level - 1 )\n pixel_y = safe_val(y * map_size_level + 0.5, 0, map_size_level - 1 )\n\n [pixel_x,pixel_y]\n end", "def coordinate_region_with_map_view(map_view, center_coordinate, zoom_level)\n center_coordinate = LocationCoordinate.new(center_coordinate).mercator_limit\n center_pixel = center_coordinate.to_pixel_space\n\n # determine the scale value from the zoom level\n zoom_exponent = 20 - zoom_level\n zoom_scale = 2 ** zoom_exponent\n\n # scale the map’s size in pixel space\n scaled_map_size = (MapSize.new(map_view.bounds.size) * zoom_scale)\n\n # figure out the position of the corner pixels\n top_left_pixel = center_pixel - (scaled_map_size / 2)\n bottom_right_pixel = top_left_pixel + scaled_map_size\n\n # if we’re at a pole then calculate the distance from the pole towards the equator\n # as MKMapView doesn’t like drawing boxes over the poles\n adjusted_center_point = false\n if top_left_pixel.y > BaseDataTypes::Vector::MERCATOR_OFFSET * 2\n top_left_pixel.y = center_pixel.y - scaled_map_size.height\n bottom_right_pixel.y = BaseDataTypes::Vector::MERCATOR_OFFSET * 2\n adjusted_center_point = true\n end\n\n # find delta between left and right longitudes\n # convert center coordinates to location space and find the span between them\n top_left_coordinate = top_left_pixel.to_location_space\n bottom_right_coordinate = bottom_right_pixel.to_location_space\n span = bottom_right_coordinate.span_to(top_left_coordinate)\n\n # create and return the lat/lng span\n span = CoordinateSpan.new(span.y, span.x)\n\n # once again, MKMapView doesn’t like drawing boxes over the poles\n # so adjust the center coordinate to the center of the resulting region\n if adjusted_center_point\n center_coordinate.latitude = (top_left_coordinate + (span / 2)).latitude\n end\n\n CoordinateRegion.new(center_coordinate, span).api\n end", "def zoom_center(x)\n idx = @grf.near_x x\n printf(\"zoom center start: %3d % 4d % 4d % 4d\\n\", x, @zoom_beg, idx, @zoom_end)\n range = @zoom_end - @zoom_beg\n cpidx = idx / range\n \n newl = (@zoom_beg + (range * 0.125)).to_i\n newr = (@zoom_end - (range * 0.125)).to_i\n @zoom_beg = newl\n @zoom_end = newr\n printf(\"zoom center end: %3d % 4d % 4d % 4d \\n\", x, @zoom_beg, idx, @zoom_end)\n @zooming = true;\n @grf.zoom @zoom_beg, @zoom_end\n end", "def normalize_offset(offset); end", "def initialize\r\n @map_id = 0\r\n @display_x = 0\r\n @display_y = 0\r\n end", "def center(x, y, flag = false)\n # set pix value\n pix = flag ? $BlizzABS.pixel : 1\n # resize coordinates\n x, y = x * 128 / pix, y * 128 / pix\n # get maximum coordinates of map\n m_x, m_y = ($game_map.width - 20) * 128, ($game_map.height - 15) * 128\n ox, oy = x - CX, y - CY\n # set new display coordinates\n if ox > m_x\n $game_map.display_x = m_x\n elsif ox < 0\n $game_map.display_x = 0\n else\n $game_map.display_x = ox\n end\n if oy > m_y\n $game_map.display_y = m_y\n elsif oy < 0\n $game_map.display_y = 0\n else\n $game_map.display_y = oy\n end\n end", "def center(x, y)\n $game_map.set_display_pos(x - center_x, y - center_y)\n end", "def center(x, y)\n $game_map.set_display_pos(x - center_x, y - center_y)\n end", "def zoom=(val)\n self.zoom_x = val\n self.zoom_y = val\n end", "def zoom=(val)\n self.zoom_x = val\n self.zoom_y = val\n end", "def offset_large_unit\n #large unit position update\n self.x += 16*(@character.unit_size-1)\n self.y += 16*(@character.unit_size-1)\n self.y = @character.apply_float_effect(self.y)\n update_dodge_offsets\n update_shadow\n end", "def apply_transform!\n @location = @dy.transformPoint( @location )\n end", "def is_in_map(v)\n v.x >= 0 && v.y >= 0 && v.x < @size.x && v.y < @size.y\n end", "def coords_to_pos(point)\n (size - 1 - point.y) * size + point.x\n end", "def zoom(factor = 5)\n upstream_slice = self.class.sketch.slices.select{|s| s.start_cumulative_bp < @start_cumulative_bp}.sort_by{|s| s.start_cumulative_bp}[-1]\n downstream_slice = self.class.sketch.slices.select{|s| s.start_cumulative_bp > @start_cumulative_bp}.sort_by{|s| s.start_cumulative_bp}[0]\n\n center_bp = (@start_cumulative_bp + @length_bp.to_f/2).round\n\n @length_bp = (@length_bp.to_f/factor).round\n @start_cumulative_bp = (center_bp - @length_bp.to_f/2).round\n @stop_cumulative_bp = (center_bp + @length_bp.to_f/2 - 1).round\n @resolution = @length_pixel.to_f/@length_bp\n self.fetch_sequence\n\n upstream_slice.stop_cumulative_bp = @start_cumulative_bp - 1\n downstream_slice.start_cumulative_bp = @stop_cumulative_bp + 1\n [upstream_slice, downstream_slice].each do |s|\n s.length_bp = s.stop_cumulative_bp - s.start_cumulative_bp + 1\n s.resolution = s.length_pixel.to_f/s.length_bp\n s.range_cumulative_bp = Range.new(s.start_cumulative_bp, s.stop_cumulative_bp)\n s.fetch_sequence\n end\n self.class.sketch.slices.each{|s| s.format_resolution}\n\n self.class.sketch.buffer_images[:zoomed] = self.class.sketch.draw_zoomed_buffer\n self.class.sketch.buffer_images[:information_panel] = self.class.sketch.draw_information_panel\n end", "def spritesheet_coordinates\n return -184, 20\n end", "def center_on x,y,w,h\n x = x - w / 2\n y = y - h / 2 \n return x,y \n end", "def translate(x, y, &rendering_code); end", "def update_position\n self.x = @battler.screen_x\n self.y = @battler.screen_y - (oy * zoom_y)\n self.z = @battler.screen_z\n end", "def draw\n @map.draw\n end", "def normalize_coordinates\n minY = minX = 1000000\n maxX = maxY = -minX\n @passages.each do |passage|\n if passage.x < minX then minX = passage.x end\n if passage.x > maxX then maxX = passage.x end\n if passage.y < minY then minY = passage.y end\n if passage.y > maxY then maxY = passage.y end\n end\n x_distance = 0 - minX\n y_distance = 0 - minY\n @extentX = maxX + x_distance\n @extentY = maxY + y_distance\n @passages.each do |passage|\n passage.x += x_distance\n passage.y += y_distance\n end\n end", "def mapy\n return $game_map.events[@id].real_y * 32\n end", "def vscale(factor)\n @height = @height * factor\n @top *= factor\n self\n end", "def google_tile(tx, ty, zoom)\n [tx, (2**zoom - 1) - ty]\n end", "def scale(factor)\n Point.new(self.x * factor, self.y * factor)\n end", "def start_coords\n marker_coords('S')\n end", "def zoom_level\n region = self.region\n center_pixel = region.center.to_pixel_space\n top_left_pixel = (region.center - (region.span / 2)).to_pixel_space\n\n scaled_map_width = (center_pixel.x - top_left_pixel.x) * 2\n map_size_in_pixels = MapSize.new(self.bounds.size)\n\n zoom_scale = scaled_map_width / map_size_in_pixels.width\n zoom_exponent = log(zoom_scale) / log(2)\n 20 - zoom_exponent\n end", "def sector_a_intfx_coords\n [ [-1.5 * @radius, @radius], [-1.5 * @radius, -@radius], \n [-1.5 * @radius, 3 * @radius], [-3 * @radius, 2 * @radius],\n [-3 * @radius, 0], [-3 * @radius, -2 * @radius],\n [-1.5 * @radius, -3 * @radius] ]\n end", "def spritestack_coordinates\n return 25, 125\n end", "def get_screen_pos(map_x, map_y)\n return Vector.new(map_x * @tile_size.x - @cam.x, map_y * @tile_size.y - @cam.y) unless @isometric\n Vector.new ((map_x - map_y - 1) * @tile_size.x * 0.5) - @cam.x + @x_offset,\n ((map_x + map_y) * @tile_size.y * 0.5) - @cam.y\n end", "def origin\n Entities::Point.new(\n (Game::WIDTH - map.pixel_width) / 2,\n (Game::HEIGHT - map.pixel_height) / 2\n )\n end", "def offset_vector=(offset_vector)\n end", "def center_y\n (Graphics.height / TILE_HEIGHT - 1) / 2\n end", "def center\n @center ||= begin\n xs, ys = vertices.transpose\n [xs.inject(:+)/xs.size.to_f, ys.inject(:+)/ys.size.to_f]\n end\n end", "def translate(x, y)\n [ x - bounds.x, y - bounds.y ]\n end", "def coordinateRegionForItems(items, itemsCount)\n r = MKMapRectNull\n (0..itemsCount).each do |i|\n p = MKMapPointForCoordinate(items[i].coordinate)\n r = MKMapRectUnion(r, MKMapRectMake(p.x, p.y, 0.0, 0.0))\n end\n region = MKCoordinateRegionForMapRect(r)\n\n puts region \n\n region.span.latitudeDelta = region.span.latitudeDelta + region.span.latitudeDelta * 0.5\n region.span.longitudeDelta = region.span.longitudeDelta + region.span.longitudeDelta * 0.8\n\n puts region.span.latitudeDelta \n puts region.span.longitudeDelta\n region\n end", "def center_origins\n return if !self.bitmap\n self.ox = self.bitmap.width / 2\n self.oy = self.bitmap.height / 2\n end", "def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n @zoom = args[:zoom] if args.key?(:zoom)\n end", "def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n @zoom = args[:zoom] if args.key?(:zoom)\n end", "def drawmap(map,z=0)\r\nend", "def trans(coord)\n\treturn [coord[0]+600, -coord[1]+350]\nend", "def cent_y\n @spr_y + (@spr_h / 2)\n end", "def modify_image\n if @vertical\n @main_image = @main_image.zooming_v\n else\n @main_image = @main_image.zooming_h\n end\n end", "def scale(factor_x, factor_y=factor_x, &rendering_code); end", "def calc_position_emus(worksheet)\n c_start, r_start,\n xx1, yy1, c_end, r_end,\n xx2, yy2, x_abslt, y_abslt =\n worksheet.position_object_pixels(\n @column_start,\n @row_start,\n @x_offset,\n @y_offset,\n @width * @scale_x,\n @height * @scale_y\n )\n\n # Now that x2/y2 have been calculated with a potentially negative\n # width/height we use the absolute value and convert to EMUs.\n @width_emu = (@width * 9_525).abs.to_i\n @height_emu = (@height * 9_525).abs.to_i\n\n @column_start = c_start.to_i\n @row_start = r_start.to_i\n @column_end = c_end.to_i\n @row_end = r_end.to_i\n\n # Convert the pixel values to EMUs. See above.\n @x1 = (xx1 * 9_525).to_i\n @y1 = (yy1 * 9_525).to_i\n @x2 = (xx2 * 9_525).to_i\n @y2 = (yy2 * 9_525).to_i\n @x_abs = (x_abslt * 9_525).to_i\n @y_abs = (y_abslt * 9_525).to_i\n end", "def position_to_location_and_tile_coords(position)\n ::Demiurge::TiledLocation.position_to_loc_coords(position)\n end", "def zoom_factor\n Zif.position_math(:fdiv, [@cur_w, @cur_h], zoom_unit)\n end", "def lvl_text_coordinates\n return 121, 5, 35, 16\n end", "def pos\r\n { x: @tile.x,\r\n y: @tile.y }\r\n end", "def paint(painted_map, x, y, brush_size)\n return if [x, y].max + brush_size > @size\n y.upto(y + brush_size - 1) do |yy|\n x.upto(x + brush_size - 1) do |xx|\n painted_map [yy][xx] = 1\n end\n end\n end", "def fit_sprite(s, r)\n s.x, s.y = r.x, r.y\n s.zoom_x, s.zoom_y = r.width, r.height\n end", "def calculate_coordinate(size_in_inches)\n return size_in_inches * 144\n end" ]
[ "0.6161229", "0.60563916", "0.60165495", "0.6006493", "0.59475714", "0.59425133", "0.5939935", "0.593446", "0.59197176", "0.59090954", "0.59085965", "0.5879614", "0.58218867", "0.5818909", "0.5802727", "0.5795695", "0.5779449", "0.57459235", "0.5739234", "0.5736272", "0.5729804", "0.57206196", "0.56141853", "0.5609682", "0.56072116", "0.5602997", "0.5590743", "0.55814826", "0.55764943", "0.55585146", "0.55585146", "0.55584794", "0.55557126", "0.5555229", "0.5549716", "0.5542408", "0.55259764", "0.5520343", "0.55182606", "0.5511422", "0.55006784", "0.5496452", "0.54843813", "0.54840755", "0.5482504", "0.54823416", "0.5481661", "0.5475951", "0.5454663", "0.5453284", "0.54525566", "0.5445488", "0.54331946", "0.5430091", "0.54271954", "0.54271954", "0.5421638", "0.5421638", "0.53768903", "0.53735864", "0.53712493", "0.53631073", "0.53280544", "0.5321709", "0.531991", "0.53124833", "0.53032863", "0.52827185", "0.5278861", "0.52768606", "0.5274199", "0.52737594", "0.52721924", "0.526039", "0.52599996", "0.52591014", "0.5252721", "0.5243808", "0.52432424", "0.5235571", "0.5235441", "0.5230164", "0.52231175", "0.5211421", "0.52096146", "0.5203192", "0.5203192", "0.5197822", "0.5196139", "0.51951593", "0.51931965", "0.5191681", "0.5188852", "0.51821107", "0.51746047", "0.5165265", "0.51602757", "0.5156598", "0.51543826", "0.5153751" ]
0.60409784
2
Checks if a point is inside the polygon shape of the terrain, returns true if so
def contains? position # If POI is given instead of location, get location first position = position.location if PointOfInterest === position x = position[0] y = position[1] # Use the raycasting technique to determine if point is inside polygon # We are in 2D, which makes it easier. # We can also choose the direction of the ray, which makes it almost trivial # (Choose ray paralell to x-achis intersections = 0 [vertices, vertices.first].flatten.each_cons(2) do |v1, v2| # Check if we are inside bounding recangle of 2 vertices v1x = v1[0] v1y = v1[1] v2x = v2[0] v2y = v2[1] if (v1y < y and y <= v2y) or (v1y >= y and y > v2y) # check if we are LEFT of or onthe line from v1 to v2 is at this x coordinate cp.polygon(*p.map_vertices.map{|v| v.to_a}.flatten) vx = v2x - v1x vy = v2y - v1y if (x <= v1x and x < v2x) intersections +=1 elsif x >= v1x and x > v2x next else x_line = v1x + vx * (y - v1y) / vy if vy == 0 or vx == 0 or x < x_line intersections += 1 end end end end return intersections.odd? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def point_inside?(point)\n Geom.point_in_polygon_2D(point, hexagon(position, RADIUS), true)\n end", "def inside?(zone)\n inPoly = false\n if zone == nil || zone.count == 0\n return false\n end\n\n lastPointData = Point.new(zone[zone.size-1])\n lastPoint = lastPointData.asMapPoint\n here = self.asMapPoint\n\n zone.each do |point|\n point = Point.new(point).asMapPoint\n\n if (((point.y < here.y) && (lastPoint.y >= here.y)) || ((lastPoint.y < here.y) && (point.y >= here.y)))\n if ((point.x + (((here.y - point.y) / (lastPoint.y - point.y)) * (lastPoint.x - point.x))) < here.x)\n inPoly = !inPoly\n end\n end\n lastPoint = point\n end\n\n inPoly\n end", "def contains_point?(point)\n contains_point = false\n i = -1\n j = @polygon_points.size - 1\n while (i += 1) < @polygon_points.size\n a_point_on_polygon = @polygon_points[i]\n trailing_point_on_polygon = @polygon_points[j]\n if point_is_between_the_ys_of_the_line_segment?(point, a_point_on_polygon, trailing_point_on_polygon)\n if ray_crosses_through_line_segment?(point, a_point_on_polygon, trailing_point_on_polygon)\n contains_point = !contains_point\n end\n end\n j = i\n end\n return contains_point\n end", "def check_polygon\n return false if @points.length < 3\n zpoints = Array.new(@points)\n zpoints += [@points[0], @points[1]]\n side_prev = zcrossproduct(zpoints[0], zpoints[1], zpoints[2])\n for i in 1...(zpoints.length-2)\n side_next = zcrossproduct(zpoints[i], zpoints[i+1], zpoints[i+2])\n return false if (side_prev * side_next < 0)\n end\n return true\n end", "def point_is_inside(point)\n result = false\n vertex1 = @points.length - 1\n for vertex2 in 0...@points.length\n if ((@points[vertex2].y > point.y) != (@points[vertex1].y >= point.y)) && (point.x <= (points[vertex1].x - points[vertex2].x) * (point.y - points[vertex2].y) / (points[vertex1].y - points[vertex2].y) + points[vertex2].x)\n result = !result\n end\n vertex1 = vertex2\n vertex2 += 1\n end\n return result\n end", "def check_interior(polygon, point)\n sum = 0\n polygon.each_index do |i|\n next_i = i + 1\n next_i = 0 if next_i >= polygon.size\n sum += compute_angle(\n [polygon[i][0] - point[0],\n polygon[i][1] - point[1],\n polygon[i][2] - point[2]],\n [polygon[next_i][0] - point[0],\n polygon[next_i][1] - point[1],\n polygon[next_i][2] - point[2]],\n )\n end\n\n (sum >= 2*3.1415926 and sum <= 2*3.1415927) or\n check_border(polygon, point)\n end", "def contains_point?(pt)\n pt.x.between?(left, left + width - 1) &&\n pt.y.between?(top, top + height - 1)\n end", "def is_encloses_point?(point)\n point = Point.new(point[0], point[1]) if point.is_a?(Array)\n raise TypeError, 'Must pass only Point objects' unless point.is_a?(Point)\n\n return false if vertices.include?(point)\n\n sides.each do |s|\n return false if s.contains?(point)\n end\n\n # move to point, checking that the result is numeric\n lit = []\n vertices.each do |v|\n lit << v - point\n end\n\n poly = Polygon.new(*lit)\n # polygon closure is assumed in the following test but Polygon removes duplicate pts so\n # the last point has to be added so all sides are computed. Using Polygon.sides is\n # not good since Segments are unordered.\n args = poly.vertices\n indices = (-args.length..0).to_a\n\n if poly.is_convex?\n orientation = nil\n indices.each do |i|\n a = args[i]\n b = args[i + 1]\n test = ((-a.y)*(b.x - a.x) - (-a.x)*(b.y - a.y)) < 0\n \n if orientation.nil?\n orientation = test\n elsif test != orientation\n return false\n end\n end\n\n return true\n end\n\n hit_odd = false\n p1x, p1y = args[0].x, args[0].y\n indices[1..-1].each do |i|\n p2x, p2y = args[i].x, args[i].y\n\n if [p1y, p2y].min < 0 && [p1y, p2y].max >= 0 && \n [p1x, p2x].max >= 0 && p1y != p2y\n\n xinters = (-p1y)*(p2x - p1x)/(p2y - p1y) + p1x\n hit_odd = !hit_odd if p1x == p2x or 0 <= xinters \n end \n\n p1x, p1y = p2x, p2y\n end\n\n return hit_odd\n end", "def point_is_inside_poly(poly_verts, point)\n count = poly_verts.count\n intersections = 0\n\n poly_verts.each_with_index do |face_start, i|\n face_end = poly_verts[(i+1) % count]\n\n if line_line_intersection(V.new(0, 0), point, face_start, face_end)\n intersections += 1\n end\n end\n\n !intersections.modulo(2).zero?\n end", "def include?(pnt)\n pnt.lat >= south && pnt.lng >= west && pnt.lat < north && pnt.lng < east\n end", "def isInside(_pos)\n return @shape.insidePoint?(_pos) ;\n end", "def point_in_polygon(p, poly)\n UNIT_SQUARE.position.set(p)\n T_RESPONSE.clear\n result = test_polygon_polygon(UNIT_SQUARE, poly, T_RESPONSE)\n result = T_RESPONSE.a_in_b if result\n result\n end", "def contains?(point)\n contains_xy?(point.x, point.y)\n end", "def contains?(point)\n point.inside?(self)\n end", "def includes_point?(point)\n horizontal_extent.include?(point.x) && vertical_extent.include?(point.y)\n end", "def contains_point(point, include_border=false)\n point.x.between?(@x, self.right) && point.y.between?(y, self.bottom) unless include_border\n (point.x >= @x) && (point.x <= self.right) && (point.y >= @y) && (point.y <= self.bottom)\n end", "def in_bounding_box?(point, box)\n if point.lon > box.west_lon and point.lon < box.east_lon and point.lat < box.north_lat and point.lat > box.south_lat\n return true\n else\n return false \n end\n end", "def lies_outside? point\n\t\tx = point.x\n\t\ty = point.y\n\n\t\tx < 0 or x > @dimension or \\\n\t\ty < 0 or y > @dimension\n\tend", "def is_same_polygon?(entity, player)\n return entity == player\n end", "def test_is_polygon_with_polygon\n m = Sketchup.active_model\n ents = m.entities\n\n # Create a polygon\n center = [0, 0, 0]\n normal = [0, 0, 1]\n radius = 20\n nsides = 8\n ents.add_ngon center, normal, radius, nsides\n\n # Check poly edges\n m.entities.each do |e|\n if e.is_a? Sketchup::Edge and e.curve.respond_to? 'is_polygon?'\n assert_equal(true, e.curve.is_polygon?,\n 'Curve of polygon edge should be polygon.')\n end\n end\n end", "def contains p\n naive_walls = Road.naive_walls @n0.pos, @n1.pos\n a = naive_walls[0].p0\n b = naive_walls[0].p1\n c = naive_walls[1].p1\n d = naive_walls[1].p0\n p.in_convex_poly([a, b, c, d])\n end", "def is_out_of_boundary?(point)\n point.x < 0 || point.y < 0 || point.x >= @dimension || point.y >= @dimension\n end", "def contains_point?(point)\n x, y = point.x, point.y\n tuples = @points.zip(@points[1..-1] + [@points[0]])\n crossings =\n tuples.select do |a, b|\n (b.y > y != a.y > y) && (x < (a.x - b.x) * (y - b.y) / (a.y - b.y) + b.x)\n end\n\n crossings.size % 2 == 1\n end", "def check_interior(check, point1, point2, point3)\n # Points on a vertex cannot be interior; due to precision issues, we\n # need to make an explicit check for this\n if (check.same?(point1) || check.same?(point2) || check.same?(point3))\n return false\n end\n # Unlike the above function, this can be negative; in fact, if the\n # triangle is wound counter-clockwise (I think) it needs to be for\n # the rest of the math to work out\n area = (point1.x * (point2.y - point3.y) +\n point2.x * (point3.y - point1.y) +\n point3.x * (point1.y - point2.y))/2\n s = 1 / (2 * area) * (point1.y * point3.x - point1.x * point3.y +\n (point3.y - point1.y) * check.x +\n (point1.x - point3.x)*check.y);\n t = 1 / (2 * area) * (point1.x * point2.y - point1.y * point2.x +\n (point1.y - point2.y) * check.x +\n (point2.x - point1.x)*check.y);\n if (s > 0 && t > 0 && 1 - s - t > 0)\n return true\n end\n return false\nend", "def inArea lat, lon\n if(!inBounds(lat,lon))\n false\n else\n lastpoint = border_points.last\n y2 = 100\n x2 = 200\n a = (y2 - lat)/(x2 - lon)\n b = lat - a*lon\n icount = 0\n border_points_minus_removed.each_with_index do |point|\n\tif(intersect(lastpoint, point, a, b, lon, x2))\n\t icount += 1\n\tend\n\tlastpoint = point\n end\n (icount % 2) == 1\n end\n end", "def inbounds?(point)\n return false if point.x < 0\n return false if point.x >= @grid_width\n return false if point.y < 0\n return false if point.y >= @grid_height\n return true\n end", "def contains(v)\n if @area == (Tri.area(v, @points[:a], @points[:c]) + \n Tri.area(v, @points[:b], @points[:a]) + \n Tri.area(v, @points[:c], @points[:b]))\n return true\n else\n return false\n end\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 contains?(p)\n areaABP = Triangle.new(a, b, p).area\n areaACP = Triangle.new(a, c, p).area\n areaBCP = Triangle.new(b, c, p).area\n (areaABP + areaACP + areaBCP - area < 0.1)\n end", "def polygonal_checker(a,b,num)\n\tif b*b+4*a*num < 0 then\n\t\tfalse\n\telse\n\t\tn = (-b+Math.sqrt(b*b+4*a*num)) / (a*2);\n\t\tn.to_i.to_f == n;\n\tend\nend", "def at_boundary?\n\t\tif @location.x == 0 || @location.x == @dimension-1 || @location.y == 0 || @location.y == @dimension-1\n\t\t\ttrue\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend", "def has_point(x, y)\n is_negative = (x < 0 or y < 0)\n is_greater_than_dimensions = (x > @width or y > @height)\n\n if is_negative or is_greater_than_dimensions\n result = false\n puts \"[#{x},#{y}] is Outside of Grid, Robot will ignore command\"\n else\n result = true\n end\n\n return result;\n end", "def within?(x, y)\n (x >= 0) && (x < height) && (y >= 0) && (y < height)\n end", "def intersects_polygon?(coordinates, lat_start, lon_start, lat_end, lon_end)\n prev = coordinates.last\n does_intersect = false\n\n # checks if the line segment between start and end coordinates intersects any line segments in the polygon\n coordinates.each do |coord|\n a_lat = prev['lat']\n a_lon = prev['lon']\n b_lat = coord['lat']\n b_lon = coord['lon']\n\n # line segment intersection as described by http://stackoverflow.com/a/565282\n cmp_x, cmp_y = (lat_start - a_lat), (lon_start - a_lon)\n r_x, r_y = (b_lat - a_lat), (b_lon - a_lon)\n s_x, s_y = (lat_end - lat_start), (lon_end - lon_start)\n \n cmpxr = (cmp_x * r_y) - (cmp_y * r_x)\n cmpxs = (cmp_x * s_y) - (cmp_y * s_x)\n rxs = (r_x * s_y) - (r_y * s_x)\n \n rxsr = 1.0 / rxs\n t = cmpxs * rxsr\n u = cmpxr * rxsr\n \n if ((t >= 0.0) && (t <= 1.0) && (u >= 0.0) && (u <= 1.0))\n does_intersect = true\n end\n\n\n prev = coord\n end\n\n return does_intersect\n end", "def formPolygon?(lines)\n endpoints = {}\n\n lines.each do |l|\n [l.p1, l.p2].each do |p|\n endpoints[p.to_s] ||= []\n endpoints[p.to_s] << l\n end\n end\n\n # the algorithm is to follow the points until you end up at one that \n # you've already seen\n l = lines.first\n p = l.p1\n op = p\n begin\n ls = endpoints[p.to_s]\n return false if ls.nil?\n endpoints.delete p.to_s\n\n # get the line that we weren't on before\n ls.delete(l)\n l = ls[0]\n return false if l.nil? # this means that there weren't 2 lines with endpoint p\n\n # get the other point on that line\n p = (l.p1 == p) ? l.p2 : l.p1\n end until p == op\n\n return endpoints.length == 0\n end", "def contains_point(x,y,z)\n behind = true\n @planes.each{|p|\n behind = (0 >= p.distance_to_point(x,y,z))\n break if not behind\n }\n return behind\n end", "def include?(point)\r\n (point - @pos).abs <= @radius\r\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 contains_position?(point)\n translated_position = absolute_position\n\n # TODO: Sizing ignores zoom\n # TODO: Disgustingly long line\n point.x >= translated_position.x && point.x <= translated_position.x + width && point.y >= translated_position.y && point.y <= translated_position.y + height\n end", "def test_is_polygon_api_example\n # For backwards compatibility, only run test if curve instance has\n # is_polygon? method\n if Sketchup::Curve.new().public_methods.include? 'is_polygon?'\n assert_nothing_raised do\n # Create a polygon and check its edge\n ents = Sketchup.active_model.entities\n ents.add_ngon [0, 0, 0], [0, 0, 1], 10, 6\n curve = nil\n ents.each { |e| curve = e.curve if e.is_a? Sketchup::Edge }\n is_poly = curve.is_polygon?\n end\n end\n end", "def is_within(layer)\n if !layer.nil?\n layerStartsWithinXBoundaries = self.x > layer.x && (self.x + self.width) < (layer.x + layer.width)\n layerStartsWithinYBoundaries = self.y > layer.y && (self.y + self.height) < (layer.y + layer.height)\n\n return layerStartsWithinXBoundaries && layerStartsWithinYBoundaries\n end\n\n false\n end", "def is_valid?\n return is_closed? && (@polygon_points.length >= 3)\n end", "def is_valid?\n return is_closed? && (@polygon_points.length >= 3)\n end", "def is_wall?(point)\n objects.any? do |object|\n object.location == point && object.is_wall?\n end\n end", "def is_closed?\n return @polygon_points.first == @polygon_points.last\n end", "def is_closed?\n return @polygon_points.first == @polygon_points.last\n end", "def overlaps? point\n inside_top_left?(point) && inside_bottom_right?(point)\n end", "def is_inside(shape)\n shape.surrounds(self)\n end", "def in?(*p)\n point = p.to_point\n point.in?(self.computed)\n end", "def surrounds(shape)\n shape.points.each do |point|\n return false unless point_is_inside(point)\n end\n return true\n end", "def inside?(x, y)\n x >= 0 && x < @width && y >= 0 && y < @height\n end", "def include?(point)\n Math.sqrt((point.x - @middle.x)**2 + (point.y - @middle.y)**2) <= @radius\n end", "def contains_point?(x,y)\n contains_x = x.between?(left, right)\n contains_y = y.between?(bottom, top)\n return (contains_x && contains_y)\n end", "def under_point?(mouse_x, mouse_y)\n border.contains?(mouse_x, mouse_y)\n end", "def point1d?(any)\n any.int?\nend", "def coord_within_map?(array)\n array.map!(&:to_i)\n map = Socrata::Map.all.last\n if array.first <= map.x && array.first >= 0 && array.last <= map.y && array.last >= 0\n true\n else\n false\n end\n end", "def lenient_multi_polygon_assertions?\n @zfactory.lenient_multi_polygon_assertions?\n end", "def in?(px, py)\n ix, iy = @max+100, @max+100\n nbintersections = 0\n @points.each_index do |index|\n ax, ay = *@points[index]\n bx, by = *@points[(index + 1) % @points.length]\n nbintersections += intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n end\n return (nbintersections%2 == 1)\n end", "def check_region(coords, region_coordinates)\n\t\t\tcoords_to_check = Locations::Coordinates.new(coords)\n\t\t\tcoords_to_check.point_in_polygon?(region_coordinates)\n\t\tend", "def pass_boundary_check?(coordinate)\n coordinate.each do |c|\n if c.is_i?\n if c < 0\n return false\n elsif c > @map.my_matrix.length-1\n return false\n elsif c > @map.my_matrix[0].length-1\n return false\n end\n end\n end\n true\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 shape_include?(shape, point)\n if shape1d?(shape) and point1d?(point) then shape_include_1d?(shape, point)\n elsif shape2d?(shape) and point.point2d? then shape_include_2d?(shape, point)\n else check_pre(false)\n end\nend", "def contains?(x, y)\n self_area = triangle_area(@x1, @y1, @x2, @y2, @x3, @y3)\n questioned_area =\n triangle_area(@x1, @y1, @x2, @y2, x, y) +\n triangle_area(@x2, @y2, @x3, @y3, x, y) +\n triangle_area(@x3, @y3, @x1, @y1, x, y)\n\n questioned_area <= self_area\n end", "def contains?(x, y)\n self_area = triangle_area(@x1, @y1, @x2, @y2, @x3, @y3)\n questioned_area =\n triangle_area(@x1, @y1, @x2, @y2, x, y) +\n triangle_area(@x2, @y2, @x3, @y3, x, y) +\n triangle_area(@x3, @y3, @x1, @y1, x, y)\n\n questioned_area <= self_area\n end", "def out_of_bounds?\n (0..@grid_size[0]).cover?(@coordinates[0]) &&\n (0..@grid_size[1]).cover?(@coordinates[1])\nend", "def a_point_belongs_to_ship(a_point)\n\toccupied_points.any? { |point| point.is_equal(a_point) } \n end", "def in_world?\n return false if lat < -90 || lat > 90\n return false if lon < -180 || lon > 180\n true\n end", "def supported_point? point\n r,c,h = point[0], point[1], point[2]\n h == 0 || occupied?([r,c,h-1])\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 point_in_rectangle(point_x, point_y, first_x, first_y, second_x, second_y)\r\n\t\tif point_x.between?(first_x, second_x) and point_y.between?(first_y, second_y)\r\n\t\t\treturn true\r\n\t\tend\r\n\tend", "def point_in_rectangle(point_x, point_y, first_x, first_y, second_x, second_y)\r\n\t\tif point_x.between?(first_x, second_x) and point_y.between?(first_y, second_y)\r\n\t\t\treturn true\r\n\t\tend\r\n\tend", "def isInside(_pos)\n _pos = Geo2D::Point::sureGeoObj(_pos) ;\n distance = centerPos().distanceTo(_pos) ;\n return distance < @radius ;\n end", "def is_latlng?\n coordinates && coordinates.valid?\n end", "def shape_include?(shape, point)\n check_pre((\n (shape?(shape)) and\n (point?(point))\n ))\n\n shape.include?(point)\nend", "def left_corner_inside?(rectangle, point)\n return ((point[0] >= rectangle[0][0] and\n point[0] < rectangle[1][0]) and\n (point[1] >= rectangle[0][1] and\n point[1] < rectangle[1][1]))\nend", "def isBoundedBy(coord)\n inBox(getBox([nw_lon,nw_lat],[se_lon,se_lat]),coord)\n end", "def point?(x)\n x.int? || x.point2d?\nend", "def enemyContainsPoint?(x, y)\n @DobjectArray.each do |object|\n if object.is_a? Enemy and (object.x + object.width / 2 - x).abs <= object.width / 2 and (object.y - object.height / 2 - y).abs <= object.height / 2\n object.loseHealth\n return true\n end\n end\n return false\n end", "def test_inside_non_overlapping()\n shape_ds = Gdal::Ogr.open('../../ogr/data/testpoly.shp')\n shape_lyr = shape_ds.get_layer(0)\n\n shape_lyr.set_spatial_filter_rect( -10, -130, 10, -110 )\n assert(check_features_against_list( shape_lyr, 'FID',\n [ 13 ] ))\n end", "def collide_point?(point)\n distance = Math.hypot(point[0]-@rect.center[0],point[1]-@rect.center[1])\n distance < @rect.w/2\n end", "def resembles_latlng?\n !!coordinates\n end", "def intersects(shape)\n p1 = shape.points.length - 1\n for p2 in 0...shape.points.length\n p3 = @points.length - 1\n for p4 in 0...@points.length\n return true if segments_intersection(shape.points[p1], shape.points[p2], @points[p3], @points[p4])\n p3 = p4\n p4 += 1\n end\n p1 = p2\n p2 += 1\n end\n return false\n end", "def poly?\n self.class.poly?\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 containsOrigin(f)\n\n\t#Formats input into a size 3 array of the points\n\tvalues = f.split(\",\").map{|x| Integer(x)}\n\tpoints = []\n\tfor i in BOTTOM..TOP\n\t\tpoints << [values[i * 2], values[i * 2 + 1]]\n\tend\n\n\treturn false if not inRectangle(points)\n\t#Origin is now now guaranteed to be in a y position where it is necessary to check using bounds/slopes\n\t#If the origin was completely below or above the triangle, the generated slopes could be incorrect\n\n\t#Sorts the input by Y Coordinate\n\tpointsByY = points.sort{|a, b| a[Y_COORDINATE] <=> b[Y_COORDINATE]}\n\n\n\t#target is bottom or top -- bottom if the origin is between the mid/bottom or top if the origin is mid/top\n\ttarget = pointsByY[MID][Y_COORDINATE] >= BOTTOM ? \"bottom\" : \"top\"\n\t#directPoint is the point beyond the origin from the midpoint's perspective\n\tdirectPoint = target == 'top' ? pointsByY[TOP] : pointsByY[BOTTOM]\n\t#longpoint is the point behind the midpoint relative to the origin\n\tlongPoint = target == 'top' ? pointsByY[BOTTOM] : pointsByY[TOP]\n\n\t#directSlope and longSlope are the slopes from the midpoint to the directPoint and longPoint respectively\n\tdirectSlope = (pointsByY[MID][X_COORDINATE] - directPoint[X_COORDINATE]) * 1.0 / (pointsByY[MID][Y_COORDINATE] - directPoint[Y_COORDINATE])\n\tlongSlope = (longPoint[X_COORDINATE] - directPoint[X_COORDINATE]) * 1.0 / (longPoint[Y_COORDINATE] - directPoint[Y_COORDINATE])\n\n\t#walls are the x-wise bounds of the triangle at the y coordinate of the origin\n\tdirectWall = directPoint[X_COORDINATE] - (directPoint[Y_COORDINATE] * directSlope)\n\tlongWall = directPoint[X_COORDINATE] - (directPoint[Y_COORDINATE] * longSlope)\n\n\tleftWall = (directWall > longWall ? longWall : directWall)\n\trightWall = (directWall > longWall ? directWall : longWall)\n\n\treturn (leftWall < ORIGIN[X_COORDINATE] and ORIGIN[X_COORDINATE] < rightWall)\nend", "def test_contains_point_true\n\n bbox = Geom::BoundingBox.new\n bbox.add Geom::Point3d.new(0,0,0)\n bbox.add Geom::Point3d.new(10,10,10)\n\n point = Geom::Point3d.new(5,5,5)\n assert_equal(true, bbox.contains?(point),\n 'Failed in test_contains_point_true: center' )\n\n point = Geom::Point3d.new(0,0,0)\n assert_equal(true, bbox.contains?(point),\n 'Failed in test_contains_point_true: min' )\n\n point = Geom::Point3d.new(10,10,10)\n assert_equal(true, bbox.contains?(point),\n 'Failed in test_contains_point_true: max' )\n end", "def inside_rect? outer, tolerance = 0.0\n Geometry.inside_rect? self, outer, tolerance\n end", "def inRectangle(points)\n\tpointsY = points.sort{|a, b| a[Y_COORDINATE] <=> b[Y_COORDINATE]}\n\treturn false if pointsY[0][Y_COORDINATE] > ORIGIN[Y_COORDINATE]\n\treturn false if pointsY[2][Y_COORDINATE] < ORIGIN[Y_COORDINATE]\n\tpointsX = points.sort{|a, b| a[X_COORDINATE] <=> b[X_COORDINATE]}\n\treturn false if pointsX[0][X_COORDINATE] > ORIGIN[X_COORDINATE]\n\treturn false if pointsX[2][X_COORDINATE] < ORIGIN[X_COORDINATE]\n\treturn true\nend", "def under_point?(mouse_x, mouse_y)\n mouse_x > x - PAD && mouse_x < x + width + PAD && mouse_y > y - PAD && mouse_y < y + height + PAD\n end", "def check_area(point1, point2, point3)\n area = (point1.x * (point2.y - point3.y) +\n point2.x * (point3.y - point1.y) +\n point3.x * (point1.y - point2.y))/2\n if (area < 0)\n area = -area\n end\n return area\nend", "def is_point?\n point_data = RGeo::GeoJSON.decode(params.to_json)\n if point_data.blank? || point_data.geometry.geometry_type.to_s != 'Point'\n json_response(nil, :unprocessable_entity, :incompatible_geomtry)\n end\n end", "def inBox(box, point)\n # Make a box with the point and the SE corner of the box.\n # Make another box with the point and the NE Corner of the box.\n # Combine the new boxes.\n # The point is inside the given box, if the area of the combined boxes is\n # equal (or a little less than due to roundoff error) than the area of the given box.\n box1 = getBox(point,box[1])\n box2 = getBox(box[1],point)\n box3 = combineBoxes( box1, box2 )\n return area(box3) <= area(box)\n end", "def in_bounds?(point, scr_height, scr_width)\n point[0].between?(0, scr_height-1) && point[1].between?(0, scr_width-1)\nend", "def inside?(mouse_x, mouse_y)\n pos_x = @x * @width\n pos_y = @y * @height\n mouse_x >= pos_x && mouse_x <= pos_x + @width && \\\n mouse_y >= pos_y && mouse_y <= pos_y + @height\n end", "def coordinates_inside_box?(x_idx, y_idx)\n (x_idx >= 0 && x_idx < width) && (y_idx >= 0 && y_idx < height)\n end", "def exists_at?(coords)\n coords.all? { |c| c.between?(0, 7) }\n end", "def under_point?(mouse_x, mouse_y)\n mouse_x > x - PADDING_X and mouse_x < x + @width + PADDING_X and\n mouse_y > y - PADDING_Y and mouse_y < y + @height + PADDING_Y\n end", "def in?(x, y)\n ((x-@x)**2) + ((y-@y)**2) <= (@r**2)\n end", "def inside_circle?(point, radius)\n (self.distance_to(point) <= radius)\n end", "def polygon\n respond_to?(:constituencyAreaExtent) ? constituencyAreaExtent : []\n end" ]
[ "0.78786373", "0.75921226", "0.75572115", "0.7374165", "0.7271648", "0.7168096", "0.70395756", "0.6995843", "0.69282925", "0.6861745", "0.67810047", "0.6733664", "0.6679317", "0.6673137", "0.66147876", "0.6575991", "0.6575082", "0.6569133", "0.6556269", "0.6550415", "0.6494455", "0.64629245", "0.6447798", "0.64176255", "0.64031297", "0.6400552", "0.6384468", "0.6378542", "0.6331243", "0.6321046", "0.6284971", "0.62569314", "0.6249866", "0.6232546", "0.62188053", "0.62123215", "0.6187906", "0.61790085", "0.61686665", "0.61602", "0.6157501", "0.6139416", "0.6139416", "0.6130755", "0.611783", "0.611783", "0.6110791", "0.6098689", "0.6097287", "0.60955966", "0.6079153", "0.60710996", "0.6071056", "0.6065964", "0.6040966", "0.6038585", "0.6026876", "0.6017502", "0.60027725", "0.5999008", "0.59917384", "0.5977836", "0.59645885", "0.59645885", "0.5962657", "0.59587556", "0.5958344", "0.5957368", "0.5931628", "0.5928831", "0.5928831", "0.5919513", "0.59145874", "0.59071356", "0.5894045", "0.58926404", "0.5890967", "0.5884693", "0.5878744", "0.586651", "0.58553165", "0.5850992", "0.58360165", "0.5828381", "0.5812345", "0.5811693", "0.58074725", "0.58042264", "0.57989514", "0.5789299", "0.57809347", "0.5777772", "0.57770854", "0.5774812", "0.576783", "0.57336247", "0.571661", "0.5709852", "0.5691212", "0.5688086" ]
0.68823504
9
Calculates the distance from self (polygon) to a vector or POI
def distance position return -1 if contains? position # If POI is given instead of location, get location first position = position.location if PointOfInterest === position # Set a ridiculous min distance. Any way around this? min_dist = 999999999 # Iterate over every edge-point (vertex) vertices.each_cons(2) do |vertices| c_v = vertices[0] o_v = vertices[1] r = ((c_v - o_v) * (position - o_v)) / (position - o_v).magnitude if r < 0 then dist = (position - o_v).magnitude elsif r > 1 then dist = (c_v - position).magnitude else dist = (position - o_v).magnitude ** 2 - r * (c_v - o_v).magnitude ** 2 end min_dist = [dist, min_dist].min end min_dist end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def distance_to(pt)\n if pt.is_valid?\n vect = GeoFunctions.point_minus_point(pt,@origin)\n GeoFunctions.vector_dot_product(vect, @z_axis)\n else\n nil\n end\n end", "def distance_to(other)\n pyth(self.x, self.y, other.x, other.y)\n \n# Math.sqrt((other.x - self.x) ** 2 + (other.y - self.y) ** 2)\n end", "def distance(vector)\n Math.sqrt((@x - vector.x)**2 + (@y - vector.y)**2)\n end", "def distance(other_point)\n ((self.x - other_point.x) ** 2 + (self.y - other_point.y) ** 2) ** 0.5\n end", "def distance obj\n\t\t\ta = obj.x-@x\n\t\t\tb = obj.y-@y\n\t\t\tc = Math.sqrt(a**2 + b**2)\t\n\t\tend", "def distance(other)\n\t\treturn ((other.x-@x).abs + (other.y-@y).abs + (other.z-@z).abs)/2\n\tend", "def distance x1, y1, x2, y2\n ((x1-x2)**2+(y1-y2)**2)**0.5\nend", "def distance_to(p)\n x_diff = self.x-p.x\n y_diff = self.y-p.y\n return Math.sqrt(x_diff*x_diff + y_diff*y_diff)\n end", "def distance(other)\n other = Point.new(other[0], other[1]) if other.is_a?(Array)\n\n if other.is_a?(Point)\n dist = BigDecimal('Infinity')\n \n sides.each do |side|\n current = side.distance(other)\n if current == 0\n return 0\n elsif current < dist\n dist = current\n end\n end\n \n return dist\n\n elsif other.is_a?(Polygon) && self.is_convex? && other.is_convex?\n return do_poly_distance(other)\n end\n\n raise TypeError, \"Distance not handled for #{ other.class }\"\n end", "def dist(v)\n dx = v.x - @x\n dy = v.y - @y\n Math.sqrt(dx*dx + dy*dy)\n end", "def distance(other_vector)\n dx = @x - other_vector.x\n dy = @y - other_vector.y\n Math.sqrt(dx ** 2 + dy ** 2)\n end", "def distance_to(cell)\n (@x - cell.x).abs + (@y - cell.y).abs\n end", "def distance(pt)\n raise ArgumentError unless is_point?(pt)\n return sqrt((pt.first - @xy.first) ** 2 + (pt.last - @xy.last) ** 2)\n end", "def dist other\n case other\n when Atom\n pos = other.pos(false)\n when Surface\n return other.dist(self)\n else\n pos = pos.to_v \n end\n if @units == :angstrom\n (@pos - pos).magnitude\n else\n @cell.dist(self, other)\n end\n end", "def distance point\n dx = @x - point.x\n dy = @y - point.y\n Math.sqrt(dx**2 + dy**2)\n end", "def distance(other_point)\n\t\t((@x - other_point.x)**2 + (@y - other_point.y)**2)**0.5\n\tend", "def calculate_gd(vector)\n gd = 0.0\n\n vector.each do |key,value|\n gd += (@vcentroid[key].to_f-value.to_f) * (@vcentroid[key].to_f-value.to_f)\n end\n\n gd = Math.sqrt(gd)\n end", "def distanceCalculation(x1, y1, _z1, x2, y2, z2)\n Math.sqrt((x1 - x2)**2 + (y1 - y2)**2 + (y1 - z2)**2)\n end", "def distance_sq(vector2)\n dx = vector2.x - @x\n dy = vector2.y - @y\n dx * dx + dy * dy\n end", "def distance(*vertex) v = vertex.extract_vector3i!; Math.sqrt(((v[0]-x) ** 2) + ((v[1]-y) ** 2 ) + ((v[2]-z) ** 2)) end", "def distance(pt)\n x2, y2 = pt\n must_be_number(x2, 'pt.x')\n must_be_number(y2, 'pt.y')\n x1, y1 = xy\n hypot(x2 - x1, y2 - y1)\n end", "def distance_to(loc2)\n self.point.ellipsoidal_distance(loc2.point)/1000\n end", "def distance(point2)\n end", "def distance(p1,p2)\ndelta_x = p1[0] - p2[0]\ndelta_y = p1[1] - p2[1]\n\nMath.sqrt(delta_x ** 2 + delta_y **2)\n\nend", "def point_point_distance(a, b)\n (((a.x - b.x) ** 2 + (a.y - b.y) ** 2) ** 0.5).abs\n end", "def distance_between_points(a, b)\n Math.sqrt( (b.x - a.x)**2 + (b.y - a.y)**2 ).round(6)\nend", "def distance_to(point)\n d=Ubiquity::Geoformulas.distance self.lat, self.lon, point.lat, point.lon\n if self.elems && self.elems.has_key?('ele') && point.elems.has_key?('ele')\n d=Ubiquity::Geoformulas.distance_correction d, self.elems['ele'], point.elems['ele']\n end\n d\n end", "def distance\n # we use memoization because calculating distance is expensive\n @distance ||= begin\n self.points.inject(nil) do |a, p|\n new_pt = p\n if a\n last_pt = Ubiquity::Point.new(a[:last_lat], a[:last_lon], {'ele' => a[:last_ele]})\n d = last_pt.to new_pt\n a[:dist] += d\n else\n a=Hash.new\n a[:dist]=0\n end\n a[:last_lat]=new_pt.lat\n a[:last_lon]=new_pt.lon\n a[:last_ele]=new_pt.elems['ele']\n a\n end[:dist]\n end\n end", "def distance(vector2)\n Math.sqrt(distance_sq(vector2))\n end", "def distance_to(other)\n Math.sqrt((0..(self.dimension_count-1)).map {|d| (other.value(d) - self.value(d)) ** 2 }.reduce(&:+))\n end", "def distance_to(coord)\n @vector.cross_vector.normal.dot_product(coord - @start)\n end", "def distance_to(point3)\n Math.sqrt(((@x-point3.x)**2)+((@y-point3.y)**2)+((@z-point3.z)**2))\n end", "def distance(x1,y1,x2,y2)\n return ((x2 - x1)**2 + (y2 - y1)**2)**0.5\nend", "def distCalc(point1, point2)\n first = ((point2[:x] - point1[:x]) **2)\n second = ((point2[:y] - point1[:y]) **2)\n sum = (first + second)\n dist = Math.sqrt(sum)\n return dist\nend", "def distance(point)\n Math.hypot(point.x - x, point.y - y)\n end", "def distance_to_line(line)\n numer = Vector.construct_with_two_points(self, line.point).cross_product(line.vector)\n numer.length / line.vector.length\n end", "def distance(p0,p1,p2)\r\n if p1.lat == p2.lat and p1.lng == p2.lng\r\n out = Math.sqrt(((p2.lat - p0.lat)**2) + ((p2.lng - p0.lng)**2))\r\n else\r\n u = ((p0.lat - p1.lat)*(p2.lat - p1.lat)+(p0.lng - p1.lng)*(p2.lng - p1.lng))/\r\n (((p2.lat - p1.lat)**2) + ((p2.lng - p1.lng)**2))\r\n if u <= 0\r\n out = Math.sqrt( ((p0.lat - p1.lat)**2 ) + ((p0.lng - p1.lng)**2) )\r\n end\r\n if u >= 1\r\n out = Math.sqrt(((p0.lat - p2.lat)**2) + ((p0.lng - p2.lng)**2))\r\n end\r\n if 0 < u and u < 1\r\n out = Math.sqrt( ((p0.lat-p1.lat-u*(p2.lat-p1.lat))**2) +\r\n ((p0.lng-p1.lng-u*(p2.lng-p1.lng))**2) )\r\n end\r\n end\r\n return out\r\n end", "def distance\n distance = 0\n (@path.size - 1).times { |i| distance += Vertex.euclidean_distance(@path[i], @path[i+1]) }\n return distance\n end", "def length\n Math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))\n end", "def distance(point1, point2)\n # square root of (x2-x1) squared + (y2-y1) squared\n Math.sqrt(((point2[0]-point1[0])**2)+((point2[1]-point1[1])**2))\nend", "def distance_to(other)\n point.distance_to(other)\n end", "def distance(a, b)\n (a.x - b.x).abs + (a.y - b.y).abs\n end", "def distance_between(city_1, city_2)\n Math.hypot(city_2.x - city_1.x, city_2.y - city_1.y)\nend", "def distance\n self.distance_from(@origin) * 1.609344\n end", "def dist (x1, y1, x2, y2)\n return (x1 - x2) ** 2 + (y1 - y2) ** 2\nend", "def distance_to ultima_posicao_da_vitima, ultima_posicao_do_aggressor\n\n # cria dois objetos da classe location, com a posicao da vitima e agressor\n loc_agressor = Loc::Location[ultima_posicao_do_aggressor.latitude.to_d, ultima_posicao_do_aggressor.longitude.to_d]\n loc_vitima = Loc::Location[ultima_posicao_da_vitima.latitude.to_d, ultima_posicao_da_vitima.longitude.to_d]\n \n loc_vitima.distance_to loc_agressor\n\n end", "def distance object\n GeographyHelper.distance latitude, longitude, object.latitude, object.longitude\n end", "def distance(x1, y1, x2, y2)\n Math.sqrt((y2 - y1)**2 + (x2 - x1)**2)\n end", "def cross_length(other)\n # cross(other).magnitude\n\n # It is more efficient to not create a new Vector object since we are only returning \n # a scalar value \n new_x = (@y * other.z) - (@z * other.y)\n new_y = (@z * other.x) - (@x * other.z)\n new_z = (@x * other.y) - (@y * other.x)\n\n Math.sqrt(new_x ** 2 + new_y ** 2 + new_z ** 2)\n end", "def distance\n distance = 0\n distance_2d = 0\n elev_change = 0\n num_waypoints = 0\n if @waypoints.nil? then self.load_processed_waypoints end\n ext_waypoints = self.extrapolated_waypoints()\n for waypoint in ext_waypoints do\n if waypoint.length < 3\n waypoint[2] = get_elevation(waypoint[0],waypoint[1])\n end\n end\n for i in 1..ext_waypoints.length-1\n waypointA = ext_waypoints[i-1]\n waypointB = ext_waypoints[i]\n #num_waypoints += 1 + sub_waypoints(waypointA, waypointB)\n elevation_diff = (waypointB[2]-waypointA[2])\n distance_flat = waypoint_distance(waypointA, waypointB)\n distance_3d = Math.sqrt(distance_flat**2 + elevation_diff**2)\n #pp [distance_3d, elevation_diff, distance_flat]\n distance += distance_3d\n distance_2d += distance_flat\n elev_change += elevation_diff.abs\n end\n return [distance, elev_change, distance_2d]\n \n end", "def distance(other)\n other = Point.new(other[0], other[1]) if other.is_a?(Array)\n raise TypeError, \"Distance between Line and #{ other.class } is not defined\" unless other.is_a?(Point)\n\n return 0 if self.contains?(other)\n self.perpendicular_segment(other).length\n end", "def distance_to_squared p\n dx = p.x - x\n dy = p.y - y\n dx * dx + dy * dy\n end", "def distSq(v)\n dx = v.x - @x\n dy = v.y - @y\n dx*dx + dy*dy\n end", "def euclidian_distance(point)\n Math.hypot((point.x - x),(point.y - y))\n end", "def distance(a, b)\n Math.sqrt(((a.x - b.x) ** 2) + ((a.y - b.y) ** 2).abs)\n end", "def euclidian_distance(point)\r\n Math.sqrt((point.x - x)**2 + (point.y - y)**2)\r\n end", "def distance\n distance = 0\n @solution.each { |route| distance += route.distance }\n return distance\n end", "def euclidean_distance_to(point)\n if self.dimensions != point.dimensions\n raise HonorRoll::IncompatibleDimensionsError\n end\n coord_pairs = self.coords.zip point.coords\n Math.sqrt coord_pairs.map{ |p| (p[0] - p[1])**2 }.reduce(:+)\n end", "def points\n object.polygon.points\n end", "def distance_to(n)\n return 0 unless n\n @@cache[self.object_id][n.object_id] ||= Math.sqrt((n.x - @x)**2 + (n.y - @y)**2)\n end", "def distance_to(position)\n\t\t\tMath.sqrt((position.x - x).abs ** 2 + (position.y - y).abs ** 2)\n\t\tend", "def distance(p0, p1)\n a = factory.point(p0.x, p0.y)\n b = factory.point(p1.x, p1.y)\n\n a.distance(b) / 1000.0\n end", "def manhatten_distance(base_coordinates)\n x1 = base_coordinates[0] + 10\n x2 = coordinates[0] + 10\n y1 = base_coordinates[1] + 10\n y2 = coordinates[1] + 10\n return (x1 - x2).abs + (y1 - y2).abs\n end", "def get_cost(current_coordinates, goal_vector)\n\t\t\tNMath.sqrt(((current_coordinates - goal_vector) ** 2).sum)\n\t\tend", "def distance(x = 0, y = nil, z = nil)\n if !y && x.respond_to?(:x)\n x, y, z = x.x, x.y, x.z\n else\n y ||= 0\n z ||= 0\n end\n\n Math.sqrt((x - self.x)**2 + (y - self.y)**2 + (z - self.z)**2)\n end", "def distance_preceding_character\r\r\n sx = distance_x_from(@preceding_character.x)\r\r\n sy = distance_y_from(@preceding_character.y)\r\r\n return Math.hypot(sx, sy)\r\r\n end", "def distance( h )\n to_cube.distance(h.to_cube)\n end", "def distance( h )\n to_cube.distance(h.to_cube)\n end", "def calculate_distance_between(target)\n Math.sqrt((target.x - x)**2 + (target.y - y)**2)\n end", "def get_distance\n return Math.hypot($game_player.real_x * 32 -\\\n self.mapx, $game_player.real_y * 32 - self.mapy)\n end", "def offset_distance(x1, y1, x2, y2)\n ac = offset_to_cube(x1, y1)\n bc = offset_to_cube(x2, y2)\n cube_distance(ac, bc)\nend", "def distance_to_point(point)\n to_a.zip(point.to_a).map{|a, b| (b - a) ** 2}.reduce(:+) ** 0.5\n end", "def length; Math.sqrt((@x*@x)+(@y*@y)); end", "def calculate(route)\n dist = 0\n route.each_cons(2) { |points| dist = dist + points[0].distance(points[1])}\n dist\nend", "def distance2d(x = 0, y = nil)\n if !y && x.respond_to?(:x)\n x, y = x.x, x.y\n else\n y ||= 0\n end\n\n Math.sqrt((x - self.x)**2 + (y - self.y)**2)\n end", "def distance_to(x, y)\n return Math.hypot(x - @x, y - @y)\n end", "def distance_from shooter\n (self.position - shooter.position).length\n end", "def - (other); \n if(self && other)\n i = other.i - self.i \n j = other.j - self.j\n pt = Point2D.new(i, j)\n vectorAdd = Vector2D.new( 0, 0 )\n vectorAdd.initializeWithPoint( pt )\n end\n end", "def perimeter\n return @perimeter if defined?(@perimeter)\n\n @perimeter = 0.0\n (0...vertices.length).each do |i|\n @perimeter += vertices[i - 1].distance(vertices[i])\n end\n\n @perimeter\n end", "def dist point\n point = point.pos(false) if point.is_a? Atom\n (point.to_v- @p).to_a * @normal / @normal.magnitude\n end", "def points_distance(x1, y1, x2, y2)\n Math.sqrt((x1 - x2).abs2 + (y1 - y2).abs2)\n end", "def calculate_length\n l = @points.enum_cons(2).inject(0) { |s, points|\n s + distance_between(*points)\n }\n\n # include distance to go from last point to first to make loop\n l + distance_between(@points[-1], @points[0])\n end", "def distance_from_line_segment(point_a,point_b)\n\n # Define the line as the vector between two points\n line_vector = point_b - point_a\n \n # Define a second vector representing the distance between self and the line start\n point_vector = self - point_a\n\n # Determine if self falls within the perpendicular 'shadow' of the line by calculating\n # the projection of the point vector onto the line.\n #\n # The dot product divided by the magnitude of the line gives the absolute projection\n # of the point vector onto the line.\n #\n # Dividing again by the line magnitude gives the relative projection along the line, \n # i.e. the ratio of the projection to the line. Values between 0-1 indicate that the\n # point falls within the perpendicular shadow.\n #\n projection_ratio = line_vector.dot(point_vector) / line_vector.magnitude ** 2\n\n if projection_ratio >= 1\n # The point is beyond point b, calculate distance to point b\n distance = (point_b - self).magnitude\n elsif projection_ratio <= 0\n # The point is beyond point a, calculate distance to point a\n distance = (point_a - self).magnitude\n else\n # The point is in the shadow of the line, return the perpendicular distance\n distance = line_vector.cross(point_vector).magnitude / line_vector.magnitude\n end\n\n return distance.abs\n end", "def distance_from(bounds)\n center = Atlas::Place.bounds_to_center_radius(bounds)[:center]\n \n # We ask PostGIS to compute this in meters...\n self.distance = Atlas::Geography.connection.select_value(\"select st_distance_sphere(\n st_transform(st_setsrid(st_makepoint(#{longitude}, #{latitude}), 4326), 2163), \n st_transform(st_setsrid(st_makepoint(#{center[:longitude]}, #{center[:latitude]}), 4326), 2163)\n ) as distance\").to_f\n end", "def distance_to_plane(plane)\n end", "def distance(p1, p2)\n dx = ED * (p1['lat']-p2['lat'])\n dy = ED * Math::cos(Math::PI*p1['lat']/180)*(p1['lon']-p2['lon'])\n return (dx**2 + dy**2)**0.5\nend", "def initialize(polygon)\n a = 2 * (polygon.p2.x - polygon.p1.x)\n b = 2 * (polygon.p2.y - polygon.p1.y)\n c = 2 * (polygon.p2.x - polygon.p3.x)\n d = 2 * (polygon.p2.y - polygon.p3.y)\n e = polygon.p2.x*polygon.p2.x + polygon.p2.y*polygon.p2.y - polygon.p1.x*polygon.p1.x - polygon.p1.y*polygon.p1.y\n f = polygon.p2.x*polygon.p2.x + polygon.p2.y*polygon.p2.y - polygon.p3.x*polygon.p3.x - polygon.p3.y*polygon.p3.y\n \n det = a*d - b*c\n\n x = (d*e - b*f)/det\n y = (a*f - c*e)/det\n r = Math.sqrt((polygon.p1.x - x)**2 + (polygon.p1.y - y)**2)\n \n @middle = Point.new(x, y)\n @radius = r\n end", "def distance(g0, g1)\n Math::sqrt( ((g1.lat-g0.lat).abs**2) + ((g1.lon-g0.lon).abs**2) )\n end", "def distance2_to(data_point)\n [@coordinates,data_point.coordinates].transpose.map{|arr| arr.inject{|sum, coordinate| (sum - coordinate)**2}}.inject(:+)\n end", "def distanceSqr _obj, _args\n \"_obj distanceSqr _args;\" \n end", "def distance_from(char)\n return distance_x_from(char.x).abs + distance_y_from(char.y).abs\n end", "def law_of_cosines_distance_from(p2)\n Math.acos(Math.sin(latr) * Math.sin(p2.latr) + Math.cos(latr) * Math.cos(p2.latr) * Math.cos(p2.lonr - lonr)) * RADIUS\n end", "def distanceToCoord(startXPosition, startYPosition, endXPosition, endYPosition)\n if startXPosition == endXPosition and startYPosition == endYPosition\n return 0\n end\n \n return (startXPosition - endXPosition).abs + (startYPosition - endYPosition).abs\nend", "def distance_from_line(point_a,point_b)\n \n # Define the line as the vector between two points\n line_vector = point_b - point_a\n\n # Define a second vector representing the distance between self and the line start\n point_vector = self - point_a\n\n # The magnitude of the cross product is equal to the area of the parallelogram described\n # by the two vectors. Dividing by the line length gives the perpendicular distance.\n (line_vector.cross(point_vector).magnitude / line_vector.magnitude).abs\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 length\n Math.sqrt(@x * @x + @y * @y)\n end", "def distance\n distance_and_arc[:distance]\n end", "def distance\n distance_and_arc[:distance]\n end", "def distance2_to(data_point)\n [@coordinates,data_point.coordinates].transpose.map do\n |arr| arr.inject { |sum, coordinate| (sum - coordinate)**2 }\n end.inject(:+)\n end", "def distance_from(other)\n\t\t\trlong1 = self.longitude * D2R\n\t\t\trlat1 = self.latitude * D2R\n\t\t\trlong2 = other.longitude * D2R\n\t\t\trlat2 = other.latitude * D2R\n\t\t\t\n\t\t\tdlon = rlong1 - rlong2\n\t\t\tdlat = rlat1 - rlat2\n\t\t\t\n\t\t\ta = Math::sin(dlat/2) ** 2 + Math::cos(rlat1) * Math::cos(rlat2) * Math::sin(dlon/2) ** 2\n\t\t\tc = 2 * Math::atan2(Math::sqrt(a), Math::sqrt(1-a))\n\t\t\td = R * c\n\t\t\t\n\t\t\treturn d\n\t\tend" ]
[ "0.6710497", "0.6653491", "0.6636838", "0.65885985", "0.6560118", "0.64400387", "0.6377738", "0.6374143", "0.6362559", "0.6303656", "0.6293953", "0.62795234", "0.6207172", "0.61964726", "0.6186724", "0.6179033", "0.61749256", "0.61479104", "0.6121144", "0.6088965", "0.60885566", "0.6085837", "0.60431737", "0.6041974", "0.6024149", "0.601586", "0.6006599", "0.60049593", "0.5954009", "0.5934142", "0.59318614", "0.59271085", "0.59205484", "0.5919019", "0.58992755", "0.5889509", "0.5873986", "0.5864135", "0.58516085", "0.5841343", "0.5839912", "0.58339524", "0.581093", "0.5803977", "0.5791139", "0.5746316", "0.5725781", "0.57247007", "0.57145387", "0.56989175", "0.5693448", "0.5680793", "0.56650096", "0.56556416", "0.565471", "0.5650871", "0.5648198", "0.5641629", "0.56412655", "0.56091464", "0.56087923", "0.5587963", "0.55707574", "0.55658996", "0.55654633", "0.5561673", "0.55525607", "0.55525607", "0.5542457", "0.5533859", "0.5527971", "0.55199075", "0.5518097", "0.5488711", "0.54857105", "0.54795873", "0.5474421", "0.5473453", "0.5472068", "0.54658717", "0.546098", "0.5451768", "0.5451029", "0.5447889", "0.5446535", "0.5437882", "0.5437538", "0.5432353", "0.5422641", "0.54215795", "0.54199815", "0.5417837", "0.5412597", "0.5411563", "0.53909135", "0.53826725", "0.537507", "0.537507", "0.5371691", "0.5366539" ]
0.5557853
66
Offset Polygon Functions Get the orientation of a polygon Pick "bottom left" corner vertex (and adjacent oes) determine orientation matrix of this subpolygon (which is guaranteed to be convex)
def orientation p1, p2, p3 = *convex_sub_polygon det = (p2[0]-p1[0])*(p3[1]-p1[1]) - (p3[0]-p1[0])*(p2[1]-p1[1]) @orientation ||= (det < 0)? 1 : -1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mill_polygon(mill, cent_x, cent_y, diam, \r\n no_sides, depth=nil, cutter_comp=false)\r\n#############################################\r\n if cutter_comp == true\r\n diam -= mill.bit_radius\r\n end #if\r\n #mill.retract()\r\n side_count = 0\r\n curr_angle = 0.0\r\n radius = diam / 2\r\n degree_inc = 360 / no_sides\r\n while (curr_angle <= 360)\r\n cp = calc_point_from_angle(cent_x, cent_y, curr_angle, radius)\r\n mill.move(cp.x, cp.y)\r\n if (side_count == 0)\r\n mill.plung(depth)\r\n end #if\r\n side_count = side_count + 1\r\n curr_angle += degree_inc\r\n end #while\r\nend", "def polygon\n respond_to?(:constituencyAreaExtent) ? constituencyAreaExtent : []\n end", "def envelope_to_polygon\n exp = /^\\s*ENVELOPE\\(\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*\n \\)\\s*$/x # uses 'x' option for free-spacing mode\n bbox_match = exp.match(geom)\n minx, maxx, maxy, miny = bbox_match.captures\n \"POLYGON ((#{minx} #{maxy}, #{minx} #{miny}, #{maxx} #{miny}, #{maxx} #{maxy}, #{minx} #{maxy}))\"\n end", "def as_polygon\n GeoRuby::SimpleFeatures::Polygon.from_points([@points[0] == @points[-1] ? @points : (@points + [@points[0].clone])])\n end", "def polygon_vertices(sides, size)\n return [CP::Vec2.new(-size, size), CP::Vec2.new(size, size), CP::Vec2.new(size, -size), CP::Vec2.new(-size, -size)]\n end", "def polygon (sides, length)\n sides.times do\n line length\n turn (360.0/sides).degrees\n end\n end", "def test_is_polygon_with_polygon\n m = Sketchup.active_model\n ents = m.entities\n\n # Create a polygon\n center = [0, 0, 0]\n normal = [0, 0, 1]\n radius = 20\n nsides = 8\n ents.add_ngon center, normal, radius, nsides\n\n # Check poly edges\n m.entities.each do |e|\n if e.is_a? Sketchup::Edge and e.curve.respond_to? 'is_polygon?'\n assert_equal(true, e.curve.is_polygon?,\n 'Curve of polygon edge should be polygon.')\n end\n end\n end", "def polygon\n raise OSMLib::Error::NoDatabaseError.new(\"can't create Polygon from relation if it is not in a OSMLib::Database\") if @db.nil?\n raise OSMLib::Error::NoDatabaseError.new(\"can't create Polygon from relation if it does not represent a polygon\") if self['type'] != 'multipolygon' and self['type'] != 'polygon'\n\n c = []\n member_objects.each do |way|\n raise TypeError.new(\"member is not a way so it can't be represented as Polygon\") unless way.kind_of? OSMLib::Element::Way\n raise OSMLib::Error::NotClosedError.new(\"way is not closed so it can't be represented as Polygon\") unless way.is_closed?\n raise OSMLib::Error::GeometryError.new(\"way with less then three nodes can't be turned into a polygon\") if way.nodes.size < 3\n c << way.node_objects.collect{ |node| [node.lon.to_f, node.lat.to_f] }\n end\n GeoRuby::SimpleFeatures::Polygon.from_coordinates(c)\n end", "def sample_polygon\n polygon(200, [[10.0, 10.0], [180.0, 20.0], [160.0, 150.0], [100.0, 50.0], [20.0,180.0]])\nend", "def sum_of_interior_angles\n 180 * (@number_of_sides - 2)\n end", "def polygon_vertices(sides, size)\n vertices = []\n sides.times do |i|\n angle = -2 * Math::PI * i / sides\n vertices << radians_to_vec2(angle) * size\n end\n return vertices\n end", "def polygon_vertices(sides, size)\n vertices = []\n sides.times do |i|\n angle = -2 * Math::PI * i / sides\n vertices << angle.radians_to_vec2() * size\n end\n return vertices\n end", "def polygon_image(vertices)\n box_image = Magick::Image.new(EDGE_SIZE * 2, EDGE_SIZE * 2) { self.background_color = 'transparent' }\n gc = Magick::Draw.new\n gc.stroke('red')\n gc.fill('plum')\n draw_vertices = vertices.map { |v| [v.x + EDGE_SIZE, v.y + EDGE_SIZE] }.flatten\n gc.polygon(*draw_vertices)\n gc.draw(box_image)\n return Gosu::Image.new(@window, box_image, false)\n end", "def convex_sub_polygon\n subsets = []\n vertices.each_cons(3) do |p1, p2, p3|\n subsets << [p2, [p1, p2, p3]]\n end\n subsets.sort.first.last\n end", "def polygon_image(vertices)\n box_image = Magick::Image.new(EDGE_SIZE * 2, EDGE_SIZE * 2) { self.background_color = \"transparent\" }\n gc = Magick::Draw.new\n gc.stroke(\"red\")\n gc.fill(\"plum\")\n draw_vertices = vertices.map { |v| [v.x + EDGE_SIZE, v.y + EDGE_SIZE] }.flatten\n gc.polygon(*draw_vertices)\n gc.draw(box_image)\n return Gosu::Image.new(box_image)\n end", "def polygon(x, y, r, sides, options={})\n cur_page.polygon(x, y, r, sides, options)\n end", "def initialize(polygon)\n a = 2 * (polygon.p2.x - polygon.p1.x)\n b = 2 * (polygon.p2.y - polygon.p1.y)\n c = 2 * (polygon.p2.x - polygon.p3.x)\n d = 2 * (polygon.p2.y - polygon.p3.y)\n e = polygon.p2.x*polygon.p2.x + polygon.p2.y*polygon.p2.y - polygon.p1.x*polygon.p1.x - polygon.p1.y*polygon.p1.y\n f = polygon.p2.x*polygon.p2.x + polygon.p2.y*polygon.p2.y - polygon.p3.x*polygon.p3.x - polygon.p3.y*polygon.p3.y\n \n det = a*d - b*c\n\n x = (d*e - b*f)/det\n y = (a*f - c*e)/det\n r = Math.sqrt((polygon.p1.x - x)**2 + (polygon.p1.y - y)**2)\n \n @middle = Point.new(x, y)\n @radius = r\n end", "def get_3d_polygon()\n height = get_keyword_value(\"HEIGHT\").to_f\n width = get_keyword_value(\"WIDTH\").to_f\n x = self.check_keyword?(\"X\")? self.get_keyword_value(\"X\").to_f : 0.0\n y = self.check_keyword?(\"Y\")? self.get_keyword_value(\"Y\").to_f : 0.0\n #counter clockwise\n origin = OpenStudio::Point3d.new( x, y , 0.0 )\n p2 = OpenStudio::Point3d.new(x + width , y,0.0 )\n p3 = OpenStudio::Point3d.new(x + width , y + height , 0.0 )\n p4 = OpenStudio::Point3d.new(x, y + height,0.0 )\n return [origin,p2,p3,p4]\n end", "def polygons_points(p_polygon)\n # initialization\n points = \"\"\n i_polygon = 0\n current_hexagon = p_polygon[:enveloppe][0]\n i_connection = p_polygon[:connections][0].index(\"0\")\n initial_vertex = \"#{current_hexagon.to_s},#{VERTICES[i_connection].to_s}\"\n done = false\n \n until done\n while not done and p_polygon[:connections][i_polygon][i_connection] == \"0\"\n done = initial_vertex == \"#{current_hexagon.to_s},#{VERTICES[i_connection].to_s}\" unless points.empty?\n unless done\n vertex = VERTICES[i_connection]\n points << \"#{x_vertex(current_hexagon, vertex).floor},#{y_vertex(current_hexagon, vertex).floor} \"\n i_connection == 5 ? i_connection = 0 : i_connection += 1\n end\n end\n \n if not done and i_connection < 6 then\n current_hexagon = adjacent(current_hexagon, EDGES[i_connection])\n i_polygon = p_polygon[:enveloppe].index(current_hexagon)\n i_connection -= 2\n i_connection += 6 unless i_connection >= 0\n end \n end\n \n return points.chop\n end", "def closed_polygon(height, width, coords, dot_size = 0)\n return if @options[:underneath_color].nil?\n\n list = []\n\n list << [coords.first.first - 1 + (dot_size / 2.0), height - 3 - (dot_size / 2.0)]\n list << [coords.first.first - 1 + (dot_size / 2.0), coords.first.last]\n\n list << coords\n\n list << [coords.last.first + 1 - (dot_size / 2.0), coords.last.last]\n list << [coords.last.first + 1 - (dot_size / 2.0), height - 3 - (dot_size / 2.0)]\n\n @draw.stroke(@options[:underneath_color])\n @draw.fill(@options[:underneath_color])\n @draw.polygon( *list.flatten )\n end", "def check_interior(polygon, point)\n sum = 0\n polygon.each_index do |i|\n next_i = i + 1\n next_i = 0 if next_i >= polygon.size\n sum += compute_angle(\n [polygon[i][0] - point[0],\n polygon[i][1] - point[1],\n polygon[i][2] - point[2]],\n [polygon[next_i][0] - point[0],\n polygon[next_i][1] - point[1],\n polygon[next_i][2] - point[2]],\n )\n end\n\n (sum >= 2*3.1415926 and sum <= 2*3.1415927) or\n check_border(polygon, point)\n end", "def offset(delta, dist = 1.5)\n # set delta according to polygon direction, set veriables for first and last p/l\n delta = delta * orientation\n p_first, p_last = nil; offset_lines = []\n l_first, l_last = nil; offset_points = []\n refined_points = []\n\n # Offset lines between 2 consecutive vertices out by delta\n vertices.each_cons(2) do |p1, p2|\n p_first ||= p1; p_last = p2 # save first and last vector for final line\n offset_lines << offset_line(p1, p2, delta)\n end\n offset_lines << offset_line(p_last, p_first, delta)\n\n # Calculate intersections between adjacent lines for new vertices\n offset_lines.each_cons(2) do |l1, l2|\n l_first ||= l1; l_last = l2 # save first and last vector for final intersection\n offset_points << line_intersection(l1, l2)\n end\n offset_points.insert(0, line_intersection(l_first, l_last))\n\n # Smooth corners of very acute angles\n offset_points.each_with_index do |p, key|\n v = p - vertices[key]\n if v.magnitude > (dist * delta).abs\n p2 = vertices[key] + v.normalize * dist * delta.abs\n # normal vector for 2 vertices through a point dist*delta away\n cutoff_line = [p2, p2 + v.normal_vector]\n [-1, 0].each do |i|\n if key + i < 0\n n = offset_lines.size - 1\n elsif key + i >= offset_lines.size\n n = 0\n else\n n = key + i\n end\n refined_points << line_intersection(cutoff_line, offset_lines[n])\n end\n else\n refined_points << p\n end\n end\n refined_points\n end", "def vertices\n vertices = []\n\n vertices << [(@origin[0] + @l/2.0), (@origin[1] + @h/2.0), (@origin[2] + @w/2.0)]\n vertices << [(@origin[0] + @l/2.0), (@origin[1] + @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] + @l/2.0), (@origin[1] - @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] + @l/2.0), (@origin[1] - @h/2.0), (@origin[2] + @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] - @h/2.0), (@origin[2] + @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] - @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] + @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] + @h/2.0), (@origin[2] + @w/2.0)]\n\n vertices\n end", "def -(polygon)\n\t\t\tps = Polygon_set_2.difference_polygons_with_holes root, polygon.root\n\t\t\tps.to_a.collect{|pwh| Polygon.new(pwh)}\n\t\tend", "def orientation\n return nil if not @rep\n\n # get the transformation from the group or component instance\n t = @rep.transformation\n eye = t.origin\n dir = t.xaxis\n up = t.zaxis\n y = t.yaxis\n\n # See if there is an offset that needs to be applied to the eye position\n eo = self.get_offset\n if( eo )\n offset = Geom::Vector3d.linear_combination eo.x, dir, eo.y, y, eo.z, up\n eye.offset!(offset)\n end\n\n [eye, dir, up]\nend", "def orientation \n @position - @prev_position\n end", "def polygon_area(vertices)\n raise \"A polygon must have 3 or more vertices, not #{vertices.length}\" unless vertices.length >= 3\n\n area = 0\n\n # Rely on Ruby's circular array indexing for negative indices\n vertices.size.times do |idx|\n x2, y2 = vertices[idx]\n x1, y1 = vertices[idx - 1]\n area += x1 * y2 - x2 * y1\n end\n\n return area * 0.5\n end", "def orient_patch\n rotmat = CVFFI::CvMat.new CVFFI::cvCreateMat( 2,3, :CV_32F )\n CVFFI::cv2DRotationMatrix( CVFFI::CvPoint2D32f.new( [ @patch.width/2.0, @patch.height/2.0 ]), -@angle*180.0/Math::PI, 1.0, rotmat )\n\n dstimg = @patch.twin\n CVFFI::cvWarpAffine( @patch, dstimg, rotmat )\n\n dstimg \n end", "def shape_in_pos(pos)\n @all_rotations[pos[2]].map do |point|\n plus(point, pos)\n end\n end", "def extend!(envelope)\r\n lower_corner.x = [lower_corner.x,envelope.lower_corner.x].min\r\n lower_corner.y = [lower_corner.y,envelope.lower_corner.y].min\r\n upper_corner.x = [upper_corner.x,envelope.upper_corner.x].max\r\n upper_corner.y = [upper_corner.y,envelope.upper_corner.y].max\r\n self\r\n end", "def horiz_extent(shape)\n left = 0\n right = 0\n shape.each do |point|\n if point[0] < left\n then left = point[0]\n elsif right < point[0]\n then right = point[0]\n end\n end\n [left, right]\n end", "def envelope\r\n Envelope.from_points(bounding_box,srid,with_z)\r\n end", "def reverse!\n\t super\n\n\t # Simply reversing the vertex array causes the reversed polygon to\n\t # start at what had been the last vertex, instead of starting at\n\t # the same vertex and just going the other direction.\n\t vertices.unshift vertices.pop\n\n\t self\n\tend", "def draw_diagonal_from_top_left(png, color)\n\tpng.polygon([0, 0, png.width, png.height], color)\nend", "def points\n object.polygon.points\n end", "def [](index)\n return nil unless index.between?(0, vertex_count - 1)\n vertex = Vector.zero\n FMOD.invoke(:Geometry_GetPolygonVertex, @geometry, @index, index, vertex)\n vertex\n end", "def corner(corner_index)\n end", "def polygon *points, color\n points << points.first\n points.each_cons(2) do |p1, p2|\n w.line(*p1, *p2, color)\n end\n end", "def test_is_polygon_api_example\n # For backwards compatibility, only run test if curve instance has\n # is_polygon? method\n if Sketchup::Curve.new().public_methods.include? 'is_polygon?'\n assert_nothing_raised do\n # Create a polygon and check its edge\n ents = Sketchup.active_model.entities\n ents.add_ngon [0, 0, 0], [0, 0, 1], 10, 6\n curve = nil\n ents.each { |e| curve = e.curve if e.is_a? Sketchup::Edge }\n is_poly = curve.is_polygon?\n end\n end\n end", "def upper_left\n @upper_left ||= Quadtree::Point.new(\n provinces.map { |province| province.upper_left.x }.min,\n provinces.map { |province| province.upper_left.y }.max\n )\n end", "def side(p_)\n px_ = p_.x\n py_ = p_.y\n (@sx - px_) * (@ey - py_) - (@sy - py_) * (@ex - px_)\n end", "def corners\n\t\t[[0,0],[0,@m-1],[@n-1,0],[@n-1,@m-1]]\n\tend", "def polygon(options={},&block)\n set RGhost::Polygon.new(options,&block)\n end", "def edit_draw_polygon(request, opts = {})\n data, _status_code, _headers = edit_draw_polygon_with_http_info(request, opts)\n data\n end", "def center\n @center ||= begin\n xs, ys = vertices.transpose\n [xs.inject(:+)/xs.size.to_f, ys.inject(:+)/ys.size.to_f]\n end\n end", "def direction\n return nil if x_vel.zero? && y_vel.zero?\n vector_to_angle(*drop_diagonal)\n end", "def calc_vertices\n @worksheet.position_object( @params[:start_col],\n @params[:start_row],\n @params[:x_offset],\n @params[:y_offset],\n @params[:width],\n @params[:height]\n )\n end", "def point_in_polygon(p, poly)\n UNIT_SQUARE.position.set(p)\n T_RESPONSE.clear\n result = test_polygon_polygon(UNIT_SQUARE, poly, T_RESPONSE)\n result = T_RESPONSE.a_in_b if result\n result\n end", "def postgis_polygon_format(coordinates)\n ordinates = 'POLYGON (('\n ordinates += coordinates.gsub(\"0.0\", \" \").gsub(\",-\",\" -\").gsub(/, $/, \")\")\n ordinates += ')'\n end", "def clockwise points\n ul = Struct.new(:x, :y).new 0, 0\n upper_left = points.min_by { |point| distance point, ul }\n until points.first == upper_left\n points = points.rotate\n end\n points\n end", "def to_polycube_layout\n rows = []\n\n all_pieces = Piece.generate_pieces\n pieces_on_the_board = self.pieces\n codes_on_the_board = pieces_on_the_board.map {|p| p.code }.uniq\n pieces_off_the_board = all_pieces.select do |piece|\n !codes_on_the_board.include?(piece.code)\n end\n\n rows << \"D:xDim=6:yDim=6:zDim=1:oneSide\"\n if pieces_off_the_board.size > 0\n rows << \"L\"\n rows << \" \"\n pieces_off_the_board.each do |piece|\n rows << piece.to_polycube_layout\n rows << \" \"\n end\n rows << \"~L\"\n end\n rows << \" \"\n\n if codes_on_the_board.size > 0\n rows << \"L:stationary=#{codes_on_the_board.join(' ')}\"\n else\n rows << \"L\"\n end\n\n (1..DEFAULT_WIDTH).each do |y|\n row = []\n\n (1..DEFAULT_WIDTH).each do |x|\n row << (cell(x, y).piece&.code || \".\")\n end\n rows << row.join(\" \")\n end\n rows << \"~L\"\n rows << \" \"\n rows << \"~D\"\n\n rows.join(\"\\n\")\n end", "def clockwise(p)\n base_idx = @neighbors.index(p) # FIXME: this is using <=> but we want __id__\n\n idx = base_idx\n n = nil\n loop do\n # Skip newly added neighbors during a hull merge; not sure if this is\n # a proper fix for the point-walk ending up on the wrong hull, or if\n # it causes new problems\n idx = (idx - 1) % @neighbors.length\n n = @neighbors[idx]\n\n break if n.hull == hull || idx == base_idx\n end\n\n n\n end", "def deskew_angle(img)\n temp = Tempfile.new 'split-subjects-vertically'\n sample = img.clone\n # inset crop 10% from borders:\n sample_inset = 0.10\n sample.crop! img.columns * sample_inset, img.rows * sample_inset, img.columns - (img.columns * 2 * sample_inset), img.rows - (img.rows * 2 * sample_inset)\n sample.write temp.path\n sample.write \"temp.sample.jpg\"\n angle = `convert #{temp.path} -deskew 40 -format '%[deskew:angle]' info:`.to_f\n # If angle is greater than this, it's probably an error\n angle.abs >= 2 ? 0 : angle\nend", "def angle_at(point)\n Point.angle(centre, point)\n end", "def add_polygon(options)\n polygon = Google::OptionsHelper.to_polygon(options)\n \n self.add_overlay polygon\n polygon.added_to_map self\n \n unless polygon.encoded?\n self.extend_track_bounds polygon.vertices\n end\n \n polygon\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 extent; @bounds.diagonal; end", "def extend(envelope)\r\n e = Envelope.from_points([Point.from_x_y(lower_corner.x,lower_corner.y),\r\n Point.from_x_y(upper_corner.x,upper_corner.y)],srid,with_z)\r\n e.extend!(envelope)\r\n e\r\n end", "def drill(mesh,outer)\n side = outer ? mesh.meshes.first : mesh.meshes.last\n\n # opening start\n t1 = @meshes.first.vertices[outer ? 0 : 3].clone\n t1.z = side.vertices[0].z\n t1b = @meshes[3].vertices[outer ? 0 : 3]\n\n b1 = @meshes.first.vertices[outer ? 0 : 3].clone\n b1.z = side.vertices[2].z\n b1t = @meshes.first.vertices[outer ? 0 : 3]\n\n # opening end\n t2 = @meshes.first.vertices[outer ? 1 : 2].clone\n t2.z = side.vertices[0].z\n t2b = @meshes[3].vertices[outer ? 1 : 2]\n\n b2 = @meshes.first.vertices[outer ? 1 : 2].clone\n b2.z = side.vertices[2].z\n b2t = @meshes.first.vertices[outer ? 1 : 2]\n\n # old side vertices\n ot = side.vertices[1]\n ob = side.vertices[2]\n side.vertices[1] = outer ? t2 : t1\n side.vertices[2] = outer ? b2 : b1\n\n # polygon above opening\n op_top = Geom::Polygon.new\n if outer\n op_top.vertices.push(t2,t1,t1b,t2b)\n else\n op_top.vertices.push(t1,t2,t2b,t1b)\n end\n\n # polygon below opening\n op_bot = Geom::Polygon.new\n if outer\n op_bot.vertices.push(b2t,b1t,b1,b2)\n else\n op_bot.vertices.push(b1t,b2t,b2,b1)\n end\n\n rest = Geom::Polygon.new\n if outer\n rest.vertices.push(t1,ot,ob,b1)\n else\n rest.vertices.push(t2,ot,ob,b2)\n end\n\n mesh.meshes.push(op_top)\n mesh.meshes.push(op_bot)\n mesh.meshes.push(rest)\n end", "def update_shape()\n\t\t\t# define current position for faster access\n\t\t\t@position = self.bounds.center\n\t\t\tedges = self.definition.entities.to_a { |ent| ent.class == Sketchup::Edge }\n\t\t\t\n\t\t\t# set vertices array\n\t\t\tvertices = Array.new\n\t\t\tedges.each do |edge|\n\t\t\t\tvertices << edge.vertices\n\t\t\tend\n\t\t\tvertices.flatten!\n\t\t\tvertices.uniq!\n\t\t\t\n\t\t\t# now calculate each vertex global position\n\t\t\t@points = Array.new\n\t\t\ttransformation = self.transformation\n\t\t\tvertices.each do |vertex|\n\t\t\t\t@points << (vertex.position.transform! transformation)\n\t\t\tend\n\t\t\t\n\t\t\t@trans_array = transformation.to_a\n\t\t\treturn nil\n\t\tend", "def hn_from_xyp(p_xp, p_yp)\n sc = (p_xp / fw).floor\n sl = (p_yp / (th + hex_side_length)).floor\n xs = p_xp - sc * fw\n ys = p_yp - sl * (th + hex_side_length)\n gr = th / rhl\n if sl%2 == 0 then\n # default zone for odd section line\n hl = sl\n hc = sc\n # upper left triangle\n if ys < (th - xs * gr) then\n hl = hl - 1\n hc = hc - 1\n end\n # upper right triangle\n if ys < (- th + xs * gr) then\n hl = hl - 1\n end\n else\n # even section line\n if xs >= rhl then\n # right side\n if ys < (2 * th - xs * gr) then\n # upper triangle\n hl = sl - 1\n hc = sc\n else \n # lower polygon \n hl = sl\n hc = sc\n end\n else \n # left side\n if ys < (xs * gr) then\n # upper triangle\n hl = sl - 1\n hc = sc\n else\n # lower polygon\n hl = sl\n hc = sc - 1\n end \n end\n end\n # adjust for off grid situations\n if hl < 0 or hl >= maxlin or hc < 0 or hc >= (maxcol - hl%2) then\n return -1\n else \n return hn_from_hcl(hc, hl)\n end \n end", "def diagonalize floor = 0\n raise 'err: not 2d' unless self[0].class == Array\n size = self.length + self[0].length - 1\n array = Array.new(size) {Array.new}\n # acquire top and main diagonal\n self.length.times do |row|\n (0 .. row).each do |col|\n array[row] << self[row-col][col]\n end\n end\n # now cover the additional bottom diagonals\n sides_difference = self.length[0] - self.length\n if sides_difference == 0\n (1 .. self.length - 1).reverse_each do |row|\n offset_value = 0\n temp_arr = []\n while row + offset_value < self.length\n temp_arr << self[self.length - 1 - offset_value][row + offset_value]\n offset_value += 1\n end\n array[self.length - 1 + row] = temp_arr\n end\n else\n (1 .. self[0].length - 1).reverse_each do |row|\n offset_value = 0\n temp_arr = []\n while row + offset_value < self[0].length\n temp_arr << self[self.length - 1 - offset_value][row + offset_value]\n offset_value += 1\n end\n array[self[0].length - 2 + row] = temp_arr\n end\n end\n\n # phew... now to trim and format\n unless floor == 0\n index = 0\n while index < size\n if array[index].length < floor\n array.slice! index\n size -= 1\n index -= 1\n end\n index += 1\n end\n end\n\n (0..size-1).each do |index|\n while array[index].length < self.length\n array[index] << nil\n end\n end\n array\n end", "def to_outer(point)\n transform * point\n end", "def zrotation\n end", "def getVertices( x0, y0, x1, y1) # arguments define bounding box\n\t\tw, h = x1 - x0, y1 - y0\n\t\td = 5 # size of corner chip\n\n\t\t[\n\t\t\t[ d, 0], [ w - d, 0],\n [ w, d], [w, h - d],\n [ w - d, h], [ d, h],\n [ 0, h - d], [ 0, d]\n\t\t].map do |v| [ v[0] + x0, v[1] + y0 ] end.flatten\n\tend", "def geometry_as_wkt\n return geom unless geom.match?(/ENVELOPE/)\n\n envelope_to_polygon\n end", "def getOrientation(row, col)\n case (@orientation_index)\n when 0\n return [\n Block.new(row, col),\n Block.new(row, col - 1),\n Block.new(row, col + 1),\n Block.new(row + 1, col + 1)\n ]\n when 1\n return [\n Block.new(row, col),\n Block.new(row + 1, col - 1),\n Block.new(row + 1, col),\n Block.new(row - 1, col)\n ]\n when 2\n return [\n Block.new(row, col),\n Block.new(row, col - 1),\n Block.new(row - 1, col - 1),\n Block.new(row, col + 1)\n ]\n when 3\n return [\n Block.new(row, col),\n Block.new(row + 1, col),\n Block.new(row - 1, col),\n Block.new(row - 1, col + 1)\n ]\n else\n abort('No such rotation orientation')\n end\n end", "def check_polygon\n return false if @points.length < 3\n zpoints = Array.new(@points)\n zpoints += [@points[0], @points[1]]\n side_prev = zcrossproduct(zpoints[0], zpoints[1], zpoints[2])\n for i in 1...(zpoints.length-2)\n side_next = zcrossproduct(zpoints[i], zpoints[i+1], zpoints[i+2])\n return false if (side_prev * side_next < 0)\n end\n return true\n end", "def mill_hex_pocket(mill, cent_x, cent_y, diam, depth=nil)\r\n#####################################\r\n aPoly = CNCShapePolygon.new(mill, cent_x, cent_y, nil, diam=diam, num_sides=6, depth=depth, degree_inc=nil)\r\n aPoly.do_mill()\r\n return aPoly\r\nend", "def coords_to_wkt_polygon(min_x, min_y, max_x, max_y)\n [[min_x, min_y],\n [max_x, min_y],\n [max_x, max_y],\n [min_x, max_y],\n [min_x, min_y]]\n end", "def petunin(points)\n\tif points.size() < 4\n\t\tputs \"Error on #{__LINE__} in #{__FILE__}\"\n\t\texit(1)\n\tend\n\t#return [x,x0,y,y0]\n\trect = find_rect(points)\n\tdx, phi, coef = get_transf_coef(rect)\n\tdx.each {}\n\t#rect = translate(rect, -dx[0], -dx[1])\n\trect = rotate(rect, phi)\n\trect = scale(rect, 1.0, coef)\n\n\t#points = translate(points, -dx[0], -dx[1])\n\tpoints = rotate(points,phi)\n\tpoints = scale(points, 1, coef)\n\n\tcentre = rect[0].zip(rect[2]).to_a.map { |u,v| (u+v)/2 }\n\trs = []\n\tpoints.each do |p|\n\t\trs << [dist(p, centre), p]\n\tend\n\trs = rs.sort\n\n\tres = []\n\n\trs.each do |r,p|\n\t\tel = Ellipse.new\n\t\tel.centre = centre\n\t\tel.axes = [r]*2\n\n\t\t#back\n\t\tel.scale(1, 1/coef)\n\n\t\tel.rotate(-phi)\n\t\tres << [el,p]\n\tend\n\n\treturn res\n\n\t# For testing reasons only\n\n\t#rect = scale(rect, 1, 1/coef)\n\t#points = scale(points, 1, 1/coef)\n\t#rect = rotate(rect, -phi)\n\t#points = rotate(points, -phi)\n\t#points.map! { |x| [x] }\n\n\t#points + [rect] + res.inject([]) { |sum,el| sum + [el.get_draw_data] }\nend", "def orient! direction, edge\n\t\treturn false if edge_to_the(direction) == edge\n\t\tensure_unplaced\n\t\t2.times do\n\t\t\tDIRECTIONS.count.times do\n\t\t\t\trotate!\n\t\t\t\treturn true if edge_to_the(direction) == edge\n\t\t\tend\n\t\t\tflip!\n\t\tend\n\t\traise \"Could not orient piece so that edge matched.\"\n\tend", "def outer_boundary; root.outer_boundary.to_a;\t\t\t\t\t\t\tend", "def angle_from_input\n\n return if @path.size < 2\n return unless @active_controller.is_a? Symbol\n\n i = @active_controller == :start ? 0 : 1\n corner = @path[-i]\n ref_vector = @path[-i] - @path[1 - 3 * i]\n input_vector = corner - @ip.position\n return unless input_vector.valid?\n return if input_vector.parallel? Z_AXIS\n return if input_vector.parallel? ref_vector\n\n angle = -(MyGeom.angle_in_plane input_vector, ref_vector)\n angle -= GRAPHICAL_ANGLES[i]\n angle = ((angle+90.degrees)%180.degrees)-90.degrees\n\n @end_angles[i] = angle\n\n end", "def chech_first_corner_edge()\n\t\tposition = 4\n\t\treturn position\n\tend", "def chech_first_corner_edge()\n\t\tposition = 4\n\t\treturn position\n\tend", "def oriented_exit(exit_point)\n @orientation.times do\n exit_point = Direction.clockwise_from(exit_point)\n end\n\n exit_point\n end", "def points_for_polygon(x, y, r, sides, options={})\n cur_page.points_for_polygon(x, y, r, sides, options)\n end", "def rotate_origo(angle_x = 0, angle_y = 0, angle_z = 0)\n\t\t@rect.each 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 formPolygon?(lines)\n endpoints = {}\n\n lines.each do |l|\n [l.p1, l.p2].each do |p|\n endpoints[p.to_s] ||= []\n endpoints[p.to_s] << l\n end\n end\n\n # the algorithm is to follow the points until you end up at one that \n # you've already seen\n l = lines.first\n p = l.p1\n op = p\n begin\n ls = endpoints[p.to_s]\n return false if ls.nil?\n endpoints.delete p.to_s\n\n # get the line that we weren't on before\n ls.delete(l)\n l = ls[0]\n return false if l.nil? # this means that there weren't 2 lines with endpoint p\n\n # get the other point on that line\n p = (l.p1 == p) ? l.p2 : l.p1\n end until p == op\n\n return endpoints.length == 0\n end", "def orient(rx, ry, qx, qy, px, py)\n (orient_if_sure(px, py, rx, ry, qx, qy) || orient_if_sure(rx, ry, qx, qy, px, py) || orient_if_sure(qx, qy, px, py, rx, ry)) < 0\n end", "def parse_poly_holes\n raise StandardError, 'Polygon with Holes not supported'\nend", "def surfacedirection(face)\n vect = face.normal\n hvector = Geom::Vector3d.new(0, 0, 1)\n ang = hvector.angle_between vect\n return ang\nend", "def inside?(zone)\n inPoly = false\n if zone == nil || zone.count == 0\n return false\n end\n\n lastPointData = Point.new(zone[zone.size-1])\n lastPoint = lastPointData.asMapPoint\n here = self.asMapPoint\n\n zone.each do |point|\n point = Point.new(point).asMapPoint\n\n if (((point.y < here.y) && (lastPoint.y >= here.y)) || ((lastPoint.y < here.y) && (point.y >= here.y)))\n if ((point.x + (((here.y - point.y) / (lastPoint.y - point.y)) * (lastPoint.x - point.x))) < here.x)\n inPoly = !inPoly\n end\n end\n lastPoint = point\n end\n\n inPoly\n end", "def calculate_orientation\n x, y = @components.values\n if x.pos? and y.zero?\n 0.deg\n elsif x.zero? and y.pos?\n 90.deg\n elsif x.neg? and y.zero?\n 180.deg\n elsif x.zero? and y.neg?\n 270.deg\n elsif x.pos? and y.pos?\n Math.atan( y/x ).rad # Will return an Angle object (with the property \"degrees\")\n elsif x.neg? and y.pos?\n angle = Math.atan( y/x.abs ).rad\n (180 - angle.deg).deg # Will return an Angle object (with the property \"degrees\")\n elsif x.neg? and y.neg?\n angle = Math.atan( y.abs/x.abs ).rad\n (180 + angle.deg).deg # Will return an Angle object (with the property \"degrees\")\n elsif x.pos? and y.neg?\n angle = Math.atan( y.abs/x ).rad\n (360 - angle.deg).deg\n end\n end", "def to_bounding_box\n [[west, south], [east, north]] if @envelope.present?\n end", "def plot_polygon(vertices = [])\n return self.plot if vertices.empty?\n plot_lines([vertices + [vertices[0]]])\n end", "def update!(**args)\n @rest_of_world_polygon = args[:rest_of_world_polygon] if args.key?(:rest_of_world_polygon)\n @self_polygon = args[:self_polygon] if args.key?(:self_polygon)\n end", "def midright; return self.right, self.centery; end", "def getPolyCoordinates(radius, lat, lon, num_sides)\r\n # Create array to the radian values of the regular polygon\r\n rads = (0..2*Math::PI).step((2 * Math::PI) / num_sides.to_f).to_a\r\n\r\n # Compute angular distance (meters)\r\n ang_dist = (radius.to_f / EARTH_RAD_M.to_f) #*(Math::PI/180.0)\r\n lat_rad = lat * Math::PI/180.0\r\n lon_rad = lon * Math::PI/180.0\r\n\r\n # Constants\r\n a = Math.sin(lat_rad) * Math.cos(ang_dist)\r\n b = Math.cos(lat_rad) * Math.sin(ang_dist)\r\n\r\n # Loop over radians (clockwise) to compute geo points of the polygon\r\n points = Array.new\r\n cnt = 0\r\n rads.each do |r|\r\n # new point latitude (in radians)\r\n new_lat = Math.asin(a + b * Math.cos(r)) \r\n\r\n # new point longitude (in radians)\r\n c = Math.cos(ang_dist) - Math.sin(lat_rad) * Math.sin(new_lat)\r\n new_lon = lon_rad + Math.atan2(Math.sin(r) * Math.sin(ang_dist) * Math.cos(lat_rad), c)\r\n\r\n # Store (in degrees)\r\n points[cnt] = {:lat => new_lat*180.0/Math::PI, :lon => new_lon*180.0/Math::PI}\r\n cnt += 1\r\n end\r\n\r\n return points\r\n end", "def incenter\n return @incenter if defined?(@incenter)\n\n s = self.sides\n l = [1, 2, 0].map { |i| s[i].length }\n p = l.sum\n\n x_arr = self.vertices.map { |v| v.x / p }\n y_arr = self.vertices.map { |v| v.y / p }\n\n x = l[0] * x_arr[0] + l[1] * x_arr[1] + l[2] * x_arr[2]\n y = l[0] * y_arr[0] + l[1] * y_arr[1] + l[2] * y_arr[2]\n\n @incenter = Point.new(x, y)\n @incenter\n end", "def perimeter\n\n return @side_len * 4\n\n end", "def get_edge_corner_dis\n top_left = [self.x - self.ox, self.y - self.oy]\n bot_right = [top_left[0] + self.width, top_left[1] + self.height]\n return [top_left, bot_right]\n end", "def get_contour_points_adv()\r\n result = []\r\n idx = 0\r\n result[idx] = Offset.vertices(@active_face.outer_loop.vertices, -(@bit_diameter * 0.5)).offsetPoints\r\n# puts \" outer #{result[idx].length} #{result[idx]} \"\r\n @active_face.loops.each { |lp|\r\n if (!lp.outer?)\r\n idx += 1\r\n result[idx] = Offset.vertices(lp.vertices, -(@bit_diameter * 0.5) ).offsetPoints \r\n# puts \" inner[#{idx}] #{result[idx]}\" \r\n end\r\n }\r\n return result \r\nend", "def to_padded_coordinates\n w = @direction == :across ? @length : 1\n h = @direction == :across ? 1 : @length\n\n all = (@x - 1..@x + w + 1).map {|i| [i, @y - 1] } + # top\n (@x - 1..@x + w + 1).map {|i| [i, @y + 1] } + # bottom\n (@y - 1..@y + h + 1).map {|i| [@x - 1, i] } + # left\n (@y - 1..@y + h + 1).map {|i| [@x + 1, i] } # right\n\n all.select { |c|\n c[0] >= 0 && c[0] < Board::SIZE &&\n c[1] >= 0 && c[1] < Board::SIZE\n } + to_coordinates\n end", "def vertices\n result = [[@origin_x, @origin_y, @origin_z]]\n dimensions = [@length, @width, @height]\n \n dimensions.each_with_index do |dimension, index|\n temp = result[0].dup\n temp[index] += dimension\n result << temp\n (index...dimensions.length).each do |index2|\n next if index == index2\n temp2 = temp.dup\n temp2[index2] += dimensions[index2]\n result << temp2\n end\n end\n result << [@origin_x + @length, @origin_y + @width, @origin_z + @height]\n result\n end", "def _update!\n self.class.repository_or_fail.createPolygon self\n end", "def triangulate(geometry)\n ring = geometry.exterior_ring\n\n input = ring.points.map { |point| [point.x, point.y] }\n input.pop if input.first == input.last\n\n cdt = Poly2Tri::CDT.new(input)\n cdt.triangulate!\n cdt.triangles\n end", "def min_angle\n 6 * self.min\n end", "def diagonal_left\n end" ]
[ "0.5706218", "0.5680307", "0.55774313", "0.5497918", "0.5491631", "0.54648197", "0.5400046", "0.53660953", "0.53585744", "0.53214765", "0.53126967", "0.528629", "0.52474815", "0.52182263", "0.5201485", "0.5201322", "0.5177382", "0.5163872", "0.5160315", "0.5154005", "0.51375216", "0.5107566", "0.5009886", "0.4968044", "0.49493986", "0.49493602", "0.49229994", "0.48915014", "0.4832596", "0.48241767", "0.4795412", "0.47901368", "0.4772938", "0.47547176", "0.4752696", "0.4745065", "0.47059992", "0.47006813", "0.4691802", "0.46847367", "0.46845305", "0.46739483", "0.46670055", "0.46596837", "0.46543038", "0.46436748", "0.4633593", "0.46314248", "0.4579439", "0.45773047", "0.45556554", "0.4550269", "0.4547162", "0.45231354", "0.45191008", "0.4515735", "0.45081088", "0.45004657", "0.4492964", "0.4491503", "0.44807303", "0.44689986", "0.4454031", "0.44424284", "0.44394752", "0.44385558", "0.44379762", "0.442038", "0.44186488", "0.4416396", "0.44147924", "0.44102803", "0.44056645", "0.4400983", "0.43962377", "0.43962377", "0.4389046", "0.43838468", "0.43751273", "0.4362993", "0.4355554", "0.43517938", "0.43510115", "0.4348423", "0.4345312", "0.43368354", "0.4317966", "0.4314959", "0.43146804", "0.4305921", "0.43002266", "0.42878127", "0.42757308", "0.42743742", "0.4269287", "0.4269033", "0.42648476", "0.42632914", "0.4258371", "0.4256924" ]
0.73073494
0
Returns a set of 3 points along a convex subsection of the polygon
def convex_sub_polygon subsets = [] vertices.each_cons(3) do |p1, p2, p3| subsets << [p2, [p1, p2, p3]] end subsets.sort.first.last end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def polygon_vertices(sides, size)\n return [CP::Vec2.new(-size, size), CP::Vec2.new(size, size), CP::Vec2.new(size, -size), CP::Vec2.new(-size, -size)]\n end", "def sample_polygon\n polygon(200, [[10.0, 10.0], [180.0, 20.0], [160.0, 150.0], [100.0, 50.0], [20.0,180.0]])\nend", "def get_3d_polygon()\n height = get_keyword_value(\"HEIGHT\").to_f\n width = get_keyword_value(\"WIDTH\").to_f\n x = self.check_keyword?(\"X\")? self.get_keyword_value(\"X\").to_f : 0.0\n y = self.check_keyword?(\"Y\")? self.get_keyword_value(\"Y\").to_f : 0.0\n #counter clockwise\n origin = OpenStudio::Point3d.new( x, y , 0.0 )\n p2 = OpenStudio::Point3d.new(x + width , y,0.0 )\n p3 = OpenStudio::Point3d.new(x + width , y + height , 0.0 )\n p4 = OpenStudio::Point3d.new(x, y + height,0.0 )\n return [origin,p2,p3,p4]\n end", "def convex_hull\n a = @points.to_a\n left = a.first\n a = a[1..-1]\n right = a.pop\n puts \"left = #{left} right = #{right} a = #{a.map{|p| p.to_s}.join(\", \")}\" if @debug\n upper = []\n lower = []\n # Partition remaining points into upper and lower buckets\n a.each do |p|\n dir = direction(left, right, p)\n puts \"p = #{p} dir = #{dir}\" if @debug\n if dir < 0\n upper << p\n else\n lower << p\n end\n end\n puts \"upper = #{upper.map{|p| p.to_s}.join(', ')}\" if @debug\n puts \"lower = #{lower.map{|p| p.to_s}.join(', ')}\" if @debug\n upper_hull = half_hull(left, right, upper, -1)\n lower_hull = half_hull(left, right, lower, 1)\n puts \"upper_hull = #{upper_hull.map{|p| p.to_s}.join(', ')}\" if @debug\n puts \"lower_hull = #{lower_hull.map{|p| p.to_s}.join(', ')}\" if @debug\n (upper_hull + lower_hull).uniq\n end", "def mesh_points( subdivs, transformation )\r\n points = []\r\n for patch in @patches\r\n points.concat( patch.mesh_points( subdivs, transformation ).to_a )\r\n end\r\n points = TT::Point3d.extend_all( points ) # So that .uniq! works\r\n points.uniq!\r\n points\r\n end", "def intersection(other)\n intersection_result = []\n \n if other.is_a?(Polygon) \n k = other.sides \n else \n k = [other]\n end\n\n self.sides.each do |side|\n k.each do |side1|\n intersection_result += side.intersection(side1)\n end\n end\n\n intersection_result.uniq! do |a|\n if a.is_a?(Point)\n [a.x, a.y]\n else\n [a.p1, a.p2].sort_by {|p| [p.x, p.y]} \n end\n end\n points = []; segments = []\n\n intersection_result.each do |entity|\n points << entity if entity.is_a?(Point)\n segments << entity if entity.is_a?(Segment)\n end\n\n if !points.empty? && !segments.empty?\n points_in_segments = []\n\n points.each do |point|\n segments.each do |segment|\n points_in_segments << point if segment.contains?(point)\n end\n end\n\n points_in_segments.uniq! {|a| [a.x, a.y]}\n if !points_in_segments.empty?\n points_in_segments.each do |p|\n points.delete(p)\n end\n end\n\n return points.sort + segments.sort\n end\n\n return intersection_result.sort\n end", "def test_nonconvex\n nonconvex_polygon = Polygon.new [\n Point(0, 0),\n Point(0, 6),\n Point(4, 6),\n Point(4, 4),\n Point(2, 4),\n Point(2, 2),\n Point(4, 2),\n Point(4, 0)\n ]\n\n inner_points = [\n Point(1, 5),\n Point(3, 5),\n Point(1, 3),\n Point(1, 1),\n Point(3, 1)\n ]\n\n outer_points = [\n Point(7, 5),\n Point(5, 3),\n Point(7, 3),\n Point(7, 1)\n ]\n\n inner_points.each do |inner_point|\n assert nonconvex_polygon.contains?(inner_point)\n end\n\n outer_points.each do |outer_point|\n assert ! nonconvex_polygon.contains?(outer_point)\n end\n end", "def test_nonconvex\n nonconvex_polygon = Polygon.new [\n Point(0, 0),\n Point(0, 6),\n Point(4, 6),\n Point(4, 4),\n Point(2, 4),\n Point(2, 2),\n Point(4, 2),\n Point(4, 0)\n ]\n\n inner_points = [\n Point(1, 5),\n Point(3, 5),\n Point(1, 3),\n Point(1, 1),\n Point(3, 1)\n ]\n\n outer_points = [\n Point(7, 5),\n Point(5, 3),\n Point(7, 3),\n Point(7, 1)\n ]\n\n inner_points.each do |inner_point|\n assert nonconvex_polygon.contains?(inner_point)\n end\n\n outer_points.each do |outer_point|\n assert ! nonconvex_polygon.contains?(outer_point)\n end\n end", "def polygon_vertices(sides, size)\n vertices = []\n sides.times do |i|\n angle = -2 * Math::PI * i / sides\n vertices << radians_to_vec2(angle) * size\n end\n return vertices\n end", "def polygon\n respond_to?(:constituencyAreaExtent) ? constituencyAreaExtent : []\n end", "def polygon_vertices(sides, size)\n vertices = []\n sides.times do |i|\n angle = -2 * Math::PI * i / sides\n vertices << angle.radians_to_vec2() * size\n end\n return vertices\n end", "def as_polygon\n GeoRuby::SimpleFeatures::Polygon.from_points([@points[0] == @points[-1] ? @points : (@points + [@points[0].clone])])\n end", "def getVertices( x0, y0, x1, y1) # arguments define bounding box\n\t\tw, h = x1 - x0, y1 - y0\n\t\td = 5 # size of corner chip\n\n\t\t[\n\t\t\t[ d, 0], [ w - d, 0],\n [ w, d], [w, h - d],\n [ w - d, h], [ d, h],\n [ 0, h - d], [ 0, d]\n\t\t].map do |v| [ v[0] + x0, v[1] + y0 ] end.flatten\n\tend", "def points\n object.polygon.points\n end", "def polygons_points(p_polygon)\n # initialization\n points = \"\"\n i_polygon = 0\n current_hexagon = p_polygon[:enveloppe][0]\n i_connection = p_polygon[:connections][0].index(\"0\")\n initial_vertex = \"#{current_hexagon.to_s},#{VERTICES[i_connection].to_s}\"\n done = false\n \n until done\n while not done and p_polygon[:connections][i_polygon][i_connection] == \"0\"\n done = initial_vertex == \"#{current_hexagon.to_s},#{VERTICES[i_connection].to_s}\" unless points.empty?\n unless done\n vertex = VERTICES[i_connection]\n points << \"#{x_vertex(current_hexagon, vertex).floor},#{y_vertex(current_hexagon, vertex).floor} \"\n i_connection == 5 ? i_connection = 0 : i_connection += 1\n end\n end\n \n if not done and i_connection < 6 then\n current_hexagon = adjacent(current_hexagon, EDGES[i_connection])\n i_polygon = p_polygon[:enveloppe].index(current_hexagon)\n i_connection -= 2\n i_connection += 6 unless i_connection >= 0\n end \n end\n \n return points.chop\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def triangulate(vertices)\n\t\tedges = []\n tris = []\n # sort by X coord\n vertices = vertices.sort_by {|p|p.x}\n # center/radius cache used by circum_circle\n cc_cache = {}\n\n # Set up the supertriangle\n # This is a triangle which encompasses all the sample points.\n # The supertriangle coordinates are added to the end of the\n # vertex list. The supertriangle is the first triangle in\n # the triangle list.\n number_of_vertices = vertices.size\n\t\tbounding_p1, bounding_p2, bounding_p3 = get_bounding_vertices(vertices)\n\t\tvertices << bounding_p1 << bounding_p2 << bounding_p3\n\t\ttris << ITRIANGLE.new(number_of_vertices, number_of_vertices+1, number_of_vertices+2)\n\n # Include each point one at a time into the existing mesh\n vertices.each_with_index { |current_point, i|\n edges.clear\n # Set up the edge buffer.\n # If the point (xp,yp) lies inside the circumcircle then the\n # three edges of that triangle are added to the edge buffer\n # and that triangle is removed.\n j = 0\n\t\t\ttris_size = tris.size\n\t\t\twhile j < tris_size\n\t\t\t\tcurrent_triangle = tris[j]\n if !current_triangle.complete\n p1 = vertices[current_triangle.p1]\n p2 = vertices[current_triangle.p2]\n p3 = vertices[current_triangle.p3]\n inside,xc,yc,r = circum_circle(current_point, p1, p2, p3, cc_cache)\n if (xc + r) < current_point.x\n current_triangle.complete = true\n end\n if inside\n\t\t\t\t\t\tedges << IEDGE.new(current_triangle.p1, current_triangle.p2)\n edges << IEDGE.new(current_triangle.p2, current_triangle.p3)\n edges << IEDGE.new(current_triangle.p3, current_triangle.p1)\n tris.delete_at(j)\n\t\t\t\t\t\ttris_size -= 1\n j -= 1\n end\n end\n j += 1\n end #while j\n\t\t\t\n\t\t\twhile !edges.empty?\n\t\t\t\tedge = edges.shift\n\t\t\t\trejected = edges.reject! {|e| e == edge}\n\t\t\t\ttris << ITRIANGLE.new(edge.p1, edge.p2, i) if rejected.nil? \n\t\t \tend\n \n } #each i\n \n\t\t# Remove supertriangle vertices\n\t\t3.times do \n\t\t\tvertices.pop\n\t\tend\n\t\tnumber_of_vertices = vertices.size\n\n # Remove triangles with supertriangle vertices\n # These are triangles which have a vertex number greater than number_of_vertices\n\t\ttris.delete_if {|tri| tri.p1 >= number_of_vertices || tri.p2 >= number_of_vertices || tri.p3 >= number_of_vertices}\n\n [ vertices, tris ]\n end", "def hull_points(hull)\n points = []\n hull.map {|x| points.push(x[0],x[1])}\n points.uniq\nend", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def points_for_polygon(x, y, r, sides, options={})\n cur_page.points_for_polygon(x, y, r, sides, options)\n end", "def calculate_concave_points\n # Requires polygon to be clockwise, we'll go ahead and do this here\n verify_clockwise\n\n @concave_points = []\n 0.upto(length - 1) do |index|\n if (concave?(index))\n @concave_points.push(self[index])\n end\n end\n end", "def convex_hull\n raise Error::UnsupportedOperation, \"Method Geometry#convex_hull not defined.\"\n end", "def triangle_point(sPoint, a, b, c)\r\n pts = []\r\n pts[0] = sPoint\r\n pts[1] = Geom::Point3d.new(sPoint[0] + a, sPoint[1], sPoint[2])\r\n a = a.to_f\r\n b = b.to_f\r\n c = c.to_f\r\n dx = (b*b - c*c + a*a) / (2*a)\r\n dy = Math.sqrt(b*b - dx*dx)\r\n pts[2] = Geom::Point3d.new(sPoint[0] + dx, sPoint[1] + dy, sPoint[2])\r\n return pts\r\nend", "def mesh_vertices\r\n # private ?\r\n d = TT::Instance.definition( @instance )\r\n transformation = @instance.model.edit_transform\r\n points = mesh_points( final_subdivs, transformation )\r\n vertices = raw_mesh_vertices()\r\n\r\n # <debug>\r\n unless points.size == vertices.size\r\n Console.log( 'mesh_vertices' )\r\n Console.log( \"> Points: #{points.size}\" )\r\n Console.log( \"> Vertices: #{vertices.size}\" )\r\n end\r\n # </debug>\r\n\r\n patch_vertices = []\r\n for point in points\r\n vertex = vertices.find { |v| v.position == point } # (!) Optimize\r\n patch_vertices << vertex\r\n vertices.delete( vertex )\r\n end\r\n patch_vertices\r\n end", "def Point3dInPolygonXY(arg0, arg1, arg2 = nil)\n ret = _invoke(1610744132, [arg0, arg1, arg2], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_ARRAY | VT_DISPATCH, VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def getVertices( x0, y0, x1, y1) # arguments define bounding box\n\t\tw, h = x1 - x0, y1 - y0\n\t\thh = (h/2).to_i\n\n\t\t[\n\t\t\t[ hh, 0], [ w - hh, 0], [ w, hh], [ w - hh, h], [ hh, h], [ 0, hh]\n\t\t].map do |v| [ v[0] + x0, v[1] + y0 ] end.flatten\n\tend", "def polygon *points, color\n points << points.first\n points.each_cons(2) do |p1, p2|\n w.line(*p1, *p2, color)\n end\n end", "def get_contour_points_adv()\r\n result = []\r\n idx = 0\r\n result[idx] = Offset.vertices(@active_face.outer_loop.vertices, -(@bit_diameter * 0.5)).offsetPoints\r\n# puts \" outer #{result[idx].length} #{result[idx]} \"\r\n @active_face.loops.each { |lp|\r\n if (!lp.outer?)\r\n idx += 1\r\n result[idx] = Offset.vertices(lp.vertices, -(@bit_diameter * 0.5) ).offsetPoints \r\n# puts \" inner[#{idx}] #{result[idx]}\" \r\n end\r\n }\r\n return result \r\nend", "def subdivide\n ab = (midpoint a, b).normalize\n bc = (midpoint b, c).normalize\n ca = (midpoint c, a).normalize\n smallerTriangles = Array.new\n smallerTriangles << (Triangle.new a, ab, ca)\n smallerTriangles << (Triangle.new ab, b, bc)\n smallerTriangles << (Triangle.new bc, c, ca)\n smallerTriangles << (Triangle.new ab, bc, ca)\n end", "def vertices\n [\n @origin,\n { x: x_max, y: y_min, z: z_min },\n { x: x_min, y: y_max, z: z_min },\n { x: x_min, y: y_min, z: z_max },\n { x: x_max, y: y_max, z: z_min },\n { x: x_max, y: y_min, z: z_max },\n { x: x_min, y: y_max, z: z_max },\n { x: x_max, y: y_max, z: z_max }\n ]\n end", "def points_of_subset_simple subset\n subset = subset.to_s(2)\n (2 ... subset.length+1).find_all { |i| subset[-i,1] == '1' }\n end", "def points_of_subset_fast subset, options={}\n points_of_subset = []\n lower_range_bound = options[:omit_first] ? 2 : 1\n power = 1; while (2**power <= subset) do power +=1 end\n\n (lower_range_bound .. power).each do |i|\n points_of_subset << i if (subset & 2**(i-1) == 2**(i-1))\n end\n points_of_subset\n end", "def polygon(x, y, r, sides, options={})\n cur_page.polygon(x, y, r, sides, options)\n end", "def points_n2\n result = [:infinity]\n (0...@p).each do |x|\n (0...@p).each do |y|\n point = [x,y]\n result << point if valid?(point)\n end\n end\n result\n end", "def [] (index)\n if (@points.length == 0)\n raise \"cannot get any points from an empty polygon\"\n end\n while (index < 0)\n index += @points.length\n end\n while (index > @points.length - 1)\n index -= @points.length\n end\n @points[index]\n end", "def bounding_box\r\n max_x, min_x, max_y, min_y = -Float::MAX, Float::MAX, -Float::MAX, Float::MAX, -Float::MAX, Float::MAX \r\n if with_z\r\n max_z, min_z = -Float::MAX, Float::MAX\r\n each do |geometry|\r\n bbox = geometry.bounding_box\r\n sw = bbox[0]\r\n ne = bbox[1]\r\n \r\n max_y = ne.y if ne.y > max_y\r\n min_y = sw.y if sw.y < min_y\r\n max_x = ne.x if ne.x > max_x\r\n min_x = sw.x if sw.x < min_x \r\n max_z = ne.z if ne.z > max_z\r\n min_z = sw.z if sw.z < min_z \r\n end\r\n [Point.from_x_y_z(min_x,min_y,min_z),Point.from_x_y_z(max_x,max_y,max_z)]\r\n else\r\n each do |geometry|\r\n bbox = geometry.bounding_box\r\n sw = bbox[0]\r\n ne = bbox[1]\r\n \r\n max_y = ne.y if ne.y > max_y\r\n min_y = sw.y if sw.y < min_y\r\n max_x = ne.x if ne.x > max_x\r\n min_x = sw.x if sw.x < min_x \r\n end\r\n [Point.from_x_y(min_x,min_y),Point.from_x_y(max_x,max_y)]\r\n end\r\n end", "def check_polygon\n return false if @points.length < 3\n zpoints = Array.new(@points)\n zpoints += [@points[0], @points[1]]\n side_prev = zcrossproduct(zpoints[0], zpoints[1], zpoints[2])\n for i in 1...(zpoints.length-2)\n side_next = zcrossproduct(zpoints[i], zpoints[i+1], zpoints[i+2])\n return false if (side_prev * side_next < 0)\n end\n return true\n end", "def test_inside_non_overlapping()\n shape_ds = Gdal::Ogr.open('../../ogr/data/testpoly.shp')\n shape_lyr = shape_ds.get_layer(0)\n\n shape_lyr.set_spatial_filter_rect( -10, -130, 10, -110 )\n assert(check_features_against_list( shape_lyr, 'FID',\n [ 13 ] ))\n end", "def envelope_to_polygon\n exp = /^\\s*ENVELOPE\\(\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*,\n \\s*([-.\\d]+)\\s*\n \\)\\s*$/x # uses 'x' option for free-spacing mode\n bbox_match = exp.match(geom)\n minx, maxx, maxy, miny = bbox_match.captures\n \"POLYGON ((#{minx} #{maxy}, #{minx} #{miny}, #{maxx} #{miny}, #{maxx} #{maxy}, #{minx} #{maxy}))\"\n end", "def getPolyCoordinates(radius, lat, lon, num_sides)\r\n # Create array to the radian values of the regular polygon\r\n rads = (0..2*Math::PI).step((2 * Math::PI) / num_sides.to_f).to_a\r\n\r\n # Compute angular distance (meters)\r\n ang_dist = (radius.to_f / EARTH_RAD_M.to_f) #*(Math::PI/180.0)\r\n lat_rad = lat * Math::PI/180.0\r\n lon_rad = lon * Math::PI/180.0\r\n\r\n # Constants\r\n a = Math.sin(lat_rad) * Math.cos(ang_dist)\r\n b = Math.cos(lat_rad) * Math.sin(ang_dist)\r\n\r\n # Loop over radians (clockwise) to compute geo points of the polygon\r\n points = Array.new\r\n cnt = 0\r\n rads.each do |r|\r\n # new point latitude (in radians)\r\n new_lat = Math.asin(a + b * Math.cos(r)) \r\n\r\n # new point longitude (in radians)\r\n c = Math.cos(ang_dist) - Math.sin(lat_rad) * Math.sin(new_lat)\r\n new_lon = lon_rad + Math.atan2(Math.sin(r) * Math.sin(ang_dist) * Math.cos(lat_rad), c)\r\n\r\n # Store (in degrees)\r\n points[cnt] = {:lat => new_lat*180.0/Math::PI, :lon => new_lon*180.0/Math::PI}\r\n cnt += 1\r\n end\r\n\r\n return points\r\n end", "def get_intersection\n end", "def petunin(points)\n\tif points.size() < 4\n\t\tputs \"Error on #{__LINE__} in #{__FILE__}\"\n\t\texit(1)\n\tend\n\t#return [x,x0,y,y0]\n\trect = find_rect(points)\n\tdx, phi, coef = get_transf_coef(rect)\n\tdx.each {}\n\t#rect = translate(rect, -dx[0], -dx[1])\n\trect = rotate(rect, phi)\n\trect = scale(rect, 1.0, coef)\n\n\t#points = translate(points, -dx[0], -dx[1])\n\tpoints = rotate(points,phi)\n\tpoints = scale(points, 1, coef)\n\n\tcentre = rect[0].zip(rect[2]).to_a.map { |u,v| (u+v)/2 }\n\trs = []\n\tpoints.each do |p|\n\t\trs << [dist(p, centre), p]\n\tend\n\trs = rs.sort\n\n\tres = []\n\n\trs.each do |r,p|\n\t\tel = Ellipse.new\n\t\tel.centre = centre\n\t\tel.axes = [r]*2\n\n\t\t#back\n\t\tel.scale(1, 1/coef)\n\n\t\tel.rotate(-phi)\n\t\tres << [el,p]\n\tend\n\n\treturn res\n\n\t# For testing reasons only\n\n\t#rect = scale(rect, 1, 1/coef)\n\t#points = scale(points, 1, 1/coef)\n\t#rect = rotate(rect, -phi)\n\t#points = rotate(points, -phi)\n\t#points.map! { |x| [x] }\n\n\t#points + [rect] + res.inject([]) { |sum,el| sum + [el.get_draw_data] }\nend", "def is_convex?\n return @is_convex if defined?(@is_convex)\n\n @is_convex = false\n\n cw = Polygon.is_right?(vertices[-2], vertices[-1], vertices[0])\n (1...vertices.length).each do |i|\n if cw ^ Polygon.is_right?(vertices[i - 2], vertices[i - 1], vertices[i])\n return @is_convex\n end\n end\n\n # check for intersecting sides\n sides = self.sides\n sides.each_with_index do |si, i|\n points = [si.p1, si.p2]\n\n first_number = 0\n first_number = 1 if i == sides.length - 1\n (first_number...i - 1).each do |j|\n sj = sides[j]\n if !points.include?(sj.p1) && !points.include?(sj.p2)\n hit = si.intersection(sj)\n return @is_convex if !hit.empty?\n end\n end\n end\n \n @is_convex = !@is_convex\n @is_convex\n end", "def bounding_box\r\n unless with_z\r\n [Point.from_x_y(@x,@y),Point.from_x_y(@x,@y)]\r\n else\r\n [Point.from_x_y_z(@x,@y,@z),Point.from_x_y_z(@x,@y,@z)]\r\n end\r\n end", "def minimal_convex_hull_2d(points)\n return points if points.empty? || points.size == 1 || points.size == 2\n\n points.sort_by! { |p| [p.x, p.y] }\n p1 = points[0]\n p2 = points.last\n up = [p1]\n down = [p1]\n\n (1...points.size).each do |i|\n point = points[i]\n if i == points.size - 1 || clockwise(p1, point, p2)\n while up.size >= 2 && !clockwise(up[up.size - 2], up[up.size - 1], point)\n up.pop\n end\n up.push(point)\n end\n\n if i == points.size - 1 || counter_clockwise(p1, point, p2)\n while down.size >= 2 && !counter_clockwise(down[down.size - 2], down[down.size - 1], point)\n down.pop\n end\n down.push(point)\n end\n end\n hull = []\n (0...up.size).each do |j|\n hull.push(up[j])\n end\n (1..(down.size - 2)).reverse_each do |j|\n puts j\n hull.push(down[j])\n end\n hull\n end", "def find_feature_center(vertices)\n number_of_locations = vertices.length\n\n return vertices.first if number_of_locations == 1\n\n x = y = z = 0.0\n vertices.each do |station|\n latitude = station[1] * Math::PI / 180\n longitude = station[0] * Math::PI / 180\n\n x += Math.cos(latitude) * Math.cos(longitude)\n y += Math.cos(latitude) * Math.sin(longitude)\n z += Math.sin(latitude)\n end\n\n x /= number_of_locations\n y /= number_of_locations\n z /= number_of_locations\n\n central_longitude = Math.atan2(y, x)\n central_square_root = Math.sqrt(x * x + y * y)\n central_latitude = Math.atan2(z, central_square_root)\n\n [central_longitude * 180 / Math::PI,\n central_latitude * 180 / Math::PI]\n \n end", "def crossPointsAround\n [KBPoint.new.init([x+1,y]),KBPoint.new.init([x-1,y]),KBPoint.new.init([x,y-1]),KBPoint.new.init([x,y+1])]\n end", "def bounds\n return [] unless @grpc.bounding_poly\n @bounds ||= Array(@grpc.bounding_poly.vertices).map do |v|\n Vertex.from_grpc v\n end\n end", "def bounds\n return [] unless @grpc.bounding_poly\n @bounds ||= Array(@grpc.bounding_poly.vertices).map do |v|\n Vertex.from_grpc v\n end\n end", "def bounds\n return [] unless @grpc.bounding_poly\n @bounds ||= Array(@grpc.bounding_poly.vertices).map do |v|\n Vertex.from_grpc v\n end\n end", "def vertices\n vertices = []\n\n vertices << [(@origin[0] + @l/2.0), (@origin[1] + @h/2.0), (@origin[2] + @w/2.0)]\n vertices << [(@origin[0] + @l/2.0), (@origin[1] + @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] + @l/2.0), (@origin[1] - @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] + @l/2.0), (@origin[1] - @h/2.0), (@origin[2] + @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] - @h/2.0), (@origin[2] + @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] - @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] + @h/2.0), (@origin[2] - @w/2.0)]\n vertices << [(@origin[0] - @l/2.0), (@origin[1] + @h/2.0), (@origin[2] + @w/2.0)]\n\n vertices\n end", "def bisectors\n s = self.sides.map { |side| Line.new(side.p1, side.p2) }\n c = self.incenter\n\n inter1 = Line.new(self.vertices[0], c).intersection(s[1]).first\n inter2 = Line.new(self.vertices[1], c).intersection(s[2]).first\n inter3 = Line.new(self.vertices[2], c).intersection(s[0]).first\n\n {\n self.vertices[0] => Segment.new(self.vertices[0], inter1), \n self.vertices[1] => Segment.new(self.vertices[1], inter2),\n self.vertices[2] => Segment.new(self.vertices[2], inter3),\n }\n end", "def polygon(options={},&block)\n set RGhost::Polygon.new(options,&block)\n end", "def bounds\n return [] unless @grpc.bounding_poly\n @bounds ||= Array(@grpc.bounding_poly.vertices).map do |v|\n Vertex.from_grpc v\n end\n end", "def [](index)\n return nil unless index.between?(0, vertex_count - 1)\n vertex = Vector.zero\n FMOD.invoke(:Geometry_GetPolygonVertex, @geometry, @index, index, vertex)\n vertex\n end", "def cross(v1, v2)\n dx, dy = v2[0] - v1[0], v2[1] - v1[1]\n cr = [] # array containing intersections\n\n if dx == 0 and dy ==0 then\n\tnc = 0\n elsif dx == 0 then\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n elsif dy == 0 then\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n else\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy \n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n end\n return cr\n end", "def point_is_inside_poly(poly_verts, point)\n count = poly_verts.count\n intersections = 0\n\n poly_verts.each_with_index do |face_start, i|\n face_end = poly_verts[(i+1) % count]\n\n if line_line_intersection(V.new(0, 0), point, face_start, face_end)\n intersections += 1\n end\n end\n\n !intersections.modulo(2).zero?\n end", "def sector_a_intfx_coords\n [ [-1.5 * @radius, @radius], [-1.5 * @radius, -@radius], \n [-1.5 * @radius, 3 * @radius], [-3 * @radius, 2 * @radius],\n [-3 * @radius, 0], [-3 * @radius, -2 * @radius],\n [-1.5 * @radius, -3 * @radius] ]\n end", "def pfsub(x, y, z)\r\n (Math.sqrt(z) - y) / x / 2.0\r\n end", "def vertices\n VertexList.new(1, nil, [@centre])\n end", "def getPolygonPoints(n, rx = 50,ry=50,a=0,tx=Graphics.width/2,ty=Graphics.height/2)\n points = []\n ang = 360/n\n n.times do\n b = a*(Math::PI/180)\n r = rx*Math.cos(b).abs + ry*Math.sin(b).abs\n x = tx + r*Math.cos(b)\n y = ty - r*Math.sin(b)\n points.push([x,y])\n a += ang\n end\n return points\nend", "def initialize(polygon)\n a = 2 * (polygon.p2.x - polygon.p1.x)\n b = 2 * (polygon.p2.y - polygon.p1.y)\n c = 2 * (polygon.p2.x - polygon.p3.x)\n d = 2 * (polygon.p2.y - polygon.p3.y)\n e = polygon.p2.x*polygon.p2.x + polygon.p2.y*polygon.p2.y - polygon.p1.x*polygon.p1.x - polygon.p1.y*polygon.p1.y\n f = polygon.p2.x*polygon.p2.x + polygon.p2.y*polygon.p2.y - polygon.p3.x*polygon.p3.x - polygon.p3.y*polygon.p3.y\n \n det = a*d - b*c\n\n x = (d*e - b*f)/det\n y = (a*f - c*e)/det\n r = Math.sqrt((polygon.p1.x - x)**2 + (polygon.p1.y - y)**2)\n \n @middle = Point.new(x, y)\n @radius = r\n end", "def Segment3dPlane3dIntersect(arg0, arg1, arg2, arg3)\n ret = _invoke(1610744270, [arg0, arg1, arg2, arg3], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def find_farthest_points(vertices_hash)\n @positive_x = center.x + radius\n @positive_y = center.y + radius\n # In case the convexity is pointing down the negative direction of the x or y axis.\n @negative_x = center.x - radius\n @negative_y = center.y - radius\n end", "def sub_identities(point)\r\n identities = Array.new\r\n subtracted_point = sub(point)\r\n identities << subtracted_point.identity_x unless subtracted_point.x == 0\r\n identities << subtracted_point.identity_y unless subtracted_point.y == 0\r\n return identities\r\n end", "def intersection\n self.reduce(&:intersection)\n end", "def intersection( to )\n cp = self.pos.to_gpos\n sp = self.size.to_gpos\n line = cp.to_vec( to )\n\n n = line.rad\n a = sp.x\n b = sp.y\n\n div = Math.sqrt( ( b*Math.cos(n) ) ** 2 + ( a*Math.sin(n) ) ** 2 )\n px = ( a * b * Math.cos(n) ) / div\n py = ( a * b * Math.sin(n) ) / div\n\n cp.to_vec + Gvec[ px, py ]\n end", "def test_is_polygon_with_polygon\n m = Sketchup.active_model\n ents = m.entities\n\n # Create a polygon\n center = [0, 0, 0]\n normal = [0, 0, 1]\n radius = 20\n nsides = 8\n ents.add_ngon center, normal, radius, nsides\n\n # Check poly edges\n m.entities.each do |e|\n if e.is_a? Sketchup::Edge and e.curve.respond_to? 'is_polygon?'\n assert_equal(true, e.curve.is_polygon?,\n 'Curve of polygon edge should be polygon.')\n end\n end\n end", "def vertices\n @vertices\n end", "def check_interior(polygon, point)\n sum = 0\n polygon.each_index do |i|\n next_i = i + 1\n next_i = 0 if next_i >= polygon.size\n sum += compute_angle(\n [polygon[i][0] - point[0],\n polygon[i][1] - point[1],\n polygon[i][2] - point[2]],\n [polygon[next_i][0] - point[0],\n polygon[next_i][1] - point[1],\n polygon[next_i][2] - point[2]],\n )\n end\n\n (sum >= 2*3.1415926 and sum <= 2*3.1415927) or\n check_border(polygon, point)\n end", "def Segment3dSegment3dIntersectXY(arg0, arg1, arg2, arg3, arg4, arg5)\n ret = _invoke(1610744251, [arg0, arg1, arg2, arg3, arg4, arg5], [VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_R8, VT_BYREF | VT_DISPATCH, VT_BYREF | VT_R8])\n @lastargs = WIN32OLE::ARGV\n ret\n end", "def vertices\n @vertices\n end", "def intersection( to )\n cp = self.pos.to_gpos\n\n line = cp.to_vec( to )\n uline = line.unit\n radius = uline * size.x\n\n ( cp.to_vec + radius ).to_gpos\n end", "def intersects(shape)\n p1 = shape.points.length - 1\n for p2 in 0...shape.points.length\n p3 = @points.length - 1\n for p4 in 0...@points.length\n return true if segments_intersection(shape.points[p1], shape.points[p2], @points[p3], @points[p4])\n p3 = p4\n p4 += 1\n end\n p1 = p2\n p2 += 1\n end\n return false\n end", "def bounding_box\n if with_z\n [Point.from_x_y_z(@x, @y, @z), Point.from_x_y_z(@x, @y, @z)]\n else\n [Point.from_x_y(@x, @y), Point.from_x_y(@x, @y)]\n end\n end", "def points_on_circle(center, normal, radius, numseg)\r\n # Get the x and y axes\r\n axes = Geom::Vector3d.new(normal).axes\r\n center = Geom::Point3d.new(center)\r\n xaxis = axes[0]\r\n yaxis = axes[1]\r\n \r\n xaxis.length = radius\r\n yaxis.length = radius\r\n\r\n # compute the points\r\n da = (Math::PI * 2) / numseg\r\n pts = []\r\n for i in 0...numseg do\r\n angle = i * da\r\n cosa = Math.cos(angle)\r\n sina = Math.sin(angle)\r\n vec = Geom::Vector3d.linear_combination(cosa, xaxis, sina, yaxis)\r\n pts.push(center + vec)\r\n end\r\n \r\n # close the circle\r\n pts.push(pts[0].clone)\r\n\r\n pts\r\nend", "def intersectPoint p\n if real_close_point(x,y,p.x,p.y) then self\n else NoPoints.new\n end\n end", "def signedVolumeOfTriangle(p1, p2, p3)\n v321 = p3[0]*p2[1]*p1[2]\n v231 = p2[0]*p3[1]*p1[2]\n v312 = p3[0]*p1[1]*p2[2]\n v132 = p1[0]*p3[1]*p2[2]\n v213 = p2[0]*p1[1]*p3[2]\n v123 = p1[0]*p2[1]*p3[2]\n return (1.0/6.0)*(-v321 + v231 + v312 - v132 - v213 + v123)\n end", "def vertices\n (0...vertex_count).map { |i| self[i] }\n end", "def subdivisions; end", "def get_feature_subset\n # feature subset\n subset = []\n \n # step 1: calc SU(i,c) for each feature\n f2su = {}\n get_features.each do |f|\n su = get_SU_fc(f)\n f2su[f] = su\n if su >= @delta\n subset << f\n end\n end\n \n # step 2: order subset by decreasing feature SU of\n subset = subset.sort { |x,y| f2su[y] <=> f2su[x] }\n \n # step 3: main algo\n fp = subset.first\n while fp\n fq = get_next_element(subset, fp)\n \n while fq\n su_pq = get_SU_pq(fp, fq)\n \n if su_pq >= f2su[fq]\n fq_new = get_next_element(subset, fq)\n subset.delete(fq) #remove fq\n fq = fq_new\n else\n fq = get_next_element(subset, fq)\n end\n end\n \n fp = get_next_element(subset, fp)\n end\n \n subset\n end", "def find_subsets_of_points(options={})\n puts \"Calculating subsets\"\n puts \"Set of #{@points_amount} points: 2^#{@points_amount} subsets = #{2**@points_amount} different subsets\"\n @points_subsets = Array.new(@points_amount) { Array.new }\n # amount of all subsets of a set 2^n-1 (-1, as we're excluding the empty set {})\n (1..2**@points.length-1).each { |i|\n p i if i%100000 == 0\n subset_size = subset_size(i)\n if (options[:with_first_point_only] != true) || (options[:with_first_point_only] == true and i % 2 == 1)\n @points_subsets[subset_size-1] << i\n end\n }\n\n (2..@points_amount).each do |subset_size|\n subsets = @points_subsets[subset_size-1]\n puts \"Subset size: \" + subset_size.to_s + \"; Subsets total: \" + subsets.size.to_s\n end\n\n puts \"Done calculating subsets\"\n end", "def polygon\n raise OSMLib::Error::NoDatabaseError.new(\"can't create Polygon from relation if it is not in a OSMLib::Database\") if @db.nil?\n raise OSMLib::Error::NoDatabaseError.new(\"can't create Polygon from relation if it does not represent a polygon\") if self['type'] != 'multipolygon' and self['type'] != 'polygon'\n\n c = []\n member_objects.each do |way|\n raise TypeError.new(\"member is not a way so it can't be represented as Polygon\") unless way.kind_of? OSMLib::Element::Way\n raise OSMLib::Error::NotClosedError.new(\"way is not closed so it can't be represented as Polygon\") unless way.is_closed?\n raise OSMLib::Error::GeometryError.new(\"way with less then three nodes can't be turned into a polygon\") if way.nodes.size < 3\n c << way.node_objects.collect{ |node| [node.lon.to_f, node.lat.to_f] }\n end\n GeoRuby::SimpleFeatures::Polygon.from_coordinates(c)\n end", "def intersect( v1, v2 )\n b1, b2 = bound( v1 ), bound( v2 )\n cr = []\n if b1 && b2 then\n\tres = 0\n elsif b1 then\n\tcr = cross( v1, v2 )\n\tres =1\n elsif b2 then \n\tcr = cross( v1, v2 )\n\tres =2\n else\n\tcr = cross( v1, v2 )\n\tif cr.size == 2 then\n\t res = 3\n\telse\n\t res = 4\n\tend\n end\n return res, cr\n end", "def check_interior(check, point1, point2, point3)\n # Points on a vertex cannot be interior; due to precision issues, we\n # need to make an explicit check for this\n if (check.same?(point1) || check.same?(point2) || check.same?(point3))\n return false\n end\n # Unlike the above function, this can be negative; in fact, if the\n # triangle is wound counter-clockwise (I think) it needs to be for\n # the rest of the math to work out\n area = (point1.x * (point2.y - point3.y) +\n point2.x * (point3.y - point1.y) +\n point3.x * (point1.y - point2.y))/2\n s = 1 / (2 * area) * (point1.y * point3.x - point1.x * point3.y +\n (point3.y - point1.y) * check.x +\n (point1.x - point3.x)*check.y);\n t = 1 / (2 * area) * (point1.x * point2.y - point1.y * point2.x +\n (point1.y - point2.y) * check.x +\n (point2.x - point1.x)*check.y);\n if (s > 0 && t > 0 && 1 - s - t > 0)\n return true\n end\n return false\nend", "def point_in_polygon(p, poly)\n UNIT_SQUARE.position.set(p)\n T_RESPONSE.clear\n result = test_polygon_polygon(UNIT_SQUARE, poly, T_RESPONSE)\n result = T_RESPONSE.a_in_b if result\n result\n end", "def get_polygons_from_faces(ent, recursive = true, transform = true)\n faces = []\n MSketchyPhysics3.get_entities(ent).each { |e|\n if((e.is_a?(Sketchup::Group) || e.is_a?(Sketchup::ComponentInstance)) && recursive &&\n !e.get_attribute('SPOBJ', 'ignore', false) && !e.attribute_dictionary('SPJOINT', false))\n faces.concat get_polygons_from_faces(e, true, true)\n next\n end\n next unless e.is_a?(Sketchup::Face)\n e.mesh.polygons.each_index{ |i|\n pts = []\n e.mesh.polygon_points_at(i+1).each { |pt| pts << pt.to_a }\n faces << pts\n }\n }\n if transform\n tra = ent.transformation\n faces.each { |face|\n face.each { |pt| pt.transform!(tra) }\n }\n end\n faces\n end", "def subdivision\n @subdivision\n end", "def polygon_area(vertices)\n raise \"A polygon must have 3 or more vertices, not #{vertices.length}\" unless vertices.length >= 3\n\n area = 0\n\n # Rely on Ruby's circular array indexing for negative indices\n vertices.size.times do |idx|\n x2, y2 = vertices[idx]\n x1, y1 = vertices[idx - 1]\n area += x1 * y2 - x2 * y1\n end\n\n return area * 0.5\n end", "def third_degree_neighbors(edges, start)\nend", "def subset_bounding_box *indices\n subset = @vbuffer.nget([*indices].flatten)\n Cuboid.new subset.min(1).to_a, subset.max(1).to_a\n end", "def -(polygon)\n\t\t\tps = Polygon_set_2.difference_polygons_with_holes root, polygon.root\n\t\t\tps.to_a.collect{|pwh| Polygon.new(pwh)}\n\t\tend", "def is_encloses_point?(point)\n point = Point.new(point[0], point[1]) if point.is_a?(Array)\n raise TypeError, 'Must pass only Point objects' unless point.is_a?(Point)\n\n return false if vertices.include?(point)\n\n sides.each do |s|\n return false if s.contains?(point)\n end\n\n # move to point, checking that the result is numeric\n lit = []\n vertices.each do |v|\n lit << v - point\n end\n\n poly = Polygon.new(*lit)\n # polygon closure is assumed in the following test but Polygon removes duplicate pts so\n # the last point has to be added so all sides are computed. Using Polygon.sides is\n # not good since Segments are unordered.\n args = poly.vertices\n indices = (-args.length..0).to_a\n\n if poly.is_convex?\n orientation = nil\n indices.each do |i|\n a = args[i]\n b = args[i + 1]\n test = ((-a.y)*(b.x - a.x) - (-a.x)*(b.y - a.y)) < 0\n \n if orientation.nil?\n orientation = test\n elsif test != orientation\n return false\n end\n end\n\n return true\n end\n\n hit_odd = false\n p1x, p1y = args[0].x, args[0].y\n indices[1..-1].each do |i|\n p2x, p2y = args[i].x, args[i].y\n\n if [p1y, p2y].min < 0 && [p1y, p2y].max >= 0 && \n [p1x, p2x].max >= 0 && p1y != p2y\n\n xinters = (-p1y)*(p2x - p1x)/(p2y - p1y) + p1x\n hit_odd = !hit_odd if p1x == p2x or 0 <= xinters \n end \n\n p1x, p1y = p2x, p2y\n end\n\n return hit_odd\n end", "def get_vertices_from_faces(ent, recursive = true, transform = true)\n pts = []\n MSketchyPhysics3.get_entities(ent).each { |e|\n if((e.is_a?(Sketchup::Group) || e.is_a?(Sketchup::ComponentInstance)) && recursive &&\n !e.get_attribute('SPOBJ', 'ignore', false) && !e.attribute_dictionary('SPJOINT', nil))\n pts.concat get_vertices_from_faces(e, true, true)\n next\n end\n next unless e.is_a?(Sketchup::Face)\n e.vertices.each { |v| pts << v.position.to_a }\n }\n if transform\n tra = ent.transformation\n pts.each { |pt| pt.transform!(tra) }\n end\n pts.uniq!\n pts\n end", "def cull_overlap_for_list(list)\n offset = list.length/10\n i = offset\n while i < list.length-offset-1\n line1 = Curves::LineSegment.new(list[i], list[i+1])\n\n j = i+1\n while j < list.length-offset\n line2 = Curves::LineSegment.new(list[j], list[j+1])\n\n if (intersection = line1.intersection(line2))\n while i < j\n i += 1\n list[i] = intersection\n end\n return\n end\n\n j += 1\n end\n\n i += 1\n end\n end", "def vertices(filter = {})\n return @vertices if filter.empty?\n\n Set.new(@vertices.select { |vertex| vertex.match?(filter) })\n end", "def get_hatch_points_x(points, x)\r\n plane = [Geom::Point3d.new(x, 0, 0), Geom::Vector3d.new(1,0,0)]\r\n pts = []\r\n for i in 0..points.length-1 do\r\n x1 = points[i-1].x\r\n x2 = points[i].x\r\n\r\n# next if (x1 == x2)\r\n# next if ((x1 > x2) && ((x > x1) || (x < x2)))\r\n# next if ((x1 < x2) && ((x < x1) || (x > x2)))\r\n if ((x1 - x2).abs < 0.001)\r\n next\r\n end\r\n d1 = x - x1\r\n d2 = x - x2\r\n if ((x1 > x2) && ((d1 > 0.0001) || (d2 < -0.0001))) # the signs are important\r\n next\r\n end\r\n if ((x1 < x2) && ((d1 < -0.0001) || (d2 > 0.0001)))\r\n next\r\n end\r\n\r\n line = [points[i-1], points[i]]\r\n# puts \"#{line} #{x.to_mm}\"\r\n pt = Geom::intersect_line_plane(line, plane)\r\n if (pt)\r\n pts << pt\r\n end\r\n end #for\r\n pts.uniq!\r\n return pts.sort{|a,b| a.y <=> b.y}\r\n end" ]
[ "0.66696864", "0.6127653", "0.59551084", "0.5934988", "0.58613807", "0.58403933", "0.5786485", "0.5786485", "0.5766312", "0.57596177", "0.5756885", "0.5746187", "0.573527", "0.57215947", "0.56538755", "0.5618196", "0.5618196", "0.5618196", "0.56045294", "0.5539671", "0.552242", "0.552242", "0.5517174", "0.5505903", "0.5478587", "0.54773587", "0.54247874", "0.5406991", "0.53931123", "0.53919864", "0.5390086", "0.5368681", "0.5326547", "0.530305", "0.52358985", "0.5206112", "0.5182893", "0.51678157", "0.51402956", "0.5137656", "0.51009434", "0.50922686", "0.5076323", "0.5066919", "0.5034387", "0.5021937", "0.5013132", "0.5011977", "0.50118625", "0.5008403", "0.4996211", "0.4996211", "0.4996211", "0.49903893", "0.4969031", "0.49620038", "0.49489558", "0.49442226", "0.49328905", "0.49301663", "0.4928205", "0.49209607", "0.49191862", "0.49169764", "0.49155113", "0.49070653", "0.48993737", "0.48980105", "0.48948237", "0.4871507", "0.4865778", "0.48617685", "0.48480526", "0.48459032", "0.4842373", "0.48189595", "0.48172724", "0.48087296", "0.48033914", "0.4802294", "0.4793712", "0.4791012", "0.47874254", "0.47872496", "0.47841007", "0.47814855", "0.47793362", "0.4777184", "0.47717232", "0.4770962", "0.4770704", "0.47684944", "0.47654185", "0.47638732", "0.47628957", "0.47599703", "0.47564295", "0.4751236", "0.47496986", "0.47438252" ]
0.8318579
0
delta: Integer Offset amount
def offset(delta, dist = 1.5) # set delta according to polygon direction, set veriables for first and last p/l delta = delta * orientation p_first, p_last = nil; offset_lines = [] l_first, l_last = nil; offset_points = [] refined_points = [] # Offset lines between 2 consecutive vertices out by delta vertices.each_cons(2) do |p1, p2| p_first ||= p1; p_last = p2 # save first and last vector for final line offset_lines << offset_line(p1, p2, delta) end offset_lines << offset_line(p_last, p_first, delta) # Calculate intersections between adjacent lines for new vertices offset_lines.each_cons(2) do |l1, l2| l_first ||= l1; l_last = l2 # save first and last vector for final intersection offset_points << line_intersection(l1, l2) end offset_points.insert(0, line_intersection(l_first, l_last)) # Smooth corners of very acute angles offset_points.each_with_index do |p, key| v = p - vertices[key] if v.magnitude > (dist * delta).abs p2 = vertices[key] + v.normalize * dist * delta.abs # normal vector for 2 vertices through a point dist*delta away cutoff_line = [p2, p2 + v.normal_vector] [-1, 0].each do |i| if key + i < 0 n = offset_lines.size - 1 elsif key + i >= offset_lines.size n = 0 else n = key + i end refined_points << line_intersection(cutoff_line, offset_lines[n]) end else refined_points << p end end refined_points end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def offset(original, new)\n return 0 unless original && new\n relative = (new - original).abs\n relative = -relative if new < original\n relative\n end", "def delta\n @end_point - @start_point\n rescue\n 0\n end", "def default_offset_amount\n 50\n end", "def parse_delta_offset\n offset = -1\n hdr_size = 0\n begin\n hdr = byte\n hdr_size += 1\n continue = hdr & 0b10000000\n low_offset = hdr & 0b01111111\n offset = ((offset + 1) << 7) | low_offset\n end while continue != 0\n return [offset, hdr_size]\n end", "def sum_offset\n offset + operand.offset\n end", "def delta\n @delta ||= @max - @min\n end", "def offset\n @offset/86400.0\n end", "def shift_output_offsets(delta)\n return if delta == 0\n @data.each do |m|\n break if m.output.start_pos.line > 1\n m.output.start_pos.offset += delta\n m.output.end_pos.offset += delta if m.output.end_pos.line > 1\n end\n end", "def offset\n\t\t\t@position + @offset\n\t\tend", "def delta(a, b)\n 0 - (delta_value(a) - delta_value(b))*3 - side_delta(a,b)\n end", "def delta\n prev = self.val\n self.class.new(self) do |v, s|\n v - prev.tap { prev = v }\n end\n end", "def column_delta; end", "def length_to_delta(length)\n return (@ppqn * length).to_i\n end", "def offset; end", "def offset; end", "def offset; end", "def normalize_offset(offset); end", "def offset_in_days\n return @offset_in_days\n end", "def current_offset; end", "def advance ( delta=0 ) \n @actual += delta\n @current = @actual + offset\n @current_offset = @current.to_i/60 - @actual.to_i/60\n @updated = Time.new\n @update_count += 1\n self\n end", "def offset(*) end", "def offset_sec\n @offset\n end", "def offset\n operation.offset\n end", "def offset(arg0)\n end", "def b_offset\n @last_4[1].to_i\n end", "def diff\n @start_position - @position\n end", "def calculateOffset(index, offset)\n index += offset\n index -= 26 while index >= 26 # keep subtracting until we get to the right range\n index\n end", "def delta(length)\n fragment = (@lsn_no % LOG_BLOCK_SIZE) - LOG_BLOCK_HEADER_SIZE\n raise \"Invalid fragment #{fragment} for LSN #{@lsn_no}\" unless fragment.between?(0, LOG_BLOCK_DATA_SIZE - 1)\n\n length + ((fragment + length) / LOG_BLOCK_DATA_SIZE * LOG_BLOCK_FRAME_SIZE)\n end", "def get_offset\n @offset\n end", "def offset()\n @offset__\n end", "def derive_offsets(transitions, offsets); end", "def derive_offsets(transitions, offsets); end", "def offset\n 1\n end", "def view_offset\n @position + @view.position\n end", "def offset\n loffset + 6\n end", "def x_offset; end", "def position_quantity_delta\n (trade_order.is_long? == trade_order.is_buy?) ? quantity : -quantity\n end", "def column_deltas; end", "def x_offset angle, distance\n\t\t\tdistance * Math.sin(angle * Math::PI/180)\n\t\tend", "def original_query_offset\n (hits_requested - 1) / 2\n end", "def balance_delta\n prepared.map(&:amount_with_sign).reduce(:+)\n end", "def utc_total_offset; end", "def utc_total_offset; end", "def utc_total_offset; end", "def utc_total_offset; end", "def shifted_diff(first, second)\n return -1\nend", "def delta(delta_x, delta_y)\n execute(:delta, delta_x, delta_y)\n end", "def amount\n difference\n end", "def change_margin(delta)\n # binding.pry\n calc = delta.to_f/100.0\n new_sellprice = @costprice.to_f / (1.0-calc)\n self.sellprice = new_sellprice.to_i\n self.update()\n end", "def delta_x(x_position, x)\n (x - x_position).abs\n end", "def previous_offset\n @previous_offset ||= if after\n offset_from_cursor(after)\n elsif before\n offset_from_cursor(before) - (last ? last : 0) - 1\n else\n 0\n end\n end", "def current_position\n @start_position + delta\n end", "def modulus\n distance_to(origin)\n end", "def calculate_offset(page)\n if page && page != '1'\n (page.to_i - 1) * 20 - 1\n else\n 0\n end\nend", "def update_mouse_delta_index(delta)\n new_index = (@index + delta).clamp(0, @scroll_bar.max_index)\n delta = new_index - @index\n return if delta == 0\n if delta.abs < 5\n @index = new_index if delta.abs == 1\n animate_list_index_change(delta)\n else\n @index = new_index\n update_item_button_list\n update_info\n @scroll_bar.index = @index\n end\n end", "def change_offset(working_offset, state)\n if state.offset > working_offset\n working_offset\n else\n state.offset = state.next_offset\n end\n end", "def delta(v1, v2)\n if block_given?\n v1 = yield(v1)\n v2 = yield(v2)\n end\n return (v1 - v2).abs\n end", "def offset_in_days=(value)\n @offset_in_days = value\n end", "def y_offset angle, distance\n\t\t\tdistance * Math.cos(angle * Math::PI/180) * -1\n\t\tend", "def offset\n (current_page * size) - size\n end", "def offset\n (current_page - 1) * per_page\n end", "def calc_input_offset\n if input_count.zero?\n 0\n else\n buffer.abs_offset\n end\n end", "def offset\n (current_page - 1) * per_page\n end", "def offset\n (current_page - 1) * per_page\n end", "def offset\n (current_page - 1) * per_page\n end", "def showOffsetDelta\n offset = Integer(params[:offset]) * Integer(params[:delta])\n @user = User.offset(offset).limit(params[:delta])\n @user = @user.order('name ASC')\n render json: @user\n end", "def shift_output_lines(delta)\n return if delta == 0\n @data.each do |m|\n m.output.start_pos.line += delta\n m.output.end_pos.line += delta\n end\n end", "def getOffset\r\n div = (@stepOver >= 0.75) ? 3 : 2\r\n if (@stepOver >= 0.85)\r\n div = 4\r\n end\r\n if @keyflag == 1\r\n offset = @bit_diameter * @stepOver / div\r\n else\r\n offset = @bit_diameter * 0.5 + @bit_diameter * @stepOver / div\r\n end\r\n# if @keyflag == 1 # then only zigzag\r\n# offset = @bit_diameter * 0.1\r\n# else\r\n# offset = @bit_diameter * 0.6 #zigzag plus outline so leave space for outline\r\n# end\r\n return offset\r\n end", "def get_current_offset\n @offset < 0 ? 0 : @offset\n end", "def gain_multiplier(delta)\n self.multiplier += delta\n if multiplier < 0\n delta -= multiplier\n self.multiplier = 0\n end\n delta\n end", "def offset\n (page - 1) * PER_PAGE\n end", "def update_offset\n @offset_counter[1] += 0.01\n @offset_counter[1]=@offset_counter[1]%90\n @offset[1] = 30*Math.sin(@offset_counter[1]);\n @offset_counter[0]+=0.005\n @offset_counter[0]=@offset_counter[0]%90\n @offset[0] = 150*Math.sin(@offset_counter[0]);\n # @offset=[0,0]\n end", "def offset_changes\n changes(col_offset: @col_offset, row_offset: @row_offset)\n end", "def offset\n execute['offset']\n end", "def view_offset\n @position + Moon::Vector3[@view.position, 0]\n end", "def offset\n @offset ||= (position.unitless? || position.unit_str == \"px\") ? position.value : 0\n end", "def to_find_offset\n @offset\n end", "def determine_offset( image )\n offset_value = offset.is_a?( Rational ) ? image.size( axis ) * offset.to_f : offset\n return offset_value.to_i\n end", "def column_deltas=(_arg0); end", "def angle_delta_epsilon() \r\n Celes.nut06a(@ajd, 0)[ 1 ]\r\n end", "def offset\n (current_page - 1) * per_page\n end", "def content_offset(offset, dimension)\n return 0 unless offset >= dimension\n\n offset - dimension\n end", "def piezo_offset=(val)\n unless val < -13.5 or val > 13.5\n self.send_message(\":Piezo:Offset #{val}\")\n end\n end", "def move\n unless moved?\n offset = @deltas.pop\n @moved = true\n end\n end", "def offset(vector, length=vector.length)\n end", "def angle_delta_psi() \r\n Celes.nut06a(@ajd, 0)[ 0 ]\r\n end", "def transition(offset_id, timestamp_value); end", "def timestamp_delta\n @timestamp_delta ||= @records.empty? ? 0.0 : (@records.last.timestamp - @records.first.timestamp)\n end", "def utilityF(delta)\n\treturn 1.0 if delta <= 0\n\treturn 2.0 ** (-delta / 30.0)\nend", "def delta\n deltas = self.class.delta_documents(@parsed)\n self.class.friendly_deltas(deltas, @parsed)\n end", "def offset_on_line(offset)\n end", "def y_offset; end", "def apply_x_dodge_offset(val)\n @offset = 0 if @offset.nil?\n val += (get_direction == 8 ? @offset : get_direction == 6 ? -(@offset) : 0)\n return val\n end", "def move_diffs\n \n end", "def offset_self( peer, len )\n v1 = to_vec( peer )\n v2 = v1.adjust_len( len )\n peer.dup - v2.to_pos\n end", "def set_period_position_delta\n @period_offset = @freq / @sample_rate\n end", "def gain_points(delta)\n self.points_gained += delta\n max_points = 100\n\n # Total points must not exceed 100\n if points_base + points_gained > max_points\n delta -= max_points - (points_base + points_gained)\n self.points_base = max_points - points_gained\n end\n\n # Increase the multiplier\n gain_multiplier delta\n end", "def offset_after_match\n offset + match_length\n end", "def first_offset; end", "def first_offset; end", "def lines_offset\n @starting_line - 1\n end" ]
[ "0.67868996", "0.6737235", "0.66251934", "0.65755844", "0.6481874", "0.6390515", "0.6336367", "0.62968785", "0.6202527", "0.6200202", "0.61609715", "0.6159524", "0.6131591", "0.61085075", "0.61085075", "0.61085075", "0.6083769", "0.60678715", "0.6055821", "0.6011714", "0.599795", "0.59851867", "0.5930804", "0.59267694", "0.5893786", "0.5869661", "0.5831461", "0.58286846", "0.57992655", "0.57965714", "0.5772824", "0.5772824", "0.57707083", "0.5757174", "0.57564414", "0.57467645", "0.5738001", "0.5708946", "0.57065547", "0.570343", "0.5698429", "0.5697515", "0.5697515", "0.5697515", "0.5697515", "0.56941587", "0.56873345", "0.5677339", "0.56660396", "0.5639022", "0.56347996", "0.5624391", "0.56236345", "0.5610431", "0.560885", "0.5594704", "0.5593229", "0.5582864", "0.55825716", "0.55791986", "0.5575744", "0.55663115", "0.55610573", "0.55610573", "0.55610573", "0.5555935", "0.5547785", "0.5534402", "0.5529491", "0.5529405", "0.55275387", "0.55265003", "0.55182064", "0.5515796", "0.5512183", "0.550674", "0.550537", "0.5502924", "0.5496759", "0.547826", "0.5476557", "0.5460389", "0.5448783", "0.54311866", "0.5430183", "0.5422029", "0.5421238", "0.5414041", "0.5406683", "0.54009074", "0.53998166", "0.5391612", "0.5390857", "0.5360513", "0.5359119", "0.5345679", "0.5340015", "0.53333205", "0.53299135", "0.53299135", "0.53274846" ]
0.0
-1
calculate line intersections most likely used to calculate new points for an offset polygon
def line_intersection(l1, l2) x1 = l1[0][0]; x2 = l1[1][0]; x3 = l2[0][0]; x4 = l2[1][0] y1 = l1[0][1]; y2 = l1[1][1]; y3 = l2[0][1]; y4 = l2[1][1] denominator = (x1-x2)*(y3-y4) - (y1-y2)*(x3-x4) return false if denominator == 0 dxy12 = (x1*y2 - y1*x2) dxy34 = (x3*y4 - y3*x4) x = (dxy12*(x3-x4) - (x1-x2)*dxy34) / denominator y = (dxy12*(y3-y4) - (y1-y2)*dxy34) / denominator WorldGen::Vector[x.round, y.round] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def offset(delta, dist = 1.5)\n # set delta according to polygon direction, set veriables for first and last p/l\n delta = delta * orientation\n p_first, p_last = nil; offset_lines = []\n l_first, l_last = nil; offset_points = []\n refined_points = []\n\n # Offset lines between 2 consecutive vertices out by delta\n vertices.each_cons(2) do |p1, p2|\n p_first ||= p1; p_last = p2 # save first and last vector for final line\n offset_lines << offset_line(p1, p2, delta)\n end\n offset_lines << offset_line(p_last, p_first, delta)\n\n # Calculate intersections between adjacent lines for new vertices\n offset_lines.each_cons(2) do |l1, l2|\n l_first ||= l1; l_last = l2 # save first and last vector for final intersection\n offset_points << line_intersection(l1, l2)\n end\n offset_points.insert(0, line_intersection(l_first, l_last))\n\n # Smooth corners of very acute angles\n offset_points.each_with_index do |p, key|\n v = p - vertices[key]\n if v.magnitude > (dist * delta).abs\n p2 = vertices[key] + v.normalize * dist * delta.abs\n # normal vector for 2 vertices through a point dist*delta away\n cutoff_line = [p2, p2 + v.normal_vector]\n [-1, 0].each do |i|\n if key + i < 0\n n = offset_lines.size - 1\n elsif key + i >= offset_lines.size\n n = 0\n else\n n = key + i\n end\n refined_points << line_intersection(cutoff_line, offset_lines[n])\n end\n else\n refined_points << p\n end\n end\n refined_points\n end", "def line_intersection(x1, y1, x2, y2, x3, y3, x4, y4)\n # calculate vector products\n d1 = (x3 - x1) * (y4 - y1) - (x4 - x1) * (y3 - y1)\n d2 = (x3 - x2) * (y4 - y2) - (x4 - x2) * (y3 - y2)\n d3 = (x1 - x3) * (y2 - y3) - (x2 - x3) * (y1 - y3)\n d4 = (x1 - x4) * (y2 - y4) - (x2 - x4) * (y1 - y4)\n # check vector product results\n if (d1 > 0 && d2 < 0 || d1 < 0 && d2 > 0) &&\n (d3 > 0 && d4 < 0 || d3 < 0 && d4 > 0)\n # intersection exists\n return true\n end\n # if at least one point of one line lies on the other line\n if d1 == 0 && (x3 < x4 ? x3 : x4) <= x1 && x1 <= (x3 > x4 ? x3 : x4) &&\n (y3 < y4 ? y3 : y4) <= y1 && y1 <= (y3 > y4 ? y3 : y4) ||\n d2 == 0 && (x3 < x4 ? x3 : x4) <= x2 && x2 <= (x3 > x4 ? x3 : x4) &&\n (y3 < y4 ? y3 : y4) <= y2 && y2 <= (y3 > y4 ? y3 : y4) ||\n d3 == 0 && (x1 < x2 ? x1 : x2) <= x3 && x3 <= (x1 > x2 ? x1 : x2) &&\n (y1 < y2 ? y1 : y2) <= y3 && y3 <= (y1 > y2 ? y1 : y2) ||\n d4 == 0 && (x1 < x2 ? x1 : x2) <= x4 && x4 <= (x1 > x2 ? x1 : x2) &&\n (y1 < y2 ? y1 : y2) <= y4 && y4 <= (y1 > y2 ? y1 : y2)\n # intersection exists\n return true\n end\n # intersection does not exist\n return false\n end", "def line_line_intersect(pt_intersect, new_list, seg, new_seg)\n\n new_list << LineSeg.new(seg.pt1, pt_intersect)\n new_list << LineSeg.new(pt_intersect, seg.pt2)\n\n return [LineSeg.new(new_seg.pt1, pt_intersect), LineSeg.new(pt_intersect, new_seg.pt2)]\n\n end", "def calculate_points(lines)\n points = lines.map do |line|\n if line.p1.x == line.p2.x\n ys = Range.new(*[line.p1.y, line.p2.y].sort).to_a\n xs = [line.p1.x] * ys.size\n elsif line.p1.y == line.p2.y\n xs = Range.new(*[line.p1.x, line.p2.x].sort).to_a\n ys = [line.p1.y] * xs.size\n else\n # Diagonal line\n # Sort by x axis\n p1, p2 = [line.p1, line.p2].sort_by(&:x)\n xs = Range.new(*[p1.x, p2.x]).to_a\n if p1.y > p2.y \n # negative slope (reverse so we can still use range)\n ys = Range.new(*[p2.y, p1.y]).to_a.reverse\n else\n # positive slope\n ys = Range.new(*[p1.y, p2.y]).to_a\n end\n end\n xs.zip(ys).map { |c| Point.new(*c) }\n end\nend", "def line_line_intersection(l1s, l1e, l2s, l2e)\n seg1 = l1e - l1s\n seg2 = l2e - l2s\n\n d = (-seg2.x * seg1.y + seg1.x * seg2.y)\n\n s = (-seg1.y * (l1s.x - l2s.x) + seg1.x * (l1s.y - l2s.y)) / d;\n t = ( seg2.x * (l1s.y - l2s.y) - seg2.y * (l1s.x - l2s.x)) / d;\n\n if s > 0 && s < 1 && t > 0 && t < 1\n x = l1s.x + (t * seg1.x)\n y = l1s.y + (t * seg1.y)\n\n V.new(x, y)\n end\n end", "def check_intersection(line1, line2)\n # Lines that share an endpoint cannot intersect; due to precision\n # issues, we need to make an explicit check for this, and stick\n # a delta on it besides\n if (check_endpoints(line1, line2, POINT_DELTA))\n return false\n end\n x1 = line1.start_point.x\n x2 = line1.end_point.x\n x3 = line2.start_point.x\n x4 = line2.end_point.x\n y1 = line1.start_point.y\n y2 = line1.end_point.y\n y3 = line2.start_point.y\n y4 = line2.end_point.y\n den = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4)\n point_x = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - x4 * y3)\n if (den == 0)\n return false\n end\n point_x = point_x / den\n if ((x1 > x2 && point_x >= x1) || (x1 < x2 && point_x <= x1) ||\n (x3 > x4 && point_x >= x3) || (x3 < x4 && point_x <= x3) ||\n (x1 > x2 && point_x <= x2) || (x1 < x2 && point_x >= x2) ||\n (x3 > x4 && point_x <= x4) || (x3 < x4 && point_x >= x4))\n return false\n end\n # The above fails for any perfectly (or, due to precision issues,\n # sufficiently) vertical lines that would intersect (if extended to)\n # the other line; check y instead in that case:\n if ((x1 + POINT_DELTA > x2 && x1 - POINT_DELTA < x2) ||\n (x3 + POINT_DELTA > x4 && x3 - POINT_DELTA < x4))\n point_y = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - x4 * y3)\n point_y = point_y / den\n if ((y1 > y2 && point_y >= y1) || (y1 < y2 && point_y <= y1) ||\n (y3 > y4 && point_y >= y3) || (y3 < y4 && point_y <= y3) ||\n (y1 > y2 && point_y <= y2) || (y1 < y2 && point_y >= y2) ||\n (y3 > y4 && point_y <= y4) || (y3 < y4 && point_y >= y4))\n return false\n end\n end\n return true\nend", "def find_edge_intersecting_with_line(poly_verts, line_start, line_end)\n count = poly_verts.count\n\n poly_verts.each_with_index do |face_start, i|\n face_end = poly_verts[(i+1) % count]\n\n contact_loc = line_line_intersection(face_start, face_end, line_start, line_end)\n\n if contact_loc\n edge = Edge.new(face_start, face_end)\n edge.contact_loc = contact_loc\n return edge\n end\n end\n\n nil\n end", "def line_intersect_line?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end", "def segments_intersect?(line_one, line_two)\n x1 = line_one[:x]\n y1 = line_one[:y]\n x2 = line_one[:x2]\n y2 = line_one[:y2]\n\n x3 = line_two[:x]\n y3 = line_two[:y]\n x4 = line_two[:x2]\n y4 = line_two[:y2]\n\n uA = ((x4-x3)*(y1-y3) - (y4-y3)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n uB = ((x2-x1)*(y1-y3) - (y2-y1)*(x1-x3)) / ((y4-y3)*(x2-x1) - (x4-x3)*(y2-y1))\n\n uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1\n end", "def cross(v1, v2)\n dx, dy = v2[0] - v1[0], v2[1] - v1[1]\n cr = [] # array containing intersections\n\n if dx == 0 and dy ==0 then\n\tnc = 0\n elsif dx == 0 then\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n elsif dy == 0 then\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n else\n\tt = ( 0.0 - v1[1] ) / dy # y = 0\n\tx , y = v1[0] + t * dx, v1[1] + t * dy\n cr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[1] ) / dy # y = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if x >= 0 && x <= 1 && t >= 0 && t <= 1\n\tt = ( 0.0 - v1[0] ) / dx # x = 0\n\tx, y = v1[0] + t * dx, v1[1] + t * dy\n\tcr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n\tt = ( 1.0 - v1[0] ) / dx # x = 1\n\tx, y = v1[0] + t * dx, v1[1] + t * dy \n cr.push( [x, y] ) if y >= 0 && y <= 1 && t >= 0 && t <= 1\n end\n return cr\n end", "def intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n dx, dy = bx - ax, by - ay\n ex, ey = px - ix, py - iy\n denominator = (dx*ey) - (dy*ex)\n return 0 if denominator == 0\n t = (ix*ey + ex*ay - ax*ey - ex*iy) / denominator\n return 0 if t < 0 || t >= 1\n u = (dx*ay - dx*iy - dy*ax + dy*ix) / denominator\n return 0 if u < 0 || u >= 1\n return 1\n end", "def cull_overlap_for_list(list)\n offset = list.length/10\n i = offset\n while i < list.length-offset-1\n line1 = Curves::LineSegment.new(list[i], list[i+1])\n\n j = i+1\n while j < list.length-offset\n line2 = Curves::LineSegment.new(list[j], list[j+1])\n\n if (intersection = line1.intersection(line2))\n while i < j\n i += 1\n list[i] = intersection\n end\n return\n end\n\n j += 1\n end\n\n i += 1\n end\n end", "def get_line(x0,x1,y0,y1)\n points = []\n steep = ((y1-y0).abs) > ((x1-x0).abs)\n if steep\n x0,y0 = y0,x0\n x1,y1 = y1,x1\n end\n if x0 > x1\n x0,x1 = x1,x0\n y0,y1 = y1,y0\n end\n deltax = x1-x0\n deltay = (y1-y0).abs\n error = (deltax / 2).to_i\n y = y0\n ystep = nil\n if y0 < y1\n ystep = 1\n else\n ystep = -1\n end\n for x in x0..x1\n if steep\n points << {:x => y, :y => x}\n else\n points << {:x => x, :y => y}\n end\n error -= deltay\n if error < 0\n y += ystep\n error += deltax\n end\n end\n return points\nend", "def bisectors\n s = self.sides.map { |side| Line.new(side.p1, side.p2) }\n c = self.incenter\n\n inter1 = Line.new(self.vertices[0], c).intersection(s[1]).first\n inter2 = Line.new(self.vertices[1], c).intersection(s[2]).first\n inter3 = Line.new(self.vertices[2], c).intersection(s[0]).first\n\n {\n self.vertices[0] => Segment.new(self.vertices[0], inter1), \n self.vertices[1] => Segment.new(self.vertices[1], inter2),\n self.vertices[2] => Segment.new(self.vertices[2], inter3),\n }\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def test_add_intersection\n # Intersection at (1,1)\n canon = CanonicalLineSegList.new\n canon.add(LineSeg.new(p(0,0), p(2,2)))\n canon.add(LineSeg.new(p(0,2), p(2,0)))\n assert_equal(4, canon.line_segs.size)\n expect(canon, \n [\n LineSeg.new(p(0,0), p(1,1)), LineSeg.new(p(1,1), p(2,2)),\n LineSeg.new(p(0,2), p(1,1)), LineSeg.new(p(1,1), p(2,0))\n ]\n )\n \n end", "def win_line_with_uniform_markers\n populated_win_lines.select do |line|\n pos1 = squares[line[0]]\n pos2 = squares[line[1]]\n pos3 = squares[line[2]]\n [pos1.marker, pos2.marker, pos3.marker].uniq.length == 1\n end\n end", "def line x0, y0, x1, y1, c\n dx = (x1 - x0).abs\n sx = x0 < x1 ? 1 : -1\n dy = (y1 - y0).abs\n sy = y0 < y1 ? 1 : -1\n err = (dx > dy ? dx : -dy) / 2\n \n loop do\n set x0, y0, c\n break if x0 === x1 && y0 === y1\n e2 = err\n if e2 > -dx\n err -= dy\n x0 += sx\n end \n if e2 < dy\n err += dx\n y0 += sy \n end\n end \n end", "def intersection(other)\n other = Point.new(other[0], other[1]) if other.is_a?(Array)\n\n # Other is a Point.\n if other.is_a?(Point)\n return [other] if self.contains?(other)\n return []\n end\n\n # Other is a LinearEntity\n if other.is_a?(LinearEntity)\n # break into cases based on whether\n # the lines are parallel, non-parallel intersecting, or skew\n rank = Point.affine_rank(self.p1, self.p2, other.p1, other.p2)\n if rank == 1\n # we're collinear\n return [other] if self.is_a?(Line)\n return [self] if other.is_a?(Line) \n \n if self.is_a?(Ray) && other.is_a?(Ray)\n return intersect_parallel_rays(self, other)\n end\n\n if self.is_a?(Ray) && other.is_a?(Segment)\n return intersect_parallel_ray_and_segment(self, other)\n end\n\n if self.is_a?(Segment) && other.is_a?(Ray)\n return intersect_parallel_ray_and_segment(other, self)\n end\n\n if self.is_a?(Segment) && other.is_a?(Segment)\n return intersect_parallel_segments(self, other)\n end\n\n elsif rank == 2\n # we're in the same plane\n l1 = Line.new(self.p1, self.p2)\n l2 = Line.new(other.p1, other.p2)\n\n # check to see if we're parallel. If we are, we can't\n # be intersecting, since the collinear case was already\n # handled\n return [] if l1.parallel_to?(l2)\n \n # Use Cramers rule:\n # https://en.wikipedia.org/wiki/Cramer%27s_rule\n det = l1.a * l2.b - l2.a * l1.b\n det = det\n x = (l1.b * l2.c - l1.c * l2.b) / det\n y = (l2.a * l1.c - l2.c * l1.a ) / det\n\n intersection_point = Point.new(x, y)\n\n # if we're both lines, we can skip a containment check\n return [intersection_point] if self.is_a?(Line) && other.is_a?(Line)\n \n if self.contains?(intersection_point) && other.contains?(intersection_point)\n return [intersection_point] \n end\n \n return []\n else\n # we're skew\n return []\n end\n end\n\n if other.respond_to?(:intersection)\n return other.intersection(self)\n end\n\n raise TypeError, \"Intersection between LinearEntity and #{ other.class } is not defined\"\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def terminus_line_intersect(pt_intersect, new_list, seg, new_seg)\n\n # Is the intersect at one of +new_seg+ terminii?\n # If so, split +seg+ into two segs at pt_intersect.\n if pt_intersect == new_seg.pt1 || pt_intersect == new_seg.pt2\n new_list << LineSeg.new(seg.pt1, pt_intersect)\n new_list << LineSeg.new(pt_intersect, seg.pt2)\n return []\n end\n\n # Does a +seg+ terminus lie along *new_seg+?\n #\n # If so, add +seg+ to the +new_list+ and return the two part of the slit +new_seg+\n if pt_intersect == seg.pt1 || pt_intersect == seg.pt2\n new_list << seg\n return [LineSeg.new(new_seg.pt1, pt_intersect), LineSeg.new(pt_intersect, new_seg.pt2)]\n end\n\n return nil\n end", "def line(x0, y0, x1, y1)\n # clean params\n x0, y0, x1, y1 = x0.to_i, y0.to_i, x1.to_i, y1.to_i\n y0, y1, x0, x1 = y1, y0, x1, x0 if y0>y1\n sx = (dx = x1-x0) < 0 ? -1 : 1 ; dx *= sx ; dy = y1-y0\n\n # special cases\n x0.step(x1,sx) { |x| point x, y0 } and return if dy.zero?\n y0.upto(y1) { |y| point x0, y } and return if dx.zero?\n x0.step(x1,sx) { |x| point x, y0; y0 += 1 } and return if dx==dy\n\n # main loops\n point x0, y0\n\n e_acc = 0\n if dy > dx\n e = (dx << 16) / dy\n y0.upto(y1-1) do\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xFFFF\n x0 += sx if (e_acc <= e_acc_temp)\n point x0, (y0 += 1), intensity(@color,(w=0xFF-(e_acc >> 8)))\n point x0+sx, y0, intensity(@color,(0xFF-w))\n end\n point x1, y1\n return\n end\n\n e = (dy << 16) / dx\n x0.step(x1-sx,sx) do\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xFFFF\n y0 += 1 if (e_acc <= e_acc_temp)\n point (x0 += sx), y0, intensity(@color,(w=0xFF-(e_acc >> 8)))\n point x0, y0+1, intensity(@color,(0xFF-w))\n end\n point x1, y1\n end", "def segments_intersection(a, b, c, d)\n denominator = (b.y - a.y)*(d.x - c.x) - (a.x - b.x)*(c.y - d.y) \n return false if denominator == 0\n x = ( (b.x - a.x) * (d.x - c.x) * (c.y - a.y) + (b.y - a.y) * (d.x - c.x) * a.x - (d.y - c.y) * (b.x - a.x) * c.x ) / denominator\n y = -( (b.y - a.y) * (d.y - c.y) * (c.x - a.x) + (b.x - a.x) * (d.y - c.y) * a.y - (d.x - c.x) * (b.y - a.y) * c.y ) / denominator\n if (x - a.x) * (x - b.x) <= 0 && (y - a.y) * (y - b.y) <= 0 && (x - c.x) * (x - d.x) <= 0 && (y - c.y) * (y - d.y) <= 0 \n return true\n else\n return false\n end\n end", "def lineIntersects _args\n \"lineIntersects _args;\" \n end", "def formPolygon?(lines)\n endpoints = {}\n\n lines.each do |l|\n [l.p1, l.p2].each do |p|\n endpoints[p.to_s] ||= []\n endpoints[p.to_s] << l\n end\n end\n\n # the algorithm is to follow the points until you end up at one that \n # you've already seen\n l = lines.first\n p = l.p1\n op = p\n begin\n ls = endpoints[p.to_s]\n return false if ls.nil?\n endpoints.delete p.to_s\n\n # get the line that we weren't on before\n ls.delete(l)\n l = ls[0]\n return false if l.nil? # this means that there weren't 2 lines with endpoint p\n\n # get the other point on that line\n p = (l.p1 == p) ? l.p2 : l.p1\n end until p == op\n\n return endpoints.length == 0\n end", "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 intersectWithSegmentAsLineResult seg\n # self is the intersection \n self\n end", "def get_line(x0,x1,y0,y1)\n \t\tpoints = []\n\t\tsteep = ((y1-y0).abs) > ((x1-x0).abs)\n\t\tif steep then\n\t\t\tx0,y0 = y0,x0\n\t\t\tx1,y1 = y1,x1\n\t\tend\n\t\tif x0 > x1\n\t\t\tx0,x1 = x1,x0\n\t\t\ty0,y1 = y1,y0\n\t\tend\n\t\tdeltax = x1-x0\n\t\tdeltay = (y1-y0).abs\n\t\terror = (deltax / 2).to_i\n\t\ty = y0\n\t\tystep = nil\n\t\tif y0 < y1 then\n\t\t\tystep = 1\n\t\telse\n\t\t\tystep = -1\n\t\tend\n\t\tfor x in x0..x1\n\t\t\tif steep then\n\t\t\t\tpoints << {:x => y, :y => x}\n\t\t\telse\n\t\t\t\tpoints << {:x => x, :y => y}\n\t\t\tend\n\t\t\terror -= deltay\n\t\t\tif error < 0 then\n\t\t\t\ty += ystep\n\t\t\t\terror += deltax\n\t\t\tend\n\t\tend\n\t\treturn points\n\tend", "def intersectLineSegment seg\n # this is the intersect defined in method calling on \n # intersectlinesegment\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def intersection(lat, lng, r)\n \n # Convert degrees to meters\n x1 = Segment.length([lat, lng], [lat, @a[1]]) # lng\n x1 *= -1 if lng > @a[1]\n\n y1 = Segment.length([lat, lng], [@a[0], lng]) # lat\n y1 *= -1 if lat > @a[0]\n \n x2 = Segment.length([lat, lng], [lat, @b[1]]) # lng\n x2 *= -1 if lng > @b[1]\n\n y2 = Segment.length([lat, lng], [@b[0], lng]) # lat\n y2 *= -1 if lat > @b[0]\n \n # Circle equation: lat**2 + lng**2 = r**2\n # Segment equation: lat = y1 + (lng-x1)/(x2-x1) * (y2-y1)\n # See also: http://mathworld.wolfram.com/Circle-LineIntersection.html\n \n dx = x2 - x1\n dy = y2 - y1\n dr = Math.sqrt(dx**2 + dy**2) # Caution: this is estimation\n d = x1*y2 - x2*y1 \n delta = r**2 * dr**2 - d**2 \n\n sgn = lambda{ |x| x < 0 ? -1 : 1 }\n coordinates = lambda do |sign|\n x = (d*dy + sign * sgn[dy] * dx * Math.sqrt(delta)) / dr**2\n y = (-d*dx + sign * dy.abs * Math.sqrt(delta)) / dr**2\n\n intersection_lat = 180*y / (Math::PI * R) + lat\n intersection_lng = x / ( Math.cos(intersection_lat*Rad)*R) * (180/Math::PI) + lng\n \n [intersection_lat, intersection_lng] if (@a[1]..@b[1]).include?(intersection_lng) || (@b[1]..@a[1]).include?(intersection_lng) and\n (@a[0]..@b[0]).include?(intersection_lat) || (@b[0]..@a[0]).include?(intersection_lat)\n end\n \n if delta > 0\n # Return closest point (to point @a) of two\n [-1, 1].map{ |sign| coordinates[sign] }.compact.sort_by{|x,y| y }.first\n elsif delta == 0\n # Tangent line: only one point\n coordinates[0]\n else\n # No intersecting points\n nil\n end\n end", "def intersects_polygon?(coordinates, lat_start, lon_start, lat_end, lon_end)\n prev = coordinates.last\n does_intersect = false\n\n # checks if the line segment between start and end coordinates intersects any line segments in the polygon\n coordinates.each do |coord|\n a_lat = prev['lat']\n a_lon = prev['lon']\n b_lat = coord['lat']\n b_lon = coord['lon']\n\n # line segment intersection as described by http://stackoverflow.com/a/565282\n cmp_x, cmp_y = (lat_start - a_lat), (lon_start - a_lon)\n r_x, r_y = (b_lat - a_lat), (b_lon - a_lon)\n s_x, s_y = (lat_end - lat_start), (lon_end - lon_start)\n \n cmpxr = (cmp_x * r_y) - (cmp_y * r_x)\n cmpxs = (cmp_x * s_y) - (cmp_y * s_x)\n rxs = (r_x * s_y) - (r_y * s_x)\n \n rxsr = 1.0 / rxs\n t = cmpxs * rxsr\n u = cmpxr * rxsr\n \n if ((t >= 0.0) && (t <= 1.0) && (u >= 0.0) && (u <= 1.0))\n does_intersect = true\n end\n\n\n prev = coord\n end\n\n return does_intersect\n end", "def lines\n raise 'invalid polygon' unless valid?\n 0.upto(points.size - 1).collect do |i|\n Line.new(points[i % n], points[(i + 1) % n])\n end\n end", "def intersect point1, point2, a1, b1, x1, x2\n a2 = (point2.latitude - point1.latitude)/(point2.longitude-point1.longitude)\n b2 = point1.latitude - a2*point1.longitude\n x = (b2-b1)/(a1-a2)\n x3 = point1.longitude < point2.longitude ? point1.longitude : point2.longitude\n x4 = point1.longitude > point2.longitude ? point1.longitude : point2.longitude\n x >= x1 && x <= x2 && x >= x3 && x <= x4\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 intersection(other)\n # If rects don't overlap, then the line segments can't intersect.\n # Note that this handles the paralle case, as well as the case\n # where the intersection is outside the line segments.\n return nil unless rect_overlaps?(other)\n det = @a * other.b - other.a * @b\n # Shouldn't happen, but just in case.\n # Note: Everyting's an integer so far.\n return nil if det == 0\n\n x_float = (other.b * @c - @b * other.c).to_f / det.to_f\n y_float = (@a * other.c - other.a * @c).to_f / det.to_f\n \n intersect = Point.new(x_float.round, y_float.round)\n if rect.contains(intersect) && other.rect.contains(intersect)\n return intersect\n else\n return nil\n end\n end", "def getVertices( x0, y0, x1, y1) # arguments define bounding box\n\t\tw, h = x1 - x0, y1 - y0\n\t\td = 5 # size of corner chip\n\n\t\t[\n\t\t\t[ d, 0], [ w - d, 0],\n [ w, d], [w, h - d],\n [ w - d, h], [ d, h],\n [ 0, h - d], [ 0, d]\n\t\t].map do |v| [ v[0] + x0, v[1] + y0 ] end.flatten\n\tend", "def intersectLineSegment seg\n line_result = intersect(two_points_to_line(seg.x1,seg.y1,seg.x2,seg.y2))\n line_result.intersectWithSegmentAsLineResult seg\n end", "def points_on_a_line(x0, y0, x1, y1)\n raise NotImplementedError\n dx = (x1 - x0).abs\n dy = -(y1 - y0).abs\n step_x = x0 < x1 ? 1 : -1\n step_y = y0 < y1 ? 1 : -1\n err = dx + dy\n coords = Array.new\n coords << [x0, y0]\n (\n begin\n e2 = 2 * err\n\n if e2 >= dy\n err += dy\n x0 += step_x\n end\n\n if e2 <= dx\n err += dx\n y0 += step_y\n end\n\n coords << [x0, y0]\n end\n\n ) until (x0 == x1 && y0 == y1)\n coords\n end", "def calculate_coordinates\n (\n egde(@x1, @y1, @x2, @y1) +\n egde(@x2, @y1, @x2, @y2) +\n egde(@x2, @y2, @x1, @y2) +\n egde(@x1, @y2, @x1, @y1)\n ).uniq\n end", "def point_is_inside_poly(poly_verts, point)\n count = poly_verts.count\n intersections = 0\n\n poly_verts.each_with_index do |face_start, i|\n face_end = poly_verts[(i+1) % count]\n\n if line_line_intersection(V.new(0, 0), point, face_start, face_end)\n intersections += 1\n end\n end\n\n !intersections.modulo(2).zero?\n end", "def lineIntersectsObjs _args\n \"lineIntersectsObjs _args;\" \n end", "def intersection_segment(pt1, pt2, pt3, pt4)\n pt = intersection(pt1, pt2, pt3, pt4)\n \n segment_length = pt3.dist_to(pt4)\n \n dist3 = pt.dist_to(pt3)\n dist4 = pt.dist_to(pt4)\n \n if dist3 + dist4 == segment_length\n pt\n else\n nil\n end\n \n # slope = pt4.slope_to(pt3)\n # \n # y1 = pt.x * slope + pt3.y\n # y2 = pt.x * slope + pt4.y\n # \n # y1 == pt.y or y2 == pt.y\n end", "def lineoffsets\n result = {}\n offsetlines.each do |offset, lines|\n lines.each do |line|\n result[line] ||= []\n result[line] << offset\n end\n end\n result\n end", "def intersection_point(a1, a2, b1, b2)\n ip = nil\n bounds_x = bounds(a1.x, a2.x)\n bounds_y = bounds(a1.y, a2.y)\n # first line is horizontal\n if a1.y == a2.y\n # second line is vertical -> there can be an intersection\n if b2.x == b1.x\n ip = Coord2.new(b1.x, a1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.y, b2.y)\n\n return nil if b1.x < bounds_x[0] || b1.x > bounds_x[1]\n return nil if bounds_b[0] > bounds_y[0] || bounds_b[1] < bounds_y[1]\n end\n # first line is vertical\n elsif a1.x == a2.x\n # second line is horizontal -> there can be an intersection\n if b2.y == b1.y\n ip = Coord2.new(a1.x, b1.y)\n # Then we check if the point actually intersects\n bounds_b = bounds(b1.x, b2.x)\n return nil if b1.y < bounds_y[0] || b1.y > bounds_y[1]\n return nil if bounds_b[0] > bounds_x[0] || bounds_b[1] < bounds_x[1]\n end\n end\n\n ip\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def intersectNoPoints np\n np # could also have NoPoints.new here instead\n end", "def offLine(c1,c2,c3)\n\n if equalCoordinates?(c1, c2)\n return equalCoordinates?(c1, c3) ? 0 : getGeoDistance(c1, c3)\n end\n\n if equalCoordinates?(c1, c3)\n return 0\n end\n # we get the difference Geodesic angles\n theta1 = getGeoAngle(c1, c2)\n theta2 = getGeoAngle(c1, c3)\n theta3 = theta2-theta1\n\n # buf buf\n # (--- c1 ----------------- c2 ---)\n # * |\n # H(c1-c3) * | H*Sin(theta3)\n # * |\n # c3\n hc1c3 = getGeoDistance(c1, c3)\n hc1c2 = getGeoDistance(c1, c2)\n #\n # if the point is with in a buffer's radius of C1 then it is on the line,\n # Otherwise, its distance from C1 must be less than the distance to C2\n # plus the buffer, and its distance to the C1-C2 line must be less than the buffer.\n # Furthermore this calculation only works if difference in angles is less than PI/2.\n # If the difference in angles is greater than that, then the point is not near\n # the line, unless it was within the buffer radius of C1.\n #\n result = abs(Math.sin(theta3) * hc1c3)\n\n return result\n end", "def lineIntersectsWith _args\n \"lineIntersectsWith _args;\" \n end", "def rec_intersection(rect1, rect2)\n x_min = [rect1[0][0], rect2[0][0]].max\n x_max = [rect1[1][0], rect2[1][0]].min\n\n y_min = [rect1[0][1], rect2[0][1]].max\n y_max = [rect1[1][1], rect2[1][1]].min\n\n return nil if ((x_max < x_min) || (y_max < y_min)) # no overlap\n return [[x_min, y_min], [x_max, y_max]]\nend", "def get_intersection\n end", "def line(a, b)\n return [a] if a == b\n a = offset_to_cube a\n b = offset_to_cube b\n n = cube_distance a, b\n (0..n).each_with_object([]) do |i, results|\n cube_coords = cube_round cube_lerp(a, b, 1.0 / n * i)\n results << cube_to_offset(cube_coords)\n end\n end", "def intersectWithSegmentAsLineResult seg\n self\n end", "def is_on_line?(line)\n to_a.zip(line.point.to_a, line.vector.to_a).map { |a, b, c| (a - b) / c }.uniq.length == 1\n end", "def get_contour_points_adv()\r\n result = []\r\n idx = 0\r\n result[idx] = Offset.vertices(@active_face.outer_loop.vertices, -(@bit_diameter * 0.5)).offsetPoints\r\n# puts \" outer #{result[idx].length} #{result[idx]} \"\r\n @active_face.loops.each { |lp|\r\n if (!lp.outer?)\r\n idx += 1\r\n result[idx] = Offset.vertices(lp.vertices, -(@bit_diameter * 0.5) ).offsetPoints \r\n# puts \" inner[#{idx}] #{result[idx]}\" \r\n end\r\n }\r\n return result \r\nend", "def bbpLineIntersect(point_a, point_b, point_c, point_d, hit_point, second_hit_point)\n\n rise 'Method not implemented'\n end", "def find_intercept(source, touch)\n # the dimensions of the screen are 1024 x 768\n # Cocos2d puts the 0,0 origin at the bottom left, which is good\n # so, the four lines that define the borders of the screen are:\n bounds = {\n :left => { :x => 0.0 },\n :right => { :x => 1024.0 },\n :bottom => { :y => 0.0 },\n :top => { :y => 768.0 }\n }\n\n intercepts = []\n\n # check special case #1: touch is on the same spot as the source\n if source[:x] == touch[:x] && source[:y] == touch[:y]\n # this is an invalid case, so return nil\n return nil\n # check special case #2: vertical line\n elsif source[:x] == touch[:x]\n intercepts << { :x => source[:x], :y => bounds[:bottom][:y] }\n intercepts << { :x => source[:x], :y => bounds[:top][:y] }\n # check special case #3: horizontal line\n elsif source[:y] == touch[:y]\n intercepts << { :x => bounds[:left][:x], :y => source[:y] }\n intercepts << { :x => bounds[:right][:x], :y => source[:y] }\n # regular cases\n else\n # we want to define a line as y = mx + b\n # 1. find the slope of the line: (y2 - y1) / (x2 - x1)\n slope = (touch[:y] - source[:y]) / (touch[:x] - source[:x])\n # 2. Substitute slope plus one coordinate (we'll use the source's coordinate) into y = mx + b to find b\n # To find b, the equation y = mx + b can be rewritten as b = y - mx\n b = source[:y] - (slope * source[:x])\n # We now have what we need to create the equation y = mx + b. Now we need to find the intercepts.\n\n # left vertical intercept - we have x, we must solve for y\n y = slope * bounds[:left][:x] + b\n intercepts << { :x => bounds[:left][:x], :y => y }\n\n # right vertical intercept - we have x, we must solve for y\n y = slope * bounds[:right][:x] + b\n intercepts << { :x => bounds[:right][:x], :y => y }\n\n # bottom horizontal intercept - we have y, we must solve for x\n # x = (y - b) / m\n x = (bounds[:bottom][:y] - b) / slope\n intercepts << { :x => x, :y => bounds[:bottom][:y] }\n\n # top horizontal intercept - we have y, we must solve for x\n x = (bounds[:top][:y] - b) / slope\n intercepts << { :x => x, :y => bounds[:top][:y] }\n end\n\n bounds_filter(bounds, intercepts)\n directional_filter(source, touch, intercepts)\n\n # we're only ever interested in a single intercept\n intercepts.first\nend", "def contour_line_search_mod(n,lines,arrays)\n line_1 = get_next_line(arrays.first,lines[0],n)\n line_2 = get_next_line(arrays.last,lines[1],n)\n if line_1.class == Array.class\n return line_1\n elsif line_2.class == Array.class\n return line_2\n else \n contour_line_search_mod(n,[line_1,line_2],arrays)\n end\n end", "def dp_calc(new_poly, points, tol)\n return new_poly << points.last unless points.length > 2\n distances = points.map do |xy|\n line_point_distance(points.first, points.last, xy)\n end\n return new_poly << points.last unless distances.any?{ |d| d > tol }\n furthest = distances.each_with_index.max[1]\n new_poly = dp_calc(new_poly, points.slice(0, furthest+1), tol)\n new_poly = dp_calc(new_poly, points.slice(furthest, points.length), tol)\n return new_poly\n end", "def contains? position\n # If POI is given instead of location, get location first\n position = position.location if PointOfInterest === position\n\n x = position[0]\n y = position[1]\n\n # Use the raycasting technique to determine if point is inside polygon\n # We are in 2D, which makes it easier.\n # We can also choose the direction of the ray, which makes it almost trivial\n # (Choose ray paralell to x-achis\n intersections = 0\n\n [vertices, vertices.first].flatten.each_cons(2) do |v1, v2|\n # Check if we are inside bounding recangle of 2 vertices\n v1x = v1[0]\n v1y = v1[1]\n v2x = v2[0]\n v2y = v2[1]\n if (v1y < y and y <= v2y) or (v1y >= y and y > v2y)\n # check if we are LEFT of or onthe line from v1 to v2 is at this x coordinate\n cp.polygon(*p.map_vertices.map{|v| v.to_a}.flatten)\n vx = v2x - v1x\n vy = v2y - v1y\n if (x <= v1x and x < v2x)\n intersections +=1\n elsif x >= v1x and x > v2x\n next\n else\n x_line = v1x + vx * (y - v1y) / vy\n if vy == 0 or vx == 0 or x < x_line\n intersections += 1\n end\n end\n end\n end\n return intersections.odd?\n end", "def test_inside_non_overlapping()\n shape_ds = Gdal::Ogr.open('../../ogr/data/testpoly.shp')\n shape_lyr = shape_ds.get_layer(0)\n\n shape_lyr.set_spatial_filter_rect( -10, -130, 10, -110 )\n assert(check_features_against_list( shape_lyr, 'FID',\n [ 13 ] ))\n end", "def intersection(other)\n intersection_result = []\n \n if other.is_a?(Polygon) \n k = other.sides \n else \n k = [other]\n end\n\n self.sides.each do |side|\n k.each do |side1|\n intersection_result += side.intersection(side1)\n end\n end\n\n intersection_result.uniq! do |a|\n if a.is_a?(Point)\n [a.x, a.y]\n else\n [a.p1, a.p2].sort_by {|p| [p.x, p.y]} \n end\n end\n points = []; segments = []\n\n intersection_result.each do |entity|\n points << entity if entity.is_a?(Point)\n segments << entity if entity.is_a?(Segment)\n end\n\n if !points.empty? && !segments.empty?\n points_in_segments = []\n\n points.each do |point|\n segments.each do |segment|\n points_in_segments << point if segment.contains?(point)\n end\n end\n\n points_in_segments.uniq! {|a| [a.x, a.y]}\n if !points_in_segments.empty?\n points_in_segments.each do |p|\n points.delete(p)\n end\n end\n\n return points.sort + segments.sort\n end\n\n return intersection_result.sort\n end", "def rec_intersection(rect1, rect2)\n bot_x, bot_y = [rect1[0][0], rect2[0][0]].max, [rect1[0][1], rect2[0][1]].max\n top_x, top_y = [rect1[1][0], rect2[1][0]].min, [rect1[1][1], rect2[1][1]].min\n return nil if bot_x > top_x || bot_y > top_y\n [[bot_x, bot_y], [top_x, top_y]]\nend", "def intersects(shape)\n p1 = shape.points.length - 1\n for p2 in 0...shape.points.length\n p3 = @points.length - 1\n for p4 in 0...@points.length\n return true if segments_intersection(shape.points[p1], shape.points[p2], @points[p3], @points[p4])\n p3 = p4\n p4 += 1\n end\n p1 = p2\n p2 += 1\n end\n return false\n end", "def in?(px, py)\n ix, iy = @max+100, @max+100\n nbintersections = 0\n @points.each_index do |index|\n ax, ay = *@points[index]\n bx, by = *@points[(index + 1) % @points.length]\n nbintersections += intersectsegment(ax, ay, bx, by, ix, iy, px, py)\n end\n return (nbintersections%2 == 1)\n end", "def divide_line_into_points(lat1, lon1, lat2, lon2, distance)\n # puts \"in line #{lat1}, #{lon1}, #{lat2}, #{lon2}, #{distance}\"\n points = []\n\n num_points = (RoadRollerHelper.get_line_length(lat1, lon1, lat2, lon2)/distance).to_i\n\n i = 1\n #puts \"#{RoadRollerHelper.get_line_length(lat1, lon1, lat2, lon2)} #{distance}\"\n while (i <= num_points)\n #puts \"#{i} #{num_points}\"\n lat, lon = get_new_point(lat1, lon1, lat2, lon2, distance*i)\n #puts \"lat, lon => #{lat} #{lon}\"\n points.push([lat, lon])\n i=i+1\n end\n puts \"num_points = #{num_points} #{points.length}\"\n return points\n end", "def wherecrossing(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 point 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 nil\r\n end", "def intersection( to )\n cp = self.pos.to_gpos\n\n line = cp.to_vec( to )\n uline = line.unit\n radius = uline * size.x\n\n ( cp.to_vec + radius ).to_gpos\n end", "def find_intersection(lx, ly, m, cx, cy, r, dir)\n qa = m*m+1\n qb = 2*(ly*m -lx*m*m - cy*m - cx)\n qc = lx*lx*m*m + -2*lx*ly*m + 2*lx*cy*m +\n ly*ly + -2*ly*cy +\n cy*cy + cx*cx - r*r\n\n x = quadratic(qa, qb, qc, dir)\n y = (x-lx)*m + ly\n [x, y]\n end", "def poly_line\n Hash['lng', longitude , 'lat', latitude, \"strokeColor\", \"#00000\", \"strokeWeight\", 3]\n end", "def solution(a)\n # want to know the number of discs that start, stop\n # at each position. Then we can calculate how many\n # intersections there are.\n \n # create a hash with default start, stop values set to 0\n events = Hash.new{ |h, k| h[k] = {:start => 0, :stop => 0}}\n \n # store the start, stop vals for each element in a\n a.each_index do |i|\n events[i - a[i]][:start] += 1\n events[i + a[i]][:stop] += 1\n end\n \n # so now event[i][:start] is the start val for a[i]\n # sort the events\n sorted_events = events.sort_by { |index, val| index}\n sorted_events.map! {|n| n[1]}\n \n # so now sorted_events[i] tells us how many starts and stops occured at (i, 0).\n \n # iterate over our sorted array of hashes which tell us how many discs start and end at each position. There are two cases we need to worry about:\n # 1) how many discs are already going when the new disc starts: (e[:start] * past_start)\n # 2) if multiple discs start at the same position (e[:start] * (e[:start]-1) / 2)\n \n # 1) if there are 3 discs that we're in the middle of and a new disc starts, it intersects with all 3 of them. If there are 3 discs we're in the middle of and 2 new discs start, each of them will intersect with the 3 existing ones, making six interactions.\n # 2) If multiple discs start at the same location, some math is required. It's groups of 2, so the number of intersections at each index is n*(n-1)/2 - for if multiple discs start at that index - plus n*past_starts for when discs are already in progress when we start a new one. Add them all together and you have your solution.\n \n past_starts = 0\n intersects = 0\n sorted_events.each do |event|\n intersects += event[:start] * (event[:start]-1) / 2 + event[:start] * past_starts\n past_starts += event[:start]\n past_starts -= event[:stop]\n end\n \n intersects\n #puts \"events: #{events}\"\nend", "def findIntersectedPositions(moves)\n moves.inject([[0,0,'N'], [[0,0]].to_set, []]) do |acc, m|\n p = moveToNextPosition acc[0], m\n puts \"p = \" + p.to_s\n newPosition = [p[0], p[1]]\n visitedPositions = acc[1]\n puts \"vp = \" + visitedPositions.size.to_s\n crossedPositions = acc[2]\n if (visitedPositions & newPosition).size > 0\n puts \"contains: \" + newPosition.to_s\n c = crossedPositions + [newPosition]\n else\n c = crossedPositions\n end\n\n pathPositions = allPointsBetween acc[0], newPosition\n [p, visitedPositions + pathPositions, c]\n end\nend", "def locator2(image)\n result = []\n how_wide = image.first.length\n how_long = image.length\n\n image.each_with_index do |e, i|\n e.each_with_index do |e2, i2|\n next unless e2.zero? && no_overlaps?(result, i, i2)\n answer = {\n corner: [i, i2],\n height: 1,\n width: 1\n }\n result << answer\n\n lookahead = i2 + 1\n until lookahead >= how_wide || e[lookahead] == 1\n answer[:width] += 1\n lookahead += 1\n end\n\n lookdown = i + 1\n until lookdown >= how_long || image[lookdown][i2] == 1\n answer[:height] += 1\n lookdown += 1\n end\n end\n end\n p result\n result\nend", "def do_poly_distance(e2)\n e1 = self\n\n # Tests for a possible intersection between the polygons and outputs a warning\n e1_center = e1.centroid\n e2_center = e2.centroid\n e1_max_radius = Rational(0)\n e2_max_radius = Rational(0)\n\n e1.vertices.each do |vertex|\n r = e1_center.distance(vertex)\n e1_max_radius = r if e1_max_radius < r\n end\n\n e2.vertices.each do |vertex|\n r = e2_center.distance(vertex)\n e2_max_radius = r if e2_max_radius < r \n end\n\n center_dist = e1_center.distance(e2_center)\n if center_dist <= e1_max_radius + e2_max_radius\n puts \"Polygons may intersect producing erroneous output\"\n end\n\n # Find the upper rightmost vertex of e1 and the lowest leftmost vertex of e2\n e1_ymax = e1.vertices.first\n e2_ymin = e2.vertices.first\n\n e1.vertices.each do |vertex|\n if vertex.y > e1_ymax.y || (vertex.y == e1_ymax.y && vertex.x > e1_ymax.x)\n e1_ymax = vertex\n end\n end\n \n e2.vertices.each do |vertex|\n if vertex.y < e2_ymin.y || (vertex.y == e2_ymin.y && vertex.x < e2_ymin.x)\n e2_ymin = vertex\n end\n end\n\n min_dist = e1_ymax.distance(e2_ymin)\n\n # Produce a dictionary with vertices of e1 as the keys and, for each vertex, the points\n # to which the vertex is connected as its value. The same is then done for e2.\n\n e1_connections = {}\n e2_connections = {}\n\n e1.sides.each do |side|\n if e1_connections[side.p1].nil?\n e1_connections[side.p1] = [side.p2]\n else\n e1_connections[side.p1] << side.p2\n end\n\n if e1_connections[side.p2].nil?\n e1_connections[side.p2] = [side.p1]\n else\n e1_connections[side.p2] << side.p1 \n end\n end\n\n e2.sides.each do |side|\n if e2_connections[side.p1].nil?\n e2_connections[side.p1] = [side.p2]\n else\n e2_connections[side.p1] << side.p2\n end\n\n if e2_connections[side.p2].nil?\n e2_connections[side.p2] = [side.p1]\n else\n e2_connections[side.p2] << side.p1\n end\n end\n\n e1_current = e1_ymax\n e2_current = e2_ymin\n support_line = Line.new([0, 0], [1, 0])\n\n # Determine which point in e1 and e2 will be selected after e2_ymin and e1_ymax,\n # this information combined with the above produced dictionaries determines the\n # path that will be taken around the polygons\n\n point1 = e1_connections[e1_ymax][0]\n point2 = e1_connections[e1_ymax][1]\n angle1 = support_line.angle_between(Line.new(e1_ymax, point1))\n angle2 = support_line.angle_between(Line.new(e1_ymax, point2))\n\n if angle1 < angle2\n e1_next = point1\n elsif angle2 < angle1\n e1_next = point2\n elsif e1_ymax.distance(point1) > e1_ymax.distance(point2)\n e1_next = point2\n else\n e1_next = point1\n end\n\n point1 = e2_connections[e2_ymin][0]\n point2 = e2_connections[e2_ymin][1]\n angle1 = support_line.angle_between(Line.new(e2_ymin, point1))\n angle2 = support_line.angle_between(Line.new(e2_ymin, point2))\n\n if angle1 > angle2\n e2_next = point1\n elsif angle2 > angle1\n e2_next = point2\n elsif e2_ymin.distance(point1) > e2_ymin.distance(point2)\n e2_next = point2\n else\n e2_next = point1\n end\n\n # Loop which determines the distance between anti-podal pairs and updates the\n # minimum distance accordingly. It repeats until it reaches the starting position.\n\n while true\n e1_angle = support_line.angle_between(Line.new(e1_current, e1_next))\n e2_angle = Math::PI - support_line.angle_between(Line.new(e2_current, e2_next))\n\n if e1_angle < e2_angle\n support_line = Line.new(e1_current, e1_next)\n e1_segment = Segment.new(e1_current, e1_next)\n min_dist_current = e1_segment.distance(e2_current)\n\n if min_dist_current < min_dist\n min_dist = min_dist_current\n end\n\n if e1_connections[e1_next][0] != e1_current\n e1_current = e1_next\n e1_next = e1_connections[e1_next][0]\n else\n e1_current = e1_next\n e1_next = e1_connections[e1_next][1]\n end\n elsif e1_angle > e2_angle\n support_line = Line.new(e2_next, e2_current)\n e2_segment = Segment.new(e2_current, e2_next)\n min_dist_current = e2_segment.distance(e1_current)\n\n if min_dist_current < min_dist\n min_dist = min_dist_current\n end\n\n if e2_connections[e2_next][0] != e2_current\n e2_current = e2_next\n e2_next = e2_connections[e2_next][0]\n else\n e2_current = e2_next\n e2_next = e2_connections[e2_next][1]\n end\n\n else\n support_line = Line.new(e1_current, e1_next)\n e1_segment = Segment.new(e1_current, e1_next)\n e2_segment = Segment.new(e2_current, e2_next)\n min1 = e1_segment.distance(e2_next)\n min2 = e2_segment.distance(e1_next)\n\n min_dist_current = [min1, min2].min\n\n if min_dist_current < min_dist\n min_dist = min_dist_current\n end\n\n if e1_connections[e1_next][0] != e1_current\n e1_current = e1_next\n e1_next = e1_connections[e1_next][0]\n else\n e1_current = e1_next\n e1_next = e1_connections[e1_next][1]\n end\n\n if e2_connections[e2_next][0] != e2_current\n e2_current = e2_next\n e2_next = e2_connections[e2_next][0]\n else\n e2_current = e2_next\n e2_next = e2_connections[e2_next][1]\n end\n end\n\n break if e1_current == e1_ymax && e2_current == e2_ymin\n end\n\n return min_dist\n end", "def poly_line\n Hash['lng', longitude , 'lat', latitude, \"strokeColor\", plan.color, \"strokeWeight\", 3]\n end", "def bad_find_corners(all_inputs, min_max)\n puts \"#{__method__}:: \"\n\n x_sort = all_inputs.sort_by {|_key, value| value['x']}\n y_sort = all_inputs.sort_by {|_key, value| value['y']}\n\n min_max['x_min'] = x_sort[0][1]['x']\n min_max['x_max'] = x_sort[-1][1]['x']\n min_max['y_min'] = y_sort[0][1]['y']\n min_max['y_max'] = y_sort[-1][1]['y']\n pp min_max\n\n #tr = (x - point['x']).abs + (y - point['y']).abs\n tl = min_max['y_max'] + min_max['x_max']\n tl_label = ''\n x = 0\n y = 0\n all_inputs.each do |label, point|\n d = (x - point['x']).abs + (y - point['y']).abs\n if d < tl\n tl = d\n tl_label = label\n end\n end\n\n bl = min_max['y_max'] + min_max['x_max']\n bl_label = ''\n x = 0\n y = min_max['y_max']\n all_inputs.each do |label, point|\n d = (x - point['x']).abs + (y - point['y']).abs\n if d < bl\n bl = d\n bl_label = label\n end\n end\n\n tr = min_max['y_max'] + min_max['x_max']\n tr_label = ''\n x = min_max['x_max']\n y = 0\n all_inputs.each do |label, point|\n d = (x - point['x']).abs + (y - point['y']).abs\n if d < tr\n tr = d\n tr_label = label\n end\n end\n\n br = min_max['y_max'] + min_max['x_max']\n br_label = ''\n x = min_max['x_max']\n y = min_max['y_max']\n all_inputs.each do |label, point|\n d = (x - point['x']).abs + (y - point['y']).abs\n if d < br\n br = d\n br_label = label\n end\n end\n\n puts \"tl_label #{tl_label}\"\n puts \"bl_label #{bl_label}\"\n puts \"tr_label #{tr_label}\"\n puts \"br_label #{br_label}\"\n # pp x_sort\n # pp y_sort\n\n # Top right corner is a point that has overall max X and overall min\n # Y. Find it by sorting all points by x and all points by y. Then\n # start at largest X - 1 and smallest Y and look for point that has\n # matching y and label name.\n found = false\n x_sort.reverse.each do |xlabel, xpoint|\n y_sort[0..-2].each do |ylabel, ypoint|\n #puts \"Check #{xlabel} #{xpoint} #{ylabel} #{ypoint}\"\n if (xlabel == ylabel)\n puts \" MATCH TR #{xlabel} #{xpoint}\"\n all_inputs[xlabel]['corner'] = 'TR'\n found = true\n break\n end\n end\n break if found\n end\n\n # Bottom left corner is similar to to top right.\n found = false\n x_sort[1..-1].each do |xlabel, xpoint|\n y_sort.reverse.each do |ylabel, ypoint|\n #puts \"Check #{xlabel} #{xpoint} #{ylabel} #{ypoint}\"\n if (xlabel == ylabel)\n puts \" MATCH BL #{xlabel} #{xpoint}\"\n all_inputs[xlabel]['corner'] = 'BL'\n found = true\n break\n end\n end\n break if found\n end\n\n # Top left corner\n found = false\n x_sort.each do |xlabel, xpoint|\n y_sort.each do |ylabel, ypoint|\n #puts \"Check #{xlabel} #{xpoint} #{ylabel} #{ypoint}\"\n if (xlabel == ylabel)\n puts \" MATCH TL #{xlabel} #{xpoint}\"\n all_inputs[xlabel]['corner'] = 'TL'\n found = true\n break\n end\n end\n break if found\n end\n\n # Bottom corner\n found = false\n x_sort.reverse.each do |xlabel, xpoint|\n y_sort.reverse.each do |ylabel, ypoint|\n #puts \"Check #{xlabel} #{xpoint} #{ylabel} #{ypoint}\"\n if (xlabel == ylabel)\n puts \" MATCH BR #{xlabel} #{xpoint}\"\n all_inputs[xlabel]['corner'] = 'BR'\n found = true\n break\n end\n end\n break if found\n end\n\nend", "def intersection_point(segment)\n # numerator = (line.point1.y - point1.y) * (line.point1.x - line.point2.x) -\n # (line.point1.y - line.point2.y) * (line.point1.x - point1.x)\n # denominator = (point2.y - point1.y) * (line.point1.x - line.point2.x) -\n # (line.point1.y - line.point2.y) * (point2.x - point1.x)\n #\n # t = numerator.to_f / denominator\n #\n # x = point1.x + t * (point2.x - point1.x)\n # y = point1.y + t * (point2.y - point1.y)\n #\n # Point.new(x, y)\n\n x1, y1, x2, y2 = point1.x, point1.y, point2.x, point2.y\n x3, y3, x4, y4 = segment.point1.x, segment.point1.y, segment.point2.x, segment.point2.y\n\n x12 = x1 - x2\n x34 = x3 - x4\n y12 = y1 - y2\n y34 = y3 - y4\n\n c = x12 * y34 - y12 * x34\n\n raise Exception.new('Segments are parallel.') if c.zero?\n\n a = x1 * y2 - y1 * x2\n b = x3 * y4 - y3 * x4\n\n x = (a * x34 - b * x12) / c\n y = (a * y34 - b * y12) / c\n\n Point.new(x, y)\n end", "def line2offsets(line_number)\n offsetlines.select do |offset, lines| \n lines.member?(line_number) \n end.keys\n end", "def rec_intersection(r1, r2)\n p1 = [[r1[0][0],r2[0][0]].max , [r1[0][1],r2[0][1]].max]\n p2 = [[r1[1][0],r2[1][0]].min , [r1[1][1],r2[1][1]].min]\n if p1[0] < p2[0] && p1[1] < p2[1]\n return [p1,p2]\n else\n return nil\n end\nend", "def draw_part(pts)\r\n\r\n # Draw holes\r\n for i in 0..(pts.length-1)\r\n draw_circle(pts[i], $normVec, $holeRadius)\r\n end\r\n \r\n # Loop through points\r\n for i in 0..(pts.length-1)\r\n \r\n # Get adjacent points\r\n adjPts = GetAdjacentPts(pts, i)\r\n \r\n # Compute start and end angles\r\n sAngle = angle_between_point_xy([adjPts[0],adjPts[1]])\r\n eAngle = angle_between_point_xy([adjPts[1],adjPts[2]])\r\n \r\n # Make adjustments\r\n sAngle = sAngle - 0.5\r\n eAngle = eAngle - 0.5\r\n if(eAngle < sAngle) \r\n eAngle = eAngle + 2 \r\n end\r\n\r\n # Draw curves\r\n draw_curve(adjPts[1], $normVec, $xaxis, $outerRadius, sAngle * Math::PI, eAngle * Math::PI)\r\n\r\n # Draw lines \r\n draw_line(add_outer_radius(adjPts[0],$outerRadius,sAngle),add_outer_radius(adjPts[1],$outerRadius,sAngle))\r\n \r\n end\r\n \r\nend", "def distance (hash, dep_station, line, intersect)\n # line = hash.fetch(line.to_sym)\n stops = line.each_index.select{|i| line[i] == intersect}.join.to_i - line.each_index.select{|i| line[i] == dep_station}.join.to_i \n if stops < 0\n return -stops\n else\n return stops\n end\nend", "def containsOrigin(f)\n\n\t#Formats input into a size 3 array of the points\n\tvalues = f.split(\",\").map{|x| Integer(x)}\n\tpoints = []\n\tfor i in BOTTOM..TOP\n\t\tpoints << [values[i * 2], values[i * 2 + 1]]\n\tend\n\n\treturn false if not inRectangle(points)\n\t#Origin is now now guaranteed to be in a y position where it is necessary to check using bounds/slopes\n\t#If the origin was completely below or above the triangle, the generated slopes could be incorrect\n\n\t#Sorts the input by Y Coordinate\n\tpointsByY = points.sort{|a, b| a[Y_COORDINATE] <=> b[Y_COORDINATE]}\n\n\n\t#target is bottom or top -- bottom if the origin is between the mid/bottom or top if the origin is mid/top\n\ttarget = pointsByY[MID][Y_COORDINATE] >= BOTTOM ? \"bottom\" : \"top\"\n\t#directPoint is the point beyond the origin from the midpoint's perspective\n\tdirectPoint = target == 'top' ? pointsByY[TOP] : pointsByY[BOTTOM]\n\t#longpoint is the point behind the midpoint relative to the origin\n\tlongPoint = target == 'top' ? pointsByY[BOTTOM] : pointsByY[TOP]\n\n\t#directSlope and longSlope are the slopes from the midpoint to the directPoint and longPoint respectively\n\tdirectSlope = (pointsByY[MID][X_COORDINATE] - directPoint[X_COORDINATE]) * 1.0 / (pointsByY[MID][Y_COORDINATE] - directPoint[Y_COORDINATE])\n\tlongSlope = (longPoint[X_COORDINATE] - directPoint[X_COORDINATE]) * 1.0 / (longPoint[Y_COORDINATE] - directPoint[Y_COORDINATE])\n\n\t#walls are the x-wise bounds of the triangle at the y coordinate of the origin\n\tdirectWall = directPoint[X_COORDINATE] - (directPoint[Y_COORDINATE] * directSlope)\n\tlongWall = directPoint[X_COORDINATE] - (directPoint[Y_COORDINATE] * longSlope)\n\n\tleftWall = (directWall > longWall ? longWall : directWall)\n\trightWall = (directWall > longWall ? directWall : longWall)\n\n\treturn (leftWall < ORIGIN[X_COORDINATE] and ORIGIN[X_COORDINATE] < rightWall)\nend", "def line_for_offset(offset)\n end", "def intersection( to )\n cp = self.pos.to_gpos\n sp = self.size.to_gpos\n line = cp.to_vec( to )\n\n n = line.rad\n a = sp.x\n b = sp.y\n\n div = Math.sqrt( ( b*Math.cos(n) ) ** 2 + ( a*Math.sin(n) ) ** 2 )\n px = ( a * b * Math.cos(n) ) / div\n py = ( a * b * Math.sin(n) ) / div\n\n cp.to_vec + Gvec[ px, py ]\n end", "def rec_intersection(rect1, rect2)\n\txmin = rect1[0][0] > rect2[0][0] ? rect1[0][0] : rect2[0][0]\n\txmax = rect1[1][0] > rect2[1][0] ? rect2[1][0] : rect1[1][0]\n\tymin = rect1[0][1] > rect2[0][1] ? rect1[0][1] : rect2[0][1]\n\tymax = rect1[1][1] > rect2[1][1] ? rect2[1][1] : rect1[1][1]\n\nreturn nil if ((xmax < xmin) || (ymax < ymin))\nreturn [ [xmin, ymin], [xmax, ymax] ]\nend", "def sector_a_intfx_coords\n [ [-1.5 * @radius, @radius], [-1.5 * @radius, -@radius], \n [-1.5 * @radius, 3 * @radius], [-3 * @radius, 2 * @radius],\n [-3 * @radius, 0], [-3 * @radius, -2 * @radius],\n [-1.5 * @radius, -3 * @radius] ]\n end", "def onLine(c1,c2,buffer,c3)\n\n if equalCoordinates?(c1, c2)\n return equalCoordinates?(c1, c3) || buffer > getGeoDistance(c1, c3)\n end\n\n if equalCoordinates?(c1, c3)\n return true\n end\n\n # we get the difference Geodesic angles\n theta1 = getGeoAngle(c1,c2)\n theta2 = getGeoAngle(c1,c3)\n theta3 = theta2-theta1\n\n # buf buf\n # (--- c1 ----------------- c2 ---)\n # * |\n # H(c1-c3) * | H*Sin(theta3)\n # * |\n # c3\n hc1c3 = getGeoDistance(c1,c3)\n hc1c2 = getGeoDistance(c1,c2)\n #\n # if the point is with in a buffer's radius of C1 then it is on the line,\n # Otherwise, its distance from C1 must be less than the distance to C2\n # plus the buffer, and its distance to the C1-C2 line must be less than the buffer.\n # Furthermore this calculation only works if difference in angles is less than PI/2.\n # If the difference in angles is greater than that, then the point is not near\n # the line, unless it was within the buffer radius of C1.\n #\n result = hc1c3 < buffer || abs(theta3) < Math::PI/2 &&\n hc1c3 <= hc1c2 + buffer/2 && abs(Math.sin(theta3) * hc1c3) <= buffer/2\n\n return result\n end", "def extended_segment_intersection?(ax, ay, bx, by, cx, cy, dx, dy)\n\treturn true if ((cx == ax) && (cy == ay)) || ((dx == ax) && (dy == ay)) || ((cx == bx) && (cy == by)) || ((dx == bx) && (dy == by))\n\t\t(cp(bx, by, cx, cy, ax, ay) != cp(bx, by, dx, dy, ax, ay)) || (cp(dx, dy, ax, ay, cx, cy) != cp(dx, dy, bx, by, cx, cy))\n\tend", "def draw_line(x1,y1,x2,y2,r,g,b,graph_function=false)\r\n if ( @line_dot_size > 1 )\n self.draw_dotted_line(x1,y1,x2,y2,@line_dot_size,r,g,b,graph_function)\n else\n r = 0 if ( r < 0 ) \n r = 255 if ( r > 255 ) \r\n g = 0 if ( g < 0 ) \n g = 255 if ( g > 255 ) \r\n b = 0 if ( b < 0 ) \n b = 255 if ( b > 255 ) \r\n distance = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)) \r\n if ( distance == 0 )\r\n #return -1\n else \r\n xstep = (x2-x1) / distance\r\n ystep = (y2-y1) / distance\r\n i =0\n while i<=distance \r\n x = i * xstep + x1\r\n y = i * ystep + y1\r\n if((x >= @garea_x1 && x <= @garea_x2&& y >= @garea_y1 && y <= @garea_y2) || !graph_function )\r\n if ( @line_width == 1 )\r\n self.draw_antialias_pixel(x,y,r,g,b)\n else\r\n start_offset = -(@line_width/2) \n end_offset = (@line_width/2)\n j = start_offset\n while j<=end_offset\n self.draw_antialias_pixel(x+j,y+j,r,g,b)\n end \r\n end\r\n end\n i =i+1\r\n end\n end \n end \r\n end", "def getVertices( x0, y0, x1, y1) # arguments define bounding box\n\t\tw, h = x1 - x0, y1 - y0\n\t\thh = (h/2).to_i\n\n\t\t[\n\t\t\t[ hh, 0], [ w - hh, 0], [ w, hh], [ w - hh, h], [ hh, h], [ 0, hh]\n\t\t].map do |v| [ v[0] + x0, v[1] + y0 ] end.flatten\n\tend", "def segment_intersection(seg1, seg2)\n x1, y1, x2, y2 = seg1\n x3, y3, x4, y4 = seg2\n line1 = segment_to_line(*seg1)\n line2 = segment_to_line(*seg2)\n\n xmin = [[x1, x2].min, [x3, x4].min].max\n xmax = [[x1, x2].max, [x3, x4].max].min\n ymin = [[y1, y2].min, [y3, y4].min].max\n ymax = [[y1, y2].max, [y3, y4].max].min\n\n x, y = line_intersection(line1, line2)\n return nil unless x && y\n\n if x >= xmin && x <= xmax && y >= ymin && y <= ymax\n return [x, y]\n end\n\n nil\n end", "def line_point_distance(line_start, line_end, point)\n top = ((line_end.y - line_start.y) * point.x) -\n ((line_end.x - line_start.x) * point.y) +\n (line_end.x * line_start.y) - \n (line_end.y * line_start.x)\n bottom = ((line_end.y - line_start.y) ** 2 +\n (line_end.x - line_start.x) ** 2) ** 0.5\n return (top / bottom).abs\n end", "def line_xiaolin_wu(x0, y0, x1, y1, stroke_color, inclusive = true)\n stroke_color = ChunkyPNG::Color.parse(stroke_color)\n\n dx = x1 - x0\n sx = dx < 0 ? -1 : 1\n dx *= sx\n dy = y1 - y0\n sy = dy < 0 ? -1 : 1\n dy *= sy\n\n if dy == 0 # vertical line\n x0.step(inclusive ? x1 : x1 - sx, sx) do |x|\n compose_pixel(x, y0, stroke_color)\n end\n\n elsif dx == 0 # horizontal line\n y0.step(inclusive ? y1 : y1 - sy, sy) do |y|\n compose_pixel(x0, y, stroke_color)\n end\n\n elsif dx == dy # diagonal\n x0.step(inclusive ? x1 : x1 - sx, sx) do |x|\n compose_pixel(x, y0, stroke_color)\n y0 += sy\n end\n\n elsif dy > dx # vertical displacement\n compose_pixel(x0, y0, stroke_color)\n e_acc = 0\n e = ((dx << 16) / dy.to_f).round\n (dy - 1).downto(0) do |i|\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xffff\n x0 += sx if e_acc <= e_acc_temp\n w = 0xff - (e_acc >> 8)\n compose_pixel(x0, y0, ChunkyPNG::Color.fade(stroke_color, w))\n if inclusive || i > 0\n compose_pixel(x0 + sx, y0 + sy, ChunkyPNG::Color.fade(stroke_color, 0xff - w))\n end\n y0 += sy\n end\n compose_pixel(x1, y1, stroke_color) if inclusive\n\n else # horizontal displacement\n compose_pixel(x0, y0, stroke_color)\n e_acc = 0\n e = ((dy << 16) / dx.to_f).round\n (dx - 1).downto(0) do |i|\n e_acc_temp, e_acc = e_acc, (e_acc + e) & 0xffff\n y0 += sy if e_acc <= e_acc_temp\n w = 0xff - (e_acc >> 8)\n compose_pixel(x0, y0, ChunkyPNG::Color.fade(stroke_color, w))\n if inclusive || i > 0\n compose_pixel(x0 + sx, y0 + sy, ChunkyPNG::Color.fade(stroke_color, 0xff - w))\n end\n x0 += sx\n end\n compose_pixel(x1, y1, stroke_color) if inclusive\n end\n\n self\n end", "def find_lines mta, start_station, end_station\n lines = [[],[]]\n mta.each do |line, stations|\n lines[0].push line if stations.include?(start_station)\n lines[1].push line if stations.include?(end_station)\n end\n\n if lines[0] & lines[1] != []\n common_line = lines[0] & lines[1]\n return [ common_line[0], common_line[0] ] # The 1st line both stations are on\n else\n return [ lines[0][0], lines[1][0] ] # The 1st line the staions are found on\n end\nend" ]
[ "0.6644192", "0.64605063", "0.6391747", "0.62180233", "0.6208858", "0.6077043", "0.60586584", "0.6040088", "0.60101086", "0.5901956", "0.58002627", "0.57811713", "0.5762228", "0.5760642", "0.57589144", "0.57589144", "0.57589144", "0.57577795", "0.57391006", "0.5735076", "0.5689908", "0.5686083", "0.5686083", "0.5686083", "0.5660456", "0.56489563", "0.56383485", "0.5618746", "0.5617149", "0.5595492", "0.55801976", "0.55734515", "0.5571439", "0.55365646", "0.55365646", "0.55365646", "0.5535954", "0.5530506", "0.5506195", "0.5502107", "0.54928374", "0.54923505", "0.5491364", "0.5475409", "0.5474136", "0.5467651", "0.5465566", "0.5455402", "0.5453288", "0.54426396", "0.54415745", "0.5432799", "0.5432799", "0.542686", "0.5408036", "0.5398489", "0.53962934", "0.5394583", "0.5371304", "0.5368758", "0.5364003", "0.5346879", "0.5333162", "0.53243643", "0.5316977", "0.53153765", "0.52824324", "0.52822363", "0.5279233", "0.5277402", "0.52677256", "0.5241525", "0.5240655", "0.52254474", "0.5216871", "0.5203335", "0.5193468", "0.5180056", "0.5175091", "0.5166035", "0.5165582", "0.51593584", "0.51541597", "0.51517475", "0.51301444", "0.51247114", "0.510335", "0.51030695", "0.51022696", "0.51021796", "0.5092993", "0.5091501", "0.5086134", "0.508587", "0.5082348", "0.506305", "0.5059144", "0.50522566", "0.5050655", "0.50489986" ]
0.62808776
3
cost is stored in cents
def cost_in_dollars self.cost / 100.to_f end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cents; end", "def actual_cost\n self.cost/1000.to_f\n end", "def calc_total_cost()\n\t\ttotal_cost = @cost.to_i * 0.9\n\tend", "def total_cost\n # quantity * unit_cost_price\n unit_cost_price\n end", "def cost\n # Todo pull this from the DB\n 1000\n end", "def cost\n 1.99\n end", "def cost\n @cost = 0.89\n end", "def cost\n 0.99\n end", "def cost\n 0.89\n end", "def cost\n @beverage.cost + 0.10\n end", "def cost\n @beverage.cost + 0.10\n end", "def cost\n @beverage.cost + 0.15\n end", "def cost\n @cost = 1.99\n end", "def cost\n @cost = 0.99\n end", "def cents\n @cents\n end", "def cost \n return @extra_cost + @basic_booking.cost\n end", "def cost \n return @extra_cost + @basic_booking.cost\n end", "def cost\n self[:cost].to_f\n end", "def cost\n deductible * RATE\n end", "def cost\n @beverage.cost + 0.20\n end", "def total_cost\r\n self.qty * self.price\r\n end", "def total_cost(distance, mpg, cpg)\n\tprice = (distance / mpg) * cpg \nend", "def total_cost\n @quantity * @price\n end", "def cost\n return @extra_cost + @basic_booking.cost\n end", "def total_cost\n @cost + tip\n end", "def getcost()\n return @cost\n end", "def cost\n return @cost\n end", "def cost\n return @cost\n end", "def cost \n return @extra_cost + @basic_prescription.cost\n end", "def cost \n return @extra_cost + @basic_transfer.cost\n end", "def total_cost\n total_cost = (@price_night * @dates.nights)\n return Money.new(total_cost * 100, \"USD\").format\n end", "def cost\n start_value\n end", "def cents\n (amount * 100).to_i\n end", "def cost\n sales_fee\n end", "def worth_at_cost\n worth= cost*quantity\n return worth\n end", "def cost\n total = 0.0\n not_covered.each do |n|\n total += n.cost\n end\n total\n end", "def extra_cost\n if extra_cost_cents.present?\n read_attribute(:extra_cost_cents) / 100.0\n else\n 0\n end\n end", "def cost\n purchase_cost\n end", "def cost\n purchase_cost\n end", "def total_cost\n self.qty * self.unit_cost\n end", "def cost \n return @extra_cost + @basic_inst.cost\n end", "def cost\n (@items_cost - @promotion_adjustment).round(2)\n end", "def unit_cost_price\n self[:cost_price] || unit_price - application_fee\n end", "def cents(amount)\n (amount * 100).to_i\n end", "def cost \n return @extra_cost + @basic_tran.cost\n end", "def cost\n @cost ||= calibrate_cost\n end", "def cost \n return @extra_cost + @basic_drug.cost\n end", "def total\n charges.map { |x| x.total_cost.to_f }.inject(:+)\n end", "def cost\r\n 0\r\n end", "def cost\r\n\t\treturn @extra_cost + @real_need.cost\r\n\tend", "def cost\n\t\treturn @extra_cost + @real_donation.cost\n\tend", "def total_cost\n self.ingredients.map{ | ing | ing.cost_per_unit * ing.quantity } .reduce(&:+).round(2)\n end", "def total_cost\n quantity * product.price\n end", "def total_cost\n quantity * product.price\n end", "def calculate_costs\n self.amount = self.transaction.shipping_cost + self.transaction.value\n self.shipping_cost = self.transaction.shipping_cost\n self.commission_rate = self.buyer.account.commission_rate || SiteVariable.get(\"global_commission_rate\").to_f # Calculate commission rate, if neither exist commission is set to 0\n self.commission = Money.new((commission_rate * self.transaction.value.cents).ceil) # Calculate commision as commission_rate * item value (without shipping), round up to nearest cent\n end", "def adjusted_total_cost(distance, new_mpg, cpg)\n\tadjusted_price = (distance / new_mpg) * cpg\nend", "def cost\n super + 0.15\n end", "def price_in_cents\n\t\tInteger(price * 100 + 0.50)\n\tend", "def total_cost\n dates = ReservationDates.new(checkin:@checkin, checkout:@checkout)\n subtotal = dates.total_nights * 200 \n total = subtotal * 1.101\n return total.round(2)\n end", "def cost=(value)\n @cost = value\n end", "def cost=(value)\n @cost = value\n end", "def cost\n super + 0.10\n end", "def cost\n super + 0.10\n end", "def total_cost\n ingredients_cost + components_cost\n end", "def total_cost\n product.cost * quantity\n end", "def price_in_cents\n\t\tInteger(@price*100 + 0.5)\n\tend", "def cost\n super + 0.20\n end", "def total_cost\n order_items.map { |order_item| order_item.subtotal }.sum.round(2)\n end", "def price_in_cents\n\t\tInteger(price * 100 + 0.5)\n\tend", "def total_cost\n return (date_range.end_date - date_range.start_date) * (200 * (1 - discount))\n end", "def cost \n\n \ttotal=@costItems.reduce(0) do |sum,hm|\n \t\tsum+=hm \n end\n puts total\n end", "def trip_cost(distance, miles_per_gal, price_per_gal)\n result = (((distance.to_f / 100) * miles_per_gal) * price_per_gal) #can also do distance / 100.0 because as long as one of the numbers is a floating point it will return a decimal number\n return result\nend", "def get_cost_without_tax\n total_costs = 0.0\n @products.each_value { |cost| total_costs += cost if is_valid_cost?(cost) }\n return total_costs\n end", "def all_costs\n smoked_all_time * cigaret_price\n end", "def total_cost\n order_details.inject(0) { |sum, od| sum += od.total }\n end", "def cost\n @beverage.cost\n end", "def total_cost\n total_cost = 0\n trips.each do |trip|\n total_cost += trip.cost\n end\n return \"$ #{total_cost/100.round(2)}\"\n end", "def cost\n @cost ||= 10\n end", "def total_cost\n \tingredients_cost + components_cost\n end", "def price_in_cents\n Integer(price*100 + 0.5)\n end", "def product_cost\n product_with_unit_cost + product_without_unit_cost\n end", "def cigaret_price\n 0.30\n end", "def fuel_cost\n ((amount * 100) / (mileage - predecessor.mileage)).round(1) if predecessor\n end", "def total_cost\n @meal_cost + @tip_amount\n end", "def cents(origin = Ratio[1,1])\n n = self.to_f\n m = origin.to_f\n Math.log2(n / m) * 1200.0\n end", "def credit_in_cents\n (user.credit * 100).to_i\n end", "def total_min_cost_ex_discount_and_vat_cents\n amount = self.quote_activities.sum(:min_amount_cents)\n amount += self.extra_cost_cents if self.extra_cost_cents.present?\n amount\n end", "def charge\n subtotal * 0\n end", "def total_cost\n self.delivery_cost_price +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total_cost }\n end", "def update_actual_cost\n cost = BigDecimal(0.00, 10)\n self.activities.each do |activity|\n cost += activity.actualCost\n end\n self.actual_cost = cost\n end", "def cents\n @cents ||= interval_in_cents\n end", "def total_cost\n [executor_cost, team_lead_cost, account_manager_cost].compact.inject(&:+)\n end", "def total_cost(list)\r\n cost = list[\"cocktail\"]*8 + list[\"beer\"]*3 + list[\"water\"]*0.15\r\n return cost\r\nend", "def price\n 0.25 + @coffee.price\n end", "def total\n result = 0\n (1..3).each do |n|\n v = eval \"cost_\" + n.to_s\n result += v.to_f\n end\n result\n end", "def total_value_cents\n total_benefits_value\n end", "def cost(meth)\n @costs[meth][\"cost_per_call\"] / 100.0 rescue 0.0\n end", "def total\n Money.new(self.expense_entries.sum('unit_cost_pence * qty'))\n end", "def get_formula_base_cost\n price = 0.0\n self.ingredients.each do |ingredient|\n price += ingredient.getPrice * ingredient.quantity\n end\n return price\n end", "def total_contributions_cost\n contributions.to_a.sum(&:amount)\n end" ]
[ "0.78827745", "0.7859967", "0.780307", "0.7697984", "0.76807725", "0.76602143", "0.76178896", "0.7613016", "0.760285", "0.7590271", "0.7590271", "0.75808454", "0.7573254", "0.7571516", "0.75292516", "0.7527297", "0.7527297", "0.75215244", "0.7510472", "0.7501266", "0.7489259", "0.7482203", "0.7470932", "0.7470564", "0.74212223", "0.73728913", "0.73713875", "0.73713875", "0.7369988", "0.7365729", "0.73381466", "0.7286169", "0.7283555", "0.7278458", "0.72684836", "0.7267791", "0.724853", "0.7229703", "0.7229703", "0.7226187", "0.7221758", "0.7199321", "0.7185149", "0.7172039", "0.71624887", "0.71583235", "0.7152688", "0.71032304", "0.7098744", "0.70844924", "0.70824724", "0.7080178", "0.7080142", "0.7080142", "0.7078119", "0.7062963", "0.7049785", "0.70472014", "0.70448077", "0.7038847", "0.7038847", "0.7028358", "0.7028358", "0.70233464", "0.70198685", "0.6994544", "0.69883114", "0.6946546", "0.6938625", "0.692885", "0.6927139", "0.6925385", "0.6921761", "0.69168067", "0.6906326", "0.6875576", "0.6865195", "0.68606627", "0.68560684", "0.6851326", "0.6845588", "0.683665", "0.6833716", "0.6831437", "0.6827141", "0.6826173", "0.68221974", "0.6819907", "0.6819302", "0.6810196", "0.68049234", "0.67981285", "0.6794204", "0.6789138", "0.67845756", "0.67818946", "0.67807156", "0.67761314", "0.67757344", "0.6773168" ]
0.79597855
0
GET /reunion_participantes GET /reunion_participantes.json
def index @reunion_participantes = ReunionParticipante.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @participantes = Participante.all\n end", "def get_participants\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n\n if user != nil and meeting != nil\n users = meeting.participants\n send_json(users)\n else\n send_error 401\n end\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def set_reunion_participante\n @reunion_participante = ReunionParticipante.find(params[:id])\n end", "def show\n @reunion = Reunion.find(params[:id])\n @asistentes = Reunion.find_by_sql('SELECT P.nombre\n FROM Profesors P\n ,Reunions_Estudiantes ER\n WHERE P.id = ER.estudiante_id\n AND ER.reunion_id = ' + @reunion.id.to_s +\n ' UNION ALL ' +\n 'SELECT E.nombreEstudiante nombre\n FROM Estudiantes E\n ,Reunions_Estudiantes ER\n WHERE E.id = ER.estudiante_id\n AND ER.reunion_id = ' + @reunion.id.to_s )\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reunion }\n end\n end", "def participants\n participant_ids.blank? ? User.none : User.where(id: participant_ids)\n end", "def index\n @participants = @event.participants\n end", "def index\n\t\t@participants = Participant.all\n\n\t\trender json: @participants\n\tend", "def get_participants(id, params = {})\n get \"/api/v2/projects/#{id}/participants\", params\n end", "def reunion_participante_params\n params.require(:reunion_participante).permit(:reunion_id, :persona_id, :vendedor_id)\n end", "def get_conversation_participants(id)\n @client.raw('get', \"/content/conversations/#{id}/participants\")\n end", "def get_all_participants(params = {})\n room_id = self.room_id || params.delete(:room_id)\n raise ArgumentError.new(\"room_id required\") unless room_id\n res = call_api(:method => :get, :uri => @api_base.merge(\"room/#{room_id}/participant\"), :query_params => params)\n return unless res.successful?\n Users.new(res.data)\n end", "def getParticipants\r\n\t\t\t\t\treturn @participants\r\n\t\t\t\tend", "def participants\n expose Challenge.participants(@oauth_token, params[:challenge_id].strip)\n end", "def show\n\t\trender json: @participant\n\tend", "def participants\n @participants ||= ParticipantSet.new\n end", "def past_meeting_participants(*args)\n options = Zoom::Params.new(Utils.extract_options!(args))\n options.require(%i[meeting_uuid])\n Utils.parse_response self.class.get(\"/past_meetings/#{options[:meeting_uuid]}/participants\", headers: request_headers)\n end", "def destroy\n @reunion_participante.destroy\n respond_to do |format|\n format.html { redirect_to reunion_participantes_url, notice: 'Reunion participante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def index\n @search = get_participant_search_obj\n\n @participants = @search.result.not_dnd\n .page(params[:page] || 1) .per(10)\n .includes(pin_code: [:center])\n end", "def index\n @match_participants = MatchParticipant.select(:participant).distinct.map(&:participant)\n end", "def arr_participants\n participants.split(',').map{|id|\n User.find(id) rescue nil\n }\n end", "def new\n @reunion = Reunion.new\n if params[:tesisId].nil? then\n @tesis = Tese.all\n else\n @tesis = Tese.find(params[:tesisId])\n @asistentes = Reunion.find_by_sql('SELECT P.Id\n ,P.Nombre\n FROM Profesors P\n ,Teses T\n WHERE P.id = T.Profesor_id\n AND T.id = ' + @tesis.id.to_s +\n ' UNION ALL ' +\n 'SELECT E.Id\n ,E.nombreEstudiante Nombre\n FROM Estudiantes E\n ,Teses T\n WHERE E.Tesis_id = T.id\n AND T.id = ' + @tesis.id.to_s )\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reunion }\n end\n end", "def participants\n attributes['participants'] ||= []\n attributes['participants']\n end", "def participants( params={} )\n participants = get_connections(\"participants\", params)\n return map_connections participants, :to => Facebook::Graph::Generic\n end", "def get_conversation_participants(id)\r\n #TODO: Test if this method needs data in options.\r\n @client.raw('get', \"/content/conversations/#{id}/participants\", nil, nil, @contact_v1_url)\r\n end", "def index\n @activity_participants = Activity::Participant.all\n \n end", "def index\n @participants = @current_event.participants rescue nil || []\n end", "def index\n @participants = Participant.all\n\n respond_to do |format|\n format.html # index.html.erb\n #format.xml { render :xml => @participants }\n end\n end", "def participant_ids\n participants.pluck(:id)\n end", "def participants\n return @participants\n end", "def participants\n return @participants\n end", "def participant_ids\n self.report_participant_relationships.collect { |r| r.participant_id }.uniq\n end", "def participant\n ScriptoriaCore::Ruote.engine.participant(participant_name)\n end", "def index\n @participants = Participant.includes(:responses, :participant_test_cases).order(created_at: :desc)\n .paginate(:page => params[:page])\n end", "def remove_participant\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n participant_ids = params[\"participant_ids\"]\n\n if user != nil and meeting != nil and participant_ids.length > 0\n participant_ids.each do |participant_id|\n if meeting.participants.exists?(participant_id)\n # remove all the participant's votes from each suggestion\n meeting.suggestions.each do |suggestion|\n vote = Vote.where(:voter_id => participant_id, :suggestion_id => suggestion.id)\n if vote != nil\n suggestion.votes.delete(vote)\n end\n end\n meeting.participants.delete(User.find(participant_id))\n end\n end\n self.send_ok\n else\n self.send_error 401\n end\n end", "def participants=(value)\n @participants = value\n end", "def participants=(value)\n @participants = value\n end", "def index\n @matchparticipants = Matchparticipant.all\n end", "def index\n #@partnerships = Partnership.all\n @participant = Participant.find_by(user_id: current_user.id)\n @partnerships = @participant.partnerships.distinct\n end", "def deal_participants(id:, **args)\n params = parameters(args) do\n optional_params :start, :limit\n end\n request(:get, \"deals/#{id}/participants\", params)\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def index\n @participant_types = ParticipantType.all\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def create\n\n @reunion = Reunion.new(params[:reunion])\n asistente_ids = params[:asistente_ids]\n respond_to do |format|\n unless asistente_ids.nil? or asistente_ids.size < 2 then\n if @reunion.save\n\n asistente_ids.each do |asistente|\n @Asistente = ReunionsEstudiantes.new(:reunion_id => @reunion.id, :estudiante_id => asistente, :finalizado => false)\n @Asistente.save\n\n estudiante = Estudiante.find(:all, :conditions => [ \"id = ?\", asistente ])\n\n if asistente.to_f < 100 then\n datosAsist = {:nombre => estudiante[0].nombreEstudiante,\n :correo => estudiante[0].correoElectronico + \"@uniandes.edu.co\"}\n else\n profesor = Profesor.find(asistente)\n correo = \"harjair@hotmail.com\"\n datosAsist = {:nombre => profesor.nombre, :correo => correo}\n end\n\n UserMailer.notificar_reunion(datosAsist, @reunion).deliver\n end\n\n format.html { redirect_to @reunion, notice: 'Reunion creada exitosamente.' }\n format.json { render json: @reunion, status: :created, location: @reunion }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @reunion.errors, status: :unprocessable_entity }\n end\n else\n @reunion.errors[:estudiante_ids] = \"Seleccione al menos dos asistentes a la reunión\"\n format.html { render action: \"new\" }\n format.json { render json: @reunion.errors, status: :unprocessable_entity }\n end\n end\n end", "def conversation_participant_ids\n self.conversation ?\n self.conversation.participant_ids + [self.conversation.user_id] : []\n end", "def show\n @game = Game.find(params[:game_id])\n @participant = Participant.find(params[:participant_id])\n respond_to do |format|\n format.html\n format.json { render json: @participant }\n end\n end", "def index\n @project_participants = ProjectParticipant.all\n @roles = ProjectParticipant.roles\n end", "def get_participants(response_status_number)\n\t\tmeeting_participations.where(response_status: response_status_number)\n\tend", "def index\n @transaction_participants = Transaction::Participant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @transaction_participants }\n end\n end", "def participants\n recipients\n end", "def to_s\n '#<Twilio.Api.V2010.ParticipantList>'\n end", "def to_s\n '#<Twilio.Api.V2010.ParticipantList>'\n end", "def show\n @user = User.find_by_name(params[:name])\n @participants = Participant.find_all_by_user_id(@user.id).paginate(:page => params[:page], :per_page => 5)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def create\n @reunion_participante = ReunionParticipante.new(reunion_participante_params)\n respond_to do |format|\n if @reunion_participante.save\n format.html { redirect_to @reunion_participante, notice: 'Reunion participante was successfully created.' }\n format.json { render :show, status: :created, location: @reunion_participante }\n else\n format.html { render :new }\n format.json { render json: @reunion_participante.errors, status: :unprocessable_entity }\n end\n end\n end", "def participants\n User.find Participation.select(\"distinct user_id\").where(:occasion_id => id).all.map(&:user_id)\n # participations.map(&:user).uniq\n end", "def setParticipants(participants)\r\n\t\t\t\t\t@participants = participants\r\n\t\t\t\tend", "def index\n @participants = Participant.all\n redirect_to display_project_participants_path(params[:project_id])\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def listerParticipants\n puts \"\"\n puts \"\"\n puts \"---------------| PARTICIPANTS |----------------------\"\n puts \"\"\n @participants.each do |participant|\n puts \" #{participant.nom.upcase}[#{participant.initiative}] - PV(#{participant.pv} / #{participant.pv_max}) >> #{participant.etat}\"\n end\n puts \"\"\n puts \"---------------| PARTICIPANTS |----------------------\"\n puts \"\"\n puts \"\"\n end", "def participants\n return recipients\n end", "def dashboard_webinar_participants(webinar_id, opts = {})\n data, _status_code, _headers = dashboard_webinar_participants_with_http_info(webinar_id, opts)\n data\n end", "def show\n @participant = Participant.find(params[:id])\n end", "def destroy\n @reunion = Reunion.find(params[:id])\n asistente_ids = ReunionsEstudiantes.find_by_sql('SELECT DISTINCT E.estudiante_id\n FROM Reunions_Estudiantes E \n WHERE E.reunion_id = ' + params[:id].to_s)\n\n asistente_ids.each do |asistente|\n estudiante = Estudiante.find(:all, :conditions => [ \"id = ?\", asistente.estudiante_id ])\n if asistente.estudiante_id.to_f < 100 then\n datosAsist = {:nombre => estudiante[0].nombreEstudiante,\n :correo => estudiante[0].correoElectronico + \"@uniandes.edu.co\"}\n else\n profesor = Profesor.find(:all, :conditions => [ \"id = ?\", asistente.estudiante_id ])\n correo = \"harjair@hotmail.com\"\n datosAsist = {:nombre => profesor[0].nombre, :correo => correo}\n end\n UserMailer.cancelar_reunion(datosAsist, @reunion).deliver\n end\n\n @reunion.destroy\n\n respond_to do |format|\n format.html { redirect_to(reunions_url, notice: 'Reunion cancelada exitosamente.') }\n format.json { head :no_content }\n end\n end", "def index\n @challenge_participants = @challenge.challenge_participants.includes(:team, :user)\n end", "def update\n params[:interview][:participant_ids].each do |participant_id|\n unless participant_id.empty?\n participant = Participant.find(participant_id)\n @interview.participants << participant\n end\n end\n respond_to do |format|\n\n if @interview.update(interview_params)\n participants = @interview.participants\n emails = []\n participants.each do |p|\n emails += [p.email]\n ReminderMailer.update_email(p.email).deliver_now\n end\n format.html { redirect_to @interview, notice: 'Interview was successfully updated.' }\n format.json { render :show, status: :ok, location: @interview }\n else\n format.html { render :edit }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_participant_ids\n self.participant_ids = []\n self.participant_ids << user_id.to_s\n end", "def index\n @participantes = Participante.find(:all, :select => \"persona_id\")\n @audiencias = Participante.find(:all, :select => \"persona_id\")\n\n @personas = Persona.find(:all, :conditions => [\"id_persona in (?)\", (@participantes + @audiencias).map{|i|i.persona_id}]).paginate(:page => params[:page], :per_page => 25)\n\n respond_to do |format|\n# format.html # index.html.erb\n format.html {render :partial => \"list\", :layout => \"content\"}\n format.xml { render :xml => @personas.to_xml }\n format.json { render :xml => @personas.to_json }\n end\n end", "def get_all_participants\n\t\tparticipants_array = []\n\t\tmatch.teams.each do |t|\n\t\t\tparticipants_array << get_team_participants(t)\n\t\tend\n\t\tparticipants_array\n\tend", "def responses\n participants.flat_map(&:responses)\n end", "def index\n @estado_remates = EstadoRemate.all\n end", "def former_participants( params={} )\n former_participants = get_connections(\"former_participants\", params)\n return map_connections former_participants, :to => Facebook::Graph::Generic\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def create\n\n partnership = Partnership.new\n partnership.user = current_user\n\n if (partnership.participants.find_by(reference: params[:first_participant_id]) == nil)\n participant1= Participant.find_by(reference: params[:first_participant_id])\n partnership.participants.concat(participant1)\n end\n\n if (partnership.participants.find_by(reference: params[:second_participant_id]) == nil)\n participant2= Participant.find_by(reference: params[:second_participant_id])\n partnership.participants.concat(participant2)\n end\n\n #partnership.first_participant = Participant.find_by(reference: params[:first_participant_id])\n #partnership.second_participant = Participant.find_by(reference: params[:second_participant_id])\n\n partnership.save\n @partnership = partnership\n\n=begin\n respond_to do |format|\n if partnership.save\n format.html { redirect_to @partnership, notice: 'Partnership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @partnership }\n else\n format.html { render action: 'new' }\n format.json { render json: @partnership.errors, status: :unprocessable_entity }\n end\n end\n=end\n end", "def index\n\n if params[:meeting_id]\n @meeting = Meeting.find(params[:meeting_id])\n end\n\n respond_to do |f|\n f.json {\n @meetings = Meeting\n start_p = Time.parse(params[:start])\n end_p = Time.parse(params[:end])\n @meetings = @meetings.where(\"start_at > ?\", params[:start])\n if start_p and end_p\n duration = end_p - start_p\n @meetings = @meetings.where(\"duration < ?\", duration)\n end\n\n render :json => @meetings.map{|m|\n {\n :id => m.id,\n :title => m.label,\n :start => m.start_at,\n :end => m.end_at,\n :url => \"/reunions/#{m.id}.js\",\n color: '#D42700',\n textColor: 'white'\n }\n }\n }\n f.html\n end\n end", "def participatingtournaments_feed\n tournaments= getpartipatingtournaments\n tournamentslist = tournaments.map do |t|\n { :tournament_id=>t.id, :title=> t.name, :start => t.start_date }\n end\n\n render :json=> tournamentslist.to_json\n end", "def nombreParticipants\n return @participants.length\n end", "def participants\n users.where(parent_id: parent_id || current_user_id).flat_map(&:participants)\n end", "def index\n @movie_participants = MovieParticipant.paginate(per_page: 10, page: params[:page])\n end", "def destroy\n @participant = Participant.find(params[:id])\n @participant.destroy\n\n respond_to do |format|\n format.html { redirect_to participants_path }\n format.json { head :no_content }\n end\n end", "def followers\n @person = Person.find(params[:id]) \n @project = Project.find(params[:project_id])\n @persons = @person.get_all_followers\n \n respond_to do |format|\n format.html # followers.html.erb\n format.xml { render :xml => @persons }\n end\n \n end", "def index\n if params[:organization_id].blank?\n @participants = Participant.all\n else\n @organization = Organization.find(params[:organization_id])\n @participants = @organization.participants\n end\n\n # @participants = @participants.paginate(:page => params[:page]).per_page(20)\n end", "def teachers\n url = drop_url_version + \"/count/teacherAssociations/#{params['edorg_id']}/teachers\"\n begin\n entities = RestClient.get(url, get_header)\n entities = JSON.parse(entities)\n rescue => e\n logger.info(\"Could not get ed orgs for #{entities} because of #{e.message}\")\n end\n \n respond_to do |format|\n format.json { render json: entities }\n end\n end", "def other_participants(user)\n all = recipients\n all.delete(user)\n all.delete(nil) # nil will appear when any of the user in the coversation is deleted later.\n all\n end", "def destroy\n @participant = Participant.find(params[:id])\n @participant.destroy\n\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant = Participant.find(params[:id])\n @participant.destroy\n\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end", "def participants_on_issue(project, id)\n get(\"/projects/#{url_encode project}/issues/#{id}/participants\")\n end" ]
[ "0.65341324", "0.6456688", "0.6336768", "0.6336768", "0.6336768", "0.6336768", "0.6336768", "0.6336768", "0.6333179", "0.60533345", "0.60379845", "0.6029556", "0.59963757", "0.5980109", "0.59759647", "0.59687454", "0.5934961", "0.59127", "0.5909372", "0.5897896", "0.5856482", "0.5837653", "0.5791061", "0.5778501", "0.5766576", "0.5760207", "0.5724162", "0.57172436", "0.5707691", "0.5695543", "0.5691027", "0.5687874", "0.56838423", "0.56792337", "0.56705236", "0.56705236", "0.5669055", "0.56482995", "0.5647969", "0.5634821", "0.5629277", "0.5629277", "0.56167895", "0.5605895", "0.5588944", "0.55811", "0.55811", "0.55811", "0.5562089", "0.5560346", "0.5550974", "0.5550974", "0.5550974", "0.5550974", "0.5550273", "0.5549155", "0.55344313", "0.5531688", "0.55259395", "0.5499438", "0.54961526", "0.54749525", "0.5474128", "0.54624593", "0.5461491", "0.5459721", "0.545267", "0.54328823", "0.54261416", "0.541972", "0.5417154", "0.5414855", "0.5408296", "0.5393802", "0.5373395", "0.53722113", "0.5361675", "0.5343267", "0.53056955", "0.52976364", "0.52915055", "0.5291074", "0.52896154", "0.52896154", "0.5285567", "0.5267962", "0.52548456", "0.5246921", "0.52186793", "0.52074695", "0.5199624", "0.5197169", "0.519637", "0.5192003", "0.5191878", "0.5188837", "0.5188837", "0.5180923", "0.5180923", "0.5180531" ]
0.77123106
0
GET /reunion_participantes/1 GET /reunion_participantes/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @reunion_participantes = ReunionParticipante.all\n end", "def index\n @participantes = Participante.all\n end", "def set_reunion_participante\n @reunion_participante = ReunionParticipante.find(params[:id])\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def get_participants\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n\n if user != nil and meeting != nil\n users = meeting.participants\n send_json(users)\n else\n send_error 401\n end\n end", "def show\n\t\trender json: @participant\n\tend", "def show\n @reunion = Reunion.find(params[:id])\n @asistentes = Reunion.find_by_sql('SELECT P.nombre\n FROM Profesors P\n ,Reunions_Estudiantes ER\n WHERE P.id = ER.estudiante_id\n AND ER.reunion_id = ' + @reunion.id.to_s +\n ' UNION ALL ' +\n 'SELECT E.nombreEstudiante nombre\n FROM Estudiantes E\n ,Reunions_Estudiantes ER\n WHERE E.id = ER.estudiante_id\n AND ER.reunion_id = ' + @reunion.id.to_s )\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reunion }\n end\n end", "def index\n\t\t@participants = Participant.all\n\n\t\trender json: @participants\n\tend", "def get_conversation_participants(id)\n @client.raw('get', \"/content/conversations/#{id}/participants\")\n end", "def index\n @participants = @event.participants\n end", "def show\n @participant = Participant.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def get_participants(id, params = {})\n get \"/api/v2/projects/#{id}/participants\", params\n end", "def reunion_participante_params\n params.require(:reunion_participante).permit(:reunion_id, :persona_id, :vendedor_id)\n end", "def participants\n expose Challenge.participants(@oauth_token, params[:challenge_id].strip)\n end", "def getParticipants\r\n\t\t\t\t\treturn @participants\r\n\t\t\t\tend", "def participants\n participant_ids.blank? ? User.none : User.where(id: participant_ids)\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def show\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n end", "def participant\n ScriptoriaCore::Ruote.engine.participant(participant_name)\n end", "def index\n @participants = Participant.all\n\n respond_to do |format|\n format.html # index.html.erb\n #format.xml { render :xml => @participants }\n end\n end", "def index\n @activity_participants = Activity::Participant.all\n \n end", "def show\n @game = Game.find(params[:game_id])\n @participant = Participant.find(params[:participant_id])\n respond_to do |format|\n format.html\n format.json { render json: @participant }\n end\n end", "def index\n @search = get_participant_search_obj\n\n @participants = @search.result.not_dnd\n .page(params[:page] || 1) .per(10)\n .includes(pin_code: [:center])\n end", "def index\n @match_participants = MatchParticipant.select(:participant).distinct.map(&:participant)\n end", "def new\n @reunion = Reunion.new\n if params[:tesisId].nil? then\n @tesis = Tese.all\n else\n @tesis = Tese.find(params[:tesisId])\n @asistentes = Reunion.find_by_sql('SELECT P.Id\n ,P.Nombre\n FROM Profesors P\n ,Teses T\n WHERE P.id = T.Profesor_id\n AND T.id = ' + @tesis.id.to_s +\n ' UNION ALL ' +\n 'SELECT E.Id\n ,E.nombreEstudiante Nombre\n FROM Estudiantes E\n ,Teses T\n WHERE E.Tesis_id = T.id\n AND T.id = ' + @tesis.id.to_s )\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reunion }\n end\n end", "def get_conversation_participants(id)\r\n #TODO: Test if this method needs data in options.\r\n @client.raw('get', \"/content/conversations/#{id}/participants\", nil, nil, @contact_v1_url)\r\n end", "def participants\n attributes['participants'] ||= []\n attributes['participants']\n end", "def show\n @user = User.find_by_name(params[:name])\n @participants = Participant.find_all_by_user_id(@user.id).paginate(:page => params[:page], :per_page => 5)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def participants\n @participants ||= ParticipantSet.new\n end", "def destroy\n @reunion_participante.destroy\n respond_to do |format|\n format.html { redirect_to reunion_participantes_url, notice: 'Reunion participante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def index\n @participants = @current_event.participants rescue nil || []\n end", "def get_all_participants(params = {})\n room_id = self.room_id || params.delete(:room_id)\n raise ArgumentError.new(\"room_id required\") unless room_id\n res = call_api(:method => :get, :uri => @api_base.merge(\"room/#{room_id}/participant\"), :query_params => params)\n return unless res.successful?\n Users.new(res.data)\n end", "def index\n @matchparticipants = Matchparticipant.all\n end", "def index\n @participants = Participant.includes(:responses, :participant_test_cases).order(created_at: :desc)\n .paginate(:page => params[:page])\n end", "def index\n #@partnerships = Partnership.all\n @participant = Participant.find_by(user_id: current_user.id)\n @partnerships = @participant.partnerships.distinct\n end", "def index\n @participant_types = ParticipantType.all\n end", "def participants\n return @participants\n end", "def participants\n return @participants\n end", "def to_s\n '#<Twilio.Api.V2010.ParticipantList>'\n end", "def to_s\n '#<Twilio.Api.V2010.ParticipantList>'\n end", "def participant_ids\n self.report_participant_relationships.collect { |r| r.participant_id }.uniq\n end", "def participants=(value)\n @participants = value\n end", "def participants=(value)\n @participants = value\n end", "def arr_participants\n participants.split(',').map{|id|\n User.find(id) rescue nil\n }\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def index\n @transaction_participants = Transaction::Participant.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @transaction_participants }\n end\n end", "def create\n @reunion_participante = ReunionParticipante.new(reunion_participante_params)\n respond_to do |format|\n if @reunion_participante.save\n format.html { redirect_to @reunion_participante, notice: 'Reunion participante was successfully created.' }\n format.json { render :show, status: :created, location: @reunion_participante }\n else\n format.html { render :new }\n format.json { render json: @reunion_participante.errors, status: :unprocessable_entity }\n end\n end\n end", "def participant_ids\n participants.pluck(:id)\n end", "def remove_participant\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n participant_ids = params[\"participant_ids\"]\n\n if user != nil and meeting != nil and participant_ids.length > 0\n participant_ids.each do |participant_id|\n if meeting.participants.exists?(participant_id)\n # remove all the participant's votes from each suggestion\n meeting.suggestions.each do |suggestion|\n vote = Vote.where(:voter_id => participant_id, :suggestion_id => suggestion.id)\n if vote != nil\n suggestion.votes.delete(vote)\n end\n end\n meeting.participants.delete(User.find(participant_id))\n end\n end\n self.send_ok\n else\n self.send_error 401\n end\n end", "def get_participants(response_status_number)\n\t\tmeeting_participations.where(response_status: response_status_number)\n\tend", "def listerParticipants\n puts \"\"\n puts \"\"\n puts \"---------------| PARTICIPANTS |----------------------\"\n puts \"\"\n @participants.each do |participant|\n puts \" #{participant.nom.upcase}[#{participant.initiative}] - PV(#{participant.pv} / #{participant.pv_max}) >> #{participant.etat}\"\n end\n puts \"\"\n puts \"---------------| PARTICIPANTS |----------------------\"\n puts \"\"\n puts \"\"\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @participants }\n end\n end", "def past_meeting_participants(*args)\n options = Zoom::Params.new(Utils.extract_options!(args))\n options.require(%i[meeting_uuid])\n Utils.parse_response self.class.get(\"/past_meetings/#{options[:meeting_uuid]}/participants\", headers: request_headers)\n end", "def index\n @challenge_participants = @challenge.challenge_participants.includes(:team, :user)\n end", "def participants( params={} )\n participants = get_connections(\"participants\", params)\n return map_connections participants, :to => Facebook::Graph::Generic\n end", "def deal_participants(id:, **args)\n params = parameters(args) do\n optional_params :start, :limit\n end\n request(:get, \"deals/#{id}/participants\", params)\n end", "def participant_id\n return @participant_id\n end", "def participant_id\n return @participant_id\n end", "def index\n @participants = Participant.all\n redirect_to display_project_participants_path(params[:project_id])\n end", "def conversation_participant_ids\n self.conversation ?\n self.conversation.participant_ids + [self.conversation.user_id] : []\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @participant }\n end\n end", "def nombreParticipants\n return @participants.length\n end", "def create\n\n @reunion = Reunion.new(params[:reunion])\n asistente_ids = params[:asistente_ids]\n respond_to do |format|\n unless asistente_ids.nil? or asistente_ids.size < 2 then\n if @reunion.save\n\n asistente_ids.each do |asistente|\n @Asistente = ReunionsEstudiantes.new(:reunion_id => @reunion.id, :estudiante_id => asistente, :finalizado => false)\n @Asistente.save\n\n estudiante = Estudiante.find(:all, :conditions => [ \"id = ?\", asistente ])\n\n if asistente.to_f < 100 then\n datosAsist = {:nombre => estudiante[0].nombreEstudiante,\n :correo => estudiante[0].correoElectronico + \"@uniandes.edu.co\"}\n else\n profesor = Profesor.find(asistente)\n correo = \"harjair@hotmail.com\"\n datosAsist = {:nombre => profesor.nombre, :correo => correo}\n end\n\n UserMailer.notificar_reunion(datosAsist, @reunion).deliver\n end\n\n format.html { redirect_to @reunion, notice: 'Reunion creada exitosamente.' }\n format.json { render json: @reunion, status: :created, location: @reunion }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @reunion.errors, status: :unprocessable_entity }\n end\n else\n @reunion.errors[:estudiante_ids] = \"Seleccione al menos dos asistentes a la reunión\"\n format.html { render action: \"new\" }\n format.json { render json: @reunion.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n partnership = Partnership.new\n partnership.user = current_user\n\n if (partnership.participants.find_by(reference: params[:first_participant_id]) == nil)\n participant1= Participant.find_by(reference: params[:first_participant_id])\n partnership.participants.concat(participant1)\n end\n\n if (partnership.participants.find_by(reference: params[:second_participant_id]) == nil)\n participant2= Participant.find_by(reference: params[:second_participant_id])\n partnership.participants.concat(participant2)\n end\n\n #partnership.first_participant = Participant.find_by(reference: params[:first_participant_id])\n #partnership.second_participant = Participant.find_by(reference: params[:second_participant_id])\n\n partnership.save\n @partnership = partnership\n\n=begin\n respond_to do |format|\n if partnership.save\n format.html { redirect_to @partnership, notice: 'Partnership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @partnership }\n else\n format.html { render action: 'new' }\n format.json { render json: @partnership.errors, status: :unprocessable_entity }\n end\n end\n=end\n end", "def participants\n User.find Participation.select(\"distinct user_id\").where(:occasion_id => id).all.map(&:user_id)\n # participations.map(&:user).uniq\n end", "def index\n @project_participants = ProjectParticipant.all\n @roles = ProjectParticipant.roles\n end", "def participants\n recipients\n end", "def index\n @participantes = Participante.find(:all, :select => \"persona_id\")\n @audiencias = Participante.find(:all, :select => \"persona_id\")\n\n @personas = Persona.find(:all, :conditions => [\"id_persona in (?)\", (@participantes + @audiencias).map{|i|i.persona_id}]).paginate(:page => params[:page], :per_page => 25)\n\n respond_to do |format|\n# format.html # index.html.erb\n format.html {render :partial => \"list\", :layout => \"content\"}\n format.xml { render :xml => @personas.to_xml }\n format.json { render :xml => @personas.to_json }\n end\n end", "def show\n @participant_rating = ParticipantRating.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant_rating }\n end\n end", "def index\n @participant_ratings = ParticipantRating.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @participant_ratings }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @annex1_project_participant = Annex1ProjectParticipant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @annex1_project_participant }\n end\n end" ]
[ "0.7641155", "0.6546381", "0.6493932", "0.64642495", "0.64642495", "0.64642495", "0.64642495", "0.64642495", "0.64642495", "0.6375387", "0.62594587", "0.6223182", "0.6117733", "0.6100213", "0.60681844", "0.6058876", "0.6057905", "0.6057905", "0.6057905", "0.6057905", "0.6054127", "0.5980925", "0.59718895", "0.5956943", "0.5929985", "0.59278154", "0.59278154", "0.59278154", "0.5900276", "0.5883561", "0.5852033", "0.585081", "0.5840443", "0.58385485", "0.5838193", "0.58252865", "0.58137566", "0.58056426", "0.58053195", "0.5790104", "0.5775298", "0.57687724", "0.57395697", "0.5721305", "0.57137954", "0.569118", "0.56843346", "0.56709874", "0.56709874", "0.5657567", "0.5657138", "0.5654254", "0.56447935", "0.56447935", "0.56415707", "0.56391877", "0.56391877", "0.56359816", "0.5634856", "0.56267995", "0.5615846", "0.5605051", "0.55979973", "0.5594193", "0.5585476", "0.5574077", "0.5564714", "0.55454284", "0.5542936", "0.5542936", "0.5539051", "0.55282485", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5510121", "0.5505088", "0.5502873", "0.5494034", "0.5482408", "0.5463024", "0.54619354", "0.5456316", "0.54458374", "0.5434695", "0.54308283", "0.5426749", "0.5426749", "0.5426749", "0.5415911" ]
0.0
-1
POST /reunion_participantes POST /reunion_participantes.json
def create @reunion_participante = ReunionParticipante.new(reunion_participante_params) respond_to do |format| if @reunion_participante.save format.html { redirect_to @reunion_participante, notice: 'Reunion participante was successfully created.' } format.json { render :show, status: :created, location: @reunion_participante } else format.html { render :new } format.json { render json: @reunion_participante.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @reunion_participantes = ReunionParticipante.all\n end", "def create\n\n @reunion = Reunion.new(params[:reunion])\n asistente_ids = params[:asistente_ids]\n respond_to do |format|\n unless asistente_ids.nil? or asistente_ids.size < 2 then\n if @reunion.save\n\n asistente_ids.each do |asistente|\n @Asistente = ReunionsEstudiantes.new(:reunion_id => @reunion.id, :estudiante_id => asistente, :finalizado => false)\n @Asistente.save\n\n estudiante = Estudiante.find(:all, :conditions => [ \"id = ?\", asistente ])\n\n if asistente.to_f < 100 then\n datosAsist = {:nombre => estudiante[0].nombreEstudiante,\n :correo => estudiante[0].correoElectronico + \"@uniandes.edu.co\"}\n else\n profesor = Profesor.find(asistente)\n correo = \"harjair@hotmail.com\"\n datosAsist = {:nombre => profesor.nombre, :correo => correo}\n end\n\n UserMailer.notificar_reunion(datosAsist, @reunion).deliver\n end\n\n format.html { redirect_to @reunion, notice: 'Reunion creada exitosamente.' }\n format.json { render json: @reunion, status: :created, location: @reunion }\n\n else\n format.html { render action: \"new\" }\n format.json { render json: @reunion.errors, status: :unprocessable_entity }\n end\n else\n @reunion.errors[:estudiante_ids] = \"Seleccione al menos dos asistentes a la reunión\"\n format.html { render action: \"new\" }\n format.json { render json: @reunion.errors, status: :unprocessable_entity }\n end\n end\n end", "def reunion_participante_params\n params.require(:reunion_participante).permit(:reunion_id, :persona_id, :vendedor_id)\n end", "def create\n\n partnership = Partnership.new\n partnership.user = current_user\n\n if (partnership.participants.find_by(reference: params[:first_participant_id]) == nil)\n participant1= Participant.find_by(reference: params[:first_participant_id])\n partnership.participants.concat(participant1)\n end\n\n if (partnership.participants.find_by(reference: params[:second_participant_id]) == nil)\n participant2= Participant.find_by(reference: params[:second_participant_id])\n partnership.participants.concat(participant2)\n end\n\n #partnership.first_participant = Participant.find_by(reference: params[:first_participant_id])\n #partnership.second_participant = Participant.find_by(reference: params[:second_participant_id])\n\n partnership.save\n @partnership = partnership\n\n=begin\n respond_to do |format|\n if partnership.save\n format.html { redirect_to @partnership, notice: 'Partnership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @partnership }\n else\n format.html { render action: 'new' }\n format.json { render json: @partnership.errors, status: :unprocessable_entity }\n end\n end\n=end\n end", "def create\n @participant = Participant.new(participant_params)\n respond_to do |format|\n if @participant.save\n format.html { redirect_to participants_path }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors }\n end\n end\n end", "def create\n \n @participant = Participant.new(:remote_ip => params[:participant][:remote_ip],\n\t :user_id => params[:participant][:user_id], \n\t\t\t\t\t\t\t\t\t:contact_describe_id=> params[:participant][:contact_describe_id], \n\t\t\t\t\t\t\t\t\t:instructions => params[:participant][:instructions], \n\t\t\t\t\t\t\t\t\t:goodwill => params[:participant][:goodwill], \n\t\t\t\t\t\t\t\t\t:age_18_or_more => params[:participant][:age_18_or_more],\n\t\t\t\t\t\t\t\t\t:created_at => Time.current, \n\t\t\t\t\t\t\t\t\t:updated_at => Time.current,\n\t\t\t\t\t\t\t\t\t:date_deleted => Time.current) \n\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\t\t\n\n respond_to do |format|\n if @participant.save\n format.html { redirect_to @participant, notice: 'Participant was successfully created.' }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t@participant = Participant.new(participant_params)\n\n\t\tif @participant.save\n\t\t\trender json: @participant, status: :created, location: @participant\n\t\telse\n\t\t\trender json: @participant.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def set_reunion_participante\n @reunion_participante = ReunionParticipante.find(params[:id])\n end", "def add_participant\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n participant_ids = params[\"participant_ids\"]\n comment = params[\"comment\"].nil? ? \"\" : params[\"comment\"]\n\n if user != nil and meeting != nil and participant_ids.length > 0\n participant_ids.each do |participant_id|\n unless meeting.participants.exists?(participant_id)\n new_participant = User.find(participant_id)\n meeting.participants << new_participant\n # add default vote for the new added participant to each suggestion\n meeting.suggestions.each do |suggestion|\n suggestion.votes << Vote.new(:voter => new_participant, :decision => \"?\")\n end\n\n NotificationService.send_meeting_invitation(user, new_participant, meeting, comment)\n end\n end\n self.send_ok\n else\n self.send_error 401\n end\n end", "def create\n @participant = Participant.new(params[:participant])\n\n respond_to do |format|\n if @participant.save\n format.html { redirect_to participants_url, notice: 'Participant was successfully created.' }\n format.json { render json: @participant, status: :created, location: @participant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @participant = @event.participants.new(participant_params)\n @participant.organization_id = @event.organization.id\n respond_to do |format|\n if @participant.save\n format.html { redirect_to @participant, notice: 'Participant was successfully created.' }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n @participant = current_user.build_participant(participant_params)\n \n respond_to do |format|\n if @participant.save\n format.html { redirect_to @participant, notice: \"Participant was successfully created.\" }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @reunion_participante.destroy\n respond_to do |format|\n format.html { redirect_to reunion_participantes_url, notice: 'Reunion participante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @participant = Participant.new(participant_params)\n @participant.agent = request.user_agent\n @participant.ip = request.remote_ip\n respond_to do |format|\n if @participant.save\n format.html { redirect_to @participant }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @participant = Participant.new(participant_create_params)\n @participant.save\n respond_with(@participant)\n end", "def create\n @participant = Participant.new(participant_create_params)\n @participant.save\n respond_with(@participant)\n end", "def ajoutParticipants(participant)\n @participants.push(participant)\n end", "def create\n @participant = Participant.new(participant_params)\n @participant.competences = @competence\n respond_to do |format|\n if @participant.save\n TeamParticipant.create(participant: @participant, team: @team)\n format.html { redirect_to participants_url }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def remove_participant\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n participant_ids = params[\"participant_ids\"]\n\n if user != nil and meeting != nil and participant_ids.length > 0\n participant_ids.each do |participant_id|\n if meeting.participants.exists?(participant_id)\n # remove all the participant's votes from each suggestion\n meeting.suggestions.each do |suggestion|\n vote = Vote.where(:voter_id => participant_id, :suggestion_id => suggestion.id)\n if vote != nil\n suggestion.votes.delete(vote)\n end\n end\n meeting.participants.delete(User.find(participant_id))\n end\n end\n self.send_ok\n else\n self.send_error 401\n end\n end", "def create\n # @attention = Attention.new(attention_params)\n # @attention.participants = params[:participants]\n # @attention.responsible = params[:responsible]\n # @attention.nro_involved = params[:participants].count + 1\n\n # respond_to do |format|\n # if @attention.save\n # format.html { redirect_to @attention, notice: 'Attention was successfully created.' }\n # format.json { render :show, status: :created, location: @attention }\n # else\n # format.html { render :index }\n # format.json { render json: @attention.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def index\n @participantes = Participante.all\n end", "def participant_params\n params.require(:participant).permit(:email, :match_degree, :last_responded)\n end", "def create\n @family = Family.find(params[:participant][:family]) rescue nil\n params[:participant][:family] = @family\n @participants = Participant.new(params[:participant])\n\n respond_to do |format|\n if @participants.save\n AuditTrail.audit(\"Participant #{@participants.fullname} created by #{current_user.login}\", edit_participant_url(@participants))\n flash[:notice] = 'Participants was successfully created.'\n format.html { params[:commit] == 'Save' ? redirect_to(participants_path) : redirect_to(new_participant_path) }\n format.xml { render :xml => @participants, :status => :created, :location => @participants }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @participants.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n params[:interview][:participant_ids].each do |participant_id|\n unless participant_id.empty?\n participant = Participant.find(participant_id)\n @interview.participants << participant\n end\n end\n respond_to do |format|\n\n if @interview.update(interview_params)\n participants = @interview.participants\n emails = []\n participants.each do |p|\n emails += [p.email]\n ReminderMailer.update_email(p.email).deliver_now\n end\n format.html { redirect_to @interview, notice: 'Interview was successfully updated.' }\n format.json { render :show, status: :ok, location: @interview }\n else\n format.html { render :edit }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @participant = Participant.new(params[:participant])\n @participant.ganador_flag = false\n respond_to do |format|\n if @participant.save\n format.html { redirect_to new_participant_path, notice: 'Participante creado.' }\n format.json { render json: @participant, status: :created, location: @participant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def conversation_params\n params.permit(:participants, participants: [])\n end", "def set_participant_ids\n self.participant_ids = []\n self.participant_ids << user_id.to_s\n end", "def participants=(new_participants)\n @participants = new_participants\n self.participant_ids = new_participants.collect(&:id)\n end", "def create\n @interview = Interview.new(interview_params)\n params[:interview][:participant_ids].each do |participant_id|\n unless participant_id.empty?\n participant = Participant.find(participant_id)\n @interview.participants << participant\n end\n end\n respond_to do |format|\n if @interview.save\n d = @interview.interviewDate\n t = @interview.startTime\n start = DateTime.new(d.year,d.month,d.day,t.hour,t.min,t.sec,t.zone).utc.to_i\n current = Time.now.utc.to_i\n participants = @interview.participants\n # ReminderMailer.sample_email(\"aswanth@interviewbit.com\").deliver_now\n # HardWorker.perform_in((start-current-1800).seconds,participants)\n # puts participants[0].email, participants[1].email\n emails = []\n participants.each do |p|\n emails += [p.email]\n ReminderMailer.created_email(p.email).deliver_now\n end\n puts emails\n # HardWorker.perform_at(2.seconds,emails)\n HardWorker.perform_at((start-current-1800).seconds,emails)\n format.html { redirect_to @interview, notice: 'Interview was successfully created.' }\n format.json { render :show, status: :created, location: @interview }\n else\n format.html { render :new }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @room = Room.create(:user => current_user)\n \n # Creation from web form.\n if params[:room][:participant_attributes]\n @room.phonebrowser_service = PhonebrowserService.create(:room => @room)\n @room.video_service = VideoService.create(:room => @room)\n params[:room][:participant_attributes].each do |part|\n p = Participant.new\n if part[:phonebrowser_service] == '1'\n p.phonebrowser_service_id = Service.find_by_name('phonebrowser').id\n end\n if part[:video_service_id] == '1'\n p.video_service_id = Service.find_by_name('video').id\n end\n p.name = part[:name]\n p.phone = part[:phone]\n p.sip = part[:sip]\n p.browser = part[:browser]\n p.save\n @room.participants << p\n end\n @room.save\n redirect_to rooms_path\n \n # Creation from RESTful request\n elsif params[:room][:participant]\n participants_array = []\n if params[:room][:participant].class == Array\n participants_array = params[:room][:participant]\n else\n participants_array << params[:room][:participant]\n end\n participants_array.each do |part|\n p = Participant.new\n p.name = part[:name]\n p.phone = part[:phone]\n p.sip = part[:sip]\n p.browser = part[:browser]\n p.save\n @room.participants << p\n end\n @room.phonebrowser_service = PhonebrowserService.create(:room => @room)\n @room.video_service = VideoService.create(:room => @room)\n @room.save\n if params[:room][:start_now] and !params[:room][:start_now].nil? and params[:room][:start_now] == \"1\"\n @room.start\n end\n # @ltest.to_xml(:include => :sub_tests) \n respond_to do |format|\n format.html {redirect_to rooms_path}\n format.xml { render :xml => @room.to_xml(:include => [:phonebrowser_service, :participants]) } #.to_xml(:include => :phonebrowser_service)\n format.json {render :json => @room.to_json(:include => [:phonebrowser_service, :participants]) }\n end\n end\n end", "def create\n @participant = Participant.new(participant_params)\n if @participant.organization_type and @participant.organization_type.name == 'FMOH'\n @directorates = Directorate.all\n end\n respond_to do |format|\n if @participant.save\n format.html { redirect_to @participant, notice: 'Participant was successfully created.' }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @participant = Participant.new(participant_params)\n\n respond_to do |format|\n if @participant.save\n # format.html { redirect_to @participant, notice: 'Participant was successfully created.' }\n format.html { redirect_to '/confirmation/thankyou'}\n # format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n # format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @idea = Idea.new(idea_params)\n @idea.name = params[:name]\n @idea.user_id = session[:id]\n @@participants = @@participants.uniq\n @@participants.each do |p|\n \t@idea.users << p\n end\n @idea.users << User.find_by(id: session[:id])\n respond_to do |format|\n if @idea.save\n @@participants.each do |p|\n make_participant(@idea.id, p.id, 0)\n end\n make_participant(@idea.id, session[:id], 2)\n format.html { redirect_to controller: :ideas, action: :index }\n format.json { render :show, status: :created, location: @idea }\n else\n reset_participants\n format.html { render :new }\n format.json { render json: @idea.errors, status: :unprocessable_entity }\n end\n end\n end", "def participant_params\n params.require(:participant).permit(:opponent_id, :owner_id, :game_id, :winner_id, :waiting_for_user_id, :status, :game_data)\n end", "def create\n @participant = Participant.new(participant_params)\n @participant.session_id = session[:session_id]\n @participant.ip_address = request.ip\n\n respond_to do |format|\n if @participant.save\n format.html { redirect_to directions_path }\n format.json { render action: 'show', status: :created, location: @participant }\n else\n format.html { render action: 'new' }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def participant_params\n params.require(:participant).permit(:code, :first_name, :second_name, :third_name, :fourth_name, :gender_id, :birthdate, :email, :participant_type_id, :address, :website, :legal_representative, :phone, :mobile_phone, :param_matrix_id, :score, :created_by_id, :is_pep)\n end", "def setParticipants(participants)\r\n\t\t\t\t\t@participants = participants\r\n\t\t\t\tend", "def create\n @trainees = TraineeBatch.new(params[:participants][:ids], params[:training_calendar_id])\n respond_to do |format|\n if @trainees.save\n format.html { redirect_to training_calendar_path(params[:training_calendar_id]), :notice => 'The participant(s) were successfully added.' }\n format.json { render :json => @trainees, :status => :created, :location => @trainees }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @trainees.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_participant_to_deal(id:, **args)\n params = parameters(args) do\n required_params :person_id\n optional_params :person_id\n end\n request(:post, \"deals/#{id}/participants\", params)\n end", "def create\n @participant = Participant.new(participant_params)\n\n if @participant.save\n redirect_to participants_path\n flash[:success] = \"Participant was successfully created.\"\n else\n flash[:danger] = \"Participant was unsuccessfully created.\"\n render :new\n end\n end", "def create\n \n # # Get the user_id\n user_id = current_user.id\n # # Get the trip_id \n trip_id = request[:trip_id].to_i\n # # Find the trip by id\n trip = Trip.find_by(id:trip_id)\n # cal the total of booking\n total = trip.price * params[:participant_number].to_i\n # # Create a booking includs user_id, trip_id, total\n @booking = Booking.create({user_id:user_id,trip_id:trip_id,total:total})\n\n \n # // the number of form send it\n length = participant_params[\"first_name\"].length\n # //make them in separate object\n length.times do |index|\n participant = {}\n participant_params.each do |key,value|\n participant[key] = value[index]\n end\n @participant = Participant.new(participant)\n @participant[:booking_id] = @booking.id\n @participant.save\n end\n \n respond_to do |format|\n if @participant.save\n format.html { redirect_to booking_path(@booking.id), notice: \"تـم الحـجـز بنـجاح, شكراُ لـثـقتكـم\" }\n format.json { render :show, status: :created, location: @participant }\n else\n format.html { render :new }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n logged_in_log_in_or_create_user\n @challenge_participant = @challenge.challenge_participants.build(user_id: @user.id)\n respond_to do |format|\n begin\n if @challenge_participant.save\n format.html { redirect_to :root, notice: \"You successfully joined #{@challenge.name}.\" }\n format.json { render :show, status: :created, location: @challenge_participant }\n else\n format.html { render :new }\n format.json { render json: @challenge_participant.errors, status: :unprocessable_entity }\n end\n rescue\n @challenge_participant = ChallengeParticipant.where(user_id: @user.id, challenge_id: @challenge.id).first\n format.html { redirect_to :root, notice: \"You have already joined this challenge.\" }\n format.json { render :show, status: :created, location: @challenge_participant }\n end\n end\n end", "def participants=(value)\n @participants = value\n end", "def participants=(value)\n @participants = value\n end", "def new\n @reunion = Reunion.new\n if params[:tesisId].nil? then\n @tesis = Tese.all\n else\n @tesis = Tese.find(params[:tesisId])\n @asistentes = Reunion.find_by_sql('SELECT P.Id\n ,P.Nombre\n FROM Profesors P\n ,Teses T\n WHERE P.id = T.Profesor_id\n AND T.id = ' + @tesis.id.to_s +\n ' UNION ALL ' +\n 'SELECT E.Id\n ,E.nombreEstudiante Nombre\n FROM Estudiantes E\n ,Teses T\n WHERE E.Tesis_id = T.id\n AND T.id = ' + @tesis.id.to_s )\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reunion }\n end\n end", "def add_owner_to_participants\n EventParticipant.create(user_id: self.user_id, event_id: self.id)\n end", "def create\n if params[:participant][:accepted] == \"1\" and params[:participant][:prereq] == \"1\"\n unless current_user.participants.exists?(:school_id => params[:school_id])\n @participant = @school.participants.new(params[:participant])\n @participant.user_id = current_user.id\n @participant.accepted = 0\n @participant.save\n end\n end\n \n respond_to do |format|\n if @participant\n Notifier.participant_user(@participant,@school).deliver\n Notifier.participant_admins(@participant,@school).deliver\n format.js { render \"register_success\" }\n else\n format.js { render \"register_failure\" }\n end\n end\n end", "def destroy\n @reunion = Reunion.find(params[:id])\n asistente_ids = ReunionsEstudiantes.find_by_sql('SELECT DISTINCT E.estudiante_id\n FROM Reunions_Estudiantes E \n WHERE E.reunion_id = ' + params[:id].to_s)\n\n asistente_ids.each do |asistente|\n estudiante = Estudiante.find(:all, :conditions => [ \"id = ?\", asistente.estudiante_id ])\n if asistente.estudiante_id.to_f < 100 then\n datosAsist = {:nombre => estudiante[0].nombreEstudiante,\n :correo => estudiante[0].correoElectronico + \"@uniandes.edu.co\"}\n else\n profesor = Profesor.find(:all, :conditions => [ \"id = ?\", asistente.estudiante_id ])\n correo = \"harjair@hotmail.com\"\n datosAsist = {:nombre => profesor[0].nombre, :correo => correo}\n end\n UserMailer.cancelar_reunion(datosAsist, @reunion).deliver\n end\n\n @reunion.destroy\n\n respond_to do |format|\n format.html { redirect_to(reunions_url, notice: 'Reunion cancelada exitosamente.') }\n format.json { head :no_content }\n end\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def index\n @participants = Participant.all\n end", "def create\n @participant_rating = ParticipantRating.new(params[:participant_rating])\n @participant_rating.participant_id = @participant.id\n\n\n respond_to do |format|\n if @participant_rating.save\n format.html { redirect_to(new_participant_question_set1_path(@participant.id))}\n format.json { render json: @participant_rating, status: :created, location: @participant_rating }\n else\n format.html { render action: \"new\" }\n format.json { render json: @participant_rating.errors, status: :unprocessable_entity }\n end\n end\n end", "def participant_params\n params.require(:participant).permit(:email, :dynamic_id,:avatar,:name,:vote)\n end", "def create\n params[:participant] = convert_school_name_to_id params[:participant]\n @participant = Participant.new(params[:participant])\n\n respond_to do |format|\n if @participant.save\n format.html { redirect_to @participant, notice: 'Participant was successfully created.' }\n format.json { render json: @participant, status: :created, location: @participant }\n else\n format.html { render action: \"new\" }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_rounds\n\t\t@rounds = []\n\t\tcase @participant.league.type\n\t\twhen \"Fantasy\"\n\t\t\t@rounds = [\"fantasy\"]\n\t\twhen \"Elimination\"\n\t\t\t@rounds = [\"elimination\"]\n\t\tend\n\t\trender json: @rounds\n\tend", "def create\n @transaction_participant = Transaction::Participant.new(params[:transaction_participant])\n\n respond_to do |format|\n if @transaction_participant.save\n format.html { redirect_to(@transaction_participant, :notice => 'Participant was successfully created.') }\n format.xml { render :xml => @transaction_participant, :status => :created, :location => @transaction_participant }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @transaction_participant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n #directions = Score::DIRECTIONS.map{|k,v| k}\n #directions.shuffle!\n params[:game].merge!({:meeting_id => @meeting.id})\n @game = Game.create!(params[:game])\n participant_ids = params[:participants].collect{|id| id.to_i} if params[:participants]\n participant_ids.each do |id|\n score = Score.new\n score.game_id = @game.id\n score.participant_id = id.to_i\n #score.direction = directions.shift\n score.save!\n end\n\n respond_to do |format|\n if @game\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end", "def make_matches\n exchange = Exchange.find_by_id(params[:id])\n ps = exchange.participants.shuffle\n matches = []\n\n ps.each_with_index do |participant, i|\n if ps[i+1]\n matches << Match.new(santa_id: participant.id, \n recipient_id: ps[i+1].id)\n\n # When index is out of range, give first participant a santa\n else\n matches << Match.new(santa_id: participant.id,\n recipient_id: ps[0].id)\n end\n end\n begin\n matches.each do |match|\n if match.save\n next\n else\n raise match.errors.full_messages\n break\n end\n end\n\n rescue Exception => e\n flash[:error] = e\n redirect_to exchange_path(exchange)\n \n else\n flash[:success] = \"Participants successfully matched!\"\n redirect_to exchange_path(exchange)\n end\n end", "def create\n unless at_least_match_degree_times_available?\n flash[:error] = \"Error: you must be available for at least #{@participant.match_degree} times.\"\n redirect_to edit_project_participant_ranking_path(:secret_id => @participant.secret_id) and return\n return\n end\n\n update_rankings_from_params\n\n @participant.update(last_responded: Time.now.getutc)\n redirect_to end_project_participant_ranking_path\n end", "def participant_params\n params.require(:participant).permit(:first_name => [] , :last_name => [], :email => [], :gender => [])\n end", "def participant_params\n params.require(:participant).permit(:name)\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def create\n @game = Game.find(params[:game_id])\n @participant = Participant.new(participant_params)\n\n respond_to do |format|\n if @participant.save\n format.html { redirect_to show_participant_path(@game, @participant) }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @user = User.find_or_create_by_id(params[:participant_id], group: params[:group])\n @response = @user.responses.find_or_create_by_error_and_round_number(params[:response][:id], params[:response][:round_number])\n @response.update_attributes(params[:response])\n\n respond_to do |format|\n if @response.save\n format.js\n format.html { redirect_to(@response, notice: 'Response was successfully created.') }\n format.xml { render xml: @response, status: :created, location: @response }\n\n else\n format.js { render js: \"#{ @response.errors}\" }\n format.html { render action: 'new' }\n format.xml { render xml: @response.errors, status: :unprocessable_entity }\n\n end\n end\n end", "def participant_params\n params.require(:participant).permit(:event_id, :name, :title, :telephone_number, :email, :organization_name, :organization_type_id, :directorate_id, :responsibility, :place_of_work, :group_id, :field_visit_id, :stay_at, :participant_type_id, :checked_in)\n end", "def upload\n #logger.debug params\n @participant = Participant.find(params[:participantId])\n @key = params[:source]\n\n #clear all existing records of this type for this participant\n case @key\n when \"call_logs\"\n @participant.call_log_records.destroy_all\n when \"sms_logs\"\n @participant.sms_log_records.destroy_all\n when \"contacts\"\n @participant.contact_records.destroy_all\n when \"installed_apps\"\n @participant.installed_app_records.destroy_all\n\n when \"facebook_data\"\n @participant.conversations.destroy_all\n end\n\n #add each record \n params[:payload].each do|p|\n case @key\n when \"call_logs\"\n @participant.call_log_records.create(p.permit!)\n when \"sms_logs\"\n @participant.sms_log_records.create(p.permit!)\n when \"contacts\"\n @participant.contact_records.create(p.permit!)\n when \"installed_apps\"\n @participant.installed_app_records.create(p.permit!)\n\n when \"facebook_data\"\n if p[0] == \"name\"\n\n elsif p[0] == \"conversations\"\n p[1].each do |con|\n logger.debug con\n @participant.conversations.create(con.permit!)\n end\n \n end\n \n #@participant.conversations.create(p[\"conversations\"].permit!)\n end\n end\n\n render json: nil\n \n end", "def create\n @meetup_rsvp = MeetupRsvp.new(params[:meetup_rsvp])\n\t\t@meetup_rsvp.event_id = params[:event_id]\n\t\t@meetup_rsvp.rsvp = params[:rsvp]\n\t\t@meetup_rsvp.user_id = current_user.id\n\t\t@meetup_rsvp.username = current_user.username\n respond_to do |format|\n if @meetup_rsvp.save\n format.html { redirect_to meetup_path(@meetup_rsvp.event_id), notice: 'Meetup rsvp was successfully created.' }\n format.json { render json: meetup_path(@meetup_rsvp.event_id), status: :created, location: @meetup_rsvp }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meetup_rsvp.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[:sport_entry_id]\n @sport_entry = SportEntry.find(params[:sport_entry_id])\n @participant = Participant.find(params[:id])\n else\n @sport_entry = SportEntry.find(params[:id])\n @participant = Participant.find(params[:participant_id])\n end\n \n @sport_entry.participants << @participant unless @sport_entry.participants.include?(@participant)\n flash[:notice] = 'Participant added to sport entry.'\n \n respond_to do |format|\n format.html do \n if params[:return] && params[:return] == 'edit_sports'\n redirect_to(edit_sports_gc_participant_path(@participant)) \n else\n redirect_to(edit_gc_sport_entry_url(@sport_entry)) \n end\n end\n end\n end", "def new_user_and_participant\n @participant = Participant.new\n end", "def create\n params[:interview][:scheduler_id] = current_user.id\n @interview = @candidate.interviews.new(params[:interview])\n params[:other_interviewers].split(\",\").each do |interviewer|\n @interview.interviewers.new({:user_id => interviewer})\n end\n respond_to do |format|\n if @interview.save\n format.html { redirect_to candidate_path(@candidate), notice: 'Interview was successfully created.' }\n format.js { render :index }\n format.json { render json: @interview, status: :created, location: @interview }\n else\n format.html { render action: \"new\" }\n format.js { render :index }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to event_participants_url(@event), notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end", "def join\r\n if @trip.participants.include?(current_person)\r\n redirect_to(@trip, :notice => \"You are already a participant in the #{@trip.name}.\")\r\n return\r\n elsif @trip.organizers.include?(current_person) && request.post?\r\n @trip.participants << current_person\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n else\r\n @token = params[:token]\r\n invitation = Invitation.find_by_token(@token)\r\n if invitation.nil?\r\n redirect_to(person_root_url, :error => \"The invitation link you followed is invalid.\")\r\n return\r\n end\r\n \r\n if request.post?\r\n invitation.accept(current_person)\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n end\r\n end\r\n end", "def create\n @matchparticipant = Matchparticipant.new(matchparticipant_params)\n\n respond_to do |format|\n if @matchparticipant.save\n format.html { redirect_to @matchparticipant, notice: 'Matchparticipant was successfully created.' }\n format.json { render :show, status: :created, location: @matchparticipant }\n else\n format.html { render :new }\n format.json { render json: @matchparticipant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @eatvent = Eatvent.new(params[:eatvent])\n \n #put names into array\n #participantArr = @eatvent.people.gsub(/ /,'').split('-').select{|x|!x.empty?}\n participantArr = @eatvent.people\n @eatvent.people = participantArr.join(\",\")\n participantArr.each {|name| \n tempemail = User.where(:name => name).first.email \n UserMailer.eatvent_email(tempemail,@eatvent,\"You're invited to a new Eatvent!!\").deliver\n }\n \n respond_to do |format|\n if @eatvent.save\n format.html { redirect_to @eatvent, notice: 'Eatvent was successfully created.' }\n format.json { render json: @eatvent, status: :created, location: @eatvent }\n else\n format.html { render action: \"new\" }\n format.json { render json: @eatvent.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @movie_participant = MovieParticipant.new(movie_participant_params)\n\n respond_to do |format|\n if @movie_participant.save\n format.html { redirect_to @movie_participant, notice: 'Movie participant was successfully created.' }\n format.json { render action: 'show', status: :created, location: @movie_participant }\n else\n format.html { render action: 'new' }\n format.json { render json: @movie_participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def movie_participant_params\n params.require(:movie_participant).permit(:participant_id, :name, :birthplace, :birthdate)\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: '' }\n format.json { head :no_content }\n end\n end", "def add_participant_list(list)\n participants_list\n participants_list_name.set list[:name]\n participants_list_permissions.select list[:visible]\n \n create\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to admin_participants_url, notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def create\n @meeting.add_new_participant(@participant)\n respond_to do |format|\n if @participant.save && @meeting.save\n flash[:notice] = 'Participant and meeting updates were successfully created.'\n format.html { redirect_to(meeting_path(@meeting)) }\n format.xml { render :xml => @participant, :status => :created, :location => @participant }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @project_participant = ProjectParticipant.new(project_participant_params)\n\n respond_to do |format|\n if @project_participant.save\n format.html { redirect_to @project_participant, notice: 'Project participant was successfully created.' }\n format.json { render :show, status: :created, location: @project_participant }\n else\n format.html { render :new }\n format.json { render json: @project_participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def participant_params\n params.require(:participant).permit(:main_language, :years_programming, :language_choice, :client_w, :client_h)\n end", "def create\n @activity_participant = Activity::Participant.new(activity_participant_params)\n @activity_participant.user = current_user\n @activity_participant.activity = Activity.find_by_id(params[:activity_id])\n\n respond_to do |format|\n if @activity_participant.save\n format.html { redirect_to activity_participants_url, notice: \"Participant was successfully created.\" }\n format.json { render :show, status: :created, location: @activity_participant }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @activity_participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_participants\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n\n if user != nil and meeting != nil\n users = meeting.participants\n send_json(users)\n else\n send_error 401\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end" ]
[ "0.6766301", "0.6517003", "0.63479257", "0.61971337", "0.5998164", "0.59765255", "0.59743035", "0.59365195", "0.5928585", "0.5899314", "0.5885909", "0.58291566", "0.57847625", "0.57826763", "0.5775749", "0.5775749", "0.5760512", "0.57528865", "0.56993395", "0.566833", "0.56514347", "0.56368697", "0.5624477", "0.56226295", "0.56041104", "0.559288", "0.5574918", "0.5571357", "0.5550459", "0.5532803", "0.55175954", "0.5499368", "0.5497306", "0.54788965", "0.54681253", "0.54673415", "0.5462833", "0.54471034", "0.54468256", "0.54368573", "0.5436104", "0.54286873", "0.5403728", "0.5403728", "0.54031783", "0.5365555", "0.53625447", "0.5354227", "0.53535974", "0.53535974", "0.53535974", "0.53535974", "0.53535974", "0.53535974", "0.5346209", "0.533817", "0.53219825", "0.5309868", "0.53098595", "0.5308508", "0.53042006", "0.53027546", "0.5296947", "0.52870953", "0.52841365", "0.52841365", "0.52790177", "0.52774036", "0.52747846", "0.5266262", "0.52647495", "0.5262624", "0.5250445", "0.5238409", "0.5228408", "0.52274865", "0.52274865", "0.52242976", "0.5217073", "0.5216222", "0.5206029", "0.5198258", "0.51879203", "0.51875216", "0.5178965", "0.517823", "0.5175011", "0.51710737", "0.51666224", "0.51659304", "0.516428", "0.516428", "0.516428", "0.5160392", "0.5160392", "0.5160392", "0.5160392", "0.5160392", "0.5160392", "0.5160392" ]
0.6457217
2
PATCH/PUT /reunion_participantes/1 PATCH/PUT /reunion_participantes/1.json
def update respond_to do |format| if @reunion_participante.update(reunion_participante_params) format.html { redirect_to @reunion_participante, notice: 'Reunion participante was successfully updated.' } format.json { render :show, status: :ok, location: @reunion_participante } else format.html { render :edit } format.json { render json: @reunion_participante.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @participant.update(participant_update_params)\n respond_with(@participant)\n end", "def update\n @participant = Participant.find(params[:id])\n respond_to do |format|\n if @participant.update_attributes(participant_params)\n format.html { redirect_to @participant, notice: 'Participant was successfully updated.' }\n format.json { render json: @participant }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t@participant = Participant.find(params[:id])\n\n\t\tif @participant.update(participant_params)\n\t\t\thead :no_content\n\t\telse\n\t\t\trender json: @participant.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def update\n @participant.update_attributes(participant_update_params)\n respond_with(@participant)\n end", "def update\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n format.html { redirect_to @participant, notice: 'Participante actualizado.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participant.update(participant_params)\n format.html { redirect_to @participant, notice: 'Participant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participant.update(participant_params)\n format.html { redirect_to @participant, notice: 'Participant was successfully updated.' }\n # format.json { render :show, status: :ok, location: @participant }\n else\n format.html { render :edit }\n # format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participant.update(participant_params)\n format.html { redirect_to @participant, notice: 'Participant was successfully updated.' }\n format.json { render :show, status: :ok, location: @participant }\n else\n format.html { render :edit }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participant.update(participant_params)\n format.html { redirect_to @participant, notice: \"Participant was successfully updated.\" }\n format.json { render :show, status: :ok, location: @participant }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n game = Game.find(params[:game_id])\n participant = Participant.find(params[:participant_id])\n respond_to do |format|\n if participant.update(participant_params)\n format.html { redirect_to show_participant_path(game, participant) }\n format.json\n else\n format.html { render :edit }\n format.json\n end\n end\n end", "def update\n params[:interview][:participant_ids].each do |participant_id|\n unless participant_id.empty?\n participant = Participant.find(participant_id)\n @interview.participants << participant\n end\n end\n respond_to do |format|\n\n if @interview.update(interview_params)\n participants = @interview.participants\n emails = []\n participants.each do |p|\n emails += [p.email]\n ReminderMailer.update_email(p.email).deliver_now\n end\n format.html { redirect_to @interview, notice: 'Interview was successfully updated.' }\n format.json { render :show, status: :ok, location: @interview }\n else\n format.html { render :edit }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participant.update(participant_params)\n format.html { redirect_to participant_path }\n format.json { render :show, status: :ok, location: @participant }\n else\n format.html { render :edit }\n format.json { render json: @participant.errors }\n end\n end\n end", "def update\n debugger\n @participants = Participant.find(params[:id])\n\n respond_to do |format|\n if @participants.update_attributes(params[:participant])\n AuditTrail.audit(\"Participant #{@participants.fullname} updated by #{current_user.login}\", edit_participant_url(@participants))\n flash[:notice] = 'Participants was successfully updated.'\n format.html { redirect_to(participants_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participants.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participant.update(participant_params)\n render_participant_modified_message \"updated\"\n format.html { redirect_to display_project_participants_path(params[:project_id]) }\n format.json { render :show, status: :ok, location: @participant }\n else\n format.html { render :edit }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @participant = Participant.find(params[:id])\n # @participant.city = City.find(params[:participant][:city])\n\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n format.html { redirect_to participants_url, notice: 'Participant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @trip = Trip.find(params[:id])\n if params[:update]\n validated = true\n end\n respond_to do |format|\n if @trip.update(validated: validated)\n if validated == true\n @trip.participants.each do |u|\n u.update(token: u.token + 5)\n end\n format.js { render :layout => false , notice: 'Success of acceptance of correspondance status' }\n else\n flash[:danger] = 'Failure of modification of correspondance status.'\n redirect_to current_user\n end\n end\n end\n end", "def update\n @participant_bkp = Participant.new(@participant.attributes)\n respond_to do |format|\n if @participant.update(participant_params)\n @participant.competences.delete_all\n @competence.each {|competence| competence.participant = @participant; competence.save}\n @participant_bkp.id = nil\n @participant_bkp.original_participant_id = @participant.id\n @participant_bkp.save(validate: false)\n @participant_bkp.delete\n format.html { redirect_to add_to_list_participant_url(@participant), notice: 'Participant was successfully updated.' }\n format.json { render :show, status: :ok, location: @participant }\n else\n format.html { render :edit }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participant.update(participant_params)\n format.html { redirect_to \"/dynamics/#{@participant.dynamic_id}\", notice: '' }\n format.json { render :show, status: :ok, location: @participant }\n else\n format.html { render :edit }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participant.update_attributes(params[:participant]) && @meeting.update_attributes(@meeting.new_meeting_params_from(@participant, params[:participant]))\n flash[:notice] = 'Participant was successfully updated.'\n format.html { redirect_to(meeting_path(@meeting)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @activity_participant.update(activity_participant_params)\n format.html { redirect_to @activity_participant, notice: \"Participant was successfully updated.\" }\n format.json { render :show, status: :ok, location: @activity_participant }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @activity_participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @participant.update_attributes(params[:participant])\r\n format.html { redirect_to(@participant, :notice => 'Participant was successfully updated.') }\r\n format.xml { head :ok }\r\n else\r\n format.html { render :action => \"edit\" }\r\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @participant = Participant.find(params[:id])\n respond_to do |format|\n begin\n if @participant.update_attributes(params[:participant])\n AuditTrail.audit(\"Participant #{@participant.fullname} updated by #{current_user.login}\", edit_participant_url(@participant))\n flash[:notice] = 'Participants was successfully updated.'\n format.html { redirect_to(participants_url) }\n format.xml { head :ok }\n else\n flash[:error] = format_flash_error(\"Error updating #{@participant.fullname}\",\n \"participant update(): \\n #{format_validation_errors(@participant.errors)}\")\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n end\n rescue Exception => e\n flash[:error] = format_flash_error(\"Error updating #{@participant.fullname}\", \"participant update(): \\n #{e.to_s}\")\n logger.error \"ERROR updating participant \\n#{@participant.inspect}\"\n logger.error e.backtrace.join(\"\\n\\t\")\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @transaction_participant = Transaction::Participant.find(params[:id])\n\n respond_to do |format|\n if @transaction_participant.update_attributes(params[:transaction_participant])\n format.html { redirect_to(@transaction_participant, :notice => 'Participant was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @transaction_participant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n params[:participant] = convert_school_name_to_id params[:participant]\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n format.html { redirect_to @participant, notice: 'Participant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @participant_id = args[:participant_id] if args.key?(:participant_id)\n end", "def update\n @participant = @school.participants.find(params[:id])\n\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n @team = Team.find(params[:coreteam])\n @team.add_member(@participant.user)\n format.js\n if @participant.accepted == 2\n Notifier.participant_acceptance(@participant,@school).deliver\n end \n else\n format.js { render \"register_failure\" }\n end\n end\n end", "def update\n respond_to do |format|\n if @project_participant.update(project_participant_params)\n format.html { redirect_to @project_participant, notice: 'Project participant was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_participant }\n else\n format.html { render :edit }\n format.json { render json: @project_participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # // the number of form send it\n \n # //make them in separate object\n \n participant = {}\n participant_params.each do |key,value|\n participant[key] = value[0]\n end\n\n \n\n respond_to do |format|\n if @participant.update(participant)\n format.html { redirect_to booking_path(@participant.booking_id), notice: 'تم تحديث بيانات العضو بنجاح' }\n format.json { render :show, status: :ok, location: @participant }\n else\n format.html { render :edit }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @reunion = Reunion.find(params[:id])\n\n respond_to do |format|\n if @reunion.update_attributes(params[:reunion])\n format.html { redirect_to @reunion, notice: 'Reunion actualizada exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reunion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @rank_participant.update(rank_participant_params)\n format.html { redirect_to @rank_participant, notice: 'Rank participant was successfully updated.' }\n format.json { render :show, status: :ok, location: @rank_participant }\n else\n format.html { render :edit }\n format.json { render json: @rank_participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @participant.update(participant_params)\n flash[:success] = 'Participant was successfully updated.'\n redirect_to participants_url\n else\n flash[:danger] = 'Failed to update participant.'\n render :edit\n end\n end", "def update\n @volunteer = Volunteer.find(params[:id])\n #@user = @volunteer.user\n #@user.email = params[:email]\n #update emil here\n old = @volunteer.orientation\n \n respond_to do |format|\n if @volunteer.update_attributes(params[:volunteer])\n\t if old != @volunteer.orientation\n\t old.numCurrParticipant = old.numCurrParticipant - 1\n\t old.save\n\t @volunteer.orientation.numCurrParticipant = @volunteer.orientation.numCurrParticipant + 1\n\t @volunteer.orientation.save\n\t end\n \n @volunteer.user.email = @volunteer.email\n @volunteer.user.save\n \n\t format.html { \n\t redirect_to @volunteer, \n\t notice: 'Volunteer was successfully updated.' }\n\t format.json { head :no_content }\n else\n\t format.html { render action: \"edit\" }\n\t format.json { \n\t render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_reunion_participante\n @reunion_participante = ReunionParticipante.find(params[:id])\n end", "def update\n respond_to do |format|\n if @movie_participant.update(movie_participant_params)\n format.html { redirect_to @movie_participant, notice: 'Movie participant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @movie_participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_participant request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_update_participant_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Dialogflow::V2::Participant.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def update\n @meeting = Meeting.find(params[:id])\n\n respond_to do |format|\n if developer?\n #take care of meeting participants\n param_users = (params[:users].map {|i| i.to_i} rescue []).to_set\n meeting_users = (@meeting.meeting_participants.map {|mp| mp.user.id}).to_set\n (param_users - meeting_users).each {|uid| MeetingParticipant.create(:user => User.find(uid), :meeting => @meeting)}\n (meeting_users - param_users).each {|uid| MeetingParticipant.find(:first, :conditions => [\"meeting_id = ? and user_id = ?\", @meeting.id, uid]).destroy rescue nil}\n\n if @meeting.update_attributes(params[:meeting])\n flash[:notice] = 'Meeting was successfully updated.'\n format.html { redirect_to(iteration_stories_url(@meeting.iteration)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @meeting.errors, :status => :unprocessable_entity }\n end\n else\n format.xml { render :xml => XML_ERRORS[:not_authorized] }\n end\n end\n end", "def update\n @participant = Participant.find(params[:id])\n @notice = nil\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n format.html { redirect_to(@participant, :notice => 'Participant was successfully updated.') }\n #format.xml { head :ok }\n format.js\n else\n @notice = \"Cannot update your status at thte moment\"\n format.html { render :action => \"edit\" }\n #format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def reunion_participante_params\n params.require(:reunion_participante).permit(:reunion_id, :persona_id, :vendedor_id)\n end", "def update\n if @participant.organization_type.try(:name) == 'FMOH'\n @directorates = Directorate.all\n end\n respond_to do |format|\n if @participant.update(participant_params)\n format.html { redirect_to @participant, notice: 'Participant was successfully updated.' }\n format.json { render :show, status: :ok, location: @participant }\n else\n format.html { render :edit }\n format.json { render json: @participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @annex1_project_participant = Annex1ProjectParticipant.find(params[:id])\n\n respond_to do |format|\n if @annex1_project_participant.update_attributes(params[:annex1_project_participant])\n format.html { redirect_to @annex1_project_participant, notice: 'Annex1 project participant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @annex1_project_participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # if params[:attend].present?\n # @meetup_rsvp = MeetupRsvp.find(params[:id])\n # @meetup_rsvp.attend = params[:attend]\n # else\n @meetup_rsvp = MeetupRsvp.find(params[:id])\n\t @meetup_rsvp.rsvp = params[:rsvp]\n\t#end\n respond_to do |format|\n if @meetup_rsvp.update_attributes(params[:meetup_rsvp])\n format.html { redirect_to meetup_path(@meetup_rsvp.event_id), notice: 'Meetup rsvp was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @meetup_rsvp.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @trip = Trip.find(params[:id])\n #params[:trip][:participations] ||=[]\n respond_to do |format|\n if @trip.owner_id == current_user.id && @trip.update_attributes(params[:trip])\n flash[:notice] = 'Trip was successfully updated.'\n format.html { redirect_to(@trip) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @trip.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @orientation = Orientation.find(params[:id])\n volunteer = nil\n \n if !params[:id].nil?\n params.each do |p|\n if p[0].to_s.match(\"delOrien_*\")\n id = p[0].to_s.slice(9..-1).to_i\n volunteer = Volunteer.find(id) \n volunteer.orientation.numCurrParticipant = volunteer.orientation.numCurrParticipant - 1\n volunteer.orientation.save\n \n\n volunteer.orientation_id = 1\n volunteer.save\n \n #volunteer.orientation.numCurrParticipant = volunteer.orientation.numCurrParticipant + 1\n #volunteer.orientation.save\n elsif p[0].to_s.match(\"addOrien_*\")\n id = p[0].to_s.slice(9..-1).to_i\n volunteer = Volunteer.find(id)\n\n \n #volunteer.orientation.numCurrParticipant = volunteer.orientation.numCurrParticipant - 1\n #volunteer.orientation.save\n \n\n\t volunteer.orientation_id = params[p[0]][:id]\n\t volunteer.save\n \n volunteer.orientation.numCurrParticipant = volunteer.orientation.numCurrParticipant + 1\n volunteer.orientation.save\n end\n end\n end\n #@orientation2 = Orientation.find(volunteer.orientation_id)\n #@orientation2.numCurrParticipant = @orientation2.volunteers.length\n #@orientation.save\n #@orientation2.save\n\n\n# volunteer = nil\n# if !params[:id].nil?\n# params.each do |p|\n \n# if p[0].to_s.match(\"addOrien_*\")\n# id = p[0].to_s.slice(9..-1).to_i\n# volunteer = Volunteer.find(id)\n# volunteer.orientation_id = params[p[0]][:id]\n# volunteer.save\n \n \n \n \n# orient = Orientation.find(params[p[0]][:id])\n# myid = orient.id\n# puts \"ORIENTATIONNNNNNNNNNNNNNNNNNNN\"\n \n# puts orient.numCurrParticipant\n# orient.numCurrParticipant = orient.numCurrParticipant + 1\n# puts orient.numCurrParticipant\n \n# @orientation.save\n# end\n \n# end\n\n \n respond_to do |format|\n if @orientation.update_attributes(params[:orientation])\n format.html { redirect_to @orientation, notice: 'Orientation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @orientation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @participant = Participant.find(params[:id])\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n AuditTrail.audit(\"Participant #{@participant.fullname} updated by #{current_user.login}\", edit_participant_url(@participant))\n flash[:notice] = 'Participants was successfully updated.'\n format.html { redirect_to(participants_url) }\n format.xml { head :ok }\n# I don't think we're using this anymore?\n# format.js do\n# flash.discard\n# render(:update) do |page|\n# element = \"#{@participant.class}_#{@participant.id}_#{params[:participant].keys[0]}\"\n# page.replace_html(element,\n# :partial => 'flipflop',\n# :locals => {:p => @participant,\n# :type => params[:participant].keys[0] } )\n# end\n# end\n else\n flash[:error] = \"Error updating #{@participant.fullname} <br />[TECHNICAL DETAILS: update(): #{@participant.errors.join(',')}]\"\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n end\n end\n rescue Exception => e\n flash[:error] = \"Error updating #{@participant.fullname} <br />[TECHNICAL DETAILS: update(): #{e.to_s}]\"\n logger.error \"ERROR updating participant \\n#{@participant.inspect}\"\n logger.error e.backtrace.join(\"\\n\\t\")\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def set_participant\n @participant = Participant.find(params[:id])\n end", "def update\r\n respond_to do |format|\r\n if @sivic_participantecelula.update(sivic_participantecelula_params)\r\n format.html { redirect_to @sivic_participantecelula, notice: 'Registro alterado com sucesso.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: 'edit' }\r\n format.json { render json: @sivic_participantecelula.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update_participant(safebox_guid, participant_guid, participant_params)\n handle_error { sendsecure_connection.patch(\"api/v2/safeboxes/#{safebox_guid}/participants/#{participant_guid}.json\", participant_params) }\n end", "def update\n @person = Person.find(params[:id])\n @provider = Provider.find(params[:provider_id]) unless params[:provider_id].blank?\n\n respond_to do |format|\n if @person.update_attributes(params[:person])\n\n path = people_path\n msg = 'Person was successfully updated.'\n if @participant\n path = participant_path(@participant, :anchor => \"relationships_tab\")\n msg = 'Person was successfully updated.'\n end\n if @provider\n path = provider_path(@provider)\n msg = \"Person was successfully updated for #{@provider}.\"\n end\n\n format.html { redirect_to(path, :notice => msg) }\n format.json { render :json => @person }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_participant\n @participant = Participant.find_by_id(params[:id])\n end", "def update\n @participation = Participation.find(params[:id])\n\n respond_to do |format|\n if @participation.update_attributes(params[:participation])\n format.html {redirect_to contest_participants_path(:contest => @contest.permalink, :role => \"admin\", :contest_id => @contest_instance.permalink, :uuid => @contest_instance.uuid)}\n format.js { head :ok}\n else\n format.html {redirect_to contest_participants_path(:contest => @contest.permalink, :role => \"admin\", :contest_id => @contest_instance.permalink, :uuid => @contest_instance.uuid)}\n format.js { head :unprocessable_entity}\n end\n end\n end", "def update\n respond_to do |format|\n if @participante.update(participante_params)\n format.html { redirect_to @participante, notice: 'Participante was successfully updated.' }\n format.json { render :show, status: :ok, location: @participante }\n else\n format.html { render :edit }\n format.json { render json: @participante.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @order.update(order_params)\n @users = User.order(:user_name)\n @restaurants = Restaurant.order(:rest_name)\n @parts = params[:part_ids]\n \tif !(@parts.nil?)\n \t @parts.each do |part|\n\t\t \tif (part != @order.order_organizer)\n\t\t\t @thispart = Participant.create!({:part_user => part, :part_order => @order.id, :part_role => \"participant\", :part_cost => 0.00})\n \t end\n \t end\n \tend\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def activo_update\n respond_to do |format|\n activo = params[:laboratorio][:activo]\n id = params[:id]\n Laboratorio.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end", "def update\n respond_to do |format|\n if @waiter.update(waiter_params.slice(:name, :email, :mobile))\n format.html { redirect_to waiters_manager_path(current_user), notice: i18n_notice('updated',@waiter) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @waiter.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participant_type.update(participant_type_params)\n format.html { redirect_to @participant_type, notice: 'Participant type was successfully updated.' }\n else\n format.html { render action: 'edit' }\n end\n end\n end", "def update_by_body\n @person = Person.find(person_update_params[:id])\n\n if @person.update_attributes(person_update_params)\n render json: { status: 'PUT Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error updating person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @participate.update_attributes(participate_params)\n flash[:notice] = 'Participate was successfully updated.'\n format.html { redirect_to(@participate) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participate.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n partnership = Partnership.new\n partnership.user = current_user\n\n if (partnership.participants.find_by(reference: params[:first_participant_id]) == nil)\n participant1= Participant.find_by(reference: params[:first_participant_id])\n partnership.participants.concat(participant1)\n end\n\n if (partnership.participants.find_by(reference: params[:second_participant_id]) == nil)\n participant2= Participant.find_by(reference: params[:second_participant_id])\n partnership.participants.concat(participant2)\n end\n\n #partnership.first_participant = Participant.find_by(reference: params[:first_participant_id])\n #partnership.second_participant = Participant.find_by(reference: params[:second_participant_id])\n\n partnership.save\n @partnership = partnership\n\n=begin\n respond_to do |format|\n if partnership.save\n format.html { redirect_to @partnership, notice: 'Partnership was successfully created.' }\n format.json { render action: 'show', status: :created, location: @partnership }\n else\n format.html { render action: 'new' }\n format.json { render json: @partnership.errors, status: :unprocessable_entity }\n end\n end\n=end\n end", "def update\n if @recruiter.update(recruiter_params)\n render_json_message({success: t('.success')}, 200)\n else\n render_json_message({errors: @recruiter.errors.messages}, 422)\n end\n end", "def update\n respond_to do |format|\n if @teammate.update(teammate_params)\n format.html { redirect_to pitch_teammate_path(@pitch, @teammate), notice: \"O Tripulante <strong>#{@teammate.user.name}</strong> foi atualizado.\" }\n format.json { render :show, status: :ok, location: [@pitch, @teammate] }\n else\n format.html { render :edit }\n format.json { render json: @teammate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @subscriber = Subscriber.where(openid: volunteer_params[:openid]).first\n @volunteer = @subscriber.volunteer\n @volunteer.name = volunteer_params[:name]\n @volunteer.tel = volunteer_params[:tel]\n @volunteer.commun = volunteer_params[:commun]\n @volunteer.neighborhood = volunteer_params[:neighborhood]\n respond_to do |format|\n if @volunteer.save\n # format.html { redirect_to @volunteer, notice: 'Volunteer was successfully updated.' }\n format.html { render \"volunteers/success\" }\n format.json { render :show, status: :ok, location: @volunteer }\n else\n format.html { render :edit }\n format.json { render json: @volunteer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @participant = Participant.find(params[:id])\n if params[:participant][:active] == '1'\n @participant.make_active\n end\n\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n session[:operate_mode] = nil\n format.html { redirect_to(@participant, :notice => t('global.operate_success')) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n @participants = Participant.all\n @users = User.all\n if @lineitem.update(lineitem_params)\n format.html { redirect_to @lineitem, notice: 'Lineitem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @lineitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @participation.update(participation_params)\n format.html { redirect_to participations_path, notice: 'Deltaker ble oppdatert.' }\n format.json { render :show, status: :ok, location: @participation }\n else\n format.html { render :edit }\n format.json { render json: @participation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @participant_rating = ParticipantRating.find(params[:id])\n\n respond_to do |format|\n if @participant_rating.update_attributes(params[:participant_rating])\n format.html { redirect_to @participant_rating, notice: 'Participant rating was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participant_rating.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @participation = Participation.find(params[:id])\n\n respond_to do |format|\n if @participation.update_attributes(params[:participation])\n format.html { redirect_to volunteer_participation_url(current_user, @participation), notice: 'Participation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @participation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #Finding the specific chore where the id matches the one we pass in with the body\n @v1_chore = Chore.where(id: params[:id]).first\n #Here we're checking if we have user_id in our body, and if we do, we'll change the selected chore's properties\n #with the parameters of the body, we go through the specific group to our specific chore with the path\n if v1_chore_params[:user_id]\n @v1_chore.user_id = params[:user_id]\n @v1_chore.assigned = true\n if @v1_chore.save\n render :show, status: :ok\n end\n else\n render json: @v1_chore.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @matchparticipant.update(matchparticipant_params)\n format.html { redirect_to @matchparticipant, notice: 'Matchparticipant was successfully updated.' }\n format.json { render :show, status: :ok, location: @matchparticipant }\n else\n format.html { render :edit }\n format.json { render json: @matchparticipant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #parametros_autocomplete!(params[:estudiante][:persona])\n @estudiante = Estudiante.find(params[:id])\n \n begin\n @estudiante.persona_id = params[:persona][:id]\n rescue\n end\n\n respond_to do |format|\n if @estudiante.update_attributes(params[:estudiante])\n format.html { redirect_to @estudiante, notice: 'Estudiante actualizado' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @estudiante.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # if @tournament.update(tournament_params)\n # render :show, status: :ok, location: @tournament\n # else\n # render json: @tournament.errors, status: :unprocessable_entity\n # end\n end", "def update\n respond_to do |format|\n if @practice.update(practice_params)\n # Delete the currently associated partner\n if params[:original_recruiter].present?\n delete_sql = \"DELETE FROM partners_practices WHERE \" +\n \"partner_id = #{params[:original_recruiter]} AND practice_id = #{@practice.id};\"\n ActiveRecord::Base.connection.execute delete_sql\n end\n # Add the new associated partner (if any)\n if params[:recruiter_partner].present?\n insert_sql = \"INSERT INTO partners_practices (partner_id, practice_id) \" +\n \"VALUES (#{params[:recruiter_partner]}, #{@practice.id});\"\n ActiveRecord::Base.connection.execute insert_sql\n end\n format.html { redirect_to partner_path(current_partner), notice: 'Practice was successfully updated.' }\n format.json { render :show, status: :ok, location: @practice }\n else\n format.html { render :edit }\n format.json { render json: @practice.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch_conversation_participant_with_http_info(conversation_id, participant_id, body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: ConversationsApi.patch_conversation_participant ...\"\n end\n \n \n # verify the required parameter 'conversation_id' is set\n fail ArgumentError, \"Missing the required parameter 'conversation_id' when calling ConversationsApi.patch_conversation_participant\" if conversation_id.nil?\n \n \n \n \n \n \n # verify the required parameter 'participant_id' is set\n fail ArgumentError, \"Missing the required parameter 'participant_id' when calling ConversationsApi.patch_conversation_participant\" if participant_id.nil?\n \n \n \n \n \n \n # verify the required parameter 'body' is set\n fail ArgumentError, \"Missing the required parameter 'body' when calling ConversationsApi.patch_conversation_participant\" if body.nil?\n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/conversations/{conversationId}/participants/{participantId}\".sub('{format}','json').sub('{' + 'conversationId' + '}', conversation_id.to_s).sub('{' + 'participantId' + '}', participant_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(body)\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, 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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConversationsApi#patch_conversation_participant\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n @participante = Participante.find(params[:id])\n\n respond_to do |format|\n if @participante.update_attributes(params[:participante])\n format.html { redirect_to(@participante, :notice => 'Participante was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participante.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n head 404\n # @api_v1_follower = Api::V1::Follower.find(params[:id])\n\n # if @api_v1_follower.update(api_v1_follower_params)\n # head :no_content\n # else\n # render json: @api_v1_follower.errors, status: :unprocessable_entity\n # end\n end", "def update\n # TODO: add push notification here\n pending_request = PendingTutorRequest.find(params[:id])\n accepted_request = AcceptedTutorRequest\n .create(pending_request.as_json(only: [:tutor_subject_id, :student_id, :tutor_id]))\n pending_request.destroy\n json_response(accepted_request, :ok)\n end", "def update\n @persona_tipo = PersonaTipo.find(params[:id])\n\n respond_to do |format|\n if @persona_tipo.update_attributes(params[:persona_tipo])\n format.html { redirect_to @persona_tipo, notice: 'Tipo de participante actualizado correctamente.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @persona_tipo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @elector = Elector.find(params[:id])\n\n if @elector.update(elector_params)\n head :no_content\n else\n render json: @elector.errors, status: :unprocessable_entity\n end\n end", "def update\n @host_project_participant = HostProjectParticipant.find(params[:id])\n\n respond_to do |format|\n if @host_project_participant.update_attributes(params[:host_project_participant])\n format.html { redirect_to @host_project_participant, notice: 'Host project participant was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @host_project_participant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @routine_interview = RoutineInterview.find(params[:id])\n @interview = Interview.find(@routine_interview.interview_id)\n\n respond_to do |format|\n if @routine_interview.update_attributes(params[:routine_interview]) && @interview.update_attributes(params[:interview])\n format.html { redirect_to @routine_interview, notice: 'Followup interview was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @routine_interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if request.content_type == \"application/json\"\n # .update is like a \"update people set ...\" in sql\n if @person.update(person_params)\n render json: @person\n else\n render json: @person.errors, status: :not_found\n end\n else\n render status: :bad_request\n end\n end", "def update\n params[:interview][:scheduler_id] = current_user.id\n @interview = @candidate.interviews.find(params[:id])\n params[:interview][:scheduled_at] = params[:edit][:date_scheduled_at]\n @interview.interviewers.create!(convert_string_to_hash(params[:interviewer_id], :user_id)) unless params[:interviewer_id].blank?\n @interview.interviewers.destroy(*params[:mark_to_delete].split(',').uniq) unless params[:mark_to_delete].blank?\n\n respond_to do |format|\n if @interview.update_attributes(params[:interview])\n format.html { redirect_to candidate_path(@candidate), notice: 'Interview was successfully updated.' }\n format.js { render :index }\n format.json { render json: @interview, status: :updated }\n else\n format.html { render action: \"edit\" }\n format.js { render :index }\n format.json { render json: @interview.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @collaborator.update(collaborator_params)\n format.html { redirect_to :back, notice: \"Le Collaborateur #{@collaborator.name} a été modifié avec succès.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @collaborator.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n scan_procedure_array = (current_user.edit_low_scan_procedure_array).split(' ').map(&:to_i)\n# @participant = Participant.where(\" participants.id in ( select participant_id from enrollments where enrollments.id in (select enrollment_visit_memberships.enrollment_id from enrollment_visit_memberships where enrollment_visit_memberships.visit_id in\n# (select visit_id from scan_procedures_visits where scan_procedure_id in (?)))) \", scan_procedure_array).find(params[:id])\n @participant = Participant.where(\" participants.id in ( select participant_id from enrollments where enrollments.id in (select enrollment_vgroup_memberships.enrollment_id from enrollment_vgroup_memberships, scan_procedures_vgroups\n where enrollment_vgroup_memberships.vgroup_id = scan_procedures_vgroups.vgroup_id and scan_procedures_vgroups.scan_procedure_id in (?))) \", scan_procedure_array).find(params[:id])\n\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n sql = \"update participants set wrapnum = NULL where trim(wrapnum) = '' \"\n connection = ActiveRecord::Base.connection();\n results = connection.execute(sql)\n sql = \"update participants set reggieid = NULL where trim(reggieid) = '' \"\n results = connection.execute(sql)\n if @participant.dob > 365.days.ago.to_date # form is setting a default date of today sometimes\n @participant.dob = nil\n @participant.save\n end\n if !@participant.dob.blank?\n @appointments = Appointment.where(\"appointments.vgroup_id in (select vgroups.id from vgroups where participant_id is not null and participant_id in (?))\", params[:id])\n @appointments.each do |appt|\n appt.age_at_appointment = ((appt.appointment_date - @participant.dob)/365.25).floor\n appt.save\n end\n end\n \n flash[:notice] = 'Participant was successfully updated.'\n format.html { redirect_to(@participant) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n scan_procedure_array = (current_user.edit_low_scan_procedure_array).split(' ').map(&:to_i)\n# @participant = Participant.where(\" participants.id in ( select participant_id from enrollments where enrollments.id in (select enrollment_visit_memberships.enrollment_id from enrollment_visit_memberships where enrollment_visit_memberships.visit_id in\n# (select visit_id from scan_procedures_visits where scan_procedure_id in (?)))) \", scan_procedure_array).find(params[:id])\n @participant = Participant.where(\" participants.id in ( select participant_id from enrollments where enrollments.id in (select enrollment_vgroup_memberships.enrollment_id from enrollment_vgroup_memberships, scan_procedures_vgroups\n where enrollment_vgroup_memberships.vgroup_id = scan_procedures_vgroups.vgroup_id and scan_procedures_vgroups.scan_procedure_id in (?))) \", scan_procedure_array).find(params[:id])\n\n respond_to do |format|\n if @participant.update_attributes(params[:participant])\n sql = \"update participants set wrapnum = NULL where trim(wrapnum) = '' \"\n connection = ActiveRecord::Base.connection();\n results = connection.execute(sql)\n sql = \"update participants set reggieid = NULL where trim(reggieid) = '' \"\n results = connection.execute(sql)\n if @participant.dob > 365.days.ago.to_date # form is setting a default date of today sometimes\n @participant.dob = nil\n @participant.save\n end\n if !@participant.dob.blank?\n @appointments = Appointment.where(\"appointments.vgroup_id in (select vgroups.id from vgroups where participant_id is not null and participant_id in (?))\", params[:id])\n @appointments.each do |appt|\n appt.age_at_appointment = ((appt.appointment_date - @participant.dob)/365.25).floor\n appt.save\n end\n end\n \n flash[:notice] = 'Participant was successfully updated.'\n format.html { redirect_to(@participant) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participant.errors, :status => :unprocessable_entity }\n end\n end\n end" ]
[ "0.6920191", "0.688601", "0.6833657", "0.68277436", "0.6800636", "0.6793416", "0.6737852", "0.672295", "0.6712521", "0.66809267", "0.6651818", "0.6645737", "0.65834254", "0.6534882", "0.6508849", "0.64529866", "0.63919836", "0.6247253", "0.62378466", "0.6232123", "0.6221505", "0.6211944", "0.61729634", "0.6159858", "0.61428326", "0.61276245", "0.6111592", "0.6109398", "0.6103863", "0.6071834", "0.60610694", "0.6039081", "0.5999836", "0.5995846", "0.5943561", "0.59236753", "0.59236753", "0.5901026", "0.5877806", "0.58715343", "0.58650875", "0.58441764", "0.58389896", "0.58324015", "0.5818434", "0.5803193", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57903427", "0.57728356", "0.5770662", "0.5734732", "0.57182527", "0.5717388", "0.57162666", "0.5715825", "0.57128656", "0.5700819", "0.5679775", "0.5677933", "0.56640977", "0.5657152", "0.5641171", "0.5640347", "0.56394", "0.56392395", "0.56345934", "0.56220984", "0.56168175", "0.5614583", "0.5596307", "0.5594031", "0.5593378", "0.5578982", "0.5573116", "0.5571555", "0.5564656", "0.55557907", "0.5543077", "0.5542508", "0.5532256", "0.552912", "0.5527914", "0.5517512", "0.5504791", "0.55021465", "0.5496359", "0.5496359" ]
0.64498305
16
DELETE /reunion_participantes/1 DELETE /reunion_participantes/1.json
def destroy @reunion_participante.destroy respond_to do |format| format.html { redirect_to reunion_participantes_url, notice: 'Reunion participante was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant = Participant.find(params[:id])\n @participant.destroy\n\n respond_to do |format|\n format.html { redirect_to participants_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant = Participant.find(params[:id])\n @participant.destroy\n\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant = Participant.find(params[:id])\n @participant.destroy\n\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: '' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url }\n format.json { head :no_content }\n end\n Partextra.where(participant_id: @participant.id).destroy_all\n Badge.where(participant_id: @participant.id).destroy_all\n end", "def destroy\n # @participant.destroy\n # respond_to do |format|\n # format.html { redirect_to participants_url, notice: 'Participant was successfully destroyed.' }\n # format.json { head :no_content }\n # end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to admin_participants_url, notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_with(@participant)\n end", "def destroy\n @participant.destroy\n respond_with(@participant)\n end", "def destroy\n @participant.studysite.destroy_all\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@participant.destroy\n\n\t\thead :no_content\n\tend", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to event_participants_url(@event), notice: 'Participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @activity_participant.destroy\n respond_to do |format|\n format.html { redirect_to activity_participants_url, notice: \"Participant was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @participant.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(participants_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @reunion = Reunion.find(params[:id])\n asistente_ids = ReunionsEstudiantes.find_by_sql('SELECT DISTINCT E.estudiante_id\n FROM Reunions_Estudiantes E \n WHERE E.reunion_id = ' + params[:id].to_s)\n\n asistente_ids.each do |asistente|\n estudiante = Estudiante.find(:all, :conditions => [ \"id = ?\", asistente.estudiante_id ])\n if asistente.estudiante_id.to_f < 100 then\n datosAsist = {:nombre => estudiante[0].nombreEstudiante,\n :correo => estudiante[0].correoElectronico + \"@uniandes.edu.co\"}\n else\n profesor = Profesor.find(:all, :conditions => [ \"id = ?\", asistente.estudiante_id ])\n correo = \"harjair@hotmail.com\"\n datosAsist = {:nombre => profesor[0].nombre, :correo => correo}\n end\n UserMailer.cancelar_reunion(datosAsist, @reunion).deliver\n end\n\n @reunion.destroy\n\n respond_to do |format|\n format.html { redirect_to(reunions_url, notice: 'Reunion cancelada exitosamente.') }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant = Participant.find(params[:id])\n @participant.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end", "def destroy\n @movie_participant.destroy\n respond_to do |format|\n format.html { redirect_to movie_participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant = Participant.find(params[:id])\n\t\tif @participant.ganador_flag\n\t\t\t@ganador = Ganador.find_by_id_participante(@participant.id)\n\t\t\t@ganador.destroy\n\t\tend\n @participant.destroy\n\n respond_to do |format|\n format.html { redirect_to participants_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @participation.destroy\n respond_to do |format|\n format.html { redirect_to trips_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @annex1_project_participant = Annex1ProjectParticipant.find(params[:id])\n @annex1_project_participant.destroy\n\n respond_to do |format|\n format.html { redirect_to annex1_project_participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Participant was successfully destroyed.' }\n end\n end", "def destroy\n @transaction_participant = Transaction::Participant.find(params[:id])\n @transaction_participant.destroy\n\n respond_to do |format|\n format.html { redirect_to(transaction_participants_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @participante.destroy\n respond_to do |format|\n format.html { redirect_to participantes_url, notice: 'Participante was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participante = Participante.find(params[:id])\n @participante.destroy\n\n respond_to do |format|\n format.html { redirect_to(participantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @participante = Participante.find(params[:id])\n @participante.destroy\n\n respond_to do |format|\n format.html { redirect_to(participantes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @participant.destroy\n flash[:notice] = 'Participant was successfully removed.'\n respond_to do |format|\n format.html { redirect_to(meeting_participants_path(@meeting)) }\n format.xml { head :ok }\n end\n end", "def destroy\n if current_user.admin?\n @participant.destroy\n respond_to do |format|\n format.html { redirect_to participants_url, notice: \"Participant was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end \n end", "def destroy\n @challenge_participant.destroy\n respond_to do |format|\n format.html { redirect_to action: \"index\", id: @challenge.token, notice: 'Challenge participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @matchparticipant.destroy\n respond_to do |format|\n format.html { redirect_to matchparticipants_url, notice: 'Matchparticipant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant_type.destroy\n respond_to do |format|\n format.html { redirect_to participant_types_url }\n end\n end", "def destroy\n @rank_participant.destroy\n respond_to do |format|\n format.html { redirect_to rank_participants_url, notice: 'Rank participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participate.destroy\n\n respond_to do |format|\n format.html { redirect_to participates_url }\n format.json { head :no_content }\n end\n end", "def really_delete\n RankParticipant.only_deleted.find(params[:id]).really_destroy!\n\n respond_to do |format|\n format.html { redirect_to rank_participants_url, notice: 'RankParticipant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \n @laboratorio.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\n end\n end", "def destroy\n @tribe.destroy\n respond_to do |format|\n format.html { redirect_to tribes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participants = Participant.find(params[:id])\n success = @participants.destroy\n\n if success and @participants.errors.empty?\n AuditTrail.audit(\"Participant #{@participants.fullname} destroyed by #{current_user.login}\")\n flash[:success] = \"Participant #{@participants.fullname} destroyed\"\n else\n flash[:error] = @participants.errors.full_messages\n end\n respond_to do |format|\n format.html { redirect_to(participants_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @recolector.destroy\n respond_to do |format|\n format.html { redirect_to recolectors_url, notice: 'Recolector was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @estado_remate.destroy\n respond_to do |format|\n format.html { redirect_to estado_remates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @project_participant.destroy\n respond_to do |format|\n format.html { redirect_to project_participants_url, notice: 'Project participant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @relatorio_colaborador.destroy\n respond_to do |format|\n format.html { redirect_to relatorios_colaborador_url, notice: 'Relatorio colaborador was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @corporacion_policiaca = CorporacionPoliciaca.find(params[:id])\n if @corporacion_policiaca.participantes.empty?\n @corporacion_policiaca.destroy\n flash[:notice] = \"Registro eliminado correctamente\"\n else\n flash[:error] = \"Registro no se pudo eliminar\"\n end\n\n respond_to do |format|\n format.html { redirect_to(corporacion_policiacas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @uchronia = Uchronia.find(params[:id])\n @uchronia.destroy\n\n respond_to do |format|\n format.html { redirect_to uchronias_url }\n format.json { head :no_content }\n end\n end", "def destroy\n contest = @data_set.contest\n @data_set.destroy\n respond_to do |format|\n format.html { redirect_to admin_contest_url(contest), notice: 'Data set was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant.destroy\n flash[:success] = 'Participant was successfully destroyed.'\n redirect_to participants_url\n end", "def destroy\n @persona = Persona.find(params[:id])\n @persona.destroy\n\n respond_to do |format|\n format.json { head :ok }\n end\n \n end", "def destroy\n @meetup_rsvp = MeetupRsvp.find(params[:id])\n @meetup_rsvp.destroy\n\n respond_to do |format|\n format.html { redirect_to request.referer}\n format.json { head :no_content }\n end\n end", "def destroy\n @followup_interview = FollowupInterview.find(params[:id])\n @followup_interview.destroy\n\n respond_to do |format|\n format.html { redirect_to followup_interviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @host_project_participant = HostProjectParticipant.find(params[:id])\n @host_project_participant.destroy\n\n respond_to do |format|\n format.html { redirect_to host_project_participants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @participant_rating = ParticipantRating.find(params[:id])\n @participant_rating.destroy\n\n respond_to do |format|\n format.html { redirect_to participant_ratings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @auditor_participation = @site.auditor_participations.find(params[:id])\n @auditor_participation.destroy\n \n respond_to do |format|\n format.html { redirect_to @site, notice: 'AuditorParticipation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reunion_option = ReunionOption.find(params[:id])\n @reunion_option.destroy\n\n respond_to do |format|\n format.html { redirect_to(reunion_options_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n teammate_name = @teammate.name\n @teammate.destroy\n respond_to do |format|\n format.html { redirect_to pitch_teammates_path(@pitch), notice: \"O Tripulante <strong>#{teammate_name}</strong> foi removido e será notificado.\" }\n format.json { head :no_content }\n end\n end", "def destroy_by_body\n @person = Person.find(person_delete_param[:id])\n id = @person.id\n\n if @person.destroy\n render json: { status: 'DELETE Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error deleting person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def destroy\n @pessoa_receber = PessoaReceber.find(params[:id])\n @pessoa_receber.destroy\n\n respond_to do |format|\n format.html { redirect_to pessoa_recebers_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @tprimarytumor.destroy\n respond_to do |format|\n format.html { redirect_to tprimarytumors_url, notice: 'tprimarytumor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @orientation = Orientation.find(params[:id])\n @orientation.volunteers.each do |v|\n v.orientation_id = 1\n v.save\n \n #v.orientation.numCurrParticipant = v.orientation.numCurrParticipant + 1\n #v.orientation.save\n end\n @orientation.destroy\n \n respond_to do |format|\n format.html { redirect_to orientations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @trainee = Trainee.find(params[:id])\n @trainee.destroy\n respond_to do |format|\n format.html { redirect_to training_calendar_trainees_path(params[:training_calendar_id]), :notice => 'The participant was successfully removed.' }\n format.json { head :ok }\n end\n end", "def destroy\n @participation.destroy\n respond_to do |format|\n format.html { redirect_to participations_url, notice: 'Deltaker ble slettet' }\n format.json { head :no_content }\n end\n end", "def api_remove\n data_hash = make_hash\n delete_hash = { division: data_hash[:division][:value] }\n handler.remove(delete_hash, path, subscriber_id)\n end", "def destroy\n @remixer.destroy\n respond_to do |format|\n format.html { redirect_to remixers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @anexo_relatorio_colaborador.destroy\n respond_to do |format|\n format.html { redirect_to anexo_relatorios_colaborador_url, notice: 'Anexo relatorio colaborador was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reconcile = Reconcile.find(params[:id])\n @reconcile.destroy\n\n respond_to do |format|\n format.html { redirect_to reconciles_url }\n format.json { head :no_content }\n end\n end", "def delete\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n\n if user != nil and meeting != nil\n participants = meeting.participants\n meeting.participants.delete(participants)\n meeting.delete\n self.send_ok\n else\n self.send_error 401\n end\n end", "def destroy\n @repuestum = Repuestum.find(params[:id])\n @repuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to repuesta_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @collaborator = Collaborator.find(params[:id])\n @collaborator.destroy\n\n respond_to do |format|\n format.html { redirect_to collaborators_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @relatorio.destroy\n respond_to do |format|\n format.html { redirect_to relatorios_url, notice: 'Relatorio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @rameur.reservations.each { |resa| resa.destroy if resa.rameurs.size == 1 }\n Reservation.where(responsable_id: @rameur.id).each { |resa| resa.destroy(responsable_id: nil) }\n @rameur.destroy\n respond_to do |format|\n format.html { redirect_to rameurs_url, notice: \"Rameur supprimé\" }\n format.json { head :no_content, status: :success }\n end\n end", "def destroy\n @collaborator.destroy\n respond_to do |format|\n format.html { redirect_to collaborators_url, notice: \"Colaborador removido com sucesso!!\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @tournament.destroy\n respond_to do |format|\n format.html { redirect_to tournaments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tournament.destroy\n respond_to do |format|\n format.html { redirect_to tournaments_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n \r\n @sivic_participantecelula.destroy\r\n respond_to do |format|\r\n format.html { redirect_to sivic_participantecelulas_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @remito = Remito.find(params[:id])\n @remito.destroy\n\n respond_to do |format|\n format.html { redirect_to remitos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting.destroy\n respond_to do |format|\n format.html { redirect_to meetings_url, notice: 'Reunion borrada :(' }\n format.json { head :no_content }\n end\n end", "def destroy\n #@german_go_league = GermanGoLeague.find(params[:id])\n @german_go_league.destroy\n\n respond_to do |format|\n format.html { redirect_to german_go_leagues_url }\n format.json { head :ok }\n end\n end", "def remove_participant\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n participant_ids = params[\"participant_ids\"]\n\n if user != nil and meeting != nil and participant_ids.length > 0\n participant_ids.each do |participant_id|\n if meeting.participants.exists?(participant_id)\n # remove all the participant's votes from each suggestion\n meeting.suggestions.each do |suggestion|\n vote = Vote.where(:voter_id => participant_id, :suggestion_id => suggestion.id)\n if vote != nil\n suggestion.votes.delete(vote)\n end\n end\n meeting.participants.delete(User.find(participant_id))\n end\n end\n self.send_ok\n else\n self.send_error 401\n end\n end", "def destroy\n @participate_in.destroy\n respond_to do |format|\n format.html { redirect_to participate_ins_url, notice: 'Participate in was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @recitator.destroy\n respond_to do |format|\n format.html { redirect_to recitators_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @election = Election.find(params[:id])\n @election.destroy\n respond_to do |format|\n format.html { redirect_to user_elections_path, notice: 'Election was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def undo_deletion\n RankParticipant.only_deleted.find(params[:id]).restore\n\n respond_to do |format|\n format.html { redirect_to rank_participants_url, notice: 'RankParticipant was successfully recovered.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tumor.destroy\n respond_to do |format|\n format.html { redirect_to tumors_url, notice: 'El registro se elimino con exito.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reel = Reel.find(params[:id])\n @reel.destroy\n\n respond_to do |format|\n format.html { redirect_to reels_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @persona.destroy\n respond_to do |format|\n format.html { redirect_to personas_url, notice: 'Datos personales eliminados exitosamente.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @colleague = Colleague.find(params[:id])\n @colleague.destroy\n\n respond_to do |format|\n format.html { redirect_to colleagues_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @colleague = Colleague.find(params[:id])\n @colleague.destroy\n\n respond_to do |format|\n format.html { redirect_to colleagues_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ptel_reup.destroy\n respond_to do |format|\n format.html { redirect_to ptel_reups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @updaterete = Updaterete.find(params[:id])\n @updaterete.destroy\n\n respond_to do |format|\n format.html { redirect_to updateretes_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @relatorio.destroy\r\n respond_to do |format|\r\n format.html { redirect_to relatorios_url, notice: 'Relatório excluído com sucesso.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @participant = @school.participants.find(params[:id])\n @participant.remove_school_teams(current_user.id, @school)\n @participant.destroy\n\n respond_to do |format|\n Notifier.participant_deleted(@participant,@school).deliver\n format.html { redirect_to admin_tools_personnel_url }\n end\n end", "def destroy\n @contest = Contest.find_by(path: params[:id])\n\n destroy_directory(@contest.path)\n destroy_problems(@contest)#with submits\n destroy_participants(@contest)\n @contest.destroy\n\n respond_to do |format|\n format.html { redirect_to contests_url }\n #format.json { head :no_content }\n end\n end", "def destroy\n @interview.destroy\n participants = @interview.participants\n emails = []\n participants.each do |p|\n emails += [p.email]\n ReminderMailer.cancel_email(p.email).deliver_now\n end\n respond_to do |format|\n format.html { redirect_to interviews_url, notice: 'Interview was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_has_employeur.destroy\n respond_to do |format|\n format.html { redirect_to client_has_employeurs_url, notice: 'Client has employeur was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_collaborator = GroupCollaborator.find(params[:id])\n @group_collaborator.destroy\n\n respond_to do |format|\n format.html { redirect_to group_collaborators_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7235546", "0.7235546", "0.72209346", "0.72061276", "0.72061276", "0.7182637", "0.7098842", "0.70149934", "0.6988022", "0.6969382", "0.6969382", "0.6969382", "0.6956189", "0.6956189", "0.6919971", "0.69035554", "0.6841168", "0.68308055", "0.6802261", "0.67692906", "0.6766808", "0.67459714", "0.6742437", "0.6682646", "0.66754895", "0.6672021", "0.6666397", "0.6661984", "0.66598046", "0.66598046", "0.6631648", "0.662835", "0.6622112", "0.6561518", "0.65508896", "0.6541721", "0.6515351", "0.6508593", "0.65050036", "0.6493329", "0.6485215", "0.64575404", "0.6456145", "0.6451613", "0.64491814", "0.64305764", "0.643009", "0.64249325", "0.6409877", "0.6408853", "0.6408604", "0.63966316", "0.6392519", "0.6389663", "0.63882977", "0.6385259", "0.6376454", "0.63746923", "0.6369181", "0.6367945", "0.6365137", "0.6362401", "0.6356763", "0.6355426", "0.63492167", "0.63488805", "0.63419545", "0.6337054", "0.6330355", "0.6329303", "0.63273746", "0.63244855", "0.6323084", "0.632199", "0.63136256", "0.6313181", "0.6313181", "0.6312596", "0.6302971", "0.63014305", "0.6299632", "0.6292821", "0.6289794", "0.62894726", "0.628737", "0.62836486", "0.627954", "0.6276803", "0.62767804", "0.6273533", "0.6273533", "0.6272388", "0.6267787", "0.626504", "0.6264783", "0.6263838", "0.6263378", "0.6263341", "0.626252", "0.6261795" ]
0.73164445
0
Use callbacks to share common setup or constraints between actions.
def set_reunion_participante @reunion_participante = ReunionParticipante.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 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 setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def 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 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 startcompany(action)\n @done = true\n action.setup\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 setup\n #implement in subclass;\n end", "def after_set_callback; 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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def around_hooks; end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def 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 shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6165152", "0.60463154", "0.59467196", "0.5917112", "0.5890387", "0.58345735", "0.57773316", "0.56991524", "0.56991524", "0.565454", "0.5622282", "0.54232633", "0.54119074", "0.54119074", "0.54119074", "0.53937256", "0.53801376", "0.5358599", "0.53412294", "0.5340814", "0.53314966", "0.53114754", "0.52984965", "0.52977055", "0.5296272", "0.5260649", "0.5245076", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.52388334", "0.5235081", "0.52321917", "0.5228592", "0.5220735", "0.52198535", "0.52139324", "0.5208539", "0.5206585", "0.5178542", "0.5175199", "0.5173538", "0.5167041", "0.51614195", "0.51577675", "0.5153909", "0.51528823", "0.5152225", "0.51429904", "0.5141399", "0.51345575", "0.51145", "0.5114052", "0.5114052", "0.5110216", "0.5108656", "0.50935394", "0.5089196", "0.5081936", "0.5079627", "0.50675833", "0.5056105", "0.5053687", "0.5050475", "0.5050475", "0.503471", "0.5028311", "0.501982", "0.50157547", "0.5013552", "0.50014806", "0.50011593", "0.49976763", "0.4990292", "0.4990292", "0.49882022", "0.4981269", "0.49792367", "0.49766538", "0.4967978", "0.49667212", "0.4958987", "0.49572337", "0.49550423", "0.4954479", "0.4952353", "0.494726", "0.4944055", "0.4935437", "0.4931248", "0.49283475", "0.49281213", "0.49268973", "0.4921738", "0.49204507", "0.4918924", "0.49182287", "0.4916538", "0.49158585", "0.49156788" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def reunion_participante_params params.require(:reunion_participante).permit(:reunion_id, :persona_id, :vendedor_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
Notifies everyone who has commented on the video as well as the video owner that someone has commented on that video
def notify_all_users_in_the_conversation(current_user, video, video_owner) # send e-mail to the video owner unless the person commented on their own video # or their notification settings say not to unless (video.user_id == self.user_id) # for whatever reason, delayed_job won't send the email unless you do it as a delayed_job UserMailer.delay(:priority => 40).new_comment(self, video_owner, false) if video_owner.send_email_for_new_comments # Add event to activity feed UserEvent.delay(:priority => 40).create(:event_type => UserEvent.event_type_value(:comment), :event_object_id => self.id, :user_id => video_owner.id, :event_creator_id => current_user.id) end # send e-mail to other people (except the video owner, or the person that just commented) # that have commented on the video unless their notification settings say not to users_we_will_not_notify = [] users_we_will_not_notify << video_owner.id << self.user_id commenters = Comment.where('video_id = ? AND user_id NOT IN (?)', self.video_id, users_we_will_not_notify).group_by(&:user_id) unless commenters.blank? commenters.each do |comment_owner_id, comment| the_commenter = User.find_by_id(comment_owner_id) # for whatever reason, delayed_job won't send the email unless you do it as a delayed_job UserMailer.delay(:priority => 40).new_comment(self, the_commenter, true) if the_commenter.send_email_for_replies_to_a_prior_comment # Add event to activity feed UserEvent.delay(:priority => 40).create(:event_type => UserEvent.event_type_value(:comment_response), :event_object_id => self.id, :user_id => the_commenter.id, :event_creator_id => current_user.id) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def notify_watchers(comment_id)\n comment = Comment.find comment_id\n\n article_id = comment.article_id\n favs = Favorite.where(favorable_id: article_id)\n uid = comment.user_id\n ids = []\n favs.each do |f|\n i = f.user_id\n next if uid == i or i == 0\n ids << i\n f.updated_at = Time.now()\n f.save!\n end\n end", "def notify\n reviewers = proposal.reviewers.reject{|r| r.id == user_id }\n Notification.create_for(reviewers, proposal: proposal, message: \"Internal comment on #{proposal.title}\")\n end", "def changes(comment)\n @comment = comment\n\n mail to: [@comment.video.project.users.pluck(:email)],\n subject: 'New Comment on ' + @comment.video.project.title\n end", "def comment (video, str, user)\r\n self.connect(user) unless user.token?\r\n uri = URI(HOST + 'feeds/api/videos/' + video.id.to_s + '/comments')\r\n post = Net::HTTP::Post.new uri.path\r\n post.content_type = 'application/atom+xml'\r\n post.body = Comment.formatString(str)\r\n _http_post(uri, post, user)\r\n end", "def notifies_commenter? # ...of direct responses to this comment\n wants_notifications?\n end", "def motivatedByCommenting\n q = [nil, OA.motivatedBy, OA.commenting]\n @graph.query(q).collect {|s| s.subject }\n end", "def send_to_participants(owner,from)\n\t\t# send an email to the owner of the status post, unless the comment is coming from the creator\n\t\tdeliver(\"#{from.name} posted a comment on your status\", owner, from) unless owner.eql? from\n\t\t# iterate through all the collaborators and send an email to all, unless the comment is coming from the creator\n\t\tself.commentable.comments.collaborators.each do |user|\n\t\t\tunless user.eql? owner or user.eql? from\n\t\t\t\tif owner.eql? from\n\t\t\t\t\tdeliver(\"#{from.name} posted a comment on their status\", user, from) \n\t\t\t\telse\n\t\t\t\t\tdeliver(\"#{from.name} posted a comment on #{owner.name} status\", user, from) \n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def listeners\n users_to_notify = Set.new\n users_to_notify += self.proposal.currently_awaiting_approvers\n users_to_notify += self.proposal.individual_steps.approved.map(&:user)\n users_to_notify += self.proposal.observers\n users_to_notify << self.proposal.requester\n # Creator of comment doesn't need to be notified\n users_to_notify.delete(self.user)\n users_to_notify\n end", "def watching_notification\n @sender = @watchable.user\n @user = @receiver\n path = \"/#{@watchable.class.name.downcase.pluralize}/#{@watchable.id}\"\n @notification = @user.notifications.find_by(path: path)\n subject = \"[bootcamp] #{@sender.login_name}さんの【 #{@watchable.notification_title} 】に#{@comment.user.login_name}さんがコメントしました。\"\n mail to: @user.email, subject: subject\n end", "def notify\n notify_unmentioned_reviewers\n notify_mentioned_event_staff if mention_names.any?\n end", "def comment_owner\n unless current_user.id == @comment.user.id\n flash[:notice] = \"You don't have access to that!\"\n redirect_to @post\n end\n \n end", "def comment_notification(user, commenter, post, comment)\n @user = user\n @commenter = commenter\n @post = post\n @comment = comment\n\n mail to: user.email, subject: \"#{commenter.username} has commented on your post!\"\n end", "def notify_on_mention?; true; end", "def create_post_owner_notification_of_reply(reply)\n return if reply.user.id == self.user.id # don't notify user of his own replies..\n if self.user.role == \"Poster\"\n url = \"wall_expert/#{self.id}\"\n else\n url = \"wall/#{self.id}\"\n end\n notify(self.user, \"Your post was commented on!\", \"#{reply.user.profile.full_name} commented on your post!\", :from => reply.user, :key => post_reply_notification_key(reply), :link => '#{url}?reply=#{reply.id}')\n end", "def edited_comment_notification(user_id, comment_id)\n user = User.find(user_id)\n @comment = Comment.find(comment_id)\n mail(\n :to => user.email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Edited comment on \" + @comment.ultimate_parent.commentable_name.gsub(\"&gt;\", \">\").gsub(\"&lt;\", \"<\")\n )\n end", "def comments_mentioning_user(other_user_id, options={})\n self.class.parse_comments(request(singular(user_id) + \"/comments/#{other_user_id}\", options))\n end", "def can_comment?(person)\n self.reviewer != person && !commented_by?(person)\n end", "def redmine_add_comment(m, params)\n begin\n \tcertificate = redmine_check_auth(m)\n\t\tif ! certificate\n\t\t\t# ne rien faire, l'utilisateur n'est pas connecté\n\t\telse\n\t\t\tresulted_task = redmine_check_task(m, params, certificate)\n\t\t\tif ! resulted_task.nil?\n\t\t\t\t# Best way to save text line\n\t\t\t\tmessageEntry = params[:message].to_s.strip\n\t\t\t\t# Ajout d'un commentaire\n\t\t\t\tresulted_task.notes = messageEntry\t\n\t\t\t\t# Save an issue\n\t\t\t\tif ! resulted_task.save\n\t\t\t\t\t# on indique à l'utilisateur\n\t\t\t\t\t@bot.say m.replyto, \"#{certificate[:username]}, #{@redmine_l_thetask} ##{resulted_task.id} #{@redmine_l_hasnotbeenupdated}\"\n\t\t\t\telse \n\t\t\t\t\t# on indique à l'utilisateur\n\t\t\t\t\t@bot.say m.replyto, \"#{certificate[:username]}, #{@redmine_l_thetask} ##{resulted_task.id} #{@redmine_l_hasbeenupdated} => #{@redmine_rapid_url}#{@redmine_issue_show_path}/#{resulted_task.id}\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tm.reply \"#{@redmine_l_thetask} ##{params[:task]} #{@redmine_l_doesnotexistsinredmine}\"\n\t\t\tend\n\t\tend\n rescue Exception => e\n m.reply e.message\n m.reply e.backtrace.inspect\n end\n end", "def received_comments\n my_comments = []\n self.pictures.each do |picture|\n picture.comments.each do |comment|\n if comment.user_id != self.id\n my_comments.push(comment)\n end\n end\n end\n my_comments\n end", "def commented (commentable, comment, email)\n @commentable = commentable\n @comment = comment\n mail :to => email,\n :subject =>\"#{@commentable.class} \\\"#{@commentable.title}\\\" has been commented\"\n end", "def user_wrote_editnote(user_id, media_id)\n @company = Company.first\n @user = User.find(user_id)\n @media_file = MediaFile.find(media_id)\n @booking = @media_file.booking\n mail(to: @company.email, subject: \"For admin: #{ @user.full_name} wrote an edit note\")\n # CHANGE @USER.EMAIL TO COMPANY EMAIL OR PRODUCER EMAIL\n end", "def commenters # the user who commented on you\n self.comments.map do |comment|\n comment.user\n end\n end", "def set_video_comment\n @video_comment = VideoComment.find(params[:id])\n end", "def watch_comment_by_user_ids\n user_ids = watch_comment_by_user_actions.where(\"action_option is null or action_option != ?\", \"ignore\").pluck(:user_id)\n user_ids += repository.watch_by_user_ids\n user_ids.uniq!\n\n user_ids - unwatch_comment_by_user_ids\n end", "def on_comment(msg)\n end", "def watch_comment_by_user_ids\n self.watch_comment_by_user_actions.where(\"action_option is null or action_option != ?\", \"ignore\").pluck(:user_id)\n end", "def comment_added(comment)\n @place = comment.place # pulling from db\n @place_owner = @place.user # pulling specific owner of comment from db\n # Would be mail(to: @place_owner.email, ...) if owner of comment to receive msg\n mail(to: 'webdev.throwaway@gmail.com',\n subject: \"A comment was added to #{@place.name}\")\n end", "def comment_on(params)\n if @environment.in_dry_run_mode\n notify(:msg => \"[#{@name}] Would comment on issue #{params[:issue]}\",\n :tags => [:jira, :dryrun])\n nil\n else\n key = get_param(params, :issue)\n issue = issueify(key)\n if issue\n comment = Jira4R::V2::RemoteComment.new()\n comment.author = params[:author] || @config[:auth][:username]\n comment.body = params[:comment] || ''\n with_jira do\n addComment(issue.key.upcase, comment)\n end\n notify(:msg => \"[#{@name}] Added a comment to issue #{issue.key}\",\n :tags => [:jira, :trace])\n else\n raise \"Could not find JIRA issue #{params[:issue]}\"\n end\n issue\n end\n end", "def send_comment_notifications(comment)\n plan_detail = comment.commentable\n plan = plan_detail.plan\n users = plan.members.select { |u| u.opt_in == true }\n # exclude user making the comment\n users = users - Array(comment.user)\n\n users.each do |user|\n logger.info \"[soph] sending notification email to #{user.email} about comment.id #{comment.id}\"\n UserMailer.delay.new_comment_notification(to_user: user,\n comment_text: comment.comment,\n commenter: comment.user,\n passage_ref: plan_detail.passage_ref,\n plan_url: plan_path(plan))\n end\n end", "def video_comment_params\n params.require(:video_comment).permit(:creation, :video_id, :customer_id, :comment)\n end", "def comment_of_current_user\n if user_signed_in?\n @movie = Movie.find(params[:movie_id] || params[:id])\n @comment = @movie.comments.find_by(user_id: current_user.id)\n end\n end", "def test_ID_25863_comment_on_review()\n login_as_user1\n read_all_updates\n share_review(\"outside-in\")\n logout_common\n login_as_user2\n leave_comment_on_share_review_group(\"outside-in\")\n logout_common\n login_as_user1\n verify_updates\n end", "def commented_by(name)\n get_data(\"user/#{name}/commented\")\n end", "def watch\n klass = params[:commentable_type].constantize\n @commentable = klass.find(params[:commentable_id])\n\n authorize! :read, @commentable\n\n if request.post?\n User.create_action(:watch_comment, target: @commentable, user: current_user, action_option: \"watch\")\n else\n User.create_action(:watch_comment, target: @commentable, user: current_user, action_option: \"ignore\")\n end\n end", "def update\n @video = Video.find(params[:id])\n if owner?(@video.user_id)|| not_signed_in_owner?(@video)\n @video.update(video_title)\n redirect_to video_path(@video.id)\n else\n #TODO not authorized error\n redirect_to \"/\"\n end\n end", "def commentable_user\n current_user\n end", "def show\n #2nd you retrieve the comment thanks to params[:id]\n @video = Video.find(params[:id])\n end", "def edited_comment_reply_notification(your_comment_id, edited_comment_id)\n @your_comment = Comment.find(your_comment_id)\n @comment = Comment.find(edited_comment_id)\n mail(\n :to => @your_comment.comment_owner_email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Edited reply to your comment on \" + @comment.ultimate_parent.commentable_name.gsub(\"&gt;\", \">\").gsub(\"&lt;\", \"<\")\n )\n end", "def send_video_is_ready_email(moderator,video)\n @moderator = moderator\n @video = video\n mail(:from => self.moovi_email, :to => @moderator.email, :subject => \"Your Video is Ready\" )\n end", "def set_video_request_comment\n @video_request_comment = VideoRequestComment.find(params[:id])\n end", "def send_video_is_rendering_email(moderator,video)\n @moderator = moderator\n @video = video\n mail(:from => self.moovi_email, :to => @moderator.email, :subject => \"Your Video is Rendering\" )\n end", "def video_watched?(user, video)\n @watched_video = WatchedVideo.where(user_id: user.id, video_id: video.id).first\n if @watched_video && @watched_video.watched == true\n true\n else\n false\n end\n end", "def audio_event_comments(user)\n user = Access::Validate.user(user, false)\n AudioEventComment\n .where('(audio_event_comments.creator_id = ? OR audio_event_comments.updater_id = ?)', user.id, user.id)\n .order('audio_event_comments.updated_at DESC')\n end", "def show\n @video = Video.find(params[:id])\n @run = Run.find(@video.run_id)\n @videos = @run.visiblevideos\n @video.counter += 1\n @video.save\n \n @videocomments = Videocomment.find(:all, :conditions => {:video_id => @video.id})\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @video }\n end\n end", "def user_comments\n comments = Comment.where(:commentable_id => self.id, :commentable_type => \"Conversation\")\n str = \"\"\n comments.each do |comment|\n user_name = Invitee.where(:id => comment.user_id).first.name_of_the_invitee rescue nil\n desc = comment.description if user_name.present?\n str += \"#{user_name} => #{desc}\" + ' ~ ' \n end\n str\n end", "def notify_comment(comment_id)\n puts \"comment parent #{comment_id}\"\n comment = Comment.find comment_id\n\n if comment.parent_id\n parent = Comment.find(comment.parent_id, include:[:user,:article])\n puts parent\n if parent and comment.user_id != parent.user_id\n commented_user= parent.user\n commented_article = parent.article\n\n if commented_user && commented_article\n\n key=\"new_comment.#{commented_article.id}.#{comment.user_id}\"\n notification = Notification.find_by_key(key)\n puts key\n\n if !notification\n Notification.create user_id: commented_user.id,\n key: key,\n content: \"#{commented_article.id}.#{comment.id}\"\n else\n Notification.update(notification.id,\n user_id: commented_user.id,\n key: key,\n content: \"#{commented_article.id}.#{comment.id}\",read:false)\n end\n end\n end\n end\n end", "def send_email_to_owner\n return if !self.support_case or self.support_case.contact == self.created_by\n if AppSetting.config('Send Comment Notifications') == AppSetting::SEND_COMMENT_NOTIFICATIONS[:send_notification]\n SfcontactMailer.deliver_owner_notification(self)\n end\n rescue\n logger.info(\"Error occured creating case comment notification email: #{$!.message}\")\n end", "def came_comment\n @user = @receiver\n path = \"/#{@comment.commentable_type.downcase.pluralize}/#{@comment.commentable.id}\"\n @notification = @user.notifications.find_by(path: path)\n mail to: @user.email, subject: \"[bootcamp] #{@message}\"\n end", "def comment_moderation(user_id, comment_id, url_title, response)\n @user = User.find(user_id)\n @utitle = url_title\n @comment = Comment.find(comment_id)\n\n mail :to => recipient(@user.email), :subject => \"25c Testimonial Notification for #{@utitle}\"\n end", "def update_reviewer_comment(connection, comment)\n xml = connection.make_xml('VulnerabilityExceptionUpdateCommentRequest',\n { 'exception-id' => @id })\n cxml = REXML::Element.new('reviewer-comment')\n cxml.add_text(comment)\n xml.add_element(cxml)\n @reviewer_comment = comment\n\n connection.execute(xml, '1.2').success\n end", "def update_reviewer_comment(connection, comment)\n xml = connection.make_xml('VulnerabilityExceptionUpdateCommentRequest',\n { 'exception-id' => @id })\n cxml = REXML::Element.new('reviewer-comment')\n cxml.add_text(comment)\n xml.add_element(cxml)\n @reviewer_comment = comment\n\n connection.execute(xml, '1.2').success\n end", "def notify_subscribers\n AdminMailer.notify_of_comment(self)\n end", "def send_join_my_video_email(from_user,to_user,video_id)\n @from_user = from_user\n @to_user = to_user\n @video = Video.find(video_id)\n @video_link = \"#{ENV['MOOVI_URL']}/www/#/app/join-video/#{video_id}/#{to_user.id}\"\n mail(:from => self.moovi_email, :to => @to_user.email, :subject => \"Join #{from_user.name} to create the best video for #{@video.receiver.name}\" )\n end", "def comment_replied_to(options = {})\n send_comment_notification(options, \"reply_notice\")\n end", "def new_comment(comment, commenter, author, question)\n if author.privacy_setting.notify_on_post_comment \n @comment, @commenter, @author, @post = comment, commenter, author, question\n mail(\n :subject => \"#{@commenter.name.titleize} just commented on your post.\",\n :from => \"noreply@studyhall.com\",\n :to => author.email,\n :date => Time.now\n )\n end\n end", "def notifications_to_show_user\n notifications ||= UserEvent.where('user_id = ? AND error_during_render = ? AND event_type != ?', self.id, false, UserEvent.event_type_value(:video_play))\n end", "def show\n @video = Video.find(params['id'])\n @comment = @video.comments.new\n @comments = @video.comments\n end", "def comments\n @presentation = Presentation.in_conference(current_conference).\n find(params[:id])\n end", "def presence\n participant = Participant.includes(:person).find_by!(\n \"people.id\" => params[:person_id],\n activity: @activity\n )\n if params[:person_id].to_i != current_person.id && !@activity.may_change?(current_person)\n head :forbidden\n return\n end\n\n if @activity.deadline&.past? && !@activity.may_change?(current_person)\n head :locked\n return\n end\n\n params[:notes] = params[:participant][:notes] if params[:participant]\n participant.update!(params.permit(:notes, :attending))\n head :no_content\n end", "def update\n @plan_id = comment_params[:plan_id]\n comments = Comment.where(plan_id: @plan_id)\n @reviewer_comments = comments.reviewer_comments.order('created_at DESC')\n @owner_comments = comments.owner_comments.order('created_at DESC')\n respond_to do |format|\n if @comment.update(comment_params)\n format.html { redirect_to comments_path, notice: 'comment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @comment.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_comment?(user_id)\n @current_user.id == user_id\n end", "def came_comment\n @user = @receiver\n link = \"/#{@comment.commentable_type.downcase.pluralize}/#{@comment.commentable.id}\"\n @notification = @user.notifications.find_by(link: link) || @user.notifications.find_by(link: \"#{link}#latest-comment\")\n mail to: @user.email, subject: \"[FBC] #{@message}\"\n end", "def comment_added(comment)\n @comment = comment\n @user = @comment.user\n @track = @comment.track\n @project = @track.project\n\n mail to: @user.email,\n bcc: \"pierre@sugaryourcoffee.de, #{@project.user.email}\",\n subject: \"[apptrack] New Comment in Project #{@project.title}\"\n end", "def notify_requester(needs_review, comment)\n if proposal.requester != comment.user\n if needs_review == true\n ProposalMailer.\n proposal_updated_needs_re_review(proposal.requester, proposal, comment).\n deliver_later\n else\n ProposalMailer.\n proposal_updated_no_action_required(proposal.requester, proposal, comment).\n deliver_later\n end\n end\n end", "def comment_moderator? comment\n id == comment.holder_id\n end", "def comments_given(user_id)\n comments = Comment.where(user_id: user_id)\n end", "def create\n usr = User.where(fb_id: params[:user_id]).first\n @comment = Comment.new(\n bet_id: params[:bet_id],\n text: params[:text],\n user: usr\n )\n\n if @comment.save\n # make a list of all possible notification recipients\n list = get_bet_opponents(params[:bet_id])\n list.select! {|uid| uid != params[:user_id]} #filter out the guy who made the notification\n push_notify_users(list, \"#{usr.name} commented on #{User.where(fb_id: @comment.bet.owner).first.name}'s bet!\")\n push_notify_user(@comment.bet.owner, \"#{usr.name} commented on your bet!\") unless params[:user_id] == @comment.bet.owner\n render action: 'show', status: :created, location: @comment\n else\n render json: @comment.errors, status: :unprocessable_entity\n end\n end", "def news_comment_added(user, comment)\n news = comment.commented\n redmine_headers 'Project' => news.project.identifier\n @author = comment.author\n message_id comment\n references news\n @news = news\n @comment = comment\n @user = user\n @news_url = url_for(:controller => 'news', :action => 'show', :id => news)\n mail :to => user,\n :subject => \"Re: [#{news.project.name}] #{l(:label_news)}: #{news.title}\"\n end", "def log_activity\n #Activity.log_activity(self, self.commentable, 'commented', self.user_id)\n if self.user.facebook_omniauth\n Activity.create_log_for_each_friend(self, self.commentable, 'commented on' , self.user.facebook_omniauth.uid, self.user.display_name)\n end\n end", "def update\n respond_to do |format|\n if @video_comment.update(video_comment_params)\n format.html { redirect_to @video_comment, notice: 'Video comment was successfully updated.' }\n format.json { render :show, status: :ok, location: @video_comment }\n else\n format.html { render :edit }\n format.json { render json: @video_comment.errors, status: :unprocessable_entity }\n end\n end\n end", "def already_commented_by_user?(the_user)\n !self.comments.where([\"user_id = ?\", the_user.id]).empty?\n end", "def test_ID_25866_comment_on_post_you_wrote()\n login_as_user1\n post_to_any_group(\"Sports\",\"Basketball\")\n logout_common\n login_as_user2\n leave_a_comment_on_any_group(\"Sports\",\"Basketball\")\n logout_common\n login_as_user1\n verify_updates()\n end", "def show\n @video = Video.find(params[:id])\n @comments = Comment.all.paginate(:page => params[:page],:per_page => 10)\n @comment = @video.comments.build()\n @recomment = Comment.new\n end", "def update\n @comment = Comment.find(params[:id])\n @comment.user_id = params[:user_id]\n @comment.announcement_id = params[:announcement_id]\n @comment.description = params[:description]\n @comment.save\n render json:@comment\n end", "def before_update_save(record)\n record.comments.each do |comment|\n comment.user = current_user\n end\n end", "def show\n @yt_client = YouTubeIt::Client.new(:dev_key => \"AI39si6hkRNCL77mzzv1LycIohZtksVIi0L5S9lQMx6crqOfGdyKcB2U2M5WHeNBUT2VLgTVzjR9rxPa1RJZw-sZ6wqtnaZ7AA\")\n @video = Video.find(params[:id])\n\n @comments = @video.comments.all\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @video }\n end\n end", "def comments\n expose Challenge.comments(@oauth_token, params[:challenge_id].strip)\n end", "def notify!\n if self.commentable.comments.count > 1\n MailWorker.perform_async(\"CommentMailer\", :comment_received, self.id)\n else\n MailWorker.perform_async(\"RequestMailer\", :request_in_process, self.commentable.id)\n end\n end", "def allows_comment?(a_person=nil)\n self.alive?\n end", "def create\n @comment = @commentable.wall_comments.new comment_params\n if @comment.save\n @commentable.create_activity :comment, owner: current_user, recipient: @comment if log_activity?\n end\n end", "def record_reveal\n votes = Vote.where(story_id: @resource[:story_id])\n project_id = session[:last_project].to_i\n comment_content = votes.map { |vote| \"#{vote.user}: #{vote.vote}\"}.join('\\n')\n comment_content = \"Votes: \\n#{comment_content}\"\n\n story = @client.project(project_id).story(@resource[:story_id].to_i)\n story.create_comment(text: comment_content)\n end", "def watched\n if !@video.video_watched?(@user, @video)\n @watched_video = @video.watched_videos.build(watched_params)\n @watched_video.user = @user\n @watched_video.save \n redirect_to new_video_rating_path(@video)\n else\n redirect_to video_path(@video)\n flash[:error] = \"You have already marked this video watched, are you trying to delete the view status?\"\n end\n #only positive views, if you havent seen a video then you dont have an entry in the join table,\n # if you want to delete a view, then you just delete the entry from the table\n end", "def update_to_video_calendar_invite(virtual_hearing, email_recipient_info)\n create_calendar_event(virtual_hearing.hearing) do |event, time_zone, start_time|\n if email_recipient_info.title == HearingEmailRecipient::RECIPIENT_TITLES[:judge]\n # For judges, just cancel the original invitation.\n event.status = \"CANCELLED\"\n else\n template_context = {\n virtual_hearing: virtual_hearing,\n time_zone: time_zone,\n start_time_utc: start_time\n }\n\n event.status = \"CONFIRMED\"\n event.summary = summary(email_recipient_info)\n event.description = render_virtual_hearing_calendar_event_template(\n email_recipient_info, :changed_to_video, template_context\n )\n end\n end\n end", "def commenting_allowed?\n return false if owner.commenting_banned == true\n return true if owner.commenting_allowed\n\n if owner.supporter?\n set commenting_allowed: true\n save_changes validate: false\n return true\n else\n return false if owner.commenting_too_much?\n end\n\n if (account_sites_events_dataset.exclude(site_change_id: nil).count >= COMMENTING_ALLOWED_UPDATED_COUNT || (created_at < Date.new(2014, 12, 25).to_time && changed_count >= COMMENTING_ALLOWED_UPDATED_COUNT )) &&\n created_at < Time.now - 604800\n owner.set commenting_allowed: true\n owner.save_changes validate: false\n return true\n end\n\n false\n end", "def commented(request, comment)\n @request = request\n @comment = comment\n mail to: @request.user.email, subject: default_i18n_subject(id: @request.id)\n end", "def comment_sent_notification(comment_id)\n @comment = Comment.find(comment_id)\n @noreply = true # don't give reply link to your own comment\n mail(\n :to => @comment.comment_owner_email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Comment you left on \" + @comment.ultimate_parent.commentable_name.gsub(\"&gt;\", \">\").gsub(\"&lt;\", \"<\")\n )\n end", "def new_comment_notification(comment)\n\n blog = Post.find comment.post_id\n sender = User.find comment.user_id\n blog_owner = User.find blog.user_id\n #@subscribe = Subscribe.find :all, :conditions => [\"model_id = ? and model_type = ?\",blog.id, \"Post\"],:select => [\"user_id\"]\n #@subscribers = User.find :all, :conditions => [\"id in (?)\",@subscribe], :select => [\"email\"]\n setup_email(blog_owner)\n\n @subject += \"У ваc новый комментарий\"\n\n body[:comment]= comment\n body[:from_who] = sender\n body[:url] = RAILS_URL + \"posts/show/#{comment.post_id}#comments\"\n\n end", "def comment_notification(user_id, comment_id)\n user = User.find(user_id)\n @comment = Comment.find(comment_id)\n mail(\n :to => user.email,\n :subject => \"[#{ArchiveConfig.APP_NAME}] Comment on \" + @comment.ultimate_parent.commentable_name.gsub(\"&gt;\", \">\").gsub(\"&lt;\", \"<\")\n )\n end", "def show\n @comments = Comment.where(video_id: params[:id])\n end", "def user_want_notified_new_comment user_eject\n EntrMissionUser\n .includes(:user)\n .where(\"entr_mission_users.mission_id = ? AND users.mail_comments = ? AND users.id != ?\", \n self.id, \n true, \n user_eject.id)\n .collect { |l| l.user }\n end", "def check_owner\n if @comment.user != current_user\n respond_to do |format|\n format.html { redirect_to post_comments_path, alert: \"You dont have permissions for this action!\"}\n end\n end\n end", "def insert_motivatedByCommenting\n insert_motivatedBy OA.commenting\n end", "def update\n @comment = Comment.find(params[:id])\n\n properly_owned = (current_user == @comment.user)\n\n flash[:error] = \"Must be author of a comment to update it.\" unless properly_owned\n\n respond_to do |format|\n if properly_owned and @comment.update_attributes(params[:comment])\n flash[:notice] = 'Comment was successfully updated.'\n format.html { redirect_to(@comment) }\n format.xml { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @comment.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def news_comment_added_with_change(comment)\n news = comment.commented\n redmine_headers 'Project' => news.project.identifier\n @author = comment.author\n message_id comment\n references news\n @news = news\n @comment = comment\n @news_url = url_for(:controller => 'news', :action => 'show', :id => news)\n mail :to => news.recipients,\n :cc => news.watcher_recipients,\n :subject => \"Re: [#{news.project.to_s}] #{l(:label_news)}: #{news.title}\"\n end", "def someone_did_invite(stem, inviter, invitee, channel)\n end", "def name_owner_changed(msg)\n raise \"Skype has stopped running.\" if msg.params.first == \"com.Skype.API\" and msg.params[1].to_s.match(/^:\\d\\.\\d+$/)\n end", "def comment_notice_to_user(user, tutor, comment)\n @user = user\n @tutor = tutor\n @comment = comment\n\n mail to: \"#{user.email}\", bcc: 'studyconcierge@gmail.com', subject: \"【StudyConcierge】【新着コメントのお知らせ】\"\n end", "def allow_comment?(user) \n # for now, we allow everyone\n return true \n end", "def update\n @seen_comment = SeenComment.find(params[:id])\n\n unless @seen_comment.author.id == @author.id\n raise Exception.new '権限がありません'\n end\n\n respond_to do |format|\n if @seen_comment.update_attributes(params[:seen_comment])\n format.html do\n redirect_to movie_seen_seen_comments_path(@seen.movie, @seen), notice: 'SeenComment was successfully updated.'\n end\n else\n format.html { render action: \"edit\" }\n end\n end\n end", "def create\n @comment = Comment.new comment_params\n @comment.user = current_user\n if @comment.save\n @comments = Comment.where(\n polycomment_type: params[:comment][:polycomment_type],\n polycomment_id: params[:comment][:polycomment_id]\n )\n @comments = @comments.paginate(page: 1, per_page: 10)\n project = Project.find_by(name: params[:comment][:project_name])\n\n notify_followers(project, @comment)\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.js {}\n end\n else\n redirect_to :back\n flash[:alert] = 'Something went wrong, try reposting your comment.'\n end\n end" ]
[ "0.6341719", "0.61025774", "0.60463345", "0.60395116", "0.5946618", "0.58695436", "0.5813978", "0.57936853", "0.57907104", "0.5777171", "0.5762344", "0.57525826", "0.5684363", "0.5681352", "0.56734", "0.56484014", "0.5639869", "0.56309175", "0.55900097", "0.5585", "0.5575286", "0.55610836", "0.55546576", "0.55540115", "0.5531499", "0.55298245", "0.5516478", "0.55119175", "0.5499412", "0.54793084", "0.54754657", "0.5471014", "0.5468456", "0.5460953", "0.54575664", "0.54533654", "0.54423565", "0.54355514", "0.5425446", "0.5422827", "0.5420777", "0.5410904", "0.54051185", "0.5394769", "0.53858656", "0.5368287", "0.5364667", "0.5364583", "0.53526586", "0.53344727", "0.53344727", "0.5328892", "0.53263724", "0.53201705", "0.53119093", "0.53084075", "0.5306414", "0.530444", "0.5296097", "0.52936536", "0.5289447", "0.52872574", "0.52864355", "0.5282767", "0.52770066", "0.5273261", "0.5256309", "0.52555543", "0.5236755", "0.52356875", "0.52313673", "0.5230016", "0.5227179", "0.522552", "0.5222798", "0.5222493", "0.5219086", "0.5210339", "0.5201962", "0.51992345", "0.5194767", "0.519455", "0.51854247", "0.51804537", "0.51764345", "0.51669806", "0.51648", "0.5160059", "0.5158552", "0.5154272", "0.515351", "0.5151033", "0.5137517", "0.5136877", "0.5136554", "0.5131601", "0.51305896", "0.5128345", "0.51240987", "0.51240957" ]
0.6805111
0
p sum_of_range([1, 4]) => 10 p sum_of_range([4, 1]) => 10
def sum_of_range(arr) arr[0] < arr[1] ? (arr[0]..arr[1]).reduce(:+) : arr[0].downto(arr[1]).reduce(:+) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_of_range(range)\n range.sort! # easiest way to max sure it's in min max order\n # range = [range[1], range[0]] if range[1] < range[0] # longer way to check min/max order\n (range[0]..range[1]).reduce(:+)\nend", "def get_sum(a,b)\n\trange = b..a\n\trange = a..b if b > a\n\trange.inject(&:+)\nend", "def sum_range(num)\n if num == 1\n 1\n else\n num + sum_range(num - 1)\n end\nend", "def sum_of_range(array)\n first = array.first\n last = array.last\n if first < last\n numbers = (first..last).to_a\n else\n numbers = (last..first).to_a\n end\n index = 0\n numbers.each do |number|\n index += number\n end\n result = index\nend", "def get_sum(a, b)\n a < b ? (a..b).sum : (b..a).sum\nend", "def sum_range(start, finish)\n return 0 if finish < start\n return start if start == finish\n sum = start + sum_range(start.next, finish)\nend", "def get_sum(a,b)\n return a if a == b # if range is 1 return self\n a < b ? sum = (a..b).inject(:+) : sum = (b..a).inject(:+) # ternery used to order range\nend", "def process_range(range)\n multi = multiple_of_3_and_5(range - 1)\n sum = addition(multi)\n\n puts sum\nend", "def sum_range(i, j)\n \n end", "def get_sum(a, b)\n (b < a) ? a : (a..b).to_a.inject(:+)\nend", "def get_sum(a,b)\n a < b ? (a..b).reduce(:+) : (b..a).reduce(:+)\nend", "def sum_range(left, right)\n @sums[right + 1] - @sums[left]\n end", "def get_sum(a,b)\n a < b ? (a..b).inject(:+) : (b..a).inject(:+)\nend", "def sum_range(left, right)\n sum = @left_sum[right]\n sum -= @left_sum[left-1] if left > 0\n sum\n end", "def get_sum(a,b)\n a == b ? a : a < b ?\n (a..b).to_a.sum : \n (b..a).to_a.sum\nend", "def get_sum(a,b)\n\treturn a < b ? (a..b).reduce(:+) : (b..a).reduce(:+)\nend", "def range(start_val, end_val)\n return [] if start_val + 1 == end_val\n nums = [start_val + 1]\n nums + range(start_val + 1, end_val)\nend", "def sum_of_all_integers(num)\n (0..num).sum\nend", "def sum_of_range(array)\n\n if array[0] > array[1]\n rev_array = array.reverse\n range_array = (rev_array[0]..rev_array[1]).to_a\n sum = 0\n range_array.each {|e| sum += e}\n p sum\n else\n range_array = (array[0]..array[1]).to_a\n sum = 0\n range_array.each {|e| sum += e }\n p sum\n end\n\nend", "def sequence_sum(begin_number, end_number, step)\n (begin_number..end_number).step(step).sum\nend", "def sum_range(i, j)\n @accum[j + 1] - @accum[i]\n end", "def get_sum(a,b)\n a, b = [a, b].minmax\n [*a..b].inject(:+)\nend", "def get_sum(a, b)\n if a <= b\n (a..b).inject(:+)\n elsif a > b\n (b..a).inject(:+)\n end\nend", "def triangular_number_logic(range)\n sum = 0\n\n (1..range).each { |num| sum += num }\n sum\n end", "def sum(from, to, &b)\n accumulator = 0.0\n Range.new(from, to).each do |i|\n accumulator += b.call(i)\n end\n return accumulator\nend", "def summation(num)\n (1..num).reduce(:+)\nend", "def sum_of_square(range)\n\trange.inject(0) { |sum, i| sum + i**2 }\nend", "def range(range_start, range_end)\n return [] if range_end < range_start\n return [range_end] if range_end == range_start\n result = [range_end]\n range(range_start, range_end - 1) + result\nend", "def range(start, finish)\n #base case\n return nil if finish <= start\n return [start] if finish == start + 1 #return [0] for [0,1]\n #inductive step\n range(start, finish - 1) + [finish - 1]\nend", "def sum_range(i, j)\n return nil if i > j\n return @dp[j + 1] - @dp[i]\n end", "def SimpleAdding(num)\n\n # code goes here\n range_sum = *(1..num)\n return range_sum.inject(:+)\n \nend", "def compute_sum(number)\n (1..number).reduce(:+)\nend", "def sum_range(i, j)\n return @sums[j] - ((i > 0) ? @sums[i-1] : 0)\n end", "def sequence_sum(begin_number, end_number, step)\n return 0 if begin_number > end_number\n sum = 0\n until begin_number > end_number\n \tsum += step\n end\nend", "def sum_integers_up_to(n)\n (n * ( n + 1 ) ) / 2\nend", "def sum_using_for(min, max)\n # your code here\n total = 0\n for i in min..max\n total += i\n end\n total\nend", "def p6\n\trange = (1..100).to_a\n\tsquare_of_sum = range.reduce(:+) ** 2\n\tsum_of_square = (range.map{|x| x ** 2}).reduce(:+)\n\tsquare_of_sum - sum_of_square\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers == []\n return 0\nelsif upper_bound < lower_bound\n return 0\nend\n# sum = 0\n# sum = list_of_integers[lower_bound..upper_bound].each\n# for integer in lower_bound..upper_bound\n# p integer\n# if list_of_integers.each >= lower_bound && list_of_integers.each <= upper_bound\nnew_array = []\nlist_of_integers.each do |number| if number >= lower_bound && number <= upper_bound\nnew_array.push(number)\nend\nend\nsum = new_array.length\nsum\nend", "def sum_of_range(array)\n value = 0\n if array[0] < array[1] == true\n value = array[0] \n elsif array[0] > array[1] == true\n value = array[1] \n end\n\n new_array = []\n 50.times do \n if value.between?(array[0], array[1]) == true\n new_array << value\n value = value + 1\n elsif value.between?(array[1], array[0]) == true\n new_array << value\n value = value + 1\n end\n end\n sum = 0\n new_array.each { |n| sum += n } \n p sum\nend", "def sum(upper_limit)\n acc = 0\n (1..upper_limit).each { |num| acc+=num }\n acc\nend", "def sequence_sum(begin_number, end_number, step)\n return 0 if end_number < begin_number\n \n x = begin_number\n sum = 0\n \n while x <= end_number\n sum += x\n x += step\n end\n \n sum\nend", "def summation(num)\n sum = (0..num).inject(:+)\n return sum\nend", "def sum_range(i, j)\n if i >= len || j >= @len\n return nil\n end\n return sum(j) - sum(i-1)\n end", "def compute_sum(number)\n (1..number).inject(:+)\nend", "def sum_to(min=1, n)\n if n > 0\n return min if min == n \n min + sum_to(min + 1, n)\n end\nend", "def get_sum(a,b)\n if a > b\n [ *b..a ].sum\n elsif a == b\n a\n else\n [ *a..b ].sum\n end\nend", "def range(start, finish)\n return [] if start >= finish\n [start + 1] + range(start + 1, finish)\nend", "def square_of_sums\n range.reduce(:+)**2\n end", "def sum_range(left, right)\n sum = 0\n i,j = left, right\n strt = i/@len\n fin = j/@len\n if(strt == fin)\n (i..j).each{|k| sum += @nums[k]}\n else\n (i..((strt+1)*@len-1)).each{|k| sum += @nums[k]}\n ((strt+1)..(fin-1)).each{|k| sum += @b[k]}\n ((fin*@len)..j).each{|k| sum += @nums[k]}\n end\n sum\n end", "def sum(number)\n a = (1..number).to_a\n puts a.inject(:+)\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n\n list_of_integers.each do |n|\n answer = 0\n if n >= lower_bound && n <= upper_bound\n answer = answer + 1\n else\n end\n\n end\nend", "def sum_integers_up_to(n)\n sum = 0\n for i in 1..n\n sum += i\n end\n sum\nend", "def sum_nums(num)\n (1..num).inject(&:+)\nend", "def SimpleAdding(num)\n\n # code goes here\n range_num = *(1..num)\n return range_num.inject(:+)\n \nend", "def get_sum(a,b)\n return a if a == b\n \n result = 0\n min = a < b ? a : b\n max = min == a ? b : a\n num = min\n \n until num == max\n result += num\n num += 1\n end\n \n result + max\nend", "def range(start_num, end_num)\n range_array = []\n range_array << start_num\n\n if(start_num < end_num)\n range_array += range(start_num + 1, end_num)\n end\n\n range_array\nend", "def range(num1, num2)\n return [] if num2 <= num1\n range(num1, num2-1) + [num2 - 1] \nend", "def get_sum(a,b)\n c, d = [a, b].sort\n (c..d).inject(:+)\nend", "def summation(num)\n sum = 0\n (0..num).each do |v|\n sum += v\n end\n return sum\nend", "def sum_of_primes(upper_bound)\n Prime.each(upper_bound).reduce(:+)\nend", "def sum_of_sums(numbers)\n total = 0\n numbers.each_index { |index| total += numbers[0..index].sum }\n total\nend", "def sum_of_sequence(begin_number, end_number, step)\n begin_number.step(end_number, step).reduce(0, :+)\nend", "def sum_range(i, j)\n @sum[j] - @sum[i] + @nums[i] + sum_updator(i, j)\n end", "def multisum(range_end)\n multiples = []\n for i in 1..range_end\n multiples << i if i % 3 == 0 || i % 5 == 0\n end\n multiples.reduce(:+)\nend", "def get_sum(a,b)\n if a > b \n (b..a).reduce(:+)\n else\n (a..b).reduce(:+)\n end\n end", "def summation(n)\n #iterate through numbers less than or equal to n and add them up\n sum = 0\n\n (1..n).each { |num| sum += num }\n return sum\nend", "def sum_of_n(n)\n # your code here\n # result = []\n # if n >= 0\n # ary = (0..n).to_a\n # else\n # ary = (n..0).to_a.reverse\n # end\n # ary.each_with_index do |_numb, index|\n # somme = 0\n # result << somme += ary[0..index].sum + somme\n # end\n # result\n sum = 0\n (n.negative? ? 0.downto(n) : 0.upto(n)).map do |number|\n sum += number\n end\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n # Your code goes here!\n return 0 if list_of_integers.length == 0 || upper_bound < lower_bound\n\n numbers_between = 0\n\n list_of_integers.each { |this_integer| \n if this_integer >= lower_bound && this_integer <= upper_bound\n numbers_between += 1\n end\n }\n\n return numbers_between\nend", "def addition(number)\n (1..number).reduce(:+)\nend", "def sum_amicable_numbers(range)\r\n array = []\r\n range.each do |a|\r\n next if array.include?(a)\r\n array += [a, a.sum_divisors] if a.amicable?\r\n end\r\n array.reduce(:+)\r\nend", "def range(arr)\n\nend", "def get_sum(a,b)\n cla = [a,b].sort\n (cla[0]..cla[1]).reduce(:+)\nend", "def get_sum(a,b)\n def get_sum(a,b)\n (a..b).reduce(:+) || (b..a).reduce(:+)\n end\nend", "def range_sum(max_val)\n\n range = (1...max_val).to_a\n\n multiple_three_five = []\n\n range.each do |num|\n if num % 5 == 0 && num % 3 == 0\n multiple_three_five << num\n elsif num % 5 == 0 && num %3 != 0\n multiple_three_five << num\n elsif num % 3 == 0 && num %5 != 0\n multiple_three_five << num\n end\n end\n multiple_three_five.inject{|sum,num| sum + num }\nend", "def sum(n)\n end", "def sum_of_sums(numbers)\n sum = 0\n numbers.size.times { |counter| sum += numbers[0..counter].sum }\n sum\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n if list_of_integers == []\n return 0\n end\n\n counter = 0\n list_of_integers.each { |x|\n if (x >= lower_bound) && (x <= upper_bound)\n counter += 1\n elsif\n counter += 0\n end\n }\n p counter\nend", "def range(start, finish)\n return [] if finish < start\n return [start] if finish - 1 == start\n range(start, finish - 1) + [finish - 1]\nend", "def sum_to(n)\n return nil if n <= 0 #negatives and 0\n return 1 if n == 1 #base step\n #inclusive step 1 + sum_to(n)\n n + sum_to(n - 1)\nend", "def sum_primes(upper_bound)\r\n Prime.each(upper_bound).inject(:+)\r\nend", "def sum_of_squares\n @range.sum { |n| n**2 }\n end", "def sum_of_sums(numbers)\n (0...numbers.size).reduce(0) { |sum, idx| sum += numbers[0..idx].reduce(:+) }\nend", "def square_of_sum\n @range.sum**2\n end", "def count_between(list_of_integers, lower_bound, upper_bound)\nin_bounds = []\n\n list_of_integers.each do |num|\n if num >= lower_bound && num <= upper_bound\n in_bounds << num\n else\n \"out of bounds\"\n end\n end\n\n p in_bounds.length\n\nend", "def count_between(list_of_integers,lower_bound,upper_bound)\nr = Range.new(lower_bound,upper_bound)\nnew_array=[]\nlist_of_integers.each do |x|\n if r.include?(x)\n new_array.push(x)\n end\n\nend\n\nreturn new_array.length\nend", "def square_of_sum\n @number_range.sum**2\n end", "def running_total4(numbers)\n sums = []\n numbers.each_with_index do |_, idx|\n current_total = numbers[0..idx].sum\n sums << current_total\n end\n\n sums\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n new_array = []\n \n list_of_integers.each do |num|\n if num >= lower_bound && num <= upper_bound\n new_array.push(num)\n end\n end\n new_array.length\nend", "def each_value_square_sum(range)\n (1..range).inject {|sum, num| sum += num * num }\n end", "def rec_range(min, max)\n return [] if max == min\n [min] + rec_range(min+1, max)\nend", "def sum_of_squares\n range.reduce { |a, e| a + e**2 }\n end", "def sum_even_nums_in_range(start, stop)\n\tsum = 0;\n\ta = (start..stop).select { |n| n.even? }\n\tsum = a.sum\n\tsum\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\nnew_array=Array.new\nlist_of_integers.each {|x|\n if x >= lower_bound.to_i && x <= upper_bound.to_i\n new_array << x\n end}\n return new_array.length\nend", "def sum_multiples_of_3_and_5(range)\n range.select { |n| n % 3 == 0 || n % 5 == 0 }.inject(:+)\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\n count = 0\n list_of_integers.each do |int|\n if (lower_bound..upper_bound).include? int\n count = count + 1\n end\n end\n return count\nend", "def count_between(list_of_integers, lower_bound, upper_bound)\ncount = 0\nrange_array = *(lower_bound..upper_bound)\nlist_of_integers.each do |i|\nif range_array.include?(i) == true\ncount += 1\nend\nend\nreturn count\nend", "def range(start, ending_value)\n return [] if start > ending_value\n result = [start] + range(start + 1, ending_value)\nend", "def running_total(numbers)\n numbers.map.with_index { |_, i| numbers[0..i].reduce(:+)}\nend", "def range(min, max)\n return max if max < min\n range(min, max) << max\nend" ]
[ "0.8308774", "0.78453916", "0.77965695", "0.7785309", "0.7745558", "0.76876223", "0.7679498", "0.76598024", "0.7606298", "0.75951713", "0.7544433", "0.74849266", "0.7481171", "0.7476813", "0.74693817", "0.73276687", "0.7308638", "0.72997403", "0.72878706", "0.7277177", "0.72497714", "0.7244137", "0.72412", "0.72202045", "0.7187872", "0.71809596", "0.7172514", "0.7169179", "0.71608686", "0.7160747", "0.7148003", "0.71459645", "0.7142397", "0.7116475", "0.70740074", "0.7054437", "0.7048418", "0.70197374", "0.69874", "0.69849986", "0.6984881", "0.69738215", "0.696415", "0.6961929", "0.6942762", "0.6929528", "0.6927587", "0.6913512", "0.6912601", "0.69104165", "0.68860817", "0.68826425", "0.6865946", "0.68636763", "0.6861547", "0.68478626", "0.6844021", "0.683448", "0.6802737", "0.68023586", "0.67846173", "0.6784501", "0.6780285", "0.6774651", "0.6769868", "0.67693204", "0.676741", "0.6758314", "0.6757691", "0.6755577", "0.6755268", "0.6753619", "0.67444", "0.6740049", "0.6739077", "0.67384803", "0.6732652", "0.67223173", "0.67127615", "0.67053014", "0.6696713", "0.6696652", "0.66959", "0.6690134", "0.6687921", "0.6683247", "0.6671876", "0.66671216", "0.6660152", "0.66434455", "0.6642775", "0.66418517", "0.6639314", "0.66375995", "0.66368085", "0.66306895", "0.6624662", "0.6619875", "0.66095036", "0.6600888" ]
0.8161494
1
if ( str.length() ==0 ) puts s; return end ch = str[0,1] ros = str[1,str.length()1] print_Subsequence(ros,s) print_Subsequence(ros,s+ch) end print_Subsequence("abc","")
def print_Subsequence(str) if(str.length() == 0 ) base = []; base.push(".") return base; end ch = str[0,1]; ros = str[1,str.length()-1] recResult = print_Subsequence(ros) res=[] for i in (0..recResult.length-1) res.push(recResult[i]) end for i in (0..recResult.length-1) res.push(ch+recResult[i]) end return res end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_subs(str)\n result = []\n str.chars.each_index do |current_idx|\n (str.size - current_idx).times do |inner_idx|\n result << str[current_idx..(current_idx + inner_idx)]\n end\n end\n p result\nend", "def find_subs(string)\n result = []\n arr = string.chars\n arr.each_index do |outer_idx|\n (arr.size - outer_idx).times do |inner_idx|\n result << arr[outer_idx..(inner_idx + outer_idx)].join\n end\n end\n result\nend", "def substrings(str)\n chars = str.chars\n substrings = []\n loop do\n break if chars.empty?\n chars.size.times do |idx|\n substrings << chars[0..idx].join\n end\n chars.shift\n end\n substrings\nend", "def subsequence(str_one = @str_one, str_two = @str_two)\n #If either strings are zero then the subsequence is 0\n if str_one.length == 0 || str_two.length == 0\n 0\n\n #If its already been memoized, don't search again for it!\n\n elsif @matrix[str_one.length - 1][str_two.length - 1]\n return @matrix[str_one.length - 1][str_two.length - 1]\n\n #If the last letters are the same, then the subsequence is\n # equal to 1 + subsequnce minus each of the last letters\n\n elsif str_one[-1] == str_two[-1]\n @matrix[str_one.length - 1][str_two.length - 1] =\n 1 + subsequence(str_one[0...-1], str_two[0...-1])\n\n #If the last letters are NOT the same, then s(\"ab\", \"bc\") =\n # [s(\"ab\", \"b\"), s(\"a\", \"bc\")] because\n # we are decrementing each by one and will eventually find all\n # permutations of choosing letters(i.e. eventually if there are common letters\n #then our previous recursive case will find it.)\n\n\n else\n @matrix[str_one.length - 1][str_two.length - 1] =\n [subsequence(str_one, str_two[0...-1]),\n subsequence(str_one[0...-1], str_two)\n ].max\n end\n end", "def print_combinations(str)\n return if !str || str.length == 0\n str_length = str.length\n char_count = 1\n while char_count <= str_length\n start_index = 0\n print_current(start_index, char_count, str, str_length)\n char_count += 1\n end\n return\nend", "def substrings(str)\n result = []\n until str.empty?\n str.size.times { |index| result << str[0..index] }\n str[0] = ''\n end\n result\nend", "def subsequence\n setup_basecase\n\n (1...@matrix.length).each do |row|\n (1...@matrix[0].length).each do |col|\n substring_one = @str_one[0...row]\n substring_two = @str_two[0...col]\n if substring_one[-1] == substring_two[-1]\n @matrix[row][col] = @matrix[row - 1][col - 1] + substring_one[-1]\n else\n if @matrix[row - 1][col].length > @matrix[row][col - 1].length\n @matrix[row][col] = @matrix[row - 1][col]\n else\n @matrix[row][col] = @matrix[row][col - 1]\n end\n end\n end\n end\n\n @matrix[-1][-1]\n end", "def subsubstrings(string)\n string.size <= 1 ? [string] : [*subsubstrings(string.chop), string]\nend", "def longestSub(str)\n\n\nend", "def subSeq(seq, step)\n if step < 1 || step > seq.length\n return []\n elsif step == seq.length\n return [seq]\n elsif step < seq.length\n \n @subs = []\n i = 0\n n = seq.length/step\n n += seq.length%step\n # puts \"#{n} \\n\"\n\n while i < n\n x = seq[i..(i+(step -1))]\n# puts \"#{x} \"\n @subs.push(x)\n i += 1\n end\n\n # puts \"#{@subs}\\n\"\n return @subs\n end\n\n end", "def substring(str)\n subs = []\n start_idx = 0\n 0.upto(str.length - 2) do |i1|\n 1.upto(str.length - 1) do |i2|\n subs << str[i1..i2] if i2 > i1\n end\n end\n subs\nend", "def perm_recur(ans=\"\",s)\n if s.length == 0\n return\n end\n\n if s.length == 1\n puts ans + s\n return\n end\n \n if s.length == 2\n puts ans + s[0] + s[1] \n puts ans + s[1] + s[0]\n return\n end\n\n (0..s.size-1).each do |l|\n new = s.chars.rotate(l).join('')\n element = new[0] \n rest = new[1..new.size-1]\n perm_recur(ans + element, rest)\n end\nend", "def substrings(str)\n i = 0\n j = 0\n subArr = []\n\n while i < str.length\n sub = \"\"\n j = i\n while j < str.length\n sub += str[j]\n subArr << sub\n j += 1\n end\n i += 1\n end\n return subArr\nend", "def substrings(str)\n subs = []\n\n (0...str.length).each do |start_idx|\n (start_idx...str.length).each do |end_idx|\n subs << str[start_idx..end_idx]\n end\n end\n\n subs\nend", "def substrings_at_start(str)\n subs = []\n str.size.times { |i| subs << str[0..i] }\n subs\nend", "def substrings(string)\r\n \r\nend", "def substrings(string)\r\n subs = []\r\n i = 0\r\n while i < string.length - 1\r\n j = i\r\n while j < string.length - 1\r\n subs << string[i..j] unless subs.include? string[i..j]\r\n j += 1\r\n end\r\n i += 1\r\n end\r\n subs\r\nend", "def substrings(str)\n results = []\n list_of_chars = str.chars\n next_index = 0\n\n loop do\n break if list_of_chars[next_index] == nil\n\n list_of_chars.each_with_index do |char, index|\n next if index < next_index\n results << list_of_chars.slice(next_index..index).join\n end\n\n next_index += 1\n end\n results\nend", "def substrings(str)\n arr = []\n\n str.each_char.with_index do\n |char, i|\n\n arr << char\n\n next_i = i + 1\n while next_i < str.length\n char += str[next_i]\n arr << char\n next_i += 1\n end \n end\n\n arr\nend", "def substrings(string)\n result = []\n 0.upto(string.length - 1) do |index|\n 1.upto(string.length - index) do |length|\n result << string[index,length]\n end\n end\n result\nend", "def substrings(str)\r\n result = []\r\n starting_index = 0\r\n num_chars = 2\r\nend", "def substrings(string)\n\nend", "def substrings(string)\n arr = []\n string.each_char.with_index do |char1, idx1|\n arr << char1\n \n idx2 = idx1 + 1\n while idx2 < string.length\n arr << string[idx1..idx2]\n \n idx2 += 1\n end\n \n end\n\n arr\nend", "def substrings(str)\r\n result = []\r\n starting_index = 0;\r\n \r\n while (starting_index <= str.length - 2)\r\n num_chars = 2\r\n while (num_chars <= str.length - starting_index)\r\n substring = str.slice(starting_index, num_chars)\r\n result << substring\r\n num_chars += 1\r\n end\r\n starting_index += 1\r\n end\r\n result\r\nend", "def substrings(str)\r\n result = []\r\n starting_index = 0;\r\n \r\n while (starting_index <= str.length - 2)\r\n num_chars = 2\r\n while (num_chars <= str.length - starting_index)\r\n substring = str.slice(starting_index, num_chars)\r\n result << substring\r\n num_chars += 1\r\n end\r\n starting_index += 1\r\n end\r\n result\r\nend", "def fn(s)\n\t# Not only that, but since I heard you liked functions, I put a\n\t# function IN YOUR FUNCTION.\n\t#\n\t# And not only that, THAT function is a recursive function\n\t# We'll call it sub, cause we're original.\n\t#\n\t# It takes more parameters:\n\t# s : the string we're parsing\n\t# i : an index to remember how many steps we did already\n\t# floor : the floor we're in at the moment\n\tdef sub(s, i, floor)\n\t\treturn i if floor < 0\n\n\t\t# A recursive function is a function which calls itself\n\t\t# here, we call ourself with different parameters:\n\t\t# s[1, s.length-1] : We remove the first character from the string\n\t\t# i+1 : We increase the number of steps we did already\n\t\t# floor + (s[0] == '(' ? 1 : -1 ) : We add 1 or subtract 1 depending on\n\t\t# wether the first character from the string is '(' or ')'\n\t\tsub(s[1, s.length-1], i+1, floor + (s[0] == '(' ? 1 : -1 ))\n\tend\n\n\t# Here is the first call to the recursive sub function:\n\t# We start with the full string, on the 0th step, on floor 0\n\tsub(s, 0, 0)\nend", "def custom_start(str, sub_str)\n str_plc, sub_len = str, sub_str.length\n #str_plc.slice(0, sub_len) == sub_str\n str_plc[0, sub_len] == sub_str\nend", "def is_subsequence(s, t)\n t_id = 0\n s_id = 0\n while t_id < t.length && s_id < s.length\n s_id += 1 if t[t_id] == s[s_id]\n t_id += 1\n end\n s_id == s.length\nend", "def substrings(str)\n index = 0\n substrings = []\n \n while index < (str.length - 1) # Index Loop\n size = 2\n while size <= (str.length - index) # String length loop\n substrings << str[index, size]\n size += 1\n end\n index += 1\n end\n\n substrings\nend", "def substrings_at_start(str)\r\n chars = str.chars\r\n chars.each_with_object([]).with_index { |(el,memo), idx| memo << chars.take(idx+1).join('').to_s }\r\nend", "def substrings(str)\n return_arr = []\n\n str.length.times {|i| return_arr << substrings_at_start(str[i..-1])}\n return_arr.flatten\nend", "def substrings_at_start(string)\n result = []\n 0.upto(string.size - 1) do |idx|\n result << string[0..idx]\n end\n p result\nend", "def substrings(str)\n result = []\n start_substring_idx = 0\n end_substring_idx = start_substring_idx + 1\n\n loop do \n break if start_substring_idx == (str.size - 1)\n\n loop do \n break if end_substring_idx == str.size\n result << str[start_substring_idx..end_substring_idx]\n end_substring_idx += 1\n end\n\n start_substring_idx += 1\n end_substring_idx = start_substring_idx + 1\n end\n\n result\nend", "def function(str,start_position, end_position) #the method of return substring\n\tstr1=str.split(\"\")\n\tstr2=[]\n\tj=0\n\tfor i in start_position-1...end_position\n\t\tstr2[j]=str1[i]\n\t\tj+=1\n\tend\n\treturn str2\nend", "def leading_substrings_recursive(str, arr = [])\n if str.size > 1\n leading_substrings_recursive(str[0..str.size-2], arr)\n end\n arr << str\nend", "def substrings(str)\n results = []\n (0..str.size).each do |start_index|\n this_substring = str[start_index..-1]\n results.concat(leading_substrings(this_substring))\n end\n results\nend", "def substrings(str)\n result = []\n str.size.times do |idx|\n result << leading_substrings(str[idx..-1])\n end\n result.flatten\nend", "def find_substrings(str)\n sub_str = []\n \n (0...str.size).each do |s_index|\n (s_index...str.size).each do |e_index|\n sub_str << str[s_index..e_index]\n end\n end\n sub_str.uniq\nend", "def substrings(str)\n result_array = []\n 0.upto(str.size - 1) do |x|\n 1.upto(str.size - x) do |y|\n result_array << str[x, y]\n end\n end\n result_array\nend", "def find_substrings(string)\n result = []\n 0.upto(0) do |index|\n 1.upto(string.length - index) do |length|\n result << string[index, length]\n end\n end\n result\nend", "def find_substrings_from_start(str)\n substrings = []\n str.size.times { |i| substrings << str[0..i] }\n substrings\nend", "def substrings(string)\n result = []\n 0.upto(string.size-1) do |index1|\n index1.upto(string.size-1) do |index2|\n result << string[index1..index2]\n end \n end\n result\nend", "def substrings(string)\n subs = []\n\n (0...string.length).each do |i|\n (i...string.length).each do |j|\n subs << string[i..j]\n end\n end\n subs.sort\nend", "def substrings(str)\n result = []\n 1.upto(str.size) do |idx|\n str.chars.each_cons(idx) do |subr|\n result << subr.join\n end\n end\n result.sort\nend", "def subs\n puts \"foobar\".sub('bar','foo')\n end", "def genStr strLen\nsortedAlphabet = @alphabet.sort\nresultStrs = [ ]\ntestStrings = [ ]\ntestStrings[0] = []\ntestStrings[0].push \"\"\n1.upto(strLen.to_i) { |x|\ntestStrings[x] = []\ntestStrings[x-1].each { |s|\nsortedAlphabet.each { |c|\ntestStrings[x].push s+c\n}\n}\n}\ntestStrings.flatten.each { |s|\nresultStrs.push s if accept? s, @start\n}\nresult = \"\"\nresultStrs.each { |x| result.concat '\"'+x+'\" ' }\nresult\nend", "def substrings_at_start(string)\n substring = string\n results = []\n n = -1\n \n string.length.times do\n results << substring\n substring = substring.chop\n end\n \n results.reverse\nend", "def substrings(string)\n 0.upto(string.chop.size).with_object([]) do |idx, arr|\n arr.concat(subsubstrings(string[idx..-1]))\n end\nend", "def substrings_at_start(string)\n substrings = []\n counter = 1\n\n until counter > string.size\n substrings << string[0, counter]\n counter += 1\n end\n\n substrings\nend", "def substrings_at_start(string)\n substrings = []\n counter = 1\n\n until counter > string.size\n substrings << string[0, counter]\n counter += 1\n end\n\n substrings\nend", "def substrings(string)\n array = []\n (0..string.length).each do |i|\n ((i+1)..string.length).each do |j|\n array << string[i..(j-1)]\n end \n end \n array\nend", "def substrings_at_start(string)\n result = []\n\n loop do\n break if string.empty?\n result << string\n string = string.chop\n end\n\n result.reverse\nend", "def get_substrings str\n\t\t(0..string.length-1).flat_map do |i|\n\t\t (1..string.length-i).flat_map do |j|\n\t\t string[i,j]\n\t\t end\n\t \tend\n\tend", "def substrings(string)\n substring_array = []\n string.each do |letter|\n \n end\n substring_array\nend", "def substrings_at_start(string)\n string.size.times.with_object([]) { |idx, arr| arr << string.chars.take(idx + 1).join}\nend", "def substring(string)\n stringArray = string.each_char.to_a\n returnArray = []\n stringArray.each_with_index { |e, i| puts \"current letter: #{e}\"\n index = 0\n while index + i < stringArray.length\n if index == 0\n returnArray.push(e)\n else\n #Adding to a tempString to get entries longer than 2\n #This part could be cleaned up\n tempString = ''\n idx = index\n while i + idx < stringArray.length\n tempString += stringArray[i + idx]\n idx += 1\n end\n returnArray.push(e + tempString)\n end\n\n index += 1\n end\n }\n\n print returnArray\nend", "def substrings_at_start(str)\n results = []\n substring = ''\n \n str.chars.each do |char|\n substring += char\n results << substring\n end\n \n results\nend", "def substrings(string)\n if string.size == 1\n [string]\n else\n [string] + (substrings(string[0...-1]) + substrings(string[1..-1])).uniq\n end\nend", "def substrings_at_start(str)\n new_arr = []\n 0.upto(str.size) do |i|\n next if i == 0 \n new_arr << str.slice(0,i)\n end\n new_arr\nend", "def generate_substring(str)\n result_array = []\n req_len = 2\n while req_len <= str.length do\n result_array.concat(generate_substring_with_length(str, req_len))\n req_len += 1\n end\n result_array\nend", "def substrings(str)\n result = []\n count = 0\n\n until count == str.length\n result << substrings_at_start(str.slice(count..-1))\n count += 1\n end\n result.flatten\nend", "def substrings_at_start(string)\n substrings = []\n string.length.times do |i|\n substrings.push(string[0..i])\n end\n\n substrings\nend", "def substrings(str)\n str.chars.map.with_index do |subr,index|\n leading_substrings(str.slice(index..-1))\n end.flatten\nend", "def substrings_at_start(str)\n subs = []\n str.chars.each_with_index do |ch, i|\n subs << str.slice(0..i)\n end \n subs.sort {|a, b| a.length <=> b.length} \nend", "def substrings_at_start(str)\n\n results = []\n\n str.chars.each_with_index do |ss, idx|\n results << str.slice(0..idx)\n end\n\n results\n\nend", "def substrings(string)\n substrs = []\n string.size.times do |idx|\n string.size.times do |idx2|\n substrs << string[idx..idx2]\n end\n end\n substrs.delete('')\n substrs\nend", "def sub_strings(string)\r\n blank = []\r\n idx = 0\r\n while idx < string.length\r\n length = 1\r\n while (idx + length) <= string.length\r\n blank << string.slice(idx, length)\r\n length += 1\r\n end\r\n idx += 1\r\n end\r\n return blank\r\nend", "def find_substring(string, substring)\n\n sub_len = substring.length\n # 3\n str_len = string.length\n # 5\n i = 0\n\n\n (str_len - sub_len).times do\n # 2\n if string[i] == substring[0]\n if string[i..(i+sub_len-1)] == substring\n # sublen -1 because starting on first letter\n return true\n end\n end\n i += 1\n end\n\n false\nend", "def f(str)\n 1.upto(str.size / 2) do |idx|\n number_of_subs = str.size / idx\n if str[0...idx] * number_of_subs == str\n return [str[0...idx], number_of_subs]\n end\n end\n [str, 1]\nend", "def substrings_at_start(string)\n string.size <= 1 ? [string] : [*substrings_at_start(string.chop), string] \nend", "def substrings_at_start(str)\n counter = 1\n array = str.chars\n return_array = []\n\n loop do\n break if counter > array.size\n return_array << array.take(counter).join\n counter += 1\n end\n return_array\nend", "def substrings_at_start(string)\n string_array = string.chars\n array_final = []\n\n 1.upto(string.size) do |count|\n array_final << string_array.slice(0, count).join\n end\n array_final\nend", "def substrings_at_start(string)\n results = []\n\n string.length.times do\n results << string\n string = string.chop\n end\n\n results.reverse\nend", "def solution(str)\n str+=\"_\" if str.length.odd?\n res = []\n index = 0\n while index < str.length\n res << str[index .. index+1]\n index+=2\n end\n res\nend", "def arr_all_possible_substrings(str)\n substring_array = []\n i = 0\n while i < str.length\n j = 0\n while j < str.length\n substring_array << str[i, j]\n j += 1\n end \n i += 1\n end\n substring_array\nend", "def substring(str, substr)\n\nend", "def substrings(string)\n results = []\n iteration = 0\n string = string\n\n loop do\n current_iteration = string[iteration..-1]\n results << substrings_at_start(current_iteration)\n iteration += 1\n break if iteration == string.length\n end\n results.flatten\nend", "def substrings(str)\n result = []\n 0.upto(str.size) do |number|\n result[number] = leading_substrings(str[number..str.size])\n end\n\n result.flatten\nend", "def distinct_subseq_ii(s)\n alphabets = ('a'..'z').to_a\n dict = Array.new(27, 0)\n mod = 10 ** 9 + 7\n total = 1\n s.chars.each do |char|\n index = alphabets.index(char) + 1\n combo = total * 2 - dict[index]\n dict[index] = total # if 'c' ever appears again, it will clash with the current combos.\n total = combo < 0 ? 0 + mod : combo % mod\n end\n total - 1 # subtract empty string\nend", "def leading_substrings(str)\n running_str = ''\n sub_strings = []\n str.each_char { |chr| sub_strings << running_str += chr }\n sub_strings\nend", "def substrings_at_start2(str)\n result = []\n (0..str.size - 1).each { |idx| result << str[0..idx] }\n result\nend", "def sseq(s, t)\n\tindices = []\n\tlast_idx = 0\n\tt.each_char do |chr|\n\t\ti = s.index(chr, last_idx+1)\n\t\tif i\n\t\t\tindices.push (last_idx = i + 1)\n\t\telse\n\t\t\tputs \"ooops\", chr\n\t\tend\n\tend\n\tindices.join ' '\nend", "def pirates_say_arrrrrrrrr(string)\n output = \"\"\n string.length.times do |index|\n output << string[index+1] if string[index].downcase == \"r\" && index < (string.length - 1)\n \n end\n return output\nend", "def substrings_at_start(string)\n sub_strings = []\n 1.upto(string.size) do |count|\n sub_strings << string[0, count]\n end\n\n sub_strings\nend", "def substrings_at_start(str)\n result = []\n index = 0\n while index < str.size\n result << str[0..index]\n index += 1\n end\n result\nend", "def substrings_at_start(string)\n susbtrings = []\n string.size.times do |count|\n susbtrings << string.slice(0, count + 1)\n end\n susbtrings\nend", "def substrings(string)\r\n new_array = []\r\n string.size.times do |index|\r\n new_array << leading_substrings(string[index..string.size])\r\n end\r\n new_array.flatten\r\nend", "def substrings(string)\n substring_arr = []\n count = 0\n\n until count == string.size do\n count.upto(string.size - 1) do |index|\n substring_arr << string.slice(count..index)\n end\n count += 1\n end\n\n substring_arr\nend", "def substrings(string)\n substring_arr = []\n count = 0\n\n until count == string.size do\n count.upto(string.size - 1) do |index|\n substring_arr << string.slice(count..index)\n end\n count += 1\n end\n\n substring_arr\nend", "def substrings(string)\n result = []\n string.size.times do |index|\n result << substrings_at_start(string[index..-1])\n end\n result.flatten\nend", "def substrings_at_start(string)\n length = 0\n substrings = []\n while length < string.size\n substrings << string[0..length]\n length += 1\n end\n substrings\nend", "def substrings(string_int)\n substrings = []\n \n 0.upto(string_int.length - 1) do |index|\n 1.upto(string_int.length - index) do |length|\n substrings << string_int[index, length]\n end\n end\n substrings\nend", "def substrings_at_start(str)\n new_arr = []\n 1.upto(str.size) do |count| \n substring = ''\n substring += str.slice(0, count)\n new_arr << substring\n end\n new_arr\nend", "def all_substrings(string)\n substrings = []\n string_length = string.length\n (0...string_length).each do |index|\n substring_length = 2\n while index + substring_length <= string_length\n substrings << string.slice(index, substring_length)\n substring_length += 1\n end\n end\n substrings\nend", "def substrings(str)\n str_arr = []\n 0.upto(str.length - 2) do |index|\n index.upto(str.length - 1) do |sub_endpoint|\n str_arr << substring(str, index, sub_endpoint ) unless index == sub_endpoint\n end\n end\n str_arr\nend", "def substrings_single_shot(str)\n (0..str.length - 1).each_with_object([]) do |idx1, arr|\n (idx1..str.length - 1).each do |idx2|\n arr << str[idx1..idx2]\n end\n end\nend", "def substrings_at_start(string)\n substrings = []\n 1.upto(string.length) do |index|\n substrings << string.slice(0, index)\n end\n substrings\nend", "def substrings_at_start(str)\n results = []\n count = 1\n \n str.size.times do\n results << str.slice(0, count)\n count += 1\n end\n results\nend", "def substrings(string)\n results = []\n (0...string.size).each do |start_index|\n this_substring = string[start_index..-1]\n results.concat(leading_substrings(this_substring))\n end\n results\nend", "def substrings(string)\n results = []\n (0...string.size).each do |start_index|\n this_substring = string[start_index..-1]\n results.concat(leading_substrings(this_substring))\n end\n results\nend" ]
[ "0.6843673", "0.66567266", "0.66509813", "0.66106296", "0.65680367", "0.65555406", "0.6536475", "0.6367481", "0.6352542", "0.6348208", "0.63473046", "0.63333005", "0.62908465", "0.6268469", "0.625752", "0.62387353", "0.6237308", "0.6235232", "0.62308496", "0.6228356", "0.61983466", "0.61900765", "0.617041", "0.6163071", "0.6163071", "0.6157107", "0.6154137", "0.61396897", "0.61358416", "0.61281633", "0.6117481", "0.6110416", "0.6109357", "0.609328", "0.6083054", "0.6073605", "0.6060239", "0.6056272", "0.60470706", "0.60350144", "0.6034915", "0.60341144", "0.6030473", "0.6029697", "0.60268533", "0.60114384", "0.6007772", "0.59976804", "0.59968126", "0.59968126", "0.59725493", "0.5969678", "0.59683645", "0.595423", "0.5953385", "0.59483594", "0.5948126", "0.59476256", "0.5942568", "0.5941748", "0.5932923", "0.593002", "0.5928486", "0.59280795", "0.5909063", "0.5908855", "0.5903746", "0.5903032", "0.58885646", "0.58881253", "0.58856124", "0.5873923", "0.58670384", "0.5858309", "0.58561826", "0.5856175", "0.58539385", "0.58524454", "0.5845519", "0.5831392", "0.5827663", "0.5817428", "0.58139354", "0.58125824", "0.58100533", "0.58018804", "0.579811", "0.57950383", "0.57950383", "0.57937574", "0.57921684", "0.57919437", "0.5791818", "0.57914966", "0.57913435", "0.5786218", "0.57776546", "0.57701564", "0.57644725", "0.57644725" ]
0.81107867
0
for direct access inner data from own instance
def _autonyms @autonyms end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def internal_data # nodoc\n _data\n end", "def data\n DataProxy.new(self)\n end", "def data() @data ||= Data.new( self ); end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def data; end", "def private; end", "def data\n self[:data]\n end", "def data\n @data\n end", "def me\n @obj\n end", "def instance\n local.value\n end", "def nested_under_indifferent_access\n self\n end", "def additional_data\n return @additional_data\n end", "def instance_variables() end", "def get_data()\t\n\tend", "def ob\n return self.class.ob\n end", "def data\n @data\n end", "def data\n @data\n end", "def data\n @data\n end", "def additional_data\n return @additional_data\n end", "def instance; end", "def instance; end", "def instance; end", "def stored_data; end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def __object\n __value\n end", "def data\n self[:data].with_indifferent_access\n end", "def initialize\n @data = Data.instance\n end", "def data\n raise NotImplementedError\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def instance_attributes; end", "def get_private_self\n\t\t self.private_attribute\n\t\t end", "def inner\n clone.inner!\n end", "def retrieve_data\n if is_fork?\n parent.data\n else\n self.read_attribute(\"data\")\n end\n end", "def obj\n self\n end", "def data= data \n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def data\n self.load if @data.nil?\n @data\n end", "def ___super___\n isolation_context.instance\n end", "def data\r\n @data\r\n end", "def object\n @obj\n end", "def data\n @data\n end", "def data\n @data\n end", "def data\n @data\n end", "def delegate_object_reader_method; end", "def init_data\n end", "def getters; end", "def get_data\n raise \"overwrite it\"\n end", "def get(object); end", "def instance_variables; end", "def object\n @obj\n end", "def get_private()\n res = super(self)\n return res\n end", "def value(); self.data.value; end", "def instance=(instance); end", "def data\n @data ||= @_data.respond_to?(:call) ? @_data.call() : @_data\n end", "def data\n @data\n end", "def data\n retrieve_data\n end", "def __getobj__\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def additional_data\n return @additional_data\n end", "def initialize_data\n end", "def custom_data\n super.attributes\n end", "def object\n __getobj__\n end", "def get_private_self\n self.private_attribute\n end", "def data\n Facebooker::Data.new(self)\n end", "def read_instance\n raise NotImplementedError, 'read_instance needs to be implemented by child providers'\n end", "def me\n data['me']\n end", "def member\n super\n end", "def member\n super\n end", "def item; @item; end", "def item; @item; end", "def public_values\n { 'id' => self.id, 'data' => self.data, \n 'id_data' => self.id_data, 'deleted' => self.deleted }\n end", "def data\n attributes.fetch(:data)\n end", "def data\n attributes.fetch(:data)\n end", "def initialize\n super()\n init_data()\n end", "def get()\n \n end", "def member; end", "def member; end", "def member; end", "def member; end", "def member; end", "def additional_data\n return @additional_data\n end" ]
[ "0.6445963", "0.6433098", "0.6407438", "0.6256322", "0.6256322", "0.6256322", "0.6256322", "0.6256322", "0.6256322", "0.6256322", "0.6256322", "0.6256322", "0.6256322", "0.6256322", "0.6256322", "0.6252811", "0.62502134", "0.61215353", "0.6104824", "0.60806066", "0.6060683", "0.60465604", "0.603915", "0.60344696", "0.60278684", "0.60196525", "0.60196525", "0.60196525", "0.6002126", "0.5994853", "0.5994853", "0.5994853", "0.599372", "0.5978191", "0.5978191", "0.5974684", "0.5958218", "0.5957604", "0.5957216", "0.5945008", "0.5945008", "0.5945008", "0.5945008", "0.5945008", "0.5945008", "0.5945008", "0.5945008", "0.5905329", "0.590508", "0.58703", "0.5857366", "0.585164", "0.58376604", "0.5836409", "0.5836409", "0.58022046", "0.57932454", "0.5791108", "0.57853633", "0.5783239", "0.5783239", "0.5783239", "0.57749754", "0.57699215", "0.57661366", "0.5765782", "0.5729096", "0.57261467", "0.57185984", "0.57082754", "0.5700043", "0.5698882", "0.5696219", "0.56881595", "0.568407", "0.5677401", "0.5672686", "0.5672686", "0.5672686", "0.56724113", "0.56686264", "0.5660733", "0.5660515", "0.5660033", "0.5640488", "0.5609715", "0.5605916", "0.5605916", "0.560545", "0.560545", "0.5590961", "0.55780214", "0.55780214", "0.5577925", "0.5575976", "0.55729675", "0.55729675", "0.55729675", "0.55729675", "0.55729675", "0.5566422" ]
0.0
-1
scope :approved, where(:status_id => Status.where(:status => 'approved').first.id)
def temp_id #reverting to just plain id, see issue #89 self.id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def scope_by_status(status)\n case status\n when 'new', 'shipped', 'paid'\n with_scope(:find => { :conditions => {:status => status}}) do\n yield\n end\n else\n yield\n end\n end", "def status\n \"approved\"\n end", "def scope\n finder_or_run(:scope)\n end", "def approved?\n (status == APPROVED)\n end", "def approval_status\n self.approved? ? 'Approved ' : 'Pending '\n end", "def list_by_status(status)\n\tProject.where('client_id = ? AND status = ?',self.id,status) \n\tend", "def status_id(status)\r\n case status\r\n when \"Active\"\r\n \"Y\"\r\n when \"Inactive\"\r\n \"N\"\r\n when \"Draft\"\r\n \"D\"\r\n else\r\n \"N\"\r\n end\r\n end", "def get_scope_by_id(id)\n id = id.to_s\n scopes.find{|s| s.id == id }\n end", "def scope_condition() \"1\" end", "def appeal_status_id\n \"A#{id}\"\n end", "def status\n @status ||= RecipeStatus.find status_id\n end", "def status\n STATUSES[self.status_id]\n end", "def apply_id_filter(scope, value)\n scope.where id: value\n end", "def paid\n where(:payment_status => \"paid\")\n end", "def status\n Status.find(self.status_id).name\n end", "def scoped_resource\n resource_class.where({ status: :awaiting_review })\n end", "def status\n statuses.find(:first, :order => \"updated_at DESC\")\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status ||= Status.find(params[:id])\n end", "def is_approved?\n self.approved == 'approved'\n end", "def show\n @status = Status.find(params[:id])\n end", "def confirmations_for(invitation)\n self.confirmations.find(:all, \n :conditions => ['invitation_id = ? AND status_id != ? AND status_id != ?', invitation.id, Status['approved'].id, Status['new'].id])\n end", "def status\n @review = Review.find(params[:id])\n @review.update_attribute(:approved_id, current_user.id)\n flash[:info] = \"Review is approved!\"\n redirect_to admin_home_path\n end", "def review_complete?\n self.review_status_id == ReviewStatus.find(:first,\n :conditions => \"name='Review Completed'\").id\n end", "def approved?\n status == STATUS_APPROVED\n end", "def check_status_change\n if self.status_id != @current_status\n sc = StatusChange.new\n sc.submission_id = self.id\n sc.status_id = self.status_id\n sc.changed_at = @current_time\n sc.comments = status_comments\n sc.save\n #give sub a global id if approved\n if self.status.eq?('approved')\n self.guid = generate_guid(@current_time)\n end\n end\n end", "def scope\n Pundit.policy_scope!(user, record.class)\n end", "def status\n if params[:id]\n @source = \"confessor_status\"\n else\n @source = \"priest_status\"\n end\n end", "def pending_repost?\n self.review_status_id == ReviewStatus.find(:first,\n :conditions => \"name='Pending Repost'\").id\n end", "def get_status\n shipment= Shipment.find_by_tracking(params[:tracking_no])\n shipment.status if shipment\n end", "def status\n STATUSES[self.status_id || 0]\n end", "def view_invitations\n @invitations = Invitation.all(:conditions => ['status = ?', 'pending'])\n end", "def approve\n self.update(status: \"APPROVED\")\n end", "def status(*status)\n all.select { |b| status.include?(b.status) }\n end", "def in_review?\n self.review_status_id == ReviewStatus.find(:first,\n :conditions => \"name='In Review'\").id\n end", "def status_column\n :active\n end", "def set_approval\r\n @approval = Approval.find(params[:id])\r\n end", "def is_approve\n order = current_user.customer.orders.find(params[:id])\n if order.status == \"Approved\"\n render json: {is_approve: true}\n elsif order.status == \"Declined\"\n render json: {is_approve: false}\n else\n render json: {is_approve: nil}\n end\n end", "def next_status\n @next_status ||= self.next_status_table ? self.next_status_table.to_class.find(next_status_id) : nil\n end", "def find_task_by_status(status)\n ids = user_tasks.where(status: status).pluck(:task_id).uniq\n Task.find([ids]).all || nil\n end", "def overlapping_approved_requests\n overlapping_requests.where(status: \"APPROVED\")\n end", "def approved\n @approved_users = User.where(isApproved:true).where(isDenied:false).paginate(:page => params[:uapproved_users_page], :per_page => 10)\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def show\n # @statements = Statement.where(:payment_status => \"not_paid\")\n end", "def approved_comments\n comments.select {|comment| comment.approved == true }\n end", "def show\n @profile=Profile.find(params[:id])\n authorize @profile\n #@profile=Profile.where(user==current_user)\n\n\n #authorize @profile\n\n #scope.where(:id => profile.id).exists?\n\n end", "def set_status\n @status = Status.find(params[:id])\n end", "def selected_scope\n (params[:scope] || :default).to_sym\n end", "def last_status\n self.dossier_statuses.order(\"created_at DESC\").limit(1).first\n end", "def find_approved_by_ids(items)\n items.approved_by_users_with_ids(*ids)\n end", "def approve_me\n self.update!(status: 'APPROVED')\n end", "def pending_edits\n \tself.edits.where(:is_approved => nil)\n end", "def statusing_params\n params.require(:statusing).permit(:status_id)\n end", "def show_status(status_id)\n get \"statuses/show/#{status_id}\"\n end", "def approve_reject\n @leaves = Leave.find(:all, conditions: ['user_id = ?\n and current_status = ?',\n params[:user_id].to_i, 'Approved'])\n @leave = Leave.find(params[:id])\n\n respond_to do |format|\n format.html\n end\n end", "def approved_by\n if approved?\n I18n::t(:dean, :scope => [:model, :plan])\n elsif approval\n approval.approved_by\n end\n end", "def find_friendship(inviter, invited, status)\n conditions = {:inviter_id => inviter.id, :invited_id => invited.id}\n conditions.merge!(:status => status) if status\n Friendship.find(:first, :conditions => conditions)\n end", "def scope\n @scope\n end", "def scope\n @scope\n end", "def membership_status(role)\n member = student_memberships.where(role_id: role.id).first\n member&.membership_status\n end", "def approval_id\n return @approval_id\n end", "def approved?\n self.is_approved == true \n end", "def getStatus\n @@statuses[@status]\n end", "def fetchAllUsersByApproved(collection)\n query = Hash.new()\n query = {\n \"approval_status.code\" => 2\n } \n return collection.find(query)\n end", "def retrieve_status\n \n end", "def first_approval\n miq_approvals.first || build_default_approval\n end", "def confirm\n approval = Approval.find_by(id: params[:id])\n approval.approval = true\n approval.save\n redirect_to users_path\n end", "def first_item\n self.simple_acts_as_list_scope.first\n end", "def status\n @post = Post.find(params[:id])\n @post.update_attribute(:approved_id, current_user.id)\n flash[:info] = \"Advertisement is approved!\"\n redirect_to admin_home_path\n end", "def simple_acts_as_list_scope(scope_id)\n self.where(\n \"#{self.table_name}.#{self.simple_acts_as_list_scope_id}\" => scope_id).\n order(\"#{self.table_name}.position\")\n end", "def index\n @orders =if current_user.role == \"provider\"\n Order.where(\"provider_id= ?\", current_user.id)\n elsif \n params[:status]\n Order.where(status: params[:status])\n # Order.where(\"provider_id= ? AND status= ?\", current_user.id, \"pending\")\n else\n current_user.orders\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @orders.to_json }\n end\n end", "def status=(new_status_type_id)\n new_status = statuses.create :organization_quarter_status_type_id => new_status_type_id\n organization.mark_inactive(quarter.next) if new_status.type.abbreviation == \"inactive\"\n return new_status\n end", "def set_project_status\n @project_status = Project::Status.find(params[:id])\n end", "def scope\n klass\n end", "def approved?\n if order_status == 'approved'\n return true\n else\n return false\n end\n end", "def set_approval\n @approval = Approval.find(params[:id])\n end", "def set_approval\n @approval = Approval.find(params[:id])\n end", "def active\n where(:state => \"new\")\n #actions = Action.arel_table\n #where(actions[:state].eq('new').or(actions[:state].eq('copied')))\n end", "def status(id)\n get(\"mailers/status/#{id.to_i}\")\n end", "def active_interviews\n self.interviews.where(:status=>1).order(\"date\")\nend", "def tender_by_company_and_status(status,company_id)\n\t\tTender.where(\"company_id= ? AND status= ?\", company_id, params[:status] ).order(\"bid_amount\")\n\tend", "def current_status\n Status.find_by(layer_id: id, latest: true).status\n end", "def find_by_id(client, id, options: {})\n\n self.new(parse(client.get(\"/project_statuses/#{id}\", options: options)).first, client: client)\n end", "def select(scope) # abstract\n end", "def status\n if self.status_id && !self.status_id.empty?\n self.status_id\n else\n \"new\"\n end\n end" ]
[ "0.6887195", "0.5895217", "0.57593375", "0.5603671", "0.55531305", "0.5549762", "0.5511161", "0.5509308", "0.5420376", "0.5395787", "0.53955", "0.5380863", "0.53639835", "0.53508085", "0.5317412", "0.5298869", "0.5285759", "0.52837634", "0.52837634", "0.52837634", "0.52837634", "0.52799547", "0.5277145", "0.52771205", "0.5242646", "0.5225255", "0.5208256", "0.5192271", "0.5176868", "0.5163273", "0.51563233", "0.51502144", "0.5147199", "0.51374805", "0.5134858", "0.51348364", "0.5099663", "0.50922585", "0.50805724", "0.5077029", "0.50708973", "0.50633204", "0.5046988", "0.5040631", "0.5032923", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.5009817", "0.500666", "0.50010306", "0.49987838", "0.4992567", "0.4986519", "0.49772137", "0.49673966", "0.49642634", "0.49560815", "0.4947051", "0.49435952", "0.49313974", "0.4923103", "0.49173847", "0.49169892", "0.49169892", "0.49130344", "0.49077785", "0.489701", "0.48954958", "0.48893666", "0.4867319", "0.4866048", "0.48635292", "0.48602748", "0.48580477", "0.4857868", "0.48574814", "0.48558512", "0.4851024", "0.4850298", "0.4849154", "0.48488468", "0.48488468", "0.48455215", "0.48393476", "0.48391667", "0.48383617", "0.48346677", "0.4834271", "0.4832758", "0.48306337" ]
0.0
-1
create new status change record on status change
def check_status_change if self.status_id != @current_status sc = StatusChange.new sc.submission_id = self.id sc.status_id = self.status_id sc.changed_at = @current_time sc.comments = status_comments sc.save #give sub a global id if approved if self.status.eq?('approved') self.guid = generate_guid(@current_time) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_status(Status status)\n Status.create(group_id: @group_id, status: status)\n end", "def handle_status_change\n return nil unless self.new_status.present?\n self.status = self.new_status\n if self.new_status == 'active'\n # the user wants to make the ad active now so push out the inactive and deletion dates\n self.inactive_date = Time.now + 2.months\n self.delete_date = Time.now + 4.months\n elsif self.new_status == 'inactive'\n # the user wants to make the ad inactive now so make the inactive date to day and deletion in 2 months\n self.inactive_date = Time.now\n self.delete_date = Time.now + 2.months\n end\n end", "def check_create_status\n if self.v_status.nil?\n status = VStatus.new\n status.v_project = self\n status.v_user_data = self.v_user_data\n self.v_status = status\n end\n end", "def set_status\n\t \t#establecer status en BD\n\t \tself.status = \"created\"\n\t \tself.save #para que se guarde\n\t end", "def add_status_change(post, action, transaction, options, extended = true)\n post[:szDesiredStatus] = action\n post[:szTransactionId] = transaction\n post[:szNewOrderNumber] = sanitize_order_id(options[:order_id]) unless options[:order_id].blank?\n \n if extended and status_extended_valid?(options)\n action += 'EX'\n add_invoice(post, options)\n add_address(post, options)\n end\n end", "def log(project, project_params, action, status = nil)\n status_change = 0\n if status\n old_status = Status.find(status)\n new_status = Status.find(project.status_id)\n\n status_change = new_status.sorting - old_status.sorting\n end\n\n ProjectLog.create(project_id: project.id, params: project_params.to_json, action: action, status_change: status_change)\n end", "def save_status status\n\t\n\t\t@db.rpush @type, status\n\t\n\tend", "def change_status(status)\n unless @status == status\n @status = status\n @start_time = Time.now\n end\n end", "def change_status(status)\n #not implemented \n end", "def record_status_change(status, modified_date, estimated_days)\n if status.is_tested?\n add_estimated_days_on_date @tested, modified_date, estimated_days\n elsif status.is_signed_off?\n add_estimated_days_on_date @signed, modified_date, estimated_days\n elsif status.is_relevant?\n add_estimated_days_on_date @planned, modified_date, estimated_days\n end\n end", "def new_record?(workstation_status)\n workstation_status.saved_change_to_id?\n end", "def create_statuses\n end", "def create_statuses\n end", "def create\n ActiveRecord::Base.transaction do\n @status = Status.new(status_params)\n\n respond_to do |format|\n if @status.save\n format.html { redirect_to @status, notice: 'El Estado se cre&oacute; exitosamente.' }\n format.json { render :show, status: :created, location: @status }\n else\n format.html { render :new }\n format.json { render json: @status.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create_starting_statuses\n new_status_attributes = { :public_title => \"New\",\n :application_status_type => ApplicationStatusType.find_or_create_by_name(\"new\"),\n :disallow_user_edits => 0,\n :disallow_all_edits => 0,\n :allow_application_edits => 1 }\n statuses.create(new_status_attributes)\n in_progress_status_attributes = { :public_title => \"In Progress\",\n :application_status_type => ApplicationStatusType.find_or_create_by_name(\"in_progress\"),\n :disallow_user_edits => 0,\n :disallow_all_edits => 0,\n :allow_application_edits => 1 }\n statuses.create(in_progress_status_attributes)\n submitted_status_attributes = { :public_title => \"Submitted\",\n :application_status_type => ApplicationStatusType.find_or_create_by_name(\"submitted\"),\n :disallow_user_edits => 1,\n :disallow_all_edits => 0,\n :allow_application_edits => 0 }\n statuses.create(submitted_status_attributes)\n end", "def status\n s = statuses.find(:first, :order => \"updated_at DESC\")\n if s.nil?\n s = statuses.create :organization_quarter_status_type_id => OrganizationQuarterStatusType.find_or_create_by_title(\"Needs Contact\").id\n s.type.sequence = 0; s.type.save;\n end\n s\n end", "def change_status(new_status)\n cm_status = status\n new_params = {:event_id => event.cm_event_id,\n :session_id => cm_session_id,\n :status => new_status}\n cm_status.load(new_params)\n begin\n cm_status.save\n rescue => e\n if cm_status.present?\n errors.add_to_base(e.to_s)\n end\n end\n end", "def changed\n @status = true\n end", "def status=(new_status)\n self.last_status = status\n\n self.setValue new_status, forKey: 'status'\n end", "def change_status\n\n res = RResponse.new\n\n order = Order.find_by_id(params[:id])\n order.shipping_status_id = params[\"shipping_status_id\"]\n begin\n order.save\n res.success = true\n res.msg = 'Changed order status to \"' + order.status.name + '\"'\n\n # log this\n type = OrderLogType.find_by_name('status')\n log = OrderLog.create(:account_id => current_user.account.id, :order_log_type_id => type.id, :order_id => order.id, :subject => 'Order Status', :msg => res.msg)\n res.add_action(RAction.new({\n :component_id => 'order-log-' + params[:id],\n :success => true,\n :data => {:log => log.to_a}\n })) \n end\n\n respond(res)\n\n end", "def create\n @new_status = NewStatus.new(params[:new_status])\n\n respond_to do |format|\n if @new_status.save\n format.html { redirect_to @new_status, notice: 'New status was successfully created.' }\n format.json { render json: @new_status, status: :created, location: @new_status }\n else\n format.html { render action: \"new\" }\n format.json { render json: @new_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def mark_as(status)\n self.status = status\n self.save\n end", "def create\n @breadcrumb = 'create'\n @work_order_status = WorkOrderStatus.new(params[:work_order_status])\n @work_order_status.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @work_order_status.save\n format.html { redirect_to @work_order_status, notice: crud_notice('created', @work_order_status) }\n format.json { render json: @work_order_status, status: :created, location: @work_order_status }\n else\n format.html { render action: \"new\" }\n format.json { render json: @work_order_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_status(status)\n @status = status\n @last_status_change = Time.now\n update_statusfile\n end", "def advancing_status\n if Task.statuses[status_was] > Task.statuses[status]\n errors.add(:status, 'change is invalid')\n end\n end", "def update_status status\n @job.set({\n custom_status: status,\n pinged_at: Time.now\n })\n end", "def status=(new_status)\n update_values([:status] => new_status)\n end", "def create_activity(object, symbol, old_value, new_value, activity_params)\n object.create_activity \"change_#{symbol}\".to_sym,\n owner: current_user,\n recipient: object,\n parameters: activity_params.merge(old: old_value, new: new_value)\n end", "def update_status(status)\n self.status = status\n self.save! validate: false\n end", "def status=(new_status)\n return if self.status == new_status\n if going_back_to?(new_status)\n revert_to(new_status)\n else\n if jumping_to?(new_status) #if we're skipping one or more statuses\n # fill_in_achievements here\n end\n # add a progression to the user\n if new_status::ID > AddedApplication::ID\n self.progressions << Progression.create(:user => self, :status_id => new_status::ID)\n end\n end\n # now set the status--NEED to reference self.status_id here (.status = infinite loop)\n self.status_id = new_status::ID\n self.check_for_new_achievements\n self.save!\n end", "def status_hook\n # We're not interested in PR statuses or branches other than deploy\n unless params[:branches].index { |b| b[:name] == 'deploy' }\n render(plain: 'Not a commit on deploy. Uninterested.') && return\n end\n\n # Create a new CommitStatus\n\n if CommitStatus.find_by(commit_sha: params[:sha])\n render plain: 'Already recorded status for commit', status: 200\n return\n end\n\n if params[:state] == 'pending'\n render plain: \"We don't record pending statuses\", status: 200\n return\n end\n\n commit_sha = params[:sha]\n status = params[:state]\n commit_message = params[:commit][:commit][:message]\n ci_url = params[:target_url]\n\n ActionCable.server.broadcast 'smokedetector_messages', commit_status: {\n status: status,\n ci_url: ci_url,\n commit_sha: commit_sha,\n commit_message: commit_message\n }\n CommitStatus.create(commit_sha: commit_sha, status: status)\n\n render plain: 'OK', status: 200\n end", "def enter_pending\n update_attribute(:status, :pending)\n end", "def create\n @status_record = StatusRecord.new(params[:status_record])\n\n respond_to do |format|\n if @status_record.save\n format.html { redirect_to @status_record, notice: 'Status record was successfully created.' }\n format.json { render json: @status_record, status: :created, location: @status_record }\n else\n format.html { render action: \"new\" }\n format.json { render json: @status_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @status = current_user.statuses.new(params[:status])\n\n respond_to do |format|\n if @status.save\n current_user.create_activity(@status, 'created')\n format.html { redirect_to profile_path(current_user), notice: 'Status was successfully created.' }\n format.json { render json: @status, status: :created, location: @status }\n else\n format.html { render action: \"new\" }\n format.json { render json: @status.errors, status: :unprocessable_entity }\n end\n end\n end", "def change_status(object, status)\n object.update_attribute :status, status\n end", "def update_status\n case @part.status\n when 'Unstarted'\n @part.status = 'Started'\n @part.user = current_user\n @part.bitbucket.post_user(current_user.email) if @part.name == 'Prototype'\n @part.create_activity key: 'part.started', owner: current_user\n @part.start_rep_points\n when 'Started'\n @part.status = 'Finished'\n @part.create_activity key: 'part.finished', owner: current_user\n when 'Finished' \n @part.status = 'In Review'\n @part.create_activity key: 'part.in_review', owner: current_user\n when 'In Review'\n @part.status = 'Accepted'\n @part.accepted_rep_points\n @part.create_activity key: 'part.accepted', owner: current_user\n end\n @part.save\n redirect_to :back\n end", "def create\n @record_status = RecordStatus.new(params[:record_status])\n\n respond_to do |format|\n if @record_status.save\n format.html { redirect_to @record_status, notice: 'Record status was successfully created.' }\n format.json { render json: @record_status, status: :created, location: @record_status }\n else\n format.html { render action: \"new\" }\n format.json { render json: @record_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def log_create\n if self.class.name == 'ParticipantsSportEntry'\n model = self.sport_entry\n action = 'UPDATE'\n else\n model = self\n action = 'CREATE'\n end\n\n ModelAuditJob.perform_now(model, action, audit_user_id)\n end", "def status_change\n respond_to do |format|\n format.js do\n @activity = CurationActivity.create(identifier_id: params[:id], status: params[:status], user_id: current_user.id,\n note: params[:note])\n end\n end\n end", "def set_status\n self.status = Status.find_by(code: \"OPEN\")\n end", "def changed to, data\n if (current = self.get_status)\n current_status = ::JSON.parse(current)['status']\n return current_status if current_status != to\n to\n else\n NOCH.create_object(to, data)\n end\n end", "def test_set_status\n # in the future\n @absence = Absence.create(:start_time => '1-10-3000 00:00',\n :end_time => '1-10-3000 00:00',\n :reason => 'reason',\n :user_id => User.find_by_admin(true).id,\n :variety => 'Holiday',\n :start_half_day => 'Lunch Time',\n :end_half_day => 'Lunch Time')\n assert_valid @absence\n assert_equal 'Pending', @absence.status\n # in the past\n @absence = Absence.create(:start_time => '1-10-1000 00:00',\n :end_time => '1-10-1000 00:00',\n :reason => 'reason',\n :user_id => User.find_by_admin(true).id,\n :variety => 'Holiday',\n :start_half_day => 'Lunch Time',\n :end_half_day => 'Lunch Time' )\n assert_valid @absence\n assert_equal 'Approved', @absence.status\n end", "def create\n @status = Status.new(params[:status])\n @status.save\n\n redirect_to @status, notice: 'Status was successfully created.'\n end", "def create_change(change)\n Change.create(:changeset => self,\n :action => change[:action],\n :path => change[:path],\n :from_path => change[:from_path],\n :from_revision => change[:from_revision])\n end", "def eval_transaction_status_change params\n return if params.blank? or params[:status_notification].blank? or params[:status_notification][:transaction].blank?\n init_data_by_payment(Spree::Payment.find_by_sofort_transaction(params[:status_notification][:transaction]))\n raw_response = HTTParty.post(@sofort_payment.payment_method.preferred_server_url,\n :headers => header,\n :body => transaction_request_body)\n new_entry = I18n.t(\"sofort.transaction_status_default\")\n if raw_response.parsed_response[\"transactions\"].present? and\n raw_response.parsed_response[\"transactions\"][\"transaction_details\"].present?\n\n td = raw_response.parsed_response[\"transactions\"][\"transaction_details\"]\n alter_payment_status(td)\n new_entry = \"#{td[\"time\"]}: #{td[\"status\"]} / #{td[\"status_reason\"]} (#{td[\"amount\"]})\"\n end\n old_entries = @sofort_payment.sofort_log || \"\"\n @sofort_payment.update_attribute(:sofort_log, old_entries += \"#{new_entry}\\n\")\n end", "def create_note(issue)\n Note.create_status_change_note(issue, issue.project, current_user, issue.state, current_commit)\n end", "def create\n @request_status = RequestStatus.new(params[:request_status])\n\n respond_to do |format|\n if @request_status.save\n format.html { redirect_to @request_status, notice: 'Request status was successfully created.' }\n format.json { render json: @request_status, status: :created, location: @request_status }\n else\n format.html { render action: \"new\" }\n format.json { render json: @request_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def store_status(id, status, expiration = nil)\n store_for_id id, {status: status}, expiration\n end", "def create\n @status = Status.new(params[:status])\n\n respond_to do |format|\n if @status.save \n @user = @status.user\n @user.view_status = @status.view_status\n @user.save\n \n if @user.view_status == 'live' && @user.teacher?\n Innsights.report(\"Maestro aceptado\", :user => current_user, :group => current_network).run\n elsif @user.teacher?\n Innsights.report(\"Maestro suspendido\", :user => current_user, :group => current_network).run\n end\n\n format.html { redirect_to :back, notice: 'El status ha sido agregado correctamente al usuario' }\n format.json { render json: :back , status: :created, location: @status }\n else\n format.html { render action: \"new\" }\n format.json { render json: @status.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_status(new_stat)\n\n attrs = ActionController::Parameters.new({status: new_stat, req_to_del_at: nil})\n self.update_attributes(attrs.permit(Team::PERMIT_BASE))\n end", "def add_status(timestamp, status, message=nil)\n # creates a status entry\n timestamp = timestamp.to_i\n entry = StatusEntry.new(timestamp, status, message)\n\n # sets the status_entry in the redis status hash\n redis.zadd(key(:uuid, @uuid), timestamp, encode(entry.to_h))\n\n # set/reset expiration on status hash\n if Status.expire_after\n redis.expire(key(:uuid, @uuid), Status.expire_after)\n end\n\n # Add entry to index if necessary.\n # We only score using the creation timestamp this way.\n if redis.zscore(key(:uuid_index), @uuid).nil?\n redis.zadd(key(:uuid_index), timestamp, @uuid)\n end\n end", "def comprado!\n \tupdate_column(:status, true)\n end", "def status=(new_status_type_id)\n new_status = statuses.create :organization_quarter_status_type_id => new_status_type_id\n organization.mark_inactive(quarter.next) if new_status.type.abbreviation == \"inactive\"\n return new_status\n end", "def create_change_log_entry\n @change_log = @backup.create_change_log_entry(params[:action])\n @change_log.save!\n end", "def duplicate_workflow_status\r\n return if self.workflow_statuses.none?\r\n self.workflow_statuses.create(workflow_status_template_id: self.workflow_statuses.last.workflow_status_template_id)\r\n end", "def transmogrify\n\t\tassign_value_of_changed_status\n\t\tupdate_attributes(last_sent: DateTime.now)\n\n\tend", "def change_job_status_from_details\n @project_job = @current_organization.project_jobs.find(params[:id])\n if params[:status].present?\n if @project_job.status.present? && @project_job.status != params[:status]\n @project_job.update_column(:status, params[:status])\n @project_job.check_or_upgrade_project_stage \n create_comment_activity(\"<b>\"+params[:status]+ \"</b> the Task\")\n create_in_app_notification(\"Update\", \"Job status changed to #{params[:status]}\")\n Activity.create(:organization_id => @project_job.organization_id, :activity_user_id => @current_user.id, :activity_type => @project_job.class.name, :activity_id => @project_job.id, :activity_status => \"StatusChanged\", :activity_desc => \"Job status changed to #{params[:status]}\", :activity_date => @project_job.updated_at, :is_public => true, :source_id => @project_job.project.id,:source_type => @project_job.project.class.name)\n end\n end\n render partial: \"project_job_status_bar\"\n end", "def create\n @status = Status.new(status_params)\n\n if @status.save\n render json: @status\n else\n render json: @status.errors, status: :unprocessable_entity\n end\n end", "def build_status_update(curr_lsn, send_time)\n return nil if curr_lsn.nil?\n\n message = ['r']\n # received/flushed/applied\n 3.times { message << curr_lsn }\n # send_time\n message << format_time(send_time)\n # require reply\n message << 0\n message = message.pack('aQ>4C')\n end", "def get_date_for_status_change(from_status, to_status)\n selected_version = self.versions.select {|x| YAML.load(x.object_changes)[\"status\"] == [from_status, to_status] }\n !selected_version.empty? ? selected_version.last.created_at : 0\n end", "def create\n @breadcrumb = 'create'\n @order_status = OrderStatus.new(params[:order_status])\n @order_status.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @order_status.save\n format.html { redirect_to @order_status, notice: crud_notice('created', @order_status) }\n format.json { render json: @order_status, status: :created, location: @order_status }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order_status.errors, status: :unprocessable_entity }\n end\n end\n end", "def status=(status); end", "def set_on_create\n set Status::DEFAULT, \"Initialization\"\n end", "def make_log(current_employee, old_in, old_out, new_in, new_out)\n self.changelogs.build(:changed_by => current_employee.name, :old_in => old_in, :old_out => old_out, :new_in => new_in, :new_out => new_out)\n self.save!\n end", "def update_status\n begin\n if self.service_test.status_changed?\n results = self.service_test.test_results.last(2)\n unless results.empty?\n case results.length\n when 1\n previous = TestResult.new_with_unknown_status\n when 2\n previous = results[0] \n end\n \n if USE_EVENT_LOG\n \n service = self.service_test.service\n \n ActivityLog.create(:action => \"status_change\",\n :data =>{:current_result_id => self.id, :previous_result_id =>previous.id },\n :activity_loggable => self.service_test,\n :referenced => service)\n \n current_status = ServiceCatalographer::Monitoring::TestResultStatus.new(self)\n previous_status = ServiceCatalographer::Monitoring::TestResultStatus.new(previous)\n \n \n if ENABLE_TWITTER\n ServiceCatalographer::Util.say \"Called TestResult#update_status. A status change has occurred so submitting a job to tweet about...\"\n msg = \"Service '#{ServiceCatalographer::Util.display_name(service)}' has a test change status from #{previous_status.label} to #{current_status.label} (#{self.created_at.strftime(\"%Y-%m-%d %H:%M %Z\")})\"\n Delayed::Job.enqueue(ServiceCatalographer::Jobs::PostTweet.new(msg), :priority => 0, :run_at => 5.seconds.from_now)\n end\n \n unless MONITORING_STATUS_CHANGE_RECIPIENTS.empty?\n status_recipients_emails = MONITORING_STATUS_CHANGE_RECIPIENTS.dup\n \n if NOTIFY_SERVICE_RESPONSIBLE\n status_recipients_emails = status_recipients_emails + self.responsible_emails\n end\n ServiceCatalographer::Util.say \"Called TestResult#update_status. A status change has occurred so emailing the special set of recipients about it...\"\n subject = \"[#{SITE_NAME}] Service '#{ServiceCatalographer::Util.display_name(service)}' has a test change status from #{previous_status.label} to #{current_status.label}\"\n text = \"A monitoring test status change has occurred! Service '#{ServiceCatalographer::Util.display_name(service)}' has a test (#{self.service_test.test_type}, ID: #{self.service_test.test_id}) change status from #{previous_status.label} to #{current_status.label}. Last test result message: #{current_status.message}. Go to Service: #{ServiceCatalographer::Api.uri_for_object(service)}\"\n Delayed::Job.enqueue(ServiceCatalographer::Jobs::StatusChangeEmails.new(subject, text, status_recipients_emails), :priority => 0, :run_at => 5.seconds.from_now)\n end\n \n end\n end\n end\n rescue Exception => ex\n logger.error(\"There was problems updating the status for service test : #{self.service_test.id}\")\n logger.error(ex)\n end\n end", "def create\n @task_changes = TaskChange.new(params[:task_change])\n\n respond_to do |format|\n if @task_changes.save\n format.html { redirect_to @task_changes, notice: 'Task change was successfully created.' }\n format.json { render json: @task_changes, status: :created, location: @task_changes }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task_changes.errors, status: :unprocessable_entity }\n end\n end\n end", "def on_change_status(&block)\n self.actions[:change_status] = block\n end", "def refresh_status!\n update!(:status => 'new') if status.nil?\n update!(:status => 'ack') if acked?\n update!(:status => 'nack') if nacked?\n update!(:status => 'push') if pushed?\n end", "def create\n s = Spooge.new()\n create_status = s.save\n n = generate_random_name\n s.name = n\n s.email = \"#{n}@gmail.com\"\n s.touch_date = DateTime.now\n s.status = STATUS[rand(STATUS.length)]\n\n resp = {:create_status => create_status, :record => s}\n render :json => resp\n end", "def auto_update_status\n if self.criminal_date && self.child_abuse_date && self.fbi_date\n if self.status < 2\n self.status = 2\n end\n elsif self.status == 2\n self.status = 1\n end\n end", "def added; status[:added]; end", "def status_transfer\n if status_changed? && status_changed?(from: \"finish\")\n errors.add(:base, \"错误的操作\")\n end\n end", "def create\n @status = Status.new(params[:status])\n\n respond_to do |format|\n if @status.save\n flash[:notice] = 'Status was successfully created.'\n format.html { redirect_to status_url(@status) }\n format.xml { head :created, :location => status_url(@status) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @status.errors.to_xml, :status => :unprocessable_entity }\n end\n end\n end", "def convert_status(status)\n case status\n when :added\n 'create'\n when :deleted\n 'delete'\n when :modified\n 'update'\n when :renamed\n 'move'\n else\n raise ArgumentError\n end\n end", "def status_updated\n new_status = params[:new_status]\n id = params[:id]\n application = EventApplication.find_by(user_id: id)\n application.status = new_status\n application.save(:validate => false)\n flash[:success] = \"Status successfully updated.\"\n\n redirect_to event_application_path(application)\n\n\n\n # Send email when status changes.\n if new_status == 'accepted'\n UserMailer.accepted_email(application.user).deliver_now\n elsif new_status == 'denied'\n UserMailer.denied_email(application.user).deliver_now\n else\n UserMailer.waitlisted_email(application.user).deliver_now\n end\n end", "def history_create\n # history_log('created', created_by_id)\n end", "def lent_out\n\tupdate_attributes(status: 'Lent Out')\nend", "def save_beginning_status user_id\n self.payment_status = PTE::PaymentStatus.processing\n self.user_id = user_id\n self.transaction_time = Time.now\n self.save\n end", "def check_for_state_change\n\n stored_task = ModelTask.find(self.id) if self.id\n\n if stored_task \n if !stored_task.completed? && self.completed?\n self.completed_at = Time.now\n state_change = 'Task Completed'\n elsif !stored_task.closed? && self.closed?\n self.closed_at = Time.now\n state_change = 'Task Closed'\n elsif stored_task.closed? && !self.closed?\n state_change = 'Task Reopened'\n elsif stored_task.completed? && !self.completed?\n state_change = 'Task Incomplete - Needs more work/input'\n end\n\n if state_change\n self.model_comments << ModelComment.new( :user_id => self.get_user.id, \n :comment => 'STATUS CHANGE: ' + state_change)\n end\n end\n \n end", "def activate\n self.status = 'current'\n self.save\n end", "def change_status(applicant_id, status_id)\n details = { status: status_id.to_i }.to_json\n options = { body: details, headers: { \"Content-Type\" => \"application/json\" } }\n\n request(:post, \"applicant_tracking/applications/#{applicant_id}/status\", options)\n end", "def initialize(status)\n @status = status\n @created_at = Time.new\n end", "def initialize(status)\n @status = status\n @created_at = Time.new\n end", "def save_changes_from(record)\n self.save_base_attributes(record)\n if record.new_record?\n self.log_type = \"created\"\n end\n self.extract_changes_from(record)\n end", "def set_attr_for_create\n self.agreement_status ||= 0 #unsigned\n self.trans_type = TRANS_TYPE[:AccountSetup]\n self.acct_open_date = Date.today\n self.last_trans_date = Date.today\n log_event(\"Customer\", self.id, \"Account Created\")\n end", "def mark_as_pushed!\n self.status_code = 200\n self.pushed_at = Time.now\n self.save!\n end", "def populate_issues_status(issue)\n @issues_status.push(IssueStatus.find_by_id(issue.status_id))\n end", "def create\n @status = Status.new(status_params)\n\n respond_to do |format|\n if @status.save\n format.html { redirect_to @status, notice: 'Status was successfully created.' }\n format.json { render :show, status: :created, location: @status }\n else\n format.html { render :new }\n format.json { render json: @status.errors, status: :unprocessable_entity }\n end\n end\n end", "def record_status(what, record)\n col, prefix = if what == :update\n [36, \"===\"]\n elsif what == :add\n [32, \"+++\"]\n elsif what == :delete\n [31, \"---\"]\n else\n [0, what]\n end\n\n if record.nil?\n message = \"nil\"\n else\n id = \"%-11s\" % \"[#{record.class.name} ##{record.id}]\"\n id = color(id, col)\n\n message = record.respond_to?(:inspect_name) ? record.inspect_name : record.to_s\n message = \"#{id} #{message}\"\n message.gsub! \"\\n\", \"\\n\"+(\" \"*12)\n end\n\n status message, prefix, col\nend", "def create_change\n @change_depth += 1\n save\n save_key(1, @change_depth, derive_key(1, @change_depth))\n end", "def set_new_state_after_notify(was_successful, event, status)\n unless status.attending?\n if was_successful\n if event.event?\n status.not_responded!\n else\n status.delivered!\n end\n else\n status.not_delivered!\n end\n status.save\n end\n end", "def schedule_new_record(row)\n ETL::Engine.logger.debug \"writing new record\"\n if scd_type == 2\n row[scd_effective_date_field] = @timestamp\n row[scd_end_date_field] = '9999-12-31 00:00:00'\n row[scd_latest_version_field] = true\n end\n buffer << row\n end", "def lors_status(status)\n @@LORS[status].create\n @w_lors.icon = @@LORS[status]\n end", "def create_translation_status(project_id, params)\n c_r Lokalise::Resources::CustomTranslationStatus, :create, project_id, params\n end", "def create\n @reqstatus = Reqstatus.new(reqstatus_params)\n\n respond_to do |format|\n if @reqstatus.save\n format.html { redirect_to @reqstatus, notice: 'Reqstatus was successfully created.' }\n format.json { render action: 'show', status: :created, location: @reqstatus }\n else\n format.html { render action: 'new' }\n format.json { render json: @reqstatus.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @status = Status.new(params[:status])\n\n respond_to do |format|\n if @status.save\n format.html { redirect_to(@status, :notice => 'Status was successfully created.') }\n format.xml { render :xml => @status, :status => :created, :location => @status }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @status.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @status = Status.new(status_params)\n\n respond_to do |format|\n if @status.save\n format.html { redirect_to @status, notice: 'Status was successfully created.' }\n format.json { render action: 'show', status: :created, location: @status }\n else\n format.html { render action: 'new' }\n format.json { render json: @status.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_status_timestamp\n self.overall_status_modified_at = Time.zone.now\n end", "def set_status\n self.status = 1\n end", "def create\n @change_history = ChangeHistory.new(params[:change_history])\n\n respond_to do |format|\n if @change_history.save\n format.html { redirect_to @change_history, notice: 'Change history was successfully created.' }\n format.json { render json: @change_history, status: :created, location: @change_history }\n else\n format.html { render action: \"new\" }\n format.json { render json: @change_history.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.66669685", "0.6452245", "0.6452151", "0.63089436", "0.61982274", "0.61640203", "0.61028206", "0.60521525", "0.60329837", "0.5996082", "0.59941417", "0.5970475", "0.5970475", "0.5955967", "0.59524834", "0.5933079", "0.5919985", "0.5896049", "0.5881074", "0.587314", "0.58672786", "0.58316284", "0.5796952", "0.5784994", "0.5782044", "0.57690066", "0.57662827", "0.57443666", "0.5744047", "0.5739937", "0.5738306", "0.5736482", "0.5731981", "0.57150686", "0.57125986", "0.5697681", "0.5686976", "0.56758815", "0.56736946", "0.5667502", "0.56597847", "0.5650316", "0.5609949", "0.56072605", "0.56032556", "0.5600414", "0.55990154", "0.55905724", "0.55832916", "0.5568898", "0.5567805", "0.55669427", "0.55642205", "0.55495316", "0.55481577", "0.5545086", "0.5541158", "0.5532551", "0.5525922", "0.5525789", "0.55251694", "0.5511003", "0.5509073", "0.55083567", "0.54948765", "0.5494668", "0.5480402", "0.5471565", "0.5469463", "0.5442928", "0.543557", "0.54302216", "0.5424097", "0.542349", "0.5419283", "0.54145914", "0.54103005", "0.54025596", "0.5400954", "0.5399688", "0.5397826", "0.5395564", "0.5395564", "0.53939545", "0.53902715", "0.5385241", "0.53847075", "0.538129", "0.53744715", "0.53687036", "0.53657895", "0.53551924", "0.535316", "0.53520906", "0.5342999", "0.5342219", "0.53389376", "0.53350365", "0.53350234", "0.53341067" ]
0.70357925
0
mainmenu(companyname,user,client_hash) Returns option selected by user
def main_menu(companyname="Unknown",username="Unknown",client_hash) prompt = TTY::Prompt.new(symbols: {marker: ">"}) input = "" while input != "Exit" system('clear') Debug.show "Debug ON\ninput: #{input} | company_name: #{companyname} | username: #{username}" menuoptions = ["Add new client","Search client","Exit"] menuoptions.delete("Add new client") if username == "guest" input = prompt.select("#{companyname} accounts\n\nLogged in as user #{username}\n\nTotal clients: #{client_hash[:clients].length}\n\n", menuoptions) if input == "Add new client" client_hash = add_new_client(client_hash) end if input == "Search client" clientsearch(client_hash,username) end end return input end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def booth_main_menu\n prompt.select(\"Welcome Booth Operator, what would you like to do today?\" ) do |menu|\n menu.choice \"View Merchandise\", -> {self.user.check_merchandise}\n menu.choice \"Update Inventory\", -> {self.user.add_to_inventory}\n menu.choice \"List of Customers\", -> {self.user.list_of_attendees}\n menu.choice \"Number of Sales\", -> {self.user.number_of_sales}\n menu.choice \"Items Sold\", -> {self.user.sales_made}\n menu.choice \"Sales Revenue\", -> {self.user.sales_revenue}\n menu.choice \"Exit\", -> {exit!}\n end\n end", "def main_menu\n @ui.input_1_change\n @ui.user_input1.downcase\n unless %w[trains routes stations cars].include? @ui.user_input1\n puts 'There is no such option in the main menu.'\n end\n main_menu_choose_option(@ui.user_input1)\n end", "def main_menu\n prompt.select(\"What would you like to do today #{user.name}?\") do |menu|\n menu.choice \"Choose Protein\", -> {choose_protein}\n menu.choice \"Exit!\", -> {exit_helper}\n menu.choice \"Delete Account!?!?\", -> {delete_account_helper}\n end\n end", "def menu\n ([[0, 'Choisir l’icarien…']] + User.values_select(type_icarien => true)).in_my_select(id: 'opuser_user_id', name: 'opuser[user_id]', selected: param_opuser[:user_id])\n end", "def user_select(items)\n h.choose do |menu|\n menu.index = :number\n menu.prompt = 'Please Choose One:'\n menu.select_by = :index_or_name\n items.each do |item|\n menu.choice item.to_sym do |command|\n ui.msg \"Using: #{command}\"\n selected = command.to_s\n end\n end\n menu.choice :all do return :all end\n menu.choice :exit do exit 1 end\n end\n end", "def my_account(user)\n router = nil\n message = []\n # base options\n options = [\n [\"Change Name\", 12],\n [\"Delete Account\", 7],\n [\"Log Out\", 4],\n [\"Main Menu\", 2],\n [\"Exit\", 1]\n ]\n # display loop until validated choice\n until router\n display_menu_header([\"My Account:\"], user)\n router = display_options_menu(options, message)\n message = [\"Sorry, invalid selection. Please choose again...\"]\n end\n menu_routing(user, \"\", router)\nend", "def login_menu\n system(\"clear\")\n prompt = prompt_instance\n prompt.select(\"Select option!\".colorize(:magenta)) do |menu|\n menu.choice \"LOGIN\", -> {login}\n menu.choice \"SIGN UP\", -> {sign_up}\n menu.choice \"BACK\".colorize(:red), -> {start_menu}\n end\nend", "def login\n puts \"Welcome to Singh Accounting Online Appointment System\"\n @prompt.select \"Are you a returning client?\" do |menu|\n menu.choice \"Yes\", -> do\n phone = @prompt.ask(\"Please Enter Your Phone Number\")\n @client = Client.find_by(phone: phone)\n \n \n\n if @client.nil?\n puts \"Sorry, cannot find client with that phone\"\n @prompt.select \"What would you like to do?\" do |m|\n m.choice \"Try Again\", -> { login }\n m.choice \"Create Account\", -> { new_client }\n m.choice \"Exit\", -> { exit_method }\n end\n end\n end\n\n menu.choice \"No (Create New Client Portal)\", -> { new_client }\n menu.choice \"Exit The System\", -> { exit_method }\n \n \n \n end\n end", "def main_menu(user=\"guest\")\n game = nil\n router = nil\n message = []\n # base options\n options = [\n [\"Continue as a Guest\", 8],\n [\"Log In\", 3],\n [\"Create Account\", 5],\n [\"Select a Game\", 8],\n [\"My Reviewed Games\", 13],\n [\"Log Out\", 4],\n [\"My Account\", 6],\n [\"Exit\", 1]\n ]\n # removing options based on status\n if user == \"guest\"\n options.delete_at(6)\n options.delete_at(5)\n options.delete_at(4)\n options.delete_at(3)\n elsif Review.where(user_id: user.id).count == 0\n options.delete_at(4)\n options.delete_at(2)\n options.delete_at(1)\n options.delete_at(0)\n else\n options.delete_at(2)\n options.delete_at(1)\n options.delete_at(0)\n end\n # display loop until validated choice\n until router\n display_menu_header([\"Main Menu:\"], user)\n router = display_options_menu(options, message)\n message = [\"Sorry, invalid selection. Please choose again...\"]\n end\n menu_routing(user, \"\", router)\nend", "def main_menu_choose_option(user_input)\n case user_input\n when 'trains'\n manage_trains\n when 'routes'\n manage_routes\n when 'stations'\n manage_stations\n when 'cars'\n manage_cars\n else\n @ui.wrong_input_msg\n end\n end", "def cli_menu\n system \"clear\"\n menu_header\n puts\n puts \"Welcome, #{@customer.name}!\"\n puts\n $prompt.select(\"SELECT AN OPTION ⬇\") do |menu|\n menu.choice \"Fast Food\", -> { full_menu }\n menu.choice \"Restaurants\", -> { restaurants_menu }\n menu.choice \"Place Order\", -> { place_an_order }\n menu.choice \"Previous Orders\", -> { customer_orders }\n menu.choice \"Cancel Order\", -> { cancel_order }\n menu.choice \"My Account\", -> { account_information }\n menu.choice \"Logout\", -> { exit }\n end\nend", "def select_list\n require 'pashua'\n include Pashua\n\n config = \"\n *.title = personal time tracker\n cb.type = combobox\n cb.completion = 2\n cb.width = 400\n cb.default = surfing\n cb.tooltip = Choose from the list\n db.type = cancelbutton\n db.label = Cancel\n db.tooltip = Closes this window without taking action\" + \"\\n\"\n\n # insert list of all choices\n cust = get_custom_cats || []\n cat = (cust ? cust + Categories : Categories)\n cat.each { |c| config << \"cb.option = #{c}\\n\" }\n pagetmp = pashua_run config\n exit if pagetmp['cancel'] == 1 || pagetmp['cb'] == nil\n\n choice = pagetmp['cb'].strip\n notify_change(choice)\n log(choice)\n\n unless cat.index(choice)\n cust << choice\n write_custom_cats(cust)\n end\nend", "def login_menu_display\n puts \"Welcome to Ticket Search app!\"\n login_choice = @prompt.select(\"What would you like to do?\", [\"Create Account\", \"Login\", \"Exit\"])\n case login_choice\n when \"Create Account\"\n user_create\n system \"clear\"\n when \"Login\"\n account_login\n system \"clear\"\n when \"Exit\"\n exit\n end\n end", "def main_menu(user)\n user = user\n self.clear\n Ascii.image\n menu = [\"See all my plants\",\"Add new plant\",\"Delete my account\",\"Quit\"]\n menu_selection = @@prompt.select(\"What would you like to do?\",menu)\n \n case menu_selection\n when \"See all my plants\"\n my_plant(user)\n when \"Add new plant\"\n add_plant(user)\n when \"Delete my account\"\n answer = @@prompt.yes?(\"Are you sure?\")\n answer == true ? user.destroy : self.main_menu(user)\n when \"Quit\"\n index = 0\n # binding.pry\n color = [\"#7FFF00\",\"#6B8E23\",\"#008000\",\"#2F4F4F\",\"#00008B\"]\n 5.times do\n self.clear\n # binding.pry\n puts Paint[Ascii.goodbye, color[index]] \n index += 1\n sleep(0.7)\n end \n end\n end", "def main_menu\n\tputs \"\\n1 Library\\n2 Staff Members\\n3 Books\\n4 Patrons\\n0 Exit\\n\"\n\tselect = make_selection\n\n\twhile select != \"1\" && select != \"2\" && select != \"3\" && select != \"4\" && select != \"0\"\n\t\tputs \"\\nInvalid choice selected\\n\"\t\t \t\t\n\t\tselect = make_selection\n\tend\n\n\tif select == \"1\"\n\t\tlibrary_choice = \"9\"\n\t\twhile library_choice != \"0\"\n\t\t\tlibrary_choice = select_choice_library\n\t\tend\n\n \telsif select == \"2\"\n\t\tstaff_member_choice = \"9\"\n\t\twhile staff_member_choice != \"0\"\n\t\t\tstaff_member_choice = select_choice_staff_member\n\t\tend\n\n\n\telsif select == \"3\"\n\t\tbook_choice = \"9\"\n\t\twhile book_choice != \"0\"\n\t\t\tbook_choice = select_choice_book\n\t\tend\n\n\n\telsif select == \"4\"\n\t\tpatron_choice = \"9\"\n\t\twhile patron_choice != \"0\"\n\t\t\tpatron_choice = select_choice_patron\n\t\tend\n\n\n\telsif select == \"0\"\n\t\tputs \"\\nGoodbye\"\t\t \t\t\n\tend\n\tselect \nend", "def manage_account_menu\n choice = @prompt.select(\"Please choose from the following options:\") do |menu|\n menu.choice 'Change my name'\n menu.choice 'Change my password'\n menu.choice 'Delete my account'.blue\n menu.choice \"Back to Main Menu\"\n end\n\n if choice == \"Change my name\"\n change_name\n elsif choice == \"Change my password\"\n change_password\n elsif choice == \"Delete my account\".blue\n delete_account\n elsif choice == \"Back to Main Menu\"\n start_menu\n end\nend", "def main_menu\n\tputs \"Welcome to Creighton Bank!\"\n\tputs \"Please make choose an option:\"\n\tputs \"------------------------------\"\n\tputs \"1. Create a new account\"\n\tputs \"2. View Account Information\"\n\tputs \"3. Exit Program\"\n\n\tprint \"Option: \"\n\n\toption = gets.chomp.to_i\n\n\tif option == 1\n\t\t\tcreate_account\n\t\t\tmain_menu\n\telsif option == 2\n\t\t\taccount_menu\n\telsif option == 3\n\t\t\tputs \"Thank you for stopping by!\"\n\telse\n\t\tputs \"Invalid entry! Please choose from the available options!\"\n\t\tmain_menu\n\n\tend\t\nend", "def main_menu\n\tputs \"Welcome to Roy Bank!\"\n\tputs\"Please make a selection:\"\n\tputs \"____________________________\"\n\tputs \"1. Create a new account\"\n\tputs \"2. View Account Information\"\n\tputs \"3. Exit Program\"\n\nprint \"Option: \"\n\noption = gets.chomp.to_i\n\nif option == 1\n\tcreate_account\n\tmain_menu\n\telsif option == 2\n\t\t# some code here\n\t\t#user_login\n\t\taccount_menu\n\telsif option == 3\n\t\tputs \"Thank you for stopping by!\"\n\telse \n\t\tputs \"Invalid entry! Please choose from the available options!\"\n\n\t\tmain_menu\n\n\tend\n\t\t\t\n\t\t\n\n\n\n\nend", "def user_select(items)\n choose do |menu|\n menu.index = :number\n menu.prompt = \"Please Choose One:\"\n menu.select_by = :index_or_name\n items.each do |item|\n menu.choice item.to_sym do |command| \n say \"Using: #{command}\" \n selected = command.to_s\n end\n end\n menu.choice :exit do exit 1 end\n end\n end", "def menu\n puts \"#{dashes}\\n\n Choose from the following options - using the numbers (1-6) as your input:\\n\n - 1 - Create your user profile\n - 2 - Search for doctors by region\n - 3 - Search for doctors by specialty\n - 4 - Search for the doctors the user has visited\n - 5 - Does something else\n - 6 - Quit the application\n \"\n end", "def list_option\n list_politicians\n list_voters\n puts\n puts \"(R)eturn to the main menu?\".center(80).green\n menu_return = gets\n end", "def interface\r\n clear\r\n menu_banner\r\n puts\r\n options = [\r\n { name: 'New Game', value: -> { get_user_selection } },\r\n { name: 'Custom quiz collections', value: -> { custom_collection } },\r\n { name: 'History', value: -> { history_select } },\r\n { name: 'Exit', value: lambda {\r\n clear\r\n exit_banner\r\n exit\r\n } }\r\n ]\r\n option = @prompt.select(\"Please select from the following options.\\n\\n\", options,\r\n help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\", show_help: :always)\r\n end", "def call_option(user_selected)\n case user_selected\n when 1 then add_new_contact\n when 2 then modify_existing_contact\n when 3 then delete_contact\n when 4 then display_all_contacts\n when 5 then search_by_attribute\n when 6 then exit\n end\n end", "def main_menu\n menu_options = [\"Start exploring\", \"Check Inventory\", \"Check Your Score\", \"Go to Pokemon Center\", \"Quit\"]\n menu_prompt = Interactivity.mainMenu \n \n if user.pokemon == nil\n menu_options.shift()\n menu_options.unshift(\"Choose a Pokemon and start exploring\")\n elsif self.user_current_location\n menu_options.shift()\n menu_options.unshift(\"Keep Exploring\")\n end\n \n choice = prompt.select(menu_prompt, menu_options) \n if choice == \"Start exploring\" || choice == \"Choose a Pokemon and start exploring\" || choice == \"Keep Exploring\"\n self.trainer_chooses_pokemon if user.pokemon == nil \n self.trainer_chooses_town\n self.exploring_town\n elsif choice == \"Check Inventory\"\n puts \"MANAGE INVENTORY - CHANGE POKEMONS AROUND\"\n elsif choice == \"Go to Pokemon Center\"\n self.pokemon_center\n elsif choice == \"Check Your Score\"\n puts \"CHECK YOUR SCORE\"\n else\n Interactivity.quit\n end\n end", "def main_menu\n options = [\"View recipe book\", \"Search by ingredient\", \"Quit app\"]\n answer = @prompt.select(\"Choose an option:\".colorize(:color => :blue), (options))\n if answer == options[0]\n select_recipe_from_book(@user.view_recipe_book)\n elsif answer == options[1]\n find_recipe\n elsif answer == options[2]\n puts ''\n puts \"Thanks for using Feed. See you next time!\".colorize(:color => :blue)\n system exit\n end\nend", "def main_menu\n while true\n print_main_menu\n user_selected = gets.chomp.to_s\n call_option(user_selected)\n end\n end", "def main_menu\n menu = [\n \"My Stats\",\n \"My Hikes\",\n \"Trails\",\n \"Quit\"]\n choice = nil\n while choice != \"Quit\"\n system 'clear'\n puts \"------MAIN MENU------\"\n choice = @prompt.select(\"What would you like to do #{@current_user.name}?\", menu)\n\n case choice\n when \"My Stats\"\n user_stats\n when \"My Hikes\"\n hike_options\n when \"Trails\"\n trail_options\n end\n end\n end", "def situation_selection\n $prompt.select(\"Welcome to Ticket Master! What would you like to do?\") do |menu|\n menu.choice 'Sign up'\n menu.choice 'Login'\n menu.choice 'Terminate program'\n end\nend", "def call_option(user_selected) \n\t case user_selected\n\t when 1 then add_new_contact\t\t\n\t when 2 then modify_existing_contact\n\t when 3 then display_one_contact\n\t when 4 then delete_contact\n\t when 5 then display_all_contacts\n\t when 6 then display_by_attribute\n\t when 7\n\t\t\tputs \"Current session ended, goodbye!\"\n\t\t\treturn\n\t\telse\n\t\t\tputs \"Invalid Option, try again.\"\n\t\t\treturn\n\t\tend\t\n\tend", "def login_menu\n\t\tlogin_display\n option = gets.chomp.downcase\n if option == \"1\" || option == \"1.\" || option == \"new user\"\n get_user_info\n elsif option == \"2\" || option == \"2.\" || option == \"returning user\"\n login\n elsif option == \"3\" || option == \"3.\" || option == \"exit\"\n goodbye\n else\n\t\t\tputs \"Check your input and make sure you are selecting a number. \"\n\t\t\tsleep(2)\n login_menu\n end\n end", "def main_menu\n @active = 0\n @prompt.select(\"\\nWhat would you like to do?\\n\".blue) do |menu|\n menu.choice \"Check out what's on today\", -> {today_menu} \n menu.choice \"Check out things to do on the weekend\", -> {weekend_menu}\n menu.choice \"Look at my favourites\", -> {display_favorites}\n menu.choice \"Exit\".red, -> {leave_app} \n end \n end", "def init_menu\n @menus.set_selected(\"teambox\")\n @menus.set_selected(\"licenses\")\n end", "def main_menu(owner_name, owner)\n puts \"#{page_break}\\n\n Select from the following menu options to get started:\\n\n 1 - Make New Appointent\n 2 - Reschedule Appointment\n 3 - Cancel Appointment\n 4 - Search for a Groomer\n 5 - Exit\n \"\n end", "def main_menu\n while true\n print_main_menu\n user_selected =gets.to_i\n call_option(user_selected)\n end\n end", "def main_menu(current_user)\n puts \"*****************************************************\"\n puts \"What would you like to choose?\"\n puts \" \"\n puts \"1. Make appointment\"\n puts \"2. My appointments\"\n puts \"3. Change user\"\n puts \"4. Exit\"\n\n input = gets.chomp\n case input\n when \"1\"\n stylists_menu(current_user)\n when \"2\"\n my_appointments_menu(current_user)\n when \"3\"\n puts \"Enter new username\"\n username = gets.chomp\n current_user = User.find_or_create_by(name: username)\n main_menu(current_user)\n when \"4\"\n close_app\n\n else\n puts \"Please choose numbers 1 to 3\"\n main_menu(current_user)\n end\nend", "def main_menu(user)\n calories = Calories.new\n loop do\n calories.calorie_intake(user)\n case Prompts.main_selection\n when '1'\n calories.log_daily_meals\n when '2'\n calories.log_daily_intake\n when '3'\n Details.update_weight(user)\n when '4'\n Quotes.inspirational\n when '5'\n quit\n end\n end\n end", "def menu_choice\n user_input = gets.chomp\n case user_input\n when \"1\"\n # Call function to show all of the doctors by region\n\n # show_all_doctors_by_region\n\n show_all_article_by_with_authors\n return_to_menu\n when \"2\"\n # Call function to show all of the doctors by specialties\n show_all_article_titles_with_content\n return_to_menu\n when \"3\"\n # Call function to show all of the doctors a user has visited\n show_all_authors\n return_to_menu\n when \"4\"\n puts Rainbow(\"Here are all the authors to choose from:\\n\").white.bright\n show_all_authors\n puts Rainbow(\"\\nPlease provide an author name:\").white.bright\n author = gets.chomp\n find_article_titles_by_author(author)\n show_full_list_of_articles(author)\n return_to_menu\n when \"5\"\n show_latest_article\n return_to_menu\n when \"6\"\n quit\n else\n puts Rainbow(\"Invalid option. Please select a number between 1 and 6.\").white.bright\n menu\n menu_choice\n end\n end", "def start_menu\n printf \"\\nPrograma para a disciplina de LPD\\n\"\n printf \"Choose one option\\n\"\n printf \"------------------------------------\\n\"\n printf \"1) Insert user\\n\"\n printf \"2) Login user\\n\"\n printf \"3) Delete user\\n\"\n printf \"0) Exit\\n\"\nend", "def op_menu\n loop do\n case Prompts.op_selection\n when '1'\n user = User.new_user_input\n main_menu(user)\n when '2'\n User.user_login\n when '3'\n quit\n end\n end\n end", "def main_menu\n choice = self.prompt.select(\"Hi there, #{self.user.name}! What would you like to do today?\", [\"Create a new post\", \"Find a book\", \"View or edit my posts\", \"Delete my account\", \"Logout\"])\n\n case choice\n when \"Create a new post\"\n self.new_post\n when \"Find a book\"\n self.find_book\n when \"View or edit my posts\"\n self.view_edit_posts\n when \"Delete my account\"\n self.delete_account\n when \"Logout\"\n self.spinner(\" ✌️✌️✌️ \")\n self.greet\n end\n end", "def main_menu_prompt\n welcome\n menu = [\n { name: \"View list of Recipes\", value: 1},\n { name: \"Input a new recipe into the recipe book\", value: 2},\n { name: \"Edit a recipe from the recipe book\", value: 3},\n { name: \"Display Help information\", value: 4},\n { name: \"Exit\", value: 5}\n ]\nmm_choice = $prompt.select(\"Please select an option\", menu)\nreturn mm_choice\nend", "def check_main_menu_choice(given_choice)\n if given_choice == \"First Time User, Want To Register\"\n choice = 1\n end\n if given_choice == \"Already A Registered User, Want To Login\"\n choice = 2\n end\n if given_choice == \"Do Not Wish To Register, Just Browsing\"\n choice = 3\n end\n if given_choice == \"Looking For Info About The App\"\n choice = 4\n end\n if given_choice == \"Nothing Really, Spare Me Your @?%#&?|%!\"\n choice = 5\n end\n choice\nend", "def main_menu\n \twhile true\n \t\tprint_main_menu\n\n \t\tprint \"Choose an option:\"\n \t\tuser_input = gets.chomp.to_i\n\n \t\tbreak if user_input == 7\n \t\t\n choose_option(user_input)\n \tend\n end", "def home_chooser(current_user)\n if(current_user.nil?) then\n link_to \"Home\",root_url\n else\n if(current_user.role==\"admin\") then\n link_to \"Home\",user_admin_path(:user_id=>current_user.id,:id=>current_user.admin.id)\n elsif(current_user.role==\"company\") then\n if(current_user.company.nil?) then\n link_to \"Home\",new_user_company_path(:user_id=>current_user.id)\n else\n link_to \"Home\",user_company_path(:user_id=>current_user.id,:id=>current_user.company.id)\n end\n else\n if(current_user.applicant.nil?)then\n link_to \"Home\",new_user_applicant_path(:user_id=>current_user.id) \n else\n link_to \"Home\",user_applicant_path(:user_id=>current_user.id,:id=>current_user.applicant.id) \n end\n end\n end\n end", "def assignee_menu( mt_req, building, tag_name = \"mtreq_assignee\" )\n # build the array from which we will build the select\n arr = [];\n if building!=nil && building.has_mt_company?\n \n if building.has_mt_manager?\n arr << [ \"#{building.mt_manager.hr_name} (#{ loc.term(Localization::BUILDING_MANAGER)})\",\n unique_obj_id(building.mt_manager) ];\n else\n #arr << [ \"mt_building_manager == nil\", \"xxx\"];\n end\n \n building.mt_company.workers.each do | wkr | \n if ( wkr.role.professional? )\n arr << [ \"#{wkr.role.name} (#{wkr.hr_name})\", unique_obj_id(wkr) ];\n end\n end\n \n arr << [ \"#{building.mt_company.name} (#{loc.term(Localization::MT_COMPANY)})\", \n unique_obj_id(building.mt_company) ];\n else\n if mt_req.has_mt_company?\n mt_req.mt_company.workers.each do | wkr | \n if ( wkr.role.professional? )\n arr << [ \"#{wkr.role.name} (#{wkr.hr_name})\", unique_obj_id(wkr) ];\n end\n end \n end \n end\n \n if building.respond_to?(:has_owner) && building.has_owner?\n arr << [ \"#{building.building_owner} (#{loc.term(Localization::BUILDING_OWNER)})\",\n unique_obj_id(building.building_owner) ];\n end\n \n # TODO add vaad.\n \n selected_id = \"\";\n selected_id = unique_obj_id(mt_req.assignee) unless mt_req.nil?\n \n return \"<select id='#{tag_name.gsub(\"[\",\"_\").gsub(\"]\",\"\")}' name='#{tag_name}'>\n #{options_for_select(arr, selected_id)}\n </select>\"; \n end", "def main_menu_selection\n puts \"\"\n PROMPT.select(\"What would you like to do?\") do |menu|\n menu.choice \"Download this week's quiz\", 1\n menu.choice \"Download last week's quiz\", 2\n menu.choice \"Exit app\", 3\n end\n end", "def menu\n\n puts \"________________\"\n\n puts \"insert the user name to continue\"\n @user_name = gets.chomp\n response = User.find_by(user_name: @user_name)\n\n puts \"________________\"\n\n if response\n \n mainscreen\n else\n puts \"try again\"\n menu\n end\n end", "def login_page\n prompt.select(\"Login or Sign up\") do |menu|\n menu.choice \"Login\", -> {login_helper}\n menu.choice \"Sign up\", -> {sign_up_helper}\n menu.choice \"Exit\", -> {exit_helper}\n end\n end", "def main_menu\n\t\twhile true\n\t\t\tprint_main_menu\n\t\t\tuser_selected = gets.chomp.to_i\n\t\t\t\tif user_selected == 7\n\t\t\t\tputs \"Current session ended, goodbye!\"\n\t\t\t\treturn\n\t\t\tend\n\t\t\tcall_option(user_selected)\n\t\tend\n\tend", "def selection_menu\n h = {\n a: :select_all,\n u: :unselect_all,\n s: :toggle_select,\n '*' => 'toggle_multiple_selection',\n 'x' => 'toggle_visual_mode',\n 'm' => 'toggle_selection_mode',\n v: :view_selected_files\n }\n menu 'Selection Menu', h\nend", "def wiki_menu_select\n wiki_menu\n prompt = TTY::Prompt.new\n menu_choices = [\n \" [1] Search by Character\",\n \" [2] Search by House\",\n \" [3] Main Menu\",\n \" [4] Exit App\"\n ]\n prompt.select(\" \", menu_choices)\nend", "def main_menu\n prompt = TTY::Prompt.new(active_color: :blue)\n response = prompt.select(\"CTT-Lite\", available_options)\n system \"clear\"\n handle_main_menu(response)\n end", "def selection(input, user)\n case input\n when 1\n get_number_of_random_recipes(user)\n when 2\n recipe_hash = run_option_find_recipe_by_name\n run_sub_menu_option(user, recipe_hash)\n when 3\n run_option_create(user)\n when 4\n run_option_view_favs(user)\n end\n end", "def menu_rainfall\r\n clear\r\n puts \"Please select from the following options: \"\r\n puts\r\n puts \"1. View rainfall details\"\r\n puts \"2. Add rainfall details\"\r\n # puts \"3. Delete rainfall details\"\r\n puts\r\n puts \"x. to exit \"\r\n menuoption = $stdin.gets.chomp.upcase\r\n return menuoption\r\nend", "def display_menu\n system('clear')\n arr = ['My List', 'Recommendations', 'Playlist', 'Account Details', 'Exit']\n @prompt.select(\"》 MAIN MENU 《\\n\".colorize(:light_green), arr)\n end", "def get_user_selection\r\n clear\r\n test_banner\r\n puts\r\n puts \"---------- User selection----------\\n\\n\"\r\n # First get the name to represent the user\r\n user_name = @prompt.ask(\"Hello, visitor! Can I have you name please?\\n\\n\") do |input|\r\n input.required true\r\n input.validate(/\\A\\w+\\Z/)\r\n input.modify :capitalize\r\n input.messages[:valid?] =\r\n 'My dear friend, only letters, numbers and underscore are allowed. Please try again.'\r\n end\r\n clear\r\n test_banner\r\n puts\r\n # Get the time attribute from the test model\r\n level_selections = [\r\n { name: 'Easy: 16s', value: lambda {\r\n @test.time_level[:Easy]\r\n } },\r\n { name: 'Normal: 12s', value: lambda {\r\n @test.time_level[:Normal]\r\n } },\r\n { name: 'Hard: 8s', value: lambda {\r\n @test.time_level[:Hard]\r\n } },\r\n { name: 'I want to change my name. Please let me go back', value: lambda {\r\n interface\r\n } }\r\n ]\r\n selection = @prompt.select(\r\n \"Please select one time mode for answering each question in a quiz.\\nIf you can not selection a option in the limited time\\nIt will be considered as false amswer\".colorize(:light_magenta), level_selections, help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\", show_help: :always, per_page: 5\r\n )\r\n\r\n clear\r\n test_banner\r\n puts\r\n # Choose default or custom collections\r\n test_collections = [\r\n { name: 'Default collections', value: lambda {\r\n pick_collection('Default', user_name, selection)\r\n } },\r\n { name: 'Custom collections', value: lambda {\r\n pick_collection('Custom', user_name, selection)\r\n } },\r\n { name: 'I want to change the time setting. Please let me go back to main menu', value: lambda {\r\n interface\r\n } }\r\n ]\r\n test_collection = @prompt.select('Please select one group of collecctions', test_collections,\r\n help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\", show_help: :always, per_page: 3)\r\n end", "def main_menu\n\tputs \"Welcome to Happitails!\"\n\tputs \"Please choose from the options below\"\n\tputs \"1. Add Animal\"\n\tputs \"2. Create Client\"\n\tputs \"3. Adopt an animal\"\n\tputs \"4. Put animal up for adoption\"\n\tputs \"5. View all animals\"\n\tputs \"6. View all clients\"\n\n\n\t# puts \"Z. SECRET DEBUGGING MODE\"\n\n\tputs \"q. Quit\"\nend", "def main_menu\n puts\n puts \"What would you like to do? Please enter a number:\".colorize(:green)\n puts \"---------------------\"\n puts \"1. Search Developer Jobs\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n puts \"2. See Saved Jobs\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n puts \"3. Apply From Saved Jobs\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n puts \"4. Have You Moved? Update Location Here\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n puts \"5. Sign Out\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n puts \"6. Exit Program\".colorize(:color => :blue, :background => :white)\n puts \"---------------------\"\n main_menu_response = gets.chomp.downcase\n if main_menu_response == \"1\"\n search_jobs\n elsif main_menu_response == \"2\"\n saved_jobs\n elsif main_menu_response == \"3\"\n apply_job\n elsif main_menu_response == \"4\"\n update_location\n elsif main_menu_response == \"5\"\n @@user_id = nil\n puts \"Signing out\".colorize(:color => :blue, :background => :white)\n sleep(1)\n welcome\n elsif main_menu_response == \"6\"\n exit\n else\n invalid_response\n main_menu\n end\n end", "def user_settings\n\n prompt.select (\"Choose an option\") do |menu|\n menu.choice \"Delete account\", -> {\n answer = prompt.yes? (\"Are you sure?\")\n if answer \n User.find(user_id).delete_account \n user_id = nil \n welcome\n else\n puts \"Glad you're staying\" \n user_settings\n end\n }\n\n menu.choice \"Change Password\\n\", -> {\n\n password = prompt.mask(\"Enter your current password:\")\n while User.find(user_id).password != password\n puts \"Invalid password - please try again.\"\n password = prompt.mask(\"Enter your current password:\")\n end\n\n password = prompt.mask(\"Choose a new password over 5 characters.\")\n while password.length < 5\n puts \"Password too short - must be over 5 characters long\"\n password = prompt.mask(\"Choose a new password over 5 characters.\")\n end\n\n User.find(user_id).change_password(password)\n user_settings\n }\n\n menu.choice \"Return to threads\", -> {show_threads}\n end \n\n end", "def select(option)\n\t\tcase option \n\t\twhen \"1\" then login\n\t\twhen \"2\" then register\n\t\twhen \"3\" then exit\n\t\tend\n\tend", "def display_main_menu_choice\n #The disabled choice will be displayed with a cross ✘ character next to it and followed by an explanation:\n menu_choices = [\n 'First Time User, Want To Register',\n 'Already A Registered User, Want To Login',\n # { name: 'Goro', disabled: '(injury)' },\n 'Do Not Wish To Register, Just Browsing',\n 'Looking For Info About The App',\n 'Nothing Really, Spare Me Your @?%#&?|%!'\n ]\n choice_msg = 'What Will It Be, We Offer A Great Many Choices!'\n # system \"say #{choice_msg}\"\n main_menu_choice = prompt.select('What Will It Be, We Offer A Great Many Choices!'.colorize(:color => :light_blue), menu_choices)\nend", "def display_guest_options_menu\n prompt = TTY::Prompt.new\n display_options_menu = prompt.select('Please select an option:') do |menu| \n menu.choice 'Search'\n menu.choice 'Favourites'\n menu.choice 'Help'\n menu.choice 'Exit'\n end\nend", "def select_user(workspace)\n print \"Enter user id or name: \"\n choice = gets.chomp\n begin\n workspace.select_user(choice)\n rescue => exception\n puts \"Error: #{exception.message}\"\n end\nend", "def menu\n selection = gets.chomp.to_i\n case selection\n when 1\n all_tickets = Tickets.new(@zendesk_tickets)\n all_tickets.view_all\n when 2\n single_ticket = Ticket.new(@zendesk_tickets)\n single_ticket.view_all\n when 3\n system 'clear'\n puts \"Goodbye!\"\n exit\n else\n system 'clear'\n puts \"Invalid choice, select between 1, 2 or 3\"\n welcome_message \n menu\n end\n end", "def user_selector(users, selected_user)\n user_chooser_html = \"<label>Select team:</label>&nbsp&nbsp\n <select class='input-large' id='user_chooser'>\"\n users.each { |user|\n user_chooser_html << \"<option value=\" + user.id.to_s\n user_chooser_html << \" selected\" if user.id == selected_user.id\n user_chooser_html << \">\" + user.full_name + \"</option>\"\n }\n user_chooser_html << \"</select>\"\n return user_chooser_html.html_safe\n end", "def menu\n\toption = gets.chomp.downcase\nend", "def list_all_users(menu)\n system('clear')\n puts \"All users currently in the system:\"\n puts \"==================================\"\n puts User.pluck(:name)\n puts\n puts \"Press enter to return to main menu.\"\n STDIN.gets.chomp\n if menu == \"user_select_menu\"\n self.welcome_message\n elsif menu == \"main_menu\"\n @menu_message = nil\n self.main_menu\n end\nend", "def main_menu\n\n\tif @count < 3\n\n\tputs \"Welcome to The Bank\"\n\tputs \"Please select action from the following menu options:\"\n\tputs \"-----------------------------------------------------\"\n\tputs \"1. Add an account\"\n\tputs \"2. View existing acocunt\"\n\tputs \"3. Exit Menu\"\n\n\n\toption = gets.chomp.to_i # User Choice\n\tif option == 1 \n\t\t@count = 0 #resetting the count\n\t\tadd_account #calling the method\n\telsif option == 2\n\t\t@count = 0 #resetting the count\n\t\tview_account #calling \n\telsif option == 3\n\t\tputs \"Thank you for visiting The Bank\"\n\t\texit\n\telse\n\t\t\tif @account != (1..3)\n\t\t\t\tputs \"invalid selection. Try Again.\"\n\t\t\tend\n\t\t\t@count += 1\n\t\t\tmain_menu\n\t\tend\n\n\telse \n\t\tputs \"You seem to be having trouble. Contact Customer Service.\"\n\t\texit\n\tend\n\nend", "def user_company\n if Client.find_by_id(current_user.client_id)\n Client.find_by_id(current_user.client_id).client_name\n end\n end", "def display_menu\n puts \"Choose from the following options: \\n\n to find a candidate, type 'find id' (ex. find 1)\n to view all candidates, type 'all'\n to view all qualified candidates, type 'qualified'\n to exit, type 'quit' \n to view menu, type 'menu' \\n\\n\"\nend", "def main_menu\n @@prompt.select(\"What would you like to do today?\".colorize(:yellow)) do |menu|\n menu.choice \"Read Reviews\", -> {self.read_reviews}\n menu.choice \"Write a review\", -> { self.writing }\n menu.choice \"Update a review\", -> { self.update_reviews }\n menu.choice \"Delete a review\", -> { self.deleting }\n menu.choice \"Log Out\", -> { self.log_out }\n end\n end", "def handle_menu\n values = {\n \"change_pw_url\" => url(:handle_change_pw),\n \"update_det_url\" => url(:handle_update_details)\n }\n standard_page(\"Maintain My Account\",\n values,\n Login::UPDATE_MENU)\n end", "def menu_selection \nend", "def menu\n puts `clear`\n puts Rainbow(\"Welcome to the Happitails Database\\n\\n\").blue\n print 'Choose: (L)ists, (A)nimal Management, (C)lient Management or (Q)uit. '\n gets.chomp.downcase\nend", "def main_menu\n main_menu_options = {'Interact with Existing Kits' => :list_and_select_kit,\n 'Create a new Kit' => :prompt_kit_params, \n 'Quit' => :quit}\n \n op = @io.select_from_options(\"What would you like to do?\", main_menu_options)\n @operation_stack.unshift op\n \n # return nil, because there's nothing to pass onto the next method\n return\n end", "def login_choice\n end", "def welcome\n self.user_id = nil\n prompt.select(\"\\nWelcome to the Forum! Choose an action - \\n (Press Esc at any time to return to this menu!\") do |menu|\n menu.choice \"Login\", -> {login}\n menu.choice \"Create Account\", -> {account_creation}\n menu.choice \"Browse as a Guest\", -> {\n user_id = nil\n show_threads\n }\n menu.choice \"Exit\", -> {exit}\n end\n \n end", "def display_options_menu\n prompt = TTY::Prompt.new\n display_options_menu = prompt.select('Please select an option:') do |menu| \n menu.choice 'Add Code'\n menu.choice 'Edit Code'\n menu.choice 'Remove Code'\n menu.choice 'Search'\n menu.choice 'Help'\n menu.choice 'Exit'\n end\nend", "def present_menu_options\n space(1)\n puts \"Choose an option from the list below.\"\n space(1)\n puts '1. Search for events by city'\n puts '2. Search for events by artist or sports team'\n puts '3. See what I have coming up'\n puts '4. Delete my account'\n puts '5. Exit'\n space(1)\n pick_option\nend", "def items_menu_prompt(**)\n 'Select an EMMA user account' # TODO: I18n\n end", "def main_menu\n puts \"\"\n puts \"-----------------------------------------------\"\n puts \"\"\n puts \"Please select an option:\"\n puts \"\"\n puts \"Enter 'list' for a list characters, 'quote' for a random Stan Lee quote, or 'exit' to bid farewell.\"\n puts \"\"\n input = user_input\n\n if input == 'list'\n list_characters\n elsif input == 'quote'\n stan_lee_quote\n elsif input == 'exit'\n goodbye\n elsif input != 'list' || input != 'exit' # had to add \"input !=\" each time to avoid the string literal warning\n invalid_input\n main_menu\n end\n \n end", "def select_choice_staff_member\n\tputs \"\\n1 Add a Staff Member\\n2 Information on a Staff Member\\n3 Edit a Staff Member\\n4 Remove a Staff Member\\n5 View All Staff Members\\n6 Reassign a Staff Member to a Different Branch\\n0 Return to Main Menu\"\n\tselect = make_selection\n\n\twhile select != \"1\" && select != \"2\" && select != \"3\" && select != \"4\" && select != \"5\" && select != \"6\" && select != \"0\"\n\t\tputs \"\\nInvalid choice selected\\n\"\t\t \t\t\n\t\tselect = make_selection\n\tend\n\n\tif select == \"1\"\n\t\tadd_staff_member\n\n\telsif select == \"2\"\n\t\tputs \"\\nTo get information about a staff member please enter their ID #\\n\"\n\t\tshow_all_staff_members\n\t\tselect = make_selection.to_i\n\t\tselect = verify_staff_member_exists(select)\n\t\tdisplay_staff_member(select)\n\n\telsif select == \"3\"\n\t\tputs \"\\nTo edit a please enter their ID #\\n\"\n\t\tshow_all_staff_members\n\t\tselect = make_selection.to_i\n\t\tselect = verify_staff_member_exists(select)\n\t\tedit_staff_member(select)\n\n\telsif select == \"4\"\n\t\tputs \"\\nTo remove a staff member please enter their ID #\\n\"\n\t\tshow_all_staff_members\n\t\tselect = make_selection.to_i\n\t\tselect = verify_staff_member_exists(select)\n\t\tremove_staff_member(select)\n\n\telsif select == \"5\"\n\t\tshow_all_staff_members\n\n\telsif select == \"6\"\n\t\tputs \"\\nTo reassign an employee to a different branch please enter their ID #\\n\"\n\t\tshow_all_staff_members\n\t\tselect = make_selection.to_i\n\t\tselect = verify_staff_member_exists(select)\n\t\treassign_staff_member(select)\n\n\n\telsif select == \"0\"\n\t\tputs \"\\nNow entering main menu\\n\"\n\n\tend\n\tselect\t\t\nend", "def student_main_menu(student_user) \n self.line_break\n puts \"Please select a command:\".colorize(:light_blue), \"1: Return to Main Menu\".colorize(:cyan), \"2: Exit\".colorize(:cyan)\n self.line_break\n input = gets.chomp\n until input == \"1\" || input == \"2\"\n puts \"Invalid response. Please select a command:\".colorize(:yellow), \"1: Return to Main Menu\".colorize(:cyan), \"2: Exit\".colorize(:cyan) \n input = gets.chomp\n end\n if input == \"1\"\n self.student_tasks(student_user)\n elsif input == \"2\"\n puts \"Have a great day!\".colorize(:light_green)\n end\n end", "def tableau_menu\n player_name_list = @mk.players.collect { |p| p.name }\n @@cli.choose do |menu|\n menu.prompt = \"Whose situation do you want information on? \"\n menu.choices(*player_name_list) do |chosen|\n @@cli.say \"You have chosen <%= color('#{chosen}', BOLD) %>. \"\n @mk.players.find { |p| p.name==chosen }.tableau.console_output\n end\n menu.choice(:none) { @@cli.say \"OK, leaving tableau menu\"}\n end\n end", "def menu\n\tputs \"Select an option: \\n\n\t1. Create new contact \\n\n\t2. Search \\n\n\t3. Quit \\n\"\n\treturn gets.chomp\nend", "def reporthelp_user_selection( form, users )\n if ( users.empty? )\n return ''\n else\n return apphelp_collection_select(\n form,\n 'reportable_user_ids',\n users,\n :id,\n :name\n )\n end\n end", "def select_option\n return $prompt.select(\"What's your option?\",\n [\"Ladder\", \"Team's info\", \"Play a game!\", \"Training\", \"Exit\"])\n \nend", "def items_menu_prompt(user: nil, **)\n case user\n when nil, :all then 'Select an existing manifest' # TODO: I18n\n else 'Select a manifest you created' # TODO: I18n\n end\n end", "def user_profile \n system 'clear'\n CoffeeMan.stay_logo\n choice = @prompt.select(\"~P R O F I L E~\") do |menu|\n puts \"HELLO #{@userid.username}\".colorize(:light_blue)\n menu.choice \"Update Username\", -> {change_username}\n menu.choice \"Update Password\", -> {change_password}\n menu.choice \"Delete Account\", -> {delete_profile}\n menu.choice \"Back\", -> {main_menu}\n end\n sleep 1\n end", "def menu_list \n puts \"Please select from the following options: \"\n puts \" Enter '1' to create a new donation!\"\n puts \" Enter '2' to see a list of the organizations accepting donations\"\n puts \" Enter 'exit' if you changed your mind and wish to leave the app\"\n puts \" To see the menu options again, please enter 'menu'\"\nend", "def get_user_input\n puts \"\\n\\nMAIN MENU - please select from the following\"\n\n OPTIONS.each do |option|\n puts option.join(\" \")\n end\n \n print \"\\nWhat would you like to do? > \"\n choice = gets.strip.downcase\n return choice\nend", "def user_choice_of_object_in_class(class_object)\n create_menu = Menu.new(\"Which #{class_object.name} do you want to look up?\")\n all = class_object.all\n all.each_with_index do |object, x|\n create_menu.add_menu_item({key_user_returns: x + 1, user_message: object.to_s, do_if_chosen: \n [object]})\n end\n return run_menu(create_menu)[0]\n end", "def employee_menu\n header(\"employee functions\")\n puts\n\n #TTY::Prompt keypress method constantly monitors keyboard for input\n @prompt = TTY::Prompt.new\n\n puts \"1) view the employee roster\"\n puts\n puts \"2) add employee\"\n puts\n puts \"3) update employee details\"\n puts\n puts \"4) delete employee\"\n puts\n puts \"5) return to main menu\"\n puts\n\n selection = @prompt.keypress(\"Please make your selection:\").to_i\n case selection\n when 1\n view_employee_roster\n system \"clear\"\n employee_menu\n when 2\n add_employee\n system 'clear'\n employee_menu\n when 3\n view_employee_roster\n update_employee\n system 'clear'\n employee_menu\n when 4\n view_employee_roster\n delete_employee\n system 'clear'\n employee_menu\n when 5\n system \"clear\"\n main_menu\n else\n error\n press_any_key\n end\n end", "def show_menu\n\n menu_pick = @prompt.select('Please select a menu option: ') do |menu|\n menu.choice 'Show Events by Country', 'find by country'\n menu.choice 'Show Events by City', 'find by city'\n menu.choice 'Show Events By Date', 'find by date'\n menu.choice 'Get Event Info By Name', 'find by name'\n menu.choice 'Exit', 'exit'\n end\n\n return menu_pick if menu_pick == 'exit'\n\n event = handle_input(menu_pick)\n\n display_info(event) if event\n\n end", "def list_stock_search_menu\n choice_num = 1\n puts_blanks\n puts \"::: #{@company_name} STOCK MENU :::\".colorize( :blue )\n blank\n puts \"What would you like to view about #{@company_name}?\"\n blank\n @@company_choices.each do |choice|\n puts \"[#{choice_num}] #{choice[:title]}\"\n choice_num += 1\n end\n\n puts \"[a] to run all\"\n puts \"[x] Exit Program\"\n end", "def menu\n input = gets.strip.downcase\n \n if input == \"hungry\"\n cuisine_list\n menu # return 'menu' don't want my user to get kicked out of application \n elsif input == \"goodbye\"\n goodbye\n else \n invalid_entry\n end \n end", "def run\n welcome\n main_menu_selection #choose to create a character or login to pre-existing character\n player_options #a list of options the selected player from 'selection_menu' can accomplish\nend", "def call_option(selected)\n case selected\n when 1\n Contact.add_contact\n when 2\n Contact.modify\n when 3\n Contact.delete_versions\n when 4\n Contact.display_contacts\n when 5\n Contact.search_by_attribute\n when 6\n puts \"Bye bye Sasha...\"\n exit\n end\n\n end", "def main_selector\n print \"What would you like to do? Create, List, Update, or Vote: \"\n main_decision = gets.chomp.downcase\n main_decision = main_decision[0]\n case main_decision\n when \"c\"\n create_person_or_politician\n when \"l\"\n list_characters_created\n when \"u\"\n update_character\n when \"v\"\n vote\n else\n puts \"That is not a valid entry please try again!\"\n main_selector\n end\n end", "def show_menu\n clear_screen\n\n puts \"[+] #{FreelancerFinder::Job.all.count} Jobs Scraped [+]\".magenta\n puts \"_____________________________________________________________\"\n return @prompt.select(\"Please Select a Menu Option: \") do |menu|\n menu.choice \"show recent\"\n menu.choice \"scrape more\"\n menu.choice \"search\"\n menu.choice \"search by pay\"\n if @last_results\n menu.choice \"results\"\n end\n menu.choice \"exit\"\n end\n\n end" ]
[ "0.6683829", "0.6619521", "0.6475951", "0.6423823", "0.6411169", "0.6322222", "0.62314653", "0.6187118", "0.61712605", "0.61637294", "0.61376595", "0.61367303", "0.6131876", "0.6098732", "0.60840327", "0.6078142", "0.60523623", "0.60432315", "0.6037656", "0.6008937", "0.60054475", "0.5993402", "0.5974598", "0.59739953", "0.5950605", "0.5948568", "0.5945941", "0.5924916", "0.5916125", "0.59157085", "0.5910135", "0.5890032", "0.58884", "0.5882642", "0.58782786", "0.58765376", "0.5874145", "0.58701026", "0.58597904", "0.585008", "0.5831924", "0.5823976", "0.57942164", "0.579143", "0.57734686", "0.57733923", "0.5767989", "0.57505405", "0.57485926", "0.5748105", "0.574098", "0.57315975", "0.57301843", "0.5718263", "0.56891656", "0.5687071", "0.56823766", "0.56808615", "0.56735903", "0.56728786", "0.5667139", "0.5661744", "0.565206", "0.56505203", "0.5648211", "0.5641485", "0.5639846", "0.5638578", "0.56369036", "0.5628445", "0.5627552", "0.562299", "0.5618296", "0.5613905", "0.55971533", "0.5585356", "0.5581659", "0.5575896", "0.5571551", "0.5568847", "0.5547913", "0.5547115", "0.5535703", "0.553469", "0.5532075", "0.55249906", "0.55230176", "0.5509729", "0.5506863", "0.55065906", "0.5505051", "0.5480974", "0.54796356", "0.5475569", "0.5472711", "0.54678035", "0.5465815", "0.54576457", "0.5441109", "0.5438203" ]
0.6884344
0