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 |
|---|---|---|---|---|---|---|
Post method which accepts form parameters from postcode lookup and redirects to constituency_path.
|
def postcode_lookup
flash[:postcode] = params[:postcode]
redirect_to constituency_path(params[:constituency_id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def post\n\t redirect_to search_path( query: params[:query] )\n\tend",
"def create\n @post_code = PostCode.new(post_code_params)\n\n respond_to do |format|\n if @post_code.save\n format.html { redirect_to @post_code, notice: 'Post code was successfully created.' }\n format.json { render :show, status: :created, location: @post_code }\n else\n format.html { render :new }\n format.json { render json: @post_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @postcode = Postcode.new(params[:postcode])\n\n respond_to do |format|\n if @postcode.save\n format.html { redirect_to admin_postcode_url, notice: 'Postcode was successfully created.' }\n format.json { render json: admin_postcode_url, status: :created, location: postcodes_url }\n else\n format.html { render action: \"new\" }\n format.json { render json: @postcode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def employee_post\n if params[\"new\"] \n redirect_to \"/employee/new\" and return\n else\n redirect_to \"/employee/#{params[\"edit\"]}\" and return\n end\n end",
"def create\n #Create a mutable copy of the params\n dnc_contents=dnc_params\n #Delete params that are only passed as flags\n #A DNC will not save correctly if these params are passed to the DNC itself\n dnc_contents.delete(\"terrtype\")\n dnc_contents.delete(\"redirid\")\n @dnc = Dnc.new(dnc_contents)\n\n respond_to do |format|\n if @dnc.save\n if dnc_params[\"terrtype\"]\n #Terrtype is passed when creating from a territory listing\n #This section is to redirect back to that listing instead of to the DNC\n format.html { redirect_to \"/#{dnc_params[\"terrtype\"]}/#{dnc_params[\"redirid\"]}\", notice: 'DNC was successfully created.' }\n format.json { render :show, status: :ok, location: @dnc }\n else\n format.html { redirect_to @dnc, notice: 'DNC was successfully created.' }\n format.json { render :show, status: :ok, location: @dnc }\n end\n else\n format.html { render :new }\n format.json { render json: @dnc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_req\n redirect_to :controller => :listings, :action => :index\n end",
"def create\n @post_code = PostCode.new(params[:post_code])\n @towns = Town.find :all \n @geo_positions = GeoPosition.find :all\n \n respond_to do |format|\n if @post_code.save\n flash[:notice] = 'PostCode was successfully created.'\n format.html { redirect_to(@post_code) }\n format.xml { render :xml => @post_code, :status => :created, :location => @post_code }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @post_code.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n # create new address\n @new_address = UserAddress.create!(address_params)\n \n if session[:new_membership_path] == true\n @redirect_path = knird_preferred_new_membership_path\n elsif session[:new_trial_path] == true\n @redirect_path = knird_preferred_new_trial_path\n else\n @redirect_path = session.delete(:return_to)\n end\n \n # redirect \n redirect_to @redirect_path\n\n end",
"def post_processing\n if params['redirect_status'] == 'succeeded'\n flash[:success] =\n 'Payment submitted. Thank you! Please wait a moment and refresh to see your dues updated.'\n else\n flash[:error] =\n 'Payment could not be submitted. Please contact a director for further help.'\n end\n redirect_to(root_url)\n end",
"def create\n redirect_to ctos_path :myLocation=>params[:myLocation],:radius=>params[:radius], :page=>params[:page]\n end",
"def create\n @post_code_electorate_map = PostCodeElectorateMap.new(post_code_electorate_map_params)\n\n respond_to do |format|\n if @post_code_electorate_map.save\n format.html { redirect_to @post_code_electorate_map, notice: 'Post code electorate map was successfully created.' }\n format.json { render :show, status: :created, location: @post_code_electorate_map }\n else\n format.html { render :new }\n format.json { render json: @post_code_electorate_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @discount_code = DiscountCode.new(discount_code_params)\n if @discount_code.save\n redirect_to dashboard_discount_code_path(@discount_code), notice: 'Discount code was successfully created.'\n else\n render :new\n end\n end",
"def create\n @distributor_missed_pincode = DistributorMissedPincode.new(distributor_missed_pincode_params)\n\n respond_to do |format|\n if @distributor_missed_pincode.save\n format.html { redirect_to @distributor_missed_pincode, notice: 'Distributor missed pincode was successfully created.' }\n format.json { render :show, status: :created, location: @distributor_missed_pincode }\n else\n format.html { render :new }\n format.json { render json: @distributor_missed_pincode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def business_details_page_enter_ltd_business_details_postcode_lookup_and_submit(companyNo: '10926928',\n companyName: 'Test Company', postcode: 'BS1 5AH',\n address: 'NATURAL ENGLAND, HORIZON HOUSE, DEANERY ROAD, BRISTOL, BS1 5AH')\n\n fill_in 'registration_company_no', with: companyNo\n fill_in 'registration_companyName', with: companyName\n fill_in 'sPostcode', with: postcode\n click_button 'find_address'\n select address\n business_details_page_submit_business_details_page\n end",
"def post\n # Make sure cid belongs to user\n if check_id(params[:cid])\n flash[:danger] = \"Try not to post in places that doesn't belong to you\"\n return redirect_to '/'\n end\n\n @grade = Grade.new(:courseItem => params[:courseItem],\n :worth => params[:worth],\n :mark => params[:mark],\n :courseMark => \"%.2f\" % (params[:worth].to_f*(params[:mark].to_f/100)),\n :subject_id => params[:cid])\n\n #Data Validation - Blank values\n if !@grade.valid?\n flash[:danger] = \"Please Input Valid Values\"\n return redirect_to '/'\n elsif @grade.save\n update_subject_grade(Grade.where(subject_id: params[:cid]), params[:cid])\n return redirect_to action: \"show\",\n id:params[:cid]\n else\n flash[:warning] = \"A Random Bug Occured, Please Try Again\"\n return redirect_to '/'\n end\n end",
"def show\n @postcode = flash[:postcode]\n\n @constituency, @seat_incumbencies, @party = Parliament::Utils::Helpers::FilterHelper.filter(@request, 'ConstituencyGroup', 'SeatIncumbency', 'Party')\n # Instance variable for single MP pages\n @single_mp = true\n @constituency = @constituency.first\n @seat_incumbencies = @seat_incumbencies.reverse_sort_by(:start_date)\n\n @current_incumbency = @seat_incumbencies.shift if !@seat_incumbencies.empty? && @seat_incumbencies.first.current?\n\n @json_location = constituency_map_path(@constituency.graph_id, format: 'json')\n\n @current_party = @current_incumbency.member.current_party if @current_incumbency\n\n @party = @current_party ? @current_party : @party.first\n\n return if @postcode.nil?\n\n begin\n response = Parliament::Utils::Helpers::PostcodeHelper.lookup(@postcode)\n @postcode_constituency = response.filter(Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path('ConstituencyGroup')).first\n postcode_correct = @postcode_constituency.graph_id == @constituency.graph_id\n @postcode_constituency.correct = postcode_correct\n rescue Parliament::Utils::Helpers::PostcodeHelper::PostcodeError => error\n flash[:error] = error.message\n @postcode = nil\n end\n end",
"def create\n @advance_search = AdvanceSearch.new(advance_search_params)\n\n respond_to do |format|\n if @advance_search.save\n if request.env['HTTP_REFERER'].include? overview_url\n format.html { redirect_to overview_url(:id=>@advance_search), notice: 'Search was successful'}\n else\n format.html { redirect_to spendings_url(:id=>@advance_search), notice: 'Advance search was successfully created.'}\n end\n # format.html { redirect_to :back,params:{:id=>@advance_search}, notice: 'Advance search was successfully created.' }\n format.json { render action: 'show', status: :created, location: @advance_search }\n else\n format.html { render action: 'new' }\n format.json { render json: @advance_search.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @diagnosis_code = DiagnosisCode.new(diagnosis_code_params)\n\n respond_to do |format|\n if @diagnosis_code.save\n format.html { redirect_to @diagnosis_code, notice: 'Diagnosis code was successfully created.' }\n format.json { render :show, status: :created, location: @diagnosis_code }\n else\n format.html { render :new }\n format.json { render json: @diagnosis_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def redirect_params\n params.require(:redirect).permit(:code, :event_id, :evidence_id)\n end",
"def create\n city = params['city'].downcase\n state = params['state'].upcase\n @result = process_location(city, state)\n\n if @result[:type] == \"error\"\n flash[:error] = @result[:value]\n redirect_to '/artists'\n else\n redirect_to \"/artists?select_location=#{@result[:value].id}\"\n end\n end",
"def redirect\n \n if \"succeeded\" == params[\"state\"]\n # Acknowledge the update payment method hosted page id passed in return URL. \n # The response will have customer and their masked payment details.\n result = ChargeBee::HostedPage.acknowledge(params[\"id\"])\n hosted_page = result.hosted_page\n \n \n id = hosted_page.content.customer.id\n redirect_to \"/update_payment_method/profile?customer_id=#{URI.escape(id)}&updated=#{URI.escape(\"true\")}\"\n \n else\n redirect_to \"/400\"\n end\n end",
"def create\n @booking_postal_code = BookingPostalCode.new(params[:booking_postal_code])\n\n respond_to do |format|\n if @booking_postal_code.save\n format.html { redirect_to [:admin,@booking_postal_code], notice: 'Booking postal code was successfully created.' }\n format.json { render json: [:admin,@booking_postal_code], status: :created, location: @booking_postal_code }\n else\n format.html { render action: \"new\" }\n format.json { render json: @booking_postal_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pincode = Pincode.new(pincode_params)\n \n respond_to do |format|\n if @pincode.save\n #format.html { redirect_to @pincode, notice: 'Pincode was successfully created.' }\n format.html { redirect_to @pincode}\n format.json { render :show, status: :created, location: @pincode }\n else\n format.html { render :new }\n format.json { render json: @pincode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post_code.update(post_code_params)\n format.html { redirect_to @post_code, notice: 'Post code was successfully updated.' }\n format.json { render :show, status: :ok, location: @post_code }\n else\n format.html { render :edit }\n format.json { render json: @post_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @criminal_code = CriminalCode.new(criminal_code_params)\n\n respond_to do |format|\n if @criminal_code.save\n format.html do\n redirect_to @criminal_code,\n notice: t('shared.msgs.success_created',\n obj: t('activerecord.models.criminal_code', count: 1))\n end\n format.json { render :show, status: :created, location: @criminal_code }\n else\n format.html { render :new }\n format.json { render json: @criminal_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post_address = PostAddress.new(post_address_params)\n\n respond_to do |format|\n if @post_address.save\n format.html { redirect_to @post_address, notice: 'Adress skapad.' }\n format.json { render action: 'show', status: :created, location: @post_address }\n else\n format.html { render action: 'new' }\n format.json { render json: @post_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def lookup\n @constituency = @request.get.first\n\n redirect_to constituency_path(@constituency.graph_id)\n end",
"def create\n session[:return_to] ||= request.referer\n param = params[:geofence]\n @geofence = Geofence.new(user_id: param[:user_id], post_id: param[:post_id], latitude: param[:latitude],\n longitude: param[:longitude],region: param[:region])\n if param[:post_id] != \"\"\n post = Post.find(param[:post_id])\n\n respond_to do |format|\n if @geofence.save\n format.html { redirect_to edit_home_path(post) , notice: 'Geofence was successfully created.' }\n format.json { render :show, status: :created, location: @geofence }\n else\n format.html { render :new }\n format.json { render json: @geofence.errors, status: :unprocessable_entity }\n end\n end\n else\n @user_profile = UserProfile.find(session[\"warden.user.user.key\"][0][0])\n respond_to do |format|\n if @geofence.save\n format.html { redirect_to edit_user_profile_path(@user_profile) , notice: 'Geofence was successfully created.' }\n format.json { render :show, status: :created, location: @geofence }\n else\n format.html { render :new }\n format.json { render json: @geofence.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @parking_code = ParkingCode.new(parking_code_params)\n\n respond_to do |format|\n if @parking_code.save\n format.html { redirect_to @parking_code, notice: 'Parking code was successfully created.' }\n format.json { render action: 'show', status: :created, location: @parking_code }\n else\n format.html { render action: 'new' }\n format.json { render json: @parking_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def POST; end",
"def create\n flash[:messages] = []\n puts \"create\"\n\n if params[:stress][:reason].present? and params[:stress][:response_type].present?\n session[:stress_reason] = params[:stress][:reason]\n session[:response_type] = params[:stress][:response_type]\n\n redirect_to \"/solutions\"\n else\n if not params[:stress][:reason].present?\n flash[:messages].push({ 'status' => 'error', 'text' => 'Reason cannot be blank.' })\n end\n if not params[:stress][:response_type].present?\n flash[:messages].push({ 'status' => 'error', 'text' => 'Response type cannot be blank.' })\n end\n redirect_to \"/\"\n end\n end",
"def create\n @countrycode = Countrycode.new(params[:countrycode])\n\n respond_to do |format|\n if @countrycode.save\n flash[:notice] = 'Countrycode was successfully created.'\n format.html { redirect_to(@countrycode) }\n format.xml { render :xml => @countrycode, :status => :created, :location => @countrycode }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @countrycode.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n sign_out current_user\n redirect_to handoff_start_path(@project, @handoff, language: params[:language])\n end",
"def new\n @postcode = Postcode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: admin_postcode_url }\n end\n end",
"def create\n @constituency = Constituency.new(params[:constituency])\n\n respond_to do |format|\n if @constituency.save\n flash[:notice] = 'Constituency was successfully created.'\n format.html { redirect_to(@constituency) }\n format.xml { render :xml => @constituency, :status => :created, :location => @constituency }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @constituency.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def business_details_page_enter_ltd_business_details_manual_postcode_and_submit(companyNo: '10926928',\n companyName: 'Test Company', houseNumber: '12', line1: 'Deanery Road',\n line2: 'EA Building', townCity: 'Bristol', postcode: 'BS1 5AH')\n\n click_link 'manual_uk_address'\n fill_in 'registration_company_no', with: companyNo\n fill_in 'registration_companyName', with: companyName\n fill_in 'address_houseNumber', with: houseNumber\n fill_in 'address_addressLine1', with: line1\n fill_in 'address_addressLine2', with: line2\n fill_in 'address_townCity', with: townCity\n fill_in 'address_postcode', with: postcode\n business_details_page_submit_business_details_page\n end",
"def create\n @postulate_area_interest = PostulateAreaInterest.new(postulate_area_interest_params)\n\n respond_to do |format|\n if @postulate_area_interest.save\n format.html { redirect_to @postulate_area_interest }\n format.json { render :show, status: :created, location: @postulate_area_interest }\n else\n format.html { render :new }\n format.json { render json: @postulate_area_interest.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n\n\n # Direct user to ORCID registration prompt before submitting MS\n if params[:register_orcid]\n # store destination in session? \n redirect_to users_register_orcid_path(:destination => new_manuscript_path) and return # ToDo: add destination=current URL\n end\n\n # Otherwise go straight to form to submit MS\n @manuscript = current_user.manuscripts.new\n render\n end",
"def create\n # Creating the patient with present surgeon\n params[:patient][:owner_id] = devise_current_user.id.to_s\n patient = current_user.patients.new(patient_params)\n # Condition for checking the saved or not\n if patient.save\n # Check the condition of which url is present\n if params[:patient][:prev_url].present?\n # If prev present then navigate to the patients case form\n redirect_to new_patient_case_path(patient)\n else\n # redirect to the patients if prev url not present\n redirect_to patients_path\n end\n else\n # redirect to the same page of the patient new page\n redirect_to :back\n # if the record is not save then navigate to the same page and showing the flash\n flash.notice = \"Need fill out the Essential Fields\"\n end\n end",
"def update\n # Updating the particular surgery and after update redirecto toe surgries page\n if @surgery.update(surgery_params)\n redirect_to surgeries_path\n else\n # else redirect to the same page surgery\n redirect_to :back\n end\n end",
"def create_property\n @p = Property.create(address: params[:address], state: params[:state], city: params[:city])\n redirect_to '/'\n end",
"def create\n @federal1870_census_entry = Federal1870CensusEntry.new(params[:federal1870_census_entry])\n\n respond_to do |format|\n if @federal1870_census_entry.save\n format.html { redirect_to @federal1870_census_entry, notice: 'Federal1870 census entry was successfully created.' }\n format.json { render json: @federal1870_census_entry, status: :created, location: @federal1870_census_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @federal1870_census_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @english_country_residence = EnglishCountryResidence.new(english_country_residence_params)\n\n respond_to do |format|\n if @english_country_residence.save\n format.html { redirect_to @english_country_residence, notice: 'English country residence was successfully created.' }\n format.json { render :show, status: :created, location: @english_country_residence }\n else\n format.html { render :new }\n format.json { render json: @english_country_residence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def check_cancel_submit\n redirect_to matters_path if params[:cancel]\n end",
"def create\n @income_and_deduction = IncomeAndDeduction.new(params[:income_and_deduction])\n\n respond_to do |format|\n if @income_and_deduction.save\n #flash[:notice] = 'IncomeAndDeduction was successfully created.'\n format.html { redirect_to(@income_and_deduction) }\n format.xml { render :xml => @income_and_deduction, :status => :created, :location => @income_and_deduction }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @income_and_deduction.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def opportunities\n redirect_to '/pages/searches', :status => :moved_permanently\n end",
"def create\n @national_outcome = NationalOutcome.new(national_outcome_params)\n\n\n if @national_outcome.save\n flash[:success] = 'National outcome was successfully created.'\n redirect_to :back\n else\n flash[:danger] = 'National outcome was not created.'\n redirect_to :back\n end\n\n end",
"def create\n @dispocode = Dispocode.new(dispocode_params)\n\n respond_to do |format|\n if @dispocode.save\n format.html { redirect_to @dispocode, notice: 'Dispocode was successfully created.' }\n format.json { render :show, status: :created, location: @dispocode }\n else\n format.html { render :new }\n format.json { render json: @dispocode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_code_params\n params.require(:post_code).permit(:code)\n end",
"def push_to_external\n if !params.has_key?(:callback) && @cite_to.redirect_to_external?\n redirect @cite_to.action + callback, 303\n elsif @cite_to.to_sym === :openurl\n if primo.openurl\n redirect primo.openurl, 303\n else\n halt 422, error_messages[:openurl_not_found_error]\n end\n else\n erb :post_form, locals: { csf: citations }\n end\n end",
"def update\n dnc_contents=dnc_params\n #Delete params that are only passed as flags\n #A DNC will not save correctly if these params are passed to the DNC itself\n dnc_contents.delete(\"terrtype\")\n dnc_contents.delete(\"redirid\")\n\n respond_to do |format|\n if @dnc.update(dnc_contents)\n if dnc_params[\"terrtype\"]\n #Terrtype is passed when creating from a territory listing\n #This section is to redirect back to that listing instead of to the DNC\n format.html { redirect_to \"/#{dnc_params[\"terrtype\"]}/#{dnc_params[\"redirid\"]}\", notice: 'DNC was successfully updated.' }\n format.json { render :show, status: :ok, location: @dnc }\n else\n format.html { redirect_to @dnc, notice: 'DNC was successfully updated.' }\n format.json { render :show, status: :ok, location: @dnc }\n end\n else\n format.html { render :edit }\n format.json { render json: @dnc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @contrac_establishment = ContracEstablishment.new(contrac_establishment_params)\n\n respond_to do |format|\n if @contrac_establishment.save\n format.html { redirect_to @contrac_establishment, notice: 'Contrac establishment was successfully created.' }\n format.json { render :show, status: :created, location: @contrac_establishment }\n else\n format.html { render :new }\n format.json { render json: @contrac_establishment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @pc.update(pc_params)\n redirect_to(session.delete(:redirect_to) || :training_top)\n else\n redirect_to :back\n end\n end",
"def business_details_page_enter_business_or_organisation_details_manual_postcode_and_submit(companyName: 'Test Company',\n houseNumber: '12', line1: 'Deanery Road',\n line2: 'EA Building', townCity: 'Bristol', postcode: 'BS1 5AH')\n\n click_link 'manual_uk_address'\n fill_in 'registration_companyName', with: companyName\n fill_in 'address_houseNumber', with: houseNumber\n fill_in 'address_addressLine1', with: line1\n fill_in 'address_addressLine2', with: line2\n fill_in 'address_townCity', with: townCity\n fill_in 'address_postcode', with: postcode\n business_details_page_submit_business_details_page\n end",
"def submit\n @proposal = current_user.proposals.find(params[:id])\n\n if request.post?\n @proposal.submit!\n\n redirect_to proposals_path\n end\n end",
"def new\n @post_code = PostCode.new\n @towns = Town.find :all \n @geo_positions = GeoPosition.find :all\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post_code }\n end\n end",
"def product_post\n if params[\"new\"] \n redirect_to \"/product/new\" and return\n elsif params[\"search\"]\n @name = params[\"search_field\"].gsub(\" \", \"_\")\n redirect_to \"/products/#{@name}\" and return\n elsif params[\"clear\"]\n redirect_to \"/products\" and return\n else\n redirect_to \"/product/#{params[\"edit\"]}\" and return\n end\n end",
"def create\n @naics_code = NaicsCode.new(naics_code_params)\n\n respond_to do |format|\n if @naics_code.save\n format.html { redirect_to @naics_code, notice: 'Naics code was successfully created.' }\n format.json { render action: 'show', status: :created, location: @naics_code }\n else\n format.html { render action: 'new' }\n format.json { render json: @naics_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reward_code = RewardCode.new(params[:reward_code])\n\n respond_to do |format|\n if @reward_code.save\n format.html { redirect_to @reward_code, notice: 'Reward code was successfully created.' }\n format.json { render json: @reward_code, status: :created, location: @reward_code }\n else\n format.html { render action: \"new\" }\n format.json { render json: @reward_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post\r\n end",
"def exchange_code_for_token\n current_user.update_attributes(:api_country_code => params[:country].downcase)\n body_params = token_request_body\n body_params << [\"code\", params[:code]]\n body_params << [\"grant_type\", \"authorization_code\"]\n body_params << [\"redirect_uri\", sage_accounting_config['sage_accounting']['callback_url']]\n\n get_token(body_params)\n redirect_to sage_accounting_data_path\n end",
"def create\n @council_district = CouncilDistrict.new(council_district_params)\n\n respond_to do |format|\n if @council_district.save\n format.html { redirect_to @council_district, notice: 'Council district was successfully created.' }\n format.json { render action: 'show', status: :created, location: @council_district }\n else\n format.html { render action: 'new' }\n format.json { render json: @council_district.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n if @national_outcome.update(national_outcome_params)\n flash[:success] = 'National outcome was successfully updated.'\n redirect_to :back\n else\n flash[:danger] = 'National outcome was not updated.'\n redirect_to :back\n end\n\n end",
"def r_to code\n redirect_to site_url, :status => code\n end",
"def create\n @secrate_code = SecrateCode.new(params[:secrate_code])\n\n respond_to do |format|\n if @secrate_code.save\n format.html { redirect_to @secrate_code, notice: 'Secrate code was successfully created.' }\n format.json { render json: @secrate_code, status: :created, location: @secrate_code }\n else\n format.html { render action: \"new\" }\n format.json { render json: @secrate_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @charge_type.save\n if params[:from_charge].present?\n redirect_to new_charge_path\n return\n end\n redirect_to charge_types_path\n end",
"def create\n @incidence = Incidence.new(incidence_params)\n\n respond_to do |format|\n if @incidence.save\n format.html { redirect_to @incidence, notice: 'Incidencia creada exitosamente.' }\n format.json { render :show, status: :created, location: @incidence }\n else\n format.html { render :new }\n format.json { render json: @incidence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_code_result\n params['PostCodeResult']\n end",
"def create\n @resolution_code = ResolutionCode.new(resolution_code_params)\n\n respond_to do |format|\n if @resolution_code.save\n format.html { redirect_to @resolution_code, notice: 'Resolution code was successfully created.' }\n format.json { render :show, status: :created, location: @resolution_code }\n else\n format.html { render :new }\n format.json { render json: @resolution_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @postcard_return = PostcardReturn.new(postcard_return_params)\n\n respond_to do |format|\n if @postcard_return.save\n format.html { redirect_to @postcard_return, notice: 'Postcard return was successfully created.' }\n format.json { render :show, status: :created, location: @postcard_return }\n else\n format.html { render :new }\n format.json { render json: @postcard_return.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show_prediction_by_postcode\n params = location_params\n @cur_date = {:date => Time.now.strftime(\"%d-%m-%Y\")}\n postcode = Postcode.find_by(postcode: params[:post_code])\n @location = postcode.locations.first\n @predictions = DataHelper.predict(@location, params[:period])\n end",
"def create\n @congressional_district = CongressionalDistrict.new(params[:congressional_district])\n\n respond_to do |format|\n if @congressional_district.save\n format.html { redirect_to @congressional_district, notice: 'Congressional district was successfully created.' }\n format.json { render json: @congressional_district, status: :created, location: @congressional_district }\n else\n format.html { render action: \"new\" }\n format.json { render json: @congressional_district.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @title_view = 'Nuevo Pre Registro de Patrimonio Cultural'\n @cultural_heritage_cultural_heritage_pre_register = CulturalHeritage::CulturalHeritagePreRegister.new(params[:cultural_heritage_cultural_heritage_pre_register])\n@cultural_heritage_cultural_heritage_pre_register.state = 5\n @cultural_heritage_cultural_heritage_pre_register.preRegisterRegistrationCode = PRE0 +@cultural_heritage_cultural_heritage_pre_register.id\n\n respond_to do |format|\n if @cultural_heritage_cultural_heritage_pre_register.save\n format.html { redirect_to(@cultural_heritage_cultural_heritage_pre_register, :notice => 'Pre Registro fue registrado correctamente.') }\n format.xml { render :xml => @cultural_heritage_cultural_heritage_pre_register, :status => :created, :location => @cultural_heritage_cultural_heritage_pre_register }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cultural_heritage_cultural_heritage_pre_register.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n redirect_to posting_types_path\n end",
"def create\n @promo_code = PromoCode.new(promo_code_params)\n category = Category.find(category_params)\n @promo_code.category = category\n\n respond_to do |format|\n if @promo_code.save\n format.html { redirect_to @promo_code, notice: 'Promo code was successfully created.' }\n format.json { render :show, status: :created, location: @promo_code }\n else\n format.html { render :new }\n format.json { render json: @promo_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @go_to_law = params[:go_to_law]\n @go_to_checkout = params[:go_to_checkout]\n @is_monthly = params[:is_monthly]\n @is_annually = params[:is_annually]\n @is_student = params[:is_student]\n @pricing_onboarding = params[:pricing_onboarding]\n # session[:return_to] = params[:return_to] if params[:return_to]\n super\n\n end",
"def create\n check_tutorial_params(property_and_casualty_params[:name]) and return\n \n @insurance_card = PropertyAndCasualty.new(property_and_casualty_params.merge(user_id: resource_owner.id, category: Category.fetch(Rails.application.config.x.InsuranceCategory.downcase)))\n authorize @insurance_card\n PolicyService.fill_property_and_casualty_policies(policy_params, @insurance_card)\n respond_to do |format|\n if validate_params && @insurance_card.save\n PolicyService.update_shares(@insurance_card.id, @insurance_card.share_with_ids, nil, resource_owner)\n PolicyService.update_properties(@insurance_card, property_params)\n @path = success_path(property_path(@insurance_card), property_and_casualty_shared_view_path(shared_user_id: resource_owner.id, id: @insurance_card.id))\n \n # If comes from Tutorials workflow, redirect to next step\n if params[:tutorial_name]\n tutorial_redirection(format, @insurance_card.as_json)\n else\n format.html { redirect_to @path, flash: { success: 'Insurance successfully created.' } }\n format.json { render :show, status: :created, location: @insurance_card }\n end\n else\n # If comes from Tutorials workflow, redirect to same Tutorial step\n tutorial_error_handle(\"Fill in Insurance Provider Name field to continue\") && return\n error_path(:new)\n format.html { render controller: @path[:controller], action: @path[:action], layout: @path[:layout] }\n format.json { render json: @insurance_card.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n sigcode_params[:language] = sigcode_params[:language].to_i\n sigcode_params[:frequency] = sigcode_params[:frequency].to_i\n\n @sigcode = Sigcode.new(sigcode_params)\n\n respond_to do |format|\n if @sigcode.save\n format.html { redirect_to @sigcode, notice: 'Sigcode was successfully created.' }\n format.json { render :show, status: :created, location: @sigcode }\n else\n format.html { render :new }\n format.json { render json: @sigcode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @area_code_detail = AreaCodeDetail.new(area_code_detail_params)\n\n respond_to do |format|\n if @area_code_detail.save\n format.html { redirect_to @area_code_detail, notice: 'Area code detail was successfully created.' }\n format.json { render :show, status: :created, location: @area_code_detail }\n else\n format.html { render :new }\n format.json { render json: @area_code_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pointcode = Pointcode.new(params[:pointcode])\n\n respond_to do |format|\n if @pointcode.save\n format.html { redirect_to pointcodes_url }\n format.json { render json: @pointcode, status: :created, location: @pointcode }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pointcode.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @early_pregnancy = EarlyPregnancy.new(params[:early_pregnancy])\n\n respond_to do |format|\n if @early_pregnancy.save\n format.html { redirect_to @early_pregnancy, notice: 'Early pregnancy was successfully created.' }\n format.json { render json: @early_pregnancy, status: :created, location: @early_pregnancy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @early_pregnancy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resubmit = Resubmit.new(params[:resubmit])\n\n if @resubmit.save\n# redirect_to('https://www.mturk.com/mturk/externalSubmit?participantId='+@resubmit.id.to_s+'&assignmentId='+@resubmit.assignment_id.to_s+'&hitId='+@resubmit.hit_id.to_s+'&workerId='+@resubmit.worker_id.to_s+'&cond=1') \n redirect_to resubmit_path(@resubmit.id) \n else\n render action: \"new\" \n end\n end",
"def create\n @caste_category = CasteCategory.new(caste_category_params)\n\n session.delete(:return_to)\n session[:return_to] ||= request.referer\n\n respond_to do |format|\n if @caste_category.save\n format.html { redirect_to session.delete(:return_to), notice: 'Caste category was successfully created.' }\n format.json { render :show, status: :created, location: @caste_category }\n else\n format.html { render :new }\n format.json { render json: @caste_category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n payment_type = nil \n if params.has_key? :payment_type\n payment_type = params[:payment_type]\n else\n payment_type = 'sign_up'\n end\n @payment = Payment.new\n\n respond_to do |format|\n format.html {\n case payment_type\n when 'sign_up'\n # really want to go to a form, that submits here, i save that info, populate the send\n # thing and send it off to payp.\n render(:action => 'sign_up.rhtml') && return \n when 'trip'\n render(:action => 'trip_sign_up.rhtml') && return \n else\n end\n }\n format.xml { render :xml => @payment }\n end\n end",
"def create\n @student = Student.new\n @student.name = params[:student][:name]\n @student.registration = params[:student][:registration]\n @student.admission = params[:student][:admission]\n respond_to do |format|\n if @student.save\n if params[:student][:pc] == 0\n format.html { redirect_to students_path}\n else\n format.html { redirect_to complete_new_user_path(params[:student][:registration], params[:student][:pc]), method: 'post'}\n format.json { render :show, status: :created, location: @student }\n end\n else\n format.html { render :new }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @category_map = CategoryMap.new(category_map_params)\n category_map = params[\"category_map\"]\n category = category_map[\"category\"].to_i\n respond_to do |format|\n if @category_map.save\n format.html do \n if category == CategoryMap::DIARY\n redirect_to '/diaries/new'\n elsif category == CategoryMap::TRAVEL\n redirect_to '/travel_journals/new'\n elsif category == CategoryMap::MISC\n redirect_to '/miscs/new'\n end\n end\n # format.html { redirect_to '/diaries/new'}\n format.json { render :show, status: :created, location: @category_map }\n else\n format.html { render :new }\n format.json { render json: @category_map.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_venue\r\n if request.post?\r\n @venue = Venue.new(params[:venue])\r\n if @venue.save \r\n redirect_to :controller => 'agents', :action => 'index'\r\n else\r\n render :action => 'create_venue'\r\n end\r\n else\r\n @venue = Venue.new\r\n @venue.country = User.find(session[:user_id]).country\r\n @venue.county = User.find(session[:user_id]).county\r\n @venue.city = User.find(session[:user_id]).city\r\n @venue.postcode = User.find(session[:user_id]).postcode \r\n end\r\n end",
"def create\n @code_postal_ville = CodePostalVille.new(params[:code_postal_ville])\n\n respond_to do |format|\n if @code_postal_ville.save\n format.html { redirect_to(@code_postal_ville, :notice => 'Code postal ville was successfully created.') }\n format.xml { render :xml => @code_postal_ville, :status => :created, :location => @code_postal_ville }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @code_postal_ville.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n \tredirect_to results_path\n end",
"def billing_address_post\n params[:address][:country] = params[:address][:state].split(\"-\")[0]\n params[:address][:state] = params[:address][:state].split(\"-\")[1]\n @address = Address.new(params[:address])\n @address.customer = @customer\n if @address.save\n @cart.billing_address = @address\n @cart.save\n redirect_to build_url_options_for_checkout\n return\n else\n flash[:error] = @address.errors.full_messages.join('<br/>')\n render :action => 'billing_address'\n end\n end",
"def create\n @zip_code_area_code = ZipCodeAreaCode.new(zip_code_area_code_params)\n\n respond_to do |format|\n if @zip_code_area_code.save\n format.html { redirect_to @zip_code_area_code, notice: 'Zip code area code was successfully created.' }\n format.json { render :show, status: :created, location: @zip_code_area_code }\n else\n format.html { render :new }\n format.json { render json: @zip_code_area_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @lookup_ethnicity = LookupEthnicity.new(params[:lookup_ethnicity])\n\n respond_to do |format|\n if @lookup_ethnicity.save\n format.html { redirect_to(@lookup_ethnicity, :notice => 'Lookup ethnicity was successfully created.') }\n format.xml { render :xml => @lookup_ethnicity, :status => :created, :location => @lookup_ethnicity }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @lookup_ethnicity.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def redirect_from_params\n if params[:redirect_to]\n redirect_to params[:redirect_to]\n end\n end",
"def create\n @codigo_postal = CodigoPostal.new(codigo_postal_params)\n\n respond_to do |format|\n if @codigo_postal.save\n format.html { redirect_to @codigo_postal, notice: 'Codigo postal was successfully created.' }\n format.json { render :show, status: :created, location: @codigo_postal }\n else\n format.html { render :new }\n format.json { render json: @codigo_postal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def welcome_back\n @univ_choice = University.find(params[:univ_id])\n\n if request.post?\n\n begin \n params[:terms] = true # cust already accepted once!\n\n # find order\n #\n oo = Order.for_cust(@customer).for_univ(@univ_choice.id).last\n raise \"error - no #{@univ_choice.name} univ for customer #{@customer.email}!\" unless oo\n \n # set cc\n #\n card = CreditCard.secure_setup(params[\"credit_card\"], @customer)\n card_success = card.save\n raise \"problem w CC\" unless card_success\n \n # set addr\n #\n addr_success = private_addr_do\n raise \"problem w addr\" unless addr_success\n\n # test CC\n #\n charge_amount = 0.01\n success, msg = ChargeEngine.charge_credit_card(card, charge_amount, oo.id, \"test charge\") \n raise \"we tested your credit card and had a problem: #{msg}\" unless success\n \n # apply 1 month credit\n #\n @customer.add_account_credit(0, nil, 1) if @customer.credit_months <= 0\n\n # reenable univ\n #\n oo.reinstate\n\n session[:reinstated_univ_id] = oo.id\n return redirect_to :univstore_welcome_back_done, :flash => { :message => \"success!\" }\n\n rescue Exception => e\n\n return redirect_to :back, :flash => { :message => e.message }\n end\n end\n\n end",
"def request_sample\n\n respond_to do |format|\n\n # Checks that the form has been filled out correctly\n if params[:line1].blank? or params[:city].blank? or params[:county].blank? or params[:postcode].blank?\n format.html { redirect_to @post, notice: 'To request a sample you must provide your full address.' }\n else\n # Creates a new sample and redirect to the profile page\n @request = Request_Sample.new\n @request.post_id = @post.id\n @request.seller_id = @post.trader_id\n @request.requestee_id = current_trader.id\n @request.line1 = params[:line1]\n @request.city = params[:city]\n @request.county = params[:county]\n @request.postcode = params[:postcode]\n @request.save\n format.html { redirect_to profiles_path(current_trader.id), notice: 'Request made.' }\n end\n end\n end",
"def create\n @canadianpost = Canadianpost.new(canadianpost_params)\n\n respond_to do |format|\n if @canadianpost.save\n format.html { redirect_to @canadianpost, notice: 'Canadianpost was successfully created.' }\n format.json { render :show, status: :created, location: @canadianpost }\n else\n format.html { render :new }\n format.json { render json: @canadianpost.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @purchase_preference = PurchasePreference.new(params[:purchase_preference])\n\n if @purchase_preference.save\n redirect_to(new_card_path) if true # buying\n else\n render action: \"new\"\n end\n\n respond_to do |format|\n if @purchase_preference.save\n format.html { redirect_to @purchase_preference, notice: 'Purchase preference was successfully created.' }\n format.json { render json: @purchase_preference, status: :created, location: @purchase_preference }\n else\n format.html { render action: \"new\" }\n format.json { render json: @purchase_preference.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @capacitycode = Capacitycode.new(capacitycode_params)\n @capacitycode.save\n redirect_to capacitycodes_path\n end",
"def create\n @industry_type = IndustryType.new(industry_type_params)\n\n respond_to do |format|\n if @industry_type.save\n format.html { redirect_to @industry_type, notice: 'Industria creada con exito' }\n format.json { render :show, status: :created, location: @industry_type }\n else\n format.html { render :new }\n format.json { render json: @industry_type.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.601083",
"0.58243847",
"0.57342035",
"0.5613032",
"0.5558212",
"0.5543345",
"0.5499545",
"0.5471181",
"0.546844",
"0.5455429",
"0.5447761",
"0.5424066",
"0.5388734",
"0.5366871",
"0.53646636",
"0.5326812",
"0.53149766",
"0.5274738",
"0.52576333",
"0.5253722",
"0.52461255",
"0.52379364",
"0.5237163",
"0.5224184",
"0.5223204",
"0.5213155",
"0.5190461",
"0.51890016",
"0.5166986",
"0.5160391",
"0.5151372",
"0.51469386",
"0.51457757",
"0.51434606",
"0.5142747",
"0.51419836",
"0.5135721",
"0.51248294",
"0.5094657",
"0.50897115",
"0.5089666",
"0.5086595",
"0.5076515",
"0.5072777",
"0.5072315",
"0.5066191",
"0.5063151",
"0.50626487",
"0.50571704",
"0.5056172",
"0.5053899",
"0.504937",
"0.50469637",
"0.50230694",
"0.50222206",
"0.5015473",
"0.50153226",
"0.50079024",
"0.50061506",
"0.5002408",
"0.49947104",
"0.49889722",
"0.49797943",
"0.49569312",
"0.49540025",
"0.494957",
"0.49427107",
"0.494189",
"0.49408984",
"0.4939762",
"0.49390998",
"0.49382076",
"0.49345124",
"0.49325556",
"0.49310678",
"0.49232003",
"0.49206537",
"0.49204868",
"0.4917186",
"0.49127215",
"0.4909538",
"0.49094036",
"0.4907039",
"0.4904697",
"0.4904033",
"0.490326",
"0.48996162",
"0.489823",
"0.4896521",
"0.48957062",
"0.4895124",
"0.48947275",
"0.48918986",
"0.4891401",
"0.48912242",
"0.48883554",
"0.48864853",
"0.4882597",
"0.4880501",
"0.48802096"
] |
0.7674942
|
0
|
Renders a constituency that has a constituency area object on map view given a constituency id. Will respond with GeoJSON data using the geosparqltogeojson gem if JSON is requested.
|
def map
respond_to do |format|
format.html do
@constituency = Parliament::Utils::Helpers::FilterHelper.filter(@request, 'ConstituencyGroup').first
@json_location = constituency_map_path(@constituency.graph_id, format: 'json')
end
format.json do
@constituency = Parliament::Utils::Helpers::RequestHelper.filter_response_data(
Parliament::Utils::Helpers::ParliamentHelper.parliament_request.constituency_map.set_url_params({ constituency_id: params[:constituency_id] }),
Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path('ConstituencyGroup')
).first
raise ActionController::RoutingError, 'Not Found' unless @constituency.current?
render json: GeosparqlToGeojson.convert_to_geojson(
geosparql_values: @constituency.area.polygon,
geosparql_properties: {
name: @constituency.name,
start_date: @constituency.start_date,
end_date: @constituency.end_date
},
reverse: false
).geojson
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n @county = Entity.where(id: params[:id]).where(entity_type: 'County').first\n respond_with(@county) do |format|\n format.geojson { render text: @county.to_geojson }\n end\n end",
"def map\n respond_to do |format|\n format.html do\n @constituency = Parliament::Utils::Helpers::FilterHelper.filter(@request, 'ConstituencyGroup').first\n\n @json_location = constituency_map_path(@constituency.graph_id, format: 'json')\n end\n\n format.json do\n @constituency = Parliament::Utils::Helpers::RequestHelper.filter_response_data(\n Parliament::Utils::Helpers::ParliamentHelper.parliament_request.constituency_map.set_url_params({ constituency_id: params[:constituency_id] }),\n Parliament::Utils::Helpers::RequestHelper.namespace_uri_schema_path('ConstituencyGroup')\n ).first\n\n raise ActionController::RoutingError, 'Not Found' unless @constituency.current?\n\n render json: GeosparqlToGeojson.convert_to_geojson(\n geosparql_values: @constituency.area.polygon,\n geosparql_properties: {\n name: @constituency.name,\n start_date: @constituency.start_date,\n end_date: @constituency.end_date\n },\n reverse: false\n ).geojson\n end\n end\n end",
"def show\n @curriculum_area = CurriculumArea.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @curriculum_area }\n end\n end",
"def show\n @constituency = Constituency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @constituency }\n end\n end",
"def geo\n\t\tciudad = params[:id]\n\t\t@ubication = City.where(id: ciudad)\n\t\trespond_to do |format|\n\t\t\tformat.json { render json: @ubication }\n\t\tend\n\tend",
"def render_index_mapview\n static_geojson_file_loc = \"#{Rails.root}/#{GEOJSON_STATIC_FILE['filepath']}\"\n if Rails.env.to_s == 'production' && params[:action] == 'map' && File.exist?(static_geojson_file_loc)\n geojson_for_map = File.open(static_geojson_file_loc).first\n else\n geojson_for_map = serialize_geojson(map_facet_values)\n end\n render partial: 'catalog/index_mapview',\n locals: { geojson_features: geojson_for_map }\n end",
"def show\n @spatial_coverage = SpatialCoverage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spatial_coverage }\n end\n end",
"def show\n @polygon = Polygon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @polygon }\n end\n end",
"def show\n @congressional_district = CongressionalDistrict.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @congressional_district }\n end\n end",
"def show\n @constitution = Constitution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @constitution }\n end\n end",
"def show\n @estate = Estate.find(params[:id])\n @json = @estate.to_gmaps4rails\n respond_with(@estate)\n \n end",
"def show\n @layer = Layer.find(params[:id])\n areas_json = @layer.areas.map do |area|\n {area_id: area.id, polygon: area.polygon}\n end\n @result = {id: @layer.id, name: @layer.name, number_of_polygons: @layer.areas.count, areas: areas_json }\n\n base_url = \"#{request.protocol}#{request.host_with_port}\"\n permalink_hash = PermalinkController.generate_json(base_url, 'layers/show', @layer, @tolerance)\n @permalink = permalink_hash[:url]\n @data_json = permalink_hash[:data_json]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:layer => @layer, :data_json => @data_json, :permalink => @permalink} }\n format.topojson { render json: @layer.to_topojson }\n end\n end",
"def route\n hitch = Hitch.find(params[:hitch_id])\n render json: hitch.geojson\n end",
"def geo(id)\n get \"/geo/id/#{id}.json\"\n end",
"def show\n @county = County.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @county }\n end\n end",
"def show\n @area_of_law = AreaOfLaw.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @area_of_law }\n end\n end",
"def show\n @tramite_constitucional = TramiteConstitucional.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tramite_constitucional }\n end\n end",
"def show\n @geopoint = Geopoint.find(params[:id])\n @json = @geopoint.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @geopoint }\n end\n end",
"def show\n render json: @given_circumstance\n end",
"def show\n @survey_area = SurveyArea.find(params[:id])\n @survey_areas = Array.new\n @survey_areas.push(@survey_area)\n @json = @survey_area.survey_locations.to_gmaps4rails\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @survey_area }\n end\n end",
"def show\n @bemap = Bemap.find(params[:id])\n @bemap_polylines = []\n @bemap_characters = []\n @bemap.characters.each do |v|\n @bemap_characters << { :lng => v[:longitude], :lat => v[:latitude]}\n end\n @bemap_polylines << @bemap_characters\n @bemap_polylines = @bemap_polylines.to_json\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bemap }\n end\n end",
"def show\n @country_area = CountryArea.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @country_area }\n end\n end",
"def show\n @clinicalsection = Clinicalsection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinicalsection }\n end\n end",
"def set_cat_poly\n @cat_poly = CatPoly.find(params[:id])\n end",
"def show\n @interest_area = InterestArea.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interest_area }\n end\n end",
"def show\n @story = Story.find(params[:id])\n \n # set map data, if it's the primary media for this story\n if @story.media_type.name == \"map_interview\"\n @media_geojson = @story.map_data ? @story.map_data.html_safe : \"\"\n end\n \n # we probably just want to show a dot on the map, e.g. no popup\n #@geojson = @story.to_geojson.html_safe\n @geojson = @story.to_geojson_point.html_safe\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @story }\n end\n end",
"def show\n @admin_geonode = Admin::Geonode.find(params[:id])\n @json = @admin_geonode.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_geonode }\n end\n end",
"def show\r\n @area = Area.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @area }\r\n end\r\n end",
"def show\n respond_to do |format|\n format.html\n format.geojson { render json: @abra_notice.to_geojson }\n end\n end",
"def show\n educacao = Educacao.find(params[:id])\n ponto = educacao.the_geom\n @latitude = ponto.x\n @longitude = ponto.y\n\n respond_to do |format|\n format.html\n format.json {render json: educacao}\n end\n end",
"def show\n @outdoor = Outdoor.find(params[:id])\n @json = Outdoor.find(params[:id]).to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @outdoor }\n end\n end",
"def show\n @area = Area.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @area }\n end\n end",
"def show\n @title_view = 'Culturas'\n @cultural_heritage_culture = CulturalHeritage::Culture.find(params[:id])\n\n points = @cultural_heritage_culture.list_point\n\n if points.length > 0\n\n count = 0\n @json = \"[[\"\n points.each do |point|\n if (count == 0)\n @json = @json << '{\"lng\": ' << point.longitude.to_s << ', \"lat\": ' << point.latitude.to_s <<\n ', \"strokeColor\": \"#FF0000\", \"strokeOpacity\": 0.3, \"strokeWeight\": 1, \"fillColor\": \"#FF0000\", \"fillOpacity\": 0.7}'\n else\n @json = @json << ', {\"lng\": ' << point.longitude.to_s << ', \"lat\": ' << point.latitude.to_s << '}'\n end\n count = count + 1\n end\n @json = @json << \"]]\"\n\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cultural_heritage_culture }\n format.json { render :json => @cultural_heritage_culture }\n end\n end",
"def lookup\n @constituency = @request.get.first\n\n redirect_to constituency_path(@constituency.graph_id)\n end",
"def area\n respond_to?(:constituencyGroupHasConstituencyArea) ? constituencyGroupHasConstituencyArea.first : nil\n end",
"def show\n @breadcrumb = 'read'\n @area = Area.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @area }\n end\n end",
"def area\n respond_to?(:constituencyGroupHasConstituencyArea) ? constituencyGroupHasConstituencyArea.first : nil\n end",
"def constituency_loc_real(constituency)\n begin\n # Use the TWFY API to get the data\n location = TWFY_CLIENT.geometry name: constituency\n {lat: location.centre_lat, lng: location.centre_lon}\n rescue\n # Return (0,0) in case of failure\n {lat: 0, lng: 0}\n end\nend",
"def update\n @constituency = Constituency.find(params[:id])\n\n respond_to do |format|\n if @constituency.update_attributes(params[:constituency])\n flash[:notice] = 'Constituency was successfully updated.'\n format.html { redirect_to(@constituency) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @constituency.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n begin\n @course = Course.find(params[:id])\n raise if @course.nil?\n \n conditions = [\"course_id = ?\",@course.id]\n @holes = Hole.find(:all, :conditions => conditions)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end",
"def show\n @condolence = Condolence.find(params[:id])\n @orbituarysite = current_user.orbituarysites.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @condolence }\n end\n end",
"def update\n respond_to do |format|\n if @cat_poly.update(cat_poly_params)\n format.html { redirect_to @cat_poly, notice: 'Cat poly was successfully updated.' }\n format.json { render :show, status: :ok, location: @cat_poly }\n else\n format.html { render :edit }\n format.json { render json: @cat_poly.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @cultural_heritage_culture = CulturalHeritage::Culture.find(params[:id])\n points = @cultural_heritage_culture.list_point\n\n if points.length > 0\n\n count = 0\n @json = \"[[\"\n points.each do |point|\n if (count == 0)\n @json = @json << '{\"lng\": ' << point.longitude.to_s << ', \"lat\": ' << point.latitude.to_s << \n ', \"strokeColor\": \"#FF0000\", \"strokeOpacity\": 0.3, \"strokeWeight\": 1, \"fillColor\": \"#FF0000\", \"fillOpacity\": 0.7}'\n else\n @json = @json << ', {\"lng\": ' << point.longitude.to_s << ', \"lat\": ' << point.latitude.to_s << '}'\n end\n count = count + 1\n end\n @json = @json << \"]]\"\n\n end \n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @cultural_heritage_culture_point }\n end\n end",
"def index\n load_county or raise \"county not found\"\n\n breadcrumbs.add(:url=>@state.to_url, :title=>@state.name)\n breadcrumbs.add(:url=>@county.to_url, :title=>@county.name)\n self.page_title = \"#{@county.fancy_name_with_state} Cemetery Map\"\n\n @graveyards = @county.graveyards.includes(:main_photo).includes(:county)\n\n respond_to do |fmt|\n @visits=UserVisitsCollection.new(current_user)\n @visits.add_graveyards(@graveyards)\n fmt.json do\n render :json => {\n status: :success,\n locations: @graveyards.sort_by(&:name).map(&:map_data).map { |g|\n if v = @visits.visit_for(g[:id])\n g[:visit] = v.as_json(:only=> [\n :id, :status, :visited_on,\n :expedition_id, :ordinal, :quality\n ])\n end\n g\n },\n # visits: @visits\n }\n end\n fmt.html { render :action=>:index }\n end\n end",
"def show\n @encounter_area_feature = EncounterAreaFeature.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @encounter_area_feature }\n end\n end",
"def show\n @event = Event.find_by_url(params[:id])\n @json = Location.where(id: @event.location_id).to_gmaps4rails\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @event }\n end\n end",
"def show\n @area_type = AreaType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @area_type }\n end\n end",
"def show\n @cloth_measure = ClothMeasure.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cloth_measure }\n end\n end",
"def show\n @cad_neighborhood = CadNeighborhood.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cad_neighborhood }\n end\n end",
"def show\n render json: @inciting_incident\n end",
"def show\n recorrido = Recorrido.find(params[:id].to_i)\n @polylines = []\n @stops = []\n # @shapes = Shape.all\n secuencias = recorrido.get_secuencias_of_the_hour\n\n secuencias.each_with_index do |s, i|\n @polylines[i] = []\n Shape.where(:code => s.code).first.points.each_with_index do |p, e|\n e == 0 ? @polylines[i] << {:strokeColor => '#000000', :icons => [], :lat => p.lat, :lng => p.lng } : @polylines[i] << {:lat => p.lat, :lng => p.lng }\n end\n s.stops.each do |stop|\n @stops << {:title => stop.code,\n :lat => stop.lat,\n :lng => stop.lng,\n :width => 12,\n :height => 14,\n :picture => \"../images/parada_12.png\", :type => 'stop',\n :type => 'stop',\n :ida => i,\n :description => render_to_string(:partial => \"/recorridos/stop_infowindow\", :locals => { :stop => stop})}\n end\n end\n\n\n respond_to do |format|\n format.js\n format.html\n format.json { render json: @recorrido }\n end\n end",
"def show\n\n @venue = Venue.find(params[:id])\n @concerts = Concert.where(:venue_id=>@venue.id)\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @venue }\n end\n end",
"def show\n @site = Site.find(params[:id])\n\n respond_to do |format|\n format.html { render layout: false }\n format.json\n format.geojson\n end\n end",
"def show\n @conclusion = Conclusion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conclusion }\n end\n end",
"def show\n @criterion = Criterion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @criterion }\n end\n end",
"def show\n @concept_map = ConceptMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json:@concept_map }\n end\n end",
"def show\n @map_area = MapArea.find(params[:id])\n @start = @map_area\n @zoom= 4\n @houses = House.count(:conditions => [\"map_area_id = ?\",params[:id]])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @map_area }\n end\n end",
"def show\n @map_area = MapArea.find(params[:id])\n @start = @map_area\n @zoom= 4\n @houses = House.count(:conditions => [\"map_area_id = ?\",params[:id]])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @map_area }\n end\n end",
"def polygon\n respond_to?(:constituencyAreaExtent) ? constituencyAreaExtent : []\n end",
"def show\n @trip = Trip.find(params[:id])\n @meta_title = \" Thrill Engine - #{@trip.categories.map(&:name).to_sentence} in #{@trip.location} staying at #{@trip.title} \"\n @meta_description = @trip.description\n @meta_keywords = \" #{@trip.location}, #{@trip.categories.map(&:name).to_sentence}, #{@trip.title}, #{@trip.categories.map(&:name).to_sentence} in #{@trip.location}, #{@trip.categories.map(&:name).to_sentence} travel, #{@trip.categories.map(&:name).to_sentence} trips, best #{@trip.categories.map(&:name).to_sentence} spots, top #{@trip.categories.map(&:name).to_sentence} resorts, Adventure Holidays, #{@trip.categories.map(&:name).to_sentence} Holidays, #{@trip.categories.map(&:name).to_sentence} vacations \" \n @json = Trip.find(params[:id]).to_gmaps4rails\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @trip }\n end\n end",
"def show\n @gethotelstaticdatagd = Gethotelstaticdatagd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gethotelstaticdatagd }\n end\n end",
"def show\n @clidistrict = Clidistrict.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clidistrict }\n end\n end",
"def index\n @educacao = Educacao.new\n @educacaos = Educacao.all\n @modal = true\n\n factory = RGeo::GeoJSON::EntityFactory.instance\n features = []\n @educacaos.each do |edu|\n feature = factory.feature(edu.the_geom, nil, {id: edu.id, nome: edu.nome, email: edu.email, contato: edu.contato})\n features << feature\n end\n\n json_edu = RGeo::GeoJSON.encode factory.feature_collection(features)\n\n respond_to do |format|\n format.html\n format.json { render :json => json_edu }\n format.xml { render :xml => @educacaos }\n end\n end",
"def show\n @polygon_mark = PolygonMark.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @polygon_mark }\n end\n end",
"def show\n @area = Area.find(params[:id])\n respond_with(@area)\n end",
"def show\n @traces = Trace.find_by(id: params[:id])\n url_string = ''\n response = HTTParty.get(url_string)\n data = {\n \"latitude\": @traces.latitude,\n \"longitude\": @traces.longitude,\n \"elevation\": response.body.to_i\n }\n render json: data\n end",
"def show\n @character = Character.find(params[:id])\n @json = Character.find(params[:id]).to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @character }\n end\n end",
"def show\n @county= County.find(params[:id])\n end",
"def show\n @federal1870_census_entry = Federal1870CensusEntry.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @federal1870_census_entry }\n end\n end",
"def show\n @county = params[:county] ?\n County.find_by_path_elements(params[:state], params[:county]) :\n County.find_by_full_path(params[:id])\n\n raise ActiveRecord::RecordNotFound unless @county\n\n @county = @county.decorate\n\n breadcrumbs.add(url: '/graveyards', title: 'Cemetery Lists')\n if @state=@county.state\n breadcrumbs.add(url: @state.to_url, title: \"#{@state.name}\")\n end\n breadcrumbs.add(url: @county.to_url, title: \"#{@county.fancy_name_with_state}\")\n\n self.page_title=@county.fancy_name_with_state.to_s + \" Cemetery List\"\n breadcrumbs.here.title = \"List\"\n\n @graveyards = @county.graveyards.order(:name).includes(:county)\n @visits=UserVisitsCollection.new(current_user)\n @visits.add_graveyards(@graveyards)\n\n respond_to do |fmt|\n fmt.kml {\n set_filename \"#{@county.fancy_name} Cemeteries.kml\"\n }\n fmt.html { }\n end\n end",
"def render_politics\n render json: PoliticsSerializer.new(@politics_data).to_serialized_json\n end",
"def show\n @locationmap = Locationmap.find(params[:id])\n @json=@locationmap.to_gmaps4rails\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @locationmap }\n end\n end",
"def show\n @carea = Carea.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @carea }\n end\n end",
"def curation_activity_popup\n respond_to do |format|\n @resource = Resource.includes(:identifier, :curation_activities).find(params[:id])\n @curation_activity = StashEngine::CurationActivity.new(resource_id: @resource.id)\n format.js\n end\n end",
"def show\n parameters = params[:id]\n new_params = CGI.parse(parameters)\n country_id = new_params[\"country_id\"][0].to_i\n cod_id = new_params[\"cod_id\"][0].to_i\n @country = Country.find(country_id)\n @cod = Cod.find(cod_id)\n @charities = Charity.where(:cod_id => cod_id, :country_id => country_id)\n end",
"def show\n @subcriterion = Subcriterion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subcriterion }\n end\n end",
"def show\n @client = Client.find(params[:id])\n @pets = @client.pets\n @json = @client.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client }\n end\n end",
"def show\n @overlay = Overlay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @overlay }\n end\n end",
"def mountain_area_forecast(location_id)\n query(\"txt/wxfcs/mountainarea/json/#{location_id}\")\n end",
"def show\n @researcharea = Researcharea.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @researcharea }\n end\n end",
"def new\n attrs = {}\n [:area_id, :logistic_id].each do |name|\n attrs[name] = params[name] if params[name].present?\n end\n @core_logistic_area = Core::LogisticArea.new(attrs)\n respond_to do |format|\n format.js {}\n format.html {}\n end\n end",
"def show\n # binding.pry\n @place = Place.find(params[:id])\n @place_json = Place.find(params[:id]).as_json({ :properties => :all })\n @json = Place.find(params[:id]).to_gmaps4rails\n @comments = @place.comments\n @rates = @place.rates\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:place_info => @place_json, :comments => @comments, :rating => @place.average_rating} }\n end\n end",
"def show\n @incident_kind = IncidentKind.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incident_kind }\n end\n end",
"def create\n @constituency = Constituency.new(params[:constituency])\n\n respond_to do |format|\n if @constituency.save\n flash[:notice] = 'Constituency was successfully created.'\n format.html { redirect_to(@constituency) }\n format.xml { render :xml => @constituency, :status => :created, :location => @constituency }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @constituency.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def geo(place_id)\n get \"/geo/id/#{place_id}.json\"\n end",
"def show\n @property = Property.find(params[:id])\n @json = @property.to_gmaps4rails\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @property }\n end\n end",
"def show\n @contractor_feature = ContractorFeature.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contractor_feature }\n end\n end",
"def show\n #@world_map = WorldMap.find(params[:id])\n if params.has_key?(:x) && params.has_key?(:y)\n @x = params[:x].to_i if params.has_key?(:x)\n @y = params[:y].to_i if params.has_key?(:y)\n end\n @radius = params[:radius].to_i if params.has_key?(:radius)\n if @character\n @x = @character.xloc\n @y = @character.yloc\n end\n @x ||= 50; @y ||= @x; @radius ||= 7\n @world_map = WorldMap.new\n respond_to do |format|\n format.js\n format.html # show.html.erb\n format.json { render json: @world_map }\n end\n end",
"def shape\n=begin\n\t\tgeometries = Rails.cache.fetch(MEMORY_CACHE_KEY_SHAPE.gsub(\"[shape_id]\", params[:id])\n\t\t\t\t.gsub(\"[locale]\", I18n.locale.to_s)\n\t\t\t\t.gsub(\"[shape_type_id]\", params[:shape_type_id])) {\n\t\t\tShape.build_json(params[:id], params[:shape_type_id]).to_json\n\t\t}\n=end\n\t\tkey = FILE_CACHE_KEY_SHAPE.gsub(\"[shape_id]\", params[:id])\n\t\t\t.gsub(\"[locale]\", I18n.locale.to_s)\n\t\t\t.gsub(\"[shape_type_id]\", params[:shape_type_id])\n\t\tgeometries = JsonCache.fetch_shape(key) {\n \t\tShape.build_json(params[:id], params[:shape_type_id]).to_json\n\t\t}\n\n respond_to do |format|\n format.json { render json: geometries }\n end\n end",
"def show\n @filter = Filter.find(params[:id])\n\n @area = @filter.polygon\n\n if @filter.edited && (@filter.include_markers_for == 0 || @filter.include_markers_for == 1)\n #@listings = []\n #@listings = Listing.where(:area.in => @filter.areas)\n @listings = Listing.where(location: {\n '$geoWithin' => {\n '$geometry' => {\n type: 'Polygon',\n coordinates: [\n @filter.polygon\n ]\n }\n }\n })\n @listings_agent_ids = []\n @listings.each do |listing|\n @listings_agent_ids.push listing.agent_id\n end\n @all_agents = Agent.where(:id.in => @listings_agent_ids)\n else\n @listings = []\n @all_agents = []\n end\n\n if @filter.edited && (@filter.include_markers_for == 0 || @filter.include_markers_for == 2)\n @agents = Agent.where(location: {\n '$geoWithin' => {\n '$geometry' => {\n type: 'Polygon',\n coordinates: [\n @filter.polygon\n ]\n }\n }\n })\n else\n @agents = []\n end\n\n @location = [-0.167, 51.474]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @filter }\n end\n end",
"def create\n @core_logistic_area = Core::LogisticArea.new(core_logistic_area_params)\n\n respond_to do |format|\n if params[:btn_cancel].present?\n format.html { redirect_to(action: \"index\")}\n format.json { head :no_content}\n format.js {}\n elsif @core_logistic_area.save\n format.html { redirect_to @core_logistic_area, notice: 'Logistic area was successfully created.' }\n format.json { render action: 'show', status: :created, location: @core_logistic_area }\n format.js { find_relates_by_from }\n else\n find_from_objects\n format.html { render action: 'new' }\n format.json { render json: @core_logistic_area.errors, status: :unprocessable_entity }\n format.js do \n find_from_objects\n render action: 'new'\n end\n end\n end\n end",
"def show\n @community = @district.communities.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @community }\n end\n end",
"def show\n respond_to do |format|\n format.html { render :show }\n format.json { render json: Oj.dump(@curriculum) }\n end\n end",
"def show\n @incident = Incident.find(params[:id])\n\n render json: @incident\n end",
"def show\n @golf_cource = GolfCource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @golf_cource }\n end\n end",
"def show\n @city_district = CityDistrict.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @city_district }\n end\n end",
"def show\n @reading = Reading.find(params[:id])\n @json = @reading.to_gmaps4rails\n end",
"def show\n @city_measurement = CityMeasurement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @city_measurement }\n end\n end",
"def matching_indices\n ids = RegionLethality.get_regions(params[:max])\n @provinces = Province.where(id: ids)\n\n respond_to do |format|\n format.json do\n feature_collection = Province.to_feature_collection @provinces\n render json: RGeo::GeoJSON.encode(feature_collection)\n end\n\n format.html\n end\n end",
"def show\n @place = Place.find(params[:id])\n @comment = Comment.new(place_id: @place.id)\n @json = Place.find(params[:id]).to_gmaps4rails\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @place }\n end\n end"
] |
[
"0.6665441",
"0.62658805",
"0.560211",
"0.55548006",
"0.55038095",
"0.5484718",
"0.5409774",
"0.54057163",
"0.5393519",
"0.5364922",
"0.53348184",
"0.531092",
"0.5278387",
"0.5256406",
"0.5243053",
"0.5214157",
"0.52126855",
"0.52115476",
"0.51657003",
"0.5163363",
"0.5145046",
"0.51394165",
"0.5121005",
"0.51013166",
"0.50847703",
"0.5053798",
"0.5048605",
"0.5045312",
"0.5039666",
"0.50280505",
"0.5024384",
"0.501757",
"0.5000629",
"0.49983704",
"0.4988779",
"0.4977166",
"0.4976577",
"0.49711812",
"0.49637058",
"0.49620554",
"0.49450725",
"0.49441713",
"0.49354336",
"0.4912681",
"0.4903422",
"0.489661",
"0.48750466",
"0.48690808",
"0.48632798",
"0.48606592",
"0.48605227",
"0.4858327",
"0.48535007",
"0.48533133",
"0.48450488",
"0.48379412",
"0.48368675",
"0.48368675",
"0.48335478",
"0.4829164",
"0.48289895",
"0.48182794",
"0.4814955",
"0.48133534",
"0.48050654",
"0.480251",
"0.4801795",
"0.4797991",
"0.4797684",
"0.47965044",
"0.47947297",
"0.47896945",
"0.47861373",
"0.47783566",
"0.47776413",
"0.47772914",
"0.47718173",
"0.47651365",
"0.47627804",
"0.47624716",
"0.4760051",
"0.4757628",
"0.47564897",
"0.47547597",
"0.47529674",
"0.4751692",
"0.47429657",
"0.47319156",
"0.4720122",
"0.47194487",
"0.47181004",
"0.47096562",
"0.47046626",
"0.47026142",
"0.46915868",
"0.4687249",
"0.4685501",
"0.46824354",
"0.46821302",
"0.46819654"
] |
0.6267736
|
1
|
UC1 Put nformation about vendors and products of ones
|
def put_vendor_contract(q)
$LOG.info('put_vendor_contract');
@VENDOR=q["VENDOR"];
@PRODUCT=q["PRODUCT"];
@VID=@VENDOR["VID"];
@PRODUCT["VID"]=@VID;
# CHECK IN CACHE VENDOR
@vendor=$CACHE.get("VENDOR",@VID)
# IF NOT IN CACHE CHECK IN STORE
if (@vendor == nil)
# IF IN STORAGE RENEW IN CACHE
@vendor=$STORAGE.get("VENDOR",@VID)
if (@vendor == nil)
# IF NOT IN STORAGE - ADD NEW VENDOR AND PRODUCT OF ONE
$STORAGE.put("VENDOR",@VID,@VENDOR)
@vendor=$STORAGE.get("VENDOR",@VID)
end
# AND IF OK - PUT TO THE CACHE
if (@vendor != nil)
$CACHE.put("VENDOR",@VID,@vendor)
end
end
if (@vendor != nil) # IF VENDOR OK PUT NEW PRODUCT !!!!
put_product(@PRODUCT)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sku_combination_creation\n end",
"def add_vendor\n vendor = @product_row[:vendor].match(/[\\D\\s]*/)\n vendors = Spree::Vendor.where(\"name ILIKE ?\", \"%#{vendor[0].strip}%\")\n if !(vendors.empty?)\n if(@product_row[:vendor].match(/goers/i))\n notes = notes = \"\" ? @product_row[:vendor] : notes + \", \" + @product_row[:vendor]\n end\n\n @new_product_vendor = Spree::ProductVendor.create :variant_id => @new_product_condition.id,\n :vendor_id => vendors.first.id,\n :vendor_part_number => @product_row[:vendor_part_number],\n :vendor_price => @product_row[:vendor_price],\n :notes => notes\n else\n @errors << { :part_number => @product_row[:name], :condition => @product_row[:condition], :message => \"Could not match vendor \" + @product_row[:vendor] }\n end\n end",
"def set_product\n \n end",
"def manufacture; end",
"def products\n end",
"def product_skus_json\n @product_skus_json = []\n @order = Spree::Order.find_by_id(params[:order_id])\n @products = @order.seller.products.where(:kit_id=>nil) if @order.present?\n @products.each do |product|\n product_variants = []\n product_variants << (product.variants.present? ? product.variants : product.master)\n product_variants = product_variants.flatten\n product_variants.each do |pv|\n #name = (pv.option_values.present? ? (product.name+\" -> \"+pv.option_values.first.presentation+\" (\"+pv.sku.to_s+\")\") : (product.name+\" (\"+pv.sku.to_s+\")\"))\n if !pv.parent_id.present?\n name = pv.sku.to_s\n @product_skus_json << {'label' => name, 'id' => pv.id} if name.downcase.include? params[:term].downcase\n end\n end\n end if @products.present?\n render :json=>@product_skus_json.to_json\n end",
"def set_vendor_item\n @product = Product.find(params[:product_id])\n @vendor_item = @product.vendor_items.find(params[:id])\n end",
"def create\n if params[:stage] == '1'\n if params[:variants] == 'ONE SIZE' \n @products = ProductProduct.create(\n name: params[:name],\n cost_method: 'standard',\n description: params[:description],\n procure_method: 'make_to_order',\n supply_method: 'buy',\n sale_ok: 'true', #Cand be Purchased\n purchase_ok: 'true', #Can be Sold\n weight: params[:weight],\n company_id: 3,\n default_code: params[:default_code], #ref\n list_price: params[:list_price], #sale_price\n standard_price: params[:standard_price], #cost\n property_account_income: 197, #income_account\n property_account_expense: 205, #cogs_account\n type: 'product' #product_type ('product' = stockable_product)\n )\n else \n @products = ProductProduct.create(\n name: params[:name],\n cost_method: 'standard',\n description: params[:description],\n procure_method: 'make_to_order',\n supply_method: 'buy',\n sale_ok: 'true', #Cand be Purchased\n purchase_ok: 'true', #Can be Sold\n weight: params[:weight],\n variants: params[:variants],\n company_id: 3,\n default_code: params[:default_code], #ref\n list_price: params[:list_price], #sale_price\n standard_price: params[:standard_price], #cost\n property_account_income: 197, #income_account\n property_account_expense: 205, #cogs_account\n type: 'product' #product_type ('product' = stockable_product)\n )\n end\n elsif params[:stage] == '2'\n @products = ProductSupplierinfo.create(\n name: params[:name],\n min_qty: params[:min_qty],\n product_id: params[:product_id],\n company_id: params[:company_id]\n )\n else\n @products = ProductProduct.create(\n name: params[:name],\n cost_method: 'standard',\n description: params[:description],\n procure_method: 'make_to_order',\n supply_method: 'buy',\n sale_ok: 'true', #Cand be Purchased\n purchase_ok: 'true', #Can be Sold\n weight: params[:weight],\n variants: params[:variants],\n company_id: 3,\n default_code: params[:default_code], #ref\n list_price: params[:list_price], #sale_price\n standard_price: params[:standard_price], #cost\n property_account_income: 197, #income_account\n property_account_expense: 205, #cogs_account\n type: 'product', #product_type ('product' = stockable_product)\n product_tmpl_id: params[:product_tmpl_id].to_i\n ) \n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @products }\n end\n end",
"def create_product(prod)\n\n purchase_price = BigDecimal.new(\"0.0\")\n purchase_price = BigDecimal.new(prod['purchase_price'].to_s) unless prod['purchase_price'].nil?\n sales_price = nil\n sales_price = BigDecimal.new(prod['sales_price']) unless prod['sales_price'].nil?\n weight = 0\n weight = prod['weight'].to_f unless prod['weight'].nil?\n manufacturer_product_code = prod['manufacturer_product_code']\n stock = prod['stock'].to_i unless prod['stock'].nil?\n\n tax_percentage = prod['tax_percentage'] || 8.0\n tax_class = TaxClass.where(:percentage => tax_percentage).first unless tax_percentage.nil?\n if tax_class.nil?\n tax_class = TaxClass.create(:percentage => 8.0, :name => \"8.0\")\n end\n\n prod['description'].blank? ? description = \"No description\" : description = prod['description']\n \n is_featured = false\n is_featured = true if [\"yes\", \"true\", \"1\"].include?(prod['featured'])\n is_visible = true\n is_visible = false if [\"no\", \"false\", \"0\"].include?(prod['visible'])\n is_build_to_order = false\n is_build_to_order = true if [\"yes\", \"true\", \"1\"].include?(prod['build_to_order'])\n \n supplier = Supplier.find_by_name(prod['supplier'])\n\n product = Product.where(:name => prod['name'],\n :description => description,\n :weight => weight,\n :sales_price => sales_price,\n :supplier_id => supplier,\n :tax_class_id => tax_class,\n :purchase_price => purchase_price,\n :manufacturer_product_code => manufacturer_product_code,\n :is_featured => is_featured,\n :is_visible => is_visible,\n :is_build_to_order => is_build_to_order,\n :stock => stock).first\n if product.nil?\n product = Product.create(:name => prod['name'],\n :description => description,\n :weight => weight,\n :sales_price => sales_price,\n :supplier => supplier,\n :tax_class => tax_class,\n :purchase_price => purchase_price,\n :manufacturer_product_code => manufacturer_product_code,\n :is_featured => is_featured,\n :is_visible => is_visible,\n :is_build_to_order => is_build_to_order,\n :stock => stock)\n end\n if prod['category']\n category = Category.where(:name => prod['category']).first\n category = Category.create(:name => prod['category']) if category.nil?\n product.categories << category\n product.save\n end\n\n\n # Ugly, but at least it makes test authors know what went wrong\n if product.errors.empty?\n return product\n else\n puts \"Errors creating product: #{product.errors.full_messages}\"\n return false\n end\nend",
"def create_full_product\n generate_product_name\n generate_product_code\n generate_product_manufacturer\n generate_product_description\n generate_product_price\n end",
"def vendor_params\n params.require(:vendor).permit(:name, :label, :phone1, :phone2, :other_details, :mta_partner)\n end",
"def vendor; end",
"def product_info\n {\n product_name: {\n default_value: 'similarity detection reference tool'\n },\n product_version: '1.0',\n description: {\n default_value: 'LTI 2.1 tool provider reference implementation'\n },\n product_family: {\n code: 'similarity detection reference tool',\n vendor: {\n code: 'Instructure.com',\n vendor_name: {\n default_value: 'Instructure'\n },\n description: {\n default_value: 'Canvas Learning Management System'\n }\n }\n }\n }\n end",
"def new\n logger.debug \"==> EC.n 0: #{params.inspect}\"\n @endorsement = Endorsement.new\n @marker = Endorsement.new\n @products = Array.new\n if params[:product] == \"Beverage\"\n @marker = Beverage.find(:first)\n @products = Beverage.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n #@beverages.each { |x| x.insert(1, \"Beverage\") }\n elsif params[:product] == \"Fashion\"\n @marker = Fashion.find(:first)\n @products = Fashion.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n elsif params[:product] == \"Snack\"\n @marker = Snack.find(:first)\n @products = Snack.find(:all, :order => \"name ASC\",\n :select => \"id, name\").map {|b|\n [b.name, b.id]}\n else\n logger.debug \"==> EC.n 0.1\"\n @bev = Beverage.new\n @products.concat(@bev.get_all_for_select)\n @fas = Fashion.new\n @products.concat(@fas.get_all_for_select)\n @sna = Snack.new\n @products.concat(@sna.get_all_for_select)\n logger.debug \"==> EC.n 0.4\"\n\n #this returns items that only exist in endorsements\n #not a meta table of all items. need outer join.\n #@zoo = Endorsement.find(:all, \n # :include => [:beverage, :snack, :fashion],\n # :joins => [:beverage, :snack, :fashion]).map do |x|\n # x.endorseable.name\n #end\n #@fun = Endorsement.find(:all).map { |x| x.endorseable.name }\n\n #@products.concat(@fashions)\n #@products.concat(@snacks)\n #@e = Endorsement.new\n #@products = @e.get_products_select\n=begin\n @products = Endorsement.find(:all, \n :select => \"endorseable_id, endorseable_type\").map {|b|\n [b.endorseable.name, b.endorseable_id]}\n=end\n #remove this from the above find statement\n # :include => [:beverage, :fashion, :snack],\n end\n #@beverages.each { |x| @products << x }\n #@fashions.each { |x| @products << x }\n #@snacks.each { |x| @products << x }\n logger.debug \"==> EC.n 0.3: #{@products.inspect}\"\n logger.debug \"==> EC.n 0.4: #{@marker.inspect}\"\n logger.debug \"==> EC.n 0.5: #{@marker.class}\"\n=begin\n below is the way to get stuff for dropdown from endorsement\n via interface endorseable\n @beverages = Endorsement.find(:all,\n :select => \"endorseable_id, endorseable_type\").map {|b|\n [b.endorseable.name, b.endorseable_id]}\n=end\n @players = Player.find(:all, :order => \"lastname ASC\",\n :select => \"id, firstname, lastname\").map {|p|\n [\"#{p.lastname}, #{p.firstname}\", p.id]}\n @x = Player.find(:first)\n @b = Beverage.find(:all)\n #logger.debug \"==> EC.n 1: #{@beverages.class}\"\n #logger.debug \"==> EC.n 1.1: #{@beverages.empty?}\"\n #logger.debug \"==> EC.n 1.2: #{@beverages.inspect}\"\n logger.debug \"==> EC.n 2: #{@players.class}\"\n logger.debug \"==> EC.n 2.1: #{@players.empty?}\"\n logger.debug \"==> EC.n 2.2: #{@players.inspect}\"\n logger.debug \"==> EC.n 3: #{@x.endorsements.inspect}\"\n logger.debug \"==> EC.n 4: #{@b.class}\"\n logger.debug \"==> EC.n 4.1: #{@b.empty?}\"\n logger.debug \"==> EC.n 4.2: #{@b.inspect}\"\n\n=begin\n @endorsement = Endorsement.find(:all,\n :select => \"id, name, lastname\").map {|p|\n [p.firstname, p.lastname, p.id]}\n=end\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @endorsement }\n end\n end",
"def make_vendor index, rep_key, company_key\n %{INSERT INTO vendors VALUES (#{index}, #{rep_key}, #{company_key});}\nend",
"def create\n @product = Product.new(params[:product])\n #@product = Product.create(vendor_id: @vendor.id)\n #@vendor = Vendor.all\n #@product = @vendor.products.create(product_date :Time.now, vendor_id: @vendor.id)\n respond_to do |format|\n if @product.save\n format.html { redirect_to @product, notice: 'Product was successfully created.' }\n format.json { render json: @product, status: :created, location: @product }\n else\n format.html { render action: \"new\" }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def vendor_params\n params.require(:vendor).permit(:name, :about, :email, :website_url, :category, :image)\n end",
"def setup_catalog\n [\n {product_name: 'bamba', photo_url: 'dummy_url1', barcode: 'xxx1', sku: 111, price: 2.23, producer: 'Nestle'},\n {product_name: 'apple', photo_url: 'dummy_url2', barcode: 'xxx2', sku: 555, price: 4.66, producer: 'WFM'},\n {product_name: 'tapu chepse', photo_url: 'dummy_url3', barcode: 'xxx3', sku: 1111444, price: 7.33, producer: 'Nestle'}\n ].each do |data|\n Catalog.create(data)\n end\n end",
"def vendor_params\n params.require(:vendor).permit(:bank, :bank_account, :branch_code, :account_number, :family_name, :first_name, :post_number, :city,:address, :building_name, :created_at, :updated_at, :prefecture_id ).merge(user_id: current_user.id)\n end",
"def fill_in_products\n products = []\n @data.products.all_products.each_with_index do |p, i|\n prod = {}\n prod['index'] = i\n prod['qty'] = @data.product_qty[p.prd_id]\n prod['desc'] = p.prd_long_desc\n prod['price'] = \"$\" + p.fmt_total_price\n prod['prd_id'] = p.prd_id\n products << prod\n end\n \n products\n end",
"def vendor_product_params\n params.require(:vendor_product).permit(:title, :body, :product_type, :image, :publish)\n end",
"def setup_broker_requests(broker)\n broker.license_type.each_with_index do |l,index| \n license=broker.licenses.create(license_type:l,license_number:\"test#{index}\")\n license.license_image=(Rails.root+\"spec/fixtures/test_files/example_license.pdf\").open\n license.save\n end\n \n @license1=License.all.first\n @license2=License.all.second\n broker.broker_requests.create(request_type:\"create account\",complement:false) \n broker.reload\n broker.licenses.each do |l|\n broker.broker_requests.create(request_type:\"create license\", license_id:l.id,complement:true,admin_reply:nil)\n end\n\nend",
"def get_skus\n if params[:id].present?\n @msg = 'nothing'\n respond_to do |format|\n format.json { render :json => {:variant => @msg }}\n return\n end\n end\n\n @product = Spree::Product.find(params[:product_id])\n self_parent = @product.variants.map(&:parent_id)\n self_parent << @product.master.id\n self_parent = self_parent.flatten\n @variant = params[:variant]\n @products = @product.seller.products.where(:is_approved=>true)\n @product_hash = []\n @products.each do |product|\n product_variants = []\n product_variants << (product.variants.present? ? product.variants : product.master)\n product_variants = product_variants.flatten\n product_variants.each do |pv|\n if !pv.parent_id.present? && !(self_parent.include? pv.id)\n if pv.option_values.present?\n @product_hash << {:name=> (product.name+\" -> \"+pv.option_values.first.presentation+\" (\"+pv.sku.to_s+\")\"), :id=>pv.id}\n else\n @product_hash << {:name=> (product.name+\" (\"+pv.sku.to_s+\")\"), :id=>pv.id}\n end\n end\n end\n end if @products.present?\n @variant = Spree::Variant.new(:product_id => @product.id)\n @variant.attributes = @variant.product.master.attributes.except('id', 'created_at', 'deleted_at',\n 'sku', 'is_master')\n # Shallow Clone of the default price to populate the price field.\n @variant.default_price = @variant.product.master.default_price.clone\n respond_to do |format|\n format.html { render :partial=>\"map_variant\", :locals => {:product => @product, :variant => @variant}}\n end\n end",
"def products=(dummy)\n end",
"def test_products()\n assert_equal(1, @manufacturer1.products.length())\n end",
"def set_product\n if !@products\n @products = Product.all\n end\n price_ranges = [ {to: 10 }, {from: 10.01, to: 20 }, {from: 20.01, to: 30 }, {from: 30.01}]\n if !@producss\n @producss = Product.search \"*\", aggs: {price: {ranges: price_ranges}, category_id: {}, condition_id: {}, date: {}}\n end\n if !@producs\n @producs = Product.search(params.fetch(:name, \"*\")).to_a\n end\n end",
"def add_item_value_twenty_four\n response_search = Partay.get('http://shoponline.tescolotus.com/api/v1/search/products?query=Sugar&page=1&sortBy=Relevance', :headers => {'Content-Type' => 'application/json', 'language' => 'en-gb', 'region' => 'TH', 'userId' => access_token})\n puts search_result=JSON(response_search['productItems'][0])\n puts productid =JSON(search_result)[\"product\"][\"id\"]\n items_json_responses = {'items' => [{'id'=>'6071448594','oldValue'=>0.0,'oldUnitChoice'=>'pcs','newUnitChoice'=>'pcs','newValue'=>24.0}]}.to_json\n puts items_json_responses\n response = Partay.put('http://shoponline.tescolotus.com/api/v1/trolley/items/', :headers => {'Content-Type' => 'application/json', 'language' => 'en-GB', 'region' => 'TH', 'userId' => access_token}, :body => items_json_responses)\n puts response\n end",
"def create_sku_combination(arr, number, user)\n Sku.create(sku_denomination: number, sku_combination: arr*\",\", user_id: user.id)\n end",
"def set_vendor_product\n @vendor_product = VendorProduct.find(params[:id])\n end",
"def omega\n products = GetProducts.new.send_request\n SaveProducts.new(products[:productRecords]).save\n end",
"def vendor_params\n params.require(:vendor).permit(:name, :image, :description, :search_tags, :email, :phone_number, :password, :password_confirmation)\n end",
"def fill_catalogue()\n @@products.clear\n add_product(Fruit.new(\"Apples\", 10))\n add_product(Fruit.new(\"Oranges\", 5))\n add_product(Fruit.new(\"Banana\", 20))\n add_product(Fruit.new(\"Watermelon\", 1))\n add_product(Houseware.new(\"Vacuum cleaner\", 150))\n add_product(Product.new(\"Anchovies\",2))\n end",
"def create\n components = params[:components]\n str = ''\n i = 0\n components.try(:each) do |c|\n str = if i == 0\n c.to_s\n else\n str.to_s + ',' + c.to_s\n end\n i += 1\n end\n\n @professional_tax_master = ProfessionalTaxMaster.new(professional_tax_master_params)\n @professional_tax_master.base_component = str\n @professional_tax_masters = ProfessionalTaxMaster.all\n @professional_tax_master.save\n @professional_tax_master = ProfessionalTaxMaster.new\n end",
"def create\n @vendor = Vendor.new(vendor_params)\n @old_vendor = params[:previos_vendor]\n copy_contacts(@old_vendor) unless @old_vendor.blank?\n @vendor.mta_partner = params[:mTAButton].present? ? true : false\n respond_to do |format|\n if @vendor.save\n successful_create(format)\n else\n unless @old_vendor.blank?\n @clone = true\n @old_vendor = Vendor.find(@old_vendor)\n end\n unsuccessful_create(format)\n end\n end\n end",
"def set_attributes_and_image( prod , row )\n if prod.class == Product\n prod.name = at_in(:name,row) if at_in(:name,row)\n prod.description = at_in(:description, row) if at_in(:description, row)\n end\n set_sku(prod , row)\n set_weight(prod , row)\n set_dimensions(prod, row)\n set_available(prod, row)\n set_price(prod, row)\n add_image( prod , row)\n end",
"def vendor_params\n params.require(:vendor).permit(:name)\n end",
"def audit_tirerack_properties\n mfg_list = get_manufacturer_list\n manufacturer_property = Property.find_by_name('manufacturer')\n counter = 0\n Product.in_taxon('Tires').each do |tire|\n mfg_list.each do |mfg|\n if tire.taxons.map(&:name).include?(mfg)\n # does this tire have the manufacturer property! If not make it so...\n if !tire.properties.include?('manufacturer')\n ProductProperty.create(:product_id => tire.id, :property_id => manufacturer_property.id, :value => mfg)\n counter += 1\n end\n end\n end\n end\n puts \"Updated #{counter} Tire Products to have an appropriate manufacturer Property\\n\"\n end",
"def setup(params)\n self.delivery = '1' == params['delivery']\n if !params['sku'].empty?\n self.sku = params['sku'].strip\n end\n end",
"def assign_products(row, input, pubYear)\n products = []\n base = ''\n\n if( pubYear < 2020 )\n base = 'bar_pre2020_collection'\n else\n base = \"bar_#{pubYear}_annual\"\n end\n products.push base\n\n case input['Series']\n when 'BAR British Series'\n products.push base+='_brit'\n when 'BAR International Series'\n products.push base+='_int'\n end\n\n i = 1\n products.each { |p|\n row[\"Fulcrum Product #{i}\"] = p\n i += 1\n }\n\nend",
"def vendor_params\n params.require(:vendor).permit(:category_id,:title,:name,:content,:cover_img)\n end",
"def index\n requestd = Vacuum.new\n unless params[:page].present?\n params[:page] = 1\n end\n requestd.configure(aws_access_key_id: 'AKIAIP4ABLWHY7ANK2TQ',aws_secret_access_key: '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',associate_tag: 'bstoda-20' )\n response = requestd.item_search(query: {'SearchIndex' => 'FashionWomen','Keywords' => 'shoes,Handbags & Wallets','ResponseGroup' => \"ItemAttributes,Images\",:ItemPage => params[:page]})\n response_shoes = requestd.item_search(query: {'SearchIndex' => 'FashionWomen','Keywords' => 'shoes','ResponseGroup' => \"ItemAttributes,Images\",:ItemPage => params[:page]})\n hashed_response_shoes = response_shoes.to_h\n hashed_products = response.to_h\n @products = []\n \n hashed_products['ItemSearchResponse']['Items']['Item'].each do |item|\n product = OpenStruct.new\n product.asin = item['ASIN']\n product.name = item['ItemAttributes']['Title']\n product.price = item['ItemAttributes']['ListPrice']['FormattedPrice'] if item['ItemAttributes']['ListPrice']\n #product.url = item['DetailPageURL']\n product.feature = item['ItemAttributes']['Feature']\n product.image_url = item['MediumImage']['URL'] if item['LargeImage']\n product.link = item['ItemLinks']['ItemLink'][5]['URL']\n @products << product\n end\n hashed_response_shoes['ItemSearchResponse']['Items']['Item'].each do |item|\n product = OpenStruct.new\n product.asin = item['ASIN']\n product.name = item['ItemAttributes']['Title']\n product.price = item['ItemAttributes']['ListPrice']['FormattedPrice'] if item['ItemAttributes']['ListPrice']\n #product.url = item['DetailPageURL']\n product.feature = item['ItemAttributes']['Feature']\n product.image_url = item['MediumImage']['URL'] if item['LargeImage']\n product.link = item['ItemLinks']['ItemLink'][5]['URL']\n @products << product\n end\n\n respond_to do |format|\n format.js\n format.html\nend\n end",
"def update\n components = params[:components]\n str = ''\n i = 0\n components.try(:each) do |c|\n str = if i == 0\n c.to_s\n else\n str.to_s + ',' + c.to_s\n end\n i += 1\n end\n @professional_tax_master.base_component = str\n @professional_tax_master.update(professional_tax_master_params)\n @professional_tax_masters = ProfessionalTaxMaster.all\n @professional_tax_master = ProfessionalTaxMaster.new\n\n end",
"def show\n \n @product = Product.find(params[:id])\n @vendors = @product.vendor(:all)\n #@vendors = Vendor.find(params[:id])\n #@vendors = Vendor.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product }\n end\n end",
"def skus=(list)\n list.each do |s|\n if s.class == Array then\n qty = s[1]\n s = s[0]\n end\n item = Item.get_by_code(s)\n if item then\n if item.class == LoyaltyCard then\n self.customer = item\n else\n oi = self.add_item(item)\n if qty then\n oi.quantity = qty\n end\n end\n end #if item\n end # end list.each\n end",
"def api_v1_product_params\n params.permit(:name, :sku, :type, :price)\n end",
"def increment_units\n contents.each do |key,content|\n id = content[\"_id\"] || content[\"item_id\"]\n begin\n \n product = shop.products.find(id)\n return false if product.nil? || product.dont_track_quantities?\n\n new_pv = []\n\n if product.price_variants.length==1\n\n new_pv = product.price_variants.first\n new_pv['quantity'] = new_pv['quantity'].to_i+content['quantity'].to_i\n product.num_orders = [product.num_orders-content['quantity'].to_i].max\n product.price_variants = [ new_pv ]\n\n else\n\n product.price_variants.each do |pv|\n name = [pv['primary'],pv['secondary']].join(\" \").downcase.trim\n name = \"\" if name==\" \"\n if name==content['variant_name'].trim.downcase && !pv['quantity'].blank?\n new_pv << pv.merge( 'quantity' => (pv['quantity'].to_i+content['quantity'].to_i) )\n else \n new_pv << pv\n end\n end\n product.num_orders = [product.num_orders-content['quantity'].to_i].max\n product.price_variants = new_pv\n\n end\n product.save\n\n rescue Exception => e\n ::Exceptional::Catcher.handle(e)\n # raise(e)\n end\n end\n end",
"def vendor_info\n ioss_vendor_collect_id = '0356'\n\n Element.new('VendorInfo').tap do |vendor_info|\n vendor_info << element_with_value('VendorCollectIDNumber', opts[:sender_ioss_number] || '')\n vendor_info << element_with_value('VendorCollectIDTypeCode', ioss_vendor_collect_id)\n vendor_info << element_with_value('ConsigneeType', '02')\n end\n end",
"def set_product1\n @sub_category = SubCategory.find_by_name(params[:name].tr('-',' '))\n @products = Product.where(sub_category_id: @sub_category.id)\n end",
"def vendor_table\n update unless @vendor_table\n @vendor_table\n end",
"def add_provenance(microtiter_plate:, pooling_groups:)\n pooling_groups.each do |pooling_group|\n microtiter_plate.associate_provenance_next_empty(\n key: :specimens,\n data: pooling_group.map { |item| hash_data(item) }\n )\n end\n microtiter_plate\n end",
"def set_vendors\n @promotion = Promotion.find(params[:promotion_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 shopify_object\n Nokogiri::XML::Builder.new{ |xml|\n xml.items {\n ShopifyAPI::Product.all.each do |product|\n variant_root = product.variants.first\n xml.item {\n xml.sku variant_root.sku\n # == Google based Parameters ==\n # xml.parent_sku\n # xml.multipack_amount\n # xml.is_bundle\n # == Collections related Parameters ==\n set_product_collections(xml, product)\n # == Variants related Parameters ==\n set_product_variants(xml, product)\n # == Other Parameters ==\n xml.product product.title\n xml.description product.body_html if product.body_html.present?\n xml.brand product.vendor if product.vendor.present?\n xml.gtin variant_root.barcode if variant_root.barcode.present?\n xml.image_url product.image.src if product.image.present?\n xml.price variant_root.price if variant_root.price.present?\n xml.stock_amount variant_root.inventory_quantity if variant_root.inventory_quantity.present?\n xml.stock_available (variant_root.inventory_quantity != 0 ) if variant_root.inventory_quantity.present?\n }\n end\n }\n }.to_xml\n end",
"def create\n init = params[:sku][:name][0]\n brand_id = Brand.find_by_name(params[:brand_id])\n sku_number = Sku.create_number(params)\n @sku = Sku.new(sku_params.merge(:code => (('%03d' % ((Sku.last.code.to_i rescue 0)+1)))).merge(:brand_id => brand_id.id))\n if @sku.save\n flash[:notice] = 'Divisi berhasil ditambahkan'\n redirect_to skus_path\n else\n flash[:error] = @sku.errors.full_messages\n render \"new\"\n end\n end",
"def make_and_model\n\tfor i in 0...@manufacturers.count\n\t\tputs \"#{i}. #{@manufacturers[i]}: #{@models[i]}\"\n\t\ti += 1\n\tend\nend",
"def import_vendor_file()\n @worksheet_products.each { |row|\n if(@vendor_row = build_vendor_hash(row))\n import_vendor()\n end\n }\n end",
"def initialize\n @vendors = []\n end",
"def setup\n @products = products(:kit_lapis)\n end",
"def product_params\n params.require(:product).permit(:product_code, :upg_description, :compound, :nec_article, :shielded, :application, :strand_type, :pairs_count, :awg, :stand_count, :stranded, :solid, :putup, :length, :unit_weight_lbs, :unit_weight_kgs, :nom_od, :unit_copper_weight, :carton_quantity, :selected_app)\n end",
"def vendorpart_params\n params.require(:vendorpart).permit(:vendor_id, :part_id, :vendor_part, :price, :quantity)\n end",
"def index\n @gdocs = Gdoc.all\n @datee = Gdoc.obtain_date\n @rowss = Gdoc.obtain_rows\n\n# @filas.each do |n|\n# ProductosNuevos.create(:SKU => n[0], :cliente => n[1], :cantidad => n[2], :utilizado => n[3])\n# end\n end",
"def build_product\n bundle = Bundle.default\n Product.new(name: 'Product 1', measure_ids: ['BE65090C-EB1F-11E7-8C3F-9A214CF093AE'], bundle_id: bundle._id)\nend",
"def vendor_params\n params.require(:vendor).permit(:name, :vendor_type, :phone_number, :mobile_number, :governorate, :address, :lat, :lng)\n end",
"def products\n vendor_ids = vendors.collect { |vendor| vendor.vendor_id}\n CSV.read(PRODUCT_CSV).collect do |line|\n FarMar::Product.new(line) if vendor_ids.include? line[2].to_i\n end\n end",
"def create_product_for(line_item)\n default_tax_category = TaxCategory.find_by_name(\"default\")\n product = Product.create(:name => line_item.title, \n :master_price => line_item.price, \n :description => line_item.title,\n :tax_category_id => default_tax_category ? default_tax_category.id : nil)\n product.save!\n product.variants.create(:product_id => product.id, :sku => line_item.sku, :price => line_item.price)\n product\n end",
"def product_params\n params.require(:product).permit(:image, :title, :sku, :catagory, :price, :description, :subdescription, :install_ids , :quantity, :exvat_price, :buom , :suom)\n end",
"def create\n @copon = Copon.new(copon_params)\n get_product(@copon, params.require(:copon)[:product])\n set_associative_criteria @copon, params.require(:copon)\n\n respond_to do |format|\n if @copon.save\n format.html { redirect_to @copon, notice: 'Copon was successfully created.' }\n format.json { render :show, status: :created, location: @copon }\n else\n format.html { render :new }\n format.json { render json: @copon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @product = current_vendor.vendor_products.new(vendor_product_params)\n\n respond_to do |format|\n if @product.save\n format.html { redirect_to vendor_products_url, notice: 'product was successfully created.' }\n format.json { render :show, status: :created, location: @product }\n else\n format.html { render :new }\n format.json { render json: @product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def vendor_product_params\n params.require(:vendor_product).permit(:product_id, :country, :inventory, :category, :color, :size, :product_price, :price_embroidery)\n end",
"def create\n @vendor = Vendor.new(params[:vendor])\n\t\t@vendor.user_id = current_user.id\n respond_to do |format|\n if @vendor.save\n\t\t\t\tif params[:service]\n\t\t\t\t\tparams[:service].keys.each do |f| \n\t\t\t\t\t\t@vendor.services.create(:name=>f,:is_active=>true)\n\t\t\t\t\tend\n\t\t\t\tend\n format.html { redirect_to @vendor, notice: 'Vendor was successfully created.' }\n format.json { render json: @vendor, status: :created, location: @vendor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vendor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @vendor = current_user.vendors.new(vendor_params)\n\n respond_to do |format|\n if @vendor.save\n format.html { redirect_to @vendor, notice: 'Vendor was successfully created.' }\n format.json { render :show, status: :created, location: @vendor }\n else\n format.html { render :new }\n format.json { render json: @vendor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_products_details; end",
"def product_params\n \tparams.require(:org_product).permit(:name, :tax_amount, {typ_category: :id}, {typ_subcategory: :id}, :price,\n \t:weight_in_grams, :available_quantity, :expiry_date, :description, :online_order_available, :image)\n end",
"def create\n @vendor = Vendor.new(params[:vendor])\n\n respond_to do |format|\n if @vendor.save\n format.html { redirect_to([:admin,@vendor], :notice => 'Vendor was successfully created.') }\n format.xml { render :xml => [:admin,@vendor], :status => :created, :location => @vendor }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @vendor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def comprar sku, cantidad, fechaEntrega\n begin\n #sku = (params[:sku]).to_i\n #cantidad = (params[:cantidad]).to_i\n #fechaEntrega = (params[:fechaEntrega]).to_time\n if sku != nil\n ## Debemos preguntar si el grupo tiene la cantidad del producto que necesitamos\n proveedor = (Proveedor.find_by skuMateriaPrima: sku)\n grupoProveedor = proveedor.grupoProveedor\n ## Nos conectamos a la API para consultar el stock que tienen\n respuestaStock = RestClient.get 'http://integra'+grupoProveedor.to_s+'.ing.puc.cl/api/consultar/'+sku.to_s ,{:Content_Type => 'application/json'}\n hashRespuesStock = JSON.parse respuestaStock\n ## Si el stock que tienen es suficiente creamos la orden de compra\n if hashRespuesStock['stock'] >= cantidad\n ## Buscamos el id del grupo proveedor\n idGrupo = (IdGrupoProduccion.find_by numeroGrupo: grupoProveedor).idGrupo\n ## Creamos la orden de compra\n ## Fecha en el formato pedido!\n fechaEnFormato = (fechaEntrega.to_i) * 1000\n precio = proveedor.precio\n ## En produccion\n ordenCompra=RestClient.put 'http://moto.ing.puc.cl/oc/crear/', {:cliente => '572aac69bdb6d403005fb042', :proveedor => idGrupo, :sku => sku, :fechaEntrega => fechaEnFormato, :cantidad => cantidad, :precioUnitario => precio, :canal => 'b2b'}.to_json, :content_type => 'application/json'#ambiente\n ## En desarrollo\n ##ordenCompra=RestClient.put 'http://moto.ing.puc.cl/oc/crear/', {:cliente => '572aac69bdb6d403005fb042', :proveedor => idGrupo, :sku => sku, :fechaEntrega => fechaEnFormato, :cantidad => cantidad, :precioUnitario => precio, :canal => 'b2b'}.to_json, :content_type => 'application/json'\n ## Ya creada la orden de compra tenemos que ir a la aplicacion del grupo proveedor y exigir dicha cantidad\n hashOrdenCompra = JSON.parse ordenCompra\n ## Enviamos al grupo proveedor la orden de compra\n respuestaEnvioOC = RestClient.get 'http://integra'+grupoProveedor.to_s+'.ing.puc.cl/api/oc/recibir/'+hashOrdenCompra['_id'] ,{:Content_Type => 'application/json'}\n hashEnvioOC = JSON.parse respuestaEnvioOC\n ## Esperamos la respuesta y si es positiva tendriamos que guardarla en una base de datos y esperar que nos llegue la factura, que generara el pago automaticamente\n if hashEnvioOC['aceptado'] == true || hashEnvioOC['aceptado'] == 'true' ## ACA SE CAMBIO\n ## Deberiamos guardar en la base de datos que tenemos una orden aceptada\n puts 'se acepto la orden'\n ## Ver bien la insercion!\n Pedido.create(idPedido: hashOrdenCompra['_id'] , creacion: Time.now , proveedor: idGrupo , cantidad: cantidad.to_i , despachado: 0 , fechaEntrega: fechaEntrega.to_i , estado: 'Aceptada' , transaccion: false)\n else\n ## \n puts 'no me lee que la acepto'\n Pedido.create(idPedido: hashOrdenCompra['_id'] , creacion: Time.now , proveedor: idGrupo , cantidad: cantidad.to_i , despachado: 0 , fechaEntrega: fechaEntrega.to_i , estado: 'Rechazada' , transaccion: false)\n end\n ## Luego hay que esperar que el cliente nos despache\n else\n\n end\n end\n rescue\n ## No compra si se cae, deberia alomejor guardar en el log la informacion por la que se cayo\n end\n\n end",
"def vendor_params\n params.require(:vendor).permit(:name)\n end",
"def put_on_sale(value, params = {})\n all_variants = params[:all_variants] || true\n run_on_variants(all_variants) { |v| v.put_on_sale(value, params) }\n self.touch\n end",
"def perform\n update_null = \" or (stock is null and last_stock_reported_centry is not null)\"\n query = \"stock <> last_stock_reported_centry or ((stock is not null and last_stock_reported_centry is null)#{update_null if ENV[\"UPDATE_NULL_STOCK\"] == \"false\"})\"\n\n ::Product.where(query).each do |local_product|\n resp = centry.put('/conexion/v1/variants/sku.json', {}, {\"sku\": local_product[:sku], \"quantity\": local_product[:stock]})\n if (resp.code == \"200\")\n centry_variant_info = JSON.parse(resp.body)\n local_product[:last_stock_reported_centry] = centry_variant_info[\"quantity\"]\n local_product[:id_product_centry] = centry_variant_info[\"product_id\"]\n local_product.save!\n end\n end\n end",
"def cpes_affected\n vendor_data = @entry.dig('cve', 'affects', 'vendor', 'vendor_data') || []\n vendor_data.map do |vendor_data_entry|\n vendor_name = vendor_data_entry['vendor_name']\n vendor_data_entry\n .fetch('product', {})\n .fetch('product_data', [])\n .map {|product_data_entry| \"#{vendor_name}:#{product_data_entry['product_name']}\"}\n end.flatten.uniq\n end",
"def create\n @product = Product.find(params[:product_id])\n @sku = @product.skus.create!(sku_params)\n #@sku = Sku.new(sku_params)\n\n redirect_to @product\n \n end",
"def createH2KSysType1( elements, sysType1Name )\n locationText = \"HouseFile/House/HeatingCooling/Type1\"\n\n elements[locationText].add_element(sysType1Name)\n if ( sysType1Name == \"Baseboards\" )\n locationText = \"HouseFile/House/HeatingCooling/Type1/Baseboards\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Baseboards/EquipmentInformation\"\n elements[locationText].attributes[\"numberOfElectronicThermostats\"] = \"0\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Baseboards\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Baseboards/Specifications\"\n elements[locationText].attributes[\"sizingFactor\"] = \"1.1\"\n elements[locationText].attributes[\"efficiency\"] = \"100\"\n elements[locationText].add_element(\"OutputCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Baseboards/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\" # Calculated\n elements[locationText].attributes[\"value\"] = \"0\" # Calculated value - will be replaced!\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n elsif ( sysType1Name == \"Furnace\" )\n\n\n stream_out (\"ADDING FURNACE ....\\n\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/EquipmentInformation\"\n elements[locationText].attributes[\"energystar\"] = \"false\"\n elements[locationText].add_element(\"Manufacturer\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace\"\n elements[locationText].add_element(\"Equipment\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Equipment\"\n elements[locationText].attributes[\"isBiEnergy\"] = \"false\"\n elements[locationText].attributes[\"switchoverTemperature\"] = \"0\"\n elements[locationText].add_element(\"EnergySource\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Equipment/EnergySource\"\n elements[locationText].attributes[\"code\"] = \"2\" # Gas\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Equipment\"\n elements[locationText].add_element(\"EquipmentType\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Equipment/EquipmentType\"\n elements[locationText].attributes[\"code\"] = \"1\" # Furnace with cont. pilot\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Specifications\"\n elements[locationText].attributes[\"sizingFactor\"] = \"1.1\"\n elements[locationText].attributes[\"efficiency\"] = \"78\"\n elements[locationText].attributes[\"isSteadyState\"] = \"true\"\n elements[locationText].attributes[\"pilotLight\"] = \"0\"\n elements[locationText].attributes[\"flueDiameter\"] = \"127\"\n elements[locationText].add_element(\"OutputCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Furnace/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\" # Calculated\n elements[locationText].attributes[\"value\"] = \"0\" # Calculated value - will be replaced!\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n elsif ( sysType1Name == \"Boiler\" )\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/EquipmentInformation\"\n elements[locationText].attributes[\"energystar\"] = \"false\"\n elements[locationText].add_element(\"Manufacturer\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler\"\n elements[locationText].add_element(\"Equipment\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Equipment\"\n elements[locationText].attributes[\"isBiEnergy\"] = \"false\"\n elements[locationText].attributes[\"switchoverTemperature\"] = \"0\"\n elements[locationText].add_element(\"EnergySource\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Equipment/EnergySource\"\n elements[locationText].attributes[\"code\"] = \"2\" # Gas\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Equipment\"\n elements[locationText].add_element(\"EquipmentType\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Equipment/EquipmentType\"\n elements[locationText].attributes[\"code\"] = \"1\" # Boiler with cont. pilot\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Specifications\"\n elements[locationText].attributes[\"sizingFactor\"] = \"1.1\"\n elements[locationText].attributes[\"efficiency\"] = \"78\"\n elements[locationText].attributes[\"isSteadyState\"] = \"true\"\n elements[locationText].attributes[\"pilotLight\"] = \"0\"\n elements[locationText].attributes[\"flueDiameter\"] = \"127\"\n elements[locationText].add_element(\"OutputCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/Boiler/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\" # Calculated\n elements[locationText].attributes[\"value\"] = \"0\" # Calculated value - will be replaced!\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n elsif ( sysType1Name == \"ComboHeatDhw\" )\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/EquipmentInformation\"\n elements[locationText].attributes[\"energystar\"] = \"false\"\n elements[locationText].add_element(\"Manufacturer\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw\"\n elements[locationText].add_element(\"Equipment\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Equipment\"\n elements[locationText].add_element(\"EnergySource\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Equipment/EnergySource\"\n elements[locationText].attributes[\"code\"] = \"2\" # Gas\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Equipment\"\n elements[locationText].add_element(\"EquipmentType\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Equipment/EquipmentType\"\n elements[locationText].attributes[\"code\"] = \"1\" # ComboHeatDhw with cont. pilot\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw\"\n elements[locationText].add_element(\"Specifications\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Specifications\"\n elements[locationText].attributes[\"sizingFactor\"] = \"1.1\"\n elements[locationText].attributes[\"efficiency\"] = \"78\"\n elements[locationText].attributes[\"isSteadyState\"] = \"true\"\n elements[locationText].attributes[\"pilotLight\"] = \"25.3\"\n elements[locationText].attributes[\"flueDiameter\"] = \"152.4\"\n elements[locationText].add_element(\"OutputCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/Specifications/OutputCapacity\"\n elements[locationText].attributes[\"code\"] = \"2\" # Calculated\n elements[locationText].attributes[\"value\"] = \"0\" # Calculated value - will be replaced!\n elements[locationText].attributes[\"uiUnits\"] = \"kW\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw\"\n elements[locationText].add_element(\"ComboTankAndPump\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/ComboTankAndPump\"\n elements[locationText].add_element(\"TankCapacity\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/ComboTankAndPump/TankCapacity\"\n elements[locationText].attributes[\"code\"] = \"3\"\n elements[locationText].attributes[\"value\"] = \"151.4\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/ComboTankAndPump\"\n elements[locationText].add_element(\"EnergyFactor\")\n elements[locationText].attributes[\"useDefaults\"] = \"true\"\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/ComboTankAndPump\"\n elements[locationText].add_element(\"TankLocation\")\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/ComboHeatDhw/ComboTankAndPump\"\n elements[locationText].add_element(\"CirculationPump\")\n elements[locationText].attributes[\"isCalculated\"] = \"true\"\n elements[locationText].attributes[\"value\"] = \"0\"\n elements[locationText].attributes[\"hasEnergyEfficientMotor\"] = \"false\"\n\n elsif ( sysType1Name == \"P9\" )\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9\"\n elements[locationText].attributes[\"id\"] = \"0\"\n elements[locationText].attributes[\"numberOfSystems\"] = \"1\"\n elements[locationText].attributes[\"thermalPerformanceFactor\"] = \"0.9\"\n elements[locationText].attributes[\"annualElectricity\"] = \"1800\"\n elements[locationText].attributes[\"spaceHeatingCapacity\"] = \"23900\"\n elements[locationText].attributes[\"spaceHeatingEfficiency\"] = \"90\"\n elements[locationText].attributes[\"waterHeatingPerformanceFactor\"] = \"0.9\"\n elements[locationText].attributes[\"burnerInput\"] = \"0\"\n elements[locationText].attributes[\"recoveryEfficiency\"] = \"0\"\n elements[locationText].attributes[\"isUserSpecified\"] = \"true\"\n elements[locationText].add_element(\"EquipmentInformation\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/EquipmentInformation\"\n elements[locationText].add_element(\"Manufacturer\")\n elements[locationText].add_element(\"Model\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/EquipmentInformation/Manufacturer\"\n elements[locationText].text = \"Generic\"\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/EquipmentInformation/Model\"\n elements[locationText].text = \"Generic\"\n\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9\"\n elements[locationText].add_element(\"TestData\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData\"\n elements[locationText].attributes[\"controlsPower\"] = \"10\"\n elements[locationText].attributes[\"circulationPower\"] = \"130\"\n elements[locationText].attributes[\"dailyUse\"] = \"0.2\"\n elements[locationText].attributes[\"standbyLossWithFan\"] = \"0\"\n elements[locationText].attributes[\"standbyLossWithoutFan\"] = \"0\"\n elements[locationText].attributes[\"oneHourRatingHotWater\"] = \"1000\"\n elements[locationText].attributes[\"oneHourRatingConcurrent\"] = \"1000\"\n elements[locationText].add_element(\"EnergySource\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData/EnergySource\"\n elements[locationText].attributes[\"code\"] = \"2\"\n elements[locationText].add_element(\"English\")\n elements[locationText].add_element(\"French\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData\"\n elements[locationText].add_element(\"NetEfficiency\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData/NetEfficiency\"\n elements[locationText].attributes[\"loadPerformance15\"] = \"80\"\n elements[locationText].attributes[\"loadPerformance40\"] = \"80\"\n elements[locationText].attributes[\"loadPerformance100\"] = \"80\"\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData\"\n elements[locationText].add_element(\"ElectricalUse\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData/ElectricalUse\"\n elements[locationText].attributes[\"loadPerformance15\"] = \"100\"\n elements[locationText].attributes[\"loadPerformance40\"] = \"200\"\n elements[locationText].attributes[\"loadPerformance100\"] = \"300\"\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData\"\n elements[locationText].add_element(\"BlowerPower\")\n locationText = \"HouseFile/House/HeatingCooling/Type1/P9/TestData/BlowerPower\"\n elements[locationText].attributes[\"loadPerformance15\"] = \"300\"\n elements[locationText].attributes[\"loadPerformance40\"] = \"500\"\n elements[locationText].attributes[\"loadPerformance100\"] = \"800\"\n end\nend",
"def create\n @usr_vendor_property = UsrVendorProperty.new(usr_vendor_property_params)\n\n respond_to do |format|\n if @usr_vendor_property.save\n format.html { redirect_to root_path, notice: 'Usr vendor property was successfully created.' }\n format.json { render :show, status: :created, location: @usr_vendor_property }\n else\n format.html { render :new }\n format.json { render json: @usr_vendor_property.errors, status: :unprocessable_entity }\n end\n end\n end",
"def inlet(inlet_index, *params)\r\n out0 'product', params.inject(:*) \r\nend",
"def vs_spec_save\n event_id = params[\"event_id\"]\n products = Product.joins(:designed_products).where(\"designed_products.florist_id\" => session[\"found_florist_id\"]).where(\"designed_products.event_id\" => event_id).uniq.order(\"name\")\n for product in products \n designed_product = DesignedProduct.where(product_id: product.id).where(specification_id: params[\"spec_id\"]).first\n if designed_product != nil && params[\"stemcount_#{product.id}\"].to_f > 0\n if params[\"stemcount_#{product.id}\"].to_f * 100 != designed_product.product_qty\n designed_product.product_qty = params[\"stemcount_#{product.id}\"].to_f * 100.round(2)\n designed_product.save!\n else # don't save\n end\n elsif designed_product != nil && params[\"stemcount_#{product.id}\"].to_f <= 0\n designed_product.destroy\n elsif designed_product == nil && params[\"stemcount_#{product.id}\"].to_f > 0\n new_dp = DesignedProduct.new\n new_dp.specification_id = params[\"spec_id\"]\n new_dp.product_id = product.id\n new_dp.event_id = event_id\n new_dp.product_qty = params[\"stemcount_#{product.id}\"].to_f * 100.round(2)\n new_dp.florist_id = session[\"found_florist_id\"]\n new_dp.image_in_quote = 1\n new_dp.save!\n end\n end\n \n # Create a DP for the product assigned to the placeholder specification.\n if params[\"add\"]\n new_item = params[\"new_item\"]\n specification = Specification.where(event_id: event_id).where(item_name: \"X1Z2-PlaCeHoldEr\").first\n new_dp = DesignedProduct.new\n new_dp.specification_id = specification.id\n new_dp.product_qty = 0\n new_dp.florist_id = session[\"found_florist_id\"]\n new_dp.product_id = Product.where(name: new_item).where(florist_id: session[\"found_florist_id\"]).first.id\n new_dp.event_id = event_id\n new_dp.image_in_quote = 1\n new_dp.save! \n redirect_to \"/virtual_studio/#{params[\"spec_id\"]}\" and return\n end\n \n \n if params[\"save\"]\n redirect_to \"/virtual_studio/#{params[\"spec_id\"]}\" and return\n end\n specifications = Specification.where(florist_id: session[\"found_florist_id\"]).where(event_id: params[\"event_id\"]).where(\"item_name not like 'X1Z2-PlaCeHoldEr'\").order(\"id\")\n spec_list = []\n for specification in specifications\n spec_list << specification.id\n end\n last_items_index = spec_list.index(Specification.where(id: params[\"spec_id\"]).first.id)\n if params[\"save_previous\"]\n if last_items_index - 1 >= 0 \n @spec = Specification.where(id: spec_list[last_items_index - 1]).first\n redirect_to \"/virtual_studio/#{@spec.id}\" and return\n else\n redirect_to \"/stem_count/#{event_id}\" and return\n end\n elsif params[\"save_next\"]\n if last_items_index + 1 < spec_list.size\n @spec = Specification.where(id: spec_list[last_items_index + 1]).first\n \n redirect_to \"/virtual_studio/#{@spec.id}\" and return\n else\n redirect_to \"/stem_count/#{event_id}\" and return\n end \n end\n end",
"def put_new_pricebid(q)\n$LOG.info('put_new_pricebid');\n@CID=q[\"USER\"];\n@PID=q[\"PRODUCT\"];\n@PRICE=q[\"PRICE\"];\n\n\n@product=get_product(@PID)\n$LOG.info('put_new_pricebid: '+@PID.to_s());\n$LOG.info('put_new_pricebid: '+@PRICE.to_s());\n$LOG.info('put_new_pricebid: '+@CID.to_s());\n\n$LOG.info('put_new_pricebid: '+@product.to_s());\n\nif (@product != nil)\n\n@VID=@product[\"VID\"]\n@contracts=get_contracts_by_vendor(@VID);\n@contract=@contracts[@CID]\n$LOG.info('put_new_pricebid: '+@contract.to_s());\n\nif (@contract!=nil)\n# CONTRACT EXISTS - IT'S OK TO PUT PRICE \n$LOG.info('put_new_pricebid: '+@prices.to_s());\nput_price_for_the_product(@CID,@PID,@PRICE)\n\nend\nend\n\nend",
"def create\n @admin_vendor = Vendor.new(admin_vendor_params)\n\n respond_to do |format|\n if @admin_vendor.save\n format.html { redirect_to admin_vendors_url, notice: 'Vendor was successfully created.' }\n format.json { render :show, status: :created, location: @admin_vendor }\n else\n format.html { render :new }\n format.json { render json: @admin_vendor.errors, status: :unprocessable_entity }\n end\n end\n end",
"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 make_products_section\n\t$products_hash[\"items\"].each do |toy|\n\t\ttoy_name toy\n print_toy_name\n\t\ttoy_full_price toy\n\t print_toy_full_price\n \ttotal_purchases toy\n\t\tprint_total_purchases\n\t total_sales toy\n\t\tprint_total_sales\n \taverage_price toy\n\t\tprint_average_price\n \taverage_discount toy\n\t\tprint_average_discount\n\tend\nend",
"def write_to_acc_table (sku,recommendations,acc_cats,store)\n p \"Saving recommendations for #{sku}\"\n sku_id = get_id(sku,:main,store)\n unless sku_id == \"\"\n # Write the total number of transactions with accessories\n total_sales = 0\n acc_cats.each_pair do |cat,sales|\n total_sales += sales[0]\n end\n accessory = Accessory.find_or_initialize_by_product_id_and_name(sku_id,\"accessory_sales_total\")\n accessory.update_attribute(:count, total_sales)\n # Write the number of times a product is sold with the desired item\n acc_cats.sort_by{|sku,sales| sales[0]}.reverse.first(NUM_CHOICES).each do |category|\n cat = category[0]\n cat_sales = category[1][0]\n sku_hash = category[1][1]\n unless cat == \"\" # This means the product(s) has/have no category in db (I think)\n accessory = Accessory.find_or_initialize_by_product_id_and_name_and_value_and_acc_type(sku_id,\"accessory_type\",cat,cat)\n accessory.update_attribute(:count, cat_sales)\n sku_hash.each_pair do |acc_sku, sales|\n acc_id = get_id(acc_sku,:accessory,store)\n unless acc_id == \"\"\n accessory = Accessory.find_or_initialize_by_product_id_and_name_and_value_and_acc_type(sku_id,\"accessory_id\",acc_id,cat)\n accessory.update_attribute(:count, sales)\n else\n p \"Accessory #{acc_sku} does not have the information necessary\"\n end\n end\n end\n end\n # Ensure top 'NUM_CHOICES' accessories are in db table\n recommendations.sort_by{|sku,sales| sales}.reverse.first(NUM_CHOICES).each do |acc|\n acc_sku = acc[0]\n sales = acc[1]\n acc_id = get_id(acc_sku,:accessory,store)\n unless acc_id == \"\"\n accessory = Accessory.find_or_initialize_by_product_id_and_name_and_value(sku_id,\"accessory_id\",acc_id)\n accessory.update_attribute(:count, sales)\n else\n p \"Accessory #{acc_sku} does not have the information necessary\"\n end\n end\n else\n p \"Product #{sku} is unidentifiable in database/will not successfully save accessories\"\n end\nend",
"def sample_products( facturama )\n sample_products_list(facturama) # Listar todos los productos\n\n sample_products_create(facturama) # Agregar producto y eliminarlo\n end",
"def set_sku(prod , row)\n prod.sku = at_in(:sku,row) if at_in(:sku,row) \n end",
"def set_vendor_product\n @product = current_vendor.vendor_products.find_by_id(params[:id])\n end",
"def products\n FarMar::Product.by_vendor(id)\n end",
"def products\n FarMar::Product.by_vendor(id)\n end",
"def products\n FarMar::Product.by_vendor(self.id)\n end",
"def index\n 3.times { @product.product_specifications.build }\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @product_specifications }\n end\n end",
"def create\n @vendor = Vendor.new(params[:vendor])\n\n respond_to do |format|\n if @vendor.save\n format.html { redirect_to @vendor, notice: 'Vendor was successfully created.' }\n format.json { render json: @vendor, status: :created, location: @vendor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vendor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def load_products\n @products_type[\"watermelon\"] = Creator.createProduct(:watermelon, \"watermelon\")\n @products_type[\"watermelon\"].add_pack(3, 6.99)\n @products_type[\"watermelon\"].add_pack(5, 8.99)\n\n @products_type[\"pineapple\"] = Creator.createProduct(:pineapple, \"pineapple\")\n @products_type[\"pineapple\"].add_pack(2, 9.95)\n @products_type[\"pineapple\"].add_pack(5, 16.95)\n @products_type[\"pineapple\"].add_pack(8, 24.95)\n\n @products_type[\"rockmelon\"] = Creator.createProduct(:rockmelon, \"rockmelon\")\n @products_type[\"rockmelon\"].add_pack(3, 5.95)\n @products_type[\"rockmelon\"].add_pack(5, 9.95)\n @products_type[\"rockmelon\"].add_pack(9, 16.99)\n end",
"def vendors(type)\n\t\t\tl2_vendors = rules.map {|r| r.l2_vendor(type)}.compact\n\n\t\t\tl2_vendors.each_with_object(Hash.new(0)) { |v,counts| counts[v] += 1 }\n\t\tend",
"def give_variants\n @variants.each.with_index(1).map { |variant, index| \"#{index}. #{variant}\" }.join(\"\\n\")\n end"
] |
[
"0.58449596",
"0.58203465",
"0.55460596",
"0.5476416",
"0.54544294",
"0.5346234",
"0.532324",
"0.5238781",
"0.5215226",
"0.52136964",
"0.51984155",
"0.5191942",
"0.5150586",
"0.51504123",
"0.5126002",
"0.5106959",
"0.50947833",
"0.509215",
"0.5088456",
"0.5064857",
"0.5055025",
"0.5051692",
"0.50434965",
"0.5040447",
"0.5037124",
"0.503296",
"0.50307536",
"0.5029667",
"0.5027593",
"0.50238174",
"0.50155914",
"0.50091255",
"0.500439",
"0.49804276",
"0.49654543",
"0.49642536",
"0.4963372",
"0.49560207",
"0.49545485",
"0.49514237",
"0.49470007",
"0.4944645",
"0.49320754",
"0.49295455",
"0.49233583",
"0.49231908",
"0.4916446",
"0.49154493",
"0.49119928",
"0.49114907",
"0.49097466",
"0.49068856",
"0.48990464",
"0.48945364",
"0.48926952",
"0.4890106",
"0.48897487",
"0.48862407",
"0.48794088",
"0.48754394",
"0.48749033",
"0.48713854",
"0.48674855",
"0.48653316",
"0.4863679",
"0.48622364",
"0.48610634",
"0.48547706",
"0.48537213",
"0.48500332",
"0.48449698",
"0.48438406",
"0.4839285",
"0.48389992",
"0.48385328",
"0.48347342",
"0.48319834",
"0.4828695",
"0.48256144",
"0.4820823",
"0.48202607",
"0.48175082",
"0.48166108",
"0.4814359",
"0.48111877",
"0.48103622",
"0.48058495",
"0.47859448",
"0.47814173",
"0.47794655",
"0.47763985",
"0.47749943",
"0.47744632",
"0.47744632",
"0.4773796",
"0.47730166",
"0.47705925",
"0.4769421",
"0.47651237",
"0.47648478"
] |
0.56582946
|
2
|
UC2 Put information about Users and contracts with Vendors
|
def put_contract(q)
$LOG.info('put_contract');
@USER=q["USER"];
@CONTRACT=q["CONTRACT"];
@CID=@USER["CID"];
@user=$CACHE.get("USER",@CID)
$LOG.info(@USER.to_s()+' - '+@CONTRACT.to_s());
if (@user == nil)
@user=$STORAGE.get("USER",@CID)
if (@user == nil)
$STORAGE.put("USER",@CID,@USER)
@user=$STORAGE.get("USER",@CID)
end
if (@user != nil)
@user=$CACHE.put("USER",@CID,@user) ## new user added
end
end
## add new contract with vendor
if (@CONTRACT!=nil)
@VID=@CONTRACT["VID"];
@vendor=get_vendor(@VID)
if (@vendor != nil)
## vendor exists - OK!!!
@contracts=get_contracts_by_vendor(@VID);
$LOG.info(@VID.to_s()+' get_contracts_by_vendor '+@contracts.to_s());
@contract=@contracts[@CID]
$LOG.info(@CID.to_s()+' get_contract '+@contract.to_s());
if (@contract!=nil)
clear_price_for_contract(@contract)
end
put_contract_for_vendor(@USER, @CONTRACT)
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def vendor_params\n params.require(:vendor).permit(:bank, :bank_account, :branch_code, :account_number, :family_name, :first_name, :post_number, :city,:address, :building_name, :created_at, :updated_at, :prefecture_id ).merge(user_id: current_user.id)\n end",
"def create\n @vendor = current_user.vendors.new(vendor_params)\n\n respond_to do |format|\n if @vendor.save\n format.html { redirect_to @vendor, notice: 'Vendor was successfully created.' }\n format.json { render :show, status: :created, location: @vendor }\n else\n format.html { render :new }\n format.json { render json: @vendor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def mf_api_user_update_tags\n\n # Get User From DB with client_id\n user = User.where(clientid: params[:client_id]).first\n\n # If user not found, return error response\n if user.empty?\n response = {\n success: false,\n message: 'User with ClientID not found'\n }\n\n render json: response\n end\n\n # Get the Infusionsoft contact info\n contact = Infusionsoft.data_load('Contact', user.clientid, [:Groups])\n\n # Update User Tags\n user.put('', {\n :client_tags => contact['Groups']\n })\n\n\n response = {\n success: true,\n message: 'User Tags Updated'\n }\n\n render json: response\n\n end",
"def contractor_params\n params.require(:contractor).permit(:id, :name, :username, :uid, :has_office,:address, :avatar, :mobileNumber, :fax, :website)\n end",
"def create\n @user = User.new(params[:user])\n if params[:reservation].nil?\n @company = Company.new(params[:company])\n else\n\t # user has been invited, company already exists\n\t @company = Company.find(params[:company][:id])\n\t @user.company = @company\n\t Reservation.find_by_token(params[:reservation][:token]).delete\n\t end\n\n respond_to do |format|\n if @user.save\n\t if params[:reservation].nil?\n\t\t # set company owner\n\t @company.owner = @user\n\t @company.save\n\t @company.create_default_infos\n\t @user.company = @company\n\t end\n\t @user.save\n format.html { redirect_to :users, notice: 'Registration successful.' }\n format.json { render json: @user, status: :created, location: @user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def co_update_from_organization\n organization = params[:company]\n if organization != '0'\n @organization = Organization.find(organization)\n @users = @organization.blank? ? users_dropdown : users_dropdown\n #@users = @organization.blank? ? users_dropdown : @organization.users.order(:email)\n else\n @users = users_dropdown\n end\n @json_data = { \"users\" => @users }\n render json: @json_data\n end",
"def index\n @v2_users = V2User.all\n end",
"def voucher_params\n params.require(:voucher).permit(:id_cloud, :client, :bruto, :iva, :oc_id_cloud, :status)\n end",
"def put_vendor_contract(q)\n$LOG.info('put_vendor_contract');\n\n@VENDOR=q[\"VENDOR\"];\n@PRODUCT=q[\"PRODUCT\"];\n@VID=@VENDOR[\"VID\"];\n@PRODUCT[\"VID\"]=@VID;\n\n# CHECK IN CACHE VENDOR\n@vendor=$CACHE.get(\"VENDOR\",@VID)\n# IF NOT IN CACHE CHECK IN STORE \nif (@vendor == nil) \n# IF IN STORAGE RENEW IN CACHE\n@vendor=$STORAGE.get(\"VENDOR\",@VID)\nif (@vendor == nil) \n# IF NOT IN STORAGE - ADD NEW VENDOR AND PRODUCT OF ONE \n$STORAGE.put(\"VENDOR\",@VID,@VENDOR)\n@vendor=$STORAGE.get(\"VENDOR\",@VID)\nend\n\n\n# AND IF OK - PUT TO THE CACHE\nif (@vendor != nil) \n$CACHE.put(\"VENDOR\",@VID,@vendor)\nend\n\nend\n\n\nif (@vendor != nil) # IF VENDOR OK PUT NEW PRODUCT !!!!\n put_product(@PRODUCT)\nend\n\n\nend",
"def org_params\n params.require(:organization).permit(:name, :variety, {:user_ids =>[]})\n end",
"def update\n #update venues trought users controller\n\n @user = User.find_by(authentication_token: request.headers['Authorization'])\n\n if @user.is_venue?\n @user.venue.update(venue_params)\n if @user.venue.update(venue_params)\n render json: {status: :ok}\n else\n render json: {msg: 'Invalid params'}\n end\n else\n render json: {msg: 'You dont own a venue'}, status: :error\n end\n \n\n end",
"def contract_params\n params.require(:contract).permit(:status, :contractor_id, :user_profile_id)\n end",
"def set_v2_user\n @v2_user = V2User.find(params[:id])\n end",
"def postContractFreeactivate( contract_id, user_name, user_surname, user_email_address)\n params = Hash.new\n params['contract_id'] = contract_id\n params['user_name'] = user_name\n params['user_surname'] = user_surname\n params['user_email_address'] = user_email_address\n return doCurl(\"post\",\"/contract/freeactivate\",params)\n end",
"def post_license_users_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: LicenseApi.post_license_users ...\"\n end\n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/license/users\".sub('{format}','json')\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(opts[:'body'])\n \n auth_names = ['PureCloud OAuth']\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 => 'Hash<String, Object>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LicenseApi#post_license_users\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def save\n unless operational?\n propose unless @user1_confirmed\n return confirm\n end\n response = begin\n CoachClient::Request.put(url, username: @user1.username,\n password: @user1.password,\n payload: payload,\n content_type: :xml)\n rescue CoachClient::Exception\n CoachClient::Request.put(url, username: @user2.username,\n password: @user2.password,\n payload: payload,\n content_type: :xml)\n end\n unless response.code == 200 || response.code == 201\n fail CoachClient::NotSaved.new(self), 'Could not save partnership'\n end\n self\n end",
"def create\n if api_key.blank?\n current_user_id = spree_current_user[:id]\n else\n user = Spree::User.find_by(spree_api_key: api_key)\n current_user_id = user[:id]\n end\n create_vendor(current_user_id)\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 postContractPaymentSetup( contract_id, payment_provider_id, payment_provider_profile, user_name, user_surname, user_billing_address, user_email_address)\n params = Hash.new\n params['contract_id'] = contract_id\n params['payment_provider_id'] = payment_provider_id\n params['payment_provider_profile'] = payment_provider_profile\n params['user_name'] = user_name\n params['user_surname'] = user_surname\n params['user_billing_address'] = user_billing_address\n params['user_email_address'] = user_email_address\n return doCurl(\"post\",\"/contract/payment/setup\",params)\n end",
"def vendor_params\n params.require(:vendor).permit(:name, :image, :description, :search_tags, :email, :phone_number, :password, :password_confirmation)\n end",
"def contractor_add\n\n # get the cliebt\n @client = Client.find(params[:client_id])\n\n # get the contract\n @contract = Contract.find(params[:id])\n\n # get the contractor\n @contractor = ContractorUser.find(params[:contractor_id])\n\n # if the contractor is not already added, add!\n\n @contract.contractor_user=@contractor\n @contract.save!\n redirect_to edit_client_contract_path(@client, @contract, :contracts_page => @contracts_page, :status => @status)\n\n end",
"def voucher_params\n params.require(:voucher).permit(:owner_id, :event)\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def vendor_params\n params.require(:vendor).permit(:name, :vendor_type, :phone_number, :mobile_number, :governorate, :address, :lat, :lng)\n end",
"def index\n if api_key.blank? \n user = spree_current_user\n @users = user.vendors\n else\n @users = current_api_user.vendors\n end \n end",
"def contractor_params\n params.require(:contractor).permit(:first_name, :last_name, :company, :email, :password, :password_confirmation, :maintenance_request_id, :phone, :stripe_uid, occupation: [])\n end",
"def vendor_params\n params.require(:vendor).permit(:name, :about, :email, :website_url, :category, :image)\n end",
"def putEntity( type, scope, country, trust, our_data)\n params = Hash.new\n params['type'] = type\n params['scope'] = scope\n params['country'] = country\n params['trust'] = trust\n params['our_data'] = our_data\n return doCurl(\"put\",\"/entity\",params)\n end",
"def user_vendor_subscriptions\n get(\"/api/v1/oauth_user_vendor_subscriptions.json\")\n end",
"def create(config, name, user_guid)\n\n token = @client.token\n\n user_setup_obj = UsersSetup.new(config)\n admin_token = user_setup_obj.get_admin_token\n\n # elevate user just to create organization\n @client.token = admin_token\n\n new_org = @client.organization\n new_org.name = name\n if new_org.create!\n org_guid = new_org.guid\n users_obj = Users.new(admin_token, @client.target)\n users_obj.add_user_to_org_with_role(org_guid, user_guid, ['owner', 'billing'])\n\n # then put token back to the initial one\n @client.token = token\n org_guid\n end\n\n end",
"def v2_user_params\n params.require(:v2_user).permit(:name, :email, :age, :password)\n end",
"def update!\n @authorize = nil\n update_plan! &&\n resp = put(\"/users/#{username}.xml\", {\n :user_key => apikey,\n \"user[first_name]\" => first_name,\n \"user[last_name]\" => last_name\n })\n end",
"def license_to_params\n params.require(:license_to).permit(:name, :uid, :licenceagreement)\n end",
"def userin_params\n params.permit(:user_id, :product_invest_id, :investor_slot,\n :investor_pay, :invest_year, :created_at)\n end",
"def toKitten(**_args)\n\n bok = {\n \"cloud\" => \"Google\",\n \"credentials\" => @config['credentials']\n }\n\n bok['name'] = cloud_desc.name\n bok['cloud_id'] = cloud_desc.email\n bok['members'] = members.dup\n# bok['members'] = members.map { |m|\n# MU::Config::Ref.get(\n# id: m,\n# cloud: \"Google\",\n# credentials: @config['credentials'],\n# type: \"users\"\n# )\n# }\n group_roles = MU::Cloud.resourceClass(\"Google\", \"Role\").getAllBindings(@config['credentials'])[\"by_entity\"]\n if group_roles[\"group\"] and group_roles[\"group\"][bok['cloud_id']] and\n group_roles[\"group\"][bok['cloud_id']].size > 0\n bok['roles'] = MU::Cloud.resourceClass(\"Google\", \"Role\").entityBindingsToSchema(group_roles[\"group\"][bok['cloud_id']], credentials: @config['credentials'])\n end\n\n bok\n end",
"def create_vin_credit_order(admin_user, data)\n products = []\n\n username = data[:username]\n user = @user_service.get_by_username username\n\n vin_amount = calculate_vin_amount(data, products)\n local_order = create_local_vin_credit_order user, vin_amount, products\n\n # update the balance on the user\n balance_result = @user_service.update_balance(user, vin_amount)\n\n # log the admin user's action\n @log_service.log_operation admin_user, 'create_vin_credit_order',\n \"#{USER_BALANCE_UPDATE} | target user: #{username}; amount: #{vin_amount}\"\n\n {\n :id => local_order.id.to_s,\n :status => local_order.transaction.status,\n :balance => balance_result[:balance]\n }\n\n end",
"def vendor_params\n params.require(:vendor).permit(:name, :label, :phone1, :phone2, :other_details, :mta_partner)\n end",
"def pos_usr_transpoter_params\n params.require(:pos_usr_transpoter).permit(:name, :owner_name, :address, :email,\n :vat_reg_num, :pos_usr_user_id)\n end",
"def create_users(accountId, model) path = \"/api/v2/accounts/#{accountId}/users\"\n post(path, model, {}, AvaTax::VERSION) end",
"def do_comp!\n # user = User.where('id=? OR rfid=?', user_param.to_i, user_param).first\n user = User.find(user_param)\n user.comps.create!(\n amount_in_cents: comp_amount,\n employee_id: comp_params.dig(:employee_id),\n venue_id: comp_params.dig(:venue_id),\n description: comp_params.dig(:description)\n )\n end",
"def test_update_user()\n # Parameters for the API call\n\n metadata = JSON.parse('{'\\\n '\"email\": \"testrubyapi@user.com\",'\\\n '\"name\": \"ruby api user\",'\\\n '\"custom\": \"testdata\"'\\\n '}')\n\n campaign_model = CampaignModel.new()\n campaign_model.utm_source = \"Newsletter\"\n campaign_model.utm_medium = \"Email\"\n\n user_model = UserModel.new()\n user_model.modified_time = Time.now.utc.iso8601\n user_model.user_id = \"12345\"\n user_model.company_id = \"67890\"\n user_model.metadata = metadata\n user_model.campaign = campaign_model\n\n # Perform the API call through the SDK function\n self.class.controller.update_user(user_model)\n\n # Test response code\n assert_equal(@response_catcher.response.status_code, 201)\n end",
"def create(params)\n put('v1/account', params)\n end",
"def vendor_params\n params.require(:vendor).permit(:name)\n end",
"def company_owner_params\n params.require(:company_owner).permit(:user_id, :company_id)\n end",
"def volunteer_opportunity_params\n params.require(:volunteer_opportunity).permit(:org_name, :event_type,\n :description, :contact_phone, :contact_name, :contact_email,\n :event_start, :event_end, :user_id, :agree_terms, :ein, :type_of_org,\n :title, :location, :required_documents, :profile_picture)\n end",
"def create_org_member\n @organization = Organization.find(params[:organization_id].to_i)\n @email = params[:email]\n\n @first_name = params[:first_name]\n @last_name = params[:last_name]\n @pw = params[:password]\n @pw_confirmation = params[:password_confirmation]\n\n # TODO check if authtoken is in sess variable\n # If so, only update user password\n \n # Allocate User account, dashboard, and profile \n @user = User.create(\n email: @email,\n password: @pw,\n password_confirmation: @pw_confirmation,\n organization: @organization\n )\n if @user\n Dashboard.create(\n lead_email: @email, \n lead_name: \"#{@first_name} #{@last_name}\",\n user: @user\n )\n\n profile = Profile.find_or_create_by!(email: @email) do |profile|\n profile.first_name = @first_name\n profile.last_name = @last_name\n profile.dashboard_registered = true\n end\n\n profile.update(user: @user)\n\n # Create zoho lead record\n if !@orgnization.nil? && @organization.name != 'test'\n ZohoService.save_to_zoho(profile)\n end\n\n #sign in newly created user\n sign_in(@user, scope: :user)\n # Setting up alias to map user id to mixapanel unique id. So we can use userid moving forward\n mixpanel_distinct_id = params[:distinct_id]\n @tracker.alias(@user.id,mixpanel_distinct_id)\n @tracker.people.set(@user.id,{\n '$first_name' => @user.profile.first_name,\n '$last_name' => @user.profile.last_name,\n '$email' => @user.email,\n '$phone' => @user.profile.phone\n },@user.current_sign_in_ip.to_s)\n @tracker.track(@user.id,'User account created for org. member')\n\n # flash[:notice] = 'Welcome to MyDomino!'\n \n render json: {\n message: 'User added',\n status: 200\n }, status: 200\n else\n render json: {\n message: 'Error adding user',\n status: 400\n }, status: 400\n end\n end",
"def contractor_params\n params.require(:contractor).permit(:company, :first_name, :last_name, :street_address, :city, :state, :zip, :phone, :email, :specilization, :contractor_license_number, :insurance, :insurance_type, :coverage, :experience, :management_experience, :employees, :projects, :past_projects, :job_capacity, :recent_jobs, :sow, :job_address, :job_bid, :materials_labor, :warranties, :warranties_length, :sub_contractor, :licensed_insured, :electrician, :plumber, :certificates_licenses, :bbb_coc, :bankruptcy, :communication, :clean, :lien_waiver, :references, :lead_source)\n end",
"def accept_contract\n @contract=Contract.find(params[:id])\n @contract.provider_id=current_user.id\n @contract.save\n end",
"def volunteer_params\n params.require(:volunteer).permit(:openid, :name, :tel, :commun, :neighborhood)\n end",
"def set_users\n post = Post.find(@contract.post_id)\n if post.post_type == \"offer\"\n @contract.seller_id = post.user_id\n # If the person who starts this contract is not the person offering the book, then he is the buyer; otherwise, the receiver is the buyer %>\n if @sender_id != post.user_id\n @contract.buyer_id = @sender_id\n else\n @contract.buyer_id = @receiver_id\n end\n\n elsif post.post_type == \"request\"\n @contract.buyer_id = post.user_id\n # If the current user is not the person requesting the book, then he is the seller; otherwise, the receiver is the seller %>\n if @sender_id != post.user_id\n @contract.seller_id = @sender_id\n else\n @contract.seller_id = @receiver_id\n end\n end\n @contract.unsigned_user_id = @receiver_id\n end",
"def create\n (head :unauthorized unless @user.students.find_by_id(params[:contract][:user_id])) and return\n\n contract = Contract.new(contract_params)\n if contract.save\n puts render json: contract\n else\n render json: { errors: contract.errors.full_messages }\n end\n end",
"def create\n sleep(2)\n @v2_user = V2User.new(v2_user_params)\n\n respond_to do |format|\n if @v2_user.save\n format.html { redirect_to @v2_user, notice: \"V2 user was successfully created.\" }\n format.json { render :show, status: :created, location: @v2_user }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @v2_user.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 organizer_params\n params.require(:organizer).permit(:user_id, :company_name)\n end",
"def company_params\n params.require(:company).permit(:Name, :Address, :NIF, :CreatedBy, :UpdatedBy, :Chat_ID, :user_id)\n end",
"def send_to_hubspot\n if self.customer.present? #&& self.user.blank? #if customer is not a user then use the default ID to create order \n #find the Hubspot user id (called vid)\n hubspot_customer_response = Hubspot::Contact.find_by_email(self.customer.email)\n hubspot_id = hubspot_customer_response.vid if hubspot_customer_response.present?\n\n #if not present then create new hubspot id and assigned the new id to hubspot_id\n if hubspot_id.blank?\n hubspot_id = HubspotService::Send.user_to_hubspot_and_retrieve_hubspot_id(self.customer)\n end\n\n #check if payment is received? \n if self.authorized == true \n dealstage = ENV['HUBSPOT_STAGE_ID_ORDER_RECEIVED']\n else\n dealstage = ENV['HUBSPOT_STAGE_ID_ABANDONED_CART']\n end\n\n if @hubspot_deal_id.present? == true\n #update \n HubspotService::Send.order_to_hubspot(self, hubspot_id, dealstage, @hubspot_deal_id)\n else\n #create hubspot deals\n HubspotService::Send.order_to_hubspot(self, hubspot_id, dealstage, \"\")\n end\n else\n return \"ERROR CREATING HUBSPOT DEAL\"\n end\n end",
"def v1_user_params\n params.require(:user).permit(\n :full_name,\n :email,\n :city,\n :orgnaization_id,\n :region,\n :code_country,\n :mobile,\n :password,\n :role,\n :status\n )\n end",
"def create\n @vendor = Vendor.new(params[:vendor])\n\t\t@vendor.user_id = current_user.id\n respond_to do |format|\n if @vendor.save\n\t\t\t\tif params[:service]\n\t\t\t\t\tparams[:service].keys.each do |f| \n\t\t\t\t\t\t@vendor.services.create(:name=>f,:is_active=>true)\n\t\t\t\t\tend\n\t\t\t\tend\n format.html { redirect_to @vendor, notice: 'Vendor was successfully created.' }\n format.json { render json: @vendor, status: :created, location: @vendor }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vendor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def configure_contracts\n # configure accounts for eosdactokens\n `cleos push action eosdactokens updateconfig '[\"daccustodian\"]' -p eosdactokens`\n `cleos push action eosdactokens create '{ \"issuer\": \"eosdactokens\", \"maximum_supply\": \"100000.0000 EOSDAC\", \"transfer_locked\": false}' -p eosdactokens`\n `cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"78337.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p eosdactokens`\n `cleos push action eosio.token issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"100000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio.token`\n `cleos push action dacdirectory regdac '{\"owner\": \"dacdirectory\", \"dac_name\": \"dacproposals\", \"dac_symbol\": \"4,MYSYM\", \"title\": \"Dac Title\", \"refs\": [[1,\"some_ref\"]], \"accounts\": [[2,\"daccustodian\"], [5,\"dacescrow\"], [7,\"dacescrow\"], [0, \"dacauthority\"], [4, \"eosdactokens\"], [1, \"eosdacthedac\"] ], \"scopes\": [[2,\"daccustodian\"], [4, \"eosdactokens\"]]}' -p dacdirectory`\n \n #create users\n # Ensure terms are registered in the token contract\n `cleos push action eosdactokens newmemterms '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\"}' -p eosdactokens`\n\n #create users\n seed_dac_account(\"proposeracc1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"proposeracc2\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"arbitrator11\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n\n seed_dac_account(\"custodian1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian2\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian3\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian4\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian5\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian11\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian12\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian13\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian14\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n\n `cleos push action daccustodian updatecust '[[\"custodian1\", \"custodian2\", \"custodian3\", \"custodian4\", \"custodian5\", \"custodian11\", \"custodian12\", \"custodian13\", \"custodian14\"]]' -p proposeracc1`\n\n `cleos set account permission dacauthority one '{\"threshold\": 1,\"keys\": [],\"accounts\": [{\"permission\":{\"actor\":\"custodian1\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian11\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian12\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian13\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian2\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian3\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian4\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian5\",\"permission\":\"active\"},\"weight\":1}]}' low -p dacauthority@low`\nend",
"def register_with_et\r\n App.et[\"accounts\"].each_pair do |account_name, account_config|\r\n next unless account_config[:rsvp_guest_list]\r\n ETSubscriberAdd.create!(\r\n :account => account_name,\r\n :target => self,\r\n :properties => {\r\n :list_id => account_config[:rsvp_guest_list],\r\n :values => {\r\n :email_address => self.email,\r\n :cobrand => cobrand.short_name\r\n }\r\n }\r\n )\r\n end\r\n end",
"def edit\n begin\n @vendor = current_user.vendors.find(params[:id])\n rescue Exception => e\n flash[:error] = \"ERROR: #{e.message}.\"\n redirect_to client_vendors_path\n end\n end",
"def subcontractor_params\n params.require(:subcontractor).permit(:name, :email, :skills, :company_size, :created_at, :location, :link, :description, :password)\n end",
"def make_vendor index, rep_key, company_key\n %{INSERT INTO vendors VALUES (#{index}, #{rep_key}, #{company_key});}\nend",
"def update_driver_details \n\t\tcurrent_user.license_plate = user_params[:license_plate]\n\t\tcurrent_user.car_model = user_params[:car_model]\n\t\tcurrent_user.save!\n\t\trender json: {\n\t\t\tstatus: 'succeess',\n\t\t\tmessage: 'Driver Details Updated!'\n\t\t}, status: 200\n\tend",
"def set_voucher\n @voucher = current_user.companies.find(params[:company_id]).fiscal_years.find(params[:fiscal_year_id]).vouchers.find(params[:id])\n end",
"def toKitten(**args)\n\n bok = {\n \"cloud\" => \"Google\",\n \"credentials\" => @config['credentials'],\n \"cloud_id\" => @cloud_id\n }\n my_org = MU::Cloud::Google.getOrg(@config['credentials'])\n\n # This can happen if the role_source isn't set correctly. This logic\n # maybe belongs inside cloud_desc. XXX\n if cloud_desc.nil?\n if @cloud_id and @cloud_id.match(/^roles\\/(.*)/)\n @config['role_source'] = \"canned\"\n elsif @cloud_id and @cloud_id.match(/^organizations\\/\\d+\\/roles\\/(.*)/)\n @config['role_source'] = \"org\"\n elsif @cloud_id and @cloud_id.match(/^projects\\/\\d+\\/roles\\/(.*)/)\n @config['role_source'] = \"project\"\n end\n end\n\n # GSuite or Cloud Identity role\n if cloud_desc.class == ::Google::Apis::AdminDirectoryV1::Role\nif @cloud_id =~ /ncbi_snapshot_manager/\n MU.log \"directory-tier role\", MU::NOTICE\nend\n return nil if cloud_desc.is_system_role\n\n bok[\"name\"] = @config['name'].gsub(/[^a-z0-9]/i, '-').downcase\n bok['role_source'] = \"directory\"\n bok[\"display_name\"] = @config['name']\n if !cloud_desc.role_description.empty?\n bok[\"description\"] = cloud_desc.role_description\n end\n if !cloud_desc.role_privileges.nil? and !cloud_desc.role_privileges.empty?\n bok['import'] = []\n ids, _names, _privs = MU::Cloud::Google::Role.privilege_service_to_name(@config['credentials'])\n cloud_desc.role_privileges.each { |priv|\n if !ids[priv.service_id]\n MU.log \"Role privilege defined for a service id with no name I can find, writing with raw id\", MU::DEBUG, details: priv\n bok[\"import\"] << priv.service_id+\"/\"+priv.privilege_name\n else\n bok[\"import\"] << ids[priv.service_id]+\"/\"+priv.privilege_name\n end\n }\n bok['import'].sort! # at least be legible\n end\n else # otherwise it's a GCP IAM role of some kind\nif @cloud_id =~ /ncbi_snapshot_manager/\n MU.log \"cloud-tier role\", MU::NOTICE\nend\n\n return nil if cloud_desc.stage == \"DISABLED\"\n if cloud_desc.name.match(/^roles\\/([^\\/]+)$/)\n name = Regexp.last_match[1]\n bok['name'] = name.gsub(/[^a-z0-9]/i, '-')\n bok['role_source'] = \"canned\"\n elsif cloud_desc.name.match(/^([^\\/]+?)\\/([^\\/]+?)\\/roles\\/(.*)/)\n _junk, type, parent, name = Regexp.last_match.to_a\n bok['name'] = name.gsub(/[^a-z0-9]/i, '-')\n bok['role_source'] = type == \"organizations\" ? \"org\" : \"project\"\n if bok['role_source'] == \"project\"\n bok['project'] = parent\n end\n if cloud_desc.included_permissions and cloud_desc.included_permissions.size > 0\n bok['import'] = cloud_desc.included_permissions\n end\n\n else\n raise MuError, \"I don't know how to parse GCP IAM role identifier #{cloud_desc.name}\"\n end\n\n if !cloud_desc.description.nil? and !cloud_desc.description.empty?\n bok[\"description\"] = cloud_desc.description\n end\n bok[\"display_name\"] = cloud_desc.title\n\n bindings = MU::Cloud::Google::Role.getAllBindings(@config['credentials'])[\"by_role\"][@cloud_id]\n\n if bindings\n refmap = {}\n bindings.keys.each { |scopetype|\n bindings[scopetype].each_pair { |scope_id, entity_types|\n # If we've been given a habitat filter, skip over bindings\n # that don't match it.\n if scopetype == \"projects\"\n if (args[:habitats] and !args[:habitats].empty? and\n !args[:habitats].include?(scope_id)) or\n !MU::Cloud::Google.listHabitats(@credentials).include?(scope_id)\n next\n end\n end\n\n entity_types.each_pair { |entity_type, entities|\n next if entity_type == \"deleted\"\n mu_entitytype = (entity_type == \"serviceAccount\" ? \"user\" : entity_type)+\"s\"\n entities.each { |entity|\n next if entity.nil?\n foreign = if entity_type == \"serviceAccount\" and entity.match(/@(.*?)\\.iam\\.gserviceaccount\\.com/)\n !MU::Cloud::Google.listHabitats(@credentials).include?(Regexp.last_match[1])\n end\n\n entity_ref = if entity_type == \"organizations\"\n { \"id\" => ((org == my_org.name and @config['credentials']) ? @config['credentials'] : org) }\n elsif entity_type == \"domain\"\n { \"id\" => entity }\n else\n shortclass, _cfg_name, _cfg_plural, _classname = MU::Cloud.getResourceNames(mu_entitytype)\n if args[:types].include?(shortclass) and\n !(entity_type == \"serviceAccount\" and\n MU::Cloud::Google::User.cannedServiceAcctName?(entity))\n MU.log \"Role #{@cloud_id}: Skipping #{shortclass} binding for #{entity}; we are adopting that type and will set bindings from that resource\", MU::DEBUG\n next\n end\n\n MU::Config::Ref.get(\n id: entity,\n cloud: \"Google\",\n type: mu_entitytype\n )\n end\n if entity_ref.nil?\n MU.log \"I somehow ended up with a nil entity reference for #{entity_type} #{entity}\", MU::ERR, details: [ bok, bindings ]\n next\n end\n refmap ||= {}\n refmap[entity_ref] ||= {}\n refmap[entity_ref][scopetype] ||= []\n mu_scopetype = scopetype == \"projects\" ? \"habitats\" : scopetype\n if scopetype == \"organizations\" or scopetype == \"domains\" # XXX singular? plural? barf\n refmap[entity_ref][scopetype] << ((scope_id == my_org.name and @config['credentials']) ? @config['credentials'] : scope_id)\n else\n refmap[entity_ref][scopetype] << MU::Config::Ref.get(\n id: scope_id,\n cloud: \"Google\",\n type: mu_scopetype\n )\n end\n refmap[entity_ref][scopetype].uniq!\n }\n }\n }\n }\n\n bok[\"bindings\"] ||= []\n refmap.each_pair { |entity, scopes|\n newbinding = { \"entity\" => entity }\n scopes.keys.each { |scopetype|\n newbinding[scopetype] = scopes[scopetype].sort\n }\n bok[\"bindings\"] << newbinding\n }\n end\n end\n\n # Our only reason for declaring canned roles is so we can put their\n # bindings somewhere. If there aren't any, then we don't need\n # to bother with them.\n if bok['role_source'] == \"canned\" and\n (bok['bindings'].nil? or bok['bindings'].empty?)\nif @cloud_id =~ /ncbi_snapshot_manager/\n MU.log \"ditching at canned role check\", MU::NOTICE\nend\n return nil\n end\n\n bok\n end",
"def update_object2_with_http_info(username, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UserServiceApi.update_object2 ...'\n end\n # verify the required parameter 'username' is set\n if @api_client.config.client_side_validation && username.nil?\n fail ArgumentError, \"Missing the required parameter 'username' when calling UserServiceApi.update_object2\"\n end\n # resource path\n local_var_path = '/users/{username}'.sub('{' + 'username' + '}', CGI.escape(username.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\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(['application/json', 'application/xml'])\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 = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(opts[:'body']) \n\n # return_type\n return_type = opts[:return_type] || 'File' \n\n # auth_names\n auth_names = opts[:auth_names] || []\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(:PUT, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UserServiceApi#update_object2\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_license_users_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: LicenseApi.get_license_users ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/license/users\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'UserLicensesEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LicenseApi#get_license_users\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def consumers_virtuoso_id_put_with_http_info(virtuoso_id, body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ConsumerApi.consumers_virtuoso_id_put ...'\n end\n # verify the required parameter 'virtuoso_id' is set\n if @api_client.config.client_side_validation && virtuoso_id.nil?\n fail ArgumentError, \"Missing the required parameter 'virtuoso_id' when calling ConsumerApi.consumers_virtuoso_id_put\"\n end\n # verify the required parameter 'body' is set\n if @api_client.config.client_side_validation && body.nil?\n fail ArgumentError, \"Missing the required parameter 'body' when calling ConsumerApi.consumers_virtuoso_id_put\"\n end\n # resource path\n local_var_path = '/consumers/{virtuosoId}'.sub('{' + 'virtuosoId' + '}', virtuoso_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\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(body)\n auth_names = []\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'ConsumerResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ConsumerApi#consumers_virtuoso_id_put\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def post_license_organization_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: LicenseApi.post_license_organization ...\"\n end\n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/license/organization\".sub('{format}','json')\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(opts[:'body'])\n \n auth_names = ['PureCloud OAuth']\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 => 'Array<LicenseUpdateStatus>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: LicenseApi#post_license_organization\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def configure_contracts\n # configure accounts for eosdactokens\n `cleos push action eosdactokens updateconfig '[\"daccustodian\"]' -p eosdactokens`\n `cleos push action eosdactokens create '{ \"issuer\": \"eosdactokens\", \"maximum_supply\": \"100000.0000 EOSDAC\", \"transfer_locked\": false}' -p eosdactokens`\n `cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"78337.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p eosdactokens`\n `cleos push action eosio.token issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"100000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio`\n\n #create users\n # Ensure terms are registered in the token contract\n `cleos push action eosdactokens newmemterms '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\"}' -p eosdactokens`\n\n #create users\n seed_dac_account(\"sender1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"sender2\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"sender3\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"sender4\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"receiver1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"arb1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"arb2\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n\n `cleos push action eosio.token issue '{ \"to\": \"sender1\", \"quantity\": \"1000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio`\n `cleos push action eosio.token issue '{ \"to\": \"sender2\", \"quantity\": \"1000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio`\n `cleos push action eosio.token issue '{ \"to\": \"sender3\", \"quantity\": \"1000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio`\n `cleos push action eosio.token issue '{ \"to\": \"sender4\", \"quantity\": \"1000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio`\nend",
"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 api_v11_users_user_name_put_with_http_info(user_name, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DefaultApi#api_v11_users_user_name_put ...\"\n end\n \n # verify the required parameter 'user_name' is set\n fail \"Missing the required parameter 'user_name' when calling api_v11_users_user_name_put\" if user_name.nil?\n \n # resource path\n path = \"/api/v11/users/{userName}\".sub('{format}','json').sub('{' + 'userName' + '}', user_name.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = []\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:PUT, 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: DefaultApi#api_v11_users_user_name_put\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update_user_details_in_chargify\n unless self.account.chargify_customer_id.blank?\n\n if self.roles.any? { |r| r.title == 'account_holder' }\n chargify_customer = Chargify::Customer.find_by_reference(self.account.id)\n chargify_customer.first_name = self.firstname\n chargify_customer.last_name = self.lastname\n chargify_customer.email = self.email\n chargify_customer.save\n end\n end\n end",
"def put user_id, options={}, headers={}\n @connection.put \"users/#{user_id}.json\", options, headers\n end",
"def propose\n response = CoachClient::Request.put(url, username: @user1.username,\n password: @user1.password,\n payload: payload,\n content_type: :xml)\n unless response.code == 200 || response.code == 201\n fail CoachClient::NotProposed.new(self), 'Could not propose partnership'\n end\n set_user_confirmed(response.to_h)\n self\n end",
"def sync\n prizes = params[:prizes]\n users = params[:users]\n if prizes\n prizes.each do |entry|\n entry = entry[1]\n @entry = Entry.find_or_create_by_id(entry['id']);\n logger.debug(\"entry remote id #{entry['created_at']}\")\n @entry.update_attributes({:delivered => entry['delivered']})\n end\n\n end\n if users\n users.each do |entry|\n entry = entry[1]\n @entry = User.find_or_create_by_id(entry['id']);\n logger.debug(\"entry remote id #{entry['created_at']}\")\n @entry.update_attributes({:laps => entry['laps']})\n end\n end\n\n end",
"def update\n respond_to do |format|\n if @v2_user.update(v2_user_params)\n format.html { redirect_to @v2_user, notice: \"V2 user was successfully updated.\" }\n format.json { render :show, status: :ok, location: @v2_user }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @v2_user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_user\n @contractor = Contractor.find(params[:id])\n end",
"def set_v1_user\n @v1_user = V1::User.find(params[:id])\n end",
"def api_v1_user_device_info_params\n params.require(:api_v1_user_device_info).permit(:user_id, :os, :device_type, :device_model, :system_version, :app_version, :device_locale, :bundle_device)\n end",
"def create\n #create venues trought users controller\n end",
"def set_owner_info\n property.owner_email = 'belvillapt@belvilla.com'\n country_info = {\n 'AU' => ['Australia', '1800 442586'],\n 'AT' => ['Austria', '0800 296669'],\n 'BE' => ['Belgium', '(+32) 03 808 09 54'],\n 'CA' => ['Canada', '1800 4045160'],\n 'DK' => ['Denmark', '8088 7970'],\n 'FR' => ['France', '0800 905 849'],\n 'DE' => ['Germany', '0800 1826013'],\n 'IE' => ['Ireland', '1800 552175'],\n 'IT' => ['Italy', '800 871005'],\n 'LU' => ['Luxembourg', '8002 6106'],\n 'NL' => ['Netherlands', '(+31) 088 202 12 12'],\n 'NO' => ['Norway', '800 19321'],\n 'PL' => ['Poland', '(+48) 22 3988048'],\n 'PT' => ['Portugal', '8008 31532'],\n 'ES' => ['Spain', '900 983103'],\n 'SE' => ['Sweden', '020 794849'],\n 'CH' => ['Switzerland', '0800 561913'],\n 'GB' => ['United Kingdom', '0800 0516731'],\n 'US' => ['United States', '1 800 7197573']\n }\n info = meta_data['BasicInformationV3']\n if country_info.has_key?(info['Country'])\n property.owner_city, property.owner_phone_number = country_info[info['Country']]\n end\n end",
"def user_params\n params.require(:user).permit(:region_id ,:interestversion_id,:username, :sex, :address, :tel, :content, :capital)\n end",
"def update\n # @company.users = []\n # unless params[:user][:user_ids].nil?\n # params[:user][:user_ids].each do |user_id|\n # @company.users << User.find(user_id) unless user_id.empty?\n # end\n # end\n #\n # respond_to do |format|\n # if @company.update(company_params)\n # format.html { redirect_to @company, notice: 'Company was successfully updated.' }\n # format.json { render :show, status: :ok, location: @company }\n # else\n # format.html { render :edit }\n # format.json { render json: @company.errors, status: :unprocessable_entity }\n # end\n # end\n @company.update(company_params)\n end",
"def v2_api_response\n user_attributes = self.attributes.only(:id, :email, :first_name, :last_name, :company, :job_title, :phone_number, :webpage, :type, :address_1, :address_2, :city, :state, :zip, :country, :mobile, :fax, :designer_firm, :designer_name, :my_products_count)\n user_attributes.merge! :is_premium => self.premium?, :avatar => ([:thumb, :small, :large].collect do |kind| { kind => self.avatar(kind).to_s } end)\n if self.premium?\n user_attributes.merge! :firm => self.firm.attributes.only(:id, :name, :logo, :tier_id)\n end\n user_attributes\n end",
"def configure_contracts\n # configure accounts for eosdactokens\n\n run %(cleos push action eosdactokens create '{ \"issuer\": \"dacdirectory\", \"maximum_supply\": \"100000.0000 EOSDAC\", \"transfer_locked\": false}' -p dacdirectory)\n\n run %(cleos push action dacdirectory regdac '{\"owner\": \"dacdirectory\", \"dac_name\": \"dacproposals\", \"dac_symbol\": \"4,MYSYM\", \"title\": \"Dac Title\", \"refs\": [], \"accounts\": [[2,\"daccustmock\"], [5,\"\"], [7,\"dacescrow\"], [0, \"dacauthority\"], [4, \"eosdactokens\"], [1, \"eosdacthedac\"] ], \"scopes\": []}' -p dacdirectory)\n run %(cleos push action dacdirectory regdac '{\"owner\": \"dacdirectory\", \"dac_name\": \"mydacname2\", \"dac_symbol\": \"4,EOSDAC\", \"title\": \"Dac Title\", \"refs\": [], \"accounts\": [[1,\"account1\"]], \"scopes\": []}' -p dacdirectory)\n\n run %(cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"78337.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p dacdirectory)\n run %(cleos push action eosio.token issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"100000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio)\n\n # Ensure terms are registered in the token contract\n run %(cleos push action eosdactokens newmemtermse '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\", \"dac_id\": \"dacproposals\"}' -p dacauthority)\n\n #create users\n seed_dac_account(\"proposeracc1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"proposeracc2\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"proposeracc3\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"arbitrator11\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n\n seed_dac_account(\"custodian1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"custodian2\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"custodian3\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"custodian4\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"custodian5\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"custodian11\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"custodian12\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"custodian13\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n seed_dac_account(\"custodian14\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"dacproposals\", dac_owner: \"dacdirectory\")\n\n run %(cleos push action daccustmock updatecust '{\"custodians\": [\"custodian1\", \"custodian2\", \"custodian3\", \"custodian4\", \"custodian5\", \"custodian11\", \"custodian12\", \"custodian13\", \"custodian14\"], \"dac_id\": \"dacproposals\"}' -p proposeracc1)\n\n run %(cleos set account permission dacauthority one '{\"threshold\": 1,\"keys\": [],\"accounts\": [{\"permission\":{\"actor\":\"custodian1\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian11\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian12\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian13\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian2\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian3\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian4\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian5\",\"permission\":\"active\"},\"weight\":1}]}' low -p dacauthority@low)\nend",
"def vendor_params\n params.require(:vendor).permit(:name)\n end",
"def update\n response = begin\n CoachClient::Request.get(url, username: @user1.username,\n password: @user1.password)\n rescue CoachClient::Exception\n CoachClient::Request.get(url, username: @user2.username,\n password: @user2.password)\n end\n response = response.to_h\n @id = response[:id]\n @datecreated = response[:datecreated]\n @publicvisible = response[:publicvisible]\n set_user_confirmed(response)\n @subscriptions = []\n unless response[:subscriptions].nil?\n response[:subscriptions].each do |s|\n sport = s[:uri].match(/\\/(\\w+)\\/\\z/).captures.first\n @subscriptions << CoachClient::PartnershipSubscription.new(client, self,\n sport)\n end\n end\n self\n end",
"def put_network(request, params)\n xmldoc = XMLElement.build_xml(request.body, 'NETWORK')\n vnet_info = XMLElement.new(xmldoc) if xmldoc != nil\n\n vnet = VirtualNetworkOCCI.new(\n VirtualNetwork.build_xml(params[:id]),\n @client)\n\n rc = nil\n if vnet_info['PUBLIC'] == 'YES'\n rc = vnet.publish\n elsif vnet_info['PUBLIC'] == 'NO'\n rc = vnet.unpublish\n end\n\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n # --- Prepare XML Response ---\n vnet.info\n return to_occi_xml(vnet, :code=>202)\n end",
"def update\n respond_to do |format|\n if @vendor.update(vendor_params)\n format.html { redirect_to @vendor, notice: 'Vendor was successfully updated.' }\n format.json { render :show, status: :ok, location: @vendor }\n else\n format.html { render :edit }\n format.json { render json: @vendor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @vendor.update(vendor_params)\n format.html { redirect_to @vendor, notice: 'Vendor was successfully updated.' }\n format.json { render :show, status: :ok, location: @vendor }\n else\n format.html { render :edit }\n format.json { render json: @vendor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def vendor_params\n params.require(:vendor).permit(:name, :phone, :website, :city, :state, :country, :hours, :notes, :active)\n end",
"def create\n \n if params[:user][:app] == \"instainvoice\"\n options = {:body => {:user => {\n :email => params[:user][:email], :password => params[:user][:password], \n :referrer => params[:user][:referrer], :source => \"InstaInvoice\"}\n }\n \n }\n resp = HTTParty.post(\"http://billing.breeasy.com/api/v1/users.json\", options)\n #raise resp.body.inspect\n retval = JSON.parse(resp.body)\n elsif params[:user][:app] == \"bfsb\"\n \n options = {:body => {:user => {:email => params[:user][:email], :password => params[:user][:password],\n :first_name => params[:user][:first_name], :last_name => params[:user][:last_name],\n :title => params[:user][:title],\n :username => params[:user][:username],:refferal_code => params[:user][:referral_code]}\n },\n :query => {:plan_id => params[:plan_id]}\n }\n resp = HTTParty.post(\"http://app.breeasy.com/api/v1/users.json\", options)\n retval = JSON.parse(resp.body)\n \n end\n # user = User.find 35\n \n respond_to do |format|\n format.json { render :json => retval } # note, no :location or :status options\n end\n end",
"def create\n @admin_vendor = Vendor.new(admin_vendor_params)\n\n respond_to do |format|\n if @admin_vendor.save\n format.html { redirect_to admin_vendors_url, notice: 'Vendor was successfully created.' }\n format.json { render :show, status: :created, location: @admin_vendor }\n else\n format.html { render :new }\n format.json { render json: @admin_vendor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def organization_invite\n params['host'] = Ind.http_api\n params['api_key'] = Accounts.new.find_by_email(params['email']).api_key\n\n org_res = Organizations.new.list(params).orgs\n\n org_res[0][:related_orgs] << params['org_id']\n org_res[0][:api_key] = params['api_key']\n org_res[0][:email] = params['email']\n org_res[0][:host] = Ind.http_api\n\n res = Organizations.new.update(org_res[0])\n redirect_to root_url\n end",
"def set_usr_vendor_property\n @user_contact = UsrContact.find(current_usr_contact )\n end",
"def vendedor_params\n params.require(:vendedor).permit(:codigo, :user_id)\n end",
"def update\n respond_to do |format|\n if @admin_vendor.update(admin_vendor_params)\n format.html { redirect_to admin_vendors_url, notice: 'Vendor was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_vendor }\n else\n format.html { render :edit }\n format.json { render json: @admin_vendor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_customer_information(name1, name2, addr1, city, state, zip, addr2='', country='')\n @PARAM_HASH['NAME1'] = name1\n @PARAM_HASH['NAME2'] = name2\n @PARAM_HASH['ADDR1'] = addr1\n @PARAM_HASH['CITY'] = city\n @PARAM_HASH['STATE'] = state\n @PARAM_HASH['ZIPCODE'] = zip\n @PARAM_HASH['ADDR2'] = addr2\n @PARAM_HASH['COUNTRY'] = country\n end"
] |
[
"0.55371755",
"0.54913795",
"0.54703075",
"0.53519434",
"0.5263387",
"0.51892287",
"0.5170976",
"0.5159538",
"0.5153413",
"0.51261294",
"0.5103107",
"0.51030314",
"0.5053509",
"0.5051054",
"0.5040232",
"0.50084823",
"0.4998513",
"0.4972688",
"0.49528152",
"0.4945624",
"0.49452677",
"0.49406648",
"0.4895346",
"0.48854175",
"0.48834804",
"0.4876696",
"0.4850418",
"0.4824336",
"0.48239875",
"0.4823413",
"0.4815451",
"0.4814413",
"0.48115262",
"0.47939405",
"0.47912043",
"0.47835505",
"0.47817078",
"0.47733095",
"0.47684708",
"0.47652423",
"0.47571757",
"0.475151",
"0.47469947",
"0.47447643",
"0.47438943",
"0.47339877",
"0.4731188",
"0.47295222",
"0.4727352",
"0.47253817",
"0.47253025",
"0.4721596",
"0.47187036",
"0.4715233",
"0.47109437",
"0.471082",
"0.46995413",
"0.46991765",
"0.46986616",
"0.4694176",
"0.46926966",
"0.46773967",
"0.46746564",
"0.4674512",
"0.46740106",
"0.4670484",
"0.46679246",
"0.4665562",
"0.46633154",
"0.4663163",
"0.46629918",
"0.4657972",
"0.46551597",
"0.46523035",
"0.4652228",
"0.46509686",
"0.4644728",
"0.46403936",
"0.4640016",
"0.4633912",
"0.46338668",
"0.462891",
"0.46274215",
"0.46226716",
"0.46175376",
"0.46157193",
"0.4612319",
"0.46116778",
"0.46110696",
"0.46105164",
"0.46083802",
"0.46083802",
"0.46023488",
"0.46008688",
"0.45977393",
"0.45972908",
"0.45955747",
"0.45955297",
"0.4588273",
"0.45863748"
] |
0.55504066
|
0
|
UC3 Put Special prices for corresponding contracts
|
def put_new_pricebid(q)
$LOG.info('put_new_pricebid');
@CID=q["USER"];
@PID=q["PRODUCT"];
@PRICE=q["PRICE"];
@product=get_product(@PID)
$LOG.info('put_new_pricebid: '+@PID.to_s());
$LOG.info('put_new_pricebid: '+@PRICE.to_s());
$LOG.info('put_new_pricebid: '+@CID.to_s());
$LOG.info('put_new_pricebid: '+@product.to_s());
if (@product != nil)
@VID=@product["VID"]
@contracts=get_contracts_by_vendor(@VID);
@contract=@contracts[@CID]
$LOG.info('put_new_pricebid: '+@contract.to_s());
if (@contract!=nil)
# CONTRACT EXISTS - IT'S OK TO PUT PRICE
$LOG.info('put_new_pricebid: '+@prices.to_s());
put_price_for_the_product(@CID,@PID,@PRICE)
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def contract_params\n params.require(:contract).permit(:ticker, :strike_price, :option_type, :expiration_date, :premium, :average_premium_purchase_price, :count, :resource_id, daily_premium_prices: [[]] )\n end",
"def with_currency(new_currency); end",
"def contract_params\n params.require(:contract).permit(:user_id, :item_id, :contract_price, :payment_type_id, :favour_id, :clear)\n end",
"def eth_value\n return eth_portfolio * eth_price\n end",
"def price(_currency)\n raise Sibit::NotSupportedError, 'price() doesn\\'t work here'\n end",
"def cigaret_price\n 0.30\n end",
"def special_prices\n prices\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 update_stock_price(tckr)\n #return a float with current price\n\n #api\n url = 'https://cloud.iexapis.com/stable'\n end_point = \"/stock/#{tckr.downcase}/batch?\"\n query_string = \"types=quote&\"\n\n composite_url = \"#{url}#{end_point}#{query_string}token=#{TOKEN}\"\n\n response = Validation.validate_api(composite_url)\n # stock_valid(response)\n #url\n #endpoints\n #querystring => transform some array of companytickers into string separated by commas\n\n #parse with json\n\n json = JSON.parse(response[1])\n\n #pp json[\"quote\"]\n\n return [json[\"quote\"][\"companyName\"], json[\"quote\"][\"latestPrice\"]]\n\n\n end",
"def final_price\n base_markup_price + add_markup_person + add_markup_materials\n end",
"def contract_params\n params.require(:contract).permit(:title, :client_id, :sign_date, :description, :cost, :amount, :file, :company)\n end",
"def put_contract(q)\n$LOG.info('put_contract');\n@USER=q[\"USER\"];\n@CONTRACT=q[\"CONTRACT\"];\n@CID=@USER[\"CID\"];\n\n@user=$CACHE.get(\"USER\",@CID)\n$LOG.info(@USER.to_s()+' - '+@CONTRACT.to_s());\n\nif (@user == nil) \n @user=$STORAGE.get(\"USER\",@CID)\n if (@user == nil) \n $STORAGE.put(\"USER\",@CID,@USER)\n @user=$STORAGE.get(\"USER\",@CID)\n end\n if (@user != nil)\n @user=$CACHE.put(\"USER\",@CID,@user) ## new user added\n end \nend\n\n## add new contract with vendor\n\nif (@CONTRACT!=nil)\n@VID=@CONTRACT[\"VID\"];\n@vendor=get_vendor(@VID)\nif (@vendor != nil)\n## vendor exists - OK!!!\n@contracts=get_contracts_by_vendor(@VID);\n\n$LOG.info(@VID.to_s()+' get_contracts_by_vendor '+@contracts.to_s());\n\n\n@contract=@contracts[@CID]\n\n$LOG.info(@CID.to_s()+' get_contract '+@contract.to_s());\n\nif (@contract!=nil)\nclear_price_for_contract(@contract)\nend\nput_contract_for_vendor(@USER, @CONTRACT)\nend \nend\n\nend",
"def price(_currency = 'USD')\n raise Sibit::NotSupportedError, 'Btc.com API doesn\\'t provide prices'\n end",
"def currency; end",
"def currency; end",
"def set_btc_price\n # These associations need to be present or exception occurs.\n if shippingoption && unitprice && payment_method\n set_exchange_rate()\n btc = sum_product_and_shipping_in_currency(\"USD\") / get_exchange_rate(\"USD\")\n self.btc_price = btc.truncate(8)\n end\n end",
"def price(coin_name, qty, btc: nil, date: nil)\n \n price_usd = if date then\n @ccf.price coin_name, date\n else\n coin = @ccf.find(coin_name) \n coin.price_usd.to_f \n end\n \n \"%.2f %s\" % [(price_usd * qty.to_f) * @jer.rate(@mycurrency), \n @mycurrency]\n end",
"def special_prices\n customized_special_prices || prices\n end",
"def contract_params\n params.fetch(:contract, {}).permit(:contract, :risk, :risk_limit)\n end",
"def set_parent_item_base_cost(new_unit_price)\n\n price = 0.0\n case (self.item.price_basis.to_i)\n when 0#[:awp]\n self.item.awp_unit_price = new_unit_price\n when 1 #[:act]\n self.item.act_unit_price = new_unit_price\n when 2 #[:basis_340b]\n self.item.govt_340b_unit_price = new_unit_price\n when 3 #[:wac]\n self.item.wac_unit_price = new_unit_price\n when 4 #[:contract]\n self.item.contract_unit_price = new_unit_price\n when 5 #[:nadac]\n self.item.nadac_unit_price = new_unit_price\n when 6 #[:custom]\n self.item.custom_unit_price = new_unit_price\n when 7 #[:user]\n self.item.mac_unit_price = new_unit_price\n else\n price = 0.0\n end\n self.item.save!\n end",
"def contract_params\n params.require(:contract).permit( :date, :season, :portfolio_number, :membership, :membership_number, :membership_type, :mail, :sell_price, :number_weeks, :price_week, :price_rent, :tipo, :owner, :commission, :coowner, :lenguaje, :unit_size, :country, :city, :resort)\n end",
"def ticket_price\n\t\t#There is no base cost\n\t\tticket_price = @price\n\t\t@items.each do |item|\n\t\tif @items.count > 5\n\t\t\tticket_price += item.price * 0.9\n\t\telse\n\t\t\tticket_price += item.price\n\t\tend\n\t\tend\n\t\tticket_price.round(2)\n\tend",
"def mark_up_amt\n rounder5(self.vehicle.price * 0.082)\n end",
"def compute_tax(item_price, tax_rate)\n item_price * tax_rate\n end",
"def populate_product_price_in_multi_currency\n\tcurrency = Currency.new\n\tcurrency.create_product_currency(@product_ids)\nend",
"def all_costs\n smoked_all_time * cigaret_price\n end",
"def buyback_price=(p)\n self.buy_price_cents = (self.string_to_float(p, :locale => self.vendor.region) * 100).round\n end",
"def format_vat\n if self.vat_type == \"standard_rate_purchases_15\" || self.vat_type == \"standard_rate_sales_15\" || self.vat_type == \"standard_rate_sales_capital_goods_15\"\n self.vat_amount = ( self.price * 0.15) / (1 + 0.15)\n self.net_price = self.price / (1.15)\n \n else\n self.vat_amount = 0\n self.net_price = self.price\n end\n end",
"def stock_market; end",
"def mark_up()\n return @retail_price-@buying_cost\n end",
"def price_in_cents=(cents)\n\t\t@price = cents / 100.0\n\tend",
"def price_in_cents=(cents)\n\t\t@price = cents / 100.0\n\tend",
"def contract_item_params\n params.require(:contract_item).permit(:contract_id, :prod_type_id, :product_id)\n end",
"def make_currency_trade(trade)\n instrument = trade.instrument.classify.constantize.find(trade.instrument_id)\n #make sure you have what you are selling\n if trade.typ == \"ask\"\n if portfolio.usd >= trade.amount\n trade.save\n \"Trade executed.\"\n else \n \"You do not have sufficient USD to sell.\"\n end\n elsif trade.typ == \"bid\"\n if portfolio.funds >= trade.amount*trade.price\n trade.save\n \"Trade executed. Check portfolio page.\"\n else\n \"You do not have sufficient funds.\"\n end\n end\n end",
"def cost(op)\n {labor: 4.38, materials: 0}\nend",
"def price(_currency = 'USD')\n raise Sibit::NotSupportedError, 'Blockchair doesn\\'t provide BTC price'\n end",
"def ntbFromWholesale(wholesale, containerType, items, alcoholType=\"beer\")\n\n # 'Fixed' variables, these would be updated from another method in a full version\n gstRate = 0.05\n aglcRateBeer = 0.51 # cents per litre\n aglcRateCider = 1.57 # cents per litre\n depositRateKeg = 30.00 # dollars per keg\n depositRateBottle = 0.10 # dollars per bottle\n depositRateCan = 0.10 # dollars per can\n recyclingRateBottle = 0.08 # dollars per bottle\n recyclingRateCan = 0.00 # dollars per can [right now zero, but can and will be non-zero]\n \n bottleSize = 0.33 # litres\n bomberSize = 0.65 # litres\n bottle750Size = 0.75\n bottle500Size = 0.5\n canSize = 0.355 # litres\n tallSize = 0.473 # litres\n firkinSize = 40\n pinSize = 20\n vertSize = 30\n kegSize = 58.6\n \n \n ws = wholesale # wholesale for Alberta is all-in except deposit\n ntb = 0.00\n atype = alcoholType\n \n #itemSize\n case containerType \n when \"bottle\"\n itemSize = bottleSize\n when \"bomber\"\n itemSize = bomberSize\n when \"bottle750\"\n itemSize = bottle750Size\n when \"bottle500\"\n itemSize = bottle500Size\n when \"can\"\n itemSize = canSize\n when \"tall\"\n itemSize = tallSize\n when \"firkin\"\n itemSize = firkinSize\n when \"pin\"\n itemSize = pinSize\n when \"vert\"\n itemSize = vertSize\n when \"keg\"\n itemSize = kegSize\n else\n puts \"ERROR: unknown containerType\"\n end\n \n \n # NTB + recycling + AGLC = GST'ble\n # GST'ble * rate = GST\n # GST'ble + GST + can deposit + bottle deposit = sell sheet\n # sell sheet + keg deposit = wholesale\n \n #kegDeposit\n \n case containerType\n \n when \"firkin\"\n kegDeposit = depositRateKeg * items\n when \"pin\"\n kegDeposit = depositRateKeg * items\n when \"keg\"\n kegDeposit = depositRateKeg * items\n when \"vert\"\n kegDeposit = depositRateKeg * items\n else\n kegDeposit = 0\n end\n puts \"kegDeposit = #{kegDeposit}\"\n\n\n #sell sheet\n\n sellSheet = ws - kegDeposit\n puts \"sellSheet = #{ws} - #{kegDeposit} = #{sellSheet}\"\n \n # canDeposit\n \n case containerType\n \n when \"can\"\n canDeposit = depositRateCan * items\n when \"tall\"\n canDeposit = depositRateCan * items\n else\n canDeposit = 0\n end\n \n # bottleDeposit\n\n case containerType\n \n when \"bottle\"\n bottleDeposit = depositRateBottle * items\n when \"bomber\"\n bottleDeposit = depositRateBottle * items\n when \"bottle750\"\n bottleDeposit = depositRateBottle * items\n when \"bomber750\"\n bottleDeposit = depositRateBottle * items\n else\n bottleDeposit = 0\n end\n \n #gstGross\n \n gstGross = sellSheet - canDeposit - bottleDeposit\n puts \"gstGross = sellSheet (#{sellSheet}) - canDeposit (#{canDeposit}) - bottleDeposit (#{bottleDeposit}) = #{gstGross}\"\n \n #gst\n \n gst = gstGross * (gstRate / (1 + gstRate))\n \n #gstble\n \n gstble = gstGross - gst\n \n #aglc\n \n if alcoholType == \"beer\"\n aglcRate = aglcRateBeer\n elsif alcoholType == \"cider\"\n aglcRate = aglcRateCider\n else\n puts \"ERROR: NO ALCOHOL TYPE\"\n end\n \n aglc = aglcRate * itemSize * items\n \n #bottleRecycle\n \n case containerType\n \n when \"bottle\"\n bottleRecycle = recyclingRateBottle * items\n when \"bomber\"\n bottleRecycle = recyclingRateBottle * items\n when \"bottle750\"\n bottleRecycle = recyclingRateBottle * items\n when \"bomber750\"\n bottleRecycle = recyclingRateBottle * items\n else\n bottleRecycle = 0\n end\n \n #canRecycle\n \n case containerType\n \n when \"can\"\n canRecycle = recyclingRateCan * items\n when \"tall\"\n canRecycle = recyclingRateCan * items\n else\n canRecycle = 0\n end\n \n #ntb\n \n ntb = gstble - aglc - bottleRecycle - canRecycle\n \nend",
"def initialize(company, symbol, price_per_share, currency, quantity)\n @company = company\n @symbol = symbol\n @price_per_share = price_per_share.to_i\n @currency = currency\n @quantity = quantity\n end",
"def price_with_vat\n # si el valor es nil, devolvera igualmente nil:\n return nil if price.nil?\n # de lo contrario, se aplica formula de IVA:\n price * (100 + BOOK_VAT) / 100\n end",
"def mk_coupon_hash(c)\n rounded_unit_price = (c[:cost].to_f * 1.0 / c[:num]).round(2)\n {\n :item => \"#{c[:item]} W/COUPON\",\n :price => rounded_unit_price,\n :count => c[:num]\n }\nend",
"def price\n BigDecimal('3.0')\n end",
"def ict3_params\n params.require(:ict3).permit(:Item, :Total, :Coverage_in_percentage)\n end",
"def utransaction_params\n params.require(:utransaction).permit(:transaction_type, :contract_id, :user_id, :quantity, :comment, :contract_current_value, :cost)\n end",
"def add_volatility_rows(db, q1, q2, q3, q4, q5)\n db.execute(\"INSERT INTO volatility_table \n (quintile_1, quintile_2, quintile_3, quintile_4, quintile_5) \n VALUES (?, ?, ?, ?, ?)\", [q1, q2, q3, q4, q5])\nend",
"def initialize(name, price, currency, shares)\n @name = name\n @price = price\n @currency = currency.upcase\n @shares = shares\n convert_curr\n shares_totals\n end",
"def contractual_labour_params\n params.require(:contractual_labour).permit(:date, :contract_name, :contractor_id, :site_id, :quantity, :unit, :rate, :amount, :gst_rate, :gst_cost, :tds_rate, :tds_cost, :created_by)\n end",
"def adapt_gross\n return if self.vendor.net_prices || self.tax == self.item.tax_profile.value\n \n net_cents = self.total_cents / ( 1.0 + ( self.item.tax_profile.value / 100.0 ) )\n self.total_cents = (net_cents * ( 1.0 + ( self.tax / 100.0 ) )).round(2)\n end",
"def price_with_tax\n price_as_price.with_tax\n end",
"def apply_clearance(cart)\n cart.each do |item_name, item_info|\n item_info.each do |key, value|\n if key == :clearance\n if value == true\n cart[item_name][:price] = (cart[item_name][:price] * 0.8).round(3)\n end\n end\n end\n end\n return cart\nend",
"def set_price_from_item\n self.price_cents = self.item.price_cents if self.price_cents.blank?\n end",
"def contract_params\n params.require(:contract).permit(:reference, :source, :department_id, :supplier_name, :value, :end_date, :organisation_id, :project, :product, :value_cents, :start_date, :years, :sector, :annual_value_cents, :category, :sub_contrators, :notes, :status, :year_awarded)\n end",
"def currency_conversion(price = 0.0)\n exchange = 6.98\n price * exchange\nend",
"def get_price\n item_prc_1\n end",
"def contract_params\n params.require(:contract).permit(:origin_id, :entity_id, :mode_id, :control_number, :publication_number, :description, :status_id, :contracted_amount_cents, :contracted_amount_currency, :publication_date, :presentation_date, :contact, :warranty, :specification_price, :aclaration_date, :granted_date, :abandonment_date, :region_id, :regulation_id)\n end",
"def contract_params\n params.require(:contract).permit(:contract_name, :customer_id, :signed_date , :expiring_date, :description)\n end",
"def contract_params\n params.require(:contract).permit(:hourly, :amount, :payment_protection, :freelancer_signed, :poster_signed, :freelancer_approved, :poster_approved, :weekly_hours, :payment_interval, :project_start, :post_id, :project_end )\n end",
"def get_price_of_the_product(q)\n@pricebid=nil\n$LOG.info('get_price_of_the_product');\n@CID=q[\"USER\"];\n@PID=q[\"PRODUCT\"];\n@product=get_product(@PID)\n\n$LOG.info(@PID.to_s()+' - '+@product.to_s());\n\nif (@product != nil)\n@pricebid=@product[\"DEFPRICE\"]\n@vid=@product[\"VID\"]\n\n$LOG.info(@vid.to_s()+' - '+@pricebid.to_s());\n\n@contracts=get_contracts_by_vendor(@vid); # GET all contracts of vendor\n@contract=@contracts[@CID]\n\n$LOG.info(' contract => '+@contract.to_s());\n\nif (@contract!=nil) # User has contract with vendor\n# CONTRACT EXISTS - IT'S OK TO PUT PRICE \n@prices=get_prices_for_the_product(@PID) \n@pricebid=nil;\nif (@prices != nil)\n@pricebid0=@prices[@CID]\nif (@pricebid0 != nil)\n@pricebid=@pricebid0\nend\nend\nend\n\n\n \nend\n\n$LOG.info(' RESULT => '+@pricebid.to_s());\n\n@pricebid\nend",
"def apply_clearance(cart)\n cart.each do |item|\n if item[:clearance]\n item[:price] = item[:price] - item[:price] * 0.2\n end\n end\nend",
"def convert_to_user_currency(statements)\n exchange_rate = Currency.count_exchange_rate(session[:default_currency], session[:show_currency])\n\n statements.each { |statement|\n statement.price = statement.price.to_d * exchange_rate\n statement.price_with_vat = statement.price_with_vat.to_d * exchange_rate\n }\n\n statements\n end",
"def rupees_coins(rupees, x_coin, y_coin, z_coin)\n factor = rupees / 3\n {\n rupees_coins1: factor * x_coin,\n paisa_coins50: factor * y_coin,\n paisa_coins25: factor * z_coin\n }\nend",
"def set_contract\n @contract = Contract.find(params[:id])\n @parties = @contract.parties\n @committees = @contract.committees\n @financial_term = @contract.financial_term\n @physical_scope = @contract.physical_scope\n end",
"def price\n { 'price' => success ? '0.03' : '0.00' }\n end",
"def net_single_base\n conv_price_single * ( 1 - (conv_discount / 100 ) )\n end",
"def price\n MoneyUtils.format(self.price_basis)\n end",
"def setup_cost_types\n q = params[:q]\n t = q[:total_cost_eq].to_i\n\n if t == TechnicalServicesHelper::COST_TYPE_FREE\n q[:total_cost_eq] = '0.0'\n elsif t == TechnicalServicesHelper::COST_TYPE_NONFREE\n q[:total_cost_gt] = '0.0'\n q.delete(:total_cost_eq)\n end\n end",
"def update\n respond_to do |format|\n if @contract.daily_premium_prices.push(params[:daily_premium_prices][0])\n @contract.update_attributes(:premium => contract_params[:premium], :count => contract_params[:count])\n @contract.save\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 apply_clearance(cart)\n cart.map{ |item|\n if item[:clearance] == true\n item[:price] = (item[:price] * 0.80).round(2)\n end\n }\n cart\nend",
"def calcTaxes price\r\n taxrate = 0.95\r\n return taxrate * price\r\nend",
"def apply_clearance(cart)\n cart.each do |item, info_hash|\n if info_hash[:clearance] == true\n info_hash[:price] = (info_hash[:price] * 0.80).round(2)\n end\n end\nend",
"def add_taxes(amt, good_tax, import_tax)\n amt += good_tax + import_tax\n amt.round(2)\n end",
"def apply_clearance(cart)\n cart.each do |product_name, stats|\n stats[:price]-= stats[:price] * 0.2 if stats[:clearance]\n end\ncart\nend",
"def price_with_vat(q, inc_vat)\n if inc_vat\n price_inc_vat(q)\n else\n price_ex_vat(q)\n end\n end",
"def full_price\n price + tax_evaluation\n end",
"def us_dollar(cents); end",
"def product_selling_price_after_tax\n product_markup_price * (1 - county.tax_factor) \n end",
"def tax\n \"#{price}\".to_i * 0.09 \n end",
"def set_gojek_cost(line_items)\n\t\tline_items.any? ? 'Rp 15,000' : 'Rp 0'\n\tend",
"def apply_coupons(cart, coupons)\n coupons.each do |elem|\n if cart[elem[:item]]\n if cart[elem[:item]][:count] >= elem[:num]\n if cart[\"#{elem[:item]} W/COUPON\"]\n cart[\"#{elem[:item]} W/COUPON\"][:count] += elem[:num]\n else\n coupon_price = elem[:cost] / elem[:num]\n coupon_clearance = cart[elem[:item]][:clearance]\n cart[\"#{elem[:item]} W/COUPON\"] = {\n price: coupon_price,\n clearance: coupon_clearance,\n count: elem[:num]\n }\n end\n cart[elem[:item]][:count] -= elem[:num]\n end\n end\n end\n cart\nend",
"def save_quote\n event_id = params[\"event_id\"]\n for each in Specification.where(event_id: event_id).where(exclude_from_quote: nil)\n if params[\"quoted_price-#{each.id}\"] == nil\n each.quoted_price = 0\n else\n each.quoted_price = (params[\"quoted_price-#{each.id}\"].gsub(\",\" , \"\").to_f * 100).round(2)\n end\n items_cost = params[\"per_item_cost-#{each.id}\"].to_f * 100.0\n each.per_item_cost = items_cost.round(2)\n each.per_item_list_price = (params[\"per_item_list_price-#{each.id}\"].to_f * 100).round(2)\n each.extended_list_price = (params[\"extended_list_price-#{each.id}\"].to_f * 100).round(2)\n each.save!\n end\n quote = Quote.where(event_id: event_id).first\n quote.quote_name = params[\"quote_name\"]\n quote.quote_style = params[\"quote_style\"]\n quoted_total_price = 0\n quoted_total_cost = 0\n for each in Specification.where(event_id: event_id).where(exclude_from_quote: nil)\n if each.quoted_price == nil\n each.quoted_price = 0\n else # do nothing\n end\n quoted_total_price = quoted_total_price + each.quoted_price\n quoted_total_cost = quoted_total_cost + (((each.per_item_cost / 100.0) * (each.item_quantity / 100.0)).round(2) * 100.0).round(2)\n end \n quote.total_price = quoted_total_price\n quote.total_cost = quoted_total_cost\n if quoted_total_cost != 0\n quote.markup = (quoted_total_price / quoted_total_cost) * 100\n else # do nothing\n end\n quote.status = params[\"status\"]\n if params[\"status\"] != \"Completed\" && params[\"status\"] != \"Ordered\"\n quote.wholesale_order_date = nil\n else # do nothing\n end\n quote.save!\n event = Event.where(id: event_id).first\n event.event_status = params[\"status\"]\n event.quote_message = params[\"quote_message\"]\n event.save!\n redirect_to \"/generate_quote/#{event_id}\" and return\n end",
"def transform_profit_to_cost\n items.map! do |item|\n if item[:c].nil? && item[:p].present?\n item.merge(c: -item[:p])\n else\n item\n end\n end\n end",
"def collection_currency\n card_prices = []\n current_user.cards.each do |card|\n price = remove_dot(card.usd_price)\n card_prices << Money.new(price) * card.quantity \n end\n # call `format`\n card_prices.inject(:+) \n end",
"def price_adjustment \n price_adjustment_fixed / 100.0 \n end",
"def fixed_price\n data.fixed_price\n end",
"def price\n \n end",
"def contract_params\n params.require(:contract).permit(:description, :service_type)\n end",
"def configure_contracts_for_tests\n # configure accounts for eosdactokens\n run? %(cleos system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"20.0000 EOS\" --transfer --buy-ram-kbytes 2024 eosio dacowner #{CONTRACT_PUBLIC_KEY} #{CONTRACT_PUBLIC_KEY})\n run? %(cleos system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"10.0000 EOS\" --transfer --buy-ram-kbytes 2024 eosio otherowner #{CONTRACT_PUBLIC_KEY} #{CONTRACT_PUBLIC_KEY})\n\n run %(cleos push action dacdirectory regdac '{\"owner\": \"dacowner\", \"dac_name\": \"eosdac\", \"dac_symbol\": \"4,EOSDAC\", \"title\": \"Custodian Test DAC\", \"refs\": [[1,\"some_ref\"]], \"accounts\": [[2,\"daccustodian\"], [5,\"dacocoiogmbh\"], [7,\"dacescrow\"], [0, \"dacowner\"], [4, \"eosdactokens\"], [1, \"eosdacthedac\"]], \"scopes\": [] }' -p dacowner)\n\n run %(cleos push action daccustodian updateconfige '{\"newconfig\": { \"lockupasset\": \"10.0000 EOSDAC\", \"maxvotes\": 5, \"periodlength\": 604800 , \"numelected\": 12, \"should_pay_via_service_provider\": 1, \"auththresh\": 3, \"initial_vote_quorum_percent\": 15, \"vote_quorum_percent\": 10, \"auth_threshold_high\": 11, \"auth_threshold_mid\": 7, \"auth_threshold_low\": 3, \"lockup_release_time_delay\": 10, \"requested_pay_max\": \"450.0000 EOS\"}, \"dac_id\": \"eosdac\"}' -p dacowner)\n # run %(cleos push action daccustodian updateconfige '{\"newconfig\": { \"lockupasset\": \"10.0000 EOSDAC\", \"maxvotes\": 5, \"periodlength\": 604800 , \"numelected\": 12, \"should_pay_via_service_provider\": 1, \"auththresh\": 3, \"initial_vote_quorum_percent\": 15, \"vote_quorum_percent\": 10, \"auth_threshold_high\": 11, \"auth_threshold_mid\": 7, \"auth_threshold_low\": 3, \"lockup_release_time_delay\": 10, \"requested_pay_max\": \"450.0000 EOS\"}, \"dac_id\": \"otherdac\"}' -p otherowner -p dacowner)\n\n # run %(cleos push action eosdactokens create '{ \"issuer\": \"dacowner\", \"maximum_supply\": \"100000.0000 EOSDAC\", \"transfer_locked\": false}' -p dacowner)\n # run %(cleos push action eosdactokens create '{ \"issuer\": \"otherowner\", \"maximum_supply\": \"100000.0000 OTRDAC\", \"transfer_locked\": false}' -p otherowner)\n\n # run %(cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"77337.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p dacowner)\n # run %(cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"77337.0000 OTRDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p otherowner)\n # run %(cleos push action eosio.token issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"100000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio)\n # run %(cleos push action eosdactokens issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"1000.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p dacowner)\n # run %(cleos push action eosdactokens issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"1000.0000 OTRDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p otherowner)\n\n\n # run %(cleos push action eosdactokens newmemtermse '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\", \"dac_id\": \"custtestdac\"}' -p dacowner)\n # run %(cleos push action eosdactokens newmemtermse '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\", \"dac_id\": \"otherdac\"}' -p otherowner -p dacowner)\n\n #create users \n # seed_dac_account(\"testreguser1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n # seed_dac_account(\"testreguser1\", issue: \"100.0000 OTRDAC\", memberreg: \"New Latest terms\", dac_id: \"otherdac\", dac_owner: \"otherowner\") # run again for the same user in a different dac should just do the DAC stuff.\n # seed_dac_account(\"testreguser2\", issue: \"100.0000 EOSDAC\")\n # seed_dac_account(\"testreguser3\", issue: \"100.0000 EOSDAC\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n # seed_dac_account(\"testreguser4\", issue: \"100.0000 EOSDAC\", memberreg: \"old terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n # seed_dac_account(\"testreguser5\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n # seed_dac_account(\"testregusera\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n\n # This is required to allow the newperiode to run and set the account permissions from within the action.\n run %(cleos set account permission dacowner owner '{\"threshold\": 1,\"keys\": [{\"key\": \"#{CONTRACT_PUBLIC_KEY}\",\"weight\": 1}],\"accounts\": [{\"permission\":{\"actor\":\"daccustodian\",\"permission\":\"eosio.code\"},\"weight\":1}]}' '' -p dacowner@owner)\n # Configure accounts permissions hierarchy\n run %(cleos set account permission dacowner high #{CONTRACT_PUBLIC_KEY} active -p dacowner)\n run %(cleos set account permission dacowner med #{CONTRACT_PUBLIC_KEY} high -p dacowner)\n run %(cleos set account permission dacowner low #{CONTRACT_PUBLIC_KEY} med -p dacowner)\n run %(cleos set account permission dacowner one #{CONTRACT_PUBLIC_KEY} low -p dacowner)\n\nend",
"def net_price\n if self.patient.is_a_firm?\n self.price\n else\n self.price + get_additional_cost_totals()[:negative]\n end\n end",
"def configure_contracts_for_tests\n # configure accounts for eosdactokens\n run %(cleos system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"10.0000 EOS\" --transfer --buy-ram-kbytes 2024 eosio dacowner #{CONTRACT_PUBLIC_KEY} #{CONTRACT_PUBLIC_KEY})\n run %(cleos system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"10.0000 EOS\" --transfer --buy-ram-kbytes 2024 eosio otherowner #{CONTRACT_PUBLIC_KEY} #{CONTRACT_PUBLIC_KEY})\n run %(cleos push action dacdirectory regdac '{\"owner\": \"dacowner\", \"dac_id\": \"custtestdac\", \"dac_symbol\": {\"symbol\": \"4,EOSDAC\", \"contract\": \"eosdactokens\"}, \"title\": \"Custodian Test DAC\", \"refs\": [[1,\"some_ref\"]], \"accounts\": [[2,\"daccustodian\"], [5,\"dacocoiogmbh\"], [7,\"dacescrow\"], [0, \"dacowner\"], [4, \"eosdactokens\"], [1, \"eosdacthedac\"]], \"scopes\": [] }' -p dacowner -p eosdacthedac@owner)\n run %(cleos push action dacdirectory regdac '{\"owner\": \"otherowner\", \"dac_id\": \"otherdac\", \"dac_symbol\": {\"symbol\": \"4,OTRDAC\", \"contract\": \"eosdactokens\"}, \"title\": \"Other Test DAC\", \"refs\": [[1,\"some_ref\"]], \"accounts\": [[2,\"daccustodian\"], [5,\"dacocoiogmbh\"], [7,\"dacescrow\"], [0, \"otherowner\"], [4, \"eosdactokens\"], [1, \"eosdacthedac\"]], \"scopes\": [] }' -p otherowner -p eosdacthedac@owner)\n\n run %(cleos push action daccustodian updateconfige '{\"newconfig\": { \"lockupasset\": {\"quantity\": \"10.0000 EOSDAC\", \"contract\": \"eosdactokens\"}, \"maxvotes\": 5, \"periodlength\": 604800 , \"numelected\": 12, \"should_pay_via_service_provider\": 1, \"auththresh\": 3, \"initial_vote_quorum_percent\": 15, \"vote_quorum_percent\": 10, \"auth_threshold_high\": 11, \"auth_threshold_mid\": 7, \"auth_threshold_low\": 3, \"lockup_release_time_delay\": 10, \"requested_pay_max\": { \"contract\": \"eosio.token\",\"quantity\": \"450.0000 EOS\"}}, \"dac_id\": \"custtestdac\"}' -p dacowner)\n run %(cleos push action daccustodian updateconfige '{\"newconfig\": { \"lockupasset\": {\"quantity\": \"10.0000 EOSDAC\", \"contract\": \"eosdactokens\"}, \"maxvotes\": 5, \"periodlength\": 604800 , \"numelected\": 12, \"should_pay_via_service_provider\": 1, \"auththresh\": 3, \"initial_vote_quorum_percent\": 15, \"vote_quorum_percent\": 10, \"auth_threshold_high\": 11, \"auth_threshold_mid\": 7, \"auth_threshold_low\": 3, \"lockup_release_time_delay\": 10, \"requested_pay_max\": { \"contract\": \"eosio.token\",\"quantity\": \"450.0000 EOS\"}}, \"dac_id\": \"otherdac\"}' -p otherowner -p dacowner)\n\n run %(cleos push action eosdactokens create '{ \"issuer\": \"dacowner\", \"maximum_supply\": \"100000.0000 EOSDAC\", \"transfer_locked\": false}' -p dacowner)\n run %(cleos push action eosdactokens create '{ \"issuer\": \"otherowner\", \"maximum_supply\": \"100000.0000 OTRDAC\", \"transfer_locked\": false}' -p otherowner)\n\n run %(cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"77337.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p dacowner)\n run %(cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"77337.0000 OTRDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p otherowner)\n run %(cleos push action eosio.token issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"100000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio)\n run %(cleos push action eosdactokens issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"1000.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p dacowner)\n run %(cleos push action eosdactokens issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"1000.0000 OTRDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p otherowner)\n\n\n run %(cleos push action eosdactokens newmemtermse '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\", \"dac_id\": \"custtestdac\"}' -p dacowner)\n run %(cleos push action eosdactokens newmemtermse '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\", \"dac_id\": \"otherdac\"}' -p otherowner -p dacowner)\n\n #create users \n seed_dac_account(\"testreguser1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"testreguser1\", issue: \"100.0000 OTRDAC\", memberreg: \"New Latest terms\", dac_id: \"otherdac\", dac_owner: \"otherowner\") # run again for the same user in a different dac should just do the DAC stuff.\n seed_dac_account(\"testreguser2\", issue: \"100.0000 EOSDAC\")\n seed_dac_account(\"testreguser3\", issue: \"100.0000 EOSDAC\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"testreguser4\", issue: \"100.0000 EOSDAC\", memberreg: \"old terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"testreguser5\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"testregusera\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n\n # This is required to allow the newperiode to run and set the account permissions from within the action.\n run %(cleos set account permission dacowner owner '{\"threshold\": 1,\"keys\": [{\"key\": \"#{CONTRACT_PUBLIC_KEY}\",\"weight\": 1}],\"accounts\": [{\"permission\":{\"actor\":\"daccustodian\",\"permission\":\"eosio.code\"},\"weight\":1}]}' '' -p dacowner@owner)\n # Configure accounts permissions hierarchy\n run %(cleos set account permission dacowner high #{CONTRACT_PUBLIC_KEY} active -p dacowner)\n run %(cleos set account permission dacowner med #{CONTRACT_PUBLIC_KEY} high -p dacowner)\n run %(cleos set account permission dacowner low #{CONTRACT_PUBLIC_KEY} med -p dacowner)\n run %(cleos set account permission dacowner one #{CONTRACT_PUBLIC_KEY} low -p dacowner)\nend",
"def new_trade(time, price, amount)\n { time: time, price: BigDecimal.new(price), amount: BigDecimal.new(amount) }\n end",
"def contract_saved contract\n\t\t@contract = contract\n\t\t@semesters = @contract.semesters\n\t\t# Prices\n\t\t@application_fee = Prices::application_fee\n\t\t@deposit = Prices::deposit(@semesters)\n\t\t@early_bird = Prices::early_bird(@semesters, Date.today)\n\t\t@rent = Prices::rent(@semesters)\n\t\t@parking = Prices::parking_price(@contract.parking_type, @semesters)\n\t\t@multiple_semesters = Prices::multiple_semester_discounts @semesters\n\n\t\t# Calculations\n\t\t@parking_price = 0\n\t\t@parking.each do |park|\n\t\t\t@parking_price += park\n\t\tend\n\t\t@early_bird_sum = 0\n\t\t@early_bird.each do |early|\n\t\t\t@early_bird_sum += early\n\t\tend\n\t\t@multiple_semesters_sum = 0\n\t\t@multiple_semesters.each do |discount|\n\t\t\t@multiple_semesters_sum += discount\n\t\tend\n\n\t\t@euro = 0\n\t\t@euro = 50 unless @contract.euro.empty?\n\t\t@discounts_total = @early_bird_sum + @multiple_semesters_sum + @euro\n\n\t\t@rent_sum = 0\n\t\t@rent.each do |rent|\n\t\t\t@rent_sum += rent\n\t\tend\n\t\t@total = @application_fee + @deposit + @rent_sum + @parking_price - @discounts_total\n\n\t\tmail to: ['managers@windsormanor.net', @contract.email],\n\t\t\tsubject: 'Your Receipt for Windsor Manor'\n\tend",
"def get_additional_cost_totals\n pos_cost = 0.0 # init result\n neg_cost = 0.0 # init result\n AppParameterCustomizations.get_receipt_costs().each do |c|\n if c[:value] > 0\n pos_cost += c[:value].to_f / 100.0\n elsif self.price >= 78.19\n neg_cost += c[:value].to_f / 100.0 unless self.patient.is_a_firm?\n end\n end\n return { :negative => neg_cost, :positive => pos_cost }\n end",
"def calculate_sell_price_using_account_pricing_tier cogs\n if cogs.nil?\n nil\n else\n account_pricing_tier = AccountPricingTier.where(:account_id => account, :product => product).first()\n\n if account_pricing_tier.nil?\n # Assume GP of 25% if no pricing tier exists\n sell_price = cogs / (1 - 25.0 / 100)\n else\n pricing_tier = PricingTier.find(account_pricing_tier.pricing_tier_id)\n sell_price = cogs / (1 - pricing_tier.gross_profit / 100)\n end\n sell_price\n end\n end",
"def calculate_sell_price_using_account_pricing_tier cogs\n if cogs.nil?\n nil\n else\n account_pricing_tier = AccountPricingTier.where(:account_id => account, :product => product).first()\n\n if account_pricing_tier.nil?\n # Assume GP of 25% if no pricing tier exists\n sell_price = cogs / (1 - 25.0 / 100)\n else\n pricing_tier = PricingTier.find(account_pricing_tier.pricing_tier_id)\n sell_price = cogs / (1 - pricing_tier.gross_profit / 100)\n end\n sell_price\n end\n end",
"def cost(op)\n { materials: 0.84, labor: 1.24 }\nend",
"def bitcoin\n @bitcoin_data = {\n price: @api_hash[\"RAW\"][\"BTC\"][\"USD\"][\"PRICE\"],\n change_usd: @api_hash[\"RAW\"][\"BTC\"][\"USD\"][\"CHANGE24HOUR\"].round(2),\n change_percent: @api_hash[\"RAW\"][\"BTC\"][\"USD\"][\"CHANGEPCT24HOUR\"].round(2)\n }\nend",
"def coin_params\n params.permit(:name, :currency, :symbol, :logo_url, :price, :rank, :price_date, :market_cap, :circulating_supply, :max_supply, :high, :high_timestamp, :max_sold)\n end",
"def currency_list\n list = [[price_currency, price_currency]]\n list << [alt1_price_currency, alt1_price_currency] unless alt1_price_currency.blank?\n list << [alt2_price_currency, alt2_price_currency] unless alt2_price_currency.blank?\n list\n end",
"def contract_params\n params.require(:contract).permit(:name, :abi, :methods, :address)\n end",
"def find_other_taxes\n @service_tax = @seats_price * SERVICE_TAX\n @swach_bharath_cess = @seats_price * SWACH_BHARATH_CESS\n @krishi_kalyan_cess = @seats_price * KRISHI_KALYAN_CESS\n end",
"def discounted_price_for_customs\n hash[\"DiscountedPriceForCustoms\"]\n end"
] |
[
"0.59256154",
"0.5680014",
"0.5652126",
"0.56215507",
"0.5534247",
"0.5528158",
"0.5477522",
"0.5467856",
"0.54495084",
"0.5385718",
"0.53639704",
"0.5354278",
"0.5350004",
"0.5319892",
"0.5319892",
"0.5305047",
"0.5298456",
"0.5295921",
"0.52634",
"0.5247313",
"0.5245897",
"0.5225047",
"0.52228487",
"0.52085",
"0.52083796",
"0.5192943",
"0.517635",
"0.5172089",
"0.51689553",
"0.5162812",
"0.51626325",
"0.51626325",
"0.51622385",
"0.51541036",
"0.5151853",
"0.5145027",
"0.5144951",
"0.51447207",
"0.5138748",
"0.51351386",
"0.5134586",
"0.5122509",
"0.5117039",
"0.5115539",
"0.51115525",
"0.5111368",
"0.51107514",
"0.51098996",
"0.51092595",
"0.5101962",
"0.5101823",
"0.5095855",
"0.50845796",
"0.5081425",
"0.5071188",
"0.50620985",
"0.5060996",
"0.50503826",
"0.5049125",
"0.50419146",
"0.5041472",
"0.50388193",
"0.503468",
"0.50329196",
"0.5031079",
"0.50272703",
"0.50265193",
"0.50264704",
"0.5024751",
"0.5020296",
"0.5018539",
"0.5014144",
"0.5002927",
"0.5002785",
"0.49933526",
"0.49925745",
"0.4990209",
"0.4989479",
"0.4976306",
"0.49731818",
"0.4971758",
"0.496481",
"0.4963987",
"0.49605963",
"0.49538517",
"0.4952394",
"0.49517584",
"0.4951103",
"0.49498275",
"0.49485874",
"0.49433985",
"0.49414128",
"0.49414128",
"0.49411684",
"0.49397802",
"0.49340063",
"0.49326658",
"0.49300233",
"0.49271914",
"0.49215162"
] |
0.56760985
|
2
|
UC4 Put Special pricies for corresponding contracts
|
def get_price_of_the_product(q)
@pricebid=nil
$LOG.info('get_price_of_the_product');
@CID=q["USER"];
@PID=q["PRODUCT"];
@product=get_product(@PID)
$LOG.info(@PID.to_s()+' - '+@product.to_s());
if (@product != nil)
@pricebid=@product["DEFPRICE"]
@vid=@product["VID"]
$LOG.info(@vid.to_s()+' - '+@pricebid.to_s());
@contracts=get_contracts_by_vendor(@vid); # GET all contracts of vendor
@contract=@contracts[@CID]
$LOG.info(' contract => '+@contract.to_s());
if (@contract!=nil) # User has contract with vendor
# CONTRACT EXISTS - IT'S OK TO PUT PRICE
@prices=get_prices_for_the_product(@PID)
@pricebid=nil;
if (@prices != nil)
@pricebid0=@prices[@CID]
if (@pricebid0 != nil)
@pricebid=@pricebid0
end
end
end
end
$LOG.info(' RESULT => '+@pricebid.to_s());
@pricebid
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_random_contract\n available_contract_missions.each do |m|\n end\n end",
"def contract_params\n params.fetch(:contract, {}).permit(:contract, :risk, :risk_limit)\n end",
"def add_contract_requirements(sheet)\n bold_style = sheet.styles.add_style b: true\n sheet.add_row []\n sheet.add_row ['2. Contract requirements'], style: bold_style\n add_initial_call_off_period(sheet)\n add_mobilisation_period(sheet)\n sheet.add_row ['Date of First Indexation', @procurement.initial_call_off_period < 1.year ? 'Not applicable' : (@procurement.initial_call_off_start_date + 1.year).strftime('%d/%m/%Y')]\n add_extension_periods(sheet)\n add_tupe(sheet)\n end",
"def contract_params\n params.require(:contract).permit(\n :contract_type, \n :contract_name,\n :objectives, \n :confirmation_date,\n :approval_date,\n :start_date, \n :end_date,\n :attachment, \n financial_term_attributes: [\n :id, \n :payer,\n :payee,\n :amount,\n :frequency,\n :start_date,\n :end_date,\n :escalation_rate,\n :advance,\n :deposit,\n :contract_id,\n :_destroy\n ], \n physical_scope_attributes: [\n :id,\n :address,\n :land_area,\n :boundaries,\n :use_of_premises,\n :contract_id,\n :_destroy\n ],\n committees_attributes: [\n :id,\n :committee_name,\n :responsibilities, \n :contract_id,\n :_destroy,\n committee_members_attributes: [\n :id,\n :member_name,\n :leader,\n :committee_id,\n :_destroy\n ]\n ],\n parties_attributes: [\n :id,\n :party_name,\n :external,\n :contract_id,\n :_destroy\n ]\n )\n end",
"def contract_params\n params.require(:contract).permit(:user_id, :item_id, :contract_price, :payment_type_id, :favour_id, :clear)\n end",
"def cict_params\n params.require(:cict).permit(:commitmentitem_id, :customtemplate_id)\n end",
"def set_contract\n @contract = Contract.find(params[:id])\n @parties = @contract.parties\n @committees = @contract.committees\n @financial_term = @contract.financial_term\n @physical_scope = @contract.physical_scope\n end",
"def contract_params\n params.require(:contract).permit(:origin_id, :entity_id, :mode_id, :control_number, :publication_number, :description, :status_id, :contracted_amount_cents, :contracted_amount_currency, :publication_date, :presentation_date, :contact, :warranty, :specification_price, :aclaration_date, :granted_date, :abandonment_date, :region_id, :regulation_id)\n end",
"def contract_params\n params.require(:contract).permit(:reference, :source, :department_id, :supplier_name, :value, :end_date, :organisation_id, :project, :product, :value_cents, :start_date, :years, :sector, :annual_value_cents, :category, :sub_contrators, :notes, :status, :year_awarded)\n end",
"def contract_params\n params.require(:contract).permit( :date, :season, :portfolio_number, :membership, :membership_number, :membership_type, :mail, :sell_price, :number_weeks, :price_week, :price_rent, :tipo, :owner, :commission, :coowner, :lenguaje, :unit_size, :country, :city, :resort)\n end",
"def fp7_contractor_params\n params.require(:fp7_contractor).permit(:rcn, :project_title, :contract_number, :role, :pj_uid, :organization_name, :organization_department, :organization_subdepartment, :organization_acronym, :organization_size, :organization_type, :address, :po_box, :post_code, :city, :country, :organization_website, :pe_uid, :contact_surname, :contact_name, :contact_position, :contact_initials, :contact_title)\n end",
"def contractor_params\n params.require(:contractor).permit(:company, :first_name, :last_name, :street_address, :city, :state, :zip, :phone, :email, :specilization, :contractor_license_number, :insurance, :insurance_type, :coverage, :experience, :management_experience, :employees, :projects, :past_projects, :job_capacity, :recent_jobs, :sow, :job_address, :job_bid, :materials_labor, :warranties, :warranties_length, :sub_contractor, :licensed_insured, :electrician, :plumber, :certificates_licenses, :bbb_coc, :bankruptcy, :communication, :clean, :lien_waiver, :references, :lead_source)\n end",
"def put_contract(q)\n$LOG.info('put_contract');\n@USER=q[\"USER\"];\n@CONTRACT=q[\"CONTRACT\"];\n@CID=@USER[\"CID\"];\n\n@user=$CACHE.get(\"USER\",@CID)\n$LOG.info(@USER.to_s()+' - '+@CONTRACT.to_s());\n\nif (@user == nil) \n @user=$STORAGE.get(\"USER\",@CID)\n if (@user == nil) \n $STORAGE.put(\"USER\",@CID,@USER)\n @user=$STORAGE.get(\"USER\",@CID)\n end\n if (@user != nil)\n @user=$CACHE.put(\"USER\",@CID,@user) ## new user added\n end \nend\n\n## add new contract with vendor\n\nif (@CONTRACT!=nil)\n@VID=@CONTRACT[\"VID\"];\n@vendor=get_vendor(@VID)\nif (@vendor != nil)\n## vendor exists - OK!!!\n@contracts=get_contracts_by_vendor(@VID);\n\n$LOG.info(@VID.to_s()+' get_contracts_by_vendor '+@contracts.to_s());\n\n\n@contract=@contracts[@CID]\n\n$LOG.info(@CID.to_s()+' get_contract '+@contract.to_s());\n\nif (@contract!=nil)\nclear_price_for_contract(@contract)\nend\nput_contract_for_vendor(@USER, @CONTRACT)\nend \nend\n\nend",
"def contract_params\n params.require(:contract).permit(:title, :client_id, :sign_date, :description, :cost, :amount, :file, :company)\n end",
"def contract_params\n params.require(:contract).permit(:ticker, :strike_price, :option_type, :expiration_date, :premium, :average_premium_purchase_price, :count, :resource_id, daily_premium_prices: [[]] )\n end",
"def available_contract_missions\n Institution.all.map do |i|\n i.campaign = self\n i.available_missions.map do |m|\n { institution: i, mission: m }\n end\n end.flatten\n end",
"def prison_params\n params.require(:prison).permit(:name, criminal_ids:[])\n end",
"def contract_item_params\n params.require(:contract_item).permit(:contract_id, :prod_type_id, :product_id)\n end",
"def contract_params\n params.require(:contract).permit(:status, :contractor_id, :user_profile_id)\n end",
"def contract_params\n params.require(:contract).permit(:game_id, :name)\n end",
"def setup_companies\n setup_associated_minors\n @companies.sort_by! { rand }\n\n minors = @companies.select { |c| c.id[0] == self.class::COMPANY_MINOR_PREFIX }\n minor_6, minors = minors.partition { |c| c.id == 'M6' }\n minors_assoc, minors = minors.partition { |c| @minor_associations.key?(corp_id_from_company_id(c.id)) }\n\n privates = @companies.select { |c| c.id[0] == self.class::COMPANY_PRIVATE_PREFIX }\n private_1 = privates.find { |c| c.id == 'P1' }\n privates.delete(private_1)\n privates.unshift(private_1)\n\n # Clear and add the companies in the correct randomize order sorted by type\n @companies.clear\n @companies.concat(minor_6)\n stack_1 = (minors_assoc[0..2] + minors[0..5]).sort_by! { rand }\n @companies.concat(stack_1)\n stack_2 = (minors_assoc[3..4] + minors[6..10]).sort_by! { rand }\n @companies.concat(stack_2)\n stack_3 = (minors_assoc[5..6] + minors[11..15]).sort_by! { rand }\n @companies.concat(stack_3)\n @companies.concat(privates)\n\n # Setup company abilities\n @company_trains = {}\n @company_trains['P1'] = find_and_remove_train_by_id('5P-0')\n @company_trains['P2'] = find_and_remove_train_by_id('2P-0', buyable: false)\n @company_trains['P3'] = find_and_remove_train_by_id('LP-0', buyable: false)\n @company_trains['P4'] = find_and_remove_train_by_id('LP-1', buyable: false)\n @company_trains['P5'] = find_and_remove_train_by_id('P+-0', buyable: false)\n @company_trains['P6'] = find_and_remove_train_by_id('P+-1', buyable: false)\n end",
"def contract_params\n params.fetch(:contract, {}).permit(:auth_party, :op_type, :auth_fee, :auth_duration, :payment_type, :auth_platform, :auth_location, :song_count, :list_type, :auth_type, :is_shared, :auth_bussiness, :extend_terms, :contract_type, :notes, :name, :time_limit, :expire_date, :auth_right)\n end",
"def contract_params\n params.require(:contract).permit(:contract_name, :customer_id, :signed_date , :expiring_date, :description)\n end",
"def contract_params\n params.require(:contract).permit(:hourly, :amount, :payment_protection, :freelancer_signed, :poster_signed, :freelancer_approved, :poster_approved, :weekly_hours, :payment_interval, :project_start, :post_id, :project_end )\n end",
"def put_new_pricebid(q)\n$LOG.info('put_new_pricebid');\n@CID=q[\"USER\"];\n@PID=q[\"PRODUCT\"];\n@PRICE=q[\"PRICE\"];\n\n\n@product=get_product(@PID)\n$LOG.info('put_new_pricebid: '+@PID.to_s());\n$LOG.info('put_new_pricebid: '+@PRICE.to_s());\n$LOG.info('put_new_pricebid: '+@CID.to_s());\n\n$LOG.info('put_new_pricebid: '+@product.to_s());\n\nif (@product != nil)\n\n@VID=@product[\"VID\"]\n@contracts=get_contracts_by_vendor(@VID);\n@contract=@contracts[@CID]\n$LOG.info('put_new_pricebid: '+@contract.to_s());\n\nif (@contract!=nil)\n# CONTRACT EXISTS - IT'S OK TO PUT PRICE \n$LOG.info('put_new_pricebid: '+@prices.to_s());\nput_price_for_the_product(@CID,@PID,@PRICE)\n\nend\nend\n\nend",
"def ict3_params\n params.require(:ict3).permit(:Item, :Total, :Coverage_in_percentage)\n end",
"def subcontract_category; end",
"def data_for_qualifiers\n @tournament_data = JSON.parse(self.data)\n if @tournament_data['Qualifier 2']\n @q2 = @tournament_data['Qualifier 2']['prize_money']\n if @tournament_data['Qualifier']['prize_money'] == 0\n @tournament_data['Qualifier']['prize_money'] = @q2 * 2\n @tournament_data['Qualifier 3']['prize_money'] = @q2 * 2\n self.data = @tournament_data.to_json\n end\n end\n\n # sur Qualifier et Qualifier 3\n # pour chaque pair verifier la valeur de prize money\n # si prize money = 0\n # assigner nouvelle valeur a prize money (/10?)\n # update instance du tournoi avec nouvelles valeurs de q1\n # Reparser en json (tournoi.update(data.to_json))\n end",
"def contract_params\n params.require(:contract).permit(:name, :abi, :methods, :address)\n end",
"def contractual_labour_params\n params.require(:contractual_labour).permit(:date, :contract_name, :contractor_id, :site_id, :quantity, :unit, :rate, :amount, :gst_rate, :gst_cost, :tds_rate, :tds_cost, :created_by)\n end",
"def create_random_contract\n return nil if contracts.offered.count > 3\n create_third_party_mission available_contract_missions.sample\n end",
"def special_occasion_params\n params.require(:special_occasion).permit(:name, :recipient_id)\n end",
"def admin_contract_params\n # params[:admin_contract]\n # params.require(:contract).permit!\n params.require(:contract).permit(:id,\n :hospital_user_id, :marketing_user_id, :hospital_code, :studio_user_id, :partnership,\n :contracted_at, :contract_renewal,\n :setup_by, :setup_free, :setup_fee, :setup_vat,\n :equipment_by, :equipment_quantity, :equipment_free, :equipment_fee, :equipment_vat,\n :manage_by, :manage_start_at, :manage_period, :manage_vat, :manage_pay_by,\n :marketing_company_id, :marketing_user_name, :marketing_fee_use, :marketing_fee,\n :marketing_fee_ratio, :marketing_fee_vat, :marketing_equipment_fee_free, :marketing_equipment_fee,\n :marketing_equipment_fee_ratio, :marketing_equipment_fee_vat, :note,\n hospital_user_attributes: [:id, :name, :email, :password, :password_confirmation,\n partner_detail_attributes: PartnerDetail.attribute_names.collect { |attr| attr.to_sym }\n ],\n studio_users_attributes: [:id, :name, :email, :password, :password_confirmation,\n partner_detail_attributes: PartnerDetail.attribute_names.collect { |attr| attr.to_sym }\n\n ]\n )\n end",
"def configure_contracts_for_tests\n # configure accounts for eosdactokens\n run? %(cleos system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"20.0000 EOS\" --transfer --buy-ram-kbytes 2024 eosio dacowner #{CONTRACT_PUBLIC_KEY} #{CONTRACT_PUBLIC_KEY})\n run? %(cleos system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"10.0000 EOS\" --transfer --buy-ram-kbytes 2024 eosio otherowner #{CONTRACT_PUBLIC_KEY} #{CONTRACT_PUBLIC_KEY})\n\n run %(cleos push action dacdirectory regdac '{\"owner\": \"dacowner\", \"dac_name\": \"eosdac\", \"dac_symbol\": \"4,EOSDAC\", \"title\": \"Custodian Test DAC\", \"refs\": [[1,\"some_ref\"]], \"accounts\": [[2,\"daccustodian\"], [5,\"dacocoiogmbh\"], [7,\"dacescrow\"], [0, \"dacowner\"], [4, \"eosdactokens\"], [1, \"eosdacthedac\"]], \"scopes\": [] }' -p dacowner)\n\n run %(cleos push action daccustodian updateconfige '{\"newconfig\": { \"lockupasset\": \"10.0000 EOSDAC\", \"maxvotes\": 5, \"periodlength\": 604800 , \"numelected\": 12, \"should_pay_via_service_provider\": 1, \"auththresh\": 3, \"initial_vote_quorum_percent\": 15, \"vote_quorum_percent\": 10, \"auth_threshold_high\": 11, \"auth_threshold_mid\": 7, \"auth_threshold_low\": 3, \"lockup_release_time_delay\": 10, \"requested_pay_max\": \"450.0000 EOS\"}, \"dac_id\": \"eosdac\"}' -p dacowner)\n # run %(cleos push action daccustodian updateconfige '{\"newconfig\": { \"lockupasset\": \"10.0000 EOSDAC\", \"maxvotes\": 5, \"periodlength\": 604800 , \"numelected\": 12, \"should_pay_via_service_provider\": 1, \"auththresh\": 3, \"initial_vote_quorum_percent\": 15, \"vote_quorum_percent\": 10, \"auth_threshold_high\": 11, \"auth_threshold_mid\": 7, \"auth_threshold_low\": 3, \"lockup_release_time_delay\": 10, \"requested_pay_max\": \"450.0000 EOS\"}, \"dac_id\": \"otherdac\"}' -p otherowner -p dacowner)\n\n # run %(cleos push action eosdactokens create '{ \"issuer\": \"dacowner\", \"maximum_supply\": \"100000.0000 EOSDAC\", \"transfer_locked\": false}' -p dacowner)\n # run %(cleos push action eosdactokens create '{ \"issuer\": \"otherowner\", \"maximum_supply\": \"100000.0000 OTRDAC\", \"transfer_locked\": false}' -p otherowner)\n\n # run %(cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"77337.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p dacowner)\n # run %(cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"77337.0000 OTRDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p otherowner)\n # run %(cleos push action eosio.token issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"100000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio)\n # run %(cleos push action eosdactokens issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"1000.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p dacowner)\n # run %(cleos push action eosdactokens issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"1000.0000 OTRDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p otherowner)\n\n\n # run %(cleos push action eosdactokens newmemtermse '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\", \"dac_id\": \"custtestdac\"}' -p dacowner)\n # run %(cleos push action eosdactokens newmemtermse '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\", \"dac_id\": \"otherdac\"}' -p otherowner -p dacowner)\n\n #create users \n # seed_dac_account(\"testreguser1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n # seed_dac_account(\"testreguser1\", issue: \"100.0000 OTRDAC\", memberreg: \"New Latest terms\", dac_id: \"otherdac\", dac_owner: \"otherowner\") # run again for the same user in a different dac should just do the DAC stuff.\n # seed_dac_account(\"testreguser2\", issue: \"100.0000 EOSDAC\")\n # seed_dac_account(\"testreguser3\", issue: \"100.0000 EOSDAC\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n # seed_dac_account(\"testreguser4\", issue: \"100.0000 EOSDAC\", memberreg: \"old terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n # seed_dac_account(\"testreguser5\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n # seed_dac_account(\"testregusera\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n\n # This is required to allow the newperiode to run and set the account permissions from within the action.\n run %(cleos set account permission dacowner owner '{\"threshold\": 1,\"keys\": [{\"key\": \"#{CONTRACT_PUBLIC_KEY}\",\"weight\": 1}],\"accounts\": [{\"permission\":{\"actor\":\"daccustodian\",\"permission\":\"eosio.code\"},\"weight\":1}]}' '' -p dacowner@owner)\n # Configure accounts permissions hierarchy\n run %(cleos set account permission dacowner high #{CONTRACT_PUBLIC_KEY} active -p dacowner)\n run %(cleos set account permission dacowner med #{CONTRACT_PUBLIC_KEY} high -p dacowner)\n run %(cleos set account permission dacowner low #{CONTRACT_PUBLIC_KEY} med -p dacowner)\n run %(cleos set account permission dacowner one #{CONTRACT_PUBLIC_KEY} low -p dacowner)\n\nend",
"def subcontractor_params\n params.require(:subcontractor).permit(:name, :email, :skills, :company_size, :created_at, :location, :link, :description, :password)\n end",
"def modification_1_insert\n projects =[]\n 5.times do\n proj = Project.new\n proj.budget = 300000.0\n proj.delivery_deadline = '2015-02-12'\n proj.status = \"Planning\"\n Perpetuity[Project].insert proj\n projects << proj\n end\n\n 20.times do\n projects.each do |project|\n doc = Document.new\n doc.project = project\n doc.doc_type = \"drawing\"\n doc.doc_name = \"The first floor plans\"\n doc.revision_number = 3\n doc.revision_date = '2014-07-12'\n\n Perpetuity[Document].insert doc\n end\n end\n\n projects.each do |project|\n contract = LegalContract.new\n contract.project = project\n contract.title = \"SLA\"\n contract.signed_on = '2013-04-02'\n contract.revised_on = '2013-12-12'\n contract.copy_stored = 'electronic version'\n\n Perpetuity[LegalContract].insert contract\n end\n return projects.size\nend",
"def contract; end",
"def contract; end",
"def contract_params\n params.require(:contract).permit(:description, :service_type)\n end",
"def opt10075_params\n params.require(:opt10075).permit(:contract_time, :order_number, :manager_number, :stock_code, :business_gubun, :order_status, :stock_name, :order_quantity, :order_price, :not_contract_quantity, :contract_total_amount, :last_order_number, :order_gubun, :trade_gubun, :contract_number, :contract_price, :contract_quantity, :current_price, :offered_price, :bid_price, :contract_price_unit, :contract_price_quantity, :today_commission, :today_tax, :domestic_investor)\n end",
"def configure_contracts_for_tests\n # configure accounts for eosdactokens\n run %(cleos system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"10.0000 EOS\" --transfer --buy-ram-kbytes 2024 eosio dacowner #{CONTRACT_PUBLIC_KEY} #{CONTRACT_PUBLIC_KEY})\n run %(cleos system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"10.0000 EOS\" --transfer --buy-ram-kbytes 2024 eosio otherowner #{CONTRACT_PUBLIC_KEY} #{CONTRACT_PUBLIC_KEY})\n run %(cleos push action dacdirectory regdac '{\"owner\": \"dacowner\", \"dac_id\": \"custtestdac\", \"dac_symbol\": {\"symbol\": \"4,EOSDAC\", \"contract\": \"eosdactokens\"}, \"title\": \"Custodian Test DAC\", \"refs\": [[1,\"some_ref\"]], \"accounts\": [[2,\"daccustodian\"], [5,\"dacocoiogmbh\"], [7,\"dacescrow\"], [0, \"dacowner\"], [4, \"eosdactokens\"], [1, \"eosdacthedac\"]], \"scopes\": [] }' -p dacowner -p eosdacthedac@owner)\n run %(cleos push action dacdirectory regdac '{\"owner\": \"otherowner\", \"dac_id\": \"otherdac\", \"dac_symbol\": {\"symbol\": \"4,OTRDAC\", \"contract\": \"eosdactokens\"}, \"title\": \"Other Test DAC\", \"refs\": [[1,\"some_ref\"]], \"accounts\": [[2,\"daccustodian\"], [5,\"dacocoiogmbh\"], [7,\"dacescrow\"], [0, \"otherowner\"], [4, \"eosdactokens\"], [1, \"eosdacthedac\"]], \"scopes\": [] }' -p otherowner -p eosdacthedac@owner)\n\n run %(cleos push action daccustodian updateconfige '{\"newconfig\": { \"lockupasset\": {\"quantity\": \"10.0000 EOSDAC\", \"contract\": \"eosdactokens\"}, \"maxvotes\": 5, \"periodlength\": 604800 , \"numelected\": 12, \"should_pay_via_service_provider\": 1, \"auththresh\": 3, \"initial_vote_quorum_percent\": 15, \"vote_quorum_percent\": 10, \"auth_threshold_high\": 11, \"auth_threshold_mid\": 7, \"auth_threshold_low\": 3, \"lockup_release_time_delay\": 10, \"requested_pay_max\": { \"contract\": \"eosio.token\",\"quantity\": \"450.0000 EOS\"}}, \"dac_id\": \"custtestdac\"}' -p dacowner)\n run %(cleos push action daccustodian updateconfige '{\"newconfig\": { \"lockupasset\": {\"quantity\": \"10.0000 EOSDAC\", \"contract\": \"eosdactokens\"}, \"maxvotes\": 5, \"periodlength\": 604800 , \"numelected\": 12, \"should_pay_via_service_provider\": 1, \"auththresh\": 3, \"initial_vote_quorum_percent\": 15, \"vote_quorum_percent\": 10, \"auth_threshold_high\": 11, \"auth_threshold_mid\": 7, \"auth_threshold_low\": 3, \"lockup_release_time_delay\": 10, \"requested_pay_max\": { \"contract\": \"eosio.token\",\"quantity\": \"450.0000 EOS\"}}, \"dac_id\": \"otherdac\"}' -p otherowner -p dacowner)\n\n run %(cleos push action eosdactokens create '{ \"issuer\": \"dacowner\", \"maximum_supply\": \"100000.0000 EOSDAC\", \"transfer_locked\": false}' -p dacowner)\n run %(cleos push action eosdactokens create '{ \"issuer\": \"otherowner\", \"maximum_supply\": \"100000.0000 OTRDAC\", \"transfer_locked\": false}' -p otherowner)\n\n run %(cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"77337.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p dacowner)\n run %(cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"77337.0000 OTRDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p otherowner)\n run %(cleos push action eosio.token issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"100000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio)\n run %(cleos push action eosdactokens issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"1000.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p dacowner)\n run %(cleos push action eosdactokens issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"1000.0000 OTRDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p otherowner)\n\n\n run %(cleos push action eosdactokens newmemtermse '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\", \"dac_id\": \"custtestdac\"}' -p dacowner)\n run %(cleos push action eosdactokens newmemtermse '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\", \"dac_id\": \"otherdac\"}' -p otherowner -p dacowner)\n\n #create users \n seed_dac_account(\"testreguser1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"testreguser1\", issue: \"100.0000 OTRDAC\", memberreg: \"New Latest terms\", dac_id: \"otherdac\", dac_owner: \"otherowner\") # run again for the same user in a different dac should just do the DAC stuff.\n seed_dac_account(\"testreguser2\", issue: \"100.0000 EOSDAC\")\n seed_dac_account(\"testreguser3\", issue: \"100.0000 EOSDAC\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"testreguser4\", issue: \"100.0000 EOSDAC\", memberreg: \"old terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"testreguser5\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"testregusera\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_id: \"custtestdac\", dac_owner: \"dacowner\")\n\n # This is required to allow the newperiode to run and set the account permissions from within the action.\n run %(cleos set account permission dacowner owner '{\"threshold\": 1,\"keys\": [{\"key\": \"#{CONTRACT_PUBLIC_KEY}\",\"weight\": 1}],\"accounts\": [{\"permission\":{\"actor\":\"daccustodian\",\"permission\":\"eosio.code\"},\"weight\":1}]}' '' -p dacowner@owner)\n # Configure accounts permissions hierarchy\n run %(cleos set account permission dacowner high #{CONTRACT_PUBLIC_KEY} active -p dacowner)\n run %(cleos set account permission dacowner med #{CONTRACT_PUBLIC_KEY} high -p dacowner)\n run %(cleos set account permission dacowner low #{CONTRACT_PUBLIC_KEY} med -p dacowner)\n run %(cleos set account permission dacowner one #{CONTRACT_PUBLIC_KEY} low -p dacowner)\nend",
"def contract_params\n params.require(:contract).permit(:name, :email, :phone, :address)\n end",
"def contract_params\n params.require(:contract).permit(:meeting_time, :meeting_address_first, :meeting_address_second, :final_payment_method, :final_price, :expiration_time, :status, :post_id, :seller_id, :buyer_id, :unsigned_user_id)\n end",
"def generate_repssubcomm(congress, data)\n puts \"generating repssubcomm for #{congress.number}...\"\n @columns = reps_columns\n representatives = congress.representatives.sort {|x,y| x.last_name <=> y.last_name }\n all_bills = congress.bills\n 1.upto(3) do |importance|\n bills_importance = all_bills.reject { |b| b.importance != importance }\n (\"all\".to_a + congress.subcommittees).each do |subcommittee|\n bills = Array.new(bills_importance)\n bills.reject! { |b| !b.subcommittees.include?(subcommittee) } if subcommittee.class == Subcommittee\n amended_bills = bills.reject { |b| b.amendments.size == 0 }\n @data = []\n representatives.each do |rep|\n rep_data = []\n rep_data << \"#{rep.last_name}, #{rep.first_name}\"\n rep_sponsored_bills = bills.reject { |b| !b.sponsors.include? rep }\n rep_sponsored_bills_unamended = rep_sponsored_bills.reject { |b| b.amendments.any? { |a| a.passed == true } }\n rep_cosponsored_bills = bills.reject { |b| !b.cosponsors.include? rep }\n rep_cosponsored_bills_unamended = rep_cosponsored_bills.reject { |b| b.amendments.any? { |a| a.passed == true } }\n rep_items(rep_data, rep_sponsored_bills)\n rep_items(rep_data, rep_sponsored_bills_unamended)\n rep_items(rep_data, rep_cosponsored_bills)\n rep_items(rep_data, rep_cosponsored_bills_unamended)\n # amendment_bills = amended_bills.reject { |b| b.amendments.any? { |a| a.sponsor_type != \"Representative\" or a.sponsor_id != rep.id } }\n # amendment_bills_passed = amendment_bills.reject { |b| b.amendments.any? { |a| a.passed != true } }\n amendment_bills = []\n amendment_bills_passed = []\n amended_bills.each { |b| amendment_bills << b if b.amendments.any? { |a| a.sponsor_type == \"Representative\" and a.sponsor_id == rep.id } }\n amended_bills.each { |b| amendment_bills_passed << b if b.amendments.any? { |a| a.sponsor_type == \"Representative\" and a.sponsor_id == rep.id and a.passed == true } }\n rep_items(rep_data, amendment_bills)\n rep_items(rep_data, amendment_bills_passed)\n rep_data << amendment_bills.size\n rep_data << amendment_bills_passed.size\n rep_data << amendment_bills.inject(0) { |sum, b| sum + b.amendments.find_all { |a| a.sponsor_type == \"Representative\" and a.sponsor_id == rep.id }.size }\n rep_data << amendment_bills_passed.inject(0) { |sum, b| sum + b.amendments.find_all { |a| a.sponsor_type == \"Representative\" and a.sponsor_id == rep.id and a.passed == true }.size }\n \n score = 0.0\n amendment_bills_passed.each do |b|\n score += ( b.amendments.find_all { |a| a.sponsor_type == \"Representative\" and a.sponsor_id == rep.id and a.passed == true }.size.to_f / b.passed_amendments.size.to_f )\n end\n rep_data << score\n\n @data << rep_data\n end\n data << [ render_to_string(:action => \"reps\", :layout => false), \"#{congress.number.ordinalize}-reps-#{if importance==1 then \"unimportant\" elsif importance==2 then \"regular\" elsif importance==3 then \"important\" end}#{\"-\" + subcommittee.name if subcommittee.class == Subcommittee}\" ] \n end\n end\n end",
"def set_prizes\n users.each_with_index do |u, i| \n u[:prize] = {id: prizes[i].id, name: prizes[i].name, class_name: prizes[i].class_name}\n u[:finished] = false\n u[:gift] = UNOPENED_GIFTS[rand(3)]\n u[:final] = i == 0 ? false : true\n u[:action] = i == 0 ? (u[:bot] ? \"DECIDING...\" : \"OPEN NEW GIFT\" ) :nil\n u[:id] = i\n u[:stolen] = false\n end\n end",
"def contractor_params\n params.require(:contractor).permit(:first_name, :last_name, :company, :email, :password, :password_confirmation, :maintenance_request_id, :phone, :stripe_uid, occupation: [])\n end",
"def contract_params\n params.require(:contract).permit(:value, :passenger_id, :account_id, :interest,\n :start, :user_id, :closing_date)\n end",
"def test_withdraw_consent\n # add a protocol consent tier\n @pcl.consent_tiers << ct = CaTissue::ConsentTier.new(:statement => Jinx::StringUniquifier.uniquify('Test Consent'))\n # add a CPR consent tier response\n @scg.registration.consent_tier_responses << CaTissue::ConsentTierResponse.new(:consent_tier => ct)\n # make the PMI\n mrn = Jinx::UID.generate\n pnt = @scg.registration.participant\n pmi = CaTissue::ParticipantMedicalIdentifier.new(:participant => pnt, :medical_record_number => mrn)\n # save the SCG\n verify_save(@scg)\n # SCG save adds consent statuses\n assert(!@scg.consent_tier_statuses.empty?, \"No #{@spc} SCG constent status.\")\n logger.debug { \"Verifying #{pmi} consent withdrawal...\" }\n # Withdraw consent and update each specimen.\n pmi.copy(:medical_record_number).query(:participant, :registrations, :specimen_collection_groups, :specimens).each do |spc|\n spc.withdraw_consent\n spc.save\n end\n # Refetch the SCG and verify the specimen consents.\n @scg.copy(:identifier).find.specimens.each do |spc|\n cts = spc.consent_tier_statuses.first\n assert_not_nil(cts, \"#{spc} does not have a consent tier status\")\n assert_not_nil(cts.identifier, \"#{spc} consent tier status was not created\")\n assert_equal('Withdrawn', cts.status, \"#{spc} consent was not withdrawn\")\n end\n end",
"def contractor_params\n params.require(:contractor).permit(:id, :name, :username, :uid, :has_office,:address, :avatar, :mobileNumber, :fax, :website)\n end",
"def add_provenance(microtiter_plate:, pooling_groups:)\n pooling_groups.each do |pooling_group|\n microtiter_plate.associate_provenance_next_empty(\n key: :specimens,\n data: pooling_group.map { |item| hash_data(item) }\n )\n end\n microtiter_plate\n end",
"def custodian_params\n params.require(:custodian).permit(:name, :specialty)\n end",
"def contract_saved contract\n\t\t@contract = contract\n\t\t@semesters = @contract.semesters\n\t\t# Prices\n\t\t@application_fee = Prices::application_fee\n\t\t@deposit = Prices::deposit(@semesters)\n\t\t@early_bird = Prices::early_bird(@semesters, Date.today)\n\t\t@rent = Prices::rent(@semesters)\n\t\t@parking = Prices::parking_price(@contract.parking_type, @semesters)\n\t\t@multiple_semesters = Prices::multiple_semester_discounts @semesters\n\n\t\t# Calculations\n\t\t@parking_price = 0\n\t\t@parking.each do |park|\n\t\t\t@parking_price += park\n\t\tend\n\t\t@early_bird_sum = 0\n\t\t@early_bird.each do |early|\n\t\t\t@early_bird_sum += early\n\t\tend\n\t\t@multiple_semesters_sum = 0\n\t\t@multiple_semesters.each do |discount|\n\t\t\t@multiple_semesters_sum += discount\n\t\tend\n\n\t\t@euro = 0\n\t\t@euro = 50 unless @contract.euro.empty?\n\t\t@discounts_total = @early_bird_sum + @multiple_semesters_sum + @euro\n\n\t\t@rent_sum = 0\n\t\t@rent.each do |rent|\n\t\t\t@rent_sum += rent\n\t\tend\n\t\t@total = @application_fee + @deposit + @rent_sum + @parking_price - @discounts_total\n\n\t\tmail to: ['managers@windsormanor.net', @contract.email],\n\t\t\tsubject: 'Your Receipt for Windsor Manor'\n\tend",
"def names\n \n # COMBINE split names into composite names for these rows\n composites = [\n {:row => :sa, :version => /^[6-8]/, :field => [:contributor, :donor_candidate]},\n {:row => :sb, :version => /^[6-8]/, :field => [:payee, :beneficiary_candidate]},\n {:row => :sc, :version => /^[6-8]/, :field => [:lender, :lender_candidate]},\n {:row => :sc1, :version => /^[6-8]/, :field => [:treasurer, :authorized]},\n {:row => :sc2, :version => /^[6-8]/, :field => :guarantor},\n {:row => :sd, :version => /^[6-8]/, :field => :creditor},\n {:row => :se, :version => /^[6-8]/, :field => [:payee, :candidate]},\n {:row => :sf, :version => /^[6-8]/, :field => [:payee, :payee_candidate]},\n {:row => :f3p, :version => /^[6-8]/, :field => :treasurer},\n {:row => :f3p31, :version => /^[6-8]/, :field => :contributor},\n ]\n # SPLIT composite names into component parts for these rows\n components = [\n {:row => :sa, :version => /^3|(5.0)/, :field => :contributor},\n {:row => :sa, :version => /^[3-5]/, :field => :donor_candidate},\n {:row => :sb, :version => /^3|(5.0)/, :field => :payee},\n {:row => :sb, :version => /^[3-5]/, :field => :beneficiary_candidate},\n {:row => :sc, :version => /^[3-5]/, :field => [:lender, :lender_candidate]},\n {:row => :sc1, :version => /^[3-5]/, :field => [:treasurer, :authorized]},\n {:row => :sc2, :version => /^[3-5]/, :field => :guarantor},\n {:row => :sd, :version => /^[3-5]/, :field => :creditor},\n {:row => :se, :version => /^[3-5]/, :field => [:payee, :candidate]},\n {:row => :sf, :version => /^[3-5]/, :field => [:payee, :payee_candidate]},\n {:row => :f3p, :version => /^[3-5]/, :field => :treasurer},\n {:row => :f3p31, :version => /^[3-5]/, :field => :contributor},\n ]\n \n composites.each { |c| combine_components_into_name(c) }\n components.each { |c| split_name_into_components(c) }\n \n end",
"def tag_with_company source_card\n add_trait_to_source source_card, :wikirate_company, company_names\nend",
"def utransaction_params\n params.require(:utransaction).permit(:transaction_type, :contract_id, :user_id, :quantity, :comment, :contract_current_value, :cost)\n end",
"def configure_contracts_for_tests\n\n run %(cleos system newaccount --stake-cpu \"10.0000 EOS\" --stake-net \"10.0000 EOS\" --transfer --buy-ram-kbytes 2024 eosio dacowner #{CONTRACT_PUBLIC_KEY} #{CONTRACT_PUBLIC_KEY})\n\n run %(cleos push action dacdirectory regdac '{\"owner\": \"dacowner\", \"dac_name\": \"escrowdac\", \"dac_symbol\": \"4,EOSDAC\", \"title\": \"Dac Title\", \"refs\": [], \"accounts\": [[2,\"daccustodian\"], [5,\"dacescrow\"], [7,\"dacescrow\"], [0, \"dacowner\"], [4, \"eosdactokens\"], [1, \"eosdacthedac\"] ]}' -p dacowner)\n run %(cleos push action eosdactokens create '{ \"issuer\": \"dacowner\", \"maximum_supply\": \"100000.0000 EOSDAC\", \"transfer_locked\": false}' -p dacowner)\n\n run %(cleos push action eosdactokens issue '{ \"to\": \"dacowner\", \"quantity\": \"78337.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p dacowner)\n run %(cleos push action eosio.token issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"100000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio)\n\n run %(cleos push action daccustodian updateconfig '{\"newconfig\": { \"lockupasset\": \"10.0000 EOSDAC\", \"maxvotes\": 5, \"periodlength\": 604800 , \"numelected\": 12, \"should_pay_via_service_provider\": 1, \"auththresh\": 3, \"initial_vote_quorum_percent\": 15, \"vote_quorum_percent\": 10, \"auth_threshold_high\": 11, \"auth_threshold_mid\": 7, \"auth_threshold_low\": 3, \"lockup_release_time_delay\": 10, \"requested_pay_max\": \"450.0000 EOS\"}, \"dac_scope\": \"escrowdac\"}' -p dacowner)\n\n run %(cleos set account permission dacescrow active '{\"threshold\": 1,\"keys\": [{\"key\": \"#{CONTRACT_PUBLIC_KEY}\",\"weight\": 1}],\"accounts\": [{\"permission\":{\"actor\":\"dacescrow\",\"permission\":\"eosio.code\"},\"weight\":1}]}' owner -p dacescrow)\n\n # Ensure terms are registered in the token contract\n run %(cleos push action eosdactokens newmemtermse '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\", \"dac_id\": \"escrowdac\"}' -p dacowner)\n\n #create users\n\n seed_dac_account(\"sender1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_scope: \"escrowdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"sender2\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_scope: \"escrowdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"sender3\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_scope: \"escrowdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"sender4\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_scope: \"escrowdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"receiver1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_scope: \"escrowdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"arb1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_scope: \"escrowdac\", dac_owner: \"dacowner\")\n seed_dac_account(\"arb2\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\", dac_scope: \"escrowdac\", dac_owner: \"dacowner\")\n\n run %(cleos push action eosio.token issue '{ \"to\": \"sender1\", \"quantity\": \"1000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio)\n run %(cleos push action eosio.token issue '{ \"to\": \"sender2\", \"quantity\": \"1000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio)\n run %(cleos push action eosio.token issue '{ \"to\": \"sender3\", \"quantity\": \"1000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio)\n run %(cleos push action eosio.token issue '{ \"to\": \"sender4\", \"quantity\": \"1000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio)\nend",
"def castle_params\n params.require(:castle).permit(:name, :kingdom_id, stocks_attributes: [:qte, :ressource_id, :id, :_destroy], garrisons_attributes: [:qte, :soldier_type_id, :id, :_destroy], tile_attributes: [:x, :y, :id, :_destroy])\n end",
"def existing_organizer_attributes=(organizer_attributes)\n organizer_attributes.each do |attributes|\n proceed_contribution_attribute(attributes[1][:name], 'organizer')\n end\n end",
"def create_individual_uqhp\n individual_util INDIVIDUAL_UQHP do |individual_util|\n reset_count\n write_json individual_util.create_individual_uqhp, individual_util\n end\n end",
"def liability_params\n params.require(:liability).permit(:name, :value, :user_id)\n end",
"def fixed_om_costs\n fixed_om_costs_per_unit * number_of_units\n end",
"def insurance_police_params\n params.require(:insurance_police).permit(:basic, :standard, :premium)\n end",
"def assignable_specialties\n\t\t(Specialty.predefined + specialties).sort_by(&:lower_case_name).uniq\n\tend",
"def produce_spaceship6(type = :freighter, size: 10, **custom_components)\r\n components = {\r\n engine: :standard,\r\n seats: :standard,\r\n subwoofer: :none\r\n }\r\n components.merge!(custom_components)\r\nend",
"def create\n\n @company = Company.find(1)\n\n @cout = Cout.new(cout_params)\n\n\n @cout[:code] = @cout.generate_cout_number\n @puntos = @company.get_puntos()\n @employees = @company.get_employees2() \n @trucks = @company.get_trucks\n\n respond_to do |format|\n if @cout.save\n format.html { redirect_to @cout, notice: 'Cout was successfully created.' }\n format.json { render :show, status: :created, location: @cout }\n else\n format.html { render :new }\n format.json { render json: @cout.errors, status: :unprocessable_entity }\n end\n end\n end",
"def contract_type_params\n params.require(:contract_type).permit(:name)\n end",
"def genetic_code_table; 11; end",
"def tyc_company_params\n params.require(:tyc_company).permit(:code, :logo, :name, :old_name, :phone, :mail, :url, :address, :intro, :update_date, :boss_name, :reg_money, :set_date, :status, :reg_number, :credit_code, :company_code, :tax_code, :category_id, :end_time, :industry_id, :tax, :allow_time, :pay_money, :all_people, :insured_people, :organ, :reg_address, :en_name, :operate_scope)\n end",
"def compound_params\n params.require(:compound).permit(:name, :molecular_formula, :molar_mass, :cas, :structure, :amount, :shelf, :room_number, :additional_info)\n end",
"def general_params\n params.require(:general).permit(:abbr, :year, :order, :motto, :nickname, :population, :poprank, :size, :sizerank, :largestcity, :bird, :birdimg, :flower, :flowerimg, :tree, :treeimg)\n end",
"def available_contract_missions\n Institution.all.map do |i|\n i.available_missions\n end.flatten\n end",
"def create_third_party_mission(mission_hash)\n i = mission_hash[:institution]\n i.campaign = self\n m = mission_hash[:mission]\n c = m.contracts.new\n # some defaults, inherited properties\n c.status = :offered\n c.campaign_id = id\n c.institution_id = i.id\n # Rewards, penalties etc. dependant on reputation to faction\n c.reward = (m.reward * i.reward_mod).round(-1)\n c.advance_percent = ((i.advance_mod).round(2) * 100).to_i\n c.penalty = (c.reward * i.penalty_mod).round(-1)\n time_span = (m.maximal_time - m.minimal_time)\n c.time_limit = m.minimal_time + (time_span * i.time_mod).round\n c.save\n\n c\n end",
"def init_companies(_players)\n mine_comps = game_minors.map do |gm|\n description = \"Mine in #{gm[:coordinates]}. Machine revenue: \"\\\n \"#{gm[:extended][:machine_revenue].join('/')}. Switcher revenue: \"\\\n \"#{gm[:extended][:switcher_revenue].join('/')}\"\n revenue = \"#{format_currency(gm[:extended][:machine_revenue].first)} - \"\\\n \"#{format_currency(gm[:extended][:machine_revenue].last + gm[:extended][:switcher_revenue].last)}\"\n\n Company.new(sym: gm[:sym], name: \"#{gm[:sym]} #{gm[:name]}\", value: gm[:extended][:value],\n revenue: revenue, desc: description)\n end\n corp_comps = game_corporations.map do |gc|\n next if gc[:sym] == 'MHE'\n\n if gc[:extended][:type] == :railway\n description = \"Concession for Railway #{gc[:name]} in #{gc[:coordinates].join(', ')}. \"\\\n \"Total concession tile cost: #{format_currency(gc[:extended][:concession_cost])}\"\n name = \"#{gc[:sym]} Concession\"\n else\n description = \"Purchase Option for Public Mining Company #{gc[:name]}\"\n name = \"#{gc[:sym]} Purchase Option\"\n end\n Company.new(sym: gc[:sym], name: name, value: RAILWAY_MIN_BID, revenue: 'NA', desc: description)\n end.compact\n mine_comps + corp_comps\n end",
"def add_construction_set(template, clim, building_type, spc_type, is_residential)\n\n construction_set = OpenStudio::Model::OptionalDefaultConstructionSet.new\n\n # Find the climate zone set that this climate zone falls into\n climate_zone_set = find_climate_zone_set(clim, template)\n if !climate_zone_set\n return construction_set\n end\n \n # Get the object data\n data = self.find_object(self.standards['construction_sets'], {'template'=>template, 'climate_zone_set'=> climate_zone_set, 'building_type'=>building_type, 'space_type'=>spc_type, 'is_residential'=>is_residential})\n if !data\n data = self.find_object(self.standards['construction_sets'], {'template'=>template, 'climate_zone_set'=> climate_zone_set, 'building_type'=>building_type, 'space_type'=>spc_type})\n if !data\n return construction_set\n end\n end \n \n OpenStudio::logFree(OpenStudio::Info, 'openstudio.standards.Model', \"Adding construction set: #{template}-#{clim}-#{building_type}-#{spc_type}-is_residential#{is_residential}\") \n \n name = make_name(template, clim, building_type, spc_type)\n\n # Create a new construction set and name it\n construction_set = OpenStudio::Model::DefaultConstructionSet.new(self)\n construction_set.setName(name)\n\n # Exterior surfaces constructions\n exterior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(self)\n construction_set.setDefaultExteriorSurfaceConstructions(exterior_surfaces)\n if data['exterior_floor_standards_construction_type'] && data['exterior_floor_building_category']\n exterior_surfaces.setFloorConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorFloor',\n data['exterior_floor_standards_construction_type'],\n data['exterior_floor_building_category']))\n end\n if data['exterior_wall_standards_construction_type'] && data['exterior_wall_building_category']\n exterior_surfaces.setWallConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorWall',\n data['exterior_wall_standards_construction_type'],\n data['exterior_wall_building_category']))\n end\n if data['exterior_roof_standards_construction_type'] && data['exterior_roof_building_category']\n exterior_surfaces.setRoofCeilingConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorRoof',\n data['exterior_roof_standards_construction_type'],\n data['exterior_roof_building_category']))\n end\n\n # Interior surfaces constructions\n interior_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(self)\n construction_set.setDefaultInteriorSurfaceConstructions(interior_surfaces)\n construction_name = data['interior_floors']\n if construction_name != nil\n interior_surfaces.setFloorConstruction(add_construction(construction_name))\n end\n construction_name = data['interior_walls']\n if construction_name != nil\n interior_surfaces.setWallConstruction(add_construction(construction_name))\n end\n construction_name = data['interior_ceilings']\n if construction_name != nil\n interior_surfaces.setRoofCeilingConstruction(add_construction(construction_name))\n end\n\n # Ground contact surfaces constructions\n ground_surfaces = OpenStudio::Model::DefaultSurfaceConstructions.new(self)\n construction_set.setDefaultGroundContactSurfaceConstructions(ground_surfaces)\n if data['ground_contact_floor_standards_construction_type'] && data['ground_contact_floor_building_category']\n ground_surfaces.setFloorConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'GroundContactFloor',\n data['ground_contact_floor_standards_construction_type'],\n data['ground_contact_floor_building_category']))\n end\n if data['ground_contact_wall_standards_construction_type'] && data['ground_contact_wall_building_category']\n ground_surfaces.setWallConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'GroundContactWall',\n data['ground_contact_wall_standards_construction_type'],\n data['ground_contact_wall_building_category']))\n end\n if data['ground_contact_ceiling_standards_construction_type'] && data['ground_contact_ceiling_building_category']\n ground_surfaces.setRoofCeilingConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'GroundContactRoof',\n data['ground_contact_ceiling_standards_construction_type'],\n data['ground_contact_ceiling_building_category']))\n end\n\n # Exterior sub surfaces constructions\n exterior_subsurfaces = OpenStudio::Model::DefaultSubSurfaceConstructions.new(self)\n construction_set.setDefaultExteriorSubSurfaceConstructions(exterior_subsurfaces)\n if data['exterior_fixed_window_standards_construction_type'] && data['exterior_fixed_window_building_category']\n exterior_subsurfaces.setFixedWindowConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorWindow',\n data['exterior_fixed_window_standards_construction_type'],\n data['exterior_fixed_window_building_category']))\n end\n if data['exterior_operable_window_standards_construction_type'] && data['exterior_operable_window_building_category']\n exterior_subsurfaces.setOperableWindowConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorWindow',\n data['exterior_operable_window_standards_construction_type'],\n data['exterior_operable_window_building_category']))\n end\n if data['exterior_door_standards_construction_type'] && data['exterior_door_building_category']\n exterior_subsurfaces.setDoorConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorDoor',\n data['exterior_door_standards_construction_type'],\n data['exterior_door_building_category']))\n end\n construction_name = data['exterior_glass_doors']\n if construction_name != nil\n exterior_subsurfaces.setGlassDoorConstruction(add_construction(construction_name))\n end\n if data['exterior_overhead_door_standards_construction_type'] && data['exterior_overhead_door_building_category']\n exterior_subsurfaces.setOverheadDoorConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'ExteriorDoor',\n data['exterior_overhead_door_standards_construction_type'],\n data['exterior_overhead_door_building_category']))\n end\n if data['exterior_skylight_standards_construction_type'] && data['exterior_skylight_building_category']\n exterior_subsurfaces.setSkylightConstruction(find_and_add_construction(template,\n climate_zone_set,\n 'Skylight',\n data['exterior_skylight_standards_construction_type'],\n data['exterior_skylight_building_category']))\n end\n if construction_name = data['tubular_daylight_domes']\n exterior_subsurfaces.setTubularDaylightDomeConstruction(add_construction(construction_name))\n end\n if construction_name = data['tubular_daylight_diffusers']\n exterior_subsurfaces.setTubularDaylightDiffuserConstruction(add_construction(construction_name))\n end\n\n # Interior sub surfaces constructions\n interior_subsurfaces = OpenStudio::Model::DefaultSubSurfaceConstructions.new(self)\n construction_set.setDefaultInteriorSubSurfaceConstructions(interior_subsurfaces)\n if construction_name = data['interior_fixed_windows']\n interior_subsurfaces.setFixedWindowConstruction(add_construction(construction_name))\n end\n if construction_name = data['interior_operable_windows']\n interior_subsurfaces.setOperableWindowConstruction(add_construction(construction_name))\n end\n if construction_name = data['interior_doors']\n interior_subsurfaces.setDoorConstruction(add_construction(construction_name))\n end\n\n # Other constructions\n if construction_name = data['interior_partitions']\n construction_set.setInteriorPartitionConstruction(add_construction(construction_name))\n end\n if construction_name = data['space_shading']\n construction_set.setSpaceShadingConstruction(add_construction(construction_name))\n end\n if construction_name = data['building_shading']\n construction_set.setBuildingShadingConstruction(add_construction(construction_name))\n end\n if construction_name = data['site_shading']\n construction_set.setSiteShadingConstruction(add_construction(construction_name))\n end\n\n # componentize the construction set\n #construction_set_component = construction_set.createComponent\n\n # Return the construction set\n return OpenStudio::Model::OptionalDefaultConstructionSet.new(construction_set)\n \n end",
"def invoice_params\n params.require(:b2b_composite).permit(:supply_type ,:total_b2b_composite_value,:invoice_type,:tax_rate,:rcm,:user_id,:customer_id, :invoice_number,:invoice_date,b2b_composite_items_attributes:[:id ,:unit_price, :quantity,:item_id,:rate, :qty, :net_amt, :sgst, :cgst, :tax_rate, :tax_amt, :total_amt,:_destroy])\n end",
"def allowSpecialCommunity()\n banner(\"Allow special communities\")\n @run.society.communities.each do |community|\n debug \"working on community #{community.name}\"\n\n specialMembers = getSpecialCommunityAgentsRecursive(community)\n debug \"special members = #{specialMembers.join(\", \")}\"\n specialSetName = \"Special#{community.name}Members\"\n declareSet(specialSetName, specialMembers);\n\n enclaves = getCommunityEnclaves(community)\n communityNodesName = \"Possible#{community.name}Nodes\"\n declareSet(communityNodesName, getNodesFromEnclaves(enclaves))\n\n membersName = communityMembersName(community)\n members = translateSet(membersName)\n if (members == nil || members.empty?) then\n next\n end\n debug \"members = #{members.join(\", \")}\"\n\n permit(communityNodesName, membersName, \n \"Special#{community.name}Policy-I\",\n enclaves)\n permit(membersName, communityNodesName,\n \"Special#{community.name}Policy-II\",\n enclaves)\n if (specialMembers.empty?) then\n next\n end\n permit(membersName, specialSetName, \n \"Special#{community.name}Policy-III\",\n getCommunityEnclaves(community))\n permit(specialSetName, membersName,\n \"Special#{community.name}Policy-IV\",\n getCommunityEnclaves(community))\n end \n end",
"def company_create_params\r\n params.require(:company).permit(:company_name, :first_name, :last_name,\r\n :phone, :contract_start, :contract_end, :owner_id)\r\n end",
"def contract_profile_params\n params.require(:contract_profile).permit(:id, :descripcion, :id_contratos)\n end",
"def tax_change\n owner = correct_owner_id\n tax ={\n :tax1_enabled => 1,\n :tax2_enabled => Confline.get_value2(\"Tax_2\", owner).to_i,\n :tax3_enabled => Confline.get_value2(\"Tax_3\", owner).to_i,\n :tax4_enabled => Confline.get_value2(\"Tax_4\", owner).to_i,\n :tax1_name => Confline.get_value(\"Tax_1\", owner),\n :tax2_name => Confline.get_value(\"Tax_2\", owner),\n :tax3_name => Confline.get_value(\"Tax_3\", owner),\n :tax4_name => Confline.get_value(\"Tax_4\", owner),\n :total_tax_name => Confline.get_value(\"Total_tax_name\", owner),\n :tax1_value => Confline.get_value(\"Tax_1_Value\", owner).to_d,\n :tax2_value => Confline.get_value(\"Tax_2_Value\", owner).to_d,\n :tax3_value => Confline.get_value(\"Tax_3_Value\", owner).to_d,\n :tax4_value => Confline.get_value(\"Tax_4_Value\", owner).to_d,\n :compound_tax => Confline.get_value(\"Tax_compound\", owner).to_i\n }\n\n tax[:total_tax_name] = \"TAX\" if tax[:total_tax_name].blank?\n tax[:tax1_name] = tax[:total_tax_name].to_s if tax[:tax1_name].blank?\n\n case params[:u].to_i\n when 1\n users = User.find(:all, :include => [:tax], :conditions => [\"owner_id = ?\", owner])\n for user in users do\n user.assign_default_tax(tax, {:save => true})\n end\n Confline.set_default_object(Tax, owner, tax)\n flash[:status] = _('User_taxes_set_successfully')\n when 2\n Cardgroup.set_tax(tax, session[:user_id])\n flash[:status] = _('Cardgroup_taxes_set_successfully')\n when 3\n Voucher.set_tax(tax)\n flash[:status] = _('voucher_taxes_set_successfully')\n else\n dont_be_so_smart\n end\n\n if owner == 0\n redirect_to :action => 'settings' and return false\n else\n redirect_to :action => 'reseller_settings' and return false\n end\n end",
"def combustible_params\n params.require(:combustible).permit(:PKCOMBUSTIBLE, :COM_FINICIO, :COM_FFIN, :COM_DESCRIPCION, :COM_PRECIO)\n end",
"def set_values_for_commision_types\n COMISSION_TYPES.each do |key|\n @hash[key] = calculate_value_of_specific_commission_(key)\n end\n end",
"def create\n @contract = Contract.new(contract_params)\n respond_to do |format|\n if @contract.save\n if params[:song_ids].present?\n songs = []\n params[:song_ids].each{|song_id| songs << Song.find_by(:id=>song_id)}\n songs = songs.compact.reject(&:nil?)\n songs.each{|song| song.contract_assignments.create!(:contract_id=>@contract.id) }\n end\n \n if params[:demo_ids].present?\n demos = []\n params[:demo_ids].map{|demo_id| demos << Demo.find_by(:id=>demo_id) }\n demos.each{|demo| demo.contract_assignments.create!(:contract_id=>@contract.id) }\n end\n\n if params[:library_ids].present?\n libraries = []\n params[:library_ids].map{|library_id| libraries << Library.find_by(:id=>library_id) }\n libraries.each{|library| library.contract_assignments.create!(:contract_id=>@contract.id) }\n end\n\n format.json { render :show, status: :created, location: @api_v1_contract }\n else\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end",
"def change_membership(gym_membership, person_name, membership)\n gym_membership[person_name.to_sym][:\"membership type\"] = membership\n \n if membership == \"yellow\"\n gym_membership[person_name.to_sym][:\"payment details\"][:\"monthly payment\"] = 10\n gym_membership[person_name.to_sym][:\"privileges\"] = []\n else\n gym_membership[person_name.to_sym][:\"privileges\"].push(\"Suana\", \"Massage chair\", \"Bathing\")\n gym_membership[person_name.to_sym][:\"payment details\"][:\"monthly payment\"] = 20\n end\n \n gym_membership\nend",
"def setup( num_proposals )\r\n @chairperson = msg.sender\r\n @voters = Mapping.of( Address => Voter )\r\n @proposals = Array.of( Proposal, num_proposals )\r\n\r\n @voters[@chairperson].weight = 1\r\nend",
"def contract_params\n # rubocop:disable Metrics/LineLength\n params.require(:contract).permit(:agency_id, :effective_date, :termination_date)\n # rubocop:enable Metrics/LineLength\n end",
"def before_create\n select = \"#{Company.table_name}.id\"\n \n # serialized adjustments. initialize the array.\n self.adjustments = []\n \n case payable_type\n when \"OrderEntityCost\" \n j = \"LEFT OUTER JOIN #{OrderEntity.table_name} AS oe ON oe.company_id = #{Company.table_name}.id\"\n j += \" LEFT OUTER JOIN #{OrderEntityCost.table_name} AS oec ON oec.order_entity_id = oe.id\"\n c = \"oec.id = #{payable_id}\" \n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id\n self.name = payable.type.name\n when \"OrderEntity\"\n j = \"LEFT OUTER JOIN #{OrderEntity.table_name} AS oe ON oe.company_id = #{Company.table_name}.id\"\n c = \"oe.id = #{payable_id}\"\n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id\n self.name = payable.type.label + ' charge' #<-- OrderTypeEntity.label [Pickup Agent, Carrier, Delivery-agent, etc]\n when \"CompanySalesAccount\"\n j = \"LEFT OUTER JOIN #{Account.table_name} AS a ON a.company_id = #{Company.table_name}.id\"\n j += \" LEFT OUTER JOIN #{CompanySalesAccount.table_name} AS csa ON csa.account_id = a.id\"\n c = \"csa.id = #{payable_id}\"\n self.name = \"Commission\"\n self.company_id = Company.find(:first, :select => select, :conditions => c, :joins => j).id \n end\n end",
"def contract_params\n params.require(:contract).permit(:title, :description, :due_date, :showroom_id)\n end",
"def consumable_params\n params.require(:consumable).permit(:pantry_id, :name, :cost, :unit, :quantity, :category)\n end",
"def pro_concrete_params\n params.require(:pro_concrete).permit(:province_pro_asset_id, :day, :pro_concrete_hours, :pro_concrete_machines_num, pro_concrete_subs_attributes: ProConcreteSub.attribute_names.map(&:to_sym).push(:_destroy))\n end",
"def company_information_params\n params.require(:company_information).permit(:Sector, :BusinessActivity, :ReasonPartner, :Address, :Unity, :City, :State, :Cp, :Phone, :CellPhone, :Email, :Website, :Boss, :Area, :PrimarySector, :SecondarySector, :ThirdSector, :LevelStudy, :UpdateCourses, :Postgraduate, :AreaPostgraduate, :SocialOrganizations, :Which, :Committee, :Recommendation)\n end",
"def create\n # render text: admin_contract_params\n\n assign_params = admin_contract_params.dup\n\n if assign_params[:hospital_user_attributes][:name].blank?\n assign_params.delete :hospital_user_attributes\n end\n\n if assign_params[:studio_users_attributes][:name].blank?\n assign_params.delete :studio_users_attributes\n end\n\n admin_contract_params = assign_params\n\n if admin_contract_params[:hospital_user_attributes][:address_1]\n admin_contract_params[:hospital_code] = get_hospital_code(admin_contract_params[:hospital_user_attributes][:address_1])\n end\n\n @admin_contract = Contract.new(admin_contract_params )\n\n respond_to do |format|\n if @admin_contract.save\n format.html { redirect_to admin_contracts_path, notice: 'Contract was successfully created.' }\n format.json { render :show, status: :created, location: @admin_contract }\n else\n format.html { render :new }\n format.json { render json: @admin_contract.errors, status: :unprocessable_entity }\n end\n end\n end",
"def setup_cost_types\n q = params[:q]\n t = q[:total_cost_eq].to_i\n\n if t == TechnicalServicesHelper::COST_TYPE_FREE\n q[:total_cost_eq] = '0.0'\n elsif t == TechnicalServicesHelper::COST_TYPE_NONFREE\n q[:total_cost_gt] = '0.0'\n q.delete(:total_cost_eq)\n end\n end",
"def insurance_coverage_params\n params.require(:insurance_coverage).permit(:employer, :insurance_company, :policy_number, :coverage_percentage, :coverage_type, :product_quantity, :maximum_amount, :coverage_frequency, :coverage_period)\n end",
"def add_customer_and_contract_details(package)\n package.workbook.add_worksheet(name: 'Customer & Contract Details') do |sheet|\n add_contract_number(sheet) if @contract.contract_number.present?\n add_customer_details(sheet)\n add_contract_requirements(sheet)\n end\n end",
"def buy_yes_contracts\n #set variables\n @contract_id = params.fetch(\"contract_id\")\n @contract_row = Contract.where({ :id => @contract_id }).at(0)\n @market_id = @contract_row.market.id\n @season_id = @contract_row.market.season.id\n @club_id = @contract_row.market.season.club.id\n \n @number_of_contracts = params.fetch(\"quantity_buy_yes\")\n @membership_row = Membership.where({ :users_id => current_user.id, :seasons_id => @season_id, :goes_to => \"seasons_table\"}).at(0)\n @user_asset_rows = @membership_row.assets\n @user_season_funds_row = @user_asset_rows.where({ :membership_id => @membership_row.id, :category => \"season_fund\"}).at(0)\n @user_starting_season_funds = @user_season_funds_row.quantity\n @starting_contract_asset_row = @user_asset_rows.where({ :membership_id => @membership_row.id, :contract_id => @contract_id, :category => \"contract_quantity_a\"}).at(0) #membership_row.id is probably unnecessary.\n\n #confirm user actually belongs to the Season associated with this Contract/Market and that the market is active\n if (@membership_row.present?) && (@contract_row.market.status == \"active\")\n \n #Confirm number is a positive integer.\n if @number_of_contracts.to_i < 1 || @number_of_contracts.include?(\".\")\n flash[:alert] = \"There was an error processing your request.\"\n else\n #check if user already has an asset row associated with this contract (contract id matches and category is \"contract_quantity_a\").\n #If user does, skip step, otherwise, if user does not, create a new asset with a quantity of 0.\n if @starting_contract_asset_row.present?\n else\n new_asset = Asset.new\n new_asset.membership_id = @membership_row.id\n new_asset.season_id = @season_id\n new_asset.contract_id = @contract_id\n new_asset.category = \"contract_quantity_a\"\n new_asset.quantity = 0\n new_asset.save\n end\n\n #add variable to track contract_asset_row now that we know it must exist:\n @contract_asset_row = @user_asset_rows.where({ :membership_id => @membership_row.id, :contract_id => @contract_id, :category => \"contract_quantity_a\"}).at(0) #membership_row.id is probably unnecessary.\n \n #algorithm (C= b * ln(e^(q1/b) + e^(q2/b)...))\n #consider updating contract table to include column for quantity outstanding to avoid many of these calculations\n liquidity_param = 50 #set liquidity parameter (b) for now. Later might allow custommization or make b variable.\n\n #calculate price/cost by running price_check algo\n total_cost = @contract_row.price_check(@contract_id, liquidity_param, @number_of_contracts, \"yes\")\n\n if total_cost > @user_season_funds_row.quantity\n flash[:alert] = \"Insufficient funds. Sell some contracts or request more funds from the Season owner.\"\n else\n \n \n #(1) remove accumulated funds from user's season_funds, (2) add contract asset (3) later, make it so this is reflected in transaction table(probably in a first step and base everything off transaction)\n #Update tables based on actions above.\n\n # remove accumulated funds from user's season_funds. Consider updating method to be based on subtraction from current amount instead of current way.\n @user_season_funds_row.quantity = @user_season_funds_row.quantity - total_cost\n @user_season_funds_row.save\n\n #update contract quantity in assets table to reflect new purchase\n @contract_asset_row.quantity = @contract_asset_row.quantity + @number_of_contracts.to_i\n @contract_asset_row.save\n\n #update contract quantity in contracts table to reflect new outstanding balance\n @contract_row.quantity_a = @contract_row.quantity_a + @number_of_contracts.to_i\n @contract_row.save\n\n if @number_of_contracts.to_i == 1\n flash[:notice] = \"Yay! \" + @number_of_contracts.to_s + \" yes contract was sucessfully purchased for \" + number_to_currency(total_cost) + \".\"\n else\n flash[:notice] = \"Yay! \" + @number_of_contracts.to_s + \" yes contracts were sucessfully purchased for \" + number_to_currency(total_cost) + \".\"\n end\n \n\n end\n end\n\n #add instance variables needed for partials that are refreshed\n @contract_rows = @contract_row.market.contracts.order({ :created_at => :asc })\n @membership_id = @membership_row.id\n @season_membership_rows = Membership.where({ :seasons_id => @season_id, :goes_to => \"seasons_table\"})\n @market_row = @contract_row.market\n\n \n\n respond_to do |format|\n format.js { render 'contract_templates/render_contracts.js.erb' }\n end\n\n else\n flash[:alert] = \"You are not authorized to perform this action.\"\n end\n\n\n #old algorithm\n #contract_id_looper = @contract_row.market.contracts.at(0).id\n #tester = Asset.where({ :contract_id => contract_id_looper }).sum(:quantity)\n \n # #set trackers and counters\n # asset_quantity_counter = 0\n # asset_remaining_tracker = @number_of_contracts.to_i\n # looper = asset_remaining_tracker\n # funds_remaining_tracker = @user_starting_season_funds\n # asset_price_tracker = @starting_contract_price\n\n # #check if user has sufficient funds to buy one contract. If not, return them to the screen and alert them of insufficient funds.\n # if @user_starting_season_funds < @starting_contract_price\n # flash[:alert] = \"Insufficient funds. Sell some assets or request more money from Season owner.\"\n # redirect_to(\"/markets/\" + @club_id.to_s + \"/\" + @season_id.to_s + \"/\" + @market_id.to_s)\n # return\n # else\n # while looper > 0 \n # if funds_remaining_tracker > asset_price_tracker\n \n # #reduce season funds by amount of current contract price\n # funds_remaining_tracker = funds_remaining_tracker - asset_price_tracker\n\n # #update asset quantity counter to reflect number of assets accumulated\n # asset_quantity_counter = asset_quantity_counter + 1\n\n # #update contract price based on algorithm. Start with simple algorithm that only adds 0.005 to contract price each time one is purchased.\n # if asset_price_tracker < 1.000\n # asset_price_tracker = asset_price_tracker + 0.005\n # end\n\n # #update asset_remaining_tracker to reflect number of assets remaining to be fufilled\n # asset_remaining_tracker = asset_remaining_tracker - 1\n\n # end\n\n # #update looper to remove one loop count\n # looper = looper - 1\n\n # end\n\n # end\n\n # #(1) remove accumulated funds from user's season_funds, (2) add contract asset, (3) update contract price based on algorithm, (4)later, make it so this is reflected in transaction table(probably in a first step and base everything off transaction)\n # #Update tables based on actions above.\n\n # #remove accumulated funds from user's season_funds. Consider updating method to be based on subtraction from current amount instead of current way.\n # @user_season_funds_row.quantity = funds_remaining_tracker\n # @user_season_funds_row.save\n\n # #update contract quantity in assets table to reflect new purchase\n # @contract_asset_row.quantity = @contract_asset_row.quantity + asset_quantity_counter\n # @contract_asset_row.save\n \n # #update overall contract quantity in contract table\n # #update contract price based on accumulated new price based on current algo.\n # #Consider issues with multiple purchases in quick sucession. Better/safer way to do this?\n # @contract_row.price = asset_price_tracker\n # @contract_row.save\n\n # if asset_remaining_tracker == 0\n # flash[:notice] = \"Yay! All \" + asset_quantity_counter.to_s + \" contract(s) were sucessfully purchased!\" + \" Test parameter pre: \" + tester_pre.to_s + \" Test parameter post: \" + tester_post.to_s\n # else\n # flash[:notice] = \"Your order has partially completed. You only had sufficient funds to purchase \" + asset_quantity_counter.to_s + \" contract(s).\"\n # end\n\n end",
"def create\n #住所のパラメータを正常化\n adjust_address_params\n\t\n\t#add170809\n #手入力時の顧客マスターの新規登録\n \tcreate_manual_input_customer\n\t\n @quotation_header = QuotationHeader.new(quotation_header_params)\n\n #見出しデータ(コピー元)の補完\n complementCopyHeader\n\n respond_to do |format|\n if @quotation_header.save\n\t \n\t\t #参照コードがあれば内訳マスターをコピー\n\t copyBreakDown\n\t\t\n\t #顧客Mも更新\n\t\t if @manual_flag.blank? \n\t update_params_customer\n\t\t end\n \n #工事担当者を更新\n #add190131\n update_construction_personnel\n\t\t\n #add220617\n #工事の見積もりフラグを更新\n update_construction_quotation_flag\n \n format.html { redirect_to @quotation_header, notice: 'Quotation header was successfully created.' }\n format.json { render :show, status: :created, location: @quotation_header }\n else\n format.html { render :new }\n format.json { render json: @quotation_header.errors, status: :unprocessable_entity }\n end\n end\n end",
"def insurance_params\n params.require(:insurance).permit(:primary_name, :primary_plocy_number, :primary_group_number, :primary_coverage_limits, \n :primary_deductible, :primary_copay, :primary_coinsurance, :primary_out_of_network_fee, \n :secondary_name, :secondary_plocy_number, :secondary_group_number, :secondary_coverage_limits, \n :secondary_deductible, :secondary_copay, :secondary_coinsurance, :secondary_out_of_network_fee, \n :tertiary_name, :tertiary_plocy_number, :tertiary_group_number, :tertiary_coverage_limits, \n :tertiary_deductible, :tertiary_copay, :tertiary_coinsurance, :tertiary_out_of_network_fee)\n end",
"def trannig_params\n params.require(:trannig).permit(:name, :description, :company_id)\n end",
"def company_params\n params.require(:company).permit(:GPHProductCode, :SupplierProductCode, :BarCode, :Description, :GPH_RRP)\n end",
"def catalog_contract_type_params\n params.require(:catalog_contract_type).permit(:Type, :Supplier)\n end",
"def configure_contracts\n # configure accounts for eosdactokens\n `cleos push action eosdactokens updateconfig '[\"daccustodian\"]' -p eosdactokens`\n `cleos push action eosdactokens create '{ \"issuer\": \"eosdactokens\", \"maximum_supply\": \"100000.0000 EOSDAC\", \"transfer_locked\": false}' -p eosdactokens`\n `cleos push action eosdactokens issue '{ \"to\": \"eosdactokens\", \"quantity\": \"78337.0000 EOSDAC\", \"memo\": \"Initial amount of tokens for you.\"}' -p eosdactokens`\n `cleos push action eosio.token issue '{ \"to\": \"eosdacthedac\", \"quantity\": \"100000.0000 EOS\", \"memo\": \"Initial EOS amount.\"}' -p eosio.token`\n `cleos push action dacdirectory regdac '{\"owner\": \"dacdirectory\", \"dac_name\": \"dacproposals\", \"dac_symbol\": \"4,MYSYM\", \"title\": \"Dac Title\", \"refs\": [[1,\"some_ref\"]], \"accounts\": [[2,\"daccustodian\"], [5,\"dacescrow\"], [7,\"dacescrow\"], [0, \"dacauthority\"], [4, \"eosdactokens\"], [1, \"eosdacthedac\"] ], \"scopes\": [[2,\"daccustodian\"], [4, \"eosdactokens\"]]}' -p dacdirectory`\n \n #create users\n # Ensure terms are registered in the token contract\n `cleos push action eosdactokens newmemterms '{ \"terms\": \"normallegalterms\", \"hash\": \"New Latest terms\"}' -p eosdactokens`\n\n #create users\n seed_dac_account(\"proposeracc1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"proposeracc2\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"arbitrator11\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n\n seed_dac_account(\"custodian1\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian2\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian3\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian4\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian5\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian11\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian12\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian13\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n seed_dac_account(\"custodian14\", issue: \"100.0000 EOSDAC\", memberreg: \"New Latest terms\")\n\n `cleos push action daccustodian updatecust '[[\"custodian1\", \"custodian2\", \"custodian3\", \"custodian4\", \"custodian5\", \"custodian11\", \"custodian12\", \"custodian13\", \"custodian14\"]]' -p proposeracc1`\n\n `cleos set account permission dacauthority one '{\"threshold\": 1,\"keys\": [],\"accounts\": [{\"permission\":{\"actor\":\"custodian1\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian11\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian12\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian13\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian2\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian3\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian4\",\"permission\":\"active\"},\"weight\":1}, {\"permission\":{\"actor\":\"custodian5\",\"permission\":\"active\"},\"weight\":1}]}' low -p dacauthority@low`\nend"
] |
[
"0.5693713",
"0.5360878",
"0.5329585",
"0.532126",
"0.52766716",
"0.52474195",
"0.5227371",
"0.521614",
"0.5170425",
"0.51640564",
"0.5157892",
"0.51266116",
"0.51208174",
"0.5117237",
"0.5105529",
"0.5101629",
"0.5049592",
"0.504398",
"0.50347215",
"0.5031669",
"0.5021257",
"0.50130427",
"0.50117654",
"0.4996724",
"0.49958137",
"0.4993008",
"0.4978086",
"0.4925725",
"0.49257112",
"0.49000806",
"0.48933172",
"0.48789418",
"0.48705828",
"0.486175",
"0.4851882",
"0.48414752",
"0.4831097",
"0.4831097",
"0.48305494",
"0.4823044",
"0.48218125",
"0.48169723",
"0.4800081",
"0.4797319",
"0.47947",
"0.4790973",
"0.47775623",
"0.47751153",
"0.47734535",
"0.4748299",
"0.47397053",
"0.47351402",
"0.47149572",
"0.47110635",
"0.47096577",
"0.47060528",
"0.47048587",
"0.4695122",
"0.4690525",
"0.4690163",
"0.46784022",
"0.46714708",
"0.46598026",
"0.46502072",
"0.46479464",
"0.46463943",
"0.46459267",
"0.46424496",
"0.4635739",
"0.4629919",
"0.46285886",
"0.4627688",
"0.46140447",
"0.46120387",
"0.4607206",
"0.46054807",
"0.46018875",
"0.46015108",
"0.4600348",
"0.4598895",
"0.45933178",
"0.45928526",
"0.45890597",
"0.45834428",
"0.45807117",
"0.4579516",
"0.45769966",
"0.45740214",
"0.4573505",
"0.4572361",
"0.45718595",
"0.45702896",
"0.45662707",
"0.456455",
"0.45633638",
"0.4561499",
"0.45584425",
"0.45447582",
"0.45412937",
"0.45356226",
"0.45322555"
] |
0.0
|
-1
|
UC5 Make Order for Product
|
def order_product(q)
$LOG.info('order_product');
@CID=q["USER"];
@PID=q["PRODUCT"];
@orders=get_orders_by_product(@PID)
@orders[@CID]=DateTime.now
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def install_order(arr)\n\nend",
"def order1 \n puts(\"\\n\\n- - - - - - - - - - - - - - - -\\n[SHOP] Executing order 1: ABCDABA should be $13.25\\n\\n\") \n @shop.reset_order\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('C')\n @shop.add_product_to_order_by_name('D')\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('A')\nend",
"def order3\n puts(\"\\n\\n- - - - - - - - - - - - - - - -\\n[SHOP] Executing order 3: ABCD should be $7.25\\n\\n\") \n @shop.reset_order\n @shop.add_product_to_order_by_name('A')\n @shop.add_product_to_order_by_name('B')\n @shop.add_product_to_order_by_name('C')\n @shop.add_product_to_order_by_name('D')\nend",
"def processOrder\n \n end",
"def order; end",
"def order; end",
"def order2\n puts(\"\\n\\n- - - - - - - - - - - - - - - -\\n[SHOP] Executing order 2: CCCCCCC should be $6.00\\n\\n\") \n @shop.reset_order\n 7.times { @shop.add_product_to_order_by_name('C') }\nend",
"def manufacture; end",
"def order\n end",
"def normalize_order(order); end",
"def sku_combination_creation\n end",
"def original_order\n end",
"def orders\n \"intake, matrixno ASC\"\n # \"course_id, intake, matrixno ASC\"\n end",
"def product_assembly_package\n package = Package.new(stock_location, order)\n order.line_items.each do |line_item|\n next unless stock_location.stock_item(line_item.variant)\n\n is_an_assembly = line_item.product.assembly?\n on_hand, backordered = stock_location.fill_status(line_item.variant, line_item.quantity)\n\n if is_an_assembly\n quantity = (backordered > 0 ? backordered : on_hand)\n package.add( line_item.variant, quantity, :on_hand) \n else\n package.add line_item.variant, on_hand, :on_hand if on_hand > 0\n package.add line_item.variant, backordered, :backordered if backordered > 0\n end\n \n if is_an_assembly\n line_item.required_and_optional_parts.each do |part|\n next unless stock_location.stock_item(part)\n \n on_hand, backordered = stock_location.fill_status(part, (line_item.quantity * part.count_part))\n package.add( part, on_hand, :on_hand) if on_hand > 0\n package.add( part, backordered, :backordered) if backordered > 0\n end\n end\n end\n\n package\n end",
"def merit_order\n order = Merit::Order.new\n\n producers.each do |producer|\n order.add(producer) unless producer.marginal_costs == Float::NAN\n end\n\n order.add(local_demand_user)\n\n order\n end",
"def order_object\n prices = []\n\n cores_price_item = @cores ? _item_price_with_capacity(\"guest_core\", @cores) : nil\n ram_price_item = @ram ? _item_price_with_capacity(\"ram\", @ram) : nil\n max_port_speed_price_item = @max_port_speed ? _item_price_with_capacity(\"port_speed\", @max_port_speed) : nil\n\n prices << { \"id\" => cores_price_item['id'] } if cores_price_item\n prices << { \"id\" => ram_price_item['id'] } if ram_price_item\n prices << { \"id\" => max_port_speed_price_item['id'] } if max_port_speed_price_item\n\n # put together an order\n upgrade_order = {\n 'complexType' => 'SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade',\n 'virtualGuests' => [{'id' => @virtual_server.id }],\n 'properties' => [{'name' => 'MAINTENANCE_WINDOW', 'value' => @upgrade_at ? @upgrade_at.iso8601 : Time.now.iso8601}],\n 'prices' => prices\n }\n end",
"def product_assembly_package\n package = Package.new(stock_location, order)\n order.line_items.each do |line_item|\n\n variant = line_item.variant\n if variant.assembly?\n \n # original logic applied to each assembly part \n \n variant.parts.each do |part|\n if line_item.should_track_inventory?\n next unless stock_location.stock_item(part)\n\n # do not split on backorder items, pretend they are always on hand\n # on_hand, backordered = stock_location.fill_status(part, line_item.quantity * variant.count_of(part))\n # package.add part, on_hand, :on_hand, line_item if on_hand > 0\n # package.add part, backordered, :backordered, line_item if backordered > 0\n package.add part, line_item.quantity, :on_hand, line_item \n else\n package.add part, line_item.quantity, :on_hand, line_item\n end\n end\n\n else\n\n # original logic\n\n if line_item.should_track_inventory?\n next unless stock_location.stock_item(variant)\n\n # do not split on backorder items, pretend they are always on hand\n # on_hand, backordered = stock_location.fill_status(variant, line_item.quantity)\n # package.add variant, on_hand, :on_hand, line_item if on_hand > 0\n # package.add variant, backordered, :backordered, line_item if backordered > 0\n package.add variant, line_item.quantity, :on_hand, line_item \n else\n package.add variant, line_item.quantity, :on_hand, line_item\n end\n\n end\n end\n package\n end",
"def create_full_product\n generate_product_name\n generate_product_code\n generate_product_manufacturer\n generate_product_description\n generate_product_price\n end",
"def to_order_line\n OrderLine.new(\n product_id: product.id,\n product_sku: sku,\n product_name: product.name,\n product_brand: product.brand,\n product_rrp: product.rrp,\n product_price: product_price_ex_vat,\n product_weight: product_weight,\n vat_amount: vat_amount,\n quantity: quantity,\n feature_descriptions: feature_descriptions\n )\n end",
"def products\n end",
"def idcc_targ_rep_product_order_url( project, result_data, order_type )\n url = \"\"\n \n pipeline = project['pipeline']\n mgi_accession_id = project['mgi_accession_id'][4..-1]\n project_id = project['ikmc_project_id']\n marker_symbol = result_data['index']['marker_symbol']\n \n if pipeline == \"KOMP-CSD\"\n case order_type\n when \"vectors\"\n url = \"http://www.komp.org/vectorOrder.php?projectid=#{project_id}\"\n when \"cells\"\n url = \"http://www.komp.org/orders.php?project=CSD#{project_id}&product=1\"\n else\n url = \"http://www.komp.org/geneinfo.php?project=CSD#{project_id}\"\n end\n \n elsif pipeline == \"KOMP-Regeneron\"\n case order_type\n when \"vectors\"\n url = \"http://www.komp.org/vectorOrder.php?projectid=#{project_id}\"\n when \"cells\"\n url = \"http://www.komp.org/orders.php?project=#{project_id}&product=1\"\n else\n url = \"http://www.komp.org/geneinfo.php?project=#{project_id}\"\n end\n \n elsif pipeline == \"EUCOMM\" or pipeline == \"mirKO\"\n case order_type\n when \"vectors\"\n url = \"http://www.eummcr.org/final_vectors.php?mgi_id=#{mgi_accession_id}\"\n when \"cells\"\n url = \"http://www.eummcr.org/es_cells.php?mgi_id=#{mgi_accession_id}\"\n when \"mice\"\n url = \"http://www.emmanet.org/mutant_types.php?keyword=#{marker_symbol}%25EUCOMM&select_by=InternationalStrainName&search=ok\"\n else\n url = \"http://www.eummcr.org/order.php\"\n end\n \n elsif pipeline == \"NorCOMM\"\n url = \"http://www.phenogenomics.ca/services/cmmr/escell_services.html\"\n end\n \n return url\nend",
"def shift_up_orders()\n Feature.update_all('\"order\" = \"order\" - 1', '\"order\" > '+order.to_s)\n end",
"def up_item \n order_op2(true, @item)\n end",
"def set_product\n \n end",
"def increment_units\n contents.each do |key,content|\n id = content[\"_id\"] || content[\"item_id\"]\n begin\n \n product = shop.products.find(id)\n return false if product.nil? || product.dont_track_quantities?\n\n new_pv = []\n\n if product.price_variants.length==1\n\n new_pv = product.price_variants.first\n new_pv['quantity'] = new_pv['quantity'].to_i+content['quantity'].to_i\n product.num_orders = [product.num_orders-content['quantity'].to_i].max\n product.price_variants = [ new_pv ]\n\n else\n\n product.price_variants.each do |pv|\n name = [pv['primary'],pv['secondary']].join(\" \").downcase.trim\n name = \"\" if name==\" \"\n if name==content['variant_name'].trim.downcase && !pv['quantity'].blank?\n new_pv << pv.merge( 'quantity' => (pv['quantity'].to_i+content['quantity'].to_i) )\n else \n new_pv << pv\n end\n end\n product.num_orders = [product.num_orders-content['quantity'].to_i].max\n product.price_variants = new_pv\n\n end\n product.save\n\n rescue Exception => e\n ::Exceptional::Catcher.handle(e)\n # raise(e)\n end\n end\n end",
"def prod_nar\n\t\t@edad * 2\n\tend",
"def generate_orders\n @productos_por_taxonomias.each do |taxonomia, line_items|\n # Picamos la orden actual en sub-ordenes si la orden excede la cantidad de lineas configuradas en el backend par auna orden.\n line_items.each_slice(Spree::Config[:max_order_lines]) do |line_items_slice|\n line_items_slice.each do |line_item|\n @order = nil\n current_order = Spree::Order.new( user_id: spree_current_user.id,\n bill_address_id: @main_order.bill_address_id,\n ship_address_id: @main_order.ship_address_id,\n created_by_id: spree_current_user.id )\n populator = Spree::OrderPopulator.new(current_order, current_order.currency)\n populator.populate(line_item.variant_id, line_item.quantity)\n end\n @current_order = spree_current_user.last_incomplete_spree_order\n add_salesman\n puts \"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\"\n @current_order.next\n @current_order.next\n @current_order.next\n @zapato = \"chao\"\n end\n end\n end",
"def generate_order_no\n self.order_no = Concerns::OrderNoGenerator.generate\n end",
"def to_order_line\n OrderLine.new(\n product_id: 0,\n product_sku: SKU,\n product_name: name,\n product_price: price_adjustment,\n vat_amount: tax_adjustment\n )\n end",
"def formula_for(qty, desired_element)\n el = @elements[desired_element]\n qty += 1 while (qty % el.min_qty).positive? # Have to create in min quantity multiples\n scale = [qty / el.min_qty, 1].max # Then see if we need to multiply\n\n el.building_blocks.sort { |b, a| a[0].max_reactions <=> b[0].max_reactions }.map do |component, component_qty|\n [component.name, component_qty * scale]\n end\n end",
"def products(nums)\n prefix_products = build_prefix_products(nums)\n suffix_products = build_suffix_products(nums)\n suffix_products = suffix_products.reverse\n\n output(prefix_products, suffix_products, nums)\nend",
"def index\n set_orders()\n set_product_expiration()\n set_product_targets()\n @next_order = @product_targets.length + 1\n end",
"def base_product\n product_num\n end",
"def create\n @order = Order.new(params[:order])\n\n if @order.save\n\n\n orders = Order.by_manufacture_state(\"0\", @order.product_id)\n\n sum_meterial_manufacutured = @order.product.manufactures.sum(:quantity)\n orders.each do |order|\n\n break if order.quantity > (sum_meterial_manufacutured - Order.by_manufacture_state(\"1\", order.product.id).sum(:quantity))\n\n order.manufacture_flag = 1\n order.processing\n order.save\n\n end\n\n flash.notice = t('order.save')\n redirect_to orders_path\n else\n render :action => \"new\"\n end\n\n end",
"def update_order\r\n @order = @cards.collect {|card| card.to_s}\r\n end",
"def orders\n \"assetcode ASC\"# \"staffgrade_id ASC\"\n end",
"def product_name; end",
"def print_products\n\treturn \"\n ____ _ _ \n | _ \\\\ _ __ ___ __| |_ _ ___| |_ ___ \n | |_) | '__/ _ \\\\ / _` | | | |/ __| __/ __|\n | __/| | | (_) | (_| | |_| | (__| |_\\\\__ \\\\\n |_| |_| \\\\___/ \\\\__,_|\\\\__,_|\\\\___|\\\\__|___/\\n\\n\"\n\nend",
"def index\n @products = Product.all\n @products.each do |prod|\n if prod.pid == 1 # pid is a flag\n prod.bb = current_user.id\n prod.tbid += 1\n if prod.price <= prod.pbidprice && prod.tbid != 1\n prod.bb = prod.pbid\n prod.price = prod.pbidprice\n prod.tbid -= 1\n else\n prod.pbidprice = prod.price\n prod.pbid = prod.bb\n end\n prod.pid = 0\n prod.save\n end\n end\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 create\n code = order_params[:order_code].to_i\n shirt_type = @order_codes[code][:type]\n letter = @order_codes[code][:letter]\n count = @order_codes[code][:count]\n size = order_params[:shirt_size]\n if order_params[:letter_3] != 'none'\n letter_3 = order_params[:letter_3]\n else\n letter_3 = nil\n end\n number = OrderNumber.create!(id: order_params[:order_number])\n @order = Order.new(letter_1: order_params[:letter_1], \n letter_2: order_params[:letter_2], \n letter_3: letter_3, \n shirt_type: shirt_type, \n shirt_size: order_params[:shirt_size], \n shirt_color: order_params[:shirt_color], \n top_color: order_params[:top_color], \n bottom_color: order_params[:bottom_color], \n user_id: current_user.id,\n order_number: number)\n\n order_params[:quantity].to_i.times do |order| \n letter_1 = Letter.where(position: 'top', name: order_params[:letter_1], color: order_params[:top_color]).first.remove_one\n letter_2 = Letter.where(position: 'top', name: order_params[:letter_2], color: order_params[:top_color]).first.remove_one\n letter_4 = Letter.where(position: 'bottom', name: order_params[:letter_1], color: order_params[:bottom_color]).first.remove_one\n letter_5 = Letter.where(position: 'bottom', name: order_params[:letter_2], color: order_params[:bottom_color]).first.remove_one\n unless order_params[:letter_3] == 'none'\n letter_3 = Letter.where(position: 'top', name: order_params[:letter_3], color: order_params[:top_color]).first.remove_one\n letter_6 = Letter.where(position: 'bottom', name: order_params[:letter_3], color: order_params[:bottom_color]).first.remove_one\n end\n end\n order_params[:quantity].to_i.times do |x|\n if Item.where(item_type: shirt_type, color: order_params[:shirt_color], size: size).count > 0\n item = Item.where(item_type: shirt_type, color: order_params[:shirt_color], size: size).first\n @cost = item.cost\n item.status = 'sold'\n item.save\n else\n new_item = Item.create(item_type: shirt_type, color: order_params[:shirt_color], size: size, user_id: current_user.id, cost: 3.88)\n new_item.status = 'sold'\n @cost = item.cost\n new_item.save\n end\n end\n cost_breakdown = @order.order_breakdown(shirt_type, letter, order_params[:order_total], count, order_params[:quantity], @cost)\n current_user.account.update(\n mom_pay: current_user.account.mom_pay += cost_breakdown[:mom_pay],\n tanya_pay: current_user.account.tanya_pay += cost_breakdown[:tanya_pay],\n shop_money: current_user.account.shop_money += (cost_breakdown[:shop_money] + (order_params[:paid_shipping].to_f - order_params[:shipping_spent].to_f)),\n inventory_money: current_user.account.inventory_money += cost_breakdown[:inventory_money],\n etsy_bill: current_user.account.etsy_bill += (cost_breakdown[:etsy_bill] + order_params[:shipping_spent].to_f)\n )\n \n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\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 products\n @products.map{|prouduct, num| (1..num).map{|i| prouduct}}.flatten\n end",
"def generate_order_code\n\t\t\tsize = 5\n\t\t\tcharset = %w{0 1 2 3 4 6 7 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}\n\t\t\tself.code = \"DH\" + Time.now.strftime(\"%Y\").last(2) + (0...size).map{ charset.to_a[rand(charset.size)] }.join\n\t\tend",
"def total_product_sequence(n)\n #\n # your code goes here\n #\nend",
"def create_product(prod)\n\n purchase_price = BigDecimal.new(\"0.0\")\n purchase_price = BigDecimal.new(prod['purchase_price'].to_s) unless prod['purchase_price'].nil?\n sales_price = nil\n sales_price = BigDecimal.new(prod['sales_price']) unless prod['sales_price'].nil?\n weight = 0\n weight = prod['weight'].to_f unless prod['weight'].nil?\n manufacturer_product_code = prod['manufacturer_product_code']\n stock = prod['stock'].to_i unless prod['stock'].nil?\n\n tax_percentage = prod['tax_percentage'] || 8.0\n tax_class = TaxClass.where(:percentage => tax_percentage).first unless tax_percentage.nil?\n if tax_class.nil?\n tax_class = TaxClass.create(:percentage => 8.0, :name => \"8.0\")\n end\n\n prod['description'].blank? ? description = \"No description\" : description = prod['description']\n \n is_featured = false\n is_featured = true if [\"yes\", \"true\", \"1\"].include?(prod['featured'])\n is_visible = true\n is_visible = false if [\"no\", \"false\", \"0\"].include?(prod['visible'])\n is_build_to_order = false\n is_build_to_order = true if [\"yes\", \"true\", \"1\"].include?(prod['build_to_order'])\n \n supplier = Supplier.find_by_name(prod['supplier'])\n\n product = Product.where(:name => prod['name'],\n :description => description,\n :weight => weight,\n :sales_price => sales_price,\n :supplier_id => supplier,\n :tax_class_id => tax_class,\n :purchase_price => purchase_price,\n :manufacturer_product_code => manufacturer_product_code,\n :is_featured => is_featured,\n :is_visible => is_visible,\n :is_build_to_order => is_build_to_order,\n :stock => stock).first\n if product.nil?\n product = Product.create(:name => prod['name'],\n :description => description,\n :weight => weight,\n :sales_price => sales_price,\n :supplier => supplier,\n :tax_class => tax_class,\n :purchase_price => purchase_price,\n :manufacturer_product_code => manufacturer_product_code,\n :is_featured => is_featured,\n :is_visible => is_visible,\n :is_build_to_order => is_build_to_order,\n :stock => stock)\n end\n if prod['category']\n category = Category.where(:name => prod['category']).first\n category = Category.create(:name => prod['category']) if category.nil?\n product.categories << category\n product.save\n end\n\n\n # Ugly, but at least it makes test authors know what went wrong\n if product.errors.empty?\n return product\n else\n puts \"Errors creating product: #{product.errors.full_messages}\"\n return false\n end\nend",
"def process_order(order)\n data = order.strip.split(' ')\n return unless (data.size == 2)\n name = data.first.downcase\n return if @products_type[name].nil?\n quantity = is_numerical(data.last)\n return unless quantity && quantity > 0\n if @items_type[name].nil?\n @items_type[name] = Creator.createLineItem(@products_type[name],quantity)\n @line_items << @items_type[name]\n else\n @items_type[name].update_quantity(quantity)\n end\n end",
"def tl_dr_version\n client = SoftLayer::Client.new(\n # :username => \"joecustomer\" # enter your username here\n # :api_key => \"feeddeadbeefbadf00d...\" # enter your api key here\n )\n\n # Select a package\n quad_intel_package = SoftLayer::ProductPackage.package_with_id(client, 32)\n\n # Find required Categories and fill config_options with defaults\n config_options = {}\n required_categories = quad_intel_package.configuration.select { |category| category.required? }\n required_categories.each { |required_category| config_options[required_category.categoryCode] = required_category.default_option }\n\n # Provide a value for missing config categories\n config_options['server'] = 1417 # price id of Quad Processor Quad Core Intel 7420 - 2.13GHz (Dunnington) - 4 x 6MB / 8MB cache\n\n # With all the config options in place we can now construct the product order.\n server_order = SoftLayer::BareMetalServerOrder_Package.new(quad_intel_package, client)\n server_order.location = 'sng01'\n server_order.hostname = 'sample'\n server_order.domain = 'softlayerapi.org'\n server_order.configuration_options = config_options\n\n begin\n server_order.verify()\n puts \"The Order appears to be OK\"\n rescue Exception => e\n puts \"Order didn't verify :-( #{e}\"\n end\nend",
"def index\n\n #the following sort order items are sorted by the model\n unless params[:id].nil?\n case true\n when params[:id] == \"model\"\n Classified.set_order_var( \" makes.name , models.name ASC \")\n @classifieds = Classified.available_sorted\n when params[:id] == \"stock_code\"\n Classified.set_order_var( params[:id] << \" ASC\")\n @classifieds = Classified.available_sorted\n when params[:id] == \"price_in_cents\"\n Classified.set_order_var( params[:id] << \" DESC\")\n @classifieds = Classified.available_sorted\n when params[:id] == \"colour\"\n Classified.set_order_var( params[:id] << \" ASC\")\n @classifieds = Classified.available_sorted\n when params[:id] == \"days_in_stock\"\n Classified.set_order_var( params[:id] << \" DESC \" )\n @classifieds = Classified.available_sorted\n when params[:id] == \"mileage\"\n Classified.set_order_var( params[:id] << \" DESC \" )\n @classifieds = Classified.available_sorted\n when params[:id] == \"views\" || params[:id] == \"forms_sent\" || params[:id] == \"conversions\"\n @classifieds = Classified.available\n end\n else\n Classified.set_order_var(\"\")\n @classifieds = Classified.available\n end\n\n\n #the following params[:id] values cause the array to be sorted as the values\n # to be sorted are added to the array programmatically\n unless params[:id].nil?\n case true\n when params[:id] == \"views\" \n @classifieds.sort! {|a, b| a.stats_count <=> b.stats_count}\n @classifieds.reverse!\n when params[:id] == \"forms_sent\"\n @classifieds.sort! {|a, b| a.form_count <=> b.form_count}\n @classifieds.reverse!\n when params[:id] == \"conversions\"\n @classifieds.sort! {|a, b| a.conversions.to_f <=> b.conversions.to_f}\n @classifieds.reverse!\n end\n end\n #@classifieds.reverse!\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @classifieds }\n end\n end",
"def convert_to_order\n @order = self.wholesale_profile.orders.create(status: :draft)\n self.cart_items.each do |ci|\n pv = ProductVariant.find(ci.product_variant_id)\n @order.order_items.create(product_variant_id: pv.id, quantity: ci.quantity, line_item_total: (ci.quantity * pv.price_in_cents))\n end\n @invoice = @order.create_invoice\n if @order.update(status: :processing)\n self.cart_items.destroy_all\n end\n return @order\n end",
"def build_prefix_products(nums)\n prefix_products = []\n\n nums.each do |num|\n prefix_products << if prefix_products.count > 0\n prefix_products.last * num\n else\n num\n end\n end\n\n prefix_products\nend",
"def index\n @chemicals = Product.order(sort_column + \" \" + sort_direction)\n end",
"def item_skus_with_quantity\n line_items.map { |line| \"#{line.sku}-#{line.quantity}\" }.join(', ')\n end",
"def creator\n productlist = ProductList.find(self.product_list_id)\n\n self.update_columns(subtotal: productv.price * self.pieces,\n taxes: productv.taxes * self.pieces,\n codcharges: 0 * self.pieces,\n shipping: productv.shipping * self.pieces,\n total: productv.total * self.pieces,\n description: productv.name) # This will skip validation gracefully.\n\n self.update(description: productlist.productlistdetails)\n\n #updateOrder\n end",
"def order\n @order || \"99_99\"\n end",
"def add_ordering step1, step2\n ver = @orderings.cur_version\n @orderings.add step1, step2\n ver\n end",
"def create_config_cups kit, number_of_compartments, cup_layouts\n cup_count = 0\n cup_layouts.each_with_index do |cup_layout,index|\n cup_layout = cup_layout.sort { |a,b| a[1] <=> b[1] }\n cup = Array.new\n cup_layout.each { |cl| cup << cl.at(1) }\n cup.uniq!\n record_to_sort = Array.new\n cup.each { |record|\n record_to_sort << cup_layout.select { |data| data[1] == record }\n }\n cup_layout = Array.new\n record_to_sort.each { |rec|\n record = rec.sort! { |a,b| a[0] <=> b[0] }\n record.each { |new_rec| cup_layout << new_rec }\n }\n number_of_compartments = cup_layout.count\n index = index + 1\n\n for i in 0..number_of_compartments-1\n cup_id = kit.cups.create(:commit_status => false,:cup_dimension => cup_layout[i].join(','),:cup_number => cup_count + i+1, :status => 1)\n cup_id.update_attribute(\"cup_dimension\",cup_id.cup_dimension+\",#{index}\"+\",#{cup_id.id}\")\n end\n cup_count = cup_count + (i + 1)\n end\n cup_count =0\n end",
"def load_products\n @products_type[\"watermelon\"] = Creator.createProduct(:watermelon, \"watermelon\")\n @products_type[\"watermelon\"].add_pack(3, 6.99)\n @products_type[\"watermelon\"].add_pack(5, 8.99)\n\n @products_type[\"pineapple\"] = Creator.createProduct(:pineapple, \"pineapple\")\n @products_type[\"pineapple\"].add_pack(2, 9.95)\n @products_type[\"pineapple\"].add_pack(5, 16.95)\n @products_type[\"pineapple\"].add_pack(8, 24.95)\n\n @products_type[\"rockmelon\"] = Creator.createProduct(:rockmelon, \"rockmelon\")\n @products_type[\"rockmelon\"].add_pack(3, 5.95)\n @products_type[\"rockmelon\"].add_pack(5, 9.95)\n @products_type[\"rockmelon\"].add_pack(9, 16.99)\n end",
"def test_order; end",
"def orders_template(_power_definition)\n ''\n end",
"def order=(_arg0); end",
"def spg_ep1_5\n spg_1_5= {}\n if articulos.size >= 1 \n articulo = articulos.first\n spg_1_5[:codestpro1] = articulo.codestpro1 \n spg_1_5[:codestpro2] = articulo.codestpro2\n spg_1_5[:codestpro3] = articulo.codestpro3\n spg_1_5[:codestpro4] = articulo.codestpro4\n spg_1_5[:codestpro5] = articulo.codestpro5\n end \n spg_1_5\n end",
"def order\n \"Order nr. #{number}\"\n end",
"def order\n \"Order nr. #{number}\"\n end",
"def create_sku_combination(arr, number, user)\n Sku.create(sku_denomination: number, sku_combination: arr*\",\", user_id: user.id)\n end",
"def ordered_values; end",
"def barcode\n str_order = order.id.to_s.rjust(5, '0')\n str_cardinality = 1.to_s.rjust(3, '0')\n str_order + str_cardinality\n end",
"def make_products_section\n\t$products_hash[\"items\"].each do |toy|\n\t\ttoy_name toy\n print_toy_name\n\t\ttoy_full_price toy\n\t print_toy_full_price\n \ttotal_purchases toy\n\t\tprint_total_purchases\n\t total_sales toy\n\t\tprint_total_sales\n \taverage_price toy\n\t\tprint_average_price\n \taverage_discount toy\n\t\tprint_average_discount\n\tend\nend",
"def setup\n @products = products(:kit_lapis)\n end",
"def create_order()\n\t{\n\t\t\"destination\" => {\n\t\t\t\"name\" => \"hp.jpeng\"\n\t\t},\n\t\t\"orderData\" => {\n\t\t\t\"sourceOrderId\" => [*('A'..'Z')].sample(8).join,\n\t\t\t\"items\" => [{\n\t\t\t\t\"sourceItemId\" => [*('A'..'Z')].sample(8).join,\n\t\t\t\t\"sku\" => \"Flat\",\n\t\t\t\t\"quantity\" => 1,\n\t\t\t\t\"components\" => [{\n\t\t\t\t\t\"code\" => \"Content\",\n\t\t\t\t\t\"path\" => \"https://Server/Path/business_cards.pdf\",\n\t\t\t\t\t\"fetch\" => \"true\",\n\t\t\t\t\t# \"route\" => [{\n\t\t\t\t\t# \t\t\"name\" => \"Print\",\n\t\t\t\t\t# \t\t\"eventTypeId\" => \"\"\t\t#eventTypeId found within Site Flow -> Events\n\t\t\t\t\t# \t}, {\n\t\t\t\t\t# \t\t\"name\" => \"Cut\",\n\t\t\t\t\t# \t\t\"eventTypeId\" => \"\"\n\t\t\t\t\t# \t}, {\n\t\t\t\t\t# \t\t\"name\" => \"Laminate\",\n\t\t\t\t\t# \t\t\"eventTypeId\" => \"\"\n\t\t\t\t\t# \t}, {\n\t\t\t\t\t# \t\t\"name\" => \"Finish\",\n\t\t\t\t\t# \t\t\"eventTypeId\" => \"\"\n\t\t\t\t\t# }]\n\t\t\t\t}],\n\t\t\t}],\n\t\t\t\"shipments\" => [{\n\t\t\t\t\"shipTo\" => {\n\t\t\t\t\t\"name\" => \"John Doe\",\n\t\t\t\t\t\"address1\" => \"5th Avenue\",\n\t\t\t\t\t\"town\" => \"New York\",\n\t\t\t\t\t\"postcode\" => \"12345\",\n\t\t\t\t\t\"state\" => \"New York\",\n\t\t\t\t\t\"isoCountry\" => \"US\",\n\t\t\t\t\t\"email\" => \"johnd@acme.com\",\n\t\t\t\t\t\"phone\" => \"01234567890\"\n\t\t\t\t},\n\t\t\t\t\"carrier\" => {\n\t\t\t\t\t\"code\" => \"customer\",\n\t\t\t\t\t\"service\" => \"shipping\"\n\t\t\t\t}\n\t\t\t}]\n\t\t}\n\t}.to_json()\nend",
"def productify(array)\n\nend",
"def quantified_items\n products.map { |product| [product.variant, product.quantity] }\n end",
"def orders\n \"staffgrade_id ASC\"\n end",
"def orders\n \"staffgrade_id ASC\"\n end",
"def ordered_quantity_label\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.div.className(create_ats_regex_string(\"col3\")), format_method(__method__))\n end",
"def ordered_quantity_label\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.div.className(create_ats_regex_string(\"col3\")), format_method(__method__))\n end",
"def test_should_create_order_line_item\n a_towel = items(:towel)\n an_order_line_item = OrderLineItem.for_product(a_towel)\n \n assert_equal an_order_line_item.item, a_towel\n assert_equal an_order_line_item.name, a_towel.name\n assert_equal an_order_line_item.unit_price, a_towel.price\n # When created the quantity should be 1.\n assert_equal an_order_line_item.quantity, 1\n \n assert_equal an_order_line_item.total, a_towel.price * 1\n assert_equal an_order_line_item.product_id, a_towel.id\n assert_equal an_order_line_item.product, a_towel\n assert_equal an_order_line_item.code, a_towel.code\n assert_equal an_order_line_item.code, a_towel.code\n assert_equal an_order_line_item.name, a_towel.name\n \n assert an_order_line_item.save\n end",
"def populate\n order = current_order(create_order_if_necessary: true)\n variant = Spree::Variant.find(params[:variant_id])\n quantity = params[:quantity].to_i\n options = params[:options] || {}\n direccion = params[:direccion]\n aux = variant.product_id\n if aux == 1\n sku = 19\n elsif aux == 2\n sku = 27\n elsif aux == 3\n sku = 40\n elsif aux == 4\n sku = 45\n elsif aux == 5\n sku = 47\n end\n # 2,147,483,647 is crazy. See issue #2695.\n if quantity.between?(1, 2_147_483_647)\n if quantity <= (StockItem.find_by id: aux).count_on_hand\n begin\n order.contents.add(variant, quantity, options)\n rescue ActiveRecord::RecordInvalid => e\n error = e.record.errors.full_messages.join(\", \")\n end\n else\n error = Spree.t(:please_enter_reasonable_quantity)\n end\n else\n error = Spree.t(:please_enter_reasonable_quantity)\n end\n\n if error\n flash[:error] = error\n redirect_back_or_default(spree.root_path)\n else\n total = NuestroProducto.find(aux).precio * quantity\n factura = RestClient.put 'http://moto.ing.puc.cl/facturas/boleta', {:proveedor => '572aac69bdb6d403005fb042', :cliente => 'b2c', :total => total}\n facturaParseada = JSON.parse factura\n boleta = facturaParseada[\"_id\"]\n $idBoleta = boleta\n $iva = facturaParseada[\"iva\"]\n iva = $iva\n $montoBruto = facturaParseada[\"bruto\"]\n bruto = $montoBruto\n $total = facturaParseada[\"total\"]\n total = $total\n urlOk = 'http://integra1.ing.puc.cl/spree/orders/confirmarCompra/' + boleta\n urlFail = 'http://integra1.ing.puc.cl/cancelacion'\n url = 'http://integracion-2016-prod.herokuapp.com/web/pagoenlinea?callbackUrl='+urlOk+'&cancelUrl='+urlFail+'&boletaId=' + boleta\n redirect_to url\n #precio = NuestroProducto.find(aux).precio\n #moverA_Despacho boleta, direccion, quantity, sku, precio\n Ticket.create(idBoleta:boleta, direccion:direccion, sku:sku, cantidad:quantity, iva:iva, bruto:bruto, total:total)\n end\n end",
"def add_ordering step1, step2\r\n ver = @orderings.cur_version\r\n @orderings.add step1, step2\r\n ver\r\n end",
"def ordered_product_label\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.find.div.className(create_ats_regex_string(\"col1\")), format_method(__method__))\n end",
"def create\n @products = Product.all\n order_products = []\n @products.each do |p|\n sym = \"product_#{p.id}\".to_sym\n if params[sym].present?\n count = params[sym].to_i\n if count > 0\n order_product = OrderProduct.new(product: p, count: count)\n order_products << order_product\n end\n end\n end\n\n if order_products.size > 0\n order = Order.new(user: current_user)\n order.save!\n order_products.each do |i|\n i.order = order\n i.save!\n end\n redirect_to order_path(order.id)\n else\n redirect_to new_order_path\n end\n end",
"def generate_order\n p \"#{client}: #{total}\"\n end",
"def generate_order\n clean_order!\n\n attrs = attributes(:json).reject do |key, _|\n [:adjustments, :state, :order_id, :shipping_method_id].include?(key)\n end\n\n %w(billing shipping).each do |addr|\n attrs[:\"#{ addr }_address_attributes\"] =\n attrs.delete(:\"#{ addr }_address\")\n end\n\n unless use_another_address_for_shipping\n attrs[:shipping_address_attributes] =\n attrs[:billing_address_attributes]\n end\n\n # Append shipping method id after addresses so the latters are present\n # when shipping adjustment is processed on order\n attrs[:shipping_method_id] = shipping_method_id\n\n attrs[:discount_code] = discount_code\n\n self.order = Glysellin::Order.create!(attrs)\n end",
"def sort_edition\n \"-#{barcode.edition}\"\n end",
"def snacks\n\n @snacks = Spree::Product.limit(5).order('id desc')\n @snacks.sort_by! { |x| x[:name].downcase }\n end",
"def add_product_skus\n @order = Spree::Order.find_by_id(params[:order_id])\n @variant = Spree::Variant.find_by_id(params[:variant_id])\n @product = @variant.product\n requested_qty = params[:quantity]\n is_customer_pickup = @order.market_place_details.present? ? (@order.market_place_details[\"OrderType\"] == \"Pickup\" ? true : false) : false\n # code to find the order_total\n if @order.market_place.present?\n case @order.market_place.code\n when \"qoo10\"\n order_total = @order.market_place_details.present? ? @order.market_place_details[\"total\"] : @order.total\n when \"lazada\",'zalora'\n order_total = @order.total\n end\n end\n # code to create line item\n price = @variant.price.present? ? @variant.price : 0.0 \n @line_item = Spree::LineItem.create!(:variant_id=>@variant.id, :order_id=>@order.id, :quantity=>requested_qty, :price=>price, :currency=>@order.currency, :is_pick_at_store => is_customer_pickup)\n if @line_item.present?\n @sellers_market_places_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", @order.seller_id, @order.market_place_id, @product.id).try(:first)\n if @sellers_market_places_product.present?\n @stock_product = Spree::StockProduct.where(\"sellers_market_places_product_id=? AND variant_id=?\", @sellers_market_places_product.id, @variant.id).try(:first)\n if @stock_product.present?\n @stock_product.update_attributes(:count_on_hand=>(@stock_product.count_on_hand - requested_qty.to_i) >= 0 ? (@stock_product.count_on_hand - requested_qty.to_i) : 0)\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - requested_qty.to_i) >= 0 ? (@variant.fba_quantity - requested_qty.to_i) : 0) if !@variant.quantity_inflations.present?\n msg = 'Admin/Orders Controller add_product_skus Line 182'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n else\n @stock_product = Spree::StockProduct.create!(:sellers_market_places_product_id=>@sellers_market_places_product.id, :variant_id=>@variant.id, :count_on_hand=>requested_qty.to_i, :virtual_out_of_stock=>false)\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - requested_qty.to_i) >= 0 ? (@variant.fba_quantity - requested_qty.to_i) : 0) if !@variant.quantity_inflations.present?\n msg = 'Admin/Orders Controller add_product_skus Line 187'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n end\n end\n end\n # code to update order total after creating line item for order\n @order.update_column(:total, order_total)\n @order.reload\n line_items = @order.line_items\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => @order})\n respond_to do |format|\n format.html { render :partial=>\"modify_shipping\", :locals => { :line_items => line_items }}\n end\n end",
"def set_ordered_product\n @ordered_product =OrderedProduct.find_by(product_id: params[:product_id])\n end",
"def order(value)\n\t\t\tparam(\"order\", value)\n\t\tend",
"def custom_order_attribute(custom_key, value_instruction=nil)\n Order.custom_order_attribute(custom_key, value_instruction)\n end",
"def print_order\n p \"@@@@@@@@@ Order id: ##{order.attrs['id']}\"\n p \"Name: #{order.attrs['name']} Email: #{order.attrs['email']}\"\n p \"Status: #{order.attrs['status']}\"\n\n conn = DatabaseConnector.new.connect\n rs = conn.exec \"select li.*, products.name from line_items as li INNER JOIN products on li.product_id = products.id where li.order_id = '#{order.attrs['id']}'\"\n\n char_len = 30\n rs.each do |row|\n prod_name = \"#{row['id']} : #{row['name']}\"\n\n p \"#{prod_name} #{'-'*(char_len - prod_name.length)}---> #{row['amount']} X #{row['quantity']} = #{row['amount'].to_f * row['quantity'].to_i}\"\n end\n p '-'*55\n if order.attrs['discont_desc'] != ''\n p \"Sub Total #{'-'*25} -> #{order.attrs['sub_total']}\"\n p \"Coupon #{'-'*25} -> #{order.attrs['discont_desc']}\"\n p \"You Saved #{'-'*25} -> #{order.attrs['amount'].to_i - order.attrs['sub_total'].to_i}\"\n p '-'*55\n end\n p \"Total #{'-'*25} -> #{order.attrs['amount']}\"\n end",
"def calculate_vector_of_user_exercises\n \n if self.user_sequence.empty? \n\n new_order = self.statistic.order_exercises.map do |key, value| \n [key, value[\"actual_position\"], false, false]\n end\n new_order.sort! { |a,b| a[1] <=> b[1]} # ordena pela actual_position\n self.user_sequence = new_order \n end\n save\n end",
"def preview_order_items\n [\n {title: 'Item One', quantity: 2, price: 999, tax_exempt: false},\n {title: 'Item Two', quantity: 1, price: 25000, tax_exempt: false},\n {title: 'Item Three', quantity: 1, price: 8999, tax_exempt: false},\n {title: 'Item Four', quantity: 1, price: 100000, tax_exempt: false}\n ]\n end",
"def order_multi ()\n raise Exception, 'not implemented'\n end",
"def ordered_products_label\n $tracer.trace(format_method(__method__))\n return ToolTag.new(@tag.parent(\"td\"), format_method(__method__))\n end",
"def order(cover)\n # Step 1: Compute the weight of each cube\n weights = [ 0 ] * cover.size\n # For that purpose first compute the weight of each column\n # (number of ones)\n col_weights = [ 0 ] * cover.width\n cover.width.times do |i|\n # cover.each_cube { |cube| col_weights[i] += 1 if cube[i] == \"1\" }\n cover.each_cube do |cube| \n col_weights[i] += 1 if cube.getbyte(i) == 49\n end\n end\n # Then the weight of a cube is the scalar product of its\n # bits with the column weights.\n cover.each_cube.with_index do |cube,j|\n cube.each_byte.with_index do |bit,i|\n # weights[j] += col_weights[i] if bit == \"1\"\n weights[j] += col_weights[i] if bit == 49\n end\n end\n\n # Step 2: stort the cubes by weight\n new_cubes = cover.each_cube.sort_by.with_index { |cube,i| weights[i] }\n \n # Creates a new cover with the sorted cubes and return it.\n sorted = Cover.new(*cover.each_variable)\n new_cubes.each { |cube| sorted << cube }\n return sorted\n end",
"def display_products(products)\n puts \" ID Description Price\"\n puts \"-\" * 50\n products.each do |key, value|\n #puts key.class\n #puts value[1] + 1\n puts \"#{key} #{value[0].rjust(25)} $#{sprintf(\"%.2f\", value[1]).to_s.rjust(6)}\"\n end\nend",
"def bought_products\n order_details.sum(:quantity)\n end",
"def mk_products\n # create some test products\n @first_product = Product.create!(:name => \"Test product 1\")\n @second_products = Product.create!(:name => \"Test product 2\") \n @product_ids = Product.all.map(&:id)\n assert_equal(2,Product.all.size)\n [@first_product,@second_product]\n end",
"def mangopay_order_tag\n \" - Order: #{id} - User: #{user.id}, #{user.first_name.first}.#{user.last_name} -Slot: #{slot.id} du #{slot.date.strftime('%d/%m/%y')} - Course: #{slot.course.id}, #{slot.course.name} - Coach: #{slot.course.coach_id}/User_id: #{slot.course.coach.user.id}, #{slot.course.coach.user.first_name.first}.#{slot.course.coach.user.last_name} \"\n end",
"def prodenum(n)\n $primitives ||= primitives(90)\n $new_number_products_cache ||= Array.new(4, [])\n\n result = (4..n).to_a.flat_map { |i| primitives_combinations(i) }\n (result | [1].concat($primitives.select { |pr| pr <= n })).sort\n end",
"def product_component_print(product)\n sgc= \"<table>\"\n if(product.components.empty?)\n sgc+= \"<tr><td>No Components Available </td></tr>\"\n else\n for comp in product.components.sort {|x,y| x.name <=> y.name }\n sgc+= \"<tr><td>#{link_to comp.name, comp}</td></tr>\"\n end\n\n end\n sgc+= \"</table>\"\n return sgc\n end"
] |
[
"0.57688946",
"0.57559365",
"0.5732896",
"0.5601772",
"0.55900025",
"0.55900025",
"0.5578126",
"0.5572557",
"0.5535404",
"0.54481006",
"0.5427964",
"0.5389294",
"0.5382906",
"0.5375876",
"0.53378683",
"0.5320349",
"0.52330345",
"0.5212837",
"0.5212647",
"0.5205473",
"0.5202503",
"0.5196296",
"0.5182528",
"0.5170797",
"0.5169697",
"0.5168969",
"0.5073175",
"0.5067811",
"0.5055832",
"0.50214577",
"0.5019711",
"0.5011042",
"0.49934834",
"0.49659058",
"0.49658224",
"0.49388617",
"0.489781",
"0.4885601",
"0.4875761",
"0.48656932",
"0.48601902",
"0.48569143",
"0.48510936",
"0.4845159",
"0.48413622",
"0.48384705",
"0.48361",
"0.48286584",
"0.48186594",
"0.4816061",
"0.48128474",
"0.48120078",
"0.4808459",
"0.48078734",
"0.47967625",
"0.47913158",
"0.4789572",
"0.47872353",
"0.4776827",
"0.47677338",
"0.47676313",
"0.4767502",
"0.4767502",
"0.47674185",
"0.4761473",
"0.47608635",
"0.47558042",
"0.47539285",
"0.4750262",
"0.4738587",
"0.4736584",
"0.47341236",
"0.47341236",
"0.47281832",
"0.47281832",
"0.47261047",
"0.4725929",
"0.472428",
"0.4721595",
"0.4718954",
"0.47171864",
"0.4715463",
"0.47153145",
"0.47046247",
"0.46996433",
"0.4696985",
"0.46945605",
"0.46925375",
"0.46921417",
"0.46917847",
"0.46891394",
"0.46867013",
"0.468599",
"0.4684548",
"0.4680264",
"0.467839",
"0.4674553",
"0.46693388",
"0.46667454",
"0.46636438"
] |
0.5062189
|
28
|
Creates a new SexpProcessor. Use super to invoke this initializer from SexpProcessor subclasses, then use the attributes above to customize the functionality of the SexpProcessor
|
def initialize
@expected = Sexp
# we do this on an instance basis so we can subclass it for
# different processors.
@processors = {}
@context = []
public_methods.each do |name|
if name.to_s.start_with? "process_" then
@processors[name[8..-1].to_sym] = name.to_sym
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize\n @expected = Sexp\n @processors = self.class.processors\n @context = []\n\n if @processors.empty?\n public_methods.each do |name|\n if name.to_s.start_with? \"process_\" then\n @processors[name[8..-1].to_sym] = name.to_sym\n end\n end\n end\n end",
"def << processor\n raise ArgumentError, \"Can only add sexp processors\" unless\n SexpProcessor === processor || processor.respond_to?(:process)\n @processors << processor\n end",
"def process exp\n @processors.each do |processor|\n exp = processor.process(exp)\n end\n exp\n end",
"def process(exp)\n @processor.process(exp)\n end",
"def initialize\n @default_method = nil\n @warn_on_default = true\n @auto_shift_type = false\n @strict = false\n @unsupported = [:alloca, :cfunc, :cref, :ifunc, :last, :memo,\n :newline, :opt_n, :method]\n @unsupported_checked = false\n @debug = {}\n @expected = Sexp\n @require_empty = true\n @exceptions = {}\n\n # we do this on an instance basis so we can subclass it for\n # different processors.\n @processors = self.class.processors\n @rewriters = self.class.rewriters\n @context = []\n\n if @processors.empty?\n public_methods.each do |name|\n case name\n when /^process_(.*)/ then\n @processors[$1.to_sym] = name.to_sym\n when /^rewrite_(.*)/ then\n @rewriters[$1.to_sym] = name.to_sym\n end\n end\n end\n end",
"def process_class exp\n exp\n end",
"def process_source exp, klass = nil, method = nil, template = nil\n @current_class = klass\n @current_method = method\n @current_template = template\n process exp\n end",
"def processed_smser\n @processed_smser ||= @smser_class.new.tap do |smser|\n smser.process @action, *@args\n end\n end",
"def processor\n @processor ||= Processor.new(options)\n end",
"def process exp\n return nil if exp.nil?\n\n unless Sexp === exp then\n raise SexpTypeError, \"exp must be a Sexp, was #{exp.class}:#{exp.inspect}\"\n end\n\n if self.context.empty? then\n p :rewriting unless debug.empty?\n exp = self.rewrite(exp)\n p :done_rewriting unless debug.empty?\n end\n\n unless @unsupported_checked then\n m = public_methods.grep(/^process_/) { |o| o.to_s.sub(/^process_/, \"\").to_sym }\n supported = m - (m - @unsupported)\n\n raise UnsupportedNodeError, \"#{supported.inspect} shouldn't be in @unsupported\" unless supported.empty?\n\n @unsupported_checked = true\n end\n\n result = self.expected.new\n\n type = exp.sexp_type\n raise \"type should be a Symbol, not: #{exp.first.inspect}\" unless\n Symbol === type\n\n in_context type do\n if @debug.key? type then\n str = exp.inspect\n puts \"// DEBUG:(original ): #{str}\" if str =~ @debug[type]\n end\n\n exp_orig = nil\n exp_orig = exp.deep_clone if $DEBUG or\n @debug.key? type or @exceptions.key?(type)\n\n raise UnsupportedNodeError, \"'#{type}' is not a supported node type\" if\n @unsupported.include? type\n\n # now do a pass with the real processor (or generic)\n meth = @processors[type] || @default_method\n if meth then\n\n if @warn_on_default and meth == @default_method then\n warn \"WARNING: Using default method #{meth} for #{type}\"\n end\n\n exp = exp.sexp_body if @auto_shift_type and meth != @default_method # HACK\n\n result = error_handler(type, exp_orig) {\n self.send meth, exp\n }\n\n if @debug.key? type then\n str = exp.inspect\n puts \"// DEBUG (processed): #{str}\" if str =~ @debug[type]\n end\n\n raise SexpTypeError, \"Result of #{type} must be a #{@expected}, was #{result.class}:#{result.inspect}\" unless\n @expected === result\n\n self.assert_empty(meth, exp, exp_orig) if @require_empty\n else\n unless @strict then\n until exp.empty? do\n sub_exp, *exp = exp # HACK\n sub_result = nil\n if Array === sub_exp then\n sub_result = error_handler(type, exp_orig) do\n process(sub_exp)\n end\n raise \"Result is a bad type\" unless Array === sub_exp\n raise \"Result does not have a type in front: #{sub_exp.inspect}\" unless\n Symbol === sub_exp.sexp_type unless\n sub_exp.empty?\n else\n sub_result = sub_exp\n end\n # result << sub_result\n result = result.class.new(*result, sub_result) # HACK\n end\n\n # NOTE: this is costly, but we are in the generic processor\n # so we shouldn't hit it too much with RubyToC stuff at least.\n result.c_type ||= exp.c_type if Sexp === exp and exp.respond_to?(:c_type)\n else\n msg = \"Bug! Unknown node-type #{type.inspect} to #{self.class}\"\n msg += \" in #{exp_orig.inspect} from #{caller.inspect}\" if $DEBUG\n raise UnknownNodeError, msg\n end\n end\n end\n\n result\n end",
"def ps\n [VishParser.new, SexpTransform.new]\nend",
"def stream_processor\n @stream_processor ||= StreamProcessor.new(@parent, @name, @metadata)\n end",
"def initialize(env, processors, &block)\n @env, @processors = env, []\n chain(processors)\n instance_eval(&block) if block\n end",
"def initialize(text, *extensions)\n @text = text\n extensions.each { |e| send(\"#{e}=\", true) }\n @text = Math[@text].preprocess if preserve_math\n end",
"def processor=(_arg0); end",
"def initialize(processors)\n @processors = processors\n end",
"def super(sexp, level)\n args = []\n until sexp.empty?\n args << process(sexp.shift, :expression)\n end\n \"$super(arguments.callee, self, [#{args.join ', '}])\"\n end",
"def processor; end",
"def setup_sre(gather=true)\n @sre_object = ::ISS::SRE::ObjectHandler.new(self) if gather\n @sre_engine = ::ISS::SRE::ActionCommandEngine.new(self)\n end",
"def process_attributes!\n if !@current_command_type.nil?\n @expression = Confinicky::Parsers::Expression.new(statement: @line.gsub(/\\A#{@current_command_type} /,\"\"))\n @name = @expression.name\n @value = @expression.value\n end\n end",
"def initialize(regex, options = {})\n @@parse_options = options\n @@parse_options[:reg_options] ||= Regextest::RegexOption.new\n @verification = (options && options[:verification] == false)?false:true\n @reg_string = nil\n @reg_exp = nil\n \n # Set seed for randomizing\n @seed = set_seed_for_randomizing(@@parse_options[:seed])\n\n # Covert to source string if necessary\n set_regex(regex)\n\n # Parse string\n @front_end = Regextest::Front.new(@reg_string, @@parse_options)\n \n # Prepare back-end process. (use generate method for generating string)\n @back_end = Regextest::Back.new(@front_end)\n \n @result = nil\n @reason = nil\n end",
"def process_sclass exp\n exp.shift unless auto_shift_type # node type\n in_sklass do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def initialize\n super\n # Default operators\n @evaluator = Evaluator.new self\n @expressor = Expressor.new self\n @evolver = Evolver.new self\n end",
"def initialize(_src)\n\t\t@tokenizer = Lexer.new(_src)\n\t\t@token = nil\n\t\t@blocklevel = 0\n\t\t@node = nil\n\t\t@sav = nil\n\tend",
"def valid_processors; end",
"def initialize regex=nil, priority=50, &action\n @regex = regex\n @action = action\n @priority = priority\n end",
"def extended_regexps!\n @hsh = self.class.er(@hsh)\n end",
"def initialize(source, options)\n super\n\n reset_env\n\n @alds = {}\n @footnotes = {}\n @link_defs = {}\n update_link_definitions(@options[:link_defs])\n\n @block_parsers = [:blank_line, :codeblock, :codeblock_fenced, :blockquote, :atx_header,\n :horizontal_rule, :list, :definition_list, :block_html, :setext_header,\n :block_math, :table, :footnote_definition, :link_definition,\n :abbrev_definition, :block_extensions, :eob_marker, :paragraph]\n @span_parsers = [:emphasis, :codespan, :autolink, :span_html, :footnote_marker, :link,\n :smart_quotes, :inline_math, :span_extensions, :html_entity,\n :typographic_syms, :line_break, :escaped_chars]\n\n @span_pattern_cache ||= Hash.new { |h, k| h[k] = {} }\n end",
"def initialize( *expression_parts )\n\t\tself.log.debug \"New filter for expression: %p\" % [ expression_parts ]\n\t\t@component = self.class.parse_expression( expression_parts )\n\t\tself.log.debug \" expression parsed into component: %p\" % [ @component ]\n\n\t\tsuper()\n\tend",
"def setup\r\n\t\t@ne = NExp.from_s(@@nexp, :single)\r\n\tend",
"def initialize()\n @regexps = Hash.new {|hash,key| hash[key] = Regexp.new(key)}\n @memoization = nil\n @terminal_parse_failures = nil\n end",
"def process_source exp, opts\n @current_class = opts[:class]\n @current_method = opts[:method]\n @current_template = opts[:template]\n @current_file = opts[:file]\n @current_call = nil\n process exp\n end",
"def process(&block)\n @processor = block\n self\n end",
"def initialize(code, scope, sexp = nil)\n @code = code.to_s\n @sexp = sexp\n @scope = scope\n end",
"def initialize(expr)\n @expr = expr\n super()\n end",
"def initialize\n preprocess false\n debug false\n end",
"def initialize(name, processors)\n @name, @processors = name, []\n processors.each(&method(:<<))\n end",
"def initialize(msg = nil, parser_state = nil, expression = nil, cause = nil)\n super(msg, parser_state, cause)\n @expression = expression\n end",
"def initialize top_level, file_name, content, options, stats\n @top_level = top_level\n @top_level.parser = self.class\n @store = @top_level.store\n\n @file_name = file_name\n @content = content\n @options = options\n @stats = stats\n\n @preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include\n @preprocess.options = @options\n end",
"def initialize(context={})\n self.context = context\n self.target = context[:target]\n self.output = context[:output]\n self.eval_string = context[:eval_string]\n self.command_set = context[:command_set]\n self._pry_ = context[:pry_instance]\n end",
"def initialize(str)\n @expression = str\n end",
"def initialize()\n self.kind = CIAT::Processors::Interpreter.new\n self.description = \"Parrot virtual machine\"\n self.libraries = []\n yield self if block_given?\n end",
"def get_processor; end",
"def initialize attrs={}\n attrs[:calculator] = attrs[:calculator].constantize.new if attrs && attrs[:calculator].present?\n\n # TODO: - Pendiente queda asignar el id del precio que se esta cambiando\n\n super attrs\n end",
"def context\n unless @instance_context\n @instance_context = MediaProcessorContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def use(processor, options = {})\n @stack << [self.class.get_callable(processor, HtmlMockup::Release::Processors), options]\n end",
"def initialize(_subject, _statement)\n formatted_statement = _statement\n .gsub(/[\\<>]/, '')\n .gsub(/#PCDATA/, 'PCDATA')\n .gsub('-','_dash_')\n .gsub(/\\b/,'\\b')\n .gsub(/PCDATA/, '#PCDATA')\n .gsub('_dash_', '-')\n .gsub(/\\s/,'')\n super(_subject, formatted_statement)\n end",
"def expression sexp\n return nil if sexp == nil\n #pp sexp\n body = sexp.sexp_body\n case sexp[0]\n # when :block # a collection of things to do!\n # body.map { |i| convert(i) + NL }.join\n when :iasgn # assign to instance variable\n value = expression( sexp[2] )\n name = @vars.set( sexp[1], value.type )\n \"#{name} = (#{value})\"\n when :lit, :false, :true, :array # literal values\n literal(sexp)\n when :ivar\n @vars.get(sexp.value)\n when :call # call a 'method' on something\n call(sexp[1], sexp[2], sexp[3].sexp_body)\n when :if # statements resembling ifs\n condition = expression(sexp[1])\n true_code = expression(sexp[2])\n false_code = expression(sexp[3])\n \"( ( #{condition} )?( #{true_code} ):( #{false_code} ) )\"\n when :colon2 # lookup constants\n if sexp[1][0] == :const and sexp[1][1] == :Math\n case sexp[2]\n when :PI\n Value.typed CTypeFloat, Math::PI.inspect\n end\n end\n when :not # the !something operator\n Value.typed CTypeBoolean, \"!(#{ expression(sexp.value) })\"\n else\n raise \"IDK how to handle this S-expression: #{ sexp.inspect }!\"\n end\n end",
"def initialize(expressions)\n @expressions = expressions\n end",
"def processed_source=(_); end",
"def processed_source=(_); end",
"def initialize(input, options = {})\n @s = Scanner.new(preprocess(input))\n @options = options\n end",
"def initialize(input, options = {})\n @s = Scanner.new(preprocess(input))\n @options = options\n end",
"def initialize(source = nil)\n @arguments = []\n\n parsed_step = process_source(source)\n\n build_step(parsed_step) if parsed_step\n end",
"def initialize(opts = {})\n @line = nil\n @lexer = opts[:lexer] || Lexer.new\n @expression = ArithmeticExpression.new(self, @lexer)\n\n reset_variables\n end",
"def use(processor)\n definition << processor\n processor\n end",
"def process_defn exp\n process_all exp.body\n end",
"def initialize(identifier_regex, rep_name, block)\n @identifier_regex = identifier_regex\n @rep_name = rep_name.to_sym\n\n @block = block\n end",
"def initialize(expression, convert = false)\n @final_transform = nil\n @expression = expression\n @path = []\n @convert = convert\n parse(expression)\n end",
"def initialize(input_text = nil)\n @engine = LexerEngine.new\n\t\t@queue = TokenQueue.new\n engine.input = input_text unless input_text.nil?\n end",
"def initialize(pstack)\n super(pstack)\n end",
"def initialize()\n #@source = aSourceTemplate\n #@representation = compile(aSourceTemplate)\n end",
"def initialize()\n\t\t######## Members\n\t\t##\n\t\t# Package name\n\t\t# \n\t\t# @var\tstring\n\t\t##\n\t\t@package = 'Sifter'\n\n\t\t##\n\t\t# Holds child objects\n\t\t# \n\t\t# @var\tobject\n\t\t##\n\t\t@contents = nil\n\n\t\t##\n\t\t# Capture result flag\n\t\t# \n\t\t# @var\tbool\n\t\t##\n\t\t@capture_result = false\n\n\t\t##\n\t\t# Result\n\t\t# \n\t\t# @var\tstring\n\t\t##\n\t\t@result = ''\n\n\t\t##\n\t\t# Holds replacements\n\t\t# \n\t\t# @var\tarray\n\t\t##\n\t\t@replace_vars = {}\n\tend",
"def initialize(source)\n @transformer_factory = TransformerFactory.newInstance()\n @source = source\n @style_sheet = @transformer_factory.newTemplates(@source) \n end",
"def initialize\n super\n @actions = [].freeze\n @prepared = false\n @context = Context.new(stack: self)\n @hooks = Hooks.new(stack: self)\n @started = false\n @parallel = false\n end",
"def initialize\n @tokens = {}\n @regex_tokens = []\n @string_tokens = []\n @tokens_by_string = {}\n end",
"def initialize attrs={}\n attrs[:calculator] = attrs[:calculator].constantize.new() if attrs[:calculator].present?\n\n # ToDo - Pendiente queda asignar el id del precio que se esta cambiando\n\n super attrs\n end",
"def initialize(expr = nil)\n @expression = expr\n end",
"def use(processor)\n @processors << processor\n self\n end",
"def initialize(expression, block)\n @expression = expression\n @block = block\n end",
"def initialize(*_)\n super\n SfnAws.load!\n @translators = Smash.new\n end",
"def process_line ln, line\r\n # convert inline processor\r\n while /\\#\\#(?<p_>[A-Z][_A-Z0-9]*)(:\\s*(?<a_>.+))?\\#\\#/ =~ line\r\n rst = conv_inline(p_, a_, ln, line)\r\n raise \"do not use '##.*##' inside your inline processor converting result\" if rst =~ /\\#\\#[A-Z][_A-Z0-9]*(:\\s*.+)?\\#\\#/\r\n line.sub!(/\\#\\#[A-Z][_A-Z0-9]*(:\\s*.+)?\\#\\#/, rst)\r\n end\r\n \r\n # create a token, with processor name\r\n token = self.tokenize(ln, line)\r\n # based on the the token indent level, close token stack if any\r\n self.close_stack token.indent_level\r\n \r\n # add token and then close it unless it opens a block\r\n @token_stack << token\r\n self.close_stack token.indent_level unless token.block_open?\r\n\r\n self # for methods chain\r\n end",
"def initialize(name, regex, proc=nil, &block)\n @name = name\n @regex = regex\n @proc = proc || block\n end",
"def initialize options, markup = nil\n super\n\n @code_object = nil\n @from_path = ''\n @in_list_entry = nil\n @list = nil\n @th = nil\n @hard_break = \"<br>\\n\"\n\n init_regexp_handlings\n\n init_tags\n end",
"def parse(node, *args, &block)\n new(*args) do |instance|\n processors.each do |name, processor|\n processor.call(instance, node)\n end\n \n if block_given?\n case block.arity\n when 1 then block.call(instance)\n else instance.instance_eval(&block)\n end\n end\n end\n end",
"def initialize(stream=\"\", tagdict=DefaultHtmlTagInfo, &element_filter)\n @stream = stream\n @tagdict = tagdict\n @escape = true\n @asxml = false\n @delete_span = true\n @sanitized = false\n @compact_space = false\n @element_filter = element_filter\n end",
"def initialize(source = nil)\n parsed_example = process_source(source)\n\n super(parsed_example)\n\n @tags = []\n @tag_elements = []\n @rows = []\n @parameters = []\n @row_elements = []\n\n build_example(parsed_example) if parsed_example\n end",
"def process_defn exp\n exp.shift unless auto_shift_type # node type\n name = @sclass.empty? ? exp.shift : \"::#{exp.shift}\"\n\n in_method name, exp.file, exp.line, exp.line_max do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def initialize ( )\n @buffer = [] # буфер для символов входного потока\n @states = [] # массив с состояниями парсера, <ParserState> объекты\n @chain = [] # цепочка работающих состояний\n #\n # Машина состояний для метода classify.\n #\n @matchstate = {\n\t:state => 0,\n\t:index => 0\n }\n @parserstate = ''\n end",
"def process(*args)\n new.process(*args)\n end",
"def initialize(options={})\n defaults = {:text => \"\", :compress => false}\n options = defaults.merge options\n @text = options[:text] != nil ? options[:text] : ''\n @compress = options[:compress] != nil ? !!options[:compress] : false\n \n @output = \"\"\n @open_tags = []\n @indent_token = \"\"\n @current_level = 0\n @previous_level = nil\n @line_number = 0\n @embedding_token = '`'\n \n if @text != \"\"\n self.compile\n end\n end",
"def setup\n super\n @processor = nil\n end",
"def initialize(str)\n @expression = str\n @infix_tree = nil\n @value = nil\n end",
"def e(word)\n Exp.new word\nend",
"def process(env)\n raise \"Please ensure you call init before processing\" unless inited?\n @processor.process(env)\n end",
"def initialize(process); end",
"def initialize(options = {})\n @executable = options.fetch(:executable, 'texmath')\n self.reader = options.fetch(:from, :tex)\n self.writer = options.fetch(:to, :mathml)\n end",
"def initialize(input)\n if input.respond_to?(:expression)\n @expression = input.expression\n elsif input.respond_to?(:each)\n @terms = input\n else\n @expression = input.to_s\n end\n end",
"def process\n input_text = read_input_file\n s_exp = parse_to_s_expression(input_text)\n write_s_exp_file(s_exp)\n dot_data = get_method_calls(s_exp)\n write_dot_file(dot_data)\n end",
"def process_iter(exp)\n Sexp.from_array([:iter, process(exp.shift), process(exp.shift), process(exp.shift)])\n end",
"def initialize(source = nil)\n parsed_outline = process_source(source)\n\n super(parsed_outline)\n\n @tags = []\n @tag_elements = []\n @examples = []\n\n build_outline(parsed_outline) if parsed_outline\n end",
"def initialize\n utility_parsers\n operator_parsers\n integer_parsers\n term_and_expr_parsers\n end",
"def process_call exp\n return exp unless @current_class\n return exp if process_call_defn? exp\n\n target = exp.target\n if sexp? target\n target = process target\n end\n\n method = exp.method\n first_arg = exp.first_arg\n\n # Methods called inside class definition\n # like attr_* and other settings\n if @current_method.nil? and target.nil?\n if first_arg.nil?\n case method\n when :private, :protected, :public\n @visibility = method\n when :attr_accessible\n @current_class.set_attr_accessible\n else\n # ??\n end\n else\n case method\n when :include\n @current_class.add_include class_name(first_arg) if @current_class\n when :attr_accessible\n @current_class.set_attr_accessible exp\n when :attr_protected\n @current_class.set_attr_protected exp\n else\n if @current_class\n @current_class.add_option method, exp\n end\n end\n end\n\n exp\n else\n call = make_call target, method, process_all!(exp.args)\n call.line(exp.line)\n call\n end\n end",
"def create_string_processor string\n Processor.new(search_path, replacements, :string => string)\n end",
"def create_file_processor filename\n Processor.new(search_path, replacements, :filename => filename)\n end",
"def init\n super\n @parser = Nokogiri::XML::SAX::Parser.new(self)\n end",
"def process(exp)\n return nil if exp.nil?\n\n result = nil\n\n type = exp.first\n raise \"type should be a Symbol, not: #{exp.first.inspect}\" unless\n Symbol === type\n\n in_context type do\n # now do a pass with the real processor (or generic)\n meth = @processors[type]\n if meth then\n if $DEBUG\n result = error_handler(type) do\n self.send(meth, exp)\n end\n else\n result = self.send(meth, exp)\n end\n\n else\n result = self.process_default(exp)\n end\n end\n \n raise SexpTypeError, \"Result must be a #{@expected}, was #{result.class}:#{result.inspect}\" unless @expected === result\n \n result\n end",
"def initialize(node)\n\t\t\t@node = node\n\t\t\t@name = @node[:macro]\n\t\t\t@value = @node[:value]\n\t\t\t@source = @node[:source]\n\t\t\t@escaped_pipe = '‡‡‡‡‡ESCAPED¤PIPE‡‡‡‡‡'\n\t\tend",
"def initialize(configure, form)\n @processors = []\n @configure = configure\n @form = form\n @descent = Processor::Descend.new(self)\n @buffer = []\n @options = { headers: [] }\n end",
"def register_processor(pattern, klass, replace_all: T.unsafe(nil)); end"
] |
[
"0.68719083",
"0.67864865",
"0.6003468",
"0.5708315",
"0.56322914",
"0.5605215",
"0.55952346",
"0.558298",
"0.539174",
"0.53711504",
"0.52841204",
"0.5227974",
"0.5194748",
"0.5193247",
"0.5148749",
"0.5145704",
"0.51257926",
"0.5111365",
"0.5039571",
"0.50331455",
"0.50206196",
"0.50086355",
"0.49871495",
"0.4982861",
"0.49726468",
"0.49628827",
"0.4944156",
"0.49317834",
"0.493094",
"0.49169883",
"0.49097064",
"0.49026972",
"0.49013993",
"0.48831028",
"0.4881985",
"0.48425272",
"0.4816736",
"0.48139477",
"0.48101205",
"0.4809399",
"0.48093352",
"0.4806935",
"0.48057082",
"0.48017916",
"0.47871292",
"0.47845942",
"0.47794992",
"0.47793913",
"0.4766466",
"0.47620878",
"0.47620878",
"0.4750918",
"0.4750918",
"0.47432637",
"0.47422725",
"0.47297937",
"0.4708569",
"0.46931297",
"0.46923932",
"0.46921825",
"0.468925",
"0.4686894",
"0.46771637",
"0.46739107",
"0.46665373",
"0.4659843",
"0.4659166",
"0.46549875",
"0.46549374",
"0.46538228",
"0.46537077",
"0.46525738",
"0.464825",
"0.46454045",
"0.46449438",
"0.4644541",
"0.4634791",
"0.46347758",
"0.4631811",
"0.4631154",
"0.46295843",
"0.4619628",
"0.46095443",
"0.46029687",
"0.46027496",
"0.46008387",
"0.45957363",
"0.45944077",
"0.45924652",
"0.4590997",
"0.459054",
"0.45860153",
"0.45846042",
"0.45825002",
"0.45820028",
"0.45745608",
"0.45707262",
"0.4568642",
"0.4564034",
"0.45591336"
] |
0.69607973
|
0
|
Default Sexp processor. Invokes process_ methods matching the Sexp type given. Performs additional checks as specified by the initializer.
|
def process(exp)
return nil if exp.nil?
result = nil
type = exp.first
raise "type should be a Symbol, not: #{exp.first.inspect}" unless
Symbol === type
in_context type do
# now do a pass with the real processor (or generic)
meth = @processors[type]
if meth then
if $DEBUG
result = error_handler(type) do
self.send(meth, exp)
end
else
result = self.send(meth, exp)
end
else
result = self.process_default(exp)
end
end
raise SexpTypeError, "Result must be a #{@expected}, was #{result.class}:#{result.inspect}" unless @expected === result
result
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process exp\n return nil if exp.nil?\n\n unless Sexp === exp then\n raise SexpTypeError, \"exp must be a Sexp, was #{exp.class}:#{exp.inspect}\"\n end\n\n if self.context.empty? then\n p :rewriting unless debug.empty?\n exp = self.rewrite(exp)\n p :done_rewriting unless debug.empty?\n end\n\n unless @unsupported_checked then\n m = public_methods.grep(/^process_/) { |o| o.to_s.sub(/^process_/, \"\").to_sym }\n supported = m - (m - @unsupported)\n\n raise UnsupportedNodeError, \"#{supported.inspect} shouldn't be in @unsupported\" unless supported.empty?\n\n @unsupported_checked = true\n end\n\n result = self.expected.new\n\n type = exp.sexp_type\n raise \"type should be a Symbol, not: #{exp.first.inspect}\" unless\n Symbol === type\n\n in_context type do\n if @debug.key? type then\n str = exp.inspect\n puts \"// DEBUG:(original ): #{str}\" if str =~ @debug[type]\n end\n\n exp_orig = nil\n exp_orig = exp.deep_clone if $DEBUG or\n @debug.key? type or @exceptions.key?(type)\n\n raise UnsupportedNodeError, \"'#{type}' is not a supported node type\" if\n @unsupported.include? type\n\n # now do a pass with the real processor (or generic)\n meth = @processors[type] || @default_method\n if meth then\n\n if @warn_on_default and meth == @default_method then\n warn \"WARNING: Using default method #{meth} for #{type}\"\n end\n\n exp = exp.sexp_body if @auto_shift_type and meth != @default_method # HACK\n\n result = error_handler(type, exp_orig) {\n self.send meth, exp\n }\n\n if @debug.key? type then\n str = exp.inspect\n puts \"// DEBUG (processed): #{str}\" if str =~ @debug[type]\n end\n\n raise SexpTypeError, \"Result of #{type} must be a #{@expected}, was #{result.class}:#{result.inspect}\" unless\n @expected === result\n\n self.assert_empty(meth, exp, exp_orig) if @require_empty\n else\n unless @strict then\n until exp.empty? do\n sub_exp, *exp = exp # HACK\n sub_result = nil\n if Array === sub_exp then\n sub_result = error_handler(type, exp_orig) do\n process(sub_exp)\n end\n raise \"Result is a bad type\" unless Array === sub_exp\n raise \"Result does not have a type in front: #{sub_exp.inspect}\" unless\n Symbol === sub_exp.sexp_type unless\n sub_exp.empty?\n else\n sub_result = sub_exp\n end\n # result << sub_result\n result = result.class.new(*result, sub_result) # HACK\n end\n\n # NOTE: this is costly, but we are in the generic processor\n # so we shouldn't hit it too much with RubyToC stuff at least.\n result.c_type ||= exp.c_type if Sexp === exp and exp.respond_to?(:c_type)\n else\n msg = \"Bug! Unknown node-type #{type.inspect} to #{self.class}\"\n msg += \" in #{exp_orig.inspect} from #{caller.inspect}\" if $DEBUG\n raise UnknownNodeError, msg\n end\n end\n end\n\n result\n end",
"def process(exp)\n return nil if exp.nil?\n\n result = nil\n\n type = exp.first\n raise \"Type should be a Symbol, not: #{exp.first.inspect} in #{exp.inspect}\" unless Symbol === type\n\n in_context type do\n # now do a pass with the real processor (or generic)\n meth = @processors[type]\n if meth then\n result = self.send(meth, exp)\n else\n result = self.process_default(exp)\n end\n end\n\n raise SexpTypeError, \"Result must be a #{@expected}, was #{result.class}:#{result.inspect}\" unless @expected === result\n\n result\n end",
"def process(exp)\n @processor.process(exp)\n end",
"def initialize\n @expected = Sexp\n\n # we do this on an instance basis so we can subclass it for\n # different processors.\n @processors = {}\n @context = []\n\n public_methods.each do |name|\n if name.to_s.start_with? \"process_\" then\n @processors[name[8..-1].to_sym] = name.to_sym\n end\n end\n end",
"def process exp\n @processors.each do |processor|\n exp = processor.process(exp)\n end\n exp\n end",
"def initialize\n @expected = Sexp\n @processors = self.class.processors\n @context = []\n\n if @processors.empty?\n public_methods.each do |name|\n if name.to_s.start_with? \"process_\" then\n @processors[name[8..-1].to_sym] = name.to_sym\n end\n end\n end\n end",
"def initialize\n @default_method = nil\n @warn_on_default = true\n @auto_shift_type = false\n @strict = false\n @unsupported = [:alloca, :cfunc, :cref, :ifunc, :last, :memo,\n :newline, :opt_n, :method]\n @unsupported_checked = false\n @debug = {}\n @expected = Sexp\n @require_empty = true\n @exceptions = {}\n\n # we do this on an instance basis so we can subclass it for\n # different processors.\n @processors = self.class.processors\n @rewriters = self.class.rewriters\n @context = []\n\n if @processors.empty?\n public_methods.each do |name|\n case name\n when /^process_(.*)/ then\n @processors[$1.to_sym] = name.to_sym\n when /^rewrite_(.*)/ then\n @rewriters[$1.to_sym] = name.to_sym\n end\n end\n end\n end",
"def process_class exp\n exp\n end",
"def process_source exp, klass = nil, method = nil, template = nil\n @current_class = klass\n @current_method = method\n @current_template = template\n process exp\n end",
"def process_defn exp\n process_all exp.body\n end",
"def process_defn exp\n return exp unless @current_method\n process_all exp.body\n end",
"def processed_input!\n unknown_handling :process\n not_researched_handling :process\n self\n end",
"def process_defn exp\n exp.shift unless auto_shift_type # node type\n name = @sclass.empty? ? exp.shift : \"::#{exp.shift}\"\n\n in_method name, exp.file, exp.line, exp.line_max do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def process_sclass exp\n exp.shift unless auto_shift_type # node type\n in_sklass do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def process_class exp\n exp.shift unless auto_shift_type # node type\n in_klass exp.shift do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def valid_processors; end",
"def << processor\n raise ArgumentError, \"Can only add sexp processors\" unless\n SexpProcessor === processor || processor.respond_to?(:process)\n @processors << processor\n end",
"def process_iter exp\n process_default exp\n\n call = exp.block_call\n\n if call? call\n target = call.target\n method = call.method\n arg = exp.block_args.first_param\n block = exp.block\n\n # Check for e.g. Model.find.each do ... end\n if method == :each and arg and block and model = get_model_target(target)\n if arg.is_a? Symbol\n if model == target.target\n env[Sexp.new(:lvar, arg)] = Sexp.new(:call, model, :new)\n else\n env[Sexp.new(:lvar, arg)] = UNKNOWN_MODEL_CALL\n end\n\n process block if sexp? block\n end\n elsif FORM_METHODS.include? method\n if arg.is_a? Symbol\n env[Sexp.new(:lvar, arg)] = FORM_BUILDER_CALL\n\n process block if sexp? block\n end\n end\n end\n\n exp\n end",
"def process_input\n if @process == 'directory'\n process_directory\n elsif @process == 'file'\n process_compiled_file\n elsif @process == 'zip'\n process_zip_file\n elsif @process == 'zip-stream'\n process_zip_stream\n end\n end",
"def process_call exp\n return exp unless @current_class\n return exp if process_call_defn? exp\n\n target = exp.target\n if sexp? target\n target = process target\n end\n\n method = exp.method\n first_arg = exp.first_arg\n\n # Methods called inside class definition\n # like attr_* and other settings\n if @current_method.nil? and target.nil?\n if first_arg.nil?\n case method\n when :private, :protected, :public\n @visibility = method\n when :attr_accessible\n @current_class.set_attr_accessible\n else\n # ??\n end\n else\n case method\n when :include\n @current_class.add_include class_name(first_arg) if @current_class\n when :attr_accessible\n @current_class.set_attr_accessible exp\n when :attr_protected\n @current_class.set_attr_protected exp\n else\n if @current_class\n @current_class.add_option method, exp\n end\n end\n end\n\n exp\n else\n call = make_call target, method, process_all!(exp.args)\n call.line(exp.line)\n call\n end\n end",
"def processor=(_arg0); end",
"def process_module exp\n exp.shift unless auto_shift_type # node type\n in_klass exp.shift do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def process(*files) # TODO: rename from process - should act as SexpProcessor\n files.each do |file|\n warn \"Processing #{file}\" if option[:verbose]\n\n ext = File.extname(file).sub(/^\\./, \"\")\n ext = \"rb\" if ext.nil? || ext.empty?\n msg = \"process_#{ext}\"\n\n unless respond_to? msg then\n warn \" Unknown file type: #{ext}, defaulting to ruby\"\n msg = \"process_rb\"\n end\n\n begin\n sexp = begin\n send msg, file\n rescue => e\n warn \" #{e.message.strip}\"\n warn \" skipping #{file}\"\n nil\n end\n\n next unless sexp\n\n process_sexp sexp\n rescue SyntaxError => e\n warn \" skipping #{file}: #{e.message}\"\n end\n end\n end",
"def processes(*types)\n types.each do |type|\n raise 'processor already registered for type %s'%type if @@processor_registry[type]\n @@processor_registry[type] = self\n end\n\n @allowed_command_types ||= []\n @allowed_command_types.concat types\n end",
"def method_missing(symbol, *args)\n\t\t\t\tif(args == nil or args.length == 0)\n\t\t\t\t\tregex = Regexp.new(Regexp.escape(symbol.id2name))\n\t\t\t\t\treturn has_process?(regex)\n\t\t\t\tend\n\n\t\t\t\tsuper.method(symbol).call(args)\n\t\t\tend",
"def process_source exp, opts\n @current_class = opts[:class]\n @current_method = opts[:method]\n @current_template = opts[:template]\n @current_file = opts[:file]\n @current_call = nil\n process exp\n end",
"def register_processor(pattern, klass, replace_all: T.unsafe(nil)); end",
"def process_iter(exp)\n if exp.first.last == :lambda\n process_lambda_iter exp\n else\n process_regular_iter exp\n end\n end",
"def process_call(exp)\n receiver_node_type = exp.first.nil? ? nil : exp.first.first\n receiver = process exp.shift\n receiver = \"(#{receiver})\" if ASSIGN_NODES.include? receiver_node_type\n\n name = exp.shift\n args = []\n\n # this allows us to do both old and new sexp forms:\n exp.push(*exp.pop[1..-1]) if exp.size == 1 && exp.first.first == :arglist\n\n @calls.push name\n\n in_context :arglist do\n until exp.empty? do\n arg_type = exp.first.sexp_type\n is_empty_hash = (exp.first == s(:hash))\n arg = process exp.shift\n\n next if arg.empty?\n\n strip_hash = (arg_type == :hash and\n not BINARY.include? name and\n not is_empty_hash and\n (exp.empty? or exp.first.sexp_type == :splat))\n wrap_arg = Ruby2Ruby::ASSIGN_NODES.include? arg_type\n\n arg = arg[2..-3] if strip_hash\n arg = \"(#{arg})\" if wrap_arg\n\n args << arg\n end\n end\n\n case name\n when *BINARY then\n # CUSTOM\n \"#{receiver}#{name}#{args.join(', ')}\"\n when :[] then\n receiver ||= \"self\"\n \"#{receiver}[#{args.join(', ')}]\"\n when :[]= then\n receiver ||= \"self\"\n rhs = args.pop\n \"#{receiver}[#{args.join(', ')}] = #{rhs}\"\n when :\"-@\" then\n \"-#{receiver}\"\n when :\"+@\" then\n \"+#{receiver}\"\n # CUSTOM\n when :lambda then\n '->'\n # CUSTOM\n when :call then\n args = if args.empty?\n nil\n elsif args\n args.join(',')\n end\n\n \"#{receiver}[#{args}]\"\n else\n args = nil if args.empty?\n\n # CUSTOM\n args = if args and args.size == 1\n # It's safe to map a single arg to be spaced from\n # the receiver w/out parens in this context\n \" #{ args.first }\"\n elsif args\n \"(#{args.join(', ')})\"\n end\n\n receiver = \"#{receiver}.\" if receiver\n\n \"#{receiver}#{name}#{args}\"\n end\n ensure\n @calls.pop\n end",
"def process(*args)\n new.process(*args)\n end",
"def process(*)\n end",
"def process(*)\n end",
"def process(*)\n end",
"def processed_smser\n @processed_smser ||= @smser_class.new.tap do |smser|\n smser.process @action, *@args\n end\n end",
"def process_class exp\n if exp.class_name == :Application\n @inside_config = true\n process_all exp.body if sexp? exp.body\n @inside_config = false\n end\n\n exp\n end",
"def process(node)\n return if node.nil?\n return node unless node.respond_to?(:to_ast)\n\n node = node.to_ast\n\n # Invoke a specific handler\n on_handler = :\"on_#{node.type}\"\n if respond_to? on_handler\n new_node = send on_handler, node\n else\n new_node = handler_missing(node)\n end\n\n new_node if new_node\n end",
"def process_dregx exp\n exp.each { |arg| process arg if sexp? arg }\n\n add_simple_call :railroader_regex_interp, exp\n\n exp\n end",
"def handle_generic(tokens, options); end",
"def handle_generic(tokens, options); end",
"def processor; end",
"def process_methdef exp\n meth_name = exp.method_name\n\n Brakeman.debug \"Processing #{@current_class}##{meth_name}\"\n\n #Skip if instructed to only process a specific method\n #(but don't skip if this method was called from elsewhere)\n return exp if @current_method.nil? and @only_method and @only_method != meth_name\n\n is_route = route? meth_name\n other_method = @current_method\n @current_method = meth_name\n @rendered = false if is_route\n\n meth_env do\n if is_route\n before_filter_list(@current_method, @current_class).each do |f|\n process_before_filter f\n end\n end\n\n process_all exp.body\n\n if is_route and not @rendered\n process_default_render exp\n end\n end\n\n @current_method = other_method\n exp\n end",
"def parse(node, *args, &block)\n new(*args) do |instance|\n processors.each do |name, processor|\n processor.call(instance, node)\n end\n \n if block_given?\n case block.arity\n when 1 then block.call(instance)\n else instance.instance_eval(&block)\n end\n end\n end\n end",
"def process(_cmd); raise NotImplementedError\n end",
"def process_defs exp\n exp.shift unless auto_shift_type # node type\n process exp.shift # recv\n in_method \"::#{exp.shift}\", exp.file, exp.line, exp.line_max do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def process_call(exp)\n receiver = exp.shift\n method = exp.shift\n args = exp.shift\n\n iter = get_iter()\n\n #\n # RubyJS::inline(\"str\")\n #\n # A different form of Javascript inline. We have this form\n # because ``-style Javascript-inline has a different esacping\n # of \\. Sometimes we want no escaping, so\n #\n # RubyJS::inline %q(...) could be used.\n #\n if receiver == [:const, :RubyJS] and method == :inline and\n args[0] == :array and args.size == 2 and args[1].size == 2 and args[1][0] == :str and iter.nil?\n raise if @want_expression\n return @model.interpolate(args[1][1])\n end\n\n str = \n if $RUBYJS__OPTS.include?('OptimizeArithOps') and %w(> >= < <= + - * /).include?(method.to_s) and\n iter.nil? and args and args[0] == :array and args.size == 2\n without_result do \n want_expression do\n \"(#{process(receiver)})#{method.to_s}(#{process(args[1])})\"\n end\n end\n else\n without_result do \n generate_method_call_receiver_exp(receiver, method, iter, args)\n end\n end\n resultify(str)\n end",
"def checkExp(exp, symbs, tmap, c)\n case exp.expr\n when 'identifier'\n #if symbol is not in table the identifier is undeclared\n if not symbs.include?(exp.args.name)\n puts \"ERROR: #{exp.args.line}: Type-Check: Undeclared identifier #{exp.args.name}\"\n exit\n else\n exp.type = symbs[exp.args.name]\n end\n\n when 'assign'\n checkExp(exp.args[1], symbs, tmap, c)\n #cannot assign to self\n if exp.args[0].name == 'self'\n puts \"ERROR: #{exp.line}: Type-Check: Cannot assign to self\"\n exit\n #if assignor not subclass of identifier\n elsif not tmap.isChild(exp.args[1].type, symbs[exp.args[0].name], c)\n puts \"ERROR: #{exp.line}: Type-Check: Bad assignment, #{exp.args[1].type} does not conform to #{symbs[exp.args[0].name]}\"\n exit\n else\n exp.type = exp.args[1].type\n end\n\n when 'true', 'false'\n exp.type = 'Bool'\n\n when 'integer'\n exp.type = 'Int'\n\n when 'string'\n exp.type = 'String'\n\n when 'new'\n #all types, including SELF_TYPE, are allowed here\n exp.type = exp.args.name\n\n when 'self_dispatch'\n checkDispatch(exp, symbs, tmap, c, nil, nil, exp.args[0], exp.args[1])\n\n when 'dynamic_dispatch'\n checkDispatch(exp, symbs, tmap, c, exp.args[0], nil, exp.args[1], exp.args[2])\n\n when 'static_dispatch'\n checkDispatch(exp, symbs, tmap, c, exp.args[0], exp.args[1], exp.args[2], exp.args[3])\n\n when 'if'\n checkExp(exp.args[0], symbs, tmap, c)\n # ERROR on non-Bool condition\n if exp.args[0].type != 'Bool'\n puts \"ERROR: #{exp.line}: Type-Check: Non-boolean condition\"\n exit\n end\n checkExp(exp.args[1], symbs, tmap, c)\n checkExp(exp.args[2], symbs, tmap, c)\n exp.type = tmap.lub(exp.args[1].type, exp.args[2].type, c)\n\n when 'block'\n exp.args.each do |e|\n checkExp(e, symbs, tmap, c)\n end\n exp.type = exp.args[exp.args.size-1].type\n\n when 'let'\n nsymbs = symbs.clone()\n # Bind each let binding\n exp.args[0].each do |bind|\n # can't bind self\n if bind.name.name == 'self'\n puts \"ERROR: #{exp.line}: Type-Check: Can't bind self in a let\"\n exit\n end\n # If there is an initializer, type check it\n if not bind.init.nil?\n checkExp(bind.init, nsymbs, tmap, c)\n if not tmap.isChild(bind.init.type, bind.type.name, c)\n puts \"ERROR: #{exp.line}: Type-Check: Initializer does not conform to declared type\"\n exit\n end\n end\n nsymbs[bind.name.name] = bind.type.name\n end\n checkExp(exp.args[1], nsymbs, tmap, c)\n exp.type = exp.args[1].type\n\n when 'case'\n checkExp(exp.args[0], symbs, tmap, c)\n nsymbs = symbs.clone()\n mtype = nil\n usedTypes = []\n #iterate over all case branches\n exp.args[1].each do |bind|\n #prevent self binding\n if bind.name.name == 'self'\n puts \"ERROR: #{bind.name.line}: Type-Check: Can't bind self in case expression\"\n exit\n end\n #prevent case checking for SELF_TYPE\n if bind.type.name == 'SELF_TYPE'\n puts \"ERROR: #{bind.type.line}: Type-Check: Can't use SELF_TYPE as case branch type\"\n exit\n end\n #prevent multiple branches checking same type\n if usedTypes.include? bind.type.name\n puts \"ERROR: #{bind.type.line}: Type-Check: #{bind.type.name} used twice as case branch type\"\n exit\n end\n usedTypes.push(bind.type.name)\n #bind case var and type check the branch\n nsymbs[bind.name.name] = bind.type.name\n checkExp(bind.body, nsymbs, tmap, c)\n #remove binding so it's not visible to other branches\n nsymbs[bind.name.name] = symbs[bind.name.name]\n #final type of case is least upper bound of all branch expressions\n if mtype.nil?\n mtype = bind.body.type\n else\n mtype = tmap.lub(mtype, bind.body.type, c)\n end\n end\n exp.type = mtype\n\n when 'while'\n checkExp(exp.args[0], symbs, tmap, c)\n #predicate of while must be Bool\n if exp.args[0].type != 'Bool'\n puts \"ERROR: #{exp.line}: Type-Check: Non-boolean loop condition\"\n exit\n end\n checkExp(exp.args[1], symbs, tmap, c)\n exp.type = 'Object'\n\n when 'isvoid'\n checkExp(exp.args, symbs, tmap, c)\n exp.type = 'Bool'\n\n when 'not'\n checkExp(exp.args, symbs, tmap, c)\n #not only operates on Bool\n if exp.args.type != 'Bool'\n puts \"ERROR: #{exp.line}: Type-Check: Can't perform not on #{exp.type}, expected Bool\"\n end\n exp.type = 'Bool'\n\n when 'negate'\n checkExp(exp.args, symbs, tmap, c)\n #negate only operates on Int\n if exp.args.type != 'Int'\n puts \"ERROR: #{exp.line}: Type-Check: Can't negate #{exp.type}, expected Int\"\n end\n exp.type = 'Int'\n\n when 'plus', 'minus', 'times', 'divide'\n checkExp(exp.args[0], symbs, tmap, c)\n checkExp(exp.args[1], symbs, tmap, c)\n #args must be Int for arithmetic\n if not (exp.args[0].type == \"Int\" and exp.args[1].type == \"Int\")\n puts \"ERROR: #{exp.line}: Type-Check: Non-integer arithmetic\"\n exit\n end\n exp.type = \"Int\"\n\n when 'eq', 'lt', 'le'\n checkExp(exp.args[0], symbs, tmap, c)\n checkExp(exp.args[1], symbs, tmap, c)\n #if one arg is Int, String, or Bool, the other must be same type\n #otherwise, the two args can be of any type\n sameComp = ['Int', 'String', 'Bool']\n if not ((sameComp.include?(exp.args[0].type) \\\n and sameComp.include?(exp.args[1].type) \\\n and exp.args[0].type == exp.args[1].type) \\\n or (not sameComp.include?(exp.args[0].type) \\\n and not sameComp.include?(exp.args[1].type)))\n puts \"ERROR: #{exp.line}: Type-Check: Can't compare #{exp.args[0].type} and #{exp.args[1].type}\"\n exit\n end\n exp.type = 'Bool'\n\n when 'internal'\n # do nothing\n\n else\n puts \"Unhandled expression: #{exp.expr}\"\n\n end\nend",
"def process_iter(exp)\n begin\n type_sexp, call_sexp, arg_list_sexp, block_sexp = exp.map { |inner| \n process_inner_expr(inner) \n }\n if arg_list_sexp.nil? and (anaphor = direct_anaphor_reference_contained(prune(block_sexp)))\n #puts anaphor\n arg_list_sexp = s(:lasgn, anaphor)\n block_sexp = convert_anaphor_references(block_sexp, anaphor)\n end\n s(\n *[type_sexp, call_sexp, arg_list_sexp, block_sexp].map { |inner| \n process_inner_expr(inner) \n }\n )\n rescue Exception\n puts \"Exception for #{[type_sexp, call_sexp, arg_list_sexp, block_sexp].to_a.inspect}\"\n ensure\n exp.clear\n end\n end",
"def process(parser)\n end",
"def process_attributes!\n if !@current_command_type.nil?\n @expression = Confinicky::Parsers::Expression.new(statement: @line.gsub(/\\A#{@current_command_type} /,\"\"))\n @name = @expression.name\n @value = @expression.value\n end\n end",
"def processor(params = T.unsafe(nil)); end",
"def process(source)\r\n save, @parser, start_depth = @parser, Parser.new(source), @context.depth\r\n\r\n due_process\r\n @context.check_depth(start_depth)\r\n verify_casts_cleared\r\n\r\n @parser = save\r\n end",
"def process\n klass.new(request).process\n end",
"def process_token(token)\n token_type = token.type.to_s\n method = \"process_#{token_type}\"\n\n return @stack << token unless respond_to? method, true\n\n @line_num = @lexer.line_num if @current_scope.type == Scope::TYPE_MAIN\n\n Util::Logger.debug(Util::Options::DEBUG_2) { Util::I18n.t('interpreter.process').lyellow + token_type }\n send method, token\n end",
"def process_regular_iter(exp)\n iter = process exp.shift\n args = exp.shift\n body = exp.empty? ? nil : process(exp.shift)\n\n args = case args\n when 0 then\n ' ||'\n else\n a = process(args)[1..-2]\n a = \"|#{a}|\" unless a.empty?\n a\n end\n\n b, e = if iter == \"END\" then\n [ \"{\", \"}\" ]\n else\n [ \"do\", \"end\" ]\n end\n\n iter.sub!(/\\(\\)$/, '')\n\n # REFACTOR: ugh\n result = []\n # CUSTOM\n result << \"#{iter}{\"\n result << args\n if body then\n # CUSTOM\n result << body.strip\n else\n # CUSTOM\n result << ''\n end\n result << \"}\"\n result = result.join\n return result if result !~ /\\n/ and result.size < LINE_LENGTH\n\n result = []\n result << \"#{iter} #{b}\"\n result << args\n result << \"\\n\"\n if body then\n result << indent(body.strip)\n result << \"\\n\"\n end\n result << e\n result.join\n end",
"def process(*x)\n r.send(self.class_as_function).call(*x)\n end",
"def process(node)\n return if node.nil?\n\n @_on_handler_cache ||= {}\n type = node.type\n\n on_handler = @_on_handler_cache[type] ||= begin\n handler = :\"on_#{type}\"\n handler = :handler_missing unless respond_to?(handler)\n handler\n end\n\n send(on_handler, node) || node\n end",
"def process_iter(exp)\n Sexp.from_array([:iter, process(exp.shift), process(exp.shift), process(exp.shift)])\n end",
"def process(node)\n return node unless node.is_a?(Parser::AST::Node)\n\n process_node(node)\n end",
"def call(input)\n evaluator_klass.new(self, input)\n end",
"def process_iter(exp) # :nodoc:\n iter = process exp.shift\n args = exp.shift\n body = exp.empty? ? nil : process(exp.shift)\n\n args = case args\n when 0 then\n iter = '->' # no args? let's use a stubby\n ''\n else\n a = process(args)[1..-2]\n a = \" |#{a}|\" unless a.empty?\n a\n end\n \n b, e = if iter == \"END\" then\n [ \"{\", \"}\" ]\n else\n [ \"do\", \"end\" ]\n end\n\n iter.sub!(/\\(\\)$/, '')\n\n # REFACTOR: ugh\n result = []\n result << \"#{iter} {\"\n result << args\n if body then\n result << \" #{body.strip} \"\n else\n result << ' '\n end\n result << \"}\"\n result = result.join\n return result if result !~ /\\n/ and result.size < LINE_LENGTH\n\n result = []\n result << \"#{iter} #{b}\"\n result << args\n result << \"\\n\"\n if body then\n result << indent(body.strip)\n result << \"\\n\"\n end\n result << e\n result.join\n end",
"def process!(name, *args)\n app.get_processor(name).call(self, *args)\n self\n end",
"def process_render exp\n process exp.last if sexp? exp.last\n\n add_simple_call :render, exp\n\n exp\n end",
"def process_lit(exp)\n exp.shift\n value = exp.shift\n\n if value.is_a?(Numeric) && !@ignore.include?(value)\n @file.magic_numbers << MagicNumber.new(:value => value, :line => exp.line)\n end\n\n s()\n end",
"def method_missing(meth, *args, &block)\n if args.empty? && !block_given? && (match = /\\Ato_(\\w+)\\Z/.match(meth.to_s))\n begin\n convert_to(match[1])\n rescue ExpressionError\n super(meth, *args, &block)\n end\n else\n super(meth, *args, &block)\n end\n end",
"def process_node(node)\n method(:process).super_method.call(node)\n end",
"def valid_processors\n [:kramdown] + third_party_processors\n end",
"def process_for(exp)\n receiver = exp.shift\n asgn = exp.shift\n block = exp.shift\n\n new_exp = [:iter,\n [:call, receiver, :each],\n asgn,\n block]\n\n process(new_exp)\n end",
"def process\n raise NotImplementedError\n end",
"def process\n raise NotImplementedError\n end",
"def process_defn(exp)\n make_function exp\n end",
"def run\n handlers.each do |info, handler|\n matches = matches_options?(info[:type], info[:regexp])\n break if matches && handler.call(options)\n end\n end",
"def process_sexp pt\n filter_sexp(pt).deep_each do |node|\n next :skip if node.none? { |sub| Sexp === sub }\n next :skip if node.mass < self.mass_threshold\n\n self.hashes[node.structural_hash] << node\n\n process_fuzzy node, option[:fuzzy] if option[:fuzzy]\n end\n end",
"def process\n input_text = read_input_file\n s_exp = parse_to_s_expression(input_text)\n write_s_exp_file(s_exp)\n dot_data = get_method_calls(s_exp)\n write_dot_file(dot_data)\n end",
"def process_call exp\n target = get_target exp.target\n method = exp.method\n\n process_call_args exp\n\n if match(@find_targets, target) and match(@find_methods, method)\n\n if @current_template\n @calls << Sexp.new(:result, @current_template, exp).line(exp.line)\n else\n @calls << Sexp.new(:result, @current_module, @current_class, @current_method, exp).line(exp.line)\n end\n\n end\n\n # Normally FindCall won't match a method invocation that is the target of\n # another call, such as:\n #\n # User.find(:first, :conditions => \"user = '#{params['user']}').name\n #\n # A search for User.find will not match this unless @in_depth is true.\n if @in_depth and call? exp.target\n process exp.target\n end\n\n exp\n end",
"def process_call(exp)\n receiver = exp.shift\n name = exp.shift\n\n receiver = process receiver\n\n case name\n # TODO: these need to be numerics\n # emacs gets confused by :/ below, need quotes to fix indentation\n when :==, :<, :>, :<=, :>=, :-, :+, :*, :\"/\", :% then\n args = process exp.shift[1]\n return \"#{receiver} #{name} #{args}\"\n when :<=>\n args = process exp.shift[1]\n return \"RB_COMPARE(#{receiver}, #{args})\"\n when :equal?\n args = process exp.shift\n return \"#{receiver} == #{args}\" # equal? == address equality\n when :[]\n args = process exp.shift\n return \"#{receiver}[#{args}]\"\n when :nil?\n exp.clear\n return receiver.to_s\n else\n args = process exp.shift\n\n if receiver.nil? and args.nil? then\n args = \"\"\n elsif receiver.nil? then\n # nothing to do \n elsif args.nil? or args.empty? then\n args = receiver\n else\n args = \"#{receiver}, #{args}\"\n end\n\n args = '' if args == 'rb_ary_new()' # HACK\n\n return \"#{name}(#{args})\"\n end\n end",
"def _if_process(value)\n if check_type.to_s.downcase == 'process'\n value\n else\n nil\n end\n end",
"def process(raw)\n params = self.class.parse(raw)\n if valid?(params)\n transform(params)\n else\n raise ForgedRequest\n end\n end",
"def process_defn(exp)\n raise if @result_name\n method_name = exp.shift || raise\n exp = exp.shift || raise\n\n method_body = want_result do\n case exp.first\n when :ivar\n process(s(:block, exp))\n when :attrset\n process(s(:block, s(:args, :_), s(:iasgn, exp[1], s(:lvar, :_))))\n when :scope, :block, :fbody\n process(exp)\n else\n raise\n end\n end\n\n str = \"\"\n\n if @argument_variables.empty?\n str << \"function(){\"\n else\n args_str = ([block_name()] + @arguments_no_splat).join(\",\")\n str << \"function(#{args_str}){\"\n end\n\n raise if @local_variables.include?(@model.encode_self)\n raise if @argument_variables.include?(@model.encode_self)\n\n #\n # Add \"self\" to the local variables\n #\n @local_variables.add(@model.encode_self)\n @local_variables_need_no_initialization.add(@model.encode_self)\n\n #\n # declare local variables (except arguments)\n #\n to_declare = (@local_variables - @argument_variables).to_a\n to_declare << @result_name if @result_name\n unless to_declare.empty?\n str << \"var \" + to_declare.join(\",\") + sep()\n end\n\n #\n # initialize all local variables (that need initialization) to nil\n #\n to_initialize = (@local_variables - @argument_variables - @local_variables_need_no_initialization).to_a\n to_initialize << @result_name if @result_name\n unless to_initialize.empty?\n str << to_initialize.join(\"=\")\n str << \"=#{@model.encode_nil}#{sep()}\"\n end\n\n #\n # initialize \"self\"\n #\n str << \"#{@model.encode_self}=this#{sep()}\"\n\n #\n # If a block argument is given (&block) convert it to nil if it is\n # undefined. \n #\n if @block_arg_name\n str << \"#{@block_arg_name}=#{block_name()}==null?#{@model.encode_nil}:#{block_name()}#{sep()}\"\n end\n\n #\n # generate initialization code for each read instance variable\n #\n @read_instance_variables.each do |iv|\n str << \"if(#{@model.encode_self}.#{iv}==null)#{@model.encode_self}.#{iv}=#{@model.encode_nil}#{sep()}\"\n end\n\n # \n # Used in a zsuper call to refer to the methods \"arguments\"\n # \"arguments\" itself does not work due to iterators using functions.\n if @arguments_name\n str << \"var #{@arguments_name}=arguments#{sep()}\"\n end\n\n method_body << \"#{sep()}return #{@result_name}\" if @result_name\n\n if @iterators_used\n str << \"try{\" \n str << method_body \n\n #\n # Declare variable x?\n # No, catch introduced a new scope, so we don't have to\n # use a local or temporary variable here! \n #\n x = exception_name()\n iter_jump = @model.encode_globalattr(\"iter_jump\")\n return_value = @model.encode_attr(\"return_value\")\n scope = @model.encode_attr(\"scope\")\n uid = unique_method_scope()\n\n str << \"}catch(#{x}){\"\n # scope == null or scope == uid\n str << \"if(#{x} instanceof #{iter_jump} && (!#{x}.#{scope} || #{x}.#{scope}==#{uid}))return #{x}.#{return_value}#{sep()}\"\n str << \"throw(#{x})}\"\n else\n str << method_body\n end\n\n str << \"}\"\n\n return str\n end",
"def process(input)\n\t\tr = processString(input) if input.is_a?(String)\n\t\tr = processArray(input) if input.is_a?(Array)\n\t\tr[:type] = 'error' if !r.has_key?(:result) || r[:result].nil?\n\t\tr.delete(:result) if r[:type] == 'error'\n\n\t\treturn r\n\tend",
"def handle(*types); end",
"def process(&block)\n @processor = block\n self\n end",
"def process(cmds, vars)\n case @type\n when :protocol\n process_protocol(cmds, vars)\n\n when :portrange\n process_portrange(cmds, vars)\n\n when :icmp_type\n process_icmp_type(cmds, vars)\n\n when :icmpv6_type\n process_icmpv6_type(cmds, vars)\n\n when :net\n process_net(cmds, vars)\n\n when :net_portrange\n process_net_portrange(cmds, vars)\n\n when :net_icmp_type\n process_net_icmp_type(cmds, vars)\n\n when :net_icmpv6_type\n process_net_icmpv6_type(cmds, vars)\n end\n end",
"def process_line ln, line\r\n # convert inline processor\r\n while /\\#\\#(?<p_>[A-Z][_A-Z0-9]*)(:\\s*(?<a_>.+))?\\#\\#/ =~ line\r\n rst = conv_inline(p_, a_, ln, line)\r\n raise \"do not use '##.*##' inside your inline processor converting result\" if rst =~ /\\#\\#[A-Z][_A-Z0-9]*(:\\s*.+)?\\#\\#/\r\n line.sub!(/\\#\\#[A-Z][_A-Z0-9]*(:\\s*.+)?\\#\\#/, rst)\r\n end\r\n \r\n # create a token, with processor name\r\n token = self.tokenize(ln, line)\r\n # based on the the token indent level, close token stack if any\r\n self.close_stack token.indent_level\r\n \r\n # add token and then close it unless it opens a block\r\n @token_stack << token\r\n self.close_stack token.indent_level unless token.block_open?\r\n\r\n self # for methods chain\r\n end",
"def process_params(exp)\n _, normal, defaults, splat, rest, kwargs, doublesplat, block = exp.shift 8\n\n args =\n handle_normal_arguments(normal) +\n handle_default_arguments(defaults) +\n handle_splat(splat) +\n handle_normal_arguments(rest) +\n handle_kwargs(kwargs) +\n handle_double_splat(doublesplat) +\n handle_block_argument(block)\n\n s(:args, *args)\n end",
"def checkDispatch(exp, symbs, tmap, c, callobj, statid, methid, args)\n #get type of the caller\n calltype = nil\n if callobj.nil?\n calltype = 'SELF_TYPE'\n else\n # Type check caller expression\n checkExp(callobj, symbs, tmap, c)\n calltype = callobj.type\n end\n\n #get class name to look up in implementation map\n methtype = calltype\n #if caller is SELF_TYPE, we look up enclosing class\n if calltype == 'SELF_TYPE'\n methtype = c\n end\n #if doing static dispatch, we look up the specified class\n if not statid.nil?\n # ERROR if caller expression does not conform to static type specified\n if not tmap.isChild(calltype, statid.name, c)\n puts \"ERROR: #{exp.line}: Type-Check: Caller type #{calltype} does not conform to static type #{statid.name}\"\n exit\n end\n methtype = statid.name\n end\n\n # Find method in imap\n meth=nil\n if not tmap.imap[methtype].nil?\n tmap.imap[methtype].each do |_,m|\n if m.name.name == methid.name\n meth = m\n break\n end\n end\n end\n\n # Method not found\n if meth.nil?\n puts \"ERROR: #{methid.line}: Type-Check: Unknown method \\\"#{methtype}@#{methid.name}\\\"\"\n exit\n end\n\n # Check number of arguments\n if meth.formals.size != args.size\n puts \"ERROR: #{exp.line}: Type-Check: Invalid number of arguments, got #{args.size} expected #{meth.formals.size}\"\n exit\n end\n\n # Type check each argument\n args.each do |subexp|\n checkExp(subexp, symbs, tmap, c)\n end\n\n # Check actuals against formals\n meth.formals.zip(args) do |formal, actual|\n if not tmap.isChild(actual.type, formal[1].name, c)\n puts \"ERROR: #{exp.line}: Type-Check: Invalid actual parameter type, got #{actual.type} expected #{formal[1].name}\"\n exit\n end\n end\n\n #if return type of method is SELF_TYPE, dispatch expression's type is type of the caller\n if meth.type.name == 'SELF_TYPE'\n exp.type = calltype\n else\n exp.type = meth.type.name\n end\nend",
"def process_static(exp)\n return exp.shift\n end",
"def processors(*args)\n preprocessors(*args)\n end",
"def process_default(exp)\n until exp.size == 0\n exp.shift\n end\n s()\n end",
"def process(ast, scope = nil)\n case Array(ast)[0]\n when :module, :class\n name = ast[1]\n new_scope = Scope.new(name, ast[2])\n\n if scope\n scope.scopes[name] = new_scope\n elsif @scopes[name]\n new_scope = @scopes[name]\n else\n @scopes[name] = new_scope\n end\n\n process(ast[3], new_scope)\n when :imethod\n ast.shift\n if !scope\n scope = (@scopes[:main] ||= Scope.new(:main))\n end\n scope.instance_methods << Method.new(*ast)\n when :cmethod\n ast.shift\n if !scope\n scope = (@scopes[:main] ||= Scope.new(:main))\n end\n scope.class_methods << Method.new(*ast)\n when Array\n ast.map { |a| process(a, scope) }\n end\n end",
"def process(env)\n raise \"Please ensure you call init before processing\" unless inited?\n @processor.process(env)\n end",
"def call(input)\n process(input)\n end",
"def process_args(exp)\n raise if @want_expression\n\n args = []\n default_values = nil\n\n loop do\n arg = exp.shift\n break if arg.nil?\n if arg.is_a?(Symbol)\n args << arg\n else\n raise unless exp.empty?\n default_values = arg\n end\n end\n\n args.each do |arg|\n arg = arg.to_s\n if arg[0,1] == '*'\n raise if @argument_splat\n @argument_splat = @model.encode_local_variable(arg[1..-1])\n # argument_splat is not an argument in the function's argument list\n @local_variables.add(@argument_splat) \n else\n v = @model.encode_local_variable(arg)\n @arguments_no_splat << v \n @local_variables.add(v)\n @argument_variables.add(v)\n end\n end\n\n # that's not the correct arity, but we decrease it by one for each\n # optional argument.\n min_arity = @arguments_no_splat.size\n max_arity = @arguments_no_splat.size\n\n str = \"\"\n\n #\n # Generate code for the default values of arguments. We check\n # whether a argument has been assigned a value, if not (== null or == undefined), \n # then we assign the default value.\n #\n # NOTE: A check to ==null also returns true if the argument is undefined.\n #\n if default_values\n raise unless default_values[0] == :block\n default_values[1..-1].each do |dv|\n min_arity -= 1\n raise unless dv[0] == :lasgn\n raise unless dv.size == 3\n arg = @model.encode_local_variable(dv[1])\n @local_variables.add(arg)\n @argument_variables.add(arg)\n value = dv[2]\n\n str << \"if(#{arg}==null)\"\n str << \"#{arg}=\"\n str << want_expression do process(value) end\n str << sep()\n end\n end\n\n # now as we know the min_arity, we prepend an arity check before the\n # code generated above.\n str2 = \"\"\n\n if @argument_splat\n # max_arity == infinity => no check\n\n if min_arity == 0\n # min_arity == infinity as well => we need no check\n else\n # +1 because we have a block argument anyway.\n str2 << \"if(arguments.length<#{min_arity+1})#{throw_argument_error(min_arity)}#{sep()}\"\n end\n else\n if min_arity == 0\n # can't be less than 0 arguments anyway! => no check\n str2 << \"if(arguments.length>#{max_arity+1})#{throw_argument_error(max_arity)}#{sep()}\"\n else\n if min_arity == max_arity\n str2 << \"if(arguments.length!=#{min_arity+1})#{throw_argument_error(min_arity)}#{sep()}\"\n else\n str2 << \"if(arguments.length<#{min_arity+1})#{throw_argument_error(min_arity)}#{sep()}\"\n str2 << \"if(arguments.length>#{max_arity+1})#{throw_argument_error(max_arity)}#{sep()}\"\n end\n end\n end\n\n # NoArgumentArityChecks disable argument arity checks\n if $RUBYJS__OPTS.include?('NoArgumentArityChecks')\n else\n # prepend\n str = str2 + str\n end\n\n if @argument_splat\n # construct the code to initialize the splat argument. \n # unluckily the arguments object is not an array, instead it's a\n # special object that has only the length() and [] methods. There\n # is no way to convert it to an array, except looping over each\n # value and pushing the value into a new array.\n # FIXME: variable \"i\"\n str << \"#{@argument_splat}=[]#{sep()}\"\n @local_variables_need_no_initialization.add(@argument_splat)\n with_temporary_variable do |i|\n @local_variables_need_no_initialization.add(i)\n str << \"for(#{i}=#{@arguments_no_splat.size+1};#{i}<arguments.length;#{i}++)#{@argument_splat}.push(arguments[#{i}])#{sep()}\"\n end\n end\n \n return str \n end",
"def process_attrasgn exp\n process_call exp\n end",
"def process_attrasgn exp\n process_call exp\n end",
"def run input, params = {}\n @klass.new(input, options).process\n end",
"def method_missing(method, *args)\n args = [:process, method.to_s] + args\n self.class.start(args)\n end",
"def process_case(exp)\n obj = exp.shift \n \n with_temporary_variable do |tmp|\n @local_variables_need_no_initialization.add(tmp)\n asgn = want_expression do\n \"#{tmp}=#{process(obj)}\"\n end\n\n new_exp = current_exp = []\n\n while not exp.empty?\n _when = exp.shift\n if _when.nil? or _when.first != :when\n # last element\n raise exp.inspect unless exp.empty?\n current_exp << _when\n else\n conds = _when[1]\n block = _when[2]\n raise unless conds.first == :array\n\n cond = multi_or(conds[1..-1].map {|c| [:call, c, :===, [:array, [:special_inline_js_value, tmp]]] })\n\n my_exp = [:if, cond, block]\n\n current_exp << my_exp\n current_exp = my_exp\n end\n end\n\n if_code = process(new_exp.first)\n\n code = \n if @want_expression \n \"(#{asgn}, #{if_code})\"\n else\n \"#{asgn}#{sep()}#{if_code}\" \n end\n\n code\n end\n end",
"def process(value, context)\n value, error = cast(value, context)\n\n Input.new(self, value: value, error: error)\n end",
"def dispatch(instance, calling_scope, args)\n tc = Puppet::Pops::Types::TypeCalculator\n actual = tc.infer_set(args)\n found = @dispatchers.find { |d| tc.assignable?(d.type, actual) }\n if found\n found.invoke(instance, calling_scope, args)\n else\n raise ArgumentError, \"function '#{instance.class.name}' called with mis-matched arguments\\n#{diff_string(instance.class.name, actual)}\"\n end\n end",
"def process!(new_file=nil)\n if enable_processing\n self.class.processors.each do |method, args|\n self.send(method, *args)\n end\n end\n end"
] |
[
"0.7451764",
"0.7434105",
"0.6505911",
"0.6460087",
"0.6388599",
"0.63822263",
"0.6163957",
"0.612368",
"0.6037836",
"0.5958047",
"0.58640337",
"0.5844334",
"0.5833821",
"0.57282895",
"0.56586176",
"0.5653573",
"0.5579693",
"0.553309",
"0.55093855",
"0.5496367",
"0.54887104",
"0.5450114",
"0.5403261",
"0.5379079",
"0.535519",
"0.53342897",
"0.5328176",
"0.53038037",
"0.52897567",
"0.5252144",
"0.5206053",
"0.5190706",
"0.5190706",
"0.5184486",
"0.51662135",
"0.5140107",
"0.5121287",
"0.51041317",
"0.51041317",
"0.5102085",
"0.50983846",
"0.5087883",
"0.5079111",
"0.5071135",
"0.5068798",
"0.5055624",
"0.50507927",
"0.50381446",
"0.50221276",
"0.50170636",
"0.50085455",
"0.50005585",
"0.49995935",
"0.49960124",
"0.49932122",
"0.49829084",
"0.4966916",
"0.49528185",
"0.49421775",
"0.49409693",
"0.49324667",
"0.49283966",
"0.4924385",
"0.49057546",
"0.49024042",
"0.49010605",
"0.4900016",
"0.48991275",
"0.48991275",
"0.48911226",
"0.48910317",
"0.48796093",
"0.48706266",
"0.4869876",
"0.48644605",
"0.4835171",
"0.4833538",
"0.4828565",
"0.48261735",
"0.48019382",
"0.4798507",
"0.47885126",
"0.47855428",
"0.4781164",
"0.4777914",
"0.47644868",
"0.47602797",
"0.4759898",
"0.47558507",
"0.47548985",
"0.47470787",
"0.47429428",
"0.4739192",
"0.4739192",
"0.4738931",
"0.47375143",
"0.473398",
"0.47240523",
"0.47187752",
"0.47152194"
] |
0.75268567
|
0
|
A fairly generic processor for a dummy node. Dummy nodes are used when your processor is doing a complicated rewrite that replaces the current sexp with multiple sexps. Bogus Example: def process_something(exp) return s(:dummy, process(exp), s(:extra, 42)) end
|
def process_dummy(exp)
result = @expected.new(:dummy) rescue @expected.new
until exp.empty? do
result << self.process(exp.shift)
end
result
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_dummy exp\n result = @expected.new(:dummy) rescue @expected.new\n result << self.process(exp.shift) until exp.empty?\n result\n end",
"def process_dummy(exp)\n process_block(exp).chomp\n end",
"def process_defn exp\n exp.shift unless auto_shift_type # node type\n name = @sclass.empty? ? exp.shift : \"::#{exp.shift}\"\n\n in_method name, exp.file, exp.line, exp.line_max do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def process exp\n return nil if exp.nil?\n\n unless Sexp === exp then\n raise SexpTypeError, \"exp must be a Sexp, was #{exp.class}:#{exp.inspect}\"\n end\n\n if self.context.empty? then\n p :rewriting unless debug.empty?\n exp = self.rewrite(exp)\n p :done_rewriting unless debug.empty?\n end\n\n unless @unsupported_checked then\n m = public_methods.grep(/^process_/) { |o| o.to_s.sub(/^process_/, \"\").to_sym }\n supported = m - (m - @unsupported)\n\n raise UnsupportedNodeError, \"#{supported.inspect} shouldn't be in @unsupported\" unless supported.empty?\n\n @unsupported_checked = true\n end\n\n result = self.expected.new\n\n type = exp.sexp_type\n raise \"type should be a Symbol, not: #{exp.first.inspect}\" unless\n Symbol === type\n\n in_context type do\n if @debug.key? type then\n str = exp.inspect\n puts \"// DEBUG:(original ): #{str}\" if str =~ @debug[type]\n end\n\n exp_orig = nil\n exp_orig = exp.deep_clone if $DEBUG or\n @debug.key? type or @exceptions.key?(type)\n\n raise UnsupportedNodeError, \"'#{type}' is not a supported node type\" if\n @unsupported.include? type\n\n # now do a pass with the real processor (or generic)\n meth = @processors[type] || @default_method\n if meth then\n\n if @warn_on_default and meth == @default_method then\n warn \"WARNING: Using default method #{meth} for #{type}\"\n end\n\n exp = exp.sexp_body if @auto_shift_type and meth != @default_method # HACK\n\n result = error_handler(type, exp_orig) {\n self.send meth, exp\n }\n\n if @debug.key? type then\n str = exp.inspect\n puts \"// DEBUG (processed): #{str}\" if str =~ @debug[type]\n end\n\n raise SexpTypeError, \"Result of #{type} must be a #{@expected}, was #{result.class}:#{result.inspect}\" unless\n @expected === result\n\n self.assert_empty(meth, exp, exp_orig) if @require_empty\n else\n unless @strict then\n until exp.empty? do\n sub_exp, *exp = exp # HACK\n sub_result = nil\n if Array === sub_exp then\n sub_result = error_handler(type, exp_orig) do\n process(sub_exp)\n end\n raise \"Result is a bad type\" unless Array === sub_exp\n raise \"Result does not have a type in front: #{sub_exp.inspect}\" unless\n Symbol === sub_exp.sexp_type unless\n sub_exp.empty?\n else\n sub_result = sub_exp\n end\n # result << sub_result\n result = result.class.new(*result, sub_result) # HACK\n end\n\n # NOTE: this is costly, but we are in the generic processor\n # so we shouldn't hit it too much with RubyToC stuff at least.\n result.c_type ||= exp.c_type if Sexp === exp and exp.respond_to?(:c_type)\n else\n msg = \"Bug! Unknown node-type #{type.inspect} to #{self.class}\"\n msg += \" in #{exp_orig.inspect} from #{caller.inspect}\" if $DEBUG\n raise UnknownNodeError, msg\n end\n end\n end\n\n result\n end",
"def isDummyNode?(node) \n return node.name == Tag_Dummy ;\n end",
"def process_defn exp\n process_all exp.body\n end",
"def process_module exp\n exp.shift unless auto_shift_type # node type\n in_klass exp.shift do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def process_node(node)\n method(:process).super_method.call(node)\n end",
"def processor=(_arg0); end",
"def parse_method_dummy container\n dummy = RDoc::Context.new\n dummy.parent = container\n dummy.store = container.store\n skip_method dummy\n end",
"def process(exp)\n return nil if exp.nil?\n\n result = nil\n\n type = exp.first\n raise \"Type should be a Symbol, not: #{exp.first.inspect} in #{exp.inspect}\" unless Symbol === type\n\n in_context type do\n # now do a pass with the real processor (or generic)\n meth = @processors[type]\n if meth then\n result = self.send(meth, exp)\n else\n result = self.process_default(exp)\n end\n end\n\n raise SexpTypeError, \"Result must be a #{@expected}, was #{result.class}:#{result.inspect}\" unless @expected === result\n\n result\n end",
"def process(exp)\n return nil if exp.nil?\n\n result = nil\n\n type = exp.first\n raise \"type should be a Symbol, not: #{exp.first.inspect}\" unless\n Symbol === type\n\n in_context type do\n # now do a pass with the real processor (or generic)\n meth = @processors[type]\n if meth then\n if $DEBUG\n result = error_handler(type) do\n self.send(meth, exp)\n end\n else\n result = self.send(meth, exp)\n end\n\n else\n result = self.process_default(exp)\n end\n end\n \n raise SexpTypeError, \"Result must be a #{@expected}, was #{result.class}:#{result.inspect}\" unless @expected === result\n \n result\n end",
"def process_sclass exp\n exp.shift unless auto_shift_type # node type\n in_sklass do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def process(exp)\n @processor.process(exp)\n end",
"def process_defs exp\n exp.shift unless auto_shift_type # node type\n process exp.shift # recv\n in_method \"::#{exp.shift}\", exp.file, exp.line, exp.line_max do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def visit_ProcessingInstruction(pi, *rest)\n end",
"def process_default(exp)\n until exp.size == 0\n exp.shift\n end\n s()\n end",
"def process exp\n @processors.each do |processor|\n exp = processor.process(exp)\n end\n exp\n end",
"def process_defn(exp)\n make_function exp\n end",
"def process(node)\n return if node.nil?\n return node unless node.respond_to?(:to_ast)\n\n node = node.to_ast\n\n # Invoke a specific handler\n on_handler = :\"on_#{node.type}\"\n if respond_to? on_handler\n new_node = send on_handler, node\n else\n new_node = handler_missing(node)\n end\n\n new_node if new_node\n end",
"def process(*)\n end",
"def process(*)\n end",
"def process_node(node, this, nxt)\n if node.value == \"ALT\"\n node_alt(node, this, nxt)\n elsif node.value == \"SEQ\"\n node_seq(node, this, nxt)\n elsif node.value == \"*\"\n node_kleene(node, this, nxt)\n elsif node.value == \"lambda\"\n leaf_lambda(node, this, nxt)\n else\n leaf_child(node, this, nxt)\n end\n end",
"def reset_dummy(options = {})\r\n options[:with_processed] = true unless options.key?(:with_processed)\r\n build_dummy_table(options[:with_processed])\r\n reset_class(\"Dummy\", options)\r\nend",
"def process_defn exp\n return exp unless @current_method\n process_all exp.body\n end",
"def process(node)\n return node unless node.is_a?(Parser::AST::Node)\n\n process_node(node)\n end",
"def process_node(node, process_text)\n node_text = ''\n if node.element?\n case node.node_name\n when 'p', 'div'\n node_text.concat(process_paragraph_node(node))\n when 'span'\n node_text.concat(process_span_node(node))\n when 'h1','h2','h3','h4','h5','h6','h7','h8','h9'\n node_text.concat(process_header_node(node))\n when 'b', 'strong'\n node_text.concat(process_bold_node(node))\n when 'i', 'em'\n node_text.concat(process_italic_node(node))\n when 'u'\n node_text.concat(process_underline_node(node))\n when 'strike'\n node_text.concat(process_strike_node(node))\n when 'br'\n node_text.concat(process_line_break_node(node))\n when 'hr'\n node_text.concat(process_hrule_node(node))\n when 'table'\n node_text.concat(process_table_node(node))\n when 'tr'\n node_text.concat(process_table_row_node(node))\n when 'td'\n node_text.concat(process_table_data_node(node))\n when 'ul'\n node_text.concat(process_list_node(node, '*'))\n when 'ol'\n node_text.concat(process_list_node(node, '#'))\n when 'li'\n node_text.concat(process_list_item_node(node))\n when 'img'\n node_text.concat(process_image_node(node))\n when 'a'\n node_text.concat(process_link_node(node))\n else\n node.children.each {|n| node_text.concat(process_node(n, process_text))}\n end\n elsif process_text and node.text?\n node_text.concat(process_text_node(node))\n else\n node.children.each {|n| node_text.concat(process_node(n, process_text))}\n end\n node_text\n end",
"def process(node)\n return if node.nil?\n\n @_on_handler_cache ||= {}\n type = node.type\n\n on_handler = @_on_handler_cache[type] ||= begin\n handler = :\"on_#{type}\"\n handler = :handler_missing unless respond_to?(handler)\n handler\n end\n\n send(on_handler, node) || node\n end",
"def process(*)\n end",
"def process_yield(exp)\n value = exp.shift\n\n str = without_result do\n want_expression do\n block_name() + \"(\" + (value ? process(value) : '') + \")\"\n end\n end\n resultify(str)\n end",
"def register_processor(pattern, klass, replace_all: T.unsafe(nil)); end",
"def visit_node(n); end",
"def preprocess(&block); end",
"def process(*_arg0, **_arg1); end",
"def processor; end",
"def initialize\n @expected = Sexp\n\n # we do this on an instance basis so we can subclass it for\n # different processors.\n @processors = {}\n @context = []\n\n public_methods.each do |name|\n if name.to_s.start_with? \"process_\" then\n @processors[name[8..-1].to_sym] = name.to_sym\n end\n end\n end",
"def processing_instruction(name, content); end",
"def processing_instruction(name, content); end",
"def call(node); end",
"def visit_s(node)\n ignore_node(node)\n end",
"def process(number, processor)\n puts 'STARTING PROCESSING'\n result = processor.call(number)\n puts 'END PROCESSING'\n result\nend",
"def process_xml(string)\n xml_processor_helper(create_document(string))\nend",
"def process_sexp pt\n filter_sexp(pt).deep_each do |node|\n next :skip if node.none? { |sub| Sexp === sub }\n next :skip if node.mass < self.mass_threshold\n\n self.hashes[node.structural_hash] << node\n\n process_fuzzy node, option[:fuzzy] if option[:fuzzy]\n end\n end",
"def initialize\n @expected = Sexp\n @processors = self.class.processors\n @context = []\n\n if @processors.empty?\n public_methods.each do |name|\n if name.to_s.start_with? \"process_\" then\n @processors[name[8..-1].to_sym] = name.to_sym\n end\n end\n end\n end",
"def processor(params = T.unsafe(nil)); end",
"def primary\r\n if consume(\"(\")\r\n node = expr()\r\n expect(\")\")\r\n return node\r\n end\r\n\r\n new_num(expect_number())\r\nend",
"def process(name); end",
"def process(name); end",
"def dummy_generator(result)\n Object.new.tap { |o| o.define_singleton_method(:generate) { |*args| result } }\n end",
"def process_else(exp)\n add_to_score :branch\n penalize_by 0.1 do\n process_until_empty exp\n end\n s()\n end",
"def process_lit(exp)\n exp.shift\n value = exp.shift\n\n if value.is_a?(Numeric) && !@ignore.include?(value)\n @file.magic_numbers << MagicNumber.new(:value => value, :line => exp.line)\n end\n\n s()\n end",
"def do_nothing markup_item\n end",
"def run_dummy!\n if dummy_command\n Chef::Resource.resource_for_node(:poise_service, node).new('runsvdir', run_context).tap do |r|\n r.command(dummy_command)\n r.provider(:dummy)\n r.run_action(:enable)\n end\n end\n end",
"def process_dregx exp\n exp.each { |arg| process arg if sexp? arg }\n\n add_simple_call :railroader_regex_interp, exp\n\n exp\n end",
"def process_call(exp)\n receiver_node_type = exp.first.nil? ? nil : exp.first.first\n receiver = process exp.shift\n receiver = \"(#{receiver})\" if ASSIGN_NODES.include? receiver_node_type\n\n name = exp.shift\n args = []\n\n # this allows us to do both old and new sexp forms:\n exp.push(*exp.pop[1..-1]) if exp.size == 1 && exp.first.first == :arglist\n\n @calls.push name\n\n in_context :arglist do\n until exp.empty? do\n arg_type = exp.first.sexp_type\n is_empty_hash = (exp.first == s(:hash))\n arg = process exp.shift\n\n next if arg.empty?\n\n strip_hash = (arg_type == :hash and\n not BINARY.include? name and\n not is_empty_hash and\n (exp.empty? or exp.first.sexp_type == :splat))\n wrap_arg = Ruby2Ruby::ASSIGN_NODES.include? arg_type\n\n arg = arg[2..-3] if strip_hash\n arg = \"(#{arg})\" if wrap_arg\n\n args << arg\n end\n end\n\n case name\n when *BINARY then\n # CUSTOM\n \"#{receiver}#{name}#{args.join(', ')}\"\n when :[] then\n receiver ||= \"self\"\n \"#{receiver}[#{args.join(', ')}]\"\n when :[]= then\n receiver ||= \"self\"\n rhs = args.pop\n \"#{receiver}[#{args.join(', ')}] = #{rhs}\"\n when :\"-@\" then\n \"-#{receiver}\"\n when :\"+@\" then\n \"+#{receiver}\"\n # CUSTOM\n when :lambda then\n '->'\n # CUSTOM\n when :call then\n args = if args.empty?\n nil\n elsif args\n args.join(',')\n end\n\n \"#{receiver}[#{args}]\"\n else\n args = nil if args.empty?\n\n # CUSTOM\n args = if args and args.size == 1\n # It's safe to map a single arg to be spaced from\n # the receiver w/out parens in this context\n \" #{ args.first }\"\n elsif args\n \"(#{args.join(', ')})\"\n end\n\n receiver = \"#{receiver}.\" if receiver\n\n \"#{receiver}#{name}#{args}\"\n end\n ensure\n @calls.pop\n end",
"def process(*x)\n r.send(self.class_as_function).call(*x)\n end",
"def test_no_argument_case\n result = interpret 'one=->(a) { true };%one(1)'\n assert result\n end",
"def process\n raise NotImplementedError\n end",
"def process\n raise NotImplementedError\n end",
"def preprocess(input); end",
"def __dummy_test__\n end",
"def process_regular_iter(exp)\n iter = process exp.shift\n args = exp.shift\n body = exp.empty? ? nil : process(exp.shift)\n\n args = case args\n when 0 then\n ' ||'\n else\n a = process(args)[1..-2]\n a = \"|#{a}|\" unless a.empty?\n a\n end\n\n b, e = if iter == \"END\" then\n [ \"{\", \"}\" ]\n else\n [ \"do\", \"end\" ]\n end\n\n iter.sub!(/\\(\\)$/, '')\n\n # REFACTOR: ugh\n result = []\n # CUSTOM\n result << \"#{iter}{\"\n result << args\n if body then\n # CUSTOM\n result << body.strip\n else\n # CUSTOM\n result << ''\n end\n result << \"}\"\n result = result.join\n return result if result !~ /\\n/ and result.size < LINE_LENGTH\n\n result = []\n result << \"#{iter} #{b}\"\n result << args\n result << \"\\n\"\n if body then\n result << indent(body.strip)\n result << \"\\n\"\n end\n result << e\n result.join\n end",
"def nop_generator\n return nil if (!payload_instance)\n\n payload_instance.compatible_nops.each { |nopname, nopmod|\n return nopmod.new\n }\n end",
"def process_class exp\n exp.shift unless auto_shift_type # node type\n in_klass exp.shift do\n if block_given? then\n yield\n else\n process_until_empty exp\n end\n end\n s()\n end",
"def test_flatten_process1\r\n proc = @mymodel.node_list.add_node(1, 'proc1', PROCESS)\r\n \r\n assert_equal( { \"name\"=>\"proc1\", \"ident\"=>1, \"type\"=>\"process\",\r\n \"commentary\"=>\"\", \"description\"=>\"\", \"evidence\"=>\"undefined\" },\r\n proc.flatten_data)\r\n end",
"def get_dummy(klass)\n type = get_type(klass)\n is_analyzer = type == \"Analyzer\"\n is_analyzer ? klass.new(\"dummy\") : klass.new(artifacts: [], rule: nil)\n end",
"def << processor\n raise ArgumentError, \"Can only add sexp processors\" unless\n SexpProcessor === processor || processor.respond_to?(:process)\n @processors << processor\n end",
"def test_0_dummy\n\t\tend",
"def valid_processors; end",
"def process(parser)\n end",
"def machine=(_arg0); end",
"def handle(node)\n # XXX: FIXME, return if a bad string is passed\n return node unless defined? node.type.to_s\n # if Symbol, hack function a :symbol.to_s\n node.to_a.each do |c|\n return \"#{c}\" if c.class == Symbol && node.type.to_s == \"send\" # != \"sym\"\n end\n\n case node.type.to_s\n when \"str\"\n return variable_str(node.children)\n when \"dstr\"\n words = \"\"\n node.children.each do |dstr|\n if dstr.children[0] != \"str\"\n words << handle(dstr)\n else\n words << variable_str(dstr)\n end\n end\n return words\n when \"array\"\n array = []\n node.children.each { |item| array << handle(item) }\n return array\n when \"arg\"\n return variable_arg(node)\n when \"args\"\n array = []\n node.children.each { |item| array << handle(item) }\n # XXX: FIXME figure how to handle multi-for loops\n # like 10 formulas use them\n return array\n when \"lvasgn\"\n return variable_lvasgn(node)\n when \"lvar\"\n x = variable_str(node)\n return bash_variable(x)\n when \"splat\"\n x = variable_splat(node)\n return bash_variable(x)\n when \"const\"\n return variable_const(node)\n when \"begin\"\n # the start of a command ex. system\n type = variable_strip(node).type.to_s\n x = case type\n when \"lvar\"\n variable_str(variable_strip(node))\n else # \"send\", \"begin\"\n variable_send(variable_strip(node))\n end\n # catch const, here\n # XXX: Waste of cycles doing this, but eh\n if type == \"send\"\n z = variable_const_formula(node)\n return z if z\n z = variable_multi(node)\n return z if z\n end\n # else\n return bash_variable(x)\n when \"send\"\n z = variable_multi(node)\n return z if z\n\n x = variable_const(node)\n return variable_send(node)\n when \"hash\"\n array = []\n node.children.each { |item| array << handle(item) }\n return array\n when \"pair\"\n array = []\n node.children.each { |item| array << handle(item) }\n return array\n when \"int\"\n return variable_int(node)\n when \"sym\"\n return variable_sym(node)\n else\n # XXX: error out here\n puts \"handle UNKNOWN: #{node.type}\"\n return nil\n end\n end",
"def process(*_arg0, **_arg1, &_arg2); end",
"def process_nil(exp)\n return \"Qnil\"\n end",
"def first_part_of_call_chain(node); end",
"def first_part_of_call_chain(node); end",
"def process_until_empty exp\n until exp.empty?\n sexp = exp.shift\n process sexp if Sexp === sexp\n end\n end",
"def preprocess_input(input)\nend",
"def process_iter(exp)\n if exp.first.last == :lambda\n process_lambda_iter exp\n else\n process_regular_iter exp\n end\n end",
"def pre_process\n end",
"def process!(name, *args)\n app.get_processor(name).call(self, *args)\n self\n end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process; end",
"def process_nil(exp)\n return \"NULL\"\n end",
"def handle(body)\n process(:one, body)\n end",
"def test_documentcreateprocessinginstruction\n doc = nil\n newPINode = nil\n piValue = nil\n piName = nil\n piType = nil\n doc = load_document(\"staff\", true)\n newPINode = doc.createProcessingInstruction(\"TESTPI\", \"This is a new PI node\")\n assert_not_nil(newPINode, \"createdPINotNull\")\n piName = newPINode.nodeName()\n assert_equal(\"TESTPI\", piName, \"name\")\n piValue = newPINode.nodeValue()\n assert_equal(\"This is a new PI node\", piValue, \"value\")\n piType = newPINode.nodeType()\n assert_equal(7, piType, \"type\")\n \n end",
"def pre_process(message)\n end",
"def process_iasgn exp\n exp = exp.dup\n exp.rhs = process exp.rhs\n exp\n end",
"def process_iasgn(exp)\n ivar = exp.shift\n value = exp.shift\n ivar_name = @model.encode_instance_variable(ivar)\n\n str = without_result do\n want_expression do\n \"#{@model.encode_self}.#{ivar_name}=#{process(value)}\"\n end\n end\n\n resultify(str)\n end",
"def ev_preprocess(&block); end",
"def ev_preprocess(&block); end",
"def method_missing(symbol, *args)\n\t\t\t\tif(args == nil or args.length == 0)\n\t\t\t\t\tregex = Regexp.new(Regexp.escape(symbol.id2name))\n\t\t\t\t\treturn has_process?(regex)\n\t\t\t\tend\n\n\t\t\t\tsuper.method(symbol).call(args)\n\t\t\tend",
"def preprocess(input)\n\t\tperform_substitutions(input)\n\tend",
"def consume(node, source_part = T.unsafe(nil)); end"
] |
[
"0.63568693",
"0.6237473",
"0.5949897",
"0.5918314",
"0.5550516",
"0.55156153",
"0.54685557",
"0.5429859",
"0.5420868",
"0.5302231",
"0.5297833",
"0.5243836",
"0.52326226",
"0.52313733",
"0.521029",
"0.5202815",
"0.51909214",
"0.51699054",
"0.51671785",
"0.51224387",
"0.5115123",
"0.5115123",
"0.5096002",
"0.5032771",
"0.5029551",
"0.5004146",
"0.49866387",
"0.4958417",
"0.49110162",
"0.4894848",
"0.4849606",
"0.4842683",
"0.4821609",
"0.48158067",
"0.48102495",
"0.47969088",
"0.47898993",
"0.47898993",
"0.47721267",
"0.47471035",
"0.4694914",
"0.46881396",
"0.46856868",
"0.46664438",
"0.46642146",
"0.4658155",
"0.465568",
"0.465568",
"0.46503463",
"0.4648132",
"0.4629983",
"0.46215498",
"0.45994493",
"0.45960066",
"0.45830524",
"0.45777065",
"0.45723075",
"0.45640737",
"0.45640737",
"0.4562309",
"0.45615062",
"0.45518067",
"0.45357713",
"0.45331168",
"0.4530865",
"0.45238602",
"0.4514715",
"0.45004687",
"0.4498664",
"0.44934636",
"0.4491791",
"0.44893926",
"0.44848946",
"0.44802043",
"0.4473237",
"0.4473237",
"0.44712287",
"0.44643372",
"0.44570068",
"0.44556692",
"0.44490293",
"0.44461173",
"0.44461173",
"0.44461173",
"0.44461173",
"0.44461173",
"0.44461173",
"0.44461173",
"0.44461173",
"0.4435125",
"0.44246978",
"0.44246864",
"0.4424526",
"0.4419657",
"0.4418887",
"0.44175732",
"0.44175732",
"0.44114625",
"0.44070357",
"0.4401975"
] |
0.6348755
|
1
|
Add a scope level to the current env. Eg: def process_defn exp name = exp.shift args = process(exp.shift) scope do body = process(exp.shift) ... end end env[:x] = 42 scope do env[:x] => 42 env[:y] = 24 end env[:y] => nil
|
def scope &block
env.scope(&block)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def process_scope exp\n # NOPE?\n end",
"def scope\n @env.unshift({})\n begin\n yield\n ensure\n @env.shift\n raise \"You went too far unextending env\" if @env.empty?\n end\n end",
"def scope_level; end",
"def add_scope()\n $highest_scope += 1\n $current_scope_list << $highest_scope\n $var_list << {}\nend",
"def scope=(_); end",
"def local_scope; @scope = :local end",
"def scope(*args); end",
"def scope() binding end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def scope=(_arg0); end",
"def scope!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 2)\n\n type = SCOPE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 8:9: 'scope'\n match(\"scope\")\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__, 2)\n\n end",
"def inspect_variables_in_scope(scope_node)\n variable_table.push_scope(scope_node)\n process_children(scope_node)\n variable_table.pop_scope\n end",
"def scope=(v); end",
"def scope=(v); end",
"def enter_scope(aScope)\n # puts __callee__\n symbol_table.enter_scope(aScope)\n blackboard.enter_scope\n end",
"def scope() yield end",
"def process_scope(exp)\n declarations, body = with_scope do\n process exp.shift unless exp.empty?\n end\n\n declarations = declarations.reject { |d| d =~ / static_/ }\n\n result = []\n result << \"{\"\n result << declarations.join(\"\\n\") unless declarations.empty?\n result << body.chomp if body\n result << \"}\"\n \n return result.join(\"\\n\")\n end",
"def apply_to_scope(scope)\n scope\n end",
"def newscope(parent, options = {})\n raise _('having multiple named scopes is not supported when scripting')\n end",
"def scope\n captures.push\n yield\n ensure\n captures.pop\n end",
"def inspect_variables_in_scope(scope_node)\n variable_table.push_scope(scope_node)\n\n NodeScanner.scan_nodes_in_scope(scope_node) do |node|\n # puts \"scope:#{variable_table.current_scope_level} node:#{node}\"\n process_node(node)\n end\n\n variable_table.pop_scope\n end",
"def scope_increase()\n @@scope_no += 1\n @@variable_list.push({})\n if @@our_debug then puts \"#{debug_time} Increase the scope with 1 to #{@@scope_no}\" end\n :ok\nend",
"def push_scope(data)\n @scopes.push(\n data.respond_to?(:get_variable_value) ? data : DefaultScope.new(data))\n end",
"def default_scope=(_arg0); end",
"def create_with_scope(name); end",
"def global_scope; @scope = :global end",
"def push_scope(tag, time = Time.now.to_f, deduct_call_time_from_parent = true)\n stack = scope_stack\n transaction_sampler.notice_push_scope(time) if sampler_enabled?\n scope = ScopeStackElement.new(tag, time, deduct_call_time_from_parent)\n stack.push scope\n scope\n end",
"def inner_scope(param)\n param = 12\nend",
"def scope(level = @skl_level)\n return @skl_levelcache[level][:scope]\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def stack(new_scope = T.unsafe(nil)); end",
"def add_dynamic_scopes(params, base)\n self.dynamic_scopes.each_pair do |name, args|\n # make sure we have all required arguments\n next unless self.check_required_scope_args(args, params[name])\n\n # the args we will apply\n caller_args = []\n\n # iterate through our args and add them to an array to send to our\n # scope\n args.keys.each do |subkey|\n # we only apply things that are present or explicitly false\n if val = self.get_scope_arg_value(subkey, params[name][subkey])\n caller_args << val\n end\n end\n # call our scope with the supplied args\n base = base.send(name, *caller_args)\n end\n return base\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def set_Scope(value)\n set_input(\"Scope\", value)\n end",
"def put_var_scope\nend",
"def on_def(node)\n add_scope(node)\n end",
"def set_current_scope(scope)\n Thread.current[:webspicy_scope] = scope\n end",
"def apply_environment!(hook_context, env); end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def scope; end",
"def add_scope(scope)\n scope.ensure_uri\n patch('add', '/scopeUris/-', scope['uri'])\n end",
"def scope(scope, &block)\n @scopes[scope] ||= []\n @scopes[scope] << block\n end",
"def scope\n scope_hash = [settings.force_mode,state.total].hash\n return @state.scope unless @state.scope.nil? or scope_hash != @state.scope_hash\n state.scope_at = [\n settings.force_mode || ($stdout.isatty ? :tty : :notty),\n :unknown == state.total ? :infinite : :finite\n ]\n state.scope = state.settings\n state.scope_at.each do |s|\n begin\n state.scope = state.scope[s]\n rescue NoMethodError\n raise StandardError, \"Invalid configuration: #{state.scope_at.join('.')} \"+\n \"(Can't resolve: #{state.scope_at[state.scope_at.index(s)-1]})\"\n end\n end\n state.scope_hash = scope_hash\n state.scope\n end",
"def inspect_variables_in_scope(scope_node); end",
"def in_scope(scope)\n cur_scope = @scope\n @scope = scope\n yield\n ensure\n @scope = cur_scope\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def scope=(value)\n @scope = value\n end",
"def newscope(parent, options = {})\n parent ||= topscope\n scope = Puppet::Parser::Scope.new(self, **options)\n scope.parent = parent\n scope\n end",
"def scope_condition() {} end",
"def scope1(var)\r\n\ta = \"monkey\"\r\nend",
"def new_scope(names)\n values = names.map { |n| self[n] }\n self.class.new(names, values + extras, self)\n end",
"def scope_stack\n Thread.current[:\"[mongoid]:scope-stack\"] ||= {}\n end",
"def scope_stack\n Thread.current[:\"[mongoid]:scope-stack\"] ||= {}\n end",
"def scope_stack\n Thread.current[:\"[mongoid]:scope-stack\"] ||= {}\n end",
"def scope_with_resource_definition_addition(name, opts = {}, &block)\n # if it's a proc, we figure out its parameters\n params = if opts.is_a?(Proc)\n self.get_scope_parameters(opts)\n # otherwise we just use a blank hash\n else\n {}\n end\n\n # update scope definition\n self.stored_scope_definition = self.stored_scope_definition.merge(\n name.to_sym => params\n )\n\n # call the original scope definition method\n self.scope_without_resource_definition_addition(\n name,\n opts,\n &block\n )\n end",
"def my_method # scope gate - program enters a new scope\n # I'm in a new scope gate! I can't read my_variable\n my_variable + my_variable\nend",
"def scope_by(&block)\n raise 'Cannot define scope after scope has been called.' if @scope\n\n @scope_block = block\n end",
"def push_scope(definition)\n unless definition.is_a?(RubyLint::Definition::RubyObject)\n raise(\n ArgumentError,\n \"Expected a RubyLint::Definition::RubyObject but got \" \\\n \"#{definition.class} instead\"\n )\n end\n\n @scopes << definition\n end",
"def scope(*args, &block)\n options = if args.last.is_a?(Hash)\n args.pop\n else\n {}\n end\n \n #\n # set locale\n if locale = options[:locale]\n old_locale = self.current_locale\n self.current_locale = if I18n.backend.available_locales.include?(locale = locale.to_sym)\n locale\n else\n base\n end\n end\n\n #\n # set format\n if format = options[:format]\n old_format = self.current_format\n self.current_format = format\n end\n\n #\n # adjust scope (from the remaining arguments)\n current_scope.push(*args)\n\n yield\n ensure\n current_scope.pop(*args)\n self.current_format = old_format if old_format\n self.current_locale = old_locale if old_locale\n end",
"def identifyScope(theLine, currentScope)\n\n\ttheText = theLine[:text];\n\tnewScope = currentScope;\n\t\n\tif (theText =~ /^enum /)\n\t\tnewScope = :enum;\n\t\n\telsif (theText =~ /^struct /)\n\t\tnewScope = :struct;\n\t\n\telsif (theText =~ /^class /)\n\t\tnewScope = :class;\n\t\n\telsif (theText =~ /^(\\w+)::\\1\\(/)\n\t\tnewScope = :constructor;\n\t\n\telsif (theText == \"{\")\n\t\tif (currentScope == :global)\n\t\t\tnewScope = :function;\n\t\tend\n\t\n\telsif (theText == \"}\")\n\t\tnewScope = :global;\n\tend\n\t\n\treturn newScope;\n\nend",
"def push_local_depth\n <<-CODE\n next_int;\n k = (native_int)_int;\n next_int;\n t1 = c->active_context;\n for(j = 0; j < k; j++) {\n t2 = blokctx_env(state, t1);\n t1 = blokenv_get_home_block(t2);\n }\n stack_push(tuple_at(state, blokctx_locals(state, t1), _int));\n CODE\n end",
"def initialize\n @level = level_for_env\n end",
"def new_scope\n self.class.new(@input, @output, @wrap_at,\n @page_at, @indent_size, @indent_level)\n end",
"def named_scope_begin(&block)\n lang_eval { @named_scope_begin_block = block }\n nil\n end",
"def add_dynamic_scopes(params, scope = self.all)\n scope.klass.dynamic_scopes.each_pair do |scope_name, arg_def|\n\n # skip scopes that are not defined\n next if self.blank_param?(params[scope_name])\n\n # now apply the arguments\n args_to_pass = self.get_dynamic_scope_args(\n scope_name,\n arg_def,\n params[scope_name]\n )\n\n # actually apply the scope\n scope = scope.send(scope_name, *args_to_pass)\n end\n\n # return the final scope\n scope\n end",
"def add_scope(name, config={})\n scopes[name] = config\n end",
"def with_app_scope(*scope_sections, &block)\n @@app_scope_stack.push scope_sections\n begin\n yield\n ensure\n @@app_scope_stack.pop\n end\n end",
"def apply_scope(target, type:, name: :default, scope_options: nil)\n raise ActionPolicy::UnknownScopeType.new(self.class, type) unless\n self.class.scoping_handlers.key?(type)\n\n raise ActionPolicy::UnknownNamedScope.new(self.class, type, name) unless\n self.class.scoping_handlers[type].key?(name)\n\n mid = :\"__scoping__#{type}__#{name}\"\n scope_options ? send(mid, target, **scope_options) : send(mid, target)\n end",
"def scope=(val)\n set_scope(val)\n val\n end",
"def with_scope(scope)\n (@@scopes ||= []) << scope\n yield ensure @@scopes.pop\n end",
"def with_scope(scope)\n (@@scopes ||= []) << scope\n yield ensure @@scopes.pop\n end",
"def attr_scope\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 4 )\n return_value = AttrScopeReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal19 = nil\n __ACTION21__ = nil\n id20 = nil\n\n tree_for_string_literal19 = nil\n tree_for_ACTION21 = nil\n stream_SCOPE = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token SCOPE\" )\n stream_ACTION = ANTLR3::AST::RewriteRuleTokenStream.new( @adaptor, \"token ACTION\" )\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new( @adaptor, \"rule id\" )\n begin\n # at line 113:4: 'scope' id ACTION\n string_literal19 = match( SCOPE, TOKENS_FOLLOWING_SCOPE_IN_attr_scope_552 )\n if @state.backtracking == 0\n stream_SCOPE.add( string_literal19 )\n end\n @state.following.push( TOKENS_FOLLOWING_id_IN_attr_scope_554 )\n id20 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add( id20.tree )\n end\n __ACTION21__ = match( ACTION, TOKENS_FOLLOWING_ACTION_IN_attr_scope_556 )\n if @state.backtracking == 0\n stream_ACTION.add( __ACTION21__ )\n end\n # AST Rewrite\n # elements: SCOPE, id, ACTION\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream( \"rule return_value\", return_value.tree ) : subtree_stream( \"token return_value\" )\n\n root_0 = @adaptor.create_flat_list\n # 113:22: -> ^( 'scope' id ACTION )\n # at line 113:25: ^( 'scope' id ACTION )\n root_1 = @adaptor.create_flat_list\n root_1 = @adaptor.become_root( stream_SCOPE.next_node, root_1 )\n\n @adaptor.add_child( root_1, stream_id.next_tree )\n @adaptor.add_child( root_1, stream_ACTION.next_node )\n\n @adaptor.add_child( root_0, root_1 )\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 4 )\n\n end\n \n return return_value\n end",
"def attr_scope\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 4)\n return_value = AttrScopeReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal19 = nil\n __ACTION21__ = nil\n id20 = nil\n\n tree_for_string_literal19 = nil\n tree_for_ACTION21 = nil\n stream_SCOPE = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token SCOPE\")\n stream_ACTION = ANTLR3::AST::RewriteRuleTokenStream.new(@adaptor, \"token ACTION\")\n stream_id = ANTLR3::AST::RewriteRuleSubtreeStream.new(@adaptor, \"rule id\")\n begin\n # at line 122:4: 'scope' id ACTION\n string_literal19 = match(SCOPE, TOKENS_FOLLOWING_SCOPE_IN_attr_scope_557) \n if @state.backtracking == 0\n stream_SCOPE.add(string_literal19)\n end\n @state.following.push(TOKENS_FOLLOWING_id_IN_attr_scope_559)\n id20 = id\n @state.following.pop\n if @state.backtracking == 0\n stream_id.add(id20.tree)\n end\n __ACTION21__ = match(ACTION, TOKENS_FOLLOWING_ACTION_IN_attr_scope_561) \n if @state.backtracking == 0\n stream_ACTION.add(__ACTION21__)\n end\n # AST Rewrite\n # elements: ACTION, id, SCOPE\n # token labels: \n # rule labels: return_value\n # token list labels: \n # rule list labels: \n # wildcard labels: \n if @state.backtracking == 0\n\n return_value.tree = root_0\n stream_return_value = return_value ? subtree_stream(\"rule return_value\", return_value.tree) : subtree_stream(\"token return_value\")\n\n root_0 = @adaptor.create_flat_list!\n # 122:22: -> ^( 'scope' id ACTION )\n # at line 122:25: ^( 'scope' id ACTION )\n root_1 = @adaptor.create_flat_list!\n root_1 = @adaptor.become_root(stream_SCOPE.next_node, root_1)\n\n @adaptor.add_child(root_1, stream_id.next_tree)\n @adaptor.add_child(root_1, stream_ACTION.next_node)\n\n @adaptor.add_child(root_0, root_1)\n\n\n\n return_value.tree = root_0\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look(-1)\n\n if @state.backtracking == 0\n\n return_value.tree = @adaptor.rule_post_processing(root_0)\n @adaptor.set_token_boundaries(return_value.tree, return_value.start, return_value.stop)\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node!(@input, return_value.start, @input.look(-1), re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 4)\n\n end\n \n return return_value\n end",
"def with_scope(scope)\n current_scope = @current_scope\n @current_scope = scope\n result = yield\n @current_scope = current_scope\n result\n end",
"def bind(scope)\n bind_in body, scope\n end"
] |
[
"0.6767192",
"0.6705041",
"0.6117308",
"0.5946095",
"0.59248245",
"0.59236115",
"0.59077585",
"0.58959657",
"0.5893147",
"0.5893147",
"0.5893147",
"0.58474076",
"0.5840782",
"0.5755145",
"0.5755145",
"0.5701138",
"0.56867534",
"0.56778735",
"0.5675147",
"0.567086",
"0.5602732",
"0.5596858",
"0.55949795",
"0.5588822",
"0.5553193",
"0.55506724",
"0.55295116",
"0.54727787",
"0.546737",
"0.54543304",
"0.54359835",
"0.54359835",
"0.54359835",
"0.54359835",
"0.54359835",
"0.54359835",
"0.54359835",
"0.54359835",
"0.54359835",
"0.54359835",
"0.54359835",
"0.5435651",
"0.5435576",
"0.54319185",
"0.54319185",
"0.5421123",
"0.5410927",
"0.5402664",
"0.539095",
"0.5390275",
"0.5390275",
"0.5390275",
"0.5390275",
"0.5390275",
"0.5390275",
"0.5390275",
"0.5390275",
"0.5390275",
"0.5390275",
"0.5381187",
"0.53742653",
"0.5362024",
"0.53521305",
"0.5350135",
"0.53138906",
"0.53138906",
"0.53138906",
"0.53138906",
"0.53138906",
"0.53138906",
"0.5312467",
"0.52871",
"0.5260817",
"0.5226896",
"0.5219972",
"0.5219972",
"0.5219972",
"0.5211902",
"0.5205008",
"0.5202202",
"0.51994526",
"0.519312",
"0.5182798",
"0.51521736",
"0.5143278",
"0.5136557",
"0.5133818",
"0.5129537",
"0.5113347",
"0.5112553",
"0.5107656",
"0.51068383",
"0.508534",
"0.508534",
"0.508245",
"0.5081666",
"0.5074647",
"0.5071937"
] |
0.632707
|
3
|
ensure taht there are no line items referencing this product
|
def ensure_not_referenced_by_any_line_item
unless line_items.empty?
errors.add(:base, 'Line Items Present')
throw :abort
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ensure_not_referenced_by_any_line_item\n\t\t\tunless line_items.empty?\n\t\t\t\terrors.add(:base, 'Line items reference this product')\n\t\t\t\tthrow :abort\n\t\t\tend\n\t\tend",
"def ensure_not_referenced_by_any_line_item_product\n unless line_item_products.empty?\n errors.add(:base, 'Line Items Products present')\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Product sedang di referensikan oleh Line Item')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item #in this case before destroy a row in the database\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Itens present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n raise Error.new \"Line Items present\"\n end\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tunless line_items.empty?\n\t\t\terrors.add(:base, 'Line Items Presents')\n\t\t\tthrow :abort\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\tunless line_items.empty?\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\tthrow :abort\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.count.zero?\n\t\t\treturn true\n\t\telse\n\t\t\terrors[:base] << \"Line Items Prsent\"\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n return if line_items.empty?\n\n errors.add(:base, \"Line Items present\")\n throw :abort\n end",
"def ensure_not_referenced_by_any_line_item\r\n\t\tunless line_items.empty?\r\n\t\t\terrors.add(:base, 'Line Items Present')\r\n\t\t throw :abort\r\n\t\tend\r\n\t\r\n\tend",
"def ensure_not_referenced_by_any_line_item \n if line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items present')\n return false \n end\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.emty?\n\t\t\treturn true\n\t\tesle\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item # hook method (a method that Rails calls automatically at a given point in an object’s life)\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item \n \tif line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items present')\n return false \n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Istnieja powiazania z Line Items')\n return false;\n end\n end",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item \n\t\tif line_items.empty?\n\t\t\treturn true \n\t\telse\n\t\t\terrors.add(:base, 'Line Items present')\n\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n \tif line_items.empty?\n \t\treturn true\n \telse\n \t\terrors.add(:base, 'Line Items Present')\n \t\treturn false\n \tend\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.count.zero?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\tif line_items.empty?\n \t return true\n \telse\n \t errors.add(:base, 'Line Items present' )\n \treturn false\n \tend\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.count.zero?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line Items present' )\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.count.zero?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line Items present' )\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\"\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base,'Line Items present') #We associate errors with the base object\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item\n\t\t\tif line_items.empty?\n\t\t\t\treturn true \n\t\t\telse\n\t\t\t\terrors.add(:base, 'Line Items present')\n\t\t\t\treturn false \n\t\t\tend\n\t\tend",
"def ensure_not_referenced_by_any_line_item\n \tif line_items.empty?\n \t\treturn true\n \telse\n \t\terrors.add(:base, 'Line Items present')\n \t\treturn false\n \tend \t\t\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\" #这是什么意思\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.count.zero?\n\t\t\treturn true\n\t\telse\n\t\t\terrors[:base] << \"Line Items present\"\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n\t return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item\n\tif line_items.empty?\n\treturn true\n\telse\n\terrors.add(:base, 'Line Items present')\n\treturn false\n\tend\n\tend",
"def ensure_not_referenced_by_any_line_item \n if line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items present')\n return false \n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.count.zero?\n\t\t\treturn true\n\t\t\telse\n\t\t\terrors.add(:base, 'Line Items present' )\n\t\t\treturn false\n\t\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, \"Line Items present\")\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line items present')\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item\n \t if line_items.empty?\n \t \treturn true\n \t else\n \t \terrors.add(:base, 'Line items present')\n \t \treturn false\n \t end\n \tend",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item \n if line_items.empty?\n return true \n else\n errors.add(:base, 'Line Items present')\n return false \n end\n end",
"def ensure_not_referenced_by_any_line_item\n\tif line_items.count.zero?\n\treturn true\n\telse\n\terrors[:base] << \"Line Items present\"\n\treturn false\n\tend\nend",
"def ensure_not_referenced_by_any_line_items\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items Present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'este produto não pode ser deletado porque pertence à itens em carrinhos de compras')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item \n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present!\"\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t return true\n\t \telse\n\t \t errors.add(:base, 'Line Items present')\n\t return false\n\t end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_item1s.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\"\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\"\n return false\n end \n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.count.zero?\n return true\n else\n errors[:base] << \"Line Items present\"\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line Items present')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\t\tif line_items.empty?\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:base, 'Line Items present')\n\t\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t\t\tif line_items.empty?\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:base, 'Line Items present')\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def ensure_not_referenced_by_any_line_item\n\t\t\tif line_items.empty?\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:base, 'Line Items present')\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def ensure_not_referenced_by_any_line_item\n\t\t\tif line_items.empty?\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:base, 'Line Items present')\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def ensure_not_referenced_by_any_line_item\n\t\t\tif line_items.empty?\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:base, 'Line Items present')\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def ensure_not_referenced_by_any_line_item\n\t\t\tif line_items.empty?\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:base, 'Line Items present')\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def ensure_not_referenced_by_any_line_item\n\t\t\tif line_items.empty?\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:base, 'Line Items present')\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def ensure_not_referenced_by_any_line_item\n\t\t\tif line_items.empty?\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:base, 'Line Items present')\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def ensure_not_referenced_by_any_line_item\n unless line_items.empty?\n errors.add(:base, 'Line Items present')\n throw :abort\n end\n end",
"def ensure_not_referenced_by_any_line_item\n\t\tif line_items.empty?\n\t\t\treturn true\n\t\telse\n\t\t\terrors.add(:base, 'Line items present')\n\t\t\treturn false\n\t\tend\n\tend",
"def ensure_not_referenced_by_any_line_item\n\t if line_items.count.zero?\n\t\t return true\n\t else\n\t\t errors[:base] << \"Line Items present\"\n\t\t return false\n\t end\n\tend",
"def ensure_not_referenced_by_any_line_item\n\tif line_items.empty?\n\treturn true\n\telse\n\terrors.add(:base, 'Line Items present')\n\treturn false\n\tend\nend",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Existuju polozky')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, \"Line items exist\")\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item \n if line_items.empty? \n return true \n else \n errors.add(:base, 'Line Items present') \n return false \n end \n end",
"def ensure_not_referenced_by_any_line_item\n \t\tif line_items.empty?\n \t\t\treturn true\n \t\telse\n \t\t\terrors.add(:base, 'Existe linha de item')\n\t\t \treturn false\n \t\tend\n \tend",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Variant used in Line Items')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end",
"def ensure_not_referenced_by_any_line_item\n if line_items.empty?\n return true\n else\n errors.add(:base, 'Line Items present')\n return false\n end\n end"
] |
[
"0.8622005",
"0.8570661",
"0.8243011",
"0.8208382",
"0.8173206",
"0.81245625",
"0.8084768",
"0.80435437",
"0.8001131",
"0.7999396",
"0.7979597",
"0.79733557",
"0.7972292",
"0.79670155",
"0.79621685",
"0.79478484",
"0.7939269",
"0.7939269",
"0.7937669",
"0.79318327",
"0.79300535",
"0.79294413",
"0.79273707",
"0.7924429",
"0.7924429",
"0.7922123",
"0.7922021",
"0.79215044",
"0.7918163",
"0.7915838",
"0.79142404",
"0.79120874",
"0.7908737",
"0.79085004",
"0.7904187",
"0.7903512",
"0.7903512",
"0.7903512",
"0.7900792",
"0.7899492",
"0.7898437",
"0.78973407",
"0.7890948",
"0.7888982",
"0.7884204",
"0.78832877",
"0.7882165",
"0.7881261",
"0.7881261",
"0.7881261",
"0.78756064",
"0.7873421",
"0.7871718",
"0.78702354",
"0.78692156",
"0.78660655",
"0.7862146",
"0.78602517",
"0.7853063",
"0.78526974",
"0.78469115",
"0.78469115",
"0.78469115",
"0.78469115",
"0.78469115",
"0.78469115",
"0.78469115",
"0.784373",
"0.784224",
"0.784224",
"0.784224",
"0.784224",
"0.784224",
"0.784224",
"0.784224",
"0.78344774",
"0.7833141",
"0.7832625",
"0.7824614",
"0.7811738",
"0.7811738",
"0.7811738",
"0.78108907",
"0.7809097",
"0.7808783",
"0.78060645",
"0.7805806",
"0.7801732",
"0.779946",
"0.779946",
"0.779946",
"0.779946",
"0.779946",
"0.779946",
"0.779946",
"0.779946",
"0.779946",
"0.779946",
"0.779946",
"0.779946"
] |
0.8002314
|
8
|
==== Tenant transaction =====
|
def paid_request_to_tenant(reservation)
@reservation = reservation
@tenant = @reservation.user
@cookoon = @reservation.cookoon
@host = @cookoon.user
mail(to: @tenant.full_email, subject: 'Vous avez demandé un Cookoon !')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def within_transaction; end",
"def within_transaction; end",
"def set_current_tenant_if_necessary\n if !self.user.current_tenant\n self.user.current_tenant = self.tenant\n self.user.save\n end\n end",
"def create_tenant\n Apartment::Tenant.create(params[:id])\n Apartment::Tenant.switch!(params[:id])\n\n\n redirect_to entreprise_path(enterprise_id: params[:entreprise])\n flash[:alert] = \"Tenant...#{Apartment::Tenant.current}\"\n end",
"def transaction; end",
"def transaction; end",
"def transaction; end",
"def use_transactions; end",
"def use_transactions; end",
"def set_tenant\n if current_user\n current_account = Account.where(id: current_user.current_tenant_id).first\n set_current_tenant(current_account)\n end\n end",
"def transaction(&block); end",
"def create_tenant\n Apartment::Tenant.create(account.tenant) do\n initialize_account_data\n account.switch do\n create_defaults\n fillin_translations\n add_initial_users\n schedule_recurring_jobs\n true\n end\n end\n end",
"def create\n @tenant = Tenant.new(tenant_params)\n \n p_id = Property.searchSecond(@tenant.tenantbuildinginfo)\n Property.find_by(id: p_id).tenants << @tenant\n respond_to do |format|\n if @tenant.save\n # if (@tenant.renewal == true)\n # UserMailer.delay(run_at: @tenant.leaseend - 3.months).reminder_email(@tenant)\n # end\n format.html { redirect_to @tenant, notice: 'Tenant was successfully created.' }\n format.json { render :show, status: :created, location: @tenant }\n else\n format.html { render :new }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_tenant\n\t @tenant = Tenant.find(params[:id])\n\t end",
"def createTenant\n if params[:op] == 'local'\n params_map = ActiveSupport::HashWithIndifferentAccess.new(params[:tenant])\n user = Tenant.new(params_map)\n if !user.save\n render 'create'\n return\n end\n session[:user_id] = user.id\n render 'search'\n else\n auth = session[:auth]\n if Tenant.find_by(:email => auth[\"info\"][\"email\"])\n flash[:notice] = 'Email already used.'\n redirect_to '/create'\n else \n user=Tenant.create_with_omniauth(session[:auth])\n session[:user_id] = user.id\n render 'search'\n end\n end\n end",
"def assign_suspended_tenant_to_shard(args = {}) \n put(\"/shards.json/#{args[:shardId]}/tenant/#{args[:tenantId]}\", args)\nend",
"def create_tenant\n Apartment::Tenant.create(account.tenant) do\n initialize_account_data\n Hyrax::Workflow::WorkflowImporter.load_workflows\n end\n end",
"def within_transaction(object); end",
"def new_tenant()\n Thread.current[:tenant_id] = Factory(:tenant).id\n end",
"def set_tenant_and_account\n @account = current_user.account\n set_current_tenant @account\n end",
"def set_tenant\n @tenant = Tenant.find(params[:id])\n rescue ActiveRecord::RecordNotFound \n redirect_to root_url\n return\n end",
"def create_tenant!\n Apartment::Tenant.create(tenant_name) unless tenant_name.blank?\n end",
"def create_tenant\n \t#password = Base64.encode64(Digest::SHA1.digest(\"#{rand(1<<64)}/#{Time.now.to_f}/#{Process.pid}/#{userid}\"))[0..7]\n \tPgTools.create_tenant(userid, db_password)\n end",
"def add_user_for_tenant(args = {}) \n post(\"/tenants.json/#{args[:tenantId]}/users\", args)\nend",
"def set_current_tenant_id\n Tenant.current_id = self.id\n end",
"def set_tenant\n @tenant = Tenant.find(params[:id])\n end",
"def set_tenant\n @tenant = Tenant.find(params[:id])\n end",
"def set_tenant\n @tenant = Tenant.find(params[:id])\n end",
"def set_tenant\n @tenant = Tenant.find(params[:id])\n end",
"def set_tenant\n @tenant = Tenant.find(params[:id])\n end",
"def set_tenant\n @tenant = Tenant.find(params[:id])\n end",
"def create\n @tenant = Tenant.new(tenant_params)\n authorize @tenant\n # @tenant.apartment_id = params[:apartment_id]\n # @tenant.apartment_id = @apartment.id\n @tenant.apartment = @apartment\n @tenant.save\n redirect_to apartment_path(@apartment)\n\n\n # respond_to do |format|\n # if @tenant.save\n # format.html { redirect_to @tenant, notice: 'tenant was successfully created.' }\n # format.json { render :show, status: :created, location: @tenant }\n # else\n # format.html { render :new }\n # format.json { render json: @tenant.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def with_tenant(tenant, options = {}, &block)\n previous_tenant = Multitenant.current_tenant\n Multitenant.current_tenant = tenant\n previous_extra_tenant_ids = Multitenant.extra_tenant_ids\n Multitenant.extra_tenant_ids = options[:extra_tenant_ids] if options[:extra_tenant_ids]\n yield\n ensure\n Multitenant.current_tenant = previous_tenant\n Multitenant.extra_tenant_ids = previous_extra_tenant_ids\n end",
"def set_transaction\n #@accounts.user = current_user\n @transaction = Transaction.find(params[:id])\n # @accounts = Account.find(current_user).balance\n end",
"def set_tenant_of\n @tenant_of = TenantOf.find_by(id: params[:id])\n @tenant = @tenant_of.user\n end",
"def set_tenant\n @tenant = Tenant.find_by(id: params[:id])\n redirect_to tenants_path, :flash => { :notice => \"#{APP_MSG['authorization']['failure']}\" } if @tenant.blank?\n end",
"def verify_tenant_access\n begin\n\n yield\n\n MultiTenant.pending_verification.each do |pending|\n rec, model = pending\n curr_id = MultiTenant.current_tenant.id\n\n multi_tenant_incr(rec)\n\n rec_tenant = rec.send(model)\n if rec_tenant.nil? then\n # if no tenant, then must be globally accessible\n multi_tenant_decr()\n return\n end\n\n other_id = rec_tenant.id\n if curr_id != other_id then\n # PANIC\n multi_tenant_reset()\n raise AccessException, \"illegal access: tried to access tenant.id=#{other_id}; current_tenant.id=#{curr_id}\"\n end\n\n multi_tenant_decr()\n end\n\n ensure\n MultiTenant.pending_verification.clear\n MultiTenant.current_tenant = nil\n end\n end",
"def set_tenant\n unless params[:id] == \"undefined\"\n @tenant = Tenant.find(params[:id])\n else\n redirect_to tenants_url\n end\n end",
"def add_tenant tenant\n\n # Tenant Validation\n if tenant.credit_rating == \"Bad\"\n p \"WARNING: Tenant #{tenant.name} has a BAD credit rating\"\n elsif @apt_tenants.size > @apt_bed\n p \"WARNING: Apartment is full\"\n else\n @apt_tenants << tenant\n p \"Tenant: #{tenant.name} is added to #{@apt_number}\"\n end\n\n end",
"def create\n @tenant = keystone.create_tenant({:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n \n format.html { redirect_to @tenant, :notice => 'Tenant was successfully created.' }\n format.json { render :json => @tenant, :status => :created, :location => @tenant }\n \n end\n end",
"def scaffold_transaction(&block)\n transaction(&block)\n end",
"def index\n @tenants = Tenant.all\n @tenants = policy_scope(Tenant).order(created_at: :desc)\n #@tenant = Tenant.find(params[:id])\n #@tenant = Tenant.find(params[:id])\n #tr4 = Apartment.find(6).tenants.first.first_name\n # => apartment(:id).tenants(@tenant)\n #@tenant = Apartment.find(params[:id]).tenants(tenant_params)\n\n end",
"def set_tenant_scope(args = {}) \n put(\"/tenants.json/scope/#{args[:tenantId]}\", args)\nend",
"def initiate_tenant( tenant )\n __milia_change_tenant!( tenant.id )\n end",
"def set_transaction\n @transaction = Transaction.includes(:period, :budget).where(periods: { budgets: { user: current_user }}).find(params[:transaction_id] || params[:id])\n end",
"def transaction(&block)\n block.call\n end",
"def create\n # Build a new Tenant object and set the values based on user input\n tenant = Tenant.new do |t|\n p = params[:tenant]\n t.name = p[:name]\n t.payment_handle = p[:payment_handle]\n t.phone_num = p[:phone_num]\n t.email = p[:email]\n end\n\n # Attempt to save the tenant\n if tenant.save # success\n redirect_to back_address(\"\"), notice: return_message(record: tenant, action: \"create\")\n\n else # fail\n # Create 'failed_edits' hash which stores all the values from the records that failed to get saved\n failed_edits = Hash.new\n failed_edits['new'] = params[:tenant]\n failed_edits['new']['errors'] = tenant.errors.keys.map(&:to_s)\n\n redirect_to back_address(failed_edits.to_param), notice: return_message(record: tenant, action: \"create\")\n end\n end",
"def evict_tenant\n\t\t#if @is_rental?\n\tend",
"def mapping_tenant\n @tenants = Tenant.where(:client_id => current_user.id, :is_active => true)\n @users = current_user.corporate_user\n end",
"def create_tenant(tenant, hostname, port=DEFAULT_SERVER_HTTPPORT)\n url=\"http://#{hostname}:#{port}/application/v2/tenant/#{tenant}\"\n http_request_put(URI(url), {})\n end",
"def create_on_backend\n lab = Lab.find(self.lab_id)\n Rails.logger.info \"Creating tenant #{self.name} on openstack backend #{lab.name}.\"\n\n # First, run through some checks to ensure we can create the whole tenant properly\n # Check if an external network exists\n admin_network_c = lab.get_neutron(lab.auth_tenant) \n ext_network = admin_network_c.list_networks.select {|n| n.external == true}\n if ext_network.empty?\n Rails.logger.error \"There are no external networks on the OpenStack host\"\n return false\n end\n\n # Check if there are enough available floating ips\n # There does not appear to be an api endpoint to check ips available for an instance to check out\n # TODO - Take another look at this.\n\n # Create the tenant\n identity_c = get_connection(\"identity\")\n identity_c.create_tenant({:name => self.name, :description => \"Created by OpenShift Labs app\", :enabled => true})\n tenant = identity_c.tenants.select {|t| t.name == self.name}.first\n if tenant.nil?\n Rails.logger.error \"Attempted to create tenant with name #{self.name}, but tenant does not exist after creation.\"\n return false\n else\n Rails.logger.info \"Created tenant #{self.name} with tenant id #{tenant.id}.\"\n self.uuid = tenant.id\n end\n\n # If any of the following fails, we need to be sure we delete the OpenStack backend tenant\n begin\n\n # Add the lab's user to the tenant\n # TODO the below assumes an admin role exists. Need to verify that this is always the case.\n role = identity_c.list_roles.select {|r| r[:name] == \"admin\"}.first\n admin_user = identity_c.list_users.select {|u| u.name == lab.username }.first\n Rails.logger.info \"Adding user #{admin_user.name} to the #{self.name} tenant.\"\n identity_c.add_user_to_tenant({:tenant_id => tenant.id, :role_id => role[:id], :user_id => admin_user.id})\n\n # Get the compute and neutron connections\n compute_c = get_connection(\"compute\")\n network_c = get_connection(\"network\")\n\n # Set the quotas appropriately\n # Works needs to be done in the ruby-openstack gem to support this.\n Rails.logger.info \"Setting #{self.name} tenant quotas.\"\n compute_c.set_limits(tenant.id, {:cores => lab.default_quota_cores,\n :floating_ips => lab.default_quota_instances,\n :instances => lab.default_quota_instances,\n :ram => lab.default_quota_ram\n })\n\n # Create a network\n network_name = self.name + \"-network\"\n Rails.logger.info \"Creating network with name #{network_name} for tenant #{self.name}.\"\n network = network_c.create_network(network_name, {:admin_state_up => true})\n self.network = network_name\n\n # Create a subnet\n subnet_name = self.name + \"-subnet\"\n # TODO nameservers are hard-coded, but could change. Need to have them entered somewhere.\n Rails.logger.info \"Creating subnet with name #{subnet_name} for tenant #{self.name}.\"\n subnet = network_c.create_subnet(network.id, \"192.168.1.0/24\", \"4\", {:name => subnet_name, :gateway_ip => \"192.168.1.1\", :enable_dhcp => true, :dns_nameservers => ['10.11.5.3', '10.11.5.4']})\n\n # Create a router and add interface to subnet\n router_name = self.name + \"-router\"\n # TODO we grab the first external network, we should have a user specify which one to use somewhere, in case there are multiple\n external_network = network_c.list_networks.select {|n| n.external == true }.first\n Rails.logger.info \"Creating router with name #{router_name} for tenant #{self.name}.\"\n router = network_c.create_router(router_name, true, {:external_gateway_info => {:network_id => external_network.id}})\n Rails.logger.info \"Adding router interface for subnet #{subnet_name} on router #{router_name}.\"\n network_c.add_router_interface(router.id, subnet.id)\n\n # Get the default security group\n # TODO we assume there is a default security group, probably not the best way to go about this.\n security_group = compute_c.security_groups.select {|k,v| v[:name] == \"default\"}\n self.security_group = \"default\"\n security_group_id = security_group.keys.first\n\n # Delete default security group rules\n Rails.logger.info \"Removing default Ingress security group rules for tenant #{self.name}.\"\n security_group[security_group_id][:rules].each do |rule|\n compute_c.delete_security_group_rule(rule[:id])\n end\n\n # Create necessary security group rules\n Rails.logger.info \"Creating all-open security groups rules for tcp, udp, and icmp on tenant #{self.name}\"\n compute_c.create_security_group_rule(security_group_id, \n {:ip_protocol => \"tcp\", :from_port => 1, :to_port => 65535, :cidr => \"0.0.0.0/0\"})\n compute_c.create_security_group_rule(security_group_id, \n {:ip_protocol => \"udp\", :from_port => 1, :to_port => 65535, :cidr => \"0.0.0.0/0\"})\n compute_c.create_security_group_rule(security_group_id, \n {:ip_protocol => \"icmp\", :from_port => -1, :to_port => -1, :cidr => \"0.0.0.0/0\"})\n\n # Allocate all necessary floating ips\n # TODO shouldn't just get the first pool, should have a dropdown and database entry in project\n Rails.logger.info \"Allocating #{lab.default_quota_instances} floating ips to tenant #{self.name}\"\n floating_ip_pool = compute_c.get_floating_ip_pools.first[\"name\"]\n lab.default_quota_instances.times do\n compute_c.create_floating_ip(:pool => floating_ip_pool)\n end\n \n Rails.logger.info \"Tenant #{self.name} creation completed.\"\n rescue => e\n Rails.logger.error \"Could not create OpenStack backend tenant due to:\"\n Rails.logger.error e.message\n Rails.logger.error e.backtrace\n destroy_backend\n end\n\n end",
"def create\n\n begin\n\n Account.transaction do\n\n @server = Server.where(:current => true).first\n raise \"A VersaFile server has not been defined\" if @server.nil?\n\n #1) Create account => set status to \"Pending\"\n @account = Account.new(params[:account])\n @account.trial_period = ((@account.account_type == VersaFile::AccountTypes.Trial) ? @account.trial_period : VersaFile::TrialStates.NoTrial)\n @account.status = VersaFile::AccountStates.Pending\n @account.created_by = @super_user.name\n @account.updated_by = @super_user.name\n\n unless @account.save\n raise_errors(@account.errors)\n end\n\n #2) Create ZoneNode(s) - don't deploy it yet\n params[:subdomains].each do |subdomain|\n\n @zone_node = @account.zone_nodes.create(\n :server => @server,\n :name => @account.name,\n :template_id => (params[:template].nil? ? VersaFile::CreationTemplates.None : params[:template]),\n :subdomain => subdomain[:name],\n :status => 0,\n :current_users => 0,\n :max_users => subdomain[:user_quota],\n :current_disk_space => 0,\n :max_disk_space => subdomain[:disk_quota].to_i * VersaFile::DiskSizes.Gigabyte,\n :deployed => false\n )\n\n unless @zone_node.valid?\n raise_errors( @zone_node.errors)\n end\n\n #Auto-deploy only if it is a trial -- if not wait for update.\n @zone_node.delay.zone_deploy if @account.account_type == VersaFile::AccountTypes.Trial\n\n end\n\n end\n\n respond_to do |format|\n format.html { redirect_to @account, notice: 'Account was successfully created.' }\n format.json { render json: @account.to_json(:except=>:password, :methods => [:subdomains, :template]), status: :created, location: @account }\n end\n\n rescue => e\n logger.error \"Account creation failed => #{e.message}\"\n respond_to do |format|\n format.json { render :json => e.message, :status => :unprocessable_entity }\n end\n end\n\n end",
"def add_tenant_to_specified_shard(args = {}) \n post(\"/tenants.json/shard/#{args[:shardId]}\", args)\nend",
"def set_tenant_and_account\n @account = Account.find_by(subdomain: request.subdomain)\n if @account.nil?\n redirect_to signup_account_not_found_url(subdomain: EXTERNAL_SUBDOMAIN)\n else\n set_current_tenant @account\n end\n end",
"def with_tenant(tenant, &block)\n Multitenant.current_tenant = tenant\n Multitenant.in_block = true\n save_and_change_default_scope_for_all\n yield\n ensure\n restore_default_scope\n Multitenant.in_block = false\n Multitenant.current_tenant = nil\n end",
"def tenant_id\n return @tenant_id\n end",
"def tenant_id\n return @tenant_id\n end",
"def tenant_id\n return @tenant_id\n end",
"def tenant_id\n return @tenant_id\n end",
"def update\n\n respond_to do |format|\n if @tenant.update(tenant_params)\n p_id = Property.searchSecond(@tenant.tenantbuildinginfo)\n Property.find_by(id: p_id).tenants << @tenant\n format.html { redirect_to @tenant, notice: 'Tenant was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenant }\n else\n format.html { render :edit }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n\n if params[:generate_lease]\n generate_lease(@tenant)\n elsif params[:expense_add]\n expense_addendum(@tenant)\n else\n #do nothing\n end\n\n end",
"def create\n assign_if_empty\n @tenant = Tenant.new(tenant_params)\n respond_to do |format|\n if @tenant.save\n format.html { redirect_to tenants_url, notice: 'Tenant was successfully created.' }\n format.json { render :show, status: :created, location: @tenant }\n else\n format.html { render :new }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def current_tenant\n\t\t@current_tenant ||= Tenant.find_by(id: session[:tenant_id])\n \tend",
"def set_transaction\n @transaction = Transaction.find(params[:id])\n check_admin\n end",
"def transaction(&blk)\n tap(&blk)\n end",
"def current_tenant\n ActsAsTenant.current_tenant\n end",
"def current_tenant\n ActsAsTenant.current_tenant\n end",
"def current_tenant\n ActsAsTenant.current_tenant\n end",
"def get_current_tenant \n get(\"/tenants.json/current\")\nend",
"def update\n data = tenant_update_params\n tookan = {\"api_key\": \"50646180f541481e4c422b614c5825431be3c2f82fd57936541c03\",\"customer_id\": @tenant.customer_id,\"user_type\": 0,\"name\": data[:name],\"phone\": data[:phone1],\"email\": data[:email],\"address\": data[:address],\"latitude\": data[:latitude],\"longitude\": data[:longitude]}\n response = RestClient.post \"https://api.tookanapp.com/v2/customer/edit\", tookan.to_json, :content_type => \"application/json\"\n response = JSON.parse(response)\n respond_to do |format|\n if response[\"status\"] == 200\n if @tenant.update(tenant_update_params)\n food_category = FoodCategory.find_or_create_by(name: \"Veg\")\n @tenant.tenant_details.update(food_category_id: food_category.id)\n if @tenant.active == true\n end\n end\n @tenant.update(:updated_by=>session[:kitchen_user_id])\n format.html { redirect_to tenants_url, notice: 'Tenant was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenant }\n else\n format.html { redirect_to tenants_url, notice: 'Tenant was not updated.' }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\nend",
"def add_tenant(new_tenant)\n if @bedrooms < @tenants.count\n @tenants.push(new_tenant)\n\n elsif @bedrooms >= @tenants.count\n \"No more tenants can be added\"\n end\n end",
"def tenant\n TenantView.new(space.tenant)\n end",
"def begin_db_transaction() end",
"def begin_db_transaction() end",
"def transaction(&block)\n yield\n end",
"def transaction(&block)\n yield\n end",
"def getTransactions\n\t\t\n\tend",
"def create_external_resources\n create_account_inline && account.save && create_tenant\n end",
"def transaction\n start_transaction\n\n yield\n ensure\n end_transaction if transaction_started?\n end",
"def transaction(&block)\n @@semaphore.synchronize{\n block.call\n }\n end",
"def transactions\n\t\t@connection.savepoint\n\tend",
"def tenant_params\n params.require(:tenant).permit(:tenant_name, :address_line1, :address_line2, :city, :state, :country, :pincode, :parent_tenant_id, :companytype_id,:isactive)\n end",
"def transactions\n @connection.savepoint\n end",
"def transaction(&block)\n raise InvalidDbError if @stale\n\n return transaction_in_staging(true, &block) if self.staging?\n\n begin\n transaction_in_staging(false, &block)\n ensure\n self.unstage\n end\n end",
"def initialize_tenant!\n @database_schema_file = Rails.root.join('db', 'schema.rb')\n @database_seeds_file = Rails.root.join('db', 'seeds.rb')\n \n Customer.transaction do\n Apartment::Tenant.process(tenant_name) do\n load(@database_schema_file)\n load(@database_seeds_file) if Apartment.seed_after_create\n end\n end\n \n return true\n end",
"def tenant_id=(value)\n @tenant_id = value\n end",
"def tenant_id=(value)\n @tenant_id = value\n end",
"def tenant_id=(value)\n @tenant_id = value\n end",
"def tenant_id=(value)\n @tenant_id = value\n end",
"def create\n @tenant = Tenant.new(params[:tenant])\n\n respond_to do |format|\n if @tenant.save\n format.html { redirect_to(@tenant, :notice => 'tenant was successfully created.') }\n format.xml { render :xml => @tenant, :status => :created, :location => @tenant }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @tenant.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def begin_transaction\n return System.begin_transaction\n end",
"def post_transaction_process\n bet_wallet.persist_wallet!\n end",
"def current_tenant\n if params[:tenant_id].present?\n tenant = Tenant.find(params[:tenant_id])\n else\n Tenant.last\n end\n end",
"def save\n\t\t@connection.transactions.save\n\tend",
"def commit_db_transaction() end",
"def commit_db_transaction() end",
"def lease!\n Apartment::Tenant.create(leaser_name)\n end",
"def transactions_to_db\n\n end",
"def pp_tenant( tenant, do_flat=true )\n \tloc.pp_tenant( tenant, do_flat );\n end",
"def create\n @tenant = Tenant.new(tenant_params)\n\n respond_to do |format|\n if @tenant.save\n redirect_to tenants_dashboard_path\n else\n format.html { render :new }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def in_transaction(opts = {})\n yield\n end",
"def create\n @tenant = current_account.tenants.build(tenant_params)\n respond_to do |format|\n if @tenant.save\n TenantMailer.new_tenant_notification(@tenant, current_user).deliver_now\n format.html { redirect_to @tenant, notice: @tenant.name + ' was successfully created.' }\n format.json { render :show, status: :created, location: @tenant }\n else\n format.js { render :new, notice: @tenant.errors }\n format.html { render :new }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.6950582",
"0.6950582",
"0.6789479",
"0.67725646",
"0.6745909",
"0.6745909",
"0.6745909",
"0.66731495",
"0.66731495",
"0.6652706",
"0.66163355",
"0.6574344",
"0.65256685",
"0.6512877",
"0.64912224",
"0.6490651",
"0.64855635",
"0.64842343",
"0.64813507",
"0.64507824",
"0.64311355",
"0.64220357",
"0.6404988",
"0.6400374",
"0.638368",
"0.6361643",
"0.6361643",
"0.6361643",
"0.6361643",
"0.6361643",
"0.6361643",
"0.63551456",
"0.6350782",
"0.6343268",
"0.63145894",
"0.63104624",
"0.6293031",
"0.629203",
"0.6277852",
"0.6247089",
"0.62390816",
"0.6168877",
"0.61672276",
"0.6147693",
"0.6147656",
"0.6145718",
"0.61316067",
"0.61261255",
"0.6102557",
"0.60768014",
"0.60522366",
"0.6047255",
"0.6028666",
"0.6024974",
"0.6002335",
"0.6002258",
"0.6002258",
"0.6002258",
"0.6002258",
"0.60010517",
"0.599945",
"0.59829736",
"0.59813374",
"0.5971948",
"0.59690845",
"0.59690845",
"0.59690845",
"0.5968489",
"0.59659654",
"0.5957121",
"0.59566987",
"0.5943868",
"0.5943868",
"0.59294295",
"0.59294295",
"0.59283787",
"0.5920411",
"0.5917779",
"0.5908376",
"0.5907457",
"0.590116",
"0.58983916",
"0.58969104",
"0.58819044",
"0.5863866",
"0.5863866",
"0.5863866",
"0.5863866",
"0.5855643",
"0.58485085",
"0.58433485",
"0.5842394",
"0.58384174",
"0.5824766",
"0.5824766",
"0.5812098",
"0.5783112",
"0.5764728",
"0.57636976",
"0.5762218",
"0.57604575"
] |
0.0
|
-1
|
==== Tenant notification =====
|
def notify_approaching_reservation_to_tenant(reservation)
@reservation = reservation
@tenant = @reservation.user
@cookoon = @reservation.cookoon
@host = @cookoon.user
mail(to: @tenant.full_email, subject: 'Votre location Cookoon se rapproche !')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def tenant_notification(tenant)\n @header_img_name = 'rental_confirm'\n \n setup_email tenant.email, 'USSelfStorageLocator.com <info@usselfstoragelocator.com>', \"Your #{tenant.listing.storage_type.try(:titleize) || 'Self Storage'} Rental\"\n @body[:tenant] = tenant\n @body[:rental] = tenant.rental\n end",
"def notifications\n end",
"def create\n @tenant = Tenant.new(tenant_params)\n \n p_id = Property.searchSecond(@tenant.tenantbuildinginfo)\n Property.find_by(id: p_id).tenants << @tenant\n respond_to do |format|\n if @tenant.save\n # if (@tenant.renewal == true)\n # UserMailer.delay(run_at: @tenant.leaseend - 3.months).reminder_email(@tenant)\n # end\n format.html { redirect_to @tenant, notice: 'Tenant was successfully created.' }\n format.json { render :show, status: :created, location: @tenant }\n else\n format.html { render :new }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_notifications\n end",
"def create_notification; end",
"def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end",
"def atest_ID_25861_suspended_user_notification()\n # Need suspended account\n end",
"def send_notification\n\n\n end",
"def subscriber_notice_approval_alert\n BrandMailer.subscriber_notice(\n brand: Brand.find_by(company_name: 'Brand Nine'),\n stage: 'approval_alert'\n )\n end",
"def send_email_changed_notification; end",
"def notify_user(ad)\n #create notification for the user\n notification = self.notifications.unviewed.event(:new_relevant_ad).new\n notification.user = self.user\n notification.ad = ad\n notification.save!\n end",
"def notify_subscribers\n AdminMailer.notify_of_standard_change(self)\n end",
"def notification_subject_publish(brother)\n if (brother == self.brother)\n return \"[Voucher] You Just Created a Voucher\"\n else\n return \"[Voucher] Voucher request from: \" + self.brother.display_name\n end\n end",
"def create\n @tenant = current_account.tenants.build(tenant_params)\n respond_to do |format|\n if @tenant.save\n TenantMailer.new_tenant_notification(@tenant, current_user).deliver_now\n format.html { redirect_to @tenant, notice: @tenant.name + ' was successfully created.' }\n format.json { render :show, status: :created, location: @tenant }\n else\n format.js { render :new, notice: @tenant.errors }\n format.html { render :new }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n # notification_email\n end",
"def notification\n doctor = Doctor.first\n DoctorMailer.notification(doctor)\n end",
"def notification_about_deployment(to, project, environment, revision, user, from = self.from, sent_on = Time.now, subject = \"New version deployed on #{sent_on.strftime('%c')} by #{user}\")\n subject subject\n recipients to\n from from\n sent_on sent_on\n body :project => project, :environment => environment, :sent_on => sent_on, :revision => revision, :user => user\n content_type \"text/plain\"\n end",
"def create\n # I want a user to get a notification in respnose to this action if:\n # 1) they have not gotten a notification today\n # 2) they have gotten a notification today, _but_, it was from a separate region trigger\n\n # I don't want a user to get this notification if:\n # 1) They've already received 2 notifications today\n # 2) They've received an automatically generated entry today\n\n # AKA, a user can receive either 1 auto entry or up to 2 region entries\n logs = @current_user.todays_entry_logs\n if !Rails.env.production? || logs.length == 0 || logs.length < 2 && logs.first.is_region?\n entry = Entry.find_by_id(region_params[:identifier].to_i)\n @current_user.add_entry_to_diary(entry)\n end\n end",
"def admin_notify\n UserMailer.signup_notification(self).deliver_later!(wait: 1.minute)\n end",
"def send_email_changed_notification?; end",
"def notify_change\n SpecificNodeMailer.notify_change\n end",
"def send_booking_confirmation_notifications\n\n notify_manager_confirmation\n notify_customer\n \n end",
"def firecloud_api_notification(current_status, requester=nil)\n unless Rails.application.config.disable_admin_notifications == true\n @admins = User.where(admin: true).map(&:email)\n @requester = requester.nil? ? 'no-reply@broadinstitute.org' : requester\n @current_status = current_status\n unless @admins.empty?\n mail(to: @admins, reply_to: @requester, subject: \"[Unity Admin Notification#{Rails.env != 'production' ? \" (#{Rails.env})\" : nil}]: ALERT: FIRECLOUD API SERVICE INTERRUPTION\") do |format|\n format.html\n end\n end\n end\n end",
"def get_current_tenant_maintenance_window \n get(\"/tenants.json/maintenance\")\nend",
"def notify_superusers_of_access_request(applicant)\n superusers_emails = User.get_superuser_emails\n @user = applicant\n mail(:to => superusers_emails,\n :from => APP_CONFIG['account_request_admin_notification_sender'],\n :reply_to => @user.email,\n :subject => PREFIX + \"There has been a new access request\")\n end",
"def notify\n return if @user.email.blank?\n\n Notifier.user_event_analisys(@user, @user.events.future.analisys.first).deliver_now if @user.events.future.analisys.present?\n Notifier.user_event_visit(@user, @user.events.future.visits.first).deliver_now if @user.events.future.visits.present?\n end",
"def send_new_listing_notification(merchant)\n @merchant = merchant\n mail to: \"sales@halalfoodhunt.com\", subject: \"A New Merchant has Subscribed!\"\n end",
"def notify_via_service\n u = User.first\n u.update(last_notification_mail_sent: 30.days.ago)\n service = NotificationDigest.new(type: :notifications)\n service.notify_user(u, deliver: false)\n end",
"def notification_on_create\n create_notification(:create)\n end",
"def subscriber_notice_subscription_paid\n BrandMailer.subscriber_notice(\n brand: Brand.find_by(company_name: 'Brand Nine'),\n stage: 'subscription_paid'\n )\n end",
"def notify_administrators!\n AdminMailer.new_pending_interest_point(self).deliver!\n end",
"def notify\n {\n }\n end",
"def notify\n {\n }\n end",
"def send_devise_notification(notification, *args); end",
"def parent_registration_alert(user)\n\t\t@user = user\n\t\tsendgrid_category 'Parent Registration Alert'\n\t\tmail subject: \"Parent \\\"#{user.email}\\\" has registered\", to: ADMIN_EMAIL\n\tend",
"def subscriber_notice_awaiting_payment\n BrandMailer.subscriber_notice(\n brand: Brand.find_by(company_name: 'Brand Nine'),\n stage: 'awaiting_payment'\n )\n end",
"def call_transaction_mailer(tenant,gate)\n ActsAsTenant.current_tenant = nil\n @tenant = tenant\n @gate = gate\n mail(subject: 'Call Transaction', to: 'mayank.jani@softwebsolutions.com')\n end",
"def execute\n puts \"*********************\"\n Tenant.all.each do |tenant|\n puts tenant.subdomain\n begin\n if PackageConfig::PAY_AS_YOU_GO.eql? tenant.plan_bid.to_s\n tenant_minutes = (tenant.call_minutes.to_i - tenant.credit_minutes.to_i)\n\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant minutes - #{tenant_minutes}\")\n\n if tenant.tenant_notification.nil?\n tenant_notification = TenantNotification.new\n tenant_notification.tenant_id = tenant.id\n tenant_notification.pay_as_you_go = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification created - pay as you go\")\n else\n tenant_notification = tenant.tenant_notification\n tenant_notification.pay_as_you_go = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification updated - pay as you go\")\n end\n\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - not overage_transaction\")\n\n if tenant_minutes > 100\n overage_transaction(tenant, \"call minutes\", :call_minutes, 0)\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - overage_transaction\")\n end\n\n tenant_minutes = (tenant.call_minutes.to_i - tenant.credit_minutes.to_i)\n if (tenant_minutes >= 90 or tenant_minutes >= 350) && !tenant_notification.pay_as_you_go.present?\n ClientMailer.delay.minutes_running_low(tenant)\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - minutes running low - pay as you go\")\n end\n end\n\n if PackageConfig::MINUTE_200.eql? tenant.plan_bid.to_s\n if tenant.tenant_notification.nil?\n tenant_notification = TenantNotification.new\n tenant_notification.tenant_id = tenant.id\n tenant_notification.minutes200 = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification created - 200 minutes\")\n else\n tenant_notification = tenant.tenant_notification\n tenant_notification.minutes200 = 0\n tenant_notification.save\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - tenant notification updated - 200 minutes\")\n end\n\n tenant_minutes = (tenant.call_minutes.to_i - tenant.credit_minutes.to_i)\n if tenant_minutes >= 350 && !tenant_notification.minutes200.present?\n ClientMailer.delay.minutes_running_low(tenant)\n ClientMailer.delay.call_transaction_mailer(tenant,\"execute - minutes running low - 200 minutes\")\n end\n end\n\n #if tenant.menu_minutes > 100\n # overage_menu_minutes(tenant)\n # ClientMailer.delay.call_transaction_mailer(tenant,\"execute - overage_transaction - menu minutes\")\n #end\n #if tenant.mail_minutes > 100\n # overage_mail_minutes(tenant)\n # ClientMailer.delay.call_transaction_mailer(tenant,\"execute - overage_transaction - mail minutes\")\n #end\n rescue => e\n puts \"ERROR: #{e}\"\n end\n\n end\n end",
"def on_subscription_success\n end",
"def paid_request_to_tenant(reservation)\n @reservation = reservation\n @tenant = @reservation.user\n @cookoon = @reservation.cookoon\n @host = @cookoon.user\n mail(to: @tenant.full_email, subject: 'Vous avez demandé un Cookoon !')\n end",
"def publish\n update!(email_status: \"verified\", published_at: Time.now.utc)\n end",
"def notification\n user = User.first\n comic = Comic.first\n SubscriptionMailer.notification(work: comic, user: user)\n end",
"def subscriber_notice_subscription_renewal\n BrandMailer.subscriber_notice(\n brand: Brand.find_by(company_name: 'Brand Nine'),\n stage: 'subscription_renewal'\n )\n end",
"def notify_awaiting_request_to_host(reservation)\n @reservation = reservation\n @tenant = @reservation.user\n @cookoon = @reservation.cookoon\n @host = @cookoon.user\n mail(to: @host.full_email, subject: \"Rappel: #{@tenant.first_name} souhaite louer votre Cookoon !\")\n end",
"def notify\n @transaction_id = params[:transaction_id]\n do_notify\n end",
"def reminder_sent\n end",
"def notify_updating\n @msg = \"Deployment Started\"\n post\n end",
"def notifications\n @campus_id = current_user.campus_users.first.campus_id\n invi_status=CRUD::Utility::Invitations.new(@campus_id)\n data = invi_status.get_request_sent\n render :json=>{:data=>data}\n end",
"def get_current_tenant \n get(\"/tenants.json/current\")\nend",
"def check_notification\n referral = self\n admin = referral.job.admin\n\n if referral.is_interested == true && referral.is_admin_notified == false\n # binding.pry\n if referral.update_attribute(:is_admin_notified, true)\n ReferralMailer.deliver_admin_notification(referral, admin)\n referral.save\n else\n render 'edit', error: \"We had an issue with your referral request. Please try again.\"\n end\n end\n end",
"def notification\n BookingMailer.notification\n end",
"def notify_host\n OrganisationMailer.notify_host\n end",
"def notify_deploy\n Bug.transaction do\n find_bug\n\n list = @bug.notify_on_deploy\n\n if list.include?(current_user.id)\n list.delete current_user.id\n else\n list << current_user.id\n end\n\n @bug.notify_on_deploy = list\n @bug.save!\n end\n\n respond_to do |format|\n format.json { render json: decorate_bug(@bug), location: project_environment_bug_url(@project, @environment, @bug) }\n end\n end",
"def show\n if (current_user.tenant?)\n @tenant = current_user.tenant\n if (@tenant == nil)\n @tenant=Tenant.first\n params[:notice]=\"No user could be found with that email.\"\n end\n end\n end",
"def send_admin_notification\n Notifications.send_admin_notification(User.admin, self).deliver\n end",
"def alteration_approve\n UserNotifier.deliver_in_process(self, user)\n end",
"def message\n \"You have a new notification!\"\n end",
"def create_tenant\n Apartment::Tenant.create(params[:id])\n Apartment::Tenant.switch!(params[:id])\n\n\n redirect_to entreprise_path(enterprise_id: params[:entreprise])\n flash[:alert] = \"Tenant...#{Apartment::Tenant.current}\"\n end",
"def send_new_booking_request_notifications\n\n if pay_now\n notify_manager_pay_now\n notify_request_to_customer_pay_now\n else\n notify_manager\n notify_request_to_customer\n end\n\n end",
"def current_tenant\n ActsAsTenant.current_tenant\n end",
"def current_tenant\n ActsAsTenant.current_tenant\n end",
"def current_tenant\n ActsAsTenant.current_tenant\n end",
"def signed_up_alert(evt)\n @evt = evt\n host = User.find_by_id(@evt.user_id)\n mail(:to => host.email, :subject => \"There is a seat request for your Local Yum event\", :from => \"\\\"Local Yum\\\" <notification@localyum.me>\")\n end",
"def tutor_reserved_notification\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def notifications_for_principal(principal_uri)\n end",
"def notify(doctor ,recipient, subject, text)\n subject += \" sent to: #{recipient}, by: #{doctor.full_name}\" \n\t\tadmin_assists = AdminAssistant.all \n if admin_assists\n admin_assists.each do |adm|\n custom_email(adm, subject, text)\n end\n end\n end",
"def old_notify_user (listing, sender, receiver)\n send_as :notification\n from sender.facebook_session.user \n recipients receiver.facebook_session.user\n #fbml \"<a href='#{FB_APP_HOME_URL}/listings/#{listing.id}'><b>#{listing.title}</b></a> has been approved.\"\n fbml \"Your listing: <a href='#{listings_path(listing.id)}}'><b>#{listing.title}</b></a> has been approved.\"\n end",
"def notify_admin_about_newbie(user)\n @user = user\n mail \n end",
"def create\n super\n # slack通知\n c = Payment.create_customer(resource.email, resource.name)\n resource.update(pay_customer_id: c.id)\n notifier = Slack::Notifier.new(Rails.application.config.slack_webhook_url)\n notifier.ping(\"新しく管理人が登録されました!\")\n end",
"def create_notification\n subject = \"#{student_request.name} \"\n body = \"#{student_request.name} (#{student_request.email}) needs tutorial.\"\n tutor_request.notify(subject, body, self)\n end",
"def admin_emails\n # Must run this against proper tenant database\n Apartment::Tenant.switch(tenant) do\n Site.instance.admin_emails\n end\n end",
"def admin_emails\n # Must run this against proper tenant database\n Apartment::Tenant.switch(tenant) do\n Site.instance.admin_emails\n end\n end",
"def send_admin_notification_email\n #Notifies admin of the registration\n UserMailer.new_user(self).deliver\n end",
"def allow_notification?\n true\n end",
"def notify_resource_owner(request, user)\n @request = request\n @user = user\n @url = request_url(@request)\n \n mail :to => @user.email\n end",
"def notify\n end",
"def send_to_revision profile\n @profile = profile\n\n mail to: Rails.application.secrets.admins_emails\n end",
"def notify \n hosts = get_entity(\"hoststatus\")\n services = get_entity(\"servicestatus\")\n \n unless hosts.empty? and services.empty?\n @config[:subscribers].each do |subscriber|\n Notifier.send_notification({\n :hosts => hosts,\n :services => services,\n\n :from => @config[:smtp_settings][:user_name],\n :to => subscriber,\n :subject => @config[:subject],\n template: \"#{@config[:conf_dir]}/notification.html.erb\"\n }).deliver\n end\n else\n @logger.info(\"No hosts or services were found.\")\n end\n end",
"def send_notifications\n send_new_post_to(:person) if self.person.notify_on_response_posted\n send_new_post_to(:receiver) if self.receiver && self.receiver.notify_on_response_received\n end",
"def employeer_notification\n NotificationMailer.employeer_notification\n end",
"def notify\n {\n \"log_group_name\" => @config[\"log_group_name\"],\n \"log_stream_name\" => @config[\"log_stream_name\"]\n }\n end",
"def invite\n Notifications.invite\n end",
"def super_active_users_retention\n \n end",
"def new_tenant()\n Thread.current[:tenant_id] = Factory(:tenant).id\n end",
"def post_approve_email\n NotificationMailer.post_approve_email('default@email.com')\n end",
"def notify(type,subject,target=nil)\n self.notices.create :type => type, :subject => subject, :target => target\n end",
"def twiki_created_notification(person, options={})\n @person = person\n mail(:to=>[@person.personal_email],\n :subject=>options[:subject] || \"Twiki account information (\"+@person.email+\")\",\n :date=>Time.now)\n end",
"def send_admin_mail\n AdministratorMailer.new_user_waiting_for_approval(self).deliver_now\n end",
"def admin_story_email\n NotificationsMailer.admin_story_email(Story.first)\n end",
"def notify(res_type, key, data) \n\t\t\traise \"Called notify without active deployment!\" if MU.mommacat.nil?\n\t\t\tMU.mommacat.notify(res_type, key, data)\n\t\tend",
"def notify_admins\n team.admins.each do |admin|\n admin.send_email(:team_account_funded_admin, team_payin: self) unless admin.id == person.id\n end\n end",
"def send_notification(user_alias, message, base_uri = 'https://notifiable-staging.herokuapp.com', access_id = ENV['ACCESS_ID'], secret_key = ENV['SECRET_KEY'])\n sender = Notifiable::Sender.new access_id, base_uri: base_uri, secret_key: secret_key\n sender.send_notification_to_users([user_alias], message: message)\nend",
"def changes_notification\n NotifierMailer.changes_notification(User.limit(2), {\n title: 'Email test title',\n content: 'Email test content',\n body: 'Email test body'\n })\n end",
"def notification(params)\n mail(params)\n end",
"def notify_ready\n appointment = Appointment.find(params[:appointment_id])\n flash[:danger] = 'Patient has not checked in' unless appointment.checked_in?\n appointment.push_notify_ready\n redirect_to admin_appointments_path(@admin)\n end",
"def saw_notification\n current_user.notice_seen = true\n current_user.save\n end",
"def send_ready_notification\n\n end",
"def send_approve_email\n 'send_approve_email'\n end",
"def notify_company_admin(admin, task_submission)\n @submitter = task_submission.submitter\n\n I18n.with_locale(admin.locale) do\n mail(to: admin.email, subject: I18n.t(\"tskz.notifier.requesting_approval_of_tasks\", name: @submitter.full_name), track_opens: true)\n end\n end",
"def after_registration\n send_pending_messages\n end"
] |
[
"0.7523809",
"0.6611643",
"0.6377483",
"0.63216186",
"0.6276264",
"0.62708396",
"0.62708396",
"0.6219926",
"0.620107",
"0.6186556",
"0.6165063",
"0.614687",
"0.6116051",
"0.6088869",
"0.6049955",
"0.60401434",
"0.6025788",
"0.59896827",
"0.59855264",
"0.5979489",
"0.59681267",
"0.5938857",
"0.592835",
"0.5910524",
"0.5897707",
"0.58933634",
"0.58907497",
"0.58893293",
"0.5857635",
"0.58564425",
"0.5852302",
"0.5845988",
"0.5845988",
"0.5841017",
"0.580904",
"0.5806216",
"0.5793665",
"0.5775398",
"0.5773113",
"0.57671005",
"0.57658905",
"0.57638305",
"0.57630146",
"0.57410055",
"0.57318616",
"0.5725372",
"0.57215524",
"0.5720794",
"0.5699225",
"0.5698602",
"0.5697386",
"0.5690784",
"0.5677062",
"0.56750584",
"0.5670061",
"0.5658672",
"0.56570226",
"0.56564",
"0.56518066",
"0.5627842",
"0.5627842",
"0.5627842",
"0.56212777",
"0.56209874",
"0.5616416",
"0.56154364",
"0.5615391",
"0.5597825",
"0.5597088",
"0.5595247",
"0.5591975",
"0.5591975",
"0.55911696",
"0.5589372",
"0.5588343",
"0.55781627",
"0.5567229",
"0.55654067",
"0.55639213",
"0.5562849",
"0.5559076",
"0.55527997",
"0.5551667",
"0.5548976",
"0.55316156",
"0.5529301",
"0.5529094",
"0.5524126",
"0.55236655",
"0.55213594",
"0.5520885",
"0.55175084",
"0.5513246",
"0.5510527",
"0.55063593",
"0.55061936",
"0.55059874",
"0.55054206",
"0.5504159",
"0.54976887"
] |
0.64689314
|
2
|
==== Host transaction =====
|
def paid_request_to_host(reservation)
@reservation = reservation
@tenant = @reservation.user
@cookoon = @reservation.cookoon
@host = @cookoon.user
mail(to: @host.full_email, subject: "#{@tenant.first_name} souhaite louer votre Cookoon !")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def transaction(&block); end",
"def within_transaction; end",
"def within_transaction; end",
"def transaction; end",
"def transaction; end",
"def transaction; end",
"def transaction(&blk)\n tap(&blk)\n end",
"def use_transactions; end",
"def use_transactions; end",
"def within_transaction(object); end",
"def begin_transaction\n return System.begin_transaction\n end",
"def begin_db_transaction() end",
"def begin_db_transaction() end",
"def transaction(&block)\n block.call\n end",
"def transaction(&block)\n yield\n end",
"def transaction(&block)\n yield\n end",
"def transaction\n start_transaction\n\n yield\n ensure\n end_transaction if transaction_started?\n end",
"def commit_db_transaction() end",
"def commit_db_transaction() end",
"def transaction(&block)\n yield\n commit\n end",
"def on_prepare_transaction_commit(unit, transaction); end",
"def transaction(&block)\n @@semaphore.synchronize{\n block.call\n }\n end",
"def begin_db_transaction\n execute(\"BEGIN\")\n end",
"def begin_db_transaction\n execute(\"BEGIN\")\n end",
"def transact; end",
"def commiter() end",
"def transaction\n start\n yield self\n rescue Object => ex\n rollback\n debug \"#{ex.class}: #{ex.message}\"\n ex.backtrace.each { |line| debug line }\n else\n commit\n end",
"def begin\n self.transaction_count += 1\n end",
"def transaction(&block)\n self['AutoCommit'] = false\n self.do_transaction(&block)\n self['AutoCommit'] = true\n end",
"def transaction(options={}, &block)\n connection.transaction(options.update(:requires_new => true), &block)\n end",
"def begin_db_transaction\n @transaction = @connection.transaction('READ COMMITTED')\n end",
"def commit()\n #This is a stub, used for indexing\n end",
"def TransactionBegin()\n\t@dbh.do(\"BEGIN\")\nend",
"def transactions\n\t\t@connection.savepoint\n\tend",
"def commit; end",
"def commit; end",
"def commit; end",
"def begin\n db.transaction do\n yield\n end\n end",
"def checked_transaction(opts=OPTS)\n use_transaction?(opts) ? db.transaction({:server=>this_server}.merge!(opts)){yield} : yield\n end",
"def checked_transaction(opts=OPTS)\n use_transaction?(opts) ? db.transaction({:server=>this_server}.merge!(opts)){yield} : yield\n end",
"def transaction(&block)\n raise InvalidDbError if @stale\n\n return transaction_in_staging(true, &block) if self.staging?\n\n begin\n transaction_in_staging(false, &block)\n ensure\n self.unstage\n end\n end",
"def with_transaction(&block)\n base_model.transaction(&block)\n end",
"def in_transaction(opts = {})\n yield\n end",
"def transaction_disabled=(_arg0); end",
"def transactions\n @connection.savepoint\n end",
"def transaction(&block)\n ActiveRecord::Base.transaction(&block)\n end",
"def begin_db_transaction\n log('BEGIN', 'TRANSACTION') { @connection.begin }\n end",
"def commit_transaction(tx)\n tx.execute\n end",
"def commit_transaction\n\t super\n\t \n\t # Update the task arguments. The original\n\t # Roby::Task#commit_transaction has already translated the proxy\n\t # objects into real objects\n\t arguments.each do |key, value|\n\t\t__getobj__.arguments.update!(key, value)\n\t end\n\n execute_handlers.each do |h|\n __getobj__.execute(h.as_options, &h.block)\n end\n poll_handlers.each do |h|\n __getobj__.poll(h.as_options, &h.block)\n end\n\n __getobj__.abstract = self.abstract?\n if @fullfilled_model\n __getobj__.fullfilled_model = @fullfilled_model.dup\n end\n __getobj__.do_not_reuse if !@reusable\n\tend",
"def receive_transaction\n end",
"def receive_transaction\n end",
"def commit_transaction\n\t super\n\n\t arguments.dup.each do |key, value|\n if value.respond_to?(:transaction_proxy?) && value.transaction_proxy?\n\t\t arguments.update!(key, value.__getobj__)\n\t\tend\n\t end\n\tend",
"def transaction(message, &block)\n store.transaction(message, &block)\n end",
"def test_transactions(table=\"test_monetdb_transactions\", columndefs=['col1 INT', 'col2 VARCHAR(255)'])\n test_create_table(table, columndefs)\n \n data = [1, 'aa'] \n values = \"\"\n \n data.each do |d| values += '\\'' + d.to_s + '\\'' + ',' end\n values = values.chop # remove last ',' character \n \n insert = \"INSERT INTO \" + table + \" VALUES \" + \" ( \" + values + \" )\"\n \n @db.query('START TRANSACTION')\n @db.auto_commit(flag=false) # if @db.auto_commit?\n @db.query(insert)\n\n @db.query(\"COMMIT\") \n \n res = @db.query('SELECT * FROM ' + table)\n rows_committed = res.fetch_all\n res.free\n \n # create a save point\n @db.save\n @db.query(\"SAVEPOINT #{@db.transactions} ;\")\n \n @db.query(insert)\n \n # rollback to savepoint\n @db.query(\"ROLLBACK TO SAVEPOINT #{@db.transactions};\")\n @db.release\n \n res = @db.query('SELECT * FROM ' + table)\n rows_rolled_back = res.fetch_all\n res.free\n \n assert_equal(rows_committed, rows_rolled_back)\n \n # restore autocommit for remaining tests\n @db.auto_commit(flag=true) \n end",
"def test_transaction\n conn_subscribe make_destination\n\n @conn.begin \"txA\"\n @conn.publish make_destination, \"txn message\", 'transaction' => \"txA\"\n\n @conn.publish make_destination, \"first message\"\n\n msg = @conn.receive\n assert_equal \"first message\", msg.body\n\n @conn.commit \"txA\"\n msg = @conn.receive\n assert_equal \"txn message\", msg.body\n checkEmsg(@conn)\n end",
"def transaction(mode = :deferred, &block)\n @db.transaction(mode, &block)\n end",
"def transaction\n raise Mysql::Error, 'Not Connected' if @my.nil?\n\n if block_given?\n begin\n @my.query('START TRANSACTION WITH CONSISTENT SNAPSHOT')\n yield # Start executing the query black.\n @my.query('COMMIT')\n rescue Mysql::Error => e\n @my.query('ROLLBACK')\n raise e\n end\n end\n end",
"def perform( &block )\r\n @transaction_strategy.perform( &block )\r\n end",
"def transaction(opts={:auto_enable => false})\n @transaction_level||=0\n @transaction_level+=1\n session do\n raise_if_transaction_running\n @transaction ||= true\n raise Error.cannot_obtain_transaction_lock if not lock_transaction\n begin\n yield\n # get_transaction in case cfgsave or cfgenable was run in transaction block\n # if there is no transaction we do not need to run it\n # if there is transaction but opend by someone else then t\n cfg_save if @transaction_level==1 && get_transaction\n rescue => e\n abort_transaction\n raise e\n end \n end\n ensure\n @transaction_level-=1\n @transaction = nil if @transaction_level==0\n end",
"def transaction(opts={}, &blk)\n Toshi.db.transaction(opts, &blk)\n end",
"def execute\n Trade.transaction do\n execute_without_transaction!\n end\n end",
"def begin_db_transaction() \n log('Opening boxcar', 'begin_db_transaction()')\n @command_boxcar = []\n end",
"def commit_transaction\n # The relation graph handling is a bit tricky. We resolve the graphs\n # exclusively using self (NOT other) because if 'other' was a new\n # task, it has been already moved to the new plan (and its relation\n # graph resolution is using the new plan's new graphs already)\n\n super\n\n if @executable != __getobj__.instance_variable_get(:@executable)\n __getobj__.executable = @executable\n end\n\n finalization_handlers.each do |handler|\n __getobj__.when_finalized(handler.as_options, &handler.block)\n end\n end",
"def transaction(options = {}, &block)\n @klass.connection.run_queries_on_shard(@shard) do\n @klass = @klass.connection.transaction(options, &block)\n end\n end",
"def begin_db_transaction\n log('begin transaction', nil) do\n begin_isolated_db_transaction(default_transaction_isolation)\n end\n end",
"def transaction\n begin\n if block_given?\n begin_db_transaction\n result = yield\n commit_db_transaction\n result\n end\n rescue Exception => database_transaction_rollback\n rollback_db_transaction\n raise\n end\n end",
"def transaction\n raise Mysql2::Error, 2002 if @my.nil?\n\n if block_given?\n begin\n @my.query('START TRANSACTION WITH CONSISTENT SNAPSHOT')\n yield # Start executing the query black.\n @my.query('COMMIT')\n rescue Mysql2::Error => e\n @my.query('ROLLBACK')\n raise e\n end\n end\n end",
"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 transaction( &block )\n connect do | conn |\n conn.transaction do | conn |\n yield SqlRunner.new(SingleConnectionPool.new( conn ))\n end\n end\n end",
"def transaction\n start_transaction!\n\n result = yield\n\n query 'COMMIT'\n\n result\n rescue\n query 'ROLLBACK'\n raise\n\n ensure\n end_transaction!\n end",
"def transaction(&block)\n @in_transaction += 1\n begin\n yield self\n self.commit if @in_transaction > 0\n rescue => e\n self.rollback\n raise e\n ensure\n @in_transaction -= 1 unless @in_transaction == 0\n end\n end",
"def transaction(&block)\n @fb_txns << Rubyfb::Transaction.new(@fb_cxn)\n super &block\n end",
"def transaction(&block)\n db\n persister\n\n result = nil\n start_time = Time.now\n begin\n db.transaction(:rollback => :reraise, :isolation => :repeatable,\n :retry_on => @retry_on_error, :num_retries => 3) do\n result = yield block\n end\n total = Time.now.to_ms - start_time.to_ms\n debug \"Transaction committed (#{total} ms)\"\n result\n rescue StandardError => e\n total = Time.now.to_ms - start_time.to_ms\n warn \"Transaction failed (#{total} ms)\"\n raise e\n ensure\n GC.start\n end\n end",
"def execute_transaction\n if valid? && sender.balance > amount && self.status == \"pending\"\n sender.balance -= amount\n receiver.balance += amount\n self.status = \"complete\"\n else\n reject_transfer\n end\n\n end",
"def after_commit(unit); end",
"def scaffold_transaction(&block)\n transaction(&block)\n end",
"def transaction\n @transaction ||= PerseveringTransaction.new(connection)\n end",
"def transaction(start_db_transaction=true)\n yield\n end",
"def rollback_db_transaction() end",
"def rollback_db_transaction() end",
"def commit()\n check_return_code(PureHailDB.ib_trx_commit(@trx_ptr))\n end",
"def commit!() raise NotImplementedError end",
"def transaction(options = {}, &block)\n run_on_shard { @klass = klass.transaction(options, &block) }\n end",
"def transaction_for_hash(hash)\n raise \"Not Implemented\"\n end",
"def transaction_done\n puts \".........\" + self.class.name + \" has been notified\"\n end",
"def release\n\t\t@connection.transactions.release\n\tend",
"def transaction\n @database.transaction { yield self }\n end",
"def lint_transaction_support\n result = gateway_instance.transaction { 1 }\n\n complain \"#{gateway_instance} must return the result of a transaction block\" if result != 1\n\n gateway_instance.transaction do |t|\n t.rollback!\n\n complain \"#{gateway_instance} must interrupt a transaction on rollback\"\n end\n end",
"def transaction\n connect do |c|\n t = Txn.new(c, @log)\n yield t\n end\n end",
"def start_transaction!\n fail DbMod::Exceptions::AlreadyInTransaction if @in_transaction\n @in_transaction = true\n\n query 'BEGIN'\n end",
"def _call_in_transaction\n aliquot_updater = UpdateAliquotsHandler.new(db, bus, log, metadata, s2_resource, settings)\n\n begin \n s2_resource[:plates].each do |plate|\n aliquot_updater.send(:update_aliquots, plate) if plate[:plate].size == SupportedPlateSize\n end\n\n db.transaction(:savepoint => true) do\n begin\n date = s2_resource[:plates].first[:date]\n add_asset_links(s2_resource[:transfer_map], date)\n set_transfer_requests(s2_resource[:transfer_map], date)\n rescue PlateNotFoundInSequencescape => e\n log.info(\"The asset_link and the transfer request has not been set: #{e.message}\")\n end\n end\n rescue Sequel::Rollback, PlateNotFoundInSequencescape, UnknownSample => e\n metadata.reject(:requeue => true)\n log.info(\"Error updating plate aliquots in Sequencescape: #{e}\")\n raise Sequel::Rollback\n else\n metadata.ack\n log.info(\"Plate transfer message processed and acknowledged\")\n end\n end",
"def transaction(opts = {})\n commit, rollback = start_transaction! opts\n tx_depth = nil\n begin\n if Pacer.verbose == :very\n tx_depth = threadlocal_graph_info[:dx_depth]\n puts \"--#{self.class.name} transaction #{ tx_depth } --> \"\n puts caller[0,3]\n end\n r = yield commit, rollback\n commit.call(false)\n r\n rescue Exception => e\n rollback.call e.message\n raise\n ensure\n puts \"--#{self.class.name} #{ tx_depth } <-- \" if Pacer.verbose == :very\n finish_transaction!\n end\n end",
"def commit\n query 'commit'\n self\n end",
"def post_transaction_process\n bet_wallet.persist_wallet!\n end",
"def save\n\t\t@connection.transactions.save\n\tend",
"def monitor_single_transaction(name, env = {}, &block)\n monitor_transaction(name, env, &block)\n ensure\n stop(\"monitor_single_transaction\")\n end",
"def monitor_single_transaction(name, env = {}, &block)\n monitor_transaction(name, env, &block)\n ensure\n stop(\"monitor_single_transaction\")\n end",
"def transaction\n sanity_check\n raise InterfaceError, \"No block given\" unless block_given?\n\n commit\n begin\n yield self\n commit\n rescue Exception\n rollback\n raise\n end\n end",
"def execute_transaction\n if valid? && sender.balance > amount && status == \"pending\"\n receiver.balance += amount\n sender.balance -= amount\n self.status = \"complete\"\n else \n reject_transfer\n end\n end",
"def commit_db_transaction\n execute(\"COMMIT\")\n end",
"def commit_db_transaction\n execute(\"COMMIT\")\n end"
] |
[
"0.80423635",
"0.769474",
"0.769474",
"0.767147",
"0.767147",
"0.767147",
"0.72856444",
"0.72463876",
"0.72463876",
"0.7173958",
"0.7163731",
"0.7159608",
"0.7159608",
"0.71257496",
"0.70231944",
"0.70231944",
"0.6807834",
"0.67990243",
"0.67990243",
"0.6721091",
"0.67136455",
"0.66581523",
"0.66325617",
"0.66325617",
"0.6618041",
"0.6582081",
"0.65569913",
"0.6556629",
"0.65441793",
"0.6524206",
"0.6517867",
"0.65005416",
"0.64905983",
"0.6478947",
"0.6475368",
"0.6475368",
"0.6475368",
"0.6475229",
"0.64537305",
"0.64537305",
"0.64373666",
"0.64133286",
"0.6408044",
"0.63773227",
"0.63766396",
"0.63507444",
"0.6336849",
"0.63338053",
"0.6320405",
"0.63151217",
"0.63151217",
"0.6308295",
"0.6307086",
"0.63040245",
"0.6298021",
"0.6294134",
"0.62883884",
"0.627628",
"0.6265336",
"0.6265248",
"0.6264659",
"0.62437576",
"0.62395245",
"0.6238968",
"0.62382364",
"0.62306106",
"0.6228917",
"0.62247574",
"0.62160385",
"0.62147635",
"0.6211587",
"0.62114936",
"0.62024254",
"0.6199186",
"0.6194284",
"0.6187001",
"0.6185733",
"0.6185648",
"0.6181289",
"0.6181289",
"0.61762017",
"0.6174681",
"0.61730564",
"0.6169406",
"0.61618775",
"0.6157838",
"0.61560714",
"0.6153912",
"0.61528015",
"0.6149688",
"0.61307955",
"0.61307764",
"0.6127627",
"0.61265874",
"0.61208034",
"0.6119897",
"0.6119897",
"0.61198294",
"0.6116449",
"0.61135715",
"0.61135715"
] |
0.0
|
-1
|
==== Host notification =====
|
def notify_awaiting_request_to_host(reservation)
@reservation = reservation
@tenant = @reservation.user
@cookoon = @reservation.cookoon
@host = @cookoon.user
mail(to: @host.full_email, subject: "Rappel: #{@tenant.first_name} souhaite louer votre Cookoon !")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def notify\n {\n }\n end",
"def notify\n {\n }\n end",
"def notify\n end",
"def notify\n {}\n end",
"def notify\n {}\n end",
"def notify\n {}\n end",
"def notify_host\n OrganisationMailer.notify_host\n end",
"def notifier; end",
"def notifier; end",
"def send_notification\n\n\n end",
"def notifications\n end",
"def send_ready_notification\n\n end",
"def notify\n return {}\n end",
"def notify\n return {}\n end",
"def notify\n return {}\n end",
"def name\n\t\t\t\t\"notify\"\n\t\t\tend",
"def name\n\t\t\t\t\"notify\"\n\t\t\tend",
"def name\n\t\t\t\"notify\"\n\t\tend",
"def name\n\t\t\t\"notify\"\n\t\tend",
"def notify\n {\n \"log_group_name\" => @config[\"log_group_name\"],\n \"log_stream_name\" => @config[\"log_stream_name\"]\n }\n end",
"def notify?\n true\n end",
"def send_notifications\n end",
"def name\n\t\t\t\t\"notify_pushover\"\n\t\t\tend",
"def name\n\t\t\t\"notify_pushover\"\n\t\tend",
"def notify\n raise NotImplementedError\n end",
"def create_notification; end",
"def notify \n hosts = get_entity(\"hoststatus\")\n services = get_entity(\"servicestatus\")\n \n unless hosts.empty? and services.empty?\n @config[:subscribers].each do |subscriber|\n Notifier.send_notification({\n :hosts => hosts,\n :services => services,\n\n :from => @config[:smtp_settings][:user_name],\n :to => subscriber,\n :subject => @config[:subject],\n template: \"#{@config[:conf_dir]}/notification.html.erb\"\n }).deliver\n end\n else\n @logger.info(\"No hosts or services were found.\")\n end\n end",
"def desc\n\t\t\t\"Automatically send pushover notifications when sessions are created and closed\"\n\t\tend",
"def message_notification\n fetch(:hipchat_announce, false)\n end",
"def notify_pid\n notify(\"MAINPID=#{$$}\")\n end",
"def notify_watchdog\n notify(\"WATCHDOG=1\")\n end",
"def onping(&blk); super; end",
"def push(notif)\n\n end",
"def send_notification(msg)\n $BLIX_NOTIFY.push(msg)\n puts \"[DummyServer] notify: message=#{msg}\" if $DEBUG\n end",
"def send_status_notification\n message = case @state\n when :hungry then \"I'm hungry!!!\"\n when :sick then \"I'm not feeling so well... :(\"\n when :playful then 'Come play with me!'\n end\n\n DesktopNotifications.notify(message) unless message.nil?\n end",
"def on_ping(x)\n end",
"def notify?\n true\n end",
"def notify(type, title, body, time: 5)\n require 'cgi'\n\n puts \"[#{type}] #{title}\"\n puts \" #{body}\"\n\n time_in_ms = time * 1000\n\n cmd = [\"notify-send\"]\n cmd << \"--expire-time=#{time_in_ms}\"\n cmd << \"--app-name=play\"\n cmd << \"--icon=#{type}\"\n cmd += [title, body].map {|s| CGI.escapeHTML s }\n\n system *cmd\nend",
"def notify_game_change\n connection.execute \"NOTIFY #{channel}, #{connection.quote self.to_s}\"\n end",
"def services_notification\n return unless app.notification_service_configured? && should_notify?\n app.notification_service.create_notification(problem)\n rescue => e\n HoptoadNotifier.notify(e)\n end",
"def notify(notice)\n if @config.use_dogapi?\n notify_dogapi_event(notice) if @config.send_event\n notify_dogapi_metric(notice) if @config.send_metric\n end\n if @config.use_statsd?\n notify_statsd_event(notice) if @config.send_event\n notify_statsd_metric(notice) if @config.send_metric\n end\n end",
"def post_init\n #send_data \"220 #{get_server_greeting}\\r\\n\" (ORIGINAL)\n #(EM.spawn {|x| x.send_data \"220 #{x.get_server_greeting}\\r\\n\"}).notify(self)\n (EM.spawn {|x| x.send_server_greeting}).notify(self)\n end",
"def message\n \"You have a new notification!\"\n end",
"def notify_post\n raise \"not yet implemented\"\n end",
"def allow_notification?\n true\n end",
"def send_email_changed_notification; end",
"def notify_lights_controller\n Rails.application.config.lights_policy_manager.notify_controller!\n end",
"def notify\n MU.structToHash(cloud_desc)\n end",
"def notify\n MU.structToHash(cloud_desc)\n end",
"def notify(item)\n begin\n @growl.notify(@@notification_type, item.title, item.message, @priority, @sticky)\n rescue Errno::ECONNREFUSED => e\n # TODO throw custom exception\n raise \"Growl settings not configured to allow remote application registration. See Growl website docs: http://growl.info/documentation/exploring-preferences.php\"\n end\n end",
"def trigger_on_message(msg); @app.on_message(msg); end",
"def send_notification(method, params); end",
"def notify\n desc = MU.structToHash(cloud_desc)\n desc[\"project_id\"] = @project_id\n desc\n end",
"def notify\n send_email_notification if allow_email_notifications\n send_slack_notification if allow_slack_notifications\n end",
"def broadcast\n end",
"def growl_notify\n\t\t\toptions = { :title => @application,\n\t\t\t\t\t\t\t\t\t:description => @message.gsub(/[\\n]+/, \"\"),\n\t\t\t\t\t\t\t\t\t:application_name => @application,\n\t\t\t\t\t\t\t\t\t:image_from_location => @icon,\n\t\t\t\t\t\t\t\t\t:sticky => false,\n\t\t\t\t\t\t\t\t\t:priority => 0,\n\t\t\t\t\t\t\t\t\t:with_name => notifications.first }\n @growl.notify options\t\t\t\n\t\tend",
"def notify(internet_up)\n time = Time.now\n if internet_up\n %x( growlnotify -m \"The internet is up!\")\n puts \"Internet is UP\".green + \" @ #{time.strftime(\"%I:%M:%S %p\")}\"\n puts \"Text sent!\".blue if @mail.deliver\n else\n %x( growlnotify -m \"Internet is DOWN\" )\n puts \"Internet is DOWN\".red + \" @ #{time.strftime(\"%I:%M:%S %p\")}\"\n end\nend",
"def notify(msg, image)\n end",
"def notify\n socket.write('x')\n end",
"def notify\n descriptor = MU.structToHash(cloud_desc)\n descriptor[\"cloud_id\"] = @mu_name\n descriptor\n end",
"def notify_ready\n notify(\"READY=1\")\n end",
"def notify\n key = KEY_FORMAT % @visualization.id\n $tables_metadata.multi do\n $tables_metadata.hset(key, @user.username, current_timestamp + @notification_ttl)\n $tables_metadata.expire(key, @notification_ttl)\n end\n end",
"def host_notifications_enabled=(arg)\n @host_notifications_enabled = check_bool(arg)\n end",
"def notification\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def prePushListener\n end",
"def show!\n notify_init(app_name) or raise \"notify_init failed\"\n raw_ptr = notify_notification_new(summary, body, icon_path, nil)\n @notification = ::FFI::AutoPointer.new(raw_ptr, method(:g_object_unref))\n show\n end",
"def process\n @notifier.process\n end",
"def notifier\n {\n :name => \"crashlog\",\n :version => CrashLog::VERSION,\n :language => 'Ruby'\n }\n end",
"def notify(res_type, key, data) \n\t\t\traise \"Called notify without active deployment!\" if MU.mommacat.nil?\n\t\t\tMU.mommacat.notify(res_type, key, data)\n\t\tend",
"def notify_status(status)\n notify(\"STATUS=#{status}\")\n end",
"def notify(message)\n puts message['data']\n end",
"def act notification, options={}\n # ...or nothing\n end",
"def push_notification\n NotificationMailer.push_notification\n end",
"def notify(msg, subject)\n end",
"def notify_via_service\n u = User.first\n u.update(last_notification_mail_sent: 30.days.ago)\n service = NotificationDigest.new(type: :notifications)\n service.notify_user(u, deliver: false)\n end",
"def notify\n description = if !@config['external']\n MU.structToHash(cloud_desc)\n else\n {}\n end\n description.delete(:etag) if description\n description\n end",
"def notify\n @greeting = \"Hi\"\n\n mail to: \"to@example.org\"\n end",
"def on_connected\n end",
"def desc\n\t\t\t\"Automatically send Slack notifications when sessions are created and closed\"\n\t\tend",
"def notification?\n kind == 'notification'\n end",
"def send_email_changed_notification?; end",
"def notify_change\n SpecificNodeMailer.notify_change\n end",
"def notify_header(app_name, name, title, text, sticky, icon)\n message = \"#{get_gntp_header_start('NOTIFY')}\\r\\n\"\n message << \"Application-Name: #{@app_name}\\r\\n\"\n message << \"Notification-Name: #{name}\\r\\n\"\n message << \"Notification-Title: #{title}\\r\\n\"\n message << \"Notification-Text: #{text}\\r\\n\" if text\n message << \"Notification-Sticky: #{sticky}\\r\\n\" if sticky\n message << \"#{handle_icon(icon, 'Notification')}\\r\\n\" if icon\n message\n end",
"def notify\n return if destroy_if_old\n\n increase_busy_counter\n\n create_push\n end",
"def notify(params)\n client.post('/notify', params)\n end",
"def desc\n\t\t\t\"Automatically send Slack notifications when sessions are created and closed.\"\n\t\tend",
"def notify_show(data,\n bufferp,\n uber_empty,\n tagsn,\n isdisplayed,\n ishilight,\n prefix,\n message)\n\n server = Weechat.buffer_get_string(bufferp, \"localvar_name\").split('.')[0]\n nick = Weechat.info_get 'irc_nick', server\n\n if (Weechat.buffer_get_string(bufferp, \"localvar_type\") == \"private\" || ishilight == 1.to_s) && prefix != nick\n if delay_ok?\n `notify-send \"#{prefix}\" \"#{message}\" -t #{DELAY} -i ~/.weechat/message.png&`\n touch_delay\n end\n end\n\n Weechat::WEECHAT_RC_OK\nend",
"def heartbeat_entry\n \"#{name} #{ip} #{Application.managed_services}\"\n end",
"def host_notification_options=(arg)\n @host_notification_options = check_state_options(\n arg, %w(d u r f s n), 'host_notification_options')\n end",
"def listener\n NSWorkspace.sharedWorkspace.notificationCenter.addObserver(self, selector: 'app_launched:', name: NSWorkspaceDidLaunchApplicationNotification, object: nil)\n NSWorkspace.sharedWorkspace.notificationCenter.addObserver(self, selector: 'app_terminated:', name: NSWorkspaceDidTerminateApplicationNotification, object: nil)\n NSWorkspace.sharedWorkspace.notificationCenter.addObserver(self, selector: 'app_activated:', name: NSWorkspaceDidActivateApplicationNotification, object: nil)\n NSWorkspace.sharedWorkspace.notificationCenter.addObserver(self, selector: 'app_deactivated:', name: NSWorkspaceDidDeactivateApplicationNotification, object: nil)\n end",
"def show\n # notification_email\n end",
"def new_notification\n mail(to: \"rhammett@ycp.edu\", subject: 'New Notification', sent_on: Time.now)\n end",
"def send_notification\n unless development?\n recipient_email = Hacker.first(:username => self.recipient).email\n Notifier.send_message_notification(recipient_email, self.sender)\n end\n end",
"def host_confirmation\n \t#binding.pry\n \tSendMailToHost.host_confirmation(self).deliver!\n end",
"def notification\n BookingMailer.notification\n end",
"def notifier=(_arg0); end",
"def notifier=(_arg0); end",
"def notify\n @greeting = \"Just a test\"\n mail(to: \"cneumann@marsmonitoring.com\") #.deliver_later\n end",
"def notify(mid, *args, **kwargs)\n @notification_name = mid\n do_notify(*args, **kwargs)\n end",
"def notification\n request.websocket do |ws|\n ws.onopen do\n settings.sockets << ws\n end\n notifications\n ws.onclose do\n settings.sockets.delete(ws)\n end\n end\n end",
"def notify?\n false\n end"
] |
[
"0.69776773",
"0.69776773",
"0.6935529",
"0.6901565",
"0.6901565",
"0.6901565",
"0.6867888",
"0.6799408",
"0.6799408",
"0.67029834",
"0.66427845",
"0.66110843",
"0.6558393",
"0.6558393",
"0.6558393",
"0.6483394",
"0.6483394",
"0.64751005",
"0.64751005",
"0.64612323",
"0.6427165",
"0.639181",
"0.63741827",
"0.6349213",
"0.63366276",
"0.62774116",
"0.62768996",
"0.6253271",
"0.62331873",
"0.62191635",
"0.62020284",
"0.6174873",
"0.6173961",
"0.6155729",
"0.6154455",
"0.61379683",
"0.61357415",
"0.61148816",
"0.61089486",
"0.6101038",
"0.6093328",
"0.6078649",
"0.606198",
"0.60617155",
"0.6059676",
"0.60423285",
"0.60382354",
"0.6036648",
"0.6036648",
"0.60340106",
"0.603143",
"0.60222083",
"0.6010617",
"0.59970415",
"0.5986216",
"0.598138",
"0.597655",
"0.5973929",
"0.5943732",
"0.59424645",
"0.5938714",
"0.5931042",
"0.5926097",
"0.5925961",
"0.59231716",
"0.59218246",
"0.59161335",
"0.5914907",
"0.5909885",
"0.59070265",
"0.5904459",
"0.5886205",
"0.58841515",
"0.58808064",
"0.5870111",
"0.58679676",
"0.5861468",
"0.58583343",
"0.585476",
"0.5853734",
"0.5853228",
"0.5847695",
"0.58396006",
"0.5834241",
"0.58249515",
"0.582463",
"0.58162874",
"0.58155286",
"0.58154964",
"0.58151513",
"0.58146334",
"0.5792941",
"0.5787989",
"0.5782493",
"0.577595",
"0.5764665",
"0.5764665",
"0.5757493",
"0.5744494",
"0.5742294",
"0.57364476"
] |
0.0
|
-1
|
GET /bid_winners GET /bid_winners.json
|
def index
@bid_winners = BidWinner.all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @winners = Winner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @winners }\n end\n end",
"def index\n @bids = Bid.where(\"auction_id = ?\", params[:auction_id])\n\n render json: @bids\n end",
"def all_booking_of_client\n\t\t@bookings = Booking.where(client_id: params[:client_id])\n\t\trender json: @bookings, status: 200\n\tend",
"def bid_lists\n\t\tauction_item_bids = @auction.auction_item_bids.where(user_id: current_user.id)\n\t\trender json: @auction_item_bids.as_json\n\tend",
"def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end",
"def friend\n invs = Invite.where(invitee: params[:id], status: \"accepted\").to_a\n @bets = []\n invs.each do |inv|\n @bets.push(inv.bet) if inv.bet.status != \"won\" && inv.bet.status != \"lost\"\n end\n render 'my-bets.json.jbuilder'\n end",
"def index\n user_id = @user.id\n @auctions = Auction.where(\"seller_id = ?\", user_id)\n\n # get all belong auctions\n render json: @auctions\n end",
"def index\n @bids = Bid.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bids }\n end\n end",
"def buyers\n result = get_buyers(params, false)\n render json: result, status: 200\n end",
"def index\n @bids = @swarm_request.bids.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bids }\n end\n end",
"def index\n @bid_requests = BidRequest.all\n end",
"def show\n @bidding = Bidding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bidding }\n end\n end",
"def set_bid_winner\n @bid_winner = BidWinner.find(params[:id])\n end",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def my_bets\n @bets = Bet.where('owner = ? AND status != ? AND status != ?', params[:id], \"won\", \"lost\").to_a\n @bets.sort! {|x,y| x.id <=> y.id }\n render 'my-bets.json.jbuilder'\n end",
"def index\n @winning_numbers = WinningNumber.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @winning_numbers }\n end\n end",
"def show\n render json: @bid\n end",
"def index\n @bids = @item.auction.bids\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 show\n @borrower_bids = @borrower_request.bids\n @bids = @borrower_bids.order('rate asc')\n @last_bid = @borrower_bids.order('created_at desc').first.created_at if !@borrower_bids.blank?\n end",
"def show\n @winner = Winner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @winner }\n end\n end",
"def select_winners\n ballot_ids = ballots.pluck(:id).shuffle\n\n winner_ids = []\n ballot_ids.each do |id|\n break if winner_ids.size >= number_of_prizes\n entrant_id = Ballot.find(id).entrant_id\n winner_ids << entrant_id unless winner_ids.include? entrant_id\n end\n\n winning_entrants = Entrant.where(id: winner_ids)\n winning_entrants.update_all(winner: true)\n winning_entrants\n end",
"def index\n @breeding_pairs = current_user.breeding_pairs.all\n\n respond_to do |format|\n format.json { render json: @breeding_pairs }\n end\n end",
"def index\n # get all existing bets\n @logged_in_user = getLoggedInUser\n if !@logged_in_user.nil?\n @mlb_win_bets =\n MlbWinBet.includes(:mlb_win)\n .where(user_id: @logged_in_user)\n .order(\"amount DESC\")\n \n # pull all mlb over/unders which have not been assigned by the logged-in user for the current\n # year, separated by division\n @nl_east = availableWinsByDivision(@logged_in_user.id, \"NL\", \"East\")\n @nl_central = availableWinsByDivision(@logged_in_user.id, \"NL\", \"Central\")\n @nl_west = availableWinsByDivision(@logged_in_user.id, \"NL\", \"West\")\n @al_east = availableWinsByDivision(@logged_in_user.id, \"AL\", \"East\")\n @al_central = availableWinsByDivision(@logged_in_user.id, \"AL\", \"Central\")\n @al_west = availableWinsByDivision(@logged_in_user.id, \"AL\", \"West\")\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mlb_win_bets }\n end\n else\n redirect_to root_url\n end\n end",
"def bid\n @auction = Auction.find(params[:auction_id])\n @reward = Reward.find(params[:reward_id])\n @hours_already_bid = @reward.hours_already_bid_by(current_user)\n @hours_entry = HoursEntry.new\n @bid = Bid.new\n end",
"def show\n @mlb_win_bet = MlbWinBet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mlb_win_bet }\n end\n end",
"def show_beer\n render json: BreweryDb::ShowBeer.new(params[:beerId]).results\n end",
"def index\n @bowlers = Bowler.all\n respond_with(@bowlers)\n end",
"def winners\n answer_records = get_answers_with_votes\n _winners = []\n first = answer_records.shift\n if first[:num_votes] > 0\n _winners << first\n answer_records.each do |answer_record|\n _winners << answer_record if answer_record[:num_votes] == first[:num_votes]\n end\n end\n _winners\n end",
"def bowler_winner(id)\n win_bowler = Bowler.find_by_id(id) \n return win_bowler\n end",
"def show\n @bid = @swarm_request.bids.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bid }\n end\n end",
"def index\n @ko16_winners = Ko16Winner.all\n @teams = Team.all\n @group_stage_winners = GroupStageWinner.all\n end",
"def create\n @bid_winner = BidWinner.new(bid_winner_params)\n\n respond_to do |format|\n if @bid_winner.save\n format.html { redirect_to @bid_winner, notice: 'Bid winner was successfully created.' }\n format.json { render :show, status: :created, location: @bid_winner }\n else\n format.html { render :new }\n format.json { render json: @bid_winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def find_bikes\n user_id = params[\"user_id\"]\n bike_ids = get_bike_ids(user_id)\n bikes = []\n bike_ids.each {|bike_id|\n bikes.push(get_bike(bike_id, user_id))\n }\n update_bike_database(bikes, user_id)\n render json: { new_bikes: bikes }\n end",
"def won_offers(options={})\n won_status.offers.all(options)\n end",
"def index\n @biddings = Bidding.all\n end",
"def show\n render json: Agent.find(params[:id]).buyers\n end",
"def list_manager_owned_bidding_strategies(client, manager_customer_id)\n query = <<~QUERY\n SELECT bidding_strategy.id,\n bidding_strategy.name,\n bidding_strategy.type,\n bidding_strategy.currency_code\n FROM bidding_strategy\n QUERY\n\n responses = client.service.google_ads.search_stream(\n customer_id: manager_customer_id,\n query: query,\n )\n\n puts \"Cross-account bid strategies in manager account #{manager_customer_id}:\"\n responses.each do |response|\n response.results.each do |row|\n b = row.bidding_strategy\n puts \"ID: #{b.id}\"\n puts \"Name: #{b.name}\"\n puts \"Strategy type: #{b.type}\"\n puts \"Currency: #{b.currency_code}\"\n puts\n end\n end\nend",
"def index\n \tif params[:for_timeline]\n\t\t\t@bills = Bill.where(:initiator_id.in => params[:politicians]).where(:complete =>true).limit(10)\n\t\telse\n\t \t@bills = Bill.all.limit(10)\n \tend\n\n respond_to do |format|\n format.json { render json: @bills.to_json(:include => {:initiator => {:only =>[:name]}}) }\n end\n\n end",
"def get_bs_companies(vendors)\r\n response = make_API_request(\"https://api.bitsighttech.com/ratings/v1/companies\",'get','',false,{type: 'basic', username: $BS_TOKEN, password: ''})\r\n\tcompanies = JSON.parse(response.body)['companies']\r\n\r\n\tputs \"BitSight API code: #{response.code}, #{companies.length} companies sent\"\r\n\tif response.code != \"200\"\r\n\t\tputs \"BitSight API response:\"\r\n\t\tpp JSON.parse(response.body)\r\n\tend\r\n\r\n\tcreates = updates = Array.new\r\n\tcompanies.each do |company|\r\n\t\tcurrent_vendor = vendors[company['guid']]\r\n\t\tif(current_vendor != nil)\r\n\t\t\tif(current_vendor['attributes']['bitsight_rating_date']==company['rating_date']) then next end\r\n\t\t\tprofile = build_profile_hash(company, current_vendor['id'])\r\n\t\t\tupdates << profile\r\n\t\telse\r\n\t\t\tprofile = build_profile_hash(company)\r\n\t\t\tcreates << profile\r\n\t\tend\r\n\tend\r\n\tlists = {\r\n\t\tcreates: creates,\r\n\t\tupdates: updates,\r\n\t}\r\nend",
"def index\n waiver_picks_decorator = WaiverPicksDecorator.new(\n @fpl_team.waiver_picks.where(round_id: (params[:round_id] || Round.current_round.id))\n )\n\n render json: { waiver_picks: waiver_picks_decorator.all_data }\n end",
"def show_rounds\n\t\t@rounds = @participant.rounds\n\t\trender json: @rounds\n\tend",
"def get_winners\n json = get_json('http://oscars.yipitdata.com/')\n json.results.collect do |films_array|\n find_winner(films_array.films).tap do |winner|\n winner[:year] = films_array.year[0,4]\n end\n end\n end",
"def index\n @super_bowl_picks = SuperBowlPick.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @super_bowl_picks }\n end\n end",
"def bonuses(count = 10)\n params = { command: 'account_bonuses', count: count }\n get('/json.php', params)\n end",
"def all_bathing_waters(options = {})\n if bws_by_uri.empty?\n api_options = { _pageSize: 600 }.merge(options)\n\n bws = api_get_resources(BathingWater.endpoint_all, ALL_PAGES, BathingWater, api_options)\n bws.each do |bw|\n bws_by_uri[bw.uri] = bw\n bws_by_id[bw.id] = bw\n end\n end\n\n bws_by_uri.values\n end",
"def show\n @beer = BreweryDB.beer(params[:id]) \n render json: @beer\n end",
"def add_winner_badges\n\t\trespond_to do |format|\n\t\t\tformat.json{\n\t\t\t\tscrimage = Scrimage.find(params[:scrimage_id])\n\n\t\t\t\tmaxVotes = scrimage.photos.maximum(\"votes\")\n\n\t\t\t\twinningPhotoIDs = scrimage.photos.where(\"votes = ?\", maxVotes)\n\n\t\t\t\tscrimage.winner_id = winningPhotoIDs.first.id\n\t\t\t\t\n\t\t\t\tscrimage.save()\n\n\t\t\t\twinningPhotoIDs.each do |photoID|\n\t\t\t\t\tphoto = Photo.find(photoID)\n\t\t\t\t\tnotification = Notification.new(:user_id => photo.user_id, :message => \"100 Points Awarded - You won the scrimage with your photo, \"+photo.description+\"!\")\n\n\t\t\t\t\t#Ensures that all winners receive points for their winning photos\n\t\t\t\t\tuser = User.find(photo.user_id)\n\t\t\t\t\tuser.update(points: user.points + 100)\n\n\t\t\t\t\tnotification.save()\n\t\t\t\tend\n\n\t\t\t\t#render :json => {:winningPhotoID => winningPhotoIDs} \n\t\t\t\trender :json => {:html => render_to_string({:partial => \"scrimages/displayChildPhotos\", :formats => [:html, :js], :locals => {:scrimage => scrimage, :layout => false}})}\n \t\t\t}\t\t\t\n \t\tend\n\tend",
"def check_ranked_beer\n render json: Beer.find_by(beer_id: params[:beerId])\n end",
"def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end",
"def show\n render json: @used_bike, serializer: Web::V1::UsedBikeSerializer\n end",
"def index\n @bot_bingo_numbers = BotBingoNumber.all\n\n respond_to do |format|\n format.html # index.html.erb\n # frommat.json { render json: @bot_bingo_numbers }\n end\n end",
"def index\n @used_bikes = UsedBike.all\n\n render json: @used_bikes, each_serializer: Web::V1::UsedBikeSerializer\n end",
"def bid_history\n bid_histories = BidHistory.for_vehicle_id_and_auction_date(params[:id], params[:auction_date])\n member_ids = bid_histories.map(&:member_id).compact\n\n bid_histories_json = if member_ids.blank?\n bid_histories.as_json\n else \n members = Hash[MemberResource.find_by_ids(member_ids).map {|member| [member.id, parse_member_country_state(member) ] } ]\n members.blank? ? bid_histories.as_json : bid_histories.map{ |bid_history| bid_history.as_json().merge!(member: fill_members_data(members[bid_history.member_id]))}\n end\n\n respond_to do |format| \n format.json { render json: { bidHistories: bid_histories_json }}\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 set_bid\n @bid = Bid.find_by({\n :id => params[:id],\n :auction_id => params[:auction_id]})\n\n render json: nil, status: :not_found if @bid.nil? || @bid.auction.seller.id != @user.id\n end",
"def index\n\t\t@auction_items = @auction.auction_items\n\t\trender json: @auction_items.as_json\n\tend",
"def index\n @bids = Bid.all\n end",
"def index\n @bids = Bid.all\n end",
"def index\n @bids = Bid.all\n end",
"def index\n @bids = Bid.all\n end",
"def index\n @final_winners = FinalWinner.all\n @sf_winners = SfWinner.all\n @qf_winners = QfWinner.all\n @ko16_winners = Ko16Winner.all\n @teams = Team.all\n @group_stage_winners = GroupStageWinner.all\n end",
"def show\n @brewhouse = Brewhouse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brewhouse }\n end\n end",
"def get_shelley_balances(wid)\n w = SHELLEY.wallets.get(wid)\n total = w['balance']['total']['quantity']\n available = w['balance']['available']['quantity']\n reward = w['balance']['reward']['quantity']\n assets_total = w['assets']['total']\n assets_available = w['assets']['available']\n { 'total' => total,\n 'available' => available,\n 'rewards' => reward,\n 'assets_available' => assets_available,\n 'assets_total' => assets_total\n }\nend",
"def show\n render json: @auction\n end",
"def db_list\n beername = params[:name]\n @beer_info = BREWERY.search.beers(q: beername, withBreweries: 'Y').first(10)\n @beers_with_breweries = []\n @beerlist = @beer_info.map do |drink|\n drink_object(drink)\n end\n render json: @beerlist\n end",
"def show\n render \"api/v1/bounties/show\"\n end",
"def state_beers\n render json: BreweryDb::ShowBeers.new('state', params[:state]).results\n end",
"def index\n @advert = Advert.find(params[:advert_id])\n @bids = @advert.bids\n end",
"def new\n @bid = @swarm_request.bids.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bid }\n end\n end",
"def index\n @bookings = Booking.all\n\n render json: @bookings\n end",
"def send_auction_won(winning_bidder=nil)\n winning_bidder = find_winning_bidder if winning_bidder.nil?\n unless winning_bidder.nil?\n KaseMailer.deliver_auction_won(self, winning_bidder)\n end\n end",
"def index\n @buisnesses = Buisness.all\n\n render json: @buisnesses \n end",
"def show\n #@item = Bid.find(params[:auction_uniq_id])\n\n @bid = Bid.all\n @item = Item.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bid }\n end\n end",
"def availableWins(userId)\n return availableWinsByDivision(userId, nil, nil)\n end",
"def show\n @bidding = params[:bidding]\n @bid_event = BidEvent.new\n @bid_amount = @auctionable.bid_events.blank? ? @auctionable.base_price : @auctionable.bid_events.last.amount\n @participants = Participant.all\n render layout: 'application'\n end",
"def show\n if params[:wrestler]\n Wrestler.update(params[:wrestler].keys, params[:wrestler].values)\n end\n @wrestlers = Wrestler.all\n @tournament = Tournament.find(@weight.tournament_id)\n\n end",
"def list_lobbies\n @lobby_class.all.map do |lobby|\n { :id => lobby.id, :lobby_name => lobby.lobby_name }\n end\n end",
"def index\n response = RestClient.get 'http://api.bitvalor.com/v1/order_book.json'\n data = JSON.parse(response.body)[\"bids\"]\n @fox = data.select {|element| element[0] == \"FOX\"}\n @b2u = data.select {|element| element[0] == \"B2U\"}\n @mbt = data.select {|element| element[0] == \"MBT\"}\n end",
"def get_league_standings_by_league(league_id)\n response = parse_api_request(\"#{BASE_URL}standings/#{league_id}\")[\"standings\"]\nend",
"def set_bet_winner\n @bet_winner = BetWinner.find(params[:id])\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 items_for_bidder\n @auction_item = AuctionItem.where([\"bidderNumber = ?\", params[:id]])\n\n respond_to do |format|\n format.html # items_for_bidder.html.erb\n end \n end",
"def winks_received\n @user = User.find(params[:id])\n @users = @user.wink_senders\n render 'show_wink_senders'\n end",
"def wins\n @usersWins = User.where.not(id: 1)\n .order(wins: :desc)\n .limit(30)\n .paginate(page: params[:wins_page], per_page: 10)\n respond_to do |format|\n format.js\n format.html\n end\n end",
"def show\n @borrower = Borrower.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @borrower }\n end\n end",
"def index\n @bet_scores = @match.bet_scores\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bet_scores }\n end\n end",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def bid\n @auction = Auction.find(params[:auction_id])\n @reward = Reward.find(params[:reward_id])\n @points_already_bid = current_user ? @reward.points_already_raised_by(current_user) : 0\n @donation = Donation.new\n @program = @auction.program\n @karma_page = false\n\n if @program\n @org = @program.organization\n @profile_fields = Profile.profile_fields(current_user, @org)[@org.url] # current_user could be nil\n if @program.auction_type == \"fixed\"\n @opportunities = Profile.fixed_opportunities_for(@org)\n @nonprofit = @org.nonprofits.first\n end\n end\n\n if current_user\n @current_karma = total_karma_for(current_user)\n else\n @current_karma = 0\n end\n\n if current_user && current_user.stripe_cus_id && !@org\n Stripe.api_key = ENV['STRIPE_SECRET_KEY']\n begin\n customer = Stripe::Customer.retrieve(current_user.stripe_cus_id)\n @default_card = customer.sources.retrieve(customer.default_card)\n rescue\n # If a similar Stripe object exists in live mode, but a test mode key was used to make this request.\n @default_card = nil\n end\n end\n end",
"def bills(options = {})\n get('/bills', options)\n end",
"def index\n @draws = Draw.paginate(:page => params[:page], :per_page => 50)\n @winning_draws = Draw.where(:selection => \"WINNER\")\n @draw = Draw.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @draws }\n end\n end",
"def init_brands\n response = @conn.get do |req|\n req.url \"/api/v1/brands\"\n req.headers = rest_headers\n end\n\n @brands = json(response.body)[:brands]\n end",
"def index\n @reviews = Review.find(params[:burger_place_id])\n\n render json: @reviews\n end",
"def show\n @user = User.find_by_id(session[:user_id])\n @auction = Auction.find(params[:id])\n @seller = User.find_by_username(@auction.user_name)\n @bid = Bid.new\n @bid.auction_id = @auction.id\n @bid_count = Bid.find_by_sql(\"SELECT COUNT(auction_id) AS bid_count FROM bids WHERE auction_id = #{@auction.id}\")\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @auction }\n end\n end",
"def index\n @buddies = Buddy.all\n end",
"def show\n @winning_number = WinningNumber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @winning_number }\n end\n end",
"def show\n \trespond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bid }\n end\n end",
"def list_customer_accessible_bidding_strategies(client, customer_id)\n query = <<~QUERY\n SELECT accessible_bidding_strategy.id,\n accessible_bidding_strategy.name,\n accessible_bidding_strategy.type,\n accessible_bidding_strategy.owner_customer_id,\n accessible_bidding_strategy.owner_descriptive_name\n FROM accessible_bidding_strategy\n QUERY\n # Add the following WHERE clause to filter results to *only*\n # cross-account bidding strategies shared with the current customer by a\n # manager (and not also include the current customer's portfolio bidding\n # strategies).\n # query += <<~QUERY\n # WHERE accessible_bidding_strategy.owner_customer_id != #{customer_id}\n # QUERY\n\n responses = client.service.google_ads.search_stream(\n customer_id: customer_id,\n query: query,\n )\n\n puts \"All bid strategies accessible by account #{customer_id}:\"\n responses.each do |response|\n response.results.each do |row|\n b = row.accessible_bidding_strategy\n puts \"ID: #{b.id}\"\n puts \"Name: #{b.name}\"\n puts \"Strategy type: #{b.type}\"\n puts \"Owner customer ID: #{b.owner_customer_id}\"\n puts \"Owner description: #{b.owner_descriptive_name}\"\n puts\n end\n end\nend",
"def show\n render json: @bike #serializer: Web::V1::BikeSerializer\n end",
"def set_bowling_innings\n @bowling_innings = BowlingInnings.find(params[:id])\n end"
] |
[
"0.6780769",
"0.6647827",
"0.6563457",
"0.652974",
"0.61657447",
"0.608783",
"0.6080473",
"0.6074066",
"0.6041351",
"0.6015063",
"0.60125554",
"0.601035",
"0.59837455",
"0.595581",
"0.5943688",
"0.5916635",
"0.58888197",
"0.5884723",
"0.58798057",
"0.58788425",
"0.58627576",
"0.585273",
"0.5844739",
"0.58344275",
"0.58332413",
"0.5825255",
"0.58230543",
"0.58209866",
"0.58128154",
"0.58003587",
"0.57922393",
"0.5785943",
"0.57844937",
"0.57786316",
"0.5773791",
"0.5759163",
"0.5757503",
"0.57521087",
"0.57355636",
"0.57313263",
"0.57131433",
"0.56997406",
"0.56803256",
"0.56802195",
"0.5673357",
"0.56618625",
"0.56534994",
"0.5651681",
"0.5648571",
"0.5643497",
"0.564348",
"0.5620668",
"0.5618063",
"0.56174",
"0.56125635",
"0.56105596",
"0.5602136",
"0.5590073",
"0.5590073",
"0.5590073",
"0.5590073",
"0.55875385",
"0.5586285",
"0.55821675",
"0.55789214",
"0.5572276",
"0.5571227",
"0.5568574",
"0.55657136",
"0.5563521",
"0.55570173",
"0.5551698",
"0.5549652",
"0.55481714",
"0.5543649",
"0.55420387",
"0.552849",
"0.55241364",
"0.55215293",
"0.55031383",
"0.5495954",
"0.5492645",
"0.54919624",
"0.54863155",
"0.54859453",
"0.5481713",
"0.54808754",
"0.5472767",
"0.54699033",
"0.54684156",
"0.54656297",
"0.545979",
"0.5458753",
"0.54561096",
"0.54533637",
"0.5441026",
"0.5440149",
"0.5437474",
"0.54207593",
"0.5419672"
] |
0.7656405
|
0
|
GET /bid_winners/1 GET /bid_winners/1.json
|
def show
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @bid_winners = BidWinner.all\n end",
"def index\n @bids = Bid.where(\"auction_id = ?\", params[:auction_id])\n\n render json: @bids\n end",
"def index\n @winners = Winner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @winners }\n end\n end",
"def all_booking_of_client\n\t\t@bookings = Booking.where(client_id: params[:client_id])\n\t\trender json: @bookings, status: 200\n\tend",
"def set_bid_winner\n @bid_winner = BidWinner.find(params[:id])\n end",
"def bid_lists\n\t\tauction_item_bids = @auction.auction_item_bids.where(user_id: current_user.id)\n\t\trender json: @auction_item_bids.as_json\n\tend",
"def show\n @bidding = Bidding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bidding }\n end\n end",
"def bowler_winner(id)\n win_bowler = Bowler.find_by_id(id) \n return win_bowler\n end",
"def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end",
"def bid\n @auction = Auction.find(params[:auction_id])\n @reward = Reward.find(params[:reward_id])\n @hours_already_bid = @reward.hours_already_bid_by(current_user)\n @hours_entry = HoursEntry.new\n @bid = Bid.new\n end",
"def show\n @borrower_bids = @borrower_request.bids\n @bids = @borrower_bids.order('rate asc')\n @last_bid = @borrower_bids.order('created_at desc').first.created_at if !@borrower_bids.blank?\n end",
"def index\n @bids = Bid.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bids }\n end\n end",
"def show\n @mlb_win_bet = MlbWinBet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mlb_win_bet }\n end\n end",
"def show\n render json: @bid\n end",
"def show\n @bid = @swarm_request.bids.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @bid }\n end\n end",
"def index\n @bid_requests = BidRequest.all\n end",
"def show\n @winner = Winner.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @winner }\n end\n end",
"def show\n @beer = BreweryDB.beer(params[:id]) \n render json: @beer\n end",
"def create\n @bid_winner = BidWinner.new(bid_winner_params)\n\n respond_to do |format|\n if @bid_winner.save\n format.html { redirect_to @bid_winner, notice: 'Bid winner was successfully created.' }\n format.json { render :show, status: :created, location: @bid_winner }\n else\n format.html { render :new }\n format.json { render json: @bid_winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @winning_numbers = WinningNumber.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @winning_numbers }\n end\n end",
"def show_beer\n render json: BreweryDb::ShowBeer.new(params[:beerId]).results\n end",
"def index\n @bids = @swarm_request.bids.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @bids }\n end\n end",
"def new\n @bid = @swarm_request.bids.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bid }\n end\n end",
"def show\n #@item = Bid.find(params[:auction_uniq_id])\n\n @bid = Bid.all\n @item = Item.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bid }\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 user_id = @user.id\n @auctions = Auction.where(\"seller_id = ?\", user_id)\n\n # get all belong auctions\n render json: @auctions\n end",
"def show\n @winning_number = WinningNumber.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @winning_number }\n end\n end",
"def friend\n invs = Invite.where(invitee: params[:id], status: \"accepted\").to_a\n @bets = []\n invs.each do |inv|\n @bets.push(inv.bet) if inv.bet.status != \"won\" && inv.bet.status != \"lost\"\n end\n render 'my-bets.json.jbuilder'\n end",
"def show\n @brewhouse = Brewhouse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @brewhouse }\n end\n end",
"def index\n @bids = @item.auction.bids\n end",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def getbatteries\n puts params\n buildid = params[\"buildingid\"]\n\n batteries = Battery.where(:building_id => buildid)\n\n puts batteries.inspect\n puts \"#################################################\"\n \n respond_to do |format|\n format.json { render json: batteries }\n end\n end",
"def set_bid\n @bid = Bid.find_by({\n :id => params[:id],\n :auction_id => params[:auction_id]})\n\n render json: nil, status: :not_found if @bid.nil? || @bid.auction.seller.id != @user.id\n end",
"def index\n @super_bowl_picks = SuperBowlPick.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @super_bowl_picks }\n end\n end",
"def show\n @borrower = Borrower.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @borrower }\n end\n end",
"def my_bets\n @bets = Bet.where('owner = ? AND status != ? AND status != ?', params[:id], \"won\", \"lost\").to_a\n @bets.sort! {|x,y| x.id <=> y.id }\n render 'my-bets.json.jbuilder'\n end",
"def new\n @bid = Bid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bid }\n end\n end",
"def new\n @bid = Bid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bid }\n end\n end",
"def show\n render \"api/v1/bounties/show\"\n end",
"def show\n render json: @auction\n end",
"def buyers\n result = get_buyers(params, false)\n render json: result, status: 200\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 check_ranked_beer\n render json: Beer.find_by(beer_id: params[:beerId])\n end",
"def show\n @bid = Bid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admin_bid }\n end\n end",
"def get_bike(bikeID, userID)\n user = User.find_by(id: userID)\n authorize_time_check(user)\n response = RestClient.get('https://www.strava.com/api/v3/gear/'+bikeID, {Authorization: 'Bearer ' + user.access_token})\n bike = JSON.parse(response)\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bot_bingo_number }\n end\n end",
"def show\n @bid = current_user.bids.where(auction_id: params[:auction_id]).order(amount: :desc).offset(1).first\n end",
"def index\n @bowlers = Bowler.all\n respond_with(@bowlers)\n end",
"def set_bet_winner\n @bet_winner = BetWinner.find(params[:id])\n end",
"def show\n render json: @used_bike, serializer: Web::V1::UsedBikeSerializer\n end",
"def bid\n @auction = Auction.find(params[:auction_id])\n @reward = Reward.find(params[:reward_id])\n @points_already_bid = current_user ? @reward.points_already_raised_by(current_user) : 0\n @donation = Donation.new\n @program = @auction.program\n @karma_page = false\n\n if @program\n @org = @program.organization\n @profile_fields = Profile.profile_fields(current_user, @org)[@org.url] # current_user could be nil\n if @program.auction_type == \"fixed\"\n @opportunities = Profile.fixed_opportunities_for(@org)\n @nonprofit = @org.nonprofits.first\n end\n end\n\n if current_user\n @current_karma = total_karma_for(current_user)\n else\n @current_karma = 0\n end\n\n if current_user && current_user.stripe_cus_id && !@org\n Stripe.api_key = ENV['STRIPE_SECRET_KEY']\n begin\n customer = Stripe::Customer.retrieve(current_user.stripe_cus_id)\n @default_card = customer.sources.retrieve(customer.default_card)\n rescue\n # If a similar Stripe object exists in live mode, but a test mode key was used to make this request.\n @default_card = nil\n end\n end\n end",
"def show\n @user = User.find_by_id(session[:user_id])\n @auction = Auction.find(params[:id])\n @seller = User.find_by_username(@auction.user_name)\n @bid = Bid.new\n @bid.auction_id = @auction.id\n @bid_count = Bid.find_by_sql(\"SELECT COUNT(auction_id) AS bid_count FROM bids WHERE auction_id = #{@auction.id}\")\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @auction }\n end\n end",
"def new\n @bet = Bet.new(:odd_inflation => 10, :bid_amount => 1)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bet }\n end\n end",
"def show\n \trespond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bid }\n end\n end",
"def items_for_bidder\n @auction_item = AuctionItem.where([\"bidderNumber = ?\", params[:id]])\n\n respond_to do |format|\n format.html # items_for_bidder.html.erb\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 index\n @biddings = Bidding.all\n end",
"def show\n render json: Agent.find(params[:id]).buyers\n end",
"def find_bikes\n user_id = params[\"user_id\"]\n bike_ids = get_bike_ids(user_id)\n bikes = []\n bike_ids.each {|bike_id|\n bikes.push(get_bike(bike_id, user_id))\n }\n update_bike_database(bikes, user_id)\n render json: { new_bikes: bikes }\n end",
"def new\n @winner = Winner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @winner }\n end\n end",
"def bid\n self.bids.last.nil? ? Bid.new : self.bids.last\n end",
"def index\n @breeding_pairs = current_user.breeding_pairs.all\n\n respond_to do |format|\n format.json { render json: @breeding_pairs }\n end\n end",
"def show\n @bottling = Bottling.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bottling }\n end\n end",
"def index\n @bot_bingo_numbers = BotBingoNumber.all\n\n respond_to do |format|\n format.html # index.html.erb\n # frommat.json { render json: @bot_bingo_numbers }\n end\n end",
"def bid_history\n bid_histories = BidHistory.for_vehicle_id_and_auction_date(params[:id], params[:auction_date])\n member_ids = bid_histories.map(&:member_id).compact\n\n bid_histories_json = if member_ids.blank?\n bid_histories.as_json\n else \n members = Hash[MemberResource.find_by_ids(member_ids).map {|member| [member.id, parse_member_country_state(member) ] } ]\n members.blank? ? bid_histories.as_json : bid_histories.map{ |bid_history| bid_history.as_json().merge!(member: fill_members_data(members[bid_history.member_id]))}\n end\n\n respond_to do |format| \n format.json { render json: { bidHistories: bid_histories_json }}\n end\n end",
"def add_winner_badges\n\t\trespond_to do |format|\n\t\t\tformat.json{\n\t\t\t\tscrimage = Scrimage.find(params[:scrimage_id])\n\n\t\t\t\tmaxVotes = scrimage.photos.maximum(\"votes\")\n\n\t\t\t\twinningPhotoIDs = scrimage.photos.where(\"votes = ?\", maxVotes)\n\n\t\t\t\tscrimage.winner_id = winningPhotoIDs.first.id\n\t\t\t\t\n\t\t\t\tscrimage.save()\n\n\t\t\t\twinningPhotoIDs.each do |photoID|\n\t\t\t\t\tphoto = Photo.find(photoID)\n\t\t\t\t\tnotification = Notification.new(:user_id => photo.user_id, :message => \"100 Points Awarded - You won the scrimage with your photo, \"+photo.description+\"!\")\n\n\t\t\t\t\t#Ensures that all winners receive points for their winning photos\n\t\t\t\t\tuser = User.find(photo.user_id)\n\t\t\t\t\tuser.update(points: user.points + 100)\n\n\t\t\t\t\tnotification.save()\n\t\t\t\tend\n\n\t\t\t\t#render :json => {:winningPhotoID => winningPhotoIDs} \n\t\t\t\trender :json => {:html => render_to_string({:partial => \"scrimages/displayChildPhotos\", :formats => [:html, :js], :locals => {:scrimage => scrimage, :layout => false}})}\n \t\t\t}\t\t\t\n \t\tend\n\tend",
"def show\n render json: @bike #serializer: Web::V1::BikeSerializer\n end",
"def winners\n answer_records = get_answers_with_votes\n _winners = []\n first = answer_records.shift\n if first[:num_votes] > 0\n _winners << first\n answer_records.each do |answer_record|\n _winners << answer_record if answer_record[:num_votes] == first[:num_votes]\n end\n end\n _winners\n end",
"def index\n waiver_picks_decorator = WaiverPicksDecorator.new(\n @fpl_team.waiver_picks.where(round_id: (params[:round_id] || Round.current_round.id))\n )\n\n render json: { waiver_picks: waiver_picks_decorator.all_data }\n end",
"def bonuses(count = 10)\n params = { command: 'account_bonuses', count: count }\n get('/json.php', params)\n end",
"def show\n @bowl = Bowl.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @bowl }\n end\n end",
"def accepted_bid\n Bid.find(accepted_bid_id) if accepted_bid_id\n end",
"def index\n @buisnesses = Buisness.all\n\n render json: @buisnesses \n end",
"def index\n @bids = Bid.all\n end",
"def index\n @bids = Bid.all\n end",
"def index\n @bids = Bid.all\n end",
"def index\n @bids = Bid.all\n end",
"def show_rounds\n\t\t@rounds = @participant.rounds\n\t\trender json: @rounds\n\tend",
"def show\n @booking = Booking.find(params[:id])\n render json: @booking\nend",
"def index\n\t\t@auction_items = @auction.auction_items\n\t\trender json: @auction_items.as_json\n\tend",
"def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end",
"def new\n @user_bid = UserBid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_bid }\n end\n end",
"def show\n if params[:wrestler]\n Wrestler.update(params[:wrestler].keys, params[:wrestler].values)\n end\n @wrestlers = Wrestler.all\n @tournament = Tournament.find(@weight.tournament_id)\n\n end",
"def set_bid\n @bid = @item.bids.find_by(id: params[:id])\n render json: { errors: { detail: \"Bid not found\" } }, status: :unauthorized and return unless @bid\n end",
"def index\n \tif params[:for_timeline]\n\t\t\t@bills = Bill.where(:initiator_id.in => params[:politicians]).where(:complete =>true).limit(10)\n\t\telse\n\t \t@bills = Bill.all.limit(10)\n \tend\n\n respond_to do |format|\n format.json { render json: @bills.to_json(:include => {:initiator => {:only =>[:name]}}) }\n end\n\n end",
"def index\n @bookings = Booking.all\n\n render json: @bookings\n end",
"def index\n # get all existing bets\n @logged_in_user = getLoggedInUser\n if !@logged_in_user.nil?\n @mlb_win_bets =\n MlbWinBet.includes(:mlb_win)\n .where(user_id: @logged_in_user)\n .order(\"amount DESC\")\n \n # pull all mlb over/unders which have not been assigned by the logged-in user for the current\n # year, separated by division\n @nl_east = availableWinsByDivision(@logged_in_user.id, \"NL\", \"East\")\n @nl_central = availableWinsByDivision(@logged_in_user.id, \"NL\", \"Central\")\n @nl_west = availableWinsByDivision(@logged_in_user.id, \"NL\", \"West\")\n @al_east = availableWinsByDivision(@logged_in_user.id, \"AL\", \"East\")\n @al_central = availableWinsByDivision(@logged_in_user.id, \"AL\", \"Central\")\n @al_west = availableWinsByDivision(@logged_in_user.id, \"AL\", \"West\")\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mlb_win_bets }\n end\n else\n redirect_to root_url\n end\n end",
"def index\n @comments = Comment.where(\n \"auction_id = ? \",\n params[:auction_id])\n\n render json: @comments\n end",
"def show\n @bike = Bike.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bike }\n end\n end",
"def index\n @advert = Advert.find(params[:advert_id])\n @bids = @advert.bids\n end",
"def state_beers\n render json: BreweryDb::ShowBeers.new('state', params[:state]).results\n end",
"def set_bidding\n @bidding = Bidding.find(params[:id])\n end",
"def show\n #@bet_score = @match.bet_scores.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bet_score }\n end\n end",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def index\n @used_bikes = UsedBike.all\n\n render json: @used_bikes, each_serializer: Web::V1::UsedBikeSerializer\n end",
"def show\n @bidding = params[:bidding]\n @bid_event = BidEvent.new\n @bid_amount = @auctionable.bid_events.blank? ? @auctionable.base_price : @auctionable.bid_events.last.amount\n @participants = Participant.all\n render layout: 'application'\n end",
"def index\n @ko16_winners = Ko16Winner.all\n @teams = Team.all\n @group_stage_winners = GroupStageWinner.all\n end",
"def show\n @wager = Wager.find(params[:id])\n\n render json: @wager\n end",
"def index\n @draws = Draw.paginate(:page => params[:page], :per_page => 50)\n @winning_draws = Draw.where(:selection => \"WINNER\")\n @draw = Draw.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @draws }\n end\n end",
"def show\n @bot = Bot.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bot }\n end\n end",
"def index\n @reviews = Review.find(params[:burger_place_id])\n\n render json: @reviews\n end"
] |
[
"0.7438424",
"0.66676885",
"0.66555125",
"0.6388762",
"0.62146926",
"0.6191606",
"0.6187363",
"0.6181984",
"0.6146363",
"0.6120238",
"0.6119596",
"0.6094287",
"0.6063412",
"0.6060782",
"0.60500216",
"0.60280657",
"0.6015247",
"0.59655696",
"0.59595674",
"0.5958303",
"0.5954628",
"0.5950862",
"0.59496415",
"0.59329194",
"0.58886933",
"0.5886178",
"0.5853032",
"0.5852921",
"0.5844353",
"0.5822613",
"0.5788805",
"0.5787723",
"0.5779924",
"0.5772753",
"0.57629275",
"0.57567126",
"0.5740706",
"0.5740706",
"0.5732576",
"0.5697759",
"0.56972283",
"0.56935626",
"0.5683666",
"0.56809676",
"0.56780756",
"0.566925",
"0.56652176",
"0.5662449",
"0.5660467",
"0.5660418",
"0.5655739",
"0.5653663",
"0.5652769",
"0.56516707",
"0.5647514",
"0.56463504",
"0.5641651",
"0.5629637",
"0.5621865",
"0.5621132",
"0.56176484",
"0.5614704",
"0.5605888",
"0.56028736",
"0.5593202",
"0.5577442",
"0.5570093",
"0.556818",
"0.55678904",
"0.5559255",
"0.5553717",
"0.5550735",
"0.55444604",
"0.55367744",
"0.55367744",
"0.55367744",
"0.55367744",
"0.5534931",
"0.553309",
"0.5531271",
"0.5528797",
"0.5525143",
"0.5522877",
"0.5520213",
"0.55163383",
"0.55145216",
"0.5510321",
"0.5503727",
"0.54970104",
"0.54968816",
"0.54968345",
"0.5494157",
"0.5493531",
"0.5491046",
"0.54908735",
"0.5489114",
"0.54889226",
"0.5484606",
"0.54816014",
"0.5480476",
"0.54767656"
] |
0.0
|
-1
|
POST /bid_winners POST /bid_winners.json
|
def create
@bid_winner = BidWinner.new(bid_winner_params)
respond_to do |format|
if @bid_winner.save
format.html { redirect_to @bid_winner, notice: 'Bid winner was successfully created.' }
format.json { render :show, status: :created, location: @bid_winner }
else
format.html { render :new }
format.json { render json: @bid_winner.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create\n \t@bet = Bet.find(params[:bet_id])\n @winner = @bet.build_winner(winner_params)\n\n respond_to do |format|\n if @winner.save\n @bet.participations.each do |participation|\n if participation.choice == @winner.choice\n user = participation.user\n winnings = ParticipationsController.winnings(participation) + participation.amount\n user.balance += winnings\n user.save\n \t\t MailConfirmationMailer.close_bet_email(participation,@bet,@winner).deliver_later\n end\n end\n format.html { redirect_to @bet, notice: 'Winning choice was successfully selected.' }\n format.json { render :show, status: :created, location: @winner }\n else\n format.html { render :new, status: 422 }\n format.json { render json: @winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @bid_winners = BidWinner.all\n end",
"def create\n @bet_winner = BetWinner.new(bet_winner_params)\n\n respond_to do |format|\n if @bet_winner.save\n format.html { redirect_to @bet_winner, notice: 'Bet winner was successfully created.' }\n format.json { render :show, status: :created, location: @bet_winner }\n else\n format.html { render :new }\n format.json { render json: @bet_winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_voted_beer\n render json: BreweryDb::CreateVotedbeer.new(params[:beerId]).create\n end",
"def create\n @auction = Auction.find(params[:auction_id])\n params[:bid].reverse_merge!({owner_id: current_user.id})\n @bid = @auction.bids.build(params[:bid])\n \n respond_to do |format|\n if @bid.save\n format.html { redirect_to @auction, notice: 'You submitted a bid!'}\n format.json { render json: @bid, status: :created, location: @bid }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bid_winner_params\n params.require(:bid_winner).permit(:winner_id, :bid_product, :winning_amount, :bid_cart_id)\n end",
"def winner_params\n params.require(:winner).permit(:bet_id,:choice_id)\n end",
"def create\n @bid = @swarm_request.bids.new(params[:bid])\n @bid.user = current_user\n\n respond_to do |format|\n if @bid.save\n UserMailer.bid_notification(@bid).deliver\n format.html { redirect_to(swarm_request_bid_url(:id => @bid.to_param, :swarm_request_id => @swarm_request.to_param), :notice => 'Bid was successfully created.') }\n format.xml { render :xml => @bid, :status => :created, :location => @bid }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bid.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @winner = Winner.new(params[:winner])\n\n respond_to do |format|\n if @winner.save\n format.html { redirect_to @winner, notice: 'Winner was successfully created.' }\n format.json { render json: @winner, status: :created, location: @winner }\n else\n format.html { render action: \"new\" }\n format.json { render json: @winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bowler_params\n params.require(:bowler).permit(:first_name, :last_name, :nickname, :email, :team_ids => [])\n end",
"def set_bid_winner\n @bid_winner = BidWinner.find(params[:id])\n end",
"def create\n @bidding = Bidding.new(params[:bidding])\n\n respond_to do |format|\n if @bidding.save\n format.html { redirect_to @bidding, notice: 'Bidding was successfully created.' }\n format.json { render json: @bidding, status: :created, location: @bidding }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bidding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n ass = BowlingAssociation.find(bowler_params[:bowling_association_id])\n \n @bowler = ass.bowlers.create(bowler_params)\n\n \n respond_to do |format|\n if @bowler.save\n\n @bowler.average_entries.create(average: bowler_params[:pbc_average])\n\n @bowler.record :create, current_user, selected_tournament\n\n flash[:create_notice] = \"Bowler #{@bowler.name} has successfully been added.\"\n format.html { redirect_to @bowler }\n format.js { render 'create' }\n else\n format.html { render action: 'new' }\n format.json { render json: @bowler.errors, status: :unprocessable_entity }\n format.js { render 'error' }\n end\n end\n end",
"def create\n \tbid_p = (params[:bid] || {}).merge({user:current_user})\n \tbegin\n\t\t @bid = @auction.bid(bid_p)\n\t\t respond_to do |format|\n\t\t if @bid.save\n\t\t format.html { redirect_to @auction, notice: t(:bid_created) }\n\t\t format.json { render json: @auction, status: :created, location: @bid }\n\t\t else\n\t\t format.html { render action: \"new\" }\n\t\t format.json { render json: @bid.errors, status: :unprocessable_entity }\n\t\t end\n\t\t end\n\t rescue Exception => e\n\t \tredirect_to @auction, notice: t(:auction_closed) if e.message == 'Auction Closed'\n\t end\n end",
"def bid\n @auction = Auction.find(params[:auction_id])\n @reward = Reward.find(params[:reward_id])\n @hours_already_bid = @reward.hours_already_bid_by(current_user)\n @hours_entry = HoursEntry.new\n @bid = Bid.new\n end",
"def create\n @bowler = Bowler.new(bowler_params)\n @bowler.save\n respond_with(@bowler)\n end",
"def send_auction_won(winning_bidder=nil)\n winning_bidder = find_winning_bidder if winning_bidder.nil?\n unless winning_bidder.nil?\n KaseMailer.deliver_auction_won(self, winning_bidder)\n end\n end",
"def bet_winner_params\n params.require(:bet_winner).permit(:winner_first, :winner_second, :winner_third)\n end",
"def new\n @bid = @swarm_request.bids.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bid }\n end\n end",
"def create\n @bid = @auction.bids.new(params[:bid])\n @bid.bidder = current_character\n\n respond_to do |format|\n if @bid.save\n flash[:notice] = 'Bid was successfully created.'\n format.html { redirect_to(auction_bids_path(@auction)) }\n format.xml { render :xml => @bid, :status => :created, :location => @bid }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bid.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def bids_params\n params.require(:bid).permit(:name)\n end",
"def create\n @bid = Bid.new(params[:bid])\n\n respond_to do |format|\n if @bid.save\n format.html { redirect_to @admin_bid, notice: 'Bid was successfully created.' }\n format.json { render json: @admin_bid, status: :created, location: @admin_bid }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admin_bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def select_winners\n ballot_ids = ballots.pluck(:id).shuffle\n\n winner_ids = []\n ballot_ids.each do |id|\n break if winner_ids.size >= number_of_prizes\n entrant_id = Ballot.find(id).entrant_id\n winner_ids << entrant_id unless winner_ids.include? entrant_id\n end\n\n winning_entrants = Entrant.where(id: winner_ids)\n winning_entrants.update_all(winner: true)\n winning_entrants\n end",
"def create\n @bingo_hall = BingoHall.new(name: bingo_hall_params[:name])\n\n respond_to do |format|\n if @bingo_hall.save\n bingo_board = @bingo_hall.bingo_boards.create\n Player.create(name: bingo_hall_params[:player_name], bingo_board: bingo_board)\n format.html { redirect_to @bingo_hall, notice: \"Bingo hall was successfully created.\" }\n format.json { render :show, status: :created, location: @bingo_hall }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bingo_hall.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ko16_winner = Ko16Winner.new(ko16_winner_params)\n @ko16_winner.user = current_user\n\n respond_to do |format|\n if @ko16_winner.save\n format.html { redirect_to @ko16_winner, notice: 'Ko16 winner was successfully created.' }\n format.json { render :show, status: :created, location: @ko16_winner }\n else\n format.html { render :new }\n format.json { render json: @ko16_winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sealed_bid_params\n params.require(:sealed_bid).permit(:bid)\n end",
"def create\n @auction = Auction.new(auction_params)\n @auction.seller = @user\n\n if @auction.save\n render json: @auction, status: :created, location: seller_auction_url(@auction)\n else\n render json: @auction.errors, status: :unprocessable_entity\n end\n end",
"def create\n @ballots = ballot_params\n Ballot.insert_all(@ballots)\n @option = Option.where(id:(@ballots.first[:option_id])).first\n @participant = Participant.where(id:(@ballots.first[:participant_id])).first\n @participant.voted = true \n @participant.save\n redirect_to vote_path(@option.vote_id)\n # respond_to do |format|\n # @option = Option.where(id:(@ballots.first[:option_id])).first\n # if @ballots.save\n # format.html { redirect_to vote_path(@option.vote_id), notice: \"Your vote was cast.\" }\n # format.json { render :show, status: :created, location: @ballot }\n # else\n # format.html { render root_path, status: :unprocessable_entity }\n # format.json { render json: @ballot.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def bid_params\n params.require(:bid).permit(:amount, :user_id, :auction_id)\n end",
"def create\n @mlb_win_bet = MlbWinBet.new(params[:mlb_win_bet])\n\n respond_to do |format|\n if @mlb_win_bet.save\n format.html { redirect_to @mlb_win_bet, notice: 'Mlb win bet was successfully created.' }\n format.json { render json: @mlb_win_bet, status: :created, location: @mlb_win_bet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @mlb_win_bet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bid = Bid.new(bid_params)\n @inspection = @bid.try(:inspection)\n @bids = @inspection.try(:bids)\n respond_to do |format|\n if @bid.save\n format.html { redirect_to @bid, notice: 'Bid was successfully created.' }\n format.js\n else\n format.html { render :new }\n format.js\n end\n end\n end",
"def add_winner_badges\n\t\trespond_to do |format|\n\t\t\tformat.json{\n\t\t\t\tscrimage = Scrimage.find(params[:scrimage_id])\n\n\t\t\t\tmaxVotes = scrimage.photos.maximum(\"votes\")\n\n\t\t\t\twinningPhotoIDs = scrimage.photos.where(\"votes = ?\", maxVotes)\n\n\t\t\t\tscrimage.winner_id = winningPhotoIDs.first.id\n\t\t\t\t\n\t\t\t\tscrimage.save()\n\n\t\t\t\twinningPhotoIDs.each do |photoID|\n\t\t\t\t\tphoto = Photo.find(photoID)\n\t\t\t\t\tnotification = Notification.new(:user_id => photo.user_id, :message => \"100 Points Awarded - You won the scrimage with your photo, \"+photo.description+\"!\")\n\n\t\t\t\t\t#Ensures that all winners receive points for their winning photos\n\t\t\t\t\tuser = User.find(photo.user_id)\n\t\t\t\t\tuser.update(points: user.points + 100)\n\n\t\t\t\t\tnotification.save()\n\t\t\t\tend\n\n\t\t\t\t#render :json => {:winningPhotoID => winningPhotoIDs} \n\t\t\t\trender :json => {:html => render_to_string({:partial => \"scrimages/displayChildPhotos\", :formats => [:html, :js], :locals => {:scrimage => scrimage, :layout => false}})}\n \t\t\t}\t\t\t\n \t\tend\n\tend",
"def create_twit(twit)\n RestClient.post configuration.base_url + '/twits',\n { twit: twit }.to_json,\n content_type: :json,\n accept: :json\n end",
"def create\n outcome = ::FplTeams::CreateWaiverPickForm.run(\n params.merge(current_user: current_user)\n )\n\n if outcome.valid?\n waiver_pick = outcome.waiver_picks.last\n\n render json: {\n success: \"Waiver pick was successfully created. Pick number: #{waiver_pick.pick_number}, \" \\\n \"In: #{waiver_pick.in_player.name}, Out: #{waiver_pick.out_player.name}\",\n waiver_picks: WaiverPicksDecorator.new(@fpl_team_list.waiver_picks).all_data\n }\n else\n render json: {\n errors: outcome.errors.full_messages,\n waiver_picks: WaiverPicksDecorator.new(@fpl_team_list.waiver_picks).all_data\n }, status: :unprocessable_entity\n end\n end",
"def create\n @bot_bingo_number = BotBingoNumber.new(bot_bingo_number_params)\n\n respond_to do |format|\n if @bot_bingo_number.save\n format.html { redirect_to @bot_bingo_number, notice: 'Bot bingo number was successfully created.' }\n format.json { render json: @bot_bingo_number, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @bot_bingo_number.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @winners = Winner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @winners }\n end\n end",
"def create_bid\n @instrument.bids.create!(user: current_user, price: @instrument.price)\n end",
"def create\n @brewhouse = Brewhouse.new(params[:brewhouse])\n\n respond_to do |format|\n if @brewhouse.save\n format.html { redirect_to @brewhouse, notice: 'Brewhouse was successfully created.' }\n format.json { render json: @brewhouse, status: :created, location: @brewhouse }\n else\n format.html { render action: \"new\" }\n format.json { render json: @brewhouse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bidding = Bidding.new(bidding_params)\n\n respond_to do |format|\n if @bidding.save\n format.html { redirect_to [:admin, @bidding], notice: 'Bidding was successfully created.' }\n format.json { render :show, status: :created, location: @bidding }\n else\n format.html { render :new }\n format.json { render json: @bidding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bid = Bid.new(params[:bid])\n @bid.seller_id = self.current_user.seller.id \n @bid.bid_status = \"open\"\n @bid.step = \"step1\"\n respond_to do |format|\n if @bid.save\n flash[:notice] = 'Bid was successfully created.'\n format.html { redirect_to(@bid) }\n format.xml { render :xml => @bid, :status => :created, :location => @bid }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bid.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def bid\n bid_params = params.permit(:id, :bid_or_pass, :tricks_count, :trump_suit)\n game = Game.find(bid_params[:id])\n if bidder_has_passed?(bid_params)\n PassBid.new(game).call\n elsif bidder_has_made_bid?(bid_params)\n MakeBid.new(game, bid_params[:tricks_count], bid_params[:trump_suit]).call\n end\n\n redirect_to game\n end",
"def run_bidding_algorithm(bidding_data)\n # begin\n url = 'http://app-csc517.herokuapp.com/match_topics' # hard coding for the time being\n response = RestClient.post url, bidding_data.to_json, content_type: 'application/json', accept: :json\n JSON.parse(response.body)\n rescue StandardError\n false\n # end\n end",
"def set_bid\n @booking = Booking.find(params[:id])\n @presenter = current_user.presenter\n \n if !@presenter.presenter_profile\n flash[:info] = \"You must create your profile before you can do this\"\n redirect_to edit_presenter_profile_path(@presenter) and return\n elsif @presenter.presenter_profile.bio.nil?\n flash[:info] = \"You must wait for your profile to be approved before you can do this\"\n redirect_to root_url and return\n end\n\n if @booking.presenters.include? @presenter\n flash[:info] = \"You have already expressed interest in this booking\"\n redirect_to root_url and return\n else\n @booking.presenters << @presenter\n @bid = @booking.bids.find_by(presenter: @presenter)\n @bid.bid_date = DateTime.now\n @bid.rate = params[:rate]\n @bid.save\n end\n\n Notification.send_message(@booking.creator.user, \"#{@presenter.first_name} has expressed an interest in this booking.\", booking_path(@booking), :bid)\n flash[:success] = \"You have successfully placed a bid on this booking.\"\n redirect_to root_url\n end",
"def bid_params\n params.require(:bid).permit(:is_accepted, :is_cancelled, :points, :user_id, :donation_id)\n end",
"def bowling_params\n params.require(:bowling).permit(:score, :first_roll, :second_roll)\n end",
"def create\n @winning_number = WinningNumber.new(params[:winning_number])\n\n respond_to do |format|\n if @winning_number.save\n format.html { redirect_to @winning_number, notice: 'Winning number was successfully created. Good Luck!' }\n format.json { render json: @winning_number, status: :created, location: @winning_number }\n else\n format.html { render action: \"new\" }\n format.json { render json: @winning_number.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bid\n @auction = Auction.find(params[:auction_id])\n @reward = Reward.find(params[:reward_id])\n @points_already_bid = current_user ? @reward.points_already_raised_by(current_user) : 0\n @donation = Donation.new\n @program = @auction.program\n @karma_page = false\n\n if @program\n @org = @program.organization\n @profile_fields = Profile.profile_fields(current_user, @org)[@org.url] # current_user could be nil\n if @program.auction_type == \"fixed\"\n @opportunities = Profile.fixed_opportunities_for(@org)\n @nonprofit = @org.nonprofits.first\n end\n end\n\n if current_user\n @current_karma = total_karma_for(current_user)\n else\n @current_karma = 0\n end\n\n if current_user && current_user.stripe_cus_id && !@org\n Stripe.api_key = ENV['STRIPE_SECRET_KEY']\n begin\n customer = Stripe::Customer.retrieve(current_user.stripe_cus_id)\n @default_card = customer.sources.retrieve(customer.default_card)\n rescue\n # If a similar Stripe object exists in live mode, but a test mode key was used to make this request.\n @default_card = nil\n end\n end\n end",
"def create\n @brasseries = Brasserie.new(brasseries_params)\n\n respond_to do |format|\n if @brasseries.save\n format.html { redirect_to @brasseries, notice: 'Brasserie was successfully created.' }\n format.json { render :show, status: :created, location: @brasseries }\n else\n format.html { render :new }\n format.json { render json: @brasseries.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pay_beer\n @player = Player.find(params[:id])\n @player.beer_paid = @player.beer_paid + 1\n @res = @player.save\n \n respond_to do |format|\n format.json {\n render json: {\n :status => @res,\n :player => @player\n }\n }\n end\n end",
"def create\n @won_count = WonCount.new(won_count_params)\n\n respond_to do |format|\n if @won_count.save\n format.html { redirect_to @won_count, notice: 'Won count was successfully created.' }\n format.json { render :show, status: :created, location: @won_count }\n else\n format.html { render :new }\n format.json { render json: @won_count.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n bparams = booking_params\n bparams[:created_by] = User.find_by_name(session[:user])\n bparams[:date] = Date.strptime(session[:date], \"%d.%m.%Y\")\n \n bparams[:accounting_number] = Booking.where(account_id: bparams[:account_id]).map {|b| b.accounting_number}.compact.max.to_i+1\n \n @booking = Booking.new(bparams)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to :back, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t# Set up the new bid\n\t\t@bid = Bid.new\n\t\t@bid.amount = (bid_params[:amount].to_f * 100).to_i # Convert to integer and handle input with or without cents\n\t\t@time = Time.now\n\t\t@bid.bid_time = @time\n\t\t@bid.user_id = @current_user.id\n\t\t@bid.auction_id = session[:auction_id]\n\n\t\t# Fetch the auction and its associated bids\n\t\t@auction = Auction.find(session[:auction_id])\n\t\t@existing_bids = Bid.where(:auction_id => session[:auction_id])\n\n\t\t# Add the auction to the bidder's watch list\n\t\t@watcher = Watcher.new\n\t\t@watcher.auction_id = session[:auction_id]\n\t\t@watcher.user_id = @current_user.id\n\t\t\n\t\t# Create a new bid history entry\n\t\t@bid_history = BidHistory.new\n\n\t\tif @auction.status == 'live'\n\t\t\tif @auction.user_id == @current_user.id\n\t\t\t\tflash.notice = 'You cannot bid on your own auction'\n\t\t\t\tredirect_to auction_path(session[:auction_id]) and return\n\t\t\telse\n\t\t\t\tif @bid.amount\n\t\t\t\t\tif @existing_bids.length == 0\n\t\t\t\t\t\tif @bid.amount >= @auction.start_price\n\t\t\t\t\t\t\t@auction.current_bid = @auction.start_price\n\t\t\t\t\t\t\t@bid_history.amount = @auction.current_bid\n\t\t\t\t\t\t\t@bid_history.bid_time = @time\n\t\t\t\t\t\t\t@bid_history.username = @current_user.username\n\t\t\t\t\t\t\t@bid_history.auction_id = session[:auction_id]\n\t\t\t\t\t\t\t@bid_history.save\n\t\t\t\t\t\t\t@auction.save\n\t\t\t\t\t\t\tflash.notice = 'You are the first bidder'\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tflash.notice = 'Bid must be at least equal to the starting price'\n\t\t\t\t\t\t\trender :new and return\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\t@highest_bid = Utilities.get_highest_bid(@existing_bids)\n\t\t\t\t\t\tif @highest_bid.user_id == @current_user.id\n\t\t\t\t\t\t\tif @bid.amount > @highest_bid.amount\n\t\t\t\t\t\t\t\tflash.notice = \"You have increased your maximum bid to #{Utilities.convert_to_price(@bid.amount)}\"\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tflash.notice = \"The amount entered needs to be higher than your last maximum bid, please enter an amount greater than #{Utilities.convert_to_price(@highest_bid.amount)}\"\n\t\t\t\t\t\t\t\trender :new and return\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tif @bid.amount > @highest_bid.amount # There is a new high bidder\n\t\t\t\t\t\t\t\t@auction.current_bid = @highest_bid.amount + INCREMENT\n\t\t\t\t\t\t\t\t@bid_history.amount = @auction.current_bid\n\t\t\t\t\t\t\t\t@bid_history.bid_time = @time\n\t\t\t\t\t\t\t\t@bid_history.username = @current_user.username\n\t\t\t\t\t\t\t\t@bid_history.auction_id = session[:auction_id]\n\t\t\t\t\t\t\t\t@bid_history.save\n\t\t\t\t\t\t\t\t@auction.save\n\t\t\t\t\t\t\t\tflash.notice = \"You are now the high bidder, your maximum bid is #{Utilities.convert_to_price(@bid.amount)}\"\n\t\t\t\t\t\t\telsif @bid.amount <= @highest_bid.amount && @bid.amount > @auction.current_bid\n\t\t\t\t\t\t\t\t# The bid should increase by the challenging bidder plus the increment\n\t\t\t\t\t\t\t\tif @highest_bid.amount - @bid.amount < INCREMENT # Do not want to push the high bid over by less than the INCREMENT as this would increase the maximum bid without asking the high bidder to approve\n\t\t\t\t\t\t\t\t\t@auction.current_bid = @highest_bid.amount\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t@auction.current_bid = @bid.amount + INCREMENT\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t@bid_history.amount = @auction.current_bid\n\t\t\t\t\t\t\t\t@bid_history.bid_time = @time\n\t\t\t\t\t\t\t\t@bid_history.username = @current_user.username\n\t\t\t\t\t\t\t\t@bid_history.auction_id = session[:auction_id]\n\t\t\t\t\t\t\t\t@bid_history.save\n\t\t\t\t\t\t\t\t@auction.save\n\t\t\t\t\t\t\t\tflash.notice = 'You were outbid, please enter a higher amount'\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tflash.notice = 'Bid too low, please enter a higher amount'\n\t\t\t\t\t\t\t\trender :new and return\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tflash.notice = 'No amount entered, please try again'\n\t\t\t\t\trender :new and return\n\t\t\t\tend\n\n\t\t\t\tif @bid.save\n\t\t\t\t\t@watcher.save\n\t\t\t\t\tredirect_to auction_path(session[:auction_id])\n\t\t\t\telse\n\t\t\t\t\tflash.notice = 'Bid not entered, please try again'\n\t\t\t\t\trender :new and return\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tflash.notice = 'Sorry, bidding for this auction has ended'\n\t\t\tredirect_to auction_path(session[:auction_id])\n\t\tend\n\n\tend",
"def won_count_params\n params.require(:won_count).permit(:name, :wonCount)\n end",
"def declare_winner_of_split_test(mailing_id, winner_id)\n post(\"/mailings/#{mailing_id}/winner/#{winner_id}\")\n end",
"def create\n @bowling_innings = BowlingInnings.new(bowling_innings_params)\n\n respond_to do |format|\n if @bowling_innings.save\n format.html { redirect_to match_path(Match.matchFromInnings(Innings.where(\"Innings.id\" => @bowling_innings.Innings_id))), notice: 'Bowling innings was successfully created.' }\n format.json { render :show, status: :created, location: @bowling_innings }\n else\n format.html { render :new }\n format.json { render json: @bowling_innings.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_winner\n @game = Game.find(game_id)\n game.winners ||= []\n game.winners << player_id\n game.save\n game.winners\n end",
"def create\n @ballot = Ballot.new(ballot_params)\n\n respond_to do |format|\n if @ballot.save\n format.html { redirect_to ballots_url, notice: 'Thank you for voting.' }\n format.json { render :show, status: :created, location: @ballot }\n else\n format.html { render :new }\n format.json { render json: @ballot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bowling = Bowling.new(bowling_params)\n\n respond_to do |format|\n if @bowling.save\n format.html { redirect_to @bowling, notice: 'Bowling was successfully created.' }\n format.json { render :show, status: :created, location: @bowling }\n else\n format.html { render :new }\n format.json { render json: @bowling.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @race_winner = RaceWinner.new(race_winner_params)\n\n respond_to do |format|\n if @race_winner.save\n format.html { redirect_to @race_winner, notice: 'Race winner was successfully created.' }\n format.json { render action: 'show', status: :created, location: @race_winner }\n else\n format.html { render action: 'new' }\n format.json { render json: @race_winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @waiter = Waiter.new(params[:waiter])\n\n respond_to do |format|\n if @waiter.save\n format.html { redirect_to @waiter, notice: 'Waiter was successfully created.' }\n format.json { render json: @waiter, status: :created, location: @waiter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @waiter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @banned = Banned.new(banned_params)\n\n respond_to do |format|\n if @banned.save\n format.html { redirect_to @banned, notice: 'Banned was successfully created.' }\n format.json { render :show, status: :created, location: @banned }\n else\n format.html { render :new }\n format.json { render json: @banned.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bid_params\n params.require(:bid).permit(:price, :payout, :availability, :notes, :maintenance_request_id, :contractor_id, :approved, :info_requested)\n end",
"def set_bet_winner\n @bet_winner = BetWinner.find(params[:id])\n end",
"def create\n @wager = Wager.new(params[:wager])\n\n if @wager.save\n render json: @wager, status: :created, location: @wager\n else\n render json: @wager.errors, status: :unprocessable_entity\n end\n end",
"def bingo_hall_params\n params.require(:bingo_hall).permit(:name, :player_name)\n end",
"def create\n params[:bet][:user_id] = current_user.id\n @bet = Bet.new(bet_params)\n\n respond_to do |format|\n if @bet.save\n format.html { redirect_to @bet, notice: 'Bet was successfully created.' }\n format.json { render :show, status: :created, location: @bet }\n else\n format.html { render :new, status: 422 }\n format.json { render json: @bet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @award_winner_book = current_user.award_winner_books.build(award_winner_book_params)\n\n respond_to do |format|\n if @award_winner_book.save\n format.html { redirect_to @award_winner_book, notice: \"Award winner review was successfully created.\" }\n format.json { render :show, status: :created, location: @award_winner_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @award_winner_book.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 @bid_request = BidRequest.new(bid_request_params)\n @bid_request.user = current_user\n\n respond_to do |format|\n if @bid_request.save\n format.html { redirect_to @bid_request, notice: 'Bid request was successfully created.' }\n format.json { render :show, status: :created, location: @bid_request }\n else\n format.html { render :new }\n format.json { render json: @bid_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bid = Bid.new(bid_params)\n @bid.maintenance_request = MaintenanceRequest.find_by_id(params[:bid][:maintenance_request_id])\n @user = User.find_by_id(@bid.maintenance_request.user_id)\n @bid.contractor = current_contractor\n if @bid.price\n @bid.payout = @bid.price * 0.90\n end\n respond_to do |format|\n if @bid.save\n UserMailer.with(user: @user, bid: @bid, contractor: @bid.contractor).bid_notification.deliver_now\n message = \"New bid for your job at #{@bid.maintenance_request.property.street_1} was just created. The initial quote is $#{@bid.price} (subject to change). You can view more details at samepageco.app/maintenance_requests/#{@bid.maintenance_request.id}\"\n TwilioTextMessenger.new(message).call\n format.html { redirect_to @bid, notice: 'Bid was successfully created.' }\n format.json { render :show, status: :created, location: @bid }\n else\n flash[:bid_errors] = @bid.errors.full_messages\n @maintenance_request = MaintenanceRequest.find_by_id(params[:bid][:maintenance_request_id])\n format.html { render :new }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @winner = Winner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @winner }\n end\n end",
"def create\n \n @bid = Bid.new(params[:bid])\n @auction = Auction.find(params[:auction_id], :include => :nfl_player)\n @bid.auction_id = @auction.id\n @bid.user_id = current_user\n\n @top_bid = @auction.bids.find_top_bidder()\n \n @existing_bid = Bid.new(:auction_id => @top_bid.auction_id, :user_id => @top_bid.user_id, \n :nfl_player_id => @top_bid.nfl_player_id, :price => @bid.price,\n :max_price => @top_bid.max_price)\n\n existing_bidder = false\n \n \n unless @bid.max_price.nil?\n if @auction.top_bidder.user_id == current_user \n @modified_bid = Bid.find(@top_bid.id)\n if @bid.max_price >= @top_bid.price \n existing_bidder = true \n success_display = true\n @modified_bid.update_attributes(params[:bid]) \n @modified_bid.save ? success_display=true : error_display=true\n else \n winning_bidder = false \n success_display = true\n end\n\n else\n if @bid.max_price <= @top_bid.price \n winning_bidder = false \n success_display = true\n elsif @bid.max_price <= @top_bid.max_price \n winning_bidder = false\n @bid.price = @bid.max_price - 1\n @existing_bid.price = @bid.max_price\n @bid.save && @existing_bid.save ? success_display=true : error_display=true\n else \n winning_bidder = true\n @bid.price = @top_bid.max_price + 1\n @existing_bid.price = @top_bid.max_price\n @bid.save ? success_display=true : error_display=true\n end\n end\n end\n \n if existing_bidder && success_display\n flash[:notice] = \"Your max bid has been updated!\"\n redirect_to new_auction_bid_path\n elsif winning_bidder && success_display\n UserNotifier.deliver_auction_outbid(@bid, @top_bid.user, @auction)\n flash[:notice] = \"Congratulations! You are now the top bidder!\" \n redirect_to auction_url(@auction) + \"/bids\"\n elsif !winning_bidder && success_display\n flash[:notice] = \"Whoops! You are going to have to bid higher than $#{@bid.max_price}!\"\n redirect_to new_auction_bid_path\n else\n flash[:error] = \"Please fill in all fields!\"\n render(:action => 'new')\n end\n end",
"def create\n @bet = Bet.new(params[:bet])\n\n respond_to do |format|\n if @bet.save\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\" }\n format.json { render json: @bet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @betting = Betting.new(betting_params)\n\n respond_to do |format|\n if @betting.save\n format.html { redirect_to @betting, notice: 'Betting was successfully created.' }\n format.json { render :show, status: :created, location: @betting }\n else\n format.html { render :new }\n format.json { render json: @betting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @buyer = Buyer.new(params[:buyer])\n @locals = User.where(:city => @buyer.city)\n @users = @locals.random(5)\n respond_to do |format|\n if @buyer.save\n @users.each do |user|\n BuyerMailer.registration_welcome(@buyer, user).deliver\n Buyer.increment_counter(\"times_forwarded\", @buyer.id)\n end\n format.html { redirect_to :submitted_page, :notice => 'Seller was successfully created.' }\n format.json { render :json => @buyer, :status => :created, :location => @buyer }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @buyer.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def bid_params\n params.require(:bid).permit(:shop_id, :driver_id, :go_at, :come_back, :pass1_id, :pass2_id, :pass3_id, :pass4_id, :cangodrive, :nbrplace, :withreturn)\n end",
"def set_bid\n @bid = Bid.find_by({\n :id => params[:id],\n :auction_id => params[:auction_id]})\n\n render json: nil, status: :not_found if @bid.nil? || @bid.auction.seller.id != @user.id\n end",
"def bid_params\n params.require(:bid).permit(\n :details,\n :price,\n :period,\n :owner_id,\n :owner_type,\n :project_id)\n end",
"def create\n @rink_league = RinkLeague.new(params[:rink_league])\n\n respond_to do |format|\n if @rink_league.save\n format.html { redirect_to @rink_league, notice: 'Rink league was successfully created.' }\n format.json { render json: @rink_league, status: :created, location: @rink_league }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rink_league.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @player_round_loans = params[:player_round_loans].values.collect { |player_round_loan| PlayerRoundLoan.new(player_round_loan) }\n\n @player_round_loans.each do |player_round_loan|\n player_round_loan.save!\n end\n\n# @player_round_loan = PlayerRoundLoan.new(params[:player_round_loan])\n\n respond_to do |format|\n if @player_round_loans.all?(&:valid?)\n @round=Round.find(@player_round_loans[0].round_id)\n @round.played=true\n @round.save!\n # format.html { redirect_to new_player_round_investment_path(:player_id=>@player_round_loans[0].player_id, :round_id=>@player_round_loans[0].round_id, :brand_id=>@player_round_loans[0].brand_id) }\n format.html {redirect_to root_path}\n #format.html { redirect_to @player_round_loan, notice: 'Player round loan was successfully created.' }\n format.json { render json: @player_round_loan, status: :created, location: @player_round_loan }\n else\n format.html { render action: \"new\" }\n format.json { render json: @player_round_loan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bill = Bill.new(bill_params)\n @client = Client.new(params[:Client])\n @bill.client_id = @client.id\n @client.save\n\n respond_to do |format|\n if @bill.save\n format.html { redirect_to @bill, 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 create\n if current_user\n bid = Bid.new(user_id: session[:user_id], lowest_price: params[:lowest_price], offer_price: params[:offer_price], event_name: params[:event_name], event_id: params[:event_id])\n if session[:user_id] == current_user.id\n bid.save\n send_message(\"14155137961\", \"your bid has been created sit back while we find you your ticket\")\n #restart_jobs\n redirect_to '/bids'\n flash[:success] = \"New bid added\"\n end\n else\n flash[:danger] = \"your not logged in\"\n redirect_to '/login'\n end\n end",
"def create\n\t\tbooking = Booking.new(booking_params)\n\n\t if booking.save\n\t \tPeekBooker.use_a_boat(booking.size, booking.timeslot_id)\n\t \tPeekBooker.delete_overlap_assignments(booking.timeslot_id)\n\t \tPeekBooker.upd_availability(booking.timeslot_id)\n\t \t\n\t \trender json: booking, status: 201\n\t end\n\tend",
"def create\n owner = User.find_or_create params[:owner_id]\n name = params[:name]\n\n lobby = Lobby.create! owner: owner, name: name\n render json: lobby.as_json( only: [:id, :name] )\n end",
"def client_bonu_params\n params.require(:client_bonu).permit(:current, :added_bonus, :client_id, :bonus)\n end",
"def friend\n invs = Invite.where(invitee: params[:id], status: \"accepted\").to_a\n @bets = []\n invs.each do |inv|\n @bets.push(inv.bet) if inv.bet.status != \"won\" && inv.bet.status != \"lost\"\n end\n render 'my-bets.json.jbuilder'\n end",
"def index\n @bids = Bid.where(\"auction_id = ?\", params[:auction_id])\n\n render json: @bids\n end",
"def create\n @vote = @bet.votes.new(vote_params)\n @vote.ip_addr = params[:vote][:uuid]\n\n tmp_vote = Vote.where(ip_addr: @vote.ip_addr, bet_id: @bet.id)\n\n if @bet.ended?\n render json: {\n bet: @bet,\n error: \"EXPIRED\",\n msg: \"Bets are closed.\"\n }, status: :ok\n return\n\n elsif tmp_vote.any?\n render json: {\n status: 'error',\n error: \"ALREADY_VOTED\",\n msg: \"You've already voted on this\"\n }, status: :ok\n return\n else\n\n if @vote.answer != \"a\" and @vote.answer != \"b\"\n render json: {\n status: 'error',\n error: \"INVALID_ANSWER\",\n msg: \"Invalid answer: #{@vote.answer}\"\n }, status: :unprocessable_entity\n return\n end\n\n\n if @vote.save\n\n render json: {\n vote: @vote,\n status: \"success\",\n error: nil\n }, status: :created, location: api_v1_bet_votes_url(@bet, @vote)\n\n else\n render json: {\n status: \"error\",\n error: \"unprocessable_entity\",\n msg: @vote.errors.full_messages\n }, status: :unprocessable_entity\n end\n\n end\n\n end",
"def create\n megam_rest.post_billedhistories(to_hash)\n end",
"def add_bonuses\n return if @invitation.present?\n return unless @client.currency&.casecmp?('rub')\n\n request_path = '/api/internal/v1/payments.json'\n request_params = {\n payment: {\n puid: @client.id,\n source: 'new_registration',\n client_id: @client.id,\n amount: REDEEMING_AMOUNT,\n currency: @client.currency,\n },\n }\n\n if Rails.env == 'development'\n puts '================================'\n puts 'Services::Users::Registration#add_bonuses'\n puts request_path\n puts JSON.pretty_generate(request_params)\n puts '================================'\n return\n end\n\n service = Diplomat::Service.get('accounting')\n url = \"http://#{service.Address}:#{service.ServicePort}/\"\n\n conn = Faraday.new(url: url) do |faraday|\n faraday.response :logger, ::Logger.new(STDOUT), bodies: true\n faraday.adapter Faraday.default_adapter\n faraday.headers['Content-Type'] = 'application/json'\n end\n\n res = conn.post(request_path) do |req|\n req.body = request_params.to_json\n end\n end",
"def create\n @item = Item.find_by(id: params[:auction_uniq_id])\n @bid = Bid.new(params.require(:bid).permit(:auction_uniq_id, :bid_amount))\n # @item.notify_price = @bid.bid_amount\n #@bid.save\n respond_to do |format|\n if @bid.save\n format.html { redirect_to @bid, notice: 'Bid was successfully created.' }\n format.json { render json: @bid, status: :created, location: @bid }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @final_winner = FinalWinner.new(final_winner_params)\n @final_winner.user = current_user\n\n respond_to do |format|\n if @final_winner.save\n format.html { redirect_to @final_winner, notice: 'Final winner was successfully created.' }\n format.json { render :show, status: :created, location: @final_winner }\n else\n format.html { render :new }\n format.json { render json: @final_winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @borrower = Borrower.new(params[:borrower])\n respond_to do |format|\n if @borrower.save\n format.html { redirect_to @borrower, notice: 'Borrower was successfully created.' }\n format.json { render json: @borrower, status: :created, location: @borrower }\n else\n format.html { render action: \"new\" }\n format.json { render json: @borrower.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @borrower = Borrower.new(params[:borrower])\n\n respond_to do |format|\n if @borrower.save\n format.html { redirect_to @borrower, notice: 'Borrower was successfully created.' }\n format.json { render json: @borrower, status: :created, location: @borrower }\n else\n format.html { render action: \"new\" }\n format.json { render json: @borrower.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_booking(params)\n credentials = Concierge::Credentials.for(\"SAW\")\n SAW::Client.new(credentials).book(params)\n end",
"def wine_winery_params\n params.require(:wine_winery).permit(:wine_id, :winery_id)\n end",
"def bid_params\n params.require(:bid).permit(:inspection_id, :costRepair, :feeSeismicUpg, :feeAdmin, :payPlan_id, :status, :title)\n end",
"def bowling_innings_params\n params.require(:bowling_innings).permit(:Innings_id, :Player_id, :overs, :maidens, :runs, :wickets, :no_balls, :wides)\n end",
"def create\n @weight = Weight.new(weight_params)\n @tournament = Tournament.find(weight_params[:tournament_id])\n respond_to do |format|\n if @weight.save\n format.html { redirect_to @tournament, notice: 'Weight was successfully created.' }\n format.json { render action: 'show', status: :created, location: @weight }\n else\n format.html { render action: 'new' }\n format.json { render json: @weight.errors, status: :unprocessable_entity }\n end\n end\n end",
"def lottery_params\n params.require(:lottery).permit(:activity_id, :activity_name, :winning, :activity_award_id, :activity_award_cfg_id, :activity_award_cfg_name, :user_id)\n end"
] |
[
"0.64246356",
"0.6414788",
"0.6399638",
"0.63068753",
"0.6241566",
"0.6133156",
"0.6027251",
"0.59767824",
"0.5944652",
"0.5922627",
"0.59179306",
"0.59175223",
"0.5902692",
"0.58576345",
"0.5856097",
"0.5831401",
"0.57759506",
"0.5766759",
"0.5765637",
"0.57549363",
"0.5748618",
"0.57442766",
"0.56942576",
"0.5652074",
"0.56482244",
"0.5625169",
"0.560475",
"0.56029445",
"0.5601878",
"0.55979735",
"0.55801386",
"0.5563703",
"0.5562254",
"0.55579376",
"0.5556956",
"0.5536108",
"0.55269027",
"0.552645",
"0.5516721",
"0.55146235",
"0.5502512",
"0.54987514",
"0.5498295",
"0.54907787",
"0.5479584",
"0.5472837",
"0.54708844",
"0.545951",
"0.5441261",
"0.54345685",
"0.5425202",
"0.54236495",
"0.54092366",
"0.540606",
"0.5403689",
"0.5403086",
"0.5402854",
"0.53957736",
"0.5391267",
"0.53877336",
"0.53856635",
"0.5384073",
"0.5379596",
"0.5378065",
"0.53764534",
"0.5374829",
"0.5372363",
"0.5364193",
"0.53598124",
"0.53589475",
"0.5357908",
"0.53436464",
"0.5336458",
"0.5333117",
"0.53311664",
"0.53069144",
"0.5304748",
"0.53009576",
"0.52915734",
"0.528741",
"0.5286639",
"0.52835363",
"0.52814245",
"0.5271379",
"0.5268696",
"0.52686626",
"0.5265951",
"0.5264907",
"0.5263206",
"0.5260979",
"0.52602994",
"0.52599764",
"0.52580833",
"0.52572024",
"0.5256154",
"0.5254994",
"0.5254472",
"0.5253641",
"0.52532494",
"0.525178"
] |
0.69893986
|
0
|
PATCH/PUT /bid_winners/1 PATCH/PUT /bid_winners/1.json
|
def update
respond_to do |format|
if @bid_winner.update(bid_winner_params)
format.html { redirect_to @bid_winner, notice: 'Bid winner was successfully updated.' }
format.json { render :show, status: :ok, location: @bid_winner }
else
format.html { render :edit }
format.json { render json: @bid_winner.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n @bid = @swarm_request.bids.find(params[:id])\n\n respond_to do |format|\n if @bid.update_attributes(params[:bid])\n format.html { redirect_to(swarm_request_bid_url(:id => @bid.to_param, :swarm_request_id => @swarm_request.to_param), :notice => 'Bid was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bid.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @bid = Bid.find(params[:id])\n\n respond_to do |format|\n if @bid.update_attributes(params[:bid])\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bowler.update(bowler_params)\n\n @bowler.record :update, current_user, selected_tournament\n \n format.html { redirect_to @bowler, notice: \"Bowler [#{@bowler.full_name}] was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bowler.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bid = Bid.find(params[:id])\n\n respond_to do |format|\n if @bid.update_attributes(params[:bid])\n format.html { redirect_to @admin_bid, notice: 'Bid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bidding = Bidding.find(params[:id])\n\n respond_to do |format|\n if @bidding.update_attributes(params[:bidding])\n format.html { redirect_to @bidding, notice: 'Bidding was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bidding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bid.update_attributes(params[:bid])\n format.html { redirect_to @auction, notice: 'Bid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bid.update(bid_params)\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.json { render :show, status: :ok, location: @bid }\n else\n format.html { render :edit }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bid.update(bid_params)\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.json { render :show, status: :ok, location: @bid }\n else\n format.html { render :edit }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bid.update(bid_params)\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.json { render :show, status: :ok, location: @bid }\n else\n format.html { render :edit }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bid.update(bid_params)\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.json { render :show, status: :ok, location: @bid }\n else\n format.html { render :edit }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bowler.update(bowler_params)\n respond_with(@bowler)\n end",
"def update\n if @bid.update(bid_params)\n head :no_content\n else\n render json: @bid.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @bid.update(bid_params)\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bid.update(bid_params)\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.json { render :show, status: :ok, location: @bid }\n else\n format.html { render :edit }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @auction = Auction.find(params[:auction_id])\n params[:bid].reverse_merge!({owner_id: current_user.id})\n @bid = Bid.find(params[:id])\n \n respond_to do |format|\n if @bid.update_attributes(params[:bid])\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n \n redirect_to @auction and return\n end",
"def update\n respond_to do |format|\n if @bet_winner.update(bet_winner_params)\n format.html { redirect_to @bet_winner, notice: 'Bet winner was successfully updated.' }\n format.json { render :show, status: :ok, location: @bet_winner }\n else\n format.html { render :edit }\n format.json { render json: @bet_winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_bid = UserBid.find(params[:id])\n\n respond_to do |format|\n if @user_bid.update_attributes(params[:user_bid])\n format.html { redirect_to @user_bid, notice: 'User bid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bid_request.update(bid_request_params)\n format.html { redirect_to @bid_request, notice: 'Bid request was successfully updated.' }\n format.json { render :show, status: :ok, location: @bid_request }\n else\n format.html { render :edit }\n format.json { render json: @bid_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @super_bowl_pick = SuperBowlPick.find(params[:id])\n\n respond_to do |format|\n if @super_bowl_pick.update_attributes(params[:super_bowl_pick])\n format.html { redirect_to @super_bowl_pick, notice: 'Super bowl pick was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @super_bowl_pick.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_bid_winner\n @bid_winner = BidWinner.find(params[:id])\n end",
"def update\n @bid = Bid.find(params[:id])\n\n respond_to do |format|\n if @bid.update_attributes(params[:bid])\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n authorize! :manage, @bid\n end",
"def update\n @mlb_win_bet = MlbWinBet.find(params[:id])\n\n respond_to do |format|\n if @mlb_win_bet.update_attributes(params[:mlb_win_bet])\n format.html { redirect_to @mlb_win_bet, notice: 'Mlb win bet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mlb_win_bet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bidding.update(bidding_params)\n format.html { redirect_to [:admin, @bidding], notice: 'Bidding was successfully updated.' }\n format.json { render :show, status: :ok, location: @bidding }\n else\n format.html { render :edit }\n format.json { render json: @bidding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @setbreak.update(setbreak_params)\n format.json { respond_with_bip @setbreak }\n else\n format.json { respond_with_bip @setbreak }\n end\n end\n end",
"def update\n @brewhouse = Brewhouse.find(params[:id])\n\n respond_to do |format|\n if @brewhouse.update_attributes(params[:brewhouse])\n format.html { redirect_to @brewhouse, notice: 'Brewhouse was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @brewhouse.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @boat.update(boat_params)\n head :no_content\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def update\n @winner = Winner.find(params[:id])\n\n respond_to do |format|\n if @winner.update_attributes(params[:winner])\n format.html { redirect_to @winner, notice: 'Winner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bid.update(bid_params)\n @bid.maintenance_request = MaintenanceRequest.find_by_id(params[:bid][:maintenance_request_id])\n @user = User.find_by_id(@bid.maintenance_request.user_id)\n @bid.contractor = current_contractor\n if @bid.price\n @bid.payout = @bid.price * 0.90\n end\n @bid.save\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.json { render :show, status: :ok, location: @bid }\n else\n @bid = Bid.new\n @maintenance_request = MaintenanceRequest.find_by_id(params[:maintenance_request_id])\n format.html { render :edit }\n format.json { render json: @bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bid = Bid.find(params[:id])\n\n respond_to do |format|\n if @bid.update_attributes(params[:bid])\n flash[:notice] = 'Bid was successfully updated.'\n format.html { redirect_to bid_url(@bid) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bid.errors.to_xml }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @bid.update_attributes(params[:bid])\n flash[:notice] = 'Bid was successfully updated.'\n format.html { redirect_to(@bid) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bid.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 @bet = Bet.find(params[:id])\n @remove_voted = params[:remove_voted] ? true : false\n \n respond_to do |format|\n if @bet.update_attributes(params[:bet])\n format.js { render :action => 'update_bet' } # update_bet.js.rjs\n format.iphone_js { render :action => 'update_bet.js.rjs' }\n else\n format.js { render :action => 'update_bet' }\n format.iphone_js { render :action => 'update_bet.js.rjs' }\n end\n end\n end",
"def update\n @blocking_client = BlockingClient.find(params[:id])\n\n respond_to do |format|\n if @blocking_client.update_attributes(params[:blocking_client])\n format.html { redirect_to @blocking_client, notice: 'Blocking client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @blocking_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @waiter = Waiter.find(params[:id])\n\n respond_to do |format|\n if @waiter.update_attributes(params[:waiter])\n format.html { redirect_to @waiter, notice: 'Waiter was successfully updated.' }\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 @bot_bingo_number.update(bot_bingo_number_params)\n format.html { redirect_to @bot_bingo_number, notice: 'Bot bingo number was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bot_bingo_number.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @winning_number = WinningNumber.find(params[:id])\n\n respond_to do |format|\n if @winning_number.update_attributes(params[:winning_number])\n format.html { redirect_to @winning_number, notice: 'Winning number was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @winning_number.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bid = Bid.find(:first,\n :conditions => [\"seller_id = ? and id = ? \", self.current_user.seller.id, params[:id]]) \n @bid.step = \"step1\"\n\n respond_to do |format|\n if @bid.update_attributes(params[:bid])\n flash[:notice] = 'Bid was successfully updated.'\n format.html { redirect_to(@bid) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bid.errors, :status => :unprocessable_entity }\n end\n end\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 @bidder_amount.update(bidder_amount_params)\n format.html { redirect_to @bidder_amount, notice: 'Bidder amount was successfully updated.' }\n format.json { render :show, status: :ok, location: @bidder_amount }\n else\n format.html { render :edit }\n format.json { render json: @bidder_amount.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @borrower = Borrower.find(params[:id])\n\n respond_to do |format|\n if @borrower.update_attributes(params[:borrower])\n format.html { redirect_to @borrower, notice: 'Borrower was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @borrower.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @borrower = Borrower.find(params[:id])\n\n respond_to do |format|\n if @borrower.update_attributes(params[:borrower])\n format.html { redirect_to @borrower, notice: 'Borrower was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @borrower.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bid.update(bid_params)\n format.html { redirect_to @bid, notice: 'Bid was successfully updated.' }\n format.js\n else\n format.html { render :edit }\n format.js\n end\n end\n end",
"def update\n respond_to do |format|\n if @bitch.update(bitch_params)\n format.html { redirect_to @bitch, notice: 'Bitch was successfully updated.' }\n format.json { render :show, status: :ok, location: @bitch }\n else\n format.html { render :edit }\n format.json { render json: @bitch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rental.update(rental_params)\n Bike.where(:id => @rental.bike_id).update(available: 't',:bikestand_id =>@rental.end_stand_id)\n @rental.update :end_time => Time.now\n @rental.update :cost => ((Time.now - @rental.start_time) / 60 / 60) * 2\n format.html { redirect_to rental_pay_path(@rental), notice: 'Thank you for using bShare!' }\n format.json { render :show, status: :ok, location: @rental }\n else\n format.html { render :edit }\n format.json { render json: @rental.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @my_boice.update(my_boice_params)\n format.html { redirect_to @my_boice, notice: 'My boice was successfully updated.' }\n format.json { render :show, status: :ok, location: @my_boice }\n else\n format.html { render :edit }\n format.json { render json: @my_boice.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @realtime_best_offered_and_bid.update(realtime_best_offered_and_bid_params)\n format.html { redirect_to @realtime_best_offered_and_bid, notice: 'Realtime best offered and bid was successfully updated.' }\n format.json { render :show, status: :ok, location: @realtime_best_offered_and_bid }\n else\n format.html { render :edit }\n format.json { render json: @realtime_best_offered_and_bid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @brasseries.update(brasseries_params)\n format.html { redirect_to @brasseries, notice: 'Brasserie was successfully updated.' }\n format.json { render :show, status: :ok, location: @brasseries }\n else\n format.html { render :edit }\n format.json { render json: @brasseries.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clientsOffers = ClientsOffers.find(params[:id])\n\n respond_to do |format|\n if @clientsOffers.update_attributes(params[:clientsOffers])\n format.html { redirect_to @clientsOffers, notice: 'ClientsOffers was succesfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @clientsOffers.errors, status: :unprocesable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booth.update(booth_params)\n format.html { redirect_to event_booth_path(@booth), notice: 'Booth was successfully updated.' }\n format.json { render :show, status: :ok, location: @booth }\n else\n format.html { render :edit }\n format.json { render json: @booth.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @my_winery.update(my_winery_params)\n format.html { redirect_to @my_winery, notice: \"My winery was successfully updated.\" }\n format.json { render :show, status: :ok, location: @my_winery }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @my_winery.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 respond_to do |format|\n if @bride.update(bride_params)\n format.html { redirect_to @bride, notice: 'Bride was successfully updated.' }\n format.json { render :show, status: :ok, location: @bride }\n else\n format.html { render :edit }\n format.json { render json: @bride.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bowling_association.update(bowling_association_params)\n\n @bowling_association.record :update, current_user, selected_tournament\n\n format.html { redirect_to @bowling_association, notice: 'Bowling association was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bowling_association.errors, status: :unprocessable_entity }\n end\n end\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 @borrow_request = BorrowRequest.find(params[:id])\n\n respond_to do |format|\n if @borrow_request.update_attributes(params[:borrow_request])\n format.html { redirect_to @borrow_request, notice: 'Borrow request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @borrow_request.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 update\n respond_to do |format|\n if @bow.update(bow_params)\n format.html { redirect_to @bow, notice: 'Bow was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bow.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 @bid_action.update(bid_action_params)\n format.html { redirect_to @bid_action, notice: 'Bid action was successfully updated.' }\n format.json { render :show, status: :ok, location: @bid_action }\n else\n format.html { render :edit }\n format.json { render json: @bid_action.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bowling.update(bowling_params)\n format.html { redirect_to @bowling, notice: 'Bowling was successfully updated.' }\n format.json { render :show, status: :ok, location: @bowling }\n else\n format.html { render :edit }\n format.json { render json: @bowling.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ko16_winner.update(ko16_winner_params)\n format.html { redirect_to @ko16_winner, notice: 'Ko16 winner was successfully updated.' }\n format.json { render :show, status: :ok, location: @ko16_winner }\n else\n format.html { render :edit }\n format.json { render json: @ko16_winner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client.update(client_params)\n render json: @client\n end",
"def update\n @borrow = Borrow.find(params[:id])\n\n respond_to do |format|\n if @borrow.update_attributes(params[:borrow])\n format.html { redirect_to @borrow, notice: 'Borrow was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @borrow.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 set_bet_winner\n @bet_winner = BetWinner.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @billable.update(billable_params)\n format.html { redirect_to @billable, notice: 'Billable was successfully updated.' }\n format.json { render :show, status: :ok, location: @billable }\n else\n format.html { render :edit }\n format.json { render json: @billable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bubble_tea = BubbleTea.find(params[:id])\n\n if @bubble_tea.update(bubble_tea_params)\n render json: @bubble_tea\n else\n render plain: \"Failed to update drink information\"\n end\n end",
"def update\n respond_to do |format|\n if @watch_bill.update(watch_bill_params)\n format.html { redirect_to watch_bills_path, notice: 'Watch bill was successfully updated.' }\n format.json { render :show, status: :ok, location: @watch_bill }\n else\n format.html { render :edit }\n format.json { render json: @watch_bill.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @witch = Witch.find(params[:id])\n\n respond_to do |format|\n if @witch.update_attributes(params[:witch])\n format.html { redirect_to @witch, notice: 'Witch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @witch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bowl = Bowl.find(params[:id])\n\n respond_to do |format|\n if @bowl.update_attributes(params[:bowl])\n format.html { redirect_to(@bowl, :notice => 'Bowl was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bowl.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 @bin.assign_attributes bin_params\n\n respond_to do |format|\n if save_bin @bin\n format.html { redirect_to @bin, notice: 'Bin was successfully updated.' }\n format.json { render json: { ok: true, bin: @bin } }\n else\n Rails.logger.error \"Failed to update bin #{params[:id]}\"\n format.html { render :edit }\n format.json { render json: {\n # Respond with the current state of the bin in the database\n ok: false, errors: @bin.errors.full_messages, bin: Bin.find_by(id: params[:id]) }\n }\n end\n end\n end",
"def accept\n\n @bid = @swarm_request.bids.find(params[:id])\n @bid.update_attributes(:accepted => true)\n @swarm_request.update_attributes(:auction_closed => true)\n \n UserMailer.accept_bid_notification(@bid).deliver\n # also update the bid with any details here?\n respond_to do |format|\n format.html { redirect_to(@swarm_request, :notice => 'Bid Accepted.') }\n format.xml { head :ok }\n end\n\n end",
"def update\n respond_to do |format|\n if @award_winner_book.update(award_winner_book_params)\n format.html { redirect_to @award_winner_book, notice: \"Award winner review was successfully updated.\" }\n format.json { render :show, status: :ok, location: @award_winner_book }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @award_winner_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n set_boat\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to harbour_boats_path, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@user = User.find(params[:id])\n \n if @trainer.update(trainer_params)\n render json: @trainer\n else\n render json: @trainer.errors, status: :unprocessable_entity\n end\nend",
"def update\n respond_to do |format|\n if @blivot.update(blivot_params)\n format.html { redirect_to @blivot, notice: 'Blivot was successfully updated.' }\n format.json { render :show, status: :ok, location: @blivot }\n else\n format.html { render :edit }\n format.json { render json: @blivot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_bid\n @bid = Bid.find_by({\n :id => params[:id],\n :auction_id => params[:auction_id]})\n\n render json: nil, status: :not_found if @bid.nil? || @bid.auction.seller.id != @user.id\n end",
"def update\n if @auction.update(auction_params)\n head :no_content\n else\n render json: @auction.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @bill.update(bill_params)\n render json: { bill: @bill }, status: :ok\n else\n render json: { errors: @bill.errors, status: 501 }\n end\n end",
"def update\n @bruger = Bruger.find_by_id(current_user.id)\n @begivenhed = Begivenhed.find(params[:id])\n\n respond_to do |format|\n if @begivenhed.update_attributes(params[:begivenhed])\n format.html { redirect_to @begivenhed, notice: 'Begivenhed was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @begivenhed.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @brend = Brend.find(params[:id])\n\n respond_to do |format|\n if @brend.update_attributes(params[:brend])\n format.html { redirect_to @brend, notice: 'Brend was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @brend.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 @bingo.update(bingo_params)\n format.html { redirect_to @bingo, notice: \"Bingo was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bingo }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bingo.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 @booking = Booking.find(params[:id])\n @booking.update_attributes(params[:booking])\n respond_with(@booking)\n end",
"def update\n respond_to do |format|\n if @betting.update(betting_params)\n format.html { redirect_to @betting, notice: 'Betting was successfully updated.' }\n format.json { render :show, status: :ok, location: @betting }\n else\n format.html { render :edit }\n format.json { render json: @betting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tournament = Tournament.find(@weight.tournament_id)\n respond_to do |format|\n if @weight.update(weight_params)\n format.html { redirect_to @tournament, notice: 'Weight was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @weight.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @borrower_request.update(borrower_request_params)\n @borrower_request.update_attributes(place: JSON.parse(params[:borrower_request][:place].gsub('=>', ':')))\n format.html { redirect_to @borrower_request, notice: 'Borrower request was successfully updated.' }\n format.json { render :show, status: :ok, location: @borrower_request }\n else\n format.html { render :edit }\n format.json { render json: @borrower_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boat.update(boat_params)\n format.html { redirect_to @boat, notice: 'Boat was successfully updated.' }\n format.json { render :show, status: :ok, location: @boat }\n else\n format.html { render :edit }\n format.json { render json: @boat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @boook.update(boook_params)\n format.html { redirect_to @boook, notice: 'Boook was successfully updated.' }\n format.json { render :show, status: :ok, location: @boook }\n else\n format.html { render :edit }\n format.json { render json: @boook.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bottling = Bottling.find(params[:id])\n\n respond_to do |format|\n if @bottling.update_attributes(params[:bottling])\n format.html { redirect_to @bottling, notice: 'bottling was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bottling.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bot = Bot.find(params[:id])\n\n respond_to do |format|\n if @bot.update_attributes(params[:bot])\n format.html { redirect_to @bot, notice: 'Bot was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bot.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_bid\n @bid = @item.bids.find_by(id: params[:id])\n render json: { errors: { detail: \"Bid not found\" } }, status: :unauthorized and return unless @bid\n end",
"def update\n booking = Booking.find(params[:id])\n \n # Check if user is the owner of the booking\n if current_user[:id] == booking[:user_id]\n if booking.update_attributes(booking_params) \n render json: { status: 'SUCCESS', message: 'Updated booking', data: booking }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Booking not updated', data: booking.errors }, status: :unprocessable_entity\n end\n end\n end",
"def update\n #@bet_score = @match.bet_scores.find(params[:id])\n\n respond_to do |format|\n if @bet_score.update_attributes(params[:bet_score])\n format.html { redirect_to match_bet_score_path(@match, @bet_score), notice: 'Bet score was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bet_score.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.692455",
"0.6564157",
"0.65320796",
"0.64614964",
"0.6446403",
"0.6444107",
"0.6438846",
"0.6438846",
"0.6438846",
"0.6438846",
"0.6431077",
"0.64215314",
"0.6402706",
"0.6386484",
"0.6367449",
"0.6357738",
"0.6268321",
"0.62669903",
"0.6233732",
"0.6230411",
"0.6223576",
"0.61889863",
"0.617834",
"0.61765337",
"0.6166759",
"0.6162894",
"0.61493814",
"0.6115945",
"0.6088777",
"0.6077961",
"0.60693926",
"0.6069228",
"0.6067932",
"0.6040541",
"0.603142",
"0.6030144",
"0.6019782",
"0.60191095",
"0.60002",
"0.5986816",
"0.5986816",
"0.5980537",
"0.59675944",
"0.5964722",
"0.59636587",
"0.59612405",
"0.5953001",
"0.59463084",
"0.5939213",
"0.5937469",
"0.59356636",
"0.59317666",
"0.592812",
"0.5898016",
"0.58953583",
"0.5895062",
"0.58909464",
"0.58771974",
"0.58771974",
"0.58771974",
"0.587359",
"0.58707273",
"0.58706",
"0.5868748",
"0.5853771",
"0.5849464",
"0.5842798",
"0.58387834",
"0.5836528",
"0.5835316",
"0.58334243",
"0.5828674",
"0.58236927",
"0.58213043",
"0.5806733",
"0.57953024",
"0.5780006",
"0.5760624",
"0.5760258",
"0.5755729",
"0.5750097",
"0.5749182",
"0.5743896",
"0.57383597",
"0.5737535",
"0.5736908",
"0.5730818",
"0.5728221",
"0.57240504",
"0.5719165",
"0.57124853",
"0.57114434",
"0.57114434",
"0.57114434",
"0.5710479",
"0.5710028",
"0.5706013",
"0.5702515",
"0.56996465",
"0.56985444"
] |
0.69262636
|
0
|
DELETE /bid_winners/1 DELETE /bid_winners/1.json
|
def destroy
@bid_winner.destroy
respond_to do |format|
format.html { redirect_to bid_winners_url, notice: 'Bid winner was successfully destroyed.' }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @bid = @swarm_request.bids.find(params[:id])\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to(swarm_request_bids_url(:swarm_request_id => @swarm_request.to_param)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to auction_bids_url(@auction) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid = Bid.find(params[:id])\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to bids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid = Bid.find(params[:id])\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to bids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bidding = Bidding.find(params[:id])\n @bidding.destroy\n\n respond_to do |format|\n format.html { redirect_to biddings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n name = @bowler.full_name\n @bowler.record :destroy, current_user, selected_tournament\n @bowler.destroy\n respond_to do |format|\n format.html { redirect_to bowlers_url, notice: \"Bowler #{name} has been successfully deleted.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @brewhouse = Brewhouse.find(params[:id])\n @brewhouse.destroy\n\n respond_to do |format|\n format.html { redirect_to brewhouses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bow.destroy\n respond_to do |format|\n format.html { redirect_to bows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bounty.destroy\n respond_to do |format|\n format.html { redirect_to bounties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_bid = UserBid.find(params[:id])\n @user_bid.destroy\n\n respond_to do |format|\n format.html { redirect_to user_bids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mlb_win_bet = MlbWinBet.find(params[:id])\n @mlb_win_bet.destroy\n\n respond_to do |format|\n format.html { redirect_to mlb_win_bets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid.destroy\n respond_to do |format|\n format.html { redirect_to bids_url, notice: 'Bid was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid.destroy\n respond_to do |format|\n format.html { redirect_to bids_url, notice: 'Bid was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid.destroy\n respond_to do |format|\n format.html { redirect_to bids_url, notice: 'Bid was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid.destroy\n respond_to do |format|\n format.html { redirect_to bids_url, notice: 'Bid was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid.destroy\n respond_to do |format|\n format.html { redirect_to bids_url, notice: 'Bid was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @auction = Auction.find(params[:auction_id])\n @bid = Bid.find(params[:id])\n @bid.destroy\n \n respond_to do |format|\n format.html { redirect_to @auction }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_bid = Bid.find(params[:id])\n @admin_bid.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_bids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @winner = Winner.find(params[:id])\n @winner.destroy\n\n respond_to do |format|\n format.html { redirect_to winners_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bet_winner.destroy\n respond_to do |format|\n format.html { redirect_to bet_winners_url, notice: 'Bet winner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bowl = Bowl.find(params[:id])\n @bowl.destroy\n\n respond_to do |format|\n format.html { redirect_to bowls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @borrow = Borrow.find(params[:id])\n @borrow.destroy\n\n respond_to do |format|\n format.html { redirect_to borrows_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @bidding.destroy\n respond_to do |format|\n format.html { redirect_to biddings_url, notice: 'Bidding was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to(bids_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bid_request.destroy\n respond_to do |format|\n format.html { redirect_to bid_requests_url, notice: 'Bid request was successfully destroyed.' }\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 @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 @blocking_client = BlockingClient.find(params[:id])\n @blocking_client.destroy\n\n respond_to do |format|\n format.html { redirect_to blocking_clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid = Bid.find(params[:id])\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to bids_url }\n format.xml { head :ok }\n end\n end",
"def destroy\n @borrow_request = BorrowRequest.find(params[:id])\n @borrow_request.destroy\n\n respond_to do |format|\n format.html { redirect_to borrow_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bot = Bot.find(params[:id])\n @bot.destroy\n\n respond_to do |format|\n format.html { redirect_to bots_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @borrower = Borrower.find(params[:id])\n @borrower.destroy\n\n respond_to do |format|\n format.html { redirect_to borrowers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @borrower = Borrower.find(params[:id])\n @borrower.destroy\n\n respond_to do |format|\n format.html { redirect_to borrowers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @bid.destroy\n respond_to do |format|\n format.html { redirect_to bids_url, notice: 'Bid was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tournament = Tournament.find(@weight.tournament_id)\n @weight.destroy\n respond_to do |format|\n format.html { redirect_to @tournament }\n format.json { head :no_content }\n end\n end",
"def destroy\n @boat = Boat.find(params[:id])\n remove_reknro_from_berth\n @boat.destroy\n\n respond_to do |format|\n format.html { redirect_to boats_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bottling = Bottling.find(params[:id])\n @bottling.destroy\n\n respond_to do |format|\n format.html { redirect_to bottlings_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @twenty.destroy\n respond_to do |format|\n format.html { redirect_to twenties_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bourbon.destroy\n respond_to do |format|\n format.html { redirect_to bourbons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @brend = Brend.find(params[:id])\n @brend.destroy\n\n respond_to do |format|\n format.html { redirect_to brends_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid = Bid.find(params[:id])\n @bid.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/admin/transaction\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bot_bingo_number.destroy\n respond_to do |format|\n format.html { redirect_to bot_bingo_numbers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bounty = Bounty.find(params[:id])\n @bounty.destroy\n respond_to do |format|\n format.html { redirect_to controller: 'home', action: 'bounty_market' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @borad = Borad.find(params[:id])\n @borad.destroy\n\n respond_to do |format|\n format.html { redirect_to borads_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @realtime_best_offered_and_bid.destroy\n respond_to do |format|\n format.html { redirect_to realtime_best_offered_and_bids_url, notice: 'Realtime best offered and bid was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @super_bowl_pick = SuperBowlPick.find(params[:id])\n @super_bowl_pick.destroy\n\n respond_to do |format|\n format.html { redirect_to super_bowl_picks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @broad = Broad.find(params[:id])\n @broad.destroy\n\n respond_to do |format|\n format.html { redirect_to broads_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid_action.destroy\n respond_to do |format|\n format.html { redirect_to bid_actions_url, notice: 'Bid action was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bowler.destroy\n respond_with(@bowler)\n end",
"def destroy\n @bowl = Bowl.find(params[:id])\n @bowl.destroy\n\n respond_to do |format|\n format.html { redirect_to(bowls_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bob = Bob.find(params[:id])\n @bob.destroy\n\n respond_to do |format|\n format.html { redirect_to bobs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @loadbalancer = Loadbalancer.find(params[:id])\n checkaccountobject(\"loadbalancers\",@loadbalancer)\n @loadbalancer.send_delete\n\n respond_to do |format|\n format.html { redirect_to loadbalancers_url }\n format.json { head :ok }\n end\n end",
"def withdraw_player_bid(player)\n self.bids.find_by(name: player).destroy\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 set_boat\n @boat.destroy\n respond_to do |format|\n format.html { redirect_to harbour_boats_path}\n format.json { head :no_content }\n end\n end",
"def destroy\n @booth.destroy\n respond_to do |format|\n format.html { redirect_to event_booths_url, notice: 'Booth was successfully destroyed.' }\n format.json { head :no_content }\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 @winner.destroy\n respond_to do |format|\n format.html { redirect_to winners_url, notice: 'Winner was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clientsOffers = ClientsOffers.find(params[:id])\n @clientsOffers.destroy\n\n respond_to do |format|\n format.html { redirect_to clientsOffers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bowling.destroy\n respond_to do |format|\n format.html { redirect_to bowlings_url, notice: 'Bowling was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @much_withdraw.destroy\n respond_to do |format|\n format.html { redirect_to much_withdraws_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @click_thru = ClickThru.find(params[:id])\n @click_thru.destroy\n\n respond_to do |format|\n format.html { redirect_to click_thrus_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beer_club = BeerClub.find(params[:id])\n @beer_club.destroy\n\n respond_to do |format|\n format.html { redirect_to beer_clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @beer_club = BeerClub.find(params[:id])\n @beer_club.destroy\n\n respond_to do |format|\n format.html { redirect_to beer_clubs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bussiness.destroy\n respond_to do |format|\n format.html { redirect_to bussinesses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bride.destroy\n respond_to do |format|\n format.html { redirect_to brides_url, notice: 'Bride 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 @bike = Bike.find(params[:id])\n @bike.destroy\n\n respond_to do |format|\n format.html { redirect_to bikes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ko16_winner.destroy\n respond_to do |format|\n format.html { redirect_to ko16_winners_url, notice: 'Ko16 winner was successfully destroyed.' }\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 @bustour.destroy\n respond_to do |format|\n format.html { redirect_to bustours_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @won_count.destroy\n respond_to do |format|\n format.html { redirect_to won_counts_url, notice: 'Won count was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @auctionable.destroy\n respond_to do |format|\n format.html { redirect_to auctionables_url, notice: 'Auctionable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @waiter = Waiter.find(params[:id])\n @waiter.destroy\n\n respond_to do |format|\n format.html { redirect_to waiters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lucky_draw.destroy\n respond_to do |format|\n format.html { redirect_to lucky_draws_url, notice: 'Lucky draw was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rink_league = RinkLeague.find(params[:id])\n @rink_league.destroy\n\n respond_to do |format|\n format.html { redirect_to rink_leagues_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @withdrawal_request = WithdrawalRequest.find(params[:id])\n @withdrawal_request.destroy\n\n respond_to do |format|\n format.html { redirect_to withdrawal_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candy.destroy\n respond_to do |format|\n format.html { redirect_to candies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bid_item.destroy\n respond_to do |format|\n format.html { redirect_to bid_items_url, notice: 'Bid item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: UserBoards.delete(params[\"id\"])\n end",
"def destroy\n @bowling_association.record :destroy, current_user, selected_tournament\n @bowling_association.destroy\n\n respond_to do |format|\n format.html { redirect_to bowling_associations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @candy = Candy.find(params[:id])\n @candy.destroy\n\n respond_to do |format|\n format.html { redirect_to candies_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 @bidder_amount.destroy\n respond_to do |format|\n format.html { redirect_to bidder_amounts_url, notice: 'Bidder amount was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @baton = Baton.find(params[:id])\n @baton.destroy\n\n respond_to do |format|\n format.html { redirect_to batons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @railway = Railway.find(params[:id])\n @railway.destroy\n\n respond_to do |format|\n format.html { redirect_to railways_url }\n format.json { head :no_content }\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 @bb = Bb.find(params[:id])\n @bb.destroy\n\n respond_to do |format|\n format.html { redirect_to bbs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bbhk.destroy\n respond_to do |format|\n format.html { redirect_to bbhks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bet.destroy\n respond_to do |format|\n format.html { redirect_to bets_url, notice: 'Bet was successfully destroyed.' }\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 @bunny.destroy\n respond_to do |format|\n format.html { redirect_to bunnies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_client = ApiClient.find(params[:id])\n @api_client.destroy\n\n respond_to do |format|\n format.html { redirect_to api_clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n @uuid = params[:uuid]\n respond_to do |format|\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid }\n format.json { head :no_content }\n end\n end",
"def destroy\n @breach.destroy\n respond_to do |format|\n format.html { redirect_to breaches_url, notice: 'Breach was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @buddy.destroy\n respond_to do |format|\n format.html { redirect_to buddies_url, notice: \"Buddy was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end"
] |
[
"0.7177306",
"0.7116709",
"0.7081332",
"0.7081332",
"0.70671713",
"0.69776374",
"0.694754",
"0.69332546",
"0.6883727",
"0.6860931",
"0.6833714",
"0.6829652",
"0.6829652",
"0.6829652",
"0.6829652",
"0.6829652",
"0.6822566",
"0.6820957",
"0.68122256",
"0.6805556",
"0.6804825",
"0.674968",
"0.67474246",
"0.6746075",
"0.67429334",
"0.6721622",
"0.6721622",
"0.6714885",
"0.6704158",
"0.667659",
"0.66604763",
"0.6658717",
"0.6658717",
"0.6648769",
"0.66216683",
"0.6611345",
"0.660347",
"0.6603293",
"0.65967894",
"0.65677273",
"0.65664047",
"0.655948",
"0.6555297",
"0.6519394",
"0.6517908",
"0.6510115",
"0.6507151",
"0.6497877",
"0.64830863",
"0.64826316",
"0.64808124",
"0.6476587",
"0.64732605",
"0.64680356",
"0.6466149",
"0.64632463",
"0.64631623",
"0.64613783",
"0.64586425",
"0.645819",
"0.6453615",
"0.64472353",
"0.6446932",
"0.64455724",
"0.64455724",
"0.6437032",
"0.6436263",
"0.6435932",
"0.6435209",
"0.6430203",
"0.642891",
"0.642891",
"0.6424065",
"0.6417306",
"0.6412556",
"0.6411773",
"0.6405157",
"0.64046603",
"0.64000136",
"0.639965",
"0.6396587",
"0.6396401",
"0.6395286",
"0.6394945",
"0.63935685",
"0.63935685",
"0.63935685",
"0.6391519",
"0.63862115",
"0.63860464",
"0.6383311",
"0.63801044",
"0.6379712",
"0.6378611",
"0.63779724",
"0.6377968",
"0.63765293",
"0.6359473",
"0.6358813",
"0.63527364"
] |
0.7298102
|
0
|
Use callbacks to share common setup or constraints between actions.
|
def set_bid_winner
@bid_winner = BidWinner.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def bid_winner_params
params.require(:bid_winner).permit(:winner_id, :bid_product, :winning_amount, :bid_cart_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
|
Provide a user friendly representation
|
def to_s
'#<Twilio.Routes.V2.TrunkList>'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@name}, \" \\\n \"#{model.upcase}: \" \\\n \"#{data.values.join(\"/\")}, \" \\\n \":#{@type}\"\n end",
"def to_s\n\t\tsuper\n\tend",
"def to_s\r\n \"<#{self.class.name} id: #{self[:id]}, description: #{self[:description]}, definition: #{self[:definition]}, has_inverse: #{self[:has_inverse]} accuracy: #{self[:accuracy]}\"\r\n end",
"def render\n inspect\n end",
"def to_s\n pieces = []\n pieces << self.class.name\n pieces << \"id:##{id.inspect}\"\n pieces << \"standardized:\" + (is_standard? ? 'standard' : (standard_id.nil? ? 'no' : \"copy-of-#{standard_id}\"))\n pieces << \"mission:#{mission_id.inspect}\"\n pieces.join(', ')\n end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def rendered_format; end",
"def rendered_format; end",
"def to_s\n render\n end",
"def to_s\n return super\n end",
"def display_string\n display = [self.name]\n display << self.description if self.description && self.type == 'StorageType'\n display << self.software if self.software && self.type == 'DatabaseType'\n cpu = self.cpu_values_string\n display << \"CPU: #{cpu}\" unless cpu.blank? || self.type == 'StorageType'\n display << \"RAM: #{self.memory} GB\" if self.memory && self.type != 'StorageType'\n hdd = self.hdd_values_string\n display << \"HDD: #{hdd}\" unless hdd.blank?\n display << self.operating_system if self.operating_system && self.type != 'StorageType'\n display.join(', ')\n end",
"def to_s\n 'Id: ' + @id.to_s +\n ', Expires on: ' + display_expiry_date +\n ', Level: ' + map_number_to_word_level(@level) +\n ', Number of days left to expire: ' + display_num_of_days_left +\n ', Description: ' + @description % self\n end",
"def humanize\n # TODO\n # Inflector.humanize(self)\n end",
"def to_s\n\t\tdescription\n\tend",
"def to_s\n\t\tdescription\n\tend",
"def to_s\n %(<#{ @name }#{attributes}>)\n end",
"def to_s\n %w( name display_name uuid ).collect { |k| \"#{k}=#{ self.send(k) }\" }.join(' | ') + \" | types=#{ types.join(',') }\"\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n self.name.to_s || super\n end",
"def to_s\n descr\n end",
"def to_s\n self.name.humanize\n end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s ; format ; end",
"def formatted_name\n \"#{self.id} - #{self.name}\"\n #This is used to bring value on each page.\n end",
"def to_s\n\t\t\"#{self.name}\"\n\tend",
"def to_s\n \n end",
"def to_s\n self.name || super\n end",
"def to_s\n self.name || super\n end",
"def to_s\n return \"#{@name} - #{@description} : #{@rating}\"\n end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def to_s\n raise NotImplementedError\n end",
"def short_inspect\n attrs = []\n attrs << [\"id\", id || \"new_record\"]\n\n string_attr = proc { |value| '\"' + TextHelpers.truncate(value, :length => 10) + '\"' }\n\n if respond_to?(:name) && name.present?\n attrs << [\"name\", string_attr[name]]\n elsif respond_to?(:title) && title.present?\n attrs << [\"title\", string_attr[title]]\n end\n\n \"#<#{ self.class } #{ attrs.map { |name, value| \"#{ name }: #{ value }\" }.join(\", \") }>\"\n end"
] |
[
"0.70430577",
"0.7025487",
"0.7008232",
"0.7007793",
"0.69441473",
"0.6917163",
"0.68431",
"0.6797009",
"0.6655106",
"0.66227216",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.660979",
"0.660979",
"0.6585346",
"0.65730983",
"0.65662885",
"0.65404147",
"0.65379703",
"0.651875",
"0.651875",
"0.6516385",
"0.6501134",
"0.65010244",
"0.65010244",
"0.65010244",
"0.65010244",
"0.64861107",
"0.6478101",
"0.64581114",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6442197",
"0.64329034",
"0.64289695",
"0.64203346",
"0.6419349",
"0.6419349",
"0.6418417",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64071685",
"0.63947713"
] |
0.0
|
-1
|
Provide a user friendly representation
|
def to_s
context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
"#<Twilio.Routes.V2.TrunkContext #{context}>"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@name}, \" \\\n \"#{model.upcase}: \" \\\n \"#{data.values.join(\"/\")}, \" \\\n \":#{@type}\"\n end",
"def to_s\n\t\tsuper\n\tend",
"def to_s\r\n \"<#{self.class.name} id: #{self[:id]}, description: #{self[:description]}, definition: #{self[:definition]}, has_inverse: #{self[:has_inverse]} accuracy: #{self[:accuracy]}\"\r\n end",
"def render\n inspect\n end",
"def to_s\n pieces = []\n pieces << self.class.name\n pieces << \"id:##{id.inspect}\"\n pieces << \"standardized:\" + (is_standard? ? 'standard' : (standard_id.nil? ? 'no' : \"copy-of-#{standard_id}\"))\n pieces << \"mission:#{mission_id.inspect}\"\n pieces.join(', ')\n end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def rendered_format; end",
"def rendered_format; end",
"def to_s\n render\n end",
"def to_s\n return super\n end",
"def display_string\n display = [self.name]\n display << self.description if self.description && self.type == 'StorageType'\n display << self.software if self.software && self.type == 'DatabaseType'\n cpu = self.cpu_values_string\n display << \"CPU: #{cpu}\" unless cpu.blank? || self.type == 'StorageType'\n display << \"RAM: #{self.memory} GB\" if self.memory && self.type != 'StorageType'\n hdd = self.hdd_values_string\n display << \"HDD: #{hdd}\" unless hdd.blank?\n display << self.operating_system if self.operating_system && self.type != 'StorageType'\n display.join(', ')\n end",
"def to_s\n 'Id: ' + @id.to_s +\n ', Expires on: ' + display_expiry_date +\n ', Level: ' + map_number_to_word_level(@level) +\n ', Number of days left to expire: ' + display_num_of_days_left +\n ', Description: ' + @description % self\n end",
"def humanize\n # TODO\n # Inflector.humanize(self)\n end",
"def to_s\n\t\tdescription\n\tend",
"def to_s\n\t\tdescription\n\tend",
"def to_s\n %(<#{ @name }#{attributes}>)\n end",
"def to_s\n %w( name display_name uuid ).collect { |k| \"#{k}=#{ self.send(k) }\" }.join(' | ') + \" | types=#{ types.join(',') }\"\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n self.name.to_s || super\n end",
"def to_s\n descr\n end",
"def to_s\n self.name.humanize\n end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s ; format ; end",
"def formatted_name\n \"#{self.id} - #{self.name}\"\n #This is used to bring value on each page.\n end",
"def to_s\n\t\t\"#{self.name}\"\n\tend",
"def to_s\n \n end",
"def to_s\n self.name || super\n end",
"def to_s\n self.name || super\n end",
"def to_s\n return \"#{@name} - #{@description} : #{@rating}\"\n end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def to_s\n raise NotImplementedError\n end",
"def short_inspect\n attrs = []\n attrs << [\"id\", id || \"new_record\"]\n\n string_attr = proc { |value| '\"' + TextHelpers.truncate(value, :length => 10) + '\"' }\n\n if respond_to?(:name) && name.present?\n attrs << [\"name\", string_attr[name]]\n elsif respond_to?(:title) && title.present?\n attrs << [\"title\", string_attr[title]]\n end\n\n \"#<#{ self.class } #{ attrs.map { |name, value| \"#{ name }: #{ value }\" }.join(\", \") }>\"\n end"
] |
[
"0.70430577",
"0.7025487",
"0.7008232",
"0.7007793",
"0.69441473",
"0.6917163",
"0.68431",
"0.6797009",
"0.6655106",
"0.66227216",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.660979",
"0.660979",
"0.6585346",
"0.65730983",
"0.65662885",
"0.65404147",
"0.65379703",
"0.651875",
"0.651875",
"0.6516385",
"0.6501134",
"0.65010244",
"0.65010244",
"0.65010244",
"0.65010244",
"0.64861107",
"0.6478101",
"0.64581114",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6442197",
"0.64329034",
"0.64289695",
"0.64203346",
"0.6419349",
"0.6419349",
"0.6418417",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64071685",
"0.63947713"
] |
0.0
|
-1
|
Provide a detailed, user friendly representation
|
def inspect
context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
"#<Twilio.Routes.V2.TrunkContext #{context}>"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def details; end",
"def to_s; description end",
"def get_detail\n return self.inspect\n end",
"def to_display\n raise NotImplementedError\n end",
"def formatted_info\n \"#{self.name} - #{self.description}\"\n end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def inspect\n 'Id: ' + @id.to_s +\n ', Expires on: ' + display_expiry_date +\n ', Level: ' + map_number_to_word_level(@level) +\n ', Number of days left to expire: ' + display_num_of_days_left +\n ', Description: ' + @description % self\n end",
"def short_inspect\n attrs = []\n attrs << [\"id\", id || \"new_record\"]\n\n string_attr = proc { |value| '\"' + TextHelpers.truncate(value, :length => 10) + '\"' }\n\n if respond_to?(:name) && name.present?\n attrs << [\"name\", string_attr[name]]\n elsif respond_to?(:title) && title.present?\n attrs << [\"title\", string_attr[title]]\n end\n\n \"#<#{ self.class } #{ attrs.map { |name, value| \"#{ name }: #{ value }\" }.join(\", \") }>\"\n end",
"def render\n inspect\n end",
"def overview\n\n end",
"def record_display\n string = \"#{id}. Title: #{title}\\n Author: #{author}\\n ISBN: #{isbn}\\n\"\n if library.nil?\n string += \" Library: None\\n\"\n else\n string += \" Library: #{library.branch_name}\\n\"\n end\n if patron.nil?\n string += \" Checked Out: Available\"\n else\n string += \" Checked Out: #{patron.name}\"\n end\n string\n end",
"def render_plain\n short_category(object.action) << \"\\n\" << instance_attributes\n end",
"def details\n\n return @description + \": \" + \"#{@infection}\" + \". \" + @patient.details\n\n end",
"def to_s\n 'Id: ' + @id.to_s +\n ', Expires on: ' + display_expiry_date +\n ', Level: ' + map_number_to_word_level(@level) +\n ', Number of days left to expire: ' + display_num_of_days_left +\n ', Description: ' + @description % self\n end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def display_string\n display = [self.name]\n display << self.description if self.description && self.type == 'StorageType'\n display << self.software if self.software && self.type == 'DatabaseType'\n cpu = self.cpu_values_string\n display << \"CPU: #{cpu}\" unless cpu.blank? || self.type == 'StorageType'\n display << \"RAM: #{self.memory} GB\" if self.memory && self.type != 'StorageType'\n hdd = self.hdd_values_string\n display << \"HDD: #{hdd}\" unless hdd.blank?\n display << self.operating_system if self.operating_system && self.type != 'StorageType'\n display.join(', ')\n end",
"def to_s\r\n \"<#{self.class.name} id: #{self[:id]}, description: #{self[:description]}, definition: #{self[:definition]}, has_inverse: #{self[:has_inverse]} accuracy: #{self[:accuracy]}\"\r\n end",
"def full_description\n \"#{self.class.description} #{self.description}\"\n end",
"def to_s\n descr\n end",
"def details\r\n return @description + \"; \" + @vPatients + \"; \" + @vProfiles + \": \" + @vAppointments\r\n end",
"def display\n to_h.fetch(:display)\n end",
"def display\n to_h.fetch(:display)\n end",
"def inspect_details\n\t\treturn \"ID=%s (%s)\" % [\n\t\t\tself.id,\n\t\t\tself.components.keys.map( &:name ).sort.join( '+' )\n\t\t]\n\tend",
"def to_s\n\t\tres = \"\\nname: \" + name.to_s + \"\\nid: \" + id.to_s + \"\\nservice: \" + service.to_s + \"\\ntitle: \" + title.to_s + \"\\nthumbnail: \" + thumbnail.to_s + \"\\nhref: \" + href.to_s\n\t\tres\n\tend",
"def details\n\t\t\"#{name}---#{status}-----#{start_date}----#{description}---- #{Client.find(client_id).name}---#{Client.find(client_id).email}\"\n\tend",
"def show\n @title = @user.complete_name\n @description = \"Informations relatives à #{@user.complete_name}\"\n @jsonld = @user.to_jsonld\n end",
"def details\n end",
"def to_s\n \"#{represent_status} : #{description}\"\n end",
"def details\n format_description(@description) + \"site name: \" + format_name\n end",
"def to_s\n\t\tdescription\n\tend",
"def to_s\n\t\tdescription\n\tend",
"def to_s_details\n ''\n end",
"def details\n\n end",
"def descriptions\n return @detail + \"; \" + @firm + \"; \" + @age + \": \" + \"#{@cost}\"\n end",
"def show\n\t\t@attrib_keys = [\"desc\", \"higher_level\", \"range\", \"components\", \"material\", \"ritual\", \"duration\", \"concentration\", \"casting_time\", \"level\", \"school\", \"class_names\", \"archetype\", \"domains\", \"oaths\", \"circles\", \"patrons\"]\n\tend",
"def to_s\n \"#{@name}, \" \\\n \"#{model.upcase}: \" \\\n \"#{data.values.join(\"/\")}, \" \\\n \":#{@type}\"\n end",
"def inspect_details\n ''\n end",
"def inspect\n \"#<#{self.class} ##{id} #{name} (#{slug})>\"\n end",
"def display_quick\r\n s = ''\r\n for i in @me.keys\r\n s << \" <b>#{i}.</b><br/>\" # country\r\n for j in @me[i].keys\r\n s << \" <b>#{j}:</b><br/>\" if not j == 'unknown' # state\r\n for k in @me[i][j].keys\r\n s << \" #{k}<br/>\" if not k == 'unknown' # county\r\n for l in @me[i][j][k].keys\r\n s << (\" \" + (l == 'unknown' ? \"<i>repository not given</i>\" : \" #{l}\") + \"<br/>\") if not l == nil # repository\r\n s << \" \" + @me[i][j][k][l].keys.collect{|m| \r\n (\"#{@me[i][j][k][l][m]} \" +\r\n case m # the count\r\n when 'female'\r\n \"♀\"\r\n when 'male'\r\n \"♂\"\r\n when 'gynadropmorph'\r\n \"[♀♂]\"\r\n else\r\n \"unknown sex\"\r\n end)}.join(\",\") \r\n s << \"<br/>\" \r\n end\r\n end\r\n end\r\n end\r\n s.html_safe\r\n end",
"def details\n return @description + \"; \" + @firm + \"; \" + @age + \": \" + \"#{@cost}\"\n end",
"def to_s\n super\n end",
"def to_s\n pieces = []\n pieces << self.class.name\n pieces << \"id:##{id.inspect}\"\n pieces << \"standardized:\" + (is_standard? ? 'standard' : (standard_id.nil? ? 'no' : \"copy-of-#{standard_id}\"))\n pieces << \"mission:#{mission_id.inspect}\"\n pieces.join(', ')\n end",
"def rendered_format; end",
"def rendered_format; end",
"def to_s\n\t\t\tstr = super() + \"\\n\"\n\t\t\tstr += \"\\tAppaleable? #{appaleable}\\n\" if appaleable\n\t\t\tstr += \"\\tDisapproved text: #{disapproved_text}\\n\" if disapproved_text\n\t\t\tstr += \"\\tLocation: #{location}\\n\" if location\n\t\t\tstr += \"\\tDisapproved text: #{disapproved_text}\\n\" if disapproved_text\n\t\t\tstr += \"\\tReason code: #{reason_code} (see: http://msdn.microsoft.com/en-US/library/bing-ads-editorialfailurereasoncodes.aspx)\\n\" if reason_code\n\n\t\tend",
"def display_data\n\t\t\t\"#{@model} #{@color} #{@horsepower} #{@year} #{@brand} #{@mpg}\"\n\t\tend",
"def to_s\n \"\\n\\tTitle: #{@title}\\n\n \\tAuthor: #{@author}\\n\n \\tUrl: #{@url}\\n\\n\"\n end",
"def inspect\n to_s.inspect\n end",
"def details\n data()\n end",
"def details\n\n return @description + \"; \" + @firstname + \"; \" + @lastname + \": \" + @dob + \": \"+ @address + \": \"+ @phone + \": \" + \"#{@infection}\"\n\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def show\n raise NotImplementedError\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def inspect\n\t\tparts = []\n\t\tparts << self.one_of_description\n\t\tparts << self.all_of_description\n\t\tparts << self.none_of_description\n\t\tparts.compact!\n\n\t\tstr = \"#<%p:%#0x matching entities\" % [ self.class, self.object_id * 2 ]\n\t\tif parts.empty?\n\t\t\tstr << \" with any components\"\n\t\telse\n\t\t\tstr << parts.join( ', ' )\n\t\tend\n\t\tstr << \">\"\n\n\t\treturn str\n\tend",
"def inspect\n to_s\n end",
"def description\n return summary\n end",
"def details\n return @description + \"; \" + @doctorname + \"; \" + @medicine + \": \" + \"#{@cost}\"\n end",
"def details\n return \"ID = #{@id}\\n\" + \n \"Name = #{@name}\\n\" + \n \"Topic = #{@topic}\\n\" + \n \"Member Count = #{@member_count}\"\n end",
"def description\n name + ': ' + resource_type.to_s + ' | Sueldo: ' + salary.to_s +\n ' | Experiencia: ' + experience.to_s + ' años'\n end",
"def show\n\t\traise NotImplementedError, \"FIXME: Implement showing comments.\"\n\tend",
"def to_s\n return \"#{@name} - #{@description} : #{@rating}\"\n end",
"def inspect\n \"#{self.class}<#{@description.inspect}>\"\n end",
"def description\n end",
"def description\n end",
"def details\n return \" #{@description}, #{@lastname}, #{@date}. #{@start}, #{@hours}, #{@players}, #{@zone}. #{@cost}\"\n end",
"def display\n\t\tname\n\tend",
"def display\n\t\tname\n\tend",
"def display\n\t\tname\n\tend",
"def display\n\t\tname\n\tend",
"def details\n return @description + \"; \" + @manufacturer + \"; \" + @color + \": \" + \"#{@cost}\"\n end",
"def to_s\n \"#{self.title} - #{self.author} - #{self.date}\"\n end",
"def details\r\n return @description + \": \" + \". \" + @basic_profile.details\r\n end",
"def show\n #not needed for our implementation\n end",
"def to_s\n super\n end",
"def modeler_description\n return 'Gather orientation and story specific construction, fenestration (including overhang) specific information'\n end",
"def details_partial_for(o)\n \"#{o.class.name.underscore}s/details\"\n end",
"def display\n puts \"Personal Details\"\n puts \" Name : #{self.name}\"\n puts \" Date of Birth : #{self.dob}\"\n puts \" Marital Status : #{self.marital_status}\"\n puts \" Mobile Number : #{self.mobile_number}\"\n puts \" Email : #{self.email}\"\n end",
"def detail\n attributes.fetch(:detail)\n end",
"def detail\n attributes.fetch(:detail)\n end"
] |
[
"0.68170065",
"0.68142146",
"0.6758589",
"0.6718451",
"0.66697186",
"0.6655344",
"0.6632312",
"0.66273594",
"0.6550127",
"0.65188134",
"0.6497969",
"0.6480078",
"0.6477721",
"0.6472211",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64367676",
"0.6434794",
"0.63974625",
"0.6391661",
"0.6385164",
"0.63826483",
"0.63826483",
"0.63621265",
"0.63584715",
"0.6352767",
"0.6347243",
"0.6345342",
"0.63338625",
"0.6325844",
"0.6320725",
"0.6320725",
"0.6316434",
"0.6311974",
"0.6311425",
"0.63111603",
"0.6307294",
"0.63050634",
"0.6301272",
"0.62848294",
"0.627871",
"0.6277492",
"0.62770176",
"0.6274702",
"0.6274702",
"0.62604547",
"0.62543267",
"0.6251651",
"0.625114",
"0.62487584",
"0.62225854",
"0.6214293",
"0.6214293",
"0.6212906",
"0.62095803",
"0.62095803",
"0.62095803",
"0.62095803",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6200787",
"0.6198166",
"0.61830676",
"0.6179759",
"0.617746",
"0.61753553",
"0.61619484",
"0.6157944",
"0.61527485",
"0.615132",
"0.615132",
"0.61505795",
"0.6144682",
"0.6144682",
"0.6144682",
"0.6144682",
"0.61351794",
"0.6133033",
"0.61300874",
"0.61294436",
"0.61242044",
"0.6121309",
"0.61148214",
"0.61109483",
"0.6108956",
"0.6108956"
] |
0.0
|
-1
|
Build an instance of TrunkInstance
|
def get_instance(payload)
TrunkInstance.new(@version, payload)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def trunk code, options = {}\n TrunkCode.new code, options\n end",
"def get_instance(payload)\n TranscriptInstance.new(@version, payload)\n end",
"def new_instance(suite, platform, index)\n Instance.new(\n :busser => new_busser(suite, platform),\n :driver => new_driver(suite, platform),\n :logger => new_logger(suite, platform, index),\n :suite => suite,\n :platform => platform,\n :provisioner => new_provisioner(suite, platform),\n :binding => new_binding(suite, platform),\n :state_file => new_state_file(suite, platform)\n )\n end",
"def get_instance(payload)\n RecordingInstance.new(@version, payload, trunk_sid: @solution[:trunk_sid])\n end",
"def new_instance(suite, platform, index)\n Instance.new(\n driver: new_driver(suite, platform),\n lifecycle_hooks: new_lifecycle_hooks(suite, platform),\n logger: new_instance_logger(suite, platform, index),\n suite: suite,\n platform: platform,\n provisioner: new_provisioner(suite, platform),\n transport: new_transport(suite, platform),\n verifier: new_verifier(suite, platform),\n state_file: new_state_file(suite, platform)\n )\n end",
"def context\n unless @instance_context\n @instance_context = TrunkContext.new(@version , @params['sip_trunk_domain'])\n end\n @instance_context\n end",
"def set_trunk_unit\n @trunk_unit = TrunkUnit.find(params[:id])\n end",
"def get_instance(payload)\n WorkspaceInstance.new(@version, payload)\n end",
"def new()\n trace(\"Instance #{index} created\")\n index += 1\n end",
"def trunk() @trunk ||= simple? ? s : left end",
"def create()\n instance = create_instance()\n set_instance_properties(instance)\n create_instance_children(instance)\n return instance\n end",
"def inspect\n values = @properties.map{|k, v| \"#{k}: #{v}\"}.join(\" \")\n \"<Twilio.Routes.V2.TrunkInstance #{values}>\"\n end",
"def for_instance(instance)\n self.clone.tap{|q| q.instance = instance }\n end",
"def create_instance_core() \r\n @log.debug(\"Create core scopetta\")\r\n return CoreGameScopetta.new\r\n end",
"def build_instances\n filter_instances.map.with_index do |(suite, platform), index|\n new_instance(suite, platform, index)\n end\n end",
"def get_instance(payload)\n TaskInstance.new(@version, payload, workspace_sid: @solution[:workspace_sid], )\n end",
"def create_instance\n create_instances(1).first\n end",
"def get_instance(payload)\n TaskInstance.new(@version, payload, workspace_sid: @solution[:workspace_sid])\n end",
"def new\n # build a 'temporary' post which is written to DB later (create-method)\n @unit = Unit.new\n end",
"def to_s\n values = @params.map{|k, v| \"#{k}: #{v}\"}.join(\" \")\n \"<Twilio.Routes.V2.TrunkInstance #{values}>\"\n end",
"def create_in_database(instance)\n return unless @mapping.strategy.build?(instance)\n\n created = @mapping.database_record_type.create!(instance)\n\n @runner.cache_timestamp instance\n @runner.cache_timestamp created\n rescue ActiveRecord::ActiveRecordError, Faraday::Error::ClientError => e\n DB.logger.error(SynchronizationError.new(e, instance))\n end",
"def from_thrift(*args)\n t = args[0]\n initialize(ZTrace.from_thrift(t.trace), TraceSummary.from_thrift(t.summary), TraceTimeline.from_thrift(t.timeline), t.span_depths)\n end",
"def newInstance( params={} )\n model.new( params ).extend( InstanceMethods )\n end",
"def build\n klass = create_class(@class_name, @options)\n klass.new\n end",
"def create_object\n sut.send(:new)\n end",
"def clone_assembly_template\n new_assembly_obj = self.target.clone_into(self.assembly_template, self.override_attrs, self.clone_opts)\n assembly_instance = Assembly::Instance.create_subclass_object(new_assembly_obj)\n end",
"def start_instance\n @instance = Task.find(@task).instances.create\n end",
"def instantiate(params)\n instance = Instance.new( *interpolate(params), @parent )\n # instance.apply_resource_type # TODO: do we need apply_security_scheme?\n instance\n end",
"def new_object\n @object = scope.new params[object_name.to_sym]\n set_instance\n end",
"def new\n @trip = Trips.new\n end",
"def index\n @trunk_units = TrunkUnit.all\n end",
"def make(klass)\n\t\tprototype = @prototypes[klass]\n\t\t\n\t\traise \"No prototype registered for type #{klass}\" if prototype.nil?\n\t\t\n\t\tclone = prototype.clone\n\t\t\n\t\t\n\t\t# special manipulations to \"reset\" certain classes\n\t\t# (clones should be \"empty\", but similar in style)\n\t\t# (thus, they are not REALLY clones, and have to be manipulated from the true clones)\n\t\tif clone.is_a? ThoughtTrace::Text\n\t\t\t# don't allow the text from the prototype to leak\n\t\t\tclone.string = \"\"\n\t\tend\n\t\t\n\t\t\n\t\t# Make sure that position is always reset. Want prototypes to spawn in a reliable way.\n\t\tif clone[:physics]\n\t\t\tclone[:physics].body.p = CP::Vec2.new(0,0)\n\t\tend\n\t\t\n\t\t\n\t\treturn clone\n\tend",
"def get_trunk_by_id(account_number, trunk_id)\r\n # the base uri for api requests\r\n query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n query_builder << '/accounts/{account_number}/trunks/{trunk_id}'\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\r\n 'account_number' => account_number,\r\n 'trunk_id' => trunk_id\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'accept' => 'application/json',\r\n 'X-Auth-Token' => Configuration.x_auth_token\r\n }\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.get query_url, headers: headers\r\n\r\n # Error handling using HTTP status codes\r\n if response.code == 401\r\n raise APIException.new 'You are not authenticated', 401, response.raw_body\r\n elsif response.code == 403\r\n raise APIException.new 'This action needs a valid WSSE header', 403, response.raw_body\r\n elsif response.code == 404\r\n raise APIException.new 'Resource not found', 404, response.raw_body\r\n elsif response.code == 400\r\n raise APIException.new 'Http bad request', 400, response.raw_body\r\n elsif !response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', response.code, response.raw_body\r\n end\r\n\r\n response.body\r\n end",
"def new(options=nil)\n Tidyobj.new(options)\n end",
"def create_target_mock\n ref = self.service_name.downcase.gsub(/ /, '-')\n create_row = {\n ref: ref,\n display_name: self.service_name,\n type: 'instance',\n iaas_type: 'ec2',\n iaas_properties: {},\n project_id: self.project.id\n }\n Model.create_from_row(self.project.model_handle(:target), create_row, convert: true, ret_obj: { model_name: :target_instance })\n end",
"def create_revision!\n revision = RevisionRecord.new(self, acts_as_revisionable_options[:encoding])\n revision.save!\n return revision\n end",
"def bt_zone\n Zone.new(vt_range, tt_range)\n end",
"def initialize(params)\n @instance = params.fetch(:instance)\n end",
"def new\n @tier_setting = TierSetting.new(tier: @week.next_missing_tier)\n end",
"def convert_instance(instance)\n state = @@INSTANCE_STATE_MAP[instance[\"status\"]]\n Instance.new(\n :id => instance[\"id\"],\n :owner_id => instance[\"owner\"],\n :image_id => instance[\"imageId\"],\n :name => instance[\"name\"],\n :realm_id => instance[\"location\"],\n :state => state,\n :actions => instance_actions_for(state),\n :public_addresses => [ InstanceAddress.new(instance[\"primaryIP\"][\"ip\"]) ],\n :private_addresses => [],\n :instance_profile => InstanceProfile.new(instance[\"instanceType\"].gsub('/', '-')),\n :launch_time => instance[\"launchTime\"],\n :keyname => instance[\"keyName\"]\n )\n end",
"def get_instance(payload)\n return RecordInstance.new(\n @version,\n payload,\n account_sid: @solution['account_sid'],\n )\n end",
"def new\n BaseObject.new(self)\n end",
"def get_instance(payload)\n TriggerInstance.new(@version, payload, account_sid: @solution[:account_sid],)\n end",
"def get_instance(payload)\n NewFactorInstance.new(\n @version,\n payload,\n service_sid: @solution[:service_sid],\n identity: @solution[:identity],\n )\n end",
"def create_revision!\n revision_options = self.class.acts_as_revisionable_options\n revision = revision_record_class.new(self, revision_options[:encoding])\n if revision_options[:meta].is_a?(Hash)\n revision_options[:meta].each do |attribute, value|\n set_revision_meta_attribute(revision, attribute, value)\n end\n elsif revision_options[:meta].is_a?(Array)\n revision_options[:meta].each do |attribute|\n set_revision_meta_attribute(revision, attribute, attribute.to_sym)\n end\n elsif revision_options[:meta]\n set_revision_meta_attribute(revision, revision_options[:meta], revision_options[:meta].to_sym)\n end\n revision.save!\n return revision\n end",
"def initialize(name, length_y, width_x, monster, monster_status = \"alive\")\n @name = name\n @room_x = width_x\n @room_y = length_y\n @monster = monster\n @monster_status = monster_status\n @dropped_treasure = []\n @@instances << self\n \n if (name != \"Entryway\") && (name != \"Exit\")\n\n @dropped_treasure << treasure\n end\n \n end",
"def get_instance(payload)\n SimInstance.new(@version, payload)\n end",
"def new()\n #This is a stub, used for indexing\n end",
"def make!\n select_transactions!\n @transactions.each do |transaction|\n vh = VersionHistory.new(transaction.version, transaction.comment)\n VersionHistory.insert(vh)\n DbRegistry.instance.execute_batch(transaction.data)\n end\n end",
"def new\n @wallet = get_wallet\n @transaction = Transaction.new\n end",
"def build_new(*args)\n self.class.new(*args)\n end",
"def migrate(dst)\n self.stop\n new_instance = self.class.new(@node, @options)\n new_instance.start\n return new_instance\n end",
"def get_instance(payload)\n CompositionInstance.new(@version, payload, )\n end",
"def migrate(dst)\n self.stop\n new_instance = self.class.new(@box, @options)\n new_instance.start\n return new_instance\n end",
"def create_in_database(instance)\n return unless @strategy.build?(instance)\n @mapping.database_record_type.create!(instance)\n end",
"def build(floor, overrides)\n @instance || super\n end",
"def get_instance(payload)\n BrandRegistrationOtpInstance.new(@version, payload, brand_registration_sid: @solution[:brand_registration_sid])\n end",
"def new_transaction(res)\n transaction = Transaction.new\n transaction.new(res)\n end",
"def new\n @prediction = Prediction.new\n end",
"def initialize(tourist, landmark)\n @tourist = tourist\n @landmark = landmark\n\n @@all << self # add the current instance we're creating into all the trips\n end",
"def build_hierarchy_entry(depth, tc, name, options = {})\n ActiveRecord::Base.transaction do\n he = HierarchyEntry.gen(:hierarchy => options[:hierarchy] || Hierarchy.default, # TODO - This should *really*\n # be the H associated with the Resource that's being \"harvested\"... technically, CoL\n # shouldn't even have Data Objects. Hierarchy.last may be clever enough, really. I\n # just don't want to change this *right now*--I have other problems...\n :parent_id => options[:parent_id] || 0,\n :identifier => options[:identifier] || '',\n :depth => depth,\n # Cheating. As long as *we* created Ranks with a scenario, this works:\n :rank_id => options[:rank_id] || 0,\n :vetted_id => options[:vetted_id] || Vetted.trusted.id,\n :taxon_concept => tc,\n :name => name)\n # TODO - Create two AgentsHierarchyEntry(ies); you want \"Source Database\" and \"Compiler\" as partner roles\n return he\n end\n end",
"def instance; end",
"def instance; end",
"def instance; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def new; end",
"def context\n unless @instance_context\n @instance_context = RecordingContext.new(@version , @params['trunk_sid'])\n end\n @instance_context\n end",
"def define_vindicia_class\n vs = Vindicia::Schema.new\n transaction_class = vs.classes.select {|x| x.name == \"Transaction\"}.first\n my_needed_class_attributes = [:amount, :currency, :division_number, :merchant_transaction_id,\n :name_values, :timestamp, :vid, :auth_code, :status, :division_number, :select_transaction_id,\n :subscription_id, :subscription_start_date, :customer_id, :payment_method_id,\n :payment_method_is_tokenized, :credit_card_account, :credit_card_account_hash,\n :credit_card_expiration_date, :account_holder_name, :billing_address_line_1,\n :billing_address_district, :billing_address_postal_code, :billing_address_country, :soap_id]\n transaction_class.attributes = my_needed_class_attributes\n Vindicia::SingleClassBuilder.new transaction_class\n eval \"Vindicia::Transaction\"\n end",
"def create_branch\n @tree_class.new\n end",
"def instance\n @instance ||= new\n end",
"def init_transaction(key, settings = {})\n new_transaction = PubSubModelSync::Transaction.new(key, **settings)\n if current_transaction\n current_transaction.add_transaction(new_transaction)\n else\n self.current_transaction = new_transaction\n end\n new_transaction\n end",
"def initialize(instance)\n @instance = instance\n end",
"def initialize(instance, aws_setup_information)\n STDOUT.sync = true\n throw \"can't create an instance without setup data\" if aws_setup_information.nil?\n @aws_setup_information = aws_setup_information\n @aws_instance_data = instance\n # load tags here\n instance.tags.each do |tag|\n if tag.key == 'Repository'\n @repository = tag.value\n elsif tag.key == 'Build-Number'\n @immune = true if tag.value == '000'\n @build_number = tag.value.to_i\n elsif tag.key == 'Environment'\n @environment = tag.value\n elsif tag.key == 'Path-Name'\n @path_name = tag.value\n elsif tag.key == 'Ami-id'\n @ami_id = tag.value\n elsif tag.key == 'Service-Type'\n @service_type = tag.value\n elsif tag.key == 'Nginx-Configuration'\n @balancer_configuration = tag.value\n elsif tag.key == 'Balancer-Configuration'\n @balancer_configuration = tag.value\n elsif tag.key == 'Port'\n @host_port = tag.value.to_i\n elsif tag.key == 'Name'\n @name = tag.value\n elsif tag.key == 'Immune'\n @immune = true\n end\n end\n @host_port = 3000 if @host_port.nil?\n @ssh_timeout_period = 240_000\n @build_number ||= 0\n @immune = false if @immune.nil?\n @instance_type = instance.instance_type\n end",
"def initialize(instance)\n @klass = instance.class\n @instance = instance\n end",
"def make_new_trip(new_trip_data)\n trip = Trip.new(new_trip_data)\n trip.driver.add_trip(trip)\n trip.passenger.add_trip(trip)\n return trip\n end",
"def create_in_salesforce(instance)\n return if instance.synced?\n\n created = @mapping.salesforce_record_type.create!(instance)\n\n @runner.cache_timestamp instance\n @runner.cache_timestamp created\n rescue Faraday::Error::ClientError => e\n DB.logger.error(SynchronizationError.new(e, instance))\n end",
"def new\n @trip = Trip.new\n @trains = Train.all.map { |train| [train.name, train.id] }\n end",
"def create(name)\n object = new(name)\n @instances.push(object)\n object\n end",
"def get_instance(payload)\n RestoreAssistantInstance.new(@version, payload)\n end",
"def get_instance(payload)\n ServiceInstance.new(@version, payload)\n end",
"def get_instance(payload)\n ServiceInstance.new(@version, payload)\n end",
"def instantiate( game )\n t = RBA::Trans::new_u( RBA::Point::new_xy( @x*1000, @y*1000 ) )\n inst = RBA::CellInstArray::new_inst( @cell_index, t )\n game.topcell.insert( inst )\n end",
"def initialize(instance)\n @instance = instance\n end",
"def get_instance(payload)\n SettingsInstance.new(@version, payload, )\n end",
"def get_instance(payload)\n DomainInstance.new(@version, payload, account_sid: @solution[:account_sid])\n end",
"def new\n \n end",
"def new\n \n end",
"def new\n \n end",
"def new\n \n end",
"def new\n \n end",
"def new\n # build a 'temporary' post which is written to DB later (create-method)\n @subsystem = Subsystem.new\n end",
"def new_tenv\n TypeEnv.new(self)\n end",
"def new(klass, *args)\n unless klass.is_a?(BasicObject)\n PEROBS.log.fatal \"#{klass} is not a BasicObject derivative\"\n end\n\n @lock.synchronize do\n obj = _construct_po(klass, _new_id, *args)\n # Mark the new object as modified so it gets pushed into the database.\n @cache.cache_write(obj)\n # Return a POXReference proxy for the newly created object.\n obj.myself\n end\n end"
] |
[
"0.6475194",
"0.6136434",
"0.57862455",
"0.5784211",
"0.5720444",
"0.5533709",
"0.541989",
"0.53673667",
"0.5281895",
"0.5267927",
"0.5225712",
"0.5204002",
"0.50863034",
"0.5076422",
"0.5072901",
"0.50608623",
"0.50405186",
"0.50070596",
"0.49636728",
"0.49558178",
"0.49379736",
"0.49313092",
"0.49226153",
"0.4920466",
"0.49190697",
"0.49098063",
"0.48791042",
"0.48517245",
"0.48491183",
"0.48383027",
"0.48329455",
"0.48212785",
"0.4806692",
"0.48017755",
"0.47965562",
"0.4795153",
"0.47906178",
"0.47807968",
"0.4749373",
"0.47427568",
"0.47352657",
"0.47280687",
"0.47221944",
"0.4711528",
"0.47012588",
"0.46977684",
"0.4697001",
"0.4687672",
"0.46727598",
"0.46712366",
"0.46529183",
"0.46504018",
"0.46497136",
"0.46488082",
"0.4641541",
"0.46402088",
"0.46381384",
"0.4628793",
"0.46231446",
"0.46157876",
"0.4590675",
"0.45812163",
"0.45812163",
"0.45812163",
"0.4575499",
"0.4575499",
"0.4575499",
"0.4575499",
"0.4575499",
"0.4575499",
"0.4575499",
"0.4575499",
"0.4575499",
"0.45714846",
"0.4560428",
"0.45536414",
"0.4544496",
"0.45421994",
"0.45408684",
"0.4540827",
"0.4533338",
"0.4521533",
"0.4519014",
"0.45111847",
"0.45060325",
"0.45050806",
"0.45025873",
"0.45025873",
"0.4502573",
"0.4500158",
"0.44976997",
"0.44910538",
"0.44906637",
"0.44906637",
"0.44906637",
"0.44906637",
"0.44906637",
"0.44884682",
"0.44883853",
"0.4487972"
] |
0.79163444
|
0
|
Provide a user friendly representation
|
def to_s
'<Twilio.Routes.V2.TrunkPage>'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@name}, \" \\\n \"#{model.upcase}: \" \\\n \"#{data.values.join(\"/\")}, \" \\\n \":#{@type}\"\n end",
"def to_s\n\t\tsuper\n\tend",
"def to_s\r\n \"<#{self.class.name} id: #{self[:id]}, description: #{self[:description]}, definition: #{self[:definition]}, has_inverse: #{self[:has_inverse]} accuracy: #{self[:accuracy]}\"\r\n end",
"def render\n inspect\n end",
"def to_s\n pieces = []\n pieces << self.class.name\n pieces << \"id:##{id.inspect}\"\n pieces << \"standardized:\" + (is_standard? ? 'standard' : (standard_id.nil? ? 'no' : \"copy-of-#{standard_id}\"))\n pieces << \"mission:#{mission_id.inspect}\"\n pieces.join(', ')\n end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def rendered_format; end",
"def rendered_format; end",
"def to_s\n render\n end",
"def to_s\n return super\n end",
"def display_string\n display = [self.name]\n display << self.description if self.description && self.type == 'StorageType'\n display << self.software if self.software && self.type == 'DatabaseType'\n cpu = self.cpu_values_string\n display << \"CPU: #{cpu}\" unless cpu.blank? || self.type == 'StorageType'\n display << \"RAM: #{self.memory} GB\" if self.memory && self.type != 'StorageType'\n hdd = self.hdd_values_string\n display << \"HDD: #{hdd}\" unless hdd.blank?\n display << self.operating_system if self.operating_system && self.type != 'StorageType'\n display.join(', ')\n end",
"def to_s\n 'Id: ' + @id.to_s +\n ', Expires on: ' + display_expiry_date +\n ', Level: ' + map_number_to_word_level(@level) +\n ', Number of days left to expire: ' + display_num_of_days_left +\n ', Description: ' + @description % self\n end",
"def humanize\n # TODO\n # Inflector.humanize(self)\n end",
"def to_s\n\t\tdescription\n\tend",
"def to_s\n\t\tdescription\n\tend",
"def to_s\n %(<#{ @name }#{attributes}>)\n end",
"def to_s\n %w( name display_name uuid ).collect { |k| \"#{k}=#{ self.send(k) }\" }.join(' | ') + \" | types=#{ types.join(',') }\"\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n self.name.to_s || super\n end",
"def to_s\n descr\n end",
"def to_s\n self.name.humanize\n end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s ; format ; end",
"def formatted_name\n \"#{self.id} - #{self.name}\"\n #This is used to bring value on each page.\n end",
"def to_s\n\t\t\"#{self.name}\"\n\tend",
"def to_s\n \n end",
"def to_s\n self.name || super\n end",
"def to_s\n self.name || super\n end",
"def to_s\n return \"#{@name} - #{@description} : #{@rating}\"\n end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def to_s\n raise NotImplementedError\n end",
"def short_inspect\n attrs = []\n attrs << [\"id\", id || \"new_record\"]\n\n string_attr = proc { |value| '\"' + TextHelpers.truncate(value, :length => 10) + '\"' }\n\n if respond_to?(:name) && name.present?\n attrs << [\"name\", string_attr[name]]\n elsif respond_to?(:title) && title.present?\n attrs << [\"title\", string_attr[title]]\n end\n\n \"#<#{ self.class } #{ attrs.map { |name, value| \"#{ name }: #{ value }\" }.join(\", \") }>\"\n end"
] |
[
"0.70430577",
"0.7025487",
"0.7008232",
"0.7007793",
"0.69441473",
"0.6917163",
"0.68431",
"0.6797009",
"0.6655106",
"0.66227216",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.660979",
"0.660979",
"0.6585346",
"0.65730983",
"0.65662885",
"0.65404147",
"0.65379703",
"0.651875",
"0.651875",
"0.6516385",
"0.6501134",
"0.65010244",
"0.65010244",
"0.65010244",
"0.65010244",
"0.64861107",
"0.6478101",
"0.64581114",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6442197",
"0.64329034",
"0.64289695",
"0.64203346",
"0.6419349",
"0.6419349",
"0.6418417",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64071685",
"0.63947713"
] |
0.0
|
-1
|
Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context
|
def context
unless @instance_context
@instance_context = TrunkContext.new(@version , @params['sip_trunk_domain'])
end
@instance_context
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def context\n unless @instance_context\n @instance_context = ApplicationContext.new(@version , @params['account_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = SimContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = InteractionContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = TriggerContext.new(@version, @params['account_sid'], @params['sid'],)\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = ServiceContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = ServiceContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CallContext.new(@version , @params['account_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CpsContext.new(@version, )\n end\n @instance_context\n end",
"def proxy_context\n @context\n end",
"def context\n unless @instance_context\n @instance_context = CallContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CallContext.new(@version, @params['account_sid'], @params['sid'],)\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CurrentCallContext.new(@version, )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = AnonymizeContext.new(@version , @params['room_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = DomainContext.new(@version , @params['account_sid'], @params['sid'])\n end\n @instance_context\n end",
"def contextify\n self.class.monadic_context.new self\n end",
"def context\n unless @instance_context\n @instance_context = SandboxContext.new(\n @version,\n @params['account_sid'],\n )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CompositionHookContext.new(@version, @params['sid'], )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = ConfigurationContext.new(@version )\n end\n @instance_context\n end",
"def context\n init\n @context\n end",
"def context\n unless @instance_context\n @instance_context = InteractionChannelContext.new(\n @version,\n @params['interaction_sid'],\n @params['sid'],\n )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = UserInfoContext.new(@version )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = EngagementContextContext.new(@version , @params['flow_sid'], @params['engagement_sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CampaignContext.new(@version, @params['sid'], )\n end\n @instance_context\n end",
"def initialize(*args, &block)\n super(*args)\n instance_exec(_context, &block)\n end",
"def context\n unless @instance_context\n @instance_context = EsimProfileContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def execution_context\n initialize_context!(Object.new)\n end",
"def context\n unless @instance_context\n @instance_context = BulkEligibilityContext.new(@version , @params['request_id'])\n end\n @instance_context\n end",
"def setup_context\n context_methods.each do |m|\n @context.add_method m, self\n end\n\n @context.define_klass\n end",
"def context\n unless @instance_context\n @instance_context = RecordingContext.new(@version , @params['trunk_sid'])\n end\n @instance_context\n end",
"def context\n Context.instance\n end",
"def context\n unless @instance_context\n @instance_context = ReservationContext.new(@version , @params['workspace_sid'], @params['worker_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CountryContext.new(@version , @params['iso_code'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CompositionContext.new(@version, @params['sid'], )\n end\n @instance_context\n end",
"def context_methods\n super + [:context]\n end",
"def context\n unless @instance_context\n @instance_context = TaskContext.new(@version , @params['workspace_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = TranscriptContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = AppManifestContext.new(@version , @params['app_sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = ChannelContext.new(@version , @params['service_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n @context ||= Context.new(self)\n end",
"def context\n unless @instance_context\n @instance_context = TaskContext.new(@version, @params['workspace_sid'], @params['sid'], )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = CallSummaryContext.new(@version , @params['call_sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = NumberContext.new(@version, @params['destination_number'], )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = SummaryContext.new(\n @version,\n @params['call_sid'],\n )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = RatePlanContext.new(@version, @params['sid'], )\n end\n @instance_context\n end",
"def context\n @context ||= new_context_mock(context_options, &finalize_proc)\n end",
"def context\n unless @instance_context\n @instance_context = OauthContext.new(@version )\n end\n @instance_context\n end",
"def context\n @context ||= Context.new(self)\n end",
"def context\n unless @instance_context\n @instance_context = DeactivationsContext.new(@version )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = SipDomainContext.new(@version , @params['sip_domain'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = PhoneNumberContext.new(@version , @params['phone_number'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = PhoneNumberContext.new(@version , @params['phone_number'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = MediaProcessorContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = ChannelContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = IntentStatisticsContext.new(\n @version,\n @params['assistant_sid'],\n @params['intent_sid'],\n )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = DomainConfigContext.new(@version, @params['domain_sid'], )\n end\n @instance_context\n end",
"def context_methods; end",
"def call(*args)\n @ctx.instance_exec(args, &action)\n end",
"def context\n unless @instance_context\n @instance_context = ConfigurationContext.new(@version , @params['chat_service_sid'])\n end\n @instance_context\n end",
"def initialize\n self.context = Context.new\n end",
"def context\n unless @instance_context\n @instance_context = InteractionChannelParticipantContext.new(@version , @params['interaction_sid'], @params['channel_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = WorkflowRealTimeStatisticsContext.new(@version , @params['workspace_sid'], @params['workflow_sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = LinkshorteningMessagingServiceDomainAssociationContext.new(@version , @params['messaging_service_sid'])\n end\n @instance_context\n end",
"def context(klass, options={}, &blk)\n assoc = options.delete(:as) || self.name.demodulize.underscore\n assoc = assoc.to_sym\n\n nk = options[:name_key] ||= get_name_key\n\n self.hook_instance(\"change_#{nk}\") do |inst, old, new|\n inst.context.indices[assoc].update_membership(inst)\n end\n\n klass.index(assoc, options) do |name, target|\n inst = new(target, name)\n yield(inst, target) if block_given?\n inst\n end\n end",
"def context\n unless @instance_context\n @instance_context = ExportAssistantContext.new(@version, @params['assistant_sid'], )\n end\n @instance_context\n end",
"def method_missing(method_name, *args, &blk)\n @context.__send__(method_name, *args, &blk)\n end",
"def context\n unless @instance_context\n @instance_context = DialogueContext.new(@version , @params['assistant_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = TaskStatisticsContext.new(@version , @params['assistant_sid'], @params['task_sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = WorkspaceContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = RoomContext.new(@version , @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = WorkflowStatisticsContext.new(\n @version,\n @params['workspace_sid'],\n @params['workflow_sid'],\n )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = WorkflowRealTimeStatisticsContext.new(\n @version,\n @params['workspace_sid'],\n @params['workflow_sid'],\n )\n end\n @instance_context\n end",
"def method_missing(method, *args, &block)\n context.send(method, *args, &block)\n end",
"def method_missing(method, *args, &block)\n context.send(method, *args, &block)\n end",
"def initialize(context)\n super()\n self.context = context\n end",
"def context\n unless @instance_context\n @instance_context = DomainCertsContext.new(@version , @params['domain_sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = SettingsContext.new(@version, )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = DomainCertsContext.new(@version, @params['domain_sid'], )\n end\n @instance_context\n end",
"def context\n @context ||= {}\n end",
"def context\n @context ||= {}\n end",
"def context\n unless @instance_context\n @instance_context = SecondaryAuthTokenContext.new(@version )\n end\n @instance_context\n end",
"def context\n return @target if @target.is_a?(Module) && !@options[:class_methods]\n\n @target.singleton_class\n end",
"def _prepare_context; end",
"def context\n unless @instance_context\n @instance_context = InsightsQuestionnairesContext.new(@version , @params['questionnaire_sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = NotificationContext.new(@version, @params['chat_service_sid'], )\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = FeedbackSummaryContext.new(@version , @params['account_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = FeedbackSummaryContext.new(@version, @params['account_sid'], @params['sid'],)\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = ParticipantContext.new(@version , @params['account_sid'], @params['conference_sid'], @params['call_sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = UserDefinedMessageSubscriptionContext.new(@version , @params['account_sid'], @params['call_sid'], @params['sid'])\n end\n @instance_context\n end",
"def context\n unless @instance_context\n @instance_context = NotificationContext.new(@version , @params['chat_service_sid'])\n end\n @instance_context\n end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end"
] |
[
"0.6837958",
"0.68024147",
"0.6796363",
"0.6771269",
"0.6768456",
"0.6768456",
"0.6731739",
"0.66826314",
"0.6680222",
"0.6678165",
"0.6677005",
"0.6640645",
"0.66272235",
"0.6610219",
"0.66006243",
"0.65918165",
"0.6568012",
"0.6560853",
"0.6556747",
"0.65498286",
"0.65467674",
"0.6505262",
"0.64959955",
"0.6489847",
"0.646345",
"0.6447711",
"0.6409286",
"0.6405041",
"0.6367371",
"0.63512164",
"0.6331297",
"0.63197386",
"0.63130915",
"0.6298682",
"0.62758946",
"0.62684023",
"0.6259634",
"0.62585104",
"0.6258157",
"0.6235794",
"0.62159294",
"0.6214418",
"0.62122047",
"0.61958563",
"0.6193196",
"0.6191929",
"0.6187054",
"0.61692",
"0.61667764",
"0.6159969",
"0.6159879",
"0.61587024",
"0.61465466",
"0.6138267",
"0.61333567",
"0.6127209",
"0.6126267",
"0.61226857",
"0.61115056",
"0.60825586",
"0.6077716",
"0.6054916",
"0.6041216",
"0.6039025",
"0.6033279",
"0.60162294",
"0.6011203",
"0.60108924",
"0.60106415",
"0.6010428",
"0.5978341",
"0.5975568",
"0.5975568",
"0.59660226",
"0.5954026",
"0.59482837",
"0.59411514",
"0.5931129",
"0.5931129",
"0.590109",
"0.59004253",
"0.58905715",
"0.5883339",
"0.5879904",
"0.5867403",
"0.5849182",
"0.5830445",
"0.58264416",
"0.5819458",
"0.5816757",
"0.5816757",
"0.5816757",
"0.5816757",
"0.5816757",
"0.5816757",
"0.5816757",
"0.5816757",
"0.5816757",
"0.5816757",
"0.5816757"
] |
0.65719545
|
16
|
Provide a user friendly representation
|
def to_s
values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
"<Twilio.Routes.V2.TrunkInstance #{values}>"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def to_display\n raise NotImplementedError\n end",
"def to_s; description end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def to_s\n super\n end",
"def to_s\n super\n end",
"def to_s\n \"#{@name}, \" \\\n \"#{model.upcase}: \" \\\n \"#{data.values.join(\"/\")}, \" \\\n \":#{@type}\"\n end",
"def to_s\n\t\tsuper\n\tend",
"def to_s\r\n \"<#{self.class.name} id: #{self[:id]}, description: #{self[:description]}, definition: #{self[:definition]}, has_inverse: #{self[:has_inverse]} accuracy: #{self[:accuracy]}\"\r\n end",
"def render\n inspect\n end",
"def to_s\n pieces = []\n pieces << self.class.name\n pieces << \"id:##{id.inspect}\"\n pieces << \"standardized:\" + (is_standard? ? 'standard' : (standard_id.nil? ? 'no' : \"copy-of-#{standard_id}\"))\n pieces << \"mission:#{mission_id.inspect}\"\n pieces.join(', ')\n end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def format; end",
"def rendered_format; end",
"def rendered_format; end",
"def to_s\n render\n end",
"def to_s\n return super\n end",
"def display_string\n display = [self.name]\n display << self.description if self.description && self.type == 'StorageType'\n display << self.software if self.software && self.type == 'DatabaseType'\n cpu = self.cpu_values_string\n display << \"CPU: #{cpu}\" unless cpu.blank? || self.type == 'StorageType'\n display << \"RAM: #{self.memory} GB\" if self.memory && self.type != 'StorageType'\n hdd = self.hdd_values_string\n display << \"HDD: #{hdd}\" unless hdd.blank?\n display << self.operating_system if self.operating_system && self.type != 'StorageType'\n display.join(', ')\n end",
"def to_s\n 'Id: ' + @id.to_s +\n ', Expires on: ' + display_expiry_date +\n ', Level: ' + map_number_to_word_level(@level) +\n ', Number of days left to expire: ' + display_num_of_days_left +\n ', Description: ' + @description % self\n end",
"def humanize\n # TODO\n # Inflector.humanize(self)\n end",
"def to_s\n\t\tdescription\n\tend",
"def to_s\n\t\tdescription\n\tend",
"def to_s\n %(<#{ @name }#{attributes}>)\n end",
"def to_s\n %w( name display_name uuid ).collect { |k| \"#{k}=#{ self.send(k) }\" }.join(' | ') + \" | types=#{ types.join(',') }\"\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n self.name.to_s || super\n end",
"def to_s\n descr\n end",
"def to_s\n self.name.humanize\n end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s; end",
"def to_s ; format ; end",
"def formatted_name\n \"#{self.id} - #{self.name}\"\n #This is used to bring value on each page.\n end",
"def to_s\n\t\t\"#{self.name}\"\n\tend",
"def to_s\n \n end",
"def to_s\n self.name || super\n end",
"def to_s\n self.name || super\n end",
"def to_s\n return \"#{@name} - #{@description} : #{@rating}\"\n end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def inspect; to_s; end",
"def to_s\n raise NotImplementedError\n end",
"def short_inspect\n attrs = []\n attrs << [\"id\", id || \"new_record\"]\n\n string_attr = proc { |value| '\"' + TextHelpers.truncate(value, :length => 10) + '\"' }\n\n if respond_to?(:name) && name.present?\n attrs << [\"name\", string_attr[name]]\n elsif respond_to?(:title) && title.present?\n attrs << [\"title\", string_attr[title]]\n end\n\n \"#<#{ self.class } #{ attrs.map { |name, value| \"#{ name }: #{ value }\" }.join(\", \") }>\"\n end"
] |
[
"0.70430577",
"0.7025487",
"0.7008232",
"0.7007793",
"0.69441473",
"0.6917163",
"0.68431",
"0.6797009",
"0.6655106",
"0.66227216",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.6618043",
"0.660979",
"0.660979",
"0.6585346",
"0.65730983",
"0.65662885",
"0.65404147",
"0.65379703",
"0.651875",
"0.651875",
"0.6516385",
"0.6501134",
"0.65010244",
"0.65010244",
"0.65010244",
"0.65010244",
"0.64861107",
"0.6478101",
"0.64581114",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6448988",
"0.6442197",
"0.64329034",
"0.64289695",
"0.64203346",
"0.6419349",
"0.6419349",
"0.6418417",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64115626",
"0.64071685",
"0.63947713"
] |
0.0
|
-1
|
Provide a detailed, user friendly representation
|
def inspect
values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
"<Twilio.Routes.V2.TrunkInstance #{values}>"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def details; end",
"def to_s; description end",
"def get_detail\n return self.inspect\n end",
"def to_display\n raise NotImplementedError\n end",
"def formatted_info\n \"#{self.name} - #{self.description}\"\n end",
"def toString\n #Not sure if we want this or just use the getters for more\n #selective formatting\n end",
"def inspect\n 'Id: ' + @id.to_s +\n ', Expires on: ' + display_expiry_date +\n ', Level: ' + map_number_to_word_level(@level) +\n ', Number of days left to expire: ' + display_num_of_days_left +\n ', Description: ' + @description % self\n end",
"def short_inspect\n attrs = []\n attrs << [\"id\", id || \"new_record\"]\n\n string_attr = proc { |value| '\"' + TextHelpers.truncate(value, :length => 10) + '\"' }\n\n if respond_to?(:name) && name.present?\n attrs << [\"name\", string_attr[name]]\n elsif respond_to?(:title) && title.present?\n attrs << [\"title\", string_attr[title]]\n end\n\n \"#<#{ self.class } #{ attrs.map { |name, value| \"#{ name }: #{ value }\" }.join(\", \") }>\"\n end",
"def render\n inspect\n end",
"def overview\n\n end",
"def record_display\n string = \"#{id}. Title: #{title}\\n Author: #{author}\\n ISBN: #{isbn}\\n\"\n if library.nil?\n string += \" Library: None\\n\"\n else\n string += \" Library: #{library.branch_name}\\n\"\n end\n if patron.nil?\n string += \" Checked Out: Available\"\n else\n string += \" Checked Out: #{patron.name}\"\n end\n string\n end",
"def render_plain\n short_category(object.action) << \"\\n\" << instance_attributes\n end",
"def details\n\n return @description + \": \" + \"#{@infection}\" + \". \" + @patient.details\n\n end",
"def to_s\n 'Id: ' + @id.to_s +\n ', Expires on: ' + display_expiry_date +\n ', Level: ' + map_number_to_word_level(@level) +\n ', Number of days left to expire: ' + display_num_of_days_left +\n ', Description: ' + @description % self\n end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def display_string\n display = [self.name]\n display << self.description if self.description && self.type == 'StorageType'\n display << self.software if self.software && self.type == 'DatabaseType'\n cpu = self.cpu_values_string\n display << \"CPU: #{cpu}\" unless cpu.blank? || self.type == 'StorageType'\n display << \"RAM: #{self.memory} GB\" if self.memory && self.type != 'StorageType'\n hdd = self.hdd_values_string\n display << \"HDD: #{hdd}\" unless hdd.blank?\n display << self.operating_system if self.operating_system && self.type != 'StorageType'\n display.join(', ')\n end",
"def to_s\r\n \"<#{self.class.name} id: #{self[:id]}, description: #{self[:description]}, definition: #{self[:definition]}, has_inverse: #{self[:has_inverse]} accuracy: #{self[:accuracy]}\"\r\n end",
"def full_description\n \"#{self.class.description} #{self.description}\"\n end",
"def to_s\n descr\n end",
"def details\r\n return @description + \"; \" + @vPatients + \"; \" + @vProfiles + \": \" + @vAppointments\r\n end",
"def display\n to_h.fetch(:display)\n end",
"def display\n to_h.fetch(:display)\n end",
"def inspect_details\n\t\treturn \"ID=%s (%s)\" % [\n\t\t\tself.id,\n\t\t\tself.components.keys.map( &:name ).sort.join( '+' )\n\t\t]\n\tend",
"def to_s\n\t\tres = \"\\nname: \" + name.to_s + \"\\nid: \" + id.to_s + \"\\nservice: \" + service.to_s + \"\\ntitle: \" + title.to_s + \"\\nthumbnail: \" + thumbnail.to_s + \"\\nhref: \" + href.to_s\n\t\tres\n\tend",
"def details\n\t\t\"#{name}---#{status}-----#{start_date}----#{description}---- #{Client.find(client_id).name}---#{Client.find(client_id).email}\"\n\tend",
"def show\n @title = @user.complete_name\n @description = \"Informations relatives à #{@user.complete_name}\"\n @jsonld = @user.to_jsonld\n end",
"def details\n end",
"def to_s\n \"#{represent_status} : #{description}\"\n end",
"def details\n format_description(@description) + \"site name: \" + format_name\n end",
"def to_s\n\t\tdescription\n\tend",
"def to_s\n\t\tdescription\n\tend",
"def to_s_details\n ''\n end",
"def details\n\n end",
"def descriptions\n return @detail + \"; \" + @firm + \"; \" + @age + \": \" + \"#{@cost}\"\n end",
"def show\n\t\t@attrib_keys = [\"desc\", \"higher_level\", \"range\", \"components\", \"material\", \"ritual\", \"duration\", \"concentration\", \"casting_time\", \"level\", \"school\", \"class_names\", \"archetype\", \"domains\", \"oaths\", \"circles\", \"patrons\"]\n\tend",
"def to_s\n \"#{@name}, \" \\\n \"#{model.upcase}: \" \\\n \"#{data.values.join(\"/\")}, \" \\\n \":#{@type}\"\n end",
"def inspect_details\n ''\n end",
"def inspect\n \"#<#{self.class} ##{id} #{name} (#{slug})>\"\n end",
"def display_quick\r\n s = ''\r\n for i in @me.keys\r\n s << \" <b>#{i}.</b><br/>\" # country\r\n for j in @me[i].keys\r\n s << \" <b>#{j}:</b><br/>\" if not j == 'unknown' # state\r\n for k in @me[i][j].keys\r\n s << \" #{k}<br/>\" if not k == 'unknown' # county\r\n for l in @me[i][j][k].keys\r\n s << (\" \" + (l == 'unknown' ? \"<i>repository not given</i>\" : \" #{l}\") + \"<br/>\") if not l == nil # repository\r\n s << \" \" + @me[i][j][k][l].keys.collect{|m| \r\n (\"#{@me[i][j][k][l][m]} \" +\r\n case m # the count\r\n when 'female'\r\n \"♀\"\r\n when 'male'\r\n \"♂\"\r\n when 'gynadropmorph'\r\n \"[♀♂]\"\r\n else\r\n \"unknown sex\"\r\n end)}.join(\",\") \r\n s << \"<br/>\" \r\n end\r\n end\r\n end\r\n end\r\n s.html_safe\r\n end",
"def details\n return @description + \"; \" + @firm + \"; \" + @age + \": \" + \"#{@cost}\"\n end",
"def to_s\n super\n end",
"def to_s\n pieces = []\n pieces << self.class.name\n pieces << \"id:##{id.inspect}\"\n pieces << \"standardized:\" + (is_standard? ? 'standard' : (standard_id.nil? ? 'no' : \"copy-of-#{standard_id}\"))\n pieces << \"mission:#{mission_id.inspect}\"\n pieces.join(', ')\n end",
"def rendered_format; end",
"def rendered_format; end",
"def to_s\n\t\t\tstr = super() + \"\\n\"\n\t\t\tstr += \"\\tAppaleable? #{appaleable}\\n\" if appaleable\n\t\t\tstr += \"\\tDisapproved text: #{disapproved_text}\\n\" if disapproved_text\n\t\t\tstr += \"\\tLocation: #{location}\\n\" if location\n\t\t\tstr += \"\\tDisapproved text: #{disapproved_text}\\n\" if disapproved_text\n\t\t\tstr += \"\\tReason code: #{reason_code} (see: http://msdn.microsoft.com/en-US/library/bing-ads-editorialfailurereasoncodes.aspx)\\n\" if reason_code\n\n\t\tend",
"def display_data\n\t\t\t\"#{@model} #{@color} #{@horsepower} #{@year} #{@brand} #{@mpg}\"\n\t\tend",
"def to_s\n \"\\n\\tTitle: #{@title}\\n\n \\tAuthor: #{@author}\\n\n \\tUrl: #{@url}\\n\\n\"\n end",
"def inspect\n to_s.inspect\n end",
"def details\n data()\n end",
"def details\n\n return @description + \"; \" + @firstname + \"; \" + @lastname + \": \" + @dob + \": \"+ @address + \": \"+ @phone + \": \" + \"#{@infection}\"\n\n end",
"def inspect\n to_s\n end",
"def inspect\n to_s\n end",
"def show\n raise NotImplementedError\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def to_s\n long_display\n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def inspect\n\t\tparts = []\n\t\tparts << self.one_of_description\n\t\tparts << self.all_of_description\n\t\tparts << self.none_of_description\n\t\tparts.compact!\n\n\t\tstr = \"#<%p:%#0x matching entities\" % [ self.class, self.object_id * 2 ]\n\t\tif parts.empty?\n\t\t\tstr << \" with any components\"\n\t\telse\n\t\t\tstr << parts.join( ', ' )\n\t\tend\n\t\tstr << \">\"\n\n\t\treturn str\n\tend",
"def inspect\n to_s\n end",
"def description\n return summary\n end",
"def details\n return @description + \"; \" + @doctorname + \"; \" + @medicine + \": \" + \"#{@cost}\"\n end",
"def details\n return \"ID = #{@id}\\n\" + \n \"Name = #{@name}\\n\" + \n \"Topic = #{@topic}\\n\" + \n \"Member Count = #{@member_count}\"\n end",
"def description\n name + ': ' + resource_type.to_s + ' | Sueldo: ' + salary.to_s +\n ' | Experiencia: ' + experience.to_s + ' años'\n end",
"def show\n\t\traise NotImplementedError, \"FIXME: Implement showing comments.\"\n\tend",
"def to_s\n return \"#{@name} - #{@description} : #{@rating}\"\n end",
"def inspect\n \"#{self.class}<#{@description.inspect}>\"\n end",
"def description\n end",
"def description\n end",
"def details\n return \" #{@description}, #{@lastname}, #{@date}. #{@start}, #{@hours}, #{@players}, #{@zone}. #{@cost}\"\n end",
"def display\n\t\tname\n\tend",
"def display\n\t\tname\n\tend",
"def display\n\t\tname\n\tend",
"def display\n\t\tname\n\tend",
"def details\n return @description + \"; \" + @manufacturer + \"; \" + @color + \": \" + \"#{@cost}\"\n end",
"def to_s\n \"#{self.title} - #{self.author} - #{self.date}\"\n end",
"def details\r\n return @description + \": \" + \". \" + @basic_profile.details\r\n end",
"def show\n #not needed for our implementation\n end",
"def to_s\n super\n end",
"def modeler_description\n return 'Gather orientation and story specific construction, fenestration (including overhang) specific information'\n end",
"def details_partial_for(o)\n \"#{o.class.name.underscore}s/details\"\n end",
"def display\n puts \"Personal Details\"\n puts \" Name : #{self.name}\"\n puts \" Date of Birth : #{self.dob}\"\n puts \" Marital Status : #{self.marital_status}\"\n puts \" Mobile Number : #{self.mobile_number}\"\n puts \" Email : #{self.email}\"\n end",
"def detail\n attributes.fetch(:detail)\n end",
"def detail\n attributes.fetch(:detail)\n end"
] |
[
"0.68170065",
"0.68142146",
"0.6758589",
"0.6718451",
"0.66697186",
"0.6655344",
"0.6632312",
"0.66273594",
"0.6550127",
"0.65188134",
"0.6497969",
"0.6480078",
"0.6477721",
"0.6472211",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64502096",
"0.64367676",
"0.6434794",
"0.63974625",
"0.6391661",
"0.6385164",
"0.63826483",
"0.63826483",
"0.63621265",
"0.63584715",
"0.6352767",
"0.6347243",
"0.6345342",
"0.63338625",
"0.6325844",
"0.6320725",
"0.6320725",
"0.6316434",
"0.6311974",
"0.6311425",
"0.63111603",
"0.6307294",
"0.63050634",
"0.6301272",
"0.62848294",
"0.627871",
"0.6277492",
"0.62770176",
"0.6274702",
"0.6274702",
"0.62604547",
"0.62543267",
"0.6251651",
"0.625114",
"0.62487584",
"0.62225854",
"0.6214293",
"0.6214293",
"0.6212906",
"0.62095803",
"0.62095803",
"0.62095803",
"0.62095803",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6205272",
"0.6200787",
"0.6198166",
"0.61830676",
"0.6179759",
"0.617746",
"0.61753553",
"0.61619484",
"0.6157944",
"0.61527485",
"0.615132",
"0.615132",
"0.61505795",
"0.6144682",
"0.6144682",
"0.6144682",
"0.6144682",
"0.61351794",
"0.6133033",
"0.61300874",
"0.61294436",
"0.61242044",
"0.6121309",
"0.61148214",
"0.61109483",
"0.6108956",
"0.6108956"
] |
0.0
|
-1
|
GET /provincia/provincia_id/partidos/partido_id/localidades.json GET /localidades/1.json
|
def show
@localidad = Localidad.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_part_by_company_part\n @parts = PartsController::PartService.get_part_by_company_part(params[:param_part])\n if !@parts.nil?\n respond_to do |format|\n format.json{ render json: @parts}\n end \n else\n #não foi encontrado as informacoes\n end\n\tend",
"def partido\n localidad.partido\n end",
"def show\n @local_deportivo = LocalDeportivo.find(params[:id], :conditions=> \"estado = 'C' OR estado is NULL\")\n \n @espacio_deportivos = @local_deportivo.espacio_deportivos.find(:all)\n \n \n respond_to do |format|\n format.html \n format.json { render json: {:espacio_deportivos =>@espacio_deportivos, :local_deportivo => @local_deportivo }}\n end\n \n end",
"def index\n @localidades = Localidad.all\n end",
"def show\n @local_deportivo = LocalDeportivo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @local_deportivo }\n end\n end",
"def index\n @local_pedidos = LocalPedido.all\n end",
"def index\n @partidas = Partida.all\n end",
"def show\n @usuario_partida = UsuarioPartida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usuario_partida }\n end\n end",
"def index\n @departamentos = Departamento.all\n\n render json: @departamentos\n end",
"def new\n @espacio_deportivo = EspacioDeportivo.new\n logger.info(\">>>\")\n logger.info(params[:local_id])\n @local_deportivo = LocalDeportivo.find(params[:local_id])\n logger.info(\">>>\")\n logger.info(@local_deportivo.nombre)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @espacio_deportivo }\n end\n end",
"def show\n @coligacao_partido = ColigacaoPartido.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @coligacao_partido }\n end\n end",
"def index\n @partidas = Partida.all\n end",
"def show\n @local_desportivo = LocalDesportivo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @local_desportivo }\n end\n end",
"def index\n \n if !params[:partida_id]\n @partida = get_partida\n else\n @partida = get_usuario_sessao.partidas.find(params[:partida_id])\n set_partida(@partida)\n\n end\n\n @jogadors = @partida.jogadors.all\n end",
"def new\n @coligacao_partido = ColigacaoPartido.new\n @partidos = Partido.find(:all, :order => \"nome\")\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @coligacao_partido }\n end\n end",
"def local_pedido_params\n params.require(:local_pedido).permit(:local_id, :pedido_id, :estado_id)\n end",
"def index\n if current_user.luna?\n respond_to do |format|\n format.html do\n @parts = Part.order(\"#{lowered_column} #{sort_direction}, id DESC\").page(params[:page]).per_page(Constants::PER_PAGE)\n end\n format.json do\n render json: Part.all_as_json\n end\n end\n else\n redirect_to(logout_path)\n end\n end",
"def show\n @trlocalidad = Trlocalidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @trlocalidad }\n end\n end",
"def new\n @realiza = Realiza.new\n @pessoas=Pessoa.select(\"clientes.id,pessoas.nome\").joins(:cliente)\n @funcionarios=Pessoa.select(\"usuarios.id,pessoas.nome\").joins(:usuario)\n #@pessoas=Pessoa.select(\"clientes.id,pessoas.nome\").joins(:clientes)\n #@funcionarios=Pessoa.where(\"id in (?)\",Usuario.select(\"pessoa_id as id\").map(&:id))\n @servicos=Servico.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @realiza and @pessoas and @funcionarios and @servicos}\n end\n end",
"def index\n @persona = Persona.find(params[:persona_id])\n @info_extra_paciente = @persona.info_extra_pacientes.all\n format.html { render :show }\n end",
"def get_company_by_company_part\n @parts = CompaniesController::CompanyService.get_company_by_company_part(params[:param_part])\n if !@parts.nil?\n respond_to do |format|\n format.json{ render json: @parts}\n end \n else\n #não foi encontrado as informacoes\n end\n\tend",
"def consulta\n fiesta = Fiesta.all\n render json: fiesta\n end",
"def show\n \t\tif params[:usuario_pedido]\n \t\t\t@usuario = Usuario.find(params[:usuario_id])\n \t\t\trender json: @usuario.pedidos.find(@pedido.id)\n \t\telse\n \t\t\t@negocio = Negocio.find(params[:negocio_id])\n \t\t\trender json: @negocio.pedidos.find(@pedido.id)\n \t\tend\n \tend",
"def show\n render json: @departamento\n end",
"def get_part_by_car_category\n @cars = PartsController::PartService.get_part_by_car_category(params[:paran_car], params[:paran_category]);\n respond_to do |format|\n format.json { render json: @cars }\n end \n end",
"def patina\n sectors = Sector.where(user: current_user).load\n subsectors = Subsector.where(sector_id: sectors.map(&:id)).group_by(&:sector_id)\n activities = Activity.where(subsector_id: subsectors.values.flatten.map(&:id)).group_by(&:subsector_id)\n\n @json_locals = { sectors: sectors, subsectors: subsectors, activities: activities }\n\n respond_to do |format|\n format.html { render 'patina' }\n format.json { render partial: 'patina', locals: @json_locals, status: :ok }\n end\n end",
"def index\n @localizacions = Localizacion.all\n end",
"def index\n @localities = Locality.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @localities }\n end\n end",
"def show\n @partecipante = Partecipante.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partecipante }\n end\n end",
"def infoFarmaciaProducto\n \tid = params[:id]\n @farmacias = ProFar.find_by_sql(\"SELECT disponibilidads.nombre as nombreDisponibilidad, presentacions.descripcion, productos.nombre as nombreProducto,farmacia.nombre, farmacia.correo, farmacia.direccion, farmacia.latitud, farmacia.longitud, farmacia.telefono1, \n\t\tfarmacia.telefono2 FROM farmacia, productos, disponibilidads, pro_fars, presentacions\n\t\twhere pro_fars.id = #{id} and pro_fars.farmacium_id = farmacia.id and pro_fars.producto_id = productos.id and pro_fars.disponibilidad_id = disponibilidads.id and\n\t\tpresentacions.id = presentacion_id;\")\n\t\t render json: @farmacias\n end",
"def index\n @pacientes = Pacientes.all\n render json: @pacientes\n end",
"def get\n @cine = Cine.find(params[:cine_id], :select => [\"nombre\",\"id\",\"direccion\",\"localidad\"])\n render :json => [ @cine, :peliculas => @cine.peliculas.select('titulo,horas,pelicula_id') ]\n end",
"def show\n @plato = Plato.find(params[:id])\n\n if !@plato.comentario.first.nil?\n render json: @plato.as_json(only: [:id, :nombre, :precio, :categoria, :tipo, :calificaciones, :total, :soda_id], include: [comentario:{only: [:id]}])\n else\n render json: @plato.as_json(only: [:id, :nombre, :precio, :categoria, :tipo, :calificaciones, :total, :soda_id])\n end\n end",
"def proximos\n @lista = Array.new\n estabelecimentos = Estabelecimento.all\n if (params[:token] != nil)\n user = Usuario.find_by_token(params[:token])\n @favoritos = Favorito.find_all_by_usuario_id(user.id)\n estabelecimentos.each do |estab|\n estab.favorito = false\n @favoritos.each do |fav|\n if (fav.estabelecimento_id == estab.id)\n estab.favorito = true\n break\n end\n end \n end\n end\n \n raio = params[:raio]\n if (raio == nil)\n raio = 1000\n end\n estabelecimentos.each do |estab|\n dist = distancia(params[:latitude].to_f, params[:longitude].to_f,estab.latitude, estab.longitude)\n if (dist.to_f <= raio.to_f && dist.to_f != 0.0)\n if (estab.favorito == nil)\n estab.favorito = false\n end\n @lista.push(estab)\n end\n end\n \n respond_to do |format|\n format.html # proximos.html.erb\n format.json { render :json => @lista, :include => {:precos =>{:only => :valor, :include =>:produto } , \n :caracteristicas => {:only => [:nome, :id]} } }\n end\n \n end",
"def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def index\n @pedidos = Pedido.find(:all,:conditions=> {:status => [0], :user_id => current_user.id})\n if @pedidos.count > 0\n @imagen_pedidos = @pedidos[0].imagen_pedidos\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @imagen_pedidos }\n end\n else\n redirect_to pedidos_path, notice: 'No tiene pedidos pendientes'\n end\n end",
"def index\n @q = Contato.ransack(params[:q])\n @contatos = @q.result.includes(departamento: [:local]).order(:nome).page(params[:page])\n end",
"def show\n @partido = Partido.find(params[:id])\n end",
"def get_ponto\n render json: Usuario.ultimo_ponto(params[:user_id], params[:evento_id]).to_json\n end",
"def get_part_by_car\n @cars = PartsController::PartService.get_part_by_car(params[:param]);\n respond_to do |format|\n format.json { render json: @cars }\n end \n end",
"def index\n @pedidos = Pedido.find(:all, :conditions => [\"cliente_id=?\", session[:usuario_id]])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pedidos }\n end\n end",
"def show\n \n @protectora = Protectora.find(params[:id])\n @nombreProtectora = Protectora.find(params[:id]).nombre\n @mis_mascotas = Mascotum.find(:all, :conditions => {:protectora => @nombreProtectora})\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @protectora }\n end\n end",
"def index\n @reparticoes = Reparticao.all\n end",
"def get_part_by_category\n @categorys = PartsController::PartService.get_part_by_category(params[:param]);\n respond_to do |format|\n format.json { render json: @categorys }\n end \n end",
"def set_local_pedido\n @local_pedido = LocalPedido.find(params[:id])\n end",
"def index\n @municipio_de_la_preparatoria_o_universidad_de_origens = MunicipioDeLaPreparatoriaOUniversidadDeOrigen.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @municipio_de_la_preparatoria_o_universidad_de_origens }\n end\n end",
"def situations_arrivals_countries_three\n @situations_arrivals_countries = SituationsArrivalsCountry.where(status:true, id: [1,2,3]).order('name ASC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @situations_arrivals_countries}\n end\n end",
"def new\n @usuario_partida = UsuarioPartida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario_partida }\n end\n end",
"def InfoFarmacia\n \tid = params[:id]\n @farmacias = Farmacium.find_by_sql(\"SELECT nombre, correo, direccion, latitud, longitud, telefono1, telefono2 FROM farmacia where id = #{id}\")\n render json: @farmacias\n end",
"def mostrar_partidos\n \n puts \" \"\n puts \"Quantidade de votos por partido\"\n \n for partido in @partido\n partido.mostrar_dados \n end\n end",
"def index\n @localvdos = Localvdo.all\n end",
"def index\n if params[:estado]\n @municipios = Uf.find(params[:estado]).municipios\n else\n @municipios = Uf.first.municipios\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @municipios }\n end\n end",
"def new\n @local_deportivo = LocalDeportivo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @local_deportivo }\n end\n end",
"def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end",
"def index\n logement = Logement.find_by(id:params[:logement_id])\n equipement = logement.equi_securites[0].title\n equipements = logement.equi_securites[0]\n\n render json: {\n securites:equipement,\n fichier:equipements\n }\n end",
"def set_localidad\n @localidad = Localidad.find(params[:id])\n end",
"def geoportal\n if p = @especie.proveedor\n if p.snib_id.present? && p.snib_reino.present?\n # Catch the response\n begin\n response = RestClient.get \"#{CONFIG.geoportal_url}&rd=#{p.snib_reino}&id=#{p.snib_id}\", :timeout => 10, :open_timeout => 10\n render json: [] unless response.present?\n rescue => e\n render json: []\n end\n\n render json: response\n\n else\n render json: []\n end\n else\n render json: []\n end\n\n end",
"def index\n find_dependencias\n respond_to do |format|\n format.html\n format.json { render :json => @dependencias.to_json(:methods => :alias_or_fullname, :only => [:id, :codigo, :nombre])}\n\n end\n end",
"def index\n @partners = Partner.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @partners }\n end\n end",
"def set_partida\n @partida = Partida.find(params[:id])\n end",
"def set_partida\n @partida = Partida.find(params[:id])\n end",
"def show\n @part = @product.parts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @part }\n end\n end",
"def show\n @requerimiento ||= Requerimiento.where(:numero => params[:id]).first\n @areas = Area.where(\" nombre like '%DIT%' \")\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @requerimiento }\n end\n end",
"def index\n @participante_videoconferencia = ParticipanteVideoconferencium.all\n render json: @participante_videoconferencia\n end",
"def new\n\n @departamento = Departamento.new\n @pais = Departamento.do_orgao(@orgao.id).order(:nome).collect{|p|[p.nome,p.id]}\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @departamento }\n end\n end",
"def show\n @receita_medica = ReceitaMedica.find(params[:id])\n @item_receitas = @receita_medica.item_receitas.all\n respond_to do |format|\n format.html # show.html.erb \n format.json { render json: {\n :receita => @receita_medica, \n :medicamentos => @receita_medica.item_receitas.collect {|t| [t.medicamento.nome, t.posologia, t.quantidade]} } }\n end\n end",
"def show\n @persona = Persona.find(params[:id])\n @paciente = @persona.perstable\n #aqui deben ir los datos del paciente tambien\n end",
"def InfoPlanPaciente\n \tid = params[:id]\n @plan_paciente = TipoPlan.find_by_sql(\"select descripcion FROM tipo_plans where plan_paciente_id = #{id} and tipo = 'Paciente'\")\n render json: @plan_paciente\n end",
"def get_todo_restaurants\n @profile = Profile.find(params[:id])\n @restaurants = @profile.todos\n\n render status: 200, json: @restaurants\n end",
"def index\n @curriculum_vitaes = findable_curriculum_vitaes.all\n respond_to do |format|\n format.html {}\n format.json { render json: @curriculum_vitaes }\n end\n end",
"def index\n @parties = Party.order(:name).all\n\n respond_to do |format|\n format.html\n format.json { render json: @parties }\n format.xml { render xml: @parties }\n end\n end",
"def index\n @partenaires = Partenaire.paginate(:page => params[:page], :per_page => 12, :order => \"created_at desc\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @partenaires }\n end\n end",
"def index\n @preparatoria_o_universidad_de_origens = PreparatoriaOUniversidadDeOrigen.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @preparatoria_o_universidad_de_origens }\n end\n end",
"def new\n @uf = Uf.first\n @municipios = @uf.municipios\n @cargo_eleicao = Eleicao.find(:first, :conditions => \"status = true\").cargo_eleicaos\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cargo_eleicao }\n end\n end",
"def Plan_Paciente\n id = params[:id]\n plan_paciente = PlanPaciente.find_by_sql(\"SELECT nombre FROM plan_pacientes where laboratorio_id= #{id}\")\n render json: plan_paciente\n end",
"def parties(session_id)\n fetch \"eksport/partier/?sesjonid=#{session_id}\"\n end",
"def create\n @local_pedido = LocalPedido.new(local_pedido_params)\n\n respond_to do |format|\n if @local_pedido.save\n format.html { redirect_to @local_pedido, notice: 'Local pedido was successfully created.' }\n format.json { render :show, status: :created, location: @local_pedido }\n else\n format.html { render :new }\n format.json { render json: @local_pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @partner_project = PartnerProject.find(params[:id])\n @project = @partner_project.project \n @partner = @partner_project.partner \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partner_project }\n end\n end",
"def get_modelos\n marca = Marca.find(params[:marca_id])\n @modelos = Modelo.of_marca(marca.id)\n\n render json: @modelos\n\n end",
"def showLocal\n @user = User.by_local(params[:local])\n render json: @user\n end",
"def countries\n \tif params[:continent_id].present?\n \t\tputs params[:continent_id]\n \t\tvalor = params[:continent_id]\n \t\tcountries = Country.joins(:country_category).where(status: true, continent_number: [valor]).select(:id,:name,:name_cr,:flag_image,:generic_image,:country_category_id,'country_categories.percentage_profile AS country_category_percentage_profile')\n \trender json: countries\n else\n \trender :json => {:result => 'ERROR'}\n \tend\n end",
"def show\n @venta = Venta.find(params[:id])\n\n @domicilios = Domicilio.where(usuario_id: @venta.usuario.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @venta }\n end\n end",
"def show\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pago }\n end\n end",
"def local_params\n params.require(:local).permit(:usuario_a_id, :nombre, :foto, :calificacion, :descripcion, :horario, :direccion, :latitud, :longitud, :foto_file_name, :foto_content_type, :foto_file_size, :foto_updated_at, :visible, :imagenUrl)\n end",
"def show\n @municipio_de_la_preparatoria_o_universidad_de_origen = MunicipioDeLaPreparatoriaOUniversidadDeOrigen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @municipio_de_la_preparatoria_o_universidad_de_origen }\n end\n end",
"def show\n @vehicule_perso = VehiculePerso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @vehicule_perso }\n end\n end",
"def partner\n @services = Service.all\n @countries = Country.all\n @departments = Department.all\n end",
"def show\n @puestos_entidad = PuestosEntidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @puestos_entidad }\n end\n end",
"def show\n @ordinario = Ordinario.find(params[:id])\n @alumnos = @ordinario.alumnos\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @ordinario }\n end\n end",
"def respuesta_externa\n @comentario_root = @comentario.root\n @comentario_root.completa_info(@comentario_root.usuario_id)\n @especie_id = params[:especie_id] || 0 # Si es cero, es porque era un comentario general y lo cambiaron de tipo de comentario\n @ficha = (params[:ficha].present? && params[:ficha] == '1')\n\n # Si es una respuesta de usuario o es para mostrar en la ficha\n if (params[:created_at].present? && @comentario_root.created_at.strftime('%d-%m-%y_%H-%M-%S') != params[:created_at])\n render :file => '/public/404.html', :status => 404, :layout => false\n else\n\n @comentario_resp = @comentario\n cuantos = @comentario_root.descendant_ids.count\n categoriaContenido = @comentario.categorias_contenido_id\n\n #Esto es para que en el show se muestre el primer comentario ALWAYS (el seguro está en preguntar si resp.present?)\n @comentario_root.completa_info(@comentario_root.usuario_id)\n resp = [@comentario_root]\n\n if cuantos > 0\n resp = resp + @comentario.descendants.map{ |c|\n c.completa_info(@comentario_root.usuario_id)\n c\n }\n end\n\n # Como resp ya esta seteado desde arriba, ya no es necesario mandar uno distinto si cuantos == 0\n @comentarios = {estatus:1, cuantos: cuantos, resp: resp}\n\n # Para crear el comentario si NO es el render de la ficha\n if @ficha\n render 'show', layout: false\n else\n\n if Comentario::RESUELTOS.include?(@comentario_root.estatus) #Marcado como resuleto\n @sin_caja = true\n elsif Comentario::OCULTAR == @comentario_root.estatus # Marcado como eliminado\n @eliminado = true\n elsif Comentario::MODERADOR == @comentario_root.estatus # Marcado como eliminado\n @moderador = true\n else\n # Para saber el id del ultimo comentario, antes de sobreescribir a @comentario\n ultimo_comentario = @comentario_resp.subtree.order('ancestry ASC').map(&:id).reverse.first\n\n # Crea el nuevo comentario con las clases de la gema ancestry\n @comentario = Comentario.children_of(ultimo_comentario).new\n\n # Datos del usuario\n @comentario.usuario_id = @comentario_resp.usuario_id\n @comentario.nombre = @comentario_resp.nombre\n @comentario.correo = @comentario_resp.correo\n @comentario.institucion = @comentario.institucion\n\n # Estatus 6 quiere decir que es parte del historial de un comentario\n @comentario.estatus = Comentario::RESPUESTA\n\n # Categoria comentario ID\n @comentario.categorias_contenido_id = categoriaContenido\n\n # Caseta de verificacion\n @comentario.con_verificacion = true\n\n # Proviene de un administrador\n @comentario.es_admin = false\n\n # Si es una respuesta de un usuario\n @comentario.es_respuesta = true\n\n # Asigna la especie\n @comentario.especie_id = @comentario_resp.especie_id\n end # end si no es un comenatrio resuelto\n\n render 'show'\n\n end\n\n end\n end",
"def show\n @external_partnership = ExternalPartnership.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @external_partnership }\n end\n end",
"def FarmaciasCercanaSearch\n \tid = params[:id]\n @farmacias = ProFar.find_by_sql(\"select pro_fars.id, farmacia.nombre, farmacia.latitud, farmacia.longitud\t\n FROM pro_fars, farmacia where activo_produc = true and producto_id = #{id} and pro_fars.farmacium_id = farmacia.id\")\n render json: @farmacias\n end",
"def retrieve(id)\n @client.make_request(:get, \"parcels/#{id}\", MODEL_CLASS)\n end",
"def show\n @partido_politico = PartidoPolitico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partido_politico }\n end\n end",
"def show\n @partecipanti_gruppo = PartecipantiGruppo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @partecipanti_gruppo }\n end\n end",
"def show\n @toyota_epc_part_number_list_child = ToyotaEpc::PartNumberListChild.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @toyota_epc_part_number_list_child }\n end\n end",
"def find_partners_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PartnerApi.find_partners ...'\n end\n # resource path\n local_var_path = '/partners'\n\n # query parameters\n query_params = {}\n query_params[:'tags'] = @api_client.build_collection_param(opts[:'tags'], :csv) if !opts[:'tags'].nil?\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['api_key']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<Partner>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PartnerApi#find_partners\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n @pedido = Pedido.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pedido }\n end\n end",
"def flights\n trip = Trip.where('id = ?', params[:id]).take\n if !trip.nil\n respond_with( trip.flights )\n else\n render :json => { error: 404 }, :status => 404\n end\n end"
] |
[
"0.6416379",
"0.6206604",
"0.6159835",
"0.6154614",
"0.61402464",
"0.6113565",
"0.60688066",
"0.59984833",
"0.59729457",
"0.5954942",
"0.5925315",
"0.59159523",
"0.5900415",
"0.58651465",
"0.58270305",
"0.5802913",
"0.5779527",
"0.576133",
"0.57380867",
"0.5717439",
"0.570488",
"0.5623426",
"0.5600322",
"0.5584249",
"0.5576026",
"0.5568494",
"0.55656695",
"0.55455416",
"0.5525599",
"0.547416",
"0.54729027",
"0.5470445",
"0.5469426",
"0.54599714",
"0.54573613",
"0.54573613",
"0.5451498",
"0.5449885",
"0.5445664",
"0.5440144",
"0.54349",
"0.54314953",
"0.5426418",
"0.5420547",
"0.5415387",
"0.54054594",
"0.5402418",
"0.53826374",
"0.5376083",
"0.53706634",
"0.53676623",
"0.5360635",
"0.5347565",
"0.5347249",
"0.5346597",
"0.53418577",
"0.53398937",
"0.53325546",
"0.53323233",
"0.5330806",
"0.53264946",
"0.5324786",
"0.5318516",
"0.53108835",
"0.5306951",
"0.5298359",
"0.52888674",
"0.52883536",
"0.5288228",
"0.5286026",
"0.52818906",
"0.52782434",
"0.52764857",
"0.52761877",
"0.527388",
"0.52659315",
"0.5260211",
"0.52599597",
"0.52568233",
"0.5256432",
"0.5244571",
"0.52432424",
"0.52420354",
"0.52407473",
"0.5236987",
"0.52281123",
"0.5228107",
"0.52230644",
"0.5220655",
"0.5217419",
"0.52143764",
"0.52125406",
"0.52119005",
"0.5205984",
"0.5201499",
"0.5199998",
"0.51967186",
"0.51929",
"0.5190763",
"0.51897734"
] |
0.57600284
|
18
|
start Ebay Shopping Methods
|
def find_half_products_by_keyword( keywords, options = {} )
options.merge!({:QueryKeywords => keywords})
req = EbayShopping::Request.new(self,:FindHalfProducts,options)
req.execute
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hit_ebay\n self.gimmie_the_goods(self.ebay_grab)\n end",
"def fetch_products\n if Settings.ebay.try(:crawler)\n fetch_products_with_crawler\n else\n fetch_products_with_api\n end\n end",
"def start\n send_message('Hello! Welcome to Hedma store🥰')\n send_message('Which item do you want to buy, dear customer?')\n user.set_next_bot_command('pants')\n end",
"def buy_product\n products = @seller.show_product_info \n product_buy = @view.buy_product(products)\n @total_price = @seller.save_buy_a_product(product_buy)\n @view.buy_status(@total_price)\n input = @view.menu(\"2\")\n seller_actions(input) \n end",
"def ebay_time\n\t\t@caller.make_shop_call 'GeteBayTime'\n\tend",
"def attemp_buying\n\n end",
"def submit\n raise EbayTraderError, 'Cannot post an eBay API request before application keys have been set' unless EbayTrader.configuration.has_keys_set?\n\n uri = EbayTrader.configuration.uri\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.read_timeout = http_timeout\n\n if uri.port == 443\n # http://www.rubyinside.com/nethttp-cheat-sheet-2940.html\n http.use_ssl = true\n verify = EbayTrader.configuration.ssl_verify\n if verify\n if verify.is_a?(String)\n pem = File.read(verify)\n http.cert = OpenSSL::X509::Certificate.new(pem)\n http.key = OpenSSL::PKey::RSA.new(pem)\n end\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n else\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n end\n\n post = Net::HTTP::Post.new(uri.path, headers)\n post.body = xml_request\n\n begin\n response = http.start { |http| http.request(post) }\n rescue OpenSSL::SSL::SSLError => e\n # SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed\n raise EbayTraderError, e\n rescue Net::ReadTimeout\n raise EbayTraderTimeoutError, \"Failed to complete #{call_name} in #{http_timeout} seconds\"\n rescue Exception => e\n raise EbayTraderError, e\n ensure\n EbayTrader.configuration.counter_callback.call if EbayTrader.configuration.has_counter?\n end\n\n @http_response_code = response.code.to_i.freeze\n\n # If the call was successful it should have a response code starting with '2'\n # http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html\n raise EbayTraderError, \"HTTP Response Code: #{http_response_code}\" unless http_response_code.between?(200, 299)\n\n if response['Content-Encoding'] == 'gzip'\n @xml_response = ActiveSupport::Gzip.decompress(response.body)\n else\n @xml_response = response.body\n end\n end",
"def start\n test_btc\n test_email\n end",
"def checkout \n system 'clear'\n CoffeeMan.stay_logo\n if @@cart.count == 0 \n puts \"Your cart is empty, please select an item\"\n sleep 1\n main_menu \n else\n system('say \"Already blocked it in my calendar!\"')\n puts \"Your order has been confirmed of #{@@cart.join(\", \")}. It will be ready for pickup in #{rand(20...40)} minutes! Can't wait to hangout!\"\n puts \"Already blocked it in my calendar!\".colorize(:color => :light_blue, :background => :yellow)\n stop_music \n sleep 2\n end\n end",
"def start_application\n sleep(1)\n loop do\n puts \"\\nWhat price are you looking for?\"\n input = gets.chomp\n next if input.empty?\n\n @analyzer.process_request(input)\n end\n end",
"def request_phase\n redirect ebay_login_url(session['omniauth.ebay.session_id'] = get_session_id(options.runame))\n end",
"def merchant_end_point; end",
"def run_shopping_list\n\tputs \"Here's your list so far:\"\n\tputs\n\tputs format_list(@shopping_list)\n\tputs\n\titem = request_item\n\twhile item != \"\"\n\t\ttry_add_item(item)\n\t\titem = request_item\n\tend\nend",
"def welcome\n puts \"Welcome to Online shopping, see below list of products available\"\n end",
"def perform\n Magento2::Api.configure('dz4xnhhgfsfuyj00g6bkel0jq6mwdak2', 'hhjnlf59qh2m7an9sdpfcu0o9nox78y6', 'ie5iafduhqs1dydynidsjki582oti17w', 'mva5hldj17elic6muxmf53fq7zmm7xl5', \"https://mall2door.net\")\n orders = Magento2::Api.get(\"/rest/en/V1/orders\", {searchCriteria: 'all'})\n all_orders = orders[:items]\n all_orders.each do |order|\n order_id = order[:increment_id]\n store = order[:store_id]\n if store === 1 && order_id > \"000000047\" && order_id != \"7000000001\"\n n_perform order,order_id, store\n elsif store === 6 && order_id > \"6000000075\" && order_id != \"7000000001\"\n n_perform order,order_id, store\n end\n\n end\n end",
"def on_start\r\n # equity\r\n request_market_data(MarketDataRequestBuilder.newRequest().\r\n withSymbols(SYMBOLS).\r\n withProvider(MARKET_DATA_PROVIDER).\r\n withContent(\"TOP_OF_BOOK\").create)\r\n # option\r\n request_market_data(MarketDataRequestBuilder.newRequest().\r\n withSymbols(OPTION_OSI_SYMBOL).\r\n withAssetClass(AssetClass::OPTION).\r\n withProvider(MARKET_DATA_PROVIDER).\r\n withContent(\"LATEST_TICK\").create)\r\n end",
"def run\n SoopaStore.checkout.cashier = @cashier\n @cashier.checkout = SoopaStore.checkout\n SoopaStore.cashiers.add @cashier\n puts \"Time #{SoopaStore.current_time} : Cashier #{@cashier.eid} arrives & starts work\"\n end",
"def bigcommerce\n\n\t\t@brand = Brand.from_bc_omniauth(auth, extras)\n\n\t\tBigcommerce.configure do |config|\n\t\t\tconfig.store_hash = @brand.store_hash\n\t\t\tconfig.client_id = ENV['BC_CLIENT_ID']\n\t\t\tconfig.access_token = @brand.bctoken\n\t\tend\n\n\t\t@webhook = Bigcommerce::Webhook.create(\n\t\t\tscope: 'store/order/*',\n\t\t\tdestination: 'https://5cd6e141.ngrok.io/webhook'\n\t\t)\n\n\t\tbinding.pry\n\n\t\tif @brand.persisted?\n\t\t\tremember_me(@brand)\n\t\tend\n\n\t\tredirect_to load_path\n\n\tend",
"def buy!(qty, price)\n order = Fyb::Order.new qty, price, :buy\n order.perform\n end",
"def set_ebay_connection\n @ebay_connection = EbayConnection.find(params[:id])\n end",
"def startTrading market,hashLeft,btcLeft,tradingPrice\n\n startID = Pricepoint.last.id\n\n #Set these:\n\n username = \"whateverYourNameIS\"\n hashKey = \"YourKeyHereLotsOfNUmbers\"\n hashSecret = \"YourSecretHereLooksSimilar\" \n\n @api = Hashnest::API.new(username, hashKey, hashSecret)\n \n market = 19 #change this for other market\n origHashLeft = hashLeft\n origBtcLeft = btcLeft\n\n @api.quick_revoke market, \"sale\"\n @api.quick_revoke market, \"purchase\"\n\n\n minBuyAmount = 200\n minSaleAmount = 200\n sellMin = tradingPrice\n buyMax = tradingPrice\n\n sellSpread = 0.00005\n buySpread = 0.00004\n\n\n middle = (sellMin + buyMax) / 2.0\n\n minOrder = 93\n\n btcLeft = origBtcLeft\n hashLeft = origHashLeft\n\n \n updatedOrders = updateOrders market,minBuyAmount,minSaleAmount\n lSale = updatedOrders[0]\n hBuy = updatedOrders[1]\n sellInfo = [0,lSale]\n buyInfo = [0,hBuy]\n\n #Check initial sell and buy\n hashBal = hashBalance market\n sellAmount = hashBal[0] - hashLeft\n\n btcBal = btcBalance\n buyBtc = btcBal[0] - btcLeft\n buyAmount = (buyBtc / buyMax).round\n\n puts \"####### Starting trading Middle: #{middle} - Buying: #{buyAmount} - Selling: #{sellAmount} #######\"\n\n while (Pricepoint.last.id <= startID)\n #Check if we should buy or sell\n \n updatedOrders = updateOrders market,minBuyAmount,minSaleAmount\n lSale = updatedOrders[0]\n hBuy = updatedOrders[1]\n secSale = updatedOrders[2]\n secBuy = updatedOrders[3]\n\n if (lSale > sellMin)\n #Price is good to sell\n\n if (minSaleAmount > minOrder)\n minSaleAmount = minSaleAmount * 0.9\n end\n\n\n #Check how much we can sell\n hashBal = hashBalance market\n sellAmount = hashBal[0] - hashLeft\n #If this is larger than 0, lets go on\n\n if (sellAmount > minOrder)\n #Check if we're already selling the right amount\n if ((hashBal[1] - sellAmount).abs < 50)\n #Check if the price is right\n sellDiff = (sellInfo[1] - lSale).abs\n secSellDiff = (sellInfo[1] - secSale).abs\n if (sellDiff > 0.000000009 || secSellDiff > 0.000000011)\n puts \"Sell Price is wrong, changing price...\"\n sellInfo = revokeAndPlaceNewSell market, minBuyAmount, minSaleAmount, sellMin, sellAmount\n end\n \n\n else\n puts \"Cancelling and placing new sell order\"\n sellInfo = revokeAndPlaceNewSell market, minBuyAmount, minSaleAmount, sellMin, sellAmount\n end\n else\n puts \"Hashamount is #{sellAmount}, we can't sell less than #{minOrder}\"\n end\n else\n puts \"Lowest sell: #{lSale}, our min price: #{sellMin} = We can't sell!\"\n if ((minSaleAmount * 1.2) < sellAmount)\n minSaleAmount = minSaleAmount * 1.2\n end\n sellInfo = [0,lSale]\n end\n\n\n if (hBuy < buyMax)\n #Price is good to buy\n if (minBuyAmount > minOrder)\n minBuyAmount = minBuyAmount * 0.95\n end\n\n #Check how much we can buy\n btcBal = btcBalance\n buyBtc = btcBal[0] - btcLeft\n buyAmount = (buyBtc / hBuy).round\n\n #If this is larger than 0, lets go on\n if (buyAmount > minOrder)\n\n #Check if we're already buying the right amount\n if ((btcBal[1] - buyBtc).abs < 0.1 )\n puts \"We are buying the right amount\"\n\n #Check if the price is right\n buyDiff = (buyInfo[1] - hBuy).abs\n secBuyDiff = (buyInfo[1]- secBuy).abs\n\n #puts \"BuyDiff #{buyDiff} sec #{secBuyDiff}\"\n if (buyDiff > 0.000000009 || secBuyDiff > 0.000000011)\n puts \"Buy Price is wrong, changing price...\"\n buyInfo = revokeAndPlaceNewBuy market, minBuyAmount, minSaleAmount, buyMax, buyAmount\n end\n\n\n else\n puts \"Cancelling and placing new buy order\"\n buyInfo = revokeAndPlaceNewBuy market, minBuyAmount, minSaleAmount, buyMax, buyAmount\n end\n\n else\n puts \"Hashamout is #{buyAmount}, we can't buy less than #{minOrder} hash\"\n end\n\n\n else\n puts \"Highest buy: #{hBuy}, our max price: #{buyMax} = We can't buy!\"\n if ((minBuyAmount * 1.2) < buyAmount)\n minBuyAmount = minBuyAmount * 1.2\n end\n buyInfo = [0,hBuy]\n end\n\n puts \"Last order sell #{sellInfo[0]} for #{sellInfo[1]} and buy #{buyInfo[0]} for #{buyInfo[1]}\"\n \n\n distanceToBuy = buyMax - buyInfo[1]\n btcLeft = origBtcLeft * (1 - distanceToBuy/buySpread)\n if btcLeft < 0.0\n btcLeft = 0.0\n end\n\n distanceToSell = sellInfo[1] - sellMin\n hashLeft = origHashLeft * (1 - distanceToSell/sellSpread)\n if hashLeft < 0.0\n hashLeft = 0.0\n end\n\n\n puts \"Buy distance from middle: #{distanceToBuy*100000}, new btcLeft: #{btcLeft}, new minBuyAmount #{minBuyAmount}\"\n puts \"Sell distance from middle: #{distanceToSell*100000}, new hashLeft: #{hashLeft}, new minSaleAmount #{minSaleAmount}\"\n\n total = totalBtcValue market,hBuy\n puts \"####### Total now: #{total} #######\"\n\n end\n end",
"def test_buying_a_product\n #START:setup\n LineItem.delete_all\n Order.delete_all\n ruby_book = products(:ruby_book)\n #END:setup\n\n #START:step1\n get \"/store/index\"\n assert_response :success\n assert_template \"index\"\n #END:step1\n \n #START:step2\n xml_http_request \"/store/add_to_cart\", :id => ruby_book.id\n assert_response :success \n \n cart = session[:cart]\n assert_equal 1, cart.items.size\n assert_equal ruby_book, cart.items[0].product\n #END:step2\n \n #START:step3\n post \"/store/checkout\"\n assert_response :success\n assert_template \"checkout\"\n #END:step3\n \n #START:step4\n post_via_redirect \"/store/save_order\",\n :order => { :name => \"Dave Thomas\",\n :address => \"123 The Street\",\n :email => \"dave@pragprog.com\",\n :pay_type => \"check\" }\n assert_response :success\n assert_template \"index\"\n assert_equal 0, session[:cart].items.size\n #END:step4\n \n #START:step5\n orders = Order.find(:all)\n assert_equal 1, orders.size\n order = orders[0]\n \n assert_equal \"Dave Thomas\", order.name\n assert_equal \"123 The Street\", order.address\n assert_equal \"dave@pragprog.com\", order.email\n assert_equal \"check\", order.pay_type\n \n assert_equal 1, order.line_items.size\n line_item = order.line_items[0]\n assert_equal ruby_book, line_item.product\n #END:step5\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 buying_a_product\n\t\t# Deleting all data from the database\n\t\tLineItem.delete_all\n\t\tOrder.delete_all\n\n\t\truby_book = products(:ruby)\n\n\t\t# A user goes to the store index page\n\t\tget \"/\"\n\t\tassert_response :success\n\t\tassert_template \"index\"\n\n\t\t# They select a product, adding it to their cart\n\t\txml_http_request :post, '/line_items', product_id: ruby_book.id\n\t\tassert_response :success\n\n\t\tcart = Cart.find(session[:cart_id])\n\t\tassert_equal 1, cart.line_items.size\n\t\tassert_equal ruby_book, cart.line_items[0].product\n\n\t\t# Check out\n\t\tget \"/orders/new\"\n\t\tassert_response :success\n\t\tassert_template \"new\"\n\n\t\t# Place Order\n\t\tpost_via_redirect \"/orders\", order: { name: \"Dave Thomas\", address: \"123 The Street\", email: \"dave@example.com\", payment_type_id:\"2\" }\n\t\tassert_response :success\n\t\tassert_template \"index\"\n\t\tcart = Cart.find(session[:cart_id])\n\t\tassert_equal 0, cart.line_items.size\n\n\t\t# Check the Databse is correct\n\t\torders = Order.all\n\t\tassert_equal 1, orders.size\n\t\torder = orders[0]\n\n\t\tassert_equal \"Dave Thomas\", order.name\n\t\tassert_equal \"123 The Street\", order.address\n\t\tassert_equal \"dave@example.com\", order.email\n\t\tassert_equal 2, order.payment_type_id\n\n\t\tassert_equal 1, order.line_items.size\n\t\tline_item = order.line_items[0]\n\t\tassert_equal ruby_book, line_item.product\n\n\t\t# Checking the email is correct\n\t\tmail = ActionMailer::Base.deliveries.last\n\t\tassert_equal [\"dave@example.com\"], mail.to\n\t\tassert_equal 'Sam Ruby <depot@example.com>', mail[:from].value\n\t\tassert_equal 'Pragmatic Store Order Confirmation', mail.subject\n\tend",
"def menu\n\n # Welcome message\n\n puts `clear`\n puts \"****G.A.Market1.0****\"\n puts \"Welcome to our superfast checkout system.\"\n puts \"\\nProduct code | Name | Price\"\n puts \"----------------------------------------------------------\"\n puts \"FR1 | Fruit tea | 3.11\"\n puts \"SR1 | Strawberries | 5.00\"\n puts \"CF1 | Coffee | 11.23\"\n puts \"\\nPlease scan your items: \"\n puts \"(Please enter codes one by one,\"\n puts \"separated by a space, then press ENTER)\"\n\n\n # Scanning products and adding to basket\n\n items_scanned = gets.chomp.downcase\n items = items_scanned.split( )\n @basket = Hash.new(0)\n items.each { |item| @basket[item] +=1 }\n puts \"Your current basket contains: \" + @basket.map{|k,v| \"#{v} x #{k}\"}.join(', ') + \".\"\n\n\n # Keep shopping/exit\n\n puts \"Keep shopping with us? y/n\"\n answer = gets.chomp.downcase\n case answer\n when \"y\"\n menu\n when \"n\"\n puts \"Thank you for your shopping with us - see you soon!\"\n else\n puts \"Assistance required...\"\n end\n end",
"def index\n #IPSocket.getaddress(\"www.sandbox.paypal.com\")\n #@cart_items = CartItem.all\n \n if current_user == nil\n @cart_items = Array.new\n if session[:music_cart] != nil\n visitedArtistId = nil\n session[:music_cart].each do |cart_item_row|\n cart_item_temp = CartItem.new\n cart_item_temp.product_id = cart_item_row[:product_id]\n cart_item_temp.product_name = cart_item_row[:product_name]\n cart_item_temp.product_final_price = cart_item_row[:product_final_price]\n visitedArtistId = cart_item_row[:product_user_id]\n @cart_items.push(cart_item_temp)\n end\n \n if visitedArtistId == nil\n @continueShoppingLink = root_path\n else\n visitedArtist = User.find(visitedArtistId)\n visitedArtistName = visitedArtist.first_name+\" \"+visitedArtist.last_name\n @continueShoppingLink = artist_dashboard_path(id: visitedArtist.id.to_s+':'+visitedArtistName.parameterize) \n end\n \n else\n @continueShoppingLink = root_path\n end\n \n else\n @cart = Cart.where(:user_id => current_user.id).first\n @continueShoppingLink = root_path\n @cart_items = []\n if @cart != nil\n lastItem = nil\n @cart.cart_items.each do |item|\n lastItem = item\n end\n @cart_items = @cart.cart_items\n if lastItem != nil\n lastItemRow = Audio.find(lastItem.product_id)\n visitedArtist = User.find(lastItemRow.user_id)\n visitedArtistName = visitedArtist.first_name+\" \"+visitedArtist.last_name\n @continueShoppingLink = artist_dashboard_path(id: lastItemRow.user_id.to_s+':'+visitedArtistName.parameterize) \n \n end \n end\n end \n \n end",
"def sg_add_to_cart_from_quickview\n add_to_cart_btn.click\n sleep TimeOut::WAIT_MID_CONST\n end",
"def perform\n begin\n binding = RForce::Binding.new KEYS['salesforce']['base']\n binding.login KEYS['salesforce']['username'], KEYS['salesforce']['password'] + KEYS['salesforce']['token']\n\n sl = SellerListing.find(seller_listing_id)\n\n # User, address and phone info must be here to create a seller listing\n # http://www.salesforce.com/us/developer/docs/api/index.htm [search for Lead]\n lead = [\n :type, LEAD,\n :Lead_Source__c, LEAD_SOURCE,\n :Country, LEAD_COUNTRY,\n :FirstName, sl.user.first_name,\n :First_Name2__c, sl.user.first_name,\n :LastName, sl.user.last_name,\n :Last_Name2__c, sl.user.last_name,\n :Email, sl.user.email,\n :Phone, sl.phone_number.number,\n :Property_Address__c, [sl.address.address1, sl.address.address2].join(' '),\n :Property_City__c, sl.address.city,\n :Property_State__c, sl.address.state,\n :Property_Zip__c, sl.address.zip.to_s\n ]\n\n # Check and see if we have second-step data yet (which is, of course, the entire reason for delaying this\n # job [to give the user enough time to finish step 2])\n lead.push(:EstimatedValue__c, sl.estimated_value(true).to_s) if sl.estimated_value.present?\n lead.push(:AskingPrice__c, sl.asking_price(true).to_s) if sl.asking_price.present?\n lead.push(:LoanAmount__c, sl.loan_amount(true).to_s) if sl.loan_amount.present?\n lead.push(:DesiredSellTime__c, sl.time_frame.to_s) if sl.time_frame.present?\n lead.push(:SellingReason__c, sl.selling_reason) if sl.selling_reason.present?\n\n # Who owns this zip?\n owner_resp = SalesforceJob.account_owner_for_zip(binding, sl)\n\n if owner_resp.ok?\n account_id = owner_resp.salesforce_account_id\n lead.push(:Owned_by_Account__c, account_id)\n end\n\n # Create Lead!\n lead = binding.create :sObject => lead\n create_resp = SalesforceJob.munge_create_salesforce_lead_results(lead, sl)\n\n if create_resp.ok?\n sl.salesforce_lead_id = create_resp.salesforce_lead_id\n sl.salesforce_lead_owner_id = account_id\n sl.save!\n\n # Now that we sucessfully tied this seller listing to a buyer account in salesforce, send out our new\n # seller listing confirmation email according to the specs outlined here:\n # https://ehouseoffers.fogbugz.com/default.asp?28 -- seller_offer_request_confirmation.rtf\n # Because we already waited to process this (see seller_listings_controller.create), we send this email\n # out without delay despite what the ticket says. We just use delayed job to make it it's own process\n DelayedJobs::Salesforce.new_seller_confirmation(sl)\n DelayedJobs::Salesforce.new_seller_affiliate_services(sl, true)\n DelayedJobs::Salesforce.buyer_lead_notification(sl, owner_resp.buyer_emails)\n else\n Rails.logger.fatal(\"Salesforce create lead bombed! create_resp = #{create_resp.inspect}\")\n end\n\n rescue => e\n Rails.logger.fatal(\"SalesforceJob.perform bombed with the following exception: \"+ e)\n raise e\n end\n end",
"def merchant_end_point=(_arg0); end",
"def visit_checkout(country)\n while @page.find(:div_id,'basket_nav').has_selector?(:span_id,'miniBKQty', :minimum => 2) do\n sleep 0.5\n end\n\n @page.click_link('Shopping bag')\n return BasketPage.new(@page,country)\n end",
"def perform\n fetch_stake_currency_id_for_pax\n perform_changes\n deactivate_pax\n end",
"def request_phase\n session_id = generate_session_id\n redirect ebay_login_url(session_id)\n rescue => ex\n fail!(\"Failed to retrieve session id from ebay\", ex)\n end",
"def start_checkout(return_url, cancel_url, email)\n raise \"already activated\" if activated?\n paypal.start_checkout(return_url, cancel_url, email, plan.price_with_tax, human_description)\n end",
"def start()\n\n\t\tend",
"def buy(ticker, position)\n puts \"Buying #{ticker}\"\n end",
"def start\n\t\tend",
"def start\n i = 0\n while true\n url = URI.parse(@bank_products_list_url + (page_index + i))\n full_path = (url.query.blank?) ? url.path : \"#{url.path}?#{url.query}\"\n request = Net::HTTP::Get.new(full_path)\n\n response = Net::HTTP.start(url.host, url.port) { |http|\n http.request(request)\n }\n\n raise \"Response was not 200, response was #{response.code}, error was #{response.body}\" if response.code != \"200\"\n\n products = parse_products response\n\n products.each do |p|\n yield convert p\n end\n\n # get out of the loop if this is the last page\n break if is_last_page response\n i = i + 1;\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 get_products()\n\tputs \"Getting products\"\n\tresponse = request_get(\"/api/product\")\n\tputs response.body\nend",
"def invokeRazooSite()\n\t\n\tputs \"************** START : Invoke Razoo Application ****************\"\t\n\t# Create a new instance of the Selenium-Client driver.\n\t$browser = Selenium::Client::Driver.new \\\n\t\t:host => \"localhost\",\n\t\t:port => 4444,\n\t\t:browser => \"*firefox\", \n\t\t:url => \"https://www-qarc.razoo.com/login\",\n\t\t:timeout_in_second => 60\n\n\t# Start the browser session\n\t$browser.start_new_browser_session\n\t\n\t# Print a message in the browser-side log and status bar\n\t$browser.set_context(\"Razoo Application\")\n\t$browser.open \"/\"\n\tputs \"Passed. Razoo Site gets invoked successfully!\"\n\tputs \"************** END : Invoke Razoo Application ****************\"\n\t\nend",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def checkout\n\n\n @booking = current_booking\n @basket_items = current_order.basket_items\n @order = current_order\n \n \n\n # Wrapper to convert all purchaseable items into paypal format\n items = []\n\n # Add all booking activities\n @booking.booking_activities.each do |ba|\n booking_activity = BookingActivity.find(ba)\n activity = Activity.find(booking_activity.activity_id)\n num_guests = @booking.number_guests\n bactivity = {\n :name=>activity.name,\n :quantity=> num_guests,\n #description:\"Booking: #{@booking.id}\",\n :amount=>(activity.price*num_guests).to_f\n }\n items << bactivity\n end\n\n\n # Add accommodation\n if(!@booking.accommodation_id.nil?)\n accommodation = Accommodation.find(@booking.accommodation_id)\n accommodation_details ={\n :name=>\" #{accommodation.name} (#{@booking.end_date-@booking.start_date} nights)\",\n :quantity=>1,\n #description:\"Booking: #{@booking.id}\",\n :amount=>(accommodation.price*(@booking.end_date-@booking.start_date)).to_f\n }\n items << accommodation_details\n end\n\n # add basket items\n @basket_items.each do |bi|\n product = Product.find(bi.product_id)\n bitem = {\n :name=>product.name,\n :quantity=>bi.quantity,\n :amount=>bi.total_price\n }\n items << bitem\n end\n\n values = {\n :business=> \"yvette.kelly.2010-facilitator@gmail.com\",\n :cmd=>\"_xclick\",\n :upload=> 1,\n :return=> \"#{Rails.application.secrets.app_host}/thankyou\",\n :invoice=> @booking.id,\n :currency_code=>'USD',\n :amount=> \"#{@booking.price+@order.subtotal}\",\n :item_name=> \"booking\",\n :item_number=> @booking.id,\n :quantity=> '1'\n }\n\n redirect_to \"#{Rails.application.secrets.paypal_host}/cgi-bin/webscr?\" + values.to_query\n\n end",
"def run_addsave\n\tputs \"-----------------\"🐝\n\tload_file \n\trun_shopping_list\n\tfinish_addsave\nend",
"def invokeRazooSite()\n\t\n\tputs \"************** START : Invoke Razoo Application ****************\"\t\n\t# Create a new instance of the Selenium-Client driver.\n\t$browser = Selenium::Client::Driver.new \\\n\t\t:host => \"localhost\",\n\t\t:port => 4444,\n\t\t:browser => \"*iexplore\", \n\t\t:url => \"https://www-qatrunk.razoo.com/login\",\n\t\t:timeout_in_second => 60\n\n\t# Start the browser session\n\t$browser.start_new_browser_session\n\t\n\t# Print a message in the browser-side log and status bar\n\t$browser.set_context(\"Razoo Application\")\n\t$browser.open \"/\"\n\t$mylog.info \"Razoo Site gets invoked successfully!\"\n\tputs \"Razoo Site gets invoked successfully!\"\n\tputs \"************** END : Invoke Razoo Application ****************\"\n\t\nend",
"def start\n\n end",
"def call\n puts \"Hello! Welcome to Emo Lister\"\n\n list_podcasts\n menu\n goodbye\n end",
"def invokeRazooSite()\n\t\n\tputs \"************** START : Invoke Razoo Application ****************\"\t\n\t# Create a new instance of the Selenium-Client driver.\n\t$browser = Selenium::Client::Driver.new \\\n\t\t:host => \"localhost\",\n\t\t:port => 4444,\n\t\t:browser => \"*firefox\", \n\t\t:url => \"https://www-qatrunk.razoo.com/login\",\n\t\t:timeout_in_second => 60\n\n\t# Start the browser session\n\t$browser.start_new_browser_session\n\t\n\t# Print a message in the browser-side log and status bar\n\t$browser.set_context(\"Razoo Application\")\n\t$browser.open \"/\"\n\tputs \"Passed. Razoo Site gets invoked successfully!\"\n\tputs \"************** END : Invoke Razoo Application ****************\"\n\t\nend",
"def initialize\n @file_name = \"yandex_market.xml\"\n @shop = {\n name: \"dummy_shop\",\n company: \"dummy_company\",\n url: \"http://dummy_url.com\",\n currencies: [],\n categories: [],\n offers: []\n }\n end",
"def invokeRazooSite()\n\t\n\tputs \"************** START : Invoke Razoo Application ****************\"\t\n\t# Create a new instance of the Selenium-Client driver.\n\t$browser = Selenium::Client::Driver.new \\\n\t\t:host => \"localhost\",\n\t\t:port => 4444,\n\t\t:browser => \"*safari\", \n\t\t:url => \"https://www-stage.razoo.com/login\",\n\t\t:timeout_in_second => 60\n\n\t# Start the browser session\n\t$browser.start_new_browser_session\n\t\n\t# Print a message in the browser-side log and status bar\n\t$browser.set_context(\"Razoo Application\")\n\t$browser.open \"/\"\n\tputs \"Passed. Razoo Site gets invoked successfully!\"\n\tputs \"************** END : Invoke Razoo Application ****************\"\n\t\nend",
"def perform\n Magento2::Api.configure('dz4xnhhgfsfuyj00g6bkel0jq6mwdak2', 'hhjnlf59qh2m7an9sdpfcu0o9nox78y6', 'ie5iafduhqs1dydynidsjki582oti17w', 'mva5hldj17elic6muxmf53fq7zmm7xl5', \"https://mall2door.net\")\n orders = Magento2::Api.get(\"/rest/en/V1/orders\", {searchCriteria: 'all' })\n all_orders = orders[:items]\n all_orders.each do |order|\n unless order[:status].present?\n order_id = order[:increment_id]\n id = order[:entity_id]\n status = order[:state]\n params = {\n entity_id: id,\n increment_id: order_id,\n status: status,\n }\n if status\n Magento2::Api.put(\"/rest/en/V1/orders/create\", {entity: params})\n end\n end\n end\n end",
"def adding_to_cart\n \n sleep(2)\n puts \"click c1 ethnicwear\"\n ethnic_wear.click\n wait_for_spinner\n sleep(2)\n puts \"movin cursor over c1\"\n $driver.action.move_to(ethnic_wear).perform\n $driver.find_element(:css, \".submenu > li:nth-child(1) > ul > li > ul > li > ul > li > ul > li:nth-child(1) > ul > li:nth-child(1) > a.col-dark-grey\").click\n \n wait_for_spinner\n sleep(3)\n\n @product_flag=0\n i=4 # selection start from 4th product\n j=1 # selecting size from first\n\n \n begin \n\n puts \"clicking on product #{i}\"\n $driver.find_element(:css,\"#product-container > div.ng-isolate-scope > ul > li:nth-child(#{i}) > div > div.product-image > a > img\").click\n wait_for_spinner\n sleep(2)\n if options.displayed?\n puts \"selecting size\"\n begin\n $driver.find_element(:css,\".in-stock:nth-child(#{j}) div\").click\n add_to_cart_button.click\n @product_flag=1\n rescue\n if (j>7) # if size is exhausted\n break\n else\n j=j+1\n end\n retry\n end\n else\n begin \n sleep(3)\n puts \"no size found. add to cart ...\"\n add_to_cart_button.click\n @product_flag=1\n rescue\n puts \"product got soldout (or) product not available\"\n i=i+1 # to select the next product\n #wait_for_spinner\n end \n end\n\n end while @product_flag!=1\n puts @prod1 = productviewpage_productname.text.downcase\n\n end",
"def start app, &block\n # run available process types\n app[\"ps\"].each do |type,ps|\n ps[\"scale\"].times do |index|\n host = GV::Valley::Runner.random_service \n app[\"ps\"][type][\"containers\"] << host.start(app[\"name\"], type, index, &block)\n end\n end\n end",
"def start\n \n\tend",
"def product_info_seller\n products = @seller.show_product_info \n choice = @view.display_info_product(products)\n choice == \"1\" ? buy_product : input = @view.menu(\"2\") \n seller_actions(input)\n end",
"def index\n \n @cart = setup_cart\n \n if params[:package_id]\n @cart.add_package(params[:package_id])\n @package = Package.find(params[:package_id])\n elsif @cart.package_id\n @package = Package.find(@cart.package_id)\n else\n @package = Package.find_by_name(\"Simon XT Pro Plus Package\")\n end\n \n @cart_has_combo_item = @cart.combo_item?\n \n @blog = Blog.last\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @products }\n end\n end",
"def test_buying_a_product\n LineItem.delete_all\n Order.delete_all\n ruby_book = products(:ruby_book)\n \n get \"/store/index\"\n assert_response :success\n assert_template \"index\"\n \n xml_http_request :put, \"/store/add_to_cart\", :id => ruby_book.id\n assert_response :success\n \n post \"/store/checkout\"\n assert_response :success\n assert_template \"checkout\"\n \n post_via_redirect \"/store/save_order\",\n :order => { :name => \"Dave Thomas\",\n :address => \"123 The Street\",\n :email => \"dave@pragprog.com\",\n :pay_type => \"check\"\n }\n assert_response :success\n assert_template \"index\"\n assert_equal 0, session[:cart].items.size\n \n orders = Order.find(:all)\n assert_equal 1, orders.size\n order = orders[0]\n \n assert_equal \"Dave Thomas\", order.name\n assert_equal \"123 The Street\", order.address\n assert_equal \"dave@pragprog.com\", order.email\n assert_equal \"check\", order.pay_type\n \n assert_equal 1, order.line_items.size\n line_item = order.line_items[0]\n assert_equal ruby_book, line_item.product\n end",
"def autostart; end",
"def create\n @basket = Basket.new(basket_params)\n @basker.status = 0\n @cart_item.basket.set_price\n @basker.user = @current_user\n respond_to do |format|\n if @basket.save\n format.html { redirect_to @basket, notice: 'Basket was successfully created.' }\n format.json { render :show, status: :created, location: @basket }\n else\n format.html { render :new }\n format.json { render json: @basket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def make_ebay_url(page)\n url = \"\"\n url += \"http://svcs.ebay.com/services/search/FindingService/v1?\"\n url += \"OPERATION-NAME=findItemsByCategory\"\n url += \"&SERVICE-VERSION=1.0.0&SECURITY-APPNAME=HarlandH-af4d-46b8-929d-c6b0a5cacfc2\"\n url += \"&categoryId=38292\"\n url += \"&paginationInput.pageNumber=#{page}\"\n url += \"&sortOrder=EndTimeSoonest\" #StartTimeNewest\n url += \"&itemFilter(0).name=ListingType&itemFilter(0).value(0)=Auction\"\n end",
"def start\n send_message('Which pants do you like, dear customer?')\n \n @items=Item.where(\"itemType = ?\", \"pants\")\n @items.each do |item|\n send_photo({remote: item[:remotePath],local:item[:localPath]})\n end\n user.reset_next_bot_command\n end",
"def checkout_shopping_cart\n\tputs \"------------------------------------ ITEMS PURCHASED ------------------------------------\"\n\n\t# Displays all the items\n\t@shopping_cart.items.each_with_index do |item, index|\n\t\t# Displays the item\n\t\tputs \"(#{index+1}) Name: #{item.name} \\n\"\n\t\tputs \"Price: $#{item.price}\\n\"\n\t\tputs \"Shipping Cost: $#{item.shipping_cost}\\n \\n\"\n\tend\n\tputs \"-----------------------------------------------------------------------------------------\"\n\tputs \"TOTAL Price: $#{@shopping_cart.total_price}\"\n\tputs \"TOTAL Shipping Cost: $#{@shopping_cart.total_shipping_cost}\"\n\tputs \"-----------------------------------------------------------------------------------------\"\n\tputs \"GRAND TOTAL: $#{@shopping_cart.total_cost}\"\n\tputs \"-----------------------------------------------------------------------------------------\\n\"\nend",
"def checkout\n # get all items in cart\n items = CartItem.where(:cart_id => params[:cart_id])\n pricing_rules = [\"3_FOR_2\", \"3_OR_MORE_TSHIRTS\"]\n co = PB::Checkout.new(pricing_rules)\n #debugger\n #total = 100\n items.each do | item |\n code = Item.find(item[:item_id])[:code]\n co.scan(code)\n end\n # debugger\n @total = co.total()\n end",
"def buy\n shipment = Shipment.find(params[:shipment_id])\n shipment.update_column(:affiliate_shipping_account, params[:affiliate_shipping_account] == \"true\")\n EasyPost.api_key = shipment.easy_post_api_key\n\n begin\n ep_shipment = EasyPost::Shipment.retrieve(params[:ep_shipment_id])\n easypost_purchase(shipment, params[:rate_id], ep_shipment)\n ShipmentItem.where(shipment_id: shipment.id, special_status: \"\").update_all(special_status: :shipped)\n rescue => e\n flash[:error] = e.message + params[:ep_shipment_id]\n return redirect_back(fallback_location: admin_root_path)\n end\n\n redirect_to admin_store_shipment_path(shipment)\n end",
"def _threaded_mage_checkout\n @custom_number_of_users.times do\n start_time = Time.now\n add_to_cart @helper.get_yaml_data\n get_a_shipping_quote\n @helper.proceed_to_checkout\n # assert_section 'checkout'\n finalize_checkout_as_guest\n final_time = Time.now - start_time\n puts \"It took #{final_time} seconds to complete the order\"\n end\n end",
"def ebay_scrap(scr)\n product = scr\n url = \"http://shop.ebay.com/?_from=R40&_trksid=p3907.m570.l1313&_nkw=#{product}&_sacat=See-All-Categories\"\n doc = Nokogiri::HTML(open(url))\n\n puts url\n doc.css(\".tp\").each do |item|\n text = item.at_css(\".v4lnk\").text\n price = item.at_css(\".prices\").text + \"rur\"\n puts \"#{text} - #{price}\"\n end\n\nend",
"def index\n\n begin\n response_one = HTTParty.get(\"#{@supplier_one}/wines.json\")\n supplier_one_wines = ActiveSupport::JSON.decode(response_one.body)\n\n supplier_two_wines = ActiveSupport::JSON.decode(HTTParty.get(\"#{@supplier_two}/wines.json\").body)\n best_wines = select_cheapest_wines(supplier_one_wines, supplier_two_wines)\n\n best_wines.each do |wine|\n wine.delete('url')\n end\n\n choose_database_updates(best_wines)\n rescue Errno::ECONNREFUSED\n #recover if there is no connection with supplier\n logger.error \"No connection with supplier services\"\n end\n\n @wines = Wine.order(:productName).paginate page: params[:page], per_page: 10\n\n @basket = current_basket\n end",
"def run\n SoopaStore.checkout.cashier = nil\n @cashier.checkout = nil\n @cashier.departure_time = SoopaStore.current_time\n puts \"Time #{SoopaStore.current_time} : Cashier #{@cashier.eid} \"\\\n \"leaves checkout (worked #{@cashier.time_in_store} time units)\"\n end",
"def buyEvent\n client.arecord_user_action_on_item('buy', getUser, getCart) \n end",
"def call\n\n get_environment # gets and sets some environmental variables that we will need\n greet_user\n scrape_jobs # scrapes the 50 most recent job listings to start off\n\n ret_value = \"\"\n\n until ret_value == \"exit\" || ret_value == \"00\" # loop program until return value is one of the exit commands\n ret_value = run # store run methods return value in ret_value so we can check it for exit commands\n end\n\n farewell_message\n end",
"def get_results(store,pricelist)\n storename = 'QFC'\n visit store\n page.driver.browser.switch_to.frame(0)\n page.execute_script \"wishabi.app.gotoGridView()\"\n #sleep 1\n page.first(:button,\"Meat & Seafood\").click\n $meaty_targets.each do |m|\n page.all(:xpath,\"//li[@class='item']\").each do |node|\n item_name = node.first(:xpath,\"./div[@class='item-name']\").text\n item_price = node.first(:xpath,\"./div[@class='item-price']\").text\n pricelist[\"#{item_name}\"] = item_price\n scan_price(storename, item_name, m, item_price)\n end\n end\n end",
"def index\n @all_products = Product.all.as_json\n @all_currencies = ExchangeRateService.valid_currencies\n @base_url = Rails.env.development? ? 'http://localhost:3000' : 'http://cabifycheckout.com'\n end",
"def test_mage_checkout\n #@custom_number_of_users.times do\n start_time = Time.now\n add_to_cart @helper.get_yaml_data\n get_a_shipping_quote\n @helper.proceed_to_checkout\n # assert_section 'checkout'\n finalize_checkout_as_guest\n final_time = Time.now - start_time\n puts \"It took #{final_time} seconds to complete the order\"\n #end\n end",
"def runstartup\n\t\t@cbs.each do |cb|\n\t\t\tif cb.isChecked and @settings[\"programs\"][cb.text].has_key?(\"cmd\")\n\t\t\t\tsystem(\"#{@settings[\"programs\"][cb.text][\"cmd\"]}&\")\n\t\t\tend\n\t\tend\n\t\t$qApp::quit()\n\tend",
"def execute\n super()\n\n # executes test case info\n\n # workaround pages that need to login to secondary domains\n auth_workarounds()\n\n # Change this to 0 to get retries in buyflow test\n timeout_count = 1 \n \n begin\n puts @report.url\n\n # Navigate to the site\n @page.browser.driver.browser.get @report.url if(@report.url)\n\n\n\n\n\n # ------------ Marketing section, Landing Page ------------ \n\n @report.browser = @page.browser_name\n\n\n # pull the operating System from the user agent or other sources\n @report.os = @page.os_name\n\n # pull the brand from the page variables or domain\n @report.buyflow_report.brand = @page.brand\n\n # pull the uci code from omniture\n @report.uci_report.uci_mp = @page.uci\n\n if(@configuration['Brand'] == 'Marajo' || @configuration['Brand'] == 'smileactives')\n puts \"products hiiiiiiiii\"\n @page = @page.go_to_productpage()\n puts \"done product button\"\n else\n puts \"going to order page\"\n @page = @page.go_to_orderpage()\n puts @page\n puts \"done fetching orderpage\"\n end\n\n # navigate to the SAS page if that page section isn't present.\n # @page = @page.go_to_orderpage()\n\n\n\n\n @report.buyflow_report.lastpagefound = \"sas\"\n\n # ------------ SAS Section ------------ \n\n @report.uci_report.uci_sas = @page.uci\n \n # If an offer is not present in test\n if(@offer == nil)\n # navigate to the cart using default options\n @page = @page.skip_to_cart\n else\n # ...otherwise select the options defined by the offer\n \n @page = @page.select_options(@offer)\n end\n\n # exclude_from_selection_workaround = BrandsExcludedSelectionWorkaround.all.select('brand').collect(&:brand)\n # if(@offer)\n # if(timeout_count == 1 && @offer['OfferCode'])\n # if(exclude_from_selection_workaround.include?(@configuration[\"Brand\"].downcase) == false)\n # selection_workaround(@page.browser)\n # end\n # end\n # end\n\n \n\n\nputs \"Proceed to cart section\"\n\n # ------------ Cart Section ------------ \n\n @report.uci_report.uci_op = @page.uci\n\n @report.buyflow_report.lastpagefound = \"cart\"\n\n @report.buyflow_report.offer_code = @page.offercode\n puts \"offercode\"\n puts @report.buyflow_report.offer_code\n\n @report.grcid = @page.grcid\n puts \"grcid\"\n puts @report.grcid\n\n # catch_and_display_error do\n\n @report.buyflow_report.total_pricing = @page.total_pricing\n puts \"total_pricing\"\n puts @report.buyflow_report.total_pricing\n\n @report.buyflow_report.subtotal_price = @page.subtotal_price\n puts \"subtotal_price\"\n puts @report.buyflow_report.subtotal_price\n\n # pull the pricing for the SAS for any sections still in the same page as the cart\n begin\n @report.buyflow_report.saspricing = @page.check_sas_pricing(@report.buyflow_report.subtotal_price)\n rescue => e\n @report.buyflow_report.saspricing = \"No Offer Associated with this Test\"\n end\n \n @report.buyflow_report.saspricing = '' if @report.buyflow_report.saspricing == nil\n puts \"saspricing\"\n puts @report.buyflow_report.saspricing\n @report.buyflow_report.sasprices = @page.check_sas_prices\n puts \"sasprices\"\n puts @report.buyflow_report.sasprices\n\n # pull the cart description from the order summary section\n @report.buyflow_report.cart_language = @page.cart_description\n puts \"cart description\"\n puts @report.buyflow_report.cart_language\n\n @report.buyflow_report.cart_title = @page.cart_title\n puts \"productname\"\n puts @report.buyflow_report.cart_title\n\n @report.buyflow_report.sas_kit_name = @page.check_sas_kit_name(@report.buyflow_report.cart_title)\n\n @report.buyflow_report.kitnames = @page.cart_title\n\n @report.buyflow_report.cart_quantity = @page.quantity\n puts \"quantity\"\n puts @report.buyflow_report.cart_quantity\n\n if(@report.buyflow_report.cart_quantity.nil?)\n @report.buyflow_report.cart_quantity = \"[Quantity Dropdown Missing] - Locator may be missing\"\n end\n\n @report.buyflow_report.shipping_standard = @page.shipping('Standard')\n puts \"shipping\"\n puts @report.buyflow_report.shipping_standard\n \n # Rush Shipping\n @report.buyflow_report.shipping_rush = @page.shipping('Rush') \n\n # Overnight Shipping\n @report.buyflow_report.shipping_overnight = @page.shipping('Overnight')\n\n @report.buyflow_report.shipping_standard = 'N/A' if @report.buyflow_report.shipping_standard.nil?\n \n @report.buyflow_report.shipping_rush = 'N/A' if @report.buyflow_report.shipping_rush.nil?\n\n @report.buyflow_report.shipping_overnight = 'N/A' if @report.buyflow_report.shipping_overnight.nil?\n\n if(@offer)\n @offer.each do |offer|\n # Continuity Shipping \n @report.buyflow_report.continuity_shipping = @page.continuity(offer)\n puts \"Continuity\"\n puts @report.buyflow_report.continuity_shipping\n end\n end\n # end\n\n # get the shipping selection price\n puts \"cart_shipping_selection_price\"\n cart_shipping_selection_price = @page.current_shipping_cost\n puts cart_shipping_selection_price\n\n @page.place_order(@configuration['ConfEmailOverride'])\n\n # Submit order in order to reach confirmation page\n @page = @page.submit_order\n\n # ------------ Confirmation Page ------------\n\n puts \"proceeding to confirmation page\"\n\n @page.expand_order_details()\n \n # pull the confirmation number\n @report.buyflow_report.confirmation_number = @page.get_confirmation_number\n\n @report.buyflow_report.lastpagefound = \"confirmation page\"\n # pull the uci number for the confirmation page\n @report.uci_report.uci_cp = @page.uci\n\n # Compare the billing and shipping information to the data that was entered in the cart\n check_billing_info(@report.buyflow_report, @page)\n\n # get the offer code from the confirmation page\n @report.buyflow_report.confoffercode = @page.offercode\n\n # get the confirmation page pricing for the main product\n @report.buyflow_report.confpricing = @page.confpricing\n\n # check the shipping price matches the shipping selected in the cart\n puts \"shipping_conf\"\n shipping_conf = @page.conf_shipping_price\n puts shipping_conf\n\n if(shipping_conf == cart_shipping_selection_price)\n @report.buyflow_report.shipping_conf = \"match\"\n @report.buyflow_report.shipping_conf_val = shipping_conf\n @report.buyflow_report.selected_shipping = cart_shipping_selection_price\n else\n begin\n @report.buyflow_report.shipping_conf_val = shipping_conf\n\n rescue\n end\n begin\n @report.buyflow_report.selected_shipping = cart_shipping_selection_price\n rescue\n\n end\n begin\n @report.buyflow_report.shipping_conf = shipping_conf.to_s + \" - expected: \" + cart_shipping_selection_price.to_s\n rescue\n @report.buyflow_report.shipping_conf = \"Problem with gathering data: confirmation - \" + shipping_conf.class.to_s + \" cart - \" + cart_shipping_selection_price.class.to_s\n end\n end\n\n @report.buyflow_report.conf_kit_name = @page.cart_title\n\n # -------- Failure Checks ---------\n if(@report.grcid.nil?)\n fail 'GRCID not found for this page (AKA Campaign Code)'\n end\n\n if(@report.uci_report.uci_mp.nil?)\n fail 'UCI code for Marketing section was not found'\n end\n\n if(@report.uci_report.uci_op.nil?)\n fail 'UCI code for Cart section was not found'\n end\n \n if(@report.uci_report.uci_sas.nil?)\n fail 'UCI code for SAS section was not found'\n end \n \n if(@report.uci_report.uci_cp.nil?)\n fail 'UCI code for Confirmation page was not found'\n end\n\n if(@report.buyflow_report.subtotal_price.nil?)\n fail 'subtotal price was not found'\n end\n\n if(@report.buyflow_report.cart_title.to_s.downcase.include? 'kit')\n if(@report.buyflow_report.cart_language.nil?)\n fail 'cart language was not found'\n end\n end\n\n if(@report.buyflow_report.cart_title.nil?)\n fail 'cart title was not found'\n end\n\n # Check Shipping matches given offer if present\n if(@offer)\n if(@offer.length == 1)\n @offer.each do |offer|\n if(@report.buyflow_report.shipping_standard != offer['StartSH'].gsub('$','').strip())\n fail \"Shipping price did not match - #{offer.Offer.to_s} - Entry -a #{@report.buyflow_report.shipping_standard} -e #{offer['StartSH'].gsub('$','').strip()}\"\n end\n\n if(@report.buyflow_report.shipping_rush != offer['Rush'].gsub('$','').strip())\n fail \"Shipping price did not match - #{offer.Offer.to_s} - Rush -a #{@report.buyflow_report.shipping_rush} -e #{offer['Rush'].gsub('$','').strip()}\"\n end\n\n if(@report.buyflow_report.shipping_overnight != offer['OND'].gsub('$','').strip())\n fail \"Shipping price did not match - #{offer.Offer.to_s} - OND -a #{@report.buyflow_report.shipping_overnight} -e #{offer['OND'].gsub('$','').strip()}\"\n end\n end\n else\n standard_data = ''\n rush_data = ''\n ond_data = ''\n if((@report.buyflow_report.cart_title.to_s.downcase.include? 'kit') && (@report.buyflow_report.brand == 'Marajo'))\n @offer.each do |offer|\n next unless offer.Offer.to_s.downcase.include? 'kit'\n standard_data = offer['StartSH'].gsub('$','').strip()\n rush_data = offer['Rush'].gsub('$','').strip()\n ond_data = offer['OND'].gsub('$','').strip()\n break\n end\n else\n standard_data = '$0.00'\n @offer.each do |offer|\n rush_data = offer['Rush'].gsub('$','').strip()\n ond_data = offer['OND'].gsub('$','').strip()\n break\n end\n end\n \n if(@report.buyflow_report.shipping_standard != standard_data.gsub('$','').strip())\n fail \"Shipping price did not match - #{offer.Offer.to_s} - Entry -a #{@report.buyflow_report.shipping_standard} -e #{standard_data.gsub('$','').strip()}\"\n end\n\n if(@report.buyflow_report.shipping_rush != rush_data)\n fail \"Shipping price did not match - #{offer.Offer.to_s} - Rush -a #{@report.buyflow_report.shipping_rush} -e #{rush_data}\"\n end\n\n if(@report.buyflow_report.shipping_overnight != ond_data)\n fail \"Shipping price did not match - #{offer.Offer.to_s} - OND -a #{@report.buyflow_report.shipping_overnight} -e #{ond_data}\"\n end\n end\n end \n\n if(@report.buyflow_report.conf_kit_name.nil?)\n fail 'confirmation kit name was not found'\n end\n\n if(@report.buyflow_report.confpricing.nil?)\n fail 'confirmation price was not found'\n end\n\n if(@report.buyflow_report.billname == 'FAILED' || @report.buyflow_report.billaddress == 'FAILED' || @report.buyflow_report.billemail == 'FAILED' || @report.buyflow_report.shipaddress == 'FAILED')\n fail 'The billing/shipping info on the confirmation page did not match data input on cart page'\n end\n\n if(@report.buyflow_report.shipping_conf != 'match')\n fail 'Shipping did not match cart on confirmation page' \n end\n\n if(@report.buyflow_report.confoffercode.nil?)\n fail 'Could not find Offer code on the confirmation page'\n end\n\n if(@report.buyflow_report.offer_code.nil?)\n fail 'Could not find Offer code on the cart page'\n end\n\n if(@offer)\n @offer.each do |offer|\n puts @report.buyflow_report.offer_code\n puts @report.buyflow_report.confoffercode\n puts offer.OfferCode.to_s\n if(@report.buyflow_report.expected_offer_code)\n if @report.buyflow_report.offer_code.to_s.downcase.include?(offer.OfferCode.to_s.downcase) == false\n raise \"OfferCode didn't match in cart page\"\n end\n end\n\n if(@report.buyflow_report.expected_offer_code)\n if @report.buyflow_report.confoffercode.to_s.downcase.include?(offer.OfferCode.to_s.downcase) == false\n raise \"OfferCode didn't match in confirmation page\"\n end\n end\n# puts offer.offer_data_detail.offerdesc\n# puts @report.buyflow_report.cart_language\n if(offer.offer_data_detail)\n if(@report.buyflow_report.cart_language)\n if cleanup_format(@report.buyflow_report.cart_language).include?(cleanup_format(offer.offer_data_detail.offerdesc)) == false\n raise \"Cart language did not match\"\n end\n end\n\n if(@report.buyflow_report.cart_title)\n if @report.buyflow_report.cart_title.to_s.downcase.include?(offer.offer_data_detail.offer_title.to_s.downcase) == false\n raise \"Cart title did not match\"\n end\n end\n else\n if(@report.buyflow_report.cart_title)\n if @report.buyflow_report.cart_title.to_s.downcase.include?(offer.Offer.to_s.downcase) == false\n raise \"Cart title did not match\"\n end\n end\n end\n end\n end\n\n # ------- end of testing --------\n\n\n rescue T5::PasswordMatchException => e\n raise e\n\n rescue Net::ReadTimeout, Selenium::WebDriver::Error::UnknownError => e\n net_timeout_timeout = 0\n begin\n net_timeout_timeout += 1\n sleep(5)\n soft_browser_quit()\n # create browser for new attempt\n @browser = BrowserFactory.create_browser(@browsertype)\n\n # instatiate the starting page model\n @page = T5::Marketing.new(@configuration)\n \n # set the browser session to the current one held by the test case\n @page.browser = @browser\n \n # adapt the page based on the configuration settings\n @page = @page.adapt\n\n auth_workarounds()\n exp = @report.buyflow_report.expected_offer_code\n @report.buyflow_report = GRReporting::BuyflowReport.new()\n @report.buyflow_report.expected_offer_code = exp\n rescue => exc\n if net_timeout_timeout < 5\n retry\n else\n raise e\n end\n end\n retry\n rescue => e\n timeout_count += 1;\n # Change the limit of retries here.\n raise e if(timeout_count > 1)\n soft_browser_quit()\n @browser = BrowserFactory.create_browser(@browsertype)\n\n # instatiate the starting page model\n @page = T5::Marketing.new(@configuration)\n \n # set the browser session to the current one held by the test case\n @page.browser = @browser\n \n # adapt the page based on the configuration settings\n @page = @page.adapt\n\n auth_workarounds()\n exp = @report.buyflow_report.expected_offer_code\n @report.buyflow_report = GRReporting::BuyflowReport.new()\n @report.buyflow_report.expected_offer_code = exp\n retry\n end\n end",
"def open()\n \n #note we would want to check for the browser being open already\n #so we don't annoy people\n \n event(\"Pre\")\n require 'launchy'\n Launchy.open(\"http://store.mage.dev/admin\") #note this should be from setting file\n event(\"Post\")\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 show\n @stores = @biz.stores\n @products = Product.by_biz_id(@biz, params[:page])\n end",
"def add_sku_to_cart(go_to_cart = true)\n add_to_cart_on_search_btn.click\n wait_for_ajax\n\n return unless go_to_cart\n nav_account_menu.appcenter_cart_link.click\n wait_for_ajax\n\n AppCenterCheckOutATG.new\n end",
"def check_out\n @cart.each_with_index do |item, i|\n puts \"#{i + 1}) #{item[:name]} - $#{item[:price]}\"\n end\n def tally_up\n @total = @cart.inject(0) {|sum, hash| sum + hash[:price]}\n @totalWithTax = @total * @sales_tax\n puts \"You owe us #{@totalWithTax}!\"\n sleep(2)\n end\n def payment\n if TotalWithTax >= @card_balance\n puts \"Your transaction has been declined\"\n remove_items\n else\n puts \"Thank you for shopping at The Grocery Store\"\n exit\n end\n end\n tally_up\n payment\nend",
"def complete_order customer\n puts \"========= Completing Order\"\n # Go to Cart Page\n @b.goto 'https://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n # Check if all items can be purchased\n sleep 5\n if @b.button(class: \"buy-now-disabled-info\").exists?\n raise \"Um dos produtos do carrinho não está mais disponível\"\n end\n @b.button(class: \"buy-now\").wait_until_present(timeout: 30)\n if !@b.button(class: \"buy-now\").exists?\n raise \"Produto sem estoque na Aliexpress\"\n else\n @b.button(class: \"buy-now\").click\n end\n\n # Check if current session if up\n self.check_if_session_is_up\n\n fullname = to_english(customer[\"first_name\"]+\" \"+customer[\"last_name\"])\n\n # Fill customer's address\n puts \"========= Adding customer informations\"\n @log.add_message('Adicionando informações do cliente')\n @b.text_field(name: \"contactPerson\").wait_until_present(timeout: 3)\n @log.add_message(fullname)\n @b.text_field(name: \"contactPerson\").set fullname\n @b.select_list(name: \"country\").select \"Brazil\"\n if customer['number'].nil?\n adds = customer[\"address_1\"]\n else\n adds = customer[\"address_1\"]+\" \"+customer['number']\n end\n @log.add_message(to_english(adds))\n @b.text_field(name: \"address\").set to_english(adds)\n @log.add_message(to_english(customer[\"address_2\"]))\n @b.text_field(name: \"address2\").set to_english(customer[\"address_2\"])\n # Wait for States to turn on select\n sleep 1\n state = self.state.assoc(customer[\"state\"])\n @b.div(class: \"sa-province-wrapper\").select_list.select state[1]\n @b.text_field(name: \"city\").set to_english(customer[\"city\"])\n postcode = customer['postcode'].gsub(/\\D/, '')\n @b.text_field(name: \"zip\").set postcode\n @b.text_field(name: \"phoneCountry\").set '55'\n @b.text_field(name: \"mobileNo\").set '941873849'\n @b.text_field(name: \"cpf\").set '35825265856'\n @b.a(class: \"sa-confirm\").click\n\n check_costumer_data @b, fullname\n\n # Placing order on desktop website\n @b.button(id: \"place-order-btn\").click\n\n puts \"========= Finishing Order\"\n @log.add_message('Finalizando Pedido')\n sleep 3\n if @b.span(class: \"order-no\").exists?\n # Return the number of the Order if there is no captcha\n @finished = true\n @b.span(class: \"order-no\").text\n else\n puts \"========= Captcha detected, going to mobile...\"\n @log.add_message('Captcha detectado, indo para carrinho mobile')\n @b.goto 'm.aliexpress.com/shopcart/detail.htm'\n @b.div(class: \"buyall\").wait_until_present(timeout: 30)\n @b.div(class: \"buyall\").click\n # Create the final order on mobile website to avoid captcha\n @b.button(id: \"create-order\").wait_until_present(timeout: 30)\n @b.button(id: \"create-order\").click\n @finished = true\n @b.div(class: \"desc_txt\").wait_until_present(timeout: 30)\n @b.div(class: \"desc_txt\").text\n end\n end",
"def stop_price_tests\n shop.stop_price_tests! if shop.latest_access_token.nil? \n end",
"def buy(store)\n\t\tprint \"Enter the item you want to purchase or press <enter> to go back: \"\n\t\titem = gets.chomp.downcase\n\t\titem = store.check_inventory(item) # check store inventory\n\t\tif item != \"\"\n\t\t\tquantity = store.check_quantity(item) # check if item has stock\n\t\t\tif quantity != 0\n\t\t\t\tif @wallet_amt > store.get_price(item) # Check if the user has enough money\n\t\t\t\t\tputs \"You paid $%.2f for a #{item}\" % store.get_price(item)\n\t\t\t\t\t@wallet_amt -= store.get_price(item) # reduce wallet_amt by item price\n\t\t\t\t\t@cart << item # add item to the cart\n\t\t\t\t\tstore.increment(item,\"buy\") #increment the inventory\n\t\t\t\telse\n\t\t\t\t\tputs \"You do not have enough money to purchase a #{item}.\"\n\t\t\t\tend\t\n\t\t\tend\n\t\tend\n\tend",
"def invokeRazooSite(test_site)\n\t\n\tputs \"************** START : Invoke Razoo Application ****************\"\t\n\t# Create a new instance of the Selenium-Client driver.\n\t@browser = Selenium::Client::Driver.new \\\n\t\t:host => \"localhost\",\n\t\t:port => 4444,\n\t\t:browser => \"*firefox\", \n\t\t:url => test_site,\n\t\t:timeout_in_second => 60\n\n\t# Start the browser session\n\t@browser.start_new_browser_session\n\t\n\t# Print a message in the browser-side log and status bar\n\t@browser.set_context(\"Razoo Application\")\n\t@browser.open \"/\"\n\tputs \"Passed. Razoo Site gets invoked successfully!\"\n\tputs \"************** END : Invoke Razoo Application ****************\"\n\t\nend",
"def buy\n @page = Pwb::Page.find_by_slug \"buy\"\n @page_title = @current_agency.company_name\n # @content_to_show = []\n if @page.present?\n @page_title = @page.page_title + \" - \" + @current_agency.company_name\n # TODO: - allow addition of custom content\n # @page.ordered_visible_page_contents.each do |page_content|\n # @content_to_show.push page_content.content.raw\n # end\n end\n\n # @page_title = I18n.t(\"searchForProperties\")\n # in erb template for this action, I have js that will render search_results template\n # for properties - like search_ajax action does\n @operation_type = \"for_sale\"\n # above used to decide if link to result should be to buy or rent path\n\n @properties = Prop.visible.for_sale.limit 45\n # ordering happens clientside\n # .order('price_sale_current_cents ASC').limit 35\n @prices_from_collection = @current_website.sale_price_options_from\n @prices_till_collection = @current_website.sale_price_options_till\n # @prices_collection = @current_website.sale_price_options_from\n\n # %W(#{''} 25,000 50,000 75,000 100,000 150,000 250,000 500,000 1,000,000 2,000,000 5,000,000 )\n # ..\n\n set_common_search_inputs\n set_select_picker_texts\n apply_search_filter filtering_params(params)\n set_map_markers\n\n # below allows setting in form of any input values that might have been passed by param\n @search_defaults = params[:search].present? ? params[:search] : {}\n # {\"property_type\" => \"\"}\n # below won't sort right away as the list of results is loaded by js\n # and so won't be ready for sorting when below is called - but will wire up for sorting button\n # initial client sort called by INMOAPP.sortSearchResults();\n js \"Main/Search#sort\" # trigger client-side paloma script\n\n render \"/pwb/search/buy\"\n end",
"def activate\n\n Product.class_eval do\n def already_purchased?\n purchased = false\n\n user = UserSession.find.user if UserSession.find\n if user\n orders = Order.find_all_by_user_id user.id\n else\n orders = []\n end\n orders.each do |order|\n line_item = LineItem.conditions('variant_id = ? AND order_id = ?', master.id, order.id).all\n purchased = true if line_item.size > 0\n end\n purchased\n end\n end\n\n LineItem.class_eval do\n def increment_quantity\n self.quantity\n end\n\n def decrement_quantity\n self.quantity\n end\n end\n end",
"def trade; end",
"def complete_order customer\n puts \"========= Completing Order\"\n # Go to Cart Page\n @b.goto 'https://shoppingcart.aliexpress.com/shopcart/shopcartDetail.htm'\n # Check if all items can be purchased\n sleep 5\n if @b.button(class: \"buy-now-disabled-info\").exists?\n raise \"Um dos produtos do carrinho não está mais disponível\"\n end\n @b.button(class: \"buy-now\").wait_until_present(timeout: 30)\n if !@b.button(class: \"buy-now\").exists?\n raise \"Produto sem estoque na Aliexpress\"\n else\n @b.button(class: \"buy-now\").click\n end\n # Check if current session if up\n self.check_if_session_is_up\n # Fill customer's address\n puts \"========= Adding customer informations\"\n @log.add_message('Adicionando informações do cliente')\n @b.text_field(name: \"contactPerson\").wait_until_present(timeout: 3)\n @b.text_field(name: \"contactPerson\").set to_english(customer[\"first_name\"]+\" \"+customer[\"last_name\"])\n @b.select_list(name: \"country\").select \"Brazil\"\n if customer['number'].nil?\n @b.text_field(name: \"address\").set to_english(customer[\"address_1\"])\n else\n @b.text_field(name: \"address\").set to_english(customer[\"address_1\"]+\" \"+customer['number'])\n end\n @b.text_field(name: \"address2\").set to_english(customer[\"address_2\"])\n # Wait for States to turn on select\n sleep 1\n state = self.state.assoc(customer[\"state\"])\n @b.div(class: \"sa-province-wrapper\").select_list.select state[1]\n @b.text_field(name: \"city\").set to_english(customer[\"city\"])\n @b.text_field(name: \"zip\").set customer[\"postcode\"]\n @b.text_field(name: \"phoneCountry\").set '55'\n @b.text_field(name: \"phoneArea\").set '55'\n @b.text_field(name: \"phoneNumber\").set '11'\n @b.text_field(name: \"mobileNo\").set '941873849'\n @b.text_field(name: \"cpf\").set '35825265856'\n @b.a(class: \"sa-confirm\").click\n\n # Placing order on desktop website\n @b.button(id: \"place-order-btn\").click\n\n puts \"========= Finishing Order\"\n @log.add_message('Finalizando Pedido')\n sleep 3\n if @b.span(class:\"order-no\").exists?\n # Return the number of the Order if there is no captcha\n @finished = true\n @b.span(class:\"order-no\").text\n else\n puts \"========= Captcha detected, going to mobile...\"\n @log.add_message('Captcha detectado, indo para carrinho mobile')\n @b.goto 'm.aliexpress.com/shopcart/detail.htm'\n @b.div(class:\"buyall\").wait_until_present(timeout: 30)\n @b.div(class:\"buyall\").click\n # Create the final order on mobile website to avoid captcha\n @b.button(id:\"create-order\").wait_until_present(timeout: 30)\n @b.button(id:\"create-order\").click\n @finished = true\n @b.div(class:\"desc_txt\").wait_until_present(timeout: 30)\n @b.div(class:\"desc_txt\").text\n end\n end",
"def cart_check\n puts \"cart checking\"\n \n sleep(2)\n mini_cart_text.click\n wait_for_spinner\n sleep(2)\n puts @prod2 = cartpage_productname.text.downcase\n if(@prod1 == @prod2)\n puts \"product is added to the cart: PASS\"\n else\n puts \"product is not added to the cart: FAIL\" # cart is invalid ie when items in the cart are sold out \n end\n end",
"def test_ebook_purchases_send_to_bookshelf\n puts \"test_ebook_purchases_send_to_bookshelf\"\n\n # Verify target bookshelf installation is in nibley mode\n\n # Log test user in to bookshelf\n bookshelf_token = login_bookshelf_user(\n 'tests@deseretbook.com',\n 'test123'\n )\n \n # Ensure the book isn't already in the test user's bookshelf account.\n remove_book_from_bookshelf_account(bookshelf_token, digital_product_book_id)\n\n # do the purchase\n clear_cookies\n login\n\n add_items_to_cart([:digital])\n\n begin_checkout\n\n select_addresses(allow_skip: true)\n\n select_payment(payment_type: :credit_card)\n\n confirm_order\n verify_successful_order\n verify_order_state([:digital])\n\n # Verify the book is now in the test user's bookshelf account.\n # It may take a while to get through the queue so do a timed retry here.\n # This loop will wait a total of 30 seconds.\n retries = 10\n until present = bookshelf_account_contains_book?(bookshelf_token, digital_product_book_id)\n puts \"Book #{digital_product_book_id} present yet? #{present.inspect}\"\n unless present\n retries -= 1\n puts \"#{retries} retries left. Trying again in 3 seconds.\"\n sleep(3)\n end\n end\n assert(present, \"Book #{digital_product_book_id} not in bookshelf account\")\n end",
"def settle\n self.send_freshbooks_invoice!\n end",
"def start_placebo\n\t\tGReactor.clear_listeners\n\t\tredis # make sure the redis connection is activated\n\t\tputs \"* Plezi #{Plezi::VERSION} Services will start with no Server...\\n\"\n\t\tstart_async\n\tend",
"def start!\n setup\n adapter.start!\n end",
"def start\n end",
"def initialize\n @shop_url = \"https://#{ENV[\"SHOPIFY_API_KEY\"]}:#{ENV[\"SHOPIFY_PASSWORD\"]}@#{ENV[\"SHOP\"]}.myshopify.com/admin\"\n ShopifyAPI::Base.site = @shop_url\n end",
"def build_call(search_term)\n keywords = \"#{search_term} -replica -copy -reproduction\" #minus means \"not\". Avoid replicas.\n host = \"http://svcs.ebay.com/services/search/FindingService/v1\"\n apicall = \"OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.8.0&SECURITY-APPNAME=#{EBAY_DEVELOPER_ID}&REST-PAYLOAD&paginationInput.entriesPerPage=#{NUM_EBAY_RESULTS}&categoryId=#{@category}&sortOrder=EndTimeSoonest\"\n apicall << \"&keywords=#{keywords}\"\n if @affiliate == true\n apicall << \"&affiliate.networkId#{EBAY_TRACKING_PARTNER_CODE}&affiliate.trackingId=#{EBAY_TRACKING_ID}\"\n end\n URI.escape(\"#{host}?#{apicall}\")\n end",
"def start\n backend.start\n end",
"def offers; global.offers end",
"def index\n @stocks = Stock.all\n @webhooks = ShopifyAPI::Webhook.find(:all)\n\n\n # After Authenticate Job / after change in product listings\n if Product.count < 1\n ProductSize.all.each do |size|\n _items = ShopifyAPI::Product.find(:all, params: { collection_id: size.collection_id })\n _items.each do |product|\n prod = Product.create(name: product.title, item_id: product.id, product_size: size)\n product.variants.each do |var|\n prod.variants.create!(quantity: var.inventory_quantity, variant_id: var.id, title: var.title, inventory_item_id: var.inventory_item_id )\n end\n end\n end\n end\n\n\n end",
"def checkout\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 activate\n\n # Add your extension tab to the admin.\n # Requires that you have defined an admin controller:\n # app/controllers/admin/yourextension_controller\n # and that you mapped your admin in config/routes\n\n #Admin::BaseController.class_eval do\n # before_filter :add_yourextension_tab\n #\n # def add_yourextension_tab\n # # add_extension_admin_tab takes an array containing the same arguments expected\n # # by the tab helper method:\n # # [ :extension_name, { :label => \"Your Extension\", :route => \"/some/non/standard/route\" } ]\n # add_extension_admin_tab [ :yourextension ]\n # end\n #end\n\n # make your helper avaliable in all views\n # Spree::BaseController.class_eval do\n # helper YourHelper\n # end\n \n Admin::OrdersController.class_eval do\n \n def charge_google_order\n @gateway = Gateway.find_by_clazz \"Google4R::Checkout::Frontend\"\n @gw = GatewayConfiguration.find_by_gateway_id(@gateway.id)\n if @gw.present? && @gw.gateway_option_values[0].value.present? && @gw.gateway_option_values[1].value.present?\n configuration = { :merchant_id =>@gw.gateway_option_values[0].value, :merchant_key => @gw.gateway_option_values[1].value, :use_sandbox => true }\n @frontend = Google4R::Checkout::Frontend.new(configuration)\n order = @frontend.create_charge_order_command\n o = Order.find_by_number(params[:id])\n order.google_order_number = o.google_order_number if o.google_order_number.present? \n order.amount = Money.new(5017, \"GBP\")\n puts \"=-=-=-=-=-_+_+_+-#{order.to_xml}\"\n @orders = order.send_to_google_checkout\n flash[:notice] = t('charged_google_checkout_order')\n redirect_to :back\n end\n end\n \n def cancel_google_checkout_order\n @gateway = Gateway.find_by_clazz \"Google4R::Checkout::Frontend\"\n @gw = GatewayConfiguration.find_by_gateway_id(@gateway.id)\n if @gw.present? && @gw.gateway_option_values[0].value.present? && @gw.gateway_option_values[1].value.present?\n configuration = { :merchant_id =>@gw.gateway_option_values[0].value, :merchant_key => @gw.gateway_option_values[1].value, :use_sandbox => true }\n @frontend = Google4R::Checkout::Frontend.new(configuration)\n order = @frontend.create_cancel_order_command\n o = Order.find_by_number(params[:id])\n order.google_order_number = o.google_order_number if o.google_order_number.present? \n order.reason = params[:reason]\n order.comment = params[:comment]\n @orders = order.send_to_google_checkout\n #puts \"=-=-=-=-=-_+_+_+-#{@orders}\"\n end\n end\n \n end\n \n \n OrdersController.class_eval do\n \n def edit\n # Use your own merchant ID and Key, set use_sandbox to false for production\n @gateway = Gateway.find_by_clazz \"Google4R::Checkout::Frontend\"\n @gw = GatewayConfiguration.find_by_gateway_id(@gateway.id)\n if @gw.present? && @gw.gateway_option_values[0].value.present? && @gw.gateway_option_values[1].value.present?\n configuration = { :merchant_id =>@gw.gateway_option_values[0].value, :merchant_key => @gw.gateway_option_values[1].value, :use_sandbox => true }\n @frontend = Google4R::Checkout::Frontend.new(configuration)\n @frontend.tax_table_factory = TaxTableFactory.new\n checkout_command = @frontend.create_checkout_command\n # Adding an item to shopping cart\n @order.line_items.each do |l|\n checkout_command.shopping_cart.create_item do |item| \n item.name = l.product.name\n item.description = l.product.description\n item.unit_price = Money.new(l.price, \"GBP\") \n item.quantity = l.quantity\n end\n end\n checkout_command.shopping_cart.private_data = { 'order_number' => @order.id } \n checkout_command.edit_cart_url = edit_order_url(@order)\n checkout_command.continue_shopping_url = order_url(@order)\n #Create a flat rate shipping method\n i = 50\n ShippingMethod.all.each do |ship_method| \n \n checkout_command.create_shipping_method(Google4R::Checkout::FlatRateShipping) do |shipping_method| \n shipping_method.name = ship_method.name #\"UPS Standard 3 Day\"\n shipping_method.price = Money.new(i, \"GBP\")#Money.new(5000, \"GBP\") \n shipping_method.create_allowed_area(Google4R::Checkout::UsCountryArea) do |area|\n area.area = Google4R::Checkout::UsCountryArea::ALL\n end \n i += 50\n end\n \n end \n @response = checkout_command.to_xml #send_to_google_checkout # \n # puts \"===========#{request.raw_post}\"\n end\n end\n \n show.before do\n session[:order_id] = nil\n end\n end\n \n end"
] |
[
"0.61007935",
"0.6023272",
"0.59614694",
"0.5957287",
"0.5916267",
"0.5770658",
"0.576249",
"0.5757823",
"0.57383835",
"0.5711802",
"0.5686604",
"0.5664512",
"0.5663861",
"0.5645578",
"0.5623897",
"0.56088245",
"0.55879164",
"0.5447996",
"0.5404726",
"0.53857327",
"0.5360915",
"0.5319533",
"0.53098404",
"0.5287028",
"0.5280839",
"0.5273668",
"0.5255766",
"0.5248379",
"0.5243068",
"0.523796",
"0.5226503",
"0.5204603",
"0.5196425",
"0.5189838",
"0.5186202",
"0.51765454",
"0.5174619",
"0.51560664",
"0.51555187",
"0.51485837",
"0.5143501",
"0.5133598",
"0.5116266",
"0.5105564",
"0.5099247",
"0.5098648",
"0.5097115",
"0.5096701",
"0.5090903",
"0.5077977",
"0.50680566",
"0.5059746",
"0.50569266",
"0.50495833",
"0.50483865",
"0.5044181",
"0.50383115",
"0.5035684",
"0.5032007",
"0.50251997",
"0.5020698",
"0.5019667",
"0.5017603",
"0.50107265",
"0.50085706",
"0.500321",
"0.4998747",
"0.49978757",
"0.49851102",
"0.4985099",
"0.49799824",
"0.497936",
"0.4978122",
"0.49772173",
"0.49770758",
"0.4959233",
"0.49591872",
"0.49543962",
"0.49413604",
"0.49364528",
"0.4934267",
"0.4933833",
"0.4930028",
"0.49296537",
"0.49210373",
"0.49201822",
"0.49198553",
"0.49191174",
"0.49184144",
"0.49108192",
"0.49091512",
"0.49081898",
"0.4904847",
"0.49042118",
"0.49023852",
"0.48885307",
"0.4887931",
"0.4887564",
"0.48855394",
"0.48793474",
"0.48767674"
] |
0.0
|
-1
|
TODO remove hack, consider moving to initializers
|
def load_youtube
Video
YouTube
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize() end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def initialize(*) end",
"def init; end",
"def init; end",
"def init; end",
"def init; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def initialize; end",
"def pre_initialize; end",
"def initialize\n \n end",
"def initialize\n\t\t\n\tend",
"def init\n\n end",
"def init\n end",
"def init\n end",
"def init\n end",
"def initialize\n \n end",
"def initialize\n\n\tend",
"def initialize\n\n\tend",
"def initialize(*) \n end",
"def private; end",
"def initialize\r\n\r\n end",
"def initialize\n # nothing here for now\n end",
"def initialize\n \n end",
"def initialize\n \n end",
"def initialize\n end",
"def initialize\n\n end",
"def initialize\n\n end",
"def initialize\n\n\n\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n\t\nend",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n end",
"def initialize\n\n\nend",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n super()\n end",
"def initialize()\n\t\tend",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def initialize\n super \n end",
"def initialize(*)\n end",
"def initialize(*)\n end",
"def init; end",
"def constructor; end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize\n super\n end",
"def initialize()\r\n\r\n end",
"def initialize(*args)\n #This is a stub, used for indexing\n end",
"def initialize(*rest) end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize()\n end",
"def initialize\nend",
"def at_init\n\n\t\tend",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n super()\n end",
"def initialize\n init\n end",
"def init\n raise NotImplementedError\n end",
"def initialize\n super(true)\n end",
"def initialize()\n\tend"
] |
[
"0.74650115",
"0.7454861",
"0.7454861",
"0.7454861",
"0.7454861",
"0.7454861",
"0.74329656",
"0.74329656",
"0.74329656",
"0.74329656",
"0.7392327",
"0.7392327",
"0.7392327",
"0.7392327",
"0.7392327",
"0.7392327",
"0.7392327",
"0.7392327",
"0.7392327",
"0.7392327",
"0.7392327",
"0.7089268",
"0.7082203",
"0.7078221",
"0.696894",
"0.69580406",
"0.69580406",
"0.69580406",
"0.6954662",
"0.69474167",
"0.69474167",
"0.6864525",
"0.6859958",
"0.6817446",
"0.68116283",
"0.6798185",
"0.6798185",
"0.677308",
"0.67672366",
"0.67672366",
"0.67179906",
"0.67110544",
"0.67110544",
"0.67110544",
"0.67110544",
"0.67110544",
"0.67110544",
"0.67110544",
"0.67110544",
"0.67110544",
"0.6706236",
"0.6700261",
"0.6700261",
"0.6700261",
"0.6700261",
"0.6700261",
"0.6700261",
"0.6700261",
"0.6700261",
"0.6700261",
"0.6700261",
"0.67001593",
"0.66963714",
"0.66963714",
"0.66963714",
"0.66873556",
"0.66833514",
"0.66823137",
"0.66823137",
"0.6681214",
"0.6674038",
"0.6674038",
"0.6656765",
"0.6652872",
"0.665149",
"0.665149",
"0.665149",
"0.66506684",
"0.66332775",
"0.66327935",
"0.663035",
"0.663035",
"0.663035",
"0.663035",
"0.663035",
"0.663035",
"0.663035",
"0.663035",
"0.6627536",
"0.66184855",
"0.66135544",
"0.66135544",
"0.66135544",
"0.66135544",
"0.66135544",
"0.66135544",
"0.66135544",
"0.65993863",
"0.6589014",
"0.6587731",
"0.65742934"
] |
0.0
|
-1
|
========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: Write a method that rotates an array by moving the first element to the end of the array. The original array should not be modified. Do not use the method Arrayrotate or Arrayrotate! for your implementation. E: rotate_array([7, 3, 5, 2, 9, 1]) == [3, 5, 2, 9, 1, 7] rotate_array(['a', 'b', 'c']) == ['b', 'c', 'a'] rotate_array(['a']) == ['a'] x = [1, 2, 3, 4] rotate_array(x) == [2, 3, 4, 1] => true x == [1, 2, 3, 4] D: Input an array, output a new array A: Create a method rotate_array that takes one argument an array called array_of_numbers set variable rotated_array to array_of_numbers cloned Set the first element in rotated_array equal to the last element of array_of_numbers Set the last element of rotate_array equal to the first element of array_of_numbers return rotated_array
|
def rotate_array(array_of_numbers)
rotated_array = array_of_numbers.clone
rotated_array << rotated_array.shift
rotated_array
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rotate_array(input_array)\n return input_array if input_array.size <= 1\n new_array = []\n index_counter = 1\n loop do\n new_array << input_array[index_counter]\n index_counter += 1\n break if index_counter >= input_array.size\n end\n new_array << input_array[0]\n new_array\nend",
"def rotate_array(numbers)\n numbers[1..-1] + [numbers[0]]\nend",
"def rotate_array(numbers)\n numbers[1..-1] + [numbers[0]]\nend",
"def rotate_array(array)\n new_array = array\n\n last = new_array.shift\n new_array << last\n\n p new_array\nend",
"def rotate_array(array)\n rotated = array[1..-1]\n first = array.first\n rotated.push(first)\nend",
"def rotate_array(array)\n new_array = array.dup\n first_element = new_array.shift\n new_array.append(first_element)\n new_array\nend",
"def rotate_array(numbers)\n arr = []\n numbers.each { |num| arr << num }\n arr.push(numbers[0]).shift\n arr\nend",
"def rotate_array(numbers)\n new_numbers = []\n new_numbers << numbers[1,numbers.size] << numbers[0]\n new_numbers.flatten\nend",
"def rotate_array(array)\n new_array = array.dup \n new_array << new_array.shift \nend",
"def rotate_array(array)\narray[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] << array[0]\nend",
"def rotate_array(arr)\nnew_arr = []\narr.each do |num|\nnew_arr << num\nend\t\nnew_arr << new_arr.shift\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]] \nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]]\nend",
"def rotate_array(starting_array)\n return_array = []\n starting_array.map {|element| return_array << element }\n return_array << return_array.first\n return_array.delete_at(0)\n return_array\nend",
"def rotate_array(array)\n array[1..-1] + [array[0]] # brackets added to array[0] to force it to an array from integer.\nend",
"def rotate_array(array)\n arr2 = []\n arr2.concat(array[1..-1]) << array[0]\nend",
"def rotate_array(array)\n arr_copy = array.clone\n return arr_copy if arr_copy.empty?\n arr_copy.push(arr_copy.shift)\nend",
"def rotate_array(array)\n result = []\n array.each_with_index do |value, index|\n result.push(value) if index > 0\n end\n result.push(array[0])\n result\nend",
"def rotate_array(ar)\n ar[1..-1] << ar[0]\nend",
"def rotate_array(array, number)\n number.times{array.unshift(array.pop)}\n array\nend",
"def rotate_array(arr)\n\narr_new = arr.clone\narr_new.push(arr_new[0]).shift\narr_new\nend",
"def rotate_array(array)\n copy = array.dup\n popped = copy.shift\n copy << popped\nend",
"def rotate_array(array)\n first_value = array.slice(0)\n other_values = array.slice(1..-1)\n other_values << first_value\nend",
"def rotate_array(array)\n first_value = array.slice(0)\n other_values = array.slice(1..-1)\n other_values << first_value\nend",
"def rotate_array(array)\n array[1, array.size] << array[0]\nend",
"def rotate_array(array)\n array[1..-1] + array[0..0]\nend",
"def rotate_array(arr)\n new_arr = arr.clone\n new_arr << new_arr.shift\n new_arr\nend",
"def rotate_without_changing(arr)\n\nend",
"def rotate_array(array)\n arr = array.dup\n p arr.push(arr.shift)\nend",
"def rotate_array(arr)\n rotated = arr.clone\n rotated.insert(-1, rotated.shift)\nend",
"def rotate_array(array)\n result = []\n result << array.shift\n # array << result[-1] # can use either the push method of << operator\n array.push(result[-1])\nend",
"def rotate_array(arr)\n arr[1..(arr.size - 1)] << arr[0]\nend",
"def rotate_array(arr)\n arr[1..(arr.size - 1)] << arr[0]\nend",
"def rotate_array(array)\n array.drop(1) + array.take(1)\nend",
"def rotate_array(arr)\n new_arr = arr.clone # avoid mutation\n first_element = new_arr.shift\n new_arr << first_element # could've called new_arr.shift here instead\n new_arr # later realized that this is redundant\nend",
"def rotate_array(unrotated)\n unrotated[1..] + [unrotated.first]\nend",
"def rotate_array(unrotated)\n unrotated[1..] + [unrotated.first]\nend",
"def rotate(arr)\n\nend",
"def rotate_array(arr)\n results = arr.map { |n| n }\n results << results.shift\nend",
"def my_rotate(num = 1)\n new_array = []\n \n new_array\nend",
"def rotate_array(arr)\n arr2 = arr.dup\n first = arr2.shift\n arr2 << first\nend",
"def rotate_array(arr, num)\n\n if num == 1\n arr.unshift(arr[-1])\n arr.pop\n end\n\n if num > 1\n\n i = 0\n while i < arr.length - num\n arr.push(arr[0])\n arr.shift\n i += 1 \n end \n end\n\n return arr\nend",
"def rotate_array(arr)\n arr_copy = arr.dup\n arr_copy << arr_copy.shift\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1..-1] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1...arr.size] + [arr[0]]\nend",
"def rotate_array(arr)\n arr[1...arr.size] + [arr[0]]\nend",
"def my_rotate(arr)\n print arr.rotate\n end",
"def rotate_array(array)\n new_array = array.select { |element| element }\n new_array << new_array.shift\nend",
"def rotate_arr(arr)\n result_arr = arr.map{|num| num}\n result_arr << result_arr[0]\n result_arr.shift\n result_arr\nend",
"def rotate_array(arr)\narr.drop(1) + arr[0...1]\nend",
"def rotate_array(arr)\n array = arr.dup\n array << array.shift\nend",
"def rotate_array(arr, num)\n j = 0\n max = num\n len = arr.length - 1\n\n while j < max\n arr.unshift(arr[len])\n arr.pop()\n j += 1\n end\n return arr\n\nend",
"def rotate_array(array)\n results = []\n results << array\n results = results.flatten\n last = results.shift \n results << last\nend",
"def rotate_array(arr)\n rotated_arr = []\n if arr.length > 1\n arr.each_index do |index|\n next if index + 1 >= arr.length\n rotated_arr.push(arr[index + 1])\n end\n end\n rotated_arr.push(arr[0])\n rotated_arr\nend",
"def rotate_array(arr)\n arr.empty? ? arr : arr[1..-1] << arr[0]\nend",
"def rotate_array(arr, num)\n num.times do\n arr.unshift(arr.pop())\n end\n return arr\nend",
"def rotate_array(arr)\n\tnew_arr = arr.dup\n\tlast = new_arr.shift\n\tnew_arr << last\nend",
"def rotate(array)\n array.map.with_index do |elem, index|\n if (index + 1) < array.size\n array[index + 1]\n else\n array[0]\n end\n end\nend",
"def rotate_array(arr1)\n arr2 = arr1.clone\n num = arr2.shift\n arr2.push(num)\nend",
"def rotate_array(aArray, off_x, off_y, rel_angle, change_in_place=false)\r\n # - - - - - - - - - - - - - - - - - - - - -\r\nend",
"def rotate_by(array, offset)\n offset.times do\n starting = array.length - offset\n (starting).downto(0) do |j|\n temp = array[j]\n array[j] = array[j-1]\n array[j-1] = temp\n end\n end\n return array\nend",
"def rotate_array(arr)\n new_arr = arr.dup\n new_arr.push(new_arr.shift)\nend",
"def my_rotate!(array, amt)\n\nend",
"def rotate_array(arr, num)\n num.times do\n value = arr.pop()\n arr.unshift(value)\n end\n return arr\nend",
"def rotate_array(arr, num)\n num.times do \n ele = arr.pop \n arr.unshif(ele)\n end\n return arr \nend",
"def rotate_array(ary)\n ary[1..-1] + [ary[0]] # need to concatenate 2 arrays\nend",
"def rotate_array(arr, num)\r\n num.times do\r\n ele = arr.pop\r\n arr.unshift(ele)\r\n end\r\n\r\n return arr\r\nend",
"def rotate_array(array)\n [array[1..-1], array[0]].flatten\nend",
"def rotate_array(arr)\n local_array = arr.clone\n local_array << local_array.shift\nend",
"def rotate_array(arr)\n arr_copy = arr.dup\n rotated_element = arr_copy.shift\n arr_copy.push(rotated_element)\nend",
"def rotate_array(array)\r\n result = array.select {|x| x}\r\n result << result.shift\r\nend",
"def rotate_array(arr)\n arr1 = arr.clone\n f = arr1.shift\n arr1 << f\nend",
"def rotate_array(arr)\n result = []\n arr.reverse.each { |e| e == arr.first ? result << e : result.prepend(e) }\n result\nend",
"def array_rotation(arr, num)\n\tarr.rotate(num)\nend",
"def rotate_array(arr, num)\n num.times do\n elem = arr.pop\n arr.unshift(elem)\n return arr\n end\nend",
"def rotate_array(ary)\n ary[1..-1] + [ary[0]]\nend",
"def rotate_array(ary)\n ary[1..-1] + [ary[0]]\nend",
"def rotate_array(ary)\r\n ary[1..-1] << ary[0]\r\nend",
"def rotate_array(array)\n array.values_at(1..-1, 0)\nend",
"def rotate(array, number)\n\t#put the strings we want to move into a new string\n\tnewArray = array.shift\n\t#subtract the number\n\tnumber-=1\n\t#push the strings to the back of the array\n\tarray.push(newArray)\n\t#keep doing this until our number is 0\n\trotate(array, number) unless number ==0\nend",
"def rotate_array(arr, num)\n# \tloop num times\n for i in 0...num\n temp = arr.pop\n arr.unshift(temp)\n end\n return arr\nend"
] |
[
"0.81887287",
"0.80985403",
"0.80985403",
"0.8023813",
"0.80042064",
"0.7981421",
"0.79398644",
"0.7939189",
"0.79229003",
"0.7916857",
"0.7905621",
"0.78907263",
"0.7876534",
"0.7868385",
"0.7868385",
"0.7868385",
"0.7868385",
"0.7868385",
"0.7868385",
"0.7868385",
"0.7868385",
"0.7868385",
"0.7868385",
"0.7868385",
"0.7868385",
"0.7868385",
"0.78465366",
"0.78123003",
"0.780098",
"0.77864915",
"0.77776605",
"0.77748734",
"0.7767482",
"0.77636904",
"0.7751875",
"0.7747215",
"0.7746536",
"0.77384084",
"0.7734301",
"0.77305406",
"0.7706358",
"0.7693555",
"0.7688111",
"0.7683182",
"0.7679962",
"0.7679962",
"0.7677307",
"0.7676226",
"0.7665086",
"0.7665086",
"0.76592064",
"0.7596281",
"0.7595482",
"0.75909007",
"0.7586675",
"0.75821686",
"0.7575548",
"0.7575548",
"0.7575548",
"0.7575548",
"0.7575548",
"0.7575548",
"0.7575548",
"0.75698596",
"0.75698596",
"0.7566452",
"0.75603426",
"0.755826",
"0.7553922",
"0.7527447",
"0.75197065",
"0.7517691",
"0.7514243",
"0.75091213",
"0.7500265",
"0.74829245",
"0.74815273",
"0.74724704",
"0.74713486",
"0.7447136",
"0.74421287",
"0.7441539",
"0.74359185",
"0.7425265",
"0.74199057",
"0.74136174",
"0.7413215",
"0.7411106",
"0.74089295",
"0.74023646",
"0.7401944",
"0.7386712",
"0.7375518",
"0.73723525",
"0.7367674",
"0.7367674",
"0.73631227",
"0.7361682",
"0.73203105",
"0.73117423"
] |
0.85668236
|
0
|
Problem 2: ========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: Write a method that can rotate the last n digits of a number. For example: Note that rotating just 1 digit results in the original number being returned. You may use the rotate_array method from the previous exercise if you want. (Recommended!) You may assume that n is always a positive integer. E: rotate_rightmost_digits(735291, 1) == 735291 rotate_rightmost_digits(735291, 2) == 735219 rotate_rightmost_digits(735291, 3) == 735912 rotate_rightmost_digits(735291, 4) == 732915 rotate_rightmost_digits(735291, 5) == 752913 rotate_rightmost_digits(735291, 6) == 352917 D: Input two integers, output one integer A: create a method rotate_rightmost_digits that takes two integers, number, times Set number variable equal to an array of all the digits set swapped_numbers equal to the values in the array number from 1 to times join the array number by the index 0 to times not included plus call rotate_array on swapped_numbers and join it
|
def rotate_rightmost_digits(number, times)
rotated_number = number.to_s.split('')
rotated_number[(times * -1)..-1] = rotate_array(rotated_number[times*-1..-1])
rotated_number.join('').to_i
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rotate_rightmost_digits(number, n)\nall_digits = number.to_s.chars\nall_digits[-n..-1] = rotate_array(all_digits[-n..-1])\nall_digits.join.to_i\nend",
"def rotate_rightmost_digits(number, n)\np all_digits = number.to_s.chars\n# all_digits[-n..-1] = rotate_array(all_digits[-n..-1])\nend",
"def rotate_rightmost_digits(integer, n)\n num_arr = integer.digits.reverse\n new_arr = num_arr[0...-n] << rotate_array(num_arr[-n..-1])\n new_arr.flatten.join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n num = num.digits.reverse\n rotators = num.pop(n)\n result = num + rotate_array(rotators)\n result.join.to_i\nend",
"def rotate_rightmost_digits(number, n)\n all_digits = number.to_s.chars\n all_digits[-n..-1] = rotate_array(all_digits[-n..-1])\n all_digits.join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n arr = num.digits.reverse\n rotate_arr = rotate_array(arr.pop(n))\n (arr + rotate_arr).join.to_i\nend",
"def rotate_rightmost_digits_alt(number, n)\n digits = number.digits.reverse\n digits[-n..-1] = rotate_array_alt(digits[-n..-1])\n digits.join.to_i\nend",
"def rotate_rightmost_digits(number, n)\n number_array = number.to_s.chars\n number_array[-n..-1] = rotate_array(number_array[-n..-1])\n number_array.join.to_i\nend",
"def rotate_rightmost_digits(num, rotate)\n rotate = rotate * -1\n num_array = num.to_s.split(//)\n rotated_arr = []\n if num_array.length > 1\n num_array.each_index do |index|\n next if num_array[index] == num_array[rotate]\n rotated_arr.push(num_array[index])\n end\n end\n rotated_arr.push(num_array[rotate])\n rotated_arr.join.to_i\nend",
"def rotate_rightmost_digits(integer, n)\n ary = integer.digits.reverse\n new_ary = Array.new(ary) # avoid mutating the original argument\n new_ary << new_ary.delete_at(-n)\n new_ary.join('').to_i\nend",
"def rotate_rightmost_digits(number, n)\n arr = number.digits.reverse\n e = arr.delete_at(-n)\n arr << e\n arr.join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n arr = num.to_s.chars\n arr[-n..-1] = arr[-n..-1].rotate\n arr.join.to_i\nend",
"def rotate_rightmost_digits(array, n)\n input_array = array.to_s.chars\n start_index = input_array.length - n\n sub_array = input_array[start_index..-1]\n sub_array_rotated = rotate_array(sub_array)\n output = input_array[0...start_index] + sub_array_rotated\n output.join(\"\").to_i\nend",
"def rotate_rightmost_digits(number, rotation_digit)\n new_number = [] # hold new digit order; join; to_i\n counter = 0 # loop through digits as array of strings\n loop do\n # loop through number add all but string at rotation_digit (as number from end)\n unless number.to_s.chars[-rotation_digit].to_i == number.to_s.chars[counter].to_i\n new_number << number.to_s.chars[counter].to_i\n end\n counter += 1\n break if new_number.size == number.to_s.chars.size - 1\n end\n number.to_s.chars.select { |n| new_number << n.to_i if n == number.to_s.chars[-rotation_digit] }\n new_number.join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n arr = num.digits.reverse\n number = arr.delete_at(-n)\n arr.append(number).join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n arr = num.digits.reverse\n number = arr.delete_at(-n)\n arr.append(number).join.to_i\nend",
"def rotate_rightmost_digits(number, num)\n digits = number.to_s.chars.map(&:to_i)\n index_to_rotate = digits.size - num\n digits << digits.delete_at(index_to_rotate)\n p digits.join.to_i\nend",
"def rotate_rightmost_digits(int, position)\n int_arr = int.digits.reverse\n shifting = int_arr.pop(position)\n int_arr.concat(rotate_array(shifting)).join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n [num.to_s[0..-(n+1)],rotate_array(num.to_s[-n..-1])].flatten.join('').to_i\nend",
"def rotate_rightmost_digits(number, n)\n array = number.to_s.split(//)\n removed_element = array[-n]\n array.slice!(-n)\n [array, removed_element].flatten.join.to_i\nend",
"def rotate_rightmost_digits(num, digits)\n left, right = num.divmod(10**digits)\n [[left], rotate_array(right.to_s.chars)].join.to_i\nend",
"def rotate_rightmost_digits(long_number, n)\n return long_number if n == 1\n arr = long_number.to_s\n (arr[0...-n] + arr[-n+1..-1] + arr[-n]).to_i\nend",
"def max_rotation(original_num)\ncount = original_num.to_s.size\ncount.downto(2) do |num|\noriginal_num = rotate_rightmost_digits(original_num, num)\nend\noriginal_num\nend",
"def max_rotation(nums)\n digits = nums.digits.reverse\n n = 0\n digits.size.times do\n rotated_num = digits[n..-1].shift\n digits.delete_at(n)\n digits = digits.push(rotated_num)\n n += 1\n end\n digits.join.to_i\nend",
"def rotate_rightmost_digits(number, slice)\n digits = number.to_s.chars\n digits[-slice..-1] = rotate_array(digits[-slice..-1])\n digits.join.to_i\nend",
"def rotate_rightmost_digits(number, position)\n num_array = number.to_s.chars\n remainder_digits = num_array.delete_at(-position) # delete_at is a mutating method - original object changes\n num_array << remainder_digits\n num_array.join.to_i\nend",
"def max_rotation(num)\n arr = num.digits.reverse\n 0.upto(arr.size - 1) do |i|\n sub_arr = arr[i..-1]\n rot_arr = sub_arr[1..-1] + [sub_arr[0]]\n arr[i..-1] = rot_arr\n end\n arr.join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n digits = num.to_s.chars\n digits << digits.delete_at(-n)\n digits.join.to_i\nend",
"def max_rotation(number)\n num_length = number.to_s.length\n\n while num_length > 0\n number = rotate_rightmost_digits(number, num_length)\n num_length -= 1\n end\n\n number\nend",
"def max_rotation(number)\n number_digits = number.to_s.length\n number = number.to_s.chars\n\n number_digits.times do |n|\n number[n-1..number_digits] = rotate_array(number[n-1..number_digits])\n end\n\n number.join('').to_i\nend",
"def max_rotation(num)\n arr_num = num.digits.reverse\n arr_size = arr_num.size\n counter = 0\n while counter < arr_size - 1\n curr = arr_num[counter]\n arr_num.delete_at(counter)\n arr_num << curr\n counter += 1\n end\n arr_num.join.to_i\nend",
"def max_rotation(num)\n arr = num.digits.reverse\n arrdup = arr.dup # this code works without reduces whats deleted/pushed in.\n arrdup.each_with_index do |_, idx|\n arr << arr.delete_at(idx) \n end\n arr.join.to_i\nend",
"def max_rotation(num)\n arr = num.to_s.split(\"\")\n first_rotation = arr[1..-1] + [arr[0]]\n result = first_rotation\n if arr.size == 1\n return num\n elsif arr.size == 2\n return first_rotation.join.to_i\n else\n rotation_times = first_rotation.size - 2\n\n 1.upto(rotation_times) do |i|\n rotating_digit = result.delete_at(i)\n result.push(rotating_digit)\n end\n end\n return result.join.to_i\nend",
"def max_rotation(number)\n starting_num = number.to_s.length\n starting_num.downto(2) do |digits|\n number = rotate_rightmost_digits(number, digits)\n end\n number\nend",
"def max_rotation(number)\n number_digits = number.to_s.size\n number_digits.downto(2) do |n|\n number = rotate_rightmost_digits(number, n)\n end\n number\nend",
"def max_rotation(number)\n number_digits = number.to_s.size\n number_digits.downto(2) do |n|\n number = rotate_rightmost_digits(number, n)\n end\n number\nend",
"def rotate_rightmost_digits(int, r)\n arr = int.to_s.chars\n remove = arr.delete_at(-r)\n arr << remove\n arr.join.to_i\nend",
"def max_rotation(num)\n arr_size = num.digits.size\n arr_size.times do |idx|\n sign_idx = arr_size.odd? ? idx : -idx\n num = rotate_rightmost_digits(num, sign_idx)\n end\n num\nend",
"def max_rotation(num)\n number_string = num.to_s\n\n number_string.size.downto(2) do |i|\n num = rotate_rightmost_digits(num, i)\n end\n num\nend",
"def max_rotation(num)\n arr = num.digits.reverse\n 0.upto(num.digits.size - 1) do |idx|\n arr << arr.delete_at(idx)\n end\n arr.join.to_i\nend",
"def rotations(num)\n output = [num]\n digits = num.to_s.chars\n x = digits.count - 1\n x.times do\n first = digits.shift\n rotation = digits.push(first).join(\"\").to_i\n output << rotation\n end\n output\nend",
"def max_rotation(int)\n arr_size = int.digits.size\n max_rotations = arr_size - 1\n counter = 0\n while counter < max_rotations\n position = arr_size - counter\n int = rotate_rightmost_digits(int, position)\n counter += 1\n end\n int\nend",
"def max_rotation(number)\n num_array = number.to_s.split(//)\n rotation = num_array.length\n loop do\n break if rotation == 1\n number = rotate_rightmost_digits(number, rotation)\n rotation -= 1\n end\n number\nend",
"def max_rotation(int)\n arr = int.digits.reverse\n arrdup = arr.dup # this code works without reduces whats deleted/pushed in.\n result = []\n arrdup.each.with_index do |_,idx|\n arr << arr[idx]\n arr.delete_at(idx)\n result = arr\n end\n result.join.to_i\nend",
"def rotate_rightmost_digits(number, digit)\n string_number = number.to_s\n sliced_num = string_number[-digit]\n string_number.delete!(sliced_num)\n (string_number << sliced_num).to_i\nend",
"def max_rotation(num)\n num.to_s.size.downto(2) do |rotators|\n num = rotate_rightmost_digits(num, rotators)\n end\n num\nend",
"def max_rotation(int)\n rotated = int\n count = int.digits.size\n\n until count < 2\n rotated = rotate_rightmost_digits(rotated, count)\n count -= 1\n end\n rotated\nend",
"def max_rotation(num)\n num_out = num\n num.to_s.length.downto(1) {|n|\n num_out = rotate_rightmost_digits(num_out, n)\n }\n num_out.to_i\nend",
"def max_rotation(int)\n int_digits = int.to_s.length\n rotation_iterations = int_digits - 1\n rotated_number = int\n rotation_iterations.times { |iteration| rotated_number = rotate_rightmost_digits(rotated_number, int_digits - iteration) }\n rotated_number\nend",
"def max_rotation(i)\n i_out = 0\n list = []\n while i > 0 \n list.unshift(i%10)\n i /= 10\n end\n it = list.length \n list.each{|n| i += n ; i *= 10}\n i /= 10\n while it > 0\n i_out *= 10 # add decimal place to output\n if i / (10 ** (it-1)) == 0 # determines leading zero\n i *= 10 \n it-=1 # leading zero handling\n next \n end\n i = rotate_rightmost_digits(i,it) \n i_out += i / (10 ** (it-1)) # add first digit of i to output\n i %= 10 ** (it-1)\n it -= 1 \n end\n i_out\nend",
"def max_rotation(num)\n digits = num.to_s.chars\n\n (digits.length - 1).times do |idx|\n digits << digits.delete_at(idx)\n end\n\n digits.join.to_i\nend",
"def rotate_digits2(n, pos, excluded = [])\n a = n % 10**(pos + 1)\n r = n % 10**(pos)\n 0.upto(9) do |d|\n if excluded.first == d\n excluded.shift\n next\n end\n t = n - a\n t += d* 10**(pos)\n t += r\n yield t\n end\nend",
"def max_rotation int\n final_string = ''\n string_digits = int.to_s.chars\n loop do\n string_digits = rotate_arr(string_digits)\n final_string << string_digits.shift\n break if string_digits.size < 1\n end\n final_string.to_i\nend",
"def rotate3(num)\n length = num.inspect.length\n max_rotate = rotate2(num, length)\n loop do \n length -= 1\n max_rotate = rotate2(max_rotate, length)\n break if length == 0\n end\n max_rotate\nend",
"def max_rotation(number)\n result = []\n current_number = number\n 5.times do |_|\n current_number = rotate_one_number(current_number)\n result << current_number\n end\n result\nend",
"def max_rot(n)\n result = n\n n = n.to_s.chars\n len = n.length - 1\n n.each.with_index do |_value, i|\n n.push(n[i])\n n.delete_at(i)\n temp = n.join('').to_i\n if temp > result\n result = temp\n elsif i == len\n puts result\n return result\n end\n end\nend",
"def max_rotation(int)\n arr = int.to_s.chars\n\n arr.length.times do |i|\n arr << arr[i]\n arr.delete_at(i)\n end\n arr.join(\"\").to_i\nend",
"def circular_rotations(number)\n rotations = []\n if number.to_s.size == 1\n return rotations\n end\n digits = number.to_s.split(\"\").map { |x| x.to_i }\n (number.to_s.size-1).times {\n digits << digits.shift\n rotations << digits.to_s.to_i\n }\n return rotations\nend",
"def rotate_integer(integer)\n integer.to_s.chars.rotate.join.to_i\nend",
"def max_rot(n)\n count = n.to_s.chars.count\n i = 0\n arr = []\n arr.push(n)\n \n until i == count - 1\n n = n.to_s.chars\n n = (n[0...i] + n[i..-1].rotate).join.to_i\n arr.push(n)\n i += 1\n end\n \n arr.max\nend",
"def rotate_integer(int)\r\n ans = int.to_s[1..-1] << int.to_s[0]\r\n ans.to_i\r\nend",
"def rotate_array(array, number)\n number.times{array.unshift(array.pop)}\n array\nend",
"def reverse!(array)\n n = array.length\n p array.rotate(n)\nend",
"def solution(a)\n number = a.to_s.chars\n first_arrays = []\n (number.length/2).times do\n first_arrays << number.shift\n first_arrays << number.rotate(number.length-1).shift\n number.pop\n end\n ( first_arrays + number ).join(\"\").to_i\nend",
"def RotateNumber (input)\n\tfirst = input[0]\n\tinput[0] = ''\n\tinput += first\nend",
"def rotate(arr, n)\n curr_i = new_i = 0\n temp = new_val = arr[curr_i]; \n i = 0\n while (i < arr.length)\n curr_i = new_i\n\n #compute the new index for current value \n new_i = (arr.length - (n % arr.length) + curr_i) % arr.length; \n\n #take backup of new index value \n temp = arr[new_i]\n\n #assign the value to the new index \n arr[new_i] = new_val \n\n new_val = temp\n i+=1\n end\n arr\nend",
"def rotate_array(numbers)\n numbers[1..-1] + [numbers[0]]\nend",
"def rotate_array(numbers)\n numbers[1..-1] + [numbers[0]]\nend",
"def reverse(number)\n return number if number < 10\n array = number.to_s.split(//)\n\n test_number = array.first.to_i\n new_array = array.drop(1)\n\n new_number = reverse(new_array.join.to_i)\n new_number * 10 + test_number\nend",
"def rotate_array(array,k,type=\"right\")\n puts \"Input array is\"\n p array\n reverse_array(array, 0, array.size-1)\n if type == \"right\"\n reverse_array(array,0,k-1)\n reverse_array(array,k,array.size-1)\n else\n reverse_array(array,0,k)\n reverse_array(array,k+1,array.size-1)\n end\n puts \"#{type} rotated array is\"\n p array\nend",
"def rotate_array(numbers)\n arr = []\n numbers.each { |num| arr << num }\n arr.push(numbers[0]).shift\n arr\nend",
"def rotate(nums, k)\n right_part = nums.slice(nums.length - k, k)\n left_part = nums.slice(0, nums.length - k)\n\n return right_part + left_part\n\nend",
"def rotate(input)\n input[1..-1] << input[0]\nend",
"def rotate(array, number)\n\t#put the strings we want to move into a new string\n\tnewArray = array.shift\n\t#subtract the number\n\tnumber-=1\n\t#push the strings to the back of the array\n\tarray.push(newArray)\n\t#keep doing this until our number is 0\n\trotate(array, number) unless number ==0\nend",
"def rotLeft(a, d)\n d.times do\n ele = a.shift\n a << ele\n end\n return a\nend",
"def rotate_array(arr, num)\n j = 0\n max = num\n len = arr.length - 1\n\n while j < max\n arr.unshift(arr[len])\n arr.pop()\n j += 1\n end\n return arr\n\nend",
"def my_rotate(rotation = 1)\n # debugger\n answer = []\n each_with_index { |x, i| answer[i] = x }\n if rotation > 0\n rotation.times { answer.push(answer.shift) }\n elsif rotation == 0\n answer\n else\n rotation.abs.times { answer.unshift(answer.pop) }\n end\n answer\n end",
"def rotate_integer(integer)\n string = integer.to_s\n integer = rotate_string(string)\n integer.join.to_i # 'join' to join integers and to_i to convert string to int.\nend",
"def max_rot(n)\n count = 1\n n_array = [n]\n n_chars = n.to_s.chars\n while count <= (n_chars.length - 1)\n n_chars.each_with_index do |char, index|\n n_chars.push(n_chars[index])\n n_chars.delete_at(index)\n n_array << n_chars.join.to_i\n count += 1\n end\n end\n return n_array.uniq.max\nend",
"def next_bigger(input)\n puts \"input = #{input}\"\n puts '------------------'\n puts\n puts\n\n digits = input.to_s.chars.map(&:to_i)\n\n return -1 if all_digits_are_the_same?(digits)\n\n result = input\n tail = -1\n next_tail = -1\n next_tail_digit = nil\n\n puts 'Starting iterations to find the bigger number by permutating digits from right to left...'\n puts\n while(tail.abs < digits.length && result <= input)\n next_tail = tail -1\n tail_digit = digits[tail]\n next_tail_digit = digits[next_tail]\n\n if to_number(next_tail_digit, tail_digit) > to_number(tail_digit, next_tail_digit)\n puts \"SKIPPING flipping since #{next_tail_digit}#{tail_digit} > #{tail_digit}#{next_tail_digit}\"\n else\n puts \"FLIPPING digits...\"\n puts \"digits before = #{digits}\"\n digits[tail] = next_tail_digit\n digits[next_tail] = tail_digit\n puts \"digits after = #{digits}\"\n\n result = digits.join.to_i\n\n puts \"tail = #{tail} digit = #{tail_digit}\"\n puts \"next_tail = #{next_tail} digit = #{next_tail_digit}\"\n puts \"result = #{result}\"\n end\n\n tail -= 1\n puts \"new_tail = #{tail}\"\n puts '--'\n puts ''\n end\n\n return -1 if result == input\n\n replaced_digit = next_tail_digit\n winning_digit = digits[next_tail]\n\n puts\n puts \"Iterations Completed and Bigger number found: #{result}\"\n puts \" - Digit that won was: #{winning_digit}.\"\n puts \" - It replaced the digit: #{replaced_digit} from input: #{input} at index #{next_tail}.\"\n puts\n puts \"Let see if we can make the number smaller by sorting the numbers to the right from bigger to smaller\"\n\n digits_before = digits.slice(0..next_tail)\n digits_after = digits.slice((next_tail+1)..-1)\n sorted_digits_after = sort_desc(digits_after)\n\n puts\n puts \"digits_before: #{digits_before}, digits_after: #{digits_after}\"\n puts \"Sorting digits after: #{sorted_digits_after}\"\n puts \"Resulting Number: #{array_to_number(digits_before + sorted_digits_after)}\"\n puts\n puts \"Now let see if we can find any number to the right of the winning position that\" \\\n \" is smaller than the number that won #{winning_digit} but bigger than the replaced digit #{replaced_digit}...\"\n\n index_of_digit_smaller_than_winner = sorted_digits_after.find_index { |d| d < winning_digit && d > replaced_digit }\n\n if index_of_digit_smaller_than_winner\n digit_smaller_than_the_winner = sorted_digits_after[index_of_digit_smaller_than_winner]\n puts\n puts \"We found it one! Since the array was already sorted we can trust that the one we found is the smalles one.\"\n puts \"Index: #{index_of_digit_smaller_than_winner} and number: #{digit_smaller_than_the_winner}\"\n puts \"Lets switch the winning number by this one now.\"\n puts \"Before: #{digits_before} + #{sorted_digits_after}\"\n\n digits_before[-1] = digit_smaller_than_the_winner\n sorted_digits_after[index_of_digit_smaller_than_winner] = winning_digit\n\n puts \"After: #{digits_before} + #{sorted_digits_after}\"\n puts\n puts \"We now have to sort the digits again because they may be out of order:\"\n sorted_digits_after = sort_desc(sorted_digits_after)\n puts \"After Re-Sorting: #{digits_before} + #{sorted_digits_after}\"\n puts\n end\n\n result = digits_before + sorted_digits_after\n result.join.to_i\nend",
"def rotate_array(array_of_numbers)\n rotated_array = array_of_numbers.clone\n rotated_array << rotated_array.shift\n\n rotated_array\nend",
"def rotate_array(numbers)\n new_numbers = []\n new_numbers << numbers[1,numbers.size] << numbers[0]\n new_numbers.flatten\nend",
"def rotate(nums, k)\n k.times do\n ele = nums.pop\n nums.unshift(ele)\n end\nreturn nums\nend",
"def rotate(nums, k)\n for i in 0...k\n nums.insert(0,nums.last)\n nums.pop\n end\nend",
"def reverse(number)\n return number if number.to_s.length == 1 #1 is the last number to go\n number_array = number.to_s.split(\"\")\n first_element = number_array.pop #ie 2 (from base)\n new_number = number_array.join(\"\").to_i\n recursive_call = first_element.to_s + reverse(new_number).to_s #take advantage of string concat\n\n output_string = \"\"\n number = output_string + recursive_call\n number.to_i\nend",
"def max_rot(num)\n numbers = []\n array = num.to_s.split('').map! {|x|x.to_i}\n i = 0\n while i < num.to_s.length\n array.insert(-1, array.delete_at(i))\n numbers << array.join('').to_i\n i+=1\n end\n numbers << num\n # numbers.uniq!.max\nend",
"def rotate(n=1)\n if n == 1\n @position += 1\n @rotor_array << @rotor_array.shift\n else\n n.times do\n @position += 1\n @rotor_array << @rotor_array.shift\n end\n end\n end",
"def rotate3(nums, k)\n k.times do\n nums.unshift(nums.pop)\n end\n nums\nend",
"def max_rot(n)\n answer = Array.new\n rotation = 1\n index = 0\n answer << n\n loop do\n n = (n.to_s[0, index] + (n.to_s.split(\"\").pop(n.to_s.length - rotation).join) + n.to_s[index]).to_i\n answer << n\n rotation += 1\n index += 1\n if rotation >= n.to_s.length\n break\n end\n end\n return answer.max\nend",
"def reverse(number)\n digits = number.to_s.chars\n reversed = []\n if digits.length <= 1\n number\n else\n reversed << digits.pop\n reversed << reverse(digits.join.to_i)\n reversed.join.to_i\n end\nend",
"def rotate(array,opt)\r\n\ti=0\r\n\tif opt > 0\r\n\t\twhile i < opt\r\n\t\t\tarray.unshift(array.last)\r\n\t\t\tarray.pop\r\n\t\t\ti +=1\r\n\t\t\r\n\t\tend\r\n\telsif opt < 0\r\n\t\twhile opt < i\r\n\t\t\tarray << array.first\r\n\t\t\tarray.shift\r\n\t\t\topt +=1\r\n\t\tend\r\n\tend\r\n\r\n\tarray\r\n\r\nend",
"def rotate_reverse(n = 1)\n return if self.size.zero?\n n.times { self.unshift(self.pop) }\n end",
"def solution(a, k)\n # write your code in Ruby 2.2\n \n a.rotate(-k)\nend",
"def rotate_array(k = 0, n = 10)\n new_array = Array.new(n)\n\n n.times do |i|\n next_value = i + 1\n next_index = k + i\n last_index = n - 1\n\n next new_array[(n - k - i) * -1] = next_value if last_index < next_index\n next new_array[next_index] = next_value if last_index == next_index\n\n new_array[next_index] = next_value\n end\n\n new_array\nend",
"def rotate_array(arr, num)\n num.abs.times do |i|\n if num < 0\n ele = arr.shift\n arr.push(ele)\n else\n ele = arr.pop \n arr.unshift(ele)\n end\n end\n arr\nend",
"def rotate(nums, k)\n k.times do\n el = nums.pop\n nums.unshift(el)\n end\nend",
"def rotate_array(arr, num)\n num.times do\n arr.unshift(arr.pop())\n end\n return arr\nend",
"def rotate_array(arr, num)\n\n if num == 1\n arr.unshift(arr[-1])\n arr.pop\n end\n\n if num > 1\n\n i = 0\n while i < arr.length - num\n arr.push(arr[0])\n arr.shift\n i += 1 \n end \n end\n\n return arr\nend",
"def my_rotate!(array, amt)\n\nend",
"def left_rotate_array_optimized(arr, d, n)\n \n gcd = gcd(d, n) - 1\n \n (0..gcd).each do |i|\n temp = arr[i]\n j = i\n while 1\n k = j + d\n k = k - n if k >=n\n break if k == i\n arr[j] = arr[k]\n j = k\n end\n arr[j] = temp\n end\n return arr\nend"
] |
[
"0.8391217",
"0.835978",
"0.8349933",
"0.8316089",
"0.82851315",
"0.8275841",
"0.8262235",
"0.82566714",
"0.82449263",
"0.8137147",
"0.80840546",
"0.80435205",
"0.8026875",
"0.795778",
"0.7936077",
"0.7936077",
"0.79317474",
"0.79215944",
"0.78983253",
"0.78910375",
"0.78855085",
"0.78625715",
"0.7859558",
"0.7851565",
"0.7832739",
"0.7807977",
"0.77381456",
"0.7690738",
"0.76591384",
"0.76429087",
"0.76359314",
"0.76325893",
"0.7628715",
"0.762091",
"0.75705695",
"0.75705695",
"0.7568288",
"0.75307745",
"0.7530763",
"0.7491584",
"0.7488911",
"0.7477436",
"0.7459479",
"0.7456914",
"0.7439997",
"0.73991334",
"0.7378219",
"0.7269833",
"0.72225153",
"0.71571165",
"0.71519756",
"0.7128203",
"0.7035068",
"0.7009464",
"0.70061165",
"0.69006556",
"0.6868063",
"0.68399984",
"0.68339616",
"0.68090504",
"0.6802537",
"0.676687",
"0.67291164",
"0.66596097",
"0.6657772",
"0.6649415",
"0.66331464",
"0.66331464",
"0.6576463",
"0.65578806",
"0.6551824",
"0.6551794",
"0.6539866",
"0.6520108",
"0.64871675",
"0.64848715",
"0.6484802",
"0.6477207",
"0.6471687",
"0.6458903",
"0.64488465",
"0.6420044",
"0.6417359",
"0.64149016",
"0.63850975",
"0.63846207",
"0.63625515",
"0.6339741",
"0.6331977",
"0.6330953",
"0.63276994",
"0.6321553",
"0.63202405",
"0.6320098",
"0.630722",
"0.63022804",
"0.62963605",
"0.6282529",
"0.62808406",
"0.6272611"
] |
0.82787925
|
5
|
Problem 3: ========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: If you take a number like 735291, and rotate it to the left, you get 352917. If you now keep the first digit fixed in place, and rotate the remaining digits, you get 329175. Keep the first 2 digits fixed in place and rotate again to 321759. Keep the first 3 digits fixed in place and rotate again to get 321597. Finally, keep the first 4 digits fixed in place and rotate the final 2 digits to get 321579. The resulting number is called the maximum rotation of the original number. Write a method that takes an integer as argument, and returns the maximum rotation of that argument. You can (and probably should) use the rotate_rightmost_digits method from the previous exercise. Note that you do not have to handle multiple 0s. E: max_rotation(735291) == 321579 max_rotation(3) == 3 max_rotation(35) == 53 max_rotation(105) == 15 the leading zero gets dropped max_rotation(8_703_529_146) == 7_321_609_845 D: Input an integer, output a new integer A: Create a method max_rotation that takes one integer called number Set variable number_length equal to number to string and determining the size set the number variable equal to number to string to array do the following number_length(s) of times set number equal calling rotate_array on current index to 1 return number
|
def max_rotation(number)
number_digits = number.to_s.length
number = number.to_s.chars
number_digits.times do |n|
number[n-1..number_digits] = rotate_array(number[n-1..number_digits])
end
number.join('').to_i
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def max_rotation(number)\n num_length = number.to_s.length\n\n while num_length > 0\n number = rotate_rightmost_digits(number, num_length)\n num_length -= 1\n end\n\n number\nend",
"def max_rotation(number)\n num_array = number.to_s.split(//)\n rotation = num_array.length\n loop do\n break if rotation == 1\n number = rotate_rightmost_digits(number, rotation)\n rotation -= 1\n end\n number\nend",
"def max_rotation(number)\n starting_num = number.to_s.length\n starting_num.downto(2) do |digits|\n number = rotate_rightmost_digits(number, digits)\n end\n number\nend",
"def max_rotation(number)\n number_digits = number.to_s.size\n number_digits.downto(2) do |n|\n number = rotate_rightmost_digits(number, n)\n end\n number\nend",
"def max_rotation(number)\n number_digits = number.to_s.size\n number_digits.downto(2) do |n|\n number = rotate_rightmost_digits(number, n)\n end\n number\nend",
"def max_rotation(original_num)\ncount = original_num.to_s.size\ncount.downto(2) do |num|\noriginal_num = rotate_rightmost_digits(original_num, num)\nend\noriginal_num\nend",
"def max_rotation int\n final_string = ''\n string_digits = int.to_s.chars\n loop do\n string_digits = rotate_arr(string_digits)\n final_string << string_digits.shift\n break if string_digits.size < 1\n end\n final_string.to_i\nend",
"def max_rotation(int)\n arr_size = int.digits.size\n max_rotations = arr_size - 1\n counter = 0\n while counter < max_rotations\n position = arr_size - counter\n int = rotate_rightmost_digits(int, position)\n counter += 1\n end\n int\nend",
"def max_rotation(num)\n arr = num.to_s.split(\"\")\n first_rotation = arr[1..-1] + [arr[0]]\n result = first_rotation\n if arr.size == 1\n return num\n elsif arr.size == 2\n return first_rotation.join.to_i\n else\n rotation_times = first_rotation.size - 2\n\n 1.upto(rotation_times) do |i|\n rotating_digit = result.delete_at(i)\n result.push(rotating_digit)\n end\n end\n return result.join.to_i\nend",
"def max_rotation(num)\n number_string = num.to_s\n\n number_string.size.downto(2) do |i|\n num = rotate_rightmost_digits(num, i)\n end\n num\nend",
"def max_rotation(num)\n num.to_s.size.downto(2) do |rotators|\n num = rotate_rightmost_digits(num, rotators)\n end\n num\nend",
"def max_rotation(num)\n arr = num.digits.reverse\n 0.upto(arr.size - 1) do |i|\n sub_arr = arr[i..-1]\n rot_arr = sub_arr[1..-1] + [sub_arr[0]]\n arr[i..-1] = rot_arr\n end\n arr.join.to_i\nend",
"def max_rotation(nums)\n digits = nums.digits.reverse\n n = 0\n digits.size.times do\n rotated_num = digits[n..-1].shift\n digits.delete_at(n)\n digits = digits.push(rotated_num)\n n += 1\n end\n digits.join.to_i\nend",
"def max_rotation(int)\n int_digits = int.to_s.length\n rotation_iterations = int_digits - 1\n rotated_number = int\n rotation_iterations.times { |iteration| rotated_number = rotate_rightmost_digits(rotated_number, int_digits - iteration) }\n rotated_number\nend",
"def max_rotation(num)\n num_out = num\n num.to_s.length.downto(1) {|n|\n num_out = rotate_rightmost_digits(num_out, n)\n }\n num_out.to_i\nend",
"def max_rotation(num)\n arr_size = num.digits.size\n arr_size.times do |idx|\n sign_idx = arr_size.odd? ? idx : -idx\n num = rotate_rightmost_digits(num, sign_idx)\n end\n num\nend",
"def max_rotation(int)\n rotated = int\n count = int.digits.size\n\n until count < 2\n rotated = rotate_rightmost_digits(rotated, count)\n count -= 1\n end\n rotated\nend",
"def max_rotation(num)\n digits = num.to_s.chars\n\n (digits.length - 1).times do |idx|\n digits << digits.delete_at(idx)\n end\n\n digits.join.to_i\nend",
"def max_rotation(num)\n arr = num.digits.reverse\n 0.upto(num.digits.size - 1) do |idx|\n arr << arr.delete_at(idx)\n end\n arr.join.to_i\nend",
"def max_rotation(num)\n arr_num = num.digits.reverse\n arr_size = arr_num.size\n counter = 0\n while counter < arr_size - 1\n curr = arr_num[counter]\n arr_num.delete_at(counter)\n arr_num << curr\n counter += 1\n end\n arr_num.join.to_i\nend",
"def max_rotation(i)\n i_out = 0\n list = []\n while i > 0 \n list.unshift(i%10)\n i /= 10\n end\n it = list.length \n list.each{|n| i += n ; i *= 10}\n i /= 10\n while it > 0\n i_out *= 10 # add decimal place to output\n if i / (10 ** (it-1)) == 0 # determines leading zero\n i *= 10 \n it-=1 # leading zero handling\n next \n end\n i = rotate_rightmost_digits(i,it) \n i_out += i / (10 ** (it-1)) # add first digit of i to output\n i %= 10 ** (it-1)\n it -= 1 \n end\n i_out\nend",
"def max_rotation(int)\n arr = int.to_s.chars\n\n arr.length.times do |i|\n arr << arr[i]\n arr.delete_at(i)\n end\n arr.join(\"\").to_i\nend",
"def max_rotation(num)\n arr = num.digits.reverse\n arrdup = arr.dup # this code works without reduces whats deleted/pushed in.\n arrdup.each_with_index do |_, idx|\n arr << arr.delete_at(idx) \n end\n arr.join.to_i\nend",
"def max_rot(n)\n count = n.to_s.chars.count\n i = 0\n arr = []\n arr.push(n)\n \n until i == count - 1\n n = n.to_s.chars\n n = (n[0...i] + n[i..-1].rotate).join.to_i\n arr.push(n)\n i += 1\n end\n \n arr.max\nend",
"def max_rotation(int)\n arr = int.digits.reverse\n arrdup = arr.dup # this code works without reduces whats deleted/pushed in.\n result = []\n arrdup.each.with_index do |_,idx|\n arr << arr[idx]\n arr.delete_at(idx)\n result = arr\n end\n result.join.to_i\nend",
"def rotate_rightmost_digits(num, rotate)\n rotate = rotate * -1\n num_array = num.to_s.split(//)\n rotated_arr = []\n if num_array.length > 1\n num_array.each_index do |index|\n next if num_array[index] == num_array[rotate]\n rotated_arr.push(num_array[index])\n end\n end\n rotated_arr.push(num_array[rotate])\n rotated_arr.join.to_i\nend",
"def rotate_rightmost_digits(number, rotation_digit)\n new_number = [] # hold new digit order; join; to_i\n counter = 0 # loop through digits as array of strings\n loop do\n # loop through number add all but string at rotation_digit (as number from end)\n unless number.to_s.chars[-rotation_digit].to_i == number.to_s.chars[counter].to_i\n new_number << number.to_s.chars[counter].to_i\n end\n counter += 1\n break if new_number.size == number.to_s.chars.size - 1\n end\n number.to_s.chars.select { |n| new_number << n.to_i if n == number.to_s.chars[-rotation_digit] }\n new_number.join.to_i\nend",
"def max_rot(n)\n answer = Array.new\n rotation = 1\n index = 0\n answer << n\n loop do\n n = (n.to_s[0, index] + (n.to_s.split(\"\").pop(n.to_s.length - rotation).join) + n.to_s[index]).to_i\n answer << n\n rotation += 1\n index += 1\n if rotation >= n.to_s.length\n break\n end\n end\n return answer.max\nend",
"def rotate_rightmost_digits(number, times)\n rotated_number = number.to_s.split('')\n rotated_number[(times * -1)..-1] = rotate_array(rotated_number[times*-1..-1])\n\n rotated_number.join('').to_i\nend",
"def rotate_rightmost_digits(number, n)\nall_digits = number.to_s.chars\nall_digits[-n..-1] = rotate_array(all_digits[-n..-1])\nall_digits.join.to_i\nend",
"def max_rot(n)\n result = n\n n = n.to_s.chars\n len = n.length - 1\n n.each.with_index do |_value, i|\n n.push(n[i])\n n.delete_at(i)\n temp = n.join('').to_i\n if temp > result\n result = temp\n elsif i == len\n puts result\n return result\n end\n end\nend",
"def max_rotation(number)\n result = []\n current_number = number\n 5.times do |_|\n current_number = rotate_one_number(current_number)\n result << current_number\n end\n result\nend",
"def rotate_rightmost_digits(number, n)\np all_digits = number.to_s.chars\n# all_digits[-n..-1] = rotate_array(all_digits[-n..-1])\nend",
"def rotate_rightmost_digits(number, n)\n all_digits = number.to_s.chars\n all_digits[-n..-1] = rotate_array(all_digits[-n..-1])\n all_digits.join.to_i\nend",
"def rotate_rightmost_digits(number, n)\n number_array = number.to_s.chars\n number_array[-n..-1] = rotate_array(number_array[-n..-1])\n number_array.join.to_i\nend",
"def max_rot(n)\n count = 1\n n_array = [n]\n n_chars = n.to_s.chars\n while count <= (n_chars.length - 1)\n n_chars.each_with_index do |char, index|\n n_chars.push(n_chars[index])\n n_chars.delete_at(index)\n n_array << n_chars.join.to_i\n count += 1\n end\n end\n return n_array.uniq.max\nend",
"def max_rot(num)\n numbers = []\n array = num.to_s.split('').map! {|x|x.to_i}\n i = 0\n while i < num.to_s.length\n array.insert(-1, array.delete_at(i))\n numbers << array.join('').to_i\n i+=1\n end\n numbers << num\n # numbers.uniq!.max\nend",
"def rotate_rightmost_digits(number, slice)\n digits = number.to_s.chars\n digits[-slice..-1] = rotate_array(digits[-slice..-1])\n digits.join.to_i\nend",
"def rotate3(num)\n length = num.inspect.length\n max_rotate = rotate2(num, length)\n loop do \n length -= 1\n max_rotate = rotate2(max_rotate, length)\n break if length == 0\n end\n max_rotate\nend",
"def rotate_rightmost_digits_alt(number, n)\n digits = number.digits.reverse\n digits[-n..-1] = rotate_array_alt(digits[-n..-1])\n digits.join.to_i\nend",
"def rotate_rightmost_digits(number, num)\n digits = number.to_s.chars.map(&:to_i)\n index_to_rotate = digits.size - num\n digits << digits.delete_at(index_to_rotate)\n p digits.join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n num = num.digits.reverse\n rotators = num.pop(n)\n result = num + rotate_array(rotators)\n result.join.to_i\nend",
"def rotate_rightmost_digits(integer, n)\n num_arr = integer.digits.reverse\n new_arr = num_arr[0...-n] << rotate_array(num_arr[-n..-1])\n new_arr.flatten.join.to_i\nend",
"def rotate_rightmost_digits(num, digits)\n left, right = num.divmod(10**digits)\n [[left], rotate_array(right.to_s.chars)].join.to_i\nend",
"def rotate_rightmost_digits(array, n)\n input_array = array.to_s.chars\n start_index = input_array.length - n\n sub_array = input_array[start_index..-1]\n sub_array_rotated = rotate_array(sub_array)\n output = input_array[0...start_index] + sub_array_rotated\n output.join(\"\").to_i\nend",
"def rotate_rightmost_digits(num, n)\n arr = num.digits.reverse\n rotate_arr = rotate_array(arr.pop(n))\n (arr + rotate_arr).join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n arr = num.to_s.chars\n arr[-n..-1] = arr[-n..-1].rotate\n arr.join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n [num.to_s[0..-(n+1)],rotate_array(num.to_s[-n..-1])].flatten.join('').to_i\nend",
"def rotate_rightmost_digits(long_number, n)\n return long_number if n == 1\n arr = long_number.to_s\n (arr[0...-n] + arr[-n+1..-1] + arr[-n]).to_i\nend",
"def rotate_rightmost_digits(int, position)\n int_arr = int.digits.reverse\n shifting = int_arr.pop(position)\n int_arr.concat(rotate_array(shifting)).join.to_i\nend",
"def rotations(num)\n output = [num]\n digits = num.to_s.chars\n x = digits.count - 1\n x.times do\n first = digits.shift\n rotation = digits.push(first).join(\"\").to_i\n output << rotation\n end\n output\nend",
"def rotate_rightmost_digits(number, position)\n num_array = number.to_s.chars\n remainder_digits = num_array.delete_at(-position) # delete_at is a mutating method - original object changes\n num_array << remainder_digits\n num_array.join.to_i\nend",
"def rotate_rightmost_digits(integer, n)\n ary = integer.digits.reverse\n new_ary = Array.new(ary) # avoid mutating the original argument\n new_ary << new_ary.delete_at(-n)\n new_ary.join('').to_i\nend",
"def rotate_rightmost_digits(number, n)\n arr = number.digits.reverse\n e = arr.delete_at(-n)\n arr << e\n arr.join.to_i\nend",
"def rotate_rightmost_digits(int, r)\n arr = int.to_s.chars\n remove = arr.delete_at(-r)\n arr << remove\n arr.join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n digits = num.to_s.chars\n digits << digits.delete_at(-n)\n digits.join.to_i\nend",
"def rotate_rightmost_digits(number, n)\n array = number.to_s.split(//)\n removed_element = array[-n]\n array.slice!(-n)\n [array, removed_element].flatten.join.to_i\nend",
"def rotate_rightmost_digits(number, digit)\n string_number = number.to_s\n sliced_num = string_number[-digit]\n string_number.delete!(sliced_num)\n (string_number << sliced_num).to_i\nend",
"def rotate_rightmost_digits(num, n)\n arr = num.digits.reverse\n number = arr.delete_at(-n)\n arr.append(number).join.to_i\nend",
"def rotate_rightmost_digits(num, n)\n arr = num.digits.reverse\n number = arr.delete_at(-n)\n arr.append(number).join.to_i\nend",
"def solution(a)\n number = a.to_s.chars\n first_arrays = []\n (number.length/2).times do\n first_arrays << number.shift\n first_arrays << number.rotate(number.length-1).shift\n number.pop\n end\n ( first_arrays + number ).join(\"\").to_i\nend",
"def circular_rotations(number)\n rotations = []\n if number.to_s.size == 1\n return rotations\n end\n digits = number.to_s.split(\"\").map { |x| x.to_i }\n (number.to_s.size-1).times {\n digits << digits.shift\n rotations << digits.to_s.to_i\n }\n return rotations\nend",
"def max_number(n)\nn = n.to_s\narr = []\n n.length.times do |i|\n arr << n[i].to_i\n end\narr.sort!.reverse!\nstr= \"\"\narr.each do |i| str = str + \"#{i}\"\nend\nstr.to_i\nend",
"def max_permutation n\n min_permutation(n).to_s.reverse.ljust(4, '0').to_i\nend",
"def solution(digits)\n\tstop = digits.length - 4\n\tgo = 0\n\tlargest_number = 0\n\tindex = 0\n\n\twhile go < stop\n\t\ttest = \"\"\n\t\textra_index = index\n\t\t5.times do \n\t\t\ttest += digits[extra_index].to_s\n\t\t\textra_index += 1 \n\t\tend\n\t\tif test.to_i > largest_number\n\t\t\tlargest_number = test.to_i\n\t\tend \n\t\tindex += 1\n\t\tgo += 1 \n\tend \n\tlargest_number\nend",
"def rotate_integer(integer)\n integer.to_s.chars.rotate.join.to_i\nend",
"def solution(digits)\n digits.chars.each_cons(5).max_by(&:itself).join.to_i\nend",
"def highestProductOfConsecutiveDigits( seriesLength )\n longNum = '7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450'\n\n largestProduct = 1\n\n Range.new( 0, longNum.length - seriesLength ).each do | pos |\n slice = longNum[ pos, seriesLength ]\n newProduct = 1\n slice.each_char do | digit |\n newProduct *= digit.to_i\n end\n largestProduct = newProduct if newProduct > largestProduct\n end\n\n return largestProduct\nend",
"def revrot(str, sz)\n return '' if sz <= 0\n chunks = str.scan(/.{#{sz}}/)\n chunks.map do |chunk|\n digits = chunk.chars\n sum = digits.map { |x| x.to_i ** 3 }.inject(:+)\n sum.even? ? digits.reverse : digits.rotate\n end.join\nend",
"def rotate_integer(int)\r\n ans = int.to_s[1..-1] << int.to_s[0]\r\n ans.to_i\r\nend",
"def solution(digits)\n digits.to_s.split(\"\").each_cons(5).max.join.to_i\nend",
"def longest_sequence(num, numbers)\n\tputs \"calculating for #{num}; #{100*num / 999983}% complete\"\n\tresults = [0]\n\tleft,right = 0,0\n\tsum = numbers[0]\n\twhile numbers[left] < num\n# \t\tputs \"sum=#{sum}\"\n# \t\tputs \"real sum=#{numbers[left..right].sum}\"\n\t\tcase sum <=> num\n\t\t\twhen -1: right += 1; sum += numbers[right]\n\t\t\twhen 0: results << (right - left + 1) ; sum-= numbers[left]; left+=1\n\t\t\twhen 1: sum-= numbers[left]; left+=1\n\t\tend\n\t\t\t\t\n\tend\n\treturn results.max\nend",
"def solution(digits)\n digits.split('').each_cons(5).max.join.to_i\nend",
"def revrot(str, sz)\n return '' if sz <= 0\n # 文字数を指定して、文字列を分割する\n chunks = str.scan(/.{#{sz}}/)\n # 分割した文字列ごとに各数値の3乗の合計を計算し、偶数か奇数を判定する\n chunks.map do |chunk|\n digits = chunk.chars\n sum = digits.map {|x| x.to_i ** 3 }.inject(:+)\n sum.even? ? digits.reverse : digits.rotate\n end.join\nend",
"def sequence\r\n n = 1000000\r\n l = 1\r\n digit = 1\r\n n.times do |i|\r\n templ = collatz(i+1)\r\n if templ > l\r\n l = templ\r\n digit = i+1\r\n end\r\n end\r\n puts \"The longest sequence was #{l} from number #{digit}\"\r\nend",
"def solution(digits)\n\tlargest = (digits[0]+digits[1]+digits[2]+digits[3]+digits[4]).to_i\n\ti = 4\n\twhile i < digits.length\n\t\ttester = (digits[i-4]+digits[i-3]+digits[i-2]+digits[i-1]+digits[i]).to_i\n\t\tif tester > largest\n\t\t\tlargest = tester\n\t\tend \n\t\ti += 1\n\tend \n\tlargest\nend",
"def problem8(text)\n\tdigits = text.split('').map {|x| x.to_i }\n\t\n\treturn -1 if digits.length < 5\n\ti = 0\n\tj = 4\n\t\n\tmax = 1\n\tdigits[0..4].each do |d|\n\t\tmax *= d\n\tend\n\t\n\tmaxdigits = digits[0..4]\n\t\n\tbuffernum = max\n\twhile j < (digits.length - 1)\n\n\t\t#pop left digit\n\t\tif digits[i] == 0\n\t\t\tbuffernum = 1\n\t\t\tdigits[i+1..j].each { |x| buffernum *= x}\n\t\t\tputs buffernum\n\t\telse\n\t\t\tbuffernum /= digits[i]\n\t\tend\n\t\ti += 1\n\n\t\t#push right digit\n\n\t\tj += 1\n\t\tbuffernum *= digits[j]\n\t\tif buffernum > max\n\t\t\tmax = buffernum\n\t\t\tmaxdigits = digits[i..j]\n\t\tend\n\t\t\n\n\n\tend\n\t\n puts \"Max Product : #{max}\"\n\tputs \"Max Digits : #{maxdigits}\"\n\t\n\t\nend",
"def solution(digits)\n greatest = 0\n (0..(digits.size - 1)).each do |pos|\n num = digits[pos..pos+5].to_i\n greatest = num if num > greatest\n end\n greatest \nend",
"def solution(n)\n # write your code in Ruby 2.2\n a = n.to_s(2)\n arr = []\n if a[-1] == '1'\n arr = a.split('1')\n else\n arr = a.split('1')\n arr.pop\n end\n if arr.max.nil?\n 0\n else\n arr.max.length\n end\nend",
"def findLongestSeq(maxNum)\r\n i = 1\r\n startSeq = 0\r\n maxLength = 0\r\n \r\n while ( i <= maxNum)\r\n cLength = getSequenceLength(i)\r\n \r\n if (cLength > maxLength)\r\n maxLength = cLength\r\n startSeq = i\r\n end\r\n $seqLengthArray[i] = cLength\r\n i += 1\r\n end\r\n \r\n return getCollatzSequence(startSeq)\r\nend",
"def RotateNumber (input)\n\tfirst = input[0]\n\tinput[0] = ''\n\tinput += first\nend",
"def GetLargestPalindromic\r\n @product = 0\r\n \r\n @size.downto(1) { |i|\r\n @size.downto(1) { |j|\r\n @product = i * j\r\n \r\n if IsPalindromic(@product)\r\n puts \"Largest Palindromic = #{@product}\"\r\n return\r\n end\r\n }\r\n }\r\n\r\n puts \"Largest Palindromicaa = #{@product}\"\r\n end",
"def revrot(str, sz)\n return \"\" if sz == 0 || sz > str.length\n out = \"\"\n str.split(\"\").each_slice(sz).to_a.each do |i|\n return out if i.length < sz\n if i.reduce(0){ |sum,e| sum + (e.to_i)**3 } % 2 == 0 \n out += i.reverse!.join\n else\n out += i.rotate!.join\n end\n end\n out\nend",
"def longest_digit_run(digit)\nend",
"def longest_increasing_subsequence(nums) len = nums.length\n return len if len < 2\n\n# After calculating lis for each index, take a max by 1 value equal to max, go backwards on lis array, and every time we find an element equal to max, we add that element to result and decrement max by 1. Hereby we'll get the indexes array in reversed order.\n lis_array = find_lis_lengths(nums)\n\n result = []\n max = lis_array.max\n i = len - 1\n while i >= 0\n if lis_array[i] == max\n result.unshift(nums[i])\n max -= 1\n end\n i-= 1\n end\n result\n\nend",
"def next_bigger(input)\n puts \"input = #{input}\"\n puts '------------------'\n puts\n puts\n\n digits = input.to_s.chars.map(&:to_i)\n\n return -1 if all_digits_are_the_same?(digits)\n\n result = input\n tail = -1\n next_tail = -1\n next_tail_digit = nil\n\n puts 'Starting iterations to find the bigger number by permutating digits from right to left...'\n puts\n while(tail.abs < digits.length && result <= input)\n next_tail = tail -1\n tail_digit = digits[tail]\n next_tail_digit = digits[next_tail]\n\n if to_number(next_tail_digit, tail_digit) > to_number(tail_digit, next_tail_digit)\n puts \"SKIPPING flipping since #{next_tail_digit}#{tail_digit} > #{tail_digit}#{next_tail_digit}\"\n else\n puts \"FLIPPING digits...\"\n puts \"digits before = #{digits}\"\n digits[tail] = next_tail_digit\n digits[next_tail] = tail_digit\n puts \"digits after = #{digits}\"\n\n result = digits.join.to_i\n\n puts \"tail = #{tail} digit = #{tail_digit}\"\n puts \"next_tail = #{next_tail} digit = #{next_tail_digit}\"\n puts \"result = #{result}\"\n end\n\n tail -= 1\n puts \"new_tail = #{tail}\"\n puts '--'\n puts ''\n end\n\n return -1 if result == input\n\n replaced_digit = next_tail_digit\n winning_digit = digits[next_tail]\n\n puts\n puts \"Iterations Completed and Bigger number found: #{result}\"\n puts \" - Digit that won was: #{winning_digit}.\"\n puts \" - It replaced the digit: #{replaced_digit} from input: #{input} at index #{next_tail}.\"\n puts\n puts \"Let see if we can make the number smaller by sorting the numbers to the right from bigger to smaller\"\n\n digits_before = digits.slice(0..next_tail)\n digits_after = digits.slice((next_tail+1)..-1)\n sorted_digits_after = sort_desc(digits_after)\n\n puts\n puts \"digits_before: #{digits_before}, digits_after: #{digits_after}\"\n puts \"Sorting digits after: #{sorted_digits_after}\"\n puts \"Resulting Number: #{array_to_number(digits_before + sorted_digits_after)}\"\n puts\n puts \"Now let see if we can find any number to the right of the winning position that\" \\\n \" is smaller than the number that won #{winning_digit} but bigger than the replaced digit #{replaced_digit}...\"\n\n index_of_digit_smaller_than_winner = sorted_digits_after.find_index { |d| d < winning_digit && d > replaced_digit }\n\n if index_of_digit_smaller_than_winner\n digit_smaller_than_the_winner = sorted_digits_after[index_of_digit_smaller_than_winner]\n puts\n puts \"We found it one! Since the array was already sorted we can trust that the one we found is the smalles one.\"\n puts \"Index: #{index_of_digit_smaller_than_winner} and number: #{digit_smaller_than_the_winner}\"\n puts \"Lets switch the winning number by this one now.\"\n puts \"Before: #{digits_before} + #{sorted_digits_after}\"\n\n digits_before[-1] = digit_smaller_than_the_winner\n sorted_digits_after[index_of_digit_smaller_than_winner] = winning_digit\n\n puts \"After: #{digits_before} + #{sorted_digits_after}\"\n puts\n puts \"We now have to sort the digits again because they may be out of order:\"\n sorted_digits_after = sort_desc(sorted_digits_after)\n puts \"After Re-Sorting: #{digits_before} + #{sorted_digits_after}\"\n puts\n end\n\n result = digits_before + sorted_digits_after\n result.join.to_i\nend",
"def max_sequence(arr)\n return 0 if arr.empty?\n\n max_ending_here = max_so_far = 0\n \n arr.each do |n|\n max_ending_here = [n, max_ending_here + n].max\n max_so_far = [max_so_far, max_ending_here].max\n end\n \n max_so_far\nend",
"def rotations(x)\n\t digits = x.to_s.chars\n\t digits.map do\n\t digits.rotate!.join.to_i\n\t end\n\tend",
"def rotate_array_fe(input)\n if input.is_a?(String)\n rotate_array(input.chars).join\n elsif input.is_a?(Integer)\n rotate_array(input.to_s.chars).join.to_i\n else \n rotate_array(input)\n end\nend",
"def least_rotation(x)\n s = x + x # Concatenate arrays to it self to avoid modular arithmetic\n f = [-1] * s.length # Failure function\n k = 0 # Least rotation of array found so far\n\n (1...s.length).each do |j|\n sj = s[j]\n i = f[j - k - 1]\n\n while i != -1 && sj != s[k + i + 1]\n if sj < s[k + i + 1]\n k = j-i-1\n end\n\n i = f[i]\n end\n\n if sj != s[k + i + 1]\n if sj < s[k]\n k = j\n end\n \n f[j - k] = -1\n else\n f[j - k] = i + 1\n end\n end\n\n return k\n end",
"def longest_zig_zag(array)\n puts \"Given array: #{array}\"\n las_array = Array.new(array.size){Array.new}\n las_array[0][0] = array[0] # LIS of array of size 0 would be just that element\n for i in 1..array.size-1\n for j in 0..i-1\n \n if array[j] < array[i] && lis_array[i].size < lis_array[j].size + 1 # Have the longest matching subsequence from before.\n lis_array[i] = Array.new(lis_array[j])\n end\n end\n lis_array[i] << array[i]\n end\n i = 0\n max_seq_size = 0\n lis_array.each do |lis_row|\n max_seq_size = lis_row.size if lis_row.size > max_seq_size\n puts \"Longest substring until array position #{i}: #{lis_row}\"\n i += 1\n end\n puts \"longest increasing sequence size: #{max_seq_size}\"\nend",
"def longest_sequence_in(string)\n arr = string.split(' ').map{|num| num.to_i}\n if arr.length < 3\n return arr.length\n end\n chain_tracker = [2]\n increment = arr[1] - arr[0]\n chain = 2\n arr.each_with_index do |num, idx|\n if idx != 0 and idx != arr.length - 1\n if arr[idx + 1] - arr[idx] == increment \n chain += 1\n chain_tracker << chain\n else \n chain = 2\n increment = arr[idx + 1] - arr[idx]\n end\n end\n end\n chain_tracker.max\nend",
"def rotate_integer(integer)\n string = integer.to_s\n integer = rotate_string(string)\n integer.join.to_i # 'join' to join integers and to_i to convert string to int.\nend",
"def maxNumber(num)\n \n num.digits.sort {|a,b| b <=> a}.join.to_i\n \nend",
"def rotations(string)\n #array = string.split(//)\n #array2 = array.map {|element| }\n\n return (0...string.length).map { |i| (string * 2)[i, string.length] }\n\nend",
"def largest_palindrome(num_of_digits)\r\n\tmax_number_string = \"\"\r\n\tnum_of_digits.times { max_number_string += \"9\"}\r\n\tmax_product = max_number_string.to_i ** 2\t\t# e.g: 999* 999 = 998001\r\n\t\r\n\tsub_string = (max_product.to_s)[0..(max_product.to_s).length/2 - 1]\r\n\tsub_string_number = sub_string.to_i \r\n\t\r\n\tdelta = 1\r\n\tdelta.upto(sub_string_number) { |x|\r\n\t\tpalindrome = ((sub_string_number - x).to_s + (sub_string_number - x).to_s.reverse).to_i\r\n\t\t\r\n\t\tfactor = sub_string_number\r\n\t\tfactor.downto(10**(num_of_digits - 1)) { |div|\r\n\t\t\treturn div, (palindrome/div) if (palindrome % div == 0) and (palindrome/div).to_s.length == num_of_digits\r\n\t\t}\r\n\t}\r\nend",
"def find_longest(arr)\n longest_num = 0 # current longest number\n most_digits = 0 # current most digits found in a number in the array\n\n arr.each do |num|\n digits_in_num = num.to_s.length\n if digits_in_num <= most_digits # if length of the current number is <= longest number yet - next\n next\n else # but if length is > than any other number we have seen yet -\n longest_num = num # set this num as new longest_num\n most_digits = digits_in_num # set the length of this num as the new standard to compare against\n end\n end\n longest_num\nend",
"def solution(n)\n binary_n = convert_to_binary(n)\n current, longest = 0, 0\n seen_start_one = false\n seen_end_one = false\n\n binary_n.each_char do |c|\n if c == \"0\"\n current += 1\n longest = [longest, current].max\n else\n current = 0\n end\n end\n\n longest\nend",
"def next_bigger_num(num)\r\n digits = num.digits\r\n sorted_digits = digits.sort { |a, b| b <=> a }\r\n if digits.count(digits[0]) == digits.size || digits.size < 2 || sorted_digits == digits.reverse\r\n return -1\r\n end\r\n \r\n permutation = digits.permutation.to_a.map do |sub_arr|\r\n sub_arr.join('').to_i\r\n end\r\n \r\n sorted_permutation = permutation.sort\r\n \r\n sorted_permutation.each do |current_num|\r\n return current_num if current_num > num\r\n end\r\nend",
"def solution(a)\n \n max = 0\n # write your code in Ruby 2.2\n max if a.nil? || a.length == 0\n \n if a.length < 4\n max = 1\n a.each do |item|\n max = max * item\n end\n max\n end\n \n # order first => nlogn + left and right edge max three\n a.sort!\n \n # - - -\n # + + +\n if a[0] >= 0 || a[-1] <= 0 || a[1] >= 0\n max = a[-1] * a[-2] * a[-3]\n max\n end\n \n # n = 4\n max = a[0] * a[1] * a[2]\n max = [max,a[0] * a[1] * a[-1]].max\n max = [max,a[0] * a[-2] * a[-1]].max\n max = [max,a[-3] * a[-2] * a[-1]].max\n max\n end"
] |
[
"0.8793686",
"0.8762939",
"0.86702144",
"0.86198914",
"0.86198914",
"0.8599965",
"0.858693",
"0.8564013",
"0.85540897",
"0.8495103",
"0.84926724",
"0.84751904",
"0.8443711",
"0.8422142",
"0.84191316",
"0.8414584",
"0.83999455",
"0.8377612",
"0.8309676",
"0.8299562",
"0.80673873",
"0.8048666",
"0.7985344",
"0.7834649",
"0.7833749",
"0.78093415",
"0.7808044",
"0.77986336",
"0.7795114",
"0.7742318",
"0.7663365",
"0.7629318",
"0.7557019",
"0.75554407",
"0.74825376",
"0.7468574",
"0.7466675",
"0.74431825",
"0.7421578",
"0.7391301",
"0.73647183",
"0.7315973",
"0.72769135",
"0.72181785",
"0.7207521",
"0.71925336",
"0.71764755",
"0.7149355",
"0.71170264",
"0.7108966",
"0.7103963",
"0.7080086",
"0.69764227",
"0.69669646",
"0.6903497",
"0.6898754",
"0.6880336",
"0.6877514",
"0.68224865",
"0.68224865",
"0.6789914",
"0.64856994",
"0.6451911",
"0.63868576",
"0.6374565",
"0.6369758",
"0.63377815",
"0.6330854",
"0.63168997",
"0.6240984",
"0.62000895",
"0.6197451",
"0.61871964",
"0.6184455",
"0.6182147",
"0.61812574",
"0.61292976",
"0.6127128",
"0.60859585",
"0.60555834",
"0.60177267",
"0.600903",
"0.6008407",
"0.6007996",
"0.5999317",
"0.5996062",
"0.5994075",
"0.59867775",
"0.5984868",
"0.5984337",
"0.5980097",
"0.59733665",
"0.5963022",
"0.5962097",
"0.5957623",
"0.5952539",
"0.5948883",
"0.5948126",
"0.5947691",
"0.5937386"
] |
0.87507695
|
2
|
Problem 4: ========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: You have a bank of switches before you, numbered from 1 to n. Each switch is connected to exactly one light that is initially off. You walk down the row of switches and toggle every one of them. You go back to the beginning, and on this second pass, you toggle switches 2, 4, 6, and so on. On the third pass, you go back again to the beginning and toggle switches 3, 6, 9, and so on. You repeat this process and keep going until you have been through n repetitions. Write a method that takes one argument, the total number of switches, and returns an Array that identifies which lights are on after n repetitions. Example with n = 5 lights: round 1: every light is turned on round 2: lights 2 and 4 are now off; 1, 3, 5 are on round 3: lights 2, 3, and 4 are now off; 1 and 5 are on round 4: lights 2 and 3 are now off; 1, 4, and 5 are on round 5: lights 2, 3, and 5 are now off; 1 and 4 are on The result is that 2 lights are left on, lights 1 and 4. The return value is [1, 4]. With 10 lights, 3 lights are left on: lights 1, 4, and 9. The return value is [1, 4, 9]. D: Input an integer, output results A: create a method light_sequence that takes one argument an integer called n set variable lights equal to an empty hash iterate from 1 to n adding the value of each iteration as keys to lights and the value as "on" display message "round 1: every light is turned on" do the following n number of times iterate through the lights variable if the key is a multiple of the current iteration index then set the value to "off" if is on and "on" if it is off display message "round [current iteration]: lights [list lights off] are now off; [list lights on] are on"
|
def light_sequence(n)
lights = {}
n.times {|num| lights[num+1] = "on"}
n.times do |num|
lights.each do |light, status|
if light % (num+1) == 0
lights[light] == "on" ? lights[light] = "off" : lights[light] = "on"
end
end
end
lights.select {|light, status| status == 'off'}.keys
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def light_switches(n)\n light_hash = {}\n 1.upto(n) { |i| light_hash[i] = true }\n 2.upto(n) do |current_pass|\n light_hash.map do |light, state|\n light_hash[light] = !state if light % current_pass == 0\n end\n end\n lights_left_on = light_hash.select do |_, state|\n state\n end\n result = []\n lights_left_on.to_a.flatten.each_with_index do |element, index|\n result << element if index.even?\n end\n result\nend",
"def light_switches(n)\n all_lights = (1..n).to_a\n final_lights = []\n\n all_lights.each do |index|\n next final_lights = all_lights if index == 1\n\n lights = all_lights[(index - 1)..]\n\n lights.each do |light|\n next unless light % index == 0\n\n if final_lights.include?(light)\n final_lights -= [light]\n else\n final_lights += [light]\n end\n end\n end\n\n final_lights.sort\nend",
"def switch_lights(n)\n switches = Array.new(n, 'off')\n divisor = 1\n until divisor > switches.size\n switches.each_with_index do |light, indx|\n light_number = indx + 1\n if (light_number % divisor).zero?\n switches[indx] = 'on' if light == 'off'\n switches[indx] = 'off' if light == 'on'\n end\n end\n divisor += 1\n end\n switches\nend",
"def switches(n)\n lights = Array.new(n) { |el| el = false }\n\n 1.upto(n) do |i|\n lights = lights.map.with_index do |light, idx|\n (idx + 1) % i == 0 ? !light : light\n end\n end\n\n lights_on = []\n lights.each_with_index do |light, idx|\n lights_on << (idx + 1) if light\n end\n\n lights_on\nend",
"def light_switches(num)\n lights_arr = []\n 1.upto(num) do |n|\n lights_arr.push([n, true])\n end\n\n 2.upto(num) do |n|\n lights_arr.each do |light|\n light[1] = !light[1] if light[0] % n == 0\n end\n end\n\n lights_on = []\n lights_arr.each do |arr|\n lights_on << arr[0] if arr[1]\n end\n return lights_on\nend",
"def lights(num)\n switches = Array.new(num, false)\n num.times do |n|\n switches = switches.each_with_index.map do |el, i|\n if ((i + 1) % (n + 1)).zero?\n !el\n else\n el\n end\n end\n end\n switches.each_with_index.map { |el, i| i + 1 if el }.select { |el| el }\nend",
"def light_switch(count)\n light_array = (1..count).to_a\n light_hash = {}\n light_array.each do |light|\n light_hash[light] = 'on'\n end\n\n 2.upto(count) do |number|\n light_hash.each do |light, status|\n if light % number == 0\n status == 'off' ? light_hash[light] = 'on' : light_hash[light] = 'off'\n end\n end\n end\n p light_hash\nend",
"def light_switcher(lights)\n 1.upto(lights.size) do |light_num|\n 1.upto(lights.size) do |num|\n if num % light_num == 0\n lights[num] == \"off\" ? lights[num]=\"on\" : lights[num]=\"off\"\n end\n end\n end\n lights\nend",
"def toggle_lights(number_of_lights)\n # initialize the lights hash\n lights = {}\n 1.upto(number_of_lights) do |num|\n lights[num] = false\n end\n # toggle every nth light in the lights hash\n 1.upto(number_of_lights) do |num|\n lights.each do |position, state|\n lights[position] = !state if position % num == 0\n end\n end\n # return list of light numbers that are on\n lights.select { |_position, state| state == true }.keys\nend",
"def lights_on(n)\n lights_on = []\n lights = [*1..n]\n counter = 1\n\n while counter <= n\n lights.each do |light|\n if light % counter == 0\n lights_on.include?(light) ? lights_on.delete(light) : lights_on << light\n end\n end\n counter += 1\n end\n\n lights_on\nend",
"def light1000(num)\n lights = []\n counter = 1\n\n num.times { |i| lights << false} # initalize lights\n\n while counter <= num\n light_switcher(lights, counter)\n counter += 1\n end\n\n lights\nend",
"def lights(n)\n arr = Array.new(n, false)\n n.times do |count|\n arr.each_with_index { |element, idx| arr[idx] = !element if (idx + 1) % (count + 1) == 0}\n end\n result =[]\n arr.each_with_index { |element, idx| result << idx+1 if element }\n result\nend",
"def light_switch(number)\n on_arr = []\n counter = 0\n\n until counter == number\n counter += 1\n\n for num in (counter..number)\n on_arr << num if num % counter == 0\n end\n on_arr.each{ |elem| on_arr.delete(elem) if on_arr.count(elem) > 1 }\n end\n \n on_arr.sort\nend",
"def toggle_lights(n)\n multipled_substring = []\n\n (1..n).each do |count|\n multiplier = 1\n\n loop do\n product = count * multiplier\n break if product > n\n multipled_substring << product\n multiplier += 1\n end\n end\n #multipled_substring\n\n final_result = []\n (1..n).each do |number|\n times_of_toggle = multipled_substring.count(number)\n \n final_result << number if times_of_toggle.odd?\n end\n p final_result\nend",
"def get_on_lights(n)\n lights = initialize_lights(n)\n print_lights_state(lights) unless n > 10\n\n 1.upto(n) do |round|\n toggle_every_nth_light!(lights, round)\n print_lights_state(lights, round) unless n > 10\n end\n\n on_lights(lights)\nend",
"def toggle_switches(n)\n arr = *(1..n) #[1, 2, 3..n]\n hsh = Hash.new\n arr.each { |num| hsh[num] = false } #{1=>true, 2=>true, 3=>true..}\n counter = 0\n\n until counter == arr.length\n counter += 1\n arr.each { |n| hsh[n] = !hsh[n] if n % counter == 0 }\n end\n\n hsh.select {|k, v| v == true }.keys\nend",
"def switch_lights(lights_hash)\n 1.upto(lights_hash.length) do |count|\n lights_hash.each do |light_num, position|\n if light_num % count == 0\n lights_hash[light_num] == 'off' ? lights_hash[light_num] = 'on' : lights_hash[light_num] = 'off'\n end \n end\n end\nend",
"def switch_lights(final)\n lights = {}\n (1..final).each {|num| lights[num] = false}\n (1..final).each do |interval|\n lights.each {|key, value| lights[key] = !value if key % interval == 0}\n end\n lights.select {|_, value| value}.keys\nend",
"def thousand_lights4(n)\n lights = [false]*n\n 1.upto(n) { |i| i.step(n, i) { |j| lights[j] = !lights[j] } }\n lights.each_with_index.with_object([]) { |(light, idx), obj| obj << idx if light }\nend",
"def flip_switcher(n)\n switch_bank = []\n n.times { switch_bank << false }\n switches_on = []\n counter = 1\n\n loop do\n break if counter > switch_bank.length\n\n switch_bank.each_with_index do | switch, position |\n switch_bank[position] = !switch if (position + 1) % counter == 0\n end\n counter += 1\n end\n # Not quite rigth because I want to push the index not the actual object\n switch_bank.each.with_index do |switch, idx|\n switches_on << idx + 1 if switch == true\n end\n switches_on\nend",
"def on_lights(number)\n arr = Array.new(number, false)\n 1.upto(number) do |round|\n 1.upto(number) do |mult|\n arr[mult-1] = !arr[mult-1] if mult%round == 0\n end\n end\n arr\nend",
"def off(switches)\n #code here\n switch_arr = []\n result = []\n\n switches.times do \n switch_arr << \"O\"\n end\n\n switch_arr\n\n x = 0\n z = 2\n\n while x < switches do \n y = z - 1\n\n while y < switches do \n if switch_arr[y] == \"O\"\n switch_arr[y] = \"o\"\n else\n switch_arr[y] = \"O\"\n end\n y += z\n end\n\n x += 1\n z += 1\n end\n\n j = 0\n while j < switch_arr.length do \n if switch_arr[j] == \"O\"\n result << j + 1\n end\n j += 1\n end\n\n result\nend",
"def on_switches(total_switches)\n switches = {}\n (1..total_switches).each { |num| switches[num] = false }\n\n (1..total_switches).each do |number|\n (number).step(by:number, to: total_switches) do |num|\n switches[num] = !switches[num]\n end\n end\n\n switches.select { |_, switch_on| switch_on }.keys\nend",
"def toggle_lights(number_of_lights)\n lights = initialize_lights(number_of_lights)\n 1.upto(lights.size) do |iteration_number|\n toggle_every_nth_light(lights, iteration_number)\n end\n \n p \"Lights #{joinor(on_lights(lights))} are on\"\n p \"Lights #{joinor(off_lights(lights))} are off\"\nend",
"def toggle(lights)\n\n # Using the #upto method, we're able to iterate through each round\n 1.upto(lights.size) do |round_number|\n\n # Next we want to toggle each light off and on\n lights.each do |position, value|\n if position % round_number == 0\n\n # We use a ternary operator here\n # If the current light has a value of \"off\", then the value\n # is set to \"on\".\n value == \"off\" ? lights[position] = \"on\" : lights[position] = \"off\"\n end\n end\n end\nend",
"def thousand_lights(n)\n lights = Array.new(n, false)\n n.times do |num|\n lights.map!.with_index do |light, index|\n if (index + 1) % (num + 1) == 0\n !light\n else\n light\n end\n end\n end\n lights.map.with_index {|element, index| (index + 1) if element}.compact\nend",
"def toggle_every_nth_light(lights, nth) # works for 1st, 2nd, 3rd, etc for all cases\n lights.each do |position, state| # for each key-value pair\n if position % nth == 0 # if position hits what the nth selection criteria is\n lights[position] = (state == \"off\") ? \"on\" : \"off\" # then switch is flipped\n end\n end\nend",
"def thousand_lights3(n)\n lights = {}\n 1.upto(n) { |i| lights[i] = false }\n 1.upto(n) { |i| i.step(n, i) { |j| lights[j] = !lights[j] } }\n lights.keys.select { |idx| lights[idx] }\nend",
"def lights_hash(n, lamps)\n hash = Hash.new { |h, k| h[k] = [] }\n \n lamps.each do |lamp|\n\n end\n\n hash\nend",
"def initialize_lights(number_of_lights)\n lights = Hash.new # initialize new hash\n 1.upto(number_of_lights) { |number| lights[number] = \"off\" } # initially all lights are off\n lights # return hash\nend",
"def thousand_lights(n)\n lights = Array.new(n, false)\n 1.upto(n) do |num|\n lights.map!.with_index do |value, index|\n if (index + 1) % num == 0\n !value\n else\n value\n end\n end\n end\n lights.map!.with_index { |value, index| value = (index + 1) if value }.compact\nend",
"def toggle(switches)\n 1.upto(1000) do |step|\n switches.map do |switch_num, on_or_off|\n if switch_num % step == 0\n switches[switch_num] = !on_or_off\n end\n end\n end\nend",
"def thousand_light(n)\n bulbs = initialize_bulb(n)\n 1.upto(n) do |sequence|\n toggle(bulbs, sequence)\n end\n lights_on(bulbs)\nend",
"def initialize_lights(number_of_lights)\n lights = {}\n (1..number_of_lights).each { |number| lights[number] = false }\n lights\nend",
"def initialize_lights(number_of_lights)\n lights = Hash.new\n 1.upto(number_of_lights) { |number| lights[number] = \"off\" }\n lights\nend",
"def initialize_lights(number_of_lights)\n lights = Hash.new\n 1.upto(number_of_lights) { |number| lights[number] = \"off\" }\n lights\nend",
"def initialize_lights(number_of_lights)\n lights = Hash.new\n 1.upto(number_of_lights) { |number| lights[number] = \"off\" }\n lights\nend",
"def toggle_lights(number_of_lights)\n lights = initialize_lights(number_of_lights)\n 1.upto(lights.size) do |iteration_number|\n toggle_every_nth_light(lights, iteration_number)\n end\n\n on_lights(lights)\nend",
"def toggle_lights(number_of_lights)\n lights = initialize_lights(number_of_lights)\n 1.upto(lights.size) do |iteration_number|\n toggle_every_nth_light(lights, iteration_number)\n end\n\n on_lights(lights)\nend",
"def toggle_every_nth_light(lights, nth)\n lights.each do |position, state|\n if position % nth == 0\n lights[position] = (state == 'off') ? \"on\" : \"off\"\n end\n end\nend",
"def toggle_every_nth_light(lights, nth)\n lights.each do |position, state|\n if position % nth == 0\n lights[position] = (state == \"off\") ? \"on\" : \"off\"\n end\n end\nend",
"def toggle_every_nth_light(lights, nth)\n lights.each do |position, state|\n if position % nth == 0\n lights[position] = (state == \"off\") ? \"on\" : \"off\"\n end\n end\nend",
"def lAS(n: 0)\n array = [1]\n puts \"#{array.inspect}\"\n previous = array.first\n new_array = []\n counter = 0\n \n n.times do\n previous = array.first\n counter = 0\n new_array = []\n \n array.each do |element|\n if(element == previous)\n counter = counter + 1\n else\n new_array << counter\n new_array << previous\n counter = 1\n previous = element\n end\n end\n \n new_array << counter\n new_array << previous\n array = new_array.dup\n puts \"#{array.inspect}\"\n end\nend",
"def thousand_switches(integer)\n array = Array.new(integer, false)\n 1.upto(integer) do |n|\n array.map!.with_index do |element, index| \n if (index + 1) % n == 0\n !element\n else\n element\n end\n end\n end\n output = []\n array.each_with_index {|element, index| output << (index + 1) if element == true }\n output\nend",
"def initialize_lights(lights)\n lights_hash = {}\n 1.upto(lights) {|key_num| lights_hash[key_num] = false}\n lights_hash\nend",
"def part2(moons = INPUT, turns = 3000)\n seen = {}\n\n (0...turns).each do |turn|\n (0...4).each do |i|\n ((i + 1)...4).each do |j|\n moons[i].velocity_change += (moons[i].position.gravity(moons[j].position))\n moons[j].velocity_change += (moons[j].position.gravity(moons[i].position))\n end\n end\n\n moons.each do |moon|\n moon.adjust_state\n #print_state(moons, turn)\n end\n\n hash = moons.map(&:to_a).reduce(&:+).hash\n if seen.has_key?(hash)\n puts \"seen in #{turn} turns\"\n return\n end\n seen[hash] = 1\n #print_state(moons, turn)\n if turn % 1000 == 0\n puts \"#{turn}\"\n end\n end\n\n\n end",
"def create_lights(number)\n lights = Array.new(number + 1, \"on\")\nend",
"def on_lights(lights)\n lights.keys.select { |key| lights[key] == \"on\" }\n\n# This code will return an array of light positions, which light gets\n# chosen for our new array determined whether lights[key] == \"on\" is TRUE.\nend",
"def light_switcher(array, inc)\n counter = 0\n\n while counter < array.length\n array[counter] = !array[counter] if (counter + 1) % inc == 0\n counter += 1\n end\n\n array\nend",
"def solution1(seeds)\n turn_map = {}\n seeds.each_with_index { |n, turn| turn_map[n] = [1, turn + 1, turn + 1] }\n last_number = seeds.last\n\n ((seeds.length+1)..2020).each do |turn|\n last_stats = turn_map[last_number]\n if last_stats[TIMES_SPOKEN] == 1\n zero = turn_map[0] || [0, turn, turn]\n zero[TIMES_SPOKEN] += 1\n zero[FIRST_SPOKEN] = zero[LAST_SPOKEN]\n zero[LAST_SPOKEN] = turn\n \n turn_map[0] = zero\n last_number = 0\n else\n age = last_stats[LAST_SPOKEN] - last_stats[FIRST_SPOKEN]\n\n num = turn_map[age] || [0, turn, turn]\n num[TIMES_SPOKEN] += 1\n num[FIRST_SPOKEN] = num[LAST_SPOKEN]\n num[LAST_SPOKEN] = turn\n \n turn_map[age] = num\n last_number = age\n end\n end\n\n last_number\nend",
"def GetChangeCombos(n, c)\n ways = Array.new(n+1,0)\n ways[0] = 1\n c.select!{|c| c<n}\n return 0 if (c.empty?)\n for coin in c\n for amount in coin..n\n ways[amount] =ways[amount] + ways[amount - coin]\n end \n end\n ways[n]\nend",
"def cats_in_hats\n # your code here\n hats = Array.new(100, false) # hat status of 100 cats\n result = [] # result array contains indices of cats with hats\n \n # iterate 100 rounds of visiting cats\n (0..99).each do |j|\n round = j+1\n i = j\n while i < 100\n if hats[i] == true\n hats[i] = false\n else\n hats[i] = true\n end\n i += round\n end\n end\n \n \n hats.each_with_index do |h, i|\n result << i+1 if h == true\n end\n result\nend",
"def counterGame(n)\n # Write your code here\n pows = [1]\n pows.push(pows[-1] * 2) until pows[-1] >= n\n\n turn = 0\n\n until n == 1\n target_pow_i = pows.find_index { |p| p >= n }\n target_pow = pows[target_pow_i]\n if n == target_pow\n n /= 2\n else\n n -= pows[target_pow_i - 1]\n end\n\n turn += 1\n end\n\n turn.odd? ? 'Louise' : 'Richard'\nend",
"def toggle_on_or_off(lights)\n 1.upto(lights.size) do |round_number|\n lights.each do |position, value|\n if position % round_number == 0\n value == \"off\" ? lights[position] = \"on\" : lights[position] = \"off\"\n end\n end\n end\nend",
"def monty_hall(door_picked, switch_doors)\n # ? door_picked => which door is initially selected\n # ? switch_doors => will the user switch doors, boolean\n\n # * door_picked == 1\n # * if switch_doors => true, then output = 1\n # * if switch_doors => false, then output = 3\n # * door_picked > 1\n # * if switch_doors => true, then output = 2\n # * if switch_doors => false, then output = 4\n \n scen_one = (door_picked == 1 && !switch_doors)\n scen_two = (door_picked > 1 && switch_doors)\n scen_three = (door_picked == 1 && switch_doors)\n scen_four = (door_picked > 1 && !switch_doors)\n\n # ? Output => \n # * 1: Success w/ no switch\n # * 2: Success w/ switch\n # * 3: Failure w/ no switch\n # * 4: Failure w/ switch\n \n if scen_one\n output = 1\n elsif scen_two\n output = 2\n elsif scen_three\n output = 3\n else scen_four\n output = 4\n end\n\n output\n \nend",
"def flip_switches(num)\n i = num\n until i >= $switches.length\n $switches[i] = !$switches[i]\n i += num\n end\nend",
"def break_chocolate(n, m)\n breaks = 0\n breaks += (n-1)\n n.times do |pieces|\n breaks += (m-1)\n end\n breaks\nend",
"def state x, y, m, n, board\n old_state = board[ x ][ y ]\n live_count = 0\n (x-1..x+1).each { |i|\n (y-1..y+1).each { |j|\n if i == x and j == y\n next\n end\n if 0 <= i and i < m and 0 <= j and j < n\n if wasLive board[ i ][ j ]\n live_count = live_count + 1\n end\n end\n }\n }\n if wasLive old_state\n if live_count == 2 or live_count == 3\n new_state = 1\n else\n new_state = 2\n end\n else\n if live_count == 3\n new_state = 3\n else\n new_state = 0\n end\n end\n new_state\nend",
"def getWays(n, c)\n # i = n or change needed\n # j = enabled coins\n # dp[i][j] = dp[i - j's coin value][j] + dp[i][j - 1]\n store = [[1] * c.length]\n\n (1..n).each do |i|\n c.length.times do |j|\n sum_one = i - c[j] >= 0 ? store[i - c[j]][j] : 0\n sum_two = j - 1 >= 0 ? store[i][j - 1] : 0\n store[i] = [] unless store[i]\n store[i][j] = sum_one + sum_two\n end\n end\n\n store.last.last\nend",
"def sequence(hidden, open)\n weight = { 1 => \"A\", 2 => \"2\", 3 => \"3\", 4 => \"4\", 5 => \"5\", 6 => \"6\", 7 => \"7\", 8 => \"8\", 9 => \"9\", \n 10 => \"T\", 11 => \"J\", 12 => \"Q\", 13 => \"K\" }\n i = 0\n result = []\n inputs = 1\n differ = 0\n if weight.key(hidden[i]) > weight.key(hidden[i+2])\n small = weight.key(hidden[i+2])\n big = weight.key(hidden[i])\n differ = big - small\n elsif weight.key(hidden[i]) < weight.key(hidden[i+2])\n small = weight.key(hidden[i])\n big = weight.key(hidden[i+2])\n differ = big - small\n else\n return false\n end\n return false if differ > 4\n if differ > 1\n start = small + 1\n end1 = big - 1\n start.upto(end1) do |j|\n open.each_index do |k|\n if open[k] == weight[j]\n unless result.include? weight[j]\n result << open[k]\n result << open[k+1]\n inputs += 1\n end \n end \n end \n end\n end\n return false unless differ == inputs \n if result.size < 6\n steps = (6-result.size)/2\n start = big + 1\n end1 = big + steps\n start.upto(end1) do |j|\n open.each_index do |k|\n if open[k] == weight[j]\n unless result.include? weight[j]\n result << open[k]\n result << open[k+1]\n end \n end \n end \n end\n if result.size < 6\n steps = (6-result.size)/2\n return false if small - steps < 1 \n start = small - steps\n end1 = small - 1\n start.upto(end1) do |j|\n open.each_index do |k|\n if open[k] == weight[j]\n unless result.include? weight[j]\n result << open[k]\n result << open[k+1]\n end \n end \n end \n end\n return false if result.size < 6\n end\n end \n result \n end",
"def climb_stairs(n)\n table = Array.new(45) { 0 }\n table[0] = 1\n table[1] = 2\n\n table.each_with_index do |_val, i|\n next if i < 2\n table[i] = table[i - 1] + table[i - 2]\n end\n\n table[n-1]\nend",
"def lemonade_change(bills)\n hash = {\n 5 => 0,\n 10 => 0,\n 20 => 0\n }\n \n bills.each do |bill|\n hash[bill] += 1\n if bill != 5\n change = bill - 5\n \n until change == 0\n if change >= 20\n if hash[20] > 0\n hash[20] -=1\n change -= 20\n elsif hash[10] > 0\n hash[10] -=1\n change -= 10\n elsif hash[5] > 0\n hash[5] -=1\n change -= 5\n else\n return false\n end\n elsif change >= 10\n if hash[10] > 0\n hash[10] -=1\n change -=10\n elsif hash[5] > 0\n hash[5] -=1\n change -= 5\n else\n return false\n end\n elsif change >= 5\n if hash[5] > 0\n hash[5] -=1\n change -= 5\n else\n return false\n end\n end\n end\n \n end\n end\n true\nend",
"def hamming(n)\n base, seen, twos, threes, fives = 0, [1], [], [], []\n m = 1\n\n until n == 1\n twos << seen[base] * 2\n threes << seen[base] * 3\n fives << seen[base] * 5\n\n o = m\n until m != o\n m = [twos, threes, fives].min_by(&:first).shift\n end\n\n n -= 1\n base += 1\n seen << m\n end\n\n m\nend",
"def series_up(n) # Got help again. My first code couldn't adapt at all. This one has a reset limit, meaning it loops the amount of times it needs to for each interger. Still not perfect, but almost there. \n list = [1]\n i = 1\n length = n*(n+1)/2\n reset = 3\n list.push i\n i += 1\n if i == reset\n reset += 1\n end\n return list\nend",
"def paint_fence(n, k)\n total = k;\n \n #There are 0 ways for single post to\n #violate (same color_ and k ways to\n #not violate (different color)\n same = 0, diff = k;\n \n #Fill for 2 posts onwards\n i = 2\n while i <= n\n #Current same is same as previous diff\n same = diff;\n\n #We always have k-1 choices for next post\n diff = total * (k-1);\n\n #Total choices till i.\n total = (same + diff);\n i += 1\n end\n\n total\nend",
"def solution(m, a)\n n = a.count\n result = 0\n front = 0\n numbers = Array.new(m + 1, false)\n n.times { |back|\n while front < n and not numbers[a[front] - 1]\n numbers[a[front] - 1] = true\n front += 1\n result += front - back\n return 1_000_000_000 if result >= 1_000_000_000\n end\n numbers[a[back] - 1] = false\n }\n result\nend",
"def getWays(n, c)\n # Write your code here\n w = n\n m = c.length\n dp = Array.new(m+1){Array.new(w+1)}\n 0.upto(m) do |i|\n dp[i][0] = 1\n end\n 0.upto(w) do |j|\n dp[0][j] = 0\n end\n 1.upto(m) do |i|\n 1.upto(w) do |j|\n x = j-c[i-1] >= 0 ? dp[i][j-c[i-1]] : 0\n y = j >= 1 ? dp[i-1][j] : 0\n dp[i][j] = x+y\n end\n end\n p dp\n dp[m][w]\nend",
"def diagonalCount(n)\n\n#First number saved as \"start.\"\"\nstart = n**2\n\n#Solution is the variable to which we add all elements of the diagonals.\nsolution = 0\n\n#Increment is the gap between elements of diagonals. \nincrement = n - 1\n\n#The first loop continues until start == 1.\nwhile start > 1\n\n#The number of diagonal elements for each \"increment.\"\nk = 4\n\n#The second, nested loop, which repeats four times for each increment\n#and adds the diagonal entries (stored in the \"start\" variable)\n#to solution.\nwhile k > 0\nsolution += start\nstart -= increment\nk -= 1\nend\n\n#After each sequence of 4 entries, we subtract two from the increment\n#variable to add the diagonal elements in the next \"square\" within the\n#grid.\nincrement -= 2\n\nend\n\n#After the final loop is complete, start will equal 1, but will not\n#have been added to solution. The final step is to add 1 and output\n#the solution.\n\nputs solution + 1\n\nend",
"def sockMerchant(n, ar)\n color_hash = {}\n pairs = 0\n\n ar.each do |color|\n if color_hash[color] \n color_hash[color] += 1\n else\n color_hash[color] = 1\n end\n end\n\n color_hash.each do |key, value|\n pairs += value / 2\n end\n\n pairs\nend",
"def sockMerchant(n, ar)\n hash = Hash.new(0)\n pares = Array.new\n ar.each{|key| hash[key] += 1}\n #puts hash\n hash.each do |ky, t|\n if t - 1 > 0\n t % 2 == 0 ? pares << t/2 : pares << (t-1)/2\n end\n end\n pares.length > 0 ? \"Result: #{pares.reduce(:+)}\" : 0\nend",
"def initialize_hash(num)\n (1..num).each_with_object(lights = {}) do |number, hash|\n hash[number] = false\n end\n lights\nend",
"def sockMerchant(n, ar)\n color_bin = {}\n ar.each do |x|\n if color_bin[x] == nil\n color_bin[x] = 1\n else\n color_bin[x]+=1\n end\n end\n pairs = 0\n color_bin.each do |k,v|\n pairs += v/2\n end\n return pairs\nend",
"def sequencer(num)\n array = []\n array << num\n until array.last == 1\n if num%2 == 0 \n num = num/2\n array << num \n else \n num = num*3 + 1\n array << num \n end \n end\n return array.length\nend",
"def solve( n = 16 )\n max = 0\n \n (1..10).each do |a|\n (1..10).each do |b|\n next if b == a\n (1..10).each do |c|\n next if c == b || c == a\n (1..10).each do |d|\n next if d == c || d == b || d == a\n (1..10).each do |e|\n next if e == d || e == c || e == b || e == a\n\n rotate = 3*[a, b, c, d, e].each_with_index.min[1]\n (1..10).each do |f|\n next if f == e || f == d || f == c || f == b || f == a\n (1..10).each do |g|\n next if g == f || g == e || g == d || g == c || g == b || g == a\n \n t = a + f + g\n (1..10).each do |h|\n next if h == g || h == f || h == e || h == d || h == c || h == b || h == a\n next unless t == b + g + h\n\n (1..10).each do |i|\n next if i == h || i == g || i == f || i == e || i == d || i == c || i == b || i == a\n next unless t == c + h + i\n\n (1..10).each do |j|\n next if j == i || j == h || j == g || j == f || j == e || j == d || j == c || j == b || j == a\n next unless t == d + i + j && t == e + j + f\n\n s = [a, f, g, b, g, h, c, h, i, d, i, j, e, j, f]\n rotate.times {s.push s.shift}\n\n s = s.join\n next if n != s.length\n\n max = [max, s.to_i].max\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n\n max\n end",
"def process(num_blacks, num_whites) \r\n if (!@zero_response_code_found)\r\n # we can only get blacks during this phase of all 4's same color however we will count them later during mask phase\r\n # keep track of number of exact matches\r\n if num_blacks > 0\r\n # save for later processing when we go to half/half mode\r\n @safe_array << @current_color\r\n #puts \"color_count[#{@current_color}] = #{@color_count[@current_color]}\"\r\n #puts \"AA\"\r\n else\r\n @zero_response_code_found = true\r\n @half_half_color = @current_color\r\n #puts \"BB\"\r\n end # if num_blacks\r\n else\r\n if @num_correct_colors_found < 4\r\n #puts \"SEARCHING FOR FINAL 4\"\r\n if @three_of_a_kind_check\r\n# need to worry about 3 and 4 of a kind scenario\r\n# during find zero-response phase - if we encounter 3 or 4 of a kind, we need to set a flag, perhaps my hash is doing that\r\n# or modify the hash.\r\n# but then the problem comes about after finding the zero-response, during the finding the half-half phase. during this\r\n# phase it is not possible to determine if there are 3 or 4 of a kind due to the arrangemnet of the pattern.\r\n# one way to solve this for both zero-response phase and half-half phase is by having another 3 of a kind safe array\r\n# if during zero-response phase, we encounter 4 of a kind. game will auto end?\r\n# if during zero-response phase, we encounter 3 of a kind, then submit color into three_of_a_kind array and into safe_array\r\n# to be used later by guess method. guess will normally count the 2 on the right side, but not count the left. the \r\n# three_of_a_kind array and the half_half_left mode will count the 1 remaining color of a three of a kind\r\n# if during half-half phase, we encounter 2 of a kind(specifically, 2 blacks, or 1 black/1 white, but not 2 whites, process\r\n# will normally count the 2 colors. However there is a chance that there is a 3rd occurrence of the color that we can not see\r\n# due to the half-half-right pattern. Therefore we need to add the color to the three_of_a_kind array which causes guess to\r\n# change the pattern to\r\n# [color, color, no-response-color, no-response-color]\r\n\r\n# process needs to compensate for double counting whites (only count blacks) during 3_of_a_kind_check and for double\r\n# counting doubles. (only count blacks when blacks+whites=3, whites have already been counted, and when blacks+whites==2,\r\n# this scenario has already been counted)\r\n\r\n# I need to save the state of the initial three_of_a_kind compare in order to determine how to count the three of a kind\r\n# correctly.\r\n #puts \"THREE OF A KIND CHECK IN PROCESS method\"\r\n previous_num_blacks, previous_num_whites = @half_half_result[@current_color]\r\n if previous_num_blacks == 2\r\n #puts \"PREVIOUS_NUM_BLACKS == 2\"\r\n @num_correct_colors_found += num_blacks\r\n num_blacks.times { @match_left << @current_color }\r\n elsif previous_num_blacks == 1 && previous_num_whites == 1\r\n # for this case we need to make sure we don't double count\r\n #puts \"PREV BLACKS==1 && PREV WHITES==1\"\r\n if num_blacks == 2\r\n @num_correct_colors_found += 1\r\n @match_left << @current_color\r\n end\r\n end\r\n #puts \"Num of blacks = #{num_blacks} Previous num blacks = #{previous_num_blacks}\"\r\n #puts \"Num of whites = #{num_whites} Previous num whites = #{previous_num_whites}\"\r\n # always get out of three of a kind mode\r\n @three_of_a_kind_check = false\r\n\r\n else # if @three_of_a_kind_check\r\n # add to running total of found numbers so we can get to next phase of algo\r\n @num_correct_colors_found += (num_blacks + num_whites) ##### THIS WILL NEED TO CHANGE WHEN THREE OF A KIND LOGIC ADDED\r\n\r\n # following section is used in half-half section either by processing\r\n # new colors or by processing old colors from the safe array\r\n # if found blacks we found it on the right and update color_count for current_color\r\n # officially counting blacks and whites are only done while in half-half mode\r\n # note that safe_array take dequeue priority when it is not empty. see guess above\r\n if num_blacks > 0\r\n num_blacks.times { @match_right << @current_color } \r\n end\r\n # if found whites we found it on the left and update color_count for current_color \r\n if num_whites > 0\r\n num_whites.times { @match_left << @current_color } \r\n end \r\n # this info is necessary when doing the reverse half_half compare to see if there are three/four of a kind\r\n @half_half_result[@current_color] = [num_blacks, num_whites]\r\n # during this phase we can't know if there are 2 or 3 of the current color, so we need to do a reverse_half_half\r\n # check if there are 2 blacks or (1 black + 1 white)\r\n @three_of_a_kind_check_array << @current_color if (num_blacks == 2 || (num_blacks==1 && num_whites==1))\r\n #puts \"CC\"\r\n end # if @three_of_a_kind_mode else\r\n else\r\n # Scenarios are as follows for final code\r\n # L1,L2,R1,R2 \r\n # (4W) -> L2,L1,R2,R1\r\n # (2W2B) -> L1,L2,R2,R1 or L2,L1,R1,R2\r\n # (0W) -> pattern found\r\n #puts \"DD\"\r\n @final_four_whites = num_whites # used by guess\r\n\r\n end\r\n\r\n end # if !@zero_response...\r\n\r\n end",
"def sockMerchant(n, ar)\nsock_colors = Hash.new { | hash, key | hash[key] = 0 }\n\nar.each { | color | sock_colors[color] += 1 }\n\npairs = 0\nsock_colors.each_value { | sock_count | pairs += (sock_count / 2) }\n\nputs pairs\nreturn pairs\n\nend",
"def playerTurn(a)\n \ninitMatrix (a)\npaintMatrix (a)\nplayer = 1\nstop = false\ncounterTie = 0\n\t\n\twhile (!stop)\n\t\t\tcounterTie = counterTie + 1\n\t\t\tinsertNumber(a,player)\n\t\t\tpaintMatrix(a)\n\n\t\t\tif(player == 1)\n\t\t\t\tif(checker(a, player))\n\t\t\t\tputs \"Player #{player} wins\".yellow\n\t\t\t\tputs\"\"\n\t\t\t\tstop = true\n\t\t\t\tend\n\t\t\t\tplayer = player + 1\n\t\t\telse\n\t\t\t\tif(checker(a, player))\n\t\t\t\tputs \"Player #{player} wins\".yellow\n\t\t\t\tputs\"\"\n\t\t\t\tstop = true\n\t\t\t\tend\n\t\t\t\tplayer = player - 1\n\t\t\tend\n\t\t\t\tif(counterTie == a.length**2)\n\t\t\t\tstop = true\n\t\t\t\tputs \"TIE\".yellow\n\t\t\t\tputs\"\"\n\t\t\t\tend\n\tend \nend",
"def series_up(n)\n new_list=[] # to push into a new list\n (n + 1).times do |index| #You need the nested loop index.times to run at least once. Since Index starts at 0, you need to add 1 so that it runs at least once\n index.times do |value| # this runs the loop each time until it reaches the number needed\n new_list.push(value + 1) #Same as the loop above. Since the value starts at 0, you need to start at 1 bc that's what the challenge wants you to do. the .push pushes it into the new list \n end \n end \n return new_list # this makes the function print the newly created list\nend",
"def countLights(matrix)\n\tlitLights = 0\n\n\tfor i in 0..999\n\t\tfor j in 0..999\n\t\t\tlitLights += matrix[i,j]\n\t\tend\n\tend\n\n\treturn litLights\nend",
"def on_lights(lights)\n lights.select { |position, state| state == \"on\" }.keys\nend",
"def series_up(n)\n #nlist is the list that will be the output of the code\n nlist = []\n #i changed from an if statement to a loop.\n (n*(n+1)/2+1).times do |i|\n i.times do |x|\n nlist.push(x+1)\n end\n end\n #I use three dots to only get the information i need from the code\n return nlist[0...(n*(n+1)/2)].to_a\nend",
"def on_lights(lights)\n lights.select { |_position, state| state == \"on\" }.keys\nend",
"def on_lights(lights)\n lights.select { |_position, state| state == \"on\" }.keys\nend",
"def on_lights(lights)\n lights.select { |_position, state| state == \"on\" }.keys\nend",
"def advance(state)\n newState = Hash.new(false)\n for x in 1..$size\n for y in 1..$size\n neighbours = get_neighbours(x, y, state)\n if state[[x, y]]\n newState[[x, y]] = true if neighbours == 2 or neighbours == 3\n else\n newState[[x, y]] = true if neighbours == 3\n end\n end\n end\n return newState\nend",
"def climb_stairs(n)\n memo =[]\n climbStairs(n, memo)\nend",
"def hard(input)\n to = input / 10\n houses = Array.new(to, 0)\n (1..to).each do |n|\n count = 0\n n.step(by: n, to: to - 1) do |i|\n houses[i] += 11 * n\n count += 1\n break if count == 50\n end\n end\n houses.index { |count| count >= input }\nend",
"def freed_prisoners(arr)\n counter = 0\n return counter if arr[0] == 0\n arr.each do |cell|\n if cell == 1\n counter += 1\n arr.map! do |switch|\n if switch == 1\n switch = 0\n else\n swith = 1\n end\n end\n else\n next\n end\n end\n counter\nend",
"def diamond_array_sequence(number)\n array = []\n 1.upto(number) do |n|\n if n.odd?\n array << n\n end\n end\n array\nend",
"def climb_stairs(steps)\n return steps if steps <= 2\n cache = {}\n cache[1] = 1\n cache[2] = 2\n 3.upto(steps) do |n|\n cache[n] = cache[n - 2] + cache[n - 1]\n end\n cache[steps]\nend",
"def phase_one\n puts \"Get ready to start Part 1.\".light_grey\n puts \"Each Tribe will participate in an immunity challenge.\".light_grey\n puts \"The losing Tribe will then vote someone off the island.\".light_grey\n 8.times do \n\t#Sets variable for tribe loser of immunity challege\n\tlosing_tribe = @borneo.immunity_challenge \n\tputs \"#{losing_tribe} \".red + \"has lost the challenge and will vote someone off the island.\"\n\t#Losing tribe holds tribal council and votes off member\n\tmember_voted_off = losing_tribe.tribal_council\n\tputs \"Sadly, \" + \"#{member_voted_off} \".green + \"has been voted off the island.\"\n end\nend",
"def sockMerchant(n, ar)\n count = {}\n ar.collect do |colour|\n if count[colour] == nil\n count[colour] = 1\n else\n count[colour] += 1\n end\n end\n total_pairs = 0\n count.collect do |key, value|\n total_pairs += (value / 2).floor\n end\n p total_pairs\nend",
"def get_cycle x\r\n count = 0\r\n while (x > 1)\r\n case\r\n when x[0] == 0 #even\r\n count += 1\r\n x = x/2\r\n when x[0] == 1 #odd\r\n count += 2\r\n x = ((3*x + 1)/2)\r\n end\r\n end\r\n count += 1\r\nend",
"def hamming_weight(n)\n total_ones = 0\n until n.zero?\n n &= (n - 1)\n total_ones += 1\n end\n total_ones\nend",
"def solution(a)\n # write your code in Ruby 2.2 \n frecuencies = a.each_with_object(Hash.new(0)) { |key, value| value[key] += 1 } \n \n frecuencies.each do |key, value|\n if value.odd? then return key end\n end\nend",
"def recycle\n recycling = true\n while recycling \n while @total_caps >= 4 \n recycle_caps\n end\n while @empty_bottles >= 2 \n recycle_bottles\n end\n if @empty_bottles < 2 && @total_caps < 4 \n recycling = false\n end\n end\nend",
"def ghost_mutations_determination(roll)\n case roll\n when 1..4\n @@ghost_mutations << \"Advanced Mind\"\n when 5..6\n @@ghost_mutations << \"Agony Sphere\"\n when 7..8\n @@ghost_mutations << \"Asphyxiation Zone\"\n when 9..10\n @@ghost_mutations << \"Aura of Protection\"\n when 11\n @@ghost_mutations << \"Breath Holding\"\n when 12..13\n @@ghost_mutations << \"Coma Inducement\"\n when 14..15\n @@ghost_mutations << \"Devastator Pulse\"\n when 16..17\n @@ghost_mutations << \"Displacement \"\n when 18..19\n @@ghost_mutations << \"Doom Sphere\"\n when 20..21\n @@ghost_mutations << \"Dread Zone\"\n when 22..23\n @@ghost_mutations << \"Earth Thump\"\n when 24..27\n @@ghost_mutations << \"Electrical Pulse\"\n when 28..30\n @@ghost_mutations << \"Electro MagneticPulse\"\n when 31..37\n @@ghost_mutations << \"Empathy\"\n when 38..41\n @@ghost_mutations << \"Energy Blade\"\n when 42..45\n @@ghost_mutations << \"Force Field\"\n when 46..51\n @@ghost_mutations << \"Heal Touch\"\n when 52..56\n @@ghost_mutations << \"Heat Pulse\"\n when 57..58\n @@ghost_mutations << \"Image Multiplication\"\n when 59..60\n @@ghost_mutations << \"Image Projection\"\n when 61..62\n @@ghost_mutations << \"Light Burst\"\n when 63..64\n @@ghost_mutations << \"Mental Mine\"\n when 65..67\n @@ghost_mutations << \"Mental Screen\"\n when 68..79\n @@ghost_mutations << \"Mind Crush\"\n when 80..81\n @@ghost_mutations << \"Mind Waste\"\n when 82..83\n @@ghost_mutations << \"Peeling Radius\"\n when 84..85\n @@ghost_mutations << \"Radiation Detection\"\n when 86\n @@ghost_mutations << \"Radioactive Pulse\"\n when 87\n @@ghost_mutations << \"Reserve Heart\"\n when 88..89\n @@ghost_mutations << \"Reserve Mind\"\n when 90\n @@ghost_mutations << \"Sonic Wave Radius\"\n when 91\n @@ghost_mutations << \"Stun Ray\"\n when 92..96\n @@ghost_mutations << \"Telekinesis\"\n when 97..00\n @@ghost_mutations << \"Telepathy\"\n end\nend",
"def wizards_trial()\n\n\t#Initialize hats and gnomes\n\thats = [\"red\", \"white\"]\n\tgnomes = [\"one\", \"two\", \"three\", \"four\", \"five\", \"six\", \"seven\", \"eight\", \"nine\", \"ten\"]\n\n\t#Line up gnomes and place hats on them\n\thatted_gnomes = {}\n\tgnomes.each do |gnome|\n\t\thatted_gnomes[gnome] = hats.sample\n\tend\n\n\t#Have gnomes guess which color hats they have on\n\tguesses = gnome_guesses(hatted_gnomes)\n\n\t#Judge the gnomes\n\tjudge_the_gnomes(guesses, hatted_gnomes)\n\nend",
"def solve(n, s, d, m)\n # Complete this function\n records = s;\n\n (1...n).each do |i|\n records[i] += records[i-1]\n end\n\n numberOfWays = (m <= n && records[m - 1] == d) ? 1 : 0;\n\n (m...n).each do |i|\n if records[i] - records[i - m] == d\n numberOfWays += 1\n end\n end\n\n numberOfWays\n\nend",
"def icecreamParlor(m, arr)\n # Complete this function\n res = []\n arr.each_index do |i|\n if i + 1 !=nil\n j = i + 1\n while j <= arr.length - 1\n if arr[i]+arr[j] == m\n res.push([i+1,j+1])\n end\n j+=1\n end\n end\n end\n res\nend"
] |
[
"0.792712",
"0.7749223",
"0.7739923",
"0.7692745",
"0.76643014",
"0.74957013",
"0.7375937",
"0.7313735",
"0.72194535",
"0.71955246",
"0.7178645",
"0.71327615",
"0.6890177",
"0.6886227",
"0.687644",
"0.67687666",
"0.67145634",
"0.668294",
"0.6666244",
"0.6658966",
"0.6572849",
"0.65397966",
"0.6539404",
"0.653054",
"0.650769",
"0.643047",
"0.6409798",
"0.6383454",
"0.62187076",
"0.62151194",
"0.6206078",
"0.6203882",
"0.61831313",
"0.617346",
"0.6094224",
"0.6094224",
"0.6094224",
"0.60757565",
"0.60757565",
"0.6046254",
"0.60441446",
"0.60441446",
"0.59645665",
"0.5959861",
"0.5914252",
"0.58938605",
"0.5859193",
"0.58446735",
"0.5794922",
"0.5743413",
"0.5726471",
"0.56783956",
"0.5640213",
"0.56121564",
"0.56092876",
"0.56086564",
"0.5601532",
"0.556912",
"0.5554926",
"0.5529301",
"0.5521553",
"0.55185086",
"0.545942",
"0.545178",
"0.5441571",
"0.5441317",
"0.54395294",
"0.5422",
"0.5402771",
"0.53870106",
"0.538671",
"0.5376971",
"0.53762734",
"0.5371981",
"0.53714055",
"0.5366121",
"0.5365283",
"0.536366",
"0.5360288",
"0.53366643",
"0.5332756",
"0.5327228",
"0.5327228",
"0.5327228",
"0.5323059",
"0.5313458",
"0.5288129",
"0.5274492",
"0.52736235",
"0.52541363",
"0.5247465",
"0.5240663",
"0.52369297",
"0.5232828",
"0.5224582",
"0.5216547",
"0.5216006",
"0.5215234",
"0.5211289",
"0.52103496"
] |
0.78218555
|
1
|
Problem 5: ========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: Write a method that displays a 4pointed diamond in an n x n grid, where n is an odd integer that is supplied as an argument to the method. You may assume that the argument will always be an odd integer. E: diamond(9) D: input an integer, output display a diamond A: create a method called triangle that takes one argument an integer called num set variable stars equal to an empty array set variable spaces equal to zero push num stars to stars variable iterate through num to 3 on each iteration push spaces plus star times current iteration 2 to the variable stars add one to spaces return stars array create method diamond that takes one argument an integer num puts triangle(num) puts triangle(num) reversed
|
def triangle(num)
stars = []
spaces = ''
number_of_stars = (3..num).to_a.reverse
current_num = num
loop do
spaces += ' '
stars << spaces + ("*" * current_num)
break if current_num == 1
current_num -= 2
end
stars.reverse
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def diamond(num)\n raise ArgumentError, 'Odd number must be supplied' unless num.odd?\n\n i = 1\n middle = num / 2 + 1\n space_each_side = middle - 1\n\n while i <= num\n num_diamond = num - space_each_side * 2\n puts ' ' * space_each_side + '*' * num_diamond + ' ' * space_each_side\n if i < middle\n space_each_side -= 1\n elsif i > middle\n space_each_side += 1\n end\n i += 1\n end\nend",
"def diamond(n)\n s = \"\"\n odd_array = (1..n).select{|num| num.odd?}\n odd_array = odd_array + odd_array.reverse[1..-1]#1,3,5,7,9,7,5,3,1\n (0...n).each do |i| #0,1,2,3,4,5,6,7,8\n empty_spaces = n/2\n odd_array[i].times do |j|#1,3,5,7,9,7,5,3,1\n s = (\" \" * (empty_spaces-i).abs) + (\"*\" * (j+1)) + (\" \" * (empty_spaces-i).abs)\n end\n p s\n s=\"\"\n end\nend",
"def diamond(num)\n\n\treturn nil if num.even? || num < 0 \n\n\todds = (1..num).to_a.select do |num|\n\t\t num.odd?\n\t\t end\n\n\tspaces = odds.length\n\n\todds.each do |num|\n\t\tspaces -= 1\n\t\tputs ' ' * spaces + '*' * num + \"\\n\"\n\tend\n\n\todds.pop\n\todds.reverse!\n\n\tspaces += 1\n\n\todds.each do |num|\n\t\tputs ' ' * spaces + '*' * num + \"\\n\"\n\t\tspaces += 1\n\tend\n\nend",
"def diamond(n)\n mid = n/2\n (mid + 1).times do |i|\n puts ' '*(mid - i) + '*'*((i * 2) + 1)\n end\n (mid).times do |i|\n puts ' '*(i + 1) + '*'*(n - 2*(i+1))\n end\nend",
"def diamond(num)\n puts \"this is a #{num} diamond!\\n\\n\"\n star_count = 1\n half_point = (num.to_f/2).floor\n 0.upto(num-1) {|n|\n if n < half_point \n puts \"#{' ' * (half_point - n)}#{'*' * star_count}\"\n star_count += 2\n elsif n == half_point\n puts \"#{'*' * star_count}\"\n star_count -= 2\n elsif n > half_point\n puts \"#{' ' * (n - half_point)}#{'*' * star_count}\"\n star_count -= 2\n end\n }\n \n \" \"\nend",
"def diamond(integer)\n spaces = (1..integer).step(2).to_a\n space_line = spaces.reverse\n spaces.shift\n space_line += spaces\n space_line.map! {|num| num / 2}\n\n stars = (1..integer).step(2).to_a\n star_line = stars.reverse\n star_line.shift\n star_line = stars + star_line\n\n counter = 0\n star_line.each do |element|\n line = (\"*\" * element)\n spaces = line.length + space_line[counter]\n full_line = line.rjust(spaces) + (\" \" * space_line[counter])\n puts full_line\n counter += 1\n end\nend",
"def diamond(n, style = :solid)\n top_half = top_half(n, style)\n center = if style == :solid || n == 1\n ['*' * n]\n elsif style == :hollow\n ['*' + ' ' * (n - 2) + '*']\n else\n return puts 'Invalid style. Please enter :solid or :hollow'\n end\n bottom_half = top_half.reverse\n diamond_array = top_half + center + bottom_half\n puts diamond_array\nend",
"def diamond(n)\n (n / 2).downto(1) { |i| puts (\"*\" * (n - 2 * i)).center(n) }\n puts '*' * n\n 1.upto(n / 2) { |i| puts (\"*\" * (n - 2 * i)).center(n) }\nend",
"def diamond(n)\n rows = (1..n).select{ |num| num.odd? }\n rows.each { |row| puts \"#{'*' * row}\".center(n) }\n rows.reverse[1..-1].each { |row| puts \"#{'*' * row}\".center(n) }\nend",
"def diamond(n)\r\n return nil unless n.remainder(2) == 1\r\n diamonds = []\r\n\r\n counter = 1\r\n until counter > n\r\n spaces = (n - counter) / 2\r\n diamonds << ' ' * spaces + '*' * counter + \"\\n\"\r\n counter += 2\r\n end\r\n\r\n counter = n - 2\r\n until counter <= 0\r\n spaces = (n - counter) / 2\r\n diamonds << ' ' * spaces + '*' * counter + \"\\n\"\r\n counter -= 2\r\n end\r\n\r\n diamonds.join\r\nend",
"def diamond(num)\n spaces = (num - 1) / 2\n stars = 1\n\n loop do\n puts \" \"*spaces + \"*\"*stars + \" \"*spaces\n break if stars == num\n spaces -= 1\n stars += 2\n end\n\n unless stars == 1\n loop do\n stars -= 2\n spaces += 1\n puts \" \"*spaces + \"*\"*stars + \" \"*spaces\n break if stars == 1\n end\n end\nend",
"def diamond(n, outline_only = false)\n raise \"Input lower than '1' (#{n}) not allowed.\" if n < 1\n raise \"Even input (#{n}) is not allowed.\" if n.even?\n \n diamond = []\n increasing = true\n count = 1\n\n n.times do\n diamond << \"*\" * count\n increasing = false if count >= n\n if increasing\n count += 2\n else\n count -= 2\n end\n break if count <= 0\n end\n\n diamond = outline(diamond) if outline_only\n\n diamond.each {|e| puts e.center(n)}\n puts\nend",
"def diamond(number)\n \n empty_space = \" \" \n star = \"*\"\n \n counter_star = 1 \n counter_space = number/2\n until counter_star == number \n puts \"#{empty_space * counter_space}\" + \"#{star * counter_star}\"\n counter_star += 2\n counter_space -= 1 \n end\n \n \n while counter_star >= 1\n puts \"#{empty_space * counter_space}\" + \"#{star * counter_star}\"\n counter_star -= 2\n counter_space += 1\n end\n \nend",
"def diamond(num)\n count = 1\n stars = 1\n spaces = 1\n \n loop do\n \n puts (' ' * (num - spaces)) + ('*' * stars)\n break if count == num\n \n if count <= (num / 2)\n stars += 2\n spaces +=1\n else\n stars -= 2\n spaces -= 1\n end\n \n count += 1\n end\nend",
"def diamond(size)\n stars = 1\n # top half\n loop do\n ((size/2 + 1) - stars).times { print \" \" }\n (stars*2 - 1).times { print \"*\" }\n puts \"\"\n break if stars >= size/2\n stars += 1\n end\n return if size == 1\n # middle\n size.times { print \"*\" }\n puts \"\"\n # bottom half\n loop do\n ((size/2 + 1) - stars).times { print \" \" }\n (stars*2 - 1).times { print \"*\" }\n puts \"\"\n break if stars == 1\n stars -= 1\n end\nend",
"def diamond(size)\n stars = []\n 1.step(size, 2) { |count| stars << '*' * count }\n stars << stars.reverse[1..-1]\n\n size.times do |idx|\n puts \"#{stars.flatten[idx]}\".center(size)\n end\nend",
"def diamond(num)\n stars = 1\n \n num.times do |iteration|\n puts ('*' * stars).center(num)\n iteration < num / 2 ? stars += 2 : stars -= 2\n end\nend",
"def diamond(i) # I hope I didn't name my variables\n spaces_toggle = -1 # the same as the instruction\n spaces = i/2 # This is MY algorithm !\n bling_toggle = 1\n bling = 1\n (i).times do\n spaces.times {print \" \"} \n bling.times {print \"*\"}\n spaces.times {print \" \"} \n print \"\\n\"\n spaces += 1 * spaces_toggle\n bling += 2 * bling_toggle\n if bling == i # Center of function\n bling.times {print \"*\"}\n print \"\\n\"\n spaces += 1\n bling -= 2\n spaces_toggle = 1\n bling_toggle = -1\n end\n end\nend",
"def diamond(length)\n diamonds = (1..length).select { |num| num.odd? }\n shape_array = []\n spaces = length / 2\n length.times do |num|\n index = length / 2 - spaces.abs\n shape_array << \"#{' ' * spaces.abs}#{'*' * diamonds[index]}\"\n spaces -= 1\n end\n shape_array\nend",
"def diamond_alt(number)\n half = number / 2\n 1.upto(half) { |num| puts row(half, num) }\n (half + 1).downto(1) { |num| puts row(half, num) }\nend",
"def diamond(num)\n total = num\n iterator = 1\n until iterator > num\n puts \"#{\"*\" * iterator}\".center(total)\n iterator += 2\n end\n loop do\n num -= 2\n break if num < 0\n puts \"#{\"*\" * num}\".center(total)\n end\nend",
"def diamond(n)\n blanks = ' ' * ((n - 1) / 2)\n stars = '*'\n \n loop do\n puts blanks + stars\n break if blanks == ''\n stars << '**'\n blanks.slice!(0)\n end\n \n loop do\n break if stars == '*'\n stars.slice!(0..1)\n blanks << ' '\n puts blanks + stars\n end\n \nend",
"def diamond_enum_sol(n, full:true)\n step_one_to_n_to_one(n).each do |i|\n line = full || i == 1 ? '*' * i : '*' +' ' * (i - 2) + '*'\n puts line.center(n)\n end\nend",
"def diamond_outline(num)\n puts ''\n outer_spacer = num / 2\n inner_spacer = 0\n lines = 0\n while lines < num / 2\n if outer_spacer == num / 2\n puts ' ' * outer_spacer + '*'\n inner_spacer += 1\n else\n unless outer_spacer < 0\n puts ' ' * outer_spacer + '*' + ' ' * inner_spacer + '*'\n inner_spacer += 2\n end\n end\n outer_spacer -= 1\n lines += 1\n end\n while lines < num\n if outer_spacer < num / 2\n puts ' ' * outer_spacer + '*' + ' ' * inner_spacer + '*'\n inner_spacer -= 2\n else\n puts ' ' * outer_spacer + '*'\n inner_spacer -= 1\n end\n outer_spacer += 1\n lines += 1\n end\n puts ''\nend",
"def hollow_diamond(int)\n spaces = 1\n puts '*'.center(int)\n \n 1.upto(int - 4) do |line|\n puts ('*' + ' ' * spaces + '*').center(int)\n line > (int / 2 - 2) ? spaces -= 2 : spaces += 2\n end\n \n puts '*'.center(int)\nend",
"def triangle(num)\n spaces = num - 1\n stars = 1\n\n num.times do |n|\n puts (' ' * spaces) + ('*' * stars)\n spaces -= 1\n stars += 1\n end\n\nend",
"def triangle(num)\n spaces = num - 1\n stars = 1\n\n num.times do |n|\n puts (' ' * spaces) + ('*' * stars)\n spaces -= 1\n stars += 1\n end\nend",
"def triangle(n)\n stars = 1\n spaces = n-1\n n.times do |_|\n puts ( \" \" * spaces) + (\"*\" * stars)\n stars += 1\n spaces -= 1\n end\nend",
"def upside_down_triangle(n)\n triangle = []\n stars = n\n spaces = 0\n\n n.times do\n triangle << (' ' * spaces) + ('*' * stars)\n stars -= 1\n spaces += 1\n end\n\n triangle.each { |line| puts line }\nend",
"def triangle(integer)\n stars = 1\n integer.times do \n puts \" \" * (integer - stars) + (\"*\" * stars)\n stars += 1\n end\nend",
"def triangle(n)\n arr = []\n space = (n - 1)\n star = 1\n \n until n == 0 do\n (space).times do\n arr.push(\" \")\n end\n (star).times do \n arr.push(\"*\")\n end\n puts arr.join\n arr.clear\n space -= 1\n star += 1\n n -= 1\n end\nend",
"def diamond_array_sequence(number)\n array = []\n 1.upto(number) do |n|\n if n.odd?\n array << n\n end\n end\n array\nend",
"def diamond_full(x)\n 4.times do\n add_tip\n x.times do #Change length of side\n move\n turn_right\n move\n put_beeper\n turn_left\n end\n adjust_for_tip\n end\n end",
"def display_upper_semi_diamond(n)\n left_outline = n / 2\n right_outline = left_outline\n\n (n / 2).times do\n row = ' ' * n\n row[left_outline] = '*'\n row[right_outline] = '*'\n\n puts row\n left_outline -= 1\n right_outline += 1\n end\nend",
"def triangles(n)\n space_count = n\n star_count = 1\n\n while star_count <= n\n puts \"#{' ' * space_count}#{'*' * star_count}\"\n space_count -= 1\n star_count += 1\n end\nend",
"def star(num)\n star_number = 3\n star = '*'\n space = ' '\n counter = (num - star_number) / 2\n iterations = num / 2\n\n # upper triangle\n iterations.times do |i|\n line = \"#{space * i}#{star}#{space * counter}#{star}#{space * counter}#{star}\"\n puts line\n counter -= 1\n end\n\n # mid\n puts star * num\n\n # lower triangle\n counter = (num - star_number) / 2\n iterations.times do |i|\n line = \"#{space * counter}#{star}#{space * i}#{star}#{space * i}#{star}\"\n puts line\n counter -= 1\n end\nend",
"def tl_triangle(n)\n stars = n\n n.times do\n puts '*' * stars\n stars -= 1\n end\nend",
"def triangle(num)\n spaces = num - 1\n stars = 1\n \n loop do\n puts \" \"*spaces + \"*\"*stars\n break if stars == num\n spaces -= 1\n stars += 1\n end\nend",
"def triangle(n)\n space = \" \"\n star = \"*\"\n star_count = 1\n\n while n > 0 do\n p (space * (n-1)) + (star * star_count)\n n -= 1\n star_count += 1\n end\nend",
"def diamonds(int)\n counter = 1\n until counter == int\n space_string = ((int - counter) / 2)\n puts \"#{' ' * space_string}#{'*' * counter}#{' ' * space_string}\"\n counter += 2\n end\n puts \"#{'*' * counter}\"\n until counter == 1\n counter -= 2\n space_string = ((int - counter) / 2)\n puts \"#{' ' * space_string}#{'*' * counter}#{' ' * space_string}\"\n end\nend",
"def triangle(n)\n\tstar = \"*\"\n\tspace = \" \"\n\tcounter = 0\n\tloop do\n\t\tcounter += 1\n\t\tputs (space * (n - counter)) + (star * (n - (n - counter)))\n\t\tbreak if counter == n\n\tend\nend",
"def triangle(n)\n (1..n).each { |row| puts ' ' * (n - row) + '*' * row }\nend",
"def triangle(size, quadrant=4)\n case quadrant\n when 1\n for i in 0..size do\n puts \"*\" * (size - i) + \" \" * (i)\n end\n when 2\n for i in 0..size do\n puts \" \" * (i) + \"*\" * (size - i)\n end\n when 3\n for i in 0..size do\n puts \"*\" * (i) + \" \" * (size - i) \n end\n when 4\n for i in 0..size do\n puts \" \" * (size - i) + \"*\" * (i) \n end\n end\nend",
"def make_diamond(arr, rows)\n start = 1\n 1.upto(rows) do |iteration|\n arr << start\n iteration < (rows / 2.0).ceil ? start += 2 : start -= 2\n break if arr.length == rows\n end\n arr\nend",
"def triangle(num)\n num.times { |a| p (' ' * (num - a)) + ('*' * (a + 1)) }\nend",
"def triangle(number)\n number_of_spaces = number - 1\n number.times do\n puts (' ' * number_of_spaces) + ('*' * (number - number_of_spaces))\n number_of_spaces -= 1\n end\nend",
"def triangle(n)\n 1.upto(n){ |i| p \"#{' ' * (n-i)}#{ '*' * i }\" }\nend",
"def triangle(n)\n n.times{ |i| puts \"#{' ' * (n-i+1)}#{'*' * (i+1)}\" }\nend",
"def star(n)\n num_spaces = (n - 2) / 2\n arr = []\n until num_spaces < 0\n arr.push \"*#{' ' * num_spaces}*#{' ' * num_spaces}*\"\n num_spaces -= 1\n end \n arr += arr.reverse\n arr.insert(n / 2, \"*\" * n)\n arr.each { |x| puts x.center(n) }\nend",
"def triangle(length_of_sides)\n spaces = length_of_sides\n accum_num = length_of_sides\n length_of_sides.times do\n puts \"#{' ' * (spaces - accum_num)}#{'*' * accum_num}\"\n accum_num -= 1\n end\nend",
"def triangle(num)\n star_count = 0\n while star_count < num\n star_count += 1\n stars = \"*\" * star_count\n puts stars.rjust(num)\n end\nend",
"def triangle(num)\n count = 1\n while count <= num do\n stars = \"*\" * count\n puts \"#{(stars.rjust(num))}\"\n count += 1\n end\nend",
"def triangle(length_of_sides)\n spaces = length_of_sides\n accum_num = 1\n length_of_sides.times do\n puts \"#{' ' * (spaces - accum_num)}#{'*' * accum_num}\"\n accum_num += 1\n end\nend",
"def triangle(number)\n 1.upto(number) do |num| \n puts (\" \" * num) + (\"*\" * number)\n number -= 1\n end\nend",
"def star(n)\n outer = 0\n inner = (n-3) / 2\n\n loop do # create top\n puts \"#{\" \" * outer}*#{\" \" * inner}*#{\" \" * inner}*#{\" \" * outer}\"\n break if inner == 0\n outer += 1\n inner -= 1\n end\n\n puts \"*\" * n\n\n loop do # create bottom\n puts \"#{\" \" * outer}*#{\" \" * inner}*#{\" \" * inner}*#{\" \" * outer}\"\n break if outer == 0\n outer -= 1\n inner += 1\n end\n puts \"\"\nend",
"def triangle(num)\n space = ' '\n star = '*'\n (num + 1).times do |time|\n puts space * (num - time) + (star * time)\n end\nend",
"def print_triangle2(arg)\n array = (1..arg).to_a\n dot = []\n array.map do |num|\n dot.push(\"*\" * num)\n end\n puts dot\nend",
"def triangle(n)\n n.downto(1) do |i|\n puts \"#{'*' * i}#{' ' * (n-i)}\"\n end\nend",
"def star(n)\n x = (n - 3)/2\n loop do\n puts \"*#{' ' * x}*#{' ' * x}*\".center(n)\n x -= 1\n break if x < 0\n end\n puts \"#{'*' * n}\"\n y = 0\n loop do\n puts \"*#{' ' * y}*#{' ' * y}*\".center(n)\n y += 1\n break if y > (n - 3) / 2\n end\nend",
"def print_triangle(rows)\n n = 1\n while n <= rows\n n += 1\n x = 1\n while x < n\t\n \tprint \"*\"\n \tx += 1\n end\n puts ' '\n end \nend",
"def pyramid(height)\n height.times do |n|\n print ' ' * (height - n)\n puts '#' * (2 * n + 1)\n end\n\nend",
"def star(num)\n return puts \"number should be odd and greater than 5\" if num.even? || num < 7\n lines = (num/2).times.with_object([]) do |idx, arr|\n arr << (['*'] * 3).join(' ' * idx).center(num)\n end\n puts lines.reverse, ('*' * num), lines\nend",
"def spiral(diagonals)\n\nif diagonals % 2 == 0\n puts \"Please enter an odd number\"\nend\n\ni = 1\nsum = 0\n\nwhile i <= diagonals\n if i == 1\n sum += i\n i += 2\n end\n square = i * i\n difference = i - 1\n sum = sum + (square * 4) - (difference * 6)\n i += 2\nend\n\nsum\n\nend",
"def navidad(n)\n result = \"\"\n n.times do |ind| \n i = ind + 1 \n (n-i).times do \n result += \" \"\n end\n i.times do\n result += \"* \" \n end\n result += \"\\n\" \n end\n \n 3.times do |i|\n if i != 2\n n.times do |b|\n if (n+1)/2 == b+1\n result += \"* \"\n else\n result += \" \"\n end \n end\n result += \"\\n\"\n else\n n.times do |b| \n if ((n+1)/2)-2 == b || ((n+1)/2)-1 == b || (n+1)/2 == b\n result += \"* \"\n else\n result += \" \"\n end \n end\n end\n end \n result\nend",
"def star(n)\r\n padding_number = 0\r\n space_number = (n - 3) / 2\r\n \r\n 1.upto(n) do |row_number|\r\n central_row_number = (n / 2) + 1\r\n left_padding = ' ' * padding_number\r\n spaces = ' ' * space_number\r\n row = left_padding + (('*' + spaces) * 2) + '*'\r\n \r\n if row_number < central_row_number\r\n puts row\r\n next if row_number == central_row_number - 1\r\n padding_number += 1 \r\n space_number -= 1\r\n elsif row_number == central_row_number\r\n puts '*' * n\r\n else\r\n puts row\r\n padding_number -= 1\r\n space_number += 1\r\n end\r\n end\r\nend",
"def pyramid\r\n upper_level = \"1\"\r\n triangle = [upper_level]\r\n 40.times do\r\n triangle << upper_level = lower_level(upper_level)\r\n end\r\n triangle\r\nend",
"def print_horizontal_pyramid(height)\n n = 1\n h = height\n (1..height).each do |i|\n space = \" \"\n star = \"*\"\n print space * h + star * n\n n = n+2\n h = h-1\n print \"\\n\"\n end\nend",
"def triangle(n)\n triangle = (1..n).inject('') do |memo, current_num|\n stars = '*' * current_num\n line = stars.rjust(n) + \"\\n\"\n memo + line\n end\n puts \"\\n\" + triangle + \"\\n\"\nend",
"def print_triangle(rows)\n 1.upto(rows) do |i|\n puts \"*\" * i\n end\nend",
"def triangle(num)\n spaces = num - 1\n count = 1\n loop do\n puts \" \" * spaces + \"*\" * count\n spaces -= 1\n count += 1\n break if count == num + 1\n end\nend",
"def pyramid(a)\n b = a\n for num in 1..a\n puts (\" \" * (b - 1)) + (\"*\" * (num * 2 - 1))\n b -= 1\n end\nend",
"def pyramid(n)\n arr = Array.new(n)\n\n for i in 0..arr.length-1\n arr[i] = Array.new(n)\n end\n\n for y in 0..n/2\n if y == n/2\n if arr[y][y] == nil?\n arr[y][y] = y+1\n end\n break\n end\n for x in y..n-2-y\n arr[y][x] = y+1\n arr[x][n-1-y] = y+1\n arr[n-1-y][n-1-y-x] = y+1\n arr[n-1-y-x][y] = y+1\n end\n end\n\n for a in 0..arr.length-1\n for b in 0..arr[a].length-1\n print \"[#{arr[a][b]}]\"\n end\n print \"\\n\"\n end\n\n return arr\nend",
"def triangle(n)\n count = 1\n loop do\n p (' ' * (n - count)) + ('*' * count)\n count += 1\n break if count > n\n end\nend",
"def triangle(n)\n line = 0\n loop do\n puts ' ' * (n - line) + ('*' * line)\n break if line == n\n line += 1\n end\nend",
"def spiral(n) # n is the max dimensions. ex n = 5, this is a 5x5 square.\n\ta = [0,0]\n\tx = 1 # X is how many steps to go\n\t#t = 1 # T is how many times X\n\n\t# Round 1 - Positive!\n\tx.times do\n\t\ta[1] += 1\n\t\tputs a # [0,1]\n\tend\n\n\tx.times do\n\t\ta[0] += 1\n\t\tputs a # [1,1]\n\tend\n\t\n\tx += 1\n\t\n\t# Round 2 - Negative!\n\tx.times do\n\t\ta[1] -= 1\n\t\tputs a #[1,0],[1,-1]\n\tend\n\n\tx.times do\n\t\ta[0] -= 1\n\t\tputs a # [0,-1],[-1,-1]\n\tend\n\n\tx += 1\n\n\t# Round 3 .. etc\nend",
"def pascals_triangle(num)\r\n triangle = [[1]]\r\n\r\n\r\n\r\nend",
"def print_horizontal_pyramid(height)\n\n (1..height).each do |i|\n spaces = height - i\n stars = (2 * i) - 1\n\n spaces.times { print \" \"}\n stars.times { print \"*\"}\n spaces.times { print \" \"}\n print \"\\n\"\nend\nend",
"def triangle(n)\n counter = 1\n\n loop do\n puts \"#{' ' * (n-counter)}#{'*' * counter}\"\n counter += 1\n break if counter > n\n end\nend",
"def triangle(n)\n (n *(n + 1)) / 2\nend",
"def pyramid(n)\n count = 1\n n.times do\n puts (\" \" * (n - count)) + (\"#\" * count)\n count += 1\n end\nend",
"def triangle(integer)\n counter = integer\n until counter < 0\n puts ('*' * counter).ljust(integer)\n counter -= 1\n end\nend",
"def print_triangle(rows)\n # above i'm stating that I'm defining a method will have rows number of rows.\n rows.times do |x|\n #above i'm stating that rows will now be represented by the variable x.\n\n\n puts ('*' * x) + '*'\n #above: this is what I don't understand. I used (x * '*') first\n #and it didn't work but when I reversed it, it did. I left the\n #question on our community for clarification.\n\n end\nend",
"def pyramid(height)\n level = 1\n height.times do\n puts \" \"*(height-level) + \"#\"*level + \" \"*2 + \"#\"*level\n level += 1\n end \n \nend",
"def triangle(int)\n star_chars = '*'\n int.times do\n puts star_chars.rjust(int, ' ')\n star_chars << '*'\n end\nend",
"def circle(n)\r\n lines = []\r\n half_grid = n / 2\r\n top_stars = half_grid.even? ? half_grid - 1 : half_grid\r\n\r\n spaces_between_stars = top_stars\r\n loop do\r\n lines << ('*' +\r\n ' ' * spaces_between_stars +\r\n '*').center(n)\r\n\r\n spaces_between_stars += 2\r\n break if spaces_between_stars == n - 2\r\n end\r\n\r\n top_bottom = ('*' * top_stars).center(n)\r\n\r\n puts top_bottom\r\n puts lines\r\n (top_stars).times do\r\n puts ('*' + ' ' * (n - 2) + '*').center(n)\r\n end\r\n puts lines.reverse\r\n puts top_bottom\r\nend",
"def triangle(num)\n 1.upto(num) { |n| puts \"#{\"*\" * n}\".rjust(num) }\nend",
"def half_pyramid\n puts \"entrer un nombre d'etage de votre choix\"\n nombre = gets.chomp.to_i\n nombre += 1\n\n nombre.times do |j|\n has = \"# \"\n puts \" #{has*=j}\"\n \n end\nend",
"def pascals_triangle(n)\n triangle = [[1]]\n\n (1...n).each do |lvl_idx| # levels of pyramid by array idx\n current_lvl = []\n prev_lvl = triangle[lvl_idx - 1] \n\n (0..lvl_idx).each do |pos| # elements of level\n left = (pos == 0) ? 0 : prev_lvl[pos - 1]\n right = (pos == lvl_idx) ? 0 : prev_lvl[pos]\n current_lvl[pos] = left + right\n end\n triangle << current_lvl\n end\n triangle\nend",
"def triangle(integer)\n counter = 0\n until counter > integer\n puts ('*' * counter).rjust(integer)\n counter += 1\n end\nend",
"def triangle(reps)\n (0...reps).each do |x|\n puts \"*\" * (2 ** x)\n end\nend",
"def triangle(int)\n for i in (0..int)\n puts (\"*\"*i).rjust(int) \n end\nend",
"def p_triangle(n)\n (0..n).each{|i|\n list = [1]\n element = 1\n k = 1\n (0..i-1).step(1){|index|\n element = element * (i-k+1)/k\n list.push element \n k += 1\n }\n yield(list)\n }\nend",
"def draw\n puts \"* \" * @side_length\n (@side_length-2).times do # times loop will do something X number of times\n print \"*\"+(\" \"*(@side_length*2-3))+\"*\\n\"\n end\n puts \"* \" * @side_length\n end",
"def star(num)\n stars = ['*','*','*']\n center = (num / 2) - 1\n lines = []\n\n # create array with mirrored lines using unshift and push\n 0.upto(center) do |i|\n spaces = ' ' * i\n offset = ' ' * (center - i)\n lines.unshift(offset + stars.join(spaces))\n lines.push(offset + stars.join(spaces))\n end\n\n # insert middle line of stars at middle of array\n lines.insert( num/2, ('*' * num).split.join)\nend",
"def triangle_number(integer)\n\nend",
"def pascals_triangle(n)\n triangle = []\n (1..n).each do |line|\n level = []\n num = 1\n (1..line).each do |idx|\n level << num\n num = (num * (line - idx) / idx)\n end\n triangle << level\n end\n triangle\nend",
"def christmas_tree(height)\n base_number = 2 * height - 1\n tree = []\n height.times do |i|\n nb_stars = (base_number - (2 * i))\n stars = '*' * nb_stars\n spaces = ' ' * ((base_number - nb_stars) / 2)\n if stars.size == 1\n tree.push(spaces + stars + spaces)\n else\n tree.push(\"\\n\" + spaces + stars + spaces)\n end\n end\n tree.reverse.join\nend",
"def ex2\n for i in (0..5)\n for j in (1..(4 - (4 - i).abs))\n print '#'\n end\n print \"\\n\"\n end\nend",
"def patron_cero(n)\n n.times do |i|\n n.times do |j|\n if i == 0 || i == n - 1 || j == 0 || j == n - 1 || i == j\n print \"*\"\n else\n print \" \"\n end\n end\n print \"\\n\"\n end\nend",
"def diagonalCount(n)\n\n#First number saved as \"start.\"\"\nstart = n**2\n\n#Solution is the variable to which we add all elements of the diagonals.\nsolution = 0\n\n#Increment is the gap between elements of diagonals. \nincrement = n - 1\n\n#The first loop continues until start == 1.\nwhile start > 1\n\n#The number of diagonal elements for each \"increment.\"\nk = 4\n\n#The second, nested loop, which repeats four times for each increment\n#and adds the diagonal entries (stored in the \"start\" variable)\n#to solution.\nwhile k > 0\nsolution += start\nstart -= increment\nk -= 1\nend\n\n#After each sequence of 4 entries, we subtract two from the increment\n#variable to add the diagonal elements in the next \"square\" within the\n#grid.\nincrement -= 2\n\nend\n\n#After the final loop is complete, start will equal 1, but will not\n#have been added to solution. The final step is to add 1 and output\n#the solution.\n\nputs solution + 1\n\nend"
] |
[
"0.79708976",
"0.7965833",
"0.7901512",
"0.7843196",
"0.782509",
"0.7797201",
"0.7791015",
"0.7630087",
"0.7627679",
"0.7627008",
"0.76105285",
"0.7590149",
"0.75405943",
"0.7520621",
"0.7514975",
"0.7501551",
"0.7491178",
"0.74647987",
"0.7423649",
"0.7413358",
"0.7356257",
"0.7294977",
"0.7205547",
"0.70838845",
"0.70337254",
"0.68954426",
"0.68591875",
"0.68298763",
"0.67762303",
"0.6760764",
"0.67540103",
"0.6733779",
"0.67221415",
"0.6641089",
"0.6621624",
"0.6577732",
"0.657624",
"0.65425867",
"0.6526835",
"0.64976674",
"0.64520025",
"0.64502513",
"0.6439413",
"0.6431831",
"0.63915455",
"0.63890415",
"0.638693",
"0.6383947",
"0.63802433",
"0.63610286",
"0.6342783",
"0.63220453",
"0.63079566",
"0.6272149",
"0.6270387",
"0.6253823",
"0.6249967",
"0.62322915",
"0.6218337",
"0.6189607",
"0.61877096",
"0.61749166",
"0.61663043",
"0.6164183",
"0.61484873",
"0.610083",
"0.60997164",
"0.6093404",
"0.6084485",
"0.6076216",
"0.60756487",
"0.60509443",
"0.60363334",
"0.6009384",
"0.60078716",
"0.6003755",
"0.59988165",
"0.59981054",
"0.59594667",
"0.5939795",
"0.5912579",
"0.5877883",
"0.58776367",
"0.58708376",
"0.5854502",
"0.58460695",
"0.58400476",
"0.582296",
"0.5819663",
"0.58064127",
"0.58043015",
"0.5785328",
"0.5782747",
"0.57710487",
"0.5764178",
"0.57335293",
"0.57288367",
"0.5727067",
"0.5710419",
"0.5704987"
] |
0.6711096
|
33
|
Problem 6: ========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: A stack is a list of values that grows and shrinks dynamically. In ruby, a stack is easily implemented as an Array that just uses the push and pop methods. A stackandregister programming language is a language that uses a stack of values. Each operation in the language operates on a register, which can be thought of as the current value. The register is not part of the stack. Operations that require two values pop the topmost item from the stack (that is, the operation removes the most recently pushed value from the stack), perform the operation using the popped value and the register value, and then store the result back in the register. Consider a MULT operation in a stackandregister language. It multiplies the stack value with the register value, removes the value from the stack, and then stores the result back in the register. Thus, if we start with a stack of 3 6 4 (where 4 is the topmost item in the stack), and a register value of 7, then the MULT operation will transform things to 3 6 on the stack (the 4 is removed), and the result of the multiplication, 28, is left in the register. If we do another MULT at this point, then the stack is transformed to 3, and the register is left with the value 168. Write a method that implements a miniature stackandregisterbased programming language that has the following commands: n Place a value n in the "register". Do not modify the stack. PUSH Push the register value on to the stack. Leave the value in the register. ADD Pops a value from the stack and adds it to the register value, storing the result in the register. SUB Pops a value from the stack and subtracts it from the register value, storing the result in the register. MULT Pops a value from the stack and multiplies it by the register value, storing the result in the register. DIV Pops a value from the stack and divides it into the register value, storing the integer result in the register. MOD Pops a value from the stack and divides it into the register value, storing the integer remainder of the division in the register. POP Remove the topmost item from the stack and place in register PRINT Print the register value All operations are integer operations (which is only important with DIV and MOD). Programs will be supplied to your language method via a string passed in as an argument. Your program may assume that all programs are correct programs; that is, they won't do anything like try to pop a nonexistent value from the stack, and they won't contain unknown tokens. You should initialize the register to 0. Examples: minilang('PRINT') 0 minilang('5 PUSH 3 MULT PRINT') 15 minilang('5 PRINT PUSH 3 PRINT ADD PRINT') 5 3 8 minilang('5 PUSH POP PRINT') 5 minilang('3 PUSH 4 PUSH 5 PUSH PRINT ADD PRINT POP PRINT ADD PRINT') 5 10 4 7 minilang('3 PUSH PUSH 7 DIV MULT PRINT ') 6 minilang('4 PUSH PUSH 7 MOD MULT PRINT ') 12 minilang('3 PUSH 5 SUB PRINT') 8 minilang('6 PUSH') (nothing printed; no PRINT commands) D: Input string commands, ouput results A: Create method minilang
|
def minilang(string)
register = 0
stack = []
string.split(' ').each do |cmd|
case cmd
when 'PUSH' then stack.push(register)
when 'ADD' then register += stack.pop.to_i
when 'SUB' then register -= stack.pop.to_i
when 'MULT' then register *= stack.pop.to_i
when 'DIV' then register /= stack.pop.to_i
when 'MOD' then register %= stack.pop.to_i
when 'POP' then register = stack.pop.to_i
when 'PRINT' then puts register
else register = cmd.to_i
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def stackEval(cmdStack, resStack, memState)\n # cmdStack => the command stack implemented using a list\n # resStack => the results stack implemented using a list\n # memState => the memory state implemented using a block. Will contain a map for variable names and their integers\n\n # create a map to convert vals in resStack to actual operators\n # stack will be an array where elements are added to front and removed from front\n i = 0\n while true do\n if cmdStack.length == 0\n break\n end\n if cmdStack[0].is_a?(GCConst)\n #puts \"const\"\n #puts cmdStack[0].value\n # add constants from control stack to results stack\n resStack.unshift(cmdStack[0].value) # puts the value from cmdStack[i] into the start of resStack\n cmdStack = cmdStack.drop(1) # remove top value (index 0) from command stack\n i += 1\n elsif cmdStack[0].is_a?(GCTrue)\n # add booleans from control stack to results stack\n resStack.unshift(cmdStack[0].value) # puts the value from cmdStack[i] into the start of resStack\n cmdStack = cmdStack.drop(1)\n i += 1 \n elsif cmdStack[0].is_a?(GCFalse)\n # add booleans from control stack to results stack\n resStack.unshift(cmdStack[0].value) # puts the value from cmdStack[i] into the start of resStack\n cmdStack = cmdStack.drop(1)\n i += 1\n elsif cmdStack[0].is_a?(GCOp)\n #puts \"op\"\n a = cmdStack[0]\n cmdStack = cmdStack.drop(1) \n cmdStack.unshift(a.op) #add operator to the stack\n cmdStack.unshift(a.e2) # add second expr to cmdStack\n cmdStack.unshift(a.e1) # add first expr to cmdStack\n i += 1\n\n # binary operators on cmd stack\n elsif cmdStack[0] == :plus\n b = resStack[0] # get first value from resStack. This will be the second expr in the operator statement\n resStack = resStack.drop(1)\n a = resStack[0] # get next value from resStack. This will be the first expr in the operator statement\n resStack = resStack.drop(1)\n resStack.unshift(a + b) #apply operator and put it back on resStack\n cmdStack = cmdStack.drop(1)\n i += 1\n elsif cmdStack[0] == :minus\n b = resStack[0]\n resStack = resStack.drop(1)\n a = resStack[0]\n resStack = resStack.drop(1)\n resStack.unshift(a - b)\n cmdStack = cmdStack.drop(1)\n i += 1\n elsif cmdStack[0] == :times\n b = resStack[0]\n resStack = resStack.drop(1)\n a = resStack[0]\n resStack = resStack.drop(1)\n resStack.unshift(a * b)\n cmdStack = cmdStack.drop(1)\n i += 1\n elsif cmdStack[0] == :div\n b = resStack[0]\n resStack = resStack.drop(1)\n a = resStack[0]\n resStack = resStack.drop(1)\n resStack.unshift(a / b)\n cmdStack = cmdStack.drop(1)\n i += 1\n\n # variable\n elsif cmdStack[0].is_a?(GCVar)\n # apply memoryState function to variable and add to resultStack\n\n x = memState.call(cmdStack[0].value)\n #puts \"var\"\n #puts x\n resStack.unshift(memState.call(cmdStack[0].value))\n # remove GCVar from commandstack\n cmdStack = cmdStack.drop(1)\n i += 1\n\n # Test compare\n elsif cmdStack[0].is_a?(GCComp)\n #puts \"comp\"\n a = cmdStack[0]\n cmdStack = cmdStack.drop(1)\n cmdStack.unshift(a.op) #add operator to the stack\n cmdStack.unshift(a.e2) # add second expr to cmdStack\n cmdStack.unshift(a.e1) # add first expr to cmdStack\n i += 1 \n\n # less\n elsif cmdStack[0] == :less\n #puts \"less\"\n a = resStack[1]\n b = resStack[0]\n resStack = resStack.drop(2)\n resStack.unshift(a < b)\n cmdStack = cmdStack.drop(1)\n\n # greater\n elsif cmdStack[0] == :greater\n a = resStack[1]\n b = resStack[0]\n #puts \"greater\"\n resStack = resStack.drop(2)\n resStack.unshift(a > b)\n cmdStack = cmdStack.drop(1)\n\n # eq\n elsif cmdStack[0] == :eq\n a = resStack[0]\n b = resStack[1]\n resStack = resStack.drop(2)\n resStack.unshift(a == b)\n cmdStack = cmdStack.drop(1)\n\n elsif cmdStack[0].is_a?(GCAnd)\n #puts \"and gc\"\n a = cmdStack[0]\n cmdStack = cmdStack.drop(1)\n cmdStack.unshift(\"and\")\n cmdStack.unshift(a.t2)\n cmdStack.unshift(a.t1)\n\n elsif cmdStack[0] == \"and\"\n a = resStack[0]\n b = resStack[1]\n #puts a&b\n resStack = resStack.drop(2)\n cmdStack = cmdStack.drop(1)\n resStack.unshift(a & b)\n\n elsif cmdStack[0].is_a?(GCOr)\n a = cmdStack[0]\n cmdStack = cmdStack.drop(1)\n cmdStack.unshift(\"or\")\n cmdStack.unshift(a.t2)\n cmdStack.unshift(a.t1)\n\n elsif cmdStack[0] == \"or\"\n a = resStack[0]\n b = resStack[1]\n resStack = resStack.drop(2)\n cmdStack.drop(1)\n resStack.unshift(a | b)\n\n\n\n # skip\n elsif cmdStack[0].is_a?(GCSkip)\n # no changes to result stack or memState\n cmdStack = cmdStack.drop(1)\n break\n i += 1\n\n # variable assignment\n elsif cmdStack[0].is_a?(GCAssign)\n # add to memState the new variable substitution \n #puts \"assign\"\n a = cmdStack[0]\n cmdStack = cmdStack.drop(1) # remove GCAssign from cmdstack\n cmdStack.unshift(a.s) # add symbol to be assigned\n cmdStack.unshift(\"assign\") # add assign statement\n cmdStack.unshift(a.e) # add expression to be evaluated\n i += 1\n \n #assignment operator\n # command stack [\"assign\",symbol,...]\n # res stack [const,...]\n elsif cmdStack[0] == \"assign\"\n memState = updateState(memState, cmdStack[1], resStack[0])\n cmdStack = cmdStack.drop(2) # remove assign and symbol\n resStack = resStack.drop(1) # remove constant \n i += 1\n\n # compose\n elsif cmdStack[0].is_a?(GCCompose)\n #puts \"compose\"\n a = cmdStack[0]\n cmdStack = cmdStack.drop(1) # remove GCCompose from command stack\n cmdStack.unshift(a.st2) # add 2nd statement to be evaluated\n cmdStack.unshift(a.st1) # add first statement to be evaluated\n i += 1\n\n # if statement breakdown\n elsif cmdStack[0].is_a?(GCIf)\n p = cmdStack[0] # top element from stack. Should be of type GCIf\n cmdStack = cmdStack.drop(1) #remove GCIf from cmdStack\n l = p.pairlist # get list from GCIf\n if l.length == 0\n cmdStack.unshift(GCSkip.new())\n else\n randval = rand(l.length) # get random value \n pair = l[randval]\n l.delete_at(randval) # remove statement from index randval\n \n # re-add broken down GCIf to command stakc\n cmdStack.unshift(GCIf.new(l)) # add remaining statements\n cmdStack.unshift(pair[1]) # add statement \n cmdStack.unshift(\"if\") # add if\n cmdStack.unshift(pair[0]) # add boolean guard\n i += 1\n end\n elsif cmdStack[0] == \"if\"\n b = resStack[0] # get the boolean that would have been evaluated from result stack\n if b == true \n s1 = cmdStack[1] # get the statement to be executed\n cmdStack = cmdStack.drop(3) # remove the if, s1 and remaining GCIf block \n resStack = resStack.drop(1) # remove that boolean check\n cmdStack.unshift(s1) #place the s1 value back on command stack\n else \n cmdStack = cmdStack.drop(2) # remove \"if\" and s1. The top element on stack should now be the remaining GCIf statements \n resStack = resStack.drop(1) # remove the boolean \n end\n\n # while loop\n # logic: get random statement from list and place it at top of command stack\n # check if the guard is true. If so then do that statement and repeat\n # if false, can either find another statement or do nothing\n # in this implementation, I will do nothing in the false case\n elsif cmdStack[0].is_a?(GCDo)\n #puts \"do\"\n w = cmdStack[0] # get Do statement off command stack\n #cmdStack = cmdStack.drop(1) # remove statement\n #cmdStack.unshift(GCDo.new(w.pairlist)) \n if w.pairlist.length == 0 # if no pairs, do nothing\n cmdStack.unshift(GCSkip.new())\n else\n randval = rand(w.pairlist.length) # get random value\n pair = w.pairlist[randval] # get random pair\n cmdStack = cmdStack.drop(1) # remove GCDo\n cmdStack.unshift(pair[1]) # add statement\n cmdStack.unshift(pair[0]) # add boolean check\n cmdStack.unshift(\"while\")\n cmdStack.unshift(pair[0]) # condition\n i += 1\n # command stack should look like [guard, \"while\", guard, statement, ...]\n end\n elsif cmdStack[0] == \"while\"\n # command stack will be in form [\"while\", guard, statement, ...]\n # resStack will be in form [true/false, ...]\n b = resStack[0] # check evaluated condition\n g = cmdStack[1] # guard\n s = cmdStack[2] # statement \n if b == true\n cmdStack.unshift(g) # place guard to front of stack\n cmdStack.unshift(s) # place statement to front of stack to be evaluated\n resStack = resStack.drop(1) # remove previously evaluated condition\n # new command stack will be in form [statement, guard, \"while\", guard, statement]\n else\n #puts \"while guard was false\"\n cmdStack.drop(3) #remove while, guard and statement from command stack\n cmdStack.unshift(GCSkip.new()) #end loop\n resStack = resStack.drop(1) # remove previously computed bool\n i += 1\n end\n else \n puts \"Invalid input\"\n break\n end\n end\n return memState \n\n end",
"def minilang(program)\n register = 0\n stack = []\n\n program.split.each do |step|\n p step\n case step\n when 'PUSH' then stack.push(register)\n when 'ADD' then register += stack.pop\n when 'SUB' then register -= stack.pop\n when 'MULT' then register *= stack.pop\n when 'DIV' then register /= stack.pop\n when 'MOD' then register %= stack.pop\n when 'POP' then register = stack.pop\n when 'PRINT' then puts register\n else register = step.to_i\n end\n p stack\n end\nend",
"def evaluate\n stack = Stack.new\n\n tokens.each do |token|\n if numeric?(token)\n stack.push(token.to_i)\n elsif token == \"+\"\n # handle addition\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs + rhs)\n elsif token == \"*\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs * rhs)\n elsif token == \"-\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs - rhs)\n elsif token == \"/\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs / rhs)\n elsif token == \"^\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs ** rhs)\n elsif token == \"%\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(lhs % rhs)\n elsif token == \"max\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push([lhs, rhs].max)\n elsif token == \"min\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push([lhs, rhs].min)\n elsif token == \"rand\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push(rand(lhs..rhs))\n elsif token == \"sample\"\n rhs = stack.pop # right-hand side\n lhs = stack.pop # left-hand side\n stack.push([lhs, rhs].sample)\n elsif token == \"!\"\n num = stack.pop\n stack.push(factorial(num))\n else\n raise \"omg what is this token even?\"\n end\n end\n\n stack.pop\n end",
"def solution(s)\n stack = []\n s.split(' ').each do |input|\n case input\n when POP_COMMAND\n entry = stack.pop()\n raise InvalidOperation, 'Empty Stack' if entry == nil\n when DUPLICATE_COMMAND\n entry = stack.pop()\n raise InvalidOperation, 'Empty Stack' if entry == nil\n stack.push(entry)\n stack.push(entry)\n when ADDITION_COMMAND\n first = stack.pop()\n second = stack.pop()\n raise InvalidOperation, 'Empty Stack' if first == nil || second == nil\n raise InvalidOperation, 'Overflow Integer' if (first > UNSIGNED_INTEGER_LIMIT - second)\n stack.push(first + second)\n when SUBTRACTION_COMMAND\n first = stack.pop()\n second = stack.pop()\n raise InvalidOperation, 'Empty Stack' if first == nil || second == nil\n raise InvalidOperation, 'Negative value' if (first < second)\n stack.push(first - second)\n else\n stack.push(Integer(input))\n end\n end\n\n raise InvalidOperation, 'Empty Stack' if stack.length == 0\n stack.pop()\nend",
"def stack; end",
"def stack; end",
"def test_proper_stack\n stack = TokenStack.new\n stack.push('4')\n stack.push('3')\n stack.push('*')\n terp = Interpreter.new(false, true)\n\n result = terp.binary_operation(0, stack)\n assert_equal 12, result\n end",
"def minilang(str)\n register = 0\n stack = []\n\n str.split.each do |el|\n case \n when el == 'ADD' then register += stack.pop\n when el == 'SUB' then register -= stack.pop\n when el == 'MULT' then register *= stack.pop\n when el == 'DIV' then register /= stack.pop \n when el == 'MOD' then register %= stack.pop \n when el == 'PUSH' then stack.push(register)\n when el == 'POP' then register = stack.pop \n when el == 'PRINT' then puts register \n else register = el.to_i\n end\n end\nend",
"def rpn_calculator\n operators_list = ['+','-','*','/']\n stack = []\n \n def add(stack)\n stack.push(stack.pop + stack.pop)\n end\n \n def minus(stack)\n var1, var2 = stack.pop, stack.pop\n stack.push(var2 - var1)\n end\n \n def multiply(stack)\n stack.push(stack.pop * stack.pop)\n end\n \n def divide(stack)\n stack.push(stack.pop / stack.pop)\n end\n \n def get_user_input\n puts \"enter number or operator into calculator\"\n\n gets.chomp\n end\n \n puts \"enter 'quit' to quit\"\n loop do\n user_choice = get_user_input\n break if user_choice == \"quit\"\n \n if !(operators_list.include?(user_choice))\n stack << user_choice.to_i\n end\n \n case (user_choice)\n when \"+\"\n add(stack)\n when \"-\"\n minus(stack)\n when \"*\"\n multiply(stack)\n when \"/\"\n divide(stack)\n end \n \n \n p stack\n end \nend",
"def question_one\n stack = Stack.new\n stack.push(3)\n stack.push(5)\n stack.push(2)\n stack.push(4)\n stack.push(1)\n stack.pop\n stack.pop\n stack.pop\n stack.min\nend",
"def minilang(program)\n register = 0\n stack = []\n program.split.each do |token|\n case token\n when 'PRINT' then puts \"register: #{register}, stack:#{stack}\"\n when 'PUSH' then stack << register\n when 'ADD' then register += stack.pop\n when 'SUB' then register -= stack.pop\n when 'MULT' then register *= stack.pop\n when 'DIV' then register /= stack.pop\n when 'MOD' then register %= stack.pop\n when 'POP' then register = stack.pop\n else register = token.to_i\n end\n end\nend",
"def run(code, verbose = false)\n\n # loop over the code until end is reached\n #\n while(@str_p < code.size)\n puts code[@str_p,code.size-@str_p] if verbose\n\n # decide what shall be done now\n #\n case code[@str_p,1]\n\n # ignore this characters\n when \" \",\"\\r\",\"\\t\",\"\\n\"\n\n # perform addition on stack\n when \"+\"\n @stack.+\n\n # perform substraction on stack\n when \"-\"\n @stack.-\n\n # perform multiplication on stack\n when \"*\"\n @stack.*\n\n # perform division on stack\n when \"/\"\n @stack./\n\n # perform negation on stack\n when \"_\"\n @stack._\n\n # perform equality check on stack\n when \"=\"\n @stack.eq\n\n # perform greater than check on stack\n when \">\"\n @stack.>\n\n # perform NOT on stack\n when \"~\"\n @stack.~\n\n # perform AND on stack\n when \"&\"\n @stack.&\n\n # perform OR on stack\n when \"|\"\n @stack.|\n\n # Duplicate top element on stack\n when \"$\"\n @stack.dup\n\n # Remove top element on stack\n when \"%\"\n @stack.%\n\n # Perform swapping on 2 top elements\n when \"\\\\\"\n @stack.swap\n\n # Perform rotation on 3 top elements\n when \"@\"\n @stack.rot\n\n # Copy nth element to the top of stack\n when \"ø\"\n @stack.pick\n\n # handle comments\n when \"{\"\n @str_p = code.index('}', @str_p + 1)\n\n # Push the integer on stack\n when '0','1','2','3','4','5','6','7','8','9'\n num = code[@str_p..code.size].match /\\A\\d+/ \n @stack.push num[0].to_i\n @str_p += (num[0].size - 1)\n\n # read lambda function and push on stack\n when \"[\"\n f = 1\n c = 1\n while f > 0 do\n f += 1 if code.at(@str_p + c) == '['\n f -= 1 if code.at(@str_p + c) == ']'\n c += 1\n end\n @stack.push l = code[@str_p + 1 .. @str_p + c - 2]\n @str_p += l.size + 1\n\n # Print text between the \"\n when '\"'\n c = code[@str_p + 1 .. code.index('\"', @str_p + 1) - 1]\n @str_p += c.size+1\n puts c\n\n # Perform accessing on global variables a-z, : is value assignment, ; pushes value on stack\n when 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' #assing or push global variables\n if code.at(@str_p + 1) == ':'\n @global_variables[code.at(@str_p)] = @stack.pop\n @str_p += 1\n elsif code[@str_p + 1, 1] == ';'\n @stack.push @global_variables[code.at(@str_p)] or raise StandardError, \"Undefined global variable\"\n @str_p += 1\n else\n raise StandardError, \"Syntax error with global variables\"\n end\n\n # Execute the lambda function on stack (means copying it to after the !)\n when '!'\n code.insert(@str_p + 1, @stack.pop)\n\n # Print top element as integer\n when '.'\n puts @stack.pop.to_i\n\n # Print top element as character\n when ','\n puts @stack.pop.chr\n\n # Read one single character from stdin and push to stack\n when '^'\n c = nil\n while (c = ask('') { |q| q.character = true; q.echo = false }) != \"\\e\" do\n break\n end\n @stack.push c.to_i.to_s == c ? c.to_i : c\n\n # Push the Character after \\ as integer on stack\n when '\\''\n c = code.at(@str_p + 1)\n @stack.push c.to_i.to_s == c ? c.to_i : c\n @str_p += 1\n\n # Flush input and output\n when 'ß'\n STDOUT.flush\n\n # Perform an IF\n when '?'\n f = @stack.pop\n b = @stack.pop\n code = code.insert(@str_p + 1, f) if b == -1\n\n # Perform a WHILE\n when \"#\"\n a = @stack.pop\n b = @stack.pop\n @while_stack.push b\n @while_stack.push a\n code = code.insert(@str_p + 1, \"[#{b}]!W\")\n\n # Helper for WHILE\n when \"W\"\n r = @stack.pop\n a = @while_stack.pop\n b = @while_stack.pop\n if r == -1\n @while_stack.push b\n @while_stack.push a\n code = code.insert(@str_p + 1, \"[#{a}]![#{b}]!W\")\n end\n\n else\n raise StandardError, \"syntax error\"\n end\n\n @stack.show if verbose\n\n # in next step go for the next character\n @str_p += 1\n end\n end",
"def minilang(program)\n stack = []\n register = 0\n commands = program.split\n commands.each do |command|\n case command\n when 'PUSH' then stack << register\n when 'ADD' then register += stack.pop\n when 'SUB' then register -= stack.pop\n when 'MULT' then register = register * stack.pop\n when 'DIV' then register = register / stack.pop\n when 'MOD' then register = register % stack.pop\n when 'POP' then register = stack.pop\n when 'PRINT' then puts register\n else register = command.to_i\n end\n end\n nil\nend",
"def minilang(commands)\n stack = []\n register = 0\n command_arr = commands.split\n\n command_arr.each do |command|\n case command\n when \"PUSH\"\n stack.push(register)\n when \"ADD\"\n register += stack.pop\n when \"SUB\"\n register -= stack.pop\n when \"MULT\"\n register *= stack.pop\n when \"DIV\"\n if stack.last == 0\n puts \"Divide by zero error. Can't perform \\\"DIV\\\" command.\"\n else\n register /= stack.pop\n end\n when \"MOD\"\n if stack.last == 0\n puts \"Divide by zero error. Can't perform \\\"MOD\\\" command.\"\n else\n register %= stack.pop\n end\n when \"POP\"\n register = stack.pop\n when \"PRINT\"\n puts register\n else\n register = command.to_i\n end\n end\nend",
"def minilang(string)\n register = 0\n stack = []\n string.split.each do |command|\n case command\n when \"PUSH\" then stack << register\n when \"ADD\" then register += stack.pop\n when \"SUB\" then register -= stack.pop\n when \"MULT\" then register *= stack.pop\n when \"DIV\" then register /= stack.pop\n when \"MOD\" then register %= stack.pop\n when \"POP\" then register = stack.pop\n when \"PRINT\" then puts register\n else register = command.to_i\n end\n end\nend",
"def exp\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 24 )\n __ADDITIONSUBSTRACTIONOPERATORS11__ = nil\n\n begin\n # at line 726:5: term ( ADDITIONSUBSTRACTIONOPERATORS term )*\n @state.following.push( TOKENS_FOLLOWING_term_IN_exp_1113 )\n term\n @state.following.pop\n # at line 726:10: ( ADDITIONSUBSTRACTIONOPERATORS term )*\n while true # decision 27\n alt_27 = 2\n look_27_0 = @input.peek( 1 )\n\n if ( look_27_0 == ADDITIONSUBSTRACTIONOPERATORS )\n alt_27 = 1\n\n end\n case alt_27\n when 1\n # at line 726:11: ADDITIONSUBSTRACTIONOPERATORS term\n __ADDITIONSUBSTRACTIONOPERATORS11__ = match( ADDITIONSUBSTRACTIONOPERATORS, TOKENS_FOLLOWING_ADDITIONSUBSTRACTIONOPERATORS_IN_exp_1116 )\n # --> action\n #Regla 2 GC\n @stack_operators.push(__ADDITIONSUBSTRACTIONOPERATORS11__.text)\n \n # <-- action\n @state.following.push( TOKENS_FOLLOWING_term_IN_exp_1143 )\n term\n @state.following.pop\n # --> action\n #Regla 4 GC / VS\n if(@stack_operators.last == '+' or\n @stack_operators.last == '-' or\n @stack_operators.last == '||' ) then\n operator = @stack_operators.pop\n operand_b = @stack_operands.pop\n operand_a = @stack_operands.pop\n result = get_avail\n generate(operator, operand_a, operand_b, result)\n free_avail(operand_a)\n free_avail(operand_b)\n free_avail_const(operand_a)\n free_avail_const(operand_b)\n @stack_operands.push(result)\n @stack_types.push(resulting_type(@stack_types.pop, @stack_types.pop, operator))\n end\n \n # <-- action\n\n else\n break # out of loop for decision 27\n end\n end # loop for decision 27\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 24 )\n\n end\n \n return \n end",
"def minilang(program_str)\n register = 0\n stack = []\n commands = program_str.split(' ')\n\n commands.each do |command|\n case command\n when 'PUSH' then stack << register\n when 'ADD' then register += (stack.pop).to_i\n when 'SUB' then register -= (stack.pop).to_i\n when 'MULT' then register *= (stack.pop).to_i\n when 'DIV' then register /= (stack.pop).to_i\n when 'MOD' then register %= (stack.pop).to_i\n when 'POP' then register = (stack.pop).to_i\n when 'PRINT' then puts register\n else register = command.to_i\n end\n end\nend",
"def ropstack_memmove\n ropstack = []\n\n # 0x6003D17B : # XCHG EAX,ECX # RETN \t[Module : ijl15.dll] ** \n ropstack.push(0x6003d17b)\n # 0x763CC3D8 : # XCHG EAX,ESI # RETN \t[Module : comdlg32.dll] ** \n ropstack.push(0x763cc3d8)\n # eax = 128\n ropstack.concat(ropstack_gen_pow2(6))\n # 0x6003D17B : # XCHG EAX,ECX # RETN \t[Module : ijl15.dll] ** \n ropstack.push(0x6003d17b)\n # 0x763CC3D8 : # XCHG EAX,ESI # RETN \t[Module : comdlg32.dll] ** \n ropstack.push(0x763cc3d8)\n\n # 0x10010407 : # ADD EAX,ECX # POP EBP # RETN \t[Module : GCDSRV32.dll] ** \n for i in 1..10\n ropstack.push(0x10010407)\n ropstack.push('JUNK')\n end\n\n # 0x6002B45E : # ADD EAX,8 # RETN \t[Module : ijl15.dll] ** \n ropstack.push(0x6002B45E)\n # 0x1001DDDE : # INC EAX # RETN \t[Module : GCDSRV32.dll] ** \n ropstack.push(0x1001ddde)\n ropstack.push(0x1001ddde)\n ropstack.push(0x1001ddde)\n ropstack.push(0x1001ddde)\n\n # 0x1001C116 : # XCHG EAX,EBP # ADD EAX,5D5B5E10 # RETN \t[Module : GCDSRV32.dll] ** \n ropstack.concat(xchg_eax_ebp())\n\n # restore size\n # 0x763CC3D8 : # XCHG EAX,ESI # RETN \t[Module : comdlg32.dll] ** \n ropstack.push(0x763cc3d8)\n\n # memmove()\n ropstack.push(0x7C873C2B)\n # make room for arguments\n for i in 1..3\n ropstack.push('JUNK')\n end\n # 0x60040DAD : # RETN \t[Module : ijl15.dll] ** \n ropstack.push(0x60040dad) # seip of memmove()\n for i in 1..6\n ropstack.push('JUNK')\n end\n\n return ropstack\n end",
"def minilang(str)\n register = 0\n stack = []\n\n command = str.split(' ')\n command.map! { |element| element.to_i.to_s == element ? element.to_i : element }\n p command\n\n command.each do |element|\n case element\n when 'PUSH'\n stack.push(register)\n when 'ADD'\n register += stack.pop\n when 'SUB'\n register -= stack.pop\n when 'MULT'\n register *= stack.pop\n when 'DIV'\n register /= stack.pop\n when 'MOD'\n register %= stack.pop\n when 'POP'\n register = stack.pop\n when 'PRINT'\n puts register\n else\n register = element\n end\n end\nend",
"def minilang(str)\n stack = []\n register = 0\n\n str.split.each do |char|\n case char\n when 'PUSH' then stack.push(register)\n when 'ADD' then register += stack.pop\n when 'SUB' then register -= stack.pop\n when 'MULT' then register *= stack.pop\n when 'DIV' then register /= stack.pop\n when 'MOD' then register %= stack.pop\n when 'POP' then register += stack.shift\n when 'PRINT' then puts register\n else register = char.to_i\n end\n end\nend",
"def do_plus s; a = mega_pop(s); b = mega_pop(s); s[:stack].push(a+b); end",
"def minilang(command_string)\n stack = []\n register = 0\n command_string.split(' ').each do |command|\n case command\n when 'PUSH' then stack << register\n when 'ADD' then register += stack.pop\n when 'SUB' then register -= stack.pop\n when 'MULT' then register *= stack.pop\n when 'DIV' then register /= stack.pop\n when 'MOD' then register %= stack.pop\n when 'POP' then register = stack.pop\n when 'PRINT' then puts register\n else register = command.to_i\n end\n end\n register\nend",
"def writeArithmetic(command)\n assembly_builder = []\n # Add\n if command == 'add'\n assembly_builder.push(\n '@SP',# A=0\n 'AM=M-1',# A=RAM[0]=M[0]-1\n 'D=M',# D=RAM[257]\n 'A=A-1',# A=257-1=256\n 'M=M+D'# RAM[256]=RAM[256]+D\n )\n\n elsif command == 'sub'\n assembly_builder.push(\n '@SP',\n 'AM=M-1',\n 'D=M',\n 'A=A-1',\n 'M=M-D'\n )\n\n # y = -y\n elsif command == 'neg'\n assembly_builder.push(\n '@SP',\n 'A=M-1',\n 'M=-M',\n )\n\n # x == y ? -1 : 0\n elsif command == 'eq'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'D=M-D', # D = 5 - 4 = 1\n 'M=-1', # M[256] = -1\n '@EQEND', # if D == 0 → EQEND\n 'D;JEQ', #\n '@SP',\n 'A=M-1',\n 'M=0',\n '(EQEND)'\n )\n\n # x > y ? -1 : 0\n elsif command == 'gt'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'D=M-D', # D = 5 - 4 = 1\n 'M=-1', # M[256] = -1\n '@GTEND', # if D == 0 → EQEND\n 'D;JGT', #\n '@SP',\n 'A=M-1',\n 'M=0',\n '(GTEND)'\n )\n # x < y ? -1 : 0\n elsif command == 'lt'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'D=M-D', # D = 5 - 4 = 1\n 'M=-1', # M[256] = -1\n '@LTEND', # if D == 0 → EQEND\n 'D;JLT', #\n '@SP',\n 'A=M-1',\n 'M=0',\n '(LTEND)'\n )\n # x & y\n elsif command == 'and'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'M=D&M'\n )\n # x | y\n elsif command == 'or'\n assembly_builder.push(\n '@SP',\n 'AM=M-1', # M = 257\n 'D=M', # D = 4\n 'A=A-1', # @256\n 'M=D|M'\n )\n # not y\n elsif command == 'not'\n assembly_builder.push(\n '@SP',\n 'A=M-1', # M = 257\n 'M=!M'\n )\n end\n return assembly_builder\n end",
"def postfix_evaluator(equation)\n stack = []\n for i in equation do\n if str_to_num(i)\n stack.push(str_to_num(i))\n puts stack\n elsif (\"+-*/\").include?(i)\n second_num = stack.pop\n if stack != []\n first_num = stack.pop\n result = math(i, first_num, second_num)\n stack.push(result)\n else\n raise \"Not enough arguments\"\n end\n else\n raise \"Invalid number\"\n end\n end\n stack.pop()\nend",
"def minilang(str)\n stack = []\n reg = 0\n\n # puts str\n cmds = str.split\n cmds.each do |cmd|\n # puts \"cmd == #{cmd}\"\n case cmd\n when 'PUSH' then stack << reg\n when 'ADD' then reg += stack.pop\n when 'SUB' then reg -= stack.pop\n when 'MULT' then reg *= stack.pop\n when 'DIV' then reg /= stack.pop\n when 'MOD' then reg %= stack.pop\n when 'POP' then reg = stack.pop\n when 'PRINT' then puts reg\n else reg = cmd.to_i # integer\n end\n end\n puts\nend",
"def minilang(string)\n register = 0\n stack = []\n\n operation_array = string.downcase.split\n\n operation_array.map!{ |x| x.to_i == 0 ? x : x.to_i }\n\n string.split.size.times do\n register = operation_array.shift if operation_array.first.to_i != 0\n\n case operation_array[0]\n when \"print\"\n p register\n operation_array.shift\n when \"push\"\n stack << register\n operation_array.shift\n when \"mult\"\n register *= stack.pop\n operation_array.shift\n when \"add\"\n register += stack.pop\n operation_array.shift\n when \"pop\"\n register = stack.pop\n operation_array.shift\n when \"div\"\n register /= stack.pop\n operation_array.shift\n when \"mod\"\n register %= stack.pop\n operation_array.shift\n when \"sub\"\n register -= stack.pop\n operation_array.shift\n end\n end\nend",
"def generate_stack\n VALUES.product(SUITS).map!(&:join)\n\n # stack = []\n # VALUES.each do |value|\n # SUITS.each do |suit|\n # stack << value + suit\n # end\n # end\n # stack\n end",
"def minilang(instructions)\n stack = []\n register = 0\n functions = {\n 'PUSH' => Proc.new { stack.push(register) },\n 'ADD' => Proc.new { register += stack.pop },\n 'SUB' => Proc.new { register -= stack.pop },\n 'MULT' => Proc.new { register = stack.pop * register },\n 'DIV' => Proc.new { register = register / stack.pop },\n 'MOD' => Proc.new { register = register % stack.pop },\n 'POP' => Proc.new { register = stack.pop },\n 'PRINT'=> Proc.new { puts register },\n 'STACK'=> Proc.new { puts stack }\n }\n\n instructions = instructions.split\n instructions.map! do |instruction|\n if instruction.to_i != 0\n instruction.to_i\n else\n instruction\n end\n end\n\n instructions.each do |instruction|\n if instruction.is_a?(Integer)\n register = instruction\n next\n end\n functions[instruction].call\n end\nend",
"def stacks(arg)\n ya_ta = tuc(\"x_ya\")\n ra_ta = tuc(\"x_ra\")\n la_ta = tuc(\"x_la\")\n wa_ta = tuc(\"x_wa\")\n\n ra_go = tuc(\"ra_x\")\n la_go = tuc(\"la\")\n sa_go = tuc(\"sa\")\n\n h = Hash.[](\n # subscript YA\n \"ky\"=>tuc(\"ka\")+ya_ta, \"khy\"=>tuc(\"kha\")+ya_ta, \"gy\"=>tuc(\"ga\")+ya_ta,\n \"py\"=>tuc(\"pa\")+ya_ta, \"phy\"=>tuc(\"pha\")+ya_ta, \"by\"=>tuc(\"ba\")+ya_ta, \"my\"=>tuc(\"ma\")+ya_ta,\n # subscript RA\n \"kr\"=>tuc(\"ka\")+ra_ta, \"khr\"=>tuc(\"kha\")+ra_ta, \"gr\"=>tuc(\"ga\")+ra_ta,\n \"tr\"=>tuc(\"ta\")+ra_ta, \"thr\"=>tuc(\"tha\")+ra_ta, \"dr\"=>tuc(\"da\")+ra_ta,\n \"pr\"=>tuc(\"pa\")+ra_ta, \"phr\"=>tuc(\"pha\")+ra_ta, \"br\"=>tuc(\"ba\")+ra_ta, \"mr\"=>tuc(\"ma\")+ra_ta,\n \"shr\"=>tuc(\"sha\")+ra_ta, \"sr\"=>tuc(\"sa\")+ra_ta, \"hr\"=>tuc(\"ha\")+ra_ta,\n # subscript LA\n \"kl\"=>tuc(\"ka\")+la_ta, \"gl\"=>tuc(\"ga\")+la_ta, \"bl\"=>tuc(\"ba\")+la_ta,\n \"zl\"=>tuc(\"za\")+la_ta, \"rl\"=>tuc(\"ra\")+la_ta, \"sl\"=>tuc(\"sa\")+la_ta,\n # subscript WA\n \"kw\"=>tuc(\"ka\")+wa_ta, \"khw\"=>tuc(\"kha\")+wa_ta, \"gw\"=>tuc(\"ga\")+wa_ta, \"grw\"=>tuc(\"ga\")+ra_ta+wa_ta,\n \"cw\"=>tuc(\"ca\")+wa_ta, \"nyw\"=>tuc(\"nya\")+wa_ta, \"tw\"=>tuc(\"ta\")+wa_ta,\n \"dw\"=>tuc(\"da\")+wa_ta, \"tsw\"=>tuc(\"tsa\")+wa_ta, \"tshw\"=>tuc(\"tsha\")+wa_ta,\n \"zhw\"=>tuc(\"zha\")+wa_ta, \"zw\"=>tuc(\"za\")+wa_ta, \"rw\"=>tuc(\"ra\")+wa_ta,\n \"lw\"=>tuc(\"la\")+wa_ta, \"shw\"=>tuc(\"sha\")+wa_ta, \"sw\"=>tuc(\"sa\")+wa_ta, \"hw\"=>tuc(\"ha\")+wa_ta,\n # subscript 'A\n \"t'\"=>tuc(\"ta\")+tuc(\"x_'a\"),\n # superscript RA\n \"rk\"=>ra_go+tuc(\"x_ka\"), \"rg\"=>ra_go+tuc(\"x_ga\"), \"rng\"=>ra_go+tuc(\"x_nga\"), \"rj\"=>ra_go+tuc(\"x_ja\"),\n \"rny\"=>ra_go+tuc(\"x_nya\"), \"rt\"=>ra_go+tuc(\"x_ta\"), \"rd\"=>ra_go+tuc(\"x_da\"), \"rn\"=>ra_go+tuc(\"x_na\"), \"rm\"=>ra_go+tuc(\"x_ma\"),\n \"rb\"=>ra_go+tuc(\"x_ba\"), \"rts\"=>ra_go+tuc(\"x_tsa\"), \"rdz\"=>ra_go+tuc(\"x_dza\"),\n # superscript LA\n \"lk\"=>la_go+tuc(\"x_ka\"), \"lg\"=>la_go+tuc(\"x_ga\"), \"lng\"=>la_go+tuc(\"x_nga\"), \"lc\"=>la_go+tuc(\"x_ca\"),\n \"lj\"=>la_go+tuc(\"x_ja\"), \"lt\"=>la_go+tuc(\"x_ta\"), \"ld\"=>la_go+tuc(\"x_da\"), \"lp\"=>la_go+tuc(\"x_pa\"),\n \"lb\"=>la_go+tuc(\"x_ba\"), \"lh\"=>la_go+tuc(\"x_ha\"),\n # superscript SA\n \"sk\"=>sa_go+tuc(\"x_ka\"), \"sg\"=>sa_go+tuc(\"x_ga\"), \"sng\"=>sa_go+tuc(\"x_nga\"), \"sny\"=>sa_go+tuc(\"x_nya\"),\n \"st\"=>sa_go+tuc(\"x_ta\"), \"sd\"=>sa_go+tuc(\"x_da\"), \"sn\"=>sa_go+tuc(\"x_na\"), \"sp\"=>sa_go+tuc(\"x_pa\"),\n \"sb\"=>sa_go+tuc(\"x_ba\"), \"sm\"=>sa_go+tuc(\"x_ma\"), \"sts\"=>sa_go+tuc(\"x_tsa\"))\n h[arg]\n end",
"def test_addition\n @eval.load_stacks([5, 5, '+'])\n assert_equal 10, @eval.quick_maffs_a('+')\n end",
"def minilang(command_string)\n command_array = command_string.split\n register = 0\n stack = []\n counter = 0\n until counter > command_array.size do\n if is_string_int?(command_array[counter])\n register = command_array[counter].to_i\n else\n case command_array[counter]\n when 'PUSH' then stack << register\n when 'ADD' then register += stack.pop\n when 'SUB' then register -= stack.pop\n when 'MULT' then register *= stack.pop\n when 'DIV' then register /= stack.pop\n when 'MOD' then register %= stack.pop\n when 'POP' then register = stack.pop\n when 'PRINT' then puts register\n end\n end\n counter += 1\n end\nend",
"def rpn(operation)\n rpn_stack = Stack.new\n tokens = parse_tokens(operation)\n puts tokens.to_s\n tokens.each do |token|\n if !is_operator?(token)\n puts \"pushing token #{token}\"\n rpn_stack.push(token)\n else\n val2 = rpn_stack.pop\n val1 = rpn_stack.pop\n rpn_stack.push(calculate(val1,val2, token))\n end # end of if\n end # end of each\n rpn_stack.pop\nend",
"def dig\n @stack.push(@stack.slice!(-3))\n end",
"def stack_as_array\n puts \"Stack as array: \"\n arr = [1,3,4,5,6,7]\n print arr\n puts\n\n puts \"Pop top element (7):\"\n puts arr.pop\n print arr\n puts\n\n puts \"Push element (8):\"\n arr.push(8)\n print arr\n puts\n puts\nend",
"def do_asterisk s; a = mega_pop(s); b = mega_pop(s); s[:stack].push(a*b); end",
"def expressions_from_iseq(bytecodes, locals)\n bytecodes.reduce([]) do |stack, inst|\n puts \"INST: #{inst}\"\n # annoyingly, labels have have their own format\n # UGGGGLY, TODO: refactor\n if inst.is_a?(Symbol) && inst.to_s =~ /^label/\n if ih = self.half_pop_if(inst, stack)\n stack << ih\n elsif iff = self.pop_if(inst, stack)\n stack << iff \n else \n stack << Label.new(inst)\n end\n\n next stack\n elsif inst.is_a?(Fixnum)\n # TODO: What's with the plain numbers?\n next stack\n end\n\n case inst[0]\n # TODO\n when :throw \n # TODO?\n when :trace, :pop, :putnil, :leave\n \n when :branchunless\n test = stack.pop\n if_hole = IfHole.new(test, inst[1], nil, nil, nil)\n stack << if_hole\n when :branchif\n stack << self.pop_while(inst, stack)\n when :jump\n stack << Jump.new(inst[1])\n\n when :putobject_OP_INT2FIX_O_0_C_ \n stack << Literal.new(0)\n when :putobject_OP_INT2FIX_O_1_C_ \n stack << Literal.new(1)\n when :putobject\n stack << Literal.new(inst[1])\n when :putstring\n stack << Literal.new(inst[1])\n when :putself\n stack << Self.new\n when :newarray\n stack << self.pop_array(inst[1], stack)\n when :duparrray\n stack << ArrayLiteral.new(inst[1].map{ |v| Literal.new(v)})\n\n when :getlocal\n stack << self.get_local(inst[2], inst[1])\n when :getlocal_OP__WC__1\n stack << self.get_local(1, inst[1])\n when :getlocal_OP__WC__0\n stack << self.get_local(0, inst[1])\n\n when :setlocal\n stack << self.pop_assignment(inst[2], inst[1], stack)\n when :setlocal_OP__WC__1\n stack << self.pop_assignment(1, inst[1], stack)\n when :setlocal_OP__WC__0\n stack << self.pop_assignment(0, inst[1], stack)\n\n when :send\n stack << self.pop_expression(inst[1], stack)\n when :opt_send_simple\n stack << self.pop_expression(inst[1], stack)\n when :opt_lt\n stack << self.pop_expression(inst[1], stack)\n when :opt_le\n stack << self.pop_expression(inst[1], stack)\n when :opt_plus\n stack << self.pop_expression(inst[1], stack)\n # TODO: The other opts and sends\n else\n puts \"UNKNOWN\"\n end\n\n stack\n end\n end",
"def writePushPop(command, segment, index)\n assembly_builder = []\n # Push\n if command == 'C_PUSH'\n if segment == 'constant'\n assembly_builder.push(\n \"@#{index}\",\n 'D=A',\n '@SP',\n 'A=M',\n 'M=D',\n '@SP',\n 'M=M+1'\n )\n elsif segment == 'temp'\n assembly_builder.push(\n \"@#{5 + index.to_i}\", # A = 10\n 'D=M', # D = M[10]\n '@SP', # A = 0\n 'A=M', # A = M[0] = 258\n 'M=D', # M[258] = D\n '@SP', # A = 0\n 'M=M+1' # M[0] = 258 + 1\n )\n elsif segment == 'pointer'\n assembly_builder.push(\n \"@#{3 + index.to_i}\", # A = 10\n 'D=M', # D = M[10]\n '@SP', # A = 0\n 'A=M', # A = M[0] = 258\n 'M=D', # M[258] = D\n '@SP', # A = 0\n 'M=M+1' # M[0] = 258 + 1\n )\n elsif segment == 'static'\n assembly_builder.push(\n \"@#{file_name_without_ext}.#{index}\", # A = 10\n 'D=M', # D = M[10]\n '@SP', # A = 0\n 'A=M', # A = M[0] = 258\n 'M=D', # M[258] = D\n '@SP', # A = 0\n 'M=M+1' # M[0] = 258 + 1\n )\n else\n segment_symbol = case segment\n when 'local'\n 'LCL'\n when 'argument'\n 'ARG'\n when 'this'\n 'THIS'\n when 'that'\n 'THAT'\n end\n\n assembly_builder.push(\n \"@#{index}\",\n 'D=A',\n \"@#{segment_symbol}\", # A = THAT = 4\n 'A=M',\n 'A=A+D', # A = 3010 + 5\n 'D=M', # D = M[3015]\n '@SP', # A = 0\n 'A=M', # A = M[0] = 257\n 'M=D', # M[257] = D = M[3015]\n '@SP', # A = 0\n 'M=M+1' # M[0] = 257 + 1\n )\n end\n # Pop\n elsif command == 'C_POP'\n if segment == 'temp'\n assembly_builder.push(\n '@SP', # A = 0\n 'AM=M-1', # A = M[0] - 1, M[0] = M[0] - 1\n 'D=M', # D = M[257]\n \"@#{5 + index.to_i}\", # A = 5 + index\n 'M=D'\n )\n elsif segment == 'pointer'\n assembly_builder.push(\n '@SP', # A = 0\n 'AM=M-1', # A = M[0] - 1, M[0] = M[0] - 1\n 'D=M', # D = M[257]\n \"@#{3 + index.to_i}\", # A = 5 + index\n 'M=D'\n )\n elsif segment == 'static'\n assembly_builder.push(\n '@SP', # A = 0\n 'AM=M-1', # A = M[0] - 1, M[0] = M[0] - 1\n 'D=M', # D = M[257]\n \"@#{file_name_without_ext}.#{index}\", # A = 6 + index\n 'M=D'\n )\n else\n segment_symbol = case segment\n when 'local'\n 'LCL'\n when 'argument'\n 'ARG'\n when 'this'\n 'THIS'\n when 'that'\n 'THAT'\n end\n\n assembly_builder.push(\n # RAM[RAM[SP]] -> RAM[RAM[segment]]\n \"@#{index}\", # A = 3\n 'D=A', # D = 3\n \"@#{segment_symbol}\", # A = 1\n 'D=M+D', # D = M[1] + 3 = 300 + 3\n 'M=D', # M[1] = 303\n '@SP', # A = 0\n 'AM=M-1', # A = M[0] - 1 = 258 -1\n 'D=M', # D = M[257]\n \"@#{segment_symbol}\", # A = 1\n 'A=M', # A = M[1] = 303\n 'M=D', # M[303] = M[257]\n \"@#{index}\", # A = 3\n 'D=A', # D = 3\n \"@#{segment_symbol}\", # A = 1\n 'M=M-D' # M[1] = M[1] - 3 = 303 - 3\n )\n end\n end\n\n return assembly_builder\n end",
"def stack(*args); end",
"def term\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 25 )\n __MULTIPLICATIONDIVISIONOPERATORS12__ = nil\n\n begin\n # at line 751:5: factor ( MULTIPLICATIONDIVISIONOPERATORS factor )*\n @state.following.push( TOKENS_FOLLOWING_factor_IN_term_1181 )\n factor\n @state.following.pop\n # at line 751:12: ( MULTIPLICATIONDIVISIONOPERATORS factor )*\n while true # decision 28\n alt_28 = 2\n look_28_0 = @input.peek( 1 )\n\n if ( look_28_0 == MULTIPLICATIONDIVISIONOPERATORS )\n alt_28 = 1\n\n end\n case alt_28\n when 1\n # at line 751:13: MULTIPLICATIONDIVISIONOPERATORS factor\n __MULTIPLICATIONDIVISIONOPERATORS12__ = match( MULTIPLICATIONDIVISIONOPERATORS, TOKENS_FOLLOWING_MULTIPLICATIONDIVISIONOPERATORS_IN_term_1184 )\n # --> action\n #Regla 3 GC\n \t\t @stack_operators.push(__MULTIPLICATIONDIVISIONOPERATORS12__.text)\n \t\t \n # <-- action\n @state.following.push( TOKENS_FOLLOWING_factor_IN_term_1211 )\n factor\n @state.following.pop\n # --> action\n #Regla 5 GC / VS\n \t\t if(@stack_operators.last == '*' or\n \t\t @stack_operators.last == '/' or\n \t\t @stack_operators.last == '&&') then\n \t\t operator = @stack_operators.pop\n \t\t operand_b = @stack_operands.pop\n \t\t operand_a = @stack_operands.pop\n \t\t result = get_avail\n \t\t generate(operator, operand_a, operand_b, result)\n \t\t free_avail(operand_a)\n \t\t free_avail(operand_b)\n free_avail_const(operand_a)\n free_avail_const(operand_b)\n \t\t @stack_operands.push(result)\n \t\t @stack_types.push(resulting_type(@stack_types.pop, @stack_types.pop, operator))\n \t\t end\n \t\t \n # <-- action\n\n else\n break # out of loop for decision 28\n end\n end # loop for decision 28\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 25 )\n\n end\n \n return \n end",
"def evaluate(ex)\n @stack=[]\n @expr.each do |el|\n case el\n when HopExprVar\n # evaluate variable\n var,dot,field=el.value.partition('.')\n if field==''\n # scalar\n val=VarStor.getScalar(ex,el.value)\n else\n # cortege field\n begin\n val=VarStor.getCortege(ex,var)[field]\n rescue\n warn \">> Opppps: #{var}.#{field}\"\n nil\n end\n end\n @stack.push val\n\n when Numeric, String\n # constant\n @stack.push el\n\n when HopExprOp\n case el.value\n when '+'\n a1=@stack.pop\n a2=@stack.pop\n warn \">>PLUS: #{a1},#{a2}\"\n raise SyntaxErrHopError if a2.nil?\n @stack.push a1.to_f+a2.to_f\n when '*'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a1.to_f*a2.to_f\n when '-'\n a1=@stack.pop\n a2=@stack.pop\n warn \">>MINUS: #{a1},#{a2}\"\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f-a1.to_f\n when '/'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f/a1.to_f\n when '%'\n a1=@stack.pop\n a2=@stack.pop\n raise SyntaxErrHopError if a2.nil?\n @stack.push a2.to_f%a1.to_f\n else\n raise SyntaxErrHopError\n end\n end #~case\n end # ~each expression\n raise SyntaxErrHopError.new(@expr.to_s+' ('+@stack.to_s+')') if @stack.size>1\n\n return @stack.pop\n end",
"def evaluate\n stack = Stack.new\n\n tokens.each do |token|\n if numeric?(token)\n stack.push(token.to_i)\n elsif operator?(token)\n args = []\n\n (SYMBOL_TABLE[token].arity - 1).times do\n # This adds the return value of stack.pop to the beginning of the\n # args array\n args.unshift(stack.pop)\n end\n\n # The *args syntax might be unfamiliar. It's called the \"splat\"\n # operator and among other things it lets you turn an array into\n # a list of arguments.\n stack.push(call_operator(stack, token, *args))\n else\n stack.push(token)\n end\n end\n\n stack.pop\n end",
"def minilang(input)\n\tstack = Array.new\n\tregister = 0\n\tinput.split.each do |x|\n\t\tcase x\n\t\twhen 'PUSH' then stack.push(register)\n\t\twhen 'ADD' then register += stack.pop\n\t\twhen 'SUB' then register -= stack.pop\n\t\twhen 'MULT' then register *= stack.pop\n\t\twhen 'DIV' then register /= stack.pop\n\t\twhen 'MOD' then register %= stack.pop\n\t\twhen 'POP' then register = stack.pop\n\t\twhen 'PRINT' then p register\n\t\telse\n\t\t\tregister = x.to_i\n\t\tend\n\tend\n\tregister\nend",
"def p8\n\tvalue = 7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\n\tvalue_array = value.to_s.split('').map(&:to_i)\n\tproducts = []\n\t(0...value_array.length-5).each do |i|\n\t\tproduct = value_array[i...i+5].reduce(:*)\n\t\tproducts << product\n\tend\n\tproducts.max\nend",
"def minilang(str)\n stack = []\n reg = 0\n \n commands = str.split(' ')\n \n commands.each {|command|\n case command\n when 'PRINT'\n puts reg\n when 'PUSH'\n stack.push(reg)\n when 'POP'\n reg = stack.pop\n when 'ADD'\n reg += stack.pop \n when 'SUB'\n reg -= stack.pop \n when 'MULT'\n reg *= stack.pop \n when 'DIV'\n reg /= stack.pop \n when 'MOD'\n reg %= stack.pop\n else\n reg = command.to_i\n end\n }\nend",
"def pop\n value2Return = nil\n if @data == nil\n puts \"Stack is empty\" \n else\n value2Return = @data.value\n @data = @data.next_node\n end\n value2Return\n end",
"def test_full_stack_push_and_pop\n puts \"test_full_stack_push_and_pop\"\n (rand(10) + 2).times do\n expects = []\n 100.times do\n expects << random_string\n pr = push(expects[-1])\n assert_equal(0, pr, \"expected 0, got #{pr}\")\n end\n\n 100.times do\n r = pop\n s = expects.pop\n assert_equal(s, r, \"expected #{s}, got #{r}\")\n end\n end\n end",
"def is_valid_stack_sequence?(pushed, popped)\n return false if pushed.length != popped.length\n\n debug = false\n puts \"pushed: #{pushed}, popped: #{popped}\" if debug\n\n working_stack = []\n \n popped_index = 0\n pushed_index = 0\n \n while (pushed_index < pushed.length)\n puts \"pop_i: #{popped_index}, push_i: #{pushed_index}\" if debug\n \n # check the stack for matches\n while working_stack[-1] && working_stack[-1] == popped[popped_index]\n pop = working_stack.pop\n popped_index += 1\n puts \"popped #{pop}, pop_i incr. to #{popped_index} in 1st while loop\" if debug\n end\n \n # increment pushed index until we find a match with current popped\n if (pushed[pushed_index] == popped[popped_index])\n pushed_index += 1\n popped_index += 1\n else \n # add pushed entry to stack for later comparison\n working_stack.push pushed[pushed_index]\n pushed_index += 1\n end\n end\n puts \"working_stack: #{working_stack}, pop_i: #{popped_index}, push_i: #{pushed_index}\" if debug\n while popped_index < popped.length \n if popped[popped_index] == working_stack[-1]\n # we found a match\n pop = working_stack.pop\n popped_index += 1\n puts \"popped #{pop}, pop_i incr. to #{popped_index}\" if debug\n else\n puts \"No match at end of stack. returning false\" if debug\n return false\n end\n end \n \n # if we're off the end of the popped array, we're done\n if working_stack.size > 0 || popped_index < popped.length\n puts \"stack: #{working_stack}, pop_i: #{popped_index}, returning false\" if debug\n return false\n end\n puts \"returning true\" if debug\n return true \n\nend",
"def test_stack_sum\n stack_size = QUANTITY_OF_LETTERS.reduce(0) { |acc,ite| acc + ite }\n assert_equal stack_size, stack.size\n end",
"def initialize()\n @stack=[]\n @value=0\n end",
"def virtual_computer(memory, registers)\n # Loop will continue until we reach the point in our memory array that\n # contains the halt instruction.\n while memory[registers[PC]] != HALT do\n puts \"============================\", \"No HALT yet\", \"============================\"\n puts \"PC: \", PC\n puts \"registers[PC]: \", registers[PC]\n puts \"memory[registers[PC]]: \", memory[registers[PC]]\n puts\n op = memory[registers[PC]]\n registers[PC] += 1\n case op\n when LOAD\n puts \"============================\", \"IN LOAD\", \"============================\"\n puts \"PC: \", PC\n puts \"registers[PC]: \", registers[PC]\n puts \"memory[registers[PC]]: \", memory[registers[PC]]\n register_address = memory[registers[PC]]\n puts \"register_address: \", register_address\n puts\n registers[PC] += 1\n word_address = memory[registers[PC]]\n puts \"word_address: \", word_address\n puts\n registers[PC] += 1\n # load both bytes in word\n # Have to add the 2 bytes together to get the \"full value\" if the value is greater than 1 byte.\n # Ex: 3 can be represeted in one byte, so we have 3 + 0 = 3\n # Ex: 5281 is too big for one byte, so we have 161 + (256 * 20) = 161 + 5120 = 5281\n # memory[word_address] is the least significant byte\n # memory[word_address + 1] is the most significant byte\n registers[register_address] = memory[word_address] + (256 * memory[word_address + 1])\n puts \"memory[word_address]: \", memory[word_address]\n puts \"(256 * memory[word_address + 1]) : \", (256 * memory[word_address + 1])\n puts \"registers[register_address]: \", registers[register_address]\n puts\n when STORE\n puts \"============================\", \"IN STORE\", \"============================\"\n puts \"PC: \", PC\n puts \"registers[PC]: \", registers[PC]\n puts \"memory[registers[PC]]: \", memory[registers[PC]]\n register_address = memory[registers[PC]]\n puts \"register_address: \", register_address\n puts\n registers[PC] += 1\n word_address = memory[registers[PC]]\n puts \"word_address: \", word_address\n puts\n registers[PC] += 1\n # We have to split our value so that it's represented by two bytes\n # write first (low order) byte\n # This will be the least significant byte so we find the value modulo 256\n memory[word_address] = registers[register_address] % 256\n puts \"memory[word_address]: \", memory[word_address]\n puts\n # write second (high order) byte\n # This will be the most significant byte so we find the value divided by 256,\n # which is the reverse of when we multiplied by 256\n memory[word_address + 1] = registers[register_address] / 256\n puts \"memory[word_address + 1]: \", memory[word_address + 1]\n puts\n when ADD\n puts \"============================\", \"IN ADD\", \"============================\"\n puts \"PC: \", PC\n puts \"registers[PC]: \", registers[PC]\n puts \"memory[registers[PC]]: \", memory[registers[PC]]\n register_address_a = memory[registers[PC]]\n puts \"register_address_a: \", register_address_a\n puts\n registers[PC] += 1\n register_address_b = memory[registers[PC]]\n puts \"register_address_b: \", register_address_b\n puts\n registers[PC] += 1\n # peform computation on values in registers\n registers[register_address_a] = registers[register_address_a] + registers[register_address_b]\n puts \"registers[register_address_a]: \", registers[register_address_a]\n puts\n end\n end\nend",
"def evalRPN(exp)\n begin\n expr = parseString(exp) # Parse expression into array\n\n stack = Stack.new # stack to keep track of operands\n\n # convert string to int or float\n case expr[0]\n when /\\.{1}/\n stack.push(atof(expr[0]))\n else\n stack.push(atoi(expr[0]))\n end\n\n for i in 1..expr.length\n\n # Addition - perform addition on previous two operands\n if expr[i] == '+' \n stack.push(calc stack.pop, stack.pop, &:+)\n\n # Subtraction - perform subtraction on previous two operands\n elsif expr[i] == '-'\n stack.push(calc stack.pop, stack.pop, &:-) \n\n # Division - perform division on previous two operands\n elsif expr[i] == '/'\n stack.push(calc (stack.pop/1.0), stack.pop, &:/)\n\n # Multiplication - perform mult on previous two operands\n elsif expr[i] == '*'\n stack.push(calc stack.pop, stack.pop, &:*)\n\n # Just a number -- add to stack\n else\n next if expr[i] == nil # dont add nil to stack\n\n case expr[i]\n when /\\.{1}/\n stack.push(atof(expr[i]))\n else\n stack.push(atoi(expr[i]))\n end\n end\n end\n\n # No operator provided\n raise NotEnoughException if stack.size != 1\n \n return stack.pop # Return answer\n\n rescue NotEnoughException => e\n abort(e.mes) # inform user of error\n end\n\nend",
"def _evaluate_input(stack, input)\n # Print out the state of the stack and input every time the recursive function is called.\n puts \"\\tStack: #{stack.inspect}\"\n puts \"\\tInput: #{input.inspect}\"\n puts \"\\t#{'_' * 80}\\n\\n\"\n\n # If both the stack and the input are both empty, then ACCEPT\n if stack.is_empty and input.is_empty\n puts \"\\n\\n\\tACCEPTED: Stack and input are empty.\\n\"\n return 'ACCEPT'\n end\n\n # If either the stack or the input is empty and the other one is not, REJECT\n if stack.is_empty and !input.is_empty\n puts \"\\n\\n\\tREJECTED: Stack is empty while the input is not!\\n\"\n return 'REJECT'\n end\n\n # Pop an element off the stack\n element = stack.pop!\n\n # If the popped element is a variable, peek at the next character in the input, then search for\n # element→next_character. The next rule found lives at that index. Push the right hand side of\n # that rule to the stack. If no rule is found, reject the string.\n if is_variable(element)\n # peek at the next character in the input\n next_character = input.peek\n\n # find the rule that has the next character in the input as the first character\n # on the right hand side of the relation.\n index = matching_rule(\"#{element}→#{next_character}\", cfg.relations)\n\n # If no rule was found, REJECT\n if index == nil\n puts \"\\n\\n\\tREJECTED: No matching rule was found\\n\"\n return 'REJECT'\n end\n\n # If the rule was found, then push the right hand side of that rule to the stack\n stack.push(cfg.relations[index][2..-1])\n\n # Call the function again on the CFG with the new stack.\n return _evaluate_input(stack, input)\n end\n\n # If a terminal was popped off the stack, first pop the next character from the input. If the\n # character popped off the stack does not match the character popped off the input, then REJECT.\n # Otherwise, call the function again on the modified CFG\n if is_terminal(element)\n\n #first pop the next character off the input\n next_character = input.pop!\n\n #if the next character is not the same as the terminal popped off the stack, REJECT\n if next_character != element\n puts \"\\n\\n\\tREJECTED: Next character in input does not match top of stack\\n\"\n return 'REJECT'\n end\n\n return _evaluate_input(stack, input)\n end\n\n puts \"\\n\\n\\tREJECTED: Item popped off stack is not in alphabet!\\n\"\n puts ' (CFG was malformed)'\n 'REJECT'\n end",
"def do_minus s; a = mega_pop(s); b = mega_pop(s); s[:stack].push(b-a); end",
"def evaluate(postfix)\n stack = Stack.new\n operators = \"+-*/^\"\n for i in 0..postfix.size-1\n if !operators.include?(postfix[i])\n stack.push(postfix[i].to_i)\n else\n case postfix[i]\n when '+'\n value = stack.pop() + stack.pop\n when '-'\n b = stack.pop()\n value = stack.pop() - b\n when '*'\n value = stack.pop() * stack.pop\n when '/'\n b = stack.pop()\n value = stack.pop() / b\n when '^'\n b = stack.pop()\n value = stack.pop ^ b\n end\n stack.push(value)\n end\n end\n stack.pop\nend",
"def question_two\n set = SetOfStacks.new(5)\n set.push(3)\n set.push(2)\n set.push(5)\n set.push(1)\n set.push(7)\n set.push(4)\n set.push(2)\n set.push(8)\n set.push(2)\n set.push(1)\n set.push(3)\n set.push(5)\n set.pop\n set.pop_at(1)\n set\nend",
"def evaluate\n stack = Stack.new\n\n tokens.each do |token|\n if numeric?(token)\n stack.push(token.to_i)\n elsif operator?(token)\n args = []\n\n SYMBOL_TABLE[token].arity.times do\n # This adds the return value of stack.pop to the beginning of the\n # args array\n args.unshift(stack.pop)\n end\n\n # The *args syntax might be unfamiliar. It's called the \"splat\"\n # operator and among other things it lets you turn an array into\n # a list of arguments.\n stack.push(call_operator(token, *args))\n else\n raise \"omg what is this token even?\"\n end\n end\n\n stack.pop\n end",
"def plus\n if @stack == []\n raise ArgumentError, \"calculator is empty\"\n else\n last_two = @stack.last(2)\n @stack = @stack[0..-3]\n # map(&:to_i)\n plus_result = last_two.inject(:+)\n @stack << plus_result\n @stack\n end\n end",
"def pop()\n return \"Stack is empty\" if is_empty\n\n if @head.next == nil\n temp = @head.value\n @head = nil\n return temp\n end\n\n temp = @head.value\n @head = @head.next\n @current_size -= 1\n\n return temp\n end",
"def pop\n @stack.pop\n @pc += 1\n end",
"def expression\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n __COMPARITIONOPERATORS10__ = nil\n\n begin\n # at line 705:5: exp ( COMPARITIONOPERATORS exp )?\n @state.following.push( TOKENS_FOLLOWING_exp_IN_expression_1070 )\n exp\n @state.following.pop\n # at line 705:9: ( COMPARITIONOPERATORS exp )?\n alt_26 = 2\n look_26_0 = @input.peek( 1 )\n\n if ( look_26_0 == COMPARITIONOPERATORS )\n alt_26 = 1\n end\n case alt_26\n when 1\n # at line 705:10: COMPARITIONOPERATORS exp\n __COMPARITIONOPERATORS10__ = match( COMPARITIONOPERATORS, TOKENS_FOLLOWING_COMPARITIONOPERATORS_IN_expression_1073 )\n # --> action\n #Regla 8\n \t @stack_operators.push(__COMPARITIONOPERATORS10__.text)\n \t \n # <-- action\n @state.following.push( TOKENS_FOLLOWING_exp_IN_expression_1087 )\n exp\n @state.following.pop\n # --> action\n #Regla 9\n \t\t operator = @stack_operators.pop\n \t\t operand_b = @stack_operands.pop\n \t\t operand_a = @stack_operands.pop\n \t\t result = get_avail\n \t\t generate(operator, operand_a, operand_b, result)\n \t\t free_avail(operand_a)\n \t\t free_avail(operand_b)\n \t\t free_avail_const(operand_a)\n \t\t free_avail_const(operand_b)\n \t\t @stack_operands.push(result)\n \t\t @stack_types.push(resulting_type(@stack_types.pop, @stack_types.pop, operator))\n \t \n # <-- action\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 23 )\n\n end\n \n return \n end",
"def evaluate_with_two_stacks(string)\n vals = Stack.new\n ops = Stack.new\n\n string.each_char do |char|\n case char\n when \"(\"\n # do nothing\n when \"+\"\n ops.push(char)\n when \"*\"\n ops.push(char)\n when \")\"\n op = ops.pop\n case op\n when \"+\"\n vals.push(vals.pop + vals.pop)\n when \"*\"\n vals.push(vals.pop * vals.pop)\n end\n else\n vals.push(char.to_i)\n end\n end\n\n vals.pop\nend",
"def minus()\n \t\terror?\n \t\tsecond = @stack.pop\n \t\tfirst = @stack.pop\n \t\t@stack << (first - second)\n end",
"def stacks_sub(arg)\n ya_ta = tuc(\"x_ya\")\n ra_ta = tuc(\"x_ra\")\n la_ta = tuc(\"x_la\")\n wa_ta = tuc(\"x_wa\")\n\n h = Hash.[](\n # subscript ya\n \"ky\"=>ya_ta, \"khy\"=>ya_ta, \"gy\"=>ya_ta,\n \"py\"=>ya_ta, \"phy\"=>ya_ta, \"by\"=>ya_ta, \"my\"=>ya_ta,\n # subscript ra\n \"kr\"=>ra_ta, \"khr\"=>ra_ta, \"gr\"=>ra_ta,\n \"tr\"=>ra_ta, \"thr\"=>ra_ta, \"dr\"=>ra_ta,\n \"pr\"=>ra_ta, \"phr\"=>ra_ta, \"br\"=>ra_ta, \"mr\"=>ra_ta,\n \"shr\"=>ra_ta, \"sr\"=>ra_ta, \"hr\"=>ra_ta,\n # subscript la\n \"kl\"=>la_ta, \"gl\"=>la_ta, \"bl\"=>la_ta,\n \"zl\"=>la_ta, \"rl\"=>la_ta, \"sl\"=>la_ta,\n # subscript wa\n \"kw\"=>wa_ta, \"khw\"=>wa_ta, \"gw\"=>wa_ta, \"grw\"=>ra_ta+wa_ta,\n \"cw\"=>wa_ta, \"nyw\"=>wa_ta, \"tw\"=>wa_ta,\n \"dw\"=>wa_ta, \"tsw\"=>wa_ta, \"tshw\"=>wa_ta,\n \"zhw\"=>wa_ta, \"zw\"=>wa_ta, \"rw\"=>wa_ta,\n \"lw\"=>wa_ta, \"shw\"=>wa_ta, \"sw\"=>wa_ta, \"hw\"=>wa_ta,\n # subscript 'a\n \"t'\"=>tuc(\"x_'a\"), \"h'\"=>tuc(\"x_'a\"), \"a'\"=>tuc(\"x_'a\"))\n h[arg]\n end",
"def plus\n return error_message if stack.empty?\n x = stack.pop\n y = stack.pop\n stack << x + y\n @value = x + y\n end",
"def put\n\t\t\tputs STACK.last \n\t\tend",
"def add_stacks\n variable_stack.add_stack\n value_stack.add_stack\n end",
"def arithmeticBinary(op)\n str = getTopTwoFromStack + \"M=M\"+op+\"D\"+\"\\n\"\n return str+\"\\n\"\nend",
"def times()\n \t\terror?\n \t\t@stack << (@stack.pop * @stack.pop)\n end",
"def mod\n x, y = stack.pop(2)\n push x % y\n end",
"def build_stack\n stack = Stack.new\n rand(1..10).times do |i| \n stack.push(i)\n end\n return stack\nend",
"def interpreter\n dfaStack = [ ] \n loop do\n line = gets\n words = line.scan(/\\S+/)\n words.each{ |word|\n case word\n when /DONE/\n return\n when /DOT/\n f = dfaStack.last\n f.dotfile\n when /SIZE/\n f = dfaStack.last\n puts f.num_states\n when /PRINT/\n f = dfaStack.last\n f.prettyPrint\n when /DFA/\n f = dfaStack.pop\n f2 = f.toDFA\n dfaStack.push f2\n when /MINIMIZE/\n f = dfaStack.pop\n f2 = f.minimize\n dfaStack.push f2\n when /GENSTR([0-9]+)/\n f = dfaStack.last\n puts f.genStr($1)\n when /\"([a-z]*)\"/\n f = dfaStack.last\n str = $1\n if f.accept?(str)\n puts \"Accept #{str}\"\n else\n puts \"Reject #{str}\"\n end\n when /([a-zE])/\n puts \"Illegal syntax for: #{word}\" if word.length != 1\n f = NFA.new #changed from FA because it always gonna create a new NFA object\n sym = $1\n sym=\"\" if $1==\"E\"\n f.symbol!(sym)\n dfaStack.push f\n when /\\*/\n puts \"Illegal syntax for: #{word}\" if word.length != 1\n f = dfaStack.pop\n f.closure!\n dfaStack.push f\n when /\\|/\n puts \"Illegal syntax for: #{word}\" if word.length != 1\n f1 = dfaStack.pop\n f2 = dfaStack.pop\n f2.union!(f1)\n dfaStack.push f2\n when /\\./\n puts \"Illegal syntax for: #{word}\" if word.length != 1\n f1 = dfaStack.pop\n f2 = dfaStack.pop\n f2.concat!(f1)\n dfaStack.push f2\n else\n puts \"Ignoring #{word}\"\n end\n }\n end\nend",
"def scopify(expr)\n expr = insert_b(expr)\n @i = 0\n n_expr = \"\"\n last_empty = 0\n open_b = 0\n open_p_b = 0\n open_m_b = 0\n eq = false\n stack = Array.new\n last_e = Array.new\n state = 0\n while @i < expr.size\n case expr[@i]\n # Each part between brackets is seen as a subexpression\n # and it is analyzed recoursively.\n when '('\n scp = Scp.new\n n_expr += expr[@i] + scp.scopify(extract(expr[(@i + 1)...expr.length])) \n @i += scp.count \n when /[\\*\\/]/\n # If there are open brackets of higher opertions\n # it closes them\n if open_m_b > 0\n n_expr += ')' * open_m_b\n last_empty = last_e.pop\n open_m_b = 0\n #open_b -= 1\n end\n if state == 2\n n_expr += ')' * open_p_b\n open_p_b = 0\n state = (stack.size > 0 ? stack.pop : 0)\n end\n # If it is not still analyzing a multiplication, it adds the brackets \n # following the rules\n unless state == 1\n n_expr.insert last_empty, '(' \n state = 1\n open_b += 1\n end\n n_expr += expr[@i]\n last_empty = n_expr.size # + 1\n when /[\\+\\-]/\n # higher priority operation brackets are closed\n # last_empty is shifted\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n state = 0\n open_b = 0\n open_p_b = 0\n n_expr += expr[@i]\n last_empty = n_expr.size\n when /\\^/\n # It begins to put between brackets the operation and its exponent\n if open_m_b > 0 then\n n_expr += \")\" * open_m_b\n last_empty = last_e.pop\n #open_b -= 1\n open_m_b = 0\n end\n n_expr.insert last_empty, '(' unless state == 2\n last_empty += 1 unless state == 2\n n_expr += expr[@i] + (expr[@i+1] == '(' ? '' : '(')\n open_p_b += (expr[@i+1] == '(' ? 1 : (state == 2 ? 1:2))\n stack.push state unless state == 2\n state = 2\n when /\\=/\n # The expression at the left of `=` is put between brackets\n # and a bracket at the right is opened\n # It closes previously opened brackets\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n n_expr += ')' * open_m_b if open_m_b >0\n open_b = 0\n open_p_b = 0\n open_m_b = 0\n n_expr = '(' + n_expr + ')' + expr[@i]\n n_expr += '('\n last_empty = n_expr.size\n state = 0\n eq = true\n when /\\>/\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n open_b = 0\n open_p_b = 0\n n_expr = '(' + n_expr + ')' + expr[@i]\n last_empty = n_expr.size\n when /\\:/\n n_expr.insert last_empty, '('\n n_expr += expr[@i]\n last_k = n_expr[(last_empty+1)...n_expr.size]\n open_m_b += 1 if \"mx:integ:as:from:\".include? last_k\n last_e.pop if last_e.count > 0 and (last_k == \"mx:\" or last_k == \"integ:\")# or last_k == \"solve:\")\n last_e.push last_empty if last_k == \"mx:\" or last_k == \"integ:\"# or last_k == \"solve:\"\n last_empty = n_expr.size\n open_b += 1 unless \"mx:integ:as:from:\".include? last_k\n when /\\\"/\n n_expr += expr[@i]\n @i += 1\n n_expr += discard(expr)\n last_empty = n_expr.length\n when /\\~/\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * (open_b - 1 ) if open_b - 1 > 0\n open_p_b = 0\n open_b = 1\n state = (stack.size > 0 ? stack.pop : 0)\n n_expr += expr[@i]\n last_empty = n_expr.size \n else\n n_expr += expr[@i]\n end\n @i += 1\n end\n # it closes all the opened brackets\n n_expr += ')' * open_m_b if open_m_b > 0\n n_expr += ')' * open_p_b if open_p_b > 0\n n_expr += ')' * open_b if open_b > 0\n n_expr += ')' if eq\n return n_expr\n end",
"def test_push_and_pop\n\tn = Stack.new()\n\tn.push(3)\n\tn.push(4)\n\tn.push(5)\n\tassert_equal(5, n.pop)\n\tassert_equal(4, n.pop)\n\tassert_equal(3, n.pop)\n\tassert_raise(RuntimeError) {n.pop}\n end",
"def to_stack; end",
"def expr()\n\n\n begin\n @ruleStack.push('expr')\n # dice.g:52:7: ( mult ( '+' mult | '-' mult )* )\n # dice.g:52:7: mult ( '+' mult | '-' mult )*\n\n #@following.push(FOLLOW_mult_in_expr65)\n mult()\n #@following.pop\n\n\n # dice.g:52:12: ( '+' mult | '-' mult )*\n #catch (:loop1) do\n \twhile true\n \t\talt1 = 3\n \t\tlook_ahead1_0 = input.look_ahead(1).token_type\n \t\tif look_ahead1_0 == 6 \n \t\t alt1 = 1\n \t\telsif look_ahead1_0 == 7 \n \t\t alt1 = 2\n\n \t\tend\n\n \t\tcase alt1\n \t\t\twhen 1\n \t\t\t # dice.g:53:5: '+' mult\n\n \t\t\t match(6, nil) # FOLLOW_6_in_expr73\n\n\n \t\t\t #@following.push(FOLLOW_mult_in_expr75)\n \t\t\t mult()\n \t\t\t #@following.pop\n\n\n\n \t\t\t a, b = @stack.pop, @stack.pop\n \t\t\t dbg \"\\nAdd: #{b} + #{a}\"\n \t\t\t @stack.push(b + a)\n \t\t\t \n\n\n\n \t\t\twhen 2\n \t\t\t # dice.g:58:5: '-' mult\n\n \t\t\t match(7, nil) # FOLLOW_7_in_expr83\n\n\n \t\t\t #@following.push(FOLLOW_mult_in_expr85)\n \t\t\t mult()\n \t\t\t #@following.pop\n\n\n\n \t\t\t a, b = @stack.pop, @stack.pop\n \t\t\t dbg \"\\nSubtract: #{b} - #{a}\"\n \t\t\t @stack.push(b - a)\n \t\t\t \n\n\n\n\n \t\t\telse\n \t\t\t\tbreak\n \t\t\t\t#throw :loop1\n \t\tend\n \tend\n #end\n\n\n\n\n rescue ANTLR::RecognitionException => e\n report_error(e)\n #raise e\n ensure\n @ruleStack.pop\n end\n\n end",
"def exch\n push *(stack.pop(2).reverse)\n end",
"def stack\n @values.fetch('stack') { \n @values['stack'] = nil\n }\n end",
"def execute()\n while !@stop do\n @curr_char = @source_lines[@line_num][@col_num]\n\n if @step == true\n debug()\n end\n\n if @ascii_mode == true\n if @curr_char == '\"'\n @ascii_mode = false\n else\n @stack.push(@curr_char.ord())\n end\n\n move()\n next\n end\n\n\n case @curr_char\n when '+'\n # Pop two values a and b then push the result a+b\n a = popstack()\n b = popstack()\n @stack.push(a + b)\n when '-'\n # Pop two values a and b then push the result b-a\n a = popstack()\n b = popstack()\n @stack.push(b - a)\n when '*'\n # Pop two values a and b then push the result a*b\n a = popstack()\n b = popstack()\n @stack.push(a * b)\n when '/'\n # Pop two values a and b then push the result b/a.\n # If a is zero ask the user what result they want (this is actually in the spec)\n a = popstack()\n b = popstack()\n\n if a == 0\n puts \"Division by zero! What result do you want this to have?\"\n loop do\n prompt()\n ans = STDIN.gets\n\n if ans.respond_to?(\"to_i\")\n @stack.push(ans.to_i())\n break\n elsif ans.respond_to?(\"ord\")\n @stack.push(ans.ord())\n break\n end\n puts \"Invalid answer, please enter a better one\"\n end\n else\n @stack.push(b/a.floor())\n end\n when '%'\n # Pop two values a and b then push the result b%a.\n # If a is zero ask the user what result they want. Not in the spec but seems appropriate.\n a = popstack()\n b = popstack()\n\n if a == 0\n puts \"Division by zero! What result do you want this to have?\"\n loop do\n prompt()\n ans = STDIN.gets\n\n if ans.respond_to?(\"to_i\")\n @stack.push(ans.to_i())\n break\n elsif ans.respond_to?(\"ord\")\n @stack.push(ans.ord())\n break\n end\n puts \"Invalid answer, please enter a better one\"\n end\n else\n @stack.push(b%a)\n end\n when '!'\n # Pop a value a and perform logical NOT on it. If it is 0, push 1 otherwise push 0.\n a = popstack()\n if a == 0\n @stack.push(1)\n else\n @stack.push(0)\n end\n when '`'\n # Greater than. Pop two values a and b and push 1 if b>a otherwise 0.\n a = popstack()\n b = popstack()\n\n if b > a\n @stack.push(1)\n else\n @stack.push(0)\n end\n when '>'\n # PC direction right\n @curr_direction = :right\n when '<'\n # PC direction left\n @curr_direction = :left\n when '^'\n # PC direction up\n @curr_direction = :up\n when 'v'\n # PC direction down\n @curr_direction = :down\n when '?'\n # Random PC direction\n prng = Random.new()\n num = prng.rand(4)\n\n case num\n when 0\n @curr_direction = :up\n when 1\n @curr_direction = :down\n when 2\n @curr_direction = :left\n when 3\n @curr_direction = :right\n end\n when '_'\n # Horizontal if. Pop a value. PC goes right if it is zero, left otherwise\n a = popstack()\n\n if a == 0\n @curr_direction = :right\n else\n @curr_direction = :left\n end\n when '|'\n # Vertical if. Pop a value. PC goes down if it is zero, up otherwise\n a = popstack()\n\n if a == 0\n @curr_direction = :down\n else\n @curr_direction = :up\n end\n when '\"'\n # Toggle stringmode. Push each character's ASCII value until we see the next '\"'\n @ascii_mode = !@ascii_mode\n when ':'\n # Duplicate top stack value\n a = popstack()\n @stack.push(a)\n @stack.push(a)\n when '\\\\'\n # Swap top stack values\n a = popstack()\n b = popstack()\n @stack.push(a)\n @stack.push(b)\n when '$'\n # Discard top stack value\n popstack()\n when '.'\n # Pop the top of the stack and output as integer\n a = popstack()\n\n if a.respond_to?(\"ord\")\n print a.ord\n else\n print a\n end\n when ','\n # Pop the top of the stack and output as ASCII character\n a = popstack()\n\n if a.respond_to?(\"chr\")\n print a.chr\n else\n print a\n end\n when '#'\n # Jump over the next command in the current direction of the current PC\n @skip = true\n when 'g'\n # A get call. Basically the program and data are stored together so this pops two values y and x\n # and retrieves the character at (x,y). It then pushes the ASCII value of this character\n # If (x,y) is out of bounds, push 0 as per the specification.\n y = popstack()\n x = popstack()\n\n if @source_lines.length <= y\n @stack.push(0)\n elsif @source_lines[y].length <= x\n @stack.push(0)\n else\n c = @source_lines[y][x]\n\n if c.respond_to?(\"ord\")\n @stack.push(c.ord())\n end\n end\n when 'p'\n # A put call. Retrieves co-ordinates y and x from the stack and also a value v. It then changes\n # the character at (x,y) to the character with ASCII value v\n y = popstack()\n x = popstack()\n v = popstack()\n\n if v.respond_to?(\"chr\")\n @source_lines[y][x] = v.chr()\n end\n when '&'\n # Get integer from user and push it\n puts \"Enter an integer\"\n loop do\n prompt()\n ans = STDIN.gets\n\n if ans.respond_to?(\"to_i\")\n @stack.push(ans.to_i())\n break\n end\n puts \"Not an integer. Please enter only digits\"\n end\n when '~'\n # Get a character from user and push it\n puts \"Enter a character\"\n loop do\n prompt()\n ans = STDIN.gets\n\n if ans.respond_to?(\"ord\")\n @stack.push(ans.ord())\n break\n end\n puts \"Please enter a character\"\n end\n when '@'\n # End program\n puts \"\\n\\nProgram finished. Exiting...\"\n @stop = true\n when '0'..'9'\n # Push integer onto stack\n @stack.push(@curr_char.to_i())\n end\n\n # Move the PC\n move()\n\n # For debugging. Without this the skipped character isn't show in debug which\n # can be confusing\n if @skip == true\n @curr_char = @source_lines[@line_num][@col_num]\n\n if @step == true\n debug()\n end\n\n move()\n @skip = false\n end\n end\n end",
"def interpreter file\ndfaStack = [ ]\nloop do\nline = file.gets\nif line == nil then break end\nwords = line.scan(/\\S+/)\nwords.each{ |word|\ncase word\nwhen /DONE/\nreturn\nwhen /DOT/\nf = dfaStack.last\nf.dotfile\nwhen /SIZE/\nf = dfaStack.last\nputs f.num_states\nwhen /PRINT/\nf = dfaStack.last\nf.prettyPrint\nwhen /DFA/\nf = dfaStack.pop\nf2 = f.toDFA\ndfaStack.push f2\nwhen /MINIMIZE/\nf = dfaStack.pop\nf2 = f.minimize\ndfaStack.push f2\nwhen /GENSTR([0-9]+)/\nf = dfaStack.last\nputs f.genStr($1)\nwhen /\"([a-z]*)\"/\nf = dfaStack.last\nstr = $1\nif f.accept?(str, f.get_start)\nputs \"Accept #{str}\"\nelse\nputs \"Reject #{str}\"\nend\nwhen /([a-zE])/\nputs \"Illegal syntax for: #{word}\" if word.length != 1\nf = FiniteAutomaton.new\nsym = $1\nsym=\"\" if $1==\"E\"\nf.symbol!(sym)\ndfaStack.push f\nwhen /\\*/\nputs \"Illegal syntax for: #{word}\" if word.length != 1\nf = dfaStack.pop\nf.closure!\ndfaStack.push f\nwhen /\\|/\nputs \"Illegal syntax for: #{word}\" if word.length != 1\nf1 = dfaStack.pop\nf2 = dfaStack.pop\nf2.union!(f1)\ndfaStack.push f2\nwhen /\\./\nputs \"Illegal syntax for: #{word}\" if word.length != 1\nf1 = dfaStack.pop\nf2 = dfaStack.pop\nf2.concat!(f1)\ndfaStack.push f2\nelse\nputs \"Ignoring #{word}\"\nend\n}\nend\nend",
"def disassemble memory \n #we're going to be parsing 16-bit instructions. these masks will allow us to\n #get meaningful data out of out of those 16 bits\n #to use: (instruction & mask) >> x, where x is the index of the\n #least-significant bit of of the mask\n #e.g (0x00011011000001100 & opcode mask) >> 12 = 0001\n\n #opcode mask\n opcode_mask = 0xF000\n\n #destination/base and source register masks\n reg1_mask = 0xE00 #the register found at bits 11 through 9\n reg2_mask = 0x1C0 #the register found at bit 8 through 6\n reg3_mask = 0x7 #the register found at bits 2 through 0\n\n #condition code masks\n br_cc_mask = 0xE00 #the whole kitten kaboodle, >> 9\n br_n_mask = 0x800 # >> 11\n br_z_mask = 0x400 # >> 10\n br_p_mask = 0x200 # >> 9\n\n #imm5 vs source register flag mask\n #if 0, using 2 registers. if 1, using a register and a imm5\n operand2_flag_mask = 0x20 # >> 5\n\n #jsr vs jsrr flag mask\n #if 0, jsrr. if 1, jsr\n jsr_flag_mask = 0x800 # >> 7\n\n #offset masks\n #offset masks are always the least significant x bits\n offset9_mask = 0x1FF\n offset11_mask = 0x7FF\n offset6_mask = 0x3f\n\n #imm5 mask\n #always lsb\n imm5_mask = 0x1F\n\n #trap vector mask\n #always lsb\n trap_vector_mask = 0xFF\n\n \n #opcodes\n add_code = 0x1\n and_code = 0x5\n br_code = 0x0\n jmp_code = 0xC\n jsr_code = 0x4\n ld_code = 0x2\n ldi_code = 0xA\n ldr_code = 0x6\n lea_code = 0xE\n not_code = 0x9\n rti_code = 0x8\n st_code = 0x3\n sti_code = 0xB\n str_code = 0x7\n #trap_code = 0xF\n halt_code = 0xF025 # we only have 1 trap (0xF---), and thats halt\n\n\n #opcode strings\n add_string = \"ADD\"\n and_string = \"AND\"\n br_string = \"BR\"\n jmp_string = \"JMP\"\n jsr_string = \"JSR\"\n jsrr_string = \"JSRR\"\n ld_string = \"LD\"\n ldi_string = \"LDI\"\n ldr_string = \"LDR\"\n lea_string = \"LEA\"\n not_string = \"NOT\"\n nop_string = \"NOP\"\n ret_string = \"RET\"\n rti_string = \"RTI\"\n st_string = \"ST\"\n sti_string = \"STI\"\n str_string = \"STR\"\n trap_string = \"TRAP\"\n\n #other strings\n n_string = \"N\"\n z_string = \"Z\"\n p_string = \"P\"\n comma_string = \",\"\n halt_string = \"HALT\"\n space_string = \" \"\n r_string = \"R\" #as in register, R1, R2, ...\n error_string = \"ERROR\"\n hash_string = \"#\"\n \n #sign extension addends\n #we can encounter 2's complement numbers that are negative in x number of\n #bits, but not y number.\n #\n #for example: (binary) 0000 0101\n #in 3-bit 2's comp, this number is -3\n #in 8-bit 2's comp, this number is 5\n #\n #since ruby and lc3 have no (primitive) understanding of numbers with smaller \n #bit lengths than the system default (32 and 16 respectively), we need to sign\n #extend these numbers so that the system also conveys bit these lengths.\n #\n #for negative 2's complement numbers, if we assume that the msb == the desired\n #bit length (ie, the number has been masked so that it contains no other data\n #beyond the desired bit length) then we can simply add an appropriate addend\n #constructed of all 1's in all places beyond the msb.\n #\n #extending our previous example: \n #-3 = 1111 1101 = 1111 1000 + 0000 0101\n #\n #the following are these addends for various desired bit lengths\n #\n #NOTE: this is a system-dependent implementation. on this dev machine, the\n #integers we get by default are 32 bits. on lc3, its 16, and it could be\n #anything else for other machines. proceed with caution.\n# bit5_extender = 0xFFFFFFE0\n# bit6_extender = 0xFFFFFFC0\n# bit9_extender = 0xFFFFFE00\n# bit11_extender = 0xFFFFF800\n\n \n #a more asm way of saying index counter\n instruction_ptr = 0x0\n\n while memory[instruction_ptr] - 0xFFFF != 0\n this_instruction = memory[instruction_ptr]\n \n this_opcode = (this_instruction & opcode_mask) >> 12\n\n #we'll force the opcode code to turn this on\n #if we get down to the bottom, and this hasn't been set, we've encountered\n #one of the no-no opcodes for this homework, such as RTI, (reserved \n #opcode),or traps other thanHALT. in that case, write ERROR\n valid_instruction = 0\n \n #ADD\n #example: ADD R0, R0, R5\n #example: ADD R0, R3, #17\n if this_opcode - add_code == 0\n print add_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n print comma_string\n print space_string\n \n #immediate more or source register 2 mode?\n flag = (this_instruction & operand2_flag_mask) >> 5\n if flag == 0\n print r_string\n reg = (this_instruction & reg3_mask)\n print reg\n end\n if flag == 1\n imm5 = (this_instruction & imm5_mask)\n print hash_string\n print imm5\n end\n\n valid_instruction = 1\n end\n \n #AND\n #example: AND R0, R0, R5\n #example: AND R0, R3, #17\n if this_opcode - and_code == 0\n print and_string\n print space_string\n \n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n print comma_string\n print space_string\n \n flag = (this_instruction & operand2_flag_mask) >> 5\n if flag == 0\n print r_string\n reg = (this_instruction & reg3_mask)\n print reg\n end\n if flag == 1\n imm5 = (this_instruction & imm5_mask)\n print hash_string\n print imm5\n end\n\n valid_instruction = 1\n end\n \n #BR and NOP\n #example: BR NZP #4\n #example: NOP\n if this_opcode - br_code == 0\n cc = (this_instruction & br_cc_mask) >> 9\n if cc == 0\n print nop_string\n else\n print br_string\n \n #n set?\n n = (this_instruction & br_n_mask) >> 11\n if n > 0\n print n_string\n end\n \n #z set?\n z = (this_instruction & br_z_mask) >> 10\n if z > 0\n print z_string\n end\n \n #p set?\n p = (this_instruction & br_p_mask) >> 9\n if p > 0\n print p_string\n end\n \n print space_string\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n end\n\n valid_instruction = 1\n end\n\n #JMP and RET\n #example: JMP R5\n #example: RET\n if this_opcode - jmp_code == 0\n #ret and jmp share the same opcode\n reg = (this_instruction & reg2_mask) >> 6\n if reg - 7 == 0\n print ret_string\n else\n print jmp_string\n print space_string\n\n print r_string\n print reg\n end\n \n valid_instruction = 1\n end\n\n #JSR and JSRR\n #example: JSR #123\n #example: JSRR R3\n if this_opcode - jsr_code == 0\n #jsr and jsrr share the same opcode\n jsr_flag = (this_instruction & jsr_flag_mask) >> 11\n if jsr_flag > 0\n offset = (this_instruction & offset11_mask)\n print jsr_string\n print space_string\n\n print hash_string\n print offset\n else\n print jsrr_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n end\n\n valid_instruction = 1\n end\n\n #LD\n #example: LD R3, #5\n if this_opcode - ld_code == 0\n print ld_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n \n valid_instruction = 1\n end\n\n #LDI\n #example: LDI R2, #22\n if this_opcode - ldi_code == 0\n print ldi_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n \n valid_instruction = 1\n end\n\n #LDR\n #example: LDR R0, R4, #5\n if this_opcode - ldr_code == 0\n print ldr_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset6_mask)\n print hash_string\n print offset\n \n valid_instruction = 1\n end\n\n #LEA\n #example: LEA R3, #2\n if this_opcode - lea_code == 0\n print lea_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n \n valid_instruction = 1\n end\n\n #NOT\n #example: NOT R0, R0\n if this_opcode - not_code == 0\n print not_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n \n valid_instruction = 1\n end\n\n #ST\n #example: ST R1, #46\n if this_opcode - st_code == 0\n print st_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n\n valid_instruction = 1\n end\n\n #STI\n #example: STI R0, #128\n if this_opcode - sti_code == 0\n print sti_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset9_mask)\n print hash_string\n print offset\n\n valid_instruction = 1\n end\n\n #STR\n #example STR R0, R1, #3\n if this_opcode - str_code == 0\n print str_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg1_mask) >> 9\n print reg\n print comma_string\n print space_string\n\n print r_string\n reg = (this_instruction & reg2_mask) >> 6\n print reg\n print comma_string\n print space_string\n\n offset = (this_instruction & offset6_mask)\n print hash_string\n print offset\n\n valid_instruction = 1\n\n end\n\n #HALT\n #example: HALT\n if this_instruction - halt_code == 0\n print halt_string\n\n valid_instruction = 1\n end\n\n #ERROR (for all not accepted instructions)\n #example: ERROR\n if valid_instruction == 0\n print error_string\n end\n\n print \"\\n\"\n\n instruction_ptr += 1\n end\nend",
"def sub\n x, y = stack.pop(2)\n push x - y\n end",
"def evaluate(inputs=[], soft_fail=true)\n stack = Stack.new\n tokens.each do |token|\n if numeric?(token)\n stack.push(token.to_f)\n elsif token.start_with? \"i\"\n if inputs.size == 0\n next if soft_fail\n raise \"Trying to use 'i' token with 0 inputs\"\n end\n # input:\n index = token[1..-1].to_i % inputs.size\n stack.push(inputs[index])\n elsif token == \"+\"\n next if soft_fail and stack.size < 2\n rhs = stack.pop\n lhs = stack.pop\n stack.push(lhs + rhs)\n elsif token == \"*\"\n next if soft_fail and stack.size < 2\n rhs = stack.pop\n lhs = stack.pop\n stack.push(lhs * rhs)\n elsif token == \"-\"\n next if soft_fail and stack.size < 2\n rhs = stack.pop\n lhs = stack.pop\n stack.push(lhs - rhs)\n elsif token == \"/\"\n next if soft_fail and stack.size < 2\n rhs = stack.pop\n lhs = stack.pop\n stack.push(lhs / rhs)\n elsif token == \"log\"\n next if soft_fail and stack.size < 1\n rhs = stack.pop\n stack.push(Math.log(rhs))\n elsif token == \"log10\"\n next if soft_fail and stack.size < 1\n rhs = stack.pop\n stack.push(Math.log10(rhs))\n elsif token == \"tanh\"\n next if soft_fail and stack.size < 1\n rhs = stack.pop\n stack.push(Math.tanh(rhs))\n else\n next if soft_fail\n raise \"Unknown token: #{token}\"\n end\n end\n stack.pop\n end",
"def pop\n #if the stack is already empty do nothing\n if empty?\n nil\n else\n #set popped equal to the element at index @top, which isthe top of the stack\n popped = @store[@top]\n #set the value at the top of the stack to nil\n @store[@top] = nil\n # subtract 1 from the value of @top\n @top = @top.pred #@top--\n #returns the value that was popped\n popped\n end\n end",
"def solve_rpn(s)\n\t\t\tstack = []\n\t\t\ts.split(\"\\s\").each do |e|\n\t\t\t\tcase e\n\t\t\t\t\twhen \"+\"\n\t\t\t\t\t\tstack.push(stack.pop + stack.pop)\n\t\t\t\t\twhen \"-\"\n\t\t\t\t\t\tstack.push(-stack.pop + stack.pop)\n\t\t\t\t\twhen \"*\"\n\t\t\t\t\t\tstack.push(stack.pop * stack.pop)\n\t\t\t\t\twhen \"/\"\n\t\t\t\t\t\ta, b = stack.pop, stack.pop\n\t\t\t\t\t\tstack.push(b / a)\n when \"<?\"\n a, b = stack.pop, stack.pop\n stack.push(b < a ? 1 : 0)\n when \">?\"\n a, b = stack.pop, stack.pop\n stack.push(b > a ? 1 : 0)\n when \"<=?\"\n a, b = stack.pop, stack.pop\n stack.push(b <= a ? 1 : 0)\n when \">=?\"\n a, b = stack.pop, stack.pop\n stack.push(b >= a ? 1 : 0)\n\t\t\t\t\telse\n\t\t\t\t\t\traise TypeError, \"Bad rpn\" unless e.is_numeric?\n\t\t\t\t\t\tstack.push(e.to_f)\n\t\t\t\tend\n\t\t\tend\n\t\t\tstack[0]\n\t\tend",
"def test_stack_050\n\n @vc.parse <<EOF\n\n: test\n\n 0. 2dup 1+\n 2dup 1+\n 2dup 1+\n\n;\n\nEOF\n @vc.compile\n @vc.run\n assert_equal(:halt, @vc.vm.state)\n assert_equal(8, @vc.vm.depth)\n assert_equal(3, @vc.vm.tos)\n assert_equal(0, @vc.vm.nos)\n assert_equal(2, @vc.vm.pick(2))\n assert_equal(0, @vc.vm.pick(3))\n assert_equal(1, @vc.vm.pick(4))\n assert_equal(0, @vc.vm.pick(5))\n assert_equal(0, @vc.vm.pick(6))\n assert_equal(0, @vc.vm.pick(7))\n end",
"def push_stack\n bb = {:black => get_black,:white => get_white}\n @stack.push(Marshal.load(Marshal.dump(bb)))\n @stack.shift if @stack.size > @options[:stack_limit]\n end",
"def prefix_evaluation(expression)\n return nil if expression.class != String\n digits = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\",\"6\", \"7\", \"8\", \"9\"]\n operators = [\"+\", \"-\", \"*\", \"/\", \"**\"]\n expression_array = expression.split(\" \").reverse\n local_stack = Stack.new()\n expression_array.each do |element|\n if digits.include?(element)\n local_stack.push(element)\n elsif operators.include?(element)\n num1 = local_stack.pop()\n num2 = local_stack.pop()\n result = do_math(num1, num2, element)\n local_stack.push(result)\n else\n puts \"undefined character\"\n end\n end\n local_stack.top()\nend",
"def evaluate_postfix(postfix_expression)\n stack = Stack.new\n \n i = 0\n while i < postfix_expression.length\n if postfix_expression[i].match(/[0-9]/)\n stack.push(postfix_expression[i].to_i)\n else\n case postfix_expression[i]\n when \"+\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 + num_2)\n when \"-\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 - num_2)\n when \"*\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 * num_2)\n when \"/\"\n num_2 = stack.pop\n num_1 = stack.pop\n stack.push(num_1 / num_2)\n end\n end\n i += 1\n end\n return stack.pop\nend",
"def evaluate() \n # operand stack\n opStack = []\n \n # iterate over the tokens\n @postfix.split(\"\").each do |c|\n # check if an operator\n if %w[+ - * / ^].include? c\n # pop the stack for the two operands where\n # a [operator] b\n b, a = opStack.pop, opStack.pop\n \n # evaluate the string as an arithmetic expression\n # replace all '^' characters with '**' operator\n opStack.push(eval(\"(#{a})#{c}(#{b})\".gsub(/\\^/,'**')))\n else\n # push any operands onto stack\n opStack.push(c)\n end\n end\n \n # Last item in stack should be the final answer!\n opStack.pop\n end",
"def stack\n @stack\n end",
"def pop\n # store top value in variable\n node_value = @data.value\n # replace top node with next node in stack\n @data = @data.next_node\n # return top node value\n return node_value\n end",
"def evaluate_postfix(postfix_expression)\n operands = Set['+', '-', '*', '/'] # assume only these four operands for now\n stack = Stack.new # track operation results\n\n postfix_expression.each_char do |c| # assume expresion is valid\n if operands.include?(c) # is operand\n b = stack.pop # get second number pushed\n a = stack.pop # pop again for first number pushed\n\n new_top = 0\n\n # calculate new number to push into stack\n new_top += case c\n when '+' \n a + b\n when '-'\n a - b\n when '/'\n a / b\n when '*'\n a * b\n end\n\n stack.push(new_top) # add back to top of stack\n\n else # is number\n stack.push(c.to_i)\n end\n end\n\n return stack.pop\nend",
"def op12(interp)\n interp.stack.push(Integer(interp.stack.pop * interp.stack.pop))\n end",
"def evaluate\n stack = Stack.new\n\n tokens.each do |token|\n if numeric?(token)\n stack.push(token.to_i)\n elsif operator?(token)\n args = []\n SYMBOL_TABLE[token].arity.times do\n args.unshift(stack.pop)\n end\n\n stack.push(call_operator(token, *args))\n else\n raise \"omg what is this token?\"\n end\n end\n\n stack.pop\n end",
"def pop()\n (@stack1.size-1).times { @stack2.push(@stack1.pop) }\n result = @stack1.pop\n @stack2.times { @stack1.push(@stack2.pop) }\n\n result\n end",
"def test_clear_stacks\n @eval.load_stacks([5, 5, 6, '+', '-'])\n @eval.clear_stacks\n assert_equal 0, @eval.op_stack.size?\n assert_equal 0, @eval.n_stack.size?\n end",
"def prime_mutation_determination(roll)\n case roll\n when 1..9\n @@primary_mutations << \"Acid Blood\"\n @@attacks << {:attack_mode => \"Acid blood spray\", :SV => 20, :rate => 1, :range => 2, :damage => \"d12\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"60\", :notes => \"automatic on melee or point-blank puncturing attack\"}\n\n when 10..20\n @@primary_mutations << \"Acid Spit\"\n @@attacks << {:attack_mode => \"Acid Spit\", :SV => 6, :rate => 1, :range => 6, :damage => \"d6 + 2 per dround for d6 rounds\", :ammo => \"2/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"60\", :notes => \"does same damage to ropes, bars, locks, etc.\"}\n when 21..32\n @@primary_mutations << \"Advanced Mind\"\n @@intelligence += (d(10 + d(10) + d(10)))\n @@character_notes << \"character gains two hazard checks against insanity and mental attacks that require hazard checks\"\n\n when 33..36\n @@primary_mutations << \"Agony Sphere\"\n @@attacks << {:attack_mode => \"Agony Sphere\", :SV => \"auto\", :rate => 1, :range => (@@willpower/2), :damage => \"d6 + +10DV to targets\", :ammo => \"1/day per user rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"60\", :notes => \"requires 3 full rounds of concentration to unleash; can be sustained for 1 rd/willpower point\"}\n\n when 37..44\n @@primary_mutations << \"Amphibian\"\n @@character_notes << \"Can breathe as well in water as air\"\n @@character_notes << \"Suffers d3 dmg per day in arid environments\"\n\n when 45..52\n @@primary_mutations << \"Amplification\"\n @@character_notes << \"Doubles daily/rank-based rate of limited-use mutations\"\n\n when 53..59\n @@primary_mutations << \"Aquatic Adaptation\"\n @@character_notes << \"Webbed hands and feet\"\n @@character_notes << \"Withstands cold 2x vs. humans\"\n @@character_notes << \"Must be fully immersed in water 1hr per day or suffer d3 dmg; d6 in desert areas\"\n\n when 60..71\n @@primary_mutations << \"Arid Adaptation\"\n @@dv -= 3\n @@appearance = [@@appearance - d(8), 1].max\n @@character_notes << \"Needs 1/10th as much water as pure stock human\"\n @@character_notes << \"Specialized organ holds 2 liters drinking water (can yak up in 250 or 500ml portions)\"\n\n when 72..79\n @@primary_mutations << \"Asphyxiation Zone\"\n @@attacks << {:attack_mode => \"Asphyxiation Zone\", :SV => \"auto\", :rate => 1, :range => (@@willpower * 2), :damage => \"d10\", :ammo => \"2/day per user rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"61\", :notes => \"lasts 2 rounds per rank\"}\n\n when 80..89\n @@primary_mutations << \"Aura of Protection\"\n @@character_notes << \"2 uses / rank / day; DV -10 + 10 pt force field dmg soak per round; duration willpower rounds; 2 rounds to activate\"\n\n when 90..102\n @@primary_mutations << \"Ballistic Hide\"\n @@dv -= 4\n @@appearance = [@@appearance - d(4), 1].max\n @@character_notes << \"Additional -20DV vs. blunt/crushing attacks including non-AP bullets\"\n\n when 103..109\n @@primary_mutations << \"Beak\"\n @@appearance = [@@appearance - (d(6) + d(6)), 1].max\n @@attacks << {:attack_mode => \"Beak\", :SV => 10, :rate => 1, :range => 1, :damage => \"d12\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"61\", :notes => \"\"}\n @@character_notes << \"Character cannot speak clearly\"\n\n when 110..127\n @@primary_mutations << \"Beam Eyes\"\n @@attacks << {:attack_mode => \"Beam Eyes\", :SV => 15, :rate => 1, :range => (@@willpower + @@perception), :damage => \"10 + d6/rank\", :ammo => \"2 / rank / day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"61\", :notes => \"\"}\n\n when 128..134\n @@primary_mutations << \"Berserker Rage\"\n @@character_notes << \"Berserker Rage: 2/day/rank usage; duration 1 battle; -5DV, +10SV, +10dmg (melee weapons only); +20 strength; can fight on for d6 rounds after suffering fatal damage\"\n when 135..144\n @@primary_mutations << \"Bladed Limbs\"\n def bladed_limbs_location(roll)\n case roll\n when 1 then result = \"Shoulder\"\n when 2 then result = \"Back\"\n when 3 then result = \"Chest\"\n when 4 then result = \"Side\"\n when 5 then result = \"Hip\"\n when 6 then result = \"Abdomen\"\n end\n end\n\n d(4).times do\n bladed_limbs_location(d(6))\n @@character_notes << \"Sword-like bone blade protruding from #{result}\"\n @@appearance = [@@appearance - 2, 1].max\n @@character_weight += 5\n end\n\n @@attacks << {:attack_mode => \"Bladed limb(s)\", :SV => 5, :rate => \"1 per bladed limb\", :range => 0, :damage => \"d12 + 2\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62\", :notes => \"\"}\n\n\n when 145..149\n @@primary_mutations << \"Blurred Movement\"\n @@character_notes << \"Blurred Movement: -20DV; willpower rounds/day; can be used to blur entire body or only parts\"\n\n when 150..179\n @@character_notes << \"Due to body disporportion, no relic shell armor can be worn, but other types can be modified to fit\"\n def body_disproportion_location(roll)\n case roll\n when 1\n @@primary_mutations << \"Body Disproportion: Dominant arm is massive!\"\n @@character_notes << \"Dominant arm has strength of #{(@@strength + @@strength + d(20) + d(20))} which applies to all 1- and 2-handed melee weapons character wields\"\n @@appearance = [@@appearance - d(4), 1].max\n @@move -= 0.5\n @@character_weight += (20 + d(20))\n when 2\n @@primary_mutations << \"Body Disproportion: Character's head is massive!\"\n @@intelligence += (d(20) + 20)\n @@move -= 1\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@character_notes << \"TWO intelligence-based hazard checks, when called for\"\n @@character_weight += (20 + d(10))\n when 3\n @@primary_mutations << \"Body Disproportion: Upper body incredibly over-muscled!\"\n @@strength += (20 + d(20))\n @@endurance += (20 + d(20))\n @@move -= 1\n @@agility = [@@agility - d(10), 1].max\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@character_weight += (20 + d(20) + d(20))\n when 4\n @@primary_mutations << \"Body Disproportion: hips and legs are twice normal length!\"\n @@move += @@move\n @@character_height += 100\n @@appearance = [@@appearance - d(4), 1].max\n @@attacks << {:attack_mode => \"Wicked kick\", :SV => 0, :rate => \"1\", :range => 0, :damage => \"2d10\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62\", :notes => \"\"}\n @@character_weight += (30 + d(20) + d(20))\n when 5\n @@primary_mutations << \"Body Disproportion: comically giant hands and feet!\"\n @@attacks << {:attack_mode => \"Punch or kick\", :SV => 0, :rate => \"1\", :range => 0, :damage => \"2d12\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62\", :notes => \"\"}\n @@character_notes << \"Weapons with triggers, keyboards, or other items requiring normal human hands are unusable without modifying item.\"\n @@appearance = [@@appearance - (d(6) + 1), 1].max\n @@character_weight += (d(6) + d(6) + d(6) + d(6))\n when 6\n @@primary_mutations << \"Body Disproportion: extra long arms!\"\n @@character_notes << \"+5 SV in melee combat\"\n @@character_notes << \"+5 thrown weapon DMG\"\n @@appearance = [@@appearance - (d(4) + 1), 1].max\n when 7\n @@primary_mutations << \"Body Disproportion: greatly elongated torso!\"\n @@character_notes << \"If pregnant, gives birth to a litter of d4 + 1 offspring.\"\n @@endurance += (d(10) + d(10))\n @@appearance = [@@appearance - d(6), 1].max\n @@character_height += (20 + d(20))\n @@character_weight += (10 + d(20))\n def elongated_torso_bonus(roll1, roll2, roll3, roll4) # need to add actual mutation results via primary_mutations_roll(xx)\n case roll1\n when 1..50\n @@primary_mutations << \"Reserve heart\"\n end\n case roll2\n when 1..65\n @@primary_mutations << \"Radiation absorption\"\n end\n case roll3\n when 1..37\n @@primary_mutations << \"Breath holding\"\n end\n case roll4\n when 1..72\n @@primary_mutations << \"Nutriment cache\"\n end\n\n end\n elongated_torso_bonus(d(100),d(100),d(100),d(100))\n when 8\n 2.times do\n elongated_torso_bonus(d(7))\n end\n end\n\n end\n body_disproportion_location(d(8))\n\n when 180..195\n def body_regeneration_rate(roll)\n case roll\n when 1..12\n @@endurance_healing_rate += 4\n when 13..32\n @@endurance_healing_rate += 7\n when 33..40\n @@endurance_healing_rate += 10\n when 41..64\n @@endurance_healing_rate = 15\n when 65..87\n @@endurance_healing_rate = \"1 pt per hour\"\n when 88..93\n @@endurance_healing_rate = \"2 pts per hour\"\n when 94..96\n @@endurance_healing_rate = \"4 pts per hour\"\n when 97..98\n @@endurance_healing_rate = \"6 pts per hour\"\n when 99\n @@endurance_healing_rate = \"10 pts per hour\"\n when 100\n @@endurance_healing_rate = \"1 pt per round\"\n end\n end\n body_regeneration_rate(d(100))\n @@primary_mutations << \"Body Regeneration: #{@@endurance_healing_rate} healing rate bonus\"\n\n when 196..201\n @@primary_mutations << \"Breath Holding: triple base endurance rate + regular breath holding rate (Hub Rules p. 122)\"\n when 202..224\n @@primary_mutations << \"Claws: don’t hinder her from using bows, crossbows, or weapons that use a trigger, but disallow her from using keyboards or doing fne electronics work\"\n @@attacks << {:attack_mode => \"Claw\", :SV => 7, :rate => \"1 per hand\", :range => 0, :damage => \"d12 each\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"62-63\", :notes => \"\"}\n @@character_notes << \"Thanks to claws, character climbs as though she has 2 points in Climbing skill\"\n when 225..230\n @@primary_mutations << \"Climbing Suckers: like a gecko, character can climb on anything at 1/2 move\"\n @@character_notes << \"When falling, type A agility based hazard check to catch side of building/pit and stop fall\"\n when 231..239\n @@primary_mutations << \"Coma Inducement\"\n @@attacks << {:attack_mode => \"Coma inducement\", :SV => 0, :rate => \"\", :range => @@willpower + @@willpower, :damage => \"coma\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"victim gets tybe B willpower based hazard check; see p. 63 for details\"}\n when 240..253\n number_of_pincers = 0\n arms_too = \"True\"\n pincer_size = \"Small\"\n def pincer_formation_on_mutant(roll)\n case roll\n when 1..2\n @@primary_mutations << \"Crab Pincers: 1 pincer replacing 1 arm\"\n number_of_pincers += 1\n @@character_weight -= 15\n when 3..6\n @@primary_mutations << \"Crab Pincers: 2 pincers replacing both human arms\"\n number_of_pincers += 2\n @@character_weight -= 30\n when 7\n @@primary_mutations << \"Crab Pincers: 1 pincer growing from shoulder, both human arms intact\"\n number_of_pincers += 1\n when 8..9\n @@primary_mutations << \"Crab Pincers: 2 pincers in addition to human arms\"\n number_of_pincers += 2\n when 10\n number_of_pincers = (2 + d(2))\n def arms_too(roll)\n case roll\n when 79..100\n arms_too = \"False\"\n @@character_weight -= 30\n end\n end\n @@primary_mutations << \"Crab Pincers: #{number_of_pincers} total\"\n arms_too(d(100))\n end\n end\n def pincer_size(roll)\n case roll\n when 1..3\n pincer_size = \"Small\"\n @@character_weight += (number_of_pincers * 15)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 2, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d10 + 1\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n when 4..6\n pincer_size = \"Medium\"\n @@movement_rate_base -= (0.25 * number_of_pincers)\n @@character_weight += (number_of_pincers * 20)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 4, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d12 + 3\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n when 7..9\n pincer_size = \"Large\"\n @@movement_rate_base -= (0.5 * number_of_pincers)\n @@character_weight += (number_of_pincers * 35)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 7, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d20 + 3\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n when 10\n pincer_size = \"Massive\"\n @@movement_rate_base -= (0.75 * number_of_pincers)\n @@character_weight += (number_of_pincers * 50)\n @@attacks << {:attack_mode => \"Pincer\", :SV => 10, :rate => \"#{number_of_pincers}\", :range => 0, :damage => \"d20 + 10\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"63\", :notes => \"\"}\n end\n end\n\n pincer_formation_on_mutant(d(10))\n pincer_size(d(10))\n @@primary_mutations << \"Pincers: #{number_of_pincers} of #{pincer_size} size\"\n if arms_too == \"False\"\n @@appearance = [@@appearance - (number_of_pincers * d(4) + 2), 1].max\n @@character_notes << \"No human arms - character cannot use triggers, keyboards, or complex items\"\n elsif arms_too == \"True\"\n @@appearance = [@@appearance - (number_of_pincers * d(4)), 1].max\n end\n\n\n when 254..292\n def deviant_skin_structure(roll)\n case roll\n when 1..3\n @@primary_mutations << \"Fire-proof skin\"\n @@character_notes << \"No damage from fire for 10 rounds; 1/2 damage after\"\n @@character_notes << \"1/2 damage from explosions\"\n when 4..5\n @@primary_mutations << \"Reflective skin\"\n @@character_notes << \"1/2 damage from beam weapons when clothed; 70 percent resistance to beam weapons vs. bare skin\"\n @@appearance += d(6)\n when 6..7\n @@primary_mutations << \"Alkaline skin\"\n @@character_notes << \"Character totally immune to acid attacks (which still ruin character's gear)\"\n when 8..10\n @@primary_mutations << \"Weather sensitive skin\"\n @@character_notes << \"Sense weather changes in 20km radius; can sense open bodies of water within 2 km\"\n when 11\n @@primary_mutations << \"Glow in the dark skin\"\n @@character_notes << \"3m radius green glow; visible up to 12km away - character can't turn off glow\"\n when 12\n @@primary_mutations << \"Photosynthetic skin\"\n @@character_notes << \"4 hrs in sunlight = 1 meal; 1 hr in sunlight = 3 pts healing (in addition to normal resting healing)\"\n end\n end\n deviant_skin_structure(d(12))\n\n when 293..298\n @@primary_mutations << \"Devastator Pulse\"\n @@attacks << {:attack_mode => \"Devastator Pulse\", :SV => (@@accuracy + @@willpower), :rate => \"4 rounds to charge, release on 5th\", :range => @@willpower, :damage => \"3d20 / d100 + 40 vs. machines\", :ammo => \"1/rank/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"\"}\n\n when 299..300\n @@primary_mutations << \"Displacement\"\n @@character_notes << \"Displacement: #{@@willpower} rounds per day, DV -30\"\n when 301..305\n @@primary_mutations << \"Doom Sphere\"\n @@attacks << {:attack_mode => \"Doom Sphere\", :SV => \"01-95\", :rate => \"1/10 days\", :range => (@@willpower * 10), :damage => \"3d20 vs organics; 6d20 vs electronics\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"User must make intelligence type B hazard check or go insane for 1 hour (p. 126)\"}\n when 306..314\n @@primary_mutations << \"Dread Zone\"\n @@attacks << {:attack_mode => \"Dread Zone\", :SV => \"01-95\", :rate => 1, :range => @@intelligence, :damage => \"tybe B hazard check vs. intelligence or +10SV to attack\", :ammo => \"1/rank/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"Duration: rank in rounds; does not affect inorganic beings or creatures with morale = n/a\"}\n when 315..322\n @@primary_mutations << \"Earth Thump\"\n @@attacks << {:attack_mode => \"Earth Thump\", :SV => (@@willpower + 30), :rate => \"3 rounds to generate\", :range => @@willpower, :damage => \"d10/user rank\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"Targets 1 human-sized enemy per rank of user (assuming multiple targets close together)\"}\n when 323..341\n @@primary_mutations << \"Electrical Charge\"\n @@attacks << {:attack_mode => \"Electrical Charge\", :SV => 20, :rate => \"1\", :range => 0, :damage => \"d20 + HC\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"64\", :notes => \"Victim makes END-based tybe B hazard check or stunned for d3 rounds\"}\n @@character_notes << \"Four Electrical Charge jolts are suffcient to fully re-charge a standard power cell.\"\n when 342..349\n @@primary_mutations << \"Electrical Pulse\"\n @@attacks << {:attack_mode => \"Electrical Pulse\", :SV => 20, :rate => 1, :range => (@@willpower), :damage => \"d20 / 3d20 vs machines\", :ammo => \"3/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"Can be used to start fires as well\"}\n when 350..355\n @@primary_mutations << \"Electro Magnetic Pulse\"\n @@attacks << {:attack_mode => \"Electro Magnetic Pulse\", :SV => 30, :rate => 1, :range => @@willpower, :damage => \"d10/d100 vs electronics\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"\"}\n when 356..376\n @@primary_mutations << \"Empathy\"\n @@character_notes << \"Empathy: #{@@willpower} range. Unlimited uses. The subject is allowed a type C, intelligence based hazard check. If failed, mutant knows victim's emotions. Alternately, emotions can be projected.\"\n when 377..388\n @@primary_mutations << \"Energy Blade\"\n def energy_blade_type(roll) # table Hub Rules p. 65\n case roll\n when 1..20\n @@attacks << {:attack_mode => \"Energy Blade: Blue\", :SV => 10, :rate => 1, :range => 1, :damage => \"d12\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 21..40\n @@attacks << {:attack_mode => \"Energy Blade: Green\", :SV => 10, :rate => 1, :range => 1, :damage => \"d20 stun\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 41..65\n @@attacks << {:attack_mode => \"Energy Blade: Red\", :SV => 10, :rate => 1, :range => 1, :damage => \"d20\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 66..85\n @@attacks << {:attack_mode => \"Energy Blade: Orange\", :SV => 10, :rate => 1, :range => 1, :damage => \"2d20 stun\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 86..97\n @@attacks << {:attack_mode => \"Energy Blade: Purple\", :SV => 10, :rate => 1, :range => 1, :damage => \"2d20\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 98..99\n @@attacks << {:attack_mode => \"Energy Blade: White\", :SV => 10, :rate => 1, :range => 1, :damage => \"d100 stun\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n when 100\n @@attacks << {:attack_mode => \"Energy Blade: Gold\", :SV => 10, :rate => 1, :range => 1, :damage => \"d100\", :ammo => \"#{@@willpower} rounds\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"2/day/rank\"}\n end\n end\n if @@primary_mutations.include? \"Energy Blade\" # Note: NO duplication -- reroll if this result comes up twice.\n @@primary_mutations_rolls += 1\n else\n energy_blade_type(d(100))\n end\n\n when 389..401\n @@primary_mutations << \"Extreme Size Decrease\"\n @@character_height = (22 + d(20) + d(20)) # NOTE: should be dependent on GENDER, ignored that.\n 3.times @@skills << \"Stealth\"\n 2.times @@skills << \"Climbing\"\n @@character_notes << \"Cannot wield two-handed weapons. Normal one-handed weapons including pistols must be employed with both hands (except knifes and daggers, which are considered swords for this mutant)\"\n @@character_notes << \"Relic armor cannot be worn except scrap relic.\"\n def extreme_size_decrease(height) # Hub Rules p. 65\n case height\n when 22..27\n @@character_weight = (15 + d(10))\n @@agility += 20\n @@movement_rate_base == 4.5\n @@strength = [@@strength - 15, 1].max\n @@endurance = [@@endurance - 10, 1].max\n when 28..35\n @@character_weight = (20 + d(12))\n @@agility += 15\n @@movement_rate_base = 5\n @@strength = [@@strength - 10, 1].max\n @@endurance = [@@endurance - 7, 1].max\n when 36..45\n @@character_weight = (25 + d(20))\n @@agility += 10\n @@movement_rate_base = 5.5\n @@strength = [@@strength - 5, 1].max\n @@endurance = [@@endurance - 5, 1].max\n when 46..65\n @@character_weight = (30 + d(20) + d(20))\n @@agility += 7\n @@movement_rate_base = 6\n @@strength = [@@strength - 3, 1].max\n @@endurance = [@@endurance - 3, 1].max\n end\n end\n\n extreme_size_decrease(@@character_height)\n\n when 402..419\n def fang_size(roll) # Hub rules p. 65\n case roll\n when 1..3\n sizeoffangs = \"Small\"\n fangsv = 2\n fangdmg = \"d6\"\n @@appearance = [@@appearance - 1, 1].max\n when 4..8\n sizeoffangs = \"Medium\"\n fangsv = 4\n fangdmg = \"d10\"\n @@appearance = [@@appearance - (1 + d(2)), 1].max\n when 9..10\n sizeoffangs = \"Huge\"\n fangsv = 6\n fangdmg = \"d20\"\n @@appearance = [@@appearance - (d(3) + 2), 1].max\n @@character_notes << \"Ability to speak clearly greatly reduced\"\n end\n @@attacks << {:attack_mode => \"Fangs\", :SV => fangsv, :rate => 1, :range => 0, :damage => fangdmg, :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"65\", :notes => \"This attack can only be employed as a supplemental melee attack if involved in close fighting\"}\n @@primary_mutations << \"Fanged: #{sizeoffangs} size\"\n end\n\n fang_size(d(10))\n\n when 420..427\n @@primary_mutations << \"Flame Breath\"\n @@attacks << {:attack_mode => \"Flame Breath\", :SV => 10, :rate => 1, :range => \"3/rank\", :damage => \"d6/rd for 2d6 rds\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"66\", :notes => \"Up to 3 man sized targets can be attacked at once if close together\"}\n when 428..438\n def force_field_strength(roll) # Hub rules p. 66\n case roll\n when 1..10\n force_field = d(10)\n when 11..24\n force_field = (d(10) + 3)\n when 25..53\n force_field = (d(10) + 5)\n when 54..78\n force_field = (d(10) + 10)\n when 79..94\n force_field = (d(10) + 12)\n when 95\n force_field = (d(10) + 15)\n when 96\n force_field = (d(10) + 17)\n when 97\n force_field = (d(10) + 20)\n when 98\n force_field = (d(10) + 23)\n when 99\n force_field = (d(10) + 26)\n when 100\n force_field = (d(10) + 30)\n end\n @@primary_mutations << \"Force Field: 2 uses/rank/day; #{willpower} rounds duration; absorbs #{force_field} dmg/round\"\n end\n force_field_strength(d(100))\n\n when 439..445\n @@primary_mutations << \"Foul Flesh\"\n @@character_notes << \"Will not eat mutant: all mammals, all humanoids except moaners, horrlify, all amphibians, fsh, birds except black vultures, reptilius, all reptiles, except alligators and crocodilians.\"\n when 446..453\n def furred_mutation(roll)\n case roll\n when 1..3\n fur_type = \"Fine, cat-like\"\n fur_dv = -3\n fur_cold = \"Double normal human cold resistance\"\n @@appearance = [@@appearance - d(3), 1].max\n when 4..5\n fur_type = \"Wool, sheep-like\"\n fur_dv = -6\n fur_cold = \"Triple normal human cold resistance\"\n @@appearance = [@@appearance - (1 + d(4)), 1].max\n when 6..7\n fur_type = \"Thick, sheep-like wool\"\n fur_dv = -9\n fur_cold = \"Quadruple normal human cold resistance\"\n @@appearance = [@@appearance - (d(6) + 2), 1].max\n when 8..9\n fur_type = \"Badger-like bristles\"\n fur_dv = -11\n fur_cold = \"Double normal human cold resistance\"\n @@appearance = [@@appearance - (d(6) + d(6) + 2), 1].max\n @@character_notes << \"+2 dmg to basic punch attack\" # +2 dmg to punch attack -- HOW to implement??\n when 10\n fur_type = \"Porcupine-like quills\"\n fur_dv = -13\n fur_cold = \"Double normal human cold resistance\"\n @@appearance = [@@appearance - (d(6) + d(6) + 3), 1].max\n @@character_notes << \"+2 dmg to basic punch attack\" # +2 dmg to punch attack -- HOW to implement??\n end\n @@primary_mutations << \"Furred: #{fur_type}, #{fur_cold} cold resistance. #{fur_dv} DV bonus\"\n @@dv += fur_dv\n end\n furred_mutation(d(10))\n when 454..459\n\n def gaseous_discharge(roll) # Hub Rules p. 67\n case roll\n when 1..2\n gas_type = \"Sleep\"\n gas_effect = \"All must make an Endurance-based type A hazard check or pass out for d100 rounds.\"\n when 3..4\n gas_type = \"Blindness\"\n gas_effect = \"All must make an Endurance-based type A hazard check or go blind for d6 days.\"\n when 5\n gas_type = \"Stink\"\n gas_effect = \"All must make an Endurance-based type C hazard check or spend 2 rounds vomiting, becoming +30 to strike, with their own SV being reduced to half, rounded down.\"\n when 6\n gas_type = \"Corrosive\"\n gas_effect = \"All must make an Endurance-based type B hazard check suffer d6 damage/rd from corrosive acids. Those who succeed vs. hazard check take 1 dmg/rd.\"\n when 7\n gas_type = \"Hallucinogenic\"\n gas_effect = \"All must make an Intelligence-based tybe B hazard check or hallucinate, +30SV to strike and -30SV to retaliate. Animals must make a morale check or flee immediately.\"\n when 8\n gas_type = \"Poison\"\n gas_effect = \"All must make an Endurance-based type A hazard check or drop unconscious for 10 rounds. Their breathing ceases on the 11th round and if not resuscitated by artifcial respiration, will die on the 14th round.\"\n end\n @@primary_mutations << \"Gaseous Discharge: #{gas_type}\"\n @@attacks << {:attack_mode => \"Gaseous Discharge: #{gas_type}\", :SV => \"Auto\", :rate => 1, :range => \"10 m radius\", :damage => \"Special\", :ammo => \"2/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"66-67\", :notes => \"#{gas_effect} Gas dissipates in 2 rounds outdoors or lingers 2d10 + 4 rounds in enclosed areas.\"}\n @@character_notes << \"Character immune to #{gas_type}\"\n end\n\n gaseous_discharge(d(8))\n\n when 460..472\n def gaping_maw(roll) #Hub Rules p. 67\n case roll\n when 1..5\n maw_size = \"Large\"\n maw_sv = 4\n maw_damage = \"d12\"\n maw_mv_mod = 0\n maw_added_weight = 15\n @@appearance = [@@appearance - (d(4) + d(4) + 2), 1].max\n when 6..7\n maw_size = \"Huge\"\n maw_sv = 7\n maw_damage = \"d20\"\n maw_mv_mod -= 0.25\n maw_added_weight = 30\n @@appearance = [@@appearance - (d(4) + d(4) + 4), 1].max\n when 8..9\n maw_size = \"Massive\"\n maw_sv = 12\n maw_damage = \"2d20\"\n maw_mv_mod -= 0.5\n maw_added_weight = 70\n @@appearance = [@@appearance - (d(6) + d(6) + 5), 1].max\n when 10\n maw_size = \"Colossal\"\n maw_sv = 20\n maw_damage = \"3d20\"\n maw_mv_mod -= 1\n maw_added_weight = 120\n @@appearance = [@@appearance - (d(6) + d(6) + 8), 1].max\n end\n @@primary_mutations << \"Gaping Maw: #{maw_size} in size\"\n @@attacks << {:attack_mode => \"Gaping Maw\", :SV => maw_sv, :rate => 1, :range => 0, :damage => maw_damage, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"67\", :notes => \"Can be employed as a supplemental melee attack \"}\n @@character_notes << \"Almost totally carnivorous diet. Mutant drools and spits when speaking in a low, gruff voice difficult for strangers to understand.\"\n @@character_weight += maw_added_weight\n @@movement_rate_base -= maw_mv_mod\n end\n\n gaping_maw(d(10))\n\n\n when 473..497\n def heal_touch(willpower)\n case willpower\n when 1..6\n healrate = \"d8\"\n when 7..14\n healrate = \"d12\"\n when 15..34\n healrate = \"d20\"\n when 35..64\n healrate = \"d20 + 10\"\n when 65..84\n healrate = \"d20 + 20\"\n when 85..105\n healrate = \"d20 + 30\"\n when 106..200\n healrate = \"d20 + 40\"\n end\n @@primary_mutations << \"Heal Touch: 2/day/rank, #{healrate} trait points healed. Diseases healed if victim makes Type B willpower based hazard check.\"\n end\n\n heal_touch(@@willpower)\n\n @@primary_mutations << \"Heal Touch\"\n when 498..511\n def heat_pulse(willpower) # Hub Rules p. 67\n case willpower\n when 1..6\n heat_pulse_sv = -5\n heat_pulse_dmg = \"d6\"\n heat_pulse_range = 5\n when 7..14\n heat_pulse_sv = 0\n heat_pulse_dmg = \"d10\"\n heat_pulse_range = 10\n when 15..34\n heat_pulse_sv = 4\n heat_pulse_dmg = \"d20\"\n heat_pulse_range = @@willpower\n when 35..64\n heat_pulse_sv = 6\n heat_pulse_dmg = \"d20 + 10\"\n heat_pulse_range = (@@willpower * 2)\n when 65..84\n heat_pulse_sv = 9\n heat_pulse_dmg = \"d20 + 20\"\n heat_pulse_range = (@@willpower * 3)\n when 85..105\n heat_pulse_sv = 12\n heat_pulse_dmg = \"d20 + 30\"\n heat_pulse_range = (@@willpower * 4)\n when 106..200\n heat_pulse_sv = 15\n heat_pulse_dmg = \"d20 + 40\"\n heat_pulse_range = (@@willpower * 5)\n end\n @@primary_mutations << \"Heat Pulse\"\n @@attacks << {:attack_mode => \"Heat Pulse\", :SV => heat_pulse_sv, :rate => 1, :range => heat_pulse_range, :damage => heat_pulse_dmg, :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"67\", :notes => \"\"}\n end\n\n heat_pulse(@@willpower)\n\n\n when 512..556\n\n def heightened_attributes(roll) # Hub Rules p. 68\n case roll\n when 1\n heightened_attributes_type = \"Cat Balance\"\n @@agility += (d(20) + 20)\n @@accuracy += (d(10) + d(10))\n @@perception += (d(20) + d(20))\n @@appearance += d(10)\n 2.times @@skills << \"Stealth\"\n @@character_notes << \"Due to cat balance, character always gets two hazard checks when agility or accuracy are involved.\"\n when 2\n heightened_attributes_type = \"Eagle Eyes\"\n @@accuracy += (d(10) + d(10))\n @@perception += (d(10) + d(10) + d(10))\n @@character_notes << \"Due to eagle eyes, character sees 10x better than typical human, including at night.\"\n when 3..4\n heightened_attributes_type = \"Strength\"\n @@strength += (d(20) + 30)\n @@appearance += (d(10) + d(10))\n @@character_notes << \"Due to heightened strength, character always gets two hazard checks when strength involved.\"\n when 5..6\n heightened_attributes_type = \"Endurance\"\n @@endurance += (d(20) + 30)\n @@character_notes << \"Due to heightened endurance, character always gets two hazard checks when endurance involved (eg, poison).\"\n when 7\n heightened_attributes_type = \"Hand-Eye Coordination\"\n @@accuracy += (d(20) + 20)\n @@character_notes << \"Due to superior hand-eye coordination, character always gets two hazard checks when accuracy involved.\"\n when 8\n heightened_attributes_type = \"Beauty\"\n @@appearance += (d(20) + 30)\n @@agility += d(6)\n @@accuracy += d(6)\n @@strength += d(6)\n @@character_notes << \"Due to heightened beauty, character always gets two hazard checks when appearance involved.\"\n when 9\n heightened_attributes_type = \"Auditory\"\n @@dv -= 5\n @@character_notes << \"+2 initiative when operating alone or more than 10m from companions.\"\n @@character_notes << \"Sonic attacks do double damage, while crying babies, crowded pubs, and other intense noises are painful.\"\n @@character_notes << \"Due to heightened hearing, character receives 4 attempts on hazard checks related to listening/hearing.\"\n when 10\n heightened_attributes_type = \"Olfactory\"\n (d(2) + 1).times @@skills << \"Tracking\"\n @@character_notes << \"Due to heightened sense of smell, character gets no hazard checks vs. stink-based attacks.\"\n @@character_notes << \"Character cannot be fooled by illusions at less than 10m\"\n @@character_notes << \"Bloodhound-like tracking abilities; however, after 12 hours, or rain, sand storms, or crossing water, all result in lost trails.\"\n when 11\n heightened_attributes_type = \"Willpower\"\n @@willpower += (d(20) + 30)\n @@character_notes << \"Due to heightened willpower, character always gets two hazard checks when willpower involved.\"\n when 12\n heightened_attributes_type = \"Intelligence\"\n @@intelligence += (d(20) + 30)\n @@character_notes << \"Due to heightened intelligence, character always gets two hazard checks when intelligence involved.\"\n end\n @@primary_mutations << \"Heightened Attributes: #{heightened_attributes_type}\"\n end\n\n heightened_attributes(d(12))\n\n\n when 557..566\n number_of_horns = d(4)\n @@primary_mutations << \"Horns: #{number_of_horns} on head\"\n @@character_weight += (2 * number_of_horns)\n @@attacks << {:attack_mode => \"Horns\", :SV => (3 * number_of_horns), :rate => 1, :range => 0, :damage => \"#{number_of_horns}d10\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"68\", :notes => \"This attack can be employed as a supplemental melee attack\"}\n @@character_notes << \"Due to horns, character can't wear relic helmets or shell-class armor unless horns permanently removed.\"\n when 567..571\n @@primary_mutations << \"Image Multiplication: #{@@willpower} duration, 2 uses/day/rank. Up to #{@@willpower/10.floor} images of mutant's self created. Hub Rules p. 68\"\n when 572..578\n def image_projection(intelligence)\n case intelligence\n when 1..9\n image_projection_range = \"1 km\"\n image_projection_duration = \"d4 rounds\"\n when 10..34\n image_projection_range = \"#{@@intelligence/2} km\"\n image_projection_duration = \"2d4 rounds\"\n when 35..54\n image_projection_range = \"#{@@intelligence} km\"\n image_projection_duration = \"10 + d10 rounds\"\n when 55..74\n image_projection_range = \"#{@@intelligence * 2} km\"\n image_projection_duration = \"20 + d20 rounds\"\n when 75..94\n image_projection_range = \"#{@@intelligence * 100} km\"\n image_projection_duration = \"100 + d100 rounds\"\n when 95..200\n image_projection_range = \"anywhere within solar system\"\n image_projection_duration = \"200 + 2d100 rounds\"\n end\n @@primary_mutations << \"Image Projection: #{image_projection_range} range, #{image_projection_duration} duration. 1/rank/day. Illusion can repeat 2 words/round. Creatures with 35+ intelligence can make a type B intelligence based hazard check to recognize projection as an illusion. Hub Rules p. 69\"\n end\n\n image_projection(@@intelligence)\n\n when 579..603\n def immunity_mutation(roll)\n case roll\n when 1..2\n @@primary_mutations << \"Poison immunity: totally immune to all forms of poison. Also, cannot get drunk.\"\n when 3..4\n @@primary_mutations << \"Disease immunity: All forms of infection, disease, sickness, parasites, etc. don't affect character. Immune to parasites as well.\"\n when 5..6\n @@primary_mutations << \"Radiation immunity: unaffected by all forms of radiation.\"\n end\n end\n\n immunity_mutation(d(6))\n\n when 605..613\n @@primary_mutations << \"Increased Cellular Activity\"\n @@endurance_healing_rate = (@@endurance_healing_rate * 3)\n @@character_notes << \"Character suffers no ill effects from aging (only benefits) and will live forever if not killed in combat, disease, poison, or accident.\"\n when 614..617\n @@primary_mutations << \"Light Burst: 10m radius, 2/day/rank\"\n @@attacks << {:attack_mode => \"Light Burst\", :SV => 0, :rate => 1, :range => 0, :damage => 0, :ammo => \"1/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"69\", :notes => \"Type C agility HC or blinded for 2d5 rounds. Blindness: -2 MV, -20 SV, +20 SV to be struck.\"}\n when 618..624\n @@primary_mutations << \"Limb Regeneration: see Hub Rules p. 69 for regeneration rates.\"\n when 625..630\n def mandibles_mutation(roll)\n case roll\n when 1..2\n mandibles_size = \"Small\"\n mandibles_sv = 3\n mandibles_dmg = \"d10\"\n mandibles_weight = 5\n mandibles_appearance = -(d(4) + 3)\n when 3..5\n mandibles_size = \"Medium\"\n mandibles_sv = 5\n mandibles_dmg = \"d12\"\n mandibles_weight = 15\n mandibles_appearance = -(d(6) + 4)\n when 6..7\n mandibles_size = \"Large\"\n mandibles_sv = 8\n mandibles_dmg = \"d20\"\n mandibles_weight = 20\n mandibles_appearance = -(d(8) + 6)\n @@movement_rate_base -= 0.25\n when 8..9\n mandibles_size = \"Huge\"\n mandibles_sv = 11\n mandibles_dmg = \"d20 + 5\"\n mandibles_weight = 30\n mandibles_appearance = -(d(6) + d(6) + 5)\n @@movement_rate_base -= 0.5\n when 10\n mandibles_size = \"Massive\"\n mandibles_sv = 15\n mandibles_dmg = \"d20 + 10\"\n mandibles_weight = 40\n mandibles_appearance = -(d(6) + d(6) + d(6) + 6)\n @@movement_rate_base -= 1\n\n end\n\n @@attacks << {:attack_mode => \"Mandibles\", :SV => mandibles_sv, :rate => 1, :range => 0, :damage => mandibles_dmg, :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"69\", :notes => \"Can be employed as a supplemental melee attack\"}\n @@character_weight += mandibles_weight\n @@appearance += mandibles_appearance #due to implementation method no protection here from =< 0...\n @@primary_mutations << \"Mandibles: #{mandibles_size} size\"\n end\n\n mandibles_mutation(d(10))\n\n when 631..641\n @@primary_mutations << \"Mental Mine\"\n when 642..655\n @@primary_mutations << \"Mental Screen\"\n when 656..687\n @@primary_mutations << \"Mind Crush\"\n when 688..693\n @@primary_mutations << \"Mind Waste\"\n when 694..699\n @@primary_mutations << \"Monstrous Morph\"\n when 700..718\n def multi_arm_mutation(roll) # Hub Rules p. 71\n case roll\n when 1..10\n additional_arms = 1\n when 11..85\n additional_arms = 2\n when 86..90\n additional_arms = 3\n when 91..97\n additional_arms = 4\n when 98\n additional_arms = 5\n when 99\n additional_arms = 6\n when 100\n additional_arms = (d(6) +6)\n end\n if additional_arms % 2 == 1\n def odd_arm_side(roll)\n case roll\n when 1\n odd_arm = \"right\"\n when 2\n odd_arm = \"left\"\n end\n end\n odd_arm_side(d(2))\n @@character_notes << \"Odd arm is on the #{odd_arm_side} side.\"\n end\n\n @@primary_mutations << \"Multi-Arm: #{additional_arms} additional arms\"\n end\n\n multi_arm_mutation(d(100))\n\n when 719..728\n def multi_head_mutation(roll)\n case roll\n when 1..70\n additional_heads = 1\n multi_head_appearance = -d(4)\n multi_head_mv = 0\n multi_head_initiative = 1\n when 71..88\n additional_heads = 2\n multi_head_appearance = -(d(4) + 1 )\n multi_head_mv = 0.25\n multi_head_initiative = 1\n when 89..95\n additional_heads = 3\n multi_head_appearance = -(d(6) + 2)\n multi_head_mv = 0.5\n multi_head_initiative = 2\n when 96..97\n additional_heads = 4\n multi_head_appearance = -(d(6) + 4)\n multi_head_mv = 0.75\n multi_head_initiative = 2\n when 98..99\n additional_heads = 5\n multi_head_appearance = -(d(6) + 6)\n multi_head_mv = 1\n multi_head_initiative = 3\n when 100\n additional_heads = 6\n multi_head_appearance = -(d(6) + 8)\n multi_head_mv = 1.25\n multi_head_initiative = 4\n end\n\n @@primary_mutations << \"Multi-Head: #{additional_heads} additional heads.\"\n @@appearance += multi_head_appearance\n @@movement_rate_base -= multi_head_mv\n @@initiative += multi_head_initiative\n @@character_notes << \"Heads tend to sleep at different times, with wakeful heads acting as lookout.\"\n\n while extra_heads > 0 do\n intelligence = attributes_roll(d100)\n wisdom = attributes_roll(d100)\n puts \"Extra head no. #{extra_heads} has INT of #{intelligence} and WIS of #{wisdom}\"\n def extra_head_mutations(roll2)\n case roll2\n when 1..62\n extra_head_mutation = ghost_mutations(d(100))\n @@primary_mutations << extra_head_mutation\n @@character_notes << \"Extra head no. #{extra_heads} has the mental mutation #{extra_head_mutation}\" # HOW to pick just the name of the mental mutation??\n end\n end\n end\n additional_heads -= 1\n end\n multi_head_mutation(d(100))\n\n when 729..738\n @@primary_mutations << \"Night Vision: can see as well at night as a typical human can in daylight (at least starlight must be present).\"\n when 739..745\n @@primary_mutations << \"Peeling Radius\"\n @@attacks << {:attack_mode => \"Peeling Radius\", :SV => 0, :rate => 1, :range => 10, :damage => \"d6/rd\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"71\", :notes => \"10m radius. Automatic hit. Duration: 3 rds/rank\"}\n when 746..754\n def poison_bite_mutation(roll1, roll2) # Hub Rules p. 71\n case roll1\n when 1..54\n poison_bite_strength = \"A\"\n when 55..84\n poison_bite_strength = \"B\"\n when 85..97\n poison_bite_strength = \"C\"\n when 98..99\n poison_bite_strength = \"D\"\n when 100\n poison_bite_strength = \"E\"\n end\n\n case roll2\n when 1..5\n poison_bite_type = \"Death\"\n when 6\n poison_bite_type = \"Paralysis\"\n when 7\n poison_bite_type = \"Insanity\"\n when 8..10\n poison_bite_type = \"Sleep\"\n end\n\n @@primary_mutations << \"Poison Bite: #{poison_bite_type} venom, strength #{poison_bite_strength}, 4/day. Sufficient to coat 4 arrows/darts or 1 blade per injection's worth of poison.\"\n @@attacks << {:attack_mode => \"Poison Bite\", :SV => 0, :rate => 1, :range => 0, :damage => \"d6 plus poison\", :ammo => \"4/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"71\", :notes => \"#{poison_bite_type} venom, #{poison_bite_strength} strength.\"}\n end\n\n poison_bite_mutation(d(100),d(10))\n\n\n when 755..760\n\n def poison_blood_mutation(roll1, roll2) # Hub Rules p. 71\n case roll1\n when 1..54\n poison_bite_strength = \"A\"\n when 55..84\n poison_bite_strength = \"B\"\n when 85..97\n poison_bite_strength = \"C\"\n when 98..99\n poison_bite_strength = \"D\"\n when 100\n poison_bite_strength = \"E\"\n end\n\n case roll2\n when 1..5\n poison_bite_type = \"Death\"\n when 6\n poison_bite_type = \"Paralysis\"\n when 7\n poison_bite_type = \"Insanity\"\n when 8..10\n poison_bite_type = \"Sleep\"\n end\n\n @@primary_mutations << \"Poison Blood: #{poison_bite_type} venom, #{poison_bite_strength} strength. Any creature biting mutant poisoned.\"\n\n end\n\n poison_blood_mutation(d(100),d(10))\n\n when 761..767\n paralysis_tendrils = d(6)\n @@primary_mutations << \"Paralysis Tendrils: #{paralysis_tendrils} 3m length grow from mutant's chest\"\n @@appearance = [@@appearance - (4 * paralysis_tendrils), 1].max\n @@attacks << {:attack_mode => \"Paralysis Tendrils\", :SV => 10, :rate => 1, :range => 3, :damage => \"d12 stun, 2d20 vs machines\", :ammo => \"3/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"72\", :notes => \"#{paralysis_tendrils} tendrils, each capable of attack 3/day/rank.\"}\n\n\n when 768..773\n @@primary_mutations << \"Radiation Absorption: mutant immune to radioactivity, except for radioactive weapons, which do half damage.\"\n when 774..780\n @@primary_mutations << \"Radiation Detection: automatically senses the presence of radiation within a twenty meter radius, including those rare sources found in special radiation using robots, relic weapons and life forms.\"\n when 781..786\n @@primary_mutations << \"Radioactive Pulse\"\n @@attacks << {:attack_mode => \"Radioactive Pulse\", :SV => 10, :rate => 1, :range => @@willpower, :damage => \"d20 plus radiation\", :ammo => \"1/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"72\", :notes => \"Victim makes type B endurance hazard check or suffer medium exposure; then type A hazard check or suffer strong exposure.\"}\n when 787..794\n @@primary_mutations << \"Reserve Heart: If character deemed to be killed by poison or electricity, or a critical hit which specifcally states a piercing of the heart, she will appear to be quite dead for 2d20+10 rounds. After this comatose period without a pulse or heartbeat, her back up heart will suddenly kick in and induce 2d10 endurance of healing, bringing the character slowly back to life.\"\n when 795..802\n @@primary_mutations << \"Reserve Mind: back-up brain takes over in case of brain damage, unconsciousness, insanity, or lethal damage. Hub Rules p. 72\"\n when 803..809\n @@primary_mutations << \"Scaled Skin\"\n @@dv -= 8\n @@appearance = [@@appearance - d(4), 1].max\n @@character_notes << \"Scaled skin: immune to damage from sunburn, sand storms, insect bites, and topical irritants.\"\n when 810..814\n @@primary_mutations << \"Serpentine Body: +4 mv on land or swimming\"\n @@dv -= 5\n serpent_body_length = d(3) + 1\n @@character_weight += (40 * serpent_body_length)\n @@appearance = [@@appearance - (d(6) + 1), 1].max\n @@movement_rate_base += 4\n @@movement_rate_swimming += 4\n @@character_notes << \"Unable to wear relic shell class armor\"\n @@attacks << {:attack_mode => \"Serpentine Body Strike\", :SV => 0, :rate => 1, :range => serpent_body_length, :damage => \"d20 stun\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"72\", :notes => \"Constrict for d10 lethal dmg/rd after successful strike.\"}\n\n when 815..839\n def shell_mutation(roll) # Hub Rules p. 73\n case roll\n when 1..4\n shell_rating = \"Light\"\n shell_defense_value = 10\n shell_movement_penalty = 0.5\n shell_appearance_penalty = (d(4) + 1)\n shell_weight = 20\n when 5..7\n shell_rating = \"Medium\"\n shell_defense_value = 20\n shell_movement_penalty = 1\n shell_appearance_penalty = (d(6) + 2)\n shell_weight = 30\n when 8..9\n shell_rating = \"Heavy\"\n shell_defense_value = 30\n shell_movement_penalty = 1.5\n shell_appearance_penalty = (d(6) + 4)\n shell_weight = 40\n when 10\n shell_rating = \"Extra Heavy\"\n shell_defense_value = 40\n shell_movement_penalty = 2\n shell_appearance_penalty = (d(6) + 6)\n shell_weight = 50\n end\n @@primary_mutations << \"#{shell_rating} Shell: #{shell_defense_value} DV, -#{shell_movement_penalty} MV\"\n @@appearance = [@@appearance - shell_appearance_penalty, 1].max\n @@dv -= shell_defense_value\n @@movement_rate_base -= shell_movement_penalty\n @@character_weight += shell_weight\n @@character_notes << \"Due to Shell mutation, punches, kicks, head-butts etc. deal 2d6 dmg instead of typical d6.\"\n @@character_notes << \"Shell mutation: no relic armor OTHER than ballistic, riot, and bomb squad armor can be worn. Combat armor can be modified, d6+1 days.\"\n end\n\n shell_mutation(d(10))\n\n when 840..849\n def size_decrease_mutation(height)\n case height\n when 61..95\n @@agility += (d(8) + d(8))\n @@strength = [@@strength - d(10), 1].max\n @@endurance = [@@endurance - (d(6) + d(6)), 1].max\n 4.times @@skills << \"Stealth\"\n when 66..90\n @@agility += (d(6) + d(6))\n @@strength = [@@strength - d(8), 1].max\n @@endurance = [@@endurance - (d(4) + d(4)), 1].max\n 3.times @@skills << \"Stealth\"\n when 91..110\n @@agility += (d(4) + d(4))\n @@strength = [@@strength - d(6), 1].max\n @@endurance = [@@endurance - d(6), 1].max\n 2.times @@skills << \"Stealth\"\n when 111..130\n @@agility += d(6)\n @@strength = [@@strength - d(4), 1].max\n @@endurance = [@@endurance - d(4), 1].max\n 2.times @@skills << \"Stealth\"\n when 131..140\n @@agility += d(6)\n @@strength = [@@strength - d(3), 1].max\n @@endurance = [@@endurance - 2, 1].max\n @@skills << \"Stealth\"\n when 141..159\n @@agility += d(4)\n @@skills << \"Stealth\"\n when 160..199\n @@agility += d(3)\n @@skills << \"Stealth\"\n end\n end\n\n @@character_height -= d(100)\n size_decrease_mutation(@@character_height)\n @@primary_mutations << \"Size Decrease\"\n when 850..860\n @@primary_mutations << \"Size Increase\"\n @@character_height += (d(100) + d(100) + d(100) + d(100))\n\n def size_increase_mutation(height) # Hub Rules p. 73\n case height\n when 164..184\n @@strength += d(10)\n @@endurance && @@character_weight += (d(10) + 5)\n when 185..199\n @@movement_rate_base += 0.25\n @@strength += (d(10) + 5)\n @@endurance && @@character_weight += (d(10) + 10)\n when 200..250\n @@movement_rate_base += 0.5\n @@strength += (d(10) + 10)\n @@endurance && @@character_weight += (d(20) + 15)\n when 251..299\n @@movement_rate_base += 0.75\n @@strength += (d(20) + 15)\n @@endurance && @@character_weight += (d(20) + 20)\n when 300..350\n @@movement_rate_base += 1\n @@strength += (d(20) + 20)\n @@endurance && @@character_weight += (d(20) + 30)\n when 351..399\n @@movement_rate_base += 1.25\n @@strength += (d(20) + 30)\n @@endurance && @@character_weight += (d(20) + 40)\n when 400..425\n @@movement_rate_base += 1.5\n @@strength += (d(20) + 40)\n @@endurance && @@character_weight += (d(20) + 50)\n when 426..450\n @@movement_rate_base += 1.75\n @@strength += (d(20) + 50)\n @@endurance && @@character_weight += (d(20) + 60)\n when 451..475\n @@movement_rate_base += 2\n @@strength += (d(20) + 60)\n @@endurance && @@character_weight += (d(20) + 75)\n when 476..499\n @@movement_rate_base += 3\n @@strength += (d(20) + 75)\n @@endurance && @@character_weight += (d(20) + 88)\n when 500..525\n @@movement_rate_base += 4\n @@strength += (d(20) + 88)\n @@endurance && @@character_weight += (d(20) + 100)\n when 526..560\n @@movement_rate_base += 5\n @@strength += (d(20) + 100)\n @@endurance && @@character_weight += (d(20) + 130)\n when 561..580\n @@movement_rate_base += 6\n @@strength += (d(20) + 130)\n @@endurance && @@character_weight += (d(20) + 160)\n end\n end\n\n size_increase_mutation(@@character_height)\n\n when 861..869\n def sonic_wave_radius_mutation(willpower) # Hub Rules p. 73\n case willpower\n when 1..9\n attack_radius = 1\n damage = \"d4\"\n deafness_duration = \"1 minute\"\n when 10..23\n attack_radius = 2\n damage = \"d6\"\n deafness_duration = \"5 minutes\"\n when 24..34\n attack_radius = 4\n damage = \"d8\"\n deafness_duration = \"10 minutes\"\n when 35..60\n attack_radius = 5\n damage = \"d10\"\n deafness_duration = \"30 minutes\"\n when 61..70\n attack_radius = 7\n damage = \"d12\"\n deafness_duration = \"1 hour\"\n when 71..80\n attack_radius = 9\n damage = \"d20\"\n deafness_duration = \"2d4 hours\"\n when 81..90\n attack_radius = 15\n damage = \"d20 + 5\"\n deafness_duration = \"3d6 hours\"\n when 91..100\n attack_radius = 20\n damage = \"d20 + 10\"\n deafness_duration = \"d6 days\"\n when 101..110\n attack_radius = 25\n damage = \"d20 + 15\"\n deafness_duration = \"2d4 days\"\n when 111..120\n attack_radius = 30\n damage = \"d20 + 20\"\n deafness_duration = \"3d6 days\"\n when 121..130\n attack_radius = 40\n damage = \"d20 + 30\"\n deafness_duration = \"3d6 + 10 days\"\n when 131..140\n attack_radius = 50\n damage = \"d20 + 40\"\n deafness_duration = \"3d6 + 20 days\"\n when 141..150\n attack_radius = 60\n damage = \"d20 + 50\"\n deafness_duration = \"3d6 + 30 days\"\n end\n\n @@primary_mutations << \"Sonic Wave Radius: 2/day/rank, #{attack_radius} radius, #{damage} damage, #{deafness_duration} deafness.\"\n @@attacks << {:attack_mode => \"Sonic Wave Radius\", :SV => 100, :rate => 1, :range => attack_radius, :damage => damage, :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"73\", :notes => \"#{deafness_duration} deafness\"}\n end\n\n sonic_wave_radius_mutation(@@willpower)\n\n\n when 870..876\n @@primary_mutations << \"Spines: #{d(10) + 10} cm length, + d6 dmg to punch/kick\"\n @@dv -= (d(20) + 10)\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@character_notes << \"Unable to wear relic armor unless spines are sawed off monthly.\"\n when 877..880\n @@primary_mutations << \"Sprint: 2/day/rank, duration 2d10 + rank rounds. -20DV (-20SV with misslie weapons) while sprinting OR double melee attack rate.\"\n when 881..886\n def stalked_eyes_mutation(roll)\n case roll\n when 1..67\n eye_stalks = (d(4) + 1)\n @@primary_mutations << \"Stalked eyes: mutant has #{eye_stalks} #{(d(20) + 10)} cm long instead of typical eyes.\"\n when 68..100\n eye_stalks = (d(3) + 1)\n @@primary_mutations << \"Stalked eyes: mutant has #{eye_stalks} #{(d(20) + 10)} cm long in addition to typical eyes.\"\n end\n\n @@dv -= (eye_stalks * 3)\n @@initiative += 2\n @@appearance = [@@appearance - (eye_stalks * d(6)), 1].max\n end\n\n stalked_eyes_mutation(d(100))\n\n when 887..892\n def stench_spray_location(roll) # Hub Rules p. 74\n case roll\n when 1..2\n location = \"Groin\"\n when 3..4\n location = \"Stomach\"\n when 5..6\n location = \"Chest\"\n when 7\n location = \"Left armpit\"\n when 8\n location = \"Right armpit\"\n when 9\n location = \"Back\"\n when 10\n location = \"Butt\"\n end\n\n stench_spray_app = (6 + d(6))\n @@primary_mutations << \"Stench Spray: #{20 + d(20) + d(20)} cm organ located on character's #{location}\"\n @@attacks << {:attack_mode => \"Stench Spray\", :SV => 10, :rate => 1, :range => (@@strength / 2), :damage => \"Special\", :ammo => \"2/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"74\", :notes => \"Endurance-based type B hazard check or d6 + 1 rds vomiting, +30SV to strike, -30SV to attack others.\"}\n @@character_notes << \"Character's appearance -#{stench_spray_app} penalty after stench organ seen.\"\n\n end\n\n stench_spray_location(d(10))\n\n when 893..901\n @@primary_mutations << \"Strength Burst: 2/rank/day, 4 rds/rank duration, character's strength 4x regular amount. Contributes to strength-based hazard checks, melee damage, etc.\"\n when 902..909\n def stun_ray_launcher(roll)\n case roll\n when 1..17\n stun_location = \"eyes\"\n when 18..59\n stun_location = \"left hand\"\n when 60..101\n stun_location = \"right hand\"\n end\n\n @@primary_mutations << \"Stun Ray fired from #{stun_location}.\"\n @@attacks << {:attack_mode => \"Stun Ray\", :SV => 10, :rate => 1, :range => (@@willpower * 2), :damage => \"2d20 stun, x2 vs machines\", :ammo => \"3/day/rank\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"74\", :notes => \"Stun damage fades after 1 hour.\"}\n end\n\n stun_ray_launcher(d(101))\n\n when 910..924\n def tail_mutation(roll) # Hub Rules p. 74\n case roll\n when 1..2\n tail_type = \"Club\"\n tail_length = 1.5\n tail_agility_bonus = d(4)\n tail_move = -1\n tail_sv = 6\n tail_attack_dmg = \"d12 + 2 lethal or stun\"\n when 3\n tail_type = \"Crocodile\"\n tail_length = 1.7\n tail_agility_bonus = d(8)\n tail_move = -1\n tail_move_water = 4\n tail_sv = 5\n tail_attack_dmg = \"d12 stun\"\n when 4\n tail_type = \"Dolphin\"\n tail_length = 1.5\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_move_water = 6\n tail_sv = 4\n tail_attack_dmg = \"d12 stun\"\n when 5\n tail_type = \"Eagle\"\n tail_length = 1\n tail_agility_bonus = d(6)\n tail_move = 1\n tail_sv = 0\n tail_attack_dmg = nil\n when 6\n tail_type = \"Fish\"\n tail_length = 1.3\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_move_water = 5\n tail_sv = 4\n tail_attack_dmg = \"d10 stun\"\n when 7\n tail_type = \"Fox\"\n tail_length = 1.25\n tail_agility_bonus = (d(6) + d(6))\n tail_move = 1.5\n tail_sv = 0\n tail_attack_dmg = nil\n when 8\n tail_type = \"Cat\"\n tail_length = 1.5\n tail_agility_bonus = (d(8) + d(8))\n tail_move = 2\n tail_sv = 0\n tail_attack_dmg = nil\n when 9\n tail_type = \"Whip\"\n tail_length = (3 + d(4))\n tail_agility_bonus = d(6)\n tail_move = -0.25\n tail_sv = 4\n tail_attack_dmg = \"d8\"\n @@character_notes << \"Whip tail can be used as #{tail_length} rope.\"\n when 10..13\n tail_type = \"Prehensile (monkey)\"\n tail_length = 3\n tail_agility_bonus = (d(4) + d(4))\n tail_move = 1\n tail_sv = 0\n tail_attack_dmg = nil\n @@character_notes << \"Prehensile tail can wield dagger or knife for additional melee attack.\"\n when 14\n tail_type = \"Newt\"\n tail_length = 1.5\n tail_agility_bonus = d(8)\n tail_move = -1\n tail_move_water = 4\n tail_sv = 3\n tail_attack_dmg = \"d10 stun\"\n when 15\n tail_type = \"Porcupine\"\n tail_length = 0.75\n tail_agility_bonus = 0\n tail_move = -1\n tail_sv = 5\n tail_attack_dmg = \"d12 + 1\"\n when 16..17\n tail_type = \"Rat\"\n tail_length = 1.8\n tail_agility_bonus = d(6)\n tail_move = 0.5\n tail_sv = 0\n tail_attack_dmg = nil\n @@character_notes << \"Rat tail can wield dagger or knife for additional melee attack.\"\n when 18\n tail_type = \"Scorpion\"\n tail_length = 2\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_sv = 8\n tail_attack_dmg = \"d12 + Type A poison\"\n when 19\n tail_type = \"Spiked\"\n tail_length = 1.75\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_sv = 7\n tail_attack_dmg = \"d12 + 3\"\n when 20\n tail_type = \"Bladed\"\n tail_length = 2\n tail_agility_bonus = d(6)\n tail_move = -1\n tail_sv = 7\n tail_attack_dmg = \"d20\"\n end\n\n @@primary_mutations << \"Tailed: #{tail_type} tail of #{tail_length} m length.\"\n @@appearance += tail_agility_bonus\n @@movement_rate_base += tail_move\n @@movement_rate_swimming += tail_move_water\n if tail_attack_dmg != nil\n @@attacks << {:attack_mode => \"#{tail_type} tail strike\", :SV => tail_sv, :rate => 1, :range => tail_length, :damage => \"#{tail_attack_dmg}\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"74\", :notes => \"\"}\n end\n end\n\n tail_mutation(d(20))\n\n when 925..936\n @@primary_mutations << \"Telekinesis\"\n when 937..961\n @@primary_mutations << \"Telepathy\"\n when 962..967\n def tentacle_mutation(roll)\n case roll\n when 1..28\n number_of_tentacles = (d(4) + d(4) + 2)\n @@primary_mutations << \"Tentacles: Mutant has #{number_of_tentacles} instead of arms.\"\n when 29..100\n number_of_tentacles = (d(4) + d(4))\n @@primary_mutations << \"Tentacles: Mutant has #{number_of_tentacles} in addition to arms.\"\n end\n\n @@appearance = [@@appearance - (number_of_tentacles * 2), 1].max\n 2.times @@skills << \"Climbing\"\n @@character_notes << \"Tentacles add #{number_of_tentacles * 0.5} m to character's climbing & swimming move rates.\"\n @@character_notes << \"Tentacles can wield simple melee weapons but lack the dexterity needed to operate a keyboard, stringed, or triggered weapon.\"\n @@attacks << {:attack_mode => \"Tentacle strike\", :SV => 5, :rate => number_of_tentacles, :range => 0, :damage => \"d8 stun\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"75\", :notes => \"Tentacles gain unarmed combat modifiers, too.\"}\n end\n\n tentacle_mutation(d(100))\n\n when 968..975\n @@primary_mutations << \"Throwing Quills: fire 1/rd, up to 20/day\"\n @@dv -= 18\n @@character_notes << \"Due to quills, mutant cannot wear relic armor (except specially-designed junk or scrap relic armor)\"\n @@appearance = [@@appearance - (d(4) + d(4)), 1].max\n @@attacks << {:attack_mode => \"Throwing Quill\", :SV => 6, :rate => 1, :range => (@@strength / 2), :damage => \"d10\", :ammo => \"20/day\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"incl. strength and wpn expert skill modifiers\"}\n\n when 976..982\n def thrust_spike_mutation(roll)\n case roll\n when 1\n poison = \"type A death poison\"\n when 2..10\n poison = \"None\"\n end\n thrust_spike_length = (d(4) + d(4))\n @@primary_mutations << \"Thrust Spike #{thrust_spike_length} long.\"\n @@character_notes << \"After seeing thrust spike mutant's appearance score reduced for witness by d1- + 10.\" #obvious typo here\n if poison == \"None\"\n @@attacks << {:attack_mode => \"Thrust Spike\", :SV => 0, :rate => 1, :range => thrust_spike_length, :damage => \"d20\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"+30SV, 2d20 + 10 damage on first attack.\"}\n elsif poison != \"None\"\n @@attacks << {:attack_mode => \"Thrust Spike\", :SV => 0, :rate => 1, :range => thrust_spike_length, :damage => \"d20\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"+30SV, 2d20 + 10 damage on first attack. Also: #{poison}\"}\n end\n end\n\n thrust_spike_mutation(d(10))\n\n\n when 983..986\n @@primary_mutations << \"Tusks\"\n @@attacks << {:attack_mode => \"Tusk bite\", :SV => 6, :rate => 1, :range => 0, :damage => \"2d8 + 2\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"Additional melee attack/rd.\"}\n @@appearance = [@@appearance - (d(8) + 2), 1].max\n when 987..992\n @@primary_mutations << \"Webbed Hands: character nearly impossible to drown & can hold breath 2x normal. Double swim speed.\"\n @@movement_rate_swimming += @@movement_rate_swimming\n\n when 993..1000\n def wings_mutation(roll1,roll2) # Hub Rules p. 76\n case roll1\n when 1\n wing_type = \"Bird\"\n air_speed += 6\n @@character_notes << \"Bird wings are fragile - this character suffers double damage from fire and burst radius explosives like grenades and bombs.\"\n when 2\n wing_type = \"Insect\"\n air_speed += 3\n @@character_notes << \"Due to insect wings, character has -2 MV in enclosed spaces.\"\n when 3..6\n wing_type = \"Bat\"\n end\n\n case roll2\n when 1\n wing_size = \"Tiny\"\n flight_mode = \"Glide only\"\n air_speed += (d(6) + 10)\n flying_dv = -5\n wing_attack_dmg = nil\n wing_weight = 6\n when 2\n wing_size = \"Small\"\n flight_mode = \"Flies poorly\"\n air_speed += (d(6) + 12)\n flying_dv = -10\n wing_attack_dmg = \"d4 stun\"\n wing_weight = 12\n when 3..4\n wing_size = \"Medium\"\n flight_mode = \"Flies normally\"\n air_speed += (d(6) + 15)\n flying_dv = -14\n wing_attack_dmg = \"d6 stun\"\n wing_weight = 20\n when 5\n wing_size = \"Large\"\n flight_mode = \"Flies normally\"\n air_speed += (d(6) + 20)\n flying_dv = -20\n wing_attack_dmg = \"d8 stun\"\n wing_weight = 30\n when 6\n wing_size = \"Vast\"\n flight_mode = \"Flies excellently\"\n air_speed += (d(10) + 25)\n flying_dv = -25\n wing_attack_dmg = \"d10 stun\"\n wing_weight = 40\n end\n\n @@primary_mutations << \"Wings: #{wing_size} #{wing_type} wings. Mutant #{flight_mode} at #{air_speed} MV and #{flying_dv} DV when airborne.\"\n @@movement_rate_flying += air_speed\n\n if wing_attack_dmg != nil\n @@attacks << {:attack_mode => \"Wing bash\", :SV => 0, :rate => 2, :range => 0, :damage => \"#{wing_attack_dmg}\", :ammo => \"infinite\", :skill_pts => 0, :skill_SV_bonus => 0, :skill_damage_bonus => 0, :ref => \"76\", :notes => \"\"}\n end\n\n @@character_notes << \"Character able to fly at full air speed with full gear, arms, and armor. See Hub Rules p. 76 for more.\"\n @@character_notes << \"Due to wings, standard and relic armor must be modified and fitted to this character.\"\n\n\n end\n\n wings_mutation(d(6),d(6))\n\n end\nend",
"def push(val)\n if @stacks.empty?\n @stacks[0] = [val]\n if @capacity > 1\n @left[0] = 0\n else\n @right[0] = 0\n end\n else\n @left << @stacks.size if @left.empty?\n index = @left[0]\n @stacks[index] ||= []\n @stacks[index] << val\n if @stacks[index].size == @capacity\n @left.shift\n i = @right.bsearch_index { |j| j >= index } || @right.size\n @right.insert(i, index)\n end\n end\n end",
"def euclides_extendido(a,b)\n #condicion para comprobar si el numero b es mayor que a si es asi se hace un swap\n x,z=[],[]\n t_primo=false\n if(b.to_i>a.to_i)\n x[1],x[2]=b.to_i,a.to_i\n else\n x[1],x[2]=a.to_i,b.to_i\n end\n z[0],z[1]=0,1\n i=1\n r=x[1]%x[2]\n #puts \"resto al comienzo: #{r}\"\n if r==0\n t_primo=false\n else\n while(r>0)\n #puts \"#{\"=\"*30}\"\n #puts \"ITERACION #{i}\"\n #puts \"x[i-1]=#{x[i-1]}\"\n #puts \"x[i]=#{x[i]}\"\n #puts \"z[i-1]=#{z[i-1]}\"\n #puts \"z[i]=#{z[i]}\"\n if(i>=2)\n #puts \"entre...\"\n z[i]=(-1*((x[i-1]/x[i]).to_i))*z[i-1]+z[i-2]\n x[i+1]=x[i-1]%x[i]\n #puts \"z[i]=#{z[i]}\"\n #puts \"x[i+1]=#{x[i+1]}\"\n end\n r=x[i+1]\n mcd=x[i]\n if(mcd==1)\n t_primo=true\n #en caso de que el inverso de negativo, se suma al numero mayor que se paso a la función.\n if(z[i-1]<0)\n @inverso=z[i-1]+x[1]\n else\n @inverso=z[i-1]\n end\n end\n i+=1\n #puts \"#{\"=\"*30}\"\n end\n\n end\n puts \"MCD: #{mcd}\"\n puts \"INVERSO: #{@inverso}\"\n t_primo\n end",
"def pop(tape)\n\ta = Array.new\n\t# Move back to the stack seperator\n\ta.push Action.new(:left, tape)\n\n\t# Erase the stack seperator and the value\n\t(BitWidth + 1).times{\n\t\ta.push Action.new(BlankSymbol, tape)\n\t\ta.push Action.new(:right, tape)\n\t}\n\n\tm = SubMachine.empty \"pop-#{tape}\"\n\tm.states[m.first].transitions = [Transition.new( Hash.new, a, m.last)]\n\n\t# Now we're on top of the last bit of the prev. value on stack\n\tm2 = moveDistance(tape, (2*BitWidth) + 1, :left)\n\tm.simpleMerge(m2)\n\n\tm\nend"
] |
[
"0.6332841",
"0.633018",
"0.6228028",
"0.6073753",
"0.5940878",
"0.5940878",
"0.5924584",
"0.5902276",
"0.588438",
"0.58516985",
"0.5842788",
"0.5814223",
"0.5796433",
"0.5755147",
"0.5735655",
"0.56363976",
"0.5635745",
"0.5589201",
"0.55873513",
"0.55779636",
"0.5554847",
"0.5544647",
"0.55349094",
"0.5529853",
"0.55045027",
"0.5495728",
"0.5481077",
"0.54535353",
"0.5450435",
"0.5437192",
"0.53973305",
"0.53935546",
"0.53358006",
"0.53215235",
"0.5304477",
"0.5282959",
"0.5275121",
"0.5250228",
"0.52368253",
"0.52356356",
"0.5216195",
"0.5213568",
"0.5207544",
"0.52024657",
"0.5200813",
"0.51911265",
"0.5186445",
"0.5168549",
"0.51637566",
"0.5162162",
"0.51435316",
"0.5132483",
"0.51315266",
"0.512779",
"0.51126796",
"0.5111595",
"0.5106596",
"0.5097306",
"0.5096716",
"0.50914794",
"0.5087563",
"0.5063634",
"0.50427085",
"0.50337565",
"0.5033355",
"0.50259805",
"0.50235534",
"0.50234467",
"0.50224644",
"0.5019106",
"0.5014889",
"0.50040674",
"0.50040346",
"0.50012344",
"0.49995783",
"0.49929",
"0.49918342",
"0.49865863",
"0.49821815",
"0.49807203",
"0.49693936",
"0.49691027",
"0.49665144",
"0.49639696",
"0.49627972",
"0.49558756",
"0.4954175",
"0.49489227",
"0.49464694",
"0.49430546",
"0.49398547",
"0.49347997",
"0.49324366",
"0.49307382",
"0.49293944",
"0.49236155",
"0.49211815",
"0.49155593",
"0.49118465",
"0.49081945"
] |
0.57360953
|
14
|
Problem 8: ========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: Write a recursive method that computes the nth Fibonacci number, where nth is an argument to the method. E: fibonacci(1) == 1 fibonacci(2) == 1 fibonacci(3) == 2 fibonacci(4) == 3 fibonacci(5) == 5 fibonacci(12) == 144 fibonacci(20) == 6765 D: Input integer, output integer A: Create a method fibonacci that takes one argument an integer called num if the num is less than 2 return num else then add fibonacci(n 1) and fibonacci (n 2)
|
def fibonacci(current_num)
return current_num if current_num < 2
fibonacci(current_num -1) + fibonacci(current_num -2)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"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(n)\n if n < 2\n return n\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\nend",
"def fibonacci(n)\n if n < 2\n return n\n else\n return fibonacci(n-1) + fibonacci(n-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 fibonacci(n)\n \n return n if n == 1\n \n if n > 2 \n fibonacci(n-1) + fibonacci(n-2)\n else\n fibonacci(n-1)\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 fib(n)\n\n if n == 1 or n == 2\n return 1\n else\n return fib(n-1) + fib(n-2)\n end\n\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 fibonacci(num)\n if num < 2\n num\n else\n fibonacci(num - 1) + fibonacci(num - 2)\n end\nend",
"def fibonacci(num)\n if num < 2\n num\n else\n fibonacci(num - 1) + fibonacci(num - 2)\n end\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 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 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(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 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 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 if n < 2\n n\n else\n fib(n-1)+fib(n-2)\n end\nend",
"def fibonacci(n)\n # your code here :)\n if n < 0\n return \"You must provide a number greater than 0\"\n end\n\n if n == 1 || n ==2 \n 1\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\n \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 fibonacci(n)\n return 1 if n <= 2\n \n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fib(n)\n if n == 1 || n == 2\n n\n else\n fib(n-1) + fib(n-2)\n end\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 fib(n)\n if n <= 2\n n\n else\n fib(n-1) + fib(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(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(nth)\n return 1 if nth <= 2\n\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend",
"def fib(n)\n if n < 2\n 1\n else\n fib(n-2) + fib(n-1)\n end\nend",
"def fib(n)\n if n == 0\n 0\n elsif n == 1 || n == 2\n 1\n else fib(n - 2) + fib(n - 1)\n end\nend",
"def fibonacci n\n return n if n < 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1 ) + fibonacci(n - 2)\nend",
"def fibonacci(num)\n return 1 if num <= 2\n fibonacci(num - 1) + fibonacci(num -2)\nend",
"def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fib(n)\n if n<2\n return n\n else\n return fib(n-2)+fib(n-1)\n end\nend",
"def fibonacci(n)\n if n == nil || n < 0\n raise ArgumentError, \"Number must be positive\"\n end\n if n < 2\n return n\n else\n fibonacci(n - 1) + fibonacci(n - 2)\n end\nend",
"def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 2) + fibonacci(n - 1)\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 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 fibonacci_given(nth)\n return 1 if nth <= 2\n fibonacci_given(nth - 1) + fibonacci_given(nth - 2)\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 fib(n)\n return 1 if n == 2\n return 0 if n == 1\n\n fib(n-1) + fib(n-2)\nend",
"def fibonacci(n)\n return 1 if n == 1 || n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fibonacci(n)\n return 1 if n == 1 || n == 2\n fibonacci(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 fibonnaci(n)\n if n == 1 || n == 2\n 1\n else\n fibonnaci(n - 1) + fibonnaci(n - 2)\n end\nend",
"def fibonacci(n)\n return n if (0..1).include? n\n (fibonacci(n - 1) + fibonacci(n - 2))\nend",
"def fib(n)\n if n == 1 || n == 2\n return 1\n end\n return fib(n-1) + fib(n-2)\nend",
"def fib(n)\n if n == 1 || n == 2\n return 1\n end\n return fib(n-1) + fib(n-2)\nend",
"def fibonacci(n)\n return 1 if n == 1 || n == 2\n\n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fib(n)\n if n == 0 || n == 1\n return n\n else\n fib(n-1) + fib(n-2)\n end\nend",
"def fib(n)\n # your implementation here\n if n==0 then\n 1\n elsif n==1 then\n 1\n else \n fib(n-2) + fib(n-1)\n end\nend",
"def fib(n)\n return n if n < 2\n fib(n-1) + fib(n-2)\nend",
"def fib(n)\n if (n <= 1) \n return n;\n else\n return fib(n-1)+fib(n-2);\n end\nend",
"def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend",
"def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend",
"def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend",
"def fibonacci(number)\n if number < 2\n number\n else\n # 2 recursive calls in the recursive case\n fibonacci(number - 1) + fibonacci(number - 2)\n end\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 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 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 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 fibonacci (num)\n if num < 0\n puts \"error: cannot calcuate fibonacci of a negative number\"\n return 0\n elsif num == 0\n return 0\n elsif num == 1\n return 1\n end\n fibonacci(num - 1) + fibonacci(num - 2)\nend",
"def fibonacci(n)\n return n if n == 1 || n == 0 \n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fib(n)\n if n == 1 || n == 2\n return 1\n end\n return fib(n - 1) + fib(n - 2)\nend",
"def fib(n)\r\n if n == 1 then\r\n 10\r\n elsif n == 0 then\r\n 1\r\n else\r\n fib(n - 1) + fib(n - 2)\r\n end\r\nend",
"def fib(n)\n # return base cases of 0, 1\n return n if n == 0 || n == 1\n # call the function again to add the previous two numbers\n return fib(n-2)+fib(n-1)\nend",
"def fibonacci( n )\n return n if n <= 1 \n fibonacci( n - 1 ) + fibonacci( n - 2 ) \nend",
"def recursive_fib(n)\n if n<2\n return n\n else\n return (recursive_fib(n-1)+recursive_fib(n-2))\n end \nend",
"def fibonacci(n)\n raise ArgumentError, ('argument n cannot be a negative number') if n < 0\n return n if n == 1 || n == 0 #base case\n return fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def recursive_fib(n, a=0, b=1)\r\n if n == 0\r\n return a\r\n else\r\n recursive_fib(n - 1, b, a + b)\r\n end\r\nend",
"def fib(n)\n return 1 if n <= 2\n fib(n-1) + fib(n-2)\nend",
"def fib(n) (n<=2) ? 1 : (fib(n-2)+fib(n-1)) end",
"def recursive_fib n\n return 1 if n == 1 || n == 2\n recursive_fib(n-1) + recursive_fib(n-2)\nend",
"def fib(n)\n return 1 if n == 1 || n == 2\n fib(n-1) + fib(n-2)\nend",
"def fibonacci_v2(number)\n if number < 2\n number\n else\n fibonacci_v2(number - 1)\n end\nend",
"def fibo(n)\n if n==1 or n == 2 \n 1\n else\n return fibo(n-1) + fibo(n-2)\n end\nend",
"def fibonacci(n)\n\n return 1 if n == 1 || n == 2\n return 0 if n == 0\n raise ArgumentError if n < 0 \n\n fibonacci(n - 1) + fibonacci(n - 2)\n \nend",
"def fib(n)\n if n == 0 || n == 1\n return n\n else\n fib(n - 1) + fib(n - 2)\n end\n end",
"def fibonacci(n)\n return n unless n > 1\n fibonacci(n -1) + fibonacci(n -2)\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 fib(n)\n return 1 if n <= 2\n fib(n - 1) + fib(n - 2)\nend",
"def fib(n)\n return 0 if n == 0\n return 1 if n == 1\n\n return fib(n-1) + fib(n-2)\nend",
"def fib(n)\n return fib_num[n] if fib_num[n]\n\n fib_num[n - 2] = fib(n - 2) unless fib_num[n - 2]\n fib_num[n - 1] = fib(n - 1) unless fib_num[n - 1]\n\n return (fib_num[n - 2] + fib_num[n - 1])\n end",
"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 if n < 3\n 1\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\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 fib(n)\n return n if (0..1).include? n\n fib(n-1) + fib(n-2)\nend",
"def fibonacci(n)\n n = fibonacci( n - 1 ) + fibonacci( n - 2 ) if n > 1\n n\nend",
"def fib(n)\n return 0 if n <= 0\n return 1 if n == 1\n\n fib(n - 1) + fib(n - 2)\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 fib_basic(n)\n if (0..1).include? n\n return n\n else\n (fib_basic(n - 1) + fib_basic(n - 2))\n end\nend",
"def fib(num)\n if num == 0\n return 0\n elsif num == 1\n return 1\n else\n result = fib(num - 1) + fib(num - 2)\n return result\n end\nend",
"def fib2(n)\n if n < 2\n n\n else\n fib2(n - 1) + fib2(n - 2)\n end\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"
] |
[
"0.86330044",
"0.8520115",
"0.85185325",
"0.8517282",
"0.8505002",
"0.85015255",
"0.8484593",
"0.84775037",
"0.846297",
"0.846297",
"0.84616333",
"0.84551394",
"0.84490925",
"0.84419644",
"0.84419644",
"0.84419644",
"0.84419644",
"0.84291095",
"0.84220266",
"0.84141535",
"0.8410628",
"0.83978283",
"0.83895737",
"0.83891594",
"0.83860636",
"0.8378991",
"0.83785886",
"0.8378354",
"0.8378354",
"0.8378354",
"0.8378354",
"0.8378129",
"0.8370988",
"0.8360497",
"0.83587503",
"0.83573294",
"0.835631",
"0.8355963",
"0.8355963",
"0.8354846",
"0.8354637",
"0.83504164",
"0.8349552",
"0.83438206",
"0.83428127",
"0.8335455",
"0.8330537",
"0.8326201",
"0.8326201",
"0.83227897",
"0.8321958",
"0.83211464",
"0.8318791",
"0.8318791",
"0.83169526",
"0.83162427",
"0.83132714",
"0.8310093",
"0.8307424",
"0.8304427",
"0.8304427",
"0.8304427",
"0.8302245",
"0.83006823",
"0.8297654",
"0.8295629",
"0.82949626",
"0.8294575",
"0.8294528",
"0.829319",
"0.82874125",
"0.8285501",
"0.82767236",
"0.82686853",
"0.82601726",
"0.82546735",
"0.8250827",
"0.8249146",
"0.82485646",
"0.82483125",
"0.8247703",
"0.82463115",
"0.824365",
"0.8242094",
"0.8235723",
"0.82309055",
"0.8220809",
"0.8217955",
"0.82178706",
"0.82178277",
"0.8211165",
"0.8209988",
"0.82088614",
"0.82088506",
"0.82086354",
"0.82054156",
"0.819902",
"0.8196867",
"0.81881",
"0.81864405"
] |
0.8290971
|
70
|
Problem 9: ========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: Rewrite your recursive fibonacci method so that it computes its results without recursion. E: fibonacci(20) == 6765 fibonacci(100) == 354224848179261915075 D: Input integer, output integer A: Create a method fibonacci that takes one argument num an integer return 1 if num is less than 2 set variable num_1 equal to 1 set variable num_2 equal to 2 set variable new_num equal to 0 set counter equal to 1 loop through the following set new_num equal to num_1 + num_2 set num_1 equal to num_2 set num_2 equal to new_num break out of the loop if counter equals num return new_num
|
def fibonacci(num)
first, last = [1, 1]
3.upto(num) do
first, last = [last, first + last]
end
last
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fibonacci(num)\n return 1 if num <= 2\n fibonacci(num - 1) + fibonacci(num -2)\nend",
"def fibonacci(num)\n if num < 2\n num\n else\n fibonacci(num - 1) + fibonacci(num - 2)\n end\nend",
"def fibonacci(num)\n if num < 2\n num\n else\n fibonacci(num - 1) + fibonacci(num - 2)\n end\nend",
"def fibonacci (num)\n if num < 0\n puts \"error: cannot calcuate fibonacci of a negative number\"\n return 0\n elsif num == 0\n return 0\n elsif num == 1\n return 1\n end\n fibonacci(num - 1) + fibonacci(num - 2)\nend",
"def fibonacci(current_num)\n return current_num if current_num < 2\n fibonacci(current_num -1) + fibonacci(current_num -2)\nend",
"def fibonacci_num(num)\n return 0 if num == 0\n return 1 if num == 1\n return 1 if num == 2\n fib_num = (fibonacci_num(num - 1)) + (fibonacci_num(num - 2))\nend",
"def fibonacci(num)\n return 0 if num.zero?\n\n if num == 1\n 1\n else\n fibonacci(num - 1) + fibonacci(num - 2)\n end\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 fibo(num)\n \n print \"Fibonacci series is: \"\n\n if num == 0\n puts num\n return num\n end\n\n if num == 1\n puts \"0 1\"\n return num\n end\n\n i,j,cur = 0,1,1\n\n print \"0 1 \"\n while cur < num\n k = i\n i = j\n j = k + j\n print \"#{j} \"\n cur = cur + 1\n end\n\n return j\n\nend",
"def fibonacci(number)\n $counter += 1\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend",
"def fibonacci(num)\n return num if [0, 1].include? num\n fibonacci(num - 2) + fibonacci(num - 1)\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(p2, p1, sum)\n next_number = p2 + p1\n return sum if next_number >= 4000000\n sum += next_number if next_number.even?\n fibonacci p1, next_number, sum\nend",
"def fib(num)\n if num == 0\n return 0\n elsif num == 1\n return 1\n else\n result = fib(num - 1) + fib(num - 2)\n return result\n end\nend",
"def fibonacci2(num)\n total = 0\n count = 2\n first_num = 1\n second_num = 1\n loop do\n total = first_num + second_num\n first_num = second_num\n second_num = total\n count += 1\n break if count == num\n end\n total\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 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(num) \n\tfib = [0,1]\n (num - 2).times do \n \tfib << fib[-2] + fib[-1]\n end\n fib[-1]\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 iterative_fib(num)\r\n\treturn num if num < 2\r\n\tfib = [0, 1]\t\r\n\t(2..num).each do |digit|\r\n\t\tx = fib[digit - 1] + fib[digit - 2]\r\n\t\tfib << x\r\n\tend\r\n\treturn fib.last\r\nend",
"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(number)\n if number < 2\n number\n else\n # 2 recursive calls in the recursive case\n fibonacci(number - 1) + fibonacci(number - 2)\n end\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 fibonacci_v2(number)\n if number < 2\n number\n else\n fibonacci_v2(number - 1)\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 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 fibonacci(n)\n return 1 if n == 1\n return 1 if n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\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(num)\n return num if num < 2\n result = [0,1]\n until num == 1\n result << result[-1] + result[-2]\n num -= 1\n end\n result \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(n)\n \n return n if n == 1\n \n if n > 2 \n fibonacci(n-1) + fibonacci(n-2)\n else\n fibonacci(n-1)\n end\nend",
"def fibonacci(n)\n return 1 if n <= 2\n num1 = 1\n num2 = 1\n new_num = 0\n (n-2).times do\n new_num = num1 + num2\n num1 = num2\n num2 = new_num\n end\n new_num\nend",
"def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 2) + fibonacci(n - 1)\nend",
"def fibonacci(n)\n if n == nil || n < 0\n raise ArgumentError\n end\n# base cases are 0 and 1 (0th place is 0, 1st place is 1)\n if n < 2\n return n\n end\n\n counter = 1\n left = 0\n right = 1\n\n while counter < n\n sum = left + right\n left = right\n right = sum\n counter += 1\n end\n return sum\nend",
"def fibonacci(n)\n raise ArgumentError if n.class != Integer\n raise ArgumentError if n < 0\n return n if n < 2\n\n i = 1\n n1 = 0\n n2 = 1\n\n while i < n\n fibonacci = n1 + n2\n n1 = n2\n n2 = fibonacci\n i +=1\n end\n\n return fibonacci\n\nend",
"def fibonacci(n, num1=1, num2=1)\n return 1 if n <= 2\n (n - 2).times do\n num1, num2 = num2, num1 + num2\n end\n num2\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 if n < 2\n return n\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\nend",
"def fibonacci(integer)\n return 1 if integer <= 2\n\n fibonacci(integer - 1) + fibonacci(integer - 2)\nend",
"def fibonacci(n)\n return 1 if n <= 2\n \n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fibonacci(n)\n if n < 2\n n\n else\n fibonacci(n - 1) + fibonacci(n - 2)\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 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 num1, num2 = 1, 1\n counter = 2\n loop do\n break if counter >= n\n num2, num1 = num2 + num1, num2\n counter += 1\n end\n num2\nend",
"def recursive_fibonacci(n)\nreturn [1] if n == 1 \nreturn [1,1] if n== 2\n# a = recursive_fibonacci(n-1)\n# b = a[-1]\n# c=a[-2]\n# a+=(b+c)\nrecursive_fibonacci(n-1)+([recursive_fibonacci(n-1)[-2]+recursive_fibonacci(n-1)[-1]])\n# +([recursive_fibonacci(n-1)[-1]]+[recursive_fibonacci(n-1)[-2]])\n#fibonacci(n)=fibonacci(n-1) +=(fibonacci(n-1)[-1]+fibonacci(n-1)[-2])\nend",
"def fibonacci(n)\n if n < 2\n return n\n else\n return fibonacci(n-1) + fibonacci(n-2)\n end\nend",
"def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fibonacci(n)\n return 1 if n <= 2\n fibonacci(n - 1 ) + fibonacci(n - 2)\nend",
"def fib(n)\n return 1 if n == 2\n return 0 if n == 1\n\n fib(n-1) + fib(n-2)\nend",
"def fibonacci(number)\n\n if number == 1 || number == 0 # launch school used \"number < 2\"\n number\n else\n fibonacci(number-1) + fibonacci(number-2)\n end\n\nend",
"def fib(number)\n #start with 0 and 1\n fibonacci = [0,1]\n n = number - 2\n a = 0\n b = 1\n n.times do\n num = a\n a = b\n b += num\n fibonacci << b\n end\n return fibonacci\n end",
"def fibonacci(n)\n if n == 1 || n == 2\n 1\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\nend",
"def fibonacci_iterative(number)\n n1 = 0\n n2 = 1\n if number > 1 \n for i in 2..number\n fib = n2 + n1\n n1 = n2\n n2 = fib\n end\n elsif number == 1\n fib = 1\n else\n fib = 0\n end\n fib\nend",
"def fib(num)\n return num if num < 2\n return fib(num - 1) + fib(num - 2)\nend",
"def fibonacci n\n return n if n < 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fib(n)\n\n if n == 1 or n == 2\n return 1\n else\n return fib(n-1) + fib(n-2)\n end\n\nend",
"def fibonacci(fib)\r\n \t#Set a variable to 0\r\n\tvalue1 = 0 \r\n\t#Set a variable to 1 (array must start with 0, 1...)\r\n\tvalue2 = 1\r\n\t\t#For the number of digits it will be, loop do this many times\r\n\t\tfib.times do \r\n\t\t\t#Create a temp to store value1\r\n \t\t\ttemp = value1\r\n \t\t\t#Make value1 equal value2\r\n \t\t\t#This will help when printing out 0,1,1.. in the beginning\r\n \t\t\tvalue1 = value2\r\n \t\t\t#Make value2 equal the sum of temp and value2\r\n \t\t\t#This will add the last numbers to get the next number\r\n \t\t\tvalue2 = temp + value2\r\n \t\t#End do loop\r\n\t\tend\r\n\t#Return the first value\r\n \tvalue1\r\n#End of method\r\nend",
"def fibonacci(n)\n return 1 if n == 1\n return 0 if n == 0\n if n == nil || n < 0\n raise ArgumentError.new(\"nil\")\n end\n num1 = 0\n num2 = 1\n fibonacci_num = 0\n (n - 1).times do\n fibonacci_num = (num1 + num2)\n num1 = num2\n num2 = fibonacci_num\n end\n return fibonacci_num\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 fib(n)\n # return base cases of 0, 1\n return n if n == 0 || n == 1\n # call the function again to add the previous two numbers\n return fib(n-2)+fib(n-1)\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)\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 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 return 1 if n == 1 || n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fibonacci(n)\n return 1 if n == 1 || n == 2\n fibonacci(n - 1) + fibonacci(n - 2)\nend",
"def fib(num)\n return num if num <= 1\n fib(num-1) + fib(num-2)\nend",
"def fib_num(num)\n return 1 if num == 1\n return 1 if num == 2\n retu_num = fib_num(num-1) + fib_num(num-2)\nend",
"def fibonacci(n)\n return 1 if n == 1 || n == 2\n\n fibonacci(n - 1) + 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 fibonacci(n)\n # your code here :)\n if n < 0\n return \"You must provide a number greater than 0\"\n end\n\n if n == 1 || n ==2 \n 1\n else\n fibonacci(n-1) + fibonacci(n-2)\n end\n \nend",
"def fibonacci(num)\n if num == 0\n return 0\n end\n array = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]\n array[num - 1] + fibonacci(num - 2)\nend",
"def fib(n)\n if n < 2\n \tn\n else\n num1, num2 = 0,1\n while n > 1 #since the 0 and 1 steps were already done for the n<2 case\n n-=1\n num2 = num1 + num1 = num2 #as in: num2 = old_num1 + (num1 = old_num2, returns old_num2)\n # OR\n # tmp = num2\n # num2 += num1\n # num1 = tmp\n end\n num2\n end\nend",
"def fib(n)\n # your implementation here\n if n==0 then\n 1\n elsif n==1 then\n 1\n else \n fib(n-2) + fib(n-1)\n end\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(num)\n fib_arr = []\n\n\n if num == 0\n fib_arr = []\n return fib_arr\n elsif num == 1\n fib_arr = [0]\n return fib_arr\n elsif num == 2\n return fib_arr = [0,1] \n else \n fib_arr = [0,1]\n end\n\n while fib_arr.length < num\n fib_arr[fib_arr.length ] = fib_arr[-1] + fib_arr[-2]\n end\n\n return fib_arr\nend",
"def fibonacci(num)\n (1..num).inject( [0,1] ) { |fib| fib << fib.last(2).inject(:+) }\n\nend",
"def fib(n)\n if n == 0\n 0\n elsif n == 1 || n == 2\n 1\n else fib(n - 2) + fib(n - 1)\n end\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(number_output)\n fibonacci=[1] #default with only one number\n if number_output > 1\n fibonacci << 1 #second digit in fibonnacci sequence\n if number_output > 2\n #already has two numbers in array\n (number_output-2).times do |count|\n fibonacci << fibonacci[-1] + fibonacci[-2]\n end\n end\n end\n print fibonacci\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 fibonacci(n)\n return n if n == 1 || n == 0 \n fibonacci(n - 1) + fibonacci(n - 2)\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 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 fibonacci( n )\n return n if n <= 1 \n fibonacci( n - 1 ) + fibonacci( n - 2 ) \nend",
"def fibonacci(n)\n return n if (0..1).include? n\n (fibonacci(n - 1) + fibonacci(n - 2))\nend",
"def fibonacci(number)\n\tfibo = 0\n\tnumber1 = 0\n\tnumber2 = 1\n\tsum = 0\n\twhile(fibo < number)\n\t\tif(fibo < 2)\n\t\t\tfibo += 1\n\t\telse\n\t\t\tif(fibo % 2 == 0)\n\t\t\t\tsum += fibo\n\t\t\tend\n\t\t\tnumber1 = number2\n\t\t\tnumber2 = fibo\n\t\t\tfibo = (number2 + number1)\n\t\tend\n\tend\n\treturn sum\nend",
"def recursive_fib(num)\r\n\treturn num if num == 0 || num == 1\r\n\trecursive_fib(num - 1) + recursive_fib(num - 2)\r\nend",
"def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend",
"def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend",
"def fibonacci( n )\n return n if ( 0..1 ).include? n\n ( fibonacci( n - 1 ) + fibonacci( n - 2 ) )\nend",
"def fib(n)\n #if n > 4000000\n #\treturn puts n\n #end\n return n if (0..1).include? n\n fib(n-1) + fib(n-2) if n > 1\nend",
"def iterative_fibinacci(num)\n\tfib_container = [1,1]\n\t(num-2).times { fib_container << fib_container[-2] + fib_container.last }\n\tfib_container\nend",
"def fib(n)\n if n < 2\n n\n else\n fib(n-1)+fib(n-2)\n end\nend",
"def fibonacci(num)\n fib_arr = [0, 1]\n if num == 0 || num == 1\n return fib_arr[num]\n else\n i = 2\n until fib_arr.length == num\n sum = fib_arr[-2] + fib_arr[-1]\n fib_arr.push(sum)\n i += 1\n end\n end\n fib_arr\nend",
"def fibonacci(num)\n fib_arr = [0, 1]\n if num == 0 || num == 1\n return fib_arr[num]\n else\n i = 2\n until fib_arr.length == num\n sum = fib_arr[-2] + fib_arr[-1]\n fib_arr.push(sum)\n i += 1\n end\n end\n fib_arr\nend",
"def fibonacci_number(num)\n # make sure fibonacci_number(0) and fibonacci_number(1)\n # start the sequence by returning 1 and 1. \n # This is an edge case\n\n if num <= 2\n return 1\n end\n # start the sequence with the first two numbers\n fibs_ar = [1, 1]\n # for educational purposes\n counter = 1\n\n # calculate the next number until the array has the one we want\n while fibs_ar.length < num\n second_to_last = fibs_ar[fibs_ar.length - 2]\n last = fibs_ar.last\n next_fib = second_to_last + last\n fibs_ar << next_fib\n counter +=1\n puts \"second_to_last = #{second_to_last}\"\n puts \"last = #{last}\"\n puts \"next_fib = #{next_fib}\"\n puts \"counter = #{counter}\"\n puts \"The Fibonacci Series is = #{fibs_ar}\"\n puts \"After #{counter} iterations, the last number is #{last}\"\n puts \"===========================================\"\n end\n print \"The final Fibonacci series is: #{fibs_ar}\"\n print \"\\n\"\n print \"The number in the Fibonacci series at position #{num} is: #{fibs_ar.last}\"\n print \"\\n\"\n fibs_ar.last\nend",
"def fib(n)\n if n < 2\n 1\n else\n fib(n-2) + fib(n-1)\n end\nend"
] |
[
"0.829699",
"0.8295511",
"0.8295511",
"0.8287801",
"0.8188932",
"0.81873995",
"0.81440985",
"0.81382084",
"0.81228006",
"0.81149834",
"0.81136876",
"0.8104607",
"0.8103951",
"0.8103353",
"0.8099077",
"0.8086643",
"0.8086643",
"0.8086643",
"0.8086643",
"0.8022646",
"0.8013671",
"0.8008983",
"0.80062425",
"0.8002651",
"0.7999114",
"0.799449",
"0.79937166",
"0.7990358",
"0.7986597",
"0.7977927",
"0.79729885",
"0.7966734",
"0.7965297",
"0.79632866",
"0.79572505",
"0.79563165",
"0.79541916",
"0.7953833",
"0.79496044",
"0.79488105",
"0.79476273",
"0.7947514",
"0.794721",
"0.7943537",
"0.7942599",
"0.7940993",
"0.79401726",
"0.79393435",
"0.79335326",
"0.7931717",
"0.7931717",
"0.79236096",
"0.79235977",
"0.792312",
"0.7921399",
"0.7915581",
"0.7911122",
"0.7910116",
"0.7902706",
"0.79022723",
"0.7901847",
"0.789883",
"0.78966624",
"0.78914607",
"0.7885593",
"0.78843707",
"0.7883737",
"0.7882744",
"0.7882744",
"0.7881001",
"0.78777885",
"0.78723854",
"0.7868562",
"0.78624916",
"0.7862036",
"0.7860955",
"0.78562826",
"0.7855941",
"0.7854456",
"0.7850715",
"0.78427655",
"0.7840461",
"0.7838761",
"0.7832583",
"0.7829769",
"0.7827674",
"0.7827057",
"0.7821442",
"0.78194195",
"0.7818974",
"0.7816109",
"0.7812772",
"0.7812772",
"0.7812772",
"0.781086",
"0.78078705",
"0.780555",
"0.78051597",
"0.78051597",
"0.78047985",
"0.7804133"
] |
0.0
|
-1
|
Problem 10: ========= PEDAC. Problem, Examples, Data Structure, Algorithum, Code P: In this exercise, you are going to compute a method that returns the last digit of the nth Fibonacci number. E: fibonacci_last(15) > 0 (the 15th Fibonacci number is 610) fibonacci_last(20) > 5 (the 20th Fibonacci number is 6765) fibonacci_last(100) > 5 (the 100th Fibonacci number is 354224848179261915075) fibonacci_last(100_001) > 1 (this is a 20899 digit number) fibonacci_last(1_000_007) > 3 (this is a 208989 digit number) fibonacci_last(123456789) > 4 D: Input integer, output integer A: Create a method fibonacci_last that takes one argument an integer call fibonacci on integer and call digits on it returning the 1 index
|
def fibonacci_last(integer)
last_2 = [1, 1]
3.upto(integer) do
last_2 = [last_2.last, (last_2.first + last_2.last) % 10]
end
last_2.last
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fibonacci_last(nth)\n answer = fibonacci(nth)\n answer.to_s.chars[-1].to_i\nend",
"def fibonacci_last(n)\n num = fibonacci(n)\n num.to_s[-1].to_i\nend",
"def fibonacci_last(n)\n fibonacci(n).to_s[-1].to_i\nend",
"def fibonacci_last(n)\n return 1 if n.between?(1, 2)\n prev_last_digits = [1, 1]\n \n 3.upto(n) do |_|\n prev_last_digits << prev_last_digits.sum % 10\n prev_last_digits.shift\n end\n \n prev_last_digits.last\nend",
"def fibonacci_last(n)\n fib = q9_fibonacci(n)\n \n fib.to_s[-1].to_i\nend",
"def fibonacci_last(num)\n fibonacci(num).to_s[-1].to_i\nend",
"def fibonacci_last(number)\n first, last = [1, 1]\n 3.upto(number) do\n first, last = [last, first + last]\n end\n\n last.digits.reverse.last\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_last(num)\n total = fibonacci2(num)\n total.to_s[-1].to_i\nend",
"def fibonacci_last(nth)\n result = []\n nth.times do \n result.size < 2 ? result << 1 : result << result[-2] + result[-1]\n end\n result[-1].digits[0] # result.last.digits.first\nend",
"def fibonacci_last(n, first=1, last=1)\n 3.upto(n) do\n first, last = last, first + last\n end\n last.to_s[-1].to_i\nend",
"def fibonacci_last(num)\n results = [1,1]\n n = 2\n\n (num - 2).times do \n results << results[n - 1] + results[n - 2]\n n += 1\n end\n\n number = results.pop\n\n number.to_s.chars.pop.to_i\nend",
"def fibonacci_last(nth)\n first, last = [1, 1]\n 3.upto(nth) do\n first, last = [last, first + last]\n end\n\n last.to_s[-1].to_i\nend",
"def fibonacci_last(n)\n return 1 if n == 1 || n == 2\n\n fibs = [1, 1]\n\n while fibs.length < n\n minus_one = fibs[-1].to_s[-1].to_i\n minus_two = fibs[-2].to_s[-1].to_i\n fibs << (minus_one + minus_two).to_s[-1].to_i\n end\n\n fibs.last\nend",
"def fib_last(nth)\n first, last = [1,1]\n 3.upto(nth) do\n first, last = [last, first + last]\n end\n last.to_s.[-1].to_i\nend",
"def fibonacci_last(num)\n last_2 = [1, 1]\n 3.upto(nth) do\n last_2 = [last_2.last, (last_2.first + last_2.last) % 10]\n end\n\n last_2.last\nend",
"def fibonacci_last(n)\n x = 1\n y = 1\n z = 0\n (n-2).times do\n z = x + y\n x = y%10\n y = z%10\n end\n z % 10\nend",
"def fibonacci_last(num)\n first, last = [1, 1]\n 3.upto(num) do\n first, last = [last, (first+last) % 10]\n end\n last\nend",
"def fibonacci_last(nth)\n last_2 = [1, 1]\n 3.upto(nth) do\n last_2 = [last_2.last, (last_2.first + last_2.last) % 10]\n end\n last_2.last\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 fibonacci_last(nth)\n last_2 = [1, 1]\n 3.upto(nth) do\n last_2 = [last_2.last, (last_2.first + last_2.last) % 10]\n end\n\n last_2.last\nend",
"def fibonacci_last(nth)\n last_2 = [1, 1]\n 3.upto(nth) do\n last_2 = [last_2.last, (last_2.first + last_2.last) % 10]\n end\n\n last_2.last\nend",
"def fibonacci_last(nth)\n last_2 = [1, 1]\n 3.upto(nth) do\n last_2 = [last_2.last, (last_2.first + last_2.last) % 10]\n end\n\n last_2.last\nend",
"def fibonacci_last(nth)\n last_2 = [1, 1]\n 3.upto(nth) do\n last_2 = [last_2.last, (last_2.first + last_2.last) % 10]\n end\n\n last_2.last\nend",
"def fibonacci_number(num)\n # make sure fibonacci_number(0) and fibonacci_number(1)\n # start the sequence by returning 1 and 1. \n # This is an edge case\n\n if num <= 2\n return 1\n end\n # start the sequence with the first two numbers\n fibs_ar = [1, 1]\n # for educational purposes\n counter = 1\n\n # calculate the next number until the array has the one we want\n while fibs_ar.length < num\n second_to_last = fibs_ar[fibs_ar.length - 2]\n last = fibs_ar.last\n next_fib = second_to_last + last\n fibs_ar << next_fib\n counter +=1\n puts \"second_to_last = #{second_to_last}\"\n puts \"last = #{last}\"\n puts \"next_fib = #{next_fib}\"\n puts \"counter = #{counter}\"\n puts \"The Fibonacci Series is = #{fibs_ar}\"\n puts \"After #{counter} iterations, the last number is #{last}\"\n puts \"===========================================\"\n end\n print \"The final Fibonacci series is: #{fibs_ar}\"\n print \"\\n\"\n print \"The number in the Fibonacci series at position #{num} is: #{fibs_ar.last}\"\n print \"\\n\"\n fibs_ar.last\nend",
"def fibonacci_last(nth)\n first, last = [1, 1]\n\n 3.upto(nth) do\n first, last = [last, (first + last) % 10]\n end\n\n last\nend",
"def fibonacci_last2(num)\n num %= 60\n return 0 if num == 0\n last = 1\n pen_ultimate = 1\n 3.upto(num) do\n last, pen_ultimate = (pen_ultimate + last) % 10, last\n end\n last\nend",
"def fibonacci_last_opt(n)\n fibonacci_arr_digits = init_lookup_table\n\n fibonacci_arr_digits[n % 60]\nend",
"def fibonacci_last(nth) \n first_60 = [0, 1]\n\n 3.upto(60) do \n first_60 << (first_60[-2] + first_60.last) % 10\n end\n\n first_60[nth % 60]\nend",
"def fibonacci(number_output)\n fibonacci=[1] #default with only one number\n if number_output > 1\n fibonacci << 1 #second digit in fibonnacci sequence\n if number_output > 2\n #already has two numbers in array\n (number_output-2).times do |count|\n fibonacci << fibonacci[-1] + fibonacci[-2]\n end\n end\n end\n print fibonacci\nend",
"def nthFibonacciNumber ()\n f = [1, 1]\n puts \"Which fibonacci number do you want?\"\n n = gets.chomp\n\n # error checking baked in\n if n.to_i.to_s != n\n puts \"That is not an integer\"\n else\n while f.size < n.to_i\n length = f.length\n nextFib = f[length - 2] + f[length - 1]\n f.push(nextFib)\n end\n puts \"#{f[-1]} is the fibonacci number at position #{n}\"\n end\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(int)\n range_array = (1..int).to_a\n final_array = [1,1]\n range_array.each do |num|\n p num > 2 ? final_array << final_array[num-3] + final_array[num-2] : nil\n end\n final_array[-1]\nend",
"def find_fibonacci_index_by_length(digits)\n target_number = 10 ** (digits - 1)\n recent_nums = [1,1]\n idx = 2\n\n while recent_nums[1] < target_number\n num = recent_nums.reduce(:+)\n recent_nums.push(num).shift\n idx += 1\n end\n\n idx\nend",
"def find_fibonacci_index_by_length(num_digits)\n prev = 1\n curr = 1\n index = 2\n return 1 if num_digits == 1\n while curr.digits.size < num_digits\n # puts \"number: #{curr} size: #{curr.digits.size} num_digits: #{num_digits}\"\n new = curr + prev \n prev = curr\n curr = new\n index += 1\n end\n # puts \"We reached number #{curr} with a length of #{num_digits} at index #{index}\"\n index \nend",
"def fibonacci(n)\n # Computes the nth fibonacci number in the series starting with 0.\n # fibonacci series: 0 1 1 2 3 5 8 13 21 ...\n # e.g. 0th fibonacci number is 0\n # e.g. 1st fibonacci number is 1\n # ....\n # e.g. 6th fibonacci number is 8\n\n\n # 0 1 1 2 3 5 8 13 21 34 55 89 144\n\n # time complexity is On: linear we have to look through the length of the string on integers.\n # space complexity is 01: constant, no matter how long the string is, we need the same amount of variable space for every instance\n\n def fibonacci(n)\n if n == 1 || n == 0\n return n\n elsif n == nil || n < 0\n raise ArgumentError.new\n else\n start = 0\n second_num = 1\n fib = 1\n\n while n > 2\n\n start = second_num\n second_num = fib\n fib = start + second_num\n\n n -= 1\n\n end\n return fib\n end\n\n end\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 fibonacci_last(nth)\n nth = nth % 60\n last_2 = [1, 1]\n 3.upto(nth) do\n last_2 = [last_2.last, (last_2.first + last_2.last) % 10]\n end\n\n last_2.last\nend",
"def fibonacci_last_instant(nth)\n fibonacci_last(nth % 60)\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 iterative_fib(num)\r\n\treturn num if num < 2\r\n\tfib = [0, 1]\t\r\n\t(2..num).each do |digit|\r\n\t\tx = fib[digit - 1] + fib[digit - 2]\r\n\t\tfib << x\r\n\tend\r\n\treturn fib.last\r\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 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 find_fibonacci_index_by_length(digits)\n index = 1\n last_fib_number = 0\n fib_number = 1\n loop do\n break if fib_number >= 10 ** (digits - 1)\n\n fib_number += last_fib_number\n last_fib_number = fib_number - last_fib_number\n index += 1\n end\n\n index\nend",
"def fibo (n)\n if n > @max_fibo_size\n return \"n must be #{@max_fibo_size} or less.\"\n elsif n <= 1\n return n\n elsif @scratchpad[n] != :notcalculated\n return @scratchpad[n]\n else\n @scratchpad[n] = fibo(n-1) + fibo(n-2)\n return @scratchpad[n]\n end\nend",
"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 fib_helper(last, second_to_last, current, n)\n return n if n == 0 || n == 1\n\n if current == n\n return last + second_to_last\n end\n\n sum = last + second_to_last\n last = second_to_last\n second_to_last = sum\n\n return fib_helper(last, second_to_last, current + 1, n)\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 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)\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 last_two_fib = [1, 1]\n\n (n - 2).times do\n last_two_fib = [last_two_fib[1], last_two_fib.sum]\n end\n last_two_fib.last\nend",
"def fibonacci(int)\n range_array = (1..int).to_a\n final_array = [1,1]\n range_array.each do |num|\n num > 2 ? final_array << final_array[num-3] + final_array[num-2] : nil\n end\n final_array[-1]\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 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 if n == 0 or n == 1\n return n\n else\n return 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 fib(number)\n sequence = [0,1]\n number.times {sequence << sequence[-1] + sequence[-2]}\n sequence[-1]\n return sequence\nend",
"def find_fibonacci_index_by_length_bk(digits_num)\n fib_position = 1\n first_fib = 1\n second_fib = 1\n decimal_position = decimal_base(digits_num)\n loop do\n break if first_fib >= decimal_position\n first_fib, second_fib = second_fib, first_fib + second_fib\n fib_position += 1\n end\n fib_position\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 fibo(num)\n \n print \"Fibonacci series is: \"\n\n if num == 0\n puts num\n return num\n end\n\n if num == 1\n puts \"0 1\"\n return num\n end\n\n i,j,cur = 0,1,1\n\n print \"0 1 \"\n while cur < num\n k = i\n i = j\n j = k + j\n print \"#{j} \"\n cur = cur + 1\n end\n\n return j\n\nend",
"def fib(integer)\n\nfib_arr = [0,1]\n#declaring the beginning portion of the fibanocci sequence\nindex = 2\n#starting at two because the array is already filled with the 0 & 1 index's filled \n\tuntil index == integer \n# the integer will be the fib(x) for the sequence\n\tnext_number = fib_arr[-1] + fib_arr[-2]\n#the next number in the sequence will equal the last number in the array, represented by -1, and the second to\n#last number represented by -2 added together.\n\tfib_arr << next_number\n#feeding the next_number into the array\n\tindex += 1\n#changing to the next index in the array\n\tend\n\tputs fib_arr\n#printing the new array\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 fibonacci(num)\n (1..num).inject( [0,1] ) { |fib| fib << fib.last(2).inject(:+) }\n\nend",
"def fib(n)\n return n if n < 2\n arr = [0, 1]\n (n-1).times { arr << arr.last(2).inject(:+) }\n arr.last\nend",
"def cool_fib(number)\n (0..number).inject([1,0]) {|i_arr| [i_arr.last, i_arr.first + i_arr.last]}.first\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 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 fibonacci(nth)\n result = []\n nth.times do \n result.size < 2 ? result << 1 : result << (result[-2] + result[-1])\n end\n result[-1] # result.last\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_given(nth)\n return 1 if nth <= 2\n fibonacci_given(nth - 1) + fibonacci_given(nth - 2)\nend",
"def fibonacci(num) \n\tfib = [0,1]\n (num - 2).times do \n \tfib << fib[-2] + fib[-1]\n end\n fib[-1]\nend",
"def fibonacci(limit)\n sequence = [0]\n if limit == 0\n puts \"Please enter a number above 0\"\n else\n pattern = 1\n (limit - 1).times do |index|\n sequence << pattern\n pattern = pattern + sequence[index]\n end\n puts \"The first #{limit.to_s} numbers in the Fibonacci Sequence are #{sequence}\"\n end\nend",
"def fibonacci(number)\n $counter += 1\n if number < 2\n number\n else\n fibonacci(number - 1) + fibonacci(number - 2)\n end\nend",
"def fib(n)\r\n if n == 1 then\r\n 10\r\n elsif n == 0 then\r\n 1\r\n else\r\n fib(n - 1) + fib(n - 2)\r\n end\r\nend",
"def fibonacci(n)\n raise ArgumentError.new if n.nil? || n < 0\n return n if n == 0\n\n array = [0, 1]\n i = 2\n while i <= n\n array[i] = array[i - 1] + array[i - 2]\n i += 1\n end\n\n return array.last\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(number)\n array = [0, 1]\n index = 2\n until index == number\n last_number = array[index - 1] + array[index - 2]\n array.push(last_number)\n index += 1\n end\n return array[-1]\nend",
"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 fibonacci(nth)\n return 1 if nth <= 2\n\n fibonacci(nth - 1) + fibonacci(nth - 2)\nend",
"def fibonacci(fib)\r\n \t#Set a variable to 0\r\n\tvalue1 = 0 \r\n\t#Set a variable to 1 (array must start with 0, 1...)\r\n\tvalue2 = 1\r\n\t\t#For the number of digits it will be, loop do this many times\r\n\t\tfib.times do \r\n\t\t\t#Create a temp to store value1\r\n \t\t\ttemp = value1\r\n \t\t\t#Make value1 equal value2\r\n \t\t\t#This will help when printing out 0,1,1.. in the beginning\r\n \t\t\tvalue1 = value2\r\n \t\t\t#Make value2 equal the sum of temp and value2\r\n \t\t\t#This will add the last numbers to get the next number\r\n \t\t\tvalue2 = temp + value2\r\n \t\t#End do loop\r\n\t\tend\r\n\t#Return the first value\r\n \tvalue1\r\n#End of method\r\nend",
"def fib(n)\n return [0, 1, 1][0...n] if n <= 3\n last = fib(n-1)\n last << last[-1] + last[-2]\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 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 fib(n)\n #if n > 4000000\n #\treturn puts n\n #end\n return n if (0..1).include? n\n fib(n-1) + fib(n-2) if n > 1\nend",
"def find_fibonacci_index_by_length(digits)\n fibonacci_sequence = []\n fibonacci_sequence << 0\n\n previous_number = fibonacci_sequence.last\n current_number = 1\n\n loop do\n current_number += previous_number\n previous_number = fibonacci_sequence.last\n fibonacci_sequence << current_number\n break if current_number.to_s.size >= digits\n end\n\n fibonacci_sequence.size - 1\nend",
"def fib_basic(n)\n if (0..1).include? n\n return n\n else\n (fib_basic(n - 1) + fib_basic(n - 2))\n end\nend",
"def largest_fib\n\n fib = [1,1]\n x = 0\n\n\n\nwhile fib[-1].to_s.length != 1000\n fib << (fib[x] + fib[x + 1])\n x += 1\n\nend\n\n\nfib.each_with_index { |x, index| puts \"#{x.to_s.length} and index:#{index}\"}\n\nend",
"def fibonacci(current_num)\n return current_num if current_num < 2\n fibonacci(current_num -1) + fibonacci(current_num -2)\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 fibonnaci(index)\n if index <= 1\n return index\n else\n fibonnaci(index - 1) + fibonnaci(index - 2)\n end\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( n )\r\n fib_nums = []\r\n return n if n <= 1\r\n fib_nums << fibonacci( n - 1 )\r\n fib_nums << fibonacci( n - 2 )\r\n p \"#{fib_nums}\"\r\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 fibo(n)\n if n <= 1\n n\n else\n @scratchpad[n] ||= fibo(n-1) + fibo(n-2)\n end\nend"
] |
[
"0.8083491",
"0.79659504",
"0.79616785",
"0.7922941",
"0.79221547",
"0.78886247",
"0.78805083",
"0.78015107",
"0.77934843",
"0.7722195",
"0.7653347",
"0.7633005",
"0.7582422",
"0.75569475",
"0.7520394",
"0.75141144",
"0.7446444",
"0.7393725",
"0.7379388",
"0.7365814",
"0.7344807",
"0.7344807",
"0.7344807",
"0.7344807",
"0.7330307",
"0.7310701",
"0.7282193",
"0.7258341",
"0.7256827",
"0.71650827",
"0.715359",
"0.71478766",
"0.7146417",
"0.7124515",
"0.7111068",
"0.7107218",
"0.71014005",
"0.71008295",
"0.7083799",
"0.7067264",
"0.7048019",
"0.7034251",
"0.7032894",
"0.7028168",
"0.7027229",
"0.7025101",
"0.7022191",
"0.7019298",
"0.7012438",
"0.7000796",
"0.7000314",
"0.6992032",
"0.6991189",
"0.69885266",
"0.6977607",
"0.6974173",
"0.69676554",
"0.6965546",
"0.69594866",
"0.6949876",
"0.6949748",
"0.6949692",
"0.6949177",
"0.6947624",
"0.6944354",
"0.6935133",
"0.6935133",
"0.6935133",
"0.6935133",
"0.6923883",
"0.6921965",
"0.6917254",
"0.6916089",
"0.69102836",
"0.69087946",
"0.69082785",
"0.6906885",
"0.69007164",
"0.6899686",
"0.6899686",
"0.6899686",
"0.6899686",
"0.68949306",
"0.6894826",
"0.6894082",
"0.6888931",
"0.68799466",
"0.6867068",
"0.6866432",
"0.68634534",
"0.6861355",
"0.6856857",
"0.6846263",
"0.6845756",
"0.6843567",
"0.68430877",
"0.68414205",
"0.68388236",
"0.68380934",
"0.6835421"
] |
0.75360006
|
14
|
The perform method is in charge of our code execution when enqueued.
|
def perform(registration)
RegisterMail.register_success_mail(registration).deliver
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def perform\n raise NotImplementedError, 'Implement this in a subclass'\n end",
"def perform\n \n end",
"def perform; end",
"def perform; end",
"def _run\n super.tap { reenqueue }\n end",
"def perform(&block); end",
"def execute\n adapter.enqueue klass, *args\n end",
"def perform\n # Do some work\n end",
"def perform\n raise \"Missing implementation for #{self.class.name}#perform\"\n end",
"def perform\n raise NotImplementedError\n end",
"def perform\n raise NotImplementedError\n end",
"def perform\n fail 'unimplemented perform'\n end",
"def perform\n @worker.call\n @last_result\n end",
"def perform_task\n # actually do the work\n end",
"def perform\n raise NotImplementedError\n end",
"def dispatch\n @queue.pop.run while @queue.ready?\n end",
"def queue_job; end",
"def execute\n self.started\n self.execute_internal\n self.finished\n end",
"def perform\n raise RuntimeError, \"Worker Implementations should override this\"\n end",
"def perform(*args)\n # Do something\n puts \"perform successfully\"\n end",
"def call\n run_callbacks :call do\n enqueue\n end\n end",
"def execute\n begin\n JobDispatch.logger.info \"Worker executing job #{job_id}: #{target}.#{method}\"\n Thread.current[\"JobDispatch::Worker.job_id\"] = job_id\n @klass = target.constantize\n @result = @klass.__send__(method.to_sym, *params)\n @status = :success\n rescue StandardError => ex\n\n notify_error(ex) rescue nil\n\n @result = {\n class: ex.class.to_s,\n message: ex.to_s,\n backtrace: ex.backtrace,\n }\n @status = :error\n JobDispatch.logger.debug ex\n ensure\n Thread.current[\"JobDispatch::Worker.job_id\"] = nil\n JobDispatch.logger.info \"Worker completed job #{job_id}: #{target}.#{method}, status: #{@status}\"\n end\n end",
"def perform(*args)\n\tend",
"def perform\n super\n end",
"def perform\n super\n end",
"def perform\n super\n end",
"def perform\n super\n end",
"def perform_work\n raise NotImplementedError\n end",
"def perform(*args)\n puts \"--------------------------\"\n puts \"---- Running Job ----\"\n puts \"--------------------------\"\n end",
"def execute!\n @context.backend.schedule { run }\n end",
"def perform\n super\n end",
"def perform\n super\n end",
"def perform\n super\n end",
"def perform\n super\n end",
"def perform\n super\n end",
"def perform\n super\n end",
"def _perform(args); end",
"def enqueue(*args); end",
"def perform_with_tracking(*args)\n self.class.record_event(:dequeue)\n Rails.logger.debug \"Sidekiq perform: #{self} #{args} at #{Time.now}\"\n\n success = yield\n self.class.record_event(success ? :success : :failure)\n rescue\n self.class.record_event(:failure)\n raise\n end",
"def perform(*args); end",
"def perform(json)\n # instance method level support for sidekiq\n self.class.perform(json)\n end",
"def perform!\n end",
"def perform(record)\n run(record, false)\n end",
"def enqueue\n Karafka.logger.info(\"Enqueuing #{self.class} - #{params}\")\n Karafka::Worker.perform_async(params)\n end",
"def queue; end",
"def queue; end",
"def process(payload)\n @working = true\n begin\n @queues.outgoing.push(discover_artifact_from(payload))\n rescue => ex\n STDERR.puts \"[Error] Exception in thread: #{ex.full_message}\"\n @queues.outgoing.push(ex)\n ensure\n @working = false\n end\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 method_missing(method, *args)\n # This is the Resque queue to which this job will be sent\n queue = @options[:to] || :default\n # Encode our Performable Method into something that can be stored in Resque\n payload = PerformableMethod.prepare(@target, method, args)\n\n if @options[:run_at]\n ::Resque.enqueue_at_with_queue(queue, @options[:run_at], PerformableMethod, payload)\n else\n ::Resque.enqueue_to(queue, PerformableMethod, payload)\n end\n end",
"def perform\n # Sidekiq would not be able to get an instance as an argument\n\n\n # Do something later\n puts \"Starting to do something which takes time...\"\n sleep(5)\n puts \"Finished my time-consuming process!\"\n end",
"def enqueue!\n return nil unless persisted?\n \"#{job_type.camelize}Job\".constantize.perform_later(self)\n end",
"def enqueue(data); end",
"def call\n executor.consume\n end",
"def do_work\n end",
"def executor; end",
"def executor; end",
"def executor; end",
"def perform_inline\n Karafka.monitor.notice(self.class, to_h)\n perform\n end",
"def execute!\n event.persist_and_dispatch\n end",
"def queue(_); end",
"def queue(_); end",
"def run_all\n perform\n end",
"def run_all\n perform\n end",
"def perform!\n super\n transfer!\n cycle!\n end",
"def perform!\n transfer!\n cycle!\n end",
"def perform!\n transfer!\n cycle!\n end",
"def perform #param1, param2, ...\n # some heavy job here\n end",
"def perform\n\n begin\n\n # acquire lock and fetch the locked hooks\n fetch_hooks_to_be_processed\n\n # Process these Hooks\n process_hooks\n\n # Mark Hooks as processed\n update_status_to_processed\n\n rescue StandardError => se\n\n @hooks_to_be_processed.each do |hook|\n hook_id = hook.id\n # Skip if we already know that his hook was processed or failed\n next if @success_responses[hook_id].present? ||\n @failed_hook_to_be_ignored[hook_id].present? ||\n @failed_hook_to_be_retried[hook_id].present?\n @failed_hook_to_be_retried[hook_id] = {\n exception: {message: se.message, trace: se.backtrace}\n }\n end\n\n ensure\n\n # For hooks which failed, mark them as failed\n release_lock_and_update_status_for_non_processed_hooks\n\n # Notify Devs in case on Errors\n notify_devs\n\n success_with_data(processor_response)\n\n end\n\n end",
"def perform(*args)\n puts \"--------------------\"\n puts \"Running a super awesome job\"\n puts \"--------------------\"\n puts \"this one right here.\"\n end",
"def perform\n begin\n # prepare the job\n prepare\n # check that everything is kosher\n check\n # run the job\n run\n # perform any post processing`\n clean_up\n rescue Exception => e\n PutMetricDataService.new.put_metric('DelayedJobErrorResponse', 'Count', 1)\n\n Rails.logger.warn e.message\n Rails.logger.warn e.backtrace\n Delayed::Worker.logger.warn e.message rescue nil # log to worker logger if available\n Delayed::Worker.logger.warn e.backtrace rescue nil # log to worker logger if available\n end\n end",
"def run\n raise \"run() Not Implemented on worker #{self.class.name}\"\n end",
"def invoke_job\n payload_object.perform\n end",
"def enqueue(payload)\n end",
"def dispatch(payload)\n queue.push(payload)\n end",
"def invoke_job\n payload_object.perform\n end",
"def perform(&run_interp)\n @queries.each {|q| q.perform(&run_interp)}\n end",
"def before_perform\n end",
"def enqueue(record)\n @queue << record.representation\n end",
"def enqueue_pending_output; end",
"def perform_later(*args, **options)\n __debug_job(__method__) { \"options = #{item_inspect(options)}\" } # TODO: remove\n job_warn { \"ignoring method args #{args.inspect}\" } if args.present?\n enqueue(options)\n end",
"def perform(*args)\n if Service.get_service.jobs_enabled?\n # Job processing is enabled.\n Delayed::Worker.logger.info \"---> running #{self.class}(#{args.join(',')}) on #{self.queue_name} at priority #{Process::getpriority(Process::PRIO_PROCESS, 0)}\"\n start_time = Time.current\n perform_if_enabled(*args)\n Delayed::Worker.logger.info \"<--- finished #{self.class} after #{time_ago_in_words(start_time)}\"\n else\n # Resubmit the job with the required parameters after the specified delay. If the inline adapter is being used, we just ignore this.\n Delayed::Worker.logger.warn \"**** job processing disabled for #{self.class}\"\n begin\n self.class.set(wait: DISABLED_RETRY_INTERVAL).perform_later(*args)\n rescue NotImplementedError => _e\n Delayed::Worker.logger.error \"**** no job queue available for future job #{self.class}\"\n end\n end\n end",
"def deliver\n @queue << self\n end",
"def apply_async!(queue: 'eventually')\n super\n end",
"def perform\n publish_scheduled\n end",
"def enqueue_to(queue, klass, *args); end",
"def enqueue!\n QueryWorker.perform_async(query.id)\n end",
"def perform_later(*args, &block)\n later(:perform, *args, &block)\n end",
"def perform\n puts \"Pretending I'm doing something which takes time...\"\n # Do something later\n sleep(10)\n puts \"Finished my important task!\"\n end",
"def enqueue( * )\n\t\t# No-op\n\tend",
"def run() end",
"def run_payload(payload)\n if queue?\n log.info(\"Enqueuing #{payload}\")\n ETL.queue.enqueue(payload)\n else\n log.info(\"Running #{payload}\")\n result = ETL::Job::Exec.new(payload).run\n if result.success?\n log.info(\"SUCCESS: #{result.message}\")\n else\n log.error(result.message)\n end\n end\n end",
"def perform(handle, implementation)\n Bramble::State.running?(handle) do\n # Set how many reduce call we expect\n all_raw_keys = storage.map_keys_get(keys_key(handle))\n storage.set(reduce_total_count_key(handle), all_raw_keys.length)\n # Enqueue a job for each reduce call\n all_raw_keys.each do |raw_key|\n Bramble::ReduceJob.perform_later(handle, implementation.name, raw_key)\n end\n end\n end",
"def perform(druid)\n @druid = druid\n Honeybadger.context(druid: druid, process: process, workflow_name: workflow_name)\n\n logger.info \"#{druid} processing #{process} (#{workflow_name})\"\n return unless check_item_queued?\n\n # this is the default note to pass back to workflow service,\n # but it can be overriden by a robot that uses the Robots::ReturnState\n # object to return a status\n note = Socket.gethostname\n\n # update the workflow status to indicate that started\n workflow.start!(note)\n\n result = nil\n elapsed = Benchmark.realtime do\n result = perform_work\n end\n\n # the final workflow state is determined by the return value of the perform step, if it is a ReturnState object,\n # we will use the defined status, otherwise default to completed\n # if a note is passed back, we will also use that instead of the default\n if result.instance_of?(ReturnState)\n workflow_state = result.status\n note = result.note unless result.note.blank?\n else\n workflow_state = 'completed'\n end\n # update the workflow status from its current state to the state returned by perform\n # (or 'completed' as the default)\n # noop allows a robot to not set a workflow as complete, e.g., if that is delegated to another service.\n workflow.complete!(workflow_state, elapsed, note) unless workflow_state == 'noop'\n\n logger.info \"Finished #{druid} in #{format('%0.4f', elapsed)}s\"\n rescue StandardError => e\n handle_error(e)\n end",
"def perform_async\n Karafka.monitor.notice(self.class, to_h)\n # We use @params directly (instead of #params) because of lazy loading logic that is behind\n # it. See Karafka::Params::Params class for more details about that\n worker.perform_async(\n topic,\n interchanger.load(@params)\n )\n end",
"def work_queue(queue)\n if job = Riaque.reserve(queue)\n if klass = self.qualified_const_get(job.klass)\n klass.send(:perform, *job.payload)\n end\n\n job.dequeue\n end\n end",
"def perform\n start_instance\n begin; run; rescue; @failed = true; end\n finish_instance\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 perform_async\n Karafka.monitor.notice(\n self.class,\n params: @params,\n worker: self.class.worker,\n interchanger: self.class.interchanger\n )\n\n # We use @params directly (instead of #params) because of lazy loading logic that is behind\n # it. See Karafka::Params::Params class for more details about that\n self.class.worker.perform_async(\n self.class,\n self.class.interchanger.load(@params)\n )\n end",
"def process_queue\n begin\n while blk = Merb::Dispatcher.work_queue.pop\n # we've been blocking on the queue waiting for an item sleeping.\n # when someone pushes an item it wakes up this thread so we \n # immediately pass execution to the scheduler so we don't \n # accidentally run this block before the action finishes \n # it's own processing\n Thread.pass\n blk.call\n end\n rescue Exception => e\n Merb.logger.warn! %Q!Worker Thread Crashed with Exception:\\n#{Merb.exception(e)}\\nRestarting Worker Thread!\n retry\n end\n end",
"def run\n super\n\n config = _get_task_config \"control/collection_processor\"\n\n @sqs = Aws::SQS::Client.new({\n region: 'us-east-1',\n access_key_id: config[\"aws_access_key\"],\n secret_access_key: config[\"aws_secret_access_key\"]\n })\n\n @control_queue_uri = config[\"control_queue_uri\"]\n @status_queue_uri = config[\"status_queue_uri\"]\n sleep_interval = config[\"sleep\"] || 10\n max_seconds = config[\"max_seconds\"] || 36000\n\n handler = config[\"handler\"]\n\n # connect to the configured amazon queue & Grab one\n _set_status :available, nil\n instruction_data = nil\n iteration = 0\n while true\n\n # loop until we have something\n while !instruction_data\n\n _log \"Attempting to get an instruction from the queue!\"\n instruction_data = _get_queued_instruction # try again\n\n # kick it off if we got one, and break out of this loop\n if instruction_data\n _log \"[+] Executing #{instruction_data[\"id\"]} for #{sleep_interval} seconds! (expire in: ~#{max_seconds - (iteration * sleep_interval) }s)\"\n _set_status :start, \"#{instruction_data[\"id\"]}\"\n _execute_instruction(instruction_data)\n else\n _log \"Nothing to do, waiting!\"\n sleep sleep_interval\n end\n\n end\n\n # hold tight\n sleep sleep_interval\n\n # determine how we're doing\n task_count_left = _tasks_left\n seconds_elapsed = iteration * sleep_interval\n done = (iteration > 10 && task_count_left == 0 ) || (seconds_elapsed > max_seconds)\n\n _log \"Seconds elapsed: #{seconds_elapsed}\" if iteration % 10 == 0\n _log \"Tasks left: #{task_count_left}\" if iteration % 10 == 0\n\n if done\n _log_good \"Done with #{instruction_data[\"id\"]} after #{seconds_elapsed}s\"\n _set_status :end, {\n \"id\" => \"#{instruction_data[\"id\"]}\",\n \"elapsed\" => \"#{seconds_elapsed}\",\n \"entities\" => \"#{Intrigue::Model::Project.first(:name => instruction_data[\"id\"]).entities.count}\"\n }\n\n _log_good \"#{instruction_data[\"id\"]}\"\n _run_handlers instruction_data\n _set_status :sent, \"#{instruction_data[\"id\"]}\"\n\n instruction_data = nil\n iteration = -1\n\n end\n\n iteration +=1\n end\n\n end",
"def perform()\n 2 + 2\n end"
] |
[
"0.71829754",
"0.7173839",
"0.7080186",
"0.7080186",
"0.70769703",
"0.7040585",
"0.70270985",
"0.69795537",
"0.6891379",
"0.6850613",
"0.68463117",
"0.68291926",
"0.6788192",
"0.6747695",
"0.6741019",
"0.6697734",
"0.6690095",
"0.6655567",
"0.6651279",
"0.6634857",
"0.6597891",
"0.65619886",
"0.65214443",
"0.6510516",
"0.6510516",
"0.6510516",
"0.6510516",
"0.65052414",
"0.64680874",
"0.645363",
"0.6439827",
"0.6439827",
"0.6439827",
"0.6439827",
"0.6439827",
"0.6439827",
"0.6419359",
"0.63931644",
"0.6381977",
"0.63669014",
"0.6356738",
"0.63446695",
"0.6331951",
"0.633075",
"0.62780225",
"0.62780225",
"0.6263322",
"0.62495935",
"0.6234308",
"0.62287724",
"0.6221477",
"0.6217835",
"0.620043",
"0.61796546",
"0.6171012",
"0.6171012",
"0.6171012",
"0.61652637",
"0.6163485",
"0.6148541",
"0.6148541",
"0.61467326",
"0.61467326",
"0.6136168",
"0.61244625",
"0.61244625",
"0.6123892",
"0.6116585",
"0.6108272",
"0.6106147",
"0.61060315",
"0.61007255",
"0.6086381",
"0.6083282",
"0.607373",
"0.6062813",
"0.6044987",
"0.6033938",
"0.60297316",
"0.6023299",
"0.60068315",
"0.60022163",
"0.59966195",
"0.598484",
"0.5983477",
"0.5978188",
"0.5972953",
"0.5972821",
"0.5968692",
"0.59662646",
"0.5953527",
"0.594187",
"0.5940868",
"0.5932699",
"0.5925494",
"0.59146017",
"0.5912273",
"0.59099305",
"0.5907589",
"0.58946097",
"0.58734876"
] |
0.0
|
-1
|
GET /resource_types GET /resource_types.json
|
def index
respond_to do |format|
format.html # index.html.erb
format.json { render json: @resource_types }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def find_resources(type)\n resource_collection.all_resources.select do |resource|\n resource_name(resource) == type.to_sym\n end\n end",
"def lookup(type)\n @resource_types[type] || []\n end",
"def resource_type_filter\n return filter_for(:resource_type_id, \n objects_to_names_and_ids(current_user.company.resource_types),\n session[:resource_filters], _(\"Resource Type\"))\n end",
"def index\n @resources = Resource.eager_load(:resource_type).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def get_resource_type_identifiers\n get_kind_type_identifiers_related_to Occi::Core::Resource.kind.type_identifier\n end",
"def all_of_type\n Resource::AllOfType.new(type)\n end",
"def resource_type_filter\n return filter_for(:resource_type_id,\n objects_to_names_and_ids(current_user.company.resource_types),\n session[:resource_filters], ResourceType.model_name.human)\n end",
"def api_get_resources(url, page, resource_type, o = {})\n json = api_get_json(url, page, o)\n json.is_a?(Hash) ? resource_type.new(json) : json.map { |r| resource_type.new(r) }\n end",
"def list_resource_types(feed_id = nil)\n if feed_id.nil?\n ret = http_get('/resourceTypes')\n else\n the_feed = hawk_escape_id feed_id\n ret = http_get(\"/feeds/#{the_feed}/resourceTypes\")\n end\n ret.map { |rt| ResourceType.new(rt) }\n end",
"def type\n Resource::ALL\n end",
"def show\n @resource_fields = Field.where(\"resource_type_id = ?\", params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource_type }\n end\n end",
"def new\n @resource = Resource.new\n @resource_types=ResourceType.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def show\n @resource_type = @resource.resource_type\n @values = ResourceValue.where(\"resource_id = ?\", params[:id])\n @field_types = []\n @values.each do |value|\n if value.field.resource_type_reference_id\n @field_types << Resource.find(value.resource_reference_id).resource_type\n else\n @field_types << value.field.field_type\n end\n end \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end",
"def get_resource_type()\n return RedXmlResource::TYPE\n end",
"def resource_type\n /(\\/api\\/(?<type>\\w+)\\/?)/ =~ full_url\n type.capitalize\n end",
"def list(resource_type_identifier=nil)\n if resource_type_identifier\n # convert type to type identifier\n resource_type_identifier = @model.kinds.select {\n |kind| kind.term == resource_type_identifier\n }.first.type_identifier if @model.kinds.select {\n |kind| kind.term == resource_type_identifier\n }.any?\n\n # check some basic pre-conditions\n raise \"Endpoint is not connected!\" unless @connected\n raise \"Unkown resource type identifier! [#{resource_type_identifier}]\" unless @model.get_by_id resource_type_identifier\n\n # split the type identifier and get the most important part\n uri_part = resource_type_identifier.split('#').last\n\n # request uri-list from the server\n path = uri_part + '/'\n else\n path = '/'\n end\n\n headers = self.class.headers.clone\n headers['Accept'] = 'text/uri-list'\n\n # TODO: remove the gsub OCCI-OS hack\n response = self.class.get(\n @endpoint + path,\n :headers => headers\n ).body.gsub(/\\# uri:\\/(compute|storage|network)\\/[\\n]?/, '').split(\"\\n\").compact\n end",
"def getResourceType() \n @obj.getResourceType() \n end",
"def name(_prefix = false)\n 'Resource Types'\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def show\n @resource = Resource.find(params[:id])\n @resource_type = ResourceType.find(@resource.resource_type_id)\n @values = ResourceValue.where(resource_id: params[:id])\n @field_types=[]\n @values.each do |value|\n @field_types << value.Field\n end\n \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end",
"def map_resource_type(resource_types, node)\n if resource_types.empty?\n if node.is_a?(IFile)\n return {\n 'string' => 'File',\n 'icon' => 'file'\n }\n else\n return {\n 'string' => 'Unknown',\n 'icon' => 'cog'\n }\n end\n end\n\n types = {\n '{http://calendarserver.org/ns/}calendar-proxy-write' => {\n 'string' => 'Proxy-Write',\n 'icon' => 'people'\n },\n '{http://calendarserver.org/ns/}calendar-proxy-read' => {\n 'string' => 'Proxy-Read',\n 'icon' => 'people'\n },\n '{urn:ietf:params:xml:ns:caldav}schedule-outbox' => {\n 'string' => 'Outbox',\n 'icon' => 'inbox'\n },\n '{urn:ietf:params:xml:ns:caldav}schedule-inbox' => {\n 'string' => 'Inbox',\n 'icon' => 'inbox'\n },\n '{urn:ietf:params:xml:ns:caldav}calendar' => {\n 'string' => 'Calendar',\n 'icon' => 'calendar'\n },\n '{http://calendarserver.org/ns/}shared-owner' => {\n 'string' => 'Shared',\n 'icon' => 'calendar'\n },\n '{http://calendarserver.org/ns/}subscribed' => {\n 'string' => 'Subscription',\n 'icon' => 'calendar'\n },\n '{urn:ietf:params:xml:ns:carddav}directory' => {\n 'string' => 'Directory',\n 'icon' => 'globe'\n },\n '{urn:ietf:params:xml:ns:carddav}addressbook' => {\n 'string' => 'Address book',\n 'icon' => 'book'\n },\n '{DAV:}principal' => {\n 'string' => 'Principal',\n 'icon' => 'person'\n },\n '{DAV:}collection' => {\n 'string' => 'Collection',\n 'icon' => 'folder'\n }\n }\n\n info = {\n 'string' => [],\n 'icon' => 'cog'\n }\n\n resource_types.each do |resource_type|\n if types.key?(resource_type)\n info['string'] << types[resource_type]['string']\n else\n info['string'] << resource_type\n end\n end\n\n types.each do |key, resource_info|\n if resource_types.include?(key)\n info['icon'] = resource_info['icon']\n break\n end\n end\n\n info['string'] = info['string'].join(', ')\n\n info\n end",
"def list(resource_type,limit=0,params={})\n path = '/api/' + resource_type.to_s\n params.merge!({limit: limit.to_s})\n response = http_get(path,params)\n hydrate_list(resource_type, response['objects'])\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def itemtype\n types = resource_type || []\n ResourceTypesService.microdata_type(types.first)\n end",
"def resource_type\n case\n when controller_name.starts_with?('search')\n params[:record_type]\n when is_variable_controller?\n 'variables'\n when is_services_controller?\n 'services'\n when is_tools_controller?\n 'tools'\n else\n # default\n 'collections'\n end\n end",
"def get_resource_type_identifier(type)\n get_type_identifier(type, Occi::Core::Resource.kind)\n end",
"def types\n @title = 'Resource Type Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_type)\n erb(:objects)\nend",
"def type\n if entity.respond_to?(:resource_type)\n entity.resource_type\n else\n entity.class\n end.to_s\n end",
"def get_lesson_types\n get \"lessonTypes.json\"\n end",
"def resource_type_for_node(node)\n result = []\n @resource_type_mapping.each do |class_name, resource_type|\n result << resource_type if node.is_a?(class_name)\n end\n\n result\n end",
"def resource_names\n JSON.parse(@body).fetch('Resources', {}).keys\n end",
"def resources_by_type(ast)\n result = Hash.new{|hash, key| hash[key] = Array.new}\n find_resources(ast).each{|resource| result[resource_type(resource)] << resource}\n result\n end",
"def resources_by_type(ast)\n result = Hash.new{|hash, key| hash[key] = Array.new}\n find_resources(ast).each{|resource| result[resource_type(resource)] << resource}\n result\n end",
"def types\n @client.make_request :get, reports_path\n end",
"def index\n @resources = resource_class.send(:all)\n render json: @resources\n end",
"def new\n @resource_type = ResourceType.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource_type }\n end\n end",
"def type(type = nil)\n @type = type if type\n @type || name.split('::').last.gsub(/Resource$/, '').underscore\n end",
"def resource_type_params\n params.require(:resource_type).permit(:id, :resource_type_general, :resource_type, :resource_id)\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end",
"def get_resource_type(type, resource_path)\n changed_path = resource_path.split('/').last\n if type.eql?('singular')\n changed_path.singularize.to_sym\n else\n changed_path.to_sym\n end\n end",
"def resource_type\n \"b\"\n end",
"def set_resourcetype\n @resourcetype = Resourcetype.find(params[:id])\n end",
"def resource_type\n if collection?\n Nokogiri::XML::fragment('<D:collection xmlns:D=\"DAV:\"/>').children.first\n end\n end",
"def set_resource_type\n @resource_type = ResourceType.find(resource_type_params[:id])\n end",
"def resource_type\n document_type\n end",
"def resource_type\n document_type\n end",
"def type\n query_root_node(\"rdf:type/@rdf:resource\", @@NAMESPACES).to_s\n end",
"def get_resource(resource_type)\n\n Occi::Log.debug(\"Instantiating #{resource_type} ...\")\n\n if @model.get_by_id resource_type\n # we got a resource type identifier\n Occi::Core::Resource.new resource_type\n elsif @model.kinds.select { |kind| kind.term == resource_type }.any?\n # we got a resource type name\n Occi::Core::Resource.new @model.kinds.select {\n |kind| kind.term == resource_type\n }.first.type_identifier\n else\n raise \"Unknown resource type! [#{resource_type}]\"\n end\n\n end",
"def resource_type_params\n params.require(:resource_type).permit(:name)\n end",
"def get_fhir_resources(fhir_client, type, resource_id, patient_id=nil)\n if patient_id == nil\n search = { parameters: { _id: resource_id} } \n else\n search = { parameters: { _id: resource_id, patient: patient_id} }\n end\n results = fhir_client.search(type, search: search )\n binding.pry if results == nil || results.resource == nil || results.resource.entry == nil \n results.resource.entry.map(&:resource)\n end",
"def describe(resource_type_identifier=nil)\n\n # convert type to type identifier\n resource_type_identifier = @model.kinds.select {\n |kind| kind.term == resource_type_identifier\n }.first.type_identifier if @model.kinds.select {\n |kind| kind.term == resource_type_identifier\n }.any?\n\n # check some basic pre-conditions\n raise \"Endpoint is not connected!\" unless @connected\n\n descriptions = []\n\n if resource_type_identifier.nil?\n descriptions << get('/')\n elsif @model.get_by_id resource_type_identifier\n # we got type identifier\n # get all available resources of this type\n locations = list resource_type_identifier\n\n # make the requests\n locations.each do |location|\n descriptions << get(sanitize_resource_link(location))\n end\n elsif resource_type_identifier.start_with?(@endpoint) || resource_type_identifier.start_with?('/')\n # we got resource link\n # make the request\n descriptions << get(sanitize_resource_link(resource_type_identifier))\n else\n raise \"Unkown resource type identifier! [#{resource_type_identifier}]\"\n end\n\n descriptions\n end",
"def resources\n typed_set(entities, Occi::Core::Resource)\n end",
"def resource_type\n :collection if collection?\n end",
"def resource_type\n :collection if collection?\n end",
"def describe_types\n [@options[:type]].flatten.join('/')\n end",
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end",
"def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{params[:term]}%\"])\n else\n @type = Type.find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @types }\n end\n end",
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
"def test_ListPlatformTypes\n\t\tcolName = 'types'\n\t\tretClass = LeanTesting::PlatformType\n\t\tresp = rcol(colName, ['_id', 'name'])\n\t\t@client.debugReturn = {'data'=> JSON.generate(resp), 'status'=> 200}\n\n\t\tcol = @client.platform.types.all\n\n\t\tassert_equal resp[colName], col.toArray\n\t\tassert_instance_of retClass, col.collection[0]\n\t\tassert_equal resp['meta']['pagination']['total'], col.total\n\t\tassert_equal resp['meta']['pagination']['total_pages'], col.totalPages\n\t\tassert_equal resp['meta']['pagination']['count'], col.count\n\tend",
"def get_linked_resources(resource_type, filters = {})\n Util.convert_to_clever_object Clever.request(:get, get_uri(resource_type), filters)[:data]\n end",
"def resourceType\n 'DomainResource'\n end",
"def type_as_class(resource_name)\n\t resource_name.singularize.capitalize.constantize\n\tend",
"def resource\n return Object unless resource_type\n return resource_type.constantize unless resource_id\n return _resource\n end",
"def resource_type\n\t\t\t\t\t\traise \"Not implemented.\"\n\t\t\t\t\tend",
"def get_fhir_resources(fhir_client, type, resource_id, patient_id=nil)\n if patient_id == nil\n search = { parameters: { _id: resource_id} } \n else\n search = { parameters: { _id: resource_id, patient: patient_id} }\n end\n results = fhir_client.search(type, search: search )\n # binding.pry if results == nil || results.resource == nil || results.resource.entry == nil \n results.resource.entry.map(&:resource)\n end",
"def resources\n @resources ||= @response[@resource_field].to_a\n end",
"def resources_by_type(ast)\n raise_unless_xpath!(ast)\n result = Hash.new{|hash, key| hash[key] = Array.new}\n find_resources(ast).each do |resource|\n result[resource_type(resource)] << resource\n end\n result\n end",
"def get_resource_class\n \tresource_name.classify.constantize\n end",
"def types\n @types ||= Types.new(@client)\n end",
"def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end",
"def resource_associations(association_type)\n resource_class.reflect_on_all_associations(association_type).map(&:name)\n end",
"def lookup_resource(type, name, run_context)\n begin\n run_context.resource_collection.find(\"#{ type }[#{ name }]\")\n rescue ArgumentError => e\n puts \"You provided invalid arugments to resource_collection.find: #{ e }\"\n rescue RuntimeError => e\n puts \"The resources you searched for were not found: #{ e }\"\n end\n end",
"def type(resource_type)\n Cocina::Models::FileSetType.properties[resource_type.to_sym]\n end",
"def resources(type, path)\n Resources.new(self, path, type)\n end",
"def index \n respond_to do |format|\n format.html # index.html.erb\n format.json { \n asset_types = AssetType.all\n render json: asset_types \n }\n end\n end",
"def appointment_types(params = {})\n scope 'default'\n get('schedule/appointmenttypes/', params)\n end",
"def get_resource(id, type)\n\t\t@client.method(type).call.get(id)\n\tend",
"def index\n authorize :resquest_type, :index?\n @resquest_types = ResquestType.all\n end",
"def dor_resource_content_type\n public_xml_doc.xpath('//contentMetadata/resource/@type').map(&:text)\n end",
"def resource_type\n return 'Data'\n end",
"def to_resource_declaration(type)\n if type.respond_to?(:type_name) && type.respond_to?(:title)\n title = type.title\n type_name = type.type_name\n elsif type_result = /(\\w+)\\['?(\\w+)'?\\]/.match(type.to_s)\n # not all types have a type_name and title so we\n # output to a string and parse the results\n title = type_result[2]\n type_name = type_result[1]\n else\n return type\n end\n res = scope.catalog.resource(type_name, title)\n return res.to_ral if res\n # don't return anything or returns nil if item is not in the catalog\n end",
"def show\n status_not_acceptable && return unless accept_header?\n\n resource_type = params.permit(:resource_type)[:resource_type]&.downcase\n case resource_type\n when 'patient'\n resource = get_patient(params.permit(:id)[:id])\n when 'observation'\n resource = get_laboratory(params.permit(:id)[:id])\n when 'questionnaireresponse'\n resource = get_assessment(params.permit(:id)[:id])\n else\n status_bad_request && return\n end\n\n status_forbidden && return if resource.nil?\n\n status_ok(resource.as_fhir) && return\n rescue StandardError\n render json: operation_outcome_fatal.to_json, status: :internal_server_error\n end",
"def get_entity_types\n Occi::Log.debug(\"Getting entity types ...\")\n @model.kinds.collect { |kind| kind.term }\n end",
"def child_types(*args)\n Relationship.resource_types(child_rels(*args))\n end",
"def types\n if @@types.nil? || (@@last_type_check + (4 * 60 * 60)) < Time.now\n @@last_type_check = Time.now\n @@types = _make_request(:types)['results']\n end\n @@types\n end",
"def resource_class\n resource_specification.klass\n end",
"def type_url\n query_root_node(\"rdf:type/@rdf:resource\", @@NAMESPACES).to_s\n end",
"def show\n @api_v1_user_types = Api::V1::UserType.all\n end",
"def registered_types\n end",
"def resource_model\n Object.const_get options[:resource].classify\n end"
] |
[
"0.8383496",
"0.8339535",
"0.7316782",
"0.7301671",
"0.7277845",
"0.7234124",
"0.71839243",
"0.7138549",
"0.6978057",
"0.6942139",
"0.68985695",
"0.6896717",
"0.68536764",
"0.6807834",
"0.6777348",
"0.671819",
"0.67053664",
"0.6697003",
"0.6667048",
"0.66580653",
"0.6639848",
"0.6621806",
"0.6615639",
"0.6615639",
"0.6615639",
"0.6615639",
"0.65967184",
"0.6582896",
"0.6579921",
"0.65066874",
"0.65066874",
"0.65066874",
"0.65066874",
"0.6500904",
"0.64049137",
"0.6339153",
"0.6336487",
"0.63126254",
"0.62459266",
"0.6232804",
"0.62298816",
"0.6226528",
"0.6226528",
"0.6223183",
"0.620545",
"0.6202244",
"0.61803436",
"0.6170936",
"0.6161821",
"0.6160611",
"0.61600584",
"0.61599946",
"0.6159271",
"0.61527807",
"0.61352754",
"0.61352754",
"0.6117487",
"0.6107212",
"0.60998034",
"0.607687",
"0.60723776",
"0.60662824",
"0.6058654",
"0.6058654",
"0.60404",
"0.60381496",
"0.60345125",
"0.6025214",
"0.60245854",
"0.60223347",
"0.60205495",
"0.6019885",
"0.60184574",
"0.5996458",
"0.59950113",
"0.59863967",
"0.59855574",
"0.59760386",
"0.59729815",
"0.5972251",
"0.59668034",
"0.59644824",
"0.59542495",
"0.59519106",
"0.59499264",
"0.59386533",
"0.5921517",
"0.5919506",
"0.59186953",
"0.5877937",
"0.5876073",
"0.5862129",
"0.58569854",
"0.58536375",
"0.5852489",
"0.585038",
"0.58496195",
"0.5842841",
"0.5839262",
"0.5839108"
] |
0.7421985
|
2
|
GET /resource_types/1 GET /resource_types/1.json
|
def show
@resource_fields = Field.where("resource_type_id = ?", params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @resource_type }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end",
"def lookup(type)\n @resource_types[type] || []\n end",
"def index\n @resources = Resource.eager_load(:resource_type).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resources }\n end\n end",
"def resource_type\n /(\\/api\\/(?<type>\\w+)\\/?)/ =~ full_url\n type.capitalize\n end",
"def new\n @resource = Resource.new\n @resource_types=ResourceType.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def show\n @resource_type = @resource.resource_type\n @values = ResourceValue.where(\"resource_id = ?\", params[:id])\n @field_types = []\n @values.each do |value|\n if value.field.resource_type_reference_id\n @field_types << Resource.find(value.resource_reference_id).resource_type\n else\n @field_types << value.field.field_type\n end\n end \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end",
"def get_resource_type()\n return RedXmlResource::TYPE\n end",
"def resource_type_filter\n return filter_for(:resource_type_id, \n objects_to_names_and_ids(current_user.company.resource_types),\n session[:resource_filters], _(\"Resource Type\"))\n end",
"def find_resources(type)\n resource_collection.all_resources.select do |resource|\n resource_name(resource) == type.to_sym\n end\n end",
"def get_resource(resource_type)\n\n Occi::Log.debug(\"Instantiating #{resource_type} ...\")\n\n if @model.get_by_id resource_type\n # we got a resource type identifier\n Occi::Core::Resource.new resource_type\n elsif @model.kinds.select { |kind| kind.term == resource_type }.any?\n # we got a resource type name\n Occi::Core::Resource.new @model.kinds.select {\n |kind| kind.term == resource_type\n }.first.type_identifier\n else\n raise \"Unknown resource type! [#{resource_type}]\"\n end\n\n end",
"def show\n @resource = Resource.find(params[:id])\n @resource_type = ResourceType.find(@resource.resource_type_id)\n @values = ResourceValue.where(resource_id: params[:id])\n @field_types=[]\n @values.each do |value|\n @field_types << value.Field\n end\n \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def new\n @resource_type = ResourceType.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource_type }\n end\n end",
"def api_get_resources(url, page, resource_type, o = {})\n json = api_get_json(url, page, o)\n json.is_a?(Hash) ? resource_type.new(json) : json.map { |r| resource_type.new(r) }\n end",
"def get_resource_type_identifier(type)\n get_type_identifier(type, Occi::Core::Resource.kind)\n end",
"def type\n Resource::ALL\n end",
"def get_resource(id, type)\n\t\t@client.method(type).call.get(id)\n\tend",
"def all_of_type\n Resource::AllOfType.new(type)\n end",
"def getResourceType() \n @obj.getResourceType() \n end",
"def set_resourcetype\n @resourcetype = Resourcetype.find(params[:id])\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def set_resource_type\n @resource_type = ResourceType.find(resource_type_params[:id])\n end",
"def resource\n return Object unless resource_type\n return resource_type.constantize unless resource_id\n return _resource\n end",
"def get_resource_type_identifiers\n get_kind_type_identifiers_related_to Occi::Core::Resource.kind.type_identifier\n end",
"def read(resource_type, id)\n unless RESOURCES.include?(resource_type)\n raise Common::Exceptions::InvalidFieldValue.new('resource_type', resource_type)\n end\n\n perform(:get, \"#{resource_type}/#{id}\", nil)\n end",
"def resource_type_filter\n return filter_for(:resource_type_id,\n objects_to_names_and_ids(current_user.company.resource_types),\n session[:resource_filters], ResourceType.model_name.human)\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def type(type = nil)\n @type = type if type\n @type || name.split('::').last.gsub(/Resource$/, '').underscore\n end",
"def resource_type\n \"b\"\n end",
"def get_resource_type(type, resource_path)\n changed_path = resource_path.split('/').last\n if type.eql?('singular')\n changed_path.singularize.to_sym\n else\n changed_path.to_sym\n end\n end",
"def lookup_resource(type, name, run_context)\n begin\n run_context.resource_collection.find(\"#{ type }[#{ name }]\")\n rescue ArgumentError => e\n puts \"You provided invalid arugments to resource_collection.find: #{ e }\"\n rescue RuntimeError => e\n puts \"The resources you searched for were not found: #{ e }\"\n end\n end",
"def show\n status_not_acceptable && return unless accept_header?\n\n resource_type = params.permit(:resource_type)[:resource_type]&.downcase\n case resource_type\n when 'patient'\n resource = get_patient(params.permit(:id)[:id])\n when 'observation'\n resource = get_laboratory(params.permit(:id)[:id])\n when 'questionnaireresponse'\n resource = get_assessment(params.permit(:id)[:id])\n else\n status_bad_request && return\n end\n\n status_forbidden && return if resource.nil?\n\n status_ok(resource.as_fhir) && return\n rescue StandardError\n render json: operation_outcome_fatal.to_json, status: :internal_server_error\n end",
"def resource_type\n document_type\n end",
"def resource_type\n document_type\n end",
"def type\n if entity.respond_to?(:resource_type)\n entity.resource_type\n else\n entity.class\n end.to_s\n end",
"def itemtype\n types = resource_type || []\n ResourceTypesService.microdata_type(types.first)\n end",
"def resource_type\n if collection?\n Nokogiri::XML::fragment('<D:collection xmlns:D=\"DAV:\"/>').children.first\n end\n end",
"def to_resource_declaration(type)\n if type.respond_to?(:type_name) && type.respond_to?(:title)\n title = type.title\n type_name = type.type_name\n elsif type_result = /(\\w+)\\['?(\\w+)'?\\]/.match(type.to_s)\n # not all types have a type_name and title so we\n # output to a string and parse the results\n title = type_result[2]\n type_name = type_result[1]\n else\n return type\n end\n res = scope.catalog.resource(type_name, title)\n return res.to_ral if res\n # don't return anything or returns nil if item is not in the catalog\n end",
"def name(_prefix = false)\n 'Resource Types'\n end",
"def map_resource_type(resource_types, node)\n if resource_types.empty?\n if node.is_a?(IFile)\n return {\n 'string' => 'File',\n 'icon' => 'file'\n }\n else\n return {\n 'string' => 'Unknown',\n 'icon' => 'cog'\n }\n end\n end\n\n types = {\n '{http://calendarserver.org/ns/}calendar-proxy-write' => {\n 'string' => 'Proxy-Write',\n 'icon' => 'people'\n },\n '{http://calendarserver.org/ns/}calendar-proxy-read' => {\n 'string' => 'Proxy-Read',\n 'icon' => 'people'\n },\n '{urn:ietf:params:xml:ns:caldav}schedule-outbox' => {\n 'string' => 'Outbox',\n 'icon' => 'inbox'\n },\n '{urn:ietf:params:xml:ns:caldav}schedule-inbox' => {\n 'string' => 'Inbox',\n 'icon' => 'inbox'\n },\n '{urn:ietf:params:xml:ns:caldav}calendar' => {\n 'string' => 'Calendar',\n 'icon' => 'calendar'\n },\n '{http://calendarserver.org/ns/}shared-owner' => {\n 'string' => 'Shared',\n 'icon' => 'calendar'\n },\n '{http://calendarserver.org/ns/}subscribed' => {\n 'string' => 'Subscription',\n 'icon' => 'calendar'\n },\n '{urn:ietf:params:xml:ns:carddav}directory' => {\n 'string' => 'Directory',\n 'icon' => 'globe'\n },\n '{urn:ietf:params:xml:ns:carddav}addressbook' => {\n 'string' => 'Address book',\n 'icon' => 'book'\n },\n '{DAV:}principal' => {\n 'string' => 'Principal',\n 'icon' => 'person'\n },\n '{DAV:}collection' => {\n 'string' => 'Collection',\n 'icon' => 'folder'\n }\n }\n\n info = {\n 'string' => [],\n 'icon' => 'cog'\n }\n\n resource_types.each do |resource_type|\n if types.key?(resource_type)\n info['string'] << types[resource_type]['string']\n else\n info['string'] << resource_type\n end\n end\n\n types.each do |key, resource_info|\n if resource_types.include?(key)\n info['icon'] = resource_info['icon']\n break\n end\n end\n\n info['string'] = info['string'].join(', ')\n\n info\n end",
"def resource_type\n\t\t\t\t\t\traise \"Not implemented.\"\n\t\t\t\t\tend",
"def type\n query_root_node(\"rdf:type/@rdf:resource\", @@NAMESPACES).to_s\n end",
"def resource_type\n case\n when controller_name.starts_with?('search')\n params[:record_type]\n when is_variable_controller?\n 'variables'\n when is_services_controller?\n 'services'\n when is_tools_controller?\n 'tools'\n else\n # default\n 'collections'\n end\n end",
"def find_resource(type, name)\n begin\n return resource_collection.lookup(\"#{type}[#{name}]\")\n rescue Chef::Exceptions::ResourceNotFound; end\n\n resource_collection.all_resources.find do |resource|\n resource_name(resource) == type && (name === resource.identity || name === resource.name)\n end\n end",
"def resourceType\n 'DomainResource'\n end",
"def list(resource_type,limit=0,params={})\n path = '/api/' + resource_type.to_s\n params.merge!({limit: limit.to_s})\n response = http_get(path,params)\n hydrate_list(resource_type, response['objects'])\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def list(resource_type_identifier=nil)\n if resource_type_identifier\n # convert type to type identifier\n resource_type_identifier = @model.kinds.select {\n |kind| kind.term == resource_type_identifier\n }.first.type_identifier if @model.kinds.select {\n |kind| kind.term == resource_type_identifier\n }.any?\n\n # check some basic pre-conditions\n raise \"Endpoint is not connected!\" unless @connected\n raise \"Unkown resource type identifier! [#{resource_type_identifier}]\" unless @model.get_by_id resource_type_identifier\n\n # split the type identifier and get the most important part\n uri_part = resource_type_identifier.split('#').last\n\n # request uri-list from the server\n path = uri_part + '/'\n else\n path = '/'\n end\n\n headers = self.class.headers.clone\n headers['Accept'] = 'text/uri-list'\n\n # TODO: remove the gsub OCCI-OS hack\n response = self.class.get(\n @endpoint + path,\n :headers => headers\n ).body.gsub(/\\# uri:\\/(compute|storage|network)\\/[\\n]?/, '').split(\"\\n\").compact\n end",
"def describe(resource_type_identifier=nil)\n\n # convert type to type identifier\n resource_type_identifier = @model.kinds.select {\n |kind| kind.term == resource_type_identifier\n }.first.type_identifier if @model.kinds.select {\n |kind| kind.term == resource_type_identifier\n }.any?\n\n # check some basic pre-conditions\n raise \"Endpoint is not connected!\" unless @connected\n\n descriptions = []\n\n if resource_type_identifier.nil?\n descriptions << get('/')\n elsif @model.get_by_id resource_type_identifier\n # we got type identifier\n # get all available resources of this type\n locations = list resource_type_identifier\n\n # make the requests\n locations.each do |location|\n descriptions << get(sanitize_resource_link(location))\n end\n elsif resource_type_identifier.start_with?(@endpoint) || resource_type_identifier.start_with?('/')\n # we got resource link\n # make the request\n descriptions << get(sanitize_resource_link(resource_type_identifier))\n else\n raise \"Unkown resource type identifier! [#{resource_type_identifier}]\"\n end\n\n descriptions\n end",
"def show\n if params[:term]\n @types = Type.all(:conditions => ['typeName LIKE ?', \"%#{params[:term]}%\"])\n else\n @type = Type.find(params[:id])\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @types }\n end\n end",
"def create\n\t\t@resource_type = ResourceType.new(resource_type_params)\n\n\t\tif @resource_type.save\n\t\t\trender \"show\", :status => :created\n\t\telse\n\t\t\tinvalid_response(@resource_type)\n\t\tend\t\t\n\tend",
"def resource_type_params\n params.require(:resource_type).permit(:id, :resource_type_general, :resource_type, :resource_id)\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end",
"def get_fhir_resources(fhir_client, type, resource_id, patient_id=nil)\n if patient_id == nil\n search = { parameters: { _id: resource_id} } \n else\n search = { parameters: { _id: resource_id, patient: patient_id} }\n end\n results = fhir_client.search(type, search: search )\n binding.pry if results == nil || results.resource == nil || results.resource.entry == nil \n results.resource.entry.map(&:resource)\n end",
"def find(id)\n response = RestClient.get(\"#{@type.Resource}/#{id}\")\n @type.from_json response['data']\n end",
"def get_fhir_resources(fhir_client, type, resource_id, patient_id=nil)\n if patient_id == nil\n search = { parameters: { _id: resource_id} } \n else\n search = { parameters: { _id: resource_id, patient: patient_id} }\n end\n results = fhir_client.search(type, search: search )\n # binding.pry if results == nil || results.resource == nil || results.resource.entry == nil \n results.resource.entry.map(&:resource)\n end",
"def get_type\n return @resource[:record_type]\n end",
"def show\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_type }\n end\n end",
"def resource_type_params\n params.require(:resource_type).permit(:name)\n end",
"def resource_type\n return 'Data'\n end",
"def type\n response[\"type\"]\n end",
"def type\n response[\"type\"]\n end",
"def resourceType\n 'Patient'\n end",
"def resourceType\n 'Patient'\n end",
"def resource type, labels = {}\n Resource.new.tap do |r|\n r.type = type\n r.labels = labels\n end\n end",
"def resourceType\n 'Person'\n end",
"def get!(resource_type, name)\n result = get(resource_type, name)\n if !result\n raise \"#{identifier(resource_type, name)} not found!\"\n end\n result\n end",
"def ar_resource\n return unless type && id\n return unless self.class.union_models.include?(type.to_sym)\n\n klass = type.classify.constantize rescue nil\n return unless klass\n klass.find_by_id(id)\n end",
"def resource_type\n :collection if collection?\n end",
"def resource_type\n :collection if collection?\n end",
"def types\n @title = 'Resource Type Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_type)\n erb(:objects)\nend",
"def show\n render json: @specification_type, serializer: Web::V1::SpecificationTypeSerializer\n end",
"def service_type_name\n \"REST\"\n end",
"def get_by_type(type, cookie_or_cookies = nil)\n add_cookie_to_http_header(cookie_or_cookies)\n return @client.get(\"#{@resource_uri}/type/#{type}\")\n end",
"def show\n @realty_type = RealtyType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @realty_type }\n end\n end",
"def list_resource_types(feed_id = nil)\n if feed_id.nil?\n ret = http_get('/resourceTypes')\n else\n the_feed = hawk_escape_id feed_id\n ret = http_get(\"/feeds/#{the_feed}/resourceTypes\")\n end\n ret.map { |rt| ResourceType.new(rt) }\n end",
"def type_as_class(resource_name)\n\t resource_name.singularize.capitalize.constantize\n\tend",
"def type_url\n query_root_node(\"rdf:type/@rdf:resource\", @@NAMESPACES).to_s\n end",
"def resources(oneview_type = nil, oneview_name = nil)\n oneview_type = @options[:oneview_type] if oneview_type.nil?\n oneview_name = @options[:oneview_name] if oneview_name.nil?\n raise 'Oneview resource type must be specified.' if oneview_type.nil?\n\n # Determine the endpoint that needs to be called\n endpoint = format('/rest/%s', oneview_type)\n\n # Find the resources\n response = oneview_client.rest_get(endpoint)\n resources = oneview_client.response_handler(response)\n\n return resources if oneview_name.nil?\n\n # Filter the resources by the name if it has been specified\n resources['members'].select { |r| r['name'] == oneview_name }\n end",
"def check_resource(resource_name, resource_type)\n body = JSON.dump(:Name => resource_name, :Type => resource_type)\n url = File.join(configuration.environment.resource_url, 'providers', provider, 'checkresourcename')\n url << \"?api-version=#{@api_version}\"\n\n response = rest_post(url, body)\n response.return!\n end",
"def resource_type\n case model\n when \"Cinstance\"\n 'application'\n else\n model.singular\n end\n end",
"def get_resource_class\n \tresource_name.classify.constantize\n end",
"def parse_resource_type(uri)\n return 'unknown' if uri.blank?\n\n # We can cheat here a bit - most the google APIs (at least in compute.v1)\n # define resources directly under their type (i.e. snapshots/foo or\n # images/bar). However, 'images' allow the specification of 'family' which\n # is an alias to the latest image in a family, breaking the rule.\n parts = URI.parse(uri).path.split('/')\n\n # We assume that the resource url follows the pattern:\n # http://some-google-url.com/some/basepath/resource_type/resource_name\n _ = parts[-1] # resource_name, unused here\n resource_type = parts[-2]\n resource_type_prefix = parts[-3]\n\n return 'unknown' if resource_type.blank?\n\n # Check for the special case of 'family' as explained above\n return 'images' if resource_type == 'family' && resource_type_prefix == 'images'\n\n resource_type\n end",
"def index\n @sample_types = SampleType.all.sort_by(&:name)\n @first = if @sample_types.any?\n @sample_types[0].name\n else\n 'no sample types'\n end\n\n respond_to do |format|\n format.html { render layout: 'aq2' }\n format.json do\n render json: @sample_types\n .sort { |a, b| a.name <=> b.name }\n .to_json(methods: :field_types)\n end\n end\n end",
"def type\n @json['type']\n end",
"def show\n @crate_type = CrateType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @crate_type }\n end\n end",
"def resourceType\n 'Patient'\n end",
"def resource_class\n resource_specification.klass\n end",
"def show\n @incident_type = IncidentType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @incident_type }\n end\n end",
"def show\n @reform_type = ReformType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reform_type }\n end\n end",
"def show\n @collection_type = CollectionType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @collection_type }\n end\n end",
"def index\n @resources = resource_class.send(:all)\n render json: @resources\n end"
] |
[
"0.74772924",
"0.7396458",
"0.72913396",
"0.721878",
"0.7098519",
"0.70269924",
"0.70105314",
"0.6985157",
"0.69457066",
"0.6847062",
"0.6846108",
"0.68067735",
"0.6798842",
"0.6796883",
"0.6796883",
"0.6796883",
"0.6796883",
"0.6787315",
"0.6779011",
"0.67679393",
"0.6752532",
"0.6735794",
"0.6734357",
"0.67054534",
"0.6631727",
"0.66176444",
"0.66176444",
"0.66176444",
"0.66176444",
"0.6601013",
"0.65975034",
"0.65901196",
"0.65589255",
"0.6516746",
"0.6498705",
"0.6496544",
"0.64816",
"0.64698356",
"0.646739",
"0.6452402",
"0.64480233",
"0.64480233",
"0.6406119",
"0.637741",
"0.63448805",
"0.6332542",
"0.6322557",
"0.6304992",
"0.62609744",
"0.6250122",
"0.6219393",
"0.6217009",
"0.61980015",
"0.6190784",
"0.6183084",
"0.61720055",
"0.61680293",
"0.61587805",
"0.6156074",
"0.6155437",
"0.615519",
"0.61511755",
"0.61497444",
"0.614438",
"0.6134325",
"0.6117207",
"0.61138475",
"0.610332",
"0.61032283",
"0.61032283",
"0.6102545",
"0.6102545",
"0.609853",
"0.60962665",
"0.6087342",
"0.60803306",
"0.6061626",
"0.6061626",
"0.606138",
"0.6043806",
"0.60367316",
"0.60353553",
"0.6033053",
"0.6029582",
"0.6028502",
"0.6024558",
"0.5991471",
"0.598874",
"0.5985476",
"0.597545",
"0.5973102",
"0.5969098",
"0.5962695",
"0.59434545",
"0.5942637",
"0.5941881",
"0.5928579",
"0.59245133",
"0.5920997",
"0.5915596"
] |
0.7220071
|
3
|
GET /resource_types/new GET /resource_types/new.json
|
def new
@resource_type = ResourceType.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @resource_type }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @resource = Resource.new\n @resource_types=ResourceType.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n @type = Type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type }\n end\n end",
"def create\n\t\t@resource_type = ResourceType.new(resource_type_params)\n\n\t\tif @resource_type.save\n\t\t\trender \"show\", :status => :created\n\t\telse\n\t\t\tinvalid_response(@resource_type)\n\t\tend\t\t\n\tend",
"def new\n @breadcrumb = 'create'\n @entity_type = EntityType.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity_type }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n @resource = Resource.new\n respond_to do |format|\n format.html {render action: :new} # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n @fieldtype = Fieldtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fieldtype }\n end\n end",
"def new\n @collection_type = CollectionType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection_type }\n end\n end",
"def new\n @ctype = Ctype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ctype }\n end\n end",
"def new\n @client_type = ClientType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_type }\n end\n end",
"def new\n @resource_info = ResourceInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource_info }\n end\n end",
"def new\n @incident_type = IncidentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @incident_type }\n end\n end",
"def new\n @entry_type = EntryType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry_type }\n end\n end",
"def new\n @realty_type = RealtyType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @realty_type }\n end\n end",
"def new\n @rtype = Rtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rtype }\n end\n end",
"def new\n @instance_type = InstanceType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance_type }\n end\n end",
"def new\n @page_type = PageType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page_type }\n end\n end",
"def new\n @category_type = CategoryType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category_type }\n end\n end",
"def new\n @site_type = SiteType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site_type }\n end\n end",
"def new\n @crate_type = CrateType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @crate_type }\n end\n end",
"def new\n @identifier_type = IdentifierType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @identifier_type }\n end\n end",
"def new\n @breadcrumb = 'create'\n @product_type = ProductType.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_type }\n end\n end",
"def new\n @entity = resource_class.new\n end",
"def new\n @gl_type = GlType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gl_type }\n end\n end",
"def new\n @entry = @resource_finder.new\n initialize_new_resource\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry }\n end\n end",
"def new\n @act_type = ActType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @act_type }\n end\n end",
"def new\n @type_person = TypePerson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type_person }\n end\n end",
"def new\n @mtype = Mtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mtype }\n end\n end",
"def new\n @girltype = Girltype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @girltype }\n end\n end",
"def new\n @person = people_type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end",
"def new\n @action_type = ActionType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @action_type }\n end\n end",
"def new\n build_resource({meta_type: params[:meta].classify})\n respond_with self.resource\n end",
"def new_resource\n controller_class.new(new_resource_params)\n end",
"def new\n @reform_type = ReformType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reform_type }\n end\n end",
"def new\n @kind = Kind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kind }\n end\n end",
"def new\n @itype = Itype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @itype }\n end\n end",
"def new\n @question_type = QuestionType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question_type }\n end\n end",
"def new\n @breadcrumb = 'create'\n @invoice_type = InvoiceType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invoice_type }\n end\n end",
"def new\n @types_of_apprenticeship = TypesOfApprenticeship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @types_of_apprenticeship }\n end\n end",
"def new\n @tasktype = Tasktype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tasktype }\n end\n end",
"def new\n @breadcrumb = 'create'\n @infrastructure_type = InfrastructureType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @infrastructure_type }\n end\n end",
"def new\n @uri_type = UriType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uri_type }\n end\n end",
"def new\n @resource = Resource.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @sample_type = SampleType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sample_type }\n end\n end",
"def new\n @ftype = Ftype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ftype }\n end\n end",
"def create\n authorize :resquest_type, :create?\n @resquest_type = ResquestType.new(resquest_type_params)\n\n respond_to do |format|\n if @resquest_type.save\n format.html { redirect_to @resquest_type, notice: 'Resquest type was successfully created.' }\n format.json { render :show, status: :created, location: @resquest_type }\n else\n format.html { render :new }\n format.json { render json: @resquest_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @collection = current_user.collections.find(params[:collection_id])\n @entity_type = EntityType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity_type }\n end\n end",
"def new\n @producttype = Producttype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @producttype }\n end\n end",
"def new_resource\n base_collection.new\n end",
"def new\n @service_type = ServiceType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @service_type }\n end\n end",
"def new\n @recipe_type = RecipeType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recipe_type }\n end\n end",
"def new\n @ip_type = IpType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @ip_type }\n end\n end",
"def create_resource_type(feed_id, type_id, type_name)\n the_feed = hawk_escape_id feed_id\n\n type = create_blueprint\n type[:id] = type_id\n type[:name] = type_name\n\n begin\n http_post(\"/feeds/#{the_feed}/resourceTypes\", type)\n rescue HawkularException => error\n # 409 We already exist -> that is ok\n raise unless error.status_code == 409\n ensure\n the_type = hawk_escape_id type_id\n res = http_get(\"/feeds/#{the_feed}/resourceTypes/#{the_type}\")\n end\n ResourceType.new(res)\n end",
"def new\n @info_type = InfoType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @info_type }\n end\n end",
"def new\n @all_field_type = AllFieldType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @all_field_type }\n end\n end",
"def new\n @trtype = Trtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trtype }\n end\n end",
"def new\n @task_type = TaskType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task_type }\n end\n end",
"def new\n @role_types = RoleTypes.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @role_types }\n end\n end",
"def new\n @taxonomy = Taxonomy.new(:taxonomy_type => params[:taxonomy_type].presence || 'category')\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taxonomy }\n end\n end",
"def new\n @resource = Resource.new\n end",
"def new\n @manifestation_relationship_type = ManifestationRelationshipType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @manifestation_relationship_type }\n end\n end",
"def new\n @resources_and_link = ResourcesAndLink.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resources_and_link }\n end\n end",
"def new\n @environment_type = EnvironmentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @environment_type }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @discipline_type = DisciplineType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @discipline_type }\n end\n end",
"def new\n @customer = Customer.new\n @customer_types = [CustomerType.new]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def create\n @collection = current_user.collections.find(params[:collection_id])\n @entity_type = @collection.entity_types.new(params[:entity_type])\n\n respond_to do |format|\n if @entity_type.save\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'Type was successfully created.' }\n format.json { render json: @entity_type, status: :created, location: @entity_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @expression_relationship_type = ExpressionRelationshipType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @expression_relationship_type }\n end\n end",
"def new\n @type_customer = TypeCustomer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type_customer }\n end\n end",
"def new\n @breadcrumb = 'create'\n @timerecord_type = TimerecordType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @timerecord_type }\n end\n end",
"def new\n @breadcrumb = 'create'\n @reading_type = ReadingType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reading_type }\n end\n end",
"def new\n @ProfileType = ProfileType.new\n\n respond_to do |format|\n format.html # new.html.haml\n format.json { render json: @ProfileType }\n end\n end",
"def new\n @costtype = Costtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @costtype }\n end\n end",
"def new\n set_resource model_class.unscoped.new\n respond_with resource\n end",
"def new\n @document_type = DocumentType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @document_type }\n end\n end",
"def new\n @oma_relation_type = OmaRelationType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @oma_relation_type }\n end\n end",
"def new\n @model_type = ModelType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @model_type }\n end\n end",
"def new\n @paper_type = PaperType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paper_type }\n end\n end",
"def new\n @contract_type = ContractType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contract_type }\n end\n end",
"def new\n @contractor_type = ContractorType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contractor_type }\n end\n end",
"def new\n @tax_type = TaxType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tax_type }\n end\n end",
"def new\n @resource_file = ResourceFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource_file }\n end\n end",
"def create\n @provider_provider_type = Provider::ProviderType.new(provider_provider_type_params)\n @provider_provider_type.user_created_id = current_user.id\n respond_to do |format|\n if @provider_provider_type.save\n format.html { redirect_to provider_provider_types_path, notice: I18n.t('provider_types.controller.create') }\n format.json { render :show, status: :created, location: @provider_provider_type }\n else\n format.html { render :new }\n format.json { render json: @provider_provider_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @title = \"New Resources Periods\"\n @resource_period = ResourcePeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @resource_period }\n end\n end",
"def new\n resource = build_resource({})\n respond_with resource\n end",
"def new\n @servicetype = Servicetype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @servicetype }\n end\n end",
"def new\n @inventory_item_type = InventoryItemType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inventory_item_type }\n end\n end",
"def new\n @observation_type = ObservationType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation_type }\n end\n end",
"def new\n @incident_kind = IncidentKind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @incident_kind }\n end\n end",
"def new\n @entity_subtype = EntitySubtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity_subtype }\n end\n end",
"def new\n @type_course = TypeCourse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type_course }\n end\n end",
"def create\n\n respond_to do |format|\n if @resource.save\n format.html { redirect_to polymorphic_path(complex_namespace_helper + [@resource]), notice: \"#{@resource_class} was successfully created.\" }\n format.json { render action: 'show', status: :created, location: @resource }\n else\n format.html { render action: 'new' }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @resource = Resource.new(params[:resource])\n respond_to do |format|\n if @resource.save\n @resource.eval_description\n format.html { redirect_to @resource, notice: 'Resource was successfully created.' }\n format.json { render json: @resource, status: :created, location: @resource }\n else\n get_resource_types\n format.html { render action: :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @type_of_cleaning_and_washing = TypeOfCleaningAndWashing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type_of_cleaning_and_washing }\n end\n end",
"def new\n @genre_type = GenreType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @genre_type }\n end\n end",
"def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end"
] |
[
"0.80984217",
"0.749518",
"0.72583467",
"0.7163297",
"0.7077784",
"0.7077784",
"0.7077784",
"0.6994682",
"0.699189",
"0.69738686",
"0.6973582",
"0.69266593",
"0.6924751",
"0.68841773",
"0.6876847",
"0.6873741",
"0.6855479",
"0.6854698",
"0.6847847",
"0.6828631",
"0.6825493",
"0.6818818",
"0.6816123",
"0.6814107",
"0.6810702",
"0.6790934",
"0.679075",
"0.6788937",
"0.67783046",
"0.67635626",
"0.67487526",
"0.6732777",
"0.6731431",
"0.6726939",
"0.6726073",
"0.67141503",
"0.67030907",
"0.66984665",
"0.6698",
"0.66936886",
"0.6685817",
"0.6676856",
"0.66730493",
"0.66680634",
"0.66665834",
"0.6665109",
"0.66481334",
"0.6641218",
"0.6640298",
"0.6635212",
"0.66290283",
"0.6624592",
"0.66133267",
"0.659802",
"0.6597267",
"0.65914017",
"0.6582375",
"0.65809083",
"0.6565312",
"0.6561475",
"0.655899",
"0.6555082",
"0.6554542",
"0.6551592",
"0.6536718",
"0.653233",
"0.6518958",
"0.6518958",
"0.6518148",
"0.6516078",
"0.65129745",
"0.65103954",
"0.65096194",
"0.6508121",
"0.65066993",
"0.6505892",
"0.65016353",
"0.6491607",
"0.6490481",
"0.64880776",
"0.6487179",
"0.6482094",
"0.6480079",
"0.64696103",
"0.6469222",
"0.64685374",
"0.64587754",
"0.6458222",
"0.6457519",
"0.6453699",
"0.64459467",
"0.64437264",
"0.6441258",
"0.6440435",
"0.64370215",
"0.6435319",
"0.6432771",
"0.642982",
"0.64257157",
"0.6424233"
] |
0.8351805
|
0
|
POST /resource_types POST /resource_types.jsojoins(:field_type)n
|
def create
@resource_type = ResourceType.new(params[:resource_type])
respond_to do |format|
if @resource_type.save
if params[:fields]
params[:fields].each do |param|
@field = Field.new(
:name => param[:name],
:field_type_id => param[:field_type_id],
:resource_type_id => @resource_type.id,
:resource_type_reference_id => param[:resource_type_reference_id]
)
param[:validator_ids].each do |index|
@field.field_validations.build(validator_id: index)
end
@field.save
end
end
format.html { redirect_to @resource_type, notice: 'Resource type was successfully created.' }
format.json { render json: @resource_type, status: :created, location: @resource_type }
else
format.html { render action: "new" }
format.json { render json: @resource_type.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def field_as_json(field)\n res = \"'#{field.name}' => @#{field.name}\"\n field_base_type = _schema_base_class(field.type).type_sym\n\n if %i(record enum).include?(field_base_type)\n res += case field.type.type_sym\n when :array\n '.map { |v| v&.as_json }'\n when :map\n '.transform_values { |v| v&.as_json }'\n else\n '&.as_json'\n end\n end\n\n res + (field.name == @fields.last.name ? '' : ',')\n end",
"def type_objects\n pre = Prereq.new(:need_type => params[:type])\n pre.id = params[:id].to_i\n respond_to do |format|\n format.js {render :partial => 'prereqs/prereq_items_by_type', :locals => {:prereq => pre}}\n end\n end",
"def add_dummy_type\n params[:data] ||= {}\n params[:data][:type] = resource_klass._type.to_s\n end",
"def show\n @resource = Resource.find(params[:id])\n @resource_type = ResourceType.find(@resource.resource_type_id)\n @values = ResourceValue.where(resource_id: params[:id])\n @field_types=[]\n @values.each do |value|\n @field_types << value.Field\n end\n \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end",
"def show\n @resource_type = @resource.resource_type\n @values = ResourceValue.where(\"resource_id = ?\", params[:id])\n @field_types = []\n @values.each do |value|\n if value.field.resource_type_reference_id\n @field_types << Resource.find(value.resource_reference_id).resource_type\n else\n @field_types << value.field.field_type\n end\n end \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end",
"def show\n @resource_fields = Field.where(\"resource_type_id = ?\", params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource_type }\n end\n end",
"def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end",
"def type\n field[:type]\n end",
"def types\n FIELD_TYPES\n end",
"def resource_type_params\n params.require(:resource_type).permit(:id, :resource_type_general, :resource_type, :resource_id)\n end",
"def field_types\r\n return @field_types\r\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"resourceActions\" => lambda {|n| @resource_actions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ResourceAction.create_from_discriminator_value(pn) }) },\n }\n end",
"def update\n respond_to do |format|\n if @resource_type.update_attributes(params[:resource_type])\n if params[:fields]\n params[:fields].each do |param|\n if param[:id]\n @field = Field.find(param[:id])\n @field.update_attributes(\n :name => param[:name], \n :field_type_id => param[:field_type_id],\n :resource_type_id => params[:id],\n :resource_type_reference_id => param[:resource_type_reference_id]\n )\n else\n @field = Field.create(\n :name => param[:name],\n :field_type_id => param[:field_type_id],\n :resource_type_id => params[:id],\n :resource_type_reference_id => param[:resource_type_reference_id]\n )\n end\n if @field.field_validations.any?\n @field.field_validations.each { |v| v.destroy }\n end\n if param[:validator_ids]\n param[:validator_ids].each do |index|\n next if index == \"multiselect-all\"\n @field.field_validations.build(validator_id: index.to_i)\n end\n end \n @field.save\n end\n end \n format.html { redirect_to @resource_type, notice: 'Resource type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def _field_types\n special_attribute('@fieldTypes'.freeze)\n end",
"def get_field_type(field_name)\n\t\tend",
"def create\n field_type_ids = params[:entry_type].delete(\"field_type_ids\")\n @entry_type = EntryType.new(params[:entry_type])\n @entry_type.field_type_ids = field_type_ids\n @entry_type.form_code = build_form_code(@entry_type.field_types)\n @entry_type.model_code = build_model_code(@entry_type.name, @entry_type.field_types)\n @entry_type.model = build_model_from_code(@entry_type)\n\n respond_to do |format|\n if @entry_type.save\n format.html { redirect_to @entry_type, notice: 'Entry type was successfully created.' }\n format.json { render json: @entry_type, status: :created, location: @entry_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_field_deserializers()\n return {\n \"allowedResourceActions\" => lambda {|n| @allowed_resource_actions = n.get_collection_of_primitive_values(String) },\n \"condition\" => lambda {|n| @condition = n.get_string_value() },\n \"excludedResourceActions\" => lambda {|n| @excluded_resource_actions = n.get_collection_of_primitive_values(String) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end",
"def get_field_type\n\t\tend",
"def process_method_field_types(fields)\n fields.each do |field|\n field_type = field[:type]\n next if STANDARD_TYPES.include?(field_type)\n @raw_types << field_type unless @raw_types.include?(field_type)\n end\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"resourceId\" => lambda {|n| @resource_id = n.get_string_value() },\n \"uri\" => lambda {|n| @uri = n.get_string_value() },\n }\n end",
"def fields_for_type(type)\n return @field_mapping[type] || Set.new\n end",
"def create\n @fieldtype = Fieldtype.new(params[:fieldtype])\n\n respond_to do |format|\n if @fieldtype.save\n format.html { redirect_to @fieldtype, notice: 'Fieldtype was successfully created.' }\n format.json { render json: @fieldtype, status: :created, location: @fieldtype }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fieldtype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def resource_type_params\n params.require(:resource_type).permit(:name)\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"queryString\" => lambda {|n| @query_string = n.get_string_value() },\n \"queryTemplate\" => lambda {|n| @query_template = n.get_string_value() },\n }\n end",
"def get_field_deserializers()\n return {\n \"id\" => lambda {|n| @id = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end",
"def deimos_field_type(schema_field)\n _field_type(schema_field.type)\n end",
"def scaffold_field_type_list\n list = \"\"\n @fields.each {|field| list << field.scaffold_instruction}\n list\n end",
"def custom_fields_by_type(type)\n custom_fields.select { |field| field.type == \"platformCore:#{type}\" }\n end",
"def parse_field(field)\n [STREET_TYPES, CITY_TYPES, STATE_TYPES, POSTAL_TYPES].each do |type|\n if similar?(field['types'], type[:values])\n send(\"add_#{type[:name]}\", field)\n end\n end\n end",
"def get_field_deserializers()\n return {\n \"excludeLocations\" => lambda {|n| @exclude_locations = n.get_collection_of_primitive_values(String) },\n \"includeLocations\" => lambda {|n| @include_locations = n.get_collection_of_primitive_values(String) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"query\" => lambda {|n| @query = n.get_string_value() },\n \"queryRoot\" => lambda {|n| @query_root = n.get_string_value() },\n \"queryType\" => lambda {|n| @query_type = n.get_string_value() },\n }\n end",
"def thrift_type_to_json_type(value, field)\n type = Thrift.type_name(field[:type])\n raise Thrift::TypeError.new(\"Type for #{field.inspect} not found.\") unless type\n type.sub!('Types::', '')\n result = value\n type = 'UNION' if type == 'STRUCT' && field[:class].ancestors.any?{|x| x == Thrift::Union}\n if type == 'STRUCT'\n result = thrift_struct_to_json_map(value, field[:class])\n # field[:class].const_get('FIELDS').each do |(_, struct_field)|\n # name = struct_field[:name]\n # val = value.send(name)\n # result[name] = thrift_type_to_json_type(val, struct_field) if val\n # end\n elsif type == 'LIST' || type == 'SET'\n result = value.map {|val| thrift_type_to_json_type val, field[:element]}\n elsif type == 'MAP'\n result = value.map do |key, val|\n [thrift_type_to_json_type(key, field[:key]), thrift_type_to_json_type(val, field[:value])]\n end\n elsif enum = field[:enum_class]\n result = enum.const_get('VALUE_MAP')[value] || value\n elsif type == 'UNION'\n result = thrift_union_to_json_map(value, field[:class])\n end\n result\n end",
"def create\n @resources_table = ResourcesTable.find(params[:resources_table_id])\n @resources_field = @resources_table.resources_fields.build(params[:resources_field])\n\n respond_to do |format|\n if @resources_field.save\n format.html { redirect_to(@resources_table, :notice => 'ResourcesField was successfully created.') }\n format.xml { render :xml => @resources_field, :status => :created, :location => @resources_field }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @resources_field.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def resourcetype_params\n\t\t params.require(:resourcetype).permit(:name, :regenerating, :location)\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"resource\" => lambda {|n| @resource = n.get_string_value() },\n \"resourceType\" => lambda {|n| @resource_type = n.get_enum_value(MicrosoftGraph::Models::SecurityResourceType) },\n }\n end",
"def relation_type_params\n params.require(:relation_type).permit(:name, :color, :num_nodes, :project_id, :entity_type => [])\n end",
"def simplified_type_with_patch(field_type)\n case field_type\n when 'inet'\n :inet\n when 'cidr'\n :cidr\n when 'macaddr'\n :macaddr\n when /^numeric.+\\[\\]$/\n :decimal_array\n when /character varying.*\\[\\]/\n :string_array\n when /^(?:real|double precision)\\[\\]$/\n :float_array\n when /timestamp.*\\[\\]/\n :timestamp_array\n when /\\[\\]$/\n field_type.gsub(/\\[\\]/, '_array').to_sym\n else\n simplified_type_without_patch(field_type)\n end\n end",
"def _ field\n as_name = [name, field].join(\"_\").to_sym\n AS[\"#{relationize}.(#{field})\", as_name, Bag.new([field, field_type(field)]), nil, :skip_type]\n end",
"def get_field_deserializers()\n return {\n \"detectionType\" => lambda {|n| @detection_type = n.get_string_value() },\n \"method\" => lambda {|n| @method = n.get_string_value() },\n \"name\" => lambda {|n| @name = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end",
"def as_json(options={})\n super(methods: :type)\n end",
"def serialized_type(reference_state)\n result = field_type.serialize(reference_state)\n optional_field ? field_type.class.union_with_null(result) : result\n end",
"def type(index)\n get_field_from_relationship(workspace_id(index), @fields_extra[:type])\n end",
"def json_fields\n\n mappings = {}\n\n json = self.record.json\n if !json\n return mappings\n end\n\n mappings['language'] = json['language']\n\n if json['notes']\n json['notes'].each do |note|\n if note['type'] == 'physloc' and !note['content'].blank?\n mappings['physical_location_note'] = note['content'].map { |cont| \"#{cont}\" }.join(\"; \")\n end\n end\n end\n\n if json['dates']\n json['dates']\n .select { |date| date['expression'].present? }\n .group_by { |date| date['label'] }\n .each { |label, dates|\n mappings[\"#{label}_date\"] = dates\n .map { |date| date['expression'] }\n .join(\"; \")\n }\n end\n\n mappings['restrictions_apply'] = json['restrictions_apply']\n mappings['display_string'] = json['display_string']\n\n instances = json.fetch('instances', false)\n if !instances\n return mappings\n end\n\n mappings['requests'] = instances\n .select{ |instance| !instance['digital_object'] }\n .each_with_index\n .map { |instance, i|\n request = {}\n\n instance_count = i + 1\n\n request['Request'] = \"#{instance_count}\"\n\n request[\"instance_is_representative_#{instance_count}\"] = instance['is_representative']\n request[\"instance_last_modified_by_#{instance_count}\"] = instance['last_modified_by']\n request[\"instance_instance_type_#{instance_count}\"] = instance['instance_type']\n request[\"instance_created_by_#{instance_count}\"] = instance['created_by']\n\n container = instance['sub_container']\n if container\n request[\"instance_container_grandchild_indicator_#{instance_count}\"] = container['indicator_3']\n request[\"instance_container_child_indicator_#{instance_count}\"] = container['indicator_2']\n request[\"instance_container_grandchild_type_#{instance_count}\"] = container['type_3']\n request[\"instance_container_child_type_#{instance_count}\"] = container['type_2']\n\n request[\"instance_container_last_modified_by_#{instance_count}\"] = container['last_modified_by']\n request[\"instance_container_created_by_#{instance_count}\"] = container['created_by']\n\n top_container = container['top_container']\n if top_container\n request[\"instance_top_container_ref_#{instance_count}\"] = top_container['ref']\n\n top_container_resolved = top_container['_resolved']\n if top_container_resolved\n request[\"instance_top_container_long_display_string_#{instance_count}\"] = top_container_resolved['long_display_string']\n request[\"instance_top_container_last_modified_by_#{instance_count}\"] = top_container_resolved['last_modified_by']\n request[\"instance_top_container_display_string_#{instance_count}\"] = top_container_resolved['display_string']\n request[\"instance_top_container_restricted_#{instance_count}\"] = top_container_resolved['restricted']\n request[\"instance_top_container_created_by_#{instance_count}\"] = top_container_resolved['created_by']\n request[\"instance_top_container_indicator_#{instance_count}\"] = top_container_resolved['indicator']\n request[\"instance_top_container_barcode_#{instance_count}\"] = top_container_resolved['barcode']\n request[\"instance_top_container_type_#{instance_count}\"] = top_container_resolved['type']\n request[\"instance_top_container_uri_#{instance_count}\"] = top_container_resolved['uri']\n\n collection = top_container_resolved['collection']\n if collection\n request[\"instance_top_container_collection_identifier_#{instance_count}\"] = collection\n .select { |c| c['identifier'].present? }\n .map { |c| c['identifier'] }\n .join(\"; \")\n\n request[\"instance_top_container_collection_display_string_#{instance_count}\"] = collection\n .select { |c| c['display_string'].present? }\n .map { |c| c['display_string'] }\n .join(\"; \")\n end\n\n series = top_container_resolved['series']\n if series\n request[\"instance_top_container_series_identifier_#{instance_count}\"] = series\n .select { |s| s['identifier'].present? }\n .map { |s| s['identifier'] }\n .join(\"; \")\n\n request[\"instance_top_container_series_display_string_#{instance_count}\"] = series\n .select { |s| s['display_string'].present? }\n .map { |s| s['display_string'] }\n .join(\"; \")\n end\n\n end\n end\n end\n\n request\n }\n\n return mappings\n end",
"def typus_fields_for(filter); end",
"def create_types\n\t\t[]\n\tend",
"def create_types\n\t\t[]\n\tend",
"def create_types\n\t[]\nend",
"def create_types\n\t[]\nend",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"resourceAccess\" => lambda {|n| @resource_access = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::ResourceAccess.create_from_discriminator_value(pn) }) },\n \"resourceAppId\" => lambda {|n| @resource_app_id = n.get_string_value() },\n }\n end",
"def getTypes()\n\ttypes = Hash.new\n\n\t@fields_doc.elements.each(\"acda-fields/types/*\") { |elem|\n\t\tcase elem.name\n\t\t\twhen \"number\"\n\t\t\t\tnumber = nil\n\t\t\t\tif elem.attributes[\"default\"]\n\t\t\t\t\tnumber = NumberType.new(elem.attributes[\"id\"],\n\t\t\t\t\t\t\t\t\t\t\t elem.attributes[\"default\"])\n\t\t\t\telse\n\t\t\t\t\tnumber = NumberType.new(elem.attributes[\"id\"])\n\t\t\t\tend\n\n\t\t\t\ttypes[number.name] = number\n\n\t\t\twhen \"text\"\n\t\t\t\tstring = nil\n\t\t\t\tif elem.attributes[\"default\"]\n\t\t\t\t\tstring = StringType.new(elem.attributes[\"id\"],\n\t\t\t\t\t\t\t\t\t\t elem.attributes[\"default\"])\n\t\t\t\telse\n\t\t\t\t\tstring = StringType.new(elem.attributes[\"id\"])\n\t\t\t\tend\n\n\t\t\t\ttypes[string.name] = string\n\n\t\t\twhen \"choice\"\n\t\t\t\tchoices = Array.new\n\n\t\t\t\telem.elements.each(\"entry\") {\n |entry| choices.push(entry.attributes[\"name\"])\n }\n\n if elem.attributes[\"default\"]\n\t\t\t\t choice = ChoiceType.new(elem.attributes[\"id\"],\n\t\t\t\t\t\t\t\t\t\tchoices,\telem.attributes[\"default\"])\n else\n\t\t\t\t choice = ChoiceType.new(elem.attributes[\"id\"], choices)\n end\n\n\t\t\t \ttypes[choice.name] = choice\n\t\t\telse\n\t\t\t\traise RuntimeError, \"Unknown optional type #{elem.name}\"\n\t\tend\n\t}\n\n\treturn types\nend",
"def get_field_deserializers()\n return {\n \"id\" => lambda {|n| @id = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"targetType\" => lambda {|n| @target_type = n.get_enum_value(MicrosoftGraph::Models::FeatureTargetType) },\n }\n end",
"def get_field_deserializers()\n return {\n \"columnId\" => lambda {|n| @column_id = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"qualityId\" => lambda {|n| @quality_id = n.get_string_value() },\n }\n end",
"def get_field_deserializers()\n return {\n \"lastActionDateTime\" => lambda {|n| @last_action_date_time = n.get_date_time_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"operation\" => lambda {|n| @operation = n.get_string_value() },\n \"status\" => lambda {|n| @status = n.get_string_value() },\n }\n end",
"def type_params\n params.from_jsonapi.require(:type).permit(:name)\n end",
"def json_fields\n\n mappings = {}\n\n json = self.record.json\n return mappings unless json\n\n lang_materials = json['lang_materials']\n if lang_materials\n mappings['language'] = lang_materials\n .select { |lm| lm['language_and_script'].present? and lm['language_and_script']['language'].present?}\n .map{ |lm| lm['language_and_script']['language'] }\n .flatten\n .join(\";\")\n end\n\n language = json['language']\n if language\n mappings['language'] = language\n end\n\n\n notes = json['notes']\n if notes\n mappings['physical_location_note'] = notes\n .select { |note| note['type'] == 'physloc' and note['content'].present? and note['publish'] == true }\n .map { |note| note['content'] }\n .flatten\n .join(\"; \")\n\n mappings['accessrestrict'] = notes\n .select { |note| note['type'] == 'accessrestrict' and note['subnotes'] }\n .map { |note| note['subnotes'] }\n .flatten\n .select { |subnote| subnote['content'].present? and subnote['publish'] == true}\n .map { |subnote| subnote['content'] }\n .flatten\n .join(\"; \")\n end\n\n if json['dates']\n json['dates']\n .select { |date| date['expression'].present? }\n .group_by { |date| date['label'] }\n .each { |label, dates|\n mappings[\"#{label}_date\"] = dates\n .map { |date| date['expression'] }\n .join(\"; \")\n }\n end\n\n\n if json['linked_agents']\n mappings['creators'] = json['linked_agents']\n .select { |l| l['role'] == 'creator' and l['_resolved'] }\n .map { |l| l['_resolved']['names'] }.flatten\n .select { |n| n['is_display_name'] == true}\n .map { |n| n['sort_name']}\n .join(\"; \")\n end\n\n if json['rights_statements']\n mappings['rights_type'] = json['rights_statements'].map{ |r| r['rights_type']}.uniq.join(';')\n end\n\n digital_instances = json['instances'].select { |instance| instance['instance_type'] == 'digital_object'}\n if (digital_instances.any?)\n mappings[\"digital_objects\"] = digital_instances.map{|d| d['digital_object']['ref']}.join(';')\n end\n\n mappings['restrictions_apply'] = json['restrictions_apply']\n mappings['display_string'] = json['display_string']\n\n instances = self.container_instances\n return mappings unless instances\n\n mappings['requests'] = instances\n .each_with_index\n .map { |instance, i|\n request = {}\n \n instance_count = i + 1\n\n request['Request'] = \"#{instance_count}\"\n\n request[\"instance_is_representative_#{instance_count}\"] = instance['is_representative']\n request[\"instance_last_modified_by_#{instance_count}\"] = instance['last_modified_by']\n request[\"instance_instance_type_#{instance_count}\"] = instance['instance_type']\n request[\"instance_created_by_#{instance_count}\"] = instance['created_by']\n\n container = instance['sub_container']\n return request unless container\n\n request[\"instance_container_grandchild_indicator_#{instance_count}\"] = container['indicator_3']\n request[\"instance_container_child_indicator_#{instance_count}\"] = container['indicator_2']\n request[\"instance_container_grandchild_type_#{instance_count}\"] = container['type_3']\n request[\"instance_container_child_type_#{instance_count}\"] = container['type_2']\n request[\"instance_container_last_modified_by_#{instance_count}\"] = container['last_modified_by']\n request[\"instance_container_created_by_#{instance_count}\"] = container['created_by']\n\n top_container = container['top_container']\n return request unless top_container\n\n request[\"instance_top_container_ref_#{instance_count}\"] = top_container['ref']\n\n top_container_resolved = top_container['_resolved']\n return request unless top_container_resolved\n\n request[\"instance_top_container_long_display_string_#{instance_count}\"] = top_container_resolved['long_display_string']\n request[\"instance_top_container_last_modified_by_#{instance_count}\"] = top_container_resolved['last_modified_by']\n request[\"instance_top_container_display_string_#{instance_count}\"] = top_container_resolved['display_string']\n request[\"instance_top_container_restricted_#{instance_count}\"] = top_container_resolved['restricted']\n request[\"instance_top_container_created_by_#{instance_count}\"] = top_container_resolved['created_by']\n request[\"instance_top_container_indicator_#{instance_count}\"] = top_container_resolved['indicator']\n request[\"instance_top_container_barcode_#{instance_count}\"] = top_container_resolved['barcode']\n request[\"instance_top_container_type_#{instance_count}\"] = top_container_resolved['type']\n request[\"instance_top_container_uri_#{instance_count}\"] = top_container_resolved['uri']\n\n if (top_container_resolved['container_locations'])\n request[\"instance_top_container_location_note_#{instance_count}\"] = top_container_resolved['container_locations'].map{ |l| l['note']}.join{';'}\n end\n\n request[\"requestable_#{instance_count}\"] = (top_container_resolved['active_restrictions'] || [])\n .map{ |ar| ar['local_access_restriction_type'] }\n .flatten.uniq\n .select{ |ar| (self.repo_settings[:hide_button_for_access_restriction_types] || []).include?(ar)}\n .empty?\n\n locations = top_container_resolved[\"container_locations\"]\n if locations.any?\n location_id = locations.sort_by { |l| l[\"start_date\"]}.last()[\"ref\"]\n location = archivesspace.get_location(location_id)\n request[\"instance_top_container_location_#{instance_count}\"] = location['title']\n request[\"instance_top_container_location_id_#{instance_count}\"] = location_id\n request[\"instance_top_container_location_building_#{instance_count}\"] = location['building']\n end\n\n collection = top_container_resolved['collection']\n if collection\n request[\"instance_top_container_collection_identifier_#{instance_count}\"] = collection\n .select { |c| c['identifier'].present? }\n .map { |c| c['identifier'] }\n .join(\"; \")\n\n request[\"instance_top_container_collection_display_string_#{instance_count}\"] = collection\n .select { |c| c['display_string'].present? }\n .map { |c| c['display_string'] }\n .join(\"; \")\n end\n\n series = top_container_resolved['series']\n if series\n request[\"instance_top_container_series_identifier_#{instance_count}\"] = series\n .select { |s| s['identifier'].present? }\n .map { |s| s['identifier'] }\n .join(\"; \")\n\n request[\"instance_top_container_series_display_string_#{instance_count}\"] = series\n .select { |s| s['display_string'].present? }\n .map { |s| s['display_string'] }\n .join(\"; \")\n\n end\n\n request\n }\n\n mappings\n end",
"def get_field_deserializers()\n return {\n \"countriesBlockedForMinors\" => lambda {|n| @countries_blocked_for_minors = n.get_collection_of_primitive_values(String) },\n \"legalAgeGroupRule\" => lambda {|n| @legal_age_group_rule = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end",
"def get_field_deserializers()\n return {\n \"includeContent\" => lambda {|n| @include_content = n.get_enum_value(MicrosoftGraph::Models::SearchContent) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end",
"def type_for_field(method, options)\n if @object.nil?\n :string\n elsif @object.class.respond_to?(:meta_field)\n @object.class.meta_field(method)\n elsif (col = @object.class.columns && @object.class.columns.detect {|col| col.name == method.to_s })\n col.type\n elsif (rel = @object.class.reflections[method])\n # is method a relationship?\n raise \"relationship not managed yet\" unless [:belongs_to, :has_many].include?(rel.macro)\n rel.macro\n else\n :string\n end\n end",
"def create_types\n @types.each do |type|\n create_type(type) unless Type.where(name: type['name']).first\n end\n end",
"def resource_type_filter\n return filter_for(:resource_type_id, \n objects_to_names_and_ids(current_user.company.resource_types),\n session[:resource_filters], _(\"Resource Type\"))\n end",
"def the_json_fields(field_key)\n r = []\n object.get_fields(field_key).each do |text|\n _r = JSON.parse(text || '{}').with_indifferent_access\n _r.keys.each do |k|\n _r[k] = h.do_shortcode(_r[k].to_s.translate(@_deco_locale), object)\n end\n r << _r\n end\n r\n end",
"def as_json(options=nil)\n json = super\n json.merge({\"type\"=>self.type.to_s})\n end",
"def as_json(options={})\n super(options.merge({:methods => :type}))\n end",
"def as_json(options={})\n super(options.merge({:methods => :type}))\n end",
"def as_json(options={})\n super(options.merge({:methods => :type}))\n end",
"def get_field_deserializers()\n return super.merge({\n \"resourceId\" => lambda {|n| @resource_id = n.get_string_value() },\n \"resourceName\" => lambda {|n| @resource_name = n.get_string_value() },\n \"resourceType\" => lambda {|n| @resource_type = n.get_string_value() },\n })\n end",
"def get_field_deserializers()\n return {\n \"color\" => lambda {|n| @color = n.get_string_value() },\n \"criterion1\" => lambda {|n| @criterion1 = n.get_string_value() },\n \"criterion2\" => lambda {|n| @criterion2 = n.get_string_value() },\n \"dynamicCriteria\" => lambda {|n| @dynamic_criteria = n.get_string_value() },\n \"filterOn\" => lambda {|n| @filter_on = n.get_string_value() },\n \"icon\" => lambda {|n| @icon = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::WorkbookIcon.create_from_discriminator_value(pn) }) },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"operator\" => lambda {|n| @operator = n.get_string_value() },\n \"values\" => lambda {|n| @values = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::Json.create_from_discriminator_value(pn) }) },\n }\n end",
"def handle_field(type, name)\n @records ||= Hash.new\n @classname ||= self.to_s.to_sym\n @fields ||= Hash.new\n @fields[name] = type\n self.instance_variable_set(\"@#{name}\".to_sym, nil)\n if RGSS_TYPES.include?(type)\n accessor = Proc.new do\n instance_var = self.instance_variable_get(\"@#{name}\".to_sym)\n CommonDB.rgss_access(type, instance_var) if instance_var\n end\n self.send(:define_method, name.to_sym, &accessor)\n else\n self.send(:attr_reader, name.to_sym)\n end\n self.send(:attr_writer, name.to_sym)\n return name\n end",
"def get_field_deserializers()\n return {\n \"addLicenses\" => lambda {|n| @add_licenses = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::AssignedLicense.create_from_discriminator_value(pn) }) },\n \"removeLicenses\" => lambda {|n| @remove_licenses = n.get_collection_of_primitive_values(UUIDTools::UUID) },\n }\n end",
"def normalize_type(data, field)\n type_name = field[:type]\n result = case data\n when Array\n data.map {|item| normalize_item(type_name, item)}\n else\n normalize_item(type_name, data)\n end\n # If field signature allows an array, forcing array structure even for one\n # item.\n if !field[:min_occurs].nil? and\n (field[:max_occurs] == :unbounded ||\n (!field[:max_occurs].nil? and field[:max_occurs] > 1))\n result = arrayize(result)\n end\n return result\n end",
"def get_fields(type)\n @instrumented_field_map[type.graphql_name]\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"supportsDeviceLicensing\" => lambda {|n| @supports_device_licensing = n.get_boolean_value() },\n \"supportsUserLicensing\" => lambda {|n| @supports_user_licensing = n.get_boolean_value() },\n }\n end",
"def create_solr_core_mbean_bulkrequest_and_mbeantype_list(metric_type_to_solr_core_mbean_attr_map, collection_name)\n solr_core_mbean_bulk_request = ''\n metric_type_to_mbean_type_obj = Hash.new()\n metric_type_to_solr_core_mbean_attr_map.each do |metric_aggr_type, mbean_attr_map|\n metric_type_to_mbean_type_obj[metric_aggr_type] = Array.new()\n mbean_attr_map.each do |mbean_name, mbean_attributes|\n solr_mbean_name = get_solr_core_mbean_name(mbean_name, collection_name)\n mbean_attributes_string = attributes_to_str(mbean_attributes)\n mbean_type = get_solr_core_mbean_type(mbean_name)\n metric_type_to_mbean_type_obj[metric_aggr_type].push(mbean_type)\n solr_core_mbean_request = {\n \"type\" => \"read\",\n \"mbean\" => \"#{solr_mbean_name}\",\n \"attribute\" => \"#{mbean_attributes_string}\",\n \"target\" => {\n \"url\" => \"service:jmx:rmi:///jndi/rmi://127.0.0.1:#{@solr_jmx_port}/jmxrmi\"\n }\n }\n solr_core_mbean_bulk_request = solr_core_mbean_bulk_request + \",\" + solr_core_mbean_request.to_json\n end\n end\n solr_core_mbean_bulk_request = \"[\" + solr_core_mbean_bulk_request.slice(1, solr_core_mbean_bulk_request.length) + \"]\"\n return solr_core_mbean_bulk_request, metric_type_to_mbean_type_obj\n end",
"def get_fuel_types\n relatable_category_id = params[:car_calculator][:manufacture]\n result = CarApp.calculated_session.related_categories_from_relatable_category(relatable_category_id, \"fuel_type\") \n final_result = []\n result = result.each_pair do |key, value| \n final_result << {:name => value, :value => key}\n end\n render :json => {:options => final_result}.to_json\n end",
"def field_types_for name\n {\n text: text_fields.include?(name),\n html: html_fields.include?(name),\n atom: atom_fields.include?(name),\n datetime: datetime_fields.include?(name),\n number: number_fields.include?(name),\n geo: geo_fields.include?(name)\n }.delete_if { |_k, v| !v }.keys\n end",
"def get_field_deserializers()\n return {\n \"appliesTo\" => lambda {|n| @applies_to = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"provisioningStatus\" => lambda {|n| @provisioning_status = n.get_string_value() },\n \"servicePlanId\" => lambda {|n| @service_plan_id = n.get_guid_value() },\n \"servicePlanName\" => lambda {|n| @service_plan_name = n.get_string_value() },\n }\n end",
"def test_types\n # rec = SourceRecord.new\n source = make_dummy_source(\"http://www.newstuff.org/createtypes\", N::FOAFX.Person, N::FOAFX.Foe)\n assert_not_nil(source)\n assert_property(source.types, N::FOAFX.Person, N::FOAFX.Foe, source.rdf_selftype)\n end",
"def get_field_deserializers()\n return {\n \"buildNumber\" => lambda {|n| @build_number = n.get_string_value() },\n \"bundleId\" => lambda {|n| @bundle_id = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"versionNumber\" => lambda {|n| @version_number = n.get_string_value() },\n }\n end",
"def reltype_params\n params.require(:reltype).permit(:name, :color, :short)\n end",
"def get_field_deserializers()\n return {\n \"criteria1\" => lambda {|n| @criteria1 = n.get_string_value() },\n \"criteria2\" => lambda {|n| @criteria2 = n.get_string_value() },\n \"oper\" => lambda {|n| @oper = n.get_string_value() },\n }\n end",
"def encode_fields(*fields)\n fields.map do |type, value|\n case type\n when :raw\n value\n when :string\n encode_string(value)\n when :list\n encode_list(value)\n when :mpint\n encode_mpint(value)\n when :time\n encode_time(value)\n when :uint64\n encode_uint64(value)\n when :uint32\n encode_uint32(value)\n when :options\n encode_options(value)\n else\n raise DecodeError, \"bad type: #{type}\"\n end\n end.join\n end",
"def get_field_deserializers()\n return {\n \"costCenter\" => lambda {|n| @cost_center = n.get_string_value() },\n \"division\" => lambda {|n| @division = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end",
"def create_fields_of(data, category)\n data.each do |k, v|\n params = Field.class_name_for_type(v['type']).constantize.create_from_hash(k, v)\n params.merge!(category: category)\n field = Field.class_name_for_type(v['type']).constantize.create!(params)\n self.general_fields << field #NOTE Since we have already created the object, the category attribute will not change if we add it to the incorrect set of fields. Hence, just add all to general_fields\n end\n end",
"def field(name, type = :string)\n if @fields.nil?\n @fields = []\n field :rho__id, :string\n end \n type = type.to_sym\n type = :integer if type == :int\n \n class_name = marshal_class_name(name, type)\n \n fields << {:name => name.to_s, :type => type}\n if type == :string\n class_eval \"def #{name}; @#{name} ||= store.get_value(field_key('#{name}')); end\"\n class_eval \"def #{name}=(value); @#{name} = value.to_s; store.put_value(field_key('#{name}'), value.to_s); end\"\n else\n class_eval \"def #{name}; @#{name} ||= Marshal::#{class_name}.load(store.get_value(field_key('#{name}'))); end\"\n class_eval \"def #{name}=(value); @#{name} = value; store.put_value(field_key('#{name}'), Marshal::#{class_name}.dump(value)); end\"\n end\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"query\" => lambda {|n| @query = n.get_string_value() },\n \"queryType\" => lambda {|n| @query_type = n.get_enum_value(MicrosoftGraph::Models::SecurityQueryType) },\n }\n end",
"def listing_type_pivot\n ajax = {}\n # Clean incoming parameters\n listing_id = params[:listing_id].to_i\n listing_type_id = params[:listing_type_id].to_i\n primary_category_id = params[:primary_category_id].to_i\n primary_style_id = params[:primary_style_id].to_i\n \n # Fetch currently-checked listing type and associated data\n listing_type = ListingType.find(listing_type_id,\n# REMOVED: experimenting with joins\n# :joins => \"LEFT OUTER JOIN (`category_assignments`\" +\n# \" INNER JOIN `categories`\" +\n# \" ON `categories`.`id` = `category_assignments`.`category_id`)\" +\n# \" ON `category_assignments`.`category_assignable_type` = 'ListingType'\" +\n# \" AND `category_assignments`.`category_assignable_id` = `listing_types`.`id`\" +\n# \" LEFT OUTER JOIN (`style_assignments`\" +\n# \" INNER JOIN `styles`\" +\n# \" ON `styles`.`id` = `style_assignments`.`style_id`)\" +\n# \" ON `style_assignments`.`style_assignable_type` = 'ListingType'\" +\n# \" AND `style_assignments`.`style_assignable_id` = `listing_types`.`id`\" +\n# \" LEFT OUTER JOIN (`feature_assignments`\" +\n# \" INNER JOIN `features`\" +\n# \" ON `features`.`id` = `feature_assignments`.`feature_id`)\" +\n# \" ON `feature_assignments`.`feature_assignable_type` = 'ListingType'\" +\n# \" AND `feature_assignments`.`feature_assignable_id` = `listing_types`.`id`\",\n :include => [ :categories, :features, :styles ]\n )\n ajax[:categories] = listing_type.categories.map {\n |category| [category.name, category.id] }\n ajax[:styles] = listing_type.styles.map {\n |style| [style.name, style.id] }\n ajax[:features] = listing_type.features.map {\n |feature| [feature.name, feature.id] }\n \n # Default values to pass to javascript (prevent nils)\n ajax[:primary_category_id] = primary_category_id || ''\n ajax[:primary_style_id] = primary_style_id || ''\n ajax[:category_ids] = []\n ajax[:style_ids] = []\n ajax[:feature_ids] = []\n \n # If new record, get values from property that should be inherited\n if listing_id.zero?\n property = Property.find(params[:property_id])\n if primary_style_id.zero?\n ajax[:primary_style_id] = property.primary_style_id\n end\n ajax[:category_ids] = property.category_ids\n ajax[:style_ids] = property.style_ids\n ajax[:feature_ids] = property.feature_ids\n else\n listing = Listing.find(listing_id,\n :include => [ :primary_category, :primary_style, :categories,\n :styles, :features ]\n )\n # Use user-selected values if they exist, otherwise, use values looked up\n # from database\n if listing\n if primary_category_id.zero? && listing.primary_category\n ajax[:primary_category_id] = listing.primary_category.id\n end\n if primary_style_id.zero? && listing.primary_style\n ajax[:primary_style_id] = listing.primary_style.id\n end\n \n # Get selected values from database (discards user's changes on form)\n if listing.categories\n ajax[:category_ids] = listing.categories.map {\n |category| category.id }\n end\n if listing.styles\n ajax[:style_ids] = listing.styles.map { |style| style.id }\n end\n if listing.features\n ajax[:feature_ids] = listing.features.map { |feature| feature.id }\n end\n end\n end\n render :partial => 'listing_type_pivot',\n :layout => false,\n :locals => { :ajax => ajax }\n end",
"def create_types\n\t[Domain]\nend",
"def get_field_deserializers()\n return {\n \"externalId\" => lambda {|n| @external_id = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"teacherNumber\" => lambda {|n| @teacher_number = n.get_string_value() },\n }\n end",
"def data_source_type_params\n params.require(:data_source_type).permit(:type_name)\n end",
"def assemble_collection_specific\n # TODO custom field text_type_k\n end",
"def create_types_effectivenesses\n @types.each do |type|\n I18n.locale = :en\n type_record = Type.find_by(name: type['name_en'])\n create_type_effectivenesses(type, type_record) if type_record\n end\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"recommendedActions\" => lambda {|n| @recommended_actions = n.get_collection_of_object_values(lambda {|pn| MicrosoftGraph::Models::RecommendedAction.create_from_discriminator_value(pn) }) },\n \"resolvedTargetsCount\" => lambda {|n| @resolved_targets_count = n.get_number_value() },\n \"simulationEventsContent\" => lambda {|n| @simulation_events_content = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::SimulationEventsContent.create_from_discriminator_value(pn) }) },\n \"trainingEventsContent\" => lambda {|n| @training_events_content = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::TrainingEventsContent.create_from_discriminator_value(pn) }) },\n }\n end",
"def get_field_deserializers()\n return {\n \"accountName\" => lambda {|n| @account_name = n.get_string_value() },\n \"domainName\" => lambda {|n| @domain_name = n.get_string_value() },\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n }\n end",
"def cast_records!(*types, **options)\n where!(regclass.cast(:varchar).in(types.map(&:table_name))) if options[:filter]\n self.select_extra_values += [regclass.as(_record_class_attribute.to_s)]\n self.cast_records_value = (types.present? ? types : model.casted_dependents.values)\n self\n end",
"def enter_types(test_data)\n test_types = test_data[Org::ORG_RECORD_TYPES.name]\n test_types = [{ Org::ORG_RECORD_TYPE.name => ''}] unless test_types\n prep_fieldsets_for_test_data([fieldset(Org::ORG_RECORD_TYPES.name)], test_types)\n\n test_types.each_with_index do |test_type, index|\n wait_for_options_and_select(org_record_type_input(index), org_record_type_options(index), test_type[Org::ORG_RECORD_TYPE.name])\n end\n end",
"def get_product_count_types\n types = CountType.where(product_id: params[:product_id]).order(\"name ASC\").map { |type| [type.id, type.name] }\n render :json => types.to_json.to_s.to_json\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"v10_0\" => lambda {|n| @v10_0 = n.get_boolean_value() },\n \"v8_0\" => lambda {|n| @v8_0 = n.get_boolean_value() },\n \"v8_1\" => lambda {|n| @v8_1 = n.get_boolean_value() },\n }\n end",
"def get_field_deserializers()\n return {\n \"@odata.type\" => lambda {|n| @odata_type = n.get_string_value() },\n \"recurrence\" => lambda {|n| @recurrence = n.get_object_value(lambda {|pn| MicrosoftGraph::Models::PatternedRecurrence.create_from_discriminator_value(pn) }) },\n \"reportRange\" => lambda {|n| @report_range = n.get_string_value() },\n }\n end"
] |
[
"0.56644815",
"0.5489921",
"0.54534537",
"0.5450834",
"0.54328495",
"0.53692836",
"0.5260073",
"0.5241032",
"0.5222839",
"0.5208282",
"0.5194803",
"0.51610243",
"0.513126",
"0.5117086",
"0.50895536",
"0.5083326",
"0.5080772",
"0.50585425",
"0.5018466",
"0.4976705",
"0.49560672",
"0.49556622",
"0.49482942",
"0.49356243",
"0.4929288",
"0.49210224",
"0.4911841",
"0.48837247",
"0.48802572",
"0.48797163",
"0.48734948",
"0.4867324",
"0.48669595",
"0.48644853",
"0.48612517",
"0.48601967",
"0.48570445",
"0.48559788",
"0.4832312",
"0.48305544",
"0.4824164",
"0.48197612",
"0.4808347",
"0.4806181",
"0.4802642",
"0.47923717",
"0.47923717",
"0.47921363",
"0.47921363",
"0.47915217",
"0.4779528",
"0.47794113",
"0.47769743",
"0.47723082",
"0.4764772",
"0.47566447",
"0.4731688",
"0.47206676",
"0.47176525",
"0.46914437",
"0.4691321",
"0.46879423",
"0.4686262",
"0.46850386",
"0.4679282",
"0.4679282",
"0.4679282",
"0.46747905",
"0.46654537",
"0.46614194",
"0.46567956",
"0.46541473",
"0.4652528",
"0.464508",
"0.46432394",
"0.46399254",
"0.46385342",
"0.46360382",
"0.46307632",
"0.46303946",
"0.4630232",
"0.46228468",
"0.46193454",
"0.46163493",
"0.4616266",
"0.4612674",
"0.46119487",
"0.4607149",
"0.4606502",
"0.4605633",
"0.4597681",
"0.45969504",
"0.45904332",
"0.45900172",
"0.45888084",
"0.45811772",
"0.45782202",
"0.45759344",
"0.4571755",
"0.45700374"
] |
0.5658422
|
1
|
PUT /resouresource_type_reference_idrce_types/1 PUT /resource_types/1.json
|
def update
respond_to do |format|
if @resource_type.update_attributes(params[:resource_type])
if params[:fields]
params[:fields].each do |param|
if param[:id]
@field = Field.find(param[:id])
@field.update_attributes(
:name => param[:name],
:field_type_id => param[:field_type_id],
:resource_type_id => params[:id],
:resource_type_reference_id => param[:resource_type_reference_id]
)
else
@field = Field.create(
:name => param[:name],
:field_type_id => param[:field_type_id],
:resource_type_id => params[:id],
:resource_type_reference_id => param[:resource_type_reference_id]
)
end
if @field.field_validations.any?
@field.field_validations.each { |v| v.destroy }
end
if param[:validator_ids]
param[:validator_ids].each do |index|
next if index == "multiselect-all"
@field.field_validations.build(validator_id: index.to_i)
end
end
@field.save
end
end
format.html { redirect_to @resource_type, notice: 'Resource type was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @resource_type.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_resourcetype\n @resourcetype = Resourcetype.find(params[:id])\n end",
"def set_resource_type\n @resource_type = ResourceType.find(resource_type_params[:id])\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def resource_type=(value)\n @resource_type = value\n end",
"def resource_type_params\n params.require(:resource_type).permit(:id, :resource_type_general, :resource_type, :resource_id)\n end",
"def update!(**args)\n @resource_type = args[:resource_type] if args.key?(:resource_type)\n end",
"def update\n respond_to do |format|\n if @reference_type.update_attributes(params[:reference_type])\n flash[:notice] = 'Reference type was successfully updated.'\n @changed << @reference_type.id\n\n format.html { redirect_to reference_types_path }\n format.js { render 'shared/index'; flash.discard }\n format.json { head :no_content }\n else\n @edited << @reference_type.id\n @expanded << @reference_type.id\n\n format.html { render action: 'edit', template: 'shared/edit' }\n format.js { render 'reference_type' }\n format.json { render json: @reference_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(name, type, options = {})\n Utils.stringify_keys!(options)\n path = \"/projects/#{project.name}/resources/#{name}\"\n\n headers = build_create_base_headers(name, type, options)\n body = build_create_base_body(options)\n\n !!client.put(path, headers: headers, body: body)\n end",
"def map_resource_type(resource_types, node)\n if resource_types.empty?\n if node.is_a?(IFile)\n return {\n 'string' => 'File',\n 'icon' => 'file'\n }\n else\n return {\n 'string' => 'Unknown',\n 'icon' => 'cog'\n }\n end\n end\n\n types = {\n '{http://calendarserver.org/ns/}calendar-proxy-write' => {\n 'string' => 'Proxy-Write',\n 'icon' => 'people'\n },\n '{http://calendarserver.org/ns/}calendar-proxy-read' => {\n 'string' => 'Proxy-Read',\n 'icon' => 'people'\n },\n '{urn:ietf:params:xml:ns:caldav}schedule-outbox' => {\n 'string' => 'Outbox',\n 'icon' => 'inbox'\n },\n '{urn:ietf:params:xml:ns:caldav}schedule-inbox' => {\n 'string' => 'Inbox',\n 'icon' => 'inbox'\n },\n '{urn:ietf:params:xml:ns:caldav}calendar' => {\n 'string' => 'Calendar',\n 'icon' => 'calendar'\n },\n '{http://calendarserver.org/ns/}shared-owner' => {\n 'string' => 'Shared',\n 'icon' => 'calendar'\n },\n '{http://calendarserver.org/ns/}subscribed' => {\n 'string' => 'Subscription',\n 'icon' => 'calendar'\n },\n '{urn:ietf:params:xml:ns:carddav}directory' => {\n 'string' => 'Directory',\n 'icon' => 'globe'\n },\n '{urn:ietf:params:xml:ns:carddav}addressbook' => {\n 'string' => 'Address book',\n 'icon' => 'book'\n },\n '{DAV:}principal' => {\n 'string' => 'Principal',\n 'icon' => 'person'\n },\n '{DAV:}collection' => {\n 'string' => 'Collection',\n 'icon' => 'folder'\n }\n }\n\n info = {\n 'string' => [],\n 'icon' => 'cog'\n }\n\n resource_types.each do |resource_type|\n if types.key?(resource_type)\n info['string'] << types[resource_type]['string']\n else\n info['string'] << resource_type\n end\n end\n\n types.each do |key, resource_info|\n if resource_types.include?(key)\n info['icon'] = resource_info['icon']\n break\n end\n end\n\n info['string'] = info['string'].join(', ')\n\n info\n end",
"def set_resquest_type\n @resquest_type = ResquestType.find(params[:id])\n end",
"def update\n @crate_type = CrateType.find(params[:id])\n\n respond_to do |format|\n if @crate_type.update_attributes(params[:crate_type])\n format.html { redirect_to @crate_type, :notice => 'Crate type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @crate_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def resource_type_params\n params.require(:resource_type).permit(:name)\n end",
"def resource_type\n document_type\n end",
"def resource_type\n document_type\n end",
"def update\n @client_type = ClientType.find(params[:id])\n\n respond_to do |format|\n if @client_type.update_attributes(params[:client_type])\n format.html { redirect_to @client_type, notice: 'Client type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @resource = Resource.find(params[:id])\n\n @resource.assetable_id = 1\n @resource.assetable_type = 'User'\n\n if image_types.include? params[:resource][:data].content_type\n @resource.type = 'Ckeditor::Picture'\n else\n @resource.type = 'Ckeditor::AttachmentFile'\n end\n\n respond_to do |format|\n if @resource.update_attributes(params[:resource])\n format.html { redirect_to admin_resources_path, notice: 'Resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def update\n @client_asset = ClientAsset.find(params[:id])\n if params[:client_asset][:referenceable_type] == \"Asset\"\n # Fetch asset from Asset model\n elsif params[:client_asset][:referenceable_type] == \"Device\"\n @client_asset.referenceable_id = params[:device_id]\n elsif params[:client_asset][:referenceable_type] == \"Computer\"\n @client_asset.referenceable_id = params[:computer_id]\n end\n \n respond_to do |format|\n if @client_asset.update_attributes(params[:client_asset])\n format.html { redirect_to @client_asset, notice: \"#{@client_asset.client_name}'s asset was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_asset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize :resquest_type, :update?\n respond_to do |format|\n if @resquest_type.update(resquest_type_params)\n format.html { redirect_to @resquest_type, notice: 'Resquest type was successfully updated.' }\n format.json { render :show, status: :ok, location: @resquest_type }\n else\n format.html { render :edit }\n format.json { render json: @resquest_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def change_type_of_issue(issue_name, new_type_id)\n\tissue = @client.Issue.find(issue_name)\n\tissue.save({\"fields\"=>{\"issuetype\"=>{\"id\"=>new_type_id}}})\nend",
"def edit\n\n @resource = Resource.find(params[:id])\n @resource.type = 'Resource'\n @type = 'file' if params[:type] == 'file'\n\n end",
"def update\n @reform_type = ReformType.find(params[:id])\n\n respond_to do |format|\n if @reform_type.update_attributes(params[:reform_type])\n format.html { redirect_to @reform_type, notice: 'Reform type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reform_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @reference_type.save\n flash[:notice] = 'Reference type was successfully created.'\n @changed << @reference_type.id\n \n format.html { redirect_to reference_types_path }\n format.js { render 'shared/index'; flash.discard }\n format.json { render json: @reference_type, status: :created, location: @reference_type }\n else\n @edited << 'new'\n @expanded << 'new'\n\n format.html { render action: 'new', template: 'shared/new' }\n format.js { render 'reference_type' }\n format.json { render json: @reference_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def remap_resource_type\n return unless is_a?(Bulkrax::CsvFileSetEntry)\n\n parsed_metadata.delete('resourceType_attributes')\n parsed_metadata['resource_type'] = raw_metadata['resourcetype']&.split(/\\s*[|]\\s*/)\n end",
"def update\n @collection = @entity_type.collection\n respond_to do |format|\n if @entity_type.update(entity_type_params)\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'The entity type was successfully updated.' }\n format.json { render :show, status: :ok, location: @entity_type }\n else\n format.html { render :edit }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def type\n ::HubEdos::Common::Reference::Descriptor.new(@data['type']) if @data['type']\n end",
"def type\n ::HubEdos::Common::Reference::Descriptor.new(@data['type']) if @data['type']\n end",
"def type\n ::HubEdos::Common::Reference::Descriptor.new(@data['type']) if @data['type']\n end",
"def type\n ::HubEdos::Common::Reference::Descriptor.new(@data['type']) if @data['type']\n end",
"def type\n ::HubEdos::Common::Reference::Descriptor.new(@data['type']) if @data['type']\n end",
"def update\n if @client_type.update(client_type_params)\n render :show, status: :ok, location: @client_type\n else\n render json: @client_type.errors, status: :unprocessable_entity\n end\n end",
"def set_client_type\n @client_type = ClientType.find(params[:id])\n end",
"def update\n @type.update(type_params)\n end",
"def resource_type\n \"b\"\n end",
"def resource_type\n\t\t\t\t\t\traise \"Not implemented.\"\n\t\t\t\t\tend",
"def set_type_client\n @type_client = TypeClient.find(params[:id])\n end",
"def update(resource_type_identifier, mixins)\n raise Occi::Api::Client::Errors::NotImplementedError, \"#{__method__} is just a stub!\"\n end",
"def update\n @breadcrumb = 'update'\n @contracting_request_document_type = ContractingRequestDocumentType.find(params[:id])\n @contracting_request_document_type.updated_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @contracting_request_document_type.update_attributes(params[:contracting_request_document_type])\n format.html { redirect_to @contracting_request_document_type,\n notice: (crud_notice('updated', @contracting_request_document_type) + \"#{undo_link(@contracting_request_document_type)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contracting_request_document_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @entry_type = EntryType.find(params[:id])\n\n respond_to do |format|\n field_type_ids = params[:entry_type].delete(\"field_type_ids\")\n @entry_type.field_type_ids = field_type_ids if field_type_ids\n params[:entry_type].delete(\"form_code\")\n if @entry_type.update_attributes(params[:entry_type])\n format.html { redirect_to @entry_type, notice: 'Entry type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entry_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_resource_type(feed_id, type_id, type_name)\n the_feed = hawk_escape_id feed_id\n\n type = create_blueprint\n type[:id] = type_id\n type[:name] = type_name\n\n begin\n http_post(\"/feeds/#{the_feed}/resourceTypes\", type)\n rescue HawkularException => error\n # 409 We already exist -> that is ok\n raise unless error.status_code == 409\n ensure\n the_type = hawk_escape_id type_id\n res = http_get(\"/feeds/#{the_feed}/resourceTypes/#{the_type}\")\n end\n ResourceType.new(res)\n end",
"def update\n respond_to do |format|\n if @intervention_type.update(intervention_type_params)\n format.html { redirect_to intervention_types_path, notice: 'O tipo de intervenção foi actualizado.' }\n format.json { render :show, status: :ok, location: @intervention_type }\n else\n format.html { render :edit }\n format.json { render json: @intervention_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@resource_type = ResourceType.new(resource_type_params)\n\n\t\tif @resource_type.save\n\t\t\trender \"show\", :status => :created\n\t\telse\n\t\t\tinvalid_response(@resource_type)\n\t\tend\t\t\n\tend",
"def change_type\n\t\t\trender json: User.update_type_by_id(params[:id], params[:type], params[:is])\n\t\tend",
"def get_resource_type()\n return RedXmlResource::TYPE\n end",
"def set_content_type old_type, old_resource_type, new_type, new_resource_type\n xml=self.ng_xml\n xml.search('/contentMetadata[@type=\\''+old_type+'\\']').each do |node|\n node['type']=new_type\n xml.search('//resource[@type=\\''+old_resource_type+'\\']').each do |resource|\n resource['type']=new_resource_type\n end\n end\n self.content=xml.to_s\n end",
"def type(type = nil)\n @type = type if type\n @type || name.split('::').last.gsub(/Resource$/, '').underscore\n end",
"def get_resource_type_identifier(type)\n get_type_identifier(type, Occi::Core::Resource.kind)\n end",
"def update\n @incident_type = IncidentType.find(params[:id])\n\n respond_to do |format|\n if @incident_type.update_attributes(params[:incident_type])\n format.html { redirect_to @incident_type, notice: 'Incident type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @incident_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @resource_id = args[:resource_id] if args.key?(:resource_id)\n @resource_type = args[:resource_type] if args.key?(:resource_type)\n end",
"def update\n @collection = current_user.collections.find(params[:collection_id])\n @entity_type = @collection.entity_types.find(params[:id])\n \n if session[:edit_referrer].nil? \n success_path = collection_entity_types_path(@collection)\n else\n success_path = session[:edit_referrer]\n session[:edit_referrer] = nil\n end\n \n respond_to do |format|\n if @entity_type.update_attributes(params[:entity_type])\n format.html { redirect_to success_path, notice: 'Type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @resource.update(resource_params)\n format.html { redirect_to polymorphic_path(complex_namespace_helper + [@resource]), notice: \"#{@resource_class} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_document_all_types client, s, types\n log.debug \"Will update document #{s} for types #{types}\"\n\n if types\n types.each do |type|\n log.debug \"Updating document #{s} for type #{type}\"\n indexes = Indexes.instance.get_indexes type\n indexes.each do |key, index|\n allowed_groups = index[:allowed_groups]\n log.debug \"Got allowed groups for updated_document_all_types #{allowed_groups}\"\n rdf_type = settings.type_definitions[type][\"rdf_type\"]\n log.debug \"Got RDF type for updated_document_all_types #{rdf_type}\"\n if is_authorized s, rdf_type, allowed_groups\n log.debug \"Our current index knows that #{s} is of type #{rdf_type} based on allowed groups #{allowed_groups}\"\n properties = settings.type_definitions[type][\"properties\"]\n document, attachment_pipeline =\n fetch_document_to_index uri: s, properties: properties,\n allowed_groups: index[:allowed_groups]\n\n document_for_reporting = document.clone\n document_for_reporting[\"data\"] = document_for_reporting[\"data\"] ? document_for_reporting[\"data\"].length : \"none\"\n\n log.debug \"Fetched document to index is #{document_for_reporting}\"\n\n # TODO what is uuid supposed to be here? We abstract its meaning to be get_uuid(s) but are not sure\n uuid = get_uuid(s)\n\n if attachment_pipeline\n log.debug \"Document to update has attachment pipeline\"\n begin\n # client.upload_attachment index, uuid, attachment_pipeline, document\n client.upload_attachment index[:index], uuid, attachment_pipeline, document\n log.debug \"Managed to upload attachment for #{s}\"\n rescue\n log.warn \"Could not upload attachment #{s}\"\n begin\n log.debug \"Trying to update document with id #{uuid}\"\n client.update_document index[:index], uuid, document\n log.debug \"Succeeded in updating document with id #{uuid}\"\n rescue\n log.debug \"Failed to update document, trying to put new document #{uuid}\"\n client.put_document index[:index], uuid, document\n log.debug \"Succeeded in putting new document #{uuid}\"\n end\n end\n else\n begin\n log.debug \"Trying to update document with id #{uuid}\"\n client.update_document index[:index], uuid, document\n log.debug \"Succeeded in updating document with id #{uuid}\"\n rescue\n log.debug \"Failed to update document, trying to put new document #{uuid}\"\n client.put_document index[:index], uuid, document\n log.debug \"Succeeded in putting new document #{uuid}\"\n end\n end\n else\n log.info \"Not Authorized.\"\n end\n end\n end\n end\nend",
"def resourcetype_params\n\t\t params.require(:resourcetype).permit(:name, :regenerating, :location)\n end",
"def set_client_type\n @client_type = ClientType.find(params[:id])\n end",
"def set_client_type\n @client_type = ClientType.find(params[:id])\n end",
"def update_type\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\t#LOG.debug(fname){\"params=#{params.inspect}\"}\n\t\t@relation = Relation.find(params[:id])\n\t\t@types = Typesobject.get_types(\"relation\")\n\t\t@status = Statusobject.get_status(\"relation\")\n\t\tctrl_update_type @relation, params[:object_type]\n\tend",
"def update!(**args)\n @resource_type = args[:resource_type] if args.key?(:resource_type)\n @resource_url = args[:resource_url] if args.key?(:resource_url)\n end",
"def update!(**args)\n @resource_type = args[:resource_type] if args.key?(:resource_type)\n @resource_url = args[:resource_url] if args.key?(:resource_url)\n end",
"def new\n @resource = Resource.new\n @resource_types=ResourceType.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def update\n respond_to do |format|\n if @incident_type.update(incident_type_params)\n format.html { redirect_to admin_incident_types_path, notice: 'Incident type was successfully updated.' }\n format.json { render :show, status: :ok, location: @incident_type }\n else\n format.html { render :edit }\n format.json { render json: @incident_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @roof_type.update(roof_type_params)\n format.html { redirect_to roof_types_path, notice: 'Roof type was successfully updated.' }\n format.json { render :show, status: :ok, location: @roof_type }\n else\n format.html { render :edit }\n format.json { render json: @roof_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def reference_type=(value)\n write_attribute(:reference_type, value) unless value.blank?\n end",
"def update\n @contractor_type = ContractorType.find(params[:id])\n\n respond_to do |format|\n if @contractor_type.update_attributes(params[:contractor_type])\n format.html { redirect_to @contractor_type, notice: 'Contractor type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contractor_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_types\n\t[]\nend",
"def update_types\n\t[]\nend",
"def update\n\n raw = params[:sample_type]\n st = SampleType.find(raw[:id])\n\n st.name = raw[:name]\n st.description = raw[:description]\n st.save\n st.save_field_types raw[:field_types]\n\n render json: { sample_type: st }\n\n end",
"def update_resource(type, title, parameters = {})\n resource = catalog.resource type, title\n unless resource\n debug \"#{type}[#{title}]: was not found in the catalog!\"\n return false\n end\n parameters.each do |parameter, value|\n if [:notify, :require, :before, :subscribe].include? parameter.to_sym\n current_values = resource[parameter] || []\n resource[parameter] = current_values << value\n else\n resource[parameter] = value\n end\n end\n resource\n end",
"def create\n @resource = Resource.new(params[:resource])\n\n @resource.assetable_id = 1\n @resource.assetable_type = 'User'\n\n if params[:resource]\n if image_types.include? params[:resource][:data].content_type\n @resource.type = 'Ckeditor::Picture'\n else\n @resource.type = 'Ckeditor::AttachmentFile'\n end\n end\n\n respond_to do |format|\n \n if @resource.save\n \n #Checking resource type for image or file and redirecting as per the lists with conditions\n if @resource.is_type_image? \n redirect_path = admin_resources_path(:type => 'image')\n else\n redirect_path = admin_resources_path(:type => 'file')\n end\n\n format.html { redirect_to redirect_path, notice: 'Resource was successfully uploaded.' }\n else\n format.html { render action: \"new\", :type => @type }\n end\n end\n end",
"def update\n respond_to do |format|\n if @acquired_type.update(acquired_type_params)\n format.html { redirect_to @acquired_type, notice: 'Acquired type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @acquired_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def update\n respond_to do |format|\n if @reltype.update(reltype_params)\n format.html { redirect_to @reltype, notice: 'Reltype was successfully updated.' }\n format.json { render :show, status: :ok, location: @reltype }\n else\n format.html { render :edit }\n format.json { render json: @reltype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n status_unsupported_media_type && return unless content_type_header?\n\n # Parse in the FHIR::Patient\n contents = FHIR.from_contents(request.body.string)\n status_bad_request && return if contents.nil? || !contents.valid?\n\n resource_type = params.permit(:resource_type)[:resource_type]&.downcase\n case resource_type\n when 'patient'\n updates = Patient.from_fhir(contents).select { |_k, v| v.present? }\n resource = get_patient(params.permit(:id)[:id])\n else\n status_bad_request && return\n end\n\n status_forbidden && return if resource.nil?\n\n # Try to update the resource\n status_bad_request && return if updates.nil? || !resource.update(updates)\n\n status_ok(resource.as_fhir) && return\n rescue StandardError\n render json: operation_outcome_fatal.to_json, status: :internal_server_error\n end",
"def update\n @ref_diagnostic_test_type = Ref::DiagnosticTestType.find(params[:id])\n\n respond_to do |format|\n if @ref_diagnostic_test_type.update_attributes(params[:ref_diagnostic_test_type])\n format.html { redirect_to ref_diagnostic_test_types_path, notice: I18n.t(:record_updated) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ref_diagnostic_test_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contract_type = ContractType.find(params[:id])\n\n respond_to do |format|\n if @contract_type.update_attributes(params[:contract_type])\n format.html { redirect_to @contract_type, notice: 'Contract type was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contract_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @doc_type.update(doc_type_params)\n format.html { redirect_to @doc_type, notice: t('message.template.scaffold.update', model: t('activerecord.models.doc_type')) }\n format.json { render :show, status: :ok, location: @doc_type }\n else\n format.html { render :edit }\n format.json { render json: @doc_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_incident_type\n @incident_type = IncidentType.find(params[:id])\n end",
"def set_type\n @type = Type.find(params[:id])\n end",
"def update\n if @car_type.update(car_type_params)\n respond_with(@car_type, location: car_types_url, notice: 'Car type was successfully updated.')\n else\n respond_with(@car_type)\n end\n end",
"def set_type\n @type = IngredientType.find(params[:id])\n end",
"def set_typeconge\n @typeconge = Typeconge.find(params[:id])\n end",
"def update\n @rtype = Rtype.find(params[:id])\n\n respond_to do |format|\n if @rtype.update_attributes(params[:rtype])\n flash[:notice] = 'Rtype was successfully updated.'\n format.html { redirect_to(@rtype) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @rtype.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @resource_type = ResourceType.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource_type }\n end\n end",
"def show\n @resource_type = @resource.resource_type\n @values = ResourceValue.where(\"resource_id = ?\", params[:id])\n @field_types = []\n @values.each do |value|\n if value.field.resource_type_reference_id\n @field_types << Resource.find(value.resource_reference_id).resource_type\n else\n @field_types << value.field.field_type\n end\n end \n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @resource }\n end\n end",
"def update\n @realty_type = RealtyType.find(params[:id])\n\n respond_to do |format|\n if @realty_type.update_attributes(params[:realty_type])\n format.html { redirect_to @realty_type, notice: 'Realty type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @realty_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_types\n\t\t[]\n\tend",
"def update_types\n\t\t[]\n\tend",
"def get_resource_type(type, resource_path)\n changed_path = resource_path.split('/').last\n if type.eql?('singular')\n changed_path.singularize.to_sym\n else\n changed_path.to_sym\n end\n end",
"def set_type\n raise Error::NotFoundError unless (@type = Type.find(params[:id]))\n end",
"def set_roof_type\n @roof_type = RoofType.find(params[:id])\n end",
"def update\n \n\tbegin\n\t\t@coupon_type = CouponType.find(params[:id])\n\n\trescue Mongoid::Errors::DocumentNotFound\n\t\treturn\n\telse\t\n\t\trespond_to do |format|\n\t\t\tif @coupon_type.update_attributes(params[:coupon_type])\n\t\t\t\tformat.html { redirect_to @coupon_type, notice: 'Coupon Type Successfully Updated.' }\n\t\t\t\t#format.json { head :no_content }\n\t\t\t\tformat.json { render :json => \"Coupon Type Successfully Updated.\\n\" + @coupon_type.to_a.to_json, status: 600, location: @coupon_type }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"edit\" }\n\t\t\t\t#format.json { render json: @coupon_type.errors, status: :unprocessable_entity }\n\t\t\t\tformat.json { render :json => \"Coupon Type Not Updated.\\n\", status: 602 }\n\t\t\tend\n\t\tend\n\tend\n\t\n end",
"def update\n @customer = Customer.find(params[:id])\n @customer_types = CustomerType.find(params[:customer_type_id])\n @customer_types.customer_type= params[:customer_type]\n @customer_types.customer_type_name= params[:customer_type_name]\n @customer_types.zip_number= params[:zip_number]\n @customer_types.prefecture_cd= params[:prefecture_cd]\n @customer_types.city= params[:city]\n @customer_types.oaza= params[:oaza]\n @customer_types.town= params[:town]\n @customer_types.building_name= params[:building_name]\n @customer_types.customer_type_memo= params[:customer_type_memo]\n\n @customer.customer_types << @customer_types\n\n respond_to do |format|\n if @customer.update_attributes(params[:customer])\n format.html { redirect_to @customer, notice: 'Customer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @customer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def ref_types\n response = request(:eve, :ref_types)\n result = {}\n response.ref_types.each do |row|\n result[row.ref_type_id] = row.ref_type_name\n end\n result\n end",
"def create\n @resource_type = ResourceType.new(params[:resource_type])\n respond_to do |format|\n if @resource_type.save\n if params[:fields]\n params[:fields].each do |param|\n @field = Field.new(\n :name => param[:name], \n :field_type_id => param[:field_type_id],\n :resource_type_id => @resource_type.id, \n :resource_type_reference_id => param[:resource_type_reference_id]\n )\n param[:validator_ids].each do |index|\n @field.field_validations.build(validator_id: index)\n end\n @field.save\n end\n end\n format.html { redirect_to @resource_type, notice: 'Resource type was successfully created.' }\n format.json { render json: @resource_type, status: :created, location: @resource_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @resource_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def resource_type\n return @resource_type\n end",
"def update\n respond_to do |format|\n if @recipe_type.update(recipe_type_params)\n format.html { redirect_to @recipe_type, notice: \"Recipe type was successfully updated.\" }\n format.json { render :show, status: :ok, location: @recipe_type }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @recipe_type.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.66288024",
"0.659765",
"0.6444448",
"0.6444448",
"0.6444448",
"0.6444448",
"0.62002903",
"0.6195512",
"0.6046237",
"0.5994548",
"0.59595627",
"0.5855925",
"0.5822086",
"0.58165985",
"0.57949823",
"0.57949823",
"0.5765026",
"0.57434666",
"0.5717103",
"0.5716621",
"0.5716172",
"0.56882155",
"0.5657761",
"0.56354344",
"0.5623132",
"0.5616094",
"0.56084645",
"0.5606847",
"0.5606847",
"0.5606847",
"0.5606847",
"0.5605872",
"0.55974513",
"0.5592105",
"0.5570344",
"0.5566898",
"0.5564503",
"0.55539465",
"0.5545234",
"0.5530386",
"0.5527772",
"0.5527661",
"0.55245644",
"0.55180705",
"0.5502228",
"0.54937005",
"0.5475475",
"0.5471096",
"0.5464",
"0.54638183",
"0.5463157",
"0.54581505",
"0.5457444",
"0.54491955",
"0.5447136",
"0.5447136",
"0.5446414",
"0.54426503",
"0.54426503",
"0.54285",
"0.5427227",
"0.5426098",
"0.5423093",
"0.5421948",
"0.54212654",
"0.54212654",
"0.5403266",
"0.54028255",
"0.54012305",
"0.53993016",
"0.53984565",
"0.5396405",
"0.5391235",
"0.5384393",
"0.5380272",
"0.5376572",
"0.53747755",
"0.53742987",
"0.5361646",
"0.53616166",
"0.53602153",
"0.53590447",
"0.5355979",
"0.53554237",
"0.53554004",
"0.5353106",
"0.5353106",
"0.53526133",
"0.53513265",
"0.5348615",
"0.53466094",
"0.53446156",
"0.5343262",
"0.5338097",
"0.5335678",
"0.5334431",
"0.5334431",
"0.5334431",
"0.5334431",
"0.53337777"
] |
0.592635
|
11
|
DELETE /resource_types/1 DELETE /resource_types/1.json
|
def destroy
begin
if @resource_type.destroy
respond_to do |format|
format.html { redirect_to resource_types_url }
format.json { head :no_content }
end
end
rescue
respond_to do |format|
format.html { redirect_to "index", notice: "Resource_type cann't delete." }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def delete_resource(type, id, data = {})\n model = fetch_generic_object_definition(type, id, data)\n delete_resource_main_action(type, model, data)\n model\n rescue => err\n raise BadRequestError, \"Deleting #{model_ident(model, type)} - #{err}\"\n end",
"def destroy\n authorize :resquest_type, :destroy?\n @resquest_type.destroy\n respond_to do |format|\n format.html { redirect_to resquest_types_url, notice: 'Resquest type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(resource_type,identifier)\n path = '/api/' + resource_type.to_s + '/' + slugify(identifier)\n http_delete(path)\n end",
"def destroy\n @type = Type.find(params[:id])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n asset_type = AssetType.find(params[:id])\n asset_type.destroy\n\n respond_to do |format|\n format.html { redirect_to asset_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @realty_type = RealtyType.find(params[:id])\n @realty_type.destroy\n\n respond_to do |format|\n format.html { redirect_to realty_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident_type = IncidentType.find(params[:id])\n @incident_type.destroy\n\n respond_to do |format|\n format.html { redirect_to incident_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type = Type.find(params[:type])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to company_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reform_type = ReformType.find(params[:id])\n @reform_type.destroy\n\n respond_to do |format|\n format.html { redirect_to reform_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crate_type = CrateType.find(params[:id])\n @crate_type.destroy\n\n respond_to do |format|\n format.html { redirect_to crate_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @api_v1_resource.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_resources_url, notice: 'Resource was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_admin_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_admin_types_url, notice: 'Admin type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gl_type = GlType.find(params[:id])\n @gl_type.destroy\n\n respond_to do |format|\n format.html { redirect_to gl_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rtype = Rtype.find(params[:id])\n @rtype.destroy\n\n respond_to do |format|\n format.html { redirect_to(rtypes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dishtype.destroy\n respond_to do |format|\n format.html { redirect_to dishtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @route_type.destroy\n respond_to do |format|\n format.html { redirect_to route_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @girltype = Girltype.find(params[:id])\n @girltype.destroy\n\n respond_to do |format|\n format.html { redirect_to girltypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entity_type = EntityType.find(params[:id])\n \n respond_to do |format|\n if @entity_type.destroy\n format.html { redirect_to entity_types_url,\n notice: (crud_notice('destroyed', @entity_type) + \"#{undo_link(@entity_type)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { redirect_to entity_types_url, alert: \"#{@entity_type.errors[:base].to_s}\".gsub('[\"', '').gsub('\"]', '') }\n format.json { render json: @entity_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @segment_type = SegmentType.find(params[:id])\n @segment_type.destroy\n\n respond_to do |format|\n format.html { redirect_to segment_types_url }\n format.json { head :no_content }\n end\n end",
"def delete_resource_action(type, id = nil, data = nil)\n api_resource(type, id, \"Detaching\") do |resource|\n delete_resource_main_action(type, resource, data)\n end\n end",
"def destroy\n @jewelry_type = JewelryType.find(params[:id])\n @jewelry_type.destroy\n\n respond_to do |format|\n format.html { redirect_to jewelry_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @realty_type = RealtyType.find(params[:id])\n @realty_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(realty_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @instance_type.destroy\n respond_to do |format|\n format.html { redirect_to instance_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collection_type = CollectionType.find(params[:id])\n @collection_type.destroy\n\n respond_to do |format|\n format.html { redirect_to collection_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sample_type = SampleType.find(params[:id])\n @sample_type.destroy\n\n respond_to do |format|\n format.html { redirect_to sample_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @identifier_type.destroy\n\n respond_to do |format|\n format.html { redirect_to identifier_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @os_type = OsType.find(params[:id])\n @os_type.destroy\n\n respond_to do |format|\n format.html { redirect_to os_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_user_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_user_types_url, notice: 'User type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @claim_type.destroy\n respond_to do |format|\n format.html { redirect_to claim_types_url, notice: 'Claim type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry_type = EntryType.find(params[:id])\n @entry_type.destroy\n\n respond_to do |format|\n format.html { redirect_to entry_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incident_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_incident_types_path, notice: 'Incident type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @affected_type.destroy\n respond_to do |format|\n format.html { redirect_to affected_types_url, notice: 'Affected type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fieldtype = Fieldtype.find(params[:id])\n @fieldtype.destroy\n\n respond_to do |format|\n format.html { redirect_to fieldtypes_url }\n format.json { head :no_content }\n end\n end",
"def delete_resource!(type, name, run_context: self.run_context)\n run_context.resource_collection.delete(\"#{type}[#{name}]\").tap do |resource|\n # Purge any pending notifications too. This will not raise an exception\n # if there are no notifications.\n if resource\n run_context.before_notification_collection.delete(resource.declared_key)\n run_context.immediate_notification_collection.delete(resource.declared_key)\n run_context.delayed_notification_collection.delete(resource.declared_key)\n end\n end\n end",
"def destroy\n @question_type = QuestionType.find(params[:id])\n @question_type.destroy\n\n respond_to do |format|\n format.html { redirect_to question_types_url }\n format.json { head :no_content }\n end\n end",
"def delete_resource(type, name, run_context: self.run_context)\n delete_resource!(type, name, run_context: run_context)\n rescue Chef::Exceptions::ResourceNotFound\n nil\n end",
"def delete(resource_type_identifier)\n # convert type to type identifier\n raise \"Endpoint is not connected!\" unless @connected\n\n path = path_for_resource_type resource_type_identifier\n\n del path\n end",
"def destroy\n @instance_type = InstanceType.find(params[:id])\n @instance_type.destroy\n\n respond_to do |format|\n format.html { redirect_to instance_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_type.destroy\n respond_to do |format|\n format.html { redirect_to item_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe_type.destroy\n respond_to do |format|\n format.html { redirect_to recipe_types_url, notice: \"Recipe type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @awon_record_type.destroy\n respond_to do |format|\n format.html { redirect_to awon_record_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collection = @entity_type.collection\n @entity_type.destroy\n respond_to do |format|\n format.html { redirect_to collection_entity_types_path(@collection), notice: 'The entity type was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe_type = RecipeType.find(params[:id])\n @recipe_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(recipe_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @arc_type.destroy\n respond_to do |format|\n format.html { redirect_to arc_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reltype.destroy\n respond_to do |format|\n format.html { redirect_to reltypes_url, notice: 'Reltype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ad_type = AdType.find(params[:id])\n @ad_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @appliance_type = ApplianceType.find(params[:id])\n @appliance_type.destroy\n\n respond_to do |format|\n format.html { redirect_to appliance_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @resource = Resource.find(params[:id])\n @resource.destroy\n\n respond_to do |format|\n format.html { redirect_to resources_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_diagnostic_test_type = Ref::DiagnosticTestType.find(params[:id])\n @ref_diagnostic_test_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_diagnostic_test_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @metric_type = MetricType.find(params[:id])\n @metric_type.destroy\n\n respond_to do |format|\n format.html { redirect_to metric_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @az_simple_data_type = AzSimpleDataType.find(params[:id])\n @az_simple_data_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(az_simple_data_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @premise_type = PremiseType.find(params[:id])\n @premise_type.destroy\n\n respond_to do |format|\n format.html { redirect_to premise_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @addresstype = Addresstype.find(params[:id])\n @addresstype.destroy\n\n respond_to do |format|\n format.html { redirect_to addresstypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @service_type = ServiceType.find(params[:id])\n @service_type.destroy\n\n respond_to do |format|\n format.html { redirect_to service_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recept_type.destroy\n respond_to do |format|\n format.html { redirect_to recept_types_url, notice: 'Recept type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @claim_type = ClaimType.find(params[:id])\n @claim_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(claim_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @all_field_type = AllFieldType.find(params[:id])\n @all_field_type.destroy\n\n respond_to do |format|\n format.html { redirect_to all_field_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spec_type.destroy\n respond_to do |format|\n format.html { redirect_to spec_types_url, notice: 'Spec type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @run_type = RunType.find(params[:id])\n @run_type.destroy\n\n respond_to do |format|\n format.html { redirect_to run_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @roof_type.destroy\n respond_to do |format|\n format.html { redirect_to roof_types_url, notice: 'Roof type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tax_type = TaxType.find(params[:id])\n @tax_type.destroy\n\n respond_to do |format|\n format.html { redirect_to tax_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entity_type.destroy\n respond_to do |format|\n format.html { redirect_to entity_types_url, notice: 'Entity type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_type.destroy\n respond_to do |format|\n format.html { redirect_to client_types_url, notice: 'Tipo de Cliente deletado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incidenttype = Incidenttype.find(params[:id])\n @incidenttype.destroy\n\n respond_to do |format|\n format.html { redirect_to(incidenttypes_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @uri_type = UriType.find(params[:id])\n @uri_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(uri_types_url) }\n format.xml { head :ok }\n end\n end",
"def delete(resource_type_identifier)\n raise Occi::Api::Client::Errors::NotImplementedError, \"#{__method__} is just a stub!\"\n end",
"def destroy\n @agency_type = AgencyType.find(params[:id])\n @agency_type.destroy\n\n respond_to do |format|\n format.html { redirect_to agency_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @os_type.destroy\n respond_to do |format|\n format.html { redirect_to os_types_url, notice: 'Os type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @testtype.destroy\n respond_to do |format|\n format.html { redirect_to testtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admission_type = AdmissionType.find(params[:id])\n @admission_type.destroy\n\n respond_to do |format|\n format.html { redirect_to admission_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @costtype = Costtype.find(params[:id])\n @costtype.destroy\n\n respond_to do |format|\n format.html { redirect_to costtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @identity_type.destroy\n respond_to do |format|\n format.html { redirect_to identity_types_url, notice: 'Identity type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_hospitalization_type = Ref::HospitalizationType.find(params[:id])\n @ref_hospitalization_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_hospitalization_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @sample_type.destroy\n respond_to do |format|\n format.html { redirect_to sample_types_url, notice: \"Sample type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @act_type = ActType.find(params[:id])\n @act_type.destroy\n\n respond_to do |format|\n format.html { redirect_to act_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @intervention_type.destroy\n respond_to do |format|\n format.html { redirect_to intervention_types_url, notice: 'O tipo de intervenção foi eliminado.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fueltype = Fueltype.find(params[:id])\n @fueltype.destroy\n\n respond_to do |format|\n format.html { redirect_to fueltypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @document_type = DocumentType.find(params[:id])\n @document_type.destroy\n\n respond_to do |format|\n format.html { redirect_to document_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servicetype = Servicetype.find(params[:id])\n @servicetype.destroy\n\n respond_to do |format|\n format.html { redirect_to servicetypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servicetype = Servicetype.find(params[:id])\n @servicetype.destroy\n\n respond_to do |format|\n format.html { redirect_to servicetypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @expression_relationship_type = ExpressionRelationshipType.find(params[:id])\n @expression_relationship_type.destroy\n\n respond_to do |format|\n format.html { redirect_to expression_relationship_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey_data_type.destroy\n respond_to do |format|\n format.html { redirect_to survey_data_types_url, notice: 'Survey data type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hr_config_discipline_type.destroy\n respond_to do |format|\n format.html { redirect_to hr_config_discipline_types_url, notice: 'Discipline type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @itype = Itype.find(params[:id])\n @itype.destroy\n\n respond_to do |format|\n format.html { redirect_to itypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dish_type.destroy\n respond_to do |format|\n format.html { redirect_to dish_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dash_type = DashType.find(params[:id])\n @dash_type.destroy\n\n respond_to do |format|\n format.html { redirect_to dash_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @identifier_type.destroy\n respond_to do |format|\n format.html { redirect_to identifier_types_url, notice: 'Identifier type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @account_type\n @account_type.destroy\n respond_to do |format|\n format.html { redirect_to account_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @model_type.destroy\n respond_to do |format|\n format.html { redirect_to model_types_url, notice: 'Model type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @archetype = Archetype.find(params[:id])\n @archetype.destroy\n\n respond_to do |format|\n format.html { redirect_to archetypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @storage_type.destroy\n respond_to do |format|\n format.html { redirect_to storage_types_url, notice: 'Storage type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contract_type = ContractType.find(params[:id])\n @contract_type.destroy\n\n respond_to do |format|\n format.html { redirect_to contract_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @environment_type = EnvironmentType.find(params[:id])\n @environment_type.destroy\n\n respond_to do |format|\n format.html { redirect_to environment_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @oma_relation_type = OmaRelationType.find(params[:id])\n @oma_relation_type.destroy\n\n respond_to do |format|\n format.html { redirect_to oma_relation_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @data_set_type.destroy\n respond_to do |format|\n format.html { redirect_to data_set_types_url, notice: 'Data set type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
[
"0.75429046",
"0.74166036",
"0.7370498",
"0.7339524",
"0.7250024",
"0.7213917",
"0.7186394",
"0.7171517",
"0.71469706",
"0.71456087",
"0.7096467",
"0.70753014",
"0.7072549",
"0.7066805",
"0.70355505",
"0.6999935",
"0.698017",
"0.6972318",
"0.6968882",
"0.6968364",
"0.6964999",
"0.6964191",
"0.69638026",
"0.6962831",
"0.69587773",
"0.6944778",
"0.6934941",
"0.69324595",
"0.6924217",
"0.6921102",
"0.69188064",
"0.6916782",
"0.69167686",
"0.69136643",
"0.69104457",
"0.6899577",
"0.6895769",
"0.6883289",
"0.68820655",
"0.68808234",
"0.6880057",
"0.68715394",
"0.6871183",
"0.68580455",
"0.6857121",
"0.68478894",
"0.68374515",
"0.6827047",
"0.6820512",
"0.68203217",
"0.68203217",
"0.68203217",
"0.68203217",
"0.68181384",
"0.68175143",
"0.68160135",
"0.6815779",
"0.681051",
"0.68068016",
"0.68048835",
"0.68028253",
"0.67990965",
"0.6798407",
"0.6798137",
"0.67978936",
"0.67969185",
"0.6795897",
"0.679411",
"0.67923284",
"0.6789646",
"0.6788701",
"0.6786343",
"0.6784939",
"0.67817324",
"0.67810106",
"0.6779492",
"0.6776973",
"0.6776128",
"0.6773239",
"0.6768599",
"0.6765094",
"0.6758849",
"0.67586124",
"0.67523587",
"0.67523587",
"0.67474854",
"0.6747314",
"0.67400694",
"0.67379963",
"0.67370015",
"0.6732086",
"0.6724735",
"0.6721943",
"0.672106",
"0.67137384",
"0.6708958",
"0.67067784",
"0.6705277",
"0.67047054",
"0.6703244"
] |
0.7696583
|
0
|
Initialize with model class
|
def initialize(model_class)
@model_class = model_class
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(model)\n @model = model\n end",
"def initialize(model)\n @model = model\n end",
"def initialize(model)\n @model = model\n end",
"def initialize(model)\n @model = model\n end",
"def initialize_model\n end",
"def initialize_model\n # let's create our new empty model\n @model = OpenStudio::Model::Model.new if @model.nil?\n end",
"def initialize_model\n { :def_class => BaseDefinition,\n :processes => [],\n :process_class => nil, :process_class_name => nil,\n :controller_class => nil, :controller_class_name => nil }\n end",
"def initialize(model)\n @logger = Logger.new(self.class.name)\n self.class.model = model\n end",
"def model_class=(_arg0); end",
"def initialize(model, opts = {})\n @klass = model\n @options = opts || {}\n end",
"def initialize(model_class = nil)\n super(model_class || ActiveHouse::Model)\n end",
"def initialize(model = T.unsafe(nil)); end",
"def initialize(model_wrapper)\n @model_wrapper = model_wrapper\n end",
"def initialize(model_wrapper)\n @model_wrapper = model_wrapper\n end",
"def initialize(model, request)\n @model = model\n @request = request\n end",
"def initialize(model_class)\n @model_class = model_class\n @models_to_embed = []\n end",
"def initialize(user, model)\n @user = user\n @model = model\n end",
"def initialize(model_class)\n @model_class = model_class\n @records = []\n end",
"def initialize(model)\n @model = model\n\n instance_eval(&self.class.setup_model_blk) if model\n \n @templates = if model\n self.class.generated_files.models\n else\n self.class.generated_files.global\n end\n end",
"def initialize(model, year) #metodo constructor permite definir como se contruiran los objetos\n @model = model #guarda lo que sea que tenga en la variable \"model\"\n @year = year\n end",
"def initialize(model, client = nil)\n @model = model\n @client = client\n end",
"def initialize(model, client = nil)\n @model = model\n @client = client\n end",
"def initialize(model, name, type = nil)\n super name.to_s\n @model = model\n @type = type.to_sym if type\n end",
"def initialize(model, &block)\n @model = model\n @associations = {}\n @fields = []\n @attributes = []\n @conditions = []\n @groupings = []\n @options = {}\n @delta_object = nil\n \n initialize_from_builder(&block) if block_given?\n end",
"def initialize(model)\n\t\t\t@name = model.to_s\n\t\t\t@ar_model = ARModel.new(model)\n\t\t\t\n\n\n @api_model = APIModel.new(model, Hash[@ar_model.schema])\n\t\t\t@field_relationships = generate_field_relationships(@ar_model.schema)\n\t\t\tputs @field_relationships\n\t\tend",
"def initialize(model, context)\n @model = model\n @controller = extract_controller_from context\n end",
"def initialize(hash)\n # initialize class variable @@extension only once\n @@extension ||= Extension.new\n @@schema ||= @@extension.schema\n\n @hash = hash\n @type = @hash[:type]\n raise 'Unknown model type' if @type.nil?\n raise \"Incorrect model type '#{@type}'\" unless @type == 'Model'\n\n end",
"def initialize(model)\n raise ArgumentError, 'model must be an OpenNlp::Model' unless model.is_a?(OpenNlp::Model)\n\n @j_instance = self.class.java_class.new(model.j_model)\n end",
"def initialize(model, object_map)\n options = {}\n options, model = model, self.class._model.new if model.is_a?(Hash)\n\n\n # model, options = nil, model if model.is_a?(Hash) # sorry but i wanna have the same API as ActiveRecord here.\n @model = model #|| self.class._model.new\n\n object_map[@model] = self # DISCUSS: how to we handle compositions here?\n\n from_hash(\n self.class.new_representer.new(@model).to_hash(:object_map => object_map). # always read from model, even when it's new.\n merge(options)\n )\n end",
"def initialize(model_class, decorator_class)\n @model_class = model_class\n @decorator_class = decorator_class\n end",
"def initialize(make, model)\n @make = make\n @model = model\n end",
"def initialize_core_object(model)\n ensure_class_exist(model[:process_class_name])\n\n # Ex: Hpcloud(ForjAccount, HpcloudProvider)\n def_class = model[:def_class]\n if model[:controller_class]\n @core_object = def_class.new(@config,\n model[:process_class].new,\n model[:controller_class].new)\n else\n @core_object = def_class.new(@config,\n model[:process_class].new)\n end\n end",
"def initialize(model_class, block)\n @model_class, @block = model_class, block\n\n @scopes = {}\n @allowed_fields = {}\n @validators = {}\n @fixtures = {}\n end",
"def initialize\n @proxy_map = {}\n initialize_model\n end",
"def init(model, rec, pckg, baseName); @model = model; @rec = rec; @pckg = pckg; @baseName = baseName; self end",
"def model\n @model ||= Model.new(self)\n end",
"def initialize(model, template)\n @model = model\n @template = template\n @model_name = @template.controller_name.singularize\n self.class.send(:define_method, @model_name) do\n @model\n end\n end",
"def model=(_arg0); end",
"def model=(_arg0); end",
"def model=(_arg0); end",
"def model=(_arg0); end",
"def set_model\n @model = Info\n end",
"def set_model\n @model=Info\n end",
"def initialize model, context\n @model = model\n @controller = ControllerExtractor.new(context).extract\n end",
"def initialize\n \n end",
"def initialize(*args)\n # Call the ArsModels::Base initializer and delegate to the build or generate method\n super(*args)\n end",
"def initialize(*args)\n # Call the ArsModels::Base initializer and delegate to the build or generate method\n super(*args)\n end",
"def set_model\n\n # check credentials and handle OpenStack Keystone\n # TODO: check expiration dates on Keystone tokens\n raise \"You are not authorized to use this endpoint!\" unless check_authn\n\n #\n model = get('/-/')\n @model = Occi::Model.new(model)\n\n @mixins = {\n :os_tpl => [],\n :resource_tpl => []\n }\n\n #\n get_os_templates.each do |os_tpl|\n unless os_tpl.nil? || os_tpl.type_identifier.nil?\n tid = os_tpl.type_identifier.strip\n @mixins[:os_tpl] << tid unless tid.empty?\n end\n end\n\n #\n get_resource_templates.each do |res_tpl|\n unless res_tpl.nil? || res_tpl.type_identifier.nil?\n tid = res_tpl.type_identifier.strip\n @mixins[:resource_tpl] << tid unless tid.empty?\n end\n end\n\n model\n end",
"def initialize(model)\n @model = model\n load_defaults!\n\n @on_success = true if on_success.nil?\n @on_warning = true if on_warning.nil?\n @on_failure = true if on_failure.nil?\n end",
"def initialize() # no file name if want to build model manually\n @reRefs = Hash.new(*[]) # references to the entity, hash keyed by entity\n @enums={}; @records = {}\n @ver = nil\n end",
"def initialize(model, year, color)\n self.color = color # Call accessor (setter) method.\n @year = year # Only time and way to assign an attr_reader.\n @model = model # Instance variables defined and assigned\n end",
"def set_attributes_and_model attributes\n self.attributes = attributes\n model_class = self.class.model_class(attributes)\n self.type = model_class.to_s\n self\n end",
"def initialize\n @model = Evertils::Common::Query::Simple.new\n @format = Formatting.new\n @user = @model.user_info[:user]\n @shard = @model.user_info[:shard]\n end",
"def build_model\n self.model = nil # set up the model\n end",
"def initialize(attr, value, model, config)\n @attr = attr\n @value = value\n @model = model.is_a?(Class) ? model : model.constantize\n @config = config\n parse\n end",
"def setup(model_class); end",
"def setup(model_class); end",
"def initialize(model)\n raise ArgumentError.new(\"#{model} does not extend ActiveRecord\") unless model.ancestors.include?(ActiveRecord::Base)\n # Cache and filters start out empty\n reset!(model)\n end",
"def initialize\n initialize!\n end",
"def initialize\n initialize!\n end",
"def initialize object\n\t\tself.object = object\n\tend",
"def initialize(attrs = {})\n @nested_model_instances = {}\n \n self._nested_models.each do |model|\n model_class = model.to_s.classify.constantize\n \n if attrs.include?(model)\n @nested_model_instances[model] = initialize_nested_model(model_class, attrs[model])\n else\n @nested_model_instances[model] = initialize_nested_model(model_class)\n end\n end\n \n self._dependencies.each do |from, tos|\n tos.each do |to|\n @nested_model_instances[from].public_send(\"#{to.to_s}=\", @nested_model_instances[to])\n end\n end\n end",
"def initialize(make, model, classification, owner)\n @make = make\n @model = model\n @classification = classification\n @owner = owner\n @@all << self\n end",
"def set_object\n set_model_instance(MODEL_CLASS.find(params[:id]))\n end",
"def initialize\n end",
"def initialize(model_class, id)\n @attributes = { model_class.primary_key.to_sym => id }\n @columns = model_class.column_names\n @columns.each do |column|\n case column\n when 'created_at', 'updated_at'\n @attributes[column.to_sym] = Time.now\n when 'created_on', 'updated_on'\n @attributes[column.to_sym] = Date.today\n when model_class.inheritance_column\n @attributes[column.to_sym] = model_class.to_s\n end\n end\n end",
"def initialize()\n @models = {}\n @path = Settings.get[\"trxml\"][\"path\"]\n @xmls = Settings.get[\"trxml\"][\"xmls\"]\n\n create_models\n end",
"def initialize\n init\n end",
"def model_class\n @model_class ||= mapping.to\n end",
"def initialize_hydration(model_class, requested_fields, request_ctx)\n SuperScopes::ParamSet.new(model_class, requested_fields, request_ctx)\n end",
"def initialize(model_class, options = {})\n @model_class = model_class\n @synced_endpoint = options[:synced_endpoint]\n @scope = options[:scope]\n @id_key = options[:id_key]\n @data_key = options[:data_key]\n @only_updated = options[:only_updated]\n @include = options[:include]\n @local_attributes = synced_attributes_as_hash(options[:local_attributes])\n @api = options[:api]\n @mapper = options[:mapper].respond_to?(:call) ?\n options[:mapper].call : options[:mapper]\n @fields = options[:fields]\n @remove = options[:remove]\n @associations = Array.wrap(options[:associations])\n @association_sync = options[:association_sync]\n @perform_request = options[:remote].nil? && !@association_sync\n @remote_objects = Array.wrap(options[:remote]) unless @perform_request\n @globalized_attributes = synced_attributes_as_hash(options[:globalized_attributes])\n @query_params = options[:query_params]\n @auto_paginate = options[:auto_paginate]\n @transaction_per_page = options[:transaction_per_page]\n @handle_processed_objects_proc = options[:handle_processed_objects_proc]\n @remote_objects_ids = []\n end",
"def initialize()\n end",
"def initialize(key, data={})\n \n @path = model.build_path(key)\n @metadata = {}\n \n # Store the properties defined in the model in the metadata\n properties.each do |property_name, property|\n @metadata.store(property.name, '')\n end\n \n # Assign the values\n self.attributes=(data)\n \n end",
"def def_Model(mod)\n model = self\n mod.define_singleton_method(:Model) do |source|\n model.Model(source)\n end\n end",
"def initialize(model, make, colour)\r\n @model = model\r\n @make = make\r\n @colour = colour\r\n end",
"def initialize(obj); end",
"def get_model\n return model_classes[item_type].new()\n end",
"def initialize(model, scopes = nil)\n self.model = model\n self.scopes = scopes\n end",
"def initialize(model, database_id = nil)\n @model = model\n @database_id = database_id.to_s.gsub(/\\W/, '_') if database_id\n load_defaults!\n end",
"def initialize(model, mappers)\n @model = model\n @mappers = mappers\n @relationships = Set.new\n @target_keys = Set.new\n\n initialize_relationships\n initialize_target_keys\n end",
"def initialize(obj)\n @obj = obj\n end",
"def initialize(obj)\n @obj = obj\n end",
"def initialize(*elts)\n unless elts.empty?\n if elts.find{|val| not(val.kind_of?(BasicModel))}\n raise ArgumentError.new(elts)\n end\n unless elts.map{|val| val.pione_model_type}.uniq.size == 1\n raise ArgumentError.new(elts)\n end\n end\n @values = elts\n end",
"def model=(model)\n @model = model\n end",
"def initialize(query:, model: )\n @query = query\n @root = model.table_name\n end",
"def parsed_model(&block)\n parsed_model_class.class_eval(&block)\n end",
"def newInstance( params={} )\n model.new( params ).extend( InstanceMethods )\n end",
"def using_model(class_name)\n class_name = class_name.name if Class === class_name\n @expected_options[:class_name] = class_name\n self\n end",
"def initialize(klass, params = {})\n @klass = klass\n @instance = klass.new params[:attributes]\n reset\n where(params[:attributes]) if params[:attributes].present?\n end",
"def default_model_class=(model) #:nodoc:\n init_columns_of_table(model) unless key?(model)\n @default_model_class = model\n end",
"def initialize\n super()\n init_data()\n end",
"def initialize (model_klass, request_params, seed_query = nil,\n extra_columns = nil)\n\n @model_klass = model_klass\n @request_params = request_params\n @data = seed_query || model_klass\n\n @draw = request_params[:draw].to_i\n @records_total = @data.count\n\n parse_request_params\n\n apply_filters\n\n @records_filtered = @data.count\n\n apply_sorting\n apply_pagination\n apply_column_selection(extra_columns)\n end",
"def def_Model(mod)\n model = self\n (class << mod; self; end).send(:define_method, :Model) do |source|\n model.Model(source)\n end\n end",
"def initialize(options={})\n\t\t\t@model = options[:model]\n\t\t\t@view = options[:view]\n\t\t\t@router = options[:router]\n\t\tend",
"def model(name, model_klass)\n @root = [name, model_klass]\n end",
"def initialize() end",
"def set_model\n @model = Model.find(params[:id])\n end",
"def set_model\n @model = Model.find(params[:id])\n end",
"def set_model\n @model = Model.find(params[:id])\n end",
"def set_model\n @model = Model.find(params[:id])\n end"
] |
[
"0.82658815",
"0.8260851",
"0.8260851",
"0.8260851",
"0.7779325",
"0.7756454",
"0.74143684",
"0.73924434",
"0.73777056",
"0.7332128",
"0.7330528",
"0.7274797",
"0.723779",
"0.723779",
"0.7206016",
"0.71815187",
"0.7122468",
"0.7119589",
"0.7094314",
"0.70433825",
"0.7000995",
"0.7000995",
"0.6956362",
"0.69155705",
"0.6911318",
"0.68704563",
"0.6820363",
"0.68094134",
"0.6799443",
"0.67910194",
"0.67869204",
"0.6754538",
"0.6742047",
"0.67032486",
"0.66546535",
"0.6650138",
"0.66498125",
"0.6601983",
"0.6601983",
"0.6601983",
"0.6601983",
"0.65843177",
"0.65665185",
"0.6563333",
"0.6557705",
"0.6555195",
"0.6555195",
"0.6541141",
"0.6528351",
"0.65196395",
"0.64931977",
"0.6471448",
"0.64546347",
"0.6444978",
"0.6436836",
"0.64362925",
"0.64362925",
"0.6435653",
"0.6426443",
"0.6426443",
"0.6425431",
"0.64253455",
"0.64171475",
"0.64115965",
"0.6405613",
"0.6399153",
"0.6395304",
"0.63871014",
"0.63796014",
"0.63795155",
"0.63784575",
"0.6361476",
"0.63537663",
"0.6350636",
"0.6340433",
"0.6333618",
"0.6329572",
"0.6327496",
"0.63146514",
"0.63117826",
"0.6311699",
"0.6311699",
"0.63100797",
"0.6306474",
"0.6290042",
"0.6275688",
"0.62695855",
"0.6268097",
"0.6259781",
"0.6248152",
"0.6239935",
"0.6237755",
"0.6231728",
"0.62301636",
"0.622922",
"0.6229048",
"0.6223205",
"0.6223205",
"0.6223205",
"0.6223205"
] |
0.82601494
|
4
|
Set metadata as origin
|
def fields=(fields)
@fields = ::ActiveSupport::HashWithIndifferentAccess.new fields
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_metadata(*args)\n self.metadata.set(*args)\n end",
"def metadata=(_); end",
"def setOrigin(origin)\n @origin = origin\n end",
"def metadata=(value)\n @metadata = value\n end",
"def metadata=(value)\n @metadata = value\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def set_object_origin(content, value)\n content.oy = value\n end",
"def origin=(value)\n @origin = value\n end",
"def _UNDO_setMetadata(iNewMetadata)\n @Metadata = iNewMetadata\n end",
"def set_metadata\n return if orcid.present?\n\n self.orcid = orcid_from_url(pid) unless orcid.present?\n self.github = github_owner_from_url(pid) unless github.present?\n\n if orcid.present?\n metadata = get_metadata(orcid, \"orcid\")\n elsif github.present?\n metadata = get_metadata(github, \"github_owner\")\n else\n return nil\n end\n\n return if metadata[:error].present?\n\n author = metadata.fetch('author', []).first\n\n if author.is_a?(Hash)\n self.family_name = author.fetch('family', nil)\n self.given_names = author.fetch('given', nil)\n self.literal = author.fetch('literal', nil)\n elsif author.is_a?(String)\n self.literal = author\n end\n end",
"def add_metadata(meta={})\n @local_metadata.deep_merge!(meta.dup)\n end",
"def load_metadata!(metadata)\n load_remote_metadata(metadata)\n persists!\n self\n end",
"def meta(meta_data)\n @_meta = meta_data\n end",
"def set_meta\n puts 'meta'\n end",
"def set_object_origin(content, value)\n content.ox = value\n end",
"def metadata=(_arg0); end",
"def update_initial_metadata(metadata)\n end",
"def set_origin\n @origin = Origin.find(params[:id])\n end",
"def set_origin\n @origin = Origin.find(params[:id])\n end",
"def update_metadata(direction, metadata)\n end",
"def setFrameOrigin( origin )\n @frame.origin = origin\n end",
"def origin=(v)\n @origin = v ? URI.parse(v) : nil\n end",
"def set_asset_metadata\n headers = fog_connection.head_object(CarrierWave::Uploader::Base.fog_directory, upload_data[:path]).headers\n\n self.name = upload_data[:filename]\n self.size = headers['Content-Length']\n self.etag = headers['Etag']\n self.content_type = headers['Content-Type']\n end",
"def sync_exif_data\n self.title = self.image_title if self.title.blank?\n self.caption = self.image_description if self.caption.blank?\n self.owner = self.image_copyright if self.owner.blank?\n end",
"def metadata(_=nil)\n if !_.nil?\n warn \"[DEPRECATION] The parameter of `metadata` is ignored and will be removed in 2.0. \" \\\n \"(called from #{caller.first})\"\n end\n remote_metadata.merge(local_metadata).freeze\n end",
"def prepare metadata\n ssh = @export_obj.ssh_to_source\n metadata.ssh = ssh\n end",
"def update_metadata(dataset, metadata = {})\n metadata = get_metadata(metadata)\n metadata.each { |k, v| dataset.metadata[k] = v }\n dataset.save\n end",
"def set_metadata(metadata)\n @nodes_metadata << {\n metadata: metadata,\n nodes_selectors_stack: current_nodes_selectors_stack\n }\n end",
"def sync_exif_data\n self.title = self.image_title if self.title.blank?\n self.caption = self.image_description if self.caption.blank?\n self.owner = self.image_copyright if self.owner.blank?\n end",
"def picture_origin(id, *origin)\n origin = origin[0] if origin.length == 1\n pictures[id].origin = origin\n end",
"def origin=(point)\n end",
"def picture_origin(id, *origin)\n origin = origin[0] if origin.length == 1\n pictures[id].origin = origin\n end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def set_meta\n meta.tap do |m|\n m.tag = [{\n system: META_SYSTEM,\n code: META_CODE,\n display: META_DISPLAY\n }]\n end\n end",
"def update!(**args)\n @metadata_location = args[:metadata_location] if args.key?(:metadata_location)\n end",
"def set_metadata\n s3_obj.metadata[\"filename\"] = file_name\n s3_obj.metadata[\"bindery-pid\"] = persistent_id\n end",
"def set_datasets\n @datasets = current_user.get_datasets 'all'\n\n @metadata_array = []\n @metadata_array = Dataset.get_metadata_list(@datasets.map{|ds| ds.id}) if @datasets\n\n # TODO: Find a better way to do this\n @datasets.each_with_index do |ds, i|\n ds.metadata = @metadata_array['data'][i]['attributes']\n end\n end",
"def origin\n end",
"def set_bookmark_meta_data\n begin\n page = Pismo::Document.new(self.full_url)\n self.name = page.html_title\n self.favicon_url = page.favicon\n self.description = page.description\n rescue => e\n self.description = \"Error => #{e}\"\n ensure\n self.save\n end\n end",
"def update!(**args)\n @metadata = args[:metadata] if args.key?(:metadata)\n end",
"def origin=(object)\n self.hokusai_class = object.class.to_s\n self.hokusai_template = YAML.dump(object.as_template)\n end",
"def set_meta_headers(headers)\n @logger.info \"Setting #{headers.keys.join(', ')} for tenant #{@fog_options[:hp_tenant_id]}...\"\n response = @connection.request({\n :method => 'POST',\n :headers => headers\n })\n\n # Confirm meta data changes\n response = @connection.request({\n :method => 'HEAD'\n })\n\n @logger.info \"Done setting account meta key.\"\n end",
"def origin=(value)\n raise UnsupportedOperationError\n end",
"def origin; end",
"def origin; end",
"def origin; end",
"def set_Origin(value)\n set_input(\"Origin\", value)\n end",
"def set_Origin(value)\n set_input(\"Origin\", value)\n end",
"def follow_meta_refresh_self=(follow); end",
"def update_metadata\n response = Net::HTTP.post(URI('https://api.linkpreview.net'),\n { 'key' => ENV['LINKPREVIEW_API_KEY'],\n 'q' => self.url }.to_json)\n\n body = JSON.parse(response.body)\n self.title = body['title']\n self.image = body['image']\n self.description = body['description']\n save\n end",
"def initialize_copy(other)\n super(other)\n @metadata = other.metadata\n end",
"def set_queue_metadata(queue_name, metadata = {})\r\n execute(:put, queue_name, { :comp => 'metadata' }, metadata.merge!(:x_ms_version => '2009-09-19'))\r\n end",
"def update!(**args)\n @ae_origin = args[:ae_origin] if args.key?(:ae_origin)\n end",
"def set_object_origin(obj, value)\n obj.oy = value\n end",
"def metadata\n @metadata.clone.freeze\n end",
"def metadata_file; end",
"def metadata_file; end",
"def follow_meta_refresh=(follow); end",
"def update_catalog_metadata\n source = metadata_builder.metadata_source.find_by(source_type: 'descriptive')\n raise 'Descriptive metadata source not available' unless source\n\n bibnumber = source.original_mappings['bibnumber']&.first\n raise 'Descriptive metadata does not contain bibnumber' if bibnumber.blank?\n\n source.set_metadata_mappings(clone_location)\n source.save!\n end",
"def setUseMetadataFrom(index)\n if (!(Integer(index) >= 0))\n raise Error.new(Pdfcrowd.create_invalid_value_message(index, \"setUseMetadataFrom\", \"pdf-to-pdf\", \"Must be a positive integer number or 0.\", \"set_use_metadata_from\"), 470);\n end\n \n @fields['use_metadata_from'] = index\n self\n end",
"def update!(**args)\n @metadata = args[:metadata] if args.key?(:metadata)\n @url = args[:url] if args.key?(:url)\n end",
"def set(key, value)\n @metadata[key] = value\n end",
"def name(name)\n @metadata = @metadata.with_name(name)\n end",
"def update!(**args)\n @kind = args[:kind] if args.key?(:kind)\n @metadata = args[:metadata] if args.key?(:metadata)\n @origination = args[:origination] if args.key?(:origination)\n @time_provided = args[:time_provided] if args.key?(:time_provided)\n end",
"def set_metadata(key, value)\n params = java.util.HashMap.new()\n params.put(key.to_s, value)\n @stamp.setMoreInfo(params)\n end",
"def update!(**args)\n @annotation_source_info = args[:annotation_source_info] if args.key?(:annotation_source_info)\n @cross_domain = args[:cross_domain] if args.key?(:cross_domain)\n @url = args[:url] if args.key?(:url)\n end",
"def appendToMetadata(additionalMetadata)\n @additionalMetadata.merge!(additionalMetadata)\n end",
"def appendToMetadata(additionalMetadata)\n @additionalMetadata.merge!(additionalMetadata)\n end",
"def store_metadata\n html = HTMLParse.new(url)\n self.meta_title = html.title\n self.meta_desc = html.desc\n end",
"def with_metadata(metadata)\n self.class.new(world, radius: radius, center: center, metadata: metadata)\n end",
"def text_origin\n\t\t# puts \"Is this working *******************************\"\n\t\tif self.origin != nil\n\t\t\tBoat::LOCATIONS[self.origin]\n\t\telse\n\t\t\t\"ORIGIN NOT SET\"\n\t\tend\n\tend",
"def []= name, value\n raise \"cannot change the metadata of an object version; \"+\n \"use S3Object#write to create a new version with different metadata\" if\n @version_id\n metadata = to_h.dup\n metadata[name.to_s] = value\n object.copy_from(object.key,\n :metadata => metadata)\n value\n end",
"def update_metadata\n file_attributes = ::FileSetEditForm.model_attributes(attributes)\n actor.update_metadata(file_attributes)\n end",
"def set_origin\n origin = session[:origin] || 'boulder-colorado'\n params[:origin] = origin if params[:origin].blank?\n end",
"def canonical!\n self.local = self.canonical\n end",
"def set_object_origin(obj, value)\n obj.ox = value\n end",
"def set_dataset_rel_and_attr\n @dataset.database = @database\n @dataset_id = @dataset.id\n organization = Organization.find_by_id(@organization_id)\n organization.datasets << @dataset\n @dataset.organization = organization\n end",
"def metadata=(data)\n # make sure were providing a hash\n data = {} unless data.is_a?(Hash)\n\n # convert to xml <hash>...</hash>\n self[:metadata] = data.to_xml(:dasherize => false)\n end",
"def reset_xmp_metadata()\n @stamp.setXmpMetadata(\"\".to_java_bytes)\n end",
"def response_metadata=(_); end",
"def add_meta(meta)\n self.meta.merge!(meta)\n self\n end",
"def user_metadata=(new_metadata)\n raise ArgumentError.new(\"Cannot set user metadata to nil\") unless new_metadata\n self.service.setUserMetadata([new_metadata])\n self.refresh_details()\n end",
"def set_origin_addresses(origin_addresses_data)\n @origin_addresses = CompanyApi::Response::Entity::OriginAddresses.new(origin_addresses_data)\n end",
"def user_metadata=(new_metadata)\n raise ArgumentError, \"Cannot set user metadata to nil\" unless new_metadata\n self.service.setUserMetadata([new_metadata])\n self.refresh_details()\n end",
"def migrate_desc_metadata(ds_name, ds_object)\n from = FromDescMetadata.new(rubydora_object, ds_name)\n to = PersonMetadataDatastream.new(build_unsaved_digital_object, ds_name)\n begin\n to.name = from.display_name if from.display_name.present?\n to.email = from.preferred_email if from.preferred_email.present?\n to.alternate_email = from.alternate_email if from.alternate_email.present?\n to.save\n rescue Nokogiri::XML::XPath::SyntaxError\n # already converted\n true\n end\n end",
"def metadata\n @meta_data\n end",
"def add_meta_data(meta_hash)\n meta.merge! meta_hash\n end",
"def apply_additional_metadata(depositor_id)\n #Here's where we call specific additional metadata changes...\n\t\tif self.respond_to?(:apply_content_specific_additional_metadata)\n self.apply_content_specific_additional_metadata\n end\t\n\n\t\t#We are setting the ownerId within apply_addtional_metadata due to a Fedora bug (FCREPO-963 - which means we can't set it on ingest).\n\t\t#It only sets the ownerId with the depositor id if its in the proto queue\n \t\tif self.queue_membership.include? :proto\n\t\t\tself.owner_id = depositor_id\n\t\tend\n\t\t\t\n\t\tdc_ds = self.dc\n\t\tdescMetadata_ds = self.descMetadata\n\n unless dc_ds.nil?\n dc_ds.update_indexed_attributes([:dc_title]=> self.get_values_from_datastream(\"descMetadata\", [:title], {}).to_s)\n begin\n date_issued = self.get_values_from_datastream(\"descMetadata\", [:origin_info,:date_issued], {})\n\t\t\t\tdate_valid = self.get_values_from_datastream(\"descMetadata\", [:origin_info,:date_valid], {})\n \n if date_issued.to_s != \"\"\n \tdc_ds.update_indexed_attributes([:dc_date]=> date_issued.to_s) if date_issued.present?\n\t\t\t\telse\n\t\t\t\t\tdc_ds.update_indexed_attributes([:dc_date]=> date_valid.to_s) if date_valid.present?\n\t\t\t\tend\n rescue OM::XML::Terminology::BadPointerError => e\n logger.error \"ERROR when trying to copy date on #{self.class} #{self.pid}:\\n\\t#{e.message}\"\n end\n end\n\t\n\t\tunless descMetadata_ds.nil?\n\t\t\tdescMetadata_ds.update_indexed_attributes ([:record_info,:record_change_date] => Time.now.strftime(\"%Y-%m-%d\"))\n\t\tend\n\n\t\tself.label = generate_object_label\n\t\t\n\t return true\n end",
"def update!(**args)\n @metadata = args[:metadata] if args.key?(:metadata)\n @link = args[:link] if args.key?(:link)\n end",
"def initialize( *args )\n super\n @meta_end = end_of_meta_data\n end",
"def meta_data( name )\n fd = new name, 'r'\n fd.meta_data\n ensure\n fd.close unless fd.nil?\n end",
"def get_origin\n\t\treturn @transport.get_path(\"meta\",\"origin\")\n\tend"
] |
[
"0.69283915",
"0.6648875",
"0.65009546",
"0.6282812",
"0.6282812",
"0.6251183",
"0.6251183",
"0.6251183",
"0.6251183",
"0.6235042",
"0.6167347",
"0.61413664",
"0.60971266",
"0.609449",
"0.609051",
"0.60719144",
"0.60089135",
"0.59800416",
"0.59609365",
"0.5959143",
"0.59305394",
"0.5888672",
"0.588694",
"0.58061284",
"0.5786144",
"0.57562",
"0.57189524",
"0.5697102",
"0.56957144",
"0.56818897",
"0.56598395",
"0.565648",
"0.5648771",
"0.5648611",
"0.5634478",
"0.5634423",
"0.5634423",
"0.5634423",
"0.5634423",
"0.5634423",
"0.5634423",
"0.5634423",
"0.56314254",
"0.5626802",
"0.56113964",
"0.5582427",
"0.5534954",
"0.55315036",
"0.5507893",
"0.5507507",
"0.54931223",
"0.5491656",
"0.54674953",
"0.54674953",
"0.54674953",
"0.5453909",
"0.5453909",
"0.5438061",
"0.5423287",
"0.5412317",
"0.53993505",
"0.5375782",
"0.53745437",
"0.5366766",
"0.53579295",
"0.53579295",
"0.5352597",
"0.53454185",
"0.53198826",
"0.53029644",
"0.5297068",
"0.5294837",
"0.5293189",
"0.529303",
"0.5292652",
"0.5272951",
"0.5272951",
"0.52581143",
"0.52496195",
"0.5245928",
"0.52439743",
"0.52290964",
"0.5226878",
"0.52117735",
"0.5202599",
"0.51913947",
"0.51858884",
"0.5180488",
"0.5161521",
"0.5155917",
"0.51555157",
"0.51524806",
"0.5149365",
"0.5145545",
"0.51402056",
"0.5128953",
"0.5121732",
"0.51212287",
"0.5117125",
"0.5114803",
"0.51146245"
] |
0.0
|
-1
|
Set metadata for index page
|
def index_fields=(fields)
@index_fields = ::ActiveSupport::HashWithIndifferentAccess.new fields
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_meta\n puts 'meta'\n end",
"def initialize\n document = U.parse_html_from_file_or_uri(@base_uri, @index_html, \n :force_fetch => FORCE_FETCH)\n\n @index_metadata = get_metadata(document)\n U.write_yaml(@index_data, @index_metadata) # for easy viewing later\n end",
"def index\n @meta = Metum.all\n end",
"def index\n @meta = Metum.all\n end",
"def set_page_metadata\n params[:id].tap do |page|\n if %w(home privacy styles terms).include? page\n page_title t(\"pages.#{page}.page_title\") unless page == 'home'\n page_author t(\"pages.#{page}.page_author\", default: '')\n page_description t(\"pages.#{page}.page_description\", default: '')\n extra_body_classes \"#{page}-page\"\n end\n end\n end",
"def process_index\n bindings = {\n :url => @definition.get_url,\n :name => @definition.get_name,\n :resources => @definition.resources,\n :description => @definition.get_description,\n :version => @definition.get_version\n }\n\n page = Calamum::DocGenerator.new(:index)\n page.save_template('index.html', bindings)\n end",
"def metadata=(value)\n @metadata = value\n end",
"def metadata=(value)\n @metadata = value\n end",
"def set_meta\n meta.tap do |m|\n m.tag = [{\n system: META_SYSTEM,\n code: META_CODE,\n display: META_DISPLAY\n }]\n end\n end",
"def set_metadata(*args)\n self.metadata.set(*args)\n end",
"def index\n @title = @title + \" : Portfolio\"\n @meta_description = @title\n @portfolio_entries.each do |portfolio_entry| \n @meta_keywords = @meta_keywords + \", \" + portfolio_entry.name\n end \n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def meta(meta_data)\n @_meta = meta_data\n end",
"def set_page_data\n @page_title = \"Dragos | My Portfolio\"\n @seo_keywords = \"Dragos Portfolio\"\n end",
"def store_metadata\n html = HTMLParse.new(url)\n self.meta_title = html.title\n self.meta_desc = html.desc\n end",
"def index\n parsed_body['meta']['parameters']['index']\n end",
"def metadata\n @page.metadata\n end",
"def set_info\n @page_header = 'Insight Engine'\n @page_secondary = 'Let\\'s get a view at 10,000 feet.'\n @page_title = 'LeadAccount | Insight Engine'\n @page_icon = 'lightbulb'\n end",
"def indexed\n meta(index: true)\n end",
"def set_bookmark_meta_data\n begin\n page = Pismo::Document.new(self.full_url)\n self.name = page.html_title\n self.favicon_url = page.favicon\n self.description = page.description\n rescue => e\n self.description = \"Error => #{e}\"\n ensure\n self.save\n end\n end",
"def set_individual_action_meta_information(args={})\n\t\t\t@title = args[:title]\n\t\t\t@meta_description = args[:description]\n\t\tend",
"def metadata=(_); end",
"def index\n @test_meta = TestMetum.all\n end",
"def set_page_meta_info(custom_extended_data = {})\n service_response = GetPageMetaInfo.new(\n controller: params[:controller],\n action: params[:action],\n request_url: request.url,\n custom_extended_data: custom_extended_data\n ).perform\n\n unless service_response.success?\n raise 'Incomplete Page Meta.'\n end\n\n page_extended_data = service_response.data\n\n @page_meta_data = page_extended_data[:meta]\n @page_assets_data = page_extended_data[:assets]\n end",
"def set_page_meta_info(custom_extended_data = {})\n service_response = GetPageMetaInfo.new(\n controller: params[:controller],\n action: params[:action],\n request_url: request.url,\n custom_extended_data: custom_extended_data\n ).perform\n\n unless service_response.success?\n raise 'Incomplete Page Meta.'\n end\n\n page_extended_data = service_response.data\n\n @page_meta_data = page_extended_data[:meta]\n @page_assets_data = page_extended_data[:assets]\n end",
"def set_page_meta_info(custom_extended_data = {})\n service_response = GetPageMetaInfo.new(\n controller: params[:controller],\n action: params[:action],\n request_url: request.url,\n custom_extended_data: custom_extended_data\n ).perform\n\n unless service_response.success?\n raise 'Incomplete Page Meta.'\n end\n\n page_extended_data = service_response.data\n\n @page_meta_data = page_extended_data[:meta]\n @page_assets_data = page_extended_data[:assets]\n end",
"def index\n\t\t@post_meta = PostMetum.all\n\tend",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def index\n prepare_meta_tags\n @songs = Song.all\n set_welcome\n end",
"def index_meta_data\n {\n q: params[:q],\n page: @users.current_page,\n per_page: @users.limit_value,\n total_pages: @users.total_pages\n }\n end",
"def index\n set_persona_biometria\n end",
"def index\n @test_meta_data = TestMetaDatum.all\n end",
"def metadata\n {\n title: flickr_title,\n description: description\n }\n end",
"def index_meta_data\n {\n q: params[:q],\n order: params[:order],\n order_by: params[:order_by],\n page: @cars.current_page,\n per_page: @cars.limit_value,\n total_pages: @cars.total_pages\n }\n end",
"def site_meta\n end",
"def site_meta\n end",
"def set_seo_meta(title,keywords = '',desc = '')\n if title\n @page_title = \"#{title}\"\n if params[:page]\n @page_title += \" » (First#{params[:page]}Page)\"\n end\n @page_title += \" » #{@setting.site_name}\"\n else\n @page_title = @setting.site_name\n end\n @meta_keywords = keywords\n @meta_description = desc\n end",
"def set_metadata(metadata)\n @nodes_metadata << {\n metadata: metadata,\n nodes_selectors_stack: current_nodes_selectors_stack\n }\n end",
"def setup_index\n @index_driver.setup_index\n end",
"def index\n set_meta_tags noindex: true\n\n @articles = initialize_grid(Article,\n order: 'articles.created_at',\n order_direction: 'desc',\n )\n end",
"def set_index\n @index = Nokogiri::HTML(open(@url))\n end",
"def index\n #@animals = Animal.all\n if params[:search_inputs].present?\n @search_inputs = OpenStruct.new(params[:search_inputs])\n else\n @search_inputs = OpenStruct.new()\n end\n @animals = AnimalsSearch.new(@search_inputs).search\n @animals = @animals.page(params[:page])\n\n set_meta_tags title: 'Unsere Tiere', reverse: true,\n description: 'Alle Tiere von STINAH im Überblick!'\n end",
"def metadata(*args)\n opts = args.extract_options!\n args.each do |name|\n self.add_metadata(name, opts)\n end\n end",
"def set_seo_params\n @seo = {\n :title => ::Setting::get('Title for index page'),\n :keywords => ::Setting::get('Keywords for index page'),\n :description => ::Setting::get('Description for index page')\n }\n end",
"def set_record_metatags! tags, record\n tags['title'] = record.name\n tags['description'] = record.excerpt if record.respond_to?(:excerpt)\n tags['og:url'] = wm_url_for(record)\n tags['og:type'] = 'article'\n tags['og:image'] = record.thumbnail.url if record.try(:thumbnail).present?\n tags['og:article:published_time'] = record.created_at.to_s(:db)\n tags['og:article:modified_time'] = record.updated_at.to_s(:db)\n tags['og:article:section'] = record.category&.name if record.is_a?(Article)\n tags['twitter:card'] = 'summary'\n\n set_locale_metatags!(tags, record) if record.try(:translatable?)\n set_static_page_metatags!(tags, record) if record.is_a?(StaticPage)\n set_video_metatags!(tags, record) if record.try(:vimeo_metadata).present?\n end",
"def meta\n {\n source: @host,\n favicon: @favicon,\n url: @url,\n title: title,\n description: @description,\n keywords: keywords,\n image_url: @main_image,\n extractable: extractable?\n }\n end",
"def set_static_page_metatags! tags, record\n if record.role == 'home'\n tags['title'] = translate('we_meditate')\n image = MediaFile.find_by(id: record.content_blocks.first['data']['image']['id']) if record.content_blocks.present?\n elsif record.parsed_content.present? && record.parsed_content['mediaFiles'].present?\n image = MediaFile.find_by(id: record.parsed_content['mediaFiles'].first)\n end\n\n tags['og:image'] = image_url image.file_url if image.present?\n tags['og:type'] = 'website' if %w[home contact privacy articles meditations subtle_system].include?(record.role)\n end",
"def page_meta\n @page_meta ||= {}\n end",
"def set_index_presenter(index_as, page_presenter)\n\n\n\n page_presenters[:index] ||= {}\n\n\n\n\n\n\n\n #set first index as default value or the index with default param set to to true\n\n\n\n if page_presenters[:index].empty? || page_presenter[:default] == true\n\n\n\n page_presenters[:index].default = page_presenter\n\n\n\n @default_index = find_index_class(page_presenter[:as])\n\n\n\n end\n\n\n\n\n\n\n\n page_presenters[:index][index_as] = page_presenter\n\n\n\n end",
"def metadata=(_arg0); end",
"def show\n set_index_options\n end",
"def meta\n meta = {}\n set_meta(meta)\n return meta\n end",
"def metadata\n @meta_data\n end",
"def index\n @title = \"All pages\"\n @pages = Page.all\n end",
"def show\n @page_title = @podcast.title\n @page_description = @podcast.extrait\n @page_keywords = \"Podcasts, enseignements, Parole de Dieu, méditation, Jesus Christ\"\n\n set_meta_tags og: {\n title: @podcast.title,\n type: \"article\",\n url: request.url,\n image: rails_blob_path(@podcast.cover)\n }\n\n # adding acticle og\n set_meta_tags article: {\n published_time: @podcast.created_at,\n modified_time: @podcast.updated_at,\n section: @podcast.type_podcast.name,\n tag: \"MPPP\"\n }\n\n # adding twitter card\n set_meta_tags twitter: {\n title: @podcast.title,\n creator: \"MPPP\",\n card: @podcast.extrait,\n site: request.url,\n image: rails_blob_path(@podcast.cover)\n }\n track \"Viewed Podcast\", title: @podcast.title\n end",
"def metadata (root, info)\n info = decode_strings(info)\n\n # may be useful to some people\n callback(:pdf_version, @xref.pdf_version)\n\n # ye olde metadata\n callback(:metadata, [info]) if info\n\n # new style xml metadata\n if root[:Metadata]\n stream = @xref.object(root[:Metadata])\n callback(:xml_metadata,stream.unfiltered_data)\n end\n\n # page count\n if (pages = @xref.object(root[:Pages]))\n if (count = @xref.object(pages[:Count]))\n callback(:page_count, count.to_i)\n end\n end\n end",
"def configure_res_index(index)\n @res_index = index\n end",
"def set_info\n @page_header = 'Dashboard'\n @page_title = 'LeadAccount | Dashboard'\n @page_icon = 'dashboard'\n end",
"def metadata\n @metadata ||= {}\n end",
"def set_page_meta_tags\n req = self.request\n set_meta_tags_for_url_path(req.base_url, req.fullpath)\n end",
"def index_meta_data\n {\n order: params[:order],\n order_by: params[:order_by],\n page: @comments.current_page,\n per_page: @comments.limit_value,\n total_pages: @comments.total_pages\n }\n end",
"def metadata\n @metadata ||= {}\n end",
"def index ; @index ; end",
"def reset_index_metadata!\n @index_object_type = nil\n end",
"def set_index\n @index = Index.find(params[:id])\n end",
"def set_index\n @index = Index.find(params[:id])\n end",
"def index(index)\n @_chewy_index = index\n end",
"def index; @index; end",
"def consolidate_metadata(book)\n head = index.at_xpath('/html/head')\n head.css('meta[name]').each { |meta| meta.remove }\n book.metadata.each_pair { |name, content|\n content.split(/\\n/).each { |val|\n meta = Nokogiri::XML::Node.new('meta', index)\n meta['name'] = name\n meta['content'] = val\n head.add_child(meta)\n }\n }\n end",
"def index\n @maps = Map.all\n # gon.meta_data = @maps.last.meta_data\n end",
"def index\n @pageinfos = Pageinfo.all\n end",
"def set_vm_metadata(vm_id, metadata)\n @logger.info('Setting virtual machine metadata...')\n end",
"def show\n @interviews = Interview.find(params[:id])\n\n set_meta_tags :title => @interviews.nome_entrevistado, \n :description => 'Publicaremos entrevistas com os principais influentes do mundo da fonoaudiologia', \n :keywords => 'entrevista, fonoaudiologia, profissional de fonoaudiologia'\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interviews }\n end\n end",
"def index_information\n collection.index_information\n end",
"def index_information\n collection.index_information\n end",
"def index_information\n collection.index_information\n end",
"def seo_for_page\n PAGE_SEO_META.each do |meta|\n send(\"set_#{meta}_key\", \"#{seo_condition[:prefix]}#{meta}\")\n end\n\n set_title_variables(seo_variables)\n end",
"def setting_index\n end",
"def index\n set_index_posts\n end",
"def update_initial_metadata(metadata)\n end",
"def index\n# @providers = Provider.all\n @meta_name = \"Proveedores de Sonrisas, son expertos en alguna expresión artística y están dispuestos a llevar su talento a proyectos sociales colombianos, latinoamericanos y del mundo.\"\n @meta_desc = \"Estos son los Proveedores de sonrisas conectados, tienen un perfil de espectáculos que pueden proveer, los ofrecen de varias maneras para distintos públicos. Si tienes algún talento, y te dedicas al entretenimiento, registra tu perfil de proveedor de sonrisas en Conectando Sonrisas.\" \n @providers = Provider.order(\"name\").page(params[:page]).per(8)\n @num_providers = Provider.count \n end",
"def metadata\n @metadata ||= Mash.new\n end",
"def index_information\n @db.index_information(@name)\n end",
"def meta_data\n @meta_data ||= params['metaData']\n end",
"def add_metadata(meta={})\n @local_metadata.deep_merge!(meta.dup)\n end",
"def index\n\t\tprepare_variable_for_index_template\n\tend",
"def meta\n {}\n end",
"def metadata\n @metadata ||= Metadata.new(self)\n end",
"def generate_indexes\n @first_page = first_page\n generate_index('index')\n generate_index('indexes')\n end",
"def index\n @q = Subject.search(params[:q])\n @subjects = @q.result(distinct: true).page(params[:page])\n set_meta_tags({\n title: \"主題列表\",\n keywords: '司法改革,數位典藏',\n og: {\n type: 'website',\n title: \"主題列表\"\n }\n })\n end",
"def index_file_metadata_definitions(opts = {})\n data, _status_code, _headers = index_file_metadata_definitions_with_http_info(opts)\n data\n end",
"def index\n # you can use meta fields from your model instead (e.g. browser_title)\n # by swapping @page for @book in the line below:\n present(@page)\n end"
] |
[
"0.67659014",
"0.6616011",
"0.66055864",
"0.66055864",
"0.6605296",
"0.6555782",
"0.65321064",
"0.65321064",
"0.6521355",
"0.6491442",
"0.64829355",
"0.6482531",
"0.6482531",
"0.6482531",
"0.6482531",
"0.6454628",
"0.6446398",
"0.63646877",
"0.63381803",
"0.63096374",
"0.62749267",
"0.6261739",
"0.6246782",
"0.6232926",
"0.6222597",
"0.61161774",
"0.6111525",
"0.6111525",
"0.6111525",
"0.610544",
"0.60995084",
"0.60995084",
"0.60995084",
"0.60995084",
"0.60995084",
"0.60995084",
"0.60995084",
"0.6070527",
"0.6067356",
"0.6023383",
"0.60209084",
"0.6010008",
"0.5998168",
"0.59775287",
"0.59775287",
"0.59675103",
"0.5955802",
"0.59185356",
"0.58936435",
"0.5893297",
"0.58770144",
"0.58732736",
"0.5869666",
"0.58684134",
"0.58666325",
"0.5840561",
"0.58320594",
"0.58285934",
"0.5827976",
"0.5817137",
"0.58090097",
"0.5802381",
"0.5801899",
"0.5782101",
"0.57704836",
"0.5765607",
"0.5765414",
"0.5760401",
"0.575938",
"0.5749465",
"0.57405776",
"0.5736144",
"0.5724587",
"0.5721515",
"0.5721515",
"0.5694678",
"0.56892914",
"0.5687933",
"0.5685469",
"0.56787777",
"0.5666382",
"0.5657471",
"0.56535673",
"0.56535673",
"0.56535673",
"0.56451166",
"0.5633019",
"0.5629761",
"0.5618544",
"0.56060606",
"0.5599893",
"0.5589288",
"0.5585212",
"0.55759144",
"0.55676055",
"0.5565858",
"0.5563141",
"0.5560634",
"0.55596995",
"0.55491406",
"0.5542413"
] |
0.0
|
-1
|
Set metadata for show page
|
def show_fields=(fields)
@show_fields = ::ActiveSupport::HashWithIndifferentAccess.new fields
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_meta\n puts 'meta'\n end",
"def store_metadata\n html = HTMLParse.new(url)\n self.meta_title = html.title\n self.meta_desc = html.desc\n end",
"def show\n @page_title = @podcast.title\n @page_description = @podcast.extrait\n @page_keywords = \"Podcasts, enseignements, Parole de Dieu, méditation, Jesus Christ\"\n\n set_meta_tags og: {\n title: @podcast.title,\n type: \"article\",\n url: request.url,\n image: rails_blob_path(@podcast.cover)\n }\n\n # adding acticle og\n set_meta_tags article: {\n published_time: @podcast.created_at,\n modified_time: @podcast.updated_at,\n section: @podcast.type_podcast.name,\n tag: \"MPPP\"\n }\n\n # adding twitter card\n set_meta_tags twitter: {\n title: @podcast.title,\n creator: \"MPPP\",\n card: @podcast.extrait,\n site: request.url,\n image: rails_blob_path(@podcast.cover)\n }\n track \"Viewed Podcast\", title: @podcast.title\n end",
"def set_page_metadata\n params[:id].tap do |page|\n if %w(home privacy styles terms).include? page\n page_title t(\"pages.#{page}.page_title\") unless page == 'home'\n page_author t(\"pages.#{page}.page_author\", default: '')\n page_description t(\"pages.#{page}.page_description\", default: '')\n extra_body_classes \"#{page}-page\"\n end\n end\n end",
"def set_page_meta_info(custom_extended_data = {})\n service_response = GetPageMetaInfo.new(\n controller: params[:controller],\n action: params[:action],\n request_url: request.url,\n custom_extended_data: custom_extended_data\n ).perform\n\n unless service_response.success?\n raise 'Incomplete Page Meta.'\n end\n\n page_extended_data = service_response.data\n\n @page_meta_data = page_extended_data[:meta]\n @page_assets_data = page_extended_data[:assets]\n end",
"def set_page_meta_info(custom_extended_data = {})\n service_response = GetPageMetaInfo.new(\n controller: params[:controller],\n action: params[:action],\n request_url: request.url,\n custom_extended_data: custom_extended_data\n ).perform\n\n unless service_response.success?\n raise 'Incomplete Page Meta.'\n end\n\n page_extended_data = service_response.data\n\n @page_meta_data = page_extended_data[:meta]\n @page_assets_data = page_extended_data[:assets]\n end",
"def set_page_meta_info(custom_extended_data = {})\n service_response = GetPageMetaInfo.new(\n controller: params[:controller],\n action: params[:action],\n request_url: request.url,\n custom_extended_data: custom_extended_data\n ).perform\n\n unless service_response.success?\n raise 'Incomplete Page Meta.'\n end\n\n page_extended_data = service_response.data\n\n @page_meta_data = page_extended_data[:meta]\n @page_assets_data = page_extended_data[:assets]\n end",
"def set_meta\n meta.tap do |m|\n m.tag = [{\n system: META_SYSTEM,\n code: META_CODE,\n display: META_DISPLAY\n }]\n end\n end",
"def metadata=(value)\n @metadata = value\n end",
"def metadata=(value)\n @metadata = value\n end",
"def set_individual_action_meta_information(args={})\n\t\t\t@title = args[:title]\n\t\t\t@meta_description = args[:description]\n\t\tend",
"def show\n\n image = @animal.cover.attached? ? rails_blob_path(@animal.cover) : ActionController::Base.helpers.asset_url(\"main-picture.jpeg\", type: :image)\n\n set_meta_tags title: @animal.name, reverse: true,\n description: @animal.description.to_plain_text.truncate(300),\n keywords: I18n.t(@animal.species, count: 1),\n og: {\n title: :title,\n description: :description,\n url: animal_url(@animal),\n image: image\n }\n end",
"def show\n @interviews = Interview.find(params[:id])\n\n set_meta_tags :title => @interviews.nome_entrevistado, \n :description => 'Publicaremos entrevistas com os principais influentes do mundo da fonoaudiologia', \n :keywords => 'entrevista, fonoaudiologia, profissional de fonoaudiologia'\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interviews }\n end\n end",
"def metadata\n @page.metadata\n end",
"def set_page_data\n @page_title = \"Dragos | My Portfolio\"\n @seo_keywords = \"Dragos Portfolio\"\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def set_static_page_metatags! tags, record\n if record.role == 'home'\n tags['title'] = translate('we_meditate')\n image = MediaFile.find_by(id: record.content_blocks.first['data']['image']['id']) if record.content_blocks.present?\n elsif record.parsed_content.present? && record.parsed_content['mediaFiles'].present?\n image = MediaFile.find_by(id: record.parsed_content['mediaFiles'].first)\n end\n\n tags['og:image'] = image_url image.file_url if image.present?\n tags['og:type'] = 'website' if %w[home contact privacy articles meditations subtle_system].include?(record.role)\n end",
"def show\n\n set_meta_tags og: {\n title: @newsletter.title,\n description: truncate(@newsletter.greeting, :length => 300, :separator => /\\w/, :omission => \"…\"),\n image: root_url[0..-2] + ActionController::Base.helpers.asset_url('newsletter.png'),\n url: preview_newsletter_url(@newsletter)\n }, title: @newsletter.title\n\n end",
"def show\n set_meta_tags og: {\n url: \"#{request.base_url + request.original_fullpath}\",\n type: \"website\",\n title: \"#{@news.title} Software Libre y Codigo Abierto Panama\",\n description: @news.news_content.content,\n site_name: \"floss-pa\",\n image: \"https://floss-pa.net/images/logo.png}\"\n }\n set_meta_tags twitter: {\n card: \"summary\",\n description: @news.news_content.content,\n title: @news.title,\n creator: \"@flosspa\",\n image: {\n _: \"https://floss-pa.net/images/logo.png}\",\n width: 100,\n height: 100,\n },\n domain: \"Floss-pa\"\n }\n\n\n set_meta_tags author: user_custom_path(@news.user,@news.user.name.gsub(/\\s/,'-'))\n end",
"def show\n @page_title = @festival.title\n if @festival.image.present?\n @image_meta_url = \"https://westcornwallevents.co.uk\"\n @image_meta_url << @festival.image.to_s\n end\n @page_meta_description = @festival.meta_description\n end",
"def show\n empresa_name ||= @empresa.name\n site ||= \"Guia#{ENV['CURRENT_CITY_CAP']}.es\"\n tags ||= @empresa.tag_list\n description ||= empresa_name + \" | \" + @empresa.category.name + \" : \" + tags\n excerpt ||= @empresa.excerpt\n\n set_meta_tags title: empresa_name,\n site: site,\n reverse: true,\n description: description,\n keywords: tags,\n\n twitter: {\n card: \"summary\",\n site: site,\n title: empresa_name + \" | \" + site,\n description: excerpt,\n image: @empresa.logo.url\n },\n\n og: {\n title: empresa_name,\n description: excerpt,\n type: 'website',\n url: empresa_url(@empresa),\n image: @empresa.logo.url\n }\n\n (@hor, @abierto) = horario()\n @promos = @empresa.promos.last(3)\n end",
"def meta(meta_data)\n @_meta = meta_data\n end",
"def set_info\n @page_header = 'Insight Engine'\n @page_secondary = 'Let\\'s get a view at 10,000 feet.'\n @page_title = 'LeadAccount | Insight Engine'\n @page_icon = 'lightbulb'\n end",
"def set_bookmark_meta_data\n begin\n page = Pismo::Document.new(self.full_url)\n self.name = page.html_title\n self.favicon_url = page.favicon\n self.description = page.description\n rescue => e\n self.description = \"Error => #{e}\"\n ensure\n self.save\n end\n end",
"def set_metadata(*args)\n self.metadata.set(*args)\n end",
"def metadata\n {\n title: flickr_title,\n description: description\n }\n end",
"def update_metadata\n response = Net::HTTP.post(URI('https://api.linkpreview.net'),\n { 'key' => ENV['LINKPREVIEW_API_KEY'],\n 'q' => self.url }.to_json)\n\n body = JSON.parse(response.body)\n self.title = body['title']\n self.image = body['image']\n self.description = body['description']\n save\n end",
"def show\n @more_deals = Storepromotion.where(spcategory_id: @storepromotion.spcategory_id)\n impressionist(@storepromotion)\n set_meta_tags title: @storepromotion.sp_title,\n site: 'Oh,igottabuythis',\n revierse: true,\n description: @storepromotion.sp_description,\n keywords: @storepromotion.sp_title,\n twitter: {\n card: \"summary\",\n site: \"@OhIgottabuythis\",\n title: @storepromotion.sp_title,\n description: @storepromotion.sp_description,\n image: @storepromotion.sp_image\n },\n og: {\n title: @storepromotion.sp_title,\n description: @storepromotion.sp_description,\n type: 'website',\n url: storepromotion_url(@storepromotion),\n image: @storepromotion.sp_image\n }\n end",
"def set_record_metatags! tags, record\n tags['title'] = record.name\n tags['description'] = record.excerpt if record.respond_to?(:excerpt)\n tags['og:url'] = wm_url_for(record)\n tags['og:type'] = 'article'\n tags['og:image'] = record.thumbnail.url if record.try(:thumbnail).present?\n tags['og:article:published_time'] = record.created_at.to_s(:db)\n tags['og:article:modified_time'] = record.updated_at.to_s(:db)\n tags['og:article:section'] = record.category&.name if record.is_a?(Article)\n tags['twitter:card'] = 'summary'\n\n set_locale_metatags!(tags, record) if record.try(:translatable?)\n set_static_page_metatags!(tags, record) if record.is_a?(StaticPage)\n set_video_metatags!(tags, record) if record.try(:vimeo_metadata).present?\n end",
"def show\n @public_view = true\n page_meta[:workout_description] = @workout.short_description\n page_meta[:user_description] = @workout.user.name\n end",
"def show\n @page_title = @news.title\n @page_description = @news.description\n end",
"def show\n @meta_title = @page.title\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @page }\n end\n end",
"def show\n desc = @event.desc.truncate(160)\n\n set_meta_tags description: desc,\n og: {\n title: \"Cosplay event - #{@event.title}\",\n type: 'website',\n description: desc,\n image: @event.image.attached? ? @event.image.variant(resize: \"1024\", interlace: \"plane\").processed.service_url : nil\n }\n end",
"def set_title_and_description\n \t\tresp = get_resp(self.url)\n \t\tself.title = resp.match(/<title>(.+)<\\/title>/)[1]\n \t\tself.description = resp.match(/<meta name=\"description\" content=\"([^\\\"]*)/)[1]\n \t\tself.save!\n \tend",
"def show\n @title = @material_item.title\n @meta_keywords = @material_item.meta_keywords\n @meta_description = @material_item.meta_description\n end",
"def show\n @talk = Talk.find(params[:id])\n @chapters = @talk.chapters.all\n @page_title = \"#{@talk.name}\"\n @meta_data = {:page_title => \"#{@talk.name}\", :og_image => \"#{@talk.banner_src}\", :og_title => \"#{@talk.name} | Chicago Ideas Week\", :og_type => \"article\", :og_desc => (@talk.description) ? \"#{@talk.description[0..200]}\" : \"\"}\n end",
"def show\n set_meta_tags title: @item.title, reverse: true\n @rss = Rss.find(@item.rss_id)\n set_meta_tags twitter: {\n card: \"photo\",\n site: request.url,\n title: @item.title,\n image: @item.image,\n }\n end",
"def show\n # set_meta_tags MetaTag.new({host: request.host, movie: @movie}).hash_options\n impressionist(@post, nil, { unique: [:session_hash] })\n @post.impressionist_count(:filter => :params)\n\n set_meta_tags title: @post.title,\n site: 'Cat Blog',\n description: @post.summary,\n keywords: @post.keywords,\n og: {\n title:'Cat Blog',\n description: @post.summary,\n type: 'website',\n url: post_url(@post)\n }\n\n\n\n end",
"def metadata\n return super if block_given?\n\n @metadata || @view_context.render(@metadata_component.new(fields: presenter.field_presenters, show: show?))\n end",
"def metadata=(_); end",
"def meta\n {\n source: @host,\n favicon: @favicon,\n url: @url,\n title: title,\n description: @description,\n keywords: keywords,\n image_url: @main_image,\n extractable: extractable?\n }\n end",
"def metadata\n @meta_data\n end",
"def fetch_metadata\n self.user_id ||= biblio_commons.user_id\n self.title ||= biblio_commons.name\n self.thumbnail ||= RemoteImage.new(:url => biblio_commons.thumbnail_url)\n end",
"def set_seo_meta(title,keywords = '',desc = '')\n if title\n @page_title = \"#{title}\"\n if params[:page]\n @page_title += \" » (First#{params[:page]}Page)\"\n end\n @page_title += \" » #{@setting.site_name}\"\n else\n @page_title = @setting.site_name\n end\n @meta_keywords = keywords\n @meta_description = desc\n end",
"def show\n @experiences = @trip.experiences\n\n\n if @experiences.present?\n if @trip.experiences[0].photos.present?\n prepare_meta_tags(title: @trip.name,\n description: @trip.description.truncate(50), \n keywords: @trip.name.split(\",\"),\n image: @trip.experiences[0].photos[0].image, \n og: {\n url: request.original_url,\n site_name: @trip.name,\n title: @trip.name,\n image: @trip.experiences[0].photos[0].image,\n description: @trip.description,\n type: 'website'\n },\n twitter: {\n site_name: @trip.name,\n site: '@nomada5',\n card: 'summary',\n description: @trip.description,\n image: @trip.experiences[0].photos[0].image,\n }\n )\n end\n end\n\n end",
"def meta_data\n @meta_data ||= params['metaData']\n end",
"def show\n #@activity = Activity.find(params[:id])\n @activity = Activity.find_by_permalink(params[:id])\n \n @meta_title=@activity.name + \" a Jesolo\"\n @meta_keywords=@activity.metatag\n @meta_description=@activity.description\n\n respond_to do |format|\n format.html # show.html.erb\n format.iphone {render :layout => false}\n format.xml { render :xml => @activity }\n end\n end",
"def page_metadata(page)\n data = []\n add_data = Proc.new do |content|\n data.push(content_tag(:div, content))\n end\n \n filing = page.filing\n doc = page.filing_doc\n\n [[\"Filing: #{filing.fcc_num}\", fcc_filing_url(filing)],\n [\"Document: #{doc.fcc_num}\", doc.url]].each do |args|\n add_data[link_to(*args)]\n end\n\n add_data[\"Pages: #{doc.pagecount}\"] \n\n %w(author lawfirm applicant).each do |name|\n if (value = filing.send(name)).present?\n add_data[\"#{name.titleize}: #{value}\"]\n end\n end\n\n data.join(\"\\n\").html_safe\n end",
"def set_show_page_attributes\n @show_page_attributes = [\n :id,\n :name,\n ]\n end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def site_meta\n end",
"def site_meta\n end",
"def set_meta( title, *description )\n\t\t@title = title\n\t\t@description = description.first[0..200] unless description.first.blank?\n\tend",
"def show\n @page_title = @tutorial.title\n @seo_keywords = @tutorial.body\n end",
"def set_info\n @page_header = 'Dashboard'\n @page_title = 'LeadAccount | Dashboard'\n @page_icon = 'dashboard'\n end",
"def metadata(&blk)\n blk.call(object.metadata_attributes) if object.has_metadata?\n nil # This ensures nothing gets written to the template if someone uses '=' to call this.\n end",
"def set_album\n @album = Album.find(params[:id])\n @page_content_title = @album.title if @album.present?\n end",
"def show\n\n @main_SEO_title = @show.name\n \n end",
"def set_pageinfo\n @pageinfo = Pageinfo.find(params[:id])\n end",
"def meta_data\n #object = instance_variable_get('@'+controller_name.singularize)\n object = instance_variable_get('@resource')\n meta = {}\n\n if object.kind_of? ActiveRecord::Base\n meta[:keywords] = object.meta_keywords if object[:meta_keywords].present?\n meta[:description] = object.meta_description if object[:meta_description].present?\n end\n\n #if meta[:description].blank? && object.kind_of?(Spree::Product)\n # meta[:description] = strip_tags(truncate(object.description, length: 160, separator: ' '))\n #end\n\n meta.reverse_merge!({\n keywords: current_store.meta_keywords,\n description: current_store.meta_description,\n }) if meta[:keywords].blank? or meta[:description].blank?\n meta\n end",
"def set_descriptive_page\n @descriptive_page = DescriptivePage.find(params[:id])\n end",
"def show\n\n image = ''\n\n if !@ebook.image_url.nil?\n image = @ebook.image_url\n end\n\n prepare_meta_tags(title: @ebook.title + ' - Ebooks',\n description: @ebook.summary,\n keywords: '',\n image: @ebook.facebook_image_url,\n og: {\n title: @ebook.title,\n description: @ebook.summary,\n image: @ebook.facebook_image_url,\n type: 'article',\n 'image:type': 'image/jpg',\n updated_time: @ebook.updated_at.strftime('%FT%T')\n },\n article: {\n #tag: @article.tag_list,\n author: '947897365241721',\n section: 'Blog',\n published_time: @ebook.created_at.strftime('%FT%T'),\n modified_time: @ebook.updated_at.strftime('%FT%T')\n },\n twitter: {\n title: @ebook.title,\n card: '',\n description: @ebook.summary,\n image: @ebook.facebook_image_url\n })\n\n @banner = Banner.where(name: 'ebook').take\n end",
"def show\r\n @page_title = @page.title\r\n end",
"def fetch_metadata\n self.title ||= biblio_commons.title\n self.thumbnail ||= RemoteImage.new(:url => biblio_commons.thumbnail_url)\n self.format ||= biblio_commons.format\n end",
"def set_title_and_description\n website = Nokogiri::HTML(open(self.url))\n self.title = website.css('title').text\n self.description = website.at(\"meta[name='description']\")['content'] unless website.at(\"meta[name='description']\").nil?\n end",
"def show\n @meta_title = @post.title\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post }\n end\n end",
"def print_meta_head\n puts \"\\nDataset: #{@meta_data.name}\"\n end",
"def show\n @story = Story.find(params[:id])\n\n # Set meta information\n @page_title = @story.title\n @page_description = @story.subtitle\n\n if Arrowhead.is_arrowhead_story? @story\n @arrowhead_stories = Arrowhead.stories\n @i = @arrowhead_stories.find_index(@story)\n if @i\n @prev = @i > 0 ? @i - 1 : nil \n @next = @i < @arrowhead_stories.length - 1 ? @i + 1 : nil\n end\n set_meta_tags :og => {\n :title => @story.title,\n :description => @story.subtitle,\n :type => 'article',\n :url => url_for(@story),\n :image => URI.join(root_url, view_context.image_path('arrowhead_ogimage.jpg'))\n }\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @story.to_json(:include => { :scenes => { :include => :paragraphs }}) }\n end\n end",
"def metadata\n if !@permitted\n render :action => :reserved\n return\n end\n render :action => :metadata if @note\n render :nothing => true\n end",
"def set_show_page_attributes\n @show_page_attributes = [:group, :names, :contact, :room_count_zh, :room_type_zh, :check_in_out, :nights]\n end",
"def show\n \n @article = Article.find_by_full_url_and_published( params[:slug], true )\n \n if @article.nil?\n not_found and return \n end\n \n # set meta content\n @page_title = @article.title\n self.meta_description = @article.extract_rendered\n self.og_image = @article.masthead.file.url(:original) unless @article.masthead.nil?\n \n # comments\n @comments = @article.comments.latest.limit(5)\n end",
"def show\n @org = Org.find(params[:id])\n meta_img = @org.photo_url.nil? ? og_fallback : @org.photo_url\n set_meta_tags og: {\n title: \"#{@org.name} on Events@Penn\",\n type: 'website',\n description: @org.bio,\n image: meta_img\n }\n set_meta_tags twitter: {\n card: 'summary',\n title: \"#{@org.name} on Events@Penn\",\n image: meta_img\n }\n ScrapeNewEventsJob.perform_later(@org) if @org.fb? && user_signed_in?\n end",
"def set_title(new_title, opts={})\n if self.datastreams.has_key?(\"descMetadata\")\n desc_metadata_ds = self.datastreams[\"descMetadata\"]\n if desc_metadata_ds.respond_to?(:title_values)\n desc_metadata_ds.title_values = new_title\n else\n desc_metadata_ds.title = new_title\n end\n end\n end",
"def meta\n options[:meta]\n end",
"def set_page\n page = find_page(params[:id])\n @url = page[0]\n @title = page[1]\n @contents = find_file(page[2])\n end",
"def custom_meta_data\n end",
"def show\n # @most_hotdeals = Hotdeal.order(\"impressions_count DESC\").limit(10)\n impressionist(@hotdeal)\n set_meta_tags title: @hotdeal.h_title,\n site: 'Oh,igottabuythis',\n revierse: true,\n description: @hotdeal.h_spare_21,\n keywords: 'deals, discounts',\n twitter: {\n card: \"summary\",\n site: \"@OhIgottabuythis\",\n title: @hotdeal.h_title,\n description: @hotdeal.h_spare_21,\n image: @hotdeal.h_image\n },\n og: {\n title: @hotdeal.h_title,\n description: @hotdeal.h_spare_21,\n type: 'website',\n url: hotdeal_url(@hotdeal),\n image: @hotdeal.h_image\n }\n end",
"def show\n @page_title='Aktuator'\n end",
"def show\n set_persona_biometria\n end",
"def show\n @comment = Comment.new\n @comments = @event.comments.paginate(:page => params[:page], :per_page => 4)\n @event_attachments = @event.event_attachments.all\n @providers = @event.providers.all\n\n\nif @event.event_attachments.present?\nprepare_meta_tags(title: @event.nombre,\n description: @event.categoria, \n keywords: @event.tags\n)\nend\n\n end",
"def set_video_metatags! tags, record\n metadata = record.vimeo_metadata\n metadata = metadata[:horizontal] if metadata.key?(:horizontal)\n return unless metadata.present?\n\n tags.merge!({\n 'og:type' => 'video.other',\n 'og:image' => metadata[:thumbnail],\n 'og:video' => metadata[:download_url],\n 'og:video:duration' => metadata[:duration],\n 'og:video:release_date' => record.created_at.to_s(:db),\n 'twitter:card' => 'player',\n 'twitter:player:url' => metadata[:embed_url],\n 'twitter:player:width' => metadata[:width],\n 'twitter:player:height' => metadata[:height],\n })\n end",
"def metadata\n attributes['metadata'] ||= {}\n attributes['metadata']\n end",
"def metadata_options\n data[:metadata_options]\n end",
"def set_show_detail\n @show_detail = true\n end",
"def show\n @meta_content = MetaContent.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meta_content }\n end\n end",
"def present_meta(data, attrs = {})\n d = data.class.respond_to?(:count) ? [data] : data\n meta = {\n status: 'OK',\n method: @method,\n record_count: d.nil? ? 0 : d.size,\n response_time: Time.now - @start_time\n }.merge(attrs)\n present meta, with: Grape::Presenters::Presenter\n end",
"def set_page_meta_tags\n req = self.request\n set_meta_tags_for_url_path(req.base_url, req.fullpath)\n end",
"def meta\n @d[:meta]\n end",
"def meta\n meta = {}\n set_meta(meta)\n return meta\n end",
"def show\n @page_title = @news.title\n end",
"def seo_for_page\n PAGE_SEO_META.each do |meta|\n send(\"set_#{meta}_key\", \"#{seo_condition[:prefix]}#{meta}\")\n end\n\n set_title_variables(seo_variables)\n end",
"def show\n @page = Page.where(:permalink => params[:permalink]).first if params[:permalink]\n @page = Page.where(:permalink => params[:id]).first if params[:id]\n # @page = Page.where(:permalink => params[:id]).first\n @page = @home_page if @page.nil?\n \n @meta_title = @page.meta_title\n @meta_keywords = @page.meta_keywords\n @meta_description = @page.meta_description\n \n respond_to do |format|\n format.html\n format.xml { render :xml => @page }\n end\n end"
] |
[
"0.72025263",
"0.69920105",
"0.6989512",
"0.69105196",
"0.68542737",
"0.68542737",
"0.68542737",
"0.68460894",
"0.68245846",
"0.68245846",
"0.68170434",
"0.67233086",
"0.66963804",
"0.6692096",
"0.66808486",
"0.6680172",
"0.6680172",
"0.6680172",
"0.6680172",
"0.66790855",
"0.6671687",
"0.6651855",
"0.66335696",
"0.6630434",
"0.65690094",
"0.6565953",
"0.6565086",
"0.65581954",
"0.65506876",
"0.6516015",
"0.6494903",
"0.6492429",
"0.64804965",
"0.6457675",
"0.6449381",
"0.64454466",
"0.643378",
"0.64319676",
"0.64276534",
"0.6406212",
"0.63865924",
"0.6353634",
"0.6285164",
"0.6270726",
"0.62643147",
"0.625961",
"0.62065685",
"0.6189191",
"0.61884445",
"0.6177949",
"0.6151513",
"0.6148243",
"0.61433506",
"0.61433506",
"0.61433506",
"0.61433506",
"0.61433506",
"0.61433506",
"0.61433506",
"0.6130202",
"0.6130202",
"0.61278564",
"0.61160195",
"0.6111012",
"0.6105815",
"0.61038005",
"0.61015135",
"0.60900134",
"0.60853726",
"0.6075829",
"0.6065845",
"0.6062222",
"0.6061911",
"0.60609525",
"0.60539824",
"0.60444397",
"0.603153",
"0.6029526",
"0.6017458",
"0.60091954",
"0.6005444",
"0.5999486",
"0.59920156",
"0.5970614",
"0.59651816",
"0.5937946",
"0.59309196",
"0.59302664",
"0.59188056",
"0.5917129",
"0.59119624",
"0.59092987",
"0.58773744",
"0.58753586",
"0.5875305",
"0.587498",
"0.5872",
"0.58656925",
"0.5865522",
"0.58462214",
"0.58427954"
] |
0.0
|
-1
|
Set metadata for form (new/edit) page
|
def form_fields=(fields)
@form_fields = ::ActiveSupport::HashWithIndifferentAccess.new fields
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_new_form_information\n @information[:subtitle] = t('view.permissions.new_title')\n @information[:form_url] = [@parent, 'permissions', no_firm: @no_firm]\n end",
"def set_edit_form_information\n @information[:subtitle] = t('view.permissions.edit_title')\n @information[:form_url] = [@parent, 'permission', no_firm: @no_firm]\n end",
"def set_forminfo\n @forminfo = Forminfo.find(params[:id])\n end",
"def edit_metadata_fields\n end",
"def set_page_metadata\n params[:id].tap do |page|\n if %w(home privacy styles terms).include? page\n page_title t(\"pages.#{page}.page_title\") unless page == 'home'\n page_author t(\"pages.#{page}.page_author\", default: '')\n page_description t(\"pages.#{page}.page_description\", default: '')\n extra_body_classes \"#{page}-page\"\n end\n end\n end",
"def set_meta\n puts 'meta'\n end",
"def set_bookmark_meta_data\n begin\n page = Pismo::Document.new(self.full_url)\n self.name = page.html_title\n self.favicon_url = page.favicon\n self.description = page.description\n rescue => e\n self.description = \"Error => #{e}\"\n ensure\n self.save\n end\n end",
"def set_meta\n meta.tap do |m|\n m.tag = [{\n system: META_SYSTEM,\n code: META_CODE,\n display: META_DISPLAY\n }]\n end\n end",
"def store_metadata\n html = HTMLParse.new(url)\n self.meta_title = html.title\n self.meta_desc = html.desc\n end",
"def set_new_form_vars\n @edit = {}\n @edit[:key] = \"sm_edit__new\"\n @edit[:new] = {}\n @edit[:current] = {}\n\n @edit[:new][:name] = nil\n @edit[:sm_types] = StorageManager.storage_manager_types\n @edit[:new][:hostname] = nil\n @edit[:new][:ipaddress] = nil\n @edit[:new][:port] = nil\n @edit[:new][:sm_type] = nil\n # @edit[:new][:agent_type] = nil\n @edit[:new][:zone] = \"default\"\n @edit[:server_zones] = []\n zones = Zone.all\n zones.each do |zone|\n @edit[:server_zones].push(zone.name)\n end\n\n @edit[:new][:userid] = nil\n @edit[:new][:password] = nil\n @edit[:new][:verify] = nil\n\n session[:verify_sm_status] = nil\n set_verify_status\n\n @edit[:current] = @edit[:new].dup\n session[:edit] = @edit\n end",
"def new\n @metaform = Metaform.new\n setup_mrows()\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @metaform }\n end\n end",
"def fill_out_form(hash)\n self.main_title=hash[:main_title]\n self.main_author=hash[:main_author]\n self.co_authors=hash[:co_authors]\n self.publisher=hash[:publisher]\n self.place_of_publication=hash[:place]\n self.volume_title=hash[:volume_title]\n self.volume_information=hash[:volume_info]\n self.year=hash[:year]\n self.number=hash[:number]\n self.series_title=hash[:series]\n self.url=hash[:url]\n end",
"def set_individual_action_meta_information(args={})\n\t\t\t@title = args[:title]\n\t\t\t@meta_description = args[:description]\n\t\tend",
"def form_setup\n\tend",
"def meta(meta_data)\n @_meta = meta_data\n end",
"def set_page_meta_info(custom_extended_data = {})\n service_response = GetPageMetaInfo.new(\n controller: params[:controller],\n action: params[:action],\n request_url: request.url,\n custom_extended_data: custom_extended_data\n ).perform\n\n unless service_response.success?\n raise 'Incomplete Page Meta.'\n end\n\n page_extended_data = service_response.data\n\n @page_meta_data = page_extended_data[:meta]\n @page_assets_data = page_extended_data[:assets]\n end",
"def set_page_meta_info(custom_extended_data = {})\n service_response = GetPageMetaInfo.new(\n controller: params[:controller],\n action: params[:action],\n request_url: request.url,\n custom_extended_data: custom_extended_data\n ).perform\n\n unless service_response.success?\n raise 'Incomplete Page Meta.'\n end\n\n page_extended_data = service_response.data\n\n @page_meta_data = page_extended_data[:meta]\n @page_assets_data = page_extended_data[:assets]\n end",
"def set_page_meta_info(custom_extended_data = {})\n service_response = GetPageMetaInfo.new(\n controller: params[:controller],\n action: params[:action],\n request_url: request.url,\n custom_extended_data: custom_extended_data\n ).perform\n\n unless service_response.success?\n raise 'Incomplete Page Meta.'\n end\n\n page_extended_data = service_response.data\n\n @page_meta_data = page_extended_data[:meta]\n @page_assets_data = page_extended_data[:assets]\n end",
"def new_page(obj, opts={})\n page do\n form_attr = form_attributes(:action=>url_for(\"create\"))\n Forme.form(obj, form_attr, form_opts(form_attr[:action])) do |f|\n model.columns_for(:new, request).each do |column|\n col_opts = column_options_for(:new, request, obj, column)\n if html = model.edit_html_for(obj, column, :new, request)\n col_opts = col_opts.merge(:html=>html)\n end\n f.input(column, col_opts)\n end\n f.button(:value=>'Create', :class=>'btn btn-primary')\n end\n end\n end",
"def create\n @metaform = Metaform.new(params[:metaform])\n @metaform.user_id = current_user.id\n\n respond_to do |format|\n if @metaform.save\n format.html { redirect_to @metaform, notice: 'Metaform was successfully created.' }\n format.json { render json: @metaform, status: :created, location: @metaform }\n else\n format.html { render action: \"new\" }\n format.json { render json: @metaform.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_document_metaform(document_id, mf_id)\n if (document_id == nil or document_id == \"\" or \n mf_id == nil or mf_id == \"\")\n return false\n end\n \n metaform = Metaform.find(mf_id)\n document = Document.find(document_id)\n\n if (document.stuffing_metadata == nil or document.stuffing_metadata.empty?)\n document.stuffing_metadata = [{\"Metaform\" => metaform.name}]\n else\n document.stuffing_metadata << {\"Metaform\" => metaform.name}\n end\n \n metaform.metarows.each do |row|\n document.stuffing_metadata << {row['key'] => row['value']}\n end\n document.save\n \n return true\n end",
"def all_talent_forms_page\n \t@male = Male.new\n \t@female = Female.new\n \t@photo = Photo.new\n \t@hair = Hair.new\n \t@mua = Mua.new\n \t@stylist = Stylist.new\n \t@client = Client.new\n end",
"def metadata\n if !@permitted\n render :action => :reserved\n return\n end\n render :action => :metadata if @note\n render :nothing => true\n end",
"def metadata(path)\n resp, data = get(path)\n meta = {}\n\n data.scan(/<input type=\"hidden\" name=\"__([A-Z]+)\" id=\"__[A-Z]+\" value=\"(.*?)\" \\/>/).each do |match|\n meta[\"__#{match[0]}\"] = CGI.escape(match[1])\n end\n\n meta\n end",
"def set_custom_form\n @custom_form = CustomForm.find(params[:id])\n end",
"def pxe_image_type_set_form_vars\n @edit = {}\n @edit[:pxe_id] = @pxe_image_type.id\n @edit[:prov_types] = {:host => _('Host'), :vm => _('VM and Instance')}\n @edit[:new] = {}\n @edit[:current] = {}\n @edit[:key] = \"pxe_image_type_edit__#{@pxe_image_type.id || \"new\"}\"\n @edit[:rec_id] = @pxe_image_type.id || nil\n\n @edit[:new][:name] = @pxe_image_type.name\n @edit[:new][:provision_type] = @pxe_image_type.provision_type\n @edit[:current] = copy_hash(@edit[:new])\n session[:edit] = @edit\n end",
"def setup_resources\n if params[:metadata_ingest_form]\n template_name = params[:metadata_ingest_form].delete(:template_name)\n end\n\n defaults = {\n :asset_map => asset_map,\n :template_map => template_map,\n :asset_class => asset_class,\n }\n @form = OregonDigital::Metadata::TemplateFormContainer.new(params.merge(defaults))\n @form.asset.title = template_name if template_name\n end",
"def form_content_options(pid = nil)\n {:view => form_template, :layout => 'form_wrapper.html.erb',\n :locals => {:container => \"#{dom_id}_form\", :record => record, :pid => pid, :multipart_form => multipart_form}}\n end",
"def form_fields\n [:description, :status, :magic]\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def metadata=(metadata)\n @metadata = metadata\n end",
"def set_form_vars\n @edit = {}\n @edit[:sm_id] = @sm.id\n @edit[:key] = \"sm_edit__#{@sm.id || \"new\"}\"\n @edit[:new] = {}\n @edit[:current] = {}\n\n @edit[:new][:name] = @sm.name\n @edit[:sm_types] = StorageManager.storage_manager_types\n @edit[:new][:hostname] = @sm.hostname\n @edit[:new][:ipaddress] = @sm.ipaddress\n @edit[:new][:port] = @sm.port\n @edit[:new][:sm_type] = @sm.type_description\n # @edit[:new][:agent_type] = @sm.agent_type\n if @sm.zone.nil? || @sm.my_zone == \"\"\n @edit[:new][:zone] = \"default\"\n else\n @edit[:new][:zone] = @sm.my_zone\n end\n @edit[:server_zones] = []\n zones = Zone.all\n zones.each do |zone|\n @edit[:server_zones].push(zone.name)\n end\n\n @edit[:new][:userid] = @sm.authentication_userid\n @edit[:new][:password] = @sm.authentication_password\n @edit[:new][:verify] = @sm.authentication_password\n\n session[:verify_sm_status] = nil\n set_verify_status\n\n @edit[:current] = @edit[:new].dup\n session[:edit] = @edit\n end",
"def set_form\n form = params[:form_txt] + \"_form\"\n @tab = params[:tab_id]\n form_hash_for_loan_details if !@loan_hash\n update_respond_to_parent(form,@tab,FLASH_MESSAGES['properties']['406'],nil)\n end",
"def set_form(easy)\n end",
"def set_form\n @form = FormKit::Form.find(params[:id])\n end",
"def forms; end",
"def new\r\n\t\t@titrePage = \"S'identifier\"\r\n\tend",
"def edit_form_hash(extras = {})\n res = extras.dup\n\n res[:remote] = true\n res[:html] ||= {}\n res[:html].merge!(\n 'data-result-target' => \"#container-entry-#{@container.id}-#{@download.id}-#{@download.class.retrieval_type} \" \\\n '.bem-classification-attrs',\n 'data-template' => \"#{hyphenated_name}-result-template\"\n )\n res[:url] =\n master_filestore_classification_path(object_instance.master_id,\n object_instance.id,\n container_id: @container.id,\n retrieval_type: @retrieval_type,\n activity_log_id: @activity_log&.id,\n activity_log_type: @activity_log&.item_type)\n\n res\n end",
"def standard_form name, object, &block\n url = { :action => object.new_record? ? \"index\" : \"show\" }\n html = { :class => \"standard\",\n :style => (@edit_on ? '' : \"display: none;\"),\n :multipart => true }\n concat form_tag(url, html) + \"<fieldset>\", block.binding\n concat '<input name=\"_method\" type=\"hidden\" value=\"put\" />', block.binding unless object.new_record?\n yield LabelingFormBuilder.new(name, object, self, {}, block)\n concat \"</fieldset>\" + end_form_tag, block.binding\n end",
"def new\n @meta_content = MetaContent.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meta_content }\n end\n end",
"def get_form_vars\n @sm = @edit[:sm_id] ? StorageManager.find_by_id(@edit[:sm_id]) : StorageManager.new\n\n @edit[:new][:name] = params[:name] if params[:name]\n @edit[:new][:hostname] = params[:hostname] if params[:hostname]\n @edit[:new][:ipaddress] = params[:ipaddress] if params[:ipaddress]\n @edit[:new][:port] = params[:port] if params[:port]\n @edit[:new][:sm_type] = params[:sm_type] if params[:sm_type]\n # @edit[:new][:agent_type] = params[:agent_typ] if params[:agent_typ]\n @edit[:new][:zone] = params[:server_zone] if params[:server_zone]\n\n @edit[:new][:userid] = params[:userid] if params[:userid]\n @edit[:new][:password] = params[:password] if params[:password]\n @edit[:new][:verify] = params[:verify] if params[:verify]\n restore_password if params[:restore_password]\n set_verify_status\n end",
"def initialize(form, field_metadata, data_dictionary:, position: nil, section: nil, sub_section: nil)\n super()\n\n self.form = form\n self.form_name = form&.name\n\n self.data_dictionary = data_dictionary\n self.study = data_dictionary.study\n\n self.def_metadata = field_metadata.dup\n self.name = field_metadata[:field_name].to_sym\n self.title = field_metadata[:section_header]\n self.label = field_metadata[:field_label]\n self.label_note = field_metadata[:field_note]\n self.annotation = field_metadata[:field_annotation]\n self.is_required = field_metadata[:required_field] == 'y'\n\n self.valid_type = field_metadata[:text_validation_type_or_show_slider_number]\n self.valid_min = field_metadata[:text_validation_min]\n self.valid_max = field_metadata[:text_validation_max]\n self.is_identifier = field_metadata[:identifier] == 'y'\n\n self.storage_type = 'database'\n self.db_or_fs = ActiveRecord::Base.connection_db_config.database\n self.schema_or_path, self.table_or_file = schema_and_table_name\n self.position = position\n self.section = section\n self.sub_section = sub_section\n end",
"def set_title_and_description\n \t\tresp = get_resp(self.url)\n \t\tself.title = resp.match(/<title>(.+)<\\/title>/)[1]\n \t\tself.description = resp.match(/<meta name=\"description\" content=\"([^\\\"]*)/)[1]\n \t\tself.save!\n \tend",
"def meta_data\n @meta_data ||= params['metaData']\n end",
"def set_form\n #@form = Form.find(params[:id])\n end",
"def set_info\n @page_header = 'Insight Engine'\n @page_secondary = 'Let\\'s get a view at 10,000 feet.'\n @page_title = 'LeadAccount | Insight Engine'\n @page_icon = 'lightbulb'\n end",
"def form; end",
"def metadata=(value)\n @metadata = value\n end",
"def metadata=(value)\n @metadata = value\n end",
"def set_form\n @form = Form.find(params[:form_id])\n end",
"def set_form\n @form = Form.find(params[:form_id])\n end",
"def set_form\n @form = Form.find(params[:form_id])\n end",
"def set_form\n @form = Form.find(params[:form_id])\n end",
"def meta\n meta = {}\n set_meta(meta)\n return meta\n end",
"def new_basic_predetails\n\t\t@petsitter = Petsitter.new #object that form will bind to \n\t\t\n\t\t# we could have put what is below directly in the view but the controller's job is supposed to be to ask data from the model and set it up for the views - the view should be completely decoupled from the model( the view should never know of the model's existence )\n\t\t@all_residential_areas_in_nairobi = ResidentialArea.all\n\tend",
"def set_form_vars\n form_instance_vars\n\n @edit = {}\n @edit[:ems_id] = @ems.id\n @edit[:key] = \"ems_edit__#{@ems.id || \"new\"}\"\n @edit[:new] = {}\n @edit[:current] = {}\n\n @edit[:new][:name] = @ems.name\n @edit[:new][:provider_region] = @ems.provider_region\n @edit[:new][:hostname] = @ems.hostname\n @edit[:new][:emstype] = @ems.emstype\n @edit[:new][:port] = @ems.port\n @edit[:new][:api_version] = @ems.api_version\n @edit[:new][:provider_id] = @ems.provider_id\n\n if @ems.kind_of?(ManageIQ::Providers::Openstack::CloudManager) ||\n @ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager)\n # Special behaviour for OpenStack while keeping it backwards compatible for the rest\n @edit[:protocols] = retrieve_openstack_security_protocols\n else\n @edit[:protocols] = [['Basic (SSL)', 'ssl'], ['Kerberos', 'kerberos']]\n end\n\n if @ems.kind_of?(ManageIQ::Providers::Openstack::CloudManager) ||\n @ems.kind_of?(ManageIQ::Providers::Openstack::InfraManager)\n # Special behaviour for OpenStack while keeping it backwards compatible for the rest\n @edit[:new][:default_security_protocol] = @ems.security_protocol ? @ems.security_protocol : 'ssl'\n else\n if @ems.id\n # for existing provider before this fix, set default to ssl\n @edit[:new][:default_security_protocol] = @ems.security_protocol ? @ems.security_protocol : 'ssl'\n else\n @edit[:new][:default_security_protocol] = 'kerberos'\n end\n end\n\n @edit[:new][:realm] = @ems.realm if @edit[:new][:emstype] == \"scvmm\"\n if @ems.zone.nil? || @ems.my_zone == \"\"\n @edit[:new][:zone] = \"default\"\n else\n @edit[:new][:zone] = @ems.my_zone\n end\n\n @edit[:server_zones] = Zone.order('lower(description)').collect { |z| [z.description, z.name] }\n\n @edit[:openstack_infra_providers] = ManageIQ::Providers::Openstack::Provider.order('lower(name)').each_with_object([[\"---\", nil]]) do |openstack_infra_provider, x|\n x.push([openstack_infra_provider.name, openstack_infra_provider.id])\n end\n\n @edit[:openstack_api_versions] = retrieve_openstack_api_versions\n @edit[:nuage_api_versions] = retrieve_nuage_api_versions\n @edit[:vmware_cloud_api_versions] = retrieve_vmware_cloud_api_versions\n\n @edit[:new][:default_userid] = @ems.authentication_userid\n @edit[:new][:default_password] = @ems.authentication_password\n @edit[:new][:default_verify] = @ems.authentication_password\n\n @edit[:new][:metrics_userid] = @ems.has_authentication_type?(:metrics) ? @ems.authentication_userid(:metrics).to_s : \"\"\n @edit[:new][:metrics_password] = @ems.has_authentication_type?(:metrics) ? @ems.authentication_password(:metrics).to_s : \"\"\n @edit[:new][:metrics_verify] = @ems.has_authentication_type?(:metrics) ? @ems.authentication_password(:metrics).to_s : \"\"\n\n @edit[:new][:amqp_userid] = @ems.has_authentication_type?(:amqp) ? @ems.authentication_userid(:amqp).to_s : \"\"\n @edit[:new][:amqp_password] = @ems.has_authentication_type?(:amqp) ? @ems.authentication_password(:amqp).to_s : \"\"\n @edit[:new][:amqp_verify] = @ems.has_authentication_type?(:amqp) ? @ems.authentication_password(:amqp).to_s : \"\"\n\n @edit[:new][:ssh_keypair_userid] = @ems.has_authentication_type?(:ssh_keypair) ? @ems.authentication_userid(:ssh_keypair).to_s : \"\"\n @edit[:new][:ssh_keypair_password] = @ems.has_authentication_type?(:ssh_keypair) ? @ems.authentication_key(:ssh_keypair).to_s : \"\"\n\n @edit[:new][:bearer_token] = @ems.has_authentication_type?(:bearer) ? @ems.authentication_token(:bearer).to_s : \"\"\n @edit[:new][:bearer_verify] = @ems.has_authentication_type?(:bearer) ? @ems.authentication_token(:bearer).to_s : \"\"\n\n if @ems.kind_of?(ManageIQ::Providers::Vmware::InfraManager)\n @edit[:new][:host_default_vnc_port_start] = @ems.host_default_vnc_port_start.to_s\n @edit[:new][:host_default_vnc_port_end] = @ems.host_default_vnc_port_end.to_s\n end\n @edit[:ems_types] = model.supported_types_and_descriptions_hash\n @edit[:saved_default_verify_status] = nil\n @edit[:saved_metrics_verify_status] = nil\n @edit[:saved_bearer_verify_status] = nil\n @edit[:saved_amqp_verify_status] = nil\n set_verify_status\n\n @edit[:current] = @edit[:new].dup\n session[:edit] = @edit\n end",
"def metadata=(_); end",
"def edit\n page_meta[:workout_description] = @workout.short_description\n end",
"def set_form\n @form = Form.find(params[:id])\n end",
"def set_form\n @wrapper = Wrapper.find(params[:id])\n end",
"def set_page_data\n @page_title = \"Dragos | My Portfolio\"\n @seo_keywords = \"Dragos Portfolio\"\n end",
"def form_data?; end",
"def edit_form\n parsed = Namae::Name.parse(current_user.name)\n generic_file = ::GenericFile.new(creator: [parsed.sort_order], title: @batch.generic_files.map(&:label))\n edit_form_class.new(generic_file)\n end",
"def new\n\t\t@newpi=PersonalInfo.new\n\t\t# @newpi是從db實體化的物件,會傳進new.html.erb的form當參數,然後會以 :newpi 這個hash post 到method create\n\tend",
"def site_meta\n end",
"def site_meta\n end",
"def set_housing_form\n @housing_form = HousingForm.find(params[:id])\n end",
"def new\n # CREATES NEW PAGE ONLY IN MEMORY NO IN DATABASE\n @page = Page.new\n # renders the form\n end",
"def set_form\n @form = Form.find(params[:id])\n end",
"def method_missing(name, *args)\n name = name.to_s\n if name =~ /(.+)=/\n #Setter\n @metadata['form'][$1] = *args.first\n elsif name =~ /(.+)/\n @metadata['form'][$1] unless @metadata['form'][$1].nil?\n end\n end",
"def metadata(&blk)\n blk.call(object.metadata_attributes) if object.has_metadata?\n nil # This ensures nothing gets written to the template if someone uses '=' to call this.\n end",
"def new\n\n\t #new loads the new page, which the user gives the artist name, then it goes to create which creates the artist object.\n\t #then it goes to edit which allow the user to fill in the artist information. Then goes to update where artist info is updated\n @artist = Artist.new\n @artist.profile_layout = ProfileLayout.new\n\n\n\n\n\t@form = render_to_string('artists/_form_new_artist.html.erb',:layout => false)\n logger.info(@form)\n\n\tlayout(params[:layout])\n respond_to do |format|\n format.html # new.html.erb\n\t format.json {\n\t\t render :json => {\n\t\t\t\t :success => true,\n\t\t\t\t :\".bodyArea\" => render_to_string(\n\t\t\t\t\t\t :action => 'new.html.erb',\n\t\t\t\t\t\t :layout => \"layouts/user.html.erb\",\n\t\t\t\t ),\n\t\t\t\t #show/hides edit screen\n\t\t\t\t #:\"edit\" => \"true\"\n\t\t\t\t #sets object type to user. Loads Correct\n\t\t\t\t :\"object_type\" => \"user\"\n\t\t }\n\t }\n end\n end",
"def metadata\n return super if block_given?\n\n @metadata || @view_context.render(@metadata_component.new(fields: presenter.field_presenters, show: show?))\n end",
"def new\n @help = PageContent.find_by_name(\"profile-help\") # \"What to include in profile\" Content\n @presenter = find_presenter\n if @presenter.presenter_profile.nil?\n @presenter_profile = @presenter.build_presenter_profile(status: :new_profile)\n else\n redirect_to edit_presenter_profile_path(@presenter)\n end\n end",
"def new\n\t\tpre_new\n\tend",
"def update_metadata\n response = Net::HTTP.post(URI('https://api.linkpreview.net'),\n { 'key' => ENV['LINKPREVIEW_API_KEY'],\n 'q' => self.url }.to_json)\n\n body = JSON.parse(response.body)\n self.title = body['title']\n self.image = body['image']\n self.description = body['description']\n save\n end",
"def new\n\t\t# no code needed here; all handled in the view\n\tend",
"def change_form_content \n\tend",
"def metadata\n @page.metadata\n end",
"def set_page_meta_tags\n req = self.request\n set_meta_tags_for_url_path(req.base_url, req.fullpath)\n end",
"def set_record_metatags! tags, record\n tags['title'] = record.name\n tags['description'] = record.excerpt if record.respond_to?(:excerpt)\n tags['og:url'] = wm_url_for(record)\n tags['og:type'] = 'article'\n tags['og:image'] = record.thumbnail.url if record.try(:thumbnail).present?\n tags['og:article:published_time'] = record.created_at.to_s(:db)\n tags['og:article:modified_time'] = record.updated_at.to_s(:db)\n tags['og:article:section'] = record.category&.name if record.is_a?(Article)\n tags['twitter:card'] = 'summary'\n\n set_locale_metatags!(tags, record) if record.try(:translatable?)\n set_static_page_metatags!(tags, record) if record.is_a?(StaticPage)\n set_video_metatags!(tags, record) if record.try(:vimeo_metadata).present?\n end",
"def new\n @recipe_page = RecipePage.new\n end",
"def set_form\n @form = Form.find(params[:id])\n end",
"def set_form\n @form = Form.find(params[:id])\n end",
"def meta\n options[:meta]\n end",
"def heading\n\t\tname + \" (\" + form.name + \")\"\n\tend",
"def edit\n render partial: \"metadata_profiles/form\",\n locals: { profile: @profile }\n end",
"def new\n load_form_data\n @book = Book.new\n end",
"def create\n if params[:entry][:entry_metas_attributes].present?\n params[:entry][:entry_metas_attributes].replace(convert_entry_metas_attributes(params[:entry][:entry_metas_attributes]))\n end\n @entry = Entry.new(params[:entry])\n \n\n respond_to do |format|\n if @entry.save\n format.html { redirect_to edit_admin_entry_path(@entry), notice: 'Entry was successfully created' }\n format.json { render json: @entry, status: :created, location: @entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def metadata\n {\n title: flickr_title,\n description: description\n }\n end",
"def new\n authorize MetadataProfile\n if params.dig(:metadata_profile, :institution_id).blank?\n render plain: \"Missing institution ID\", status: :bad_request\n return\n end\n @profile = MetadataProfile.new(metadata_profile_params)\n render partial: \"form\"\n end",
"def set_about_yourself_field(details)\n end",
"def set_info\n @page_header = 'Dashboard'\n @page_title = 'LeadAccount | Dashboard'\n @page_icon = 'dashboard'\n end",
"def content_element_form(context={})\n \n app = context[:app]\n \n renderer = UIFieldSetRender::FieldSetRender.new('photo', app) \n photo_form = renderer.render('form', 'em') \n \n end",
"def set_meta( title, *description )\n\t\t@title = title\n\t\t@description = description.first[0..200] unless description.first.blank?\n\tend",
"def meta_information\n @meta_hash ||= {}\n end",
"def metadata\n metadata = {}\n @file.data.each { |key, value| metadata[key.to_sym] = value }\n\n metadata[:type] = @file.class.name.split('::')[1].downcase\n metadata[:url] = @file.url\n\n metadata[:slug] = slug\n\n metadata[:posted_at] = @file.date.to_time.to_i if @file.respond_to? :date\n metadata[:tags] = tags\n\n metadata\n end",
"def update_metadata\n file_attributes = ::FileSetEditForm.model_attributes(attributes)\n actor.update_metadata(file_attributes)\n end",
"def update_initial_metadata(metadata)\n end"
] |
[
"0.72939754",
"0.6946894",
"0.6788896",
"0.6603299",
"0.6434732",
"0.6432347",
"0.6317404",
"0.62168145",
"0.6216066",
"0.619247",
"0.6166297",
"0.61328864",
"0.61161834",
"0.5970437",
"0.5961768",
"0.5932819",
"0.5932819",
"0.5932819",
"0.5929848",
"0.59273195",
"0.59208006",
"0.5907047",
"0.59005445",
"0.58832574",
"0.58650863",
"0.58630866",
"0.5861764",
"0.58606315",
"0.58476806",
"0.58277684",
"0.58277684",
"0.58277684",
"0.58277684",
"0.581829",
"0.58115447",
"0.57972395",
"0.57815063",
"0.577632",
"0.577215",
"0.57690597",
"0.5769014",
"0.5753856",
"0.5738323",
"0.5738075",
"0.57269704",
"0.5724212",
"0.57130545",
"0.5700322",
"0.5693226",
"0.56912833",
"0.56912833",
"0.56718326",
"0.56718326",
"0.56718326",
"0.56718326",
"0.5670921",
"0.56668293",
"0.56582654",
"0.5657148",
"0.5650701",
"0.5650445",
"0.56437373",
"0.56327623",
"0.562487",
"0.56143856",
"0.5611275",
"0.5601256",
"0.5601256",
"0.55938625",
"0.5593123",
"0.5586211",
"0.5584292",
"0.55814",
"0.55531085",
"0.5551",
"0.55488014",
"0.55440205",
"0.55414563",
"0.5541438",
"0.5538826",
"0.5538214",
"0.5537124",
"0.55320495",
"0.5516566",
"0.55147195",
"0.55147195",
"0.5510388",
"0.5508718",
"0.5507943",
"0.550626",
"0.55033255",
"0.5502503",
"0.55017555",
"0.5500677",
"0.54971313",
"0.5491932",
"0.54833704",
"0.5481623",
"0.5480286",
"0.54790443",
"0.5477242"
] |
0.0
|
-1
|
To guess the title for a resource. This title will be used on the following places: page title on show page in the response for autocomplete association field title of show link for a resource
|
def guess_title(_resource)
raise NotImplemented
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def guess_title(resource)\n resource.try title_field_finder.find\n end",
"def resource_title\n title_field = components.values.last[:title] || :to_s\n resource.send(title_field.to_sym) if resource\n end",
"def guess_title(resource)\n ModuleUtils.try_to resource, title_field_finder.find\n end",
"def resource_title\n if resourceful? && resource\n resource.respond_to?(:name) ? resource.name.humanize : resource.id\n else\n 'show'\n end\n end",
"def resource_title(resource)\n title = resource.try(:title) || resource.try(:name) || resource.try(:subject) || \"#{resource.model_name.human} ##{resource.id}\"\n title = translated_attribute(title) if title.is_a?(Hash)\n title\n end",
"def nav_title(resource)\n resource.data['nav-title'] || resource.data.title\n end",
"def complete_title\n if self.title.present?\n self.title\n else\n I18n.translate(\"bento_search.missing_title\")\n end\n end",
"def title\n !@resource.title.blank?\n end",
"def title\n if detail_page?\n \"#{resource.name} - #{menu.name} - #{website_tag.name}\"\n else\n \"#{menu.name} - #{website_tag.name}\" \n end \n end",
"def get_display_title(title)\n page_info_get_val(title, 'displaytitle', 'displaytitle')\n end",
"def title\n @title ||= hash.fetch('title') { |key|\n raise \"Page id=#{id} is missing #{key}\"\n }\n end",
"def title\n if title_attribute = read_attribute(:title)\n title_attribute\n elsif self.properties && self.properties['title'].present?\n self.properties['title']\n else\n default_title\n end\n end",
"def title_for(**options)\n\t\t\t\t\tif title = options[:title]\n\t\t\t\t\t\treturn title\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\t# Generate a title from a field name:\n\t\t\t\t\tif field_name = field_for(**options)\n\t\t\t\t\t\t# Remove postfix \"_id\" or \"_ids\":\n\t\t\t\t\t\treturn Strings::to_title(field_name.to_s.sub(/_ids?/, ''))\n\t\t\t\t\tend\n\t\t\t\tend",
"def title\n self.class.title(nil, params)\n end",
"def title(alt = nil)\n # Return the resource title if available, otherwise return the specified alternative\n return self.resource.title || @title if self.resource\n case alt\n when :library_note, :private_note\n self.library_note || nil\n when :note\n self.student_note || self.note || self.library_note || nil\n when :public_note, :student_note\n self.student_note || self.note || nil\n when :uri\n self.uri\n else\n nil\n end\n end",
"def get_title\n @title\n end",
"def page_title\n \"#{human_readable_type} | #{title.first} | ID: #{id} | #{I18n.t('hyrax.product_name')}\"\n end",
"def title\n @title ||= heirarchy.full_name\n end",
"def title\n @title ||= Utilities.longest_common_substring_in_array(titles.values) \n @title = titles[:og_title] unless title_ok?\n @title = titles[:html_title] unless title_ok?\n @title = titles[:from_doc] unless title_ok?\n\n @title\n end",
"def title\n return @title if @title\n if matches = class_const(:TITLE_RE).match(page)\n @title = matches[1].to_s.strip\n title_processor\n @title = decode_entities(@title)\n end\n end",
"def title\n @title_pages.each { |tp| tp.title and return tp.title }\n nil\n end",
"def display_title\n\t\t\t@data[\"displaytitle\"]\n\t\tend",
"def get_title()\n @title\n end",
"def service_title\n @resource.title\n end",
"def get_page_title\n uri = request.request_uri\n section = uri.split(\"/\").last\n title = case section\n # these should be consistent now\n when \"questions\" then \"Key Questions\"\n when \"publications\" then \"Publication Information\"\n when \"arms\" then \"Study Arms\"\n when \"design\" then \"Study Design\"\n when \"baselines\" then \"Baseline Characteristics\"\n when \"outcomes\" then \"Outcome Setup\"\n when \"results\" then \"Results\"\n when \"adverse\" then \"Adverse Events\"\n when \"quality\" then \"Study Quality\"\n else \"\"\n end\n return title\n end",
"def get_title()\n return @title\n end",
"def get_title\n @title\n end",
"def\n get_title()\n @title\n end",
"def title\n # strip some non-breaking space at the end\n @title ||= details.at(\"h1[itemprop='name']\").children.first.text.strip.gsub(' ', '') rescue nil\n end",
"def _title\n @link['title']\n end",
"def title\n (attributes[\"title\"] == \"Untitled Datasource\") ? url : attributes[\"title\"]\n end",
"def title\n @hash[\"Title\"]\n end",
"def item_title\n if @res[\"title\"].present?\n @res[\"title\"].length > 20 ? \"#{@res[\"title\"][0,20]}...\" : @res[\"title\"]\n else\n \"Item #{@res[\"identifier\"]}\"\n end\n end",
"def title\n resource_title.presence || CGI.unescape(file_name.to_s).gsub(/\\.\\w+$/, '').titleize\n end",
"def titleize\n\t\tif @title.nil?\n\t\t\tmeta = @source.titleize metadata\n\t\t\t@title = \"#{@settings.title || @origin_id} - #{meta}\"\n\t\tend\n\t\treturn @title\n\tend",
"def title\n return super if block_given?\n\n @title || if show?\n content_tag('span', presenter.heading, itemprop: \"name\")\n else\n @view_context.link_to_document @document, counter: @counter, itemprop: 'name'\n end\n end",
"def get_title\n\t\t@fields_hash[FIELDS_MAP[:title]] || \"\"\n\tend",
"def title\n title_raw.downcase\n end",
"def title\n _title = self[\"title\"]\n _title ? _title[\"$t\"] : nil\n end",
"def title\n @lastresult[\"context\"][\"title\"]\n end",
"def title\n @title ||= begin\n if site_title && page_title != site_title\n page_title + TITLE_SEPARATOR + site_title\n elsif site_description && site_title\n site_title + TITLE_SEPARATOR + site_title_extention_or_description\n else\n page_title || site_title\n end\n end\n\n return page_number + @title if page_number\n\n @title\n end",
"def page_title\n page.title\n end",
"def resource_title(options = {})\n I18n.t(\"power_resource.titles.#{resource_name}.resource\",\n { default: \"#{resource_human_name} #{resource.id}\" }.merge(options) )\n end",
"def display_resource(episode)\n \"#{episode.english_title}\"\n end",
"def title\n @data['title']\n end",
"def title\n if @title.nil?\n BASE_TITLE\n else\n \"#{BASE_TITLE} | #{@title}\"\n end\n end",
"def fallback_title\n exception = StandardError.new(\"page title missing: #{controller_name}##{action_name}\")\n raise exception if Rails.application.config.consider_all_requests_local\n Sentry.capture_exception(exception)\n\n title ''\n end",
"def title\n @attributes[:title]\n end",
"def title\n @attributes[:title]\n end",
"def get_title\n title = []\n # Exceptions\n prefix_title = if controller_name == \"events\" && action_name == \"show\" && @event.present?\n t('titles.events.show', :name => @event.name, :city => @event.city_name)\n elsif controller_name == \"users\" && action_name == \"show\" && @user.present?\n t('titles.users.show', :name => @user.print_name)\n end\n if prefix_title.blank? || prefix_title.match(/translation_missing/)\n # Just translate the controller and action if it exists in the language file\n prefix_title = t(\"titles.#{controller_name}.#{action_name}\")\n prefix_title = (prefix_title.match(/translation_missing/)) ? nil : prefix_title\n end\n # If add the prefix and suffix in title if there isnt a translation missing\n if prefix_title.present? && !prefix_title.match(/translation_missing/)\n title << prefix_title\n title << t('titles.suffix')\n else\n # Use the default title\n title << t('titles.default_title')\n end\n # We put the controller name and action name in the title if we are in development. Just handy.\n if Rails.env == \"development\"\n title << \"#{controller_name}##{action_name}\"\n end\n # Generate the title\n strip_tags(title.join(\" - \"))\n end",
"def page_title title= nil\n\t\tif title\n\t\t\tcontent_for(:page_title) { \"#{title} - 2da.re\" }\n\t\t\treturn title\n\t\telse\n\t\t\tcontent_for?(:page_title) ? content_for(:page_title) : \"Ready 2da.re?\"\n\t\tend\n\tend",
"def title\n attributes.fetch(:title)\n end",
"def title\n attributes.fetch(:title)\n end",
"def title_attribute\n @title\n end",
"def prioritized_title\n first = self.titles.first\n return first.nil? ? self.id : first.title\n end",
"def title title = nil\n if title\n @title = title.to_s\n else\n @title ||= name[/([^:]+)$/, 1]\n end\n end",
"def title\n t = nil\n # default to long title\n long_titles = self.courses.map(&:long_title)\n return t if (t = long_titles.find(&:present?)).present?\n\n # then try specific title. then short title\n return self.specific_title if self.specific_title.present?\n\n short_titles = self.courses.map(&:short_title)\n return t if (t = short_titles.find(&:present?)).present?\n\n return '(Title Unavailable)'\n end",
"def title\n return @title\n end",
"def title\n return @title\n end",
"def title\n return @title\n end",
"def title\n return @title\n end",
"def title\n return @title\n end",
"def title\n return @title\n end",
"def title\n return @title\n end",
"def assign_page_title\n @page_title ||= resource_wizard_step_title(resource, step)\n end",
"def title\n\t\t\t@data[\"title\"]\n\t\tend",
"def title\n\t\t\t@data[\"title\"]\n\t\tend",
"def title\n base_title = \"S.Hukin ltd - Sheffield, UK. Speciality wholesale foods.\"\n if @title.nil?\n base_title\n else\n \"#{base_title} | #{@title}\"\n end\n end",
"def full_title\n name\n end",
"def full_title\n name\n end",
"def full_title\n name\n end",
"def title\n data['title'].to_s\n end",
"def title\n @info[:Title]\n end",
"def title(new_title=nil)\n if new_title\n @title = new_title\n end\n Lolita::Utils.dynamic_string(@title, :default => @name && @dbi.klass.human_attribute_name(@name))\n end",
"def accurate_title\n nil\n end",
"def page_title(page_title = nil)\n @page_title ||= page_title\n @page_title.nil? ? \"Carers: #{action_name}\" : \"#{@page_title} @ Lort Smith\"\n end",
"def title\n return @title\n end",
"def title\n return @discovery_document['title']\n end",
"def title\n @attributes[:title]\n end",
"def part_title_by_type(resource_type)\n if self.type == resource_type\n self.title\n elsif self.has_part && self.has_part.type == resource_type\n self.has_part.title\n else\n nil\n end\n end",
"def title\n base_title = \"Operation Paws for Homes\"\n if @title.nil?\n base_title\n else\n \"#{base_title} | #{@title}\"\n end\n end",
"def display_name\n title.present? && title || _('Untitled')\n end",
"def ars_title\n self.ars_titles.order('percent_appears desc').limit(1).first.title\n end",
"def get_title_property_name(entity_name)\n node = metadata.xpath(\"//EntityType[@Name='#{entity_name}']/Property[@FC_TargetPath='SyndicationTitle']\").first\n node.nil? ? nil : node.attributes['Name'].value\n end",
"def acf_title\n @title ||= postmetas.find_by(meta_key: \"title\").try(:meta_value)\n end",
"def title\n base_title = \"CloudSpokes Coding Challenges\"\n if @page_title.nil?\n base_title\n else\n \"#{base_title} - #{@page_title}\"\n end\n end",
"def check_title\n if self.title.blank? && st = (url && Site.by_link(self.url))\n self.title = (st.yield :Title, st.sampleURL)[:Title] || \"\"\n self.title = self.trimmed_title\n else\n self.title\n end\n end",
"def title\n @data.title ||= parsed_document.css('title').inner_html.gsub(/\\t|\\n|\\r/, '') rescue nil\n end",
"def title(force_refresh = false)\n if @title && !force_refresh\n @title\n else\n @title = document[\"title\"] rescue nil\n end\n end",
"def title\n base_title = \"An Andy Sharkey Production\"\n if @title.nil?\n base_title\n else\n \"#{base_title} | #{@title}\"\n end\n end",
"def title\n @title ||= self.content.split(@@title_separator).first unless self.content.nil?\n end",
"def display_resource(product)\n \"#{product.english_title}\"\n end",
"def page_title\n end",
"def get_title\n base_title = get_name_or_logo\n @title.nil? ? base_title : \"#{base_title} | #{@title}\"\n end",
"def page_title\n nil\n end",
"def page_title\n @page_title ||= format_string(page[\"title\"]) || site_title\n end",
"def title\n super.first || \"\"\n end",
"def title\n super.first || \"\"\n end",
"def title\n super.first || ''\n end",
"def title\n super.first || ''\n end"
] |
[
"0.8316989",
"0.7851038",
"0.78505635",
"0.77721363",
"0.76289654",
"0.716412",
"0.7109765",
"0.70912665",
"0.70200646",
"0.69883615",
"0.6945674",
"0.69441974",
"0.6824266",
"0.6816478",
"0.68162245",
"0.6793656",
"0.6789771",
"0.6760486",
"0.67566025",
"0.6745436",
"0.6727163",
"0.67108804",
"0.670432",
"0.6699799",
"0.6686635",
"0.66853863",
"0.66778564",
"0.66756326",
"0.6657087",
"0.6648918",
"0.6633295",
"0.66193575",
"0.6618436",
"0.66001576",
"0.65947783",
"0.65945894",
"0.6561294",
"0.65569395",
"0.6542846",
"0.6541",
"0.65328",
"0.6528614",
"0.65282",
"0.6526595",
"0.65244406",
"0.65197605",
"0.6513603",
"0.6511052",
"0.6511052",
"0.65060973",
"0.65000397",
"0.6499208",
"0.6499208",
"0.64977294",
"0.6497262",
"0.64908606",
"0.6490298",
"0.64856815",
"0.64856815",
"0.64856815",
"0.64856815",
"0.64856815",
"0.64856815",
"0.64856815",
"0.6483613",
"0.64790386",
"0.64790386",
"0.64708716",
"0.64682764",
"0.64682764",
"0.64682764",
"0.6464746",
"0.64617",
"0.64614207",
"0.6460021",
"0.6452646",
"0.64414847",
"0.64405304",
"0.6438785",
"0.6437762",
"0.6429137",
"0.6428875",
"0.642428",
"0.6405238",
"0.639858",
"0.63982856",
"0.6397805",
"0.6388764",
"0.63861924",
"0.6383777",
"0.63834536",
"0.6382031",
"0.6375943",
"0.63736767",
"0.63692904",
"0.6367982",
"0.6360039",
"0.6360039",
"0.63524866",
"0.63524866"
] |
0.74636567
|
5
|
Ensure type is present
|
def validate_presence_of(field_name, type)
type || raise(::ArgumentError, "Type is required for #{field_name}.")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def ensure_type(klass)\n ensure_par(type: '-t')\n if klass.KNOWN_TYPES[self[:type]].nil?\n raise \"Unrecognized type: #{self[:type]}\"\n end\n end",
"def check_type\n \t self.type = TYPES[0] if !TYPES.include?(self.type)\n\t end",
"def has_type?\n ! type.nil?\n end",
"def check_type type\n raise \"No such type: #{type}\" unless Modules.constants.include? type\n end",
"def validate_type(type, context:); end",
"def valid_type?(type)\n super || extended_types.include?(type)\n end",
"def try_require(type, name); end",
"def has_type?\n ! get_internal_word(TYPE_INDEX).nil?\n end",
"def ensure_proper_type\n klass = self.class\n if klass.finder_needs_type_condition?\n _write_attribute(klass.inheritance_column, klass.sti_name)\n end\n end",
"def ensure_proper_type\n klass = self.class\n if klass.finder_needs_type_condition?\n _write_attribute(klass.inheritance_column, klass.sti_name)\n end\n end",
"def valid?\n !type.nil?\n end",
"def valid?\n !type.nil?\n end",
"def raise_type_defined(key)\n raise ArgumentError, <<-MSG.squish\n Type #{key} is already defined here: #{types[key].source_location.join(':')}\n MSG\n end",
"def check_type(type, value)\n return unless type && value && !value.is_a?(type)\n\n \"should be of type #{type} but is of type #{value.class}\"\n end",
"def valid_type?(type)\n !native_database_types[type].nil?\n end",
"def auto_validate_types?\n @auto_validate_types\n end",
"def type_registered?(klass_or_type)\n end",
"def requires_placeholder_type_specifiers?\n true\n end",
"def type(type); end",
"def type\n _type rescue nil\n end",
"def has_type?(type_)\n @mutex.synchronize do\n @types.has_key?(type_)\n end\n end",
"def dummy?\n @type.nil?\n end",
"def type_exists?(name)\n user_defined_types.key? name.to_s\n end",
"def validateType\n unless Relationship_Type.include?(@type)\n raise \"value #{@type} is not a valid relationship type value\"\n end\n end",
"def add_required_object_type(type)\n type = type.to_s\n if required_object_types.include?(type)\n false\n else\n required_object_types << type\n type\n end\n end",
"def check_type(type)\n %w{galera mysql}.each do |t|\n return true if t == type\n end\n false\n end",
"def applies_type?(scope, type); end",
"def validateType\n unless Relationship_Type.include?(@type)\n raise \"value #{@type} is not a valid relationship type value\"\n end\n end",
"def validateType\n unless Agent_Types.include?(@type)\n raise \"value #{@type} is not a valid agent type value\"\n end\n end",
"def type_check(type = nil)\n children {|child| type = child.type_check(nil)}\n return type\n end",
"def has_type?(type)\n @properties.has_type?(type)\n end",
"def get_type; raise NotImplementedError end",
"def test_have_types\n @sources.each { |s| assert(!s['type'].blank?, \"No type for #{s['uri']}\") }\n end",
"def ensure_type(type)\n type.nil? ? Level : (type.is_a?(Array) ? (type.include?(Level) ? Level : type.flatten.first) : type)\nend",
"def type(type = nil, &block)\n return @type unless type\n @type = Apigen::Model.type type, &block\n end",
"def correct_type?(object)\n object.type == type\n end",
"def has_datatype?\n !datatype.nil?\n end",
"def validate_type?\n config[:validate_type] || config[:validate_types]\n end",
"def type\n return nil if checktype.nil?\n checktype.name \n end",
"def __typedeaf_valid_type?(value, type)\n return value.is_a? type\n end",
"def type_create?(type)\n if create?\n not types_create_exception.include? type\n else\n types_create_exception.include? type\n end\n end",
"def check_valid_nonexistent_object_type_name name\n if ot = valid_object_type_name(name)\n raise \"Cannot redefine #{ot.class.basename} #{name}\"\n end\n end",
"def ensure_hook_type_sections_exist(hash); end",
"def init_type(type = nil)\n return @init_type ||= _super_init_type unless type\n raise ArgumentError, \"Unknown init type '#{type}'. Must be #{INIT_TYPES.join_terms('or', encapsulate: \"'\")}.\" unless INIT_TYPES.include?(type)\n @init_type = type\n end",
"def present?(key)\n types.key?(key.class)\n end",
"def will_be?(type)\n single_class <= type\n end",
"def needed_types\n self.scan unless @needed_types\n @needed_types\n end",
"def type_of?(type)\n type.raw_type == raw_type\n end",
"def type\n raise UnimplementedError\n end",
"def type?\n !@type.nil? && @type != :any\n end",
"def valid?\n return false if @type.nil?\n return true\n end",
"def type; nil end",
"def type; nil end",
"def type?\n @data[:type].empty? ? false : true\n end",
"def same_type_guard?\n @type_guard == true\n end",
"def set_type_if_empty\n self.type = 'Protonym' if self.type.nil?\n end",
"def check_content_type!\n\n if self.content_type and (not self.content_type.saved?) and loaded_content_type = ContentType.get(self.content_type.id)\n self.content_type = loaded_content_type\n end\n\n end",
"def validate_klass!\n raise \"type can't be blank\" unless type.present?\n raise 'type must be a mergable type' unless EffectiveMergery.mergables.map(&:name).include?(type)\n raise \"invalid ActiveRecord klass\" unless klass\n raise \"invalid ActiveRecord collection\" unless collection.kind_of?(ActiveRecord::Relation)\n true\n end",
"def set_type(opts)\n opts = check_params(opts,[:types])\n super(opts)\n end",
"def assert_kind_of(cls, obj, msg = T.unsafe(nil)); end",
"def is_datatype?(); @type == GRT_DATATYPE; end",
"def ensure_valid_default_value(value)\n if !value.nil? && types && types.none? { |type| type === value }\n raise TypeError, I18n.t(\"lita.config.type_error\", attribute: name, types: types.join(\", \"))\n end\n end",
"def check_type(val, type)\n if val.class != type\n raise TypeError\n end\nend",
"def check_types(value)\n if types && types.none? { |type| type === value }\n Lita.logger.fatal(\n I18n.t(\"lita.config.type_error\", attribute: name, types: types.join(\", \"))\n )\n abort\n end\n end",
"def type\n nil\n end",
"def refute_kind_of(cls, obj, msg = T.unsafe(nil)); end",
"def unknown?\n @type == 'TYPE_UNSPECIFIED'\n end",
"def set_type\n end",
"def update_type_fields\n # Topic must be present\n errors.add :topic, :blank unless topic\n\n # Subject and pull request must be blank\n errors.add :subject, :present if subject\n errors.add :pull_request, :present if pull_request\n end",
"def required_param_types_present?\n @required_param_types.each do |string|\n return false unless param_classname_present?(string)\n end\n return true\n end",
"def nonregular_type; end",
"def type\n nil\n end",
"def ensure_proper_type\n unless self.class.descends_from_active_record?\n write_attribute(self.class.inheritance_column, Inflector.demodulize(self.class.name))\n end\n end",
"def add_type(type)\n end",
"def obj_exists_and_is_not_type?(obj:, type:)\n obj.nil? ? false : obj != type\n end",
"def custom?\n self.type.blank?\n end",
"def typed?\n type != :object\n end",
"def ensure_klass_exists!\n klass\n end",
"def check_value!(value)\n # Allow nil and Strings to fall back on the validations for typecasting\n case value\n when nil, String, expected_type\n value\n else\n raise TypeError, \"#{@name} expected #{expected_type.inspect} but got #{value.inspect}\"\n end\n end",
"def validate(obj, type); end",
"def item_type_valid?\n res = item_type.safe_constantize\n errors.add :item_type, \"is not a valid class name: '#{item_type}'\" unless res\n end",
"def type_fail\n puts\n puts \"Mismatched types!\"\n puts \"Given type should be a #{self.class}\"\n puts\n\n exit 1\n end",
"def enforce_type(type)\n\n dynamic_methods = proc do |dyn_type|\n\n define_method :get_type do\n dyn_type\n end\n\n def push(obj)\n if obj.instance_of? get_type\n super\n else\n raise WrongElementType,\n wrong_element_error_message(obj, get_type)\n end\n end\n\n def wrong_element_error_message(obj, type)\n \"The #{obj.class}, '#{obj}' is not a valid\" \\\n \" element for the #{self.class} collection.\" \\\n \" The element must be a #{type}.\"\n end\n\n def initialize(obj=nil)\n if obj.nil?\n super()\n else\n seq = super\n unless self.all_correct_types?(seq)\n raise WrongInitializationType,\n wrong_initialization_error_message(seq, get_type)\n end\n seq\n end\n end\n\n def all_correct_types?(seq)\n seq.all? {|i| i.instance_of? get_type}\n end\n\n def wrong_initialization_error_message(seq, type)\n contains_one = \" It contains a #{seq.first.class}\" \\\n \" but only elements of the #{type}\" \\\n \" type are allowed.\"\n contains_many = \" It contains elements which are\" \\\n \" not of the allowed type #{type}.\"\n \"The Array, #{seq} cannot be used to initialize\" \\\n \" an instance of #{self.class}.\".concat(\n seq.length.eql?(1) ? contains_one : contains_many)\n end\n end\n\n prepend_module = Module.new\n prepend_module.module_exec(type, &dynamic_methods)\n prepend_module\n end",
"def type\n raise Gps::Request::TypeMissingException.new(\"The Gps Request does not have the type implemented. #{@params.inspect}\")\n end",
"def expected_type\n 'string'\n end",
"def prepare_type\n @type = params[:type]\n @klass = @type.constantize\n end",
"def type?(type)\n\t\treturn self.type == type\n\tend",
"def type?(type)\n\t\treturn self.type == type\n\tend",
"def validate_as(type) # FIXME use or lose this\n @_favorite_flavor, formerly = type, @_favorite_flavor\n yield\n ensure\n @_favorite_flavor = type\n end",
"def type\n @data[:type].empty? ? false : @data[:type]\n end",
"def add_type(type)\n\n # does nothing, types are differentiated by the 'typ' column\n end",
"def type_for(type) \n case\n when type.nil?\n Spira::Types::Any\n when type.is_a?(Symbol) || type.is_a?(String)\n type\n when !(Spira.types[type].nil?)\n Spira.types[type]\n else\n raise TypeError, \"Unrecognized type: #{type}\"\n end\n end",
"def type\n raise NotImplementedError\n end",
"def add_type(type)\n\n # nothing to be done\n end",
"def add_type(type)\n\n # nothing to be done\n end",
"def valid_type?\n %w[host web].include? type\n end",
"def required_class; end",
"def type_guard?\n same_type_guard? || specific_type_guard?\n end",
"def ensure_class(obj, types, msg)\n if types.class == Array\n if not types.member?(obj.class)\n return msg\n else\n return true\n end\n\n else\n if not types == obj.class\n return msg\n else\n return true\n end\n end\n end"
] |
[
"0.77729285",
"0.7704161",
"0.7560505",
"0.7064094",
"0.692323",
"0.6918804",
"0.6846484",
"0.66028047",
"0.6579896",
"0.65788656",
"0.6546868",
"0.6546868",
"0.6426992",
"0.6408479",
"0.6406387",
"0.63634545",
"0.63630074",
"0.6336469",
"0.63176376",
"0.6297555",
"0.62947947",
"0.62891",
"0.6261258",
"0.62567055",
"0.62168884",
"0.6209225",
"0.62028474",
"0.6186904",
"0.61734045",
"0.6163502",
"0.61588943",
"0.6085913",
"0.6085901",
"0.6084846",
"0.6058186",
"0.6040211",
"0.60401976",
"0.60006106",
"0.59973156",
"0.5984188",
"0.5979402",
"0.5978842",
"0.5942249",
"0.59407663",
"0.5939795",
"0.59333396",
"0.59168404",
"0.5912307",
"0.5905696",
"0.5903351",
"0.5893144",
"0.58772796",
"0.58772796",
"0.5861187",
"0.5860981",
"0.5855193",
"0.5845864",
"0.5837024",
"0.5835813",
"0.58333147",
"0.5822349",
"0.5811567",
"0.57979417",
"0.5796472",
"0.57902527",
"0.5783667",
"0.57678753",
"0.5706043",
"0.5704351",
"0.56972814",
"0.5696464",
"0.5689074",
"0.56848574",
"0.56823754",
"0.5679583",
"0.5672511",
"0.56668913",
"0.56590956",
"0.5654978",
"0.5652275",
"0.5649789",
"0.564598",
"0.5643621",
"0.56379914",
"0.56055945",
"0.5600023",
"0.55961484",
"0.55961484",
"0.559442",
"0.5593811",
"0.5586843",
"0.5583398",
"0.55820554",
"0.5571894",
"0.5571894",
"0.55670846",
"0.55650187",
"0.5564325",
"0.5563233"
] |
0.6901915
|
7
|
Returns the Configuration for this resource.
|
def config
@config ||= Smartgen::Configuration.new
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def configuration\n Configuration::get\n end",
"def configuration\n Configuration::get\n end",
"def configuration\n self[:configuration]\n end",
"def configuration\n self.class.configuration\n end",
"def configuration\n self.class.configuration\n end",
"def config\n self.class.configuration_builder.configuration\n end",
"def configuration\n return self\n end",
"def configuration\n @configuration ||= Configuration.new(self)\n end",
"def configuration\n @configuration\n end",
"def configuration\n @configuration\n end",
"def configuration\n self[:configuration] || {}\n end",
"def configuration\n self\n end",
"def configuration\n instance\n end",
"def configuration\n instance\n end",
"def config\r\n @configuration\r\n end",
"def configuration\n _get(\"/system/configuration\") { |json| json }\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def config\r\n Configuration\r\n end",
"def configuration\n provider.configuration\n end",
"def config\n @configuration ||= Configuration.new\n end",
"def config\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n Ablerc::Configuration.instance\n end",
"def configuration\n self.class.configuration\n end",
"def configuration\n self.class.configuration\n end",
"def configuration\n self.context.configuration\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new()\n end",
"def configuration\n application.configuration\n end",
"def config\n if Config.config.nil? or Config.config.empty?\n begin\n Config.config = Configuration.load_config(Config.config_file,\n Config.config_options)\n rescue Errno::ENOENT\n Config.config = {}\n end\n end\n\n return Config.config\n end",
"def config\n @config ||= read_config\n end",
"def configuration\n @configuration ||= Clever::Configuration.new\n end",
"def get_config()\n return @api.do_request(\"GET\", get_base_api_path() + \"/config\")\n end",
"def config\n configuration\n end",
"def config\n @config ||= Config.create ConfigLoader.new(root, CONFIG_FILE).to_hash, options.merge_config\n end",
"def configuration\n @configuration ||= configuration_type.new\n end",
"def c\n configuration\n end",
"def client_configuration\n return @client_configuration\n end",
"def configuration\n application.config\n end",
"def config\n @config_file\n end",
"def config\n @config\n end",
"def get_config\n if @resource[:section]\n return node.get_config(params: \"section #{@resource[:section]}\", as_string: true)\n end\n node.running_config\n end",
"def configuration\n @_configuration ||= Configuration.new\n end",
"def configuration\n @_configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def configuration\n @configuration ||= Configuration.new\n end",
"def config\n self\n end",
"def endpoint_configuration\n return @endpoint_configuration\n end",
"def get_actual_config\n @config\n end",
"def config\n\t\t\t@config ||= begin\n\t\t\t\tfile = File.join(self.location, \"config.yaml\")\n\t\t\t\tif File.exists?(file)\n\t\t\t\t\tYAML::load_file(file)\n\t\t\t\telse\n\t\t\t\t\t{}\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def config\n @config\n end",
"def config\n @config\n end",
"def config\n @config\n end",
"def c\n configuration\n end",
"def config\n XConfig::Core.fetch(self)\n end",
"def configuration\n\t\t\t\tconfiguration = Configuration.new\n\t\t\t\t\n\t\t\t\tself.resolved_paths.each do |path|\n\t\t\t\t\tpath = File.expand_path(path)\n\t\t\t\t\t\n\t\t\t\t\tconfiguration.load_file(path)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn configuration\n\t\t\tend",
"def config\n @config ||= load_config\n end",
"def api_connector_configuration\n return @api_connector_configuration\n end",
"def config\n info['Config']\n end",
"def config\n path = config_path\n @config ||= path.exist? ? JSON.parse(path.read) : {}\n end",
"def config\n @config ||= Configuration.new\n end",
"def device_configuration\n return @device_configuration\n end",
"def configuration\n notifier.configuration\n end",
"def config\n @config ||= Config.new\n end",
"def config\n @config ||= Config.new\n end",
"def config\n @config ||= {}\n end",
"def config\n @config ||= {}\n end",
"def configuration\n return @children['configuration'][:value]\n end",
"def configuration\n {}\n end",
"def config\n Config.new(connection)\n end",
"def configuration\n @configuration || WCC::Contentful.configuration\n end",
"def configuration\n @config ||= setup\n end",
"def config\n @config\n end",
"def config\n @options[:config]\n end",
"def configuration\n @blacklight_config\n end",
"def get_config\n\t\tend",
"def config\n @config ||= nil\n return @config unless @config.nil?\n @config = app_config.find_config config_key\n @config.freeze\n @config\n end",
"def configuration\n @configuration ||= Configuration.new\n if block_given?\n yield @configuration\n else\n @configuration\n end\n end",
"def config\n @config ||= BeaconControl::Base::Config.new\n end",
"def config\n Pakyow::Config\n end",
"def config\n overview[\"config\"]\n end",
"def config\n (null_config? ? NoConfig.instance : actual_config)\n end",
"def conf\n begin\n @conf ||= JSON.parse(File.read(config_file))\n rescue\n @conf ||= {}\n end\n end",
"def conf\n begin\n @conf ||= JSON.parse(File.read(config_file))\n rescue\n @conf ||= {}\n end\n end",
"def config_get(id)\n Configuration.get(id)\n end",
"def config\n PrcLib.runtime_fail 'No config object loaded.' unless @config\n @config\n end"
] |
[
"0.79388976",
"0.79388976",
"0.7776188",
"0.7651384",
"0.7651384",
"0.7627841",
"0.7559593",
"0.74952406",
"0.7479493",
"0.7479213",
"0.74774563",
"0.7468118",
"0.74233526",
"0.74233526",
"0.73868895",
"0.73285186",
"0.7325427",
"0.7325427",
"0.7325427",
"0.7325427",
"0.7325427",
"0.7325427",
"0.73090446",
"0.72915477",
"0.72915477",
"0.72705185",
"0.72563595",
"0.7225833",
"0.7225833",
"0.72162056",
"0.71704394",
"0.71704394",
"0.71704394",
"0.71704394",
"0.71704394",
"0.71704394",
"0.71704394",
"0.71704394",
"0.71704394",
"0.71704394",
"0.7165792",
"0.71454173",
"0.71284896",
"0.7098172",
"0.7082412",
"0.7076743",
"0.7066071",
"0.7062731",
"0.7060789",
"0.70136875",
"0.7006679",
"0.6996133",
"0.69643754",
"0.6955433",
"0.6954931",
"0.6943985",
"0.6943985",
"0.6915626",
"0.6915626",
"0.6915626",
"0.6915626",
"0.6912826",
"0.6902109",
"0.690085",
"0.68958074",
"0.68902457",
"0.68902457",
"0.68902457",
"0.6887511",
"0.68715274",
"0.6867787",
"0.6864571",
"0.68618506",
"0.68302095",
"0.6822241",
"0.6821702",
"0.6806938",
"0.67967296",
"0.6785869",
"0.6785869",
"0.67778397",
"0.67778397",
"0.67740345",
"0.6767183",
"0.6759765",
"0.6758193",
"0.67492753",
"0.6731503",
"0.6716535",
"0.6702889",
"0.66940135",
"0.66931814",
"0.66881055",
"0.6687257",
"0.6685564",
"0.6667549",
"0.666653",
"0.6656639",
"0.6656639",
"0.66416675",
"0.6629927"
] |
0.0
|
-1
|
Generate files, based on the current Configuration.
|
def generate!
generator.invoke_all
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def generate_files\n ip = local_ip\n version = Farmstead::VERSION\n scaffold_path = \"#{File.dirname __FILE__}/scaffold\"\n scaffold = Dir.glob(\"#{scaffold_path}/**/*.erb\", File::FNM_DOTMATCH)\n scaffold.each do |file|\n basename = File.basename(file)\n folderstruct = file.match(\"#{scaffold_path}/(.*)\")[1]\n if basename != folderstruct\n foldername = File.dirname(folderstruct)\n create_recursive(\"#{@name}/#{foldername}\")\n end\n projectpath = \"#{@name}/#{folderstruct}\".chomp(\".erb\")\n template = File.read(file)\n results = ERB.new(template).result(binding)\n copy_to_directory(results, projectpath)\n end\n end",
"def generate!\n info \"GENERATE\"\n\n f = Generator.new @dbi, @settings, @logger\n xslt = XML::XSLT.new\n xslt.xml = f.generate_root.to_s\n\n default_template_dir = File.dirname(__FILE__) + '/../../data/templates'\n template_dir = @settings['templates'] || default_template_dir\n output_dir = @settings['output']\n\n task \"copy static files\" do\n FileUtils.mkdir_p output_dir\n FileUtils.cp_r Dir[File.join( template_dir, 'static', '*' )], output_dir\n end\n\n begin\n Dir.foreach(template_dir) { |template_file|\n next if template_file =~ /^\\./ || template_file == 'static'\n\n task \"process #{template_file}\" do\n xslt.xsl = File.join( template_dir, template_file )\n File::open( File.join( output_dir, template_file ), 'w') { |f| f.write(xslt.serve) }\n end\n }\n rescue Errno::ENOENT\n warn \"Couldn't find templates directory, fallback to default templates!\"\n template_dir = default_template_dir\n retry\n end\n end",
"def generate_from_templates\r\n %w{package.json _config.yml}.each do |file|\r\n template file\r\n end\r\n end",
"def generate(output_folder, types, version_name)\n generate_objects(output_folder, types, version_name)\n copy_files(output_folder) \\\n unless @config.files.nil? || @config.files.copy.nil?\n compile_examples(output_folder) unless @config.examples.nil?\n compile_changelog(output_folder) unless @config.changelog.nil?\n # Compilation has to be the last step, as some files (e.g.\n # CONTRIBUTING.md) may depend on the list of all files previously copied\n # or compiled.\n compile_files(output_folder, version_name) \\\n unless @config.files.nil? || @config.files.compile.nil?\n\n generate_datasources(output_folder, types, version_name) \\\n unless @config.datasources.nil?\n apply_file_acls(output_folder) \\\n unless @config.files.nil? || @config.files.permissions.nil?\n end",
"def generate()\n prepare\n ::Dir.mkdir(@output_path) unless ::File.exists? @output_path\n\n @pages.each do |name, page|\n SiteLog.debug(\"Starting page generation - #{name}\")\n page.generate(@output_path, @version, @preserve_tree)\n SiteLog.debug(\"Finished page generation - #{name}\")\n end\n\n @files.each do |path, data|\n path = ::File.join(@output_path, path)\n ::FileUtils.mkdir_p(::File.dirname(path))\n ::File.open(path, \"w\") do |f|\n f.write(data)\n end\n end\n end",
"def generate_configuration_info_files\n provider_file = Configuration.provider_path(@configuration_path)\n template_file = Configuration.template_path(@configuration_path)\n registry_path = Configuration.registry_path(@configuration_path)\n File.open(provider_file, 'w') { |f| f.write('dedicated') }\n File.open(template_file, 'w') { |f| f.write(File.expand_path(@env.template_file)) }\n @registry.save_registry(registry_path)\n SshUser.save_to_file(@ssh_users, @configuration_path)\n end",
"def generate\n setup\n\n write_style_sheet\n generate_index\n generate_class_files\n generate_file_files\n generate_table_of_contents\n @json_index.generate\n @json_index.generate_gzipped\n\n copy_static\n\n rescue => e\n debug_msg \"%s: %s\\n %s\" % [\n e.class.name, e.message, e.backtrace.join(\"\\n \")\n ]\n\n raise\n end",
"def setup_files(config_generator)\n raise NotImplementedError\n end",
"def generate_files\n copy_file 'queued_task.rb', \"app/models/#{name}.rb\"\n end",
"def generate_files\n migration_template 'create_notifications.rb', \"db/migrate/create_notifications\"\n migration_template 'create_notifyings.rb', \"db/migrate/create_notifyings\"\n end",
"def generate_file_files\n template_file = @template_dir + 'file-page.html.erb'\n debug_msg \"Generating file documentation\"\n @all_files.each do |file|\n debug_msg \" file #{file.path}\"\n outfile = @output_dir + file.path\n @file = file\n self.render_template(template_file, binding(), outfile)\n end\n end",
"def generate_file_files\n setup\n\n page_file = @template_dir + 'page.rhtml'\n fileinfo_file = @template_dir + 'fileinfo.rhtml'\n\n # for legacy templates\n filepage_file = @template_dir + 'filepage.rhtml' unless\n page_file.exist? or fileinfo_file.exist?\n\n return unless\n page_file.exist? or fileinfo_file.exist? or filepage_file.exist?\n\n debug_msg \"Generating file documentation in #{@outputdir}\"\n\n out_file = nil\n current = nil\n\n @files.each do |file|\n current = file\n\n if file.text? and page_file.exist? then\n generate_page file\n next\n end\n\n template_file = nil\n out_file = @outputdir + file.path\n debug_msg \" working on %s (%s)\" % [file.full_name, out_file]\n rel_prefix = @outputdir.relative_path_from out_file.dirname\n search_index_rel_prefix = rel_prefix\n search_index_rel_prefix += @asset_rel_path if @file_output\n\n asset_rel_prefix = rel_prefix + @asset_rel_path\n\n unless filepage_file then\n if file.text? then\n next unless page_file.exist?\n template_file = page_file\n @title = file.page_name\n else\n next unless fileinfo_file.exist?\n template_file = fileinfo_file\n @title = \"File: #{file.base_name}\"\n end\n end\n\n @title += \" - #{@options.title}\"\n template_file ||= filepage_file\n\n render_template template_file, out_file do |io|\n here = binding\n # suppress 1.9.3 warning\n here.local_variable_set(:asset_rel_prefix, asset_rel_prefix)\n here.local_variable_set(:current, current)\n here\n end\n end\n rescue => e\n error =\n RDoc::Error.new \"error generating #{out_file}: #{e.message} (#{e.class})\"\n error.set_backtrace e.backtrace\n\n raise error\n end",
"def create_source_files\n empty_directory(File.join(target_dir, \"lib/kitchen/driver\"))\n\n create_template(\n \"version.rb.erb\",\n \"lib/kitchen/driver/#{name}_version.rb\"\n )\n create_template(\n \"driver.rb.erb\",\n \"lib/kitchen/driver/#{name}.rb\"\n )\n end",
"def generate\n gen_app\n handle_public_index\n gen_file(\"config/routes.rb\", \"routes\")\n @app.goals.values.each_with_index { |goal, i| gen_goal(goal, i) }\n gen_misc\n self\n end",
"def generate_all\n copy_template_dir('layouts', 'layouts')\n copy_template_dir('content/bootstrap', 'content/bootstrap')\n copy_template_dir('content/content', 'content/content')\n delete_target_file('lib/default.rb')\n copy_template_dir('lib', 'lib')\n delete_target_file('Rules')\n copy_template_file('Rules', 'Rules')\n copy_template_file('.gitignore', '.gitignore')\n copy_template_file('cg_config.rb', 'cg_config.rb')\n copy_template_file('cg_config.rb_sample', 'cg_config.rb_sample')\n delete_target_file('content/stylesheet.css')\n delete_target_file('content/index.html')\n delete_target_file('layouts/default.html')\n create_empty_dir('content/images')\n end",
"def generate_files\n migration_template 'migration.rb', \"db/migrate/#{name}.rb\"\n end",
"def generate\n Dir.mkdir(@configuration_path)\n @configuration_template.check_nodes_names.and_then do\n create_links_to_ssh_keys\n end.and_then do\n generate_configuration_file\n end\n end",
"def generate_ansible_files\n \n # Helper to decide whether or not to generate/update a given file\n update = Proc.new do |fn, mtime|\n !(File.exists?(fn) && File.stat(fn).mtime >= mtime)\n true\n end\n\n Dir.glob('./templates/ansible.*').each do |template|\n\n # Get a template's last modified date\n source_mtime = File.stat(template).mtime \n\n # Get a destination's potential file name & path \n target_file = File.basename(template).split('.').slice(1...-1).join('.') \n target_paths = target_file.start_with?('inventory') ? ['inventory/'] : ['', 'plays/*/']\n\n # Walk destination path(s)\n target_paths.each do |target_path|\n \n Dir.glob(\"./ansible/#{target_path}\").each do |path|\n\n # Build a potential real path\n fn = File.join(File.expand_path(path), target_file) \n\n # Yield source (template file) & target if the target needs to be generated/updated\n yield template, fn if update.call(fn, source_mtime) && block_given?\n end\n end\n end\nend",
"def generate()\n objects = []\n\n # generate object file tasks\n files.each do |fname|\n output_file = File.join(@build_dir, File.basename(fname).ext('o'))\n objects.push output_file\n file output_file => [ fname ] do\n get_toolchain().compile( fname, output_file )\n end\n end\n\n # Link object files\n file output_file() => objects do\n get_toolchain().link( objects, output_file() )\n end\n\n # Create top level task\n desc \"Build the #{@name} application\"\n task @name => [ output_file() ]\n end",
"def create_output_files\n return unless @option_output_path\n return if @collected_nodes.empty?\n @collected_nodes.each do |certname, properties|\n next if properties['settings'].empty?\n output_file = \"#{@option_output_path}/nodes/#{certname}.yaml\"\n File.write(output_file, properties['settings'].to_yaml)\n output(\"## Wrote Hiera YAML file: #{output_file}\\n\\n\")\n end\n return if @common_settings.empty?\n output_file = \"#{@option_output_path}/common.yaml\"\n File.write(output_file, @common_settings.to_yaml)\n end",
"def gen_dir\n File.join(root_path, 'generated')\n end",
"def generate\n\t\t dir = \"./experiments/\" + @arguments.first\n\t\t\tDir.mkdir(dir)\n\t\t\tFile.open(dir + \"/\" + @arguments.first + \".rb\", \"w\") do |req_file|\n\t\t\t req_file.puts \"# ## #{as_human_name @arguments.first} ##\"\n\t\t\t req_file.puts \"# \"+@options.description.split(\"\\n\").join(\"\\n# \")\n\t\t\t req_file.puts\n\t\t\t req_file.puts\n\t\t\t req_file.puts \"# The first contious block of comment will be included in your report.\"\n\t\t\t req_file.puts \"# This includes the reference implementation.\"\n\t\t\t req_file.puts \"# Override any desired files in this directory.\"\n\t\t\t Dir[\"./app/**/*.{rb,o,dll,so,bundle}\"].each do |f|\n\t\t\t next if File.basename(f) == 'extconfig.rb'\n\t\t\t p = File.expand_path(f).split(\"/\") - File.expand_path(\".\").split(\"/\")\n\t\t\t req_file.puts \"require \\\"#{p.join(\"/\").gsub(/\\.(rb|o|dll|so|bundle)$/, \"\")}\\\"\"\n\t\t\t end\n\t\t\t req_file.puts \"\\nclass #{as_class_name @arguments.first} < MyExperiment\\n\\t\\nend\"\n\t\t\tend\n\t\t\tFile.open(dir + \"/config.yaml\", \"w\") do |f|\n\t\t\t f << \"---\\nexperiment:\\n development:\\n compute:\\n\"\n end\n end",
"def generate\n if @options.dry_run then\n # do nothing\n @generator.generate\n else\n Dir.chdir @options.op_dir do\n unless @options.quiet then\n $stderr.puts \"\\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}...\"\n end\n\n @generator.generate\n update_output_dir '.', @start_time, @last_modified\n end\n end\n end",
"def prepare_config_files\n #Create .config dir\n #Create tucotuco dir\n #Create short dir\n #Create info file\n end",
"def generate_index_files\n @folders.each do |folder, files|\n puts \" + Creating #{@dest}/#{folder}/index.html\" if @verbose\n File.open(\"#{@dest}/#{folder}/index.html\", \"w\") do |index|\n title = \"Rails Plug-in for #@name #@version\"\n index.write(\"<html><head><title>#{title}</title></head>\\n\")\n index.write(\"<body>\\n\")\n index.write(\"<h2>#{title}</h2>\\n\")\n extra_links = create_extra_links()\n index.write(\"<p>#{extra_links}</p>\\n\") if extra_links\n files.each { |fn|\n puts(\" - Adding #{fn}\") if @verbose\n index.write(\" <a href=\\\"#{fn}\\\">#{fn}</a><br/>\\n\")\n }\n index.write(\"<hr size=\\\"1\\\"/><p style=\\\"font-size: x-small\\\">Generated with RailsPluginPackageTask<p>\")\n index.write(\"</body>\\n\")\n index.write(\"</html>\\n\")\n end\n end\n end",
"def render_and_write_templates\n clean_build_dir()\n\n yard_file_hash = {}\n\n Dir.glob(\"#{Dir.pwd}/projects/*\").select { |f| File.directory? f }.each do|project_dir|\n yard_file = \"#{project_dir}/yard.yaml\"\n\n unless yard_file.empty?\n yard = YAML::load_file(yard_file)\n next if yard['disabled']\n\n apps = yard['apps']\n project_name = yard['project']['name']\n project_pipelines = yard['pipelines']\n\n Dir.mkdir \"#{BUILD_DIR}/#{project_name}\"\n puts project_name\n\n apps.each do |app_name, app_config|\n Dir.mkdir(\"#{BUILD_DIR}/#{project_name}/#{app_name}/\")\n app_pipelines = Hash.new({})\n\n project_pipelines.each do |pipeline|\n app_pipelines[pipeline['name']] = app_pipelines[pipeline['name']].merge(pipeline)\n end\n\n unless app_config.nil? || app_config['pipelines'].nil?\n app_config['pipelines'].each do |pipeline|\n app_pipelines[pipeline['name']] = app_pipelines[pipeline['name']].merge(pipeline)\n end\n end\n\n # puts app_pipelines\n\n base_files = Dir[\"#{Dir.pwd}/base/*\"]\n project_base_files = Dir[\"#{project_dir}/base/*\"]\n app_files = Dir[\"#{project_dir}/#{app_name}/*\"]\n\n app_pipelines.each do|pipeline_name, pipeline_config|\n template_name = pipeline_config['templateName'] ? pipeline_config['templateName'] : \"#{pipeline_name}.json\"\n\n app_files.each do|path|\n render_and_write(\n pipeline_config: pipeline_config,\n path: path,\n template_name: template_name,\n app_name: app_name,\n project_name: project_name,\n app_template_vars: app_config['template_vars']\n )\n end\n project_base_files.each do|path|\n render_and_write(\n pipeline_config: pipeline_config,\n path: path,\n template_name: template_name,\n app_name: app_name,\n project_name: project_name,\n app_template_vars: app_config['template_vars']\n )\n end\n\n base_files.each do|path|\n render_and_write(\n pipeline_config: pipeline_config,\n path: path,\n template_name: template_name,\n app_name: app_name,\n project_name: project_name,\n app_template_vars: app_config['template_vars']\n )\n end\n end\n end\n end\n end\n end",
"def generate_index_files\n @folders.each do |folder, files|\n puts \" + Creating #{@dest}/#{folder}/index.html\" if @verbose\n File.open(\"#{@dest}/#{folder}/index.html\", \"w\") do |index|\n title = \"Rails Plug-in for #@name #@version\"\n index.write(\"<html><head><title>#{title}</title></head>\\n\")\n index.write(\"<body>\\n\")\n index.write(\"<h2>#{title}</h2>\\n\")\n extra_links = create_extra_links()\n index.write(\"<p>#{extra_links}</p>\\n\") if extra_links \n files.each { |fn|\n puts(\" - Adding #{fn}\") if @verbose\n index.write(\" <a href=\\\"#{fn}\\\">#{fn}</a><br/>\\n\")\n }\n index.write(\"<hr size=\\\"1\\\"/><p style=\\\"font-size: x-small\\\">Generated with RailsPluginPackageTask<p>\")\n index.write(\"</body>\\n\")\n index.write(\"</html>\\n\")\n end\n end\n end",
"def generate_all(template_file, output_dir, override=false)\n parse_messages(template_file).each do |message|\n target_file = File.join(output_dir, \"#{message.name}.xml\")\n if !File.exist?(target_file) or override\n File.open(target_file, \"w\") do |file|\n file.write(generate_message_xml(message))\n end\n end\n end\nend",
"def generate(site)\n return unless site.config['mini_magick']\n\n site.config['mini_magick'].each_pair do |name, preset|\n \n Dir.chdir preset['source'] do\n if preset['recursive'] == false \n #false\n root = '.'\n else\n #true or nil\n root = '**'\n end\n\n puts 'Add images for later processing:'\n puts Dir.pwd\n Dir.glob(File.join(root, \"*.{png,jpg,jpeg,gif,PNG,JPG,JPEG,GIF}\")) do |source|\n puts ' ' + source\n site.static_files << GeneratedImageFile.new(site, site.source, preset['destination'], source, preset.clone)\n end\n end\n end\n end",
"def generate_data!\n start_dir = Dir.pwd\n \n Dir.chdir tool_path\n system \"./generate -pc #{product_factor} -fn #{filename} -fc\"\n ensure\n Dir.chdir start_dir\n end",
"def generated_files() = @generated_files ||= []",
"def generate_files(base_dir,script,mtime=nil)\n\n base_dir ||= Dir.pwd\n\n script.each_pair do |filename,value|\n path = File.join(base_dir,filename)\n if value.instance_of? Hash\n FileUtils.mkdir_p(path)\n if mtime\n File.utime(mtime,mtime,path)\n end\n generate_files(path,value,mtime)\n else\n FileUtils.write_text_file(path,value)\n if mtime\n File.utime(mtime,mtime,path)\n end\n end\n end\n end",
"def create_config!\n template = File.read(TEMPLATES + 'montage.yml')\n template.gsub!(/<sprites>/, @sprites_path.to_s)\n template.gsub!(/<sources>/, @sources_path.to_s)\n\n File.open(@dir + '.montage', 'w') do |config|\n config.puts template\n end\n end",
"def generate\n template = Template.new\n template.add('timestamp', Time.now.to_s)\n template.add('lib_dir', @lib_dir)\n template.add('bin_dir', @bin_dir)\n template.parse(TEMPLATE)\n end",
"def generate_logrotate_configs(config_files, logrotate_conf_dir, logrotate_template_dir)\n config_files.each do |config_file|\n output_file = logrotate_conf_dir + config_file\n template_file = logrotate_template_dir + (config_file + '.erb')\n template output_file do\n source template_file\n mode '0644'\n end\n end\nend",
"def generate\n verify_path\n \n self.layouts.each {|layout| layout.write_file}\n self.pages.each {|page| page.write_file}\n \n Webby.site.content_dir = self.content_dir\n Webby.site.layout_dir = self.layout_dir\n Webby.site.template_dir = self.template_dir\n Webby.site.output_dir = self.output_dir\n \n Merb.logger.debug \"content_dir: #{Webby.site.content_dir}\"\n Merb.logger.debug \"layout_dir: #{Webby.site.layout_dir}\"\n Merb.logger.debug \"template_dir: #{Webby.site.template_dir}\"\n Merb.logger.debug \"output_dir: #{Webby.site.output_dir}\"\n \n # Use directory => '.' option to generate the site in output_dir\n Webby.site.page_defaults = {'layout' => self.default_layout.relative_path,\n 'directory' => '.',\n 'collision' => :force}\n \n Merb.logger.debug \"page_defaults: #{Webby.site.page_defaults}\" \n # returns nil if success \n # Webby::Builder.run\n Webby::Builder.run :rebuild => true\n end",
"def generate input_dir, output_dir, templates_dir\n\n backup_output_directory(output_dir)\n metadata = read_input_directory(input_dir)\n create_tree_and_copy_assets(metadata, input_dir, output_dir)\n inflate_content(metadata, metadata, input_dir, output_dir, templates_dir)\n\n # Return metadata, e.g. for RSS Feed\n metadata\n end",
"def write_meta_files\r\n @files.each do |file|\r\n template = ERB.new(\r\n File.new(File.join(@dirs[:templates],file[:template])).read,\r\n nil, \"%\")\r\n output_file = File.new(file[:path], \"w+\")\r\n output_file.write(template.result(binding))\r\n output_file.close\r\n end\r\n end",
"def gen_sub_directories\n FileUtils.mkdir_p RDoc::Generator::FILE_DIR\n FileUtils.mkdir_p RDoc::Generator::CLASS_DIR\n rescue\n $stderr.puts $!.message\n exit 1\n end",
"def gen_sub_directories\n FileUtils.mkdir_p RDoc::Generator::FILE_DIR\n FileUtils.mkdir_p RDoc::Generator::CLASS_DIR\n rescue\n $stderr.puts $!.message\n exit 1\n end",
"def generate\n Dixi.logger.info \"Generating index for #{@project}\"\n\n @entries = {}\n\n require 'find'\n Find.find( @project.version_dir.to_s ) do |path|\n if path =~ /index\\.yaml/\n Find.prune\n elsif path =~ /\\.yaml/\n res = Dixi::Resource.from_filepath(@project, Pathname.new(path))\n self.add( res )\n end\n end\n\n save!\n @loaded = true\n\n @entries\n end",
"def create_core_files\n empty_directory(target_dir)\n\n create_template(\"CHANGELOG.md.erb\", \"CHANGELOG.md\")\n create_template(\"Gemfile.erb\", \"Gemfile\")\n create_template(\"Rakefile.erb\", \"Rakefile\")\n create_template(\"README.md.erb\", \"README.md\")\n create_template(\"gemspec.erb\", \"#{config[:gem_name]}.gemspec\")\n create_template(\"license_#{config[:license]}.erb\", license_filename)\n create_template(\"gitignore.erb\", \".gitignore\")\n create_template(\"tailor.erb\", \".tailor\")\n create_template(\"travis.yml.erb\", \".travis.yml\")\n create_file(File.join(target_dir, \".cane\"))\n end",
"def generate_file_files( options, files, classes )\n\t\tdebug_msg \"Generating file documentation in #@outputdir\"\n\t\ttemplatefile = @template_dir + 'filepage.rhtml'\n\n\t\tfiles.sort_by {|k,v| k }.each do |path, fileinfo|\n\t\t\toutfile = @outputdir + fileinfo[:outfile]\n\t\t\tdebug_msg \" working on %s (%s)\" % [ path, outfile ]\n\t\t\trel_prefix = @outputdir.relative_path_from( outfile.dirname )\n\t\t\tcontext = binding()\n\n\t\t\tdebug_msg \" rending #{outfile}\"\n\t\t\tself.render_template( templatefile, binding(), outfile )\n\t\tend\n\tend",
"def generators\n write_selected_files\n\n title = 'Select a generator'\n script_path = '~/.config/cetus/generators'\n script_path = File.join(CONFIG_PATH, 'cetus', 'generators')\n binding = `find #{script_path} -type f | fzf --prompt=\"#{title} :\"`.chomp\n return if binding.nil? || binding == ''\n\n # call generator and accept list of files\n @title = \"Files from #{File.basename(binding)}\"\n @files = `#{binding} \"#{current_file}\"`.split(\"\\n\")\nend",
"def generate\n puts @root\n \n puts \"Processing files ...\"\n start_time = Time.now\n puts \"start --\"\n\n # getting list of committers\n puts \"Getting list of committers ...\"\n @committers = `git log --raw | grep \"^Author:\" | sort | uniq | sed -e 's/^Author: //g' -e 's/<.*//g'`.split(\"\\n\")\n @committers.uniq!\n\n # creaing an html file\n html_composer = HtmlComposer.new(@root, @report_path)\n html_composer.write_html_header\n\n files = FileList.new() do |f|\n @excluded_files.each { |e| \n f.exclude(e)\n puts \"Excluded #{e}\" \n }\n end\n @included_files.each do |i|\n files.add(i)\n end\n\n FileUtils.mkdir_p \"#{@root}/gs_temp\"\n Parallel.each(files, :in_processes => @config[:in_processes]) do |path|\n process_file(html_composer, path)\n end\n FileUtils.rm_r \"#{@root}/gs_temp\"\n\n # closing the html file\n html_composer.write_html_footer\n\n puts \"\"\n puts \"-- end\"\n\n elapsed_time = (Time.now - start_time).round(2)\n puts \"Processed in #{elapsed_time} secs\"\n end",
"def template_files\n generator_job_templates_path = File.join(self.class.source_root, \"jobs/%job_name%_#{purpose}\")\n directory \"jobs/%job_name%_#{purpose}\", \"jobs/#{job_name}\"\n\n # build a hash of { 'bin/webapp_ctl.erb' => 'bin/webapp_ctl', ...} used in spec\n @template_files = {}\n FileUtils.chdir(File.join(generator_job_templates_path, \"templates\")) do\n `ls */*`.split(\"\\n\").each do |template_file|\n # clean up thor name convention\n template_file.gsub!(\"%job_name%\", job_name)\n template_file.gsub!(\".tt\", \"\")\n # strip erb from target file\n target_template_file = template_file.gsub(/.erb/, '')\n\n @template_files[template_file] = target_template_file\n end\n end\n end",
"def setup\n templates = ['default']\n templates << @opts[:testkitchen] if @opts[:testkitchen]\n\n templates.each { |type| create_file(type) }\n end",
"def generate\n @to_copy = @git.ls_files.keys - ['README', 'README.md', 'README.markdown', 'generate.rb', '.gitignore']\n\n code_path = src_path('generate.rb')\n if File.exists?(code_path)\n eval(File.read(code_path), binding, code_path)\n end\n\n interpolate(@to_copy.select {|path| path =~ /\\.erb\\z/})\n copy @to_copy\n end",
"def generate_class_files\n setup\n\n template_file = @template_dir + 'class.rhtml'\n template_file = @template_dir + 'classpage.rhtml' unless\n template_file.exist?\n return unless template_file.exist?\n debug_msg \"Generating class documentation in #{@outputdir}\"\n\n current = nil\n\n @classes.each do |klass|\n current = klass\n\n generate_class klass, template_file\n end\n rescue => e\n error = RDoc::Error.new \\\n \"error generating #{current.path}: #{e.message} (#{e.class})\"\n error.set_backtrace e.backtrace\n\n raise error\n end",
"def gen_sub_directories\n @outputdir.mkpath\n end",
"def process_specs\n source_path = configuration['specs']['source_path']\n destin_path = configuration['specs']['destin_path']\n ignored_paths = configuration['specs']['ignored_paths']\n ignored_methods = configuration['specs']['ignored_methods']\n\n find_files_without(source_path, ignored_paths).each do |path|\n next unless path.include?('/models/') || path.include?('/controllers/') || path.include?('/helpers/')\n @spec_template = indent_template(spec_template, 0)\n @spec_describe_template = spec_describe_template.gsub(' ' * 8, ' ' * 2).strip.prepend(' ' * 2)\n\n spath = path.split(\"./#{source_path}/\")[1]\n dpath = \"./#{destin_path}/#{spath}\".gsub('.rb', '_spec.rb')\n\n unless File.exists?(dpath)\n methods_names_source = extract_methods_names_from_file(path)\n specs_methods_to_string = methods_names_source.map do |method_name|\n @spec_describe_template.gsub('%{method_name}', method_name)\n end.join(\"\\n\\n\")\n\n @spec_template = @spec_template.gsub('%{class}', extract_spec_name(path))\n @spec_template = @spec_template.gsub('%{methods}', specs_methods_to_string)\n @spec_template = @spec_template.gsub('%{file_path}', path)\n @spec_template = @spec_template.gsub('%{class_type}', extract_spec_type(path))\n @spec_template = @spec_template.gsub('%{author_name}', extract_author_name)\n\n FileUtils.mkdir_p(File.dirname(dpath))\n File.new(dpath, 'w+').puts(@spec_template)\n end\n end\n end",
"def generate_file_files( options, files, classes )\n\t\tdebug_msg \"Generating file documentation in #@outputdir\"\n\t\ttemplatefile = @template_dir + 'filepage.rhtml'\n\n\t\tmodsort = self.get_sorted_module_list( classes )\n\n\t\tfiles.sort_by {|k,v| k }.each do |path, fileinfo|\n\t\t\toutfile = @outputdir + fileinfo[:outfile]\n\t\t\tdebug_msg \" working on %s (%s)\" % [ path, outfile ]\n\t\t\trel_prefix = @outputdir.relative_path_from( outfile.dirname )\n\t\t\tcontext = binding()\n\n\t\t\tdebug_msg \" rendering #{outfile}\"\n\t\t\tself.render_template( templatefile, binding(), outfile )\n\t\tend\n\tend",
"def generate_class_files\n debug_msg \"Generating class documentation in #@outputdir\"\n templatefile = Pathname.new(File.dirname(__FILE__) + '/template/railsfish/classpage.rhtml')\n \n @classes.each do |klass|\n debug_msg \" working on %s (%s)\" % [ klass.full_name, klass.path ]\n outfile = @outputdir + klass.path\n rel_prefix = @outputdir.relative_path_from( outfile.dirname )\n svninfo = self.get_svninfo( klass )\n \n debug_msg \" rendering #{outfile}\"\n self.render_template( templatefile, binding(), outfile )\n end\n end",
"def generate_data_files\n files = {}\n\n # extracted data\n @classes.each do |category|\n files[category] = {}\n folder = File.join(@res, 'data', category.to_s, 'extracted')\n\n files[category][:extracted] = File.join(folder, \"#{category}.json\")\n end\n\n # divided data\n @classes.each do |category|\n files[category][:divided] = {}\n folder = File.join(@res, 'data', category.to_s, 'divided')\n\n @subsets.each do |subset|\n files[category][:divided][subset] = File.join(folder,\n \"#{category}_#{subset}.json\")\n end\n end\n\n # preprocessed data\n @classes.each do |category|\n files[category][:preprocessed] = {}\n\n @preproc.each do |preprocess|\n folder = File.join(\n @res, 'data', category.to_s, 'preprocessed', preprocess.to_s)\n\n files[category][:preprocessed][preprocess] = {}\n\n @subsets.each do |subset|\n files[category][:preprocessed][preprocess][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n\n # transformed data\n if @trans.size > 0\n @classes.each do |category|\n files[category][:transformed] = {}\n\n @trans.each do |transformation|\n @preproc.each do |preprocess|\n ctrans = :\"#{transformation}_#{preprocess}\"\n\n folder = File.join(\n @res, 'data', category.to_s, 'transformed', ctrans.to_s)\n\n files[category][:transformed][ctrans] = {}\n\n @subsets.each do |subset|\n files[category][:transformed][ctrans][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n end\n end\n\n # classified data\n if @classifs.size > 0\n @classes.each do |category|\n files[category][:classified] = {}\n\n @classifs.each do |classifier|\n @trans.each do |transformation|\n @preproc.each do |preprocess|\n ctrans = :\"#{classifier}_#{transformation}_#{preprocess}\"\n\n folder = File.join(\n @res, 'data', category.to_s, 'classified', ctrans.to_s)\n\n files[category][:classified][ctrans] = {}\n\n @subsets.each do |subset|\n files[category][:classified][ctrans][subset] = File.join(\n folder, \"#{category}_#{subset}.json\")\n end\n end\n end\n end\n end\n end\n files\n end",
"def generate_locale_files\n enforce = I18n.enforce_available_locales\n I18n.enforce_available_locales = false\n\n locales.each do |locale|\n I18n.with_locale(locale) do\n template 'locale.yml', File.join(\"config\", \"locales\", \"#{file_name}.#{locale.to_s}.yml\")\n end\n end\n\n I18n.enforce_available_locales = enforce\n end",
"def build!\n create_output_directory\n spec.source_directories.each { |d| simple_compile_directory(d) }\n compile_files(spec.all_javascript_paths)\n compile_files(spec.all_stylesheet_paths)\n write_manifest\n end",
"def generate(save = false)\n # Code to export into the manifest cache\n export = \"Sereth::TemplateManager::Manifest.register(:raw)\"\n\n Dir.glob(\"app/template/raw/**\") do |file| \n template = Parser.read(file)\n template.raw = file\n\n if save\n # Store the parsed template to server throuch a controller\n template.cache = \"app/template/cache/#{template.name}\"\n File.open(template.cache) do |cached_template|\n cached_template.print(template.code)\n end\n\n # Store the template metadata for serving cached data in production\n File.open(\"app/template/manifest.rb\", \"w\") do |manifest| \n manifest.puts(export % {raw: template.metadata})\n end\n end\n end\n end",
"def generate_migrations\n Dir[File.join(source_paths, 'db', 'migrate', '*.rb')].each do |file|\n migration_filepath = file.match(/\\A.+\\/(db\\/migrate\\/.+)\\Z/i)[1]\n raw_migration_filename = file.match(/\\d+\\_(.+)\\Z/i)[1] \n migration_template migration_filepath, \"db/migrate/#{raw_migration_filename}\" \n end\n end",
"def generate\n # Ensure site is a directory\n FileUtils.mkdir_p site_path\n\n # If there is more than one language, then we need to create\n # multiple files, one for each language.\n if languages.size >= 1\n\n # Enter the most dastardly loop. \n # Create a View::Document with sections only containing the \n # specified language. \n languages.map do |language|\n document_views = documents.map do |document|\n document.sections = document.sections.map do |section|\n section.examples = section.examples.select {|ex| ex.language.blank? || ex.language == language }\n section\n end\n\n Views::Document.new document\n end\n\n # Use Mustache to create the file\n page = Page.new\n page.title = title\n page.logo = File.basename logo if logo\n page.documents = document_views\n\n File.open(\"#{site_path}/#{language.underscore}.html\", \"w\") do |file|\n file.puts page.render\n end\n end\n\n # copy the default language to the index and were done!\n FileUtils.cp \"#{site_path}/#{default.underscore}.html\", \"#{site_path}/index.html\"\n\n # There are no languages specified, so we can just create one page\n # using a collection of Document::View.\n else \n document_views = documents.map do |document|\n Views::Document.new document\n end\n\n page = Page.new\n page.title = title\n page.logo = File.basename logo if logo\n page.documents = document_views\n\n File.open(\"#{site_path}/index.html\", \"w\") do |file|\n file.puts page.render\n end\n end\n\n # Copy the logo if specified\n FileUtils.cp \"#{logo}\", \"#{site_path}/#{File.basename(logo)}\" if logo\n\n # Copy all the stylesheets into the static directory and that's it!\n resources_path = File.expand_path \"../resources\", __FILE__\n\n FileUtils.cp \"#{resources_path}/style.css\", \"#{site_path}/style.css\"\n FileUtils.cp \"#{resources_path}/syntax.css\", \"#{site_path}/syntax.css\"\n end",
"def generate_pages\n Dir.foreach(@site_path) do |file|\n if file =~ /(\\w+)\\.page/\n path = File.join(@site_path, file)\n\n File.open(File.join(@site_path, \"#{$1}.html\"), 'w') do |f|\n f << generate_page(parse_page(path))\n end\n\n @log.debug(\" generated a page from #{path}\")\n end\n end\n end",
"def generate(destination)\n destination = Pathname(destination).expand_path\n # First, we find all of the renderable files in the project and iterate over that list.\n #\n # Next, we create a [Page](./soundwave/page.html) object for each file and write it to\n # the destination path.\n find_paths.each do |path|\n page = Page.new(self, path)\n page.write(destination.join(page.output_path))\n end\n end",
"def generate_configuration\n template \"mebla.yml\", \"config/mebla.yml\"\n end",
"def generator\n printf(\"%-10s %s\\n\",\"generator:\", \"generating.. (*hdls, *bmm, *scr, *prj)\")\n exitcode = 1\n FileUtils.rm_r Dir.glob(\"#{TMPDIR}/hdl/*.vhd\")\n FileUtils.rm_r Dir.glob(\"#{TMPDIR}/synthesis/*.vhd\")\n File.symlink(\"../pcores\", \"#{TMPDIR}/pcores\") unless File.symlink?(\"#{TMPDIR}/pcores\")\n pipe = IO.popen(\"platgen -od #{TMPDIR}/ -p xc4vfx100ff1152-10 -lang vhdl ../system.mhs\", \"r+\")\n # pipe = IO.popen(\"platgen -p xc4vfx12ff668-10 system.mhs\", \"r+\")\n pipe.each do |line|\n # puts line\n # do not synthesize\n if line =~ /Running XST synthesis/\n exitcode = 0\n Process.kill 'TERM', pipe.pid\n break\n end\n end\n unless exitcode == 0\n p \"# Error with platgen - check platgen.log\"\n exit\n end\n\n # he generated files under $PROJECT/TMPDIR/{hdl,synthesis}\n # copy them to $PROJECT/hdl/ under certain conditions (size differs & or abstence)\n FileUtils.mkdir('hdl') unless File.directory? 'hdl'\n FileUtils.mkdir('synthesis') unless File.directory? 'synthesis'\n FileUtils.mkdir_p(BMM_RESULTSDIR) unless File.directory? BMM_RESULTSDIR # output directory\n\n # move_files_if(\"#{TMPDIR}/hdl/*.vhd\")\n move_files_if(\"#{TMPDIR}/implementation/#{TOPLEVEL}.bmm\", BMM_RESULTSDIR)\n move_files_if(\"#{TMPDIR}/synthesis/*.scr\" )\n move_files_if(\"#{TMPDIR}/synthesis/*.prj\")\n Find.find(\"#{TMPDIR}/hdl\") do |path|\n move_files_if(path) if File.file? path\n end\n\n # move logfiles to scratch\n FileUtils.mkdir_p(GEN_SCRATCHDIR) unless File.directory? GEN_SCRATCHDIR\n [\"platgen.log\", \"platgen.opt\", \"#{TMPDIR}/clock_generator*.log\"].each { |t|\n FileUtils.mv(t, \"#{GEN_SCRATCHDIR}/\") if File.file? t\n }\n\n # change timestamps\n\nend",
"def generateRakeFor_GenerateSourceFiles\n lLstGlobalRecordTasks = []\n\n # 1. Recordings\n lRecordingsConf = @RecordConf[:Recordings]\n if (lRecordingsConf != nil)\n # Generate recordings rules\n # Gather the recording environments and their respective file names to produce\n # map< Symbol, list< String > >\n lRecordings = {}\n lTracksConf = lRecordingsConf[:Tracks]\n if (lTracksConf != nil)\n lTracksConf.each do |iLstTracks, iRecordingConf|\n lEnv = iRecordingConf[:Env]\n lRecordedFileName = getRecordedFileName(lEnv, iLstTracks)\n\n desc \"Raw recording of tracks #{iLstTracks.sort.join(', ')} in recording environment #{lEnv}\"\n file lRecordedFileName do |iTask|\n # Raw recording task\n record(iTask.name, @Context[:RecordedFilesPrepared])\n end\n\n if (lRecordings[lEnv] == nil)\n lRecordings[lEnv] = []\n end\n lRecordings[lEnv] << lRecordedFileName\n # If there is a need of calibration, record also the calibration files\n if (iRecordingConf[:CalibrateWithEnv] != nil)\n lReferenceEnv = iRecordingConf[:CalibrateWithEnv]\n [\n [ lReferenceEnv, lEnv ],\n [ lEnv, lReferenceEnv ]\n ].each do |iEnvPair|\n iRefEnv, iRecEnv = iEnvPair\n lCalibrationFileName = getRecordedCalibrationFileName(iRefEnv, iRecEnv)\n if (lRecordings[iRecEnv] == nil)\n lRecordings[iRecEnv] = []\n end\n if (!lRecordings[iRecEnv].include?(lCalibrationFileName))\n\n desc \"Calibration recording in recording environment #{iRecEnv} to be compared with reference environment #{iRefEnv}\"\n file lCalibrationFileName do |iTask|\n record(iTask.name, @Context[:RecordedFilesPrepared])\n end\n\n lRecordings[iRecEnv] << lCalibrationFileName\n end\n end\n @Context[:EnvsToCalibrate][[ lReferenceEnv, lEnv ].sort] = nil\n end\n end\n end\n # Make the task recording in the correct order\n lSortedEnv = lRecordingsConf[:EnvRecordingOrder] || []\n lRecordings.sort do\n |iElem1, iElem2|\n if (iElem2[1].size == iElem1[1].size)\n next iElem1[0] <=> iElem2[0]\n else\n next iElem2[1].size <=> iElem1[1].size\n end\n end.each do |iElem|\n if (!lSortedEnv.include?(iElem[0]))\n lSortedEnv << iElem[0]\n end\n end\n lLstTasks = []\n lSortedEnv.each do |iEnv|\n lLstFiles = lRecordings[iEnv]\n if (lLstFiles != nil)\n # Record a silence file\n lSilenceFile = getRecordedSilenceFileName(iEnv)\n\n desc \"Record silence file for recording environment #{iEnv}\"\n file lSilenceFile do |iTask|\n # Raw recording task\n record(iTask.name, @Context[:RecordedFilesPrepared])\n end\n\n lSymTask = \"Record_#{iEnv}\".to_sym\n\n desc \"Record all files for recording environment #{iEnv}\"\n task lSymTask => lLstFiles + [lSilenceFile]\n\n lLstTasks << lSymTask if (@Context[:LstEnvToRecord].empty?) or (@Context[:LstEnvToRecord].include?(iEnv))\n end\n end\n\n desc 'Record all files'\n task :Record => lLstTasks\n\n lLstGlobalRecordTasks << :Record\n end\n\n # 2. Wave files\n lWaveFilesConf = @RecordConf[:WaveFiles]\n if (lWaveFilesConf != nil)\n # Generate wave files rules\n lLstWaveFiles = []\n lWaveFilesConf[:FilesList].map { |iFileInfo| iFileInfo[:Name] }.each do |iFileName|\n lWaveFileName = getWaveSourceFileName(iFileName)\n if (!File.exists?(iFileName))\n\n desc \"Generate wave file #{iFileName}\"\n file lWaveFileName do |iTask|\n puts \"Create Wave file #{iTask.name}, and press Enter when done.\"\n $stdin.gets\n end\n\n end\n lLstWaveFiles << lWaveFileName\n end\n\n desc 'Generate all wave files'\n task :GenerateWaveFiles => lLstWaveFiles\n\n lLstGlobalRecordTasks << :GenerateWaveFiles\n end\n\n desc 'Generate source files (both recording and Wave files)'\n task :GenerateSourceFiles => lLstGlobalRecordTasks\n\n @Context[:RakeSetupFor_GenerateSourceFiles] = true\n end",
"def generate\n template_dir = File.join(File.dirname(__FILE__), \"../templates\")\n proxy_hpp = Generation.render_template template_dir, \"proxies\", \"Task.hpp\", binding\n proxy_cpp = Generation.render_template template_dir, \"proxies\", \"Task.cpp\", binding\n file_proxy_hpp = Generation.save_automatic(project.name, \"/proxies\", \"#{task.basename}.hpp\", proxy_hpp)\n file_proxy_cpp = Generation.save_automatic(project.name, \"/proxies\", \"#{task.basename}.cpp\", proxy_cpp)\n\n forward_hpp = Generation.render_template template_dir, \"proxies\", \"Forward.hpp\", binding\n file_forward_hpp = Generation.save_automatic(project.name, \"proxies\", \"#{task.basename}Forward.hpp\", forward_hpp)\n\n cmake = Generation.render_template template_dir, 'proxies', 'CMakeLists.txt', binding\n Generation.save_automatic(project.name, 'proxies', \"CMakeLists.txt\", cmake)\n \n pc = Generation.render_template template_dir, \"proxies\", \"proxies.pc\", binding\n Generation.save_automatic(project.name, \"proxies\", \"#{project.name}-proxies.pc.in\", pc)\n end",
"def generate_bulk_export\n # Delete the bulk_export directory if it exists.\n FileUtils.rm_rf(\"bulk_export\")\n\n get_all_insurance_plans\n get_all_location_resources\n p \"===============================================================\"\n p \"Creating the Bulk export folder output ...\"\n generate_payer_bulk_data\n generate_formulary_bulk_data\nend",
"def generate(info)\n @info = info\n @files = []\n @classes = []\n @hyperlinks = {}\n\n build_indices\n generate_xml\n end",
"def generate_files\n copy_file 'who_is_online_channel.rb', \"app/channels/#{name}_channel.rb\"\n copy_file 'who_is_online.coffee', \"app/assets/javascripts/channels/#{name}.coffee\"\n end",
"def compile_templates\n dir = File.join(Frank.root, Frank.dynamic_folder)\n\n Dir[File.join(dir, '**{,/*/**}/*')].each do |path|\n if File.file?(path) && !File.basename(path).match(/^(\\.|_)/)\n path = path[ (dir.size + 1)..-1 ]\n ext = File.extname(path)\n new_ext = ext_from_handler(ext)\n name = File.basename(path, ext)\n\n # No suitable handler found\n if not new_ext.is_a? String\n next\n end\n\n if Frank.production? && \"#{name}.#{new_ext}\" != 'index.html' && new_ext == 'html'\n new_file = File.join(Frank.export.path, path.sub(/(\\/?[\\w-]+)\\.[\\w-]+$/, \"\\\\1/index.#{new_ext}\"))\n else\n new_file = File.join(Frank.export.path, path.sub(/\\.[\\w-]+$/, \".#{new_ext}\"))\n end\n\n create_dirs(new_file)\n File.open(new_file, 'w') {|f| f.write render(path) }\n puts \" - \\033[32mCreating\\033[0m '#{new_file}'\" unless Frank.silent_export?\n end\n end\n end",
"def all_template_files\n files = super\n files + Dir.glob(\"#{JenkinsJob.flavor_dir}/templates/**.xml.erb\")\n end",
"def all_template_files\n files = super\n files + Dir.glob(\"#{JenkinsJob.flavor_dir}/templates/**.xml.erb\")\n end",
"def generate(site)\n return unless site.config['mini_magick'] && site.config['mini_magick_enabled']\n versions = site.config['mini_magick']['versions']\n\n site.config['mini_magick']['galleries'].each do |gallery|\n path = \"/Users/adam/code/blogs/adamfortuna.com-images/images/galleries/#{gallery}\"\n\n # Loop through all images in this gallery\n Dir.glob(File.join(path, \"*.{png,jpg,jpeg,gif,JPG}\")) do |source|\n versions.each_pair do |version, options|\n settings = options.clone\n settings['source'] = path\n settings['destination'] = File.join(path, version)\n\n if site.config['mini_magick_regererate'] || !File.exists?(File.join(path, version, File.basename(source)))\n site.static_files << GeneratedImageFile.new(site, path, settings['destination'], File.basename(source), settings)\n end\n end\n end\n end\n end",
"def generate\n end",
"def generate(spec)\n setup_project(@project_name)\n add_default_files_to_definition\n `merb-gen app --force #{@project_name}`\n cd(@project_name) do\n @parser.parse(spec)\n gen_descriptions\n gen_relationships\n gen_requirements\n # gen_add_methods\n gen_router\n gen_request_specs\n \n # replace generated controllers with what we need when using restful routes\n # as defined in the app/controllers/application.rb\n hack_controllers\n\n add_files_to_project\n add_spec_to_project\n gen_app_config_file\n gen_jeweler_rake\n end\n end",
"def write\n make_parent_directory\n generate_file\n end",
"def create_model_files\n template 'model.rb', File.join('app/models/mokio', class_path, \"#{file_name}.rb\")\n end",
"def gen_app_config_file\n filename = 'config/init/app_config.rb'\n bakname = 'config/init/app_config.rb~'\n File.delete(bakname) if File.exist?(bakname)\n File.rename(filename, bakname) if File.exist?(filename)\n File.open(filename, \"w\") do |file|\n file.puts(app_config_content)\n end\n end",
"def generate\n #debug 'generate'\n\n #return nil\n path = self[:path]\n if path == nil\n path = self[:name]\n end\n existing_file_res = catalog.resource(:file, path)\n if !existing_file_res\n #_ensure = self[:ensure] == :present ? :file : :absent\n _ensure = self[:ensure]\n filetype = Puppet::Type.type(:file)\n fileparams = {:name => path, \n :ensure => _ensure,\n :backup => false,\n :checksum => :none\n }\n if self[:mode]\n fileparams[:mode] = self[:mode]\n end\n if self[:owner]\n fileparams[:owner] = self[:owner]\n end\n if self[:group]\n fileparams[:group] = self[:group]\n end\n file_res = filetype.new(fileparams)\n #debug \"resource file does not exist yet -> generate it with #{_ensure.to_s}\"\n #debug 'generated: ' + file_res.inspect\n result = [file_res]\n else\n #debug 'resource file already exists'\n result = nil\n end\n result\n end",
"def templates_for(file); end",
"def generate(output_folder, types, _product_path, _dump_yaml, generate_code, generate_docs)\n generate_objects(\n output_folder,\n types,\n generate_code,\n generate_docs\n )\n end",
"def generate_project\n @writer.make_project_root\n\n project_dirs = %w(docs lib spec bin)\n @writer.create_dirs(project_dirs)\n\n files = {\n :executable => \"bin/#{@project_name}\",\n :gemspec => '',\n :gitignore => '.gitignore',\n :gitattributes => '.gitattributes',\n :gemspec => \"#{@project_name}.gemspec\",\n }\n @writer.copy_templates_for(files)\n end",
"def create_all\n for i in 0..Pdf.get_pdf_file_count do\n pdf = Pdf.create_pdf(i.to_s, @client, @settings)\n pdf_file_name = Pdf.get_pdf_file_name(Pdf::PDFS.keys[i], @client)\n pdf.render_file(\"#{Rails.root}/app/assets/generated-pdfs/#{pdf_file_name}\")\n end\n generate_zip(@client)\n end",
"def write_default_files\n templates = load_templates\n File.open('controller.rb', 'w') { |f| f.write(templates[:controller]) }\n File.open('README.md', 'w') { |f| f.write(templates[:readme]) }\n File.open('index.html.erb', 'w') { |f| f.write(templates[:index]) }\n File.open('Gemfile', 'w') { |f| f.write(templates[:gemfile]) }\nend",
"def generate_models\n if options[:namespace]\n empty_directory(\"app/models/#{options[:namespace].downcase}\")\n generate_base_namespaced_model\n end\n discovered_tables.each do |table_name|\n @model_name = model_name_from_table_name table_name\n @model_file_name = model_file_name_from_table_name table_name\n @columns = connection.columns(table_name)\n @indexes = connection.indexes(table_name)\n @associations = detected_associations(table_name, @columns)\n template 'model.rb', \"app/models/#{options[:namespace] ? options[:namespace]+'/' : ''}#{@model_file_name}.rb\"\n end\n puts %Q(config.autoload_paths += %W(\\#{config.root}/app/models/#{options[:namespace].downcase})) if options[:namespace]\n end",
"def load_generator_tasks!(config)\n extend ::Rake::DSL\n namespace :db do\n namespace :generate do\n\n desc \"Generate and write a config/database.yml\"\n task :config do\n db_config_path = config.db_config_path\n if File.exists?(db_config_path)\n puts \"Database config already exists at #{db_config_path}; skipping...\"\n else\n FileUtils.mkdir_p(config.config_path)\n FileUtils.cp(File.join(TEMPLATES_PATH, 'database.yml'), db_config_path)\n end\n end\n\n desc \"Generate a database migration, eg: rake db:generate:migration NAME=CreatePosts\"\n task :migration do\n migrations_path = config.migrations_path\n timestamp = Time.now.strftime(\"%Y%m%d%H%M%S\")\n name = ENV.fetch('NAME') do\n fail \"Usage: rake db:generate:migration NAME=CreatePosts\"\n end\n\n # Normalise the name to a MigrationClass and a migration_filename\n migration_class = ActiveSupport::Inflector.camelize(name)\n migration_filename = \"#{timestamp}_#{ActiveSupport::Inflector.underscore(name)}.rb\"\n migration_path = File.join(migrations_path, migration_filename)\n\n template = File.read(File.join(TEMPLATES_PATH, 'migration.erb'))\n FileUtils.mkdir_p(migrations_path)\n File.write(migration_path, ERB.new(template).result(binding))\n\n puts \"Created migration: #{migration_path}\"\n end\n end\n end\n end",
"def build_docs\n object_map.each do |index, objects|\n objects.each do |object|\n template_context = {\n #:meta => Site\n index => object\n }\n content = converter.render(template_map[index], template_context)\n filename = converter.filename_for(object)\n write_output_file(filename, content)\n end\n end\n end",
"def generate_class_and_module_files\n template_file = @template_dir + 'class-page.html.erb'\n debug_msg \"Generating class documentation\"\n @unique_classes_and_modules.each do |klass|\n debug_msg \" %s %s\" % [klass.type, klass.full_name]\n outfile = @output_dir + klass.path\n @class = klass\n self.render_template(template_file, binding(), outfile)\n end\n end",
"def gen_sub_directories\n\t\t@outputdir.mkpath\n\tend",
"def gen_sub_directories\n\t\t@outputdir.mkpath\n\tend",
"def foreach\n find_files.each do |file|\n yield(@build_result_dir, file)\n end\n end",
"def generate(site)\n # Configuration\n sitemap_config = site.config['sitemap'] || {}\n\n # create destination directory if it doesn't exist yet\n Dir::mkdir(site.dest) if !File.directory? site.dest\n $fileHtml = File.new(File.join(site.dest, FILE_NAME), \"w+\")\n\n $base = site.dest\n\n traverse(File.join(site.dest, \"/setups\"))\n\n $fileHtml.close()\n\n # Keep the file from being cleaned by Jekyll\n site.static_files << Jekyll::SitemapFile.new(site, site.dest, \"/\", FILE_NAME)\n\n FileUtils.cd('./include')\n FileUtils.cp File.join(site.dest, FILE_NAME), File.join(FileUtils.pwd(), \"scen.html\")\n end",
"def generate force_build = false\n blog_template = Template::Blog.new self\n\n skipped_files = []\n new_files = []\n updated_files = []\n old_files = Dir.glob('public/**/*.html')\n\n blog_template.modes.each {\n |mode|\n\n blog_template.mode = mode\n\n (1..blog_template.pages).each { |page|\n blog_template.page = page\n path = blog_template.local_path\n pretty_path = Pathname.new(path).relative_path_from(Pathname.new(@spec.blog_root)).to_s\n\n if old_files.include? pretty_path\n old_files.delete pretty_path\n end\n\n mtime = File.exists?(path) ? File.mtime(path) : nil\n needs_update = force_build || mtime.nil?\n\n if ! needs_update\n needs_update = blog_template.posts.any? {\n |post|\n mtime < File.mtime(post.post_data.source_path)\n }\n\n if ! needs_update\n skipped_files << path\n next\n end\n end\n\n dir = File.dirname(path)\n FileUtils.mkdir_p dir unless File.directory? dir\n\n if File.exists? path\n updated_files << pretty_path\n else\n new_files << pretty_path\n end\n\n r = nil\n File.open(path, 'w') {\n |io|\n io.write blog_template.render\n }\n }\n }\n\n updated_files.each { |path| puts \"* #{path}\" }\n\n new_files.each { |path| puts \"+ #{path}\"}\n\n old_files.each {\n |path|\n puts \"- #{path}\"\n File.unlink path\n dir = File.dirname path\n if Dir.entries(dir) == @@EMPTY_DIR_ENTRIES\n Dir.unlink dir\n end\n }\n end",
"def create\n create_checkpoints\n create_config_base\n generate_deploy_files\n generate_hiera_template\n end",
"def call\n INSTALL_DIRS.each do |dir|\n FileUtils.mkdir_p Karafka.root.join(dir)\n end\n\n INSTALL_FILES_MAP.each do |source, target|\n target = Karafka.root.join(target)\n next if File.exist?(target)\n\n source = Karafka.core_root.join(\"templates/#{source}\")\n FileUtils.cp_r(source, target)\n end\n end",
"def generate_populate_folder\n empty_directory 'db/populate'\n # copy_file \"template_filename\", \"final_directory\" # With this we will copy the file straigh from tempaltes folder to the final destination\n # template \"template_filename\", \"final_directory\" # With this we can pass arguments to the template\n # if option_name ...\n end",
"def create_files\n tests.each do |test|\n FileUtils.mkdir(test.id.to_s) unless Dir.exist?(test.id.to_s) if test.option[:dir]\n files = []\n files << test.action.split('?').first\n files += test.option[:implicit]\n files << test.result_rdf if test.result_rdf\n files << test.result_json if test.result_json\n files.compact.select {|f| !File.exist?(f)}.each do |f|\n File.open(f, \"w\") {|io| io.puts( f.end_with?('.json') ? \"{}\" : \"\")}\n end\n end\n end",
"def expand_template_files\n rails_host = config['bind-address'] || `hostname`.chomp\n rails_port = config['port-number'].to_s\n rails_url = \"http://#{rails_host}:#{rails_port}\"\n Dir[File.join(install_directory,'installer','*.template')].each do |template_file|\n output_file = template_file.gsub(/\\.template/,'')\n next if File.exists?(output_file) # don't overwrite files\n\n message \"expanding #{File.basename(output_file)} template\"\n \n text = File.read(template_file).gsub(/\\$RAILS_URL/,rails_url).gsub(/\\$RAILS_HOST/,rails_host).gsub(/\\$RAILS_PORT/,rails_port)\n \n File.open(output_file,'w') do |f|\n f.write text\n end\n end\n end",
"def generate\n end",
"def generate_project_file\n template_file = @template_dir + 'hhp_file.hhp.rhtml'\n\n @values = { :title => @options.title, :opname => @outputdir.basename }\n \n static_files = ['index.html', 'classindex.html', 'fileindex.html']\n @values[:html_files] = static_files + (@generated_files+@classes).map{|f| f.path}.uniq\n \n out_file = @outputdir + @project_name\n debug_msg \" rendering #{out_file}\"\n render_template template_file, out_file do |io| binding end\n end",
"def config_dir\n runtime_config.generated_files_dir\n end"
] |
[
"0.70923567",
"0.70407",
"0.6990284",
"0.6926751",
"0.6828299",
"0.68100923",
"0.6641247",
"0.66312045",
"0.6614509",
"0.66023564",
"0.65694267",
"0.6545237",
"0.65097785",
"0.64939386",
"0.64928365",
"0.6467922",
"0.6463168",
"0.64235246",
"0.6420177",
"0.6414279",
"0.6344238",
"0.63362134",
"0.62871784",
"0.6256436",
"0.6213362",
"0.6213004",
"0.6203831",
"0.613193",
"0.6119302",
"0.61099553",
"0.6102667",
"0.6096643",
"0.60919297",
"0.60897523",
"0.6084318",
"0.6077166",
"0.6024992",
"0.60199785",
"0.599734",
"0.599734",
"0.5982777",
"0.5978482",
"0.5977754",
"0.59749305",
"0.5968554",
"0.59597635",
"0.59579676",
"0.59466964",
"0.5945898",
"0.59401083",
"0.59310895",
"0.5929514",
"0.59147924",
"0.5907731",
"0.5907106",
"0.58991003",
"0.58988845",
"0.58856696",
"0.58807",
"0.58762866",
"0.58754677",
"0.5868581",
"0.585874",
"0.58553845",
"0.58533436",
"0.58412945",
"0.5833557",
"0.5832016",
"0.58253145",
"0.5824432",
"0.5824432",
"0.58202595",
"0.58091784",
"0.5807997",
"0.58056706",
"0.5798303",
"0.5798081",
"0.5794743",
"0.5793517",
"0.57908267",
"0.5789556",
"0.57701105",
"0.57570934",
"0.5754775",
"0.57543594",
"0.57414407",
"0.5732192",
"0.57312995",
"0.57312995",
"0.5723454",
"0.57220435",
"0.56942576",
"0.5692294",
"0.5684337",
"0.5679827",
"0.5677275",
"0.5672288",
"0.56665117",
"0.56558096",
"0.5654559"
] |
0.5796557
|
77
|
I THINK IM MERGING THIS METHOD THAT ALREADY EXISTS IN MY PARENT CLASS(APPLICATION CONTROLLER, USING SUPER), SO BY DOING THAT IM OVERRRIDING THAT CLASS AND MAKING ALL THE INFO IM PASSING AVAILABLE TO ALL MY VIES AND CONTROLLERS THKS TO INHERITANCE.
|
def url_options
{todo_list_id: params[:todo_list_id]}.merge(super) #ITS AUTOMATICALLY CALLED EVERYTIME A URL IS GENERATED.
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def public_instance_methods(include_super=true) end",
"def parent_api; end",
"def parent_api; end",
"def super_method; end",
"def protected_instance_methods(include_super=true) end",
"def instance_methods(include_super=true) end",
"def overrides; end",
"def private; end",
"def initialize ( _caller )\n super\n end",
"def initialize ( _caller )\n super\n end",
"def super_class; end",
"def super_class; end",
"def private_instance_methods(include_super=true) end",
"def internal; end",
"def my_info\r\n end",
"def method_missing(wh,*therest)\n # xxx internal methods must be protected at some point\n end",
"def special\n override\n end",
"def invoke\r\n # TODO: rename to more appropriate one 2007/05/10 by shino\r\n raise 'must be implemented in subclasses'\r\n end",
"def called_from; end",
"def called_from; end",
"def inherited(base); end",
"def management\n prepareBaseContext\n end",
"def process_hook\n fail 'child class to implement'\n end",
"def methods; end",
"def methods; end",
"def methods; end",
"def methods; end",
"def before_all\n super if defined?(super)\n end",
"def probers; end",
"def methods() end",
"def method_731(base); end",
"def superclass() end",
"def bi_service\n end",
"def base_class; end",
"def who_we_are\r\n end",
"def system_information\n super\n end",
"def system_information\n super\n end",
"def call(env)\n super(env,1)\n end",
"def process_hook\n fail 'sub class to implement'\n end",
"def get_info\n end",
"def get_info\n end",
"def get_info\n end",
"def invention; end",
"def inherited(klass); end",
"def inherited(klass); end",
"def scientist; end",
"def base; self; end",
"def access_info\n super\n end",
"def set_caller_params\n end",
"def initialize ( _caller, *list )\n super\n end",
"def initialize ( _caller, *list )\n super\n end",
"def implementation; end",
"def implementation; end",
"def delegating_method; end",
"def intensifier; end",
"def extra; end",
"def context_methods; end",
"def internal_methods; end",
"def service; end",
"def _prepare_context; end",
"def info; end",
"def info; end",
"def service_name\n raise \"please implement #service_name in your subclass #{self.class}\"\n end",
"def call\n # implement in subclasses\n end",
"def weber; end",
"def method_missing(method_name, *args)\n (args && args.size > 0) ? super(method_name, *args) : before_method(method_name)\n end",
"def setup\n #implement in subclass;\n end",
"def inherited( subclass )\n\t\t\tsuper\n\n\t\t\tverbs_copy = Strelka::DataUtilities.deep_copy( self.resource_verbs )\n\t\t\tsubclass.instance_variable_set( :@resource_verbs, verbs_copy )\n\n\t\t\topts_copy = Strelka::DataUtilities.deep_copy( self.service_options )\n\t\t\tsubclass.instance_variable_set( :@service_options, opts_copy )\n\t\tend",
"def before_dispatch(env); end",
"def custom; end",
"def custom; end",
"def across_service_state\n super\n end",
"def class_variables\n end",
"def instance_helper\n\tend",
"def service; raise NotImplementedError; end",
"def lookup_context; end",
"def lookup_context; end",
"def lookup_context; end",
"def notifier; end",
"def notifier; end",
"def registry; end",
"def registry; end",
"def instance_variables; end",
"def extended( hooked_instance )\n\n super if defined?( super )\n \n end",
"def extract_parameters(superclass); end",
"def extract_parameters(superclass); end",
"def invoke\n begin \n # RequestStore.available_services[@amfbody.service_class_name] ||=\n @service = @amfbody.service_class_name.constantize.new #handle on service\n rescue Exception => e\n puts e.message\n puts e.backtrace\n raise RUBYAMFException.new(RUBYAMFException.UNDEFINED_OBJECT_REFERENCE_ERROR, \"There was an error loading the service class #{@amfbody.service_class_name}\")\n end\n \n #call one or the other method depending in the ruby version we are using\n if RUBY_VERSION > RUBY_19\n caller = \"to_sym\"\n else\n caller = \"to_s\"\n end \n\n if @service.private_methods.include?(@amfbody.service_method_name.send(caller))\n raise RUBYAMFException.new(RUBYAMFException.METHOD_ACCESS_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.service_class_file_path}} is declared as private, it must be defined as public to access it.\")\n elsif !@service.public_methods.include?(@amfbody.service_method_name.send(caller))\n raise RUBYAMFException.new(RUBYAMFException.METHOD_UNDEFINED_METHOD_ERROR, \"The method {#{@amfbody.service_method_name}} in class {#{@amfbody.service_class_file_path}} is not declared.\")\n end\n \n #clone the request and response and alter it for the target controller/method\n req = RequestStore.rails_request.clone\n res = RequestStore.rails_response.clone\n \n #change the request controller/action targets and tell the service to process. THIS IS THE VOODOO. SWEET!\n controller = @amfbody.service_class_name.gsub(\"Controller\",\"\").underscore\n action = @amfbody.service_method_name\n req.parameters['controller'] = req.request_parameters['controller'] = req.path_parameters['controller'] = controller\n req.parameters['action'] = req.request_parameters['action'] = req.path_parameters['action'] = action\n req.env['PATH_INFO'] = req.env['REQUEST_PATH'] = req.env['REQUEST_URI'] = \"#{controller}/#{action}\"\n req.env['HTTP_ACCEPT'] = 'application/x-amf,' + req.env['HTTP_ACCEPT'].to_s\n \n #set conditional helper\n @service.is_amf = true\n @service.is_rubyamf = true\n \n #process the request\n rubyamf_params = @service.rubyamf_params = {}\n if @amfbody.value && !@amfbody.value.empty?\n @amfbody.value.each_with_index do |item,i|\n rubyamf_params[i] = item\n end\n end\n \n # put them by default into the parameter hash if they opt for it\n rubyamf_params.each{|k,v| req.parameters[k] = v} if ParameterMappings.always_add_to_params \n \n begin\n #One last update of the parameters hash, this will map custom mappings to the hash, and will override any conflicting from above\n ParameterMappings.update_request_parameters(@amfbody.service_class_name, @amfbody.service_method_name, req.parameters, rubyamf_params, @amfbody.value)\n rescue Exception => e\n raise RUBYAMFException.new(RUBYAMFException.PARAMETER_MAPPING_ERROR, \"There was an error with your parameter mappings: {#{e.message}}\")\n end\n\n #fosrias\n #@service.process(req, res)\n\n # call the controller action differently depending on Rails version\n if Rails::VERSION::MAJOR < 3\n @service.process(req, res)\n else\n @service.request = req\n @service.response = res\n @service.process(action.to_sym)\n end\n #fosrias\n \n #unset conditional helper\n @service.is_amf = false\n @service.is_rubyamf = false\n @service.rubyamf_params = rubyamf_params # add the rubyamf_args into the controller to be accessed\n \n result = RequestStore.render_amf_results\n \n #handle FaultObjects\n if result.class.to_s == 'FaultObject' #catch returned FaultObjects - use this check so we don't have to include the fault object module\n e = RUBYAMFException.new(result['code'], result['message'])\n e.payload = result['payload']\n raise e\n end\n \n #amf3\n @amfbody.results = result\n if @amfbody.special_handling == 'RemotingMessage'\n @wrapper = generate_acknowledge_object(@amfbody.get_meta('messageId'), @amfbody.get_meta('clientId'))\n @wrapper[\"body\"] = result\n @amfbody.results = @wrapper\n end\n @amfbody.success! #set the success response uri flag (/onResult)\n end",
"def before_each\n super if defined?(super)\n end",
"def agentx_information\n super\n end",
"def inherited(subclass); end",
"def schubert; end",
"def inherited( subclass )\n\t\t\tsuper\n\t\t\tStrelka::App::Auth.extended_apps << subclass\n\t\t\tsubclass.instance_variable_set( :@auth_provider, @auth_provider )\n\t\t\tsubclass.instance_variable_set( :@positive_auth_criteria, @positive_auth_criteria.dup )\n\t\t\tsubclass.instance_variable_set( :@negative_auth_criteria, @negative_auth_criteria.dup )\n\t\t\tsubclass.instance_variable_set( :@positive_perms_criteria, @positive_perms_criteria.dup )\n\t\t\tsubclass.instance_variable_set( :@negative_perms_criteria, @negative_perms_criteria.dup )\n\t\tend",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end",
"def context; end"
] |
[
"0.60870045",
"0.60677075",
"0.60677075",
"0.60270256",
"0.60247606",
"0.60061765",
"0.5973717",
"0.596544",
"0.596327",
"0.596327",
"0.5901155",
"0.5901155",
"0.5897629",
"0.58964896",
"0.58944404",
"0.579621",
"0.5789971",
"0.57849133",
"0.57613987",
"0.57613987",
"0.5752098",
"0.5751995",
"0.57514095",
"0.5743814",
"0.5743814",
"0.5743814",
"0.5743814",
"0.57212853",
"0.5719845",
"0.57186276",
"0.5710342",
"0.5702388",
"0.56938475",
"0.56841993",
"0.5671069",
"0.5664892",
"0.5664892",
"0.5661882",
"0.5652853",
"0.56283265",
"0.56283265",
"0.56283265",
"0.55940276",
"0.55931085",
"0.55931085",
"0.5583216",
"0.5580478",
"0.557957",
"0.5576016",
"0.55737925",
"0.55737925",
"0.5573554",
"0.5573554",
"0.5560953",
"0.5560657",
"0.55599016",
"0.5557339",
"0.55477905",
"0.5547003",
"0.5543103",
"0.5532372",
"0.5532372",
"0.5532354",
"0.55234414",
"0.55220914",
"0.5515354",
"0.5513384",
"0.55124825",
"0.5498901",
"0.5496685",
"0.5496685",
"0.549506",
"0.54850036",
"0.5481729",
"0.5470742",
"0.5449876",
"0.5449876",
"0.5449876",
"0.5444748",
"0.5444748",
"0.54410255",
"0.54410255",
"0.5436841",
"0.54335266",
"0.54306126",
"0.54306126",
"0.5427738",
"0.5427291",
"0.54234684",
"0.5419907",
"0.5418375",
"0.5413531",
"0.54121",
"0.54121",
"0.54121",
"0.54121",
"0.54121",
"0.54121",
"0.54121",
"0.54121",
"0.54121"
] |
0.0
|
-1
|
finds the first five primes
|
def count_prime(numbers)
prime_array = []
numbers.each do |num|
if prime?(num)
prime_array << num
end
end
output = "this array has #{numbers.length} numbers and #{prime_array.length} are prime: " + prime_array.join(", ")
output
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def primes(n) \n max = Math::sqrt(n).truncate\n (2..max).each {|val|\n if n % val == 0 then\n p val\n primes(n/val)\n return\n elsif val == max then\n p n\n return\n end\n }\nend",
"def primes(n)\nend",
"def primes_under(n)\n candidates = (3..n).step(2).to_a\n primes = [2]\n\n until primes.last > n ** 0.5\n primes << candidates.shift\n candidates.reject! {|candidate| candidate % primes[-1] == 0}\n end\n\n primes + candidates\nend",
"def primes(top)\n n = 2\n primes = []\n loop do\n primes << n if (2..Math.sqrt(n)).all? {|x| n % x != 0 }\n return primes.last if primes.count == top\n n += 1\n end\nend",
"def getPrimes()\n oldlimit = $primelimit + 1\n $primelimit *= 2\n\n for i in oldlimit...$primelimit\n isPrime = true\n $primes.each do |p|\n if i % p == 0\n isPrime = false\n break\n end\n end\n if isPrime\n $primes << i\n end\n end\n\nend",
"def primes\n Prime::EratosthenesGenerator.new.take_while {|i| i <= @base}\n end",
"def first_n_primes(n)\n\t return \"n must be an integer.\" unless n.is_a? Integer\n\t return \"n must be greater than 0.\" if (n<=0)\n\n prime_array||=[]\n\tprime = Prime.new\n\tn.times {prime_array << prime.next } \n\tprime_array\nend",
"def p7\n\tprimes = [2]\n\t(1...10001).each do\n\t\tprime = next_prime(primes[-1])\n\t\tprimes << prime\n\tend\n\tprimes[-1]\nend",
"def primes\n\t\t# primes = []\n\t\t# primes << 2\n\t\tprimes = [2] # combined previous two lines\n\t\tx = 3\n\n\t\tloop do\n\t\t\tbreak if primes.length == @n_primes # End loop when desired number has been calculated\n\t\t# while primes.length < @n_primes # Alternative 1 to loop do, break\n\t\t# until primes.length == @n_primes # Alternative 2 to loop do, break\n\t\t\ty = 3\n\t\t\ty += 2 until x % y == 0 # Loop to test if x is divisible by any odd number below it, y\n\t\t\tprimes << x if x == y # If the (odd) number was not divisible by any (odd) below itself, it is a prime\n\t\t\tx += 2\n\t\tend\n\n\t\treturn primes\n\tend",
"def nth_prime(n)\n primes = []\n x = 2\n while primes.size < n\n primes << x if (2..Math.sqrt(x)).all? {|i| x % i != 0 }\n x += 1\n end\n primes\nend",
"def primes_less_than(n)\n primes = [2,3]\n (5..n).each do |i|\n if i%2 == 1\n primes << i if is_prime?(i, primes)\n end\n end\n primes\n end",
"def problem_77\n primes = Primes.upto(120)\n\n # num is the value we want and\n # off is the index in primes to use next\n hits = 0\n solve = lambda do |num, off|\n return 1 if num == 0\n return 0 if num == 1\n ret = 0\n p = primes[off]\n ret += 1 if num % p == 0 # Add if a multiple\n ret += solve.call(num,off-1) if off > 0 \n n = num / p\n if n > 0 # Do each multiple\n 1.upto(n) do |i|\n left = num - i*p\n ret += solve.call(left,off-1) if off > 0 && left > 1\n end\n end\n ret\n end\n\n #(2..100).each do |num|\n num = 0\n (2..100).each do |num|\n off = primes.index {|i| i > num } - 1\n hits = solve.call(num,off)\n puts \"#{num} => #{hits}\"\n return num if hits >= 5000\n end\nend",
"def compute_primes\n nums = (@max_checked..@max_checked * 2).map { |x| x.odd? ? x : nil }.to_a\n 1.upto(@primes.index { |p| p * p > @max_checked * 2 }) do |i|\n start_idx = -@max_checked % @primes[i] # prime[i]'s 1st multiple's index\n\n (start_idx..nums.size).step(@primes[i]) { |x| nums[x] = nil }\n end\n @max_checked *= 2\n @primes += nums.compact\n end",
"def pe50v2()\n\ta = sieveOfErathosthenes(3990)\n\tprim,total,count = [], 0, 0\n\ta.each_with_index do |x, index|\n\t\tif x \n\t\t\ttotal += index\n\t\t\tcount += 1 \n\t\t\tprim.push([total,count])\n\t\tend\n\tend\n\t#p prim\n\tmax = 0\n\tthePrime = 0\n\tseq = prim.map {|k| k }.permutation(2).to_a.each {|x| x.flatten!}\n\tseq.each do |a, b, c , d| \n\t\t#printf \"%d %d %d %d\\n\", a, b, c, d\n\t\te = a - c\n\t\tif(Prime.prime?(e)) then\n\t\t\tif(max < b - d) then\n\t\t\t\tmax = b - d\n\t\t\t\tthePrime = e\n\t\t\t\tprintf \"prime %d with max %d\\n\",e,max\n\t\t\tend\n\t\tend\n\tend\n\tprintf \"the prime is %d with a seqence of %d\\n\",thePrime, max\nend",
"def primes (n)\r\n primes = Array.new(n) { |index| index+=1 }\r\n return primes.select { |x| factors(x).length == 2 }\r\nend",
"def eratosthenes_sieve(nth_prime)\n top = nth_prime * 10\n # this is really kludgy, you might have to increase 10 if you want\n # nth primes above 10k. It seems to work fine for all numbers under\n # 10k. I need to read up on prime number theory to find out when this fails.\n sieve = []\n (2..top).each { |i| sieve[i] = i }\n for i in 2 .. Math.sqrt(top)\n next unless sieve[i]\n (i*i).step(top, i) do |j|\n sieve[j] = nil\n end\n end\n sieve.compact[nth_prime]\nend",
"def get_primes limit\n\tnums = (1...limit).select { |n| n.prime? }\n\n\tp nums\nend",
"def nth_prime(n)\n\nend",
"def nth_prime(n)\n primes = []\n\tint = 2\n\tuntil primes.length == n\n if int <= 3\n primes << int\n else\n primes << int if (2..Math.sqrt(int)).all? { |x| int % x != 0 }\n end\n if int < 3\n int += 1\n else\n int += 2\n end\n end\n puts \"Prime number #{n} is #{primes.last}\"\nend",
"def primes(num)\n \nend",
"def primes(num)\n \nend",
"def primes(num)\n \nend",
"def primes(num)\n \nend",
"def first_n_primes(n)\n\n \"n must be an integer.\" unless n.is_a? Integer\n\n \"n must be greater than 0.\" if n <= 0\n \n prime_array ||= []\n \n prime = Prime.new\n n.times { prime_array << prime.next }\nend",
"def nthPrime(nth)\n # TODO\nend",
"def first_n_primes(n)\n\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" if n <= 0\n \n prime_array ||= []\n \n prime = Prime.new\n n.times {\n prime_array << prime.next \n }\n prime_array\nend",
"def primes_up_to(max)\n repository = (0..max).collect{true} #=> Create flag array\n limit = (max ** 0.5) #=> establish search limit\n\n for index in 2..limit #=> search through flag aray\n next if !repository[index]\n num = (index * 2)\n while num <= max #=> unflag multiples of primes\n repository[num] = false\n num += index\n end\n end\n\n # => convert numbers into arrays\n primes = repository.collect.with_index do |flag, value|\n value if flag\n end\n\n # return cleaned array\n primes.shift\n primes.shift\n primes.compact\nend",
"def primes(n)\n return (2..n).select {|x| factors(x).size() == 2}\nend",
"def find_primes_magic_value(magic_number)\n @primes = []\n number = 2\n while magic_number > 1\n if magic_number % number == 0\n magic_number /= number\n @primes << number\n end\n number += 1\n end\n\n end",
"def prob_three\n max = 600851475143**0.5\n\n for i in (1..max).step(2)\n if 600851475143 % i == 0\n if is_prime(i)\n ans = i\n end\n end\n end\n ans\nend",
"def get_primes(n)\n primes = [2]\n pp = 0\n i = 3\n while pp < n do\n if i%2 != 0\n counter = 0\n prime = 1\n while counter < primes.length do\n if (i%primes[counter] == 0)\n prime = 0\n break;\n end\n counter += 1\n end\n if prime == 1\n primes.push(i)\n pp +=1\n end\n end\n i+=1\n end\n return primes[n-1]\nend",
"def prime_number_for(nth_element)\n\n #Generate Primes List \n\n \n until primes.length === nth_element do \n\n primes = [2, 3, 5, 7, 11] \n\n divisible_by_num = false\n\n for num in 13..100000 do \n curr_num = num \n curr_divisor = num - 2 \n until curr_divisor == 1 do \n if curr_num % curr_divisor === 0 \n break\n elsif curr_divisor === 3\n primes.push(curr_num)\n end\n curr_divisor -= 2 \n end\n end\n puts primes.length \n end \n\n return primes.pop\n\nend",
"def primes_from_2( x )\n # primes have no factors except for 1 and self\n primes = [ 2 ]\n i = 2\n while primes.size < x\n i += 1\n is_prime = true\n primes.each do |p|\n #( 2..( i ** 0.5 ).floor ).each do |p|\n #break if p > ( i / 2 )\n break if p > ( i ** 0.5 )\n if 0 == ( i % p )\n is_prime = false\n break\n end\n end # p\n primes << i if is_prime\n i += 1 # skip the next integer (it's even)\n end # while\n return primes[ -1 ]\nend",
"def nth_prime(n)\n nums = (0..10000).to_a\n result = []\n\n nums.each do |i| \n if prime?(i) == true\n result.push(i)\n end\n end\n\n\n return result[n]\nend",
"def pick_primes(numbers)\n numbers.select { | n | is_prime(n) }\nend",
"def all_primes(number)\n primes = []\n (2...number).each do |num|\n if prime?(num)\n primes << num \n end\n end\n primes\nend",
"def consecutive_prime_below_one_million\n @max_limit = 1000_000\n generate_prime_numbers()\n # number_of_primes = 0\n result = 0\n\n count_prime_sum = @prime_numbers_sum.length\n number_of_primes = 1\n # i_index = 0\n count_prime_sum.times do |i_index|\n for j in (count_prime_sum - 1).downto(i_index + number_of_primes ) do\n difference = @prime_numbers_sum[j] - @prime_numbers_sum[i_index]\n if (j - i_index > number_of_primes) && difference < @max_limit && ( @prime_numbers.include? difference) #\n number_of_primes, result = j - i_index, difference\n break\n end\n end ## end of j\n end ## end of i\n\n puts '=============================================================================================='\n puts 'Q2: Which prime, below one million, can be written as the sum of the most consecutive primes?'\n puts \"Sol: Result For Finding consecutive prime below #{@max_limit} : #{result}, and \\n Number of primes in those are #{number_of_primes}\"\n puts '=============================================================================================='\n\n end",
"def primes_less_than number\n ps = (2..number).each\n primes_so_far = []\n enum = Enumerator.new do |y|\n loop do\n p = ps.next\n non_prime = false\n\n p_root = (p**0.5).floor\n # Filter for primes using an inverted version of the sieve of\n # Eratosthenes--a number is prime if it's not divisible by the primes\n # less than it's square root.\n primes_so_far.each {|prime|\n if prime > p_root\n # if p has no divisors in primes_so_far less than p^0.5\n # then p must be prime\n break\n elsif p % prime == 0\n # the current p is not prime\n non_prime = true\n break\n end\n }\n\n unless non_prime\n primes_so_far.push p\n y.yield p\n end\n end\n end\n\n enum.to_a\n\nend",
"def prime(nth_prime)\n n = 0\n prime = 1\n primes = []\n while( n < nth_prime )\n prime += 1\n prime_found = true\n # refactor to use a helper\n (2..( prime-1 ) ).each do |num|\n prime_found = false if prime % num == 0\n break unless prime_found\n end\n if prime_found\n primes << prime\n n+=1\n end\n end\n primes.reduce(:+)\nend",
"def primes_upto( xmax )\n # primes have no factors except for 1 and self\n primes = [ 2 ]\n ( 3..xmax ).each do |i|\n puts i if 0 == ( i % 1000 )\n is_prime = true\n primes.each do |p|\n break if p > ( i / 2 )\n if 0 == ( i % p )\n is_prime = false\n break\n end\n end # p\n primes << i if is_prime\n end # i\n return primes\nend",
"def find_prime\n x = 2\n while @prime_numbers.count < @total\n @prime_numbers << x if prime?(x)\n x += 1\n end\n end",
"def primes (n)\n return (1..n).select {| x | factors(x).length == 2}\nend",
"def pretentious_primes(arr, num)\nend",
"def pretentious_primes(arr, ran)\n\n primes = list_of_primes(arr.max, ran )\n # print primes\n\n arr.map do |num|\n i = 0\n primes[0..-2].each_with_index do |p , idx|\n if num == p \n i = idx\n \n elsif (num > p && num < primes[idx + 1]) && ran > 0 \n i = idx\n elsif (num > p && num < primes[idx + 1]) && ran < 0 \n i = idx + 1\n \n end\n end\n # p i\n # p ran\n if (i + ran) < 0\n \n nil\n else\n primes[i + ran]\n end\n\n end\n \nend",
"def largest_prime(n) #600851475143\r\n p = 0\r\n i = 5\r\n nums = []\r\n while i*i < n\r\n if n % i == 0\r\n nums << i\r\n end\r\n\r\n i += 1\r\n end\r\n\r\n nums.reverse_each do |num|\r\n if prime?(num)\r\n return num\r\n end\r\n end\r\n\r\nend",
"def primes_up_to(n)\n raise \"Need an integer >= 2 to find primes\" unless n.is_a?(Integer) && n >= 2\n primes = (0..n).to_a\n primes[0..1] = [nil, nil]\n p = 2\n while true do\n (p .. n/p).each do |i|\n primes[i*p] = nil\n end\n break unless p = primes.index { |x| !x.nil? && x > p }\n end\n primes.compact!\n end",
"def prime_number_for(nth_element)\n number = 15485863\n return \"Cannot calculate that prime number.\" if nth_element <= 0 || nth_element > 1000000\n primes = eratosthenes(number)\n\n return primes[nth_element - 1]\n\nend",
"def specific_prime(n)\n\na = (2..n) # list of integers 2 through \nprimes = Array.new\n\nprimes = a.select { |x| (2..Math.sqrt(x)).none? { |d| (x % d).zero? }}\n\nputs primes[10000]\n# answer => 104,743\n\nend",
"def find_primes_under(num)\n\tprimes = [2]\n\tcounter = 3\n\twhile primes[-1] < num\n\t\tcounter2 = 2\n\t\twhile counter2 <= counter\n\t\t\tif counter % counter2 == 0\n\t\t\t\tbreak\n\t\t\telsif\n\t\t\t\tcounter2 * counter2 > counter\n\t\t\t\tprimes << counter\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tcounter2 += 1\n\t\tend\n\tcounter += 1\n\tend\n\tprimes[0..-2]\nend",
"def primes()\n return [] if @number < 2\n # build Boolean array to use for sieve with buffer to align indices\n sieve_array = Array.new(2, false) + Array.new(@number-1, true)\n # perform Sieve of Eratosthenes eliminations\n (2..Math.sqrt(@number).to_i).each do |i|\n (i**2..@number).step(i) {|j| sieve_array[j] = false} if sieve_array[i] == true\n end\n # return numbers by corresponding index that are still true\n (2..@number).collect {|index| index if sieve_array[index] == true}.compact\n end",
"def get_primes(limit)\n primes = []\n (2...limit).each do |number|\n primes << number if is_prime?(number)\n end\n primes\nend",
"def add_primes_upto(max)\n primes = [2, 3]\n primes_index = 1\n sum = 2 + 3\n\n 5.step(max, 2).each do|current_number|\n val_is_prime = true\n primes.each do|prime|\n if prime > Math.sqrt(current_number).to_i\n break\n elsif current_number % prime == 0 then\n val_is_prime = false\n break\n end\n end\n if val_is_prime && current_number < max then\n primes_index = primes_index + 1\n primes[primes_index] = current_number\n sum = sum + current_number\n end\n end\n return sum\nend",
"def first_n_primes(n)\n\n #unless n.is_a? Integer\n # return \"n must be an integer.\"\n #end\n return \"n must be an integer.\" unless n.is_a? Integer\n\n #if n <= 0\n # return \"n must be greater than 0.\"\n #end\n return \"n must be greater than 0.\" if n <= 0\n \n #prime_array = [] if prime_array.nil?\n prime_array ||= []\n \n prime = Prime.new\n #for num in (1..n)\n # prime_array.push(prime.next)\n #end\n # n.times { prime_array.push(prime.next) }\n n.times { prime_array << prime.next }\n \n #return prime_array\n prime_array # implicit return!\n\nend",
"def primes (n)\n return (1..n).select { |x| x.prime? }\nend",
"def pick_primes(numbers)\n numbers.select { |num| prime?(num) }\nend",
"def main(nth)\n arr = Array.new\n arr.push(2)\n arr.push(3)\n counter = 4\n\n while arr.size < nth do\n if counter%2 != 0 and counter%3 != 0\n temp = 4\n while temp*temp <= counter do\n if counter % temp == 0\n break\n end\n temp += 1\n end\n\n if temp*temp > counter\n puts 'Found ' + counter.to_s + 'th Prime = ' + counter.to_s\n arr.push(counter)\n end\n\n end\n counter += 1\n\n end\n puts arr[-1].to_s\nend",
"def get_n_primes(n)\n return [] if n < 1\n primes = [2]\n candidate = 3\n\n while primes.length < n\n is_prime = true # default assume the number is prime\n primes.each do |prime|\n if candidate % prime == 0\n is_prime = false\n break\n end\n\n break if prime >= Math.sqrt(candidate)\n end\n\n primes << candidate if is_prime\n candidate += 2\n end\n\n primes\nend",
"def prime_factor\n max = 600851475143**0.5\n\n for i in (1..max).step(2)\n if 600851475143 % i == 0\n if is_prime(i)\n ans = i\n end\n end\n end\n ans\nend",
"def primes_to_n(n)\n (2..n).select { |num| is_prime?(num) }\nend",
"def primes_up_to(top)\n s = (0..top).to_a\n s[0] = s[1] = nil\n s.each do |p|\n next unless p\n break if p * p > top\n (p*p).step(top,p){ |i| s[i] = nil}\n end\n s.compact\nend",
"def problem(nth = 6,i = 13)\n while nth < 10001\n i += 2\n nth += 1 if i.prime?\n end\n i\n end",
"def NthPrime(nth)\n first_nth_primes(nth).last\n end",
"def sieve(nth_prime)\n primes = [2]\n num = 2\n while primes.length <= nth_prime do\n primes << num if !primes.any? {|prime| num % prime == 0}\n num +=1\n end\n return primes[primes.length-2] # -2 because we don't put 1 (because every number is divisble by 1) and index is from 0 to x thus -2\nend",
"def nth_prime(nth)\n (1...Float::INFINITY).lazy.select(&:prime?).drop(nth-1).first\nend",
"def next_prime\n if !@primes.include?(FIRST_PRIME)\n @primes << FIRST_PRIME\n return FIRST_PRIME\n end\n\n # if not met the sieve only contains prime numbers\n # so we do not need to filter any further\n if @p < Math.sqrt(@max)\n # remove any multiples of p from the sieve\n @sieve = @sieve.select {|n| n % @p != 0 }\n end\n # increment p to the next value in the sieve\n @p = @sieve.shift\n @primes << @p\n return @p\n end",
"def pick_primes(numbers)\n return numbers.select { |num| prime?(num)}\nend",
"def prime_numbers\n # start with the first prime number\n primes = [2]\n # find the rest of the prime numbers\n (2..1000).each do |i|\n add_next_prime_number(primes)\n end\n return primes\nend",
"def pick_primes(numbers)\r\n return numbers.select { |num| prime?(num)}\r\nend",
"def primes(n)\n result = []\n i = 2\n while i <= n\n j=2\n prime = true\n while j<=i**0.5\n (prime = false) if i%j==0\n j += 1\n end\n (result << i) if prime\n i +=1\n end\n return result\nend",
"def next_prime(primes)\n\tlast_prime = primes.last\n\ttest = last_prime\n\tfound = false\n\twhile !found\n\t\ttest = test + 2\n\t\tmax = Math.sqrt(test).div(1)\n\n\t\tfor fact in primes do\n\t\t\tif test % fact == 0\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tif fact > max\n\t\t\t\tfound = true\n\t\t\tend\n\t\tend\n\tend\n\tprimes.push(test)\nend",
"def nth_Prime(num)\n\tprime_array = [2]\n\ti = 3\n\n\twhile prime_array.length < num\n\t\ti += 2\n\t\tif (i % 2 == 0)\n\t\t\tnext_num\n\t\tend\n\n\t\tprime = true\n\t\tprime_array.each do |j|\n\t\t\tif (i % j == 0)\n\t\t\t\tprime = false\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\n\t\tif prime\n\t\t\tprime_array << i\n\t\tend\n\tend\n\tprime_array.last\nend",
"def get_primes num\n primes = []\n for i in 0 ... num do\n if check_prime?(i) == true\n primes.push(i)\n end\n end\n p primes\nend",
"def get_nth_prime(n)\n\t\tunless n > 0 \n\t\t\traise 'Expected a positive integer'\n\t\tend\n\n\t\treturn @primes[n - 1] if @primes[n - 1]\n\t\t \n\t\t# Only check the odd numbers\n\t\ttemp = @primes.last + 2\n\t\t \n\t\twhile @primes.size < n\n\t\t\t@primes.push temp if is_prime?(temp)\n\t\t\ttemp += 2\n\t\t end\n\t\t\n\t\treturn @primes.last\n\tend",
"def p10\n\tprimes = []\n\tPrime.each do |prime|\n\t\tbreak if prime >= 2000000\n\t\tprimes << prime\n\tend\n\t# puts primes\n\tprimes.reduce(:+)\nend",
"def primes\n Enumerator.new do |y|\n result = 0\n n = 3\n loop do\n candidates = (0..n).to_a\n candidates[0] = candidates[1] = nil\n candidates.each do |c|\n next unless c\n break if c * c > n\n (c*c).step(n, c){|m| candidates[m] = nil}\n end\n candidates.compact!\n if candidates[-1] != result\n y.yield candidates[-1]\n result = candidates[-1]\n end\n n+=1\n end\n end\nend",
"def sieve_of_erastothenes3(n)\n primes = (0..n).to_a\n\n (2..n).each do |number|\n if primes[number]\n multiples(number, n).each do |multiple|\n primes[multiple] = nil\n end\n end\n end\n\n primes.compact.select { |num| num > 1 }\nend",
"def count_primes(number)\n # create an array from 2-num\n # for each number in the array of possible primes\n # modulo the number by each n\n # if the number % n is 0, it's not a prime number\n # unless the number and n are the same\n possible_primes = (2...number).to_a\n possible_primes.select! do |num|\n # need to return true if num is prime, false if it is not\n # binding.pry if num == 3\n half_num = num\n results = (2...half_num).select do |n|\n # if num % n == 0, means that n evenly divides into num making it not prime\n num % n == 0\n end\n results.empty?\n # any number within results evenly divided into the num\n # making the num not prime\n # so if results is empty, it means that nothing divided into the num\n # making the num prime\n end\n possible_primes.count\nend",
"def primes_up_to(num)\n\n\tcross_limit = Math.sqrt(num).floor\n\n\t# create a new array with num number of elements, each set as true\n\tprime_bools = Array.new(num, true)\n\n\tprime_bools.each_with_index do |is_prime, i|\n\t\t# we can stop once our steps are at the square root of the limit\n\t\tbreak if i >= cross_limit\n\n\t\t# skip first step (0+0+1 steps over everything) and\n\t\t# non-prime steps, as they're redundant\n\t\tnext if i == 0 || !is_prime\n\n\t\t# set each bool we step over to false, starting at i+i+1, which\n\t\t# ensures we keep the first primes true \n\t\t(i+i+1 .. num).step(i+1) { |i| prime_bools[i] = false }\n\t\t# puts \"removed #{i+1}s #{prime_bools.each_index.select { |i| prime_bools[i] }.map { |j| j+1 }.drop(1)}\"\n\tend\n\n\t# select all the remaining trues from prime_bools\n\tprime_bools = prime_bools.each_index.select { |i| prime_bools[i] }\n\n\t# map the prime_bools to their index/number and drop the 1 (not a prime)\n\tprimes = prime_bools.map { |i| i+1 }.drop(1)\n\nend",
"def primes\n return [] if self == 0\n return \"don't do that\" if self < 0\n list = [2]\n test = 3\n until list.length == self\n list << test if test.is_prime?\n test += 2\n end\n list\n end",
"def sieve(n)\n primes = nil\n\n OpenTracing.global_tracer.start_active_span(\"sieve\") do |scope|\n # don't really want the first two, but matching index to value makes it easier\n primes = [*0..n]\n primes[0] = nil\n primes[1] = nil\n\n for x in primes do\n next if x.nil? # already marked as composite, skip to the next one\n\n # find all the composites from this number and make them nil\n (2*x..n).step(x) do |c|\n primes[c] = nil\n end\n end\n\n # remove the nils from the array\n primes = primes.compact\n\n # tag the number of primes found\n scope.span.set_tag(\"primes.count\", primes.count)\n end\n\n primes\nend",
"def t_primes()\n t_primes = []\n 10.step do |i| # Skip all one-digit numbers.\n next unless i.prime?\n digits = i.to_s.chars\n cp_digits = digits.dup # Copy the digits as we will operate on\n # this array twice.\n lftrt = rtlft = digits.length\n # A number is a left-truncatable prime if all its leading digits\n # (that is, the digit in the most significant place), when succ-\n # essively removed, all resulting numbers are prime.\n lftrt.times do\n cp_digits.shift\n break unless cp_digits.join.to_i.prime?\n end\n # If cp_digits still has elements in it, that means those elements\n # weren't prime themselves.\n next unless cp_digits.length.zero?\n cp_digits = digits.dup\n rtlft.times do\n cp_digits.pop\n break unless cp_digits.join.to_i.prime?\n end\n next unless cp_digits.length.zero?\n t_primes << i # Found a two-sided truncatable prime!\n break if t_primes.size == 11\n end\n return t_primes\nend",
"def solution_3(num)\n starting_time = Time.now\n\n # actual sieve of eratosthenes\n potential_primes = (2..num).to_a\n potential_primes.each_with_index do |val, index|\n if val\n index += val\n while index < num\n potential_primes[index] = nil\n index += val\n end\n else\n next\n end\n end\n\n primes = potential_primes.compact\n\n p \"Sum of first #{num} primes: #{primes.reduce(:+)}\"\n\n p \"In #{Time.now - starting_time} seconds\"\nend",
"def get_primes\n j = 0\n\n while j < @limit \n prime_number = is_prime\n if prime_number\n @prime_numbers.push(prime_number)\n j += 1\n end\n @count += 1\n end\n\n return @prime_numbers\n end",
"def primes\n range = (min..max).to_a\n primes = (min..max).to_a\n\n range.each do |mod|\n primes.delete_if do |num| \n composite?(num, mod) unless num == mod\n end\n range = primes\n end\n primes\n end",
"def pick_primes(numbers)\n\tprimes = []\n \tnumbers.each do |num| \n \tif isPrime(num) \n \tprimes.push(num)\n end\n end\n \treturn primes\nend",
"def nextPrime(last_prime)\n i = 2\n last_prime = last_prime + 1\n too_far = last_prime * last_prime\n #we'll continue our search for too_far times //rewrite this later\n #too_far.times do |z|\n loop do #iterate until you find a prime\n loop do #check last_prime for primehood\n if last_prime == i\n return last_prime\n end\n break if last_prime % i == 0\n i = i + 1\n end\n i = 2\n last_prime = last_prime + 1\n end\nend",
"def collect_primes(number)\n \n sieve = [nil, nil] + (2 .. number).to_a\n \n (2 .. Math.sqrt(number)).each do |n|\n next unless sieve[n]\n (n*n).step(number, n) do |num|\n sieve[num] = nil\n end\n end\n \n primes = []\n sieve.each do |x|\n if x != nil\n primes << x\n end\n end\n return primes\nend",
"def is_prime(n) \n return false if n == 1\n return true if n < 4\n return false if (n % 2) == 0 \n return true if n < 9 \n return false if (n % 3) == 0 \n r = Math.sqrt(n).floor \n f = 5\n while (f <= r)\n return false if (n % f) == 0 \n return false if (n % (f + 2)) == 0\n f = f + 6\n end\n return true\nend",
"def first_n_primes(n)\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" if n <= 0\n Prime.first n\nend",
"def first_n_primes(n)\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" if n <= 0\n Prime.first n\nend",
"def calculate(number)\n sieve_limit = upper_limit_for(number)\n primes = sieve_upto sieve_limit\n primes[0..number-1]\n end",
"def prime_list(number_of_primes)\n return [] if number_of_primes < 1\n prime_numbers = Array.new\n for num in 2..9999999 do\n if is_prime_num(num, prime_numbers)\n prime_numbers.push(num)\n break if prime_numbers.length == number_of_primes\n end\n end\n return prime_numbers\n end",
"def prime(max)\n (1..max).select { |x| (1..max).count { |y| x % y == 0 } == 2 }\nend",
"def first_n_primes(n)\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" if n <= 0\n return Prime.first n\nend",
"def prime(n)\n return 2 if n == 1\n return 3 if n == 2\n primes = [2,3]\n (3..n).each do \n last = primes.last\n a = last + 2\n prime = false\n while prime == false\n prime = true\n primes.each do |p|\n if a % p == 0\n a = a + 1\n prime = false\n break\n end\n end\n end\n primes << a\n end\n primes.last\n end",
"def isPrime?(num)\n if ((num == 2) || (num == 5))\n return true\n end\n if (num % 2) == 0\n return false\n end\n if (num % 5) == 0\n return false\n end\n x = Math.sqrt(num)+1\n for i in 2...x\n if((num % i) == 0)\n return false\n end\n end\nend",
"def get_consecutive_prime_below_one_million(primes)\n sumation = 0;\n prime_number_list = []\n number_of_primes = 0 \n primes.each_with_index do | prime_number , i |\n # puts \"#{prime_number} - #{i}\"\n @sum = @sum + prime_number\n @primeSum[i+1] = @sum if @sum < @limit;\n end\n # puts \"#{@primeSum}\"\n\n count_of_primeSum = @primeSum.length\n number_of_primes = 1 \n count_of_primeSum.times do |i|\n for j in (count_of_primeSum - 1).downto(i + number_of_primes ) do\n difference = @primeSum[j] - @primeSum[i]\n\n if (j-i > number_of_primes) && (difference < limit) && ( primes.include? difference)\n # puts \"#{i}--#{j}\"\n \n prime_number_list = primes[i...j]\n number_of_primes = j-i\n sumation = difference \n end\n end\n end\n @result[:sumation] = sumation \n @result[:number_of_terms] = number_of_primes \n @result[:prime_number_list] = prime_number_list \n\n @result\n end",
"def first_n_primes(n)\n return \"n must be an integer.\" unless n.is_a? Integer\n return \"n must be greater than 0.\" unless n > 0\n return Prime.first n\nend",
"def nth_prime(n)\n return Primes.primes(n)[-1]\nend",
"def smallest_number()\r\n\tprime_numbers = [19,17,13,11,7,5,3,2] # primes numbers from 0-20.\r\n\tproduct_prime = prime_numbers.reduce(:*)\r\n\tnumber = product_prime\r\n\twhile (1)\r\n\t\treturn number if divisible_1to20?(number)\r\n\t\tnumber += product_prime\r\n\tend\r\nend",
"def next_prime primes\n infinity = 1.0/0\n start = primes[-1]+1\n\n (start..infinity).each do |candidate|\n if primes.any? {|prime| candidate % prime == 0}\n # is not prime, skip\n else\n return candidate\n end\n end\nend"
] |
[
"0.73485553",
"0.72513944",
"0.71873426",
"0.7142738",
"0.7114723",
"0.7069628",
"0.70629925",
"0.7061988",
"0.7056047",
"0.7028984",
"0.69411755",
"0.6935662",
"0.6907952",
"0.6894265",
"0.6890295",
"0.6888991",
"0.6885496",
"0.688398",
"0.68823606",
"0.6879862",
"0.6879862",
"0.6879862",
"0.6879862",
"0.68747914",
"0.6868964",
"0.68675077",
"0.6863844",
"0.6853261",
"0.6851438",
"0.6809852",
"0.67892426",
"0.67858195",
"0.67810196",
"0.67753494",
"0.6755799",
"0.675028",
"0.6745907",
"0.67275494",
"0.6726822",
"0.6722023",
"0.6717288",
"0.67136854",
"0.6706897",
"0.67058194",
"0.6705721",
"0.6704253",
"0.6703118",
"0.6701966",
"0.6697299",
"0.6685429",
"0.6674352",
"0.6667649",
"0.66611093",
"0.6657337",
"0.66568345",
"0.6653589",
"0.6638224",
"0.66310525",
"0.6608326",
"0.65983254",
"0.65974474",
"0.6595596",
"0.65818393",
"0.6579844",
"0.65760815",
"0.6571041",
"0.65705866",
"0.6568317",
"0.6566898",
"0.65654826",
"0.65596604",
"0.6558905",
"0.6556827",
"0.6551022",
"0.65457183",
"0.6541891",
"0.65399",
"0.65395856",
"0.6529346",
"0.6525406",
"0.65210104",
"0.651824",
"0.65171003",
"0.6516814",
"0.651377",
"0.65105563",
"0.6505669",
"0.65045553",
"0.6503234",
"0.6503234",
"0.6500803",
"0.6489123",
"0.64877087",
"0.64803",
"0.64790726",
"0.6478277",
"0.6477268",
"0.6477022",
"0.64743716",
"0.6471885",
"0.646538"
] |
0.0
|
-1
|
Cookbook Name:: tomcat Resource:: keystore.rb Copyright IBM Corp. 2017, 2018
|
def run_cmd(cmd)
Mixlib::ShellOut.new(cmd).run_command.exitstatus == 0
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def keycerts; end",
"def keycert_files; end",
"def update_key_cert\n converge_by(\"Update #{new_resource} cert key method\") do\n\t kid = new_resource.keyid\n\t cid = new_resource.certid\n caid = new_resource.cacertid if !new_resource.cacertid.nil?\n\t todel='-alt'\n\t if @current_resource.exists\n\t if !load_balancer.client['LocalLB.ProfileClientSSL'].get_key_file([\"/Common/#{new_resource.sslprofile_name}\"])[0].value.include?(\"#{new_resource.sslprofile_name}-alt\")\n\t\tkid = new_resource.sslprofile_name+'-alt.key'\n\t\tcid = new_resource.sslprofile_name+'-alt.crt'\n\t\tcaid = new_resource.sslprofile_name+'-alt.crt' if !new_resource.cacertid.nil?\n\t\ttodel = ''\n\t end\n\t end\n Chef::Log.info \"Update #{new_resource} cert key method with PASSPHRASE #{new_resource.passphrase}\"\n load_balancer.client['LocalLB.ProfileClientSSL'].set_key_certificate_file([new_resource.sslprofile_name], [{\"value\" => \"/Common/#{kid}\", \"default_flag\" => \"false\"}] , [{\"value\" => \"/Common/#{cid}\", \"default_flag\" => \"false\"}])\n load_balancer.client['LocalLB.ProfileClientSSL'].set_passphrase([\"/Common/#{new_resource.sslprofile_name}\"], [{\"value\" => \"#{new_resource.passphrase}\", \"default_flag\" => \"false\" }]) if !new_resource.passphrase.nil?\n load_balancer.client['LocalLB.ProfileClientSSL'].set_chain_file_v2([\"/Common/#{new_resource.sslprofile_name}\"], [{\"value\" => \"/Common/#{caid}\", \"default_flag\" => \"false\" }]) if !new_resource.cacertid.nil?\n\t \n\t ssl_d = load_balancer.ltm.ssls(\"MANAGEMENT_MODE_DEFAULT\").find { |p| p =~ /(^|\\/)#{new_resource.sslprofile_name}#{todel}$/ } \n\t if !ssl_d.nil?\n\t \tload_balancer.client['Management.KeyCertificate'].key_delete(\"MANAGEMENT_MODE_DEFAULT\", [\"/Common/#{new_resource.sslprofile_name}#{todel}\"])\n\t \tload_balancer.client['Management.KeyCertificate'].certificate_delete(\"MANAGEMENT_MODE_DEFAULT\", [\"/Common/#{new_resource.sslprofile_name}#{todel}\"])\n\t end\n current_resource.keyid(new_resource.keyid)\n current_resource.certid(new_resource.certid)\n current_resource.passphrase(new_resource.passphrase)\n current_resource.cacertid(new_resource.cacertid)\n\n new_resource.updated_by_last_action(true)\n end\n end",
"def set_keystore\n @keystore = Keystore.find(params[:id])\n end",
"def set_keystore\n @keystore = Keystore.find(params[:id])\n end",
"def setup_ssl_get_props\n ssl_props = {}\n attrs = node.workorder.rfcCi.ciAttributes\n\n if attrs.version.eql?('0.8.2.1')\n ssl_props['advertised.host.name'] = get_full_hostname(node[:hostname])\n else\n #ssl feature is available only for kafka version 9+\n # checking whether ssl is enabled. check secgroup_inbound_rules to decide if plaintext and/or ssl is enabled. 9092 port is for plaintext and 9093 is for ssl\n sslEnabled = attrs.enable_ssl.eql?('true')\n plainTextEnabled = attrs.disable_plaintext.eql?('false')\n saslPlainEnabled = attrs.enable_sasl_plain.eql?('true')\n hostname = `hostname -f`\n hostname.gsub!(\"\\n\", \"\")\n\n if sslEnabled\n keystore = node.workorder.payLoad.DependsOn.select { |d| d[:ciClassName] == \"bom.oneops.1.Keystore\" }\n if keystore.nil? || keystore.size==0\n Chef::Log.error(\"Keystore component is missing.\")\n exit 1\n end\n Chef::Log.info('keystore' + keystore.to_s)\n cert = node.workorder.payLoad.DependsOn.select { |d| d[:ciClassName] == \"bom.oneops.1.Certificate\" }\n if cert.nil? || cert.size==0\n Chef::Log.error(\"Certificate component is missing.\")\n exit 1\n end\n Chef::Log.info('cert' + cert.to_s)\n passphrase = cert.first[:ciAttributes].passphrase\n keystore_file = keystore.first[:ciAttributes].keystore_filename\n keystore_password = keystore.first[:ciAttributes].keystore_password\n ca_cert_file = '/tmp/kafka-ca-cert'\n truststore_file = File.dirname(keystore_file)+'/kafka.server.truststore.jks'\n truststore_password = attrs.truststore_password\n if truststore_password.to_s.empty?\n truststorepasswdmissing = \"Truststore password is missing.\"\n Chef::Log.error(\"#{truststorepasswdmissing}\")\n puts \"***FAULT:FATAL=#{truststorepasswdmissing}\"\n Chef::Application.fatal!(truststorepasswdmissing)\n end\n File.open(ca_cert_file, 'w') { |file| file.write(cert.first[:ciAttributes].cacertkey) }\n # import CA certificate to the truststore\n `keytool -keystore #{truststore_file} -alias CARoot -import -file #{ca_cert_file} -storepass #{truststore_password} -noprompt`\n #setup SSL properties for kafka\n ssl_props['ssl.keystore.location'] = keystore_file\n ssl_props['ssl.key.password'] = passphrase\n ssl_props['ssl.keystore.password'] = keystore_password\n ssl_props['ssl.truststore.password'] = truststore_password\n ssl_props['ssl.truststore.location'] = truststore_file\n\n if attrs.enable_client_auth.eql?('true') && (attrs.client_certs.nil? || attrs.client_certs.size == 0)\n clientcertsmissing = \"Client cert locations are missing when client authentication is enabled.\"\n Chef::Log.error(\"#{clientcertsmissing}\")\n puts \"***FAULT:FATAL=#{clientcertsmissing}\"\n Chef::Application.fatal!(clientcertsmissing)\n end \n \n if attrs.has_key?(\"client_certs\") && !attrs.client_certs.nil? && attrs.client_certs.size > 0\n ssl_props['client.security.protocol'] = \"SSL\"\n JSON.parse(attrs.client_certs).each do |key| \n tname = key.split(\"/\").last\n `keytool -keystore #{truststore_file} -alias #{tname} -import -file #{key} -storepass #{truststore_password} -noprompt`\n end\n ssl_props['client.ssl.truststore.location']= truststore_file\n ssl_props['client.ssl.truststore.password'] = truststore_password\n end\n\n ssl_props['advertised.listeners'] = ssl_props['listeners'] = plainTextEnabled ? \"PLAINTEXT://\"+ hostname +\":9092,SSL://\"+ hostname +\":9093\" : \"SSL://\"+ hostname +\":9093\"\n \n ssl_props['ssl.client.auth'] = 'required' if attrs.enable_client_auth.eql?('true')\n \n ssl_props['security.inter.broker.protocol'] = 'SSL' if attrs.disable_plaintext.eql?('true')\n ssl_props['authorizer.class.name'] = 'kafka.security.auth.SimpleAclAuthorizer' if attrs.enable_acl.eql?('true') and attrs.enable_client_auth.eql?('true')\n\n ssl_props['super.users'] = attrs.acl_super_user if attrs.enable_acl.eql?('true') and attrs.enable_client_auth.eql?('true')\n Chef::Log.info('Enabled SSL')\n elsif saslPlainEnabled\n ssl_props['advertised.listeners'] = ssl_props['listeners'] = \"SASL_PLAINTEXT://\"+ hostname +\":9092\"\n elsif plainTextEnabled\n\n ssl_props['advertised.listeners'] = ssl_props['listeners'] = \"PLAINTEXT://:9092\"\n \n if JSON.parse(attrs[\"kafka_properties\"])[\"listeners\"].to_s == \"host\"\n ssl_props['listeners'] = \"PLAINTEXT://\"+ hostname +\":9092\"\n end\n\n if JSON.parse(attrs[\"kafka_properties\"])[\"advertised.listeners\"].to_s == \"host\"\n ssl_props['advertised.listeners'] = \"PLAINTEXT://\"+ hostname +\":9092\"\n end\n\n \n else\n Chef::Log.error(\"For plaintext messaging include Port 9092 in secgroup. For SSL include port 9093 in secgroup.\")\n exit 1\n end\n end\n return ssl_props\nend",
"def cert_store; end",
"def cert_store; end",
"def add_keycert(keycert_file); end",
"def stashHostSSLCertSecret\n cert, key = @server.deploy.nodeSSLCerts(@server)\n certdata = {\n \"data\" => {\n \"node.crt\" => cert.to_pem.chomp!.gsub(/\\n/, \"\\\\n\"),\n \"node.key\" => key.to_pem.chomp!.gsub(/\\n/, \"\\\\n\")\n }\n }\n saveSecret(item: \"ssl_cert\", data: certdata, permissions: true)\n\n saveSecret(item: \"secrets\", data: @config['secrets'], permissions: true) if !@config['secrets'].nil?\n certdata\n end",
"def stashHostSSLCertSecret\n cert, key = @server.deploy.nodeSSLCerts(@server)\n certdata = {\n \"data\" => {\n \"node.crt\" => cert.to_pem.chomp!.gsub(/\\n/, \"\\\\n\"),\n \"node.key\" => key.to_pem.chomp!.gsub(/\\n/, \"\\\\n\")\n }\n }\n saveSecret(item: \"ssl_cert\", data: certdata, permissions: nil)\n\n saveSecret(item: \"secrets\", data: @config['secrets'], permissions: nil) if !@config['secrets'].nil?\n certdata\n end",
"def add_key_store(doc)\n @logger.debug('sso - in add_key_store')\n ks = REXML::Element.new('keyStore', doc.root)\n ks.add_attribute('id', 'ssoKeyStore')\n ks.add_attribute('password', 'changeit')\n ks.add_attribute('type', 'jks')\n ks.add_attribute('location', '${java.home}/lib/security/cacerts')\n end",
"def update_key_store(doc, keystore)\n @logger.debug('sso - in update_key_store updating keyStore attribute')\n Utils.find_and_update_attribute(keystore, 'password', 'changeit')\n Utils.find_and_update_attribute(keystore, 'type', 'jks')\n Utils.find_and_update_attribute(keysotre, 'location', '${java.home}/lib/security/cacerts')\n end",
"def cert_path; end",
"def cert_path; end",
"def verify_key\n Chef::Log.info('Check for RSA key and download key ')\n\n if ::File.exist?('/opt/IBM/SCM_id_rsa')\n Chef::Log.info('Key already exist..........')\n else\n Chef::Log.info('Downloading the key.........')\n # copy the ssh key for TSCM to /opt/IBM/\n cookbook_file node['tscm']['key'].to_s do\n source node['tscm']['key_name'].to_s\n owner 'root'\n mode '400'\n action :create_if_missing\n end\n Chef::Log.info('Finished downloading RSA key...............')\n end\nend",
"def cert; end",
"def cert; end",
"def cert; end",
"def authorizable_keystore(intermediate_path, authorizable_id)\n RubyAem::Resources::AuthorizableKeystore.new(@client, intermediate_path, authorizable_id)\n end",
"def env_key; end",
"def dir\n @keystore\n end",
"def key_files; end",
"def keyfile_arg\n return '' unless ENV['BEAKER_KEYFILE']\n \"--keyfile=#{ENV['BEAKER_KEYFILE']}\"\nend",
"def set_key_entry(aliaz, key, certificate_chain, password = nil)\n\n end",
"def use_bundled_cert!; end",
"def ca_key()\n\t\tENV['CA_KEY'] || nil # The CA private key File\n end",
"def cert_path=(_arg0); end",
"def initialize(verbose = true)\n @verbose = verbose\n \n @cert_kc_name = \"SystemCACertificates.keychain\"\n @cert_kc_path = File.join(CertTools.output_keychain_path, @cert_kc_name)\n end",
"def letsencrypt\n render plain: ENV[\"LETS_ENCRYPT_KEY\"]\n end",
"def ssl\n if @options[\"ssl-gen-self-signed-certs\"]\n puts \"Generating private key and certificate\"\n args = [\n \"-C\", HOSTNAME,\n \"-n\", HOSTNAME,\n \"-o\", @options[\"ssl-organization\"],\n \"-u\", @options[\"ssl-organization-unit\"],\n \"-e\", @options[\"ssl-email\"],\n \"-c\", @options[\"ssl-country\"],\n \"-l\", @options[\"ssl-city\"],\n \"-s\", @options[\"ssl-state\"]\n ]\n Runner.exec(\"gensslcert\", args)\n end\n\n handle_own_certs @options[\"ssl-certs-dir\"].chomp \\\n unless @options[\"ssl-certs-dir\"].chomp.empty?\n\n key_file = \"/etc/apache2/ssl.key/#{HOSTNAME}-ca.key\"\n crt_file = \"/etc/apache2/ssl.crt/#{HOSTNAME}-ca.crt\"\n portus_key = \"/srv/Portus/config/server.key\"\n\n missing_file(key_file) unless File.exist?(key_file)\n missing_file(crt_file) unless File.exist?(crt_file)\n\n # Move key to portus dir, set permissions and create symlink\n # bsc#1022811\n FileUtils.cp(\n key_file,\n portus_key\n )\n FileUtils.chown(\"wwwrun\", \"www\", portus_key)\n FileUtils.chmod(0o440, portus_key)\n FileUtils.rm(key_file)\n FileUtils.ln_s(\n portus_key,\n key_file\n )\n\n FileUtils.cp(\n crt_file,\n \"/srv/www/htdocs\"\n )\n FileUtils.chmod(0o755, \"/srv/www/htdocs/#{HOSTNAME}-ca.crt\")\n FileUtils.cp(\n crt_file,\n \"/etc/pki/trust/anchors\"\n )\n Runner.exec(\"update-ca-certificates\")\n end",
"def certificate_chain(private_key_alias, keystore_intermediate_path, keystore_authorizable_id)\n RubyAem::Resources::CertificateChain.new(@client, private_key_alias, keystore_intermediate_path, keystore_authorizable_id)\n end",
"def default_ssl_cert_store; end",
"def initialize(verbose = true)\n @verbose = verbose\n \n @root_cert_file_name = \"SystemRootCertificates.keychain\"\n @root_cert_kc_path = File.join(CertTools.output_keychain_path, @root_cert_file_name)\n\n @settings_file_name = \"SystemTrustSettings.plist\"\n @setting_file_path = File.join(CertTools.output_keychain_path, @settings_file_name)\n\n @temp_kc_name = \"SystemTempCertificates.keychain\"\n @temp_kc_path = File.join(CertTools.build_dir, @temp_kc_name)\n\n end",
"def ca_cert\n \n end",
"def ssl_client_key\n super\n end",
"def ssl_key\n self.config.ssl_key\n end",
"def create\n authorizable_keystore = client(resource).authorizable_keystore(resource[:intermediate_path], resource[:authorizable_id])\n result = authorizable_keystore.create(resource[:password])\n\n handle(result)\n end",
"def keystore_params\n params.require(:keystore).permit(:obj_type, :obj_id, :key, :value)\n end",
"def ca_file; end",
"def ca_file; end",
"def generate\n Puppet.info \"Creating a new SSL key for #{name}\"\n @content = OpenSSL::PKey::RSA.new(Puppet[:keylength].to_i)\n end",
"def configure_args\n %W[\n --prefix=#{prefix}\n --openssldir=#{openssldir}\n --libdir=lib\n no-threads\n shared\n zlib\n -g\n enable-ssl3\n enable-ssl3-method\n ]\n end",
"def secure_ssl=(_arg0); end",
"def certificate; end",
"def certificate; end",
"def certs_dir\n Pathname.new File.expand_path('../../tmp/certs', __FILE__)\nend",
"def local_client_key_path\n \"#{ssl_certs_dir}/client.key\"\n end",
"def secret_key_base=(_arg0); end",
"def secret_key_base=(_arg0); end",
"def update_sslcert # rubocop:disable AbcSize, MethodLength\n converge_by(\"Update Key/Cert #{new_resource}\") do\n Chef::Log.info \"Update #{new_resource}\"\n\n if new_resource.cert\n pem_crt = load_file_contents(new_resource.cert)\n load_balancer.client['Management.KeyCertificate'].certificate_import_from_pem(\n new_resource.mode,\n [new_resource.sslcert_name],\n [pem_crt],\n new_resource.override\n )\n end\n\n if new_resource.key\n pem_key = load_file_contents(new_resource.key)\n load_balancer.client['Management.KeyCertificate'].key_import_from_pem(\n new_resource.mode,\n [new_resource.sslcert_name],\n [pem_key],\n new_resource.override\n )\n end\n\n new_resource.updated_by_last_action(true)\n end\n end",
"def initialize()\n \n @saved_kc_list = nil;\n @build_dir = ENV[\"BUILT_PRODUCTS_DIR\"]\n @project_dir = ENV[\"PROJECT_DIR\"]\n @certificate_dir = File.join(@project_dir, \"..\")\n \n @distrusted_certs_dir = File.join(certificate_dir, \"distrusted\")\n @revoked_certs_dir = File.join(certificate_dir, \"revoked\")\n @root_certs_dir = File.join(certificate_dir, \"roots\")\n @intermediate_certs_dir = File.join(certificate_dir, \"certs\")\n \n Utilities.check_path(@distrusted_certs_dir)\n Utilities.check_path(@revoked_certs_dir)\n Utilities.check_path(@root_certs_dir)\n Utilities.check_path(@intermediate_certs_dir)\n\n @security_tool_path = '/usr/bin/security'\n Utilities.check_path(@security_tool_path, false)\n\n @output_keychain_path = File.join(@build_dir , \"BuiltKeychains\")\n FileUtils.mkdir_p(@output_keychain_path) if !FileTest.exists? @output_keychain_path\n \n output_variables = false\n if output_variables\n puts \"=================================================\"\n puts \"CertTools variables\"\n puts \" \"\n puts \"@build_dir = #{@build_dir}\"\n puts \"@project_dir = #{@project_dir}\"\n puts \"@certificate_dir = #{@certificate_dir}\"\n puts \"@distrusted_certs_dir = #{@distrusted_certs_dir}\"\n puts \"@revoked_certs_dir = #{@revoked_certs_dir}\"\n puts \"@root_certs_dir = #{@root_certs_dir}\"\n puts \"@intermediate_certs_dir = #{@intermediate_certs_dir}\"\n puts \"@security_tool_path = #{@security_tool_path}\"\n puts \"@output_keychain_path = #{@output_keychain_path}\"\n puts \"=================================================\"\n puts \" \" \n end \n end",
"def ssl_generate_certificate\n Rex::Socket::SslTcpServer.ssl_generate_certificate\n end",
"def set_client_cert_and_key (cert_file, key_file = nil, key_passwd = nil)\n return fail_response(13001, \"NaServer::set_client_cert_and_key: certificate file not specified\") unless(cert_file)\n @cert_file = cert_file\n @key_file = key_file\n if key_passwd\n @key_passwd = key_passwd\n else\n @key_passwd = \"\"\n end\n end",
"def key_pem; end",
"def service_key\n SERVICE_KEY\n end",
"def write_key!\n dir = Tinc.config['key_dir']\n File.open(\"#{dir}/#{node.mac}\", 'w') do |f|\n f.write(self.cert_data) \n end\n end",
"def certs\n request :get, '/certs'\n end",
"def cert_content; end",
"def create_sslcert\n converge_by(\"Create Cert #{new_resource}\") do\n Chef::Log.info \"Create #{new_resource}\"\n\n update_sslcert\n\n new_resource.updated_by_last_action(true)\n end\n end",
"def client_key_file\n return @client_key_file unless @client_key_file.nil?\n\n @client_key_file = ::File.join(new_resource.chef_secure_path, 'client.pem')\n return @client_key_file\n end",
"def keypair; end",
"def keypair; end",
"def keypair; end",
"def keypair; end",
"def keypair; end",
"def cli_cert()\n\t\tENV['CLI_FILE'] || \"client.crt\" # The client cert File\n end",
"def ssl_cert\n datastore['SSLCert']\n end",
"def fle_aws_temp_key\n ENV['CSFLE_AWS_TEMP_ACCESS_KEY_ID']\n end",
"def save\n # get a new KEK\n kek = OpenSSL::Random.random_bytes(32)\n \n # set up a cipher to encrypt the keystore\n cipher = get_cipher\n cipher.encrypt(kek)\n iv = cipher.random_iv\n\n # dump the keystore and pad it with a random length\n ksdata = OpenSSL::Random.random_bytes(2)\n len = ksdata.unpack(\"n\").first\n ksdata << OpenSSL::Random.random_bytes(len)\n ksdata << Marshal.dump(@ks)\n\n # encrypt the keystore with its KEK\n ciphertext = cipher.update(ksdata)\n ciphertext << cipher.final\n\n # encrypt the KEK\n public_rsa = @config[:SSLPrivateKey].public_key\n encrypted_key = public_rsa.public_encrypt(kek)\n\n # write out the encrypted KEK, the IV and the ciphertext\n File.open(@config[:filename], \"w\") do |fp| \n fp << encrypted_key\n fp << iv\n fp << ciphertext\n end\n end",
"def ssl; end",
"def generate_ssl_cert\n\t\tcert_request = TEST_WORKDIR + 'example.csr'\n\t\tsigning_key = TEST_WORKDIR + 'example.key'\n\t\tcert = TEST_WORKDIR + 'example.crt'\n\n\t\tunless File.exist?( cert )\n\t\t\tsystem 'openssl', 'req',\n\t\t\t\t'-new', '-newkey', 'rsa:4096',\n\t\t\t\t'-days', '365', '-nodes', '-x509',\n\t\t\t\t'-subj', '/C=US/ST=Oregon/L=Portland/O=IT/CN=localhost',\n\t\t\t\t'-keyout', signing_key.to_s,\n\t\t\t\t'-out', cert.to_s\n\n\t\t\tsystem 'openssl', 'req',\n\t\t\t\t'-new',\n\t\t\t\t'-subj', '/C=US/ST=Oregon/L=Portland/O=IT/CN=localhost',\n\t\t\t\t'-key', signing_key.to_s,\n\t\t\t\t'-out', cert_request.to_s\n\n\t\t\tsystem 'openssl', 'rsa',\n\t\t\t\t'-in', signing_key.to_s,\n\t\t\t\t'-out', signing_key.to_s\n\n\t\t\tsystem 'openssl', 'x509',\n\t\t\t\t'-req', '-days', '365',\n\t\t\t\t'-in', cert_request.to_s,\n\t\t\t\t'-signkey', signing_key.to_s,\n\t\t\t\t'-out', cert.to_s\n\t\tend\n\tend",
"def key_file\n super\n end",
"def create\n @keystore = Keystore.new(keystore_params)\n\n respond_to do |format|\n if @keystore.save\n format.html { redirect_to @keystore, notice: 'Keystore was successfully created.' }\n format.json { render :show, status: :created, location: @keystore }\n else\n format.html { render :new }\n format.json { render json: @keystore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sign_key; end",
"def cli_key()\n\t\tENV['CLI_KEY'] || nil # The client private key File\n end",
"def ssl_cipher\n datastore['SSLCipher']\n end",
"def ca_cert_string\n @ca_cert_string ||= begin\n return nil if ENV['VCAP_SERVICES'].blank?\n\n JSON.parse(ENV['VCAP_SERVICES'])['a9s-elasticsearch'].first['credentials']['cacrt']\n end\n end",
"def load\n # read the keystore file and extract the parts\n file = File.read(@config[:filename])\n encrypted_key = file[0,128]\n iv = file[128,16]\n ciphertext = file[144, file.length - 144]\n \n # decrypt the KEK\n kek = @config[:SSLPrivateKey].private_decrypt(encrypted_key)\n \n # decrypt the keystore with the KEK and IV\n cipher = get_cipher\n cipher.decrypt(kek)\n cipher.iv = iv\n ksdata = cipher.update(ciphertext)\n ksdata << cipher.final\n \n # remove the random offset and reanimate the keystore\n offset = ksdata.slice!(0,2).unpack(\"n\").first\n ksdata.slice!(0,offset)\n @ks = Marshal.restore(ksdata)\n end",
"def secret_key_base; end",
"def secret_key_base; end",
"def secret_key_base; end",
"def secret_key_base; end",
"def add_ssl_cert(ssl_cert, priv_key, server_alias, passphrase='')\n basedir = @config.get(\"GEAR_BASE_DIR\")\n\n ssl_cert_name = clean_server_name(server_alias) + \".crt\"\n priv_key_name = clean_server_name(server_alias) + \".key\"\n\n app_token = \"#{@container_uuid}_#{@namespace}_#{@container_name}\"\n alias_token = \"#{@container_uuid}_#{@namespace}_#{server_alias}\"\n\n app_conf_dir_path = File.join(basedir, \".httpd.d\", app_token)\n alias_conf_dir_path = File.join(basedir, \".httpd.d\", alias_token)\n ssl_cert_file_path = File.join(alias_conf_dir_path, ssl_cert_name)\n priv_key_file_path = File.join(alias_conf_dir_path, priv_key_name)\n\n # Check if the specified alias has been created for the app\n server_alias_conf_file_path = File.join(app_conf_dir_path, \"server_alias-#{server_alias}.conf\")\n \n unless File.exists? (server_alias_conf_file_path)\n raise FrontendHttpServerException.new(\"Specified alias #{server_alias} does not exist for the app\",\n @container_uuid, @container_name,\n @namespace)\n end\n\n # Make sure that the private key is not encrypted\n if priv_key.include? \"ENCRYPTED\"\n raise FrontendHttpServerException.new(\"Private key is encrypted\",\n @container_uuid, @container_name,\n @namespace)\n end\n\n # Create a new directory for the alias and copy the certificates\n FileUtils.mkdir_p(alias_conf_dir_path)\n File.open(ssl_cert_file_path, 'w') { |f| f.write(ssl_cert) }\n File.open(priv_key_file_path, 'w') { |f| f.write(priv_key) }\n\n # Verify the cert and the key\n rc, out, errout = systemu \"openssl rsa -in #{priv_key_file_path}\"\n if rc != 0\n FileUtils.rm_f(ssl_cert_file_path)\n FileUtils.rm_f(priv_key_file_path)\n FileUtils.rm_f(alias_conf_dir_path)\n raise FrontendHttpServerException.new(\"Invalid private key\",\n @container_uuid, @container_name,\n @namespace)\n end\n\n rc, out, errout = systemu \"openssl x509 -in #{ssl_cert_file_path} -text -noout\"\n if rc != 0\n FileUtils.rm_f(ssl_cert_file_path)\n FileUtils.rm_f(priv_key_file_path)\n FileUtils.rm_f(alias_conf_dir_path)\n raise FrontendHttpServerException.new(\"Invalid ssl certificate\",\n @container_uuid, @container_name,\n @namespace)\n end\n\n #\n # Create configuration for the alias\n #\n\n # Create 00000_default.conf for the alias\n default_conf_contents = <<-DEFAULT_ENTRY\nServerName #{server_alias}\nServerAdmin openshift-bofh@redhat.com\nDocumentRoot /var/www/html\nDefaultType None\n DEFAULT_ENTRY\n\n default_conf_file_path = File.join(alias_conf_dir_path, \"00000_default.conf\")\n File.open(default_conf_file_path, 'w') { |f| f.write(default_conf_contents) }\n\n # Copy zzzzz_proxy.conf for the alias\n proxy_conf_file_src_path = File.join(app_conf_dir_path, \"zzzzz_proxy.conf\")\n FileUtils.cp(proxy_conf_file_src_path, alias_conf_dir_path)\n\n # Create top level config file for the alias\n alias_conf_contents = <<-ALIAS_CONF_ENTRY\n<VirtualHost *:80>\n RequestHeader append X-Forwarded-Proto \"http\"\n\n Include #{alias_conf_dir_path}/*.conf\n</VirtualHost>\n\n<VirtualHost *:443>\n RequestHeader append X-Forwarded-Proto \"https\"\n\n# This file gets inserted into every httpd.conf ssl section\n SSLEngine on\n \n SSLCertificateFile #{ssl_cert_file_path}\n SSLCertificateKeyFile #{priv_key_file_path}\n SSLCertificateChainFile #{ssl_cert_file_path}\n SSLCipherSuite RSA:!EXPORT:!DH:!LOW:!NULL:+MEDIUM:+HIGH\n SSLProtocol -ALL +SSLv3 +TLSv1\n SSLOptions +StdEnvVars +ExportCertData\n # SSLVerifyClient must be set for +ExportCertData to take effect, so just use\n # optional_no_ca.\n SSLVerifyClient optional_no_ca\n\n RequestHeader set X-Forwarded-SSL-Client-Cert %{SSL_CLIENT_CERT}e\n\n Include #{alias_conf_dir_path}/*.conf\n</VirtualHost>\n ALIAS_CONF_ENTRY\n\n alias_conf_file_path = File.join(basedir, \".httpd.d\", \"#{alias_token}.conf\")\n File.open(alias_conf_file_path, 'w') { |f| f.write(alias_conf_contents) }\n\n # Remove original server alias conf file\n FileUtils.rm_f(server_alias_conf_file_path)\n\n # Reload httpd to pick up the new configuration\n reload_httpd\n end",
"def ssl_params; end",
"def key_manager; end",
"def cert_store=(cert_store); end",
"def cert_store=(cert_store); end",
"def cert_pem; end",
"def secret_key; end",
"def keygen_tool\n return nil, nil, nil # ADD CODE HERE\n end",
"def keychain\n @keychain ||= Keychain.new\n end",
"def set_ssl_client_key(opts)\n opts = check_params(opts,[:keys])\n super(opts)\n end",
"def default_ca_file; end",
"def compile\n puts '-----> Creating TrustStore with container certificates'\n\n resolved_certificates = certificates\n with_timing(caption(resolved_certificates)) do\n unless use_jvm_trust_store?\n FileUtils.mkdir_p File.join(@app_dir, NEW_TRUST_STORE_DIRECTORY)\n end\n resolved_certificates.each_with_index { |certificate, index| add_certificate certificate, index }\n end\n end",
"def initialize(*)\n super\n\n @encrypted_env_key = \"ENCRYPTED_#{env_key}\"\n @encrypted_key_path = \"#{key_path}.enc\"\n end",
"def ssl\n datastore['SSL']\n end",
"def private_key_file\n if ENV.include?(\"MCOLLECTIVE_SSL_PRIVATE\")\n return ENV[\"MCOLLECTIVE_SSL_PRIVATE\"]\n else\n if @initiated_by == :node\n return server_private_key\n else\n return client_private_key\n end\n end\n end",
"def openssl_create_csr(*args,&block)\n key = args[0][:key]\n name = OpenSSL::X509::Name.new [['CN', \"To be detailed\"]]\n req = OpenSSL::X509::Request.new\n req.version = 0\n req.subject = name\n req.public_key = key.public_key\n req.sign key, OpenSSL::Digest::SHA1.new\n req\n end",
"def ssl_key=(key)\n set_option(:sslkey, key)\n end",
"def do_processing()\n CertTools.createKeychain(@cert_kc_path, @cert_kc_name)\n cert_path = CertTools.intermediate_certs_dir\n \n puts \"Adding intermediate cderts to #{@cert_kc_path}\" if @verbose \n puts \"Intermediates #{cert_path}\" if @verbose \n \n Dir.foreach(cert_path) do |f|\n next if f[0].chr == \".\"\n full_path = File.join(cert_path, f)\n puts \"Processing #{f}\" if @verbose\n cmd_str = CertTools.security_tool_path\n cmd_str += \" -q add-certificates \"\n cmd_str += \" -k \"\n cmd_str += Utilities.quote_str(@cert_kc_path)\n cmd_str += \" \"\n cmd_str += Utilities.quote_str(full_path)\n `#{cmd_str}`\n Utilities.bail(\"Security add-certificates returned an error for #{full_path}\") if $? != 0\n end\n \n FileUtils.chmod 0644, @cert_kc_path\n end"
] |
[
"0.6560407",
"0.63470495",
"0.6223508",
"0.62197",
"0.62186843",
"0.6190275",
"0.6107682",
"0.6107682",
"0.5937524",
"0.58946455",
"0.5849017",
"0.58374745",
"0.58021986",
"0.57981896",
"0.57981896",
"0.57937044",
"0.5769242",
"0.5769242",
"0.5769242",
"0.57677674",
"0.5764669",
"0.57282966",
"0.56119055",
"0.5585115",
"0.55721205",
"0.5568405",
"0.5567881",
"0.55245435",
"0.55136365",
"0.54767865",
"0.5471344",
"0.5461588",
"0.54583716",
"0.54486495",
"0.5445754",
"0.54315907",
"0.5430129",
"0.54276764",
"0.5415737",
"0.5404906",
"0.5404906",
"0.5399346",
"0.53961915",
"0.5384836",
"0.5384729",
"0.5384729",
"0.5367138",
"0.5338921",
"0.5336063",
"0.5336063",
"0.53357905",
"0.5329185",
"0.53236943",
"0.53205675",
"0.5317563",
"0.5297555",
"0.5295252",
"0.52883464",
"0.5271683",
"0.5266932",
"0.52596664",
"0.5257726",
"0.5257726",
"0.5257726",
"0.5257726",
"0.5257726",
"0.52550256",
"0.52513206",
"0.52511597",
"0.5250725",
"0.5247119",
"0.52468455",
"0.5240835",
"0.5235503",
"0.52354294",
"0.52311665",
"0.52278817",
"0.5214793",
"0.52128696",
"0.51994777",
"0.51994777",
"0.51994777",
"0.51994777",
"0.51857984",
"0.51854146",
"0.51822066",
"0.51820594",
"0.51820594",
"0.51813716",
"0.516977",
"0.5167517",
"0.5142082",
"0.51393026",
"0.51257586",
"0.5106812",
"0.5106579",
"0.51001525",
"0.50987047",
"0.50971925",
"0.5091839",
"0.50862855"
] |
0.0
|
-1
|
I worked on this challenge [by myself, with: ]. largest_integer is a method that takes an array of integers as its input and returns the largest integer in the array +list_of_nums+ is an array of integers largest_integer(list_of_nums) should return the largest integer in the +list_of_nums+ If +list_of_nums+ is empty the method should return nil Your Solution Below def largest_integer(list_of_nums) len = list_of_nums.length 1 largest = list_of_nums[len] while len > 0 if list_of_nums[len1] > largest largest = list_of_nums[len1] end len = 1 end return largest end
|
def largest_integer(list_of_nums)
list_of_nums.sort!
return list_of_nums[-1]
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def largest_integer(list_of_nums)\n \tlen = list_of_nums.length\n\tlargest = list_of_nums[0]\n \tif len == 0\n\t\treturn nil\n \telsif len == 1\n \t\treturn largest\n \telse\n \t\tlist_of_nums.each do |num|\n \t\t\tif num > largest\n \t\t\t\tlargest = num\n \t\t \tend\n \t\tend\n \t\treturn largest\n \tend\nend",
"def largest_integer(list_of_nums)\n if list_of_nums.length == 0\n return nil\n else\n biggie = list_of_nums[0]\n i = 0\n while i<list_of_nums.length do\n if list_of_nums[i] >= biggie\n biggie = list_of_nums[i]\n end\n i+=1\n end\n return biggie\n end\nend",
"def largest_integer(list_of_nums)\n # Pseudocode\n # return nil if array is empty\n # Otherwise, initialize current maximum as the first element of the array\n # FOR each element of the array\n # IF that element is larger than the current maximum\n # Set the current maximum to that element\n # Return the current maximum\n\n #initial solution\n # return nil if list_of_nums.length == 0\n\n # maximum = list_of_nums[0]\n\n # list_of_nums.each do |el|\n # maximum = el if el > maximum\n # end\n\n # return maximum\n\n #using built-in Ruby enumerables method\n return list_of_nums.max\n\nend",
"def largest_integer(list_of_nums)\n i = 0\n largest = list_of_nums[0]\n while i < list_of_nums.length\n if list_of_nums[i] > largest\n largest = list_of_nums[i]\n end\n i +=1\n end\n return largest\nend",
"def largest_integer(list_of_nums)\n max = nil\n max = list_of_nums[0]\n for i in 0...list_of_nums.length\n if list_of_nums[i] > max\n max = list_of_nums[i]\n end\n return max\n end\nend",
"def largest_integer(list_of_nums)\n return list_of_nums.max\n if list_of_nums == []\n return nil\n end\nend",
"def largest_integer(list_of_nums)\n # Your code goes here!\n if list_of_nums.length == 0 then return nil end\n largest_num = list_of_nums.max\n return largest_num\nend",
"def largest_integer(list_of_nums)\n if list_of_nums.empty? \n return nil\n else \n big=list_of_nums[0]\n list_of_nums.each { |x| \n if x > big\n big=x\n end \n }\n return big\n end\nend",
"def largest_integer(list_of_nums)\n return nil if list_of_nums.empty?\n largest = list_of_nums.pop\n list_of_nums.each {|x| largest = x if x > largest }\n largest\nend",
"def largest_integer(list_of_nums)\n# Your Solution Below\n# Refactored solution\n\treturn list_of_nums.max\nend",
"def largest_integer(list_of_nums)\n\treturn nil if list_of_nums == []\n\tlargest = list_of_nums[0]\n\tfor num in list_of_nums\n\t\tif num > largest\n\t\t\tlargest = num\n\t\tend\n\tend\n\treturn largest\nend",
"def largest_integer(list_of_nums)\n\treturn nil if(list_of_nums.length <= 0)\n\n\tlargest = list_of_nums[0]\n\tlist_of_nums.each {|x|\n\t\tif(x > largest)\n\t\t\tlargest = x\n\t\tend\n\t}\n\treturn largest\nend",
"def largest_integer(list_of_nums)\n largest = list_of_nums[0]\n for num in 1...list_of_nums.length\n \tif largest < list_of_nums[num] then\n \t\tlargest = list_of_nums[num];\n \tend\n end\n return largest;\nend",
"def largest_integer(list_of_nums)\n largest = nil\n list_of_nums.each do |num|\n if largest == nil\n largest = num\n end\n if num >= largest\n largest = num\n end\n end\n largest\nend",
"def largest_integer(list_of_nums)\n largest = list_of_nums[0]\n list_of_nums.each do |thisNum|\n if thisNum > largest\n largest = thisNum\n end\n end\n return largest\nend",
"def largest_integer(list_of_nums)\ninitial = list_of_nums.kind_of?(Array) && list_of_nums[0] != nil ? 0 : nil\n\nreturn initial if initial == nil\n\nfor i in 0...list_of_nums.length\n curr_val = list_of_nums[i] if list_of_nums[i].instance_of? Fixnum\n initial = curr_val if i == 0 || initial < curr_val\nend\n\ninitial\nend",
"def largest_integer(list_of_nums)\n # Your code goes here!\n list_sorted_array = []\n zero = 3-3\n \n if list_of_nums.empty?() == true\n return\n elsif list_of_nums.length == 1\n if list_of_nums.include?(0)\n return zero.to_i\n elsif list_of_nums.include?(-10)\n return -10\n end \n \n else \n \n list_sorted_array = list_of_nums.sort\n list_sorted_last = list_sorted_array.last\n list_sorted_first = list_sorted_array.first\n \n if list_sorted_last < list_sorted_first\n return list_sorted_first\n elsif list_sorted_last > list_sorted_first\n return list_sorted_last\n end \n \n end\n \nend",
"def largest_integer(list_of_nums)\n list_of_nums.sort!\n list_of_nums.reverse!\n return list_of_nums[0]\nend",
"def largest_integer(list_of_numbers)\n # Return nil if the array doesn't have any element.\n return nil if list_of_numbers.length == 0\n # Define the variable to the first element of the array.\n largest_number = list_of_numbers[0]\n # Take the first number!! and store inside defined variable.\n list_of_numbers.each do |number|\n # Go ahead and take the next one\n # Compare that one with the stored number in the variable.\n if largest_number < number\n # Whichever is larger, keep that number inside the variable.\n largest_number = number\n end\n # Continue this process until the array is empty.\n end\n # Return the largest number.\n largest_number\nend",
"def largest_integer(list_of_nums)\n return list_of_nums.max\nend",
"def largest_integer(list_of_nums) #define method largest_integer with argument list_of_nums\n max = list_of_nums[0] #set the max as the first position of the array\n list_of_nums.each do |num| #iterate over each number of the array\n \tif \n \t\tmax < num # if max is less than a given number\n \t\tnum = max # the number is equal to max\n \tend # close the if statement\nend # close the method definition\n return max #return the max number\nend",
"def largest_integer(list_of_nums)\n largestnumber = list_of_nums.pop\n while list_of_nums.length > 0 do\n secondnum = list_of_nums.pop\n if largestnumber < secondnum\n largestnumber = secondnum\n end\n end\n p largestnumber\n\nend",
"def largest_integer(list_of_nums)\n # Your code goes here!\n list_of_nums.sort! {|x,y| y<=>x}\n return list_of_nums[0]\nend",
"def largest_integer(list_of_nums)\n\t# Your code goes here!\n\tlist_of_nums.to_a.sort! {|firstNum,secondNum| firstNum.to_i <=> secondNum.to_i}\n \treturn list_of_nums[-1]\nend",
"def largest_integer(list_of_nums)\n list_of_nums.sort!\n p list_of_nums[-1]\nend",
"def largest_integer(list_of_nums)\n return list_of_nums.sort().slice(-1)\nend",
"def largest_integer(list_of_nums)\n\n if list_of_nums.length == 0\n return nil\n end\n#Order the variable\n order_array = []\n greates_num = list_of_nums[0]\n list_of_nums.each do |x|\n greates_num = x if x > greates_num\n end\n p greates_num\nend",
"def highest_num(list)\n max = list[0]\n i = 0\n until i >= list.length\n max = list[i] if list[i] > max\n i += 1\n end\n max\nend",
"def largest_integer(array)\n large = array[0]\n array.each do |n|\n if n > large\n large = n\n end\n end\n large\nend",
"def find_largest_num(nums)\n\treturn nums.max()\nend",
"def biggest_number(array_of_integers)\n # TODO\nend",
"def largest_int(numbers)\n\tnumbers.sort!\n\tnumbers[-1]\nend",
"def find_max_num(numbers)\n if numbers.length == 0 \n \tputs \"No numbers were passed.\" \n elsif numbers.length > 0\n max_num = numbers[0]\n \tfor i in 1..numbers.length - 1 # So I don't over-run the array, and start at the 2nd position to compare against max at postion [0]\n if max_num < numbers[i] \n max_num = numbers[i] \n end\n i += 1\n \tend\n puts \"Looked through an array of lenght #{numbers.length}.\"\n puts \"The largest value is #{max_num}\"\n end\nend",
"def find_largest(array, length)\n largest_int = array[0]\n (length - 1).times do |i|\n if array[i + 1] > largest_int\n largest_int = array[i + 1]\n end\n end\n return largest_int\nend",
"def highestnumber arr \n idx = 0 \n max = arr[0]\n while idx <= arr.length - 1\n if max > arr[idx] \n max = max\n else \n max = arr[idx]\n end\n \n idx = idx + 1\n end\n return max\nend",
"def find_largest_nums(arr)\n\tlargest = []\n\tarr.each { |x| largest << x.sort[-1] }\n\treturn largest\nend",
"def find_largest(array, length)\n index = 0\n largest = array[0]\n while array[index] != nil do\n if array[index] > largest\n largest = array[index]\n end\n index += 1\n end\n return largest\nend",
"def length_of_lis(nums)\n return 0 if !nums\n return 1 if nums.size == 1\n arr = [0] * nums.size\n max = 0\n for i in 0...nums.size do \n arr[i] = 1\n for j in 0...i do \n if nums[j] < nums[i]\n arr[i] = arr[i] > arr[j] + 1 ? arr[i] : arr[j] + 1 \n end\n end\n max = [max, arr[i]].max\n end\n max\nend",
"def max_sub_array(nums)\n return 0 if nums.nil? \n return nil if nums.empty?\n \n max_so_far = nums[0]\n max_for_sub_array = 0\n\n nums.each do |num|\n max_for_sub_array = max_for_sub_array + num\n if num > max_for_sub_array\n max_for_sub_array = num\n end\n if max_for_sub_array > max_so_far\n max_so_far = max_for_sub_array\n end\n end\n return max_so_far\n\nend",
"def smallest_integer(list_of_nums)\n length = list_of_nums.length\n if length == 0\n return nil\n elsif length == 1\n return list_of_nums[0]\n else\n a = 0\n b = 1\n while b < length\n if list_of_nums[a] < list_of_nums[b]\n output = list_of_nums[a]\n b += 1\n else\n output = list_of_nums[b]\n a = b\n b += 1\n end\n end\n return output\n end\nend",
"def solve(nums)\n sorted = nums.sort\n largest = 0\n (0...sorted.length - 1).each do |i|\n if (sorted[i+1] - sorted[i]) > largest\n largest = (sorted[i+1] - sorted[i])\n end\n end\n return largest\n\nend",
"def find_largest_nums(arr)\n\ta = 0\n\tfinal_arr = []\n\twhile a < arr.length\n\t\tfinal_arr << arr[a].max\n\t\ta += 1\n\tend\n\treturn final_arr\nend",
"def find_largest(array, length)\n first_non_nil = find_first_non_nil(array, length)\n if array[0] == nil\n largest = array[first_non_nil]\n else\n largest = array[0]\n end\n index = 0\n length.times do\n if array[index] == nil\n elsif array[index] > largest\n largest = array[index]\n end\n index += 1\n end\n return largest\nend",
"def find_largest(array, length)\n largest_number = array[0]\n length.times do |i|\n if array[i] > largest_number\n largest_number = array[i]\n end\n end\n return largest_number\nend",
"def find_largest(array, length)\n largest = nil\n length.times do |index|\n largest = array[index] if !largest || array[index] > largest\n end\n return largest\nend",
"def find_largest(array, length)\n largest_num = 0\n length.times do |index|\n if array[index] > largest_num\n largest_num = array[index]\n end\n end\n\n return largest_num\n # raise NotImplementedError\nend",
"def find_largest(array, length)\n largest_number = 0\n length.times do |index|\n if array[index] > largest_number\n largest_number = array[index]\n end\n end\n return largest_number\nend",
"def maxnumbers(numbers)\n new_numbers = 0\n index = 0\n while index < numbers.length\n if numbers[index] > new_numbers\n new_numbers = numbers[index]\n end\n index += 1\n end \n return new_numbers\nend",
"def smallest_integer(list_of_nums)\n\tif list_of_nums.length == 0\n\t\treturn nil\n\tend\n\ti = list_of_nums[0]\n\tj = 1\n\twhile j <= list_of_nums.length - 1 do\n\t\tif i > list_of_nums[j]\n\t\t\ti = list_of_nums[j]\n\t\tend\n\t\tj = j + 1\n\tend\n\treturn i\nend",
"def largest(array)\n index = 0 #1\n greatest_num = array[index] #5 \n while index < array.length #0 < 5 1 < 5\n if array[index] > greatest_num #if 5 > 5 17 > 5\n greatest_num = array[index] # 17 \n end\n index += 1\n end\n greatest_num\nend",
"def smallest_integer(list_of_nums)\n if list_of_nums == []\n return nil\n else\n list_of_nums.sort!\n return list_of_nums[0]\n end\nend",
"def find_max\n\tarr = [100,10,-1000,59,03,453,2345,365,-45,266,-345]\n\tarr_new = arr.sort.pop\n\tprint \"this is the higest number in the array #{arr_new}\"\nend",
"def smallest_integer(list_of_nums)\n if list_of_nums.count > 0\n list_of_nums.sort!\n else\n return nil\n end\nreturn list_of_nums[0]\nend",
"def find_longest(arr)\n longest_num = 0 # current longest number\n most_digits = 0 # current most digits found in a number in the array\n\n arr.each do |num|\n digits_in_num = num.to_s.length\n if digits_in_num <= most_digits # if length of the current number is <= longest number yet - next\n next\n else # but if length is > than any other number we have seen yet -\n longest_num = num # set this num as new longest_num\n most_digits = digits_in_num # set the length of this num as the new standard to compare against\n end\n end\n longest_num\nend",
"def max(arr)\n greatest = array[0]\n arr.each do |num|\n if num > greatest\n greatest = num\n end\n end\n greatest\nend",
"def maximum(arr)\n\t# for empty input\n\treturn nil if arr.nil? or arr.length == 0\n\tmax = arr[0]\n\tarr.each do |elem|\n\t\tmax = elem if elem > max\n\tend\n\tmax\nend",
"def length_of_lis(nums)\n return 0 if nums.empty?\n dp = [1]\n max = 1\n\n (1...nums.length).each do |i|\n current_max = 0\n (0...i).each do |j|\n if nums[i] > nums[j]\n current_max = [current_max, dp[j]].max\n end\n end\n dp[i] = current_max + 1\n max = [max, dp[i]].max\n end\n\n max\nend",
"def max_num(array,max=array[0])\n begin\n if array.count == 1\n array[0] > max ? array[0] : max\n else\n max = array[1] if array[1] > max\n max_num(array[1..-1],max)\n end\n rescue Exception => e\n puts e.message\n end\nend",
"def solve(nums)\n largest = nums.sort[-1]\n until nums.all? {|num| num % largest == 0 }\n largest -= 1\n end\n return largest\nend",
"def find_largest(array, length)\r\n i = 0;\r\n big = array[0];\r\n while i < array.length\r\n if array[i] > big\r\n big = array[i];\r\n i++;\r\n end\r\n i++;\r\n end\r\n return big;\r\nend",
"def max(numbers)\n current_max = numbers[0]\n numbers.each do |number|\n if number > current_max\n current_max = number\n end\n end\n current_max\nend",
"def max(numbers)\n current_max = numbers[0]\n numbers.each do |number|\n if number > current_max\n current_max = number\n end\n end\n current_max\nend",
"def max(numbers)\n current_max = numbers[0]\n numbers.each do |number|\n if number > current_max\n current_max = number\n end\n end\n current_max\nend",
"def biggest_number(num)\n numbers = []\n num.each do |array_num|\n biggest = 0\n array_num.each do |num|\n if num > biggest\n biggest = num\n end\n end\n numbers << biggest\n end\n p numbers\nend",
"def max(arr)\n return nil if arr.empty?\n result = arr[0]\n arr[1...-1].each do |item|\n if item > result\n result = item\n end\n end\n return result\nend",
"def max_sub_array(nums)\n return 0 if nums == nil\n return nil if nums.empty?\n \n max_by_here = nums[0]\n max_so_far = nums[0]\n \n nums.each_with_index do |num, index|\n unless index == 0\n if max_so_far < 0\n if num > max_so_far\n max_so_far = num\n end\n else\n max_by_here += num\n \n if max_by_here < 0\n max_by_here = 0\n elsif max_by_here > max_so_far\n max_so_far = max_by_here\n end\n end\n end\n end\n \n return max_so_far\nend",
"def smallest_integer(list_of_nums)\n\n if list_of_nums == []\n\n return nil\n\n else\n\n smallest_num = list_of_nums[0]\n this_num = 0\n # puts \"First num: \" + list_of_nums[this_num].to_s\n\n while this_num < list_of_nums.length - 1\n\n if list_of_nums[this_num + 1] < smallest_num then\n smallest_num = list_of_nums[this_num + 1]\n end\n\n this_num += 1\n\n # puts \"Index: \" + this_num.to_s +\n # \"; Value: \" + list_of_nums[this_num].to_s +\n # \"; Smallest Int so far: \" + smallest_num.to_s\n\n\n end\n\n return smallest_num\n\n end\n\nend",
"def largest(*numbers)\n # numbers is an array\n p numbers\n largest = numbers[0]\n\n numbers.each do |number|\n # compare to see if it's the biggest?\n if number > largest\n largest = number\n end\n end\n\n largest\nend",
"def find_highest(array)\n highest = nil;\n for num in array do\n if highest\n if num > highest\n highest = num\n end\n else\n highest = num\n end\n end\n puts highest\nend",
"def smallest_integer(list_of_nums)\n return nil if list_of_nums.empty?\n smallest = list_of_nums.pop\n list_of_nums.each {|x| smallest = x if x < smallest }\n smallest\nend",
"def find_largest(array, length)\n max = array[0]\n\n length.times do |index|\n if array[index] > max\n max = array[index]\n end\n end\n\n return max\nend",
"def new_max array_of_elements\n\ti = 0\n\tlargest = array_of_elements[0]\n\twhile i < array_of_elements.length do\n\t\tif array_of_elements[i] > largest\n\t\t\tlargest = array_of_elements[i]\n\t\tend\n\t\ti += 1\n\tend\n\tlargest\nend",
"def find_max(some_array)\n max = some_array[0]\n some_array.each do |number|\n if number > max\n max = number\n end\n end\n max\nend",
"def smallest_integer(list_of_nums)\n\n if list_of_nums == [] then return nil\n\n else\n\n smallest_num = list_of_nums[0]\n index = 1\n # puts \"First num: \" + smallest_num.to_s\n\n while index < list_of_nums.length\n\n if list_of_nums[index] < smallest_num then\n smallest_num = list_of_nums[index]\n end\n\n # puts \"Index: \" + index.to_s +\n # \"; Value: \" + list_of_nums[index].to_s +\n # \"; Smallest Int so far: \" + smallest_num.to_s\n\n index += 1\n\n end\n\n return smallest_num\n\n end\n\nend",
"def smallest_integer(list_of_nums)\n\t if list_of_nums == []\n\t \treturn nil\n\t else\n\t \treturn list_of_nums.sort[0]\n\tend\nend",
"def third_greatest(nums)\n num1 = nil\n num2 = nil\n num3 = nil\n idx = 0\n \n while idx < nums.length\n value = nums[idx]\n if num1 == nil || value > num1\n num3 = num2\n num2 = num1\n num1 = value\n elsif num2 == nil || value > num2\n num3 = num2\n num2 = value\n elsif num3 == nil || value > num3\n num3 = value\n end\n idx +=1\n end\n return num3\nend",
"def smallest_integer(list_of_nums)\n # Your code goes here!\n \n list_of_nums.each do\n if list_of_nums[0] < list_of_nums[-1]\n list_of_nums.pop\n else\n list_of_nums.delete_at(0)\n end\n if list_of_nums.length > 0\n list_of_nums.each do\n if list_of_nums[0] < list_of_nums[-1]\n list_of_nums.pop\n else\n list_of_nums.delete_at(0)\n end\n end\n end\n end\n puts list_of_nums\nend",
"def highestnumber2 arr\n idx = 0 \n idx2 = 0 \n max = arr[0][0]\n\n while idx <= arr.length - 1\n\n if (highestnumber arr[idx]) > max\n max = highestnumber arr[idx]\n idx2 = idx \n end \n idx = idx + 1\n end\n return arr[idx2]\nend",
"def find_max_value(array)\n max_element = 0\n array.length.times { |index|\n if max_element < array[index]\n max_element = array[index]\n end\n }\n return max_element\nend",
"def smallest_integer(list_of_nums)\n while list_of_nums.length > 1\n list_of_nums[0] > list_of_nums[1] ? list_of_nums.delete_at(0) : list_of_nums.delete_at(1)\n end\n smallest_num = list_of_nums[0]\nend",
"def smallest_integer(list_of_nums)\n # Pseudocode\n # return nil if array is empty\n # Otherwise, initialize current minimum as the first element of the array\n # FOR each element of the array\n # IF that element is larger than the current minimum\n # Set the current minimum to that element\n # Return the current minimum\n\n #initial solution\n # return nil if list_of_nums.length == 0\n\n # minimum = list_of_nums[0]\n\n # list_of_nums.each do |el|\n # minimum = el if el < minimum\n # end\n\n # return minimum\n\n #using built-in Ruby enumerables method\n return list_of_nums.min\n\nend",
"def find_max(some_array)\n max = nil\n some_array.each do |val|\n \tif max.nil?\n max=val\n elsif val>max\n max=val\n end\n end\n max\nend",
"def find_greatest(numbers)\n saved_number = nil\n\n\n numbers.each do |num|\n saved_number ||= num\n if saved_number >= num\n next\n else\n saved_number = num\n end\n end\n\n\nsaved_number\nend",
"def find_greatest(numbers)\n saved_number = numbers[0]\n\n numbers.each do |num|\n if saved_number >= num\n next\n else\n saved_number = num\n end\n end\n\n saved_number\nend",
"def find_greatest(numbers)\n saved_number = nil\n\n numbers.each do |num|\n saved_number = numbers[0]\n if saved_number >= num\n next\n else\n saved_number = num\n end\n end\n p saved_number\nend",
"def find_max_number(any_array)\n\treference = any_array[1]\n\tany_array.each do |number|\n\t\tif number > reference\n\t\treference = number\n\t\tend\n\tend \n\treference\nend",
"def find_max(some_array)\n\tmaximum = some_array[0]\n\n\tsome_array.each do |number|\n\t\tif number > maximum\n\t\t\tmaximum = number\n\t\tend\n\tend\n\tmaximum\nend",
"def find_max_value(array)\n i = 0 \n max = 0 \n \n while i < array.length do\n if max < array[i]\n max = array[i]\n end \n i += 1 \nend \n return max\nend",
"def max_of_three(num1, num2, num3)\n i = 0\n arr = [num2, num3]\n max = num1\n while i < 2\n if max < arr[i]\n max = arr[i]\n end\n i += 1\n end\n return max\nend",
"def smallest_integer(list_of_nums)\n length = list_of_nums.length\n if length == 0\n return nil\n else\n list_of_nums.min\n end\nend",
"def solution(digits)\n greatest = 0\n (0..(digits.size - 1)).each do |pos|\n num = digits[pos..pos+5].to_i\n greatest = num if num > greatest\n end\n greatest \nend",
"def solution(digits)\n\tlargest = (digits[0]+digits[1]+digits[2]+digits[3]+digits[4]).to_i\n\ti = 4\n\twhile i < digits.length\n\t\ttester = (digits[i-4]+digits[i-3]+digits[i-2]+digits[i-1]+digits[i]).to_i\n\t\tif tester > largest\n\t\t\tlargest = tester\n\t\tend \n\t\ti += 1\n\tend \n\tlargest\nend",
"def max(arr)\n # sort arragnes items in array by ascending order \n # last function returns the last number in the array, which in this case should be the max value\n puts arr.sort.last\n# closing function\nend",
"def max_sub_array(nums)\n\tmax = count = nums.shift\n\n\tnums.each do |num|\n\t\tcount = num > count + num ? num : count + num\n\t\tmax = count if count > max\n\tend\n\n\tmax\nend",
"def find_greatest(numbers)\n saved_number = nil\n\n numbers.each do |num|\n saved_number ||= num # assign to first value\n if saved_number >= num\n next\n else\n saved_number = num\n end\n end\n\n saved_number\nend",
"def next_largest_number (array, given_number)\n array.find {|number| number > given_number}\nend",
"def largest_digit(input)\n\t\tcreate_array(input).max.to_i\n\tend",
"def smallest_integer(list_of_nums)\n\tsmallest_num = list_of_nums[0]\n\tif list_of_nums.empty? == true\n\t\treturn nil\n\telse list_of_nums.each do |num|\n\t\tif num < smallest_num\n\t\t\tsmallest_num = num\n\t\tend\n\t\tend\n\tend\n\treturn smallest_num\nend",
"def largest_number (number_1, number_2)\n \n [number_1, number_2].max\n \nend",
"def max # creates function max\n\tnumbers = [2, 750, 83, 71] # sets numbers array and assigns their values\n\tputs numbers.sort.last # sorts the numbers min to max and then displays the last number or index\nend"
] |
[
"0.9034175",
"0.8946485",
"0.8938047",
"0.8928415",
"0.8882369",
"0.88500947",
"0.88149774",
"0.8808036",
"0.88069385",
"0.8720289",
"0.86900926",
"0.86813873",
"0.86569315",
"0.8629564",
"0.85903436",
"0.8555338",
"0.85351384",
"0.8497995",
"0.84604335",
"0.84164834",
"0.8391034",
"0.8358224",
"0.8287302",
"0.8273834",
"0.8266461",
"0.81550467",
"0.8021049",
"0.7896131",
"0.7716263",
"0.76910883",
"0.7665353",
"0.7652419",
"0.76455027",
"0.75954163",
"0.7428987",
"0.7423461",
"0.7295664",
"0.7265301",
"0.7251281",
"0.7234166",
"0.7230414",
"0.72099227",
"0.71971315",
"0.7193792",
"0.7178569",
"0.7170169",
"0.7151012",
"0.71101385",
"0.7094323",
"0.70211184",
"0.70158684",
"0.7013823",
"0.7008269",
"0.69853055",
"0.6968611",
"0.695329",
"0.6948732",
"0.6945237",
"0.6927981",
"0.6925885",
"0.6899933",
"0.6899933",
"0.6899933",
"0.6875488",
"0.68642485",
"0.6859948",
"0.6839597",
"0.6835508",
"0.68251866",
"0.681737",
"0.68168354",
"0.6813945",
"0.6799111",
"0.67950696",
"0.6771867",
"0.67550784",
"0.67423636",
"0.6739187",
"0.6736383",
"0.67328167",
"0.671551",
"0.671386",
"0.6704749",
"0.6698558",
"0.6693243",
"0.6690648",
"0.6671793",
"0.6669965",
"0.6666816",
"0.66431165",
"0.66388226",
"0.66017234",
"0.65989375",
"0.65872246",
"0.6569057",
"0.6563672",
"0.655529",
"0.6554427",
"0.6545351",
"0.65427077"
] |
0.8482026
|
18
|
Creates a blank quote
|
def create
settings = Setting.run_sql_query("SELECT * FROM Settings WHERE dtCreated IN (SELECT MAX(dtCreated) FROM Settings GROUP BY name)")
settings_hash = {}
settings.each do |setting|
settings_hash[setting["name"]] = setting["value"]
end
count = Quote.where(dtCreated: DateTime.now.strftime("%Y-%m-01 00:00:00")).count
reference = DateTime.now.strftime("%Y%m") +("0000"+( count+1).to_s).last(4)
quote = Quote.create(
idUser: current_user.idUser,
referNo: reference,
smallCarPrice: settings_hash["smallCarPrice"] || "0",
midCarPrice: settings_hash["midCarPrice"] || "0",
largeCarPrice: settings_hash["largeCarPrice"] || "0",
steelPrice: settings_hash["steelPrice"] || "0",
wheelPrice: settings_hash["wheelPrice"] || "0",
catPrice: settings_hash["catalysorPrice"] || "0",
batteryPrice: settings_hash["batteryPrice"] || "0",
excessCost: settings_hash["excessPrice"] || "0",
freeDistance: settings_hash["freeDistance"] || "0",
pickup: settings_hash["pickup"] || "0",
dtCreated: DateTime.now,
dtStatusUpdated: DateTime.now
)
return render_json_response(quote, :ok)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quotes; end",
"def quoted_string; end",
"def quote\n _passthru \"<blockquote>\"\n _passthru _body\n _passthru \"</blockquote>\"\n _optional_blank_line\nend",
"def quote(text)\n \"#{quotes[0]}#{text}#{quotes[1]}\"\n end",
"def quote\n quote_of_the_day[0...second_to_last_index(quote_of_the_day, \"~\")].gsub(/(\\A[^a-zA-z0-9\"']*|\\s*\\z)/, \"\")\n end",
"def quote(value); end",
"def quotes\n end",
"def initial_quotes(text)\n return Typogruby.initial_quotes(text.to_s)\n end",
"def quote\n %q[(?:\"|')?]\n end",
"def single_quote\n # single quote string here\n 'Hello World and others!'\nend",
"def my_quote\n\tend",
"def set_quote\n \n end",
"def quote(character: T.unsafe(nil)); end",
"def quote(character: T.unsafe(nil)); end",
"def quote(character: T.unsafe(nil)); end",
"def esc\r\n \"\\\"#{self}\\\"\"\r\n end",
"def tex_quote\n to_s.tex_quote\n end",
"def force_quotes?() @force_quotes end",
"def quoted\n with_opts(:quoted=>true)\n end",
"def marvin_quote; end",
"def quote\n fetch('final_space.quotes')\n end",
"def quote\n %Q{\"#{self}\"}\n end",
"def quote( val )\n\t\treturn %q{\"%s\"} % [ val.to_s.gsub(/\"/, '\\\\\"') ]\n\tend",
"def quote(string)\n\t\t\tstring.nil? ? \"NULL\" : \"'#{super}'\"\n\t\tend",
"def quote1(opts)\n \"'#{opts[:text]}'\"\n end",
"def qq esc = nil\n %[\"#{esc ? self.gsub('\"') { esc } : self}\"]\n end",
"def reset_quotation\n # _ %w(q:before q:after blockquote:before blockquote:after) {\n # content '\"\"'\n # content 'none'\n # }\n mixin({\n quotes: 'none'\n # ,\n # &:before, &:after\n # content: '\"\"',\n # content: 'none'\n })\n end",
"def quote(sep = nil)\n sep ||= \"'\"\n sep + self + sep\n end",
"def quote(s)\n \"\\\"#{s}\\\"\"\n end",
"def quote_string(s) #:nodoc:\n s.gsub(/'/, \"''\") # ' (for ruby-mode)\n end",
"def king_richard_iii_quote; end",
"def simple_format_with_quote(text)\n text = '' if text.nil?\n text = text.dup\n start_tag = \"<p>\"\n text = text.to_str\n text.gsub!(/\\r\\n?/, \"\\n\") # \\r\\n and \\r -> \\n\n text.gsub!(/\\n\\n+/, \"</p>\\n\\n#{start_tag}\") # 2+ newline -> paragraph\n text.gsub!(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') # 1 newline -> br\n text.insert 0, start_tag\n text.concat(\"</p>\")\n end",
"def format_quote\n\t\t@final_quote = @number.delete('\"\\\">$')\n\t\treturn @final_quote\n\tend",
"def format_quote(q)\n if q == \"'\"\n '\"\\'\"'\n else\n \"'#{q}'\"\n end\n end",
"def space; txt ' ','' end",
"def quote\n @quote ||= quote_hash\n end",
"def hamlet_quote; end",
"def squote!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 38 )\n\n type = SQUOTE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 173:10: '\\\\''\n match( 0x27 )\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__, 38 )\n\n end",
"def quote(item)\n \"\\\"#{item}\\\"\"\n end",
"def quote(name)\n raise NotImplementedError\n end",
"def as_you_like_it_quote; end",
"def quote!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 32 )\n\n type = QUOTE\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 166:9: '\\\"'\n match( 0x22 )\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__, 32 )\n\n end"
] |
[
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.69660527",
"0.66942114",
"0.6642386",
"0.6577164",
"0.6541922",
"0.6509585",
"0.6504548",
"0.6453418",
"0.64439857",
"0.6407356",
"0.6347053",
"0.63423127",
"0.63418716",
"0.62978536",
"0.62978536",
"0.62970227",
"0.6242577",
"0.6237947",
"0.6231879",
"0.61679775",
"0.6161896",
"0.61526424",
"0.6109632",
"0.6084659",
"0.6082845",
"0.6080929",
"0.6058774",
"0.6017445",
"0.60080546",
"0.59699804",
"0.59466755",
"0.5925955",
"0.5905423",
"0.5902032",
"0.5884919",
"0.58632046",
"0.58164334",
"0.5792136",
"0.5791945",
"0.5784778",
"0.57179517",
"0.5701219",
"0.5699953"
] |
0.0
|
-1
|
Creates a blank quote ca
|
def remove_car
@quote_car = QuoteCar.where(id: params[:car])
@quote_car.destroy
return render_json_response({:msg => "ok"}, :ok)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def generate_ca_data!\n self.private_key = OpenSSL::PKey::RSA.new(2048)\n public_key = private_key.public_key\n\n self.ca_cert = OpenSSL::X509::Certificate.new\n self.ca_cert.subject = self.ca_cert.issuer = self.subject # self-signed\n self.ca_cert.not_before = Time.now\n self.ca_cert.not_after = Time.now + 365 * 24 * 60 * 60 * 10 #TODO change from hardcoded 10 years\n self.ca_cert.public_key = public_key\n self.ca_cert.serial = 0x0\n self.next_serial = 0x1\n self.ca_cert.version = 2\n\n ef = OpenSSL::X509::ExtensionFactory.new\n ef.subject_certificate = ca_cert\n ef.issuer_certificate = ca_cert\n # TODO Make this changeable\n self.ca_cert.extensions = [\n ef.create_extension(\"basicConstraints\",\"CA:TRUE\", true),\n ef.create_extension(\"subjectKeyIdentifier\", \"hash\"),\n ]\n self.ca_cert.add_extension ef.create_extension(\"authorityKeyIdentifier\", \"keyid:always,issuer:always\")\n\n self.ca_cert.sign private_key, OpenSSL::Digest::SHA1.new\n end",
"def quote\n _passthru \"<blockquote>\"\n _passthru _body\n _passthru \"</blockquote>\"\n _optional_blank_line\nend",
"def export_as_apa_citation_txt\n get_citation_style(:apa)&.html_safe || super # TODO: APA for non-MARC\n end",
"def generate_ca(prefix,passphrase=nil)\n\n\t\t\toutdir=File.expand_path(File.dirname(\"#{prefix}a.b\"))\n\t\t\tFileUtils.mkdir_p(outdir)\n\n\t\t\t#\n\t\t\t# write key file\n\t\t\t#\n\t\t\t\n\t\t\tputs \"generating CA key...\"\n\t\t\tkey = OpenSSL::PKey::RSA.new(2048)\n\t\t\tcipher = OpenSSL::Cipher::Cipher.new('AES-128-CBC')\n\t\t\texp = passphrase ? key.export(cipher,passphrase) : key.export\n\t\t\tputs \"saving CA key...\"\n\t\t\tFile.open(make_filename(prefix,:key),\"w\") do |f|\n\t\t\t\tf.write(exp)\n\t\t\tend\n\t\t\t\n\t\t\t#\n\t\t\t# generate certificate\n\t\t\t#\n\t\t\t\n\t\t\tputs \"generating CA cert...\"\n\t\t\tca_name = OpenSSL::X509::Name.parse('CN=ca')\n\t\t\tca_cert = OpenSSL::X509::Certificate.new\n\t\t\tca_cert.serial = 0\n\t\t\tca_cert.version = 2\n\t\t\tca_cert.not_before = Time.at(0)\n\t\t\tca_cert.not_after = Time.at(0x7fffffff)\n\t\t\tca_cert.public_key = key.public_key\n\t\t\tca_cert.subject = ca_name\n\t\t\tca_cert.issuer = ca_name\n\n\t\t\textension_factory = OpenSSL::X509::ExtensionFactory.new\n\t\t\textension_factory.subject_certificate = ca_cert\n\t\t\textension_factory.issuer_certificate = ca_cert\n\n\t\t\textension_factory.create_extension 'subjectKeyIdentifier', 'hash'\n\t\t\textension_factory.create_extension 'basicConstraints', 'CA:TRUE', true\n\t\t\textension_factory.create_extension 'keyUsage', 'cRLSign,keyCertSign', true\n\n\t\t\tputs \"signing CA cert...\"\n\t\t\tca_cert.sign(key, OpenSSL::Digest::SHA1.new)\n\n\t\t\tputs \"saving CA cert...\"\n\t\t\tFile.open(make_filename(prefix,:cert),\"w\") do |f|\n\t\t\t\tf.write(ca_cert.to_pem)\n\t\t\tend\t\t\t\n\t\t\t\n\t\t\tputs \"wrote #{make_filename(prefix,:key)} and #{make_filename(prefix,:cert)}\"\n\t\t\t\n\t\tend",
"def marvin_quote; end",
"def export_as_apa_citation_txt\n return '' unless to_marc\n super\n end",
"def annotate_quote\n Caption.new(\n gsub('\\\\', '\\\\\\\\\\\\').\n gsub('%', '%%').\n gsub(/^@/, '\\@'))\n end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def king_richard_iii_quote; end",
"def quote\n @quote ||= quote_hash\n end",
"def quotes; end",
"def quote(node)\n cite_value = node.attr(\"citetitle\")\n cite_value = nil unless cite_value.to_s =~ URI::DEFAULT_PARSER.make_regexp\n\n blockquote_attributes = {\n anchor: node.id,\n quotedFrom: node.attr(\"attribution\"),\n cite: cite_value,\n }\n\n noko do |xml|\n xml.blockquote **attr_code(blockquote_attributes) do |xml_blockquote|\n xml_blockquote << node.content\n end\n end\n end",
"def ca; end",
"def export_as_apa_citation_txt\n (self[:citation_apa].presence || super).html_safe\n end",
"def quote\n quote_of_the_day[0...second_to_last_index(quote_of_the_day, \"~\")].gsub(/(\\A[^a-zA-z0-9\"']*|\\s*\\z)/, \"\")\n end",
"def quote\n fetch('final_space.quotes')\n end",
"def initial_quotes(text)\n return Typogruby.initial_quotes(text.to_s)\n end",
"def generate_ca_certificate\n generate_password unless password?\n\n host.generate_key unless host.key\n\n # Create a new cert request. We do this\n # specially, because we don't want to actually\n # save the request anywhere.\n request = Puppet::SSL::CertificateRequest.new(host.name)\n request.generate(host.key)\n\n # Create a self-signed certificate.\n @certificate = sign(host.name, :ca, request)\n\n # And make sure we initialize our CRL.\n crl()\n end",
"def quote(text)\n \"#{quotes[0]}#{text}#{quotes[1]}\"\n end",
"def quote(value); end",
"def quotes\n end",
"def test_autocertgeneration\n ca = nil\n\n # create our ca\n assert_nothing_raised {\n ca = Puppet::Network::Handler.ca.new(:autosign => true)\n }\n\n # create a cert with a fake name\n key = nil\n csr = nil\n cert = nil\n hostname = \"test.domain.com\"\n assert_nothing_raised {\n cert = Puppet::SSLCertificates::Certificate.new(\n :name => \"test.domain.com\"\n )\n }\n\n # make the request\n assert_nothing_raised {\n cert.mkcsr\n }\n\n # and get it signed\n certtext = nil\n cacerttext = nil\n assert_nothing_raised {\n certtext, cacerttext = ca.getcert(cert.csr.to_s)\n }\n\n # they should both be strings\n assert_instance_of(String, certtext)\n assert_instance_of(String, cacerttext)\n\n # and they should both be valid certs\n assert_nothing_raised {\n OpenSSL::X509::Certificate.new(certtext)\n }\n assert_nothing_raised {\n OpenSSL::X509::Certificate.new(cacerttext)\n }\n\n # and pull it again, just to make sure we're getting the same thing\n newtext = nil\n assert_nothing_raised {\n newtext, cacerttext = ca.getcert(\n cert.csr.to_s, \"test.reductivelabs.com\", \"127.0.0.1\"\n )\n }\n\n assert_equal(certtext,newtext)\n end",
"def export_as_apa_citation_txt\n apa_citation(to_marc)\n end",
"def quote(character: T.unsafe(nil)); end",
"def quote(character: T.unsafe(nil)); end",
"def quote(character: T.unsafe(nil)); end",
"def my_quote\n\tend",
"def make_ca(config, verbose=false)\n unless config['certmaker'].has_key? 'customgoodca'\n puts \"CertMaker does not have a 'customgoodca' entry, so a CA will be regenerated every time.\"\n return\n end\n\n cacert = config['certmaker']['customgoodca']['certfile']\n cakey = config['certmaker']['customgoodca']['keyfile']\n\n if File.exist? cacert and File.exist? cakey\n puts \"CA and CA's key already exist.\"\n elsif File.exist? cacert and not File.exist? cakey\n raise \"CA certificate exists, but the key file does not exist?!\"\n elsif not File.exist? cacert and File.exist? cakey\n raise \"CA certificate does not exist, but the key file exists?!\"\n else\n puts \"Generating a new CA\"\n cacertdir = File.dirname(config['certmaker']['customgoodca']['certfile'])\n FileUtils.mkdir_p cacertdir, :verbose => verbose\n cakeydir = File.dirname(config['certmaker']['customgoodca']['keyfile'])\n FileUtils.mkdir_p cakeydir, :verbose => verbose\n csg = CertificateSuiteGenerator.new(config['certs'], config['hostname'], config['certmaker'])\n csg.generate_certificate('goodca',config['certs']['goodca'])\n cadata = csg.certificates['goodca']\n File.open(cacert,\"wb\") { |f| f.write cadata[:cert] }\n File.open(cakey,\"wb\") { |f| f.write cadata[:key] }\n puts \"New CA generated.\"\n puts \"Make sure you remove or comment out the passphrase in config.yml if you had one previously set!\"\n end\n end",
"def ca_file; end",
"def ca_file; end",
"def quote1(opts)\n \"'#{opts[:text]}'\"\n end",
"def test_CC_copyright_statement\n data = \"CC -----------------------------------------------------------------------\nCC Copyrighted by the UniProt Consortium, see http://www.uniprot.org/terms\nCC Distributed under the Creative Commons Attribution-NoDerivs License\nCC -----------------------------------------------------------------------\"\n sp = SPTR.new(data)\n assert_equal({}, sp.cc)\n end",
"def build_email_kase(options={})\n EmailKase.new({\n :kase => self,\n :subject => \"%{name} wants to know what you think\".t % {:name => self.person.casualize_name}\n }.merge(options))\n end",
"def tex_quote\n to_s.tex_quote\n end",
"def subject\n @subject=EzCrypto::Name.new(@cert.subject) unless @subject\n @subject\n end",
"def quote2(opts)\n \"„#{opts[:text]}”\"\n end",
"def endorsement_cert\r\n raw_cert = tag[Tem::ECert.ecert_tag_key].pack('C*')\r\n OpenSSL::X509::Certificate.new raw_cert\r\n end",
"def create_account_card\n tmp = Card.create! name: \"Company+scratch\"\n tmp.update! name: \"Company+*account\"\n end",
"def quote_text\n extract_text(@element.content).tap do |text|\n if @element.caption&.any?\n text << \" --#{extract_text(@element.caption)}\\n\"\n end\n end\n end",
"def export_as_chicago_citation_txt\n get_citation_style(:chicago)&.html_safe || super # TODO:CMOS for non-MARC\n end",
"def create_self_signed_cert(bits, cn, comment)\n rsa = OpenSSL::PKey::RSA.new(bits)\n cert = OpenSSL::X509::Certificate.new\n cert.version = 2\n cert.serial = 1\n name = OpenSSL::X509::Name.new(cn)\n cert.subject = name\n cert.issuer = name\n cert.not_before = Time.now\n cert.not_after = Time.now + (365*24*60*60)\n cert.public_key = rsa.public_key\n cert.sign(rsa, OpenSSL::Digest::SHA1.new)\n return [cert, rsa]\nend",
"def create_self_signed_cert(bits, cn, aliases, comment)\n rsa = OpenSSL::PKey::RSA.new(bits)\n cert = OpenSSL::X509::Certificate.new\n cert.version = 2\n cert.serial = Time.now.to_i % (1 << 20)\n name = OpenSSL::X509::Name.new(cn)\n cert.subject = name\n cert.issuer = name\n cert.not_before = Time.now\n cert.not_after = Time.now + (365 * 24 * 60 * 60)\n cert.public_key = rsa.public_key\n\n ef = OpenSSL::X509::ExtensionFactory.new(nil, cert)\n ef.issuer_certificate = cert\n cert.extensions = [\n ef.create_extension('basicConstraints', 'CA:FALSE'),\n ef.create_extension('keyUsage', 'keyEncipherment'),\n ef.create_extension('subjectKeyIdentifier', 'hash'),\n ef.create_extension('extendedKeyUsage', 'serverAuth'),\n ef.create_extension('nsComment', comment)\n ]\n aki = ef.create_extension('authorityKeyIdentifier',\n 'keyid:always,issuer:always')\n cert.add_extension(aki)\n cert.add_extension ef.create_extension('subjectAltName', aliases.map { |d| \"DNS: #{d}\" }.join(','))\n\n cert.sign(rsa, OpenSSL::Digest.new('SHA256'))\n\n [cert, rsa]\n end",
"def quote\n fetch('v_for_vendetta.quotes')\n end"
] |
[
"0.5664664",
"0.5629879",
"0.5611972",
"0.5579369",
"0.5542708",
"0.5536832",
"0.55252475",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.55250984",
"0.5515826",
"0.5502712",
"0.5495705",
"0.54807884",
"0.54365945",
"0.5431867",
"0.52742463",
"0.5271237",
"0.526624",
"0.5258949",
"0.5256961",
"0.5228209",
"0.5225447",
"0.5208131",
"0.5201312",
"0.5190904",
"0.5190904",
"0.51899683",
"0.51842475",
"0.5166457",
"0.5130918",
"0.5130918",
"0.5123424",
"0.5059553",
"0.50390697",
"0.5000881",
"0.49879968",
"0.498177",
"0.4973977",
"0.4966968",
"0.49646786",
"0.49533075",
"0.49493665",
"0.49490792",
"0.49392948"
] |
0.0
|
-1
|
Get all possible status.
|
def all_status
status = Status.all
return render_json_response(status, :ok)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def statuses\n api.get('status')\n end",
"def status_enum\n status_list\n end",
"def statuses; end",
"def statuses\n statuses = {\n \"Not started\" => 1,\n \"In Progress\" => 2,\n \"Finished\" => 3\n }\n return statuses\n end",
"def list_possible_status_ids\n\tstatustypes = @client.Status.all\n\tstatustypes.each do |status|\n\t\tputs \"#{status.id}\\t#{status.name}\"\n\tend\nend",
"def status_enum\n [\n [STATUSES.active],\n [STATUSES.resolved],\n [STATUSES.cancelled],\n [STATUSES.deleted]\n ]\n end",
"def all\n [ACTIVE, PENDING]\n end",
"def status(*status)\n all.select { |b| status.include?(b.status) }\n end",
"def statuses\n Sifter.\n get(\"/api/statuses\").\n parsed_response[\"statuses\"]\n end",
"def statuses\n request(:get, \"applicant_tracking/statuses\")\n end",
"def getStatus\n @@statuses[@status]\n end",
"def get_sensor_statuses\n response = @db_client.query( \"SELECT name,status,updated_time,enabled,type,dismiss,verbose FROM #{SENSOR_STATUS}\" )\n return response.entries\n end",
"def status\n STATUSES[self.status_id]\n end",
"def status_info\n current_path = '/api/v1/status'\n @conn.get(current_path)\n end",
"def statuses\n list = Array.new\n\n if @db != nil\n is_ok = false\n\n begin\n stm = @db.prepare( 'SELECT qStatus FROM qryResults GROUP BY qStatus ORDER BY qStatus')\n rs = stm.execute\n\n rs.each do |row|\n list.push row['qStatus']\n end\n\n stm.close\n is_ok = true\n rescue ::SQLite3::Exception => e\n Maadi::post_message(:Warn, \"Repository (#{@type}:#{@instance_name}) encountered an SELECT Status Codes error (#{e.message}).\")\n end\n end\n\n return list\n end",
"def statuses\n return ['canceled', 'completed'] if self.status == 'paid'\n return ['canceled', 'paid'] if self.status == 'ordered'\n end",
"def statuses\n calculated = Array(read_attribute(:statuses))\n calculated.delete(Contact::OK)\n calculated.delete(Contact::LINKED)\n calculated << Contact::OK if calculated.empty?# && valid?\n calculated << Contact::LINKED if linked?\n\n calculated.uniq\n end",
"def status\n STATUSES[self.status_id || 0]\n end",
"def status\n @status ||= STATUS[mapping_for(:status)]\n end",
"def status\n @status ||= STATUS[mapping_for(:status)]\n end",
"def all\n f = options[:format]\n a = options[:agency]\n ::Taxi::Status.list_all(format: f, agency: a)\n end",
"def possible_statuses\n\t\tcase self.status\n\t\twhen 'pending'\n\t\t\t['granted', 'denied']\n\t\twhen 'granted'\n\t\t\t['revoked']\n\t\twhen 'denied'\n\t\t\t['granted']\n\t\twhen 'revoked'\n\t\t\t['granted']\n\t\telse\n\t\t\t[]\n\t\tend\n\tend",
"def statuses\n lifecycle.statuses\n end",
"def get_status\n\t\tstatus\n\tend",
"def status(*options)\n # TODO: this is *not* how it's supposed to work. This will only give the\n # status of all *running* instances. There is no way to define what is\n # /supposed/ to be running ATM, though.\n statuses = []\n self.instances.each {|instance| statuses << instance.to_s}\n \n return statuses\n end",
"def status_detail\n @status_detail ||= []\n end",
"def index\n @entity_statuses = EntityStatus.all\n end",
"def status\n get_json('status.json')\n end",
"def list_status\n if self.available_on.nil?\n nil\n elsif self.tba?\n 'TBA'\n elsif self.upcoming?\n 'Upcoming'\n elsif self.new?\n 'New'\n elsif self.recent?\n 'Recent'\n elsif self.backlist?\n 'Backlist'\n else\n nil\n end\n end",
"def status\n request :get, \"_status\"\n end",
"def status\n get('/api/status')\n end",
"def collect_statuses\n ret = []\n versions.each do |v|\n s = v.statuses\n if s.exist?\n v.statuses.each do |status|\n ret << [status[\"key\"], status[\"value\"]]\n end\n end\n end\n ret\n end",
"def statuses\n aux = WorkOrderStatus.all\n render json: serialized_work_order_statuses(aux)\n end",
"def get_statuses\n\t\t# scrape the statuses web page (more convenient than looking up an API)\n\t\t\n\t\turl = CONFIG[\"statuses URL\"]\n\t\tdoc = Nokogiri::HTML( open(url) )\n\t\tprojects = doc.css('.project')\n\t\t\n\t\tproject_statuses = projects.map do |project|\n\t\t\t{\n\t\t\t\tid_num: begin\n\t\t\t\t\tid = project.attr('id') #=> \"project_6\"\n\t\t\t\t\tid.match(/\\d+/).to_s.to_i\n\t\t\t\tend,\n\t\t\t\tname: begin\n\t\t\t\t\tproject.at_css('h3 a').content.strip\n\t\t\t\tend,\n\t\t\t\tbuild_status: begin\n\t\t\t\t\tclasses = project.attr('class').split #=> \"status_build_failed project\"\n\t\t\t\t\tbuild_status_class_common_prefix = 'status_'\n\t\t\t\t\tbuild_status_class = classes.find { |klass| klass.start_with?(build_status_class_common_prefix) }\n\t\t\t\t\tbuild_status_class.sub(build_status_class_common_prefix, '').to_sym\n\t\t\t\tend,\n\t\t\t}\n\t\tend\n\t\t\n\t\treturn project_statuses.sort_by { |status| status[:id_num] }\n\tend",
"def statuses\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Available\", \"2\" => \"On Hold\", \"3\" => \"Borrowed\", \"4\" => \"Unavailable\"}}, :status => 200\n\t\treturn\n\tend",
"def getStatus\n @status\n end",
"def status\n service.get(\"\")\n end",
"def index\n @statuses = Status.all\n end",
"def index\n @statuses = Status.all\n end",
"def status\n response = JSON.parse(@client.get(\"items/#{send(:id)}/status\").body)\n response['items']\n end",
"def status\n response = JSON.parse(@client.get(\"items/#{send(:id)}/status\").body)\n response['items']\n end",
"def status\n response = JSON.parse(@client.get(\"items/#{send(:id)}/status\").body)\n response['items']\n end",
"def retrieve_status\n \n end",
"def statuses\n @repo ||= pr_json.base.repo.full_name\n @sha ||= head_commit\n statuses = {}\n api.statuses(@repo, @sha).each do |status|\n statuses[status.context] ||= []\n statuses[status.context].push(context: status.context,\n state: status.state,\n date: status.updated_at)\n end\n statuses.map do |_, val|\n val.sort { |a, b| b[:date] <=> a[:date] }[0]\n end\n end",
"def statuses( params={} )\n statuses = get_connections(\"statuses\", params)\n return map_connections statuses, :to => Facebook::Graph::Statuse\n end",
"def status\n @status\n end",
"def status\n @status\n end",
"def cmd_list_by_status argv\n setup argv\n status = @hash['status']\n response = @api.list_by_status(status)\n if response.is_a?(Array)\n response.each do | r |\n msg r\n end\n else\n msg response\n end\n end",
"def status\n @status\n end",
"def status\n @status\n end",
"def get_status\n @connection.get(\"/\").body\n end",
"def index\n @barrel_statuses = BarrelStatus.all\n end",
"def index\n @project_statuses = Project::Status.all\n end",
"def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end",
"def status\n fixity_graph.query({ predicate: premis_status_predicate }).map(&:object) +\n fixity_graph.query({ predicate: fedora_status_predicate }).map(&:object)\n end",
"def statuses( params={} )\n statuses = get_connections(\"statuses\", params)\n return map_connections statuses, :to => Facebook::Graph::Generic\n end",
"def set_common_data\n @statuses = Status.all\n end",
"def getStatus\n call(STATUS_PATH)\n end",
"def vital_statuses\n\t\t([self.vital_status] + VALID_VITAL_STATUSES ).compact.uniq\n\tend",
"def index\n @status_requests = StatusRequest.all\n end",
"def status()\n return [true, [], [], []] if not self.jobids.any?\n \n statuses = GridVid.query(@_keys.merge({:jobids => self.jobids}))\n passed = []\n running = [] \n failed = [] \n \n statuses.each_pair {|jobid, val|\n case val['status']\n when \"PASS\"\n passed << val['jobid'] \n when \"FAILED\" \n failed << val['jobid'] \n else\n running << val['jobid'] \n end \n }\n \n return [running.length == 0, passed, failed, running] \n end",
"def available_transitions\n status_available = respond_to?(:status) && status!=nil\n return {:allow => []} unless status_available\n self.class.states[self.status.to_sym] || {:allow => []}\n end",
"def status_information\n %i[unknown warning critical].map do |status|\n results[status].map { |result| \"#{status.upcase}: #{result}\" }\n end.flatten.compact.join(\"\\n\")\n end",
"def index\n @status = Status.last || Status.new(available: \"unavailable\", created_at: DateTime.now)\n end",
"def status_infos\n @dbi.status_infos\n end",
"def status_infos\n @dbi.status_infos\n end",
"def status_flags\n\tstatus_bits_to_flags(self.status)\n end",
"def index\n @enable_habits = Habit.available_by_user(current_user).status_enabled\n @disable_habits = Habit.available_by_user(current_user).status_disabled\n @close_habits = Habit.available_by_user(current_user).status_done\n end",
"def get_voting_statuses\n if voting_in_person?\n statuses = Status.voting_in_person_statuses\n else\n statuses = Status.voting_absentee_statuses\n end\n \n # Time for special cases!!\n case self.voting_state.name\n when \"North Dakota\" # ND doesn't have voter registration\n statuses = statuses.reject { |status| status.name =~ /Registration/ }\n when \"Oregon\" # OR always votes absentee, no need to show it\n statuses = statuses.reject { |status| status.name =~ /Absentee/ }\n end\n statuses\n end",
"def index\n @rh21_statuses = Rh21Status.all\n end",
"def get_status\n status = {}\n\n status[:noop] = @noop\n status[:tags] = @tags unless @tags.nil?\n status[:state] = @state\n status[:report_errors] = @report_errors\n status[:errors] = @errors\n status[:expired_executions] = @expired_executions\n status[:update_time] = Time.now.to_i\n status[:pid] = Process.pid\n\n unless @backtrace.nil?\n status[:backtrace] = @backtrace\n end\n\n unless @summary.nil?\n status[:summary] = @summary\n end\n\n unless @method.nil?\n status[:method] = @method\n end\n\n status\n end",
"def managed_app_statuses\n return @managed_app_statuses\n end",
"def statuses_presented\n statuses.join(\", \")\n end",
"def statuses\n data = redis.zrevrange(key(:uuid, @uuid), 0, -1) || []\n data.map { |datum| decode(datum) }\n end",
"def global_status\n status_counts = @count.values_at(*BareTest::StatusOrder)\n most_important_status = BareTest::StatusOrder.zip(status_counts) { |status, count|\n break status if count > 0\n } || :success\n end",
"def status_codes\n STATUS_CODES\n end",
"def statuses_911\n statuses_911_list ? statuses_911_list.collection : []\n end",
"def status\n instance_get(:status)\n end",
"def index\n @vacancy_request_statuses = VacancyRequestStatus.all\n end",
"def status\n\t\treturn @status\n\tend",
"def status\n @status ||= @repo.status(:unknown => true)\n end",
"def status\n end",
"def status\n end",
"def status\n end",
"def status\n end",
"def zmiany_statusow\n\tstatusy=[]\n\twhile(!@kolejka_statusow.empty?)\n\t\tstatus=@kolejka_statusow.pop(true) rescue nil\n\t\tbreak if status.nil?\n\t\tstatusy << status\n\t\tyield status if block_given?\n\tend\n\tstatusy\n end",
"def getStatus\r\n\t\t\t\t\treturn @status\r\n\t\t\t\tend",
"def getStatus()\n params = Hash.new\n return doCurl(\"get\",\"/status\",params)\n end",
"def status_options\n [\n {label: 'To-do', value: 'todo'},\n {label: 'In Progress', value: 'inprogress'},\n {label: 'To Verify', value: 'toverify'},\n {label: 'Done', value: 'done'}\n ]\n end",
"def status\n @transactions.empty? ? nil : @transactions.collect(&:status).uniq\n end",
"def status\n inspect\n end",
"def index\n @check_vehicle_statuses = CheckVehicleStatus.all\n end",
"def item_statuses\n # The previous mapping wasn't always in order\n # I18n.t(:history_actions).map { |key, value| [ value ] } \n # Retrieve translations and sort\n items = I18n.t(:item_status)\n items.map { |key, value| [ value, key ] } \n end",
"def status\n value_for('status')\n end",
"def index\n @call_statuses = CallStatus.all\n end",
"def status(*) end",
"def index\n @sa_request_statuses = SaRequestStatus.all\n end",
"def index\n @project_statuses = ProjectStatus.all\n end",
"def collectRunStatus(_syncP = false, _nth = :all)\n _statusList = [] ;\n doWithNthRun(_nth){|_run|\n sync(_run) if(_syncP) ;\n _statusList.push(_run.status) ;\n }\n return _statusList ;\n end",
"def examples_statuses\n STATUSES\n end"
] |
[
"0.809433",
"0.7732141",
"0.7430762",
"0.742711",
"0.737841",
"0.7299032",
"0.7242177",
"0.7125727",
"0.6745043",
"0.6709533",
"0.66951156",
"0.66534764",
"0.66389066",
"0.6620211",
"0.660402",
"0.6602061",
"0.6578015",
"0.657234",
"0.6551321",
"0.6551321",
"0.6545473",
"0.65320456",
"0.653088",
"0.6489511",
"0.6482645",
"0.6480548",
"0.6429003",
"0.641598",
"0.64072317",
"0.6406053",
"0.6389662",
"0.6377088",
"0.6368096",
"0.63671064",
"0.6352344",
"0.6351606",
"0.63515943",
"0.6337478",
"0.6337478",
"0.6333166",
"0.6333166",
"0.6333166",
"0.6322825",
"0.6314087",
"0.6297758",
"0.6295757",
"0.6295757",
"0.6289818",
"0.6280541",
"0.6280541",
"0.62778366",
"0.62776905",
"0.6273635",
"0.62459344",
"0.62332726",
"0.6230996",
"0.6228005",
"0.620722",
"0.6173187",
"0.6166382",
"0.6163876",
"0.6146366",
"0.6138252",
"0.61350846",
"0.6129846",
"0.6129846",
"0.612764",
"0.611833",
"0.6113465",
"0.61039627",
"0.60820204",
"0.607024",
"0.6061136",
"0.6057938",
"0.6055771",
"0.6054979",
"0.6052879",
"0.60516596",
"0.6051314",
"0.6050283",
"0.60492367",
"0.6049094",
"0.6049094",
"0.6049094",
"0.6049094",
"0.6049056",
"0.6047635",
"0.6031216",
"0.60288143",
"0.60274464",
"0.6025035",
"0.60223925",
"0.601374",
"0.6009405",
"0.59997773",
"0.5992935",
"0.59912044",
"0.59892064",
"0.5987421",
"0.5984702"
] |
0.76213694
|
2
|
Get all quotes of a particular customer.
|
def particular_customer_quotes
offset = 0
filter = "%"
if (params[:offset].class.to_s != "NilClass" && params[:offset].integer?)
offset = params[:offset].to_i
end
if (params[:filter].class.to_s != "NilClass")
filter = "%" + params[:filter] + "%"
end
# lstQuotes = Quote.includes(:dispatcher, :customer, :status).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])
# it should be this query which is written down
lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(idClient: params[:no]).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])
# lstQuotes = Quote.includes(:dispatcher, :customer, :status).where("(note like ? OR status.name LIKE ? OR dispatcher.firstName LIKE ? OR dispatcher.lastName LIKE ? OR reference LIKE ? ) AND idClient = ?", filter, filter, filter, filter, filter, params[:no]).order('DESC').offset(offset).limit(30)
# lstQuotes.each do |quote|
# # TODO! Format each quote before send it.
# end
return render_json_response(lstQuotes, :ok)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_customers()\n customers = Customer.where(company_id: self.id).order(:name)\n\n return customers\n end",
"def get_customers()\n customers = Customer.where(company_id: self.id).order(:name)\n\n return customers\n end",
"def get_customers()\n customers = Customer.where(company_id: self.id).order(:name)\n\n return customers\n end",
"def get_customers\n return ShopifyAPI::Customer.all\n end",
"def get_all_customers\r\n begin\r\n @logger.info(\"get_all_customers called.\")\r\n\r\n # prepare query url\r\n @logger.info(\"Preparing query URL for get_all_customers.\")\r\n _query_builder = Configuration.get_base_uri().clone\r\n _query_builder << '/customers'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n @logger.info(\"Preparing headers for get_all_customers.\")\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # prepare and execute HttpRequest\r\n @logger.info('Preparing and executing HttpRequest for get_all_customers.')\r\n _request = @http_client.get _query_url, headers: _headers\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request, name: 'get_all_customers')\r\n validate_response(_context)\r\n\r\n # return appropriate response type\r\n @logger.info(\"Returning response for get_all_customers.\")\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n return decoded.map{|element| CustomerModel.from_hash(element)}\r\n\r\n rescue Exception => e\r\n @logger.error(e)\r\n raise e\r\n end\r\n end",
"def customer_list\n perform_get_request('/customer/list')\n end",
"def all(options = { page: 1, page_size: 10 })\n response = JSON.parse(@client.get('Customers', options).body)\n customers = response.key?('Items') ? response['Items'] : []\n customers.map { |attributes| Unleashed::Customer.new(@client, attributes) }\n end",
"def customers(options = {})\n perform_get_with_object('/customers', options, Epages::CustomersResponse)\n end",
"def customers()\n sql = \"SELECT DISTINCT customers.* FROM customers\n INNER JOIN tickets\n ON customers.id = tickets.customer_id\n WHERE tickets.screening_id = $1;\"\n values = [@id]\n customers_array = SqlRunner.run(sql, values)\n return Customer.map_to_objects(customers_array)\n end",
"def all(params = {})\n handle_all_request(\"/customers\", :customers, params)\n end",
"def all(params = {})\n req = WebPay::BasicListRequest.create(params)\n raw_response = @client._request(:get, 'customers', req)\n WebPay::CustomerResponseList.new(raw_response)\n end",
"def list_customers(opts = {})\n operation('ListCustomers')\n .add(opts)\n\n run\n end",
"def customers()\n sql = \"SELECT customers.* FROM customers INNER JOIN tickets ON customers.id = tickets.customer_id WHERE film_id = $1\"\n values = [@id]\n customer_data = SqlRunner.run(sql, values)\n return Customer.map_items(customer_data)\n end",
"def customers()\n sql = \"SELECT DISTINCT customers.* FROM customers\n INNER JOIN tickets ON customers.id = tickets.customer_id\n INNER JOIN screenings ON tickets.screening_id = screenings.id\n WHERE screenings.film_id = $1;\"\n values = [@id]\n customers_array = SqlRunner.run(sql, values)\n return Customer.map_to_objects(customers_array)\n end",
"def customers()\n sql = \"SELECT customers.* FROM customers INNER JOIN tickets ON customers.id = tickets.cust_id WHERE tickets.film_id = $1\"\n values = [@id]\n customers = SqlRunner.run(sql, values)\n return customers.map{|cust| Customer.new(cust)}\n end",
"def customers\n ShopifyAPI::Customer.all\n end",
"def all_customers()\n sql = \"SELECT customers.* FROM customers\n INNER JOIN tickets on customers.id = tickets.customer_id\n WHERE tickets.film_id = $1\"\n values = [@id]\n result = SqlRunner.run(sql, values) #array of hashes\n booked_customers = result.map { |customer| Customer.new(customer)}\n return booked_customers\n end",
"def customers\n sql = \"SELECT customers.* FROM customers\n INNER JOIN tickets ON customers.id = tickets.customer_id\n WHERE tickets.film_id = $1\"\n values = [@id]\n result = SqlRunner.run(sql, values)\n array_of_customer_objects = result.map {|row_hash| Customer.new(row_hash)}\n return array_of_customer_objects\n end",
"def customers\n Easybill::Api::Customers\n end",
"def customers()\n sql = \"SELECT customers.*\n FROM customers\n INNER JOIN tickets\n ON customers.id = tickets.customer_id\n WHERE film_id = $1\"\n values = [@id]\n star_data = SqlRunner.run(sql, values)\n return Star.map_items(star_data)\n end",
"def get_customer_order\n begin\n db = SQLite3::Database.open(ENV[\"BANGAZON\"])\n array_of_orders = db.execute(\"SELECT customers.id 'Customer Number', customers.last_name 'Last Name', customers.first_name 'First Name', orders.id 'Order Number', products.product_title 'Product', products.product_price 'Price'\n FROM orders, customers, order_products, products\n\n WHERE orders.customer_id = ?\n AND orders.id = ?\n AND order_products.product_id = products.id\", [@customer_id, @id])\n db.close\n end\n array_of_orders\n end",
"def get_customers(opts = {})\n data, _status_code, _headers = get_customers_with_http_info(opts)\n data\n end",
"def all_customers\n if @customer_records_file.nil? || !File.exist?(@customer_records_file)\n raise ArgumentError, 'Customer records file must be provided'\n end\n\n File.open(@customer_records_file, 'r') do |f|\n f.each_line.map do |line|\n JSON.parse(line)\n end\n end\n end",
"def customers()\n sql = \"SELECT customers.* FROM customers INNER JOIN tickets ON customers.id = tickets.customer_id INNER JOIN screenings ON screenings.id = tickets.screening_id INNER JOIN films ON films.id = screenings.film_id WHERE tickets.customer_id = $1\"\n values = [@id]\n customers = SqlRunner.run(sql, values)\n return Customer.map_customers(customers)\n end",
"def get_all_customers\n begin\n db = SQLite3::Database.open(ENV[\"BANGAZON\"])\n array_of_customers = db.execute (\"SELECT * FROM customers\")\n db.close\n rescue SQLite3::Exception => e\n p \"fail to get_all_customers! #{e}\"\n end\n array_of_customers\n end",
"def get_customers(opts = {})\n data, _status_code, _headers = get_customers_with_http_info(opts)\n return data\n end",
"def customers()\n sql = \"SELECT DISTINCT customers.*\n FROM customers\n INNER JOIN tickets\n ON tickets.customer_id = customers.id\n WHERE film_id = $1\"\n values = [@id]\n customer_hash = SqlRunner.run(sql, values)\n result = customer_hash.map {|customer| Customer.new(customer) }\n return result\n end",
"def all\n @customer_objects\n end",
"def customerGet(options={})\n assert_valid_keys(options, :customerId)\n assert_keys_exists(options, :customerId)\n execute(:customerGet, options)\n end",
"def customerGet(options={})\n assert_valid_keys(options, :customerId)\n assert_keys_exists(options, :customerId)\n execute(:customerGet, options)\n end",
"def get_customer_all_using_get(opts = {})\n data, _status_code, _headers = get_customer_all_using_get_with_http_info(opts)\n data\n end",
"def quote(options = {})\n post(\"customers/#{customer_id}/delivery_quotes\", options)\n end",
"def customers\n sql = \"SELECT customers.* FROM customers\n INNER JOIN tickets ON tickets.customer_id = customers.id\n WHERE tickets.film_id = $1\"\n values = [@id]\n customer_array = SqlRunner.run(sql, values)\n result = customer_array.map { |customer| Customer.new( customer ) }\n return result\n end",
"def index\n @quote_items = QuoteItem.where(order_id: current_customer.order_id)\n end",
"def customers()\n sql = \"SELECT customers.* FROM customers\n INNER JOIN tickets\n ON tickets.customer_id = customers.id\n WHERE tickets.screening_id = $1\"\n values = [@id]\n customers = SqlRunner.run(sql, values)\n return customers.map{|customer| Customer.new(customer)}\nend",
"def all_customers() # RETURN film1.all_customers (returns all customers attending that film)\n sql = \"SELECT customers.* FROM customers INNER JOIN tickets ON customers.id = tickets.customer_id\n WHERE tickets.film_id = $1\"\n values = [@id]\n customers = SqlRunner.run(sql, values)\n result = customers.map { |customer| Customer.new(customer) }\n return result\n end",
"def customerList(options = {})\n assert_valid_keys(options, :accessKey, :testMode, :from, :count)\n execute(:customerList, options)\n end",
"def customers\n sql = \"SELECT customers.* FROM customers INNER JOIN tickets ON tickets.customer_id = customers.id WHERE tickets.film_id = #{@id};\"\n return Customer.map_items(sql) \n end",
"def customer(options = nil)\n request = Request.new(@client)\n path = \"/authorization-requests/\" + CGI.escape(@id) + \"/customers\"\n data = {\n\n }\n\n response = Response.new(request.get(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"customer\"]\n customer = Customer(self._client)\n return_values.push(customer.fill_with_data(body))\n\n \n return_values[0]\n end",
"def all_orders(options)\n request :account, :get, 'allOrders', options\n end",
"def get_orders\n return ShopifyAPI::Order.all\n end",
"def get_customer(id)\n get(\"customers/#{id}\")\n end",
"def get_customer(id)\n get(\"customers/#{id}\")\n end",
"def customer(id)\n response = get(\"customers/#{id}\")\n response.customer\n end",
"def customer(customer_id)\n client.get \"customers/#{inst_id}/#{customer_id}\"\n end",
"def customer(customer_id)\n perform_get_request(\"/customer/#{customer_id}\")\n end",
"def customers\n @customers ||= new_resource(self, :customer, :customers)\n end",
"def customer(customer)\n id = epages_id(customer)\n perform_get_with_object(\"/customers/#{id}\", {}, Epages::Customer)\n end",
"def customers(data_keys = nil)\n data_keys ||= ::LoremIpsumNearby.config.result_data_keys\n @customers.map { |customer| customer.slice(*data_keys) }\n end",
"def customers\n sql = \"SELECT customers.*\n FROM customers INNER JOIN tickets\n ON tickets.customer_id = customers.id\n WHERE film_id = $1\"\n values = [@id]\n customers = SqlRunner.run(sql, values)\n return customers.map {|customer_hash| Customer.new(customer_hash)}\nend",
"def quotes(**args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/quotes/latest\", options: params.compact).tap do |resp|\n resp.body = [resp.body]\n end\n end",
"def orders_including_customer\n Spree::Order\n .joins(:order_cycle)\n .includes(:customer)\n .for_order_cycle(order_cycle)\n .completed\n .order('customers.name ASC')\n end",
"def show_customers\n sql = \"SELECT customers.* FROM films INNER JOIN screenings ON films.id = screenings.film_id INNER JOIN tickets ON screenings.id = tickets.screening_id INNER JOIN customers on tickets.customer_id = customers.id WHERE films.id = $1\"\n values = [@id]\n result = SqlRunner.run(sql, values)\n return result.map {|customer| Customer.new(customer)}\n end",
"def customer()\n sql = \"SELECT customers.* from customers INNER JOIN tickets on\n customers.id = tickets.customer_id WHERE film_id = $1 \"\n values = [@id]\n results = SqlRunner.run(sql, values)\n results.map {|result| Customer.new(result)}\n end",
"def list(options = {})\n get(\"customers/#{customer_id}/deliveries\", options)\n end",
"def list_customer(custid = nil, email = nil)\r\n\r\n raise ArgumentError.new('Customer Id and email are nil.') if custid.nil? && email.nil?\r\n \r\n suburl = \"&action=list_customer&nodocs=1\" \r\n \r\n if !custid.nil? && email.nil?\r\n suburl << \"&custid=\" + custid.to_s\r\n elsif custid.nil? && !email.nil? \r\n suburl << \"&email=\" + email\r\n elsif !custid.nil? && !email.nil?\r\n suburl << \"&custid=\" + custid.to_s + \"&email=\" + email\r\n end\r\n\t \r\n call_target_url(suburl) # call private method\r\n\r\n end",
"def index\n @customer = current_customer\n @orders = current_customer.orders.all.order(created_at: :desc)\n end",
"def customer\n @orders = Spree::Order.where(user_id: current_spree_user.id, state: 'complete').where.not(shipment_state: 'shipped', state: 'returned').order(created_at: :desc)\n end",
"def index\n @customers = Customer.where(order_id: params[:order_id])\n @order = Order.find(params[:order_id])\n end",
"def customerGet(options = {})\n assert_valid_keys(options, :accessKey, :testMode, :customerId)\n assert_keys_exists(options, :customerId)\n execute(:customerGet, options)\n end",
"def listall\n return render :json => Customer.all.as_json(:only => [:id, :custID, :interested, :bought])\n end",
"def invoiced_orders\n return [] if !is_client?\n client.orders\n end",
"def quotations\n response = self.class.get('/quotations', OPTIONS)\n\n if response.success?\n parse_quotations(response)\n else\n []\n end\n end",
"def orders\n @title = \"Your Orders\"\n @orders = @customer.orders.paginate(\n :page => params[:page],\n :per_page => 10\n )\n end",
"def customer(q)\n Customer.find(self, q)\n end",
"def index\n @customer_order_items = CustomerOrderItem.all\n end",
"def customer\n @customer = Customer.order(name: :asc)\n end",
"def index\n\t@customers = Customer.all()\n end",
"def index\n @customers = Stripe::Customer.all(:limit => 100)\n end",
"def index\r\n @sales_orders = @customer.sales_orders\r\n end",
"def customer\n @customer ||= fetcher.get(Customer, customer_id)\n end",
"def get_customer(opts = {})\n data, _status_code, _headers = get_customer_with_http_info(opts)\n data\n end",
"def orders\n return [] if !is_client?\n client.orders\n end",
"def customer() #in the tickets (join) table so we can grab customer_id easily, the _id's are already bundled in this table\n sql = \"SELECT * FROM customers WHERE id = $1\"\n values = [@customer_id]\n customer = SqlRunner.run(sql, values).first\n return Customer.new(customer)\n end",
"def quotes\n fetch('community.quotes')\n end",
"def customer\n @@all.select {|review| self.restaurant.customers}\n end",
"def customer()\n sql = \"SELECT * FROM customers INNER JOIN rentals ON rentals.customer_id\n = customers.id WHERE rentals.id = $1\"\n values = [@id]\n result = SqlRunner.run(sql, values)[0]\n return Customer.new(result)\n end",
"def get_customers\n \n # Go to the Customers tool\n goto_tool 'redetrack/bin/manager'\n \n # Extract the table as a RubyExcel::Sheet\n s = RubyExcel::Workbook.new.load( Nokogiri::HTML( agent.page.body ).css( 'tr' ).map { |row| row.css('th,td').map { |cell| cell.nil? ? nil : cell.text.gsub( /\\s+/, ' ' ).strip } } )\n \n # Remove the buttons and blank rows\n s.row(2).delete\n s.compact!\n \n # Store the account details in a Hash by :name and :customer\n h = Hash.new({})\n s.rows(2) do |row|\n name = ( row['D'].empty? ? 'Other' : row['D'] )\n customer = ( row['E'].empty? ? 'Other' : row['E'] )\n h[ row['C'].upcase ] = { name: name, customer: customer }\n end\n h\n end",
"def customer_single_orders\n @orders = Order.where(customer_id: current_user.customer_id, category: :single)\n render json: @orders, status: 200\n\n end",
"def index\n @my_customers = MyCustomer.all\n end",
"def find(id)\n response = JSON.parse(@client.get(\"Customers/#{id}\").body)\n Unleashed::Customer.new(@client, response)\n end",
"def index\n @customers = Customer.where(user_id: current_user.id)\n end",
"def customer_filter\n customers = current_user.company.resources.map { |r| r.customer }\n customers = customers.compact.uniq.sort_by { |c| c.name.downcase }\n\n return filter_for(:customer_id, objects_to_names_and_ids(customers),\n session[:resource_filters], _(\"Customer\"))\n end",
"def index\n if params[:search_term]\n customers = Customer.search_customer(params[:search_term])\n else\n if read_from_cache(\"customers\")\n customers = read_from_cache(\"customers\")\n else\n customers = apply_scopes(Customer).all\n write_to_cache(\"customers\", customers)\n end\n end\n\n if params[:page_no]\n result = pagy(customers)\n else\n result = customers\n end\n render :json => result\n end",
"def orders\n params = { command: 'account_orders' }\n get('/json.php', params)\n end",
"def list\n display_customers\n end",
"def index\n # uses the customer_orders scope to retrieve all the orders that the current customer has made\n @orders = Order.customer_orders(current_customer)\n # uses the customer_average_order_cost scope to calculate the average cost of all the orders that the\n # current customer has made\n @average_cost_of_orders = Order.customer_average_order_cost(current_customer)\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def index\n @customers = Customer.all\n end",
"def list_customers(authorization, opts = {})\n data, _status_code, _headers = list_customers_with_http_info(authorization, opts)\n return data\n end"
] |
[
"0.71521217",
"0.71521217",
"0.71521217",
"0.71171844",
"0.7053067",
"0.69887656",
"0.69722396",
"0.6859832",
"0.6850377",
"0.6752485",
"0.6670968",
"0.6610085",
"0.65651894",
"0.65310913",
"0.6528366",
"0.6511401",
"0.6506537",
"0.6476576",
"0.6470181",
"0.6429302",
"0.6423347",
"0.64111304",
"0.6402155",
"0.6380702",
"0.637734",
"0.637166",
"0.63470244",
"0.63022435",
"0.62908137",
"0.62908137",
"0.6288358",
"0.62622094",
"0.6220022",
"0.62028027",
"0.61952835",
"0.61867905",
"0.6161391",
"0.615874",
"0.613536",
"0.613436",
"0.6096673",
"0.6094578",
"0.6094578",
"0.60850835",
"0.60780954",
"0.60741097",
"0.6046674",
"0.6039657",
"0.602338",
"0.6002986",
"0.59878445",
"0.59808904",
"0.59717566",
"0.59670436",
"0.5948513",
"0.58906317",
"0.58807486",
"0.5816035",
"0.57994765",
"0.57984275",
"0.5793728",
"0.5768918",
"0.57683945",
"0.57634765",
"0.57581264",
"0.57522917",
"0.5734332",
"0.5724472",
"0.5722046",
"0.5702315",
"0.5700686",
"0.56928426",
"0.56899786",
"0.56828225",
"0.5671533",
"0.5662139",
"0.5657131",
"0.56258225",
"0.56222075",
"0.5604024",
"0.559646",
"0.5594483",
"0.55927896",
"0.55906457",
"0.5588249",
"0.5588",
"0.55825377",
"0.55810416",
"0.55810416",
"0.55810416",
"0.55810416",
"0.55810416",
"0.55810416",
"0.55810416",
"0.55810416",
"0.55810416",
"0.55810416",
"0.55810416",
"0.55810416",
"0.5579164"
] |
0.70744073
|
4
|
0 counts as positive sign
|
def same_sign?(number, number2)
return (number * number2 > 0 or (number >= 0 and number2 >= 0))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sign\n return -1 if self < 0\n return 1 if self > 0\n return 0\n end",
"def sign(v) \n if(v > 0)\n +1\n elsif(v < 0)\n -1\n else\n 0\n end\nend",
"def zero?; end",
"def zero?; end",
"def nozero(num)\n num > 0 ? -num : num \nend",
"def zero?() end",
"def zero?() end",
"def signum x\n return -1 if x < 0\n return 1 if x > 0\n return 0\n end",
"def zero?\n end",
"def zero(z = nil)\nif z == nil then return 0 end\nif z[0] == \"+\" then return z[1] end\nif z[0] == \"-\" then return 0 - z[1] end\nif z[0] == \"*\" then return 0 end\nif z[0] == \"/\" then return 0.00 end\nend",
"def zero?(a)\n a == 0\n end",
"def zero?\n value == 0 \n end",
"def sign(x)\n big_dec_sign = x.sign\n if big_dec_sign < 0\n -1\n elsif big_dec_sign > 0\n +1\n end\n end",
"def positive; end",
"def positive; end",
"def neg?\n sign < 0\n end",
"def positive?\n self > ZERO\n end",
"def negative?\n self < 0\n end",
"def nonnegative?\n return self >= 0\n end",
"def negative?\n return self < 0\n end",
"def negative?\n self < ZERO\n end",
"def above_zero(value)\n value.negative? ? 0 : value\n end",
"def negative?\n self <= 0\n end",
"def nonpositive?\n return self <= 0\n end",
"def negative(num)\r\n num > 0 ? -num : num \r\nend",
"def normalize_zero(x)\n return x if x.zero?\n\n return x - 1 if x > 0\n x + 1\n end",
"def negative(num)\n num < 0 ? num : -1 * num\nend",
"def plusMinus(arr)\n posCount = 0\n negCount = 0\n\n arr.each do |e|\n if e < 0\n negCount += 1\n elsif e > 0\n posCount += 1\n end\n end\n\n len = arr.length*1.0\n posProp = posCount/(len)\n negProp = negCount/(len)\n zeroProp = 1 - posProp - negProp\n\n puts posProp\n puts negProp\n puts zeroProp\nend",
"def zero?\n @value.zero?\n end",
"def negative?\n self < 0\n end",
"def negative(num)\n return num<0\nend",
"def pos?\n sign > 0\n end",
"def negative?() @positive==false end",
"def get_sign(coefficient)\r\n if coefficient < 0\r\n '-'\r\n else \r\n '+' \r\n end\r\n end",
"def negative(num)\n num > 0 ? -num : num\nend",
"def negative(num)\n num > 0 ? -num : num\nend",
"def negative(num)\n num > 0 ? -num : num\nend",
"def negative(num)\n num > 0 ? -num : num\nend",
"def negative(num)\n num <= 0 ? num : -num\nend",
"def negative(num)\n num <= 0 ? num : -num\nend",
"def negative(number)\n number <= 0 ? number : number * -1\nend",
"def negative(number)\n number > 0 ? -number : number\nend",
"def negative(number)\n number > 0 ? -number : number\nend",
"def abs4(x) return x<0?-x:x end",
"def abs(x)\n x < 0 ? 0-x : x\n end",
"def negative(num)\n num < 0 ? num : -num\nend",
"def negative(num)\n\n if num <=0\n num\n else \n num * -1\n end\nend",
"def neg_pos_zero(arr)\n\tzeros = 0;\n\tnegs = 0;\n\tpos = 0;\n\tarr.each do |val|\n \tif val > 0 then\n \tpos += 1\n \telsif val < 0 then\n \tnegs += 1\n \telse\n \tzeros += 1\n \tend\n\tend\n\tputs(Float(pos)/len)\n\tputs(Float(negs)/len)\n\tputs(Float(zeros)/len)\nend",
"def negative(num)\n num *= -1 if num > 0\n num\nend",
"def nonzero?() end",
"def zero?\n amount == 0 \n end",
"def sign; end",
"def zero?\n # @digits.to_i == 0 and self.finite?\n @digits == 0 && @special._equal?(0)\n end",
"def make_negative(num)\r\n num > 0 ? -num : num\r\nend",
"def negative?\n !@positive \n end",
"def zero?\n return amount.zero?\n end",
"def not_zero(number)\n if number == 0\n return \"-\"\n else\n return number\n end\n end",
"def make_positive(number)\n if number < 0\n -number\n else\n number\n end\nend",
"def sign_creator(num)\n \"-\" if num < 0\n end",
"def negative?\n value < 0\n end",
"def check_sign(number)\n number > 0 ? \"#{number} is positive\" : \"#{number} is negative\"\nend",
"def negative(input)\n input.abs * -1\nend",
"def nonzero?\n !zero?\n end",
"def non_zero_digit; end",
"def zero?()\n #This is a stub, used for indexing\n end",
"def ∅?; self.real.zero?; end",
"def negative(number)\n number > 0 ? (number * -1) : number\nend",
"def negative(int)\n int <= 0 ? int : -int\nend",
"def check_sign(number)\n if number == 0\n number\n elsif number > 0\n \"#{number} is positive\"\n else\n \"#{number} is negative\"\n end\nend",
"def negative(integer)\n integer > 0 ? -integer : integer\nend",
"def def_non_negative_int sym, name=nil\n def_numeric(sym, name) {|v| \n next false unless (v.is_a?(Fixnum) && v >= 0)\n true\n }\n end",
"def def_non_negative_int sym, name=nil\n def_numeric(sym, name) {|v| \n next false unless (v.is_a?(Fixnum) && v >= 0)\n true\n }\n end",
"def zero_or_more\n -1\n end",
"def negative(num)\n num.positive? ? -num : num\nend",
"def negative(num)\n num > 0 ? -num : num # or -num.abs\nend",
"def solution(x)\n x.abs.to_s.reverse.to_i * (x < 0 ? -1 : 1)\nend",
"def makeNegative(num)\n num > 0 ? num * -1 : num\nend",
"def negative(num)\n\treturn -num unless num <= 0\n\tnum\nend",
"def positive?() @positive==true end",
"def makeNegative(num)\n num < 0 ? num : -num\nend",
"def is_negative(tal)\n if tal < 0\n return true\n else\n return false\n end\nend",
"def positive?; end",
"def reverse_sign(an_integer)\n return 0 - an_integer\nend",
"def reverse_sign(an_integer)\n return 0 - an_integer\nend",
"def negative(number)\n return number if number.negative? || number.zero?\n -number\nend",
"def negative(num)\n # your code goes here\n if num < 0\n return num\n elsif num == 0\n return 0\n else\n return -num\n end\nend",
"def check_sign(number)\r\n if number > 0\r\n \"#{number} is positive\"\r\n else\r\n \"#{number} is negative\"\r\n end \r\n end",
"def negative(num)\n if num.positive?\n -num\n else\n num\n end\nend",
"def zero?\n to_d.zero?\n end",
"def zero?\n to_d.zero?\n end",
"def negative\n abs.flip_sign\n end",
"def plusMinus(arr)\n positive = arr.count{|x| x > 0}\n negative = arr.count{|x| x < 0}\n zero = arr.count{|x| x == 0}\n size = arr.size\n puts positive.to_f/size\n puts negative.to_f/size\n puts zero.to_f/size\nend",
"def zero?\n @digits.to_i == 0 and self.finite?\n end",
"def zero?\n @total.zero?\n end",
"def zero?\n @total.zero?\n end",
"def make_numbers_negative(number)\n number.positive? ? -(number) : number\nend",
"def zero\n r(0)\n end",
"def makeNegative(num)\r\n if num >= 0\r\n return num * (-1)\r\n else\r\n return num * 1\r\n end\r\n end",
"def negative(num)\n return -num if num > 0\n num\nend",
"def zero?\n cents == 0 \n end",
"def isnegative(siffra)\n output = false\n if siffra < 0\n output = true\n end\n\n return output\nend"
] |
[
"0.79069316",
"0.7830235",
"0.7424184",
"0.7424184",
"0.73563755",
"0.73453236",
"0.73453236",
"0.7316459",
"0.73063517",
"0.7197056",
"0.71961325",
"0.71849084",
"0.7121114",
"0.7092033",
"0.7092033",
"0.7056567",
"0.704413",
"0.69872636",
"0.6974088",
"0.69341683",
"0.69327164",
"0.6920389",
"0.6911271",
"0.69035006",
"0.6898825",
"0.6872854",
"0.6864492",
"0.6852392",
"0.68162304",
"0.68117666",
"0.6802429",
"0.6782263",
"0.67785573",
"0.67749614",
"0.6766975",
"0.6766975",
"0.6766975",
"0.6766975",
"0.6759748",
"0.6759748",
"0.67530805",
"0.67483544",
"0.67483544",
"0.6742003",
"0.6727321",
"0.6724121",
"0.67231417",
"0.6712238",
"0.67108506",
"0.67065144",
"0.6704803",
"0.66902566",
"0.66875964",
"0.6672451",
"0.6654481",
"0.6653711",
"0.66497403",
"0.66441506",
"0.66434836",
"0.6642253",
"0.6615184",
"0.6603678",
"0.6601769",
"0.66007346",
"0.6599543",
"0.6592368",
"0.65906596",
"0.6579663",
"0.6572176",
"0.6570447",
"0.6566999",
"0.6566999",
"0.655941",
"0.65554976",
"0.65422654",
"0.65337723",
"0.6526189",
"0.6516579",
"0.6513064",
"0.65042204",
"0.6500836",
"0.64996916",
"0.64653075",
"0.64653075",
"0.6456193",
"0.64402664",
"0.6437493",
"0.6420782",
"0.6419834",
"0.6419834",
"0.6412824",
"0.6412102",
"0.6406782",
"0.6406558",
"0.6406558",
"0.6406274",
"0.6398353",
"0.6396682",
"0.6394246",
"0.63933986",
"0.6390103"
] |
0.0
|
-1
|
GID of the user
|
def initialize(*args)
super
@action = :create
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def unix_gid; end",
"def gid\n self['GID'].to_i\n end",
"def gid\n self['GID'].to_i\n end",
"def gid\n self['GID'].to_i\n end",
"def gid() end",
"def account_gid; account.gid end",
"def gid\n \"##{id}\"\n end",
"def unix_gid=(_arg0); end",
"def id\n @gid\n end",
"def gid\n self.class.key(id)\n end",
"def gid\n self.class.key(id)\n end",
"def primary_gid(user)\n if user[:gid].is_a?(Numeric)\n user[:primary_group] || user[:gid].to_i\n else\n user[:gid]\n end\n end",
"def setgid?() end",
"def gid(*) end",
"def gid(*) end",
"def group\n Group.get!(gidnumber)\n end",
"def gid_next\n gid_last = execute(\"dscl . -list /Users PrimaryGroupID | sort -k 2 -g | tail -1 | awk '{print $2}'\")\n gid_last.to_i + 1\n end",
"def gid2group(gid)\n begin\n grent = Etc.getgrgid(gid)\n return grent.name\n rescue ArgumentError => e\n # Invalid user id? No user? Return the uid.\n logger.warn(\"Failed to find group for gid #{gid}\")\n return gid.to_s\n end\n end",
"def unix_uid; end",
"def get_group(gid)\n\t\t\t@group_name=GROUPS[gid.to_s]\n\t\tend",
"def group_gid(name)\n gid = -1\n execute(\"dscacheutil -q group -a name #{name}\") do |result|\n result.stdout.each_line do |line|\n if /^gid:/.match?(line)\n gid = (line[5, line.length - 5]).chomp\n break\n end\n end\n gid\n end\n end",
"def group_id\n get_info[:groupID]\n end",
"def gid=(p0) end",
"def gid=(p0) end",
"def gricer_user_id\n nil\n end",
"def uid() end",
"def group() self['group'] || node[:users]['root'][:primary_group] ; end",
"def user_group(user)\n Etc.getpwnam(user).gid\n rescue ArgumentError\n Chef::Log.warn(\n \"ssh_authorize_key: User #{user} not found at compile time, perhaps \"\\\n \"you should specify a default group. I will use #{user} for now.\"\n )\n user\n end",
"def setgid?(mode)\n mode & 02000 == 02000\n end",
"def login_user(user_id)\n session[:user_gid] = users(user_id).to_global_id.to_s\n end",
"def uid; end",
"def group_id\n \tregisterable.class.name == \"Group\" ? registerable.id : nil\n end",
"def get_gid(groupname)\n\t\t\t\tgroup = groups()[groupname]\n\t\t\t\tif(group == nil)\n\t\t\t\t\traise(NoSuchGroupError, \"Group \\\"#{groupname}\\\" could not be found\")\n\t\t\t\tend\n\n\t\t\t\treturn(group.gid)\n\t\t\tend",
"def gid_next\n gid_last = execute(\"dscl . -list /Groups PrimaryGroupID | sort -k 2 -g | tail -1 | awk '{print $2}'\")\n gid_last.to_i + 1\n end",
"def find_gid(groupname)\n gid = nil\n Etc.group do |entry|\n if entry.name == groupname\n gid = entry.gid\n break\n end\n end\n gid\n end",
"def generate_uid\n if self.id && !self.uid\n self.uid = \"cld-#{self.id}\"\n Group.update_all({uid:self.uid}, {id: self.id})\n end\n return true\n end",
"def user_level arg = nil\n if arg == nil\n return session[:group_id]\n elsif arg.class == User\n return arg.group_id\n elsif USER_LEVELS.index(arg) != nil\n return USER_LEVELS.index(arg)\n end\n USER_LEVELS[arg]\n end",
"def get_uid_int\n self.uid.to_i\n end",
"def user_key\n uid\n end",
"def unix_uid=(_arg0); end",
"def get_group(gid)\n\t\t\t\tgroups().each do |group|\n\t\t\t\t\treturn group[1].groupname if group[1].gid == gid\n\t\t\t\tend\n\t\t\t\tnil\n\t\t\tend",
"def cmd_getuid(*args)\n print_line(\"Server username: #{client.sys.config.getuid}\")\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 google_id(name)\n @config.gid = name\n end",
"def group\n gid = File.stat(self.artifact).gid\n Etc.getgrgid(gid).name\n end",
"def uid\n @uid\n end",
"def get_default_group(user)\n case node['platform_family']\n when 'suse'\n 'users'\n when 'mac_os_x'\n 'staff'\n else\n user[:username] || user[:id]\n end\n end",
"def uid(*) end",
"def directory_group\n res = nil\n Group.role_names_for(user).each do |role_name|\n if Filesystem.test_dir role_name, self, :read\n res = File.stat(path_for(role_name: role_name)).gid\n break if res\n end\n end\n res\n end",
"def has_uid_or_gid_action\n validate :uid, /^[0-9]+$/\n uid = request[:uid].to_i\n\n uids = IO.readlines(\"/etc/passwd\").map{ |line| line.split(\":\")[2].to_i }\n gids = IO.readlines(\"/etc/group\").map{ |line| line.split(\":\")[2].to_i }\n\n if uids.include?(uid) || gids.include?(uid)\n reply[:output] = true\n else\n reply[:output] = false\n end\n reply[:exitcode] = 0\n end",
"def get_ldap_id\n\t\tself.id = Devise::LDAP::Adapter.get_ldap_param(self.username,\"uidnumber\").first\n end",
"def username\n @data[GROUPNAME]\n end",
"def current_user_group_ids\n container.current_user_group_ids\n end",
"def generate_gid(type, id)\n Base64.strict_encode64([\"0\", type.length, \":\", type, id.to_s].join)\nend",
"def login gid, gurl\n @gamblers[gid] = gurl\n end",
"def uid\n return nil unless user_id\n user_id.split('/').first\n end",
"def uid\n return nil unless user_id\n user_id.split('/').first\n end",
"def get_free_gid(search_limit = 1000)\n gid = nil; next_gid_guess = 200\n groups_gids = safe_dscl(\"list\", \"/Groups\", \"gid\")\n while next_gid_guess < search_limit + 200\n if groups_gids&.match?(Regexp.new(\"#{Regexp.escape(next_gid_guess.to_s)}\\n\"))\n next_gid_guess += 1\n else\n gid = next_gid_guess\n break\n end\n end\n gid || raise(\"gid not found. Exhausted. Searched #{search_limit} times\")\n end",
"def ensure_user_group\n if new_resource.gid.is_a?(String)\n group_name = new_resource.gid\n Etc.getgrnam(new_resource.gid).gid\n else\n group_name = new_resource.username\n Etc.getgrgid(new_resource.gid).gid\n end\nrescue ArgumentError\n Chef::Log.info(\n \"user_account[#{new_resource.username}] creating group #{group_name}\")\n group group_name do\n gid new_resource.gid if new_resource.gid.is_a?(Integer)\n end.run_action(:create)\n Etc.getgrnam(group_name).gid\nend",
"def get_id(data)\n result = get_full_data(data)\n usrgrpid = nil\n result.each { |usr| usrgrpid = usr['usrgrpid'].to_i if usr['name'] == data[:name] }\n usrgrpid\n end",
"def user_id\n @user_id ||= self.user ? self.user.to_global_id : nil\n end",
"def current_user_group_name\n logged_in? ? current_user.send(self.class.current_user_group_method) : YamledAcl.guest_group_name\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 get_userid()\n user_info = call_myspace_api(:user_info, :v1_json => true)\n user_info['userId'].to_s\n end",
"def uid\n read_attribute :uid\n end",
"def has_uid_or_gid?(uid)\n # a non-numeric string is converted to 0 with to_i (which is the uid for root)\n return false if uid.nil? or uid.to_i == 0\n MCollectiveApplicationContainerProxy.rpc_exec('openshift', @id) do |client|\n client.has_uid_or_gid(:uid => uid.to_i) do |response|\n output = response[:body][:data][:output]\n return output == true\n end\n end\n end",
"def current_group(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.group if options[:sid]\n security_descriptor.group.account_name\n elsif Pathname.new(install_dir).exist?\n Etc.getgrgid(Pathname.new(install_dir).stat.gid).name\n end\n end",
"def formatted_annotation_identifier\n \"#{self.id}--group--user\"\n end",
"def current_uid\n session[:uid] || (current_user && current_user.uid)\n end",
"def user_id\n username\n end",
"def uid_for_group_user(group_user)\n query = \"select uid, first_name, last_name from user where uid in (SELECT uid FROM group_member WHERE gid=331358835234)\"\n users_in_atc = MiniFB.call(FB_API_KEY, FB_SECRET_KEY, \"FQL.query\", \"query\" => query, \"session_key\" => FB_SESSION_KEY, \"expires\" => 0)\n user = users_in_atc.detect(){|user| \"#{user[\"first_name\"]} #{user[\"last_name\"]}\".include?(group_user) }\n return user[\"uid\"] unless user.nil?\n return nil\n end",
"def uid\n \"#{user_id}-#{team_id}\"\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 user_token\n google_account.id.to_s\n end",
"def group_org_id\n\t\t\tGroupOrganization.count + 1\n\t\tend",
"def uid\n @uid ||= (@in['uid_hi'] << 16) | @in['uid_lo']\n end",
"def get_gear_uid(gear_uuid = nil)\n # a non-numeric string is converted to 0 with to_i (which is the uid for root)\n return -1 if gear_uuid.nil?\n MCollectiveApplicationContainerProxy.rpc_exec('openshift', @id) do |client|\n client.get_gear_uid(:gear_uuid => gear_uuid) do |response|\n output = response[:body][:data][:output]\n return output\n end\n end\n return -1\n end",
"def user_id; 1; end",
"def getusername()\r\n return getvalue(SVTags::USER_ID)\r\n end",
"def to_param\n dgs_user_id\n end",
"def user\n\t\tdatastore['IRCNICK']\n\tend",
"def check_group_exists(doc, group, uid, gid)\n return unless group[gid].nil?\n\n log_error(\"User #{uid} has primary group #{gid}, but it does not exist\",\n !db_version[:is_slave])\n\n user_gid = 1\n\n doc.root.xpath('GID').each do |e|\n e.content = '1'\n end\n\n doc.root.xpath('GNAME').each do |e|\n e.content = 'users'\n end\n\n doc.root.xpath('GROUPS').each do |e|\n e.xpath(\"ID[.=#{gid}]\").each {|x| x.remove }\n\n e.add_child(doc.create_element('ID')).content = user_gid.to_s\n end\n\n [user_gid, { :body => doc.root.to_s, :gid => user_gid }]\n end",
"def getG\r\n return @g\r\n end",
"def getUser ()\n return self.directory.user \n end",
"def gadz_ans\n (user.gadz_proms_principale.to_i - 1800).to_s\n end",
"def uid\n \"#{Socket.gethostname}-#{Process.pid}-#{thread_id}\"\n end",
"def group_owner\n User.find_by(id: self.user_id)\n end",
"def id\n @uid\n end",
"def key\n 'groupid'\n end",
"def get group_identifier\n groups.fetch self.class.identifierize(group_identifier), nil\n end",
"def get_user_groups\n user_groups.keys\n end",
"def setuid?() end",
"def pgid_from_pid(pid)\n Process.getpgid(pid)\n rescue Errno::ESRCH\n nil\n end",
"def userid\n \treturn session[:userid]\n \tend",
"def ldap_busca_grupos_usuario_como_admin(uid, gidnumber, prob)\n grupos = []\n opcon = {\n host: Rails.application.config.x.jn316_servidor,\n port: Rails.application.config.x.jn316_puerto,\n auth: {\n method: :simple, \n username: Rails.application.config.x.jn316_admin,\n password: ENV['JN316_CLAVE']\n }\n }.merge(Rails.application.config.x.jn316_opcon)\n filter = Net::LDAP::Filter.eq( \"objectClass\", 'posixGroup')\n ldap_conadmin = Net::LDAP.new( opcon )\n lgrupos = ldap_conadmin.search(\n base: Rails.application.config.x.jn316_basegrupos, \n filter: filter \n )\n if lgrupos.nil?\n prob << 'No se pudieron cargar grupos: '+\n ldap_conadmin.get_operation_result.code.to_s +\n ' - ' + ldap_conadmin.get_operation_result.message \n return nil\n end\n lgrupos.each do |entry|\n if (entry.gidnumber && gidnumber && \n entry.gidnumber[0] == gidnumber) || \n (uid && entry[:memberuid].include?(uid))\n puts \"OJO gidnumber=#{entry.gidnumber}, cn=#{entry.cn}\"\n g = crear_actualizar_grupo(entry, prob)\n if (g.nil?)\n return nil\n end\n grupos << g.id\n end\n end\n return grupos\n rescue Exception => exception\n prob << 'Problema conectando a servidor LDAP '+\n '(ldap_busca_grupos_usuario_como_admin). Excepción: ' + exception.to_s\n puts prob\n return nil\n end",
"def goid\n @player\n end",
"def ldap_groups\n User.walk_ldap_groups(User.ldap_member_of(user_key), []).sort\n end",
"def get_gist_ids user\n puts \"Getting gists for user #{user.username}\"\n gists = get_gists(user)\n gist_ids = gists.collect { |g| g[:id] }\n puts \"Gists for user #{user.username}: gist_ids\"\n return gist_ids\n end",
"def uid\n @name.to_s.downcase.gsub(/[^a-z0-9]+/, '').gsub(/-+$/, '').gsub(/^-+$/, '')\n end",
"def uid\n @name.to_s.downcase.gsub(/[^a-z0-9]+/, '').gsub(/-+$/, '').gsub(/^-+$/, '')\n end",
"def request_uid(*args)\n uid\n end"
] |
[
"0.78416365",
"0.7773188",
"0.7773188",
"0.7773188",
"0.76888466",
"0.7595219",
"0.72343516",
"0.7197455",
"0.7125175",
"0.6977075",
"0.6977075",
"0.68465847",
"0.6842233",
"0.6748401",
"0.6748401",
"0.66131437",
"0.65247285",
"0.6460531",
"0.634359",
"0.6341721",
"0.6326873",
"0.63045365",
"0.6283094",
"0.6283094",
"0.625336",
"0.62286645",
"0.6153834",
"0.61423355",
"0.608433",
"0.6078666",
"0.6052062",
"0.6048246",
"0.60372084",
"0.59538513",
"0.59503305",
"0.59274185",
"0.59228784",
"0.59006524",
"0.5851575",
"0.58432084",
"0.58266526",
"0.5818819",
"0.5814842",
"0.5796778",
"0.57734495",
"0.57685065",
"0.57268465",
"0.5706879",
"0.5696888",
"0.56728107",
"0.56673896",
"0.56624615",
"0.56294304",
"0.5613359",
"0.56130856",
"0.56015813",
"0.56015813",
"0.5577545",
"0.55761844",
"0.5574611",
"0.55648196",
"0.55591434",
"0.55571324",
"0.5547842",
"0.5532151",
"0.5528645",
"0.55271757",
"0.5496778",
"0.5494727",
"0.54747224",
"0.54735816",
"0.5468503",
"0.5460043",
"0.54579747",
"0.54579735",
"0.5454427",
"0.54535645",
"0.5448298",
"0.54430705",
"0.54373854",
"0.5429631",
"0.542868",
"0.5417509",
"0.5409814",
"0.5409178",
"0.54054284",
"0.5404013",
"0.5398628",
"0.53923583",
"0.5386383",
"0.5385911",
"0.5370056",
"0.5359697",
"0.5351089",
"0.5332471",
"0.53254217",
"0.53130424",
"0.5310231",
"0.5305006",
"0.5305006",
"0.5303317"
] |
0.0
|
-1
|
Set the attribute of the error to test.
|
def on_attribute(attribute)
@attribute = attribute
self
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def error=(value) @error = true; end",
"def error=(val)\n @error = val\n self.state = 'error'\n end",
"def error=(value)\n @error = value\n end",
"def []=(attribute, error)\n self[attribute.to_sym] << error\n end",
"def []=(attribute, error)\n self[attribute] << error\n end",
"def []=(attribute, error)\n self[attribute] << error\n end",
"def error(new_error_key = 'error')\n self.error_key = new_error_key\n end",
"def set_error\n @error = Error.find(params[:id])\n end",
"def assert_good_value(object_or_klass, attribute, value, error_message_to_avoid = //)\n object = get_instance_of(object_or_klass)\n object.send(\"#{attribute}=\", value)\n object.valid?\n assert_does_not_contain(object.errors.on(attribute), error_message_to_avoid, \"when set to #{value.inspect}\")\n end",
"def assert_bad_value(object_or_klass, attribute, value,\n error_message_to_expect = self.class.default_error_message(:invalid))\n object = get_instance_of(object_or_klass)\n object.send(\"#{attribute}=\", value)\n assert !object.valid?, \"#{object.class} allowed #{value.inspect} as a value for #{attribute}\"\n assert object.errors.on(attribute), \"There are no errors on #{attribute} after being set to #{value.inspect}\"\n assert_contains(object.errors.on(attribute), error_message_to_expect, \"when set to #{value.inspect}\")\n end",
"def error(attribute_name, options = T.unsafe(nil)); end",
"def error=(value)\n doc['error'] = value.nil? ? nil : value.to_s\n end",
"def set_error\n @error = Error.find(params[:id])\n end",
"def set_error\n @error = Error.find(params[:id])\n end",
"def assert_error(object, attribute, message)\n assert_invalid object\n assert_errors_on object, attribute\n assert_errors_include object, attribute, message\n end",
"def assert_assigns_errors(object, attribute)\n assert_error_tag\n # just check that it assigns errors for now\n assert assigns(object.to_sym).errors.on(attribute.to_sym)\n end",
"def internals_set(attribute, internal_value)\n @_errors ||= {}\n internals_set(self.class[attribute], @_data)\n end",
"def set_error(error)\n @mutex.synchronize { @task_error = error }\n end",
"def error_details=(value)\n @error_details = value\n end",
"def expected_value=(arg)\n end",
"def expected_value=(arg)\n end",
"def error=(e)\n if e.is_a?(Hash) \n value = e[:value]\n exact = e[:exact]\n else\n value = e\n exact = true\n end\n \n @error = exact ? value : (value - @output)\n @gradient = @output * (1 - @output) * @error\n @error\n end",
"def set_attribute\n raise Error::CustomError.error(422, :ATT_01, \"attribute\") unless Number.is_integer?(params[:attribute_id])\n begin\n @attribute = Attribute.find(params[:attribute_id]) \n rescue ActiveRecord::RecordNotFound\n raise Error::CustomError.error(404, :ATT_02, \"attribute\")\n rescue\n raise Error::CustomError.error(500, :ISE, \"attribute\")\n end\n end",
"def set_error_status(error_message, attributes: {})\n current_span = OpenTelemetry::Trace.current_span\n current_span.status = OpenTelemetry::Trace::Status.error(error_message)\n add_attributes(current_span, attributes)\n end",
"def set_attribute(name, value); end",
"def set_error(span, exception)\n raise NotImplementedError\n end",
"def replace(attribute, value)\n errors[attribute.to_sym] = value\n end",
"def replace(attribute, value)\n errors[attribute.to_sym] = value\n end",
"def error!\n @error = true\n end",
"def clean_error\n @error = nil\n @error_description = nil\n @error_attribute = nil\n end",
"def error_count=(value)\n @error_count = value\n end",
"def failure_info=(value)\n @failure_info = value\n end",
"def error!\n self.severity = :ERROR\n end",
"def set_user_error\n @user_error = UserError.find(params[:id])\n end",
"def assert_bad_value(object_or_klass, attribute, value, error_message_to_expect = :invalid) # :nodoc:\n object = get_instance_of(object_or_klass)\n object.send(\"#{attribute}=\", value)\n \n return false if object.valid?\n return false unless object.errors.on(attribute)\n\n error_message_to_expect = error_message_from_model(object, attribute, error_message_to_expect)\n\n assert_contains(object.errors.on(attribute), error_message_to_expect)\n end",
"def error msg\n @error = msg\n end",
"def value=(newval)\n raise\n end",
"def test_hc_elementinuseattributeerr\n doc = nil\n newAttribute = nil\n addressElementList = nil\n testAddress = nil\n newElement = nil\n attrAddress = nil\n appendedChild = nil\n setAttr1 = nil\n setAttr2 = nil\n doc = load_document(\"hc_staff\", true)\n addressElementList = doc.getElementsByTagName(\"body\")\n testAddress = addressElementList.item(0)\n newElement = doc.createElement(\"p\")\n appendedChild = testAddress.appendChild(newElement)\n newAttribute = doc.createAttribute(\"title\")\n setAttr1 = newElement.setAttributeNode(newAttribute)\n \n begin\n success = false;\n begin\n setAttr2 = testAddress.setAttributeNode(newAttribute)\n rescue Taka::DOMException => ex\n success = (ex.code == Taka::DOMException::INUSE_ATTRIBUTE_ERR)\n end \n assert(success, \"throw_INUSE_ATTRIBUTE_ERR\")\n end\n\n end",
"def set_error( error )\n SQLite::API.set_result_error( @func, error )\n end",
"def assert_nmi_on_serr=(assert_nmi_on_serr)\n validator = EnumAttributeValidator.new('String', [\"platform-default\", \"enabled\", \"disabled\"])\n unless validator.valid?(assert_nmi_on_serr)\n fail ArgumentError, \"invalid value for \\\"assert_nmi_on_serr\\\", must be one of #{validator.allowable_values}.\"\n end\n @assert_nmi_on_serr = assert_nmi_on_serr\n end",
"def error_message=(value)\n @error_message = value\n end",
"def set_errors(errors)\r\n @errors = errors\r\n end",
"def expected= patient_identifier\n self.test_type_data = patient_identifier.attributes\n end",
"def validate_with(attribute, value)\n message = \"Expected errors on #{attribute.inspect} with value `#{value.inspect}' after validation\"\n @object.send(\"#{attribute}=\", value)\n @object.valid?\n if @object.errors[attribute].kind_of?(Array)\n test_case.assert(!@object.errors[attribute].empty?, message)\n else\n test_case.assert(!@object.errors.on(attribute).nil?, message)\n end\n end",
"def error_device=(e) #:nodoc:\n @@stderr = e\n end",
"def set_attributes\n attr_accessor :media_errors\n end",
"def value=(value)\n self.should = value\n end",
"def assert_attribute_is_validated(model, attribute, value, flag)\n model.assign_attributes(attribute => value)\n if flag == 1\n assert_not model.valid?\n else\n assert model.valid?\n end\n end",
"def mark_as_failed!(error)\n self.error = error\n self.save!\n if error == \"InvalidRegistration\" or error == \"NotRegistered\"\n self.device.update_attribute(:unsubscribed_at, Time.now)\n end\n end",
"def error!(msg)\n self.status = Status::ERROR\n self.error = msg\n save\n end",
"def assert_good_value(described, attr, value, fail_msg = nil)\n described = described.new if described.is_a? Class\n\n described.send(\"#{attr}=\", value)\n\n described.valid? # just validates it, don't assert about this,\n # another attributes can be invalid and we are not testing them now\n\n fail_msg ||= \"Expected #{attr} '#{value}'\" +\n \" to be valid on #{described.class.name}.\\n\" +\n \"Errors on #{attr}: <#{described.errors.inspect}>\"\n\n assert_empty described.errors[attr], fail_msg\n end",
"def error_url=(error_url)\n if !error_url.nil? && error_url.to_s.length > 255\n fail ArgumentError, 'invalid value for \"error_url\", the character length must be smaller than or equal to 255.'\n end\n\n if !error_url.nil? && error_url.to_s.length < 0\n fail ArgumentError, 'invalid value for \"error_url\", the character length must be great than or equal to 0.'\n end\n\n @error_url = error_url\n end",
"def add_error(expected_value, target_value)\n @errors[target_value.error_key] = <<-MSG\n\n Mismatch in field: '#{target_value.error_key}'\n expected: '#{expected_value.value}'\n received: '#{target_value.value}'\n\n MSG\n end",
"def full_error(attribute_name, options = T.unsafe(nil)); end",
"def mark_failure\n self.failure_occurred = true\n end",
"def mark_failure\n self.failure_occurred = true\n end",
"def set_attribute_node( new_attr )\n if new_attr.owner_document != self.owner_document then\n raise \"WRONG_DOCUMENT_ERR\"\n end\n if not new_attr.owner_element.nil? then\n raise \"INUSE_ATTRIBUTE_ERR\"\n end\n old_attr = nil\n @attr_nodes << new_attr\n new_attr._set_owner_element( self )\n old_attr\n end",
"def mark_error(model, attr_name)\n if model.errors.any? && model.errors.get(attr_name) && model.errors.get(attr_name) != \"\"\n return ' error'\n end\n return ''\n end",
"def assert_good_value(object_or_klass, attribute, value, error_message_to_avoid = //) # :nodoc:\n object = get_instance_of(object_or_klass)\n object.send(\"#{attribute}=\", value)\n\n return true if object.valid?\n\n error_message_to_avoid = error_message_from_model(object, attribute, error_message_to_avoid)\n\n assert_does_not_contain(object.errors.on(attribute), error_message_to_avoid)\n end",
"def validate_and_set(obj, attribute, value)\n if value.to_i >= 0\n obj.send(\"#{attribute}=\", value)\n validators = obj.class.validators_on(attribute)\n if !validators.empty?\n validators.each { |v| v.validate obj }\n\n unless obj.errors.full_messages.blank?\n obj.send(\"#{attribute}=\", nil)\n log_error(obj, \"#{attribute} not set because #{obj.errors.full_messages.to_sentence}.\")\n obj.errors.clear\n end\n end\n else\n log_error(obj, \"#{attribute} not set because #{value} is negative.\")\n end\n end",
"def configure_attribute(key, value, errors)\n attribute_path = path(key)\n if can_set?(key)\n set(key, value)\n else\n nested_errors = ConfigMapper.configure_with(value, get(key))\n nested_errors.each do |nested_path, error|\n errors[\"#{attribute_path}#{nested_path}\"] = error\n end\n end\n rescue NoMethodError, ArgumentError => e\n errors[attribute_path] = e\n end",
"def set_rails_error\n\n if(self.rails_error_id)\n rails_error = RailsError.find(self.rails_error_id)\n if rails_error != nil\n self.rails_error = rails_error\n return true\n else\n errors.add_to_base(\"value of field: 'rails_error' is invalid- it must be unique\")\n return false\n end\n end\nend",
"def set_extractor_error\n @extractor_error = ExtractorError.find(params[:id])\n end",
"def validate_attributes=(new_attribute)\n @validate_attributes = new_attribute\n end",
"def errors=(_); end",
"def something_should_fail!\n @should_fail = true\n end",
"def error_bar=(val)\n @error_bar = check_error_bar(val)\n end",
"def raise_error=(bool)\n @raise_error = bool\n end",
"def assert_error_on(field, model)\n \tassert !model.errors[field.to_sym].nil?, \"No validation error on the #{field.to_s} field.\"\n end",
"def expected_assessment=(value)\n @expected_assessment = value\n end",
"def assert_error_on(record, attribute, message = nil)\n error = record.errors.detect{|attr, error| attr.to_s == attribute.to_s}\n assert error\n assert error.include?(message), error.inspect if message\n end",
"def assert_attribute_is_validated(model, attribute)\n # This line sets the specified attribute to nil \n model.assign_attributes(attribute => nil)\n assert !model.valid?, \"#{attribute.to_s} is not being validated\"\n end",
"def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n end",
"def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n end",
"def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n end",
"def failure(err_msg)\n @fail = true\n @err_msg = err_msg\n end",
"def test_ro\n base = RoBaseIf.new( 'lab1', '', true )\n ex = assert_raise( RuntimeError ) { base.value = 1; }\n assert_equal( \"Model 'lab1' is read-only\", ex.message )\n end",
"def error\n\t\t\traise 'Test'\n\t\tend",
"def number=(new_number)\n self.assert_non_negative(new_number)\n @number = new_number\n end",
"def set_attr(key, value)\n value = format_value(value)\n key = format_key(key)\n send(\"#{key}=\", value)\n rescue\n unless defined?(Rails).nil?\n $lxca_log.info(\n 'XClarityClient::Endpoints::BuildableResourceMixin',\n \"UNEXISTING ATTRIBUTES FOR #{self.class}: #{key}\"\n )\n end\n end",
"def mock_error_type\n _undefined\n end",
"def add_error_and_return_false(error, attribute = :base, options = {})\n errors.add(attribute, error, options)\n false\n end",
"def assert_attribute_is_validated(model, attribute)\n # This line sets the specified attribute to nil\n model.assign_attributes(attribute => nil)\n assert !model.valid?, \"#{attribute.to_s} is not being validated\"\n end",
"def assert_attribute_is_validated(model, attribute)\n # This line sets the specified attribute to nil\n model.assign_attributes(attribute => nil)\n assert !model.valid?, \"#{attribute.to_s} is not being validated\"\n end",
"def set_attribute(key_, value_)\n attribute(key_, value_, :set)\n end",
"def actual=(value)\n throw \"must be provided by subclass\"\n end",
"def set_error_message(msg)\n if self[:error_message]\n self[:error_message] += \"\\n\" + msg\n else\n self[:error_message] = msg\n end\n end",
"def setInvalid()\n\t\t@isValid = false\n\tend",
"def validate_with(attribute, value)\n message = \"Expected #{attribute.inspect} with value `#{value.inspect}' to validate\"\n @object.send(\"#{attribute}=\", value)\n @object.valid?\n if @object.errors[attribute].kind_of?(Array)\n test_case.assert(@object.errors[attribute].empty?, message)\n else\n test_case.assert(@object.errors.on(attribute).nil?, message)\n end\n end",
"def configure_attribute(key, value, errors)\n attribute_path = path(key)\n if value.is_a?(Hash) && !get(key).nil?\n nested_errors = ConfigMapper.configure_with(value, get(key))\n nested_errors.each do |nested_path, error|\n errors[\"#{attribute_path}#{nested_path}\"] = error\n end\n else\n set(key, value)\n end\n rescue NoMethodError, ArgumentError => e\n errors[attribute_path] = e\n end",
"def set_file_path_error(error)\n @invalid_path_error ||= error.is_a?(SnippetRepository::InvalidPathError)\n end",
"def error(&block)\n @runner.set_error(@current_platform, block)\n end",
"def assert_error_occurred\n @status.wont_equal 0\n end",
"def error\n failure\n end",
"def []=(attribute, value)\n @_errors ||= {}\n @_original ||= {}\n begin\n unless @_original.include? attribute\n @_original[attribute] = self[attribute]\n end\n self.class[attribute].set(@_data, value)\n @_errors.delete(attribute)\n rescue\n @_errors[attribute] = {:value => value, :error => $!}\n end\n end",
"def assert_nmi_on_perr=(assert_nmi_on_perr)\n validator = EnumAttributeValidator.new('String', [\"platform-default\", \"enabled\", \"disabled\"])\n unless validator.valid?(assert_nmi_on_perr)\n fail ArgumentError, \"invalid value for \\\"assert_nmi_on_perr\\\", must be one of #{validator.allowable_values}.\"\n end\n @assert_nmi_on_perr = assert_nmi_on_perr\n end",
"def set_error!(error, retry_interval = nil)\n self.attempts += 1\n self.lock = nil\n self.error = \"#{error.class.name}: #{error.message}\\n#{error.backtrace.join(\"\\n\")[0, 4000]}\"\n self.run_at = (retry_interval * attempts).seconds.since.utc if retry_interval\n self.save\n rescue => e\n if self.class.logger\n self.class.logger.warn(error)\n self.class.logger.warn(e)\n end\n end",
"def inject_error_to_test(test, error_message)\n class << test\n attr_accessor :injected_error_message\n\n def run\n raise injected_error_message\n end\n end\n\n test.injected_error_message = error_message\n end",
"def set_error_notification\n @error_notification = get_credentials['error_notification'] \n end",
"def target= exp\n expect :call, :attrasgn, :safe_call, :safe_attrasgn\n @my_hash_value = nil\n self[1] = exp\n end",
"def species\n @species = \"human\" #expect(owner.species).to eq(\"human\")\n #expect { owner.species = \"hamster\" }.to raise_error\n end"
] |
[
"0.70878583",
"0.7084648",
"0.691707",
"0.6776746",
"0.67393965",
"0.6685827",
"0.625193",
"0.6231658",
"0.6187235",
"0.6161637",
"0.6142924",
"0.6120564",
"0.6117762",
"0.6117762",
"0.60640264",
"0.6009081",
"0.5941146",
"0.5901237",
"0.590055",
"0.58951557",
"0.58951557",
"0.5889008",
"0.58854616",
"0.5882419",
"0.5878409",
"0.5838163",
"0.58196026",
"0.58196026",
"0.573702",
"0.57121843",
"0.56998163",
"0.5699704",
"0.5672031",
"0.56629694",
"0.5662465",
"0.56426656",
"0.5638584",
"0.5634811",
"0.5620379",
"0.5607217",
"0.5595127",
"0.5593273",
"0.5569019",
"0.5552163",
"0.55441004",
"0.5535769",
"0.5534805",
"0.55339587",
"0.5533239",
"0.5531497",
"0.5528741",
"0.55219793",
"0.55035526",
"0.5497324",
"0.54659307",
"0.54659307",
"0.5455505",
"0.5447188",
"0.5429164",
"0.5419296",
"0.5418176",
"0.5416029",
"0.540552",
"0.5400728",
"0.5393699",
"0.5393129",
"0.5390982",
"0.53902125",
"0.53689903",
"0.5365598",
"0.5343241",
"0.5342043",
"0.53401226",
"0.53401226",
"0.53401226",
"0.53401226",
"0.5338652",
"0.5335024",
"0.53340185",
"0.53286755",
"0.5320223",
"0.5317485",
"0.53142273",
"0.53142273",
"0.53112024",
"0.5308158",
"0.53022945",
"0.5301549",
"0.5299504",
"0.529442",
"0.5279518",
"0.5279089",
"0.52781326",
"0.5275167",
"0.5266244",
"0.5266108",
"0.5255818",
"0.52533704",
"0.5247651",
"0.5247177",
"0.52411467"
] |
0.0
|
-1
|
=begin ================================================== PROBLEM: Write a method that takes one argument, a positive integer, and returns a string of alternating 1s and 0s, always starting with 1. The length of the string should match the given integer. Further exploration: Modify stringy so it takes an additional optional argument that defaults to 1. If the method is called with this argument set to 0, the method should return a String of alternating 0s and 1s, but starting with 0 instead of 1. MENTAL MODEL: for each number in INTEGER, print 1 or 0 INPUT: integer OUTPUT: string of 1 and 0, starting with 1 EDGE CASES: ASSUMPTIONS: string must start with 1 input is valid positive integer input QUESTIONS: PSEUDO: ================================================== EVALUATION Again, wondering if I'm sacrificing readablity for getting it all in on one line. Had fewer dings from rubocop this time around. ================================================== =end
|
def stringy(num, b = 1)
string = ''
if b = 0
num.times { |v| v.odd? ? string.concat('1') : string.concat('0') }
return string
else
num.times { |v| v.odd? ? string.concat('0') : string.concat('1') }
return string
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def stringy(int, int1 = 1)\n if int && int1 != 0\n Array.new(int) { |i| i.even? ? '1' : '0' }.join\n elsif int1 == 0\n Array.new(int) { |i| i.even? ? '0' : '1' }.join\n end\nend",
"def stringy(integer, optional = 1)\n return_string = ''\n if optional == 1\n integer.times { |idx| idx.even? ? return_string << '1' : return_string << '0' }\n elsif optional == 0\n integer.times { |idx| idx.even? ? return_string << '0' : return_string << '1' }\n end\n return_string\nend",
"def stringy2(int, *zero)\n str = ''\n if zero == [0] then str += '0' else str += '1' end\n int.times do |n|\n if n > 0\n array = str.chars\n if array[n - 1] == '0' then str += '1' else str += '0' end\n end\n end\n p str\nend",
"def stringy(int)\n stringy = \"\"\n odd = false\n int.times do\n if odd == true\n stringy << \"0\"\n odd = false\n else \n stringy << \"1\"\n odd = true\n end\n end\n return stringy\nend",
"def stringy(number, optional = 1)\n result = ''\n 1.upto(number) do |num|\n if optional == 1\n answer = num.odd? ? '1' : '0'\n result << answer\n else\n answer = num.even? ? '1' : '0'\n result << answer\n end\n end\n\n result\nend",
"def stringy(int)\n string = \"\"\n int.times do |x|\n x.even? ? string += \"1\" : string += \"0\"\n end\n string\nend",
"def stringy(integer)\n i = 1\n output = ''\n while i <= integer\n output += '1' if i.odd?\n output += '0' if i.even?\n i += 1\n end\n output\nend",
"def stringy(num)\n str = ''\n 1.upto(num) do |index|\n if index.odd?\n str << '1'\n else\n str << '0'\n end\n end\n str\nend",
"def stringy(number)\n result = ''\n 1.upto(number) do |num|\n answer = num.odd? ? '1' : '0'\n result << answer\n end\n\n result\nend",
"def stringy_string (int)\n true_var = true\n new_str = \"\"\n int.times do \n true_var ? new_str << '1' : new_str << '0'\n true_var = !true_var\n end\n new_str\nend",
"def stringy(num)\n str = ''\n num.times do |indx|\n indx % 2 == 0 ? str += '1' : str += '0'\n end\n return str\nend",
"def stringy(number, optional = 1)\n result = ''\n number.times do |num|\n if optional # dont need the == 1 here, just optional.\n num.even? ? result << '1' : result << '0'\n else num.odd? ? result << '1' : result << '0'\n end\n end\n result\nend",
"def stringy(num, val=1)\n str = ''\n if val == 1\n num.times do |x|\n str += \"1\" if x % 2 == 0\n str += \"0\" if x % 2 != 0\n end\n else\n num.times do |x|\n str += \"0\" if x % 2 == 0\n str += \"1\" if x % 2 != 0\n end\n end\n str\nend",
"def stringy(number, optional = 1)\n result = ''\n\n number.times do |num|\n if optional == 1\n result << ( numbers = num.even? ? '1' : '0' )\n else\n result << ( numbers = num.even? ? '0' : '1' )\n end\n end\n result\nend",
"def stringy(int)\n ones_and_zeros = []\n int.times do\n if ones_and_zeros.empty?\n ones_and_zeros << '1'\n elsif ones_and_zeros[-1] == '1'\n ones_and_zeros << '0'\n else\n ones_and_zeros << '1'\n end\n end\n ones_and_zeros.reduce(:+)\nend",
"def stringy(integer)\n ones_and_zeroes = []\n\n integer.times do |index|\n number = index.even? ? 1 : 0\n ones_and_zeroes << number\n end\n\n ones_and_zeroes.join\nend",
"def stringy(num)\n str = ''\n num.times do |i|\n str << '1' if i.even?\n str << '0' if i.odd?\n end\n str\nend",
"def stringy(number)\n string = \"\"\n number.times do |n|\n n.even? ? string << \"1\" : string << \"0\"\n end\n string\nend",
"def stringy(number, start_with = 1)\n if start_with != 1 && start_with != 0\n puts 'Invalid value for start. Only 1 and 0 allowed'\n return\n end\n\n number_string = start_with.to_s\n iterations = number - 1\n\n iterations.times do |previous_number|\n number_string[previous_number] == '1' ? number_string << '0' : number_string << '1'\n end\n\n number_string\nend",
"def stringy(len)\n str = ''\n len.times do |n|\n n.even? ? str << '1' : str << '0'\n end\n str\nend",
"def stringy(number)\n result = ''\n number.times {|i| i.even? ? result << '1' : result << '0'}\n result\nend",
"def stringy(input)\n result = []\n counter = 0\n\n result << '1'\n \n until result.size == input\n result[counter] == '1'? result << '0' : result << '1'\n counter += 1\n end\n \n result.join('')\nend",
"def stringy(number)\n result = ''\n number.times do |idx|\n result << (idx.even? ? '1' : '0')\n end\n result\nend",
"def stringy(num)\n (1..num).map { |idx| idx.odd? ? '1' : '0' }.join\nend",
"def stringy(int)\n new_string = \"\"\n (int / 2).times { new_string << \"10\" }\n new_string << \"1\" if int.odd? \n new_string\nend",
"def stringy(length)\n count = 0\n stringy_string = ''\n while count < length\n if count % 2 == 0\n stringy_string << '1'\n else\n stringy_string << '0'\n end\n count += 1\n end\n stringy_string\nend",
"def stringy(size)\n i, string = 0, \"\"\n while i < size do\n string[-1] == \"1\" ? string << \"0\" : string << \"1\"\n i += 1\n end\n return string\nend",
"def stringy(num, option = 1)\n str = ''\n first_char = option.to_s\n second_char = (option == 1 ? '0' : '1')\n num.times { |ndx| str << (ndx.even? ? first_char : second_char) }\n str\nend",
"def stringy(num = 1)\n ones_zeros = []\n counter = 0\n \n loop do\n # break if num == 1\n if ones_zeros == []\n ones_zeros << 1\n end\n\n ones_zeros[counter] == 1 ? ones_zeros << 0 : ones_zeros << 1\n counter += 1\n break if counter == num -1\n end\n string_num = ones_zeros.join\nend",
"def stringy(num)\n str = ''\n char = '1'\n\n loop do\n str += char\n\n char = char == '1' ? '0' : '1'\n break if str.size == num\n end\n\n str\nend",
"def stringy(length)\n string = ''\n length.times do |index|\n number_str = index.even? ? '1' : '0'\n string << number_str\n end\n string\nend",
"def stringy(number, optional = 1)\n result = '' # initialize empty string instead of array\n number.times do |num|\n if optional == 1\n numbers = num.even? ? '1' : '0' # initializing numbers variable to store results\n result << numbers\n else numbers = num.odd? ? '1' : '0'\n result << numbers\n end\n end\n result # no need for join here since this is a string, not an array.\nend",
"def stringy2(length, start_with = 1)\n string = ''\n length.times do |index|\n index += 1 if start_with == 0\n number_str = index.even? ? '1' : '0'\n string << number_str\n end\n string\nend",
"def stringy(num)\n binary = ''\n loop do\n binary << '1'\n break if binary.length == num\n binary << '0'\n break if binary.length == num\n end\n binary\nend",
"def stringy(pos_int)\n result = ''\n pos_int.times do |ind|\n ind%2 == 0 ? result<<'1' : result<<'0'\n end\n result\nend",
"def stringy(int1, int2 = 1)\n numbers = []\n\n int1.times do |int| \n number = int.even? ? 0 : 1\n numbers << number\n end\n\n numbers.join\nend",
"def q7_1_and_0(num)\n str_out = ''\n num.times {|num_here|\n num_here.even? ? str_out += '1' : str_out += '0'\n }\n str_out\nend",
"def stringy(number)\n arr = []\n (1..number).each { |num| arr << num }\n\n string = \"\"\n arr.each do |num|\n string << \"0\" if num % 2 == 0\n string << \"1\" if num % 2 == 1\n end\n\n string\nend",
"def stringy(num)\n arr = []\n\n num.times do |idx|\n digit = idx.odd? ? '0' : '1'\n arr << digit\n end\n\n arr.join\nend",
"def stringy(int)\n str = ''\n int.times { |i| str += ((i + 1) % 2).to_s }\n str\nend",
"def stringy(number)\n result = []\n\n 1.upto(number) do |num|\n numbers = num.even? ? '0' : '1'\n result.push(numbers)\n end\n result.join\nend",
"def stringy(num, start = 1)\n return 'Positive integer only' unless num.is_a?(Integer) && num > 0\n return 'Invalid starting number' unless start == 1 || start == 0\n\n string = ''\n num.times do\n string << start.to_s\n start = 1 - start\n end\n string\nend",
"def stringy(number)\n result = []\n\n number.times do |num|\n numbers = num.even? ? '1' : '0'\n result << numbers\n end\n \n result.join\nend",
"def stringy(number)\n string = \"\"\n counter = 0\n state = 0\n\n loop do\n if state == 0\n string << \"1\"\n state = 1\n else\n string << \"0\"\n state = 0\n end\n\n counter += 1\n\n break if counter == number\n end\n\n string\nend",
"def stringy(int)\n\ncounter = int\narr = []\n\n while counter > 0\n if !arr.empty? && counter % 2 ==0\n arr << 0\n elsif counter % 2 !=0 && arr.last != 1 || arr.empty?\n arr << 1\n else\n next\n end\n counter -= 1\n end\n arr.join()\nend",
"def stringy(input_integer)\n chunks = [] # => [], [], [], []\n (input_integer/2).times do # => 3, 4, 2, 3\n chunks << '10' # => [\"10\"], [\"10\", \"10\"], [\"10\", \"10\", \"10\"], [\"10\"], [\"10\", \"10\"], [\"10\", \"10\", \"10\"], [\"10\", \"10\", \"10\", \"10\"], [\"10\"], [\"10\", \"10\"], [\"10\"], [\"10\", \"10\"], [\"10\", \"10\", \"10\"]\n end # => 3, 4, 2, 3\n\n if input_integer.even? # => true, false, true, false\n chunks.join('') # => \"101010\", \"1010\"\n else\n chunks.join('') + '1' # => \"101010101\", \"1010101\"\n end # => \"101010\", \"101010101\", \"1010\", \"1010101\"\nend",
"def stringy(int, first_num = 1)\n first_num == 0 ? second_num = 1 : second_num = 0\n\n arr = Array(1..int)\n arr.map! { |n| n.odd? ? first_num : second_num }\n arr.join\nend",
"def stringy(num, start=1)\n string = '10' * (num/2)\n if start == 1\n num.even? ? string : string + '1'\n else\n num.even? ? string.reverse : string.reverse + '0'\n end\nend",
"def stringy(number)\n stringy = []\n number.times do |index|\n n = index.even? ? 1 : 0\n stringy << n\n end\n stringy.join\nend",
"def stringy(num)\n zero_array = []\n one_array = []\n\n (num / 2).times do\n zero_array << 0\n one_array << 1\n end\n\n if num.odd?\n one_array << 1\n end\n\n one_array.zip(zero_array).flatten.join(\"\")\nend",
"def stringy(int)\n (int/2).times { print 10 }\n 1 if int.odd?\nend",
"def stringy(num)\n string = '10' * (num/2)\n num.even? ? string : string + '1'\nend",
"def stringy(integer)\n numbers = []\n\n integer.times do |index|\n number = index.even? ? 1 : 0 # ternary operator if/then, number captures new value\n numbers << number\nend\n\n # numbers.join\nend",
"def stringy(length, reverse = 1)\n counter = 1 \n return_string = ''\n while counter <= length\n if counter % 2 == 0\n return_string << '0'\n else\n return_string << '1'\n end\n counter += 1\n end\n\n reverse == 1 ? return_string : return_string.reverse\nend",
"def stringy(number)\n number_range = (1..number)\n binary = []\n number_range.each do |num|\n if num % 2 == 1\n binary << 1\n elsif num % 2 == 0\n binary << 0\n end\n end\n binary.join(\"\")\nend",
"def stringy(num, switch = 1)\n output = []\n if switch == 1\n num.times do |index|\n number = index.even? ? 1 : 0\n output << number\n end\n return output.join\n elsif switch == 0\n num.times do |index|\n number = index.even? ? 0 : 1\n output << number\n end\n return output.join\n end\nend",
"def increment_string(input)\n nums = \"0123456789\"\n return input + \"1\" if input == \"\" || !nums.include?(input[-1]) \n end_zero = -1 \n end_nine = -1\n \n if input[end_zero] == \"0\"\n num_all_zero = true\n while num_all_zero\n num_all_zero = false\n end_zero -= 1\n if !nums.include?(input[end_zero])\n input[-1] = \"1\"\n return input\n elsif input[end_zero] == \"0\"\n puts \"zero\"\n num_all_zero = true\n end\n end\n end\n \n if input[end_nine] == \"9\"\n num_all_nine = true\n while num_all_nine\n num_all_nine = false\n input[end_nine] = \"0\"\n end_nine -= 1\n if input[end_nine] == \"9\"\n num_all_nine = true\n next\n elsif !nums.include?(input[end_nine]) \n return input[0..end_nine] + \"1\" + input[end_nine + 1..-1]\n end \n input[end_nine..end_nine + 1] = (input[end_nine].to_i + 1).to_s + \"0\"\n return input\n end\n end\n\n input.succ\nend",
"def stringy(num, start_with=0)\n numbers = []\n\n num.times do |index|\n if start_with == 1\n number = index.even? ? 1 : 0\n numbers << number\n else \n number = index.even? ? 0 : 1\n numbers << number\n end \n end\n numbers.join\nend",
"def stringy(number)\n digits = []\n counter = 0\n while counter < number do\n digits[counter] = counter.odd? ? 0 : 1\n counter += 1\n end\n digits.join\nend",
"def stringy number, count = 1\n binary_string = ''\n\n if count == 1\n (number / 2).times {binary_string << '10'}\n binary_string << '1' if number % 2 == 1\n elsif count == 0\n (number / 2).times {binary_string << '01'}\n binary_string << '0' if number % 2 == 1\n end\n\n binary_string\n end",
"def stringy_options(size, beginning=1)\n numbers = ''\n size.times do |index|\n if beginning == 1\n index.even? ? numbers << '1' : numbers << '0'\n else\n index.even? ? numbers << '0' : numbers << '1'\n end\n end\n numbers\nend",
"def a(str)\n case\n when str == \"0\"\n return \"\"\n when str == \"1\"\n return 'one'\n when str == \"2\"\n return 'two'\n when str == \"3\"\n return 'three'\n when str == \"4\"\n return 'four'\n when str == \"5\"\n return 'five'\n when str == \"6\"\n return 'six'\n when str == \"7\"\n return 'seven'\n when str == \"8\"\n return 'eight'\n when str == \"9\"\n return 'nine'\n end\nend",
"def stringy(int)\n arr_digits = (1..int).to_a\n arr10 = []\n arr_digits.each do |num|\n num % 2 == 1 ? arr10 << 1 : arr10 << 0\n end\n arr10.join\nend",
"def stringy(num, bit = 1)\n bin_arr = []\n num.times { |n| n.even? ? bin_arr << (0 + bit) : bin_arr << (1 - bit) }\n bin_arr.join\nend",
"def bi(i)\n string = []\n i.times do |n|\n if n.even?\n string << \"1\"\n else\n string << \"0\"\n end\n end\n string.join\nend",
"def change a\n a = a.downcase\n end_string = ''\n ('a'..'z').each { |let| a.include?(let) ? end_string << '1' : end_string << '0' }\n end_string\nend",
"def stringy2(size,opt1=1)\n numbers = []\n if opt1 == 0\n opt2 = 1\n else\n opt2 = 0\n end\n\n size.times do |index|\n number = index.even? ? opt1 : opt2\n numbers << number\n end\n\n numbers.join\nend",
"def stringy(size, option = 1)\n numbers = []\n\n size.times do |index|\n if option == 1\n number = index.even? ? 1 : 0\n numbers << number\n else\n number = index.even? ? 0 : 1\n numbers << number\n end\n end\n\n numbers.join\nend",
"def stringy(size, digit = 1)\n words = []\n size.times do\n words << digit\n digit = digit == 1 ? 0 : 1\n end\n words.join\nend",
"def stringy_hightech(num, zero_start=1)\n half, remainder = num.divmod 2\n\n case zero_start\n when 0 then '01' * half + '0' * remainder\n when 1 then '10' * half + '1' * remainder\n end\nend",
"def repeat(string, i)\n if i == i.to_s.to_i # could make this it's own method like integer?()\n if i > 0\n i.times {puts string}\n else\n puts \"#{i} is not a positive integer.\"\n end\n else\n puts \"#{i} is not an integer.\"\n end\nend",
"def increment_string(input)\n return '1' if input.empty?\n \n arr = input.rpartition(/\\D/)\n\n if arr[-1].empty?\n arr[-1] = '1'\n else\n arr[-1] = arr[-1].succ\n end\n\n return arr.join\nend",
"def plus_one_short digits\n # int.next return the next int Ex: 2 -> 3\n # int.digits return an array of int digits\n # array.join return an string of array digits concatenation.\n # string.to_i return an int\n # array.reverse return an reversed array.\n digits.join.to_i.next.digits.reverse\nend",
"def plural_every(int, str)\r\n return \"#{int} #{str}s\" unless int == 1\r\n \"#{str}\"\r\n end",
"def stringy(size)\n numbers = []\n\n size.times do |index|\n number = index.even? ? 1 : 0\n numbers << number\n end\n\n numbers.join\nend",
"def stringy(size)\n numbers = []\n\n size.times do |index|\n number = index.even? ? 1 : 0\n numbers << number\n end\n\n numbers.join\nend",
"def BitwiseOne(strArr)\n result = \"\"\n first = strArr[0]\n second = strArr[1]\n idx = 0\n\n while idx < strArr[0].length\n if first[idx] == \"0\" && second[idx] == \"0\"\n result << \"0\"\n else\n result << \"1\"\n end\n idx += 1\n end\n\n result\nend",
"def stringy(size, start = 1)\n numbers = []\n\n size.times do |index|\n if start = 1\n number = index.even? ? 1 : 0\n elsif start = 0\n number = index.even? ? 0 : 1\n end\n numbers << number\n end\n\n numbers.join\nend",
"def stringy(size, switch = 1)\n numbers = []\n\n size.times do |index|\n number = index.even? ? 1 : 0 if switch == 1\n number = index.even? ? 0 : 1 if switch == 0\n numbers << number\n end\n numbers.join\nend",
"def stringy(size)\n numbers = []\n\n size.times do |index|\n number = index.even? 1 : 0\n numbers << number\n end\n\n numbers.join\nend",
"def string_incrementer(str)\n # String not ending in number\n return \"#{str}1\" unless str[-1].match?(/[0-9]/)\n\n # String ends in number not ending in 9\n return \"#{str[0..-2]}#{str[-1].to_i + 1}\" unless str[-1] == '9'\n\n # String ends in number ending in 9\n num_index = str.index(/[1-9]/)\n num = str[num_index..].to_i + 1\n\n # If leading number is 9 and next to a 0\n return str[0..num_index - 2] + num.to_s if str[num_index] == '9' && str[num_index - 1] == '0'\n\n # If leading number is 9 and not next to a 0\n # and if leading number is 9 and next to a 0\n str[0..num_index - 1] + num.to_s\nend",
"def increment_string(input)\n return input + '1' if !(input[-1] =~ /[0-9]/)\n split = input.scan(/\\d+|\\D+/)\n no_num = true\n res = ''\n split.each do |item|\n if (item.scan(/\\D/).empty?)\n item = item.next\n no_num = false\n end\n res += item\n end\n return res + '1' if (no_num)\n res\n\nend",
"def repeat_string(str, i)\n return \"\" if (i <= 0)\n return str if (i == 1)\n d = repeat_string(str, i >> 1)\n d += d\n d += str if (i & 1)\n return d\n end",
"def stringy(size, start=1)\n numbers = []\n\n size.times do |index|\n if start == 1\n number = index.even? ? 1 : 0\n numbers << number\n elsif start == 0\n number = index.odd? ? 1 : 0\n numbers << number\n end\n end\n\n numbers.join\nend",
"def repeat(string, int)\n return 'invalid string argument' unless string.class == String\n return 'invalid integer argument' unless int.to_s.to_i == int\n int.times { |num| puts string }\nend",
"def pirates_say_arrrrrrrrr(string)\nresult = \"\"\n string.size.times { |i| result << string[i+1] if string[i] == \"r\" || string[i] == \"R\"}\nreturn result\nend",
"def string_to_binary(str)\n zero_array = [\"a\", \"b\", \"c\", \"d\", \"e\", \"f\", \"g\", \"h\", \"i\", \"j\", \"k\", \"l\", \"m\"]\n one_array = [\"n\" , \"o\", \"p\", \"q\", \"r\", \"s\", \"t\", \"u\", \"v\", \"w\", \"x\", \"y\", \"z\"]\n\n def check_if_in_array(check, array)\n array.each do |i|\n if check.upcase == i.upcase\n return true\n end\n end\n\n return false\n end\n\n return_word = \"\"\n\n for char in str.chars\n if check_if_in_array(char, zero_array)\n return_word = return_word + \"0\"\n elsif check_if_in_array(char, one_array)\n return_word = return_word + \"1\"\n end\n end\n\n return return_word\nend",
"def change input\r\n if input.is_a?(String)\r\n (\"A\"..\"Z\").map do |letter|\r\n input.upcase.include?(letter) ? '1' : '0'\r\n end.join\r\n end\r\nend",
"def repeat(string, num)\n string = string.to_s\n if num.to_i.positive?\n num\n else\n puts 'invalid input, integer must be positive'\n return\n end\n num.times { puts string }\nend",
"def string_increment(string)\n result = string.split(/[a-z]/i)\n new_str = ''\n if string[-1] =~ /[a-z]/i || string == \"\"\n new_str = string + \"1\"\n else\n digits_size = result.last.size\n if ((result.last.to_i + 1).to_s).size < digits_size # means 0 doestn't matter\n new_str = string[0, string.size-result.last.to_i.to_s.size]+(result.last.to_i + 1).to_s\n else\n new_str = string[0, string.size - digits_size] + (result.last.to_i + 1).to_s\n end\n end\n new_str\nend",
"def repeat(string, integer)\n unless integer.to_i > 0 || integer.is_a?(Integer)\n puts \"Incorrect input\"\n return\n end\n if string.empty?\n puts \"The string is empty\"\n return\n end\n integer.times { puts \"#{string}\"}\nend",
"def solution(value)\n answer = \"\"\n number_string = value.to_s\n ( 5 - number_string.length).times do\n answer += \"0\"\n end\n answer = answer + number_string\n \"Value is #{answer}\"\nend",
"def BitwiseOne(strArr)\n first = strArr[0]\n second = strArr[1]\n third = \"\"\n \n i = 0 \n while i < first.length\n # When i change this line to first[i] == \"0\" &&\n # second[i] == \"0\"\n # all tests passes. Why????????????????????????\n if first[i] == second[i]\n \t third << \"0\"\n else\n \t third << \"1\"\n end\n \n i += 1\n end\n third \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 encode_repeating(my_string)\n return my_string if !my_string || my_string.length < 2\n current, check_next = 0, 1\n until current == my_string.length\n check_next += 1 while my_string[current] == my_string[check_next]\n repeats = check_next - current\n if repeats > 2\n my_string[current + 1] = repeats.to_s\n check_next -= my_string.slice!((current + repeats.to_s.length + 1)...check_next).length\n end\n current = check_next\n end\n return my_string\nend",
"def increment_string(input)\nn = input.size\n i = n - 1\n numbers = '0'..'9'\n while i >= 0\n if !numbers.include?(input[i])\n break\n end\n i -= 1\n end\n numbers_size = input[i + 1..-1].size\n last_numbers = input[i + 1..-1].to_i + 1\n string = i == -1 ? '' : input[0..i]\n [string, \"%.#{numbers_size}d\" % last_numbers].join\nend",
"def encode_repeating(my_string)\n return nil if my_string.nil?\n return my_string if my_string.length <= 1\n\n i = 0\n j = 0\n k = 0\n while j <= i && i < my_string.length\n k = i\n if my_string[i] != my_string[i + 1]\n my_string[j] = my_string[i]\n\n else\n counter = 1\n while my_string[i] == my_string[i + 1]\n i += 1\n counter += 1\n end\n\n if counter == 2\n my_string[j] = my_string[k]\n my_string[j + 1] = my_string[k]\n else\n my_string[j] = my_string[k]\n my_string[j + 1] = counter.to_s\n end\n j += 1\n end\n j += 1\n i += 1\n end\n\n my_string[j...my_string.length] = \"\"\n return my_string\nend",
"def integer_to_string(number)\n result = ''\n loop do\n number, remainder = number.divmod(10)\n # binding.pry\n result.prepend(DIGITS[remainder])\n break if number == 0\n end\n result\nend",
"def repeat(str,int)\n while int.integer? && int > 0\n puts str\n int -= 1\n end\nend",
"def crunch(string)\n counter = 0\n new_string = string[0]\n return new_string if string.length <= 1\n return string if string == ''\n loop do\n counter += 1\n new_string << string[counter] if string[counter - 1] != string[counter]\n\n break if counter == (string.length - 1)\n end\n new_string\nend"
] |
[
"0.8069861",
"0.8048098",
"0.79764473",
"0.7915742",
"0.7797426",
"0.7778363",
"0.77531654",
"0.7699496",
"0.76830786",
"0.765349",
"0.7600713",
"0.758895",
"0.75617623",
"0.7559037",
"0.7528772",
"0.75243056",
"0.75237733",
"0.7521259",
"0.75043243",
"0.7469403",
"0.74595004",
"0.74468505",
"0.74461067",
"0.7438852",
"0.73729473",
"0.734945",
"0.734285",
"0.7318689",
"0.7299573",
"0.72746396",
"0.72675556",
"0.72614497",
"0.725262",
"0.7208912",
"0.71876943",
"0.71837115",
"0.71493816",
"0.71346176",
"0.71037537",
"0.7101774",
"0.7100664",
"0.7093303",
"0.70793",
"0.69746155",
"0.69672906",
"0.69646263",
"0.69491106",
"0.68996865",
"0.6849428",
"0.6837138",
"0.68235636",
"0.6779549",
"0.67754906",
"0.6775098",
"0.67381966",
"0.6737529",
"0.6734058",
"0.6728874",
"0.6663504",
"0.6633654",
"0.6538079",
"0.64983743",
"0.6491996",
"0.6448517",
"0.6398968",
"0.6396604",
"0.6282985",
"0.6172778",
"0.6153194",
"0.61438584",
"0.60902596",
"0.60599875",
"0.60457426",
"0.6026594",
"0.6021372",
"0.6021372",
"0.6018938",
"0.60064656",
"0.5998711",
"0.59882516",
"0.5970358",
"0.5968593",
"0.5951115",
"0.5936752",
"0.59319866",
"0.59095746",
"0.5908838",
"0.5895048",
"0.5868413",
"0.5861257",
"0.5856854",
"0.5851365",
"0.58503455",
"0.5843324",
"0.58267874",
"0.5819183",
"0.5812859",
"0.5786382",
"0.5774234",
"0.57657105"
] |
0.77413166
|
7
|
"1,2,3,None,None,4,None,None,5,None,None," DFS, preorder, recursion
|
def serialize2(root, results = [])
if root.nil?
results.push('None')
return
end
results.push(root.val)
serialize2(root.left, results)
serialize2(root.right, results)
results.join(',')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def dfs(node)\n preorder, visited = [], []\n dfs_visit(node, visited, preorder)\n preorder\nend",
"def dfs_rec(target,current,array_length,stack,visited)\n left = current.find_left_child[0]\n right = current.find_right_child[0]\n parent = current.find_parent[0]\n if current.value == target\n return current\n elsif visited.length == array_length\n return nil\n elsif !left.nil? && !visited.include?(left)\n stack.push(left)\n visited.push(left)\n dfs_rec(target,left,array_length,stack,visited)\n elsif !right.nil? && !visited.include?(right)\n stack.push(right)\n visited.push(right)\n dfs_rec(target,right,array_length,stack,visited)\n else\n stack.pop\n dfs_rec(target,parent,array_length,stack,visited)\n end\nend",
"def dfs(initial)\n nodes, seen = Set.new, Set.new\n stack = Array(initial).reverse\n\n while node = stack.pop\n if seen.include?(node)\n nodes.add(node)\n else\n seen.add(node)\n stack.push(node)\n stack.concat(Array(yield node).reverse)\n end\n end\n\n nodes\n end",
"def explode!(n)\n n.traverse(:preorder_left) do |p|\n if p.depth == 4\n # puts \"Explode #{p.inspect}\"\n p.explode!\n return true\n end\n end\n\n false\nend",
"def depth_first(node, visited = Set.new())\n return nil if visited.include?(node.val)\n\n puts node.val\n visited.add(node.val)\n\n node.neighbors.each do |neighbor|\n depth_first(neighbor, visited);\n end\nend",
"def recursive => nil",
"def depth_first_recursion(v, visited)\n # Mark the current node as visited and print it\n visited[v] = true\n # print v.to_s + ' '\n\n head = @adjList[v]\n\n head.each_index do |index|\n n = head[index]\n depth_first_recursion(n, visited) unless visited[n]\n end\n end",
"def preorder_traversal_rec(root)\n res = []\n preorder_dfs(root, res)\n res\nend",
"def depth_first(value)\n\tend",
"def dfs_helper(start_node)\n\n ret_list = [start_node.value]\n # Your code here\n start_node.visited = true\n start_node.edges.each do |edge|\n unless edge.node_to.visited\n ret_list += dfs_helper(edge.node_to)\n end\n end\n return ret_list\n end",
"def DFS(root, target)\n ## base case: \n return nil if root.nil?\n return root if root.value == target\n ##indecutive step: \n ## DFS on the left side then DFS on the right side \n root.children.each do |child|\n search_result = DFS(child, target) ## better to save the actual value then check the value then return nil\n return search_result unless search_result.nil?\n end \n return nil\nend",
"def dfs(list)\n s = []\n visited = Set.new\n\n s.push(start_node)\n\n while !s.empty?\n current_node = s.shift\n next if visited.include?(current_node)\n visited.add(current_node)\n current_node.neighbors.each do |n|\n s.push(n)\n end\n puts current_node.name\n p s.map(&:name)\n p visited.map(&:name)\n end\nend",
"def solution(t)\n # write your code in Ruby 2.2\n depth = 0\n childs = []\n\n childs << t.l if t.l\n childs << t.r if t.r\n\n while not childs.empty? do\n depth += 1\n\n cc = []\n childs.each do |t|\n cc << t.l if t.l\n cc << t.r if t.r\n end\n\n childs = cc\n end\n\n depth\nend",
"def dfs_tree_preorder(start, edges)\n require 'set'\n queue = [[start,nil]]\n visited = Set[start]\n while queue.size > 0\n f,ff = *(queue.pop) \n ts = edges[f].keys.reject{ |t| visited.member?(t) }\n yield(f, ff)\n ts.each{ |t| visited << t; queue << [t,f] }\n end\nend",
"def dfs(start_node)\n s = []\n visited = Set.new\n\n s.push(start_node)\n\n while !s.empty?\n current_node = s.shift\n next if visited.include?(current_node)\n visited.add(current_node)\n current_node.neighbors.each do |n|\n s.push(n)\n end\n puts current_node.name\n p s.map(&:name)\n p visited.map(&:name)\n end\nend",
"def dfs1(graph, start_vertex)\n\tstack = [start_vertex]\n\tvisited = []\n\n\tuntil stack.empty?\n\t\tcurr_vertex = stack[-1]\n\n\t\tif !graph[curr_vertex] || graph[curr_vertex][0] \n\t\t\t$finishing_time += 1\n\t\t\t$magic_order[$finishing_time] = curr_vertex\n\t\t\tstack.pop\n\t\telse\n\t\t\tmore = []\n\t\t\tgraph[curr_vertex][0] = true\n\n\t\t\tif graph[curr_vertex][2..-1]\n\t\t\t\tgraph[curr_vertex][2..-1].each do |edge|\n\t\t\t\t\tif !graph[edge] && !visited.include?(edge)\n\t\t\t\t\t\tmore << edge\n\t\t\t\t\t\tvisited << edge\n\t\t\t\t\telsif !graph[edge]\n\t\t\t\t\t\tnext\n\t\t\t\t\telsif !graph[edge][0]\n\t\t\t\t\t\tmore << edge \n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tif more.empty?\n\t\t\t\t$finishing_time += 1\n\t\t\t\t$magic_order[$finishing_time] = curr_vertex\n\t\t\t\tstack.pop\n\t\t\telse\n\t\t\t\tstack.concat(more)\n\t\t\tend\n\t\tend\n\tend\nend",
"def dfs(target)\n return self if self.value == target\n # debugger\n self.children.each do |node|\n dfs(node)\n # if node.value == target\n # return node\n # else\n # node.dfs(target)\n # end\n end\n return nil if self.children.empty?\n p new_arr\n end",
"def dfs_rec(tree, value, args = {})\r\n verbose = args.fetch(:verbose, false)\r\n return nil if tree == nil \r\n return nil if tree.visited == true\r\n tree.visited = true\r\n return tree if tree.value == value\r\n puts \"current = #{tree}\" if verbose\r\n left = dfs_rec(tree.children[0], value, args)\r\n return left if left != nil\r\n right = dfs_rec(tree.children[1], value, args)\r\n return right # if right != nil\r\n end",
"def preorder_traversal(root)\n visited = []\n traverse(root, visited)\n visited\nend",
"def depth_first_graph(node, visited = [])\n if !visited.include? node\n visited.push(node)\n output = node.data.to_s + \" \"\n output += node.connections.map do |connection|\n depth_first_graph(connection, visited)\n end.join(\"\")\n end\n output\nend",
"def recursive_solution\n\n end",
"def inorder_traversal_rec(root)\n res = []\n inorder_dfs(root, res)\n res\nend",
"def build_paths(start)\n step = 0\n visited = []\n unvisited = [[board_node_by_location(start),step]]\n \n while !unvisited.empty?\n node = unvisited[0][0]\n step = unvisited[0][1] + 1\n \n node.neighbors.each do |x|\n if not_visited(board_node_by_location(x),visited, unvisited)\n unvisited << [board_node_by_location(x),step]\n end\n end\n visited << unvisited.shift\n end\n return visited\nend",
"def dfs_rec(tree, value)\n return nil if tree.nil?\n\n p tree.value\n return tree if tree.value == value\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\nend",
"def preorder_traversal root\n result = []\n\n result << root.val\n result << preorder_traversal(root.left) unless root.left.nil?\n result << preorder_traversal(root.right) unless root.right.nil?\n\n result\nend",
"def pre_order_traverse(tree, array)\n if !tree.nil?\n array.append(tree.value)\n pre_order_traverse(tree.left, array)\n pre_order_traverse(tree.right, array)\n end\n \n return array\n\nend",
"def ids_recursive(vertex, goal_vertex, depth, max_depth)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @stack.pop() && return if depth == max_depth\n @explored[vertex.label] = true # Mark vertex as being explored\n depth = depth + 1\n vertex.edges.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if ids_recursive(edge, goal_vertex, depth, max_depth) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def prev_node_finder(n_s, i)\n path_line = $dijkstra_result.select{ |line| line =~ /^#{n_s}/}\n path_line_array = []\n if (path_line[0] == nil)\n return\n else\n path_line_array = path_line[0].split(',')\n end\n prev_node = path_line_array[2]\n $path[i].push(prev_node)\n prev_node_finder(prev_node,i)\n #puts \"Previous node of #{n_d} is #{prev_node}\"\nend",
"def breadth_first(a=[])\n unless a.length == 0\n s = []\n a.each do |z|\n if z.key?('v')\n print \"#{z['v']} \"\n s.push(z['l'])\n s.push(z['r'])\n end\n end\n breadth_first(s)\n end\n \nend",
"def dfs(root, result)\n return if root.nil?\n result << root.val if root.left.nil? && root.right.nil?\n dfs(root.left, result)\n dfs(root.right, result)\nend",
"def dfs(start_node_num)\n _clear_visited\n start_node = find_node(start_node_num)\n dfs_helper(start_node)\n end",
"def preorder(node)\n # 1->2->4->5->3->6\n if node\n print node.value.to_s + '->'\n preorder(node.left_child)\n preorder(node.right_child)\n end\n end",
"def dfs\n closed = []\n fringe = initialize_fringe\n\n loop do\n return nil if fringe.empty? # No solution\n current = fringe.pop\n city = current[:city]\n return current if done? city # Found the solution?\n unless closed.include?(city) # Expand if we have not visited the city\n closed.push city\n fringe = fringe + expand(current) # Add to end for FILO\n end\n end\n end",
"def preOrder(root) # O(n)\n\n return nil if root == nil\n\n print \" #{root.value}\"\n preOrder(root.left)\n preOrder(root.right)\n\nend",
"def preorder_traversal(node=@root)\n return if (node == nil)\n preorder_traversal(node.left)\n preorder_traversal(node.right)\n puts node.value.to_s\n end",
"def depth_helper(node, arr, depth)\n if node.left.nil? && node.right.nil? \n arr << depth\n return\n else \n depth += 1 \n if node.left\n depth_helper(node.left, arr, depth) \n end \n if node.right\n depth_helper(node.right, arr, depth)\n end \n end \n end",
"def dfs_rec(tree, value)\n return nil if tree.nil?\n\n left = dfs_rec(tree.left, value)\n return left if left && left.value == value\n\n\n right = dfs_rec(tree.right, value)\n return right if right && right.value == value\n\n p tree.value\n return tree if tree.value == value\n\nend",
"def traverse_starter (node)\n return if node == nil\n traverse(node, 0)\n traverse_starter(node.left) if node.left\n traverse_starter(node.right) if node.right\nend",
"def breadth_first(value)\n\tend",
"def dfs(i, j, visited, m, group)\n # These arrays are used to get row and\n # column numbers of 4 neighbours\n # of a given cell\n rowNbr = [-1, 0, 0, 1]\n colNbr = [ 0, -1, 1, 0]\n\n # Mark this cell as visited\n visited[i][j] = true\n group += 1\n #puts \"dfs #{i}, #{j} group:#{group}\"\n # Recurse for all connected neighbours\n 0.upto(4 - 1) do |k|\n if isSafe(i + rowNbr[k], j + colNbr[k], visited, m)\n # puts \"k:#{k} i:#{i + rowNbr[k]}, j:#{j + colNbr[k]}\"\n group = dfs(i + rowNbr[k], j + colNbr[k], visited, m, group)\n end\n end\n #puts \"RETURN:#{group}\"\n return group\nend",
"def dfs_recursive(vertex, goal_vertex)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @explored[vertex.label] = true # Mark vertex as being explored\n vertex.edges.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if dfs_recursive(edge, goal_vertex) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def DFT_pre_order_iterative(root)\n print '[\"I\", \"O\", \"L\", \"A\", \"G\", \"R\", \"H\", \"T\", \"M\"]' + \"\\n\"\n st = Stack.new\n if root == nil\n return\n end\n st.push(root)\n while !st.empty?\n root = st.pop\n print \"#{root.value}\\n\"\n if root.right\n st.push(root.right)\n end\n if root.left\n st.push(root.left)\n end\n end\n end",
"def dfs_graph(graph, target, visited = Set.new)\n graph.graph.each do |g|\n val = dfs_helper(g, target, visited)\n if (!val.nil?)\n return val\n end\n end\n nil\nend",
"def DFS(rootNode,searchValue)\n\tstack = []\n\tpath = []\n\tpath[0] =rootNode\n\t# Initializes the stack with rootNode\n\tstack[0]=rootNode\n\t# while there is something in the stack keep running\n\twhile stack.length != 0\n\t\t# if checkFunction(searchValue,stack[0]) == true\n\t\tif checkFunction(searchValue,stack[0]) == true\n\t\t\t# return true and path\n\t\t\treturn TracePath(stack[0])\n\t\t# else\n\t\telse\n\t\t\t#remove stack[0] from the stack and inmidiately stores it in temp\n\t\t\ttemp = stack.shift\n\t\t\t#if there is right brach in the formely stack[0] now stored in temp\n\t\t\tif temp.getRB\n\t\t\t\t#insert the rigth branch at the beginning of the stack\n\t\t\t\tstack.unshift(temp.getRB)\n\t\t\tend\n\t\t\t#if there is left branch in the formely stack[0] now stored in temp\n\t\t\tif temp.getLB\n\t\t\t\t#insert the left brach at the beginning of the stack.\n\t\t\t\tstack.unshift(temp.getLB)\n\t\t\t\t\n\t\t\tend\n\t\t\t#insert the temp in the path array to keep track of the path used for the search\n\t\t\tputs temp.display\n\t\tend\n\tend\n\t# return false becuase at this point the function did not find the value\n\treturn false\nend",
"def preorder(node)\n p node.value if node.value \n preorder(node.left) if node.left\n preorder(node.right) if node.right\nend",
"def dfs_rec(cur_node, value)\n return nil if cur_node.nil?\n \n if cur_node.value == value\n\tcur_node\n else\n tgt_node = nil\n cur_node.children.each do |child| \n\t tgt_node = dfs_rec(child, value)\n\t break unless tgt_node.nil?\n\tend\n\ttgt_node\n end\nend",
"def pre_order_traversal(tree=root, ordering=[])\n end",
"def dfs(root, sum, flag)\n return if root.nil?\n @count += 1 if root.val == sum\n dfs(root.left, sum - root.val, false)\n dfs(root.right, sum - root.val, false)\n if flag\n dfs(root.left, sum, true)\n dfs(root.right, sum, true)\n end\nend",
"def lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n adj_vertices(visited.last, adj_lists).each do |vertex|\n print \"Visited stack: #{visited}, Next vertex: #{vertex}\\n\"\n totald = distance + dist(visited.last, vertex)\n\n if visited.last == finish && cycles != \"NO CYCLES EXIST\"\n\n # try adding cycles\n\n visited_before_cycles = visited\n # picks expanded cycles that begin with finish vertex\n ec = expanded_cycles(cycles).select{|c| c.first == finish}\n\n # keep adding cycles till we reach max distance\n ec.each do |cycle1|\n visited, paths, break_loop = try_cycles(visited, cycle1, paths, 0, max_distance)\n visited1 = visited\n\n ec.each do |cycle2|\n begin\n visited, paths, break_loop = try_cycles(visited, cycle2, paths, 0, max_distance)\n end until break_loop\n visited = visited1\n end\n\n visited = visited_before_cycles\n end\n\n elsif !visited.include?(vertex) && totald != \"NO SUCH ROUTE\" && totald < max_distance\n visited << vertex\n path = visited\n distance = totald\n\n if vertex == finish\n paths << path\n print \"\\n*** Path: #{path}, Length: #{path_length(path)}\\n\\n\"\n visited.pop\n break\n end\n\n lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n visited.pop\n visited.pop if visited.size.between?(2, 3)\n visited = [start] if visited == []\n end\n end\n paths.size\n end",
"def DFS_solution\n\n\t\t# Checking if I got the final solution\n\t\tif @graph.solution?\n\t\t\tif DEBUG\n\t\t\t\tputs \"Solution found:\\n#{@graph.plot_graph}\"\n\t\t\tend\n\t\t\treturn 0\n\t\tend\n\n\t\t# If not i'll find which are the possible next actions from this state\n\t\t# and iterates on them.\n\t\tresult = -1\n\t\t@graph.find_next_actions\n\t\tif DEBUG\n\t\t\tputs \"Un-A -> #{@graph.get_current_node.get_unexplored_actions}\"\n\t\tend\n\t\t# TODO Make this correct, i am skipping a level in the structures\n\t\t@graph.get_current_node.get_unexplored_actions.each do |i|\n\t\t\t# I have to create a new node starting from the current one and \n\t\t\t# knowing the action we have chosen\n\t\t\t@graph.next_state( i )\n\t\t\tresult = self.DFS_solution\n\t\t\t# With break I have to pass over all the calls in the recursive\n\t\t\t# stack, with return it skips all these steps.\n\t\t\t# break if result == 0\n\t\t\treturn 0 if result == 0\n\t\tend\n\n\t\t# If I get here means that with this configuration I will not get to a\n\t\t# solution, so I have to delete what I did in this step.\n\t\t# I'll delete the last positioned Queen, replacing it with a nil.\n\t\tunless result == 0\n\t\t\tif DEBUG\n\t\t\t\tputs \"BACKWARD!\"\n\t\t\tend\n\t\t\t@graph.delete_last_action\n\t\t\treturn -1 \n\t\tend\n\n\tend",
"def dfs_iterative(target)\n stack = [self]\n\n until stack.empty?\n node = stack.pop\n\n return node if node.value == target\n\n node.children.each do |child|\n stack << child\n end\n end\n\n nil\n end",
"def use_breadth_first(item, graph, logic_function = ->(x){graph[x].empty?} , returned = \"steps\" )\r\n search_queue = []\r\n steps = {}\r\n search_queue = search_queue.concat(graph[item])\r\n searched = []\r\n #Setting up initial steps \r\n if !search_queue.empty?\r\n search_queue.each do |term|\r\n steps[term] = 1\r\n end\r\n end\r\n #Here goes the graph algorithm\r\n while !search_queue.empty?\r\n person = search_queue.shift()\r\n if !( searched.include?(person) )\r\n\r\n if logic_function.call(person)\r\n if returned == \"steps\"\r\n return steps[person]\r\n end\r\n if returned == \"found\"\r\n return true\r\n end\r\n else\r\n if !(graph[person].nil?) \r\n graph[person].each do |related|\r\n steps[related] = steps[person] + 1 #Setting up the steps of parents of the current element in the queue\r\n end\r\n search_queue = search_queue.concat(graph[person])\r\n end\r\n end\r\n\r\n end\r\n end\r\n return false\r\nend",
"def depth=(_arg0); end",
"def postorder_traversal_rec(root)\n res = []\n postorder_dfs(root, res)\n res\nend",
"def select(array, path=[], solutions=[])\n if path.size == 5 #|| array.size == 0\n solutions << path\n return solutions \n end\n\n 0.upto(array.size-1).each do |num|\n arr = array[num]\n if arr[0].is_a?(Array)\n arr.each do |a|\n select(array[(num+1..-1)], path + [a],solutions)\n end\n else\n select(array[(num+1..-1)], path + [arr], solutions)\n end\n end\n\n return solutions\nend",
"def non_deterministic_recursive(vertex, goal_vertex)\n @stack.push(vertex) # Add vertex to frontier\n return 1 if vertex == goal_vertex # If goal_vertex is reached, return 1. ! Not necessarily shortest path !\n @explored[vertex.label] = true # Mark vertex as being explored\n vertex.edges.shuffle!.each { |edge| # Expand current vertex\n unless @explored.has_key? edge.label # If already explored, then ignore the vertex\n return 1 if non_deterministic_recursive(edge, goal_vertex) == 1 # Recursively do depth_first on the vertices\n end\n }\n @stack.pop() #Backtracking so popping the vertex from the stack\n end",
"def dfs_tree_postorder(start, edges)\n require 'set'\n queue = [[start,nil]]\n visited = Set[start]\n bq = []\n while queue.size > 0\n f = queue.pop\n bq << f\n ts = edges[f[0]].keys.reject{ |t| visited.member?(t) }\n ts.each{ |t| visited << t; queue << [t,f[0]] }\n end\n bq.reverse_each{ |f| yield(*f) }\nend",
"def pp_dfs(tree)\n arr = []\n pp_dfs_helper(tree, arr)\n return arr.inspect\n end",
"def dfs(node ,max)\n return if node.nil?\n if node.val >= max\n @count += 1\n max = node.val\n end\n dfs(node.left, max)\n dfs(node.right, max)\nend",
"def preorder_traversal(root)\n stack = [root]\n result = []\n while stack.any?\n result << stack.pop\n stack.push(result[-1].right) if !result[-1].right.nil?\n stack.push(result[-1].left) if !result[-1].left.nil?\n end\n \n result.map { |x| x.val }\nend",
"def dfs_adj_list(stack, item)\n @checked_edges = []\n @current_node = start\n return stack.pop if stack.pop == item\n return if @checked_edges.include?(all edges connected to stack.pop)\n if non_checked_edges.exist?\n put each node an unchecked edge connects to on the stack, worst to best\n as you pop each new node from the stack, add that edge to checked_edges\n @current_node = stack.pop\n dfs_adj_list(stack, item)\n end\n end",
"def dfs_recursive(query, node=@tree) \n return nil if node.nil?\n return node if query == node.value\n\n# left search equals if the left child is not nil then call the method with target & left child node parameters, otherwise is nil\n left_search = node.left_child != nil ? dfs_recursive(query, node.left_child) : nil\n\n# return if left search does not result in nil\n return left_search if left_search != nil\n right_search = node.right_child != nil ? dfs_recursive(query, node.right_child) : nil\n return right_search if right_search != nil \n end",
"def busqueda(g, d, h, nro_nodos, nodos_visitados, nro_nodos_en_caminos)\r\n #Luego, en esta variable dependiendo de si estamos en un objeto DFS o BFS, se definira el orden\r\n #en el que se seleccionaran los nodos para la busqueda. Ademas, esta variable tendra los elementos\r\n #adyacentes del nodo d ya sea en una pila o en una cola. \r\n pila_o_cola = self.orden_nodos(g,d)\r\n\r\n #pila_o_cola.estructura.each {|elem| puts elem}\r\n\r\n #Verificamos si la pila o cola, de adyacentes, incluye a \"h\"\r\n if pila_o_cola.estructura.include? h \r\n\r\n #De ser asi, se incluye el numero de nodos del recorrido que llevo a \"h\"\r\n nro_nodos_en_caminos << nro_nodos\r\n\r\n #Si la pila o cola no incluye a \"h\"\r\n else\r\n\r\n #Entonces mientras no este vacia, se recorre la estructura\r\n while not(pila_o_cola.vacio)\r\n\r\n #Luego se remueve un nodo de la estructura, que sera el siguiente que se usara\r\n #como \"inicio\" de la busqueda\r\n siguiente_nodo = pila_o_cola.remover\r\n\r\n #Si el nodo en cuestion no ha sido visitado\r\n if not(nodos_visitados.include? siguiente_nodo)\r\n #Lo agregamos al arreglo de visitados\r\n nodos_visitados << siguiente_nodo\r\n #Y hacemos una llamada recursiva al metodo busqueda pero esta vez partiendo\r\n #del nodo antes tomado. En esta llamada aumentamos el numero de nodos (nro_nodos)\r\n #en 1\r\n busqueda(g, siguiente_nodo, h , nro_nodos + 1 , nodos_visitados, nro_nodos_en_caminos)\r\n end\r\n end\r\n end\r\n\r\n #Luego de que acaba todo el procesamiento verificamos si en el arreglo \"nro_nodos_en_caminos\"\r\n #esta vacio, si es asi entonces significa que el nodo \"h\" no fue alcanzado entonces\r\n if nro_nodos_en_caminos.empty?\r\n #retornamos -1\r\n return -1\r\n end\r\n\r\n #Finalmente, si sobrevivimos todo lo anterior, llegados a este punto retornamos el numero de nodos que\r\n #fueron recorridos de \"d\" a \"h\". Recordamos que el arreglo \"nro_nodos_en_caminos\" contiene para todos los\r\n #caminos de \"d\" a \"h\", el numero de nodos recorridos.\r\n\r\n ## OJO: En este caso se retornara el nro de nodos recorridos del camino mas corto. ##\r\n\r\n #Sin embargo, si se quisiera el nro de nodos de solo el primer camino por el que se metio y encontro a \"h\"\r\n #bastaria con solo retornar \"nro_nodos_en_caminos[0]\".\r\n #Por otra parte, si se quisiera para cada camino el nro de nodos recorridos entonces basta con retornar\r\n #el arreglo completo, etc.\r\n \r\n return \"#{nro_nodos_en_caminos.min} nodos recorridos.\"\r\n end",
"def dfs(node, target)\n return nil if (node.nil?) \n return node if (node.val == target) \n left = dfs(node.left, target)\n right = dfs(node.right, target)\n left || right\nend",
"def dfs(graph)\n visited = Hash.new\n\n graph.each do |vertex, _|\n visited[vertex] = Hash.new\n visited[vertex][:state] = \"not visited\"\n end\n\n # This is to enable passing by reference in the dfs_visit method, otherwise\n # simply having a variable for integer will get passed by value and does not\n # behave/increment as expected.\n order = Hash.new\n order[:time] = 0\n\n graph.each do |vertex, _|\n dfs_visit(graph, vertex, visited, order) unless visited[vertex][:state] == \"done\"\n end\n\n visited\nend",
"def dfs_rec(data, node = @root)\n if node\n puts \"Visiting node #{node.value}\" if @debug\n if data != node.value\n left = dfs_rec(data, node.left)\n if !left\n node = dfs_rec(data, node.right)\n else\n node = left\n end\n end\n end\n node\n end",
"def dfs(a_lists)\n @count = 0\n id = {}\n preorder, postorder, visited = [], [], []\n a_lists.each do |v|\n if !visited.include?(v.name)\n dfs_visit(v.name, a_lists, id, visited, preorder, postorder)\n end\n end\n return preorder, postorder.reverse\n end",
"def preOrderTraversal(root)\n return nil if root == nil\n\n stack = [root]\n while !stack.empty?\n node = stack.pop\n print \" #{node.value}\"\n if node.right != nil\n stack.push(node.right)\n end\n if node.left != nil\n stack.push(node.left)\n end\n end\nend",
"def depth_first_search(find,tree)\n current = tree[0]\n answer = \"\"\n stack = [tree[0]]\n visited = [tree[0]]\n \n condition = false\n until condition == true\n connections = [current.find_right_child[0],current.find_left_child[0]].compact\n puts current.value\n puts connections.count\n puts \"---\"\n \n if current.value == find\n answer = current\n condition = true\n elsif visited.count == tree.count\n answer = nil\n condition = true\n else\n if connections.count < 1\n stack.pop\n current = stack[-1]\n elsif connections.count == 1\n if visited.include?(connections[0])\n stack.pop\n current = stack[-1]\n else\n current = connections[0]\n stack.push(current)\n visited.push(current)\n end\n else\n if visited.include?(connections[0]) && visited.include?(connections[1])\n stack.pop\n current = stack[-1]\n elsif !visited.include?(connections[0])\n current = connections[0]\n stack.push(current)\n visited.push(current)\n else\n current = connections[1]\n stack.push(current)\n visited.push(current)\n end\n end\n end\n end\n puts answer ? answer : \"Value not found!\"\n puts answer.value if answer != nil\nend",
"def preorder_print(start, traversal)\n traversal\n end",
"def dfs_object(root_node, target)\n #two base cases\n return root_node if root_node.value == target\n # return nil if root_node.parent.nil? #when there are no parents, we know we're back at the actual root of the tree\n\n root_node.children.each do |child_node|\n result = dfs(child_node, target)\n\n #returning nil at this point would cut short\n if result #is not nil\n return result\n end\n end\n\n nil\nend",
"def depth_first_search_pre_order_with_debug(data)\n search_order = [] # For Debug output\n stack = [@root]\n node_match = nil\n match_found = false\n until stack.empty? || match_found || @root.nil?\n cur_node = stack.pop\n next_node_value = cur_node.nil? ? \"nil\" : cur_node.value # For Debug output\n search_order << next_node_value # For Debug output\n if cur_node.value == data\n match_found = true\n node_match = cur_node\n end\n right = cur_node.right_child\n stack.push(right) unless right.nil?\n left = cur_node.left_child\n stack.push(left) unless left.nil?\n end\n puts \"Pre_order depth-first search order for nodes visited:\" # For Debug output\n p search_order # For Debug output\n puts \"\\nTotal nodes visited: #{search_order.size}\" # For Debug output\n return node_match\n end",
"def preorder_traversal(root, values = [])\n current_node = root\n\n if current_node.left || current_node.right\n values << current_node.value\n values = preorder_traversal(current_node.left, values) if current_node.left\n preorder_traversal(current_node.right, values) if current_node.right\n else\n values << current_node.value\n end\n\n values\nend",
"def get_all_trees_from_preorder(array, start=0, end_index=array.size-1)\n #Pre-order visits root first. So 1st element is always root of the tree. next element could be left or right\n #Form all trees with next element being its left, then trees with next element as its right etc.\n # [1,2,3,4] => Use DP approach, bottom up approach. Go all the way down to last 2 nodes\n # 3 3\n # 4 and 4\n # Now 2 can be added as the root and left could be 3 and right could be 3\n # 4 4\n # And follow this till root\n if (start == array.size-1)\n return [Node.new(array[start])]\n end\n results = []\n trees = get_all_trees_from_preorder(array, start+1, end_index-1)\n trees.each do |tree|\n node1 = Node.new(array[start])\n node1.left = tree\n results << node1\n node2 = Node.new(array[start])\n node2.right = tree\n results << node2\n end\n results\nend",
"def recursive_iterate( arr, indent=0 )\n\n # remove the first element from the array and print it\n # - if there are any elements left in the array\n # call ourselves again with the shorter array\n\n # first = arr.shift # mutates the arg (a)\n\n # first = arr.first\n # rest = arr[1..-1]\n\n first, *rest = arr # JS: const [first, ...rest] = arr;\n\n spaces = \" \" * indent\n\n puts \"#{ spaces } recursive_iterate( #{ arr.to_s })\"\n puts \"#{ spaces } first: #{ first }\"\n puts \"#{ spaces } rest: #{ rest.to_s }\"\n # puts first\n\n if rest.any?\n recursive_iterate( rest, indent+1 )\n end\n\n puts \"#{ spaces } --- returning from recursive_iterate( #{ arr.to_s} ), first: #{ first }\"\n\nend",
"def dfs(node, visited, component = [])\n visited << node\n component << node.object\n\n node.adjacents.each do |adjacent_node|\n dfs(adjacent_node, visited, component) unless visited.include?(adjacent_node)\n end\n end",
"def preorder\n return preorder_recursion(current = @root, tree = [])\n end",
"def dfs(root, target)\n return root if root.value == target\n root.children.each do |child|\n search_result = dfs(child, target)\n return search_result unless search_result.nil?\n end\n\n nil\nend",
"def dfs_levels(node, result, depth = 0)\n return if node.nil?\n\n result[depth] ||= [node.val.to_i, 1]\n\n result[depth] = [(result[depth].first + node.val.to_i), result[depth].last + 1]\n\n dfs_levels(node.left, result, depth + 1)\n dfs_levels(node.right, result, depth + 1)\nend",
"def dfs_rec knight, target, collector=[]\n\n if knight\n puts \"#{knight.position} and #{target}\"\n\n \n\n if knight.position == target\n collector.push knight\n end\n moves = knight.moves.size - 1\n moves.times do |num|\n dfs_rec knight.moves[num], target, collector\n end\n end\n\n return collector\nend",
"def bfs(tree)\n Enumerator.new do |yielder|\n queue = [tree]\n while !queue.empty?\n node = queue.shift\n children = node[1..-1]\n yielder << node.first\n children.each do |child|\n queue << child\n end\n end\n end\nend",
"def breadth_first_traverse(s)\n a = []\n # marking visited nodes\n visited = Array.new(@vertices)\n # create a queue for BFS\n queue = Queue.new\n\n # mark the current node as visited and enqueue it\n visited[s] = true\n queue.enqueue(s)\n\n until queue.empty?\n\n # Dequeue a vertex from queue and print it or push it into 'a' array\n s = queue.poll\n\n # print \"#{s} \"\n a.push(s)\n\n # get all adjacent vertices of the dequeued vertex s\n # if a adjacent has not been visited, then mark it\n # visited and dequeue it\n adjacent_vertices = @adjList[s]\n\n i = 0\n while i < adjacent_vertices.length\n\n n = adjacent_vertices[i]\n\n unless visited[n]\n visited[n] = true\n queue.enqueue(n)\n end\n\n i += 1\n end\n\n end\n # returning the list on BFS order\n a\n end",
"def reconstruct_bst_from_traversal(pre_order)\n reconstruct_bst_rec(0, pre_order.length - 1, pre_order)\nend",
"def display_tree(an_array)\r\n an_array.length\r\n count = 1\r\n (count - 1).upto(count) do\r\n end\r\nend",
"def in_order_traversal(tree_node, arr = [])\n return arr if tree_node == nil\n\n arr = in_order_traversal(tree_node.right, arr)\n arr << tree_node\n arr = in_order_traversal(tree_node.left, arr)\n\n arr\nend",
"def preorder_recursion(current, traverse_array)\n return if current.nil?\n\n traverse_array << { key: current.key, value: current.value }\n preorder_recursion(current.left, traverse_array)\n preorder_recursion(current.right, traverse_array)\n end",
"def iterative_depth_first(target)\n return self if @value == target\n stack = []\n stack << self\n while !stack.empty?\n popped = stack.pop\n return popped if popped.get_value == target\n right_child = popped.get_right_pointer\n if !right_child.nil?\n stack << right_child\n end\n left_child = popped.get_left_pointer\n if !left_child.nil?\n stack << left_child\n end\n end\n return nil\n end",
"def preorder\n preorder_traversal(@root, [])\n end",
"def walker(list)\nidx = 1\n if list.length <= 2\n return list.flatten,list.length\n end\n walked = [list[0]]\n starting_list = list[1,list.length]\n starting_list.each do |el|\n if el == walked[-1] + 1\n walked.append(el)\n idx += 1\n else\n break\n end\n end\n if walked.length >= 3\n return \"#{walked[0]}-#{walked[-1]}\",idx\n else\n return walked.flatten,idx\n end\nend",
"def dfs(root)\n return if root.nil?\n @stack << root\n @hash[root] = [root.val]\n @stack.each do |node|\n @hash[node] << root.left&.val\n @hash[node] << root.right&.val\n end\n dfs(root.left)\n dfs(root.right)\n @stack.pop\nend",
"def depth_first_search\n visited = {}\n timestamp = {}\n tree_edges = {}\n back_edges = {}\n cross_edges = {}\n forward_edges = {}\n count = 0\n\n # begin workaround removing depencency to order of Hash#each\n if @index.empty? then\n preference_of_nodes = nil\n else\n preference_of_nodes = {}.merge(@index)\n i = preference_of_nodes.values.max\n @graph.each_key do |node0|\n preference_of_nodes[node0] ||= (i += 1)\n end\n end\n # end workaround removing depencency to order of Hash#each\n\n dfs_visit = Proc.new { |from|\n visited[from] = true\n timestamp[from] = [count += 1]\n ary = @graph[from].keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |to|\n if visited[to]\n if timestamp[to].size > 1\n if timestamp[from].first < timestamp[to].first\n \t# forward edge (black)\n \tp \"#{from} -> #{to} : forward edge\" if $DEBUG\n \tforward_edges[from] = to\n else\n \t# cross edge (black)\n \tp \"#{from} -> #{to} : cross edge\" if $DEBUG\n \tcross_edges[from] = to\n end\n else\n # back edge (gray)\n p \"#{from} -> #{to} : back edge\" if $DEBUG\n back_edges[from] = to\n end\n else\n # tree edge (white)\n p \"#{from} -> #{to} : tree edge\" if $DEBUG\n tree_edges[to] = from\n dfs_visit.call(to)\n end\n end\n timestamp[from].push(count += 1)\n }\n\n ary = @graph.keys\n # begin workaround removing depencency to order of Hash#each\n if preference_of_nodes then\n ary = ary.sort_by { |node0| preference_of_nodes[node0] }\n end\n # end workaround removing depencency to order of Hash#each\n ary.each do |node|\n unless visited[node]\n dfs_visit.call(node)\n end\n end\n return timestamp, tree_edges, back_edges, cross_edges, forward_edges\n end",
"def dfs_rec(target, current_node=@root)\n return if current_node.nil?\n return current_node if current_node.value == target\n dfs_rec(target, current_node.left_child) ||\n dfs_rec(target, current_node.right_child)\n\tend",
"def dfs\n nodes = [self]\n nodes.concat( arg1.dfs ) if arg1\n nodes.concat( arg2.dfs ) if arg2\n nodes\n end",
"def dfs(tree, target)\n\n node_stack = [ ]\n\n #push root\n node_stack.push(tree[0])\n\n # can also set current_node and do `while current_node`\n while node_stack.length > 0\n\n # pop first\n node = node_stack.pop\n\n # then do or look for something, generally w conditional\n if node == target\n return true\n else\n # seems multiple ways to do, but doing right before left\n # makes sense to me, even though most do left before right.\n # With my way, the left is pop'd first and you go down left\n # side first\n\n #### BELOW IS NOT RIGHT -- THERE HAS TO BE SOME RECURSSION HERE\n # This actually is starting to make sense: https://github.com/brianstorti/ruby-graph-algorithms/blob/master/depth_first_search/depth_first_search.rb\n #http://haozeng.github.io/blog/2014/01/05/trees-in-ruby/\n #https://github.com/breadoliveoilsalt/depth-first-search-lab-v-000/blob/solution/index.js\n if node.left\n node_stack.push(node.left)\n end\n if node.right\n node_stack.push(node.right)\n end\n end\n end\n\n return false\n\nend",
"def dfs(node, discovery_time, parent)\n puts \"Enter dfs: node=#{node}, discovery_time=#{discovery_time}, parent=#{parent};\" if @d\n # if the low is not yet discovered for this onde\n if @n == @lows[node]\n # 2. default it tot the depth or discovery time of this node.\n @lows[node] = discovery_time # ! looks like here.\n # iterate over neighbors.\n puts \"Working iwth #{node} and #{@graph[node].inspect};\" if @d\n @graph[node].each do |neighbor|\n # all neightbos except parent.\n next if neighbor == parent\n exptected = discovery_time + 1\n actual = dfs(neighbor, exptected, node)\n if actual >= exptected\n @critical.push([node,neighbor])\n end\n @lows[node] = actual if actual < @lows[node]\n end\n end\n return @lows[node]\nend",
"def scc_dfs_first(v, visited, order)\n visited[v] = true\n @vertices[v].each do |adj|\n visited, order = scc_dfs_first adj, visited, order unless visited[adj]\n end\n order << v\n [visited, order]\n end",
"def dfs(target_value)\n #self = individual possible values\n return self if self.value == target_value \n self.children.each do |child|\n leaves = child.dfs(target_value)\n return leaves unless leaves.nil?\n end\n nil\n end",
"def dfs\n visited = Hash.new(false)\n @v.each do |vertex| \n visited.merge(explore(vertex)) if !visited[vertex]\n end\n return visited\n end",
"def build_tree(arr)\n\ntree = []\n\ntree.push(Node.new(arr[0]))\n\n arr[1..-1].each do |i|\n new_node = Node.new(i)\n\n condition = false\n current = tree[0]\n until condition == true\n if i > current.value && current.find_right_child.count == 0\n new_node.create_parent(current)\n current.create_right_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i < current.value && current.find_left_child.count == 0\n new_node.create_parent(current)\n current.create_left_child(new_node)\n tree.push(new_node)\n condition = true\n elsif i > current.value && current.find_right_child.count == 1\n current = current.find_right_child[0]\n elsif i < current.value && current.find_left_child.count == 1\n current = current.find_left_child[0]\n end\n end\n end\n tree\nend",
"def dfs(root, depth)\n return if root.nil?\n @f[depth] = @f[depth].to_i + root.val\n dfs(root.left, depth + 1) if root.left\n dfs(root.right, depth + 1) if root.right\nend",
"def depthfirst?\n false\n end"
] |
[
"0.694815",
"0.65672797",
"0.64413065",
"0.64405996",
"0.6377096",
"0.6226266",
"0.62203777",
"0.6211299",
"0.6200334",
"0.6125805",
"0.6103299",
"0.6066069",
"0.6020705",
"0.60149914",
"0.5995899",
"0.5985339",
"0.59129065",
"0.58785707",
"0.58006227",
"0.57837284",
"0.5769593",
"0.57645077",
"0.5749716",
"0.57432765",
"0.5735226",
"0.5730739",
"0.5725139",
"0.57151663",
"0.56981224",
"0.5673224",
"0.563297",
"0.5629589",
"0.56256855",
"0.56230605",
"0.5614109",
"0.56107146",
"0.560954",
"0.5603936",
"0.55946594",
"0.5581582",
"0.5578964",
"0.55728436",
"0.55678695",
"0.556533",
"0.5563375",
"0.5559423",
"0.5556722",
"0.55543256",
"0.5540644",
"0.5533792",
"0.5528865",
"0.55273473",
"0.5521127",
"0.55210674",
"0.5516135",
"0.550724",
"0.5500826",
"0.5485524",
"0.5476141",
"0.5468711",
"0.546845",
"0.5464978",
"0.5463884",
"0.5462751",
"0.54586977",
"0.5456275",
"0.5454312",
"0.54532236",
"0.54441607",
"0.5435267",
"0.5431548",
"0.54289645",
"0.5416643",
"0.5408949",
"0.54015386",
"0.5399547",
"0.538934",
"0.5387373",
"0.5383814",
"0.5382248",
"0.5382002",
"0.5378748",
"0.5378242",
"0.5370639",
"0.53651714",
"0.5356652",
"0.5354067",
"0.5352469",
"0.535084",
"0.53413236",
"0.53389883",
"0.5337952",
"0.53364843",
"0.5334246",
"0.53300726",
"0.5326327",
"0.5325158",
"0.5323354",
"0.5319298",
"0.5316961",
"0.5314489"
] |
0.0
|
-1
|
code goes here buy_fish can buy a fish that is an instance of the Fish class (FAILED 1) knows about its fishes (FAILED 2)
|
def buy_fish(fish_name)
fish = Fish.new(fish_name)
self.pets[:fishes] << fish
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def buy_fish(name) # expect(owner.pets[:fishes].count).to eq(0)\n new_fish = Fish.new(name) # owner.buy_fish(\"Bubbles\")\n self.pets[:fishes] << new_fish # owner.pets[:fishes].each { |fish| expect(fish).to be_a(Fish)}\n new_fish # expect(owner.pets[:fishes].count).to eq(1)\n # = knows about its fishes; Owner knows all about its pets - Owner sets name of pet, the pet can\\'t change its name\n # owner.buy_fish(\"Bubbles\")\n # expect(owner.pets[:fishes][0].name).to eq(\"Bubbles\")\n end",
"def buy_fish(name)\n#knows about its fishes\n pets[:fishes] << Fish.new(name)\n end",
"def buy_fish(name)\n new_fish = Fish.new(name)\n if new_fish.class == Fish\n @pets[:fishes] << new_fish\n end \n end",
"def buy_fish(name)\n pets[:fishes] << Fish.new(name)\n end",
"def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end",
"def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end",
"def test_bear_take_fish\n @river1.add_fish(@fish1)\n @river1.add_fish(@fish2)\n @bear1.bear_take_fish(@fish1)\n assert_equal(1,@bear1.check_stomach)\n end",
"def buy_fish(name)\n @pets[:fishes] << Fish.new(name)\n end",
"def buy_fish(name)\n new_fish = Fish.new(name)\n self.pets[:fishes] << new_fish \n end",
"def test_bear_take_fish\n @bear1 = Bears.new(\"Nate\",\"brown\")\n @river1.add_fish(@fish1)\n @river1.add_fish(@fish2)\n @bear1.bear_take_fish(@fish1)\n @river1.lose_fish(@fish1)\n assert_equal(1,@river1.check_fish)\n assert_equal(1,@bear1.check_stomach)\n end",
"def buy_fish(name)\n pets[:fishes] << Fish.new(name)\nend",
"def test_bear_takes_fish_out_of_river\n @bear1.bear_catches_and_eats_fish(@river1)\n assert_equal(1,@bear1.amount_in_stomach())\n assert_equal(1,@river1.number_of_fishes())\n end",
"def test_bear_can_Add_fish_to_stomach\n fish = Fish.new(\"Marley\") # take in a new fish\n @bear.eats_fish(fish) #bear is going to take in the fish it wants to eat\n assert_equal(1, @bear.count_stomach)\n # remove fish from River\n end",
"def test_take_fish_from_river\n @bear.take_fish_from_river(@river)\n assert_equal(1, @bear.food_count)\n end",
"def loose_fish_when_bear_takes_it()\n @bear.add_to_stomach(@fish1)\n @river.loose_fish(@fish1)\n assert_equal(0,@river.fish_count())\n end",
"def attemp_buying\n\n end",
"def loose_fish_when_bear_takes_it(fish)\n\n end",
"def test_bear_food_count\n @river.add_fish(@fish1)\n @river.add_fish(@fish2)\n @bear.fishes_for_fish(@river)\n @bear.bear_food_count\n assert_equal(1, @bear.stomach.count)\n end",
"def hit_ebay\n self.gimmie_the_goods(self.ebay_grab)\n end",
"def get_fish\n\t# Return the current fish to eat\n\treturn $cur_fish\nend",
"def new\n @fish.Fish.new\n end",
"def test_buy_drink_from_pub\n pub = Pub.new(\"McCulls\", 0)\n drink = Drink.new(\"gin\", 5)\n\n @customer.buy_drink(drink)\n pub.serve_drink(drink)\n\n assert_equal(45, @customer.amount)\n assert_equal(5, pub.till)\n\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def catch_fish\n inventory[:fish] += @skills[:fish]\n end",
"def eat_fish(fish)\n @stomach << fish\n end",
"def look_for_food(fish)\n fish.stop_turn\n food_range = fish.food_perception\n food = food_around(fish.position, food_range)\n if food.size > 0 && !(fish.status==Escaping)\n food_found = food[0]\n if fish.position.distance(food_found.position) <= EatingAndMatingRange\n fish.consume(food_found)\n @food.delete(food_found)\n @food.compact!\n else\n fish.spot_food(food_found)\n end\n end\n end",
"def river_held_fish(fish)\n @fish << Fish_name\nend",
"def initialize(name)\n @name = name\n @fishes = []\n end",
"def create\n if params[:tournament_id].present?\n @tournament = Tournament.find(params[:tournament_id])\n @fish = @tournament.fish.new(fish_params)\n else\n @fish = Fish.new(fish_params)\n end\n @fish.member = @current_member\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish.tournament, notice: 'Fish was successfully created.' }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def take_fish_from_river(river)\n fish = river.get_fish#fish is a variable created just for function it grabs something from the 'get fish method in river'\n @bear_food<< fish unless fish.nil? #it then pushes it to the @food array\n end",
"def test_hunt__success()\n river = River.new(\"Nile\", [\"Tuna\", \"Shark\"])\n @bear.hunt(river)\n assert_equal(1, @bear.fish_in_stomach)\n end",
"def take_fish_from_river\n @stomach.concact(fish_count)\n end",
"def test_eat\n fish_before = @river.fish.length\n fish_target = @river.fish[@river.fish.length-1].name\n @bear1.eat_from(@river)\n fish_after = @river.fish.length\n assert_equal(1, fish_before - fish_after)#checks 1 fish has been removed from river\n assert_equal(fish_target, @bear1.belly[@bear1.belly.length-1])#checks bear's belly contains the fish that it should have eaten from the river\n end",
"def cook\n @burger.thaw\n @burger.make_patty\n @burger.grill\n end",
"def feed_fish\n pets[:fishes].each do |fish|\n fish.mood = \"happy\"\n end\n end",
"def test_check_fish\n assert_equal(0, @river1.check_fish)\n end",
"def buy_dog(dog_name)\n new_dog = Dog.new(dog_name, self)\nend",
"def eat_fish(fish)\n @empty_stomach << fish\n return @empty_stomach.count\n end",
"def feed_fish\n self.pets[:fishes].each do |fish|\n fish.mood = \"happy\"\n end\n end",
"def take_fish_from_river(river)\n fish = river.get_fish()\n @stomach << fish if !fish.nil?\n end",
"def create\n @fish = Fish.new(fish_params)\n\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish, notice: \"Fish was successfully created.\" }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def feed_fish\n @pets[:fishes].each {|fish| fish.mood = \"happy\"}\n end",
"def create\n @fish = Fish.new(fish_params)\n\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish, notice: 'Fish was successfully created.' }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fish = Fish.new(fish_params)\n\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish, notice: 'Fish was successfully created.' }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def feed_fish\n @pets[:fishes].each { |fish| fish.mood = \"happy\"}\n end",
"def create\n @fishing_method = FishingMethod.new(params[:fishing_method])\n\n respond_to do |format|\n if @fishing_method.save\n format.html { redirect_to @fishing_method, notice: 'Fishing method was successfully created.' }\n format.json { render json: @fishing_method, status: :created, location: @fishing_method }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fishing_method.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_bear_eats_from_river__full()\n river1 = River.new(\"Tweed\", [@fish1, @fish2])\n @bear.bear_eats_from_river(river1)\n assert_equal(2, @bear.bear_stomach())\n assert_equal(0, river1.fishes_count())\n end",
"def deal_cards\n go_fish.deal_cards\n save!\n end",
"def food_and_drink; 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_cat(name)\n Cat.new(name, self)\nend",
"def fish_params\n params.require(:fish).permit(:name, :description, :price, :user_id)\n end",
"def test_can_afford_buy_drink__true()\n customer = Customer.new(\"Jane\", 10, 25)\n drink = Drink.new(\"Beer\", 2, 6.4)\n assert_equal(true, customer.can_afford_buy_drink(drink))\nend",
"def eat_fish_from_river(fish, river)\n @stomach.push(fish)\n river.lose_fish(fish)\n end",
"def test_buy_drink\n @Tom.buy_drink(\"bub\")\n assert_equal(135, @Tom.wallet)\n end",
"def test_sell_loaves\n @bakery.sell_loaves(4,\"sourdough\")\n assert_equal(20, @bakery.get_loaf_stock(\"sourdough\"))\n assert_equal(66, @bakery.get_cash)\n end",
"def test_espresso_more_effective\n hipster = Human.new \"Hipster\"\n espresso = Espresso.new \"Espresso\"\n\n hipster.buy espresso\n assert espresso.drinks_before_empty == 1\n\n hipster.drink!\n assert (hipster.alertness > 0.4)\n\n end",
"def eat\n inventory[:fish] -= @daily_appetite = 10\n\n if inventory[:fish] < 0\n @alive = false\n inventory[:fish] = 0\n end\n end",
"def release_bike\n #fail 'No bikes available' if @bikes.empty?\n fail 'No bikes available' if empty?\n #use private helper method empty? Single Responsibility Principle\n #@bikes.pop use private attr_reader\n #Bike.new\n bikes.pop\n end",
"def get_fish() # bear will takes the fish#\n return @fish1.pop\nend",
"def give_away(dev, freebie)\n # dev_owns.give_away(Dev.find(2), Freebie.find(6))\n # if dev_owns == freebie.dev\n # if self == freebie.dev \n # # updates the freebie's dev_id to be the id of the instance of Dev passed in as an argument\n # freebie.update(dev_id: dev.id)\n # else \n # \"you can't give what you don't have.\"\n # end\n\n # if self.received_one?(freebie.item_name)\n # freebie.dev = dev\n # freebie.save\n # else\n # puts \"Not your freebie!\"\n # end\n\n freebie.update(dev: dev) unless freebie.dev != self\n\n end",
"def test_bear_eats_fish\n @bear.eats\nend",
"def create\n @fish = Fish.new(fish_params)\n @fish.user_id = current_user.id\n\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish, notice: 'Fish was successfully created.' }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_guest_cannot_buy_drink_if_they_have_insufficient_funds\n @room1.add_drinks_to_stock(@drink1)\n @room1.add_drinks_to_stock(@drink2)\n guest6=Guest.new(\"Kaka\", 1.00, \"Always look on the bright side of life.\")\n guest6.show_tab\n expected = \"You can't afford this drink.\"\n assert_equal(expected, @room1.refuse_guest_drink_if_they_cannot_afford_it(guest6, @drink1))\n end",
"def buy_dog(dog_name)\n new_dog = Dog.new(dog_name, self)\n # tommy.buy_cat(\"Garfield\")\n end",
"def fish_eaten(eat_fish)\n fish = find_fish(eat_fish)\n fishes.delete(fish)\nend",
"def buy()\n #films the customer has tickets to\n all_films = films()\n #sum the films (as there can be more than one) and from each film add the price up and assign it to price\n price = all_films.sum{|film| film.price}\n remaining_funds = @funds - price\n @funds = remaining_funds\n update() #update the customer's funds!\n end",
"def check_fish(fh)\n\tif !($fish.include?(fh))\n\t\traise \"A valid type of fish has NOT been entered.\"\n\tend\n\t\n\t# Set the current fish\n\tset_next_fish(fh)\nend",
"def bought?\n # paym\n end",
"def buy_dog(name)\n Dog.new(name,self)\n end",
"def test_get_food\n @fdb = setup\n @food = @fdb.get_food(\"Jelly\")\n assert(@food != nil, \"basicFood not gotten\")\n assert(@food.name == \"Jelly\", \"wrong food gotten\")\n\n @food = @fdb.get_food(\"Ice cream\")\n assert(@food == nil, \"Food gotten when food doesn't exist in database\")\n end",
"def spot_food(food)\n @fish.direction = @fish.move_towards(food)\n @fish.status = Pursuing\n @fish.target = food\n end",
"def buy_cat(name)\n new_cat = Cat.new(name, self)\nend",
"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 add_fish (fish)\n @fish_population << fish\n\n end",
"def buy(movie)\n end",
"def set_next_fish(fhh)\n\t# Check if the next fish to eat is valid\n\t#check_fish(fhh)\n\t\n\t$cur_fish = fhh\nend",
"def trade; end",
"def spawn_fish(n=20)\n for i in 0..n-1\n type = Aqua::Salmon\n srand\n sex = rand(2) == 0 ? Aqua::Male : Aqua::Female\n fish_desc = {\n 'type' => type,\n 'sex' => sex,\n 'speed' => Aqua::DefaultSpeed, # the following 3 can be lumped into one constant\n 'world_perception' => Aqua::DefaultWorldVision,\n 'food_perception' => Aqua::DefaultFoodPerception,\n 'mate_perception' => Aqua::DefaultMatePerception,\n 'position' => Aqua::Position.new([randomFloatSigned, 0, randomFloatSigned]),\n 'direction_change_factor' => Aqua::DefaultChangeFactor\n };\n self << Aqua::SalmonObject.new(fish_desc)\n end\n end",
"def buy_dog(name)\n new_dog = Dog.new(name,self)\n end",
"def buy!(buyer_planet, amount)\n raise GameLogicError.new(\"Cannot buy 0 or less! Wanted: #{amount}\") \\\n if amount <= 0\n amount = from_amount if amount > from_amount\n \n cost = (amount * to_rate).ceil\n buyer_source, bs_attr = self.class.resolve_kind(buyer_planet, to_kind)\n buyer_target, bt_attr = self.class.resolve_kind(buyer_planet, from_kind)\n if system?\n seller_target = nil\n else\n seller_target, _ = self.class.resolve_kind(planet, to_kind)\n end\n \n stats = CredStats.buy_offer(buyer_planet.player, cost) \\\n if seller_target.nil? && to_kind == KIND_CREDS\n \n buyer_has = buyer_source.send(bs_attr)\n raise GameLogicError.new(\"Not enough funds for #{buyer_source\n }! Wanted #{cost} #{bs_attr} but it only had #{buyer_has}.\"\n ) if buyer_has < cost\n \n # Used to determine whether to send notification or not.\n original_amount = from_amount\n \n # Subtract resource that buyer is paying with from him.\n buyer_source.send(:\"#{bs_attr}=\", buyer_has - cost)\n # Add resource that buyer has bought from seller.\n buyer_target.send(:\"#{bt_attr}=\", \n buyer_target.send(bt_attr) + amount)\n # Add resource that buyer is paying with to seller. Unless:\n # * its a system offer\n # * or #to_kind is creds and planet currently does not have an owner\n seller_target.send(\n :\"#{bs_attr}=\", seller_target.send(bs_attr) + cost\n ) unless seller_target.nil?\n # Reduce bought amount from offer.\n self.from_amount -= amount\n \n objects = [buyer_source, buyer_target]\n # We might not have seller target. See above.\n objects.push seller_target unless seller_target.nil?\n objects.uniq.each { |obj| self.class.save_obj_with_event(obj) }\n\n if from_amount == 0\n # Schedule creation of new system offer.\n CallbackManager.register(\n without_locking { galaxy },\n CALLBACK_MAPPINGS[from_kind],\n Cfg.market_bot_random_resource_cooldown_date\n ) if system?\n destroy!\n else\n save!\n end\n percentage_bought = amount.to_f / original_amount\n\n MarketRate.subtract_amount(galaxy_id, from_kind, to_kind, amount)\n\n # Create notification if:\n # * It's not a system notification\n # * Enough of the percentage was bought\n # * Sellers planet currently has a player.\n Notification.create_for_market_offer_bought(\n self, buyer_planet.player, amount, cost\n ) if ! system? &&\n percentage_bought >= CONFIG['market.buy.notification.threshold'] &&\n ! planet.player_id.nil?\n\n stats.save! unless stats.nil?\n\n amount\n end",
"def test_fish_in_river()\n assert_equal(0, @river.fish_in_river())\n end",
"def test_code2(flight_planner_instance)\n puts flight_planner_instance.can_i_fly?(\"MIA\", \"LAX\") == false\n puts flight_planner_instance.can_i_fly?(\"PHX\", \"LAX\") == true\nend",
"def test_get\n @fdb = setup\n @food = @fdb.get(\"Jelly\")\n assert(@food != nil, \"basicFood not gotten\")\n assert(@food.is_a?(BasicFood), \"Not a BasicFood\")\n assert(@food.name == \"Jelly\", \"wrong food gotten\")\n\n @food = @fdb.get(\"Ice cream\")\n assert(@food == nil, \"Food gotten when food doesn't exist in database\")\n\n \n @food = @fdb.get(\"PB&J Sandwich\")\n assert(@food != nil, \"Recipe not gotten\")\n assert(@food.is_a?(Recipe), \"not a recipe found\")\n assert(@food.name == \"PB&J Sandwich\", \"wrong recipe gotten\")\n\n @food = @fdb.get(\"Chocolate Cake\")\n assert(@food == nil, \"Recipe gotten when recipe doesn't exist in database\")\n end",
"def initialize (name) #when a fish is created in CL ie. f1 = Fish.new('nemo'), this method will autorun, and you have to give it a name\n puts 'new fish is born'\n # health = 10 # local\n @health = 10 # increases to an instance variable\n @speed = 5\n @name = name\n stomach = [ ]\n\n end",
"def buy_dog(dog)\n new_dog = Dog.all.find do |dog_instance|\n dog_instance.name == dog \n end\n if new_dog \n Dog.new(new_dog.name, self)\n else \n brand_new_dog = Dog.new(dog, self)\n end \n end",
"def skier_quest; 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 turn_player\n go_fish.turn_player\n end",
"def test_creating_your_own_chair\n your_chair = Chair.new\n your_chair.build_chair(__, __, __)\n your_chair.paint_the_chair\n\n assert_equal 10, your_chair.tell_me_your_tall\n\n assert_equal 7, your_chair.tell_me_your_width\n end",
"def add_food\n srand\n self << FishFood.new(Position.new([randomFloatSigned*2,1,randomFloatSigned]))\n end",
"def release_bike\n# the method will 'raise' an exception stating no bikes, if\n# the @rack array is empty\n raise \"No bikes available\" if @rack.empty?\n# Otherwise by implicit return it will instantiate a new Bike\n Bike.new\n end",
"def setup\n @bear = Bear.new(\"Charles\", [])\n\n\n#fish_1 = Fish.new(\"Tuna Turner\") need to define fish first, because you are putting it into the river later\n#@fish_2 = Fish.new(\"Margaret\")\n#fish = [fish_1, fish_2]\n#@river = River.new(\"Forth\", fish)\n#end\n\n end",
"def offer\n end",
"def offer\n end"
] |
[
"0.7892063",
"0.75105274",
"0.7415106",
"0.71251506",
"0.71078",
"0.71078",
"0.7060742",
"0.6967579",
"0.68729085",
"0.68459284",
"0.6725376",
"0.64211845",
"0.63710755",
"0.6366283",
"0.6306252",
"0.62900853",
"0.6183415",
"0.612467",
"0.5968325",
"0.5957169",
"0.59326524",
"0.58284634",
"0.58167243",
"0.58167243",
"0.58167243",
"0.58167243",
"0.58167243",
"0.58167243",
"0.577356",
"0.5750215",
"0.5737228",
"0.5734636",
"0.57129604",
"0.5693022",
"0.5692099",
"0.56816536",
"0.56816155",
"0.5660486",
"0.5648958",
"0.5646229",
"0.563517",
"0.56166255",
"0.56093746",
"0.55939144",
"0.5585866",
"0.5554306",
"0.5550712",
"0.5526133",
"0.5526133",
"0.5525838",
"0.5509467",
"0.5503763",
"0.549234",
"0.54919446",
"0.5489747",
"0.5488349",
"0.54871356",
"0.5475567",
"0.5475476",
"0.54714864",
"0.5453053",
"0.5451286",
"0.5446958",
"0.54370105",
"0.54347134",
"0.5421828",
"0.5420331",
"0.5401773",
"0.5383818",
"0.53788334",
"0.536978",
"0.5363599",
"0.5361761",
"0.5352868",
"0.5351782",
"0.5345523",
"0.5337392",
"0.5337355",
"0.5329003",
"0.5327251",
"0.53264683",
"0.53244704",
"0.532394",
"0.5309783",
"0.5302368",
"0.5299838",
"0.5295876",
"0.5295318",
"0.5294713",
"0.529388",
"0.5288023",
"0.52874786",
"0.5285722",
"0.5280455",
"0.52803946",
"0.5275622",
"0.5271304",
"0.5269094",
"0.5268553",
"0.5268553"
] |
0.7428818
|
2
|
buy_cat can buy a cat that is an instance of the Cat class (FAILED 3) knows about its cats (FAILED 4)
|
def buy_cat(cat_name)
cat = Cat.new(cat_name)
self.pets[:cats] << cat
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def buy_cat(name) # expect(owner.pets[:cats].count).to eq(0)\n new_cat = Cat.new(name) # owner.buy_cat(\"Crookshanks\")\n self.pets[:cats] << new_cat # owner.pets[:cats].each { |cat| expect(cat).to be_a(Cat) }\n new_cat # expect(owner.pets[:cats].count).to eq(1)\n # = knows about its cats; Owner knows all about its pets - Owner sets name of pet, the pet can\\'t change its name\n # owner.buy_cat(\"Crookshanks\")\n # expect(owner.pets[:cats][0].name).to eq(\"Crookshanks\")\n end",
"def buy_cat(cat)\n new_cat = Cat.all.find do |cat_instance|\n cat_instance.name == cat \n end\n if new_cat \n Cat.new(new_cat.name, self)\n else \n brand_new_cat = Cat.new(cat, self)\n end \n end",
"def buy_cat(name)\n #knows about its cats\n pets[:cats] << Cat.new(name)\n end",
"def buy_cat(name)\n Cat.new(name, self)\nend",
"def buy_cat(name)\n Cat.new(name,self)\n end",
"def buy_cat(name)\n new_cat = Cat.new(name, self)\nend",
"def buy_cat(cat_name)\n new_cat = Cat.new(cat_name, self)\n # self.cats << new_cat\n # binding.pry\n end",
"def buy_cat(cat_name)\n self.cats << Cat.new(cat_name,self)\n end",
"def buy_cat(name)\n #passing a name and this owner object into the cat object\n cat = Cat.new(name, self) \n @cats << cat\n \n end",
"def buy_cat(name)\n Cat.new(name, self)\n end",
"def buy_cat(name)\n Cat.new(name, self)\n end",
"def buy_cat(name)\n Cat.new(name, self)\n end",
"def buy_cat(name)\n Cat.new(name, self)\n end",
"def buy_cat(cat_name)\n Cat.new(cat_name, self)\n end",
"def buy_cat(name)\n cat = Cat.new(name)\n @pets[:cats] << cat\n end",
"def buy_cat(name)\n pets[:cats] << Cat.new(name)\n end",
"def buy_cat(name)\n Cat.new(name, self)\n end",
"def buy_dog(dog_name)\n new_dog = Dog.new(dog_name, self)\n # tommy.buy_cat(\"Garfield\")\n end",
"def buy_dog(name)\n#know sabout its dogs\n pets[:dogs] << Dog.new(name)\n end",
"def can_buy?(item)\r\n item.buyable_by?(self)\r\n end",
"def cats\n #loop through .all class method for the class Cat\n #select the value for variable cat and return it to a new array\n #every time cat.owner == self is true\n Cat.all.select do |cat|\n #block determines true value\n cat.owner == self #returns if true\n end\n end",
"def buy_fish(name) # expect(owner.pets[:fishes].count).to eq(0)\n new_fish = Fish.new(name) # owner.buy_fish(\"Bubbles\")\n self.pets[:fishes] << new_fish # owner.pets[:fishes].each { |fish| expect(fish).to be_a(Fish)}\n new_fish # expect(owner.pets[:fishes].count).to eq(1)\n # = knows about its fishes; Owner knows all about its pets - Owner sets name of pet, the pet can\\'t change its name\n # owner.buy_fish(\"Bubbles\")\n # expect(owner.pets[:fishes][0].name).to eq(\"Bubbles\")\n end",
"def can_buy?(item)\n item.buyable_by?(self)\n end",
"def category_produits?()\n return (self.category.code.eql?('produits_phyto')) \n end",
"def buy_fish(name)\n new_fish = Fish.new(name)\n if new_fish.class == Fish\n @pets[:fishes] << new_fish\n end \n end",
"def check_category!\n if self.category and (not self.category.saved?) and loaded = BookingCategory.get(self.category.code)\n self.category = loaded\n end\n if self.rental_storage and (not self.rental_storage.saved?) and loaded = RentalStorage.get(self.rental_storage.id)\n self.rental_storage = loaded\n end\n end",
"def find_cat\n @cat = Cat.find(params[:cat_id])\n end",
"def meow # Define a method that allows any instance of Cat to meow\n puts \"meow!\"\n end",
"def sell_pet_to_customer(petshop,pet,customer)\n\n if (customer[:cash] >= pet[:price]) #&& (petshop[:pets][:name] == pet[:name])\n customer[:pets].push(pet[:name])\n end\n # return customer[:pets].count()\n end",
"def cats_at_this_cafe\n Cat.all.select do |cat| \n cat.cafe == self \n end\n end",
"def test_category_purged\n religion_cat_original_id = @religion_cat.id\n assert @importance_of_religion.categories_string = @work_cat.name\n assert @importance_of_religion.save\n assert @importance_of_religion.categories.include?(@work_cat)\n assert !@importance_of_religion.categories.include?(@religion_cat)\n assert_raise(ActiveRecord::RecordNotFound) { Category.find(religion_cat_original_id) }\n end",
"def cats \n Cat.all.select do |cat_instance|\n cat_instance.owner == self \n end\n end",
"def buy_dog(dog_name)\n dog = Dog.new(dog_name)\n self.pets[:dogs] << dog\n end",
"def printCat(cat)\n puts cat.name \n puts cat.breed \n puts cat.poopSize \nend",
"def sell_pets #Owner can sell all its pets, which make them nervous\n # fido = Dog.new(\"Fido\")\n # tabby = Cat.new(\"Tabby\")\n # nemo = Fish.new(\"Nemo\")\n # [fido, tabby, nemo].each {|o| o.mood = \"happy\" }\n # owner.pets = {\n # :dogs => [fido, Dog.new(\"Daisy\")],\n # :fishes => [nemo],\n # :cats => [Cat.new(\"Mittens\"), tabby]\n # }\n # owner.sell_pets\n # owner.pets.each {|type, pets| expect(pets.empty?).to eq(true) }\n # [fido, tabby, nemo].each { |o| expect(o.mood).to eq(\"nervous\") }\n pets.each do |type, animals|\n animals.each do |animal|\n animal.mood = \"nervous\"\n end\n animals.clear\n end\n end",
"def buy_dog(dog)\n new_dog = Dog.all.find do |dog_instance|\n dog_instance.name == dog \n end\n if new_dog \n Dog.new(new_dog.name, self)\n else \n brand_new_dog = Dog.new(dog, self)\n end \n end",
"def cats\n\t\t# Note that you call upon the other class within this class.\n\t\tCat.all.select do |cat|\n\t\t\tcat.owner == self\n\t\tend\n\tend",
"def valid_fee_amort_category?(cat)\n cats = Ext::FeeAmortization::FEES.map(&:classify).map(&:to_s)\n cats << \"TranchePeggedItem\"\n cats.include?(cat.to_s)\n end",
"def buy_fish(name)\n#knows about its fishes\n pets[:fishes] << Fish.new(name)\n end",
"def customer_can_afford_pet(customer,new_pet)\n customer_cash=customer[:cash]\n @pet_shop[:pets].push(new_pet)\n for pet in @pet_shop[:pets] do\n if customer_cash >= pet[:price] \n return true\n else\n return false\n end\n end\n end",
"def test_feature_for_category\r\n\t\tfeatures = Feature.for_category(categories(:root).id, 99)\r\n\r\n\t\tassert_equal(2, features.length)\r\n\t\tassert_equal(true, features.include?(products(:persian)))\r\n\t\tassert_equal(true, features.include?(products(:cow2)))\r\n\r\n\t\tfeatures = Feature.for_category(categories(:livestock).id, 99)\r\n\r\n\t\tassert_equal(1, features.length)\r\n\t\tassert_equal(true, features.include?(products(:optioner)))\r\n\r\n\t\tfeatures = Feature.for_category(categories(:dogs).id, 99)\r\n\r\n\t\tassert_equal(3, features.length)\r\n\t\tassert_equal(true, features.include?(products(:cow2)))\r\n\t\tassert_equal(true, features.include?(products(:cow3)))\r\n\t\tassert_equal(true, features.include?(products(:optioner))) # inherited from livestock\r\n\r\n\t\tfeatures = Feature.for_category(categories(:dogs).id)\r\n\r\n\t\tassert_equal(1, features.length)\r\n\r\n\t\t# check that the correct number is given when the number to return is < the number of\r\n\t\t# results found in the db\r\n\t\tfeatures = Feature.for_category(categories(:dogs).id, 1)\r\n\r\n\t\tassert_equal(1, features.length)\r\n\r\n\t\tfeatures = Feature.for_category(categories(:dogs).id)\r\n\r\n\t\tassert_equal(1, features.length)\r\n\r\n\t\t# check a blank return\r\n\t\tfeatures = Feature.for_category(categories(:utilities).id, 1)\r\n\r\n\t\tassert_equal(0, features.length)\r\n\tend",
"def find_cat_fact\n @fact = @cat.facts.find_by!(id: params[:id]) if @cat\n end",
"def buy_dog(name)\n dog = Dog.new(name, self)\n @dogs << dog\n end",
"def buy_dog(name)\n pets[:dogs] << Dog.new(name)\n end",
"def can_sell_drug?(drug)\n drug.can_be_sold?\n end",
"def buy_dog(dog_name)\n self.dogs << Dog.new(dog_name,self)\n end",
"def buy_dog(name)\n dog = Dog.new(name)\n @pets[:dogs] << dog\n end",
"def set_cat\n @cat = Cat.find(params[:id])\n end",
"def cats \n Cat.all.select {|one_cat| one_cat.owner == self} \n end",
"def sell_pet_to_customer(shop,pet,customer)\n if pet != nil && customer_can_afford_pet(customer,pet) == true\n for animal in shop[:pets]\n if animal[:name] == pet[:name]\n amount = pet[:price]\n add_pet_to_customer(customer,pet)\n customer_pet_count(customer)\n increase_pets_sold(shop,1)\n remove_customer_cash(customer,amount)\n add_or_remove_cash(shop,amount)\n end\n end\n end\nend",
"def buy_dog(dog_name)\n new_dog = Dog.new(dog_name, self)\nend",
"def sell_pet_to_customer(shop,pet,customer)\n if pet != nil && customer_can_afford_pet(customer,pet)#this result returns true anyway and so my ==true in my version was not needed\n add_pet_to_customer(customer,pet)\n remove_pet_by_name(shop,pet)\n remove_customer_cash(customer,pet[:price])\n add_or_remove_cash(shop,pet[:price])\n increase_pets_sold(shop,1)\n end\nend",
"def buy_fish(fish_name)\n fish = Fish.new(fish_name)\n self.pets[:fishes] << fish\n end",
"def buy_fish(name)\n new_fish = Fish.new(name)\n self.pets[:fishes] << new_fish \n end",
"def buy_dog(name)\n Dog.new(name,self)\n end",
"def set_cat\n @cat = Cat.find(params[:id])\n end",
"def set_cat\n @cat = Cat.find(params[:id])\n end",
"def attemp_buying\n\n end",
"def test_buy_drink_from_pub\n pub = Pub.new(\"McCulls\", 0)\n drink = Drink.new(\"gin\", 5)\n\n @customer.buy_drink(drink)\n pub.serve_drink(drink)\n\n assert_equal(45, @customer.amount)\n assert_equal(5, pub.till)\n\n end",
"def sell_pet_to_customer(shop, pet, customer)\n if find_pet_by_name(shop, pet) != nil\n then\n if customer_can_afford_pet(customer, pet)\n then\n add_pet_to_customer(customer, pet)\n # remove_pet_by_name(shop, pet)\n increase_pets_sold(shop, 1)\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(shop, pet[:price])\nend\nend\nend",
"def test_listable\n assert_equal(0, categories(:category1).listable_products.size)\n assert_equal(2, categories(:category2).listable_products.size)\n assert_equal(products(:product1), categories(:category2).listable_products[0])\n assert_equal(products(:product2), categories(:category2).listable_products[1])\n assert_equal(2, categories(:category3).listable_products.size)\n assert_equal(products(:product3), categories(:category3).listable_products[0])\n assert_equal(products(:product5), categories(:category3).listable_products[1])\n end",
"def buy_pet(pet)\n self.pets.push(pet)\n pet.owner = self\n end",
"def test_sell_pet_to_customer__pet_found\n customer = @customers[0]\n pet = find_pet_by_name(@pet_shop,\"Arthur\")\n\n sell_pet_to_customer(@pet_shop, pet, customer)\n\n assert_equal(1, customer_pet_count(customer)) #checks the customer pet count so we need to add the pet into the :pets array\n assert_equal(1, pets_sold(@pet_shop)) #checks the pet is sold so we need to add 1 to admin: pets_sold:\n assert_equal(100, customer_cash(customer)) #checks the cash has been deducted from the customers cash e.g. customer cash should = customer cash - cost of the pet\n assert_equal(1900, total_cash(@pet_shop)) #checks the price of the pet is added to the total total cash\n end",
"def find_owner_cat\n @cat = @owner.cats.find_by!(id: params[:id]) if @owner\n end",
"def set_cat_item\n @cat_item = CatItem.find(params[:id])\n end",
"def can_buy_drug?(price, qty)\n wallet > (price * qty) \n end",
"def cats\n Cat.all.select do |cat| \n cat.owner == self \n end \n end",
"def buy_dog(name)\n new_dog = Dog.new(name,self)\n end",
"def set_cat_blok\n @cat_blok = CatBlok.find(params[:id])\n end",
"def bought?\n # paym\n end",
"def test_truth\r\n assert_kind_of CptCategory, @categories\r\n assert_not_equal @mycategory.id, @categories.id\r\n assert_not_equal @mycategory.description, @categories.description\r\n assert_not_equal @mycategory.level, @categories.level\r\n end",
"def is_cuffed?\n return weapon_id == 33\n end",
"def sell_pet_to_customer(pet_shop, pet, customer)\n\n\n if pet != nil && customer_can_afford_pet(customer, pet)\n\n add_pet_to_customer(customer, pet)\n customer_pet_count(customer)\n\n\n increase_pets_sold(pet_shop, customer_pet_count(customer))\n pets_sold(pet_shop)\n\n\n remove_customer_cash(customer, pet[:price])\n customer_cash(customer)\n\n add_or_remove_cash(pet_shop, pet[:price])\n total_cash(pet_shop)\n\n end\n\nend",
"def can_buy_depot_train?(entity)\n entity.cash >= @depot.upcoming.first.price\n end",
"def cats\n Cat.all.select {|cat| cat.owner == self}\n end",
"def popular_recipe_card\n RecipeCard.all.select do |recipe_card_ob|\n #binding.pry\n # to test this pry - call this method on an instance of a Recipe\n #(IE - taco.popular_recipe_card)\n recipe_card_ob.recipe == self\n end\nend",
"def buy_dog(new_name)\n # @dogs << Dog.new(name, self)\n Dog.new(new_name, self)\n end",
"def sell_pet_to_customer(pet_shop, pet, customer)\n customer[:pets].count\n pet_shop[:admin][:pets_sold]\n customer[:cash]\n pet_shop[:admin][:total_cash]\nend",
"def cats\n Cat.all.select do |cat|\n cat.owner == self\n end\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 sell_pet_to_customer(pet_shop, pet, customer)\n if pet && customer_can_afford_pet(customer, pet) \n add_pet_to_customer(customer, pet)\n increase_pets_sold(pet_shop, 1)\n add_or_remove_cash(pet_shop, pet[:price])\n end\nend",
"def sell_pet_to_customer(pet_shop, pet, customer)\n for l_pet_shop in pet_shop[:pets]\n if l_pet_shop == pet\n if customer_can_afford_pet(customer, pet) == true\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(pet_shop, pet[:price])\n add_pet_to_customer(customer, pet)\n increase_pets_sold(pet_shop, 1)\n end\n end\n end\nend",
"def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end",
"def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end",
"def show\n @products = @category.products.all\n\n if @products.exists?\n @products_max_price = @products.order(price: :desc).limit(1).take.price\n end\n @category_brands = []\n @products.each do |prod|\n if @category_brands.index(prod.brand).nil?\n @category_brands.push(prod.brand)\n end\n end\n @cart_item = current_cart.cart_items.new\n end",
"def buy_dog(name)\n Dog.new(name, self)\n end",
"def buy_dog(name)\n Dog.new(name, self)\n end",
"def cards_in_category(category)\n # Accumulate cards that match the input category using\n @cards.find_all do |card|\n card.category == category\n end\n end",
"def category\n\n User.find(@toko.user_id).produks.each do |produk|\n @cat = produk.category_id\n end\n end",
"def buy_dog(name)\n dog = Dog.new(name, self)\n end",
"def scraper_categories\n scraped = Scraper.scrape_website\n Flower.all \n #find method?\n # if price == $0..$79\n # @@low << flower_object\n # elsif == $80..$149\n # @@med << flower_object\n # else\n # @@high << flower_object\n # end \n\n # binding.pry\n end",
"def sell_pet_to_customer(pet_shop, pet, customer)\n # the customer pet count increases by 1\n if pet != nil\n customer_can_afford_pet(customer, pet)\n add_pet_to_customer(customer, pet)\n increase_pets_sold(pet_shop, 1)\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(pet_shop, pet[:price])\n end\nend",
"def sell_pet_to_customer(shop, pet, customer)\n for animal in shop[:pets]\n if animal == pet && customer_can_afford_pet(customer, pet) == true\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(shop, pet[:price])\n increase_pets_sold(shop,1)\n add_pet_to_customer(customer, pet)\n remove_pet_by_name(shop, pet)\n end\n end\nend",
"def buy(movie)\n end",
"def set_vendor_cat\n @vendor_cat = VendorCat.find(params[:id])\n end",
"def sell_pet_to_customer(pet_shop, pet, customer)\n if\n pet_shop[:admin][:total_cash] += pet[:price]\n customer[:cash] -= pet[:price]\n else\n p \"Not enough dough :( \"\n end\n customer[:pets] << pet\n pet_shop[:admin][:pets_sold] += [:pets].count()\nend",
"def sell_pets\n Cat.all.collect do |cats|\n cats.mood=\"nervous\"\n cats.owner=nil\n end\n Dog.all.collect do |dogs|\n dogs.mood=\"nervous\"\n dogs.owner=nil\n end\n end",
"def check_basket(basket)\n increase_support if in_basket?(basket)\n end",
"def bet(chips)\n\n end",
"def set_category\n @category = GoodCategory.find(params[:id])\n end"
] |
[
"0.77343345",
"0.7412346",
"0.7361814",
"0.7341354",
"0.7273689",
"0.7218789",
"0.7217713",
"0.7215786",
"0.71946025",
"0.7105338",
"0.7105338",
"0.7105338",
"0.7105338",
"0.7074326",
"0.70086014",
"0.6988133",
"0.6886837",
"0.5900335",
"0.57850444",
"0.57291144",
"0.5677426",
"0.566209",
"0.56281465",
"0.5577109",
"0.55419195",
"0.5493083",
"0.5489004",
"0.5450401",
"0.5447578",
"0.54445916",
"0.54183286",
"0.5413569",
"0.5406557",
"0.54032624",
"0.53712445",
"0.5371129",
"0.53708947",
"0.5364791",
"0.5338024",
"0.5318984",
"0.5317355",
"0.53173006",
"0.53130764",
"0.53100157",
"0.5303137",
"0.529793",
"0.52895516",
"0.52701896",
"0.5259799",
"0.52486265",
"0.5235677",
"0.5205477",
"0.52045226",
"0.5196021",
"0.51930416",
"0.51902354",
"0.51902354",
"0.5188573",
"0.51843613",
"0.5178811",
"0.5172116",
"0.51641005",
"0.51632595",
"0.51575804",
"0.5156943",
"0.5150887",
"0.5150365",
"0.51428074",
"0.513699",
"0.5127995",
"0.51251256",
"0.5110457",
"0.5103436",
"0.5096978",
"0.50822324",
"0.50799656",
"0.5079181",
"0.5078385",
"0.5076492",
"0.5068636",
"0.50685495",
"0.5067621",
"0.5063609",
"0.5063609",
"0.50612205",
"0.5054435",
"0.5054435",
"0.5049695",
"0.50431204",
"0.50423324",
"0.5035862",
"0.50298077",
"0.50276893",
"0.5020636",
"0.50204414",
"0.50179964",
"0.500822",
"0.50067675",
"0.50058717",
"0.5004158"
] |
0.7232027
|
5
|
buy_dog can buy a dog that is an instance of the Dog class (FAILED 5) knows about its dogs (FAILED 6)
|
def buy_dog(dog_name)
dog = Dog.new(dog_name)
self.pets[:dogs] << dog
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def buy_dog(dog_name)\n new_dog = Dog.new(dog_name, self)\n # tommy.buy_cat(\"Garfield\")\n end",
"def buy_dog(name)\n Dog.new(name,self)\n end",
"def buy_dog(name)\n new_dog = Dog.new(name,self)\n end",
"def buy_dog(name)\n Dog.new(name, self)\n end",
"def buy_dog(name)\n Dog.new(name, self)\n end",
"def buy_dog(name)\n dog = Dog.new(name, self)\n end",
"def buy_dog(name)\n#know sabout its dogs\n pets[:dogs] << Dog.new(name)\n end",
"def buy_dog(dog_name)\n self.dogs << Dog.new(dog_name,self)\n end",
"def buy_dog(dog)\n new_dog = Dog.all.find do |dog_instance|\n dog_instance.name == dog \n end\n if new_dog \n Dog.new(new_dog.name, self)\n else \n brand_new_dog = Dog.new(dog, self)\n end \n end",
"def buy_dog(dog_name)\n new_dog = Dog.new(dog_name, self)\nend",
"def buy_dog(name)\n dog = Dog.new(name, self)\n @dogs << dog\n end",
"def buy_dog(name)\n dog = Dog.new(name)\n @pets[:dogs] << dog\n end",
"def buy_dog(name)\n pets[:dogs] << Dog.new(name)\n end",
"def buy_dog(new_name)\n # @dogs << Dog.new(name, self)\n Dog.new(new_name, self)\n end",
"def buy_fish(name) # expect(owner.pets[:fishes].count).to eq(0)\n new_fish = Fish.new(name) # owner.buy_fish(\"Bubbles\")\n self.pets[:fishes] << new_fish # owner.pets[:fishes].each { |fish| expect(fish).to be_a(Fish)}\n new_fish # expect(owner.pets[:fishes].count).to eq(1)\n # = knows about its fishes; Owner knows all about its pets - Owner sets name of pet, the pet can\\'t change its name\n # owner.buy_fish(\"Bubbles\")\n # expect(owner.pets[:fishes][0].name).to eq(\"Bubbles\")\n end",
"def buy_cat(name) # expect(owner.pets[:cats].count).to eq(0)\n new_cat = Cat.new(name) # owner.buy_cat(\"Crookshanks\")\n self.pets[:cats] << new_cat # owner.pets[:cats].each { |cat| expect(cat).to be_a(Cat) }\n new_cat # expect(owner.pets[:cats].count).to eq(1)\n # = knows about its cats; Owner knows all about its pets - Owner sets name of pet, the pet can\\'t change its name\n # owner.buy_cat(\"Crookshanks\")\n # expect(owner.pets[:cats][0].name).to eq(\"Crookshanks\")\n end",
"def buy_fish(name)\n new_fish = Fish.new(name)\n if new_fish.class == Fish\n @pets[:fishes] << new_fish\n end \n end",
"def buy_fish(name)\n#knows about its fishes\n pets[:fishes] << Fish.new(name)\n end",
"def buy_cat(cat_name)\n cat = Cat.new(cat_name)\n self.pets[:cats] << cat\n\n end",
"def walk_dogs #walks the dogs which makes the dogs' moods happy\n # dog = Dog.new(\"Daisy\")\n # owner.pets[:dogs] << dog\n # owner.walk_dogs\n # expect(dog.mood).to eq(\"happy\")\n pets[:dogs].each do |dog|\n dog.mood = \"happy\"\n end\n end",
"def buy_fish(fish_name)\n fish = Fish.new(fish_name)\n self.pets[:fishes] << fish\n end",
"def buy_cat(name)\n #knows about its cats\n pets[:cats] << Cat.new(name)\n end",
"def buy_cat(name)\n Cat.new(name, self)\nend",
"def buy_fish(name)\n new_fish = Fish.new(name)\n self.pets[:fishes] << new_fish \n end",
"def buy_pet(pet)\n self.pets.push(pet)\n pet.owner = self\n end",
"def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end",
"def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end",
"def buy_cat(name)\n new_cat = Cat.new(name, self)\nend",
"def sell_pets #Owner can sell all its pets, which make them nervous\n # fido = Dog.new(\"Fido\")\n # tabby = Cat.new(\"Tabby\")\n # nemo = Fish.new(\"Nemo\")\n # [fido, tabby, nemo].each {|o| o.mood = \"happy\" }\n # owner.pets = {\n # :dogs => [fido, Dog.new(\"Daisy\")],\n # :fishes => [nemo],\n # :cats => [Cat.new(\"Mittens\"), tabby]\n # }\n # owner.sell_pets\n # owner.pets.each {|type, pets| expect(pets.empty?).to eq(true) }\n # [fido, tabby, nemo].each { |o| expect(o.mood).to eq(\"nervous\") }\n pets.each do |type, animals|\n animals.each do |animal|\n animal.mood = \"nervous\"\n end\n animals.clear\n end\n end",
"def buy_cat(name)\n #passing a name and this owner object into the cat object\n cat = Cat.new(name, self) \n @cats << cat\n \n end",
"def buy_cat(name)\n cat = Cat.new(name)\n @pets[:cats] << cat\n end",
"def buy_fish(name)\n @pets[:fishes] << Fish.new(name)\n end",
"def run #instance method, you chain it to an instance of a Dog\n # binding.pry\n puts \"#{@name} the #{@breed} is running fast as the wind\"\n end",
"def buy_cat(cat_name)\n new_cat = Cat.new(cat_name, self)\n # self.cats << new_cat\n # binding.pry\n end",
"def buy_fish(name)\n pets[:fishes] << Fish.new(name)\n end",
"def buy_fish(name)\n pets[:fishes] << Fish.new(name)\nend",
"def set_dog\n @dog = Dog.find(params[:id])\n end",
"def buy_cat(cat)\n new_cat = Cat.all.find do |cat_instance|\n cat_instance.name == cat \n end\n if new_cat \n Cat.new(new_cat.name, self)\n else \n brand_new_cat = Cat.new(cat, self)\n end \n end",
"def set_dog\n @dog = Dog.find(params[:id])\n end",
"def set_dog\n @dog = Dog.find(params[:id])\n end",
"def set_dog\n @dog = Dog.find(params[:id])\n end",
"def set_dog\n @dog = Dog.find(params[:id])\n end",
"def set_dog\n @dog = Dog.find(params[:id])\n end",
"def set_dog\n @dog = Dog.find(params[:id])\n end",
"def set_dog\n @dog = Dog.find(params[:id])\n end",
"def buy_cat(name)\n pets[:cats] << Cat.new(name)\n end",
"def buy_cat(name)\n Cat.new(name,self)\n end",
"def test_buy_drink_from_pub\n pub = Pub.new(\"McCulls\", 0)\n drink = Drink.new(\"gin\", 5)\n\n @customer.buy_drink(drink)\n pub.serve_drink(drink)\n\n assert_equal(45, @customer.amount)\n assert_equal(5, pub.till)\n\n end",
"def initialize(name, dog)\n @name = name\n @dog = dog\n end",
"def set_dog\n @dog = Dog.find(params[:dog_id])\n end",
"def happy_walker?\n @dog_walker.favorite_breed == @dog.breed \n end",
"def can_sell_drug?(drug)\n drug.can_be_sold?\n end",
"def feedPet\n @pet.eat\n end",
"def dogs\n Dog.doggies.select { |dogs| dogs.owner == self }\n end",
"def dog\n Fitbark::Data::DogInfo.new(self[:dog])\n end",
"def dogs\n Dog.all.select do |dog_instance|\n dog_instance.owner == self \n end\n end",
"def dogs\n\t\t# Note that you call upon the other class within this class.\n\t\tDog.all.select do |dog|\n\t\t\tdog.owner == self\n\t\tend\n\tend",
"def initialize(name)\n @name = name\n @@all << self # adds the new dog instance to the @@all array\n end",
"def doom(entity); @doomed << entity; end",
"def set_doggy\n @doggy = Doggy.find(params[:id])\n end",
"def test_bear_take_fish\n @river1.add_fish(@fish1)\n @river1.add_fish(@fish2)\n @bear1.bear_take_fish(@fish1)\n assert_equal(1,@bear1.check_stomach)\n end",
"def hit_ebay\n self.gimmie_the_goods(self.ebay_grab)\n end",
"def buy_cat(name)\n Cat.new(name, self)\n end",
"def buy_cat(name)\n Cat.new(name, self)\n end",
"def buy_cat(name)\n Cat.new(name, self)\n end",
"def buy_cat(name)\n Cat.new(name, self)\n end",
"def test_buy_drink\n @Tom.buy_drink(\"bub\")\n assert_equal(135, @Tom.wallet)\n end",
"def walks\n Walk.all.select { |walk_instance| walk_instance.dog == self }\n end",
"def transfer_dog\n if guest_user.dog.present?\n guest_dog = guest_user.dog\n current_user.dog.destroy if current_user.dog.present?\n guest_dog.user_id = current_user.id\n guest_dog.save!\n end\n end",
"def initialize(name, owner)\n @name = name\n @owner = owner\n @mood = \"nervous\"\n @@all << self\n @owner.dogs << self\n end",
"def walk_dogs\n Dog.all.each do |dog|\n if dog.owner == self\n dog.mood = \"happy\"\n end\n end \n end",
"def buy_cat(cat_name)\n self.cats << Cat.new(cat_name,self)\n end",
"def meow # Define a method that allows any instance of Cat to meow\n puts \"meow!\"\n end",
"def walk_dogs\n pets[:dogs].each do |dog|\n dog.mood = \"happy\"\n end\n end",
"def create\n @battle = Battle.new(battle_params)\n if params[:ghost_pet_id] == 0 or params[:ghost_pet_id] == '0'\n @ghost_archetype = Pet.order(\"RANDOM()\").first\n else\n @ghost_archetype = Pet.find(params[:ghost_pet_id])\n end\n if params[:bounty_id] != nil\n @bounty = Bounty.find(params[:bounty_id])\n @battle.update_attribute(:bounty_id, @bounty.id)\n @bounty.update_attribute(:number_of_bounties, @bounty.number_of_bounties -= 1)\n pay_from = BlockIo.get_user_address user_id: current_user.block_io_wallet_id\n BlockIo.withdraw_from_user from_addresses: pay_from['data']['address'], payment_address: 'DQmRmDRsvPNteofRBPwktTSdmB3NPjkvMd', amount: @bounty.amount\n end\n @ghost = Ghost.new\n @battle.update_attribute(:ghost_id, @ghost.id)\n @battle.update_attribute(:background_url, Guild.order(\"RANDOM()\").first.imageurl)\n @ghost.update_attribute(:name, @ghost_archetype.name)\n @ghost.update_attribute(:imageurl, @ghost_archetype.imageurl)\n @ghost.update_attribute(:element, @ghost_archetype.element)\n @ghost.update_attribute(:user_id, @ghost_archetype.user_id)\n @ghost.update_attribute(:pet_id, @ghost_archetype.id)\n @pet = Pet.find(@battle.pet_id)\n @pet.update_attribute(:health, 100)\n @pet.update_attribute(:magic, 100)\n @ghost.update_attribute(:health, 100)\n @ghost.update_attribute(:magic, 100)\n #now adding copies of pets items to ghost\n @ghost.save\n @battle.ghost = @ghost\n @battle.update_attribute(:b_pet_turn, 'true')\n\n if @pet.against_ghost_losses == nil\n @pet.update_attribute(:against_ghost_losses, 0)\n end\n if @pet.against_ghost_wins == nil\n @pet.update_attribute(:against_ghost_wins, 0)\n end\n if @pet.ghost_losses == nil\n @pet.update_attribute(:ghost_losses, 0)\n end\n if @pet.ghost_wins == nil\n @pet.update_attribute(:ghost_wins, 0)\n end\n\n if Pet.find(@ghost.pet_id).against_ghost_losses == nil\n Pet.find(@ghost.pet_id).update_attribute(:against_ghost_losses, 0)\n end\n if Pet.find(@ghost.pet_id).against_ghost_wins == nil\n Pet.find(@ghost.pet_id).update_attribute(:against_ghost_wins, 0)\n end\n if Pet.find(@ghost.pet_id).ghost_losses == nil\n Pet.find(@ghost.pet_id).update_attribute(:ghost_losses, 0)\n end\n if Pet.find(@ghost.pet_id).ghost_wins == nil\n Pet.find(@ghost.pet_id).update_attribute(:ghost_wins, 0)\n end\n\n respond_to do |format|\n if @battle.save\n Pet.find(@battle.pet_id).update_attribute(:battle_id, @battle.id)\n flash[:notice] = 'Welcome!'\n format.html { redirect_to @battle, notice: 'A new battle has begun! Time to play your first move!' }\n format.json { render :show, status: :created, location: @battle }\n else\n format.html { render :new }\n format.json { render json: @battle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_bear_take_fish\n @bear1 = Bears.new(\"Nate\",\"brown\")\n @river1.add_fish(@fish1)\n @river1.add_fish(@fish2)\n @bear1.bear_take_fish(@fish1)\n @river1.lose_fish(@fish1)\n assert_equal(1,@river1.check_fish)\n assert_equal(1,@bear1.check_stomach)\n end",
"def make_bike\n new_bike = Bike.new\n new_bike.brand = self\n end",
"def dogs\n Dog.all.select {|d| d.owner == self}\n end",
"def register_animal(animals, clients, shelter)\n\t# capture all the details of the animal\n\tputs \"What type of animal is it?\"\n\tspecies = gets.chomp.capitalize\n\tputs \"What breed of \" + species + \" is it?\"\n\tbreed = gets.chomp.capitalize\n\tputs \"What is the sex of the \" + species + \"?\"\n\tgender = gets.chomp.downcase\n\n\t# put a conditional so that the responses are using the right gender\n\tif gender.include?(\"f\")\n\t puts \"What is her name?\"\n\telse\n\t\tputs \"What is his name?\"\n\tend\n\tname = gets.chomp.capitalize\n\tputs \"How old is \" + name + \"?\"\n\tage = gets.chomp.to_i\n\tanimal_to_adopt = name.downcase.strip\n\t# create animal and make shelter the owner\n\tanimal_to_adopt = Animal.new(name, age, gender, species, breed)\n\t# adds the animal to shelter's \n\tshelter.put_up_for_adoption(animal_to_adopt)\n\tif gender.include?(\"f\")\n\t puts \"We'll take \" + name + \" and make sure she finds a great home :)\\n\"\n\telse\n\t\tputs \"We'll take \" + name + \" and make sure he finds a great home :)\\n\"\n\tend\n\t\n\t\n\n \nend",
"def dogs\nDog.all.find_all do |dog|\n dog.owner == self\nend\n\nend",
"def set_found_dog\n @found_dog = FoundDog.find(params[:id])\n end",
"def release_bike\n Bike.new\n end",
"def speak\n #useses the name variable that all GoodDog objects are assigned at creation. Different for each instance\n \"#{@name} says Arf!\"\n end",
"def drink?\n true\n end",
"def make_it_quack(duck)\n duck.quack\nend",
"def buy(movie)\n end",
"def initialize(name, breed, owner_name)\n @name = name # this returns name of the dog\n @breed = breed # returns the breed classification\n @owner = Owner.new(owner_name, self) # returns Owner when #class is called on #owner \n end",
"def dogs\n Dog.all.select do |dog|\n dog.owner == self\n end\n end",
"def walk_dogs\n self.pets[:dogs].each do |dog|\n dog.mood = \"happy\"\n end\n end",
"def cook\n @burger.thaw\n @burger.make_patty\n @burger.grill\n end",
"def dog_params\n params.require(:dog).permit(:name, :gender, :breed, :size, :age, :likes, :dislikes, :picture, :price)\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 create\n @user = User.find(params[:user_id])\n @dog = @user.dogs.new(params[:dog])\n \n if @dog.save\n if @user.dogs.count == 1\n redirect_to parks_path\n else\n redirect_to account_path\n end\n else\n render :action => \"new\"\n end\n end",
"def buy_gift_for(whom)\n if whom == TestConstants::FOR_HIM\n self.buy_gift_for_him\n elsif whom == TestConstants::FOR_HER\n self.buy_gift_for_her\n else\n raise \"Can not buy gift for #{whom} user type. Aborted!\"\n end\n end",
"def dog_params\n params.require(:dog).permit(:name, :image, :breed)\n end",
"def take_a_drink\n soda.drink_a_soda\n puts \"You drank your soda!\"\n end",
"def new_dog\n system 'clear'\n dog_name = TTY::Prompt.new.ask('Enter the name of your dog')\n\n if dog_exist?(dog_name)\n puts 'That name already exists.'\n sleep(2)\n new_dog\n end\n\n new_dog = Dog.create(name: dog_name)\n dogs << new_dog\n puts \"#{dog_name} has been added to your account.\"\n sleep(2)\n end",
"def accept(dog, group)\n transaction do\n accepted_at = Time.now\n accept_one_side(dog, group, accepted_at)\n end\n unless Group.find(group).hidden?\n log_activity(mem(dog, group))\n end\n end",
"def sell_pets\n cats.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n dogs.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n \n\n end",
"def sell_pets\n pets = dogs + cats\n\n pets.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n end"
] |
[
"0.7821202",
"0.759405",
"0.75633985",
"0.75414926",
"0.75414926",
"0.7539524",
"0.7514351",
"0.75130224",
"0.74989164",
"0.74964404",
"0.74808854",
"0.72889435",
"0.72756505",
"0.7117511",
"0.6457529",
"0.63717353",
"0.6149575",
"0.60366565",
"0.6001052",
"0.5991753",
"0.59671634",
"0.5947682",
"0.59329444",
"0.5833817",
"0.58150685",
"0.5802621",
"0.5802621",
"0.5802402",
"0.5770771",
"0.57466406",
"0.57431614",
"0.57169634",
"0.57012963",
"0.56818193",
"0.5650289",
"0.562808",
"0.5596529",
"0.55861753",
"0.5568786",
"0.5568786",
"0.5568786",
"0.5568786",
"0.5568786",
"0.5568786",
"0.5568786",
"0.55686563",
"0.5568519",
"0.5539554",
"0.55226946",
"0.55188656",
"0.5513608",
"0.55058736",
"0.5500874",
"0.54898226",
"0.54758877",
"0.54650235",
"0.5439072",
"0.5425134",
"0.5415803",
"0.5402548",
"0.54001254",
"0.5388007",
"0.53770846",
"0.53770846",
"0.53770846",
"0.53770846",
"0.53722864",
"0.53583956",
"0.53583115",
"0.5354913",
"0.5349826",
"0.5344731",
"0.5338395",
"0.5309435",
"0.5299815",
"0.5292751",
"0.52912587",
"0.5286638",
"0.5282328",
"0.52505237",
"0.5233431",
"0.5227342",
"0.5224827",
"0.52107435",
"0.520605",
"0.51938957",
"0.51908803",
"0.5190601",
"0.5186623",
"0.51854473",
"0.518211",
"0.5170874",
"0.51634085",
"0.5162383",
"0.51559776",
"0.51513135",
"0.5145003",
"0.51309246",
"0.5123495",
"0.5119779"
] |
0.74960583
|
10
|
walk_dogs walks the dogs which makes the dogs' moods happy (FAILED 7)
|
def walk_dogs
self.pets[:dogs].each do |dog|
dog.mood = "happy"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def walk_dogs\n self.dogs.each {|dog| dog.mood = \"happy\"}\n end",
"def walk_dogs\n self.dogs.each{|dog|\n dog.mood = \"happy\"\n }\n end",
"def walk_dogs\n\n self.dogs.each do |dog|\n dog.mood = \"happy\"\n end\n end",
"def walk_dogs \n self.dogs.each do |dog|\n dog.mood = \"happy\"\n end \n end",
"def walk_dogs\n @pets[:dogs].each { |dog| dog.mood = \"happy\"}\n end",
"def walk_dogs\n @pets[:dogs].each {|dog| dog.mood = \"happy\"}\n end",
"def walk_dogs\n pets[:dogs].each do |dog|\n dog.mood = \"happy\"\n end\n end",
"def walk_dogs\n @pets[:dogs][0].mood=(\"happy\")\n end",
"def walk_dogs #walks the dogs which makes the dogs' moods happy\n # dog = Dog.new(\"Daisy\")\n # owner.pets[:dogs] << dog\n # owner.walk_dogs\n # expect(dog.mood).to eq(\"happy\")\n pets[:dogs].each do |dog|\n dog.mood = \"happy\"\n end\n end",
"def walk_dogs\n dogs.map {|dog| dog.mood = \"happy\"}\n end",
"def walk_dogs\n self.pets[:dogs].map do |dogs|\n dogs.mood = \"happy\"\n end\n end",
"def walk_dogs\n Dog.all.collect do |dogs|\n dogs.mood=\"happy\"\n end\n end",
"def walk_dogs\n Dog.all.each do |dog|\n if dog.owner == self\n dog.mood = \"happy\"\n end\n end \n end",
"def walk_dogs\n dogs.each do |dog|\n dog.mood = \"happy\"\n end\nend",
"def walk_dogs\n self.pets.each do |family, type|\n if family.to_s == \"dogs\"\n type.each do |individual|\n individual.mood = \"happy\"\n end\n end\n end\nend",
"def walk\n if @legs > 0\n @speed = @speed + (0.2 * @legs)\n else\n raise TypeError, \"This dog don't exist.\"\n end\n end",
"def walk \n puts \"Hmm.. not in a mood to walk...\"\n super # parent 'walk' method\n end",
"def give_walk(length_in_minutes, dog)\n Walk.new(length_in_minutes, dog, self)\n end",
"def walks\n Walk.all.select { |walk_instance| walk_instance.dog == self }\n end",
"def walks\n Walk.all.select {|walk_instance| walk_instance.dog_walker == self}\n end",
"def walk\n return false if (@captives > 0 and captives_close and warrior.feel(get_bomb_direction).captive?) or # Captives needs to be rescued, dont walk away\n count_unit_type(:Sludge) > 5\n message = nil\n walk_to = nil\n if check_for_a_bomb and @bomb_optimal_direction != false\n message = \"Walking to captive with the bomb optimal direction to direction #{@bomb_optimal_direction}\"\n walk_to = @bomb_optimal_direction\n elsif @captives > 0 and check_for_a_bomb and !warrior.feel(:forward).enemy?\n message = \"Walking to get the captive with a bomb to direction #{get_bomb_direction}\"\n walk_to = get_bomb_direction\n elsif @captives > 0 and warrior.look(:forward)[1].to_s.to_sym == :\"Thick Sludge\" and count_unit_type(:\"Thick Sludge\") > 1\n message = \"Walking to avoid sludges to direction #{@captives_direction[0]}\"\n walk_to = :right\n elsif @enemies_binded < 3 and @captives > 0 and !enemies_close\n message = \"Walking to rescue captives to direction #{@captives_direction[0]}\"\n walk_to = @captives_direction[0]\n elsif !under_attack and warrior.listen.empty?\n message = \"Walking to the stairs to direction #{warrior.direction_of_stairs}\"\n walk_to = warrior.direction_of_stairs\n elsif !under_attack and !enemies_close\n message = \"Walking to closest unit to direction #{warrior.direction_of(warrior.listen.first)}\"\n walk_to = warrior.direction_of(warrior.listen.first)\n end\n if walk_to != nil\n if message != nil\n puts message\n end\n return warrior.walk! walk_to\n end\n return false\n end",
"def walk\n\t\tputs \"walking around\"\t\n\tend",
"def take_walk(length_in_minutes, dog_walker)\n Walk.new(length_in_minutes, self, dog_walker)\n end",
"def walk()\r\n @warrior.walk!\r\n end",
"def walk()\r\n @warrior.walk!\r\n end",
"def dogs \n dogs = self.walks.map {|walk| walk.dog}\n dogs.uniq\n end",
"def walk\n \t\tputs \"Walking...\"\n \tend",
"def walk; end",
"def dog_walkers # ex: dog_instance.dog_walkers\n dog_walkers_array = self.walks.map { |walk_instance| walk_instance.dog_walker }\n dog_walkers_array.uniq\n end",
"def walk\n puts \"The Person is walking\"\n end",
"def walk\n puts \"The Person is walking\"\n end",
"def walk\n puts \"The Person is walking\"\n end",
"def run #instance method, you chain it to an instance of a Dog\n # binding.pry\n puts \"#{@name} the #{@breed} is running fast as the wind\"\n end",
"def pbDive\n return false if $game_player.pbFacingEvent\n map_metadata = GameData::MapMetadata.try_get($game_map.map_id)\n return false if !map_metadata || !map_metadata.dive_map_id\n move = :DIVE\n movefinder = $Trainer.get_pokemon_with_move(move)\n if !pbCheckHiddenMoveBadge(Settings::BADGE_FOR_DIVE,false) || (!$DEBUG && !movefinder)\n pbMessage(_INTL(\"The sea is deep here. A Pokémon may be able to go underwater.\"))\n return false\n end\n if pbConfirmMessage(_INTL(\"The sea is deep here. Would you like to use Dive?\"))\n if movefinder\n speciesname = movefinder.name\n $PokemonGlobal.diving = movefinder\n else\n speciesname = $Trainer.name\n end\n pbMessage(_INTL(\"{1} used {2}!\",speciesname,GameData::Move.get(move).name))\n pbHiddenMoveAnimation(movefinder,false)\n pbFadeOutIn {\n $game_temp.player_new_map_id = map_metadata.dive_map_id\n $game_temp.player_new_x = $game_player.x\n $game_temp.player_new_y = $game_player.y\n $game_temp.player_new_direction = $game_player.direction\n $PokemonGlobal.surfing = false\n $PokemonGlobal.diving = true\n pbUpdateVehicle\n $scene.transfer_player(false)\n $game_map.autoplay\n $game_map.refresh\n }\n return true\n end\n return false\nend",
"def dog_eat(items)\n \t items.each do |item|\n \t\t puts \"My puppy likes #{item}\"\n \t end\n end",
"def happy_walker?\n @dog_walker.favorite_breed == @dog.breed \n end",
"def walk(direction)\r\n @warrior.walk!(direction)\r\n end",
"def walk(direction)\r\n @warrior.walk!(direction)\r\n end",
"def explore\n while (target = search_unknown)\n # puts \"PATH: #{target.inspect}\"\n target.each do |dir|\n output = @vm.run(input: [dir]).first\n case output\n when 0 # droid hits wall\n @map.set(@droid.move(dir), Map::WALL)\n when 1 # droid moved into an empty space\n @droid = @droid.move(dir)\n @map.set(@droid, Map::NOTHING)\n when 2 # droid moved into a space containing oxygen\n @droid = @droid.move(dir)\n @map.set(@droid, Map::OXYGEN)\n end\n end\n end\n end",
"def on_player_walk\n @result.clear\n check_floor_effect\n if $game_player.normal_walk?\n turn_end_on_map\n states.each {|state| update_state_steps(state) }\n show_added_states\n show_removed_states\n end\n end",
"def walk(oidorname)\n\t\tprint_status(\"Trying to Walk the '#{oidorname}' tree......\")\n\t\t@manager.walk(\"#{oidorname}\") { |x| print_good(\"#{x}\") }\n\tend",
"def walk\n @speed = @speed + (0.2 * @legs)\n end",
"def walk\n if @awake != true\n puts \"Wake up, #{@name}. It's time for a walk.\"\n @awake = true\n end #end of conditional to wake up and go out\n\n if @food_in_intestine > 50\n @food_in_intestine = 0\n puts \"#{@name} pooped.\"\n else\n puts \"#{@name} sniffs around, but doesn't do business.\"\n end #end of conditional for pooping on walk\n time_passed\nend",
"def shortest_walk(walk)\n # your code goes here\nend",
"def walk(direction)\r\n\tif direction == :north\r\n\tp \"Walking North\" \r\n\tend\r\n\tif direction == :south\r\n\tp \"Walking South\" \r\n\tend\r\n\tif direction == :east\r\n\tp \"Walking East\" \r\n\tend\r\n\tif direction == :west\r\n\tp \"Walking West\" \r\n\tend\r\nend",
"def walks_for_game(game)\n atbats = game.atbats.select {|atbat| atbat.pitcher_id == gameday_id.to_i}\n w_atbats = atbats.select {|atbat| atbat.ball == 4} \n w_atbats.size\n end",
"def test_random_walk_guarded_complex_dsl\n \t smc = a_guarded_state_machine\n \t sm = smc.state_machine\n \t \n # Create the Graphiz graph object, see if it fails...\n\t sm_graph = sm.create_dot_graph\t\n\t sm_graph.output(\"../test/test_guard_dsl_2.dot\")\n \n assert_equal(4 , sm.states_store.length , \"Check for 4 states\")\n\n \t\t# Check creates a real walk\n \t\tthe_walk = sm.random_walk(:HOME)\n \t\tassert_equal(Walk.new.class, the_walk.class , \"Check random walk returns Walk instance\" )\n \t\t\n \t\tputs \"test_random_walk_guarded_complex_dsl\"\n \t\tputs the_walk\n \t\t\n \t\t# When guards are in place, walk can only be length 4\n \t\tassert_equal(4 ,the_walk.transitions.length , \"Check Walk is length 4\")\n \t\n \tend",
"def create\n @dog_walk = current_user.dog_walks.new(params[:dog_walk])\n\n respond_to do |format|\n if @dog_walk.save\n format.html { redirect_to @dog_walk, notice: 'Dog walk was successfully created.' }\n format.json { render json: @dog_walk, status: :created, location: @dog_walk }\n else\n format.html { render action: \"new\" }\n format.json { render json: @dog_walk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def battle(monster)\n system(\"clear\") unless ENV['TEST']\n puts \"#{monster.message}\\n\"\n type(\"You've run into a vicious #{monster.name}!\\n\\n\")\n\n while hp > 0\n # Both choose an attack.\n player_attack = choose_attack\n\n # Prevents the user from using \"bad\" commands.\n # Example: \"Use\" with an empty inventory.\n while (player_attack.fails?(self))\n player_attack = choose_attack\n end\n\n monster_attack = monster.choose_attack\n\n attackers = Array.new\n attacks = Array.new\n\n if sample_agilities(monster)\n attackers << self << monster\n attacks << player_attack << monster_attack\n else\n attackers << monster << self\n attacks << monster_attack << player_attack\n end\n\n 2.times do |i|\n # The attacker runs its attack on the other attacker.\n attacks[i].run(attackers[i], attackers[(i + 1) % 2])\n\n if (attackers[i].escaped)\n attackers[i].escaped = false\n return\n end\n\n break if monster.hp <= 0 || hp <= 0\n\n end\n\n break if monster.hp <= 0 || hp <= 0\n\n end\n\n die if hp <= 0\n\n if monster.hp <= 0\n type(\"You defeated the #{monster.name}!\\n\")\n\n # Determine the rewards for defeating the monster.\n rewards = monster.sample_rewards\n\n gold = rewards.first\n treasure = rewards.second\n\n # Output some helpful text and give the rewards to the player.\n if ((gold > 0) || treasure)\n type(\"Rewards:\\n\")\n if (gold > 0)\n type(\"* #{gold} gold\\n\")\n @gold += gold\n end\n if (treasure)\n type(\"* #{treasure.name}\\n\")\n add_item(treasure)\n end\n end\n print \"\\n\"\n end\n\n end",
"def displayWalks\n\t\ti = 0\n\t\twhile i < @@walks\n\t\t\tputs \"Woof\"\n\t\t\tputs \"On the #{@time.strftime(\"%d-%m-%Y at %H:%M\")} #{@name} walked #{@@distance[i]}kms in #{@@location[i]}, coordinates: #{@@coordinates[i]}. \"\n\t\ti += 1\n\t\tend\n\tend",
"def print_details\n puts \"#{@dog_walker.name} walked #{@dog.name} for #{length_in_minutes} minutes.\"\n end",
"def is_valid_walk(walk)\n a=''\n i=0\n verdad=true\n if walk.length==1 || walk.length==0\n i = 1\n verdad = false\n else\n for w in walk\n\n # puts walk[i-1]\n if i<walk.length\n if walk[i+1]==w\n verdad=false\n end\n else\n break\n end\n i=i+1\n end \n end\n if verdad==false || i != 10\n \n return 'should return true'\n\nelse\n return 'should return false'\nend\nend",
"def on_player_walk\n for actor in members\n if actor.slip_damage?\n actor.hp -= 1 if actor.hp > 1 # Poison damage\n $game_map.screen.start_flash(Color.new(255,0,0,64), 4)\n end\n if actor.auto_hp_recover and actor.hp > 0\n actor.hp += 1 # HP auto recovery\n end\n end\n end",
"def wander\n perturb_direction\n walk\n end",
"def walk\n @speed = 2\n end",
"def fight_scene\n\tjason = PowerRanger.new(\"Jason\", \"Red\")\n\ttommy = PowerRanger.new(\"tommy\", \"Green\")\n\tjon = Person.new(\"Jon\")\n\thoward = Person.new(\"Howard\")\n\tevilGuy_a = EvilNinja.new(\"Evil Guy 1\")\n\tevilGuy_b = EvilNinja.new(\"Evil Guy 2\")\n\n\tputs \"Two innocent bystanders are attacked by evil ninjas.\"\n\tjon.scream\n\thoward.scream\n\tjon.run\n\thoward.drink_coffee\n\thoward.run\n\n\tputs \"The Power Rangers arrive!\"\n\tjason.punch(evilGuy_a)\n\ttommy.punch(evilGuy_b)\n\tjason.rest(2)\n\ttommy.drink_coffee\n\n\tputs \"The Evil Ninjas fight back.\"\n\tevilGuy_a.punch(tommy)\n\tevilGuy_b.punch(tommy)\n\tevilGuy_a.cause_mayhem(jason)\n\n\tputs \"The Power Rangers try Megazord\"\n\tjason.use_megazord(evilGuy_a)\n\tevilGuy_a.punch(jason)\n\n\tputs \"Cmon Tommy!\"\n\ttommy.use_megazord(evilGuy_a)\n\ttommy.drink_coffee(10)\n\ttommy.use_megazord(evilGuy_b)\n\n\tputs \"Did the Power Rangers save the day?\"\n\n\tninja_array = [evilGuy_a, evilGuy_b]\n\twin = \"yes\"\n\n\tninja_array.each do |ninja|\n\t\t# p ninja.show_caffeine_level\n\t\tif ninja.caffeine_level > 0\n\t\t\twin = \"no\"\n\t\tend\n\tend\n\n\tif win == \"yes\"\n\t\tputs \"Yes!\"\n\telse\n\t\tputs \"No :(.\"\n\tend\n\nend",
"def walk(*args) walk_direction[*args] end",
"def word_disambig(word1, word2, word3, word4, word5)\n\t\t\tgo_cmds = [\"go\", \"walk\", \"run\", \"move\", \"travel\", \"skip\", \"g\", \"m\"]\n\t\t\tfast_move_cmds = [\"n\", \"s\", \"e\", \"w\"]\n\t\t\tlook_cmds = [\"look\", \"see\", \"l\"]\n\t\t\tget_cmds = [\"grab\", \"get\", \"take\"]\n\t\t\tdrop_cmds = [\"drop\", \"leave\", \"dump\"]\n\t\t\tstatus_cmds = [\"status\", \"s\", \"health\", \"hp\", \"xp\", \"check\", \"level\"]\n\t\t\tinv_cmds = [\"inv\", \"i\", \"inventory\", \"loot\", \"stuff\", \"gear\"]\n\t\t\tquit_cmds = [\"q\", \"quit\", \"exit\", \"end\"]\n\t\t\tuse_cmds = [\"use\"]\n\t\t\tattack_cmds = [\"attack\", \"hit\"]\n\t\t\t@all_cmds << go_cmds\n\t\t\t@all_cmds << (look_cmds + get_cmds + drop_cmds)\n\t\t\tif go_cmds.include?(word1)\n\t\t\t\tif $hero.location.monsters.size != 0\n\t\t\t\t\tputs 'Your enemies are blocking the exit'\n\t\t\t\telse\n\t\t\t\t\tmove_disambig(word2)\n\t\t\t\t\tlooking\n\t\t\t\tend\n\t\t\telsif word1 == 'help'\n\t\t\t\tputs 'some commands:\n\t\t\t\t\t\t\tgo [direction]\n\t\t\t\t\t\t\tget [thing]\n\t\t\t\t\t\t\tget [type] [thing] Example: get ! scroll\n\t\t\t\t\t\t\tuse [type] [thing] Example: use orange bottle\n\t\t\t\t\t\t\tinv - display inventory\n\t\t\t\t\t\t\tattack [type]\n\t\t\t\t\t\t\tdrop [thing]\n\t\t\t\t\t\t\tlook - gives information about the room/what you can see\n\t\t\t\t\t\t\tstatus - displays information about your hp etc.\n\t\t\t\t\t\t\tq - quits the game'\n\t\t\t\t# Some developer commands commented out in case they are needed again later\n\t\t\t#elsif word1 == \"ah\"\n\t\t\t#\t$hero.heal(30)\n\t\t\t#elsif word1 == \"gen\"\n\t\t\t#\t$hero.location.item_gen\n\t\t\t#elsif word1 == \"boom\"\n\t\t\t#\tdef boom\n\t\t\t#\t$hero.location.monsters.each do |mob|\n\t\t\t#\t\tmob.wound(10)\n\t\t\t#\t\tdead = mob.defeated?\n\t\t\t#\t\tif dead == true\n\t\t\t#\t\t\t$hero.location.monsters.delete_at($hero.location.monsters.index(mob))\n\t\t\t#\t\tend\n\t\t\t#\tend\n\t\t\t#\tend\n\t\t\t#\tboom\n\t\t\t#\tboom\n\t\t\t#\tboom\n\t\t\t#elsif word1 == 'god'\n\t\t\t#\t$hero.hp = 100\n\t\t\telsif fast_move_cmds.include?(word1)\n\t\t\t\tmove_disambig(word1)\n\t\t\t\tlooking\n\t\t\telsif look_cmds.include?(word1)\n\t\t\t\tlooking\n\t\t\telsif get_cmds.include?(word1)\n\t\t\t\tgetting\n\t\t\telsif drop_cmds.include?(word1)\n\t\t\t\tdropping\n\t\t\telsif status_cmds.include?(word1)\n\t\t\t\t$hero.status_check\n\t\t\telsif inv_cmds.include?(word1)\n\t\t\t\t$hero.inv_check\n\t\t\telsif quit_cmds.include?(word1)\n\t\t\t\tputs \"Thanks for playing!\"\n\t\t\t\texit\n\t\t\telsif use_cmds.include?(word1)\n\t\t\t\t\t\tusing\n\t\t\telsif attack_cmds.include?(word1)\n\t\t\t\tattacking\n\t\t\telse\n\t\t\t\tputs \"I do not recognize that command. Please try again.\"\n\n\t\t\tend\n\tend",
"def attacks(player)\n \tputs \"Le joueur #{@name} attaque le joueur #{player.name}.\"\n # On récupère le nombre de points de dommage correspondant au lancer de dé via la méthode compute_damage\n damage_points = compute_damage\n puts \"Il lui inflige #{damage_points} points de dommage.\"\n # Ces points de dommage sont infligés à player. Si player n'a plus de points de vie, le programme affiche qu'il est mort.\n player.get_damage(damage_points)\n end",
"def dog(name)\r\n puts \"The dog's name is \" + name\r\n end",
"def monsterfight(user, monster, mAtk, enemy)\n\n#make a loop with a boolean value. The loop will keep running unless somebody's health goes to zero or \n#the user runs away\n\n\tenemy['name'] = monster.sample\n\tcombat = true\n\n\tif enemy['name'] == 'Mutated Octopus'\n\t\tenemy['hp'] = 7\n\t\tenemy['atkSpd'] = 6\n\t\tenemy['armor'] = 1\n\n\telsif enemy['name'] == 'Sabertooth Goldfish'\n\t\tenemy['hp'] = 6\n\t\tenemy['atkSpd'] = 5\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Lady Gaga'\n\t\tenemy['hp'] = 8\n\t\tenemy['atkSpd'] = 8\n\t\tenemy['armor'] = 1\n\n\telsif enemy ['name'] == 'Hannah Montana'\n\t\tenemy['hp'] = 10\n\t\tenemy['atkSpd'] = 10\n\t\tenemy['armor'] = 1\n\tend\n\n\tputs ''\n\n# choosing the random attack of the monster. no need to push into a hash\n\tdef monsterAttack(user, mAtk, enemy)\n\t\trandAttack = mAtk.sample\n\n\t\tif randAttack == 'Slap'\n\t\t\tmonsterDmg = 1\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Bite'\n\t\t\tmonsterDmg = 2\n\t\t\tuser['health'] -= 1\n\n\t\telsif randAttack == 'Eyepoke'\n\t\t\tmonsterDmg = 3\n\t\t\tuser['health'] -= 1\n\t\tend\n\n\t\tputs \"You get hit by #{enemy['name']} for #{monsterDmg}. Your health is now #{user['health']}\"\n\t\t\n\tend\n\n\tdef heroAttack(user, enemy)\n\n\t\theroAttack = user['weapon']\n\n\t\tif heroAttack == 'Sword'\n\t\t\thitDmg = rand(2...5)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Spear'\n\t\t\thitDmg = rand(1...6)\n\t\t\tenemy['hp'] -= hitDmg\n\n\t\telsif heroAttack == 'Axe'\n\t\t\thitDmg = rand(3...4)\n\t\t\tenemy['hp'] -= hitDmg\n\t\tend\n\t\t\n\t\tputs \"You hit the #{enemy['name']} for #{hitDmg}. Their health is now #{enemy['hp']}\"\n\tend\n\n\tputs \"A wild #{enemy['name']} has appeared. Do you choose to fight or run? (enter 'fight' or 'run')\"\n\n\tchoice = gets.chomp.downcase\n\n\twhile (user['health'] > 0 && enemy['hp'] > 0 && combat == true)\n\n\t\tif choice == 'fight'\n\t\t\tputs 'Alright lets do this!'\n\t\t\tmonsterAttack(user, mAtk, enemy)\n\t\t\theroAttack(user, enemy)\n\n\t\telsif choice == 'run'\n\t\t\tputs 'You attempt to escape'\n\n\t\telsif choice != 'fight' || choice != 'run' \n\t\t\tputs 'Please enter \"fight\" or \"run\"'\n\t\t\tchoice = gets.chomp.downcase\n\t\tend\n\n\t\tif enemy['hp'] > 0 && user['health']\n\t\t\tputs \"Continue fighting? (fight or run)\"\n\t\t\tchoice = gets.chomp.downcase\n\n\t\telsif enemy['hp'] <= 0\n\t\t\tputs \"You have killed #{enemy['name']}\"\n\t\t\tcombat == false\n\n\t\telsif user['health'] <= 0\n\t\t\tputs \"You have died\"\n\t\t\tcombat == false\n\t\tend\n\tend\n\nend",
"def leapfrog\n @list.each {|b| b.kick(@dt) }\n @list.each {|b| b.drift(@dt) }\n #warn 'kick+drift done'\n if @use_tree == false then\n @list.each {|b| b.acc = pairwise_acc(b) } \n else \n get_tree_acc(@tol)\n end\n @list.each {|b| b.kick(@dt) }\n #warn 'final kick done'\n end",
"def walk(direction)\n if direction == :north\n p 'Je marche vers le nord'\n elsif direction == :east\n p 'Je marche vers l\\'est'\n elsif direction == :south\n p 'Je marche vers le sud'\n elsif direction == :west\n p 'Je marche vers l\\'ouest'\n else\n p 'je rentre chez moi'\n end\nend",
"def isWalking _args\n \"isWalking _args;\" \n end",
"def go(direction)\n room = find_room_in_direction(direction)\n\n if room\n puts \"You go \" + direction.to_s\n @player.location = room\n show_current_description\n # When player enters certain rooms, certain events happen\n if room == :redroom\n # if you enter redroom, new instance of class Monster created, param is random damage\n minotaur = Monster.new(\"minotaur\", rand(5..12))\n puts \"Your health before the monster is #{@player.health}\"\n @player.health = minotaur.post_monster_health(minotaur.does_damage, @player.health)\n elsif room == :toyroom\n ball_string = Healthpack.new(\"ball of string\", 5)\n @player.health = ball_string.add_health(ball_string.restores_health, @player.health)\n elsif room == :goldroom\n abort\"YOU WON! You can take as much gold as you want! Congrats!\"\n end\n else\n puts \"That is a wall\"\n end\n\n end",
"def bark(visitor)\n puts \"My dog is barking at #{visitor}\"\n end",
"def write_walk(context)\n write_bits(1, 2) # we write 1 because we're walking\n write_bits(context.movement[:directions][:primary], 3)\n write_bit(context.flags[:state?])\n end",
"def get_walk(*args)\n\tif args.length > 0\n\t\tpath_num = args[0]\n\telse\n\t\tpath_num = @@vars['sim_static_walk']\n\tend\n\n\tif args.length > 0\n\t\t# This side loads the JSON with the walks\n\t\trequire(\"./walks_#{@@vars['length']}m.rb\")\n\t\twalk = JSON[@@test_data[path_num-1]]\n\t\tnew_walk = JSON[@@test_data[path_num-1]]\n\telse\n\t\turl = \"http://localhost:4570/?lon=#{@@vars['lon']}&lat=#{@@vars['lat']}&length=#{@@vars['length']}\"\n\t\tresp = Net::HTTP.get_response(URI.parse(url))\n\t\twalk = JSON[resp.body]\n\t\t# Uncomment to get a random path\n\t\t#puts resp.body\n\t\t#return\n\n\t\tnew_walk = JSON[resp.body]\n\tend\n\tputs \"Got initial walk with #{walk['body'].length} points\" if @@vars['show_intermediate_countings']\n\n\t######\n\t# Pre-process walk\n\t####\n\t# Inject intermediate points according to @@vars['walk_thresh']\n\tnew_walk['body'] = []\n\tfor c in (walk['body'].length-1).times do\n\t\tnext if walk['body'][c+1] == nil or walk['body'][c] == nil\n\t\tdist = distance(walk['body'][c],walk['body'][c+1])\n\t\tnew_walk['body'] << walk['body'][c]\n\t\taux = walk['body'][c]\n\n\t\t# If the hop is too long\n\t\tif dist > @@vars['walk_thresh']\n\t\t\t# Calculate in how many segments to divide the hop\n\t\t\tpart = (dist/@@vars['walk_thresh']).ceil\n\t\t\t# Calculate the distance for each segment\n\t\t\td_x = aux[0]>walk['body'][c+1][0] ? (aux[0]-walk['body'][c+1][0]).abs/part : (walk['body'][c+1][0]-aux[0]).abs/part\n\t\t\td_y = aux[1]>walk['body'][c+1][1] ? (aux[1]-walk['body'][c+1][1]).abs/part : (walk['body'][c+1][1]-aux[1]).abs/part\n\n\t\t\twhile dist > @@vars['walk_thresh']\n\t\t\t\tx = aux[0] > walk['body'][c+1][0] ? aux[0]-d_x : aux[0]+d_x\n\t\t\t\ty = aux[1] > walk['body'][c+1][1] ? aux[1]-d_y : aux[1]+d_y\n\t\t\t\taux = [x,y,aux[2]]\n\n\t\t\t\tnew_walk['body'] << aux\n\t\t\t\tdist = distance(aux,walk['body'][c+1])\n\t\t\tend\n\t\tend\n\tend\n\n\tputs \"Re-sampled new walk with #{new_walk['body'].length} points\" if @@vars['show_intermediate_countings']\n\n\treturn new_walk, walk\nend",
"def monster_attack\n #set up monster distance and next move\n distance_x = @mon_x - @cur_x\n distance_y = @mon_y - @cur_y\n sign_x = distance_x <=> 0\n sign_y = distance_y <=> 0\n new_x = @mon_x-(1*sign_x)\n new_y = @mon_y-(1*sign_y)\n next_square = @room[new_x][new_y]\n #move monster closer to hero unless blocked or next to hero\n if next_square == CHAR_FLOOR && (distance_x.abs > 1 || distance_y.abs > 1)\n @room[@mon_x][@mon_y] = CHAR_FLOOR\n draw_map(@mon_x, @mon_y)\n @mon_x, @mon_y = new_x, new_y\n @room[@mon_x][@mon_y] = @mon_type\n draw_map(@mon_x, @mon_y)\n end\n #hit hero if close enough and hero not on saftey square\n if (distance_x.abs <= 1 && distance_y.abs <= 1) && @room[@cur_x][@cur_y] != CHAR_SAFE\n hit = @mon_attack * 1.5\n #hit if not dodged\n skill = @stats[:luck]+@stats[:agility]\n clear_message_box\n if Random.rand(skill+(@mon_attack*3)) > skill\n @ui.place_text(MSG_DAMGAGE.ljust(20),1,2)\n damage = hit / (2+@defence)\n @stats[:strength] -= damage\n @stats[:vitality] -= damage/10\n #see if hit weapon\n if Random.rand(7) == @mon_attack #1 in 7 chance of loosing item\n item_found = false\n until item_found\n #get a random item, keep trying until found on hero\n object = ['2 HAND SWORD', 'BROADSWORD', 'SHORTSWORD', 'AXE', 'MACE', 'FLAIL', 'DAGGER', 'GAUNTLET',\n 'HEAVY ARMOUR', 'CHAIN ARMOUR'].rotate(Random.rand(10)+1).first\n item = @objects.find { |obj| obj[:name]==object }\n if item\n if object == 'HEAVY ARMOUR' || object == 'CHAIN ARMOUR'\n @defence -= item[:power]\n else\n @attack -= item[:power]\n end\n @ui.place_text(\"#{object}!!\".ljust(20), 1, 3)\n @objects.delete(item)\n item_found = true\n end\n end\n end\n else\n @ui.place_text(MSG_MMISS.ljust(20),1,2)\n end\n sleep 0.5 #slow everything down\n end\n end",
"def walk(path); end",
"def random_walk(start = 'start')\n\n word = start\n\n num_sentences = 10\n\n # first word should be our seed\n retarr = [start]\n \n begin\n \n # we need at least 1 way out\n if @graph.out_degree_of(word) <= 0 then\n break\n end\n\n word = get_word(word)\n\n if word.nil? then\n num_sentences -= 1\n break\n end\n\n retarr << word\n\n # if we hit the end of the sentence we need\n # to pick another word cause we don't keep\n # track of next words to pass spec\n # this is only for if you want more than 1 sentence\n if word.split('').last.match(/\\.|\\?|\\!/) then\n word = pick_another\n num_sentences -= 1\n end\n\n end while num_sentences > 0\n\n return retarr\n end",
"def mood room = nil, mood = nil, debug = false\n success = false\n debug and ( p 'Executing mood: ' + mood + ' in room: ' + room )\n rooms = self.class.get_rooms self.get_config\n # support for setting a mood in all rooms (recursive)\n if room == 'all'\n debug and ( p 'Processing all rooms...' )\n rooms.each do | config, each_room |\n room = each_room['name']\n debug and ( p 'Room is: ' + room )\n success = self.mood room, mood, debug\n sleep 1\n end\n success = true\n # process single mood\n else\n if rooms[room] and mood\n if rooms[room]['mood'][mood]\n command = self.command rooms[room], nil, rooms[room]['mood'][mood]\n debug and ( p 'command is ' + command )\n self.raw command\n success = true\n # support for special \"moods\" via device looping\n elsif mood[0,3] == 'all'\n state = mood[3..-1]\n debug and (p 'Selected state is: ' + state)\n rooms[room]['device'].each do | device |\n p 'Processing device: ' + device[0].to_s\n self.send room, device[0]['name'], state, debug\n sleep 1\n end\n success = true\n end\n else\n STDERR.puts self.usage( room );\n end\n end\n success\n end",
"def roll(godfest_tags)\n boosted_gfe = godfest_tags.include?(\"4\")\n unboosted_gfes = godfest_tags.select{|tag| tag[0] == \"-\"}.map{|tag| tag[1..-1].downcase}\n tags = godfest_tags.select{|tag| !([\"4\", \"X\", \"@\"].include?(tag) || tag[0] == \"-\")}\n \n test = rand(1000)\n if test < 300\n @silvers.sample\n elsif test < 650\n @troll_golds.sample\n elsif test < 700\n @gods.sample\n elsif test < (boosted_gfe ? 900 : 920)\n pantheon = tags.sample\n @pantheons[pantheon] ? @pantheons[pantheon].sample : @gods.sample\n elsif test < (boosted_gfe ? 975 : 980)\n roll_gfe(unboosted_gfes)\n else\n roll_super(unboosted_gfes)\n end\n end",
"def go(dir)\n put dir\n match = { :wait => [/\\.\\.\\.wait|you may only type ahead/],\n :retreat => [/You'll have better luck if you first retreat|You are engaged/],\n :continue => [/Roundtime/] }\n res = match_wait match\n\n case res\n when :wait\n pause 0.5\n go dir\n when :retreat\n put \"retreat\"\n put \"retreat\"\n go dir\n end\nend",
"def make_it_swim(duck)\n duck.swim\nend",
"def battle(initial_health, number_of_fighting_pairs)\n fighters = generate_fighters(number_of_fighting_pairs, initial_health)\n\n fighters.map do |fighting_pair|\n my_runner = fighting_pair[:runner]\n my_viking = fighting_pair[:viking]\n my_runner.visualize\n my_viking.visualize\n puts \"\"\n end\n gets\n key = \"start\"\n timer = 0\n while key != \"end\"\n fighters.map! do |fighting_pair|\n my_runner = fighting_pair[:runner]\n my_viking = fighting_pair[:viking]\n attack(my_runner, my_viking, timer)\n attack(my_viking, my_runner, timer)\n {runner: my_runner, viking: my_viking}\n end\n\n fighters.map do |fighting_pair|\n my_runner = fighting_pair[:runner]\n my_viking = fighting_pair[:viking]\n my_runner.visualize\n my_viking.visualize\n puts \"\"\n end\n puts \"\"\n puts \"\"\n key = gets.chomp.to_s\n timer += 1\n end\n return fighters\nend",
"def leap\n\t @dancer_leaps = \"Dancer leaps in the air!\"\n\tend",
"def sit \n puts \"The Dog is sitting\"\n end",
"def isValidWalk(walk)\r\n starting_point = []\r\n current_direction = 0\r\n distance_travelled = []\r\n if walk.size != 10\r\n false\r\n else\r\n walk.each do |direction|\r\n distance_travelled = move_player(distance_travelled, direction)\r\n end\r\n if distance_travelled == starting_point\r\n true\r\n else\r\n false\r\n end\r\n end\r\nend",
"def breed_move\n return data.breed_moves\n end",
"def play_with_cats\n#makes each of the cat's moods happy when played with\n pets[:cats].each do |cat|\n cat.mood = \"happy\"\n end\n end",
"def walk\n puts \"After a walk health decreased 1\"\n @health = @health - 1\n return self\n end",
"def look_forwards()\n if enemy_check?\n @warrior.shoot! @movement_direction\n else\n check_forwards\n end\n end",
"def phase_3(player, bots)\r\n puts \" ----------------------- \"\r\n puts \" -- TOUR ENNEMI -- \"\r\n puts \" ----------------------- \"\r\n puts \"\"\r\n i = 0\r\n bots.each do |bot|\r\n if i > 0 && bot.life_points > 0\r\n bot.attacks(player)\r\n end\r\n i += 1\r\n end\r\nend",
"def sit\n puts \"The Dog is sitting\"\nend",
"def walk()\n @state.each do |state|\n desc = state.respond_to?(:name) ? state.name : @name\n boots(state,@path,desc)\n end\n return @results\n end",
"def one_year_passes\n @height = (@height + 0.4).round(1)\n @age += 1\n # make the oranges fall off\n @orange_count = 0 if @orange_count > 0\n if @age >= 25\n @alive = false\n puts \"the tree has just died\"\n exit\n end\n end",
"def determine debug_log\n \n nouns = []\n verbs = []\n possible_relations = []\n \n # search for word types\n @pos.each.with_index do |elem, i|\n if (elem == 'NN' || elem == 'NNS')\n nouns << [@lemmas[i], i]\n # get noun hypernyms\n possible_relations += direct_hypernyms(@lemmas[i], WordNet::Noun) \n elsif elem.include? 'VB'\n verbs << [@lemmas[i], i]\n # get verb hypernyms\n possible_relations += direct_hypernyms(@lemmas[i], WordNet::Verb)\n end\n end\n \n debug_log << \"possible relations: #{possible_relations}\"\n \n case possible_relations.length\n when 0\n debug_log << \"didn't find possible relation\"\n when 1\n return { relation: Relations.map[possible_relations[0]] }\n when 2..10\n \n # if all relations target the same predicated \n targets = Set.new\n possible_relations.each do |r|\n targets.add Relations.map[r]\n end\n if targets.size == 1\n @relation = targets.to_a[0]\n else\n if possible_relations.include? 'people'\n possible_relations.delete 'people'\n end\n if possible_relations.include? 'name'\n possible_relations.delete 'name'\n end\n if possible_relations.length == 1\n return {relation: Relations.map[possible_relations[0]] }\n else\n #TODO: find correct one, print first\n return {relation: Relations.map[possible_relations[0]] }\n end\n end \n end\n\n # if still not found a relation\n \n debug_log << \"do deep search for nouns\"\n \n nouns.each do |noun, i|\n possible_relations += recursive_hypernyms(noun, WordNet::Noun)\n \n if possible_relations.any?\n break\n end\n end\n \n case possible_relations.length\n when 0\n debug_log << \"nothing found in deep search...\"\n when 1\n return { relation: Relations.map[possible_relations[0]] }\n when 2..10\n debug_log << \"possible_relations: #{possible_relations}\"\n end\n \n if @relation.nil?\n return { error: \"Could not determine the aimed relation of the question\" }\n end\n \n end",
"def sit\n puts \"The Dog is sitting\"\n end",
"def sit\n puts \"The Dog is sitting\"\n end",
"def dog_name\n end",
"def do_iteration\n @iteration += 1\n if @manual_iteration\n do_manual\n end\n persons_to_delete = Array.new\n @all_persons.each do |person|\n if @manual_movement\n puts do_manual\n end\n action = person.move(get_world_array, all_objects)\n if action[1] == 'eat'\n present_objects = get_objects_at_coord(person.get_x_location, person.get_y_location)\n present_objects.each do |food|\n if food != person\n if food.class == Strawberry\n person.eat\n food.decrement\n add_strawberry\n if food.get_amount <= 0\n @all_strawberries.delete(food)\n end\n puts \"#{person} eats strawberry on square (#{person.get_x_location}, #{person.get_y_location})\" if @printing\n elsif food.class == Mushroom\n persons_to_delete.push(person)\n food.decrement\n add_mushroom\n if food.get_amount <= 0\n @all_mushrooms.delete(food)\n end\n puts \"#{person} eats mushroom on square (#{person.get_x_location}, #{person.get_y_location})\" if @printing\n else\n puts \"cannot eat #{food.class}\"\n exit\n end\n end\n end\n elsif action[1] == 'ignore'\n person.move_random(get_world_array)\n elsif action[1] == 'towards'\n if action[0] == 3\n strawb = person.nearest_strawberry(all_objects)\n person.move_towards(get_world_array, strawb)\n elsif action[0] == 4\n mush = person.nearest_mushroom(all_objects)\n person.move_towards(get_world_array, mush)\n elsif action[0] == 5\n monster = person.nearest_monster(all_objects)\n person.move_towards(get_world_array, monster)\n elsif action[0] == 6\n creature = person.nearest_person(all_objects)\n person.move_towards(get_world_array, creature)\n else\n puts \"invalid action: #{action}\"\n exit\n end\n elsif action[1] == 'away_from'\n if action[0] == 3\n strawb = person.nearest_strawberry(all_objects)\n person.away_from(get_world_array, strawb)\n elsif action[0] == 4\n mush = person.nearest_mushroom(all_objects)\n person.away_from(get_world_array, mush)\n elsif action[0] == 5\n monster = person.nearest_monster(all_objects)\n person.away_from(get_world_array, monster)\n elsif action[0] == 6\n creature = person.nearest_person(all_objects)\n person.away_from(get_world_array, creature)\n else\n puts \"invalid action: #{action}\"\n exit\n end\n elsif action[1] == 'random'\n person.move_random(get_world_array)\n else\n puts \"#{action} not a valid action\"\n exit\n end\n\n if person.get_energy_level <= 0\n persons_to_delete.push(person)\n puts \"#{person} dies from running out of energy\" if @printing\n end\n\n present_objects = get_objects_at_coord(person.get_x_location, person.get_y_location)\n present_objects.each do |object|\n if object.class == Monster\n persons_to_delete.push(person)\n puts \"#{person} moves to monster on square (#{person.get_x_location}, #{person.get_y_location})\" if @printing\n end\n end\n end\n persons_to_delete.each do |person_to_delete|\n @all_persons.delete(person_to_delete)\n end\n\n if @iteration % @monster_iteration == 0\n @all_monsters.each do |monster|\n if @manual_movement\n do_manual\n end\n monster.move(get_world_array, all_objects)\n present_objects = get_objects_at_coord(monster.get_x_location, monster.get_y_location)\n if !present_objects.nil?\n present_objects.each do |object|\n if object != monster\n if object.class == Strawberry\n # do nothing\n elsif object.class == Mushroom\n # do nothing\n elsif object.class == Person\n @all_persons.delete(object)\n puts \"Monster eats #{object} on square (#{monster.get_x_location}, #{monster.get_y_location})\" if @printing\n else\n puts 'UNIDENTIFIED MONSTER OBJECT'\n exit\n end\n end\n end\n end\n end\n end\n display_world if @printing and !@manual_iteration\n end",
"def attacks(player)\n \tputs \"Le joueur #{@name} attaque le joueur #{player.name}\"\n \tdamage = compute_damage\n \tputs \"Il lui inflige #{damage} points de dommage\"\n \tplayer.gets_damage(damage)\n end",
"def walk_pet(pet_name, owner_name)\n puts \"#{owner_name} takes his pet #{pet_name} on a walk\"\nend",
"def go \n puts \"Lets play the Animal Game!\\n\" \n puts \"You think of an animal, and I'll try to guess what you're thinking of.\\nHit return when you are ready.\\n\\n\"\n ans = gets.chomp\n play(@animalTree)\n end",
"def get_move\n #puts \"get_move for #{self}\"\n return [] if goal == nil or goal == []\n while(1)\n rv = []\n g = goal.shift\n return [] if g == nil\n puts g.join('---')\n case g[0]\n when KILL\n e = g[1] # get the ennemy\n if(not $map.exists?(e) or e.life<=0)\n puts 'this ant does not exists anymore or is dead, next goal'\n next \n end\n \n dist = distance(self,e)\n #puts \"I am #{self}\"\n #puts \"goal: kill this enneny: #{e}\"\n i = 0\n if dist > 1 # move\n # by doing this we are finding subgoals\n # TODO: add_sub_goal ?\n\n path = find_best_way(e.x,e.y)# we have to move next to it\n #puts ppath(path)\n if path==nil\n # TODO: no path, find something else to do\n puts 'no path ! , next goal'\n next\n end\n \n # we have a path to it\n # so now we have to move smartly\n # if we are at 3 cases, we can move and attack\n # more than that we have to move at 4 cases and wait the next turn\n # TODO: do not wait at a position where we can be attacked\n if(path.size-2 <= 3) # minus two because the path include our case\n i = path.size-2 # 0 based minus one, so -2 \n #puts 's1'\n elsif(path.size-2 >= 6) # we are far away\n i = 6\n #puts 's2'\n else\n i = (path.size-2)\n #puts 's3'\n end\n #puts i\n #sleep(1)\n if i <= 0\n puts \"i <= 0 (#{i}), #{ppath(path)}\"\n sleep(5)\n else\n a,b = path[i][0]\n #puts \"I am moving to (#{[a,b].join(',')})\"\n self.x,self.y = a,b\n rv << \"Cb#{object_id}~\"+[a,b].pack('cc')\n #puts x\n end\n end\n return rv if i > 3 # return if we can not attack at the same round\n #puts i\n dist = distance(self,e)\n if dist == 1\n puts 'Attack'\n rv << \"Cc#{object_id}~#{e.object_id}\"\n e.life -= 5\n end\n return rv\n else\n puts 'unknown goal, next goal'\n end # case\n end #while\n puts \"no goal ? find something else to do !\"\n rv\n end",
"def respond(m, args)\n argv = args ? args.split(\" \") : []\n if !argv.last.nil? && argv.last.match(/\\+\\S+/)\n godfest_flags = argv.last.split(//)[1..-1].map(&:upcase)\n args = args.split(\"+\").first.strip\n if godfest_flags.include? \"@\"\n godfest_flags += [\"O\", \"M\", \"S\"]\n end\n else\n godfest_flags = []\n end\n\n if args == \"tags\" || args == \"list_tags\"\n r = \"Use +[tags] to denote godfest; for example !pad pull +JGO for a japanese/greek/odins fest.\\n\"\n r += \"Known tags: [R]oman, [J]apanese, Japanese[2], [I]ndian, [N]orse, [E]gyptian, [G]reek, [O]dins, [A]ngels, [D]evils, [C]hinese, [M]etatrons, [H]eroes, [S]onias, [@]ll Godfest-Only\"\n m.reply r\n elsif args.to_i != 0\n gods = []\n if args.to_i > 100\n m.reply \"Not doing >100 rolls at once; apparently you jackasses can't have nice things.\"\n return\n end\n args.to_i.times do\n monster = @gachapon_simulator.roll(godfest_flags)\n stars = monster.stars\n types = monster.types\n name = monster.name\n if monster.pantheon\n gods << monster.name\n end\n end\n overflow = 0\n if gods.length > 10\n overflow = gods.length - 10\n gods = gods[0..9]\n end\n price = stone_price(args.to_i * 5)\n if gods.length == 0\n r = \"You rolled #{args} times (for $#{price}) and got jackshit all. Gungtrolled.\"\n else\n r = \"You rolled #{args} times (for $#{price}) and got some gods:\\n\"\n r += gods.join(\", \")\n if overflow > 0\n r += \"...and #{overflow} more\"\n end\n end\n m.reply r\n elsif args.nil?\n monster = @gachapon_simulator.roll(godfest_flags)\n stars = monster.stars\n types = monster.types\n name = monster.name\n\n if name.include?(\"Golem\") || name.include?(\"Guardian\")\n golem = true\n name = e_a_r_t_h_g_o_l_e_m(name)\n end\n\n if stars >= 5 && types.include?(\"God\") && !monster.name.include?(\"Verche\")\n msg = (stars == 6 ? \"Lucky bastard!\" : \"Lucky bastard.\")\n elsif stars == 5\n msg = \"Meh.\"\n elsif golem\n msg = \"Y O U I D I O T.\"\n else\n msg = \"I just saved you $5.\"\n end\n r = \"You got #{name}, a #{stars}* #{types.first}. #{msg}\"\n m.reply(r)\n else\n regex = false\n identifier = args.strip.downcase\n if identifier.match(/\\A\\/.*\\/\\z/)\n regex = true\n identifier = Regexp.new(\"#{identifier[1..-2]}\")\n elsif Monster::NAME_SPECIAL_CASES.keys.include?(identifier)\n target = Monster.fuzzy_search(identifier)\n identifier = target.name.downcase\n end\n attempts = 0\n monster = nil\n loop do\n attempts = attempts + 1\n monster = @gachapon_simulator.roll(godfest_flags)\n break if !regex && (monster.name.downcase.include?(identifier) || monster.id.to_s == identifier)\n break if regex && (monster.name.downcase.match(identifier) || monster.name.match(identifier))\n m.reply(\"Unable to roll #{identifier}\") and return if attempts == 1000\n end\n price = stone_price(attempts * 5)\n m.reply(\"After #{attempts} attempts, you rolled a #{monster.name}. (There goes $#{price})\")\n end\n end",
"def update\n @dog_walk = current_user.dog_walks.find(params[:id])\n\n respond_to do |format|\n if @dog_walk.update_attributes(params[:dog_walk])\n format.html { redirect_to @dog_walk, notice: 'Dog walk was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dog_walk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def fight()\n\tputs \"--------------------\"\n\tputs \"Let's fight, but first we go to the coffe shop.\"\n\tgo_to_coffee_shop()\n\tnumber_of_turns = 10 + rand(20)\n\tputs \"------------------\"\n\tputs \"TIME TO FIGHT! There are #{number_of_turns} rounds in this fight!\"\n\tnumber_of_turns.times do |x|\n\t\tputs \"------------------\"\n\t\tputs \"Round #{x+1}, FIGHT!\"\n\t\tcurrent_fighter = Person.person_array.sample\n\t\t\n\t\tif current_fighter.is_a?(PowerRanger)\n\t\t\trandom_roll = rand(10)\n\t\t\tcurrent_fighter.run() if random_roll==0\n\t\t\tcurrent_fighter.scream() if random_roll==1\n\t\t\tcurrent_fighter.punch() if random_roll >= 2 && random_roll <= 6\n\t\t\tcurrent_fighter.megazord() if random_roll >= 7 && random_roll <=9\n\t\telsif current_fighter.is_a?(EvilNinja)\n\t\t\trandom_roll = rand(10)\n\t\t\tcurrent_fighter.run() if random_roll==0\n\t\t\tcurrent_fighter.scream() if random_roll==1\n\t\t\tcurrent_fighter.punch() if random_roll >= 2 && random_roll <= 6\n\t\t\tcurrent_fighter.cause_mayhem() if random_roll >= 7 && random_roll <=9\n\t\telse\n\t\t\trandom_roll = rand(2)\n\t\t\tcurrent_fighter.run() if random_roll==0\n\t\t\tcurrent_fighter.scream() if random_roll==1\n\t\tend\n\tend\n\tputs \"-------------------\"\nend",
"def fight(w1, w2)\n while w1.is_alive && w2.is_alive\n w1.hit(w2)\n w2.hit(w1)\n puts w1.status\n puts w2.status\n end\n\n if w1.is_alive\n puts \"#{w1.name} Won!\" \n else\n puts \"#{w2.name} Won!\"\n end\nend"
] |
[
"0.72698534",
"0.72123915",
"0.7209461",
"0.71824974",
"0.71406496",
"0.7115614",
"0.7053708",
"0.7039653",
"0.6944568",
"0.69413483",
"0.6889855",
"0.6846809",
"0.68118554",
"0.66077983",
"0.653068",
"0.6425921",
"0.6320209",
"0.6300419",
"0.6275439",
"0.6257949",
"0.6104061",
"0.6081622",
"0.6072165",
"0.60088027",
"0.60088027",
"0.59899193",
"0.59189034",
"0.5881034",
"0.5732185",
"0.57280076",
"0.57280076",
"0.5691223",
"0.5529694",
"0.55124366",
"0.550074",
"0.543553",
"0.5399487",
"0.5399487",
"0.5398467",
"0.5182632",
"0.51692903",
"0.51082176",
"0.51048976",
"0.5058094",
"0.5042255",
"0.5041806",
"0.5001824",
"0.4999244",
"0.49966756",
"0.49945563",
"0.49724758",
"0.49403328",
"0.4927947",
"0.4921599",
"0.49143764",
"0.49048567",
"0.4886504",
"0.48856106",
"0.48568013",
"0.4850086",
"0.48363513",
"0.48115247",
"0.48073548",
"0.47957146",
"0.47889513",
"0.47817093",
"0.47815204",
"0.47768492",
"0.4775974",
"0.47673643",
"0.4760333",
"0.47597685",
"0.47596917",
"0.47487083",
"0.47434157",
"0.4735322",
"0.47350878",
"0.4727509",
"0.47208682",
"0.47198483",
"0.47184968",
"0.47141987",
"0.47041023",
"0.47033003",
"0.46995273",
"0.4694911",
"0.4690924",
"0.4688859",
"0.46864325",
"0.46864325",
"0.46826786",
"0.46759322",
"0.4671828",
"0.4671247",
"0.4661338",
"0.4643455",
"0.4627567",
"0.4620042",
"0.46185452",
"0.46174577"
] |
0.70882684
|
6
|
play_with_cats plays with the cats which makes the cats moods happy (FAILED 8)
|
def play_with_cats
self.pets[:cats].each do |cat|
cat.mood = "happy"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def play_with_cats\n pets[:cats].each do |cat|\n cat.mood = \"happy\"\n end\n end",
"def play_with_cats\n @pets[:cats].each { |cat| cat.mood = \"happy\"}\n end",
"def play_with_cats\n#makes each of the cat's moods happy when played with\n pets[:cats].each do |cat|\n cat.mood = \"happy\"\n end\n end",
"def feed_cats\n self.cats.each do |cat|\n cat.mood = \"happy\"\n end \n end",
"def play\r\n while !over?\r\n turn\r\n end\r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n elsif draw?\r\n puts \"Cats Game!\"\r\n end\r\n end",
"def play\n until over?\n turn\n end\n if winner\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def play\n while over? == false\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play\n while !over?\n \t turn\n end\n if won?\n \t puts \"Congratulations \"+ winner() +\"!\"\n else\n \t puts \"Cat's Game!\"\n end\n end",
"def play\n turn until over?\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def play\n until over? == true\n turn\n end\n if self.winner == nil\n puts \"Cats Game!\"\n else\n puts \"Congratulations #{self.winner}!\"\n #Congradulate the winner of the game, using the person with the most X or O combinations\n #Code in a play again option, so players don't have to re enter name\n board.display\n end\n end",
"def play_with_cats\n @pets[:cats].each {|cat| cat.mood = \"happy\"} \n end",
"def feed_cats\n self.cats.each {|c| c.mood = \"happy\"}\n end",
"def play\n # counter = 0\n # until counter == 9\n # turn\n # counter += 1\n # end\n\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def pbPlayCry(pokemon,volume=90,pitch=nil)\n return if !pokemon\n if pokemon.is_a?(Numeric)\n pbPlayCrySpecies(pokemon,0,volume,pitch)\n elsif !pokemon.egg?\n if pokemon.respond_to?(\"chatter\") && pokemon.chatter\n pokemon.chatter.play\n else\n pkmnwav = pbCryFile(pokemon)\n if pkmnwav\n pbSEPlay(RPG::AudioFile.new(pkmnwav,volume,\n (pitch) ? pitch : (pokemon.hp*25/pokemon.totalhp)+75)) rescue nil\n end\n end\n end\nend",
"def play\n while !over?()\n turn()\n end\n\n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cat's Game!\"\n end\n end",
"def play()\n \n while !over?()\n turn()\n end\n \n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cat's Game!\"\n end\n end",
"def play\n while !over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play\n while !over?\n #binding.pry\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cats Game!\"\n end\n end",
"def play\n until over?\n turn\n end\n\n if draw?\n puts \"Cat's Game!\"\n elsif WIN_COMBINATIONS.include?(won?)\n puts \"Congratulations #{winner}!\"\n end\nend",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def play\n while !over?\n turn\n end\n won? ? (puts \"Congratulations #{@winner}!\") : (puts \"Cat's Game!\")\n\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{ winner }!\"\n elsif draw?\n puts \"Cat's Game!\"\n else\n puts \"Game over\"\n end\n end",
"def adopted_cats(dumb_friends_league, from_friend, stray_cat)\n puts \"I have adopted #{dumb_friends_league} cat(s) from Dumb Friends League.\"\n puts \"I have adopted #{from_friend} cat(s) from a friend.\"\n puts \"I have adopted #{stray_cat} stray cat(s).\"\nend",
"def feed_cats\n self.cats.each do |cat|\n cat.mood = \"happy\"\n end\n end",
"def test_pick_accusation_suspect\n puts \" testing\"\n player = Player.new\n assert_equal( \"Got it.\", player.pick_accusation_suspect(true, \"Mrs. White\") )\n assert_equal(\"Mrs. White\", player.accusation_suspect)\n assert_equal(\n \"Whaaa...??? That's not one of the suspects! Come on man!\", \n player.pick_accusation_suspect(true, \"ai 87 00\")\n )\n end",
"def play_sports\n end",
"def plays(h)\n\th.each do |bros, inst|\n\t\tputs \"#{bros.to_s.capitalize} Marx plays the #{inst}\"\n\tend\nend",
"def plays(h)\n\th.each do |bros, inst|\n\t\tputs \"#{bros.capitalize} Marx plays the #{inst}\"\n\tend\nend",
"def setup_categories # :nodoc:\n [:event, :time, :salutation, :recurrency, :preposition,\n :article, :day, :verb, :name, :number, :interrogation].each do |category|\n @matches[category] = []\n end\n @matches[:guessing] = false\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cats Game!\"\n end\nend",
"def play\r\n turn until over?\r\n \r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n \r\n else\r\n puts \"Cat's Game!\"\r\n end\r\nend",
"def sonic_play\n melody = melody()\n if melody.respond_to?(:key)\n melody.values().each do |m|\n play_melody(m)\n end\n elsif melody.respond_to?(:length)\n play_melody(melody)\n end\nend",
"def play\n puts \"#{name} got zoomies playing fetch!\"\n @hungry = true\n end",
"def play\n until self.over? do\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n end",
"def play\n\n until over?\n turn\n end\n\n if self.won?\n puts \"Congratulations #{self.winner}!\"\n elsif self.draw?\n puts \"Cat's Game!\"\n end\n\n end",
"def test_mood3\n assert_equal @p.mood?([5, 0]), 'sad.'\n end",
"def play\n while !over?\n turn\n end\n if won?\n puts \"Congratulations #{winner}!\"\n else draw?\n puts \"Cat's Game!\"\n end\n end",
"def play\n until over? == true\n turn\n end\n\n if won? != false\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def test_mood2\n assert_equal @p.mood?([1, 0]), 'sad.'\n end",
"def test_mood6\n assert_equal @p.mood?([100, 0]), 'victorious!'\n end",
"def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def play()\n until over?() == true\n turn()\n end\n if draw?() != true\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def play\n until over? do\n turn;\n end\n\n if won?\n puts \"Congratulations #{winner}!\";\n replay\n elsif draw?\n puts \"Cat's Game!\";\n replay\n end\n end",
"def feed_cats\n self.cats.each{ |cat|\n cat.mood = \"happy\"\n }\n end",
"def play()\n c=1\n p=\"X\"\n while !over?()\n turn()\n end\n if won?()\n puts \"Congratulations #{winner()}!\"\n elsif draw?()\n puts \"Cats Game!\"\n else\n end\nend",
"def feed_cats\n cats.each do |cat|\n cat.mood = \"happy\"\n end\n end",
"def play\n# \tThere are 3 players in Knuckleheads: \n\t\tputs \"There are #{to_s} players in #{@title}\"\n# \tI'm Moe with a health of 100 and a score of 103.\n# \tI'm Larry with a health of 60 and a score of 65.\n# \tI'm Curly with a health of 125 and a score of 130.\n\t\t@Player.each do |spieler|\n\t\t\tputs \"I'm #{spieler} with a health of #{@health} and a score of #{score}\"\n\t\t\tend\n# \tMoe got blammed!\n# \tMoe got w00ted!\n# \tMoe got w00ted!\n# \tI'm Moe with a health of 120 and a score of 123.\n# \tLarry got blammed!\n# \tLarry got w00ted!\n# \tLarry got w00ted!\n# \tI'm Larry with a health of 80 and a score of 85.\n# \tCurly got blammed!\n# \tCurly got w00ted!\n# \tCurly got w00ted!\n# \tI'm Curly with a health of 145 and a score of 150.\n\t\tend",
"def play\n until over?\n turn\n end\n\n if won?\n puts \"Congratulations #{winner}!\"\n\n else draw?\n puts \"Cat's Game!\"\n\n end\n end",
"def play\n @hungry = true\n end",
"def play\n @hungry = true\n end",
"def play\n @hungry = true\n end",
"def play\n congrats = Proc.new { |player| puts \"Congratulations #{player}!\" }\n tie = Proc.new { puts \"Cat's Game!\" }\n \n until over?\n turn\n end\n\n congrats.call(winner) if won?\n tie.call if draw?\nend",
"def play_sweet_riff\n puts \"You played a face melting riff!\"\n take_a_drink\n end",
"def start\n puts \"Welcome! You're playing with #{deck.count} card#{\"s\" if @deck.count != 1}.\"\n puts \"-------------------------------------------------\"\n\n# Iterates through cards, asks user for guesses, and ends after the last card.\n i = 0\n while i < deck.count\n puts \"This is card number #{i + 1} out of #{deck.count}.\"\n puts \"Question: #{deck.cards[i].question}\"\n\n guess = gets.chomp\n take_turn(guess)\n\n puts turns.last.feedback #\"Correct\" or \"incorrect\"\n i += 1\n end\n\n puts \"****** Game over! ******\"\n puts \"You had #{number_correct} correct guess#{\"es\" if number_correct != 1} out of #{i} for a total score of #{percent_correct}%.\"\n\n# Iterates through dynamic list of categories and puts % correct for each category.\n categories.each do |cat|\n puts \"#{cat} - #{percent_correct_by_category(cat)}% correct\"\n end\n end",
"def feed_cats\n Cat.all.collect do |cats|\n cats.mood=\"happy\"\n end\n end",
"def scream (*exclamations)\n\t\trandom_exclamations = [\"No way!\", \"AAAAAAHHHHHH!\", \"Please help me!\", \"OOOOOHHHHHHH!\", \"Ouch!\", \"SO UNFAIR!\", \"Ouchie ouchie ouchie ouchie...\", \"DUDE!\"]\n\t\trandom_exclamation_a = random_exclamations.sample\n\t\trandom_exclamation_b = random_exclamations.sample\n\n\t\tdef print_scream(random_exclamation_a, random_exclamation_b, *exclamations)\n\t\t\tif sufficient_caffeine_level(1)\n\t\t\t\tprint \"#{@name} is screaming: #{random_exclamation_a} \"\n\t\t\t\texclamations.each {|x| print \"WOOOOAAAHH! #{x} \"}\n\t\t\t\tputs \" #{random_exclamation_b}\"\n\t\t\t\t@caffeine_level -= 1\n\t\t\t\tcheck_caffeine_level()\n\t\t\telse\n\t\t\t\tputs \"#{@name} doesn't have enough caffeine to scream. Drink coffee now!\"\n\t\t\tend\n\t\tend\n\t\tprint_scream(random_exclamation_a, random_exclamation_b, *exclamations)\n\tend",
"def mix_the_mixing_bowl_well\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 13 )\n value = nil\n mix_the_mixing_bowl_well_start_index = @input.index\n ordinal30 = nil\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return value\n end\n # at line 202:5: mix ( ( WS the )? ( WS ordinal )? WS mixing WS bowl )? WS well EOF\n @state.following.push( TOKENS_FOLLOWING_mix_IN_mix_the_mixing_bowl_well_742 )\n mix\n @state.following.pop\n # at line 202:9: ( ( WS the )? ( WS ordinal )? WS mixing WS bowl )?\n alt_24 = 2\n look_24_0 = @input.peek( 1 )\n\n if ( look_24_0 == WS )\n look_24_1 = @input.peek( 2 )\n\n if ( look_24_1.between?( ST, TH ) || look_24_1.between?( T__16, T__17 ) || look_24_1.between?( T__40, T__41 ) )\n alt_24 = 1\n end\n end\n case alt_24\n when 1\n # at line 202:10: ( WS the )? ( WS ordinal )? WS mixing WS bowl\n # at line 202:10: ( WS the )?\n alt_22 = 2\n look_22_0 = @input.peek( 1 )\n\n if ( look_22_0 == WS )\n look_22_1 = @input.peek( 2 )\n\n if ( look_22_1.between?( T__16, T__17 ) )\n alt_22 = 1\n end\n end\n case alt_22\n when 1\n # at line 202:11: WS the\n match( WS, TOKENS_FOLLOWING_WS_IN_mix_the_mixing_bowl_well_746 )\n @state.following.push( TOKENS_FOLLOWING_the_IN_mix_the_mixing_bowl_well_748 )\n the\n @state.following.pop\n\n end\n # at line 202:20: ( WS ordinal )?\n alt_23 = 2\n look_23_0 = @input.peek( 1 )\n\n if ( look_23_0 == WS )\n look_23_1 = @input.peek( 2 )\n\n if ( look_23_1.between?( ST, TH ) )\n alt_23 = 1\n end\n end\n case alt_23\n when 1\n # at line 202:21: WS ordinal\n match( WS, TOKENS_FOLLOWING_WS_IN_mix_the_mixing_bowl_well_753 )\n @state.following.push( TOKENS_FOLLOWING_ordinal_IN_mix_the_mixing_bowl_well_755 )\n ordinal30 = ordinal\n @state.following.pop\n\n end\n match( WS, TOKENS_FOLLOWING_WS_IN_mix_the_mixing_bowl_well_759 )\n @state.following.push( TOKENS_FOLLOWING_mixing_IN_mix_the_mixing_bowl_well_761 )\n mixing\n @state.following.pop\n match( WS, TOKENS_FOLLOWING_WS_IN_mix_the_mixing_bowl_well_763 )\n @state.following.push( TOKENS_FOLLOWING_bowl_IN_mix_the_mixing_bowl_well_765 )\n bowl\n @state.following.pop\n\n end\n match( WS, TOKENS_FOLLOWING_WS_IN_mix_the_mixing_bowl_well_769 )\n @state.following.push( TOKENS_FOLLOWING_well_IN_mix_the_mixing_bowl_well_771 )\n well\n @state.following.pop\n match( EOF, TOKENS_FOLLOWING_EOF_IN_mix_the_mixing_bowl_well_773 )\n # syntactic predicate action gate test\n if @state.backtracking == 0\n # --> action\n\n value = {\n :cmd => :mix_the_mixing_bowl_well,\n :args => {:mixing_bowl => ordinal30.to_i}\n }\n \n # <-- action\n end\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 13 )\n memoize( __method__, mix_the_mixing_bowl_well_start_index, success ) if @state.backtracking > 0\n\n end\n \n return value\n end",
"def test_mood4\n assert_equal @p.mood?([9, 0]), 'sad.'\n end",
"def play\r\n\t\t[FOLD]\r\n\tend",
"def test_mood5\n assert_equal @p.mood?([10, 0]), 'victorious!'\n end",
"def play\nuntil over? do\n turn\n end\nif won?\n puts \"Congratulations #{winner}!\"\nelsif draw?\nputs \"Cats Game!\"\nend\nend",
"def feed_cats \n self.cats.each do |cat|\n cat.mood = \"happy\"\n end \n end",
"def playing?\n !current_category.nil?\n end",
"def active_voice_indicative_mood_imperfect_tense\n end",
"def play\n while !over?\n turn\n board.display\n end\n if won?\n puts \"Congratulations #{winner}!\" \n elsif draw?\n puts \"Cats Game!\" \n end\n end",
"def mood\n if self.happiness && self.nausea\n self.happiness > self.nausea ? \"happy\" : \"sad\"\n end\n end",
"def mood\n\t\tself.nausea < self.happiness ? mood = \"happy\" : mood = \"sad\"\n\tend",
"def get_adjective\n\t\t[\"pretty\", \"ugly\", \"hideous\"].sample\n\tend",
"def play\r\n self.display_board\r\n while !self.over? do\r\n self.turn\r\n end\r\n if self.draw? \r\n puts \"Cat's Game!\"\r\n else\r\n puts \"Congratulations #{self.winner}!\"\r\n end\r\n end",
"def play\n until over?\n turn\n end\n if draw?\n puts \"Cat's Game!\"\n elsif won?\n puts \"Congratulations #{winner}!\"\n end\nend",
"def play\n # Game play asks for players input on a turn of the game\n # Game play checks if the game is over after every turn\n # Game play plays the first turn of the game\n # Game play plays the first few turns of the game\n # Game play checks if the game is won after every turn\n # Game play checks if the game is a draw after every turn\n while !over?\n turn\n end\n # Game play stops playing if someone has won\n # Game play congratulates the winner X\n # Game play congratulates the winner O\n if won?\n puts \"Congratulations #{winner}!\"\n # Game play stops playing in a draw\n # Game play prints \"Cat's Game!\" on a draw\n elsif draw?\n puts \"Cat's Game!\"\n end\n end",
"def start_conversation(friend, topic) \n case(topic)\nwhen \"politics\" \n friend.happiness -= 2\n self.happiness -= 2\n return \"blah blah partisan blah lobbyist\"\nwhen \"weather\"\n friend.happiness += 1\n self.happiness += 1\n return \"blah blah sun blah rain\"\n#use else because it tells us if none of the above check out then do the following\nelse \n return \"blah blah blah blah blah\" \n end \nend",
"def mood\n \tself.happiness > self.nausea ? \"happy\" : \"sad\" if self.happiness && self.nausea\n end",
"def play\n if (test)\n # next four lines just to see if there was no chain between the words\n test_list = build_chain\n test_list.delete(@word1)\n test_list.delete(@word2)\n if (distance(@word1, @word2) > 1 and test_list.empty?)\n puts \"Error: No chain between words\"\n else\n puts build_chain\n end\n end\n end",
"def draw_cat\n\t\tputs \"\\n\\n=^.^=\"\n\t\t@ttt.view_board\n\t\tputs \"=^.^=\"\n\t\tputs \"cat's game! game over!\"\n\tend",
"def play()\n \n begin\n \n @computer_choice = get_computer_choice()\n @player_choice = get_player_choice()\n \n result = logic(@computer_choice, @player_choice)\n\n get_choices()\n \n case result\n\n when \"tie\"\n @rounds -= 1\n @ties += 1\n puts \"[~] it's a tie !\"\n \n when \"player win\"\n @rounds -= 1\n @player_wins += 1\n puts \"[$] Player win this round (#{@player_wins}/3)!\"\n\n when \"computer win\"\n @rounds -= 1\n @computer_wins += 1\n puts \"[$] Computer win this round (#{@computer_wins}/3)!\"\n\n end\n\n rescue Interrupt\n\n puts \"\\n\\n[!] Keyboard interrupt, Exting.\"; exit()\n \n \n end\n \n\n end",
"def play_against_human\r\n while @running\r\n turn(:X)\r\n result?\r\n break if !@running\r\n turn(:O)\r\n result?\r\n end\r\n end",
"def treat_called\n start_time = Time.now\n while Time.now < start_time + COMPONENTS.hammer[:called_treatment][:call_length].to_i.seconds do\n play COMPONENTS.hammer[:called_treatment][:message]\n end\n hangup\n end",
"def mood\n if self.nausea && self.happiness\n self.nausea > self.happiness ? (return \"sad\") : (return \"happy\")\n end\n end",
"def play\n beats = list.to_string\n `say -r #{rate} -v #{voice} #{beats}`\n end",
"def mood\n if nausea && happiness\n self.nausea > self.happiness ? \"sad\" : \"happy\" \n end\n end",
"def play\n\n\t\tif ran_out_of_options?\n \t\t\tputs \"SORRY, YOU ARE HOPELESSLY INDECISIVE\".red.blink\n \t\t\texit\n \tend\n\n\t\t@winner = select_winner\n\n\t until self.set_of_ten_dup.length == 1 do\n\t \t@challenger = select_challenger\n\t \n\t system \"clear\"\n\n\t\tCLI.intro_image\n\t\tdisplay_choices\n\t\tinput = input_prompt\n\t \n\t\tmatch_arr = add_businesses\n\n\t\tadd_to_winner_loser_tables(match_arr[0],match_arr[1]) if input == '1' || input == '1!'\n\t\tadd_to_winner_loser_tables(match_arr[1],match_arr[0]) if input == '2' || input == '2!'\n\t\tremove_from_match_options(input)\n\t\t@winner = @challenger if input == '2' || input == '2!'\n\t\tself.url = @winner[:url]\n\t\tbreak if input == '1!' || input == '2!'\n\t end\n\t puts \"We recommend you go to \" + \"#{@winner[:name]}\".green + \"!\" \n end",
"def test_mood1\n assert_equal @p.mood?([0, 0]), 'empty-handed.'\n end",
"def play\n until over? do\n turn\n end\n if draw?\n puts \"Cat's Game!\"\n else\n puts \"Congratulations #{winner}!\"\n end\nend",
"def passive_voice_indicative_mood_imperfect_tense\n end",
"def play\n @hungry = true\n #p \"play method called\" #print notification to console\n end",
"def play\n\t\t\twhile !win && @turns < TURNS\n\t\t\t\tturn\n\t\t\tend\n\t\t\t# counter increments at start of turn, so must be less than max turns\n\t\t\tif win\n\t\t\t\tplay_again\n\t\t\telse\n\t\t\t\tputs \"\\n Sorry, you ran out of turns. The word was #{@secret_word}\"\n\t\t\t\tplay_again\n\t\t\tend\n\t\tend",
"def play\n until over?|| draw?\n @board = turn\n end\n unless winner.nil?\n puts \"Congratulations #{winner}!\"\n else\n puts \"Cat's Game!\"\n end\n end",
"def play\n\t\t\n\t\tputs intro\n\t\tsection_completed = false\n\t\t\n\t\twhile section_completed == false do\n\t\t\n\t\t\tprompt\n\t\t\taction = gets.chomp.downcase\n\t\t\t\n\t\t\tif action.include? \"jump\"\n\t\t\t\tputs \"You jump and escape one of them. But look ahead they are still coming!! What next?\"\n\t\t\n\t\t\telsif action.include? \"kill\"\n\t\t\t\tsection_completed = true #set section complete = true\n\t\t\t\tputs \"You jump quick on them. The Goombas were beaten flat to the ground.\"\n\t\t\t\tputs \"You jump, jump... and jump again. The Goombas were beaten and you head forward with no fear. You hit the bricks on the way as they release coins for you when they break down.\"\n\t\t\t\t\n\t\t\t\t\n\t\t\telsif action.include? \"sing\"\n\t\t\t\tsection_completed = true\n\t\t\t\tputs \"You do not want to harm them as you know it would create even more conflicts in the kingdom.\"\n\t\t\t\tputs \"So you start singing...\"\n\t\t\t\t#call underground\n\t\t\t\t\n\t\t\telsif action.include? \"go back\"\n\t\t\t\tdead(\"{@go_back}\")\n\t\t\n\t\t\telsif action.include? \"suicide\"\n\t\t\t\tsuicide\n\t\t\telsif action == \"\"\n\t\t\t\tno_action\n\t\t\telse\n\t\t\t\tputs \"okay... well..\"\n\t\t\t\twrong_input\n\t\t\t\t\n\t\t\tend # end if\n\t\t\tend #end of While loop\n\t\t\n\t\tbonus #call mushroom\n\t\t\n\tend",
"def pocketed? args, ball\n ball_center_x = ball[:x] + args.state.ball_diameter / 2\n ball_center_y = ball[:y] + args.state.ball_diameter / 2\n pocket_radius = args.state.pocket_diameter / 2\n args.state.pockets.each do |pocket|\n # add pocket radius to get to the cetner of the pocket\n dist = (((ball_center_x - (pocket[0] + pocket_radius)) ** 2) + ((ball_center_y - (pocket[1] + pocket_radius)) ** 2)) ** (1/2)\n if dist < pocket_radius\n case ball[:type]\n\n # if eight ball pocketed, win if the player pocketed all other balls\n when 8\n args.state.player1_type ||= 0\n # get the player's type\n if args.state.player == 0\n player_type = args.state.player1_type\n else\n player_type = 1 - args.state.player1_type\n end\n # if all of the player's group have been pocketed, win. Otherwise lose and reset.\n if player_type == 0 && args.state.pocketed_solids == 7\n args.state.won = true\n elsif player_type == 1 && args.state.pocketed_stripes == 7\n args.state.won = true\n else\n reset args\n end\n\n # if cueball pocketed, scratch and set it invisible \n when \"cueball\"\n if args.state.movement_mode != \"scratch\"\n args.state.movement_mode = \"scratch\"\n cueball = args.state.cueball\n cueball[:velX] = 0\n cueball[:velY] = 0\n cueball[:path] = \"sprites/invisible.png\"\n end\n \n # otherwise, it's a stripe or solid, so put it in the list of balls pocketed this turn.\n # if it was the called ball and pocket, this was a successful call\n else\n args.state.sunk = true\n args.state.pocketed_this_turn << ball\n args.state.balls.delete(ball)\n if args.state.called_shot\n called_pocket = args.state.called_pocket[0] == pocket[0] && args.state.called_pocket[1] == pocket[1]\n called_ball = args.state.called_ball[0] == ball[:ball_number]\n if called_ball && called_pocket\n args.state.successful_call = true\n args.state.called_pocket[4] = \"sprites/pocket.png\"\n ball[:path] = \"sprites/ball#{args.state.called_ball[0]}.png\"\n end\n end\n end\n end\n end\nend",
"def play\n # checks if the game is over after every turn\n until over?\n # plays the first few turns of the game\n turn\n end\n\n # checks if the game is won after every turn\n if won?\n puts \"Congratulations #{winner}!\"\n # checks if the game is draw after every turn\n elsif draw?\n puts \"Cats Game!\" # prints \"Cats Game!\" on a draw\n end\n\n end",
"def request_play(trick)\n choices = sort_by_rank(valid_cards(trick))\n \n return choices.first if choices.count == 1 # No choice\n return choices.first if trick.number == 0 # Play largest in first round\n return choices.last if trick.empty? # Always play smallest if starting\n \n if choices.first.suit != trick.suit\n # We're free to play anything, get rid of the most unwanted card\n return choices.first\n else\n # We are following a suit...\n \n if trick.high_card && choices.last > trick.high_card\n # We are forced to take the trick, play most unwanted card\n return choices.first\n else\n # We are following a suit...\n \n if trick.count == 3\n # We are the last to play\n if trick.points?\n return play_safe(trick,choices)\n else\n return choices.first\n end\n end\n \n # Check if the remaining players are all out of the suit\n all_out = true\n \n # We are either 2nd or 3rd to play\n all_out = all_out && neighbour(:left).out_of?(trick.suit)\n all_out = all_out && neighbour(:left).neighbour(:left).out_of?(trick.suit) if trick.count == 1\n \n return play_safe(trick,choices) if all_out\n \n # TODO...\n \n if trick.count == 1\n if trick.number < 4\n if trick.suit == HEARTS\n return risk_it(trick,choices,4)\n elsif trick.suit == SPADES\n if trick.points?\n return risk_it(trick,choices,6)\n else\n return risk_it(trick,choices,JACK)\n end\n else\n return risk_it(trick,choices)\n end\n else\n return play_safe(trick,choices)\n end\n else\n if trick.number < 6\n if trick.suit == HEARTS\n return risk_it(trick,choices,5)\n elsif trick.suit == SPADES\n if trick.points?\n return risk_it(trick,choices,6)\n else\n return risk_it(trick,choices,JACK)\n end\n else\n if trick.points?\n return risk_it(trick,choices,7)\n else\n return risk_it(trick,choices,JACK)\n end\n end\n else\n return play_safe(trick,choices)\n end\n end\n end\n end\n end",
"def play\n until over? !=false\n turn\n end\n if won? != false\n puts \"Congratulations #{winner}!\"\n elsif draw? == true\n puts \"Cats Game!\"\n end \nend",
"def test_poor_predictable_bart()\n assert_equal(\"Paper wins!\", Game.play(\"paper\", \"rock\"))\n end",
"def pbPlayBuzzerSE()\n if $data_system && $data_system.respond_to?(\"buzzer_se\") &&\n $data_system.buzzer_se && $data_system.buzzer_se.name!=\"\"\n pbSEPlay($data_system.buzzer_se)\n elsif $data_system && $data_system.respond_to?(\"sounds\") &&\n $data_system.sounds && $data_system.sounds[3] && $data_system.sounds[3].name!=\"\"\n pbSEPlay($data_system.sounds[3])\n elsif FileTest.audio_exist?(\"Audio/SE/GUI sel buzzer\")\n pbSEPlay(\"GUI sel buzzer\",80)\n end\nend",
"def mood\n if self.happiness < self.nausea\n \"sad\"\n else\n \"happy\"\n end\n end",
"def passive_voice_subjunctive_mood_perfect_tense\n counter = -1\n TenseBlock.new(Linguistics::Latin::Verb::LatinVerb::PASS_PERF_SUBJUNCTIVE_ENDINGS.map do |ending|\n counter += 1\n (counter <=2 ?\n \"[ #{triplicate_and_genderize passive_perfect_participle} ]\" :\n \"[ #{pluralize_participial_listing(triplicate_and_genderize(passive_perfect_participle))} ]\" )+ \" \" + ending\n end,\n { :meaning => Linguistics::Latin::Verb::LatinVerb::MEANINGS[:passive_voice_subjunctive_mood_perfect_tense] }\n )\n end",
"def choose_mood(mood, genre)\n if mood == \"happy\" \n if genre == \"pop\"\n # || mood == \"pumped\" || mood == \"excited\" || mood == \"party\" || mood == \":)\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DX1H4LbvY4OJi\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"r&b\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DX2WkIBRaChxW\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"rock\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DWWJOmJ7nRx0C\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"hip-hop\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DX0XUsuxWHRQd\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"classical\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DWYRUctuBGBo1\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"country\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DWYnwbYQ5HnZU\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n end\n\n # return %{<iframe width=\"560\" height=\"315\" src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DXdPec7aLTmlC\" frameborder=\"0\" allowfullscreen></iframe>}\n # return \"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DXdPec7aLTmlC\"\n elsif mood == \"sad\" \n if genre == \"pop\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DWYp3yzk1civi\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"r&b\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DX6GYkg76TRV8\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n # || mood == \"breakup\" || mood == \":(\" || mood == \"angry\"\n elsif genre == \"rock\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DX6xOPeSOGone\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"hip-hop\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DXdF2fNg82Z7l\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"classical\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DX7cBprxbt1Fn\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"country\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DX8WMG8VPSOJC\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n end\n elsif mood == \"chill\"\n # || mood == \"sleep\" || mood == \"peaceful\" || mood == \"calm\" || mood == \"relax\"\n if genre == \"pop\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DXbIGqYf7WDxP\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"r&b\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DWZu0sk8C6mj5\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"rock\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DWXs1L3AC0Xio\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"hip-hop\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DWT6MhXz0jw61\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"classical\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DWUqIzZNMSCv3\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n elsif genre == \"country\"\n return %{<iframe src=\"https://open.spotify.com/embed/user/spotify/playlist/37i9dQZF1DWTkxQvqMy4WW\" width=\"650\" height=\"300\" frameborder=\"0\" allowtransparency=\"true\"></iframe>}\n else\n return \"Try again.\"\n end\n end\nend",
"def catnip_attack\r\n\t\t# prints string announcing cat has found catnip and is now\r\n\t\t# bouncing off the walls\r\n\t\t\tputs \"Uh oh the cat has found the catnip and is going crazy!\"\r\n\t\tend",
"def listen(rbot)\n\t\tcase rbot.message\n\n\t\twhen /^pause!$/i\n\t\t\tif @itunes.player_state.to_s == 'playing'\n\t\t\t\t@vol = @itunes.sound_volume\n\t\t\t\tstop_randchoon_timer\n\t\t\t\trbot.reply \"Pausing\"\n\n\t\t\t\t# fade_volume_to(0, rbot)\n\t\t\t\t@itunes.pause\n\t\t\tend\n\n\t\twhen /^play!$/i\n\t\t\tif @itunes.player_state.to_s != 'playing'\n\t\t\t\tstop_randchoon_timer\n\t\t\t\trbot.reply \"Playing\"\n\n\t\t\t\t# @itunes.sound_volume = 0\n\t\t\t\t@itunes.play\n\t\t\t\t# fade_volume_to(@vol, rbot)\n\t\t\tend\n\n\t\twhen /^album (.+?)$/i\n\t\t\ttracks = []\n\n\t\t\talbum, artist = $1.split(/\\s+by\\s+/)\n\n\t\t\tif artist\n\t\t\t\ttracks = search_tracks(artist, :artists)\n\t\t\t\ttracks = tracks.select { |t| t.album.downcase.include? album.downcase }\n\t\t\telse\n\t\t\t\ttracks = search_tracks(album, :albums)\n\t\t\tend\n\n\t\t\tif tracks.empty?\n\t\t\t\trbot.reply \"No matching albums\"\n\t\t\telse\n\t\t\t\tstop_randchoon_timer\n\t\t\t\ttrack = tracks.select { |t| t.track_number > 0 }.sort { |a, b| a.track_number - b.track_number }.first\n\t\t\t\trbot.reply \"Playing '#{track.name}' by '#{track.artist}', from '#{track.album}'\"\n\t\t\t\t@itunes.play track\n\t\t\tend\n\n\t\twhen /^play (.+)$/i\n\t\t\tname, artist = $1.split(/\\s+by\\s+/)\n\t\t\tif track = search_and_play(:name => name, :artist => artist)\n\t\t\t\trbot.reply \"Playing '#{track.name}' by '#{track.artist}'\"\n\t\t\telse\n\t\t\t\trbot.reply \"No matching tracks\"\n\t\t\tend\n\n\t\twhen /^choons$/\n\t\t\tif track = randchoon\n\t\t\t\trbot.reply \"Playing '#{track.name}' by '#{track.artist}'\"\n\t\t\telse\n\t\t\t\trbot.reply \"No tracks found\"\n\t\t\tend\n\n\t\twhen /^unchoon$/\n\t\t\told_track = @playlists['choons'].delete({ :name => @itunes.current_track.name, :artist => @itunes.current_track.artist })\n\t\t\trandchoon\n\t\t\trbot.reply \"Skipping '#{old_track.name}', playing #{current_track_description}\"\n\n\t\twhen /(figlet )?c+h+o{2,}n+/i\n\t\t\trbot.reply \"#{'figlet ' if $1}#{current_track_description}\"\n\t\t\t@playlists['choons'] << { :name => @itunes.current_track.name, :artist => @itunes.current_track.artist }\n\n\t\twhen /^playlist add (\\w+)$/i\n\t\t\t@playlists[$1] ||= Playlist.new($1, @playlists_path)\n\t\t\t@playlists[$1] << { :name => @itunes.current_track.name, :artist => @itunes.current_track.artist }\n\t\t\trbot.reply \"#{@itunes.current_track.name} added to playlist '#{$1}'\"\n\n\t\twhen /^playlist (\\w+)$/i\n\t\t\t# TODO playlist playing\n\n\t\twhen /^album/i\n\t\t\ttrack = @itunes.current_track\n\t\t\tif track.compilation?\n\t\t\t\trbot.reply \"The compilation '#{track.album}'\"\n\t\t\telse\n\t\t\t\trbot.reply \"'#{track.album}' by #{track.artist}\"\n\t\t\tend\n\n\t\twhen /^(previous|back)!$/i\n\t\t\tstop_randchoon_timer\n\t\t\t@itunes.previous_track\n\t\t\trbot.reply \"Replaying #{current_track_description}\"\n\n\t\twhen /^again!$/i\n\t\t\tstop_randchoon_timer\n\t\t\tif @itunes.player_state == 'stopped'\n\t\t\t\t@itunes.previous_track\n\t\t\t\t@itunes.playpause\n\t\t\telse\n\t\t\t\tif @itunes.player_position <= 10\n\t\t\t\t\t@itunes.previous_track\n\t\t\t\telse\n\t\t\t\t\t# replay current track\n\t\t\t\t\t@itunes.player_position = 0\n\t\t\t\tend\n\t\t\t\t@itunes.playpause if @itunes.player_state == 'paused'\n\t\t\tend\n\t\t\trbot.reply \"Replaying #{current_track_description}\"\n\n\t\twhen /^next!$/i\n\t\t\tstop_randchoon_timer\n\t\t\told_track = @itunes.current_track.name\n\t\t\t@itunes.next_track\n\t\t\trbot.reply \"Skipping '#{old_track}', playing #{current_track_description}\"\n\n\t\twhen /^\\++$/\n\t\t\tfade_volume_to(@itunes.sound_volume + $&.size, rbot)\n\n\t\twhen /^-+$/\n\t\t\tfade_volume_to(@itunes.sound_volume - $&.size, rbot)\n\n\t\twhen /^Vol(?:ume)?\\?$/i\n\t\t\trbot.reply @itunes.sound_volume\n\n\t\twhen /^\\+(\\d+)$/\n\t\t\tfade_volume_to(@itunes.sound_volume + $1.to_i, rbot)\n\n\t\twhen /^\\-(\\d+)$/\n\t\t\tfade_volume_to(@itunes.sound_volume - $1.to_i, rbot)\n\t\tend\n\trescue Exception => e\n\t\trbot.reply \"Caught exception! #{e} @ #{e.backtrace.shift}\"\n\tend"
] |
[
"0.66102177",
"0.6336153",
"0.63124394",
"0.59365517",
"0.5877527",
"0.5847523",
"0.58019",
"0.57824814",
"0.5780341",
"0.5767283",
"0.57447094",
"0.57197255",
"0.5716265",
"0.57112557",
"0.57064337",
"0.56984246",
"0.5640625",
"0.5630616",
"0.56266683",
"0.5612311",
"0.5593613",
"0.55689436",
"0.5563798",
"0.55575967",
"0.5550553",
"0.5543509",
"0.5520243",
"0.55178666",
"0.55080694",
"0.55023044",
"0.54909116",
"0.548495",
"0.5484769",
"0.5483859",
"0.5482872",
"0.5469539",
"0.5458196",
"0.54481256",
"0.5445602",
"0.54419386",
"0.54347974",
"0.54330367",
"0.5432115",
"0.5430945",
"0.54121107",
"0.5408421",
"0.53886646",
"0.538572",
"0.5382756",
"0.5382756",
"0.5382756",
"0.53644896",
"0.53574455",
"0.53481716",
"0.5346214",
"0.534551",
"0.5342272",
"0.5329968",
"0.53288823",
"0.5325842",
"0.5323477",
"0.53185636",
"0.53184515",
"0.5318326",
"0.5310601",
"0.52636504",
"0.52560854",
"0.5253405",
"0.5253211",
"0.5251373",
"0.5247391",
"0.5245102",
"0.5240364",
"0.5230881",
"0.52307373",
"0.5229505",
"0.5228754",
"0.5214922",
"0.52096796",
"0.52089924",
"0.5208287",
"0.5202897",
"0.5195809",
"0.51949376",
"0.5194685",
"0.51919013",
"0.517235",
"0.5166015",
"0.5158051",
"0.5154723",
"0.5147981",
"0.5147402",
"0.51397175",
"0.5136909",
"0.5132062",
"0.5130303",
"0.51099026",
"0.5109495",
"0.5108368",
"0.5107556"
] |
0.6333235
|
2
|
feed_fish feeds the fishes which makes the fishes' moods happy (FAILED 9)
|
def feed_fish
self.pets[:fishes].each do |fish|
fish.mood = "happy"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def feed_fish\n pets[:fishes].each do |fish|\n fish.mood = \"happy\"\n end\n end",
"def feed_fish\n @pets[:fishes].each { |fish| fish.mood = \"happy\"}\n end",
"def feed_fish\n @pets[:fishes].each {|fish| fish.mood = \"happy\"}\n end",
"def feed(food)\n puts \"Mmmm, \" + food + \"!\"\n @hungry = false\n end",
"def look_for_food(fish)\n fish.stop_turn\n food_range = fish.food_perception\n food = food_around(fish.position, food_range)\n if food.size > 0 && !(fish.status==Escaping)\n food_found = food[0]\n if fish.position.distance(food_found.position) <= EatingAndMatingRange\n fish.consume(food_found)\n @food.delete(food_found)\n @food.compact!\n else\n fish.spot_food(food_found)\n end\n end\n end",
"def loose_fish_when_bear_takes_it(fish)\n\n end",
"def update_fish\n @dead_fish.each do |dead_fish|\n if dead_fish.position.y >= FishDeathbed and rand<=DecomposeChance\n puts \"decomposed!!\"\n @dead_fish.delete(dead_fish)\n @dead_fish.compact!\n elsif dead_fish.position.y <= FishDeathbed\n dead_fish.move\n end\n end\n @fish.each do |fish|\n case fish.status\n when Idle || Turning\n unless check_walls(fish)\n look_for_food(fish)\n look_for_mate(fish) unless (fish.target or fish.sex==Female or fish.virility<200)\n end\n when Avoiding\n when Pursuing\n case fish.target\n when FishFood\n look_for_food(fish)\n when SalmonObject\n look_for_mate(fish)\n when Shark\n end\n when Dead\n @fish.delete(fish) \n @fish.compact!\n @dead_fish << fish\n return\n end\n fish.move\n end\n end",
"def check_fish(fh)\n\tif !($fish.include?(fh))\n\t\traise \"A valid type of fish has NOT been entered.\"\n\tend\n\t\n\t# Set the current fish\n\tset_next_fish(fh)\nend",
"def buy_fish(name)\n#knows about its fishes\n pets[:fishes] << Fish.new(name)\n end",
"def eat_fish(fish)\n @empty_stomach << fish\n return @empty_stomach.count\n end",
"def feed\n\t\tputs \"You feed #{@name}\"\n\t\t@stuff_in_belly = 10\n\t\tpassage_of_time\n\tend",
"def buy_fish(name) # expect(owner.pets[:fishes].count).to eq(0)\n new_fish = Fish.new(name) # owner.buy_fish(\"Bubbles\")\n self.pets[:fishes] << new_fish # owner.pets[:fishes].each { |fish| expect(fish).to be_a(Fish)}\n new_fish # expect(owner.pets[:fishes].count).to eq(1)\n # = knows about its fishes; Owner knows all about its pets - Owner sets name of pet, the pet can\\'t change its name\n # owner.buy_fish(\"Bubbles\")\n # expect(owner.pets[:fishes][0].name).to eq(\"Bubbles\")\n end",
"def set_next_fish(fhh)\n\t# Check if the next fish to eat is valid\n\t#check_fish(fhh)\n\t\n\t$cur_fish = fhh\nend",
"def buy_fish(name)\n pets[:fishes] << Fish.new(name)\n end",
"def buy_fish(fish_name)\n fish = Fish.new(fish_name)\n self.pets[:fishes] << fish\n end",
"def loose_fish_when_bear_takes_it()\n @bear.add_to_stomach(@fish1)\n @river.loose_fish(@fish1)\n assert_equal(0,@river.fish_count())\n end",
"def eat_fish(fish)\n @stomach << fish\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def set_fish\n @fish = Fish.find(params[:id])\n end",
"def get_fish\n\t# Return the current fish to eat\n\treturn $cur_fish\nend",
"def send_chest_fame\n Chest_Service.send_feedback(Chest_Service::FAME, online_chest)\n end",
"def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end",
"def buy_fish(name)\n fish = Fish.new(name)\n @pets[:fishes] << fish\n end",
"def create\n @fish = Fish.new(fish_params)\n\t\t@user = User.find_by email: params[:user][:email]\n\t\t@fish.user_id = @user.id\n\t\tif @fish.save\n\t\t\t@fish.fish_photo = \"fish#{@fish.id}.jpeg\"\n\t\t\t@fish.save\n\t\t\timage_convert(@fish.id)\n \t@weather = @fish.weathers.create(weather_params)\n \trespond_to do |format|\n \tif @weather.save\n \tformat.html { redirect_to @fish, notice: 'Fish was successfully created.' }\n \tformat.json { render action: 'show', status: :created, location: @fish }\n \telse\n \tformat.html { render action: 'new' }\n \tformat.json { render json: @fish.errors, status: :unprocessable_entity }\n \tend\n \tend\n\t\tend\n end",
"def buy_fish(name)\n @pets[:fishes] << Fish.new(name)\n end",
"def buy_fish(name)\n new_fish = Fish.new(name)\n if new_fish.class == Fish\n @pets[:fishes] << new_fish\n end \n end",
"def create\n @fish = Fish.new(fish_params)\n\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish, notice: \"Fish was successfully created.\" }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fish = Fish.new(fish_params)\n\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish, notice: 'Fish was successfully created.' }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @fish = Fish.new(fish_params)\n\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish, notice: 'Fish was successfully created.' }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def parse(feed_data)\n super\n\n @buzzes = []\n feed_data.elements.each('entry') do |buzz_data|\n @buzzes << Buzz.new(@user, buzz_data)\n end\n\n true\n end",
"def initialize(name)\n @name = name\n @fishes = []\n end",
"def feed(amount=10)\n @food_in_belly += amount\n\n if @food_in_belly > 100\n puts \"#{@name} is stuffed. #{@name} pukes the execess.\"\n @food_in_belly = 100\n else\n puts \"#{@name} eats happily.\"\n end # end of conditional for overstuffed\n time_passed\n end",
"def fish_eaten(eat_fish)\n fish = find_fish(eat_fish)\n fishes.delete(fish)\nend",
"def fish_params\n params.require(:fish).permit(:color_id, :weight, :over_28, :tournament_id, :member_id, :returned, :image, :remove_image)\n end",
"def start_fishing\n api_post(@current_resource.body.links[\"start_fishing\"][\"href\"], \"foo\")\n end",
"def list_fav\r\n users = User.all \r\n users.each do |user|\r\n puts \"#{user}\"\r\n user.snacks.each do |snack|\r\n puts \"- #{snack}\"\r\n end\r\n end\r\nend",
"def add_fish (fish)\n @fish_population << fish\n\n end",
"def feed\n puts 'You feed ' + @name + '. He looks satisifed.'\n puts\n @stomach = 10\n passageOfTime\n end",
"def fish_params\n params.require(:fish).permit(:name, :description, :sex, :is_neuter)\n end",
"def fbook\n @user = Koala::Facebook::API.new(ENV[\"ACCESS_TOKEN\"])\n if self.title != nil\n @user.put_connections(\"me\", \"feed\", :message => \"#{self.title} - #{self.short_desc} ($#{self.price})\")\n end\n end",
"def feed\n end",
"def feed\n\n end",
"def create\n if params[:tournament_id].present?\n @tournament = Tournament.find(params[:tournament_id])\n @fish = @tournament.fish.new(fish_params)\n else\n @fish = Fish.new(fish_params)\n end\n @fish.member = @current_member\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish.tournament, notice: 'Fish was successfully created.' }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def catch_fish\n inventory[:fish] += @skills[:fish]\n end",
"def send_chest_infame\n Chest_Service.send_feedback(Chest_Service::INFAME, online_chest)\n end",
"def is_fav_food(person, test_food)\n fav_snacks = person[:favourites][:snacks]\n for snack in fav_snacks\n if snack == test_food\n return true\n end\n end\n return false\nend",
"def create\n @fish = Fish.new(fish_params)\n @fish.user_id = current_user.id\n\n respond_to do |format|\n if @fish.save\n format.html { redirect_to @fish, notice: 'Fish was successfully created.' }\n format.json { render :show, status: :created, location: @fish }\n else\n format.html { render :new }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def trickledown_feed \n begin \n if self.feeds.present? && self.stix_package.present?\n self.stix_package.update_attribute(:feeds, self.feeds) \n end\n rescue Exception => e\n ex_msg = \"Exception during trickledown_feed on: \" + self.class.name \n ExceptionLogger.debug(\"#{ex_msg}\" + \". #{e.to_s}\")\n end\n end",
"def eat\n inventory[:fish] -= @daily_appetite = 10\n\n if inventory[:fish] < 0\n @alive = false\n inventory[:fish] = 0\n end\n end",
"def feed\n\t\t# Microalert.from_buildings_followed_by(self) \n\t\t#Microalert.where(\"vocal_type = ? AND vocal_id = ?\", self.class.name, id)\n\t\t#Microalert.from_buildings_followed_by(self)\n\t\tMicroalert.from_all_followed_by(self) \n\tend",
"def factions\n \n end",
"def update\n respond_to do |format|\n if @fish.update(fish_params)\n format.html { redirect_to @fish, notice: \"Fish was successfully updated.\" }\n format.json { render :show, status: :ok, location: @fish }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def publish_on_fb\n\t \tbegin\n\t\t \tme = FbGraph::User.me(oauth_token)\n\t\t \tme.feed!(\n\t\t \t\t:message => \"\",\n\t\t \t\t:picture => \"indirizzo immagine\",\n\t\t \t\t:link => \"indirizzo applicazione\",\n\t\t \t\t:name => \"\",\n\t\t \t\t:description => \"\"\n\t\t \t)\n\t\trescue Exception\n\t\t\t# Condivisione non andata a buon fine.\n\t\tend\n \tend",
"def set_fish\n @organism = Fish.with_all.find(params[:id])\n end",
"def farewell(m)\n return unless m.message =~ /\\b((good)?bye|adios|farewell|later|see ?(ya|you|u)|cya),? #{m.bot.nick}\\b/i\n farewells = ['Bye', 'Adios', 'Farewell', 'Later', 'See ya', 'See you', 'Take care']\n farewell = farewells[rand(farewells.size)]\n m.reply \"#{farewell}, #{m.user.nick}!\"\n end",
"def look_for_mate(fish)\n fish.stop_turn\n mate_range = fish.mate_perception\n mate = mate_around(fish.position, mate_range)\n if mate.size > 0 && !(fish.status==Escaping)\n mate_found = mate[0]\n if (fish.position.distance(mate_found.position) <= EatingAndMatingRange) and \n (fish.virility >= ReadyForAction) and \n (mate_found.sex==Female)\n if fish.court(mate_found)==true\n egg = fish.mate(mate_found)\n self << egg\n end\n else\n fish.spot_mate(mate_found) unless fish.virility < ReadyForAction\n end\n end\n end",
"def forfeit(guest)\n \"#{guest.name} is washing dishes whilst singing #{guest.fave_song}\"\n end",
"def create_feed\n end",
"def create_feed\n end",
"def create_feed\n end",
"def create_feed\n end",
"def eat_fish_from_river(fish, river)\n @stomach.push(fish)\n river.lose_fish(fish)\n end",
"def beg_for_food(food_served)\n if food_served\n puts \"Whimper\"\n end\n end",
"def take_fish_from_river\n @stomach.concact(fish_count)\n end",
"def index\n @fish = Fish.all\n end",
"def index\n @fish = Fish.all\n end",
"def index\n @fish = Fish.all\n end",
"def index\n @fish = Fish.all\n end",
"def update\n respond_to do |format|\n if @fish.update(fish_params)\n format.html { redirect_to @fish, notice: 'Fish was successfully updated.' }\n format.json { render :show, status: :ok, location: @fish }\n else\n format.html { render :edit }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fish.update(fish_params)\n format.html { redirect_to @fish, notice: 'Fish was successfully updated.' }\n format.json { render :show, status: :ok, location: @fish }\n else\n format.html { render :edit }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fish.update(fish_params)\n format.html { redirect_to @fish, notice: 'Fish was successfully updated.' }\n format.json { render :show, status: :ok, location: @fish }\n else\n format.html { render :edit }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fish.update(fish_params)\n format.html { redirect_to @fish, notice: 'Fish was successfully updated.' }\n format.json { render :show, status: :ok, location: @fish }\n else\n format.html { render :edit }\n format.json { render json: @fish.errors, status: :unprocessable_entity }\n end\n end\n end",
"def spot_food(food)\n @fish.direction = @fish.move_towards(food)\n @fish.status = Pursuing\n @fish.target = food\n end",
"def Festival(action_hash = {})\n puts 'Festival called!'\n card = Card.find(played_card_id)\n if card and phase == 'Action'\n player = game.players.find(player_turn)\n add_actions(1) # +2 actions -1 from playing festival = +1 actions\n add_buys(1)\n add_treasures(2)\n player.add_to_played(card)\n update_attributes(prompt: '<b>Played Festival!</b><br />+2 Actions / +1 Buy / +2 Treasure<br />')\n end\n reset_action_variables\n end",
"def load_fishing_groups(y)\n x = 0\n name_format = PFM::Pokemon::MALE_NAME\n $wild_battle.fishing.each do |type, arr|\n break if y >= @height\n name = FISHING_NAMES[type]\n arr.each_with_index do |group, zone|\n next unless group\n @stack.add_text(x, y, 320, 16, format(name, ZONE_TYPE_NAMES_NTAG[zone]), color: 9)\n group.ids.each do |id|\n @stack.push(x, y, format(name_format, id))\n x += 32\n if x >= @width\n y += 32\n x = 0\n end\n end\n y += 32\n x = 0\n break if y >= @height\n end\n end\n end",
"def catch_flies\n\t\t@flies.each do |f|\n\t\t\t@webs.each do |w|\n\t\t\t\tif overlap?(w, f)\n\t\t\t\t\tf.caught = true\n\t\t\t\t\tw.add_fly(f)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def feed\n\n # If the user is not logged in, render the non-member home action\n if !current_user\n render :template => 'promo/home', :layout => 'empty'\n else\n @everybody = params[:everybody]\n\n # If the everybody flag is set, respond with feed items about everybody\n # on Blavel\n # Otherwise, respond with feed items only about the people that the\n # current user is following\n if @everybody\n @feed_items = gather_feed_items\n else\n @feed_items = gather_feed_items(current_user)\n end\n\n # Pass through the first 5 followers and the first 5 followees, all\n # randomised\n @followers = current_user.followers.sort_by { rand }.first(6)\n @followees = current_user.followees.sort_by { rand }.first(6)\n\n # Respond with html or javascript, depending on whether it is requested\n # via ajax or not\n respond_to do |format|\n format.html\n format.js { render :template => 'feeds/feed.js.erb', :layout => false }\n end\n end\n end",
"def eat_allergies\t\n\t\tno_allergies != \"scallops\"\n\t\t\tputs \"#{all_food[i]} was tastey!\"\n\t\trescue AllergyError\n\t\t\tputs \"Beth, you can't eat #{i}!\"\n\t\tensure\n\t\t\tputs \"Beth went to the hosptial for some reason, hmm.\"\n\t\tend",
"def eat_allergies\t\n\t\tno_allergies != \"scallops\"\n\t\t\tputs \"#{all_food[i]} was tastey!\"\n\t\trescue AllergyError\n\t\t\tputs \"Beth, you can't eat #{i}!\"\n\t\tensure\n\t\t\tputs \"Beth went to the hosptial for some reason, hmm.\"\n\t\tend",
"def spawn_fish(n=20)\n for i in 0..n-1\n type = Aqua::Salmon\n srand\n sex = rand(2) == 0 ? Aqua::Male : Aqua::Female\n fish_desc = {\n 'type' => type,\n 'sex' => sex,\n 'speed' => Aqua::DefaultSpeed, # the following 3 can be lumped into one constant\n 'world_perception' => Aqua::DefaultWorldVision,\n 'food_perception' => Aqua::DefaultFoodPerception,\n 'mate_perception' => Aqua::DefaultMatePerception,\n 'position' => Aqua::Position.new([randomFloatSigned, 0, randomFloatSigned]),\n 'direction_change_factor' => Aqua::DefaultChangeFactor\n };\n self << Aqua::SalmonObject.new(fish_desc)\n end\n end",
"def fish_params\n params.require(:fish).permit(:user_id, :fish_type, :fish_length, :fish_weight, :caught_on, :longitude, :latitude, :caught_date, :fish_photo)\n end",
"def feed\n puts\"Votre animal se nourrit \\n\"\n @health += 30\n return 1\n end",
"def add_food\n srand\n self << FishFood.new(Position.new([randomFloatSigned*2,1,randomFloatSigned]))\n end",
"def eat_allergies\t\n\t\tno_allergies != \"gluten\"\n\t\t\tputs \"#{all_food[i]} was tastey!\"\n\t\trescue AllergyError\n\t\t\tputs \"Chris, you can't eat #{i}!\"\n\t\tensure\n\t\t\tputs \"Chris went to the hosptial for some reason, hmm.\"\n\t\tend",
"def eat_allergies\t\n\t\tno_allergies != \"gluten\"\n\t\t\tputs \"#{all_food[i]} was tastey!\"\n\t\trescue AllergyError\n\t\t\tputs \"Chris, you can't eat #{i}!\"\n\t\tensure\n\t\t\tputs \"Chris went to the hosptial for some reason, hmm.\"\n\t\tend",
"def buy_fish(name)\n new_fish = Fish.new(name)\n self.pets[:fishes] << new_fish \n end",
"def fish_count()\n return @fish.length()\n end",
"def behavior_hungry\n @world.food.each do |food|\n if distance_from_point(food.position) < (food.quantity + ROID_SIZE*5)\n @delta -= self.position - food.position\n end \n if distance_from_point(food.position) <= food.quantity + 5\n eat food\n end \n end \n end",
"def create\n @fishing_method = FishingMethod.new(params[:fishing_method])\n\n respond_to do |format|\n if @fishing_method.save\n format.html { redirect_to @fishing_method, notice: 'Fishing method was successfully created.' }\n format.json { render json: @fishing_method, status: :created, location: @fishing_method }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fishing_method.errors, status: :unprocessable_entity }\n end\n end\n end",
"def buy_fish(name)\n pets[:fishes] << Fish.new(name)\nend",
"def post(number = 1)\n results = twitter_client.search(\"#sad\")\n return unless results.try(:any?)\n results.take(number).each do |tweet|\n twitter_client.favorite(tweet)\n twitter_client.update(\"@#{tweet.user.screen_name} Happiness is the art of never holding in your mind the memory of any unpleasant thing that has passed.\")\n end\n end",
"def _stack_add_flee(pokemon: nil, reason: :roaming)\n @results << [3, get_pokemon_o(pokemon), reason]\n end",
"def feed_cats\n self.cats.each do |cat|\n cat.mood = \"happy\"\n end \n end",
"def favourited_items\n self.favourites.each do |f|\n f.favouritable\n end\n end",
"def finished?\n go_fish.over?\n end",
"def create\n @fishery = @country.fisheries.build(fishery_params)\n\n respond_to do |format|\n if @fishery.save\n format.html { redirect_to country_fisheries_path(@country), notice: \"Fishery was successfully created.\" }\n format.json { render :show, status: :created, location: @fishery }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @fishery.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.72045267",
"0.70892316",
"0.707225",
"0.6678427",
"0.643399",
"0.6155729",
"0.61218",
"0.60823095",
"0.6074913",
"0.60460913",
"0.59686893",
"0.593222",
"0.5892891",
"0.58799773",
"0.5843985",
"0.57496357",
"0.57332045",
"0.5725145",
"0.5725145",
"0.5725145",
"0.5725145",
"0.5725145",
"0.5725145",
"0.57152283",
"0.56802404",
"0.56743556",
"0.56743556",
"0.5655068",
"0.5623676",
"0.5599485",
"0.5580857",
"0.5566345",
"0.5566345",
"0.5536985",
"0.5527129",
"0.5525476",
"0.5484224",
"0.5430608",
"0.54256165",
"0.5411808",
"0.53955525",
"0.5380186",
"0.5380071",
"0.5373746",
"0.5371444",
"0.53609705",
"0.53420395",
"0.53243715",
"0.53116167",
"0.530343",
"0.5296405",
"0.52712995",
"0.52670634",
"0.5254724",
"0.52372754",
"0.5224865",
"0.5206686",
"0.51959175",
"0.5188256",
"0.5178306",
"0.51748914",
"0.5174361",
"0.5174361",
"0.5174361",
"0.5174361",
"0.51735085",
"0.51628965",
"0.51268506",
"0.51238066",
"0.51238066",
"0.51238066",
"0.51238066",
"0.51169807",
"0.51169807",
"0.51169807",
"0.51169807",
"0.5112318",
"0.51032174",
"0.50969034",
"0.5090753",
"0.50897974",
"0.5062185",
"0.5062185",
"0.50521314",
"0.5051221",
"0.5045407",
"0.5035946",
"0.5034377",
"0.5034377",
"0.50316626",
"0.5024868",
"0.5012416",
"0.501179",
"0.5009564",
"0.49993703",
"0.4995351",
"0.49770087",
"0.49739113",
"0.4970263",
"0.49674317"
] |
0.6854544
|
3
|
sell_pets can sell all its pets, which make them nervous (FAILED 10)
|
def sell_pets
self.pets[:dogs].each do |dog|
dog.mood = "nervous"
end
self.pets[:cats].each do |cat|
cat.mood = "nervous"
end
self.pets[:fishes].each do |fish|
fish.mood = "nervous"
end
self.pets[:fishes] = []
self.pets[:dogs] = []
self.pets[:cats] = []
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def sell_pets\n pets.each {|kind, moods|\n moods.each {|pets| pets.mood=(\"nervous\")}\n moods.clear\n }\n end",
"def sell_pets\n all_owner_pets = self.dogs + self.cats\n \n all_owner_pets.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end \n\n end",
"def sell_pets\n pets = dogs + cats\n\n pets.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n end",
"def sell_pets\n pets.each do |type, all_type|\n all_type.each do |pet|\n pet.mood = \"nervous\"\n end\n end\n pets.clear\n end",
"def sell_pets #Owner can sell all its pets, which make them nervous\n # fido = Dog.new(\"Fido\")\n # tabby = Cat.new(\"Tabby\")\n # nemo = Fish.new(\"Nemo\")\n # [fido, tabby, nemo].each {|o| o.mood = \"happy\" }\n # owner.pets = {\n # :dogs => [fido, Dog.new(\"Daisy\")],\n # :fishes => [nemo],\n # :cats => [Cat.new(\"Mittens\"), tabby]\n # }\n # owner.sell_pets\n # owner.pets.each {|type, pets| expect(pets.empty?).to eq(true) }\n # [fido, tabby, nemo].each { |o| expect(o.mood).to eq(\"nervous\") }\n pets.each do |type, animals|\n animals.each do |animal|\n animal.mood = \"nervous\"\n end\n animals.clear\n end\n end",
"def sell_pets\n all_pets = []\n all_pets << self.cats \n all_pets << self.dogs \n all_pets.flatten.map do |each_pet|\n each_pet.mood = \"nervous\"\n each_pet.owner = nil\n end\n end",
"def sell_pets\n Cat.all.collect do |cats|\n cats.mood=\"nervous\"\n cats.owner=nil\n end\n Dog.all.collect do |dogs|\n dogs.mood=\"nervous\"\n dogs.owner=nil\n end\n end",
"def sell_pets\n pets.each do |species, pet_array| #enumerate through pets hash...\n pet_array.each do |pet_object| #then enumerate through pet_array within pets hash...\n #binding.pry\n pet_object.mood = \"nervous\" #set each pet_object's mood to \"nervous\"\n end\n end #end loop\n self.pets.clear #and reset Owner instance .pets to an empty array, that is returned\n end",
"def sell_pets\n cats.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n dogs.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n \n\n end",
"def sell_pets\n @pets.each do |type, pet| \n pet.each { |animal| animal.mood = \"nervous\"}\n end\n @pets.clear\n end",
"def sell_pet_to_customer(shop, pet, customer)\n for animal in shop[:pets]\n if animal == pet && customer_can_afford_pet(customer, pet) == true\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(shop, pet[:price])\n increase_pets_sold(shop,1)\n add_pet_to_customer(customer, pet)\n remove_pet_by_name(shop, pet)\n end\n end\nend",
"def sell_pet_to_customer(shop,pet,customer)\n if pet != nil && customer_can_afford_pet(customer,pet) == true\n for animal in shop[:pets]\n if animal[:name] == pet[:name]\n amount = pet[:price]\n add_pet_to_customer(customer,pet)\n customer_pet_count(customer)\n increase_pets_sold(shop,1)\n remove_customer_cash(customer,amount)\n add_or_remove_cash(shop,amount)\n end\n end\n end\nend",
"def sell_pet_to_customer(pet_shop, pet, customer)\n for l_pet_shop in pet_shop[:pets]\n if l_pet_shop == pet\n if customer_can_afford_pet(customer, pet) == true\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(pet_shop, pet[:price])\n add_pet_to_customer(customer, pet)\n increase_pets_sold(pet_shop, 1)\n end\n end\n end\nend",
"def sell_pets\n all_animals = self.pets.values\n\n all_animals.each do |species|\n species.each {|pet| pet.mood = \"nervous\"}\n species.clear\n end\n end",
"def sell_pet_to_customer(shop, pet, customer)\n if find_pet_by_name(shop, pet) != nil\n then\n if customer_can_afford_pet(customer, pet)\n then\n add_pet_to_customer(customer, pet)\n # remove_pet_by_name(shop, pet)\n increase_pets_sold(shop, 1)\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(shop, pet[:price])\nend\nend\nend",
"def test_sell_pet_to_customer__pet_found\n customer = @customers[0]\n pet = find_pet_by_name(@pet_shop,\"Arthur\")\n\n sell_pet_to_customer(@pet_shop, pet, customer)\n\n assert_equal(1, customer_pet_count(customer)) #checks the customer pet count so we need to add the pet into the :pets array\n assert_equal(1, pets_sold(@pet_shop)) #checks the pet is sold so we need to add 1 to admin: pets_sold:\n assert_equal(100, customer_cash(customer)) #checks the cash has been deducted from the customers cash e.g. customer cash should = customer cash - cost of the pet\n assert_equal(1900, total_cash(@pet_shop)) #checks the price of the pet is added to the total total cash\n end",
"def sell_pet_to_customer(pet_shop, supplied_pet, supplied_customer)\n if supplied_pet != nil && customer_can_afford_pet(supplied_customer, supplied_pet) == true\n increase_pets_sold(pet_shop, 1)\n add_pet_to_customer(supplied_customer,supplied_pet)\n add_or_remove_cash(pet_shop, supplied_pet[:price])\n customer_pet_count(supplied_customer)\n remove_pet_by_name(pet_shop, supplied_pet[:name])\n end\nend",
"def sell_pet_to_customer(pet_shop, pet_to_sell, customer)\n for pet_for_sale in pet_shop[:pets]\n if pet_for_sale[:name] == pet_to_sell\n customer[:pets].push(pet_to_sell)\n pet_shop[:admin][:pets_sold] += 1\n customer[:cash] -= pet_to_sell[:price]\n pet_shop[:admin][:total_cash] += pet_to_sell[:price]\n end\n end\nend",
"def sell_pets\n#this makes them all nervous\n pets.each do |species, animals|\n animals.each do |animal|\n animal.mood = \"nervous\"\n end\n animals.clear\n end\n end",
"def sell_pets\n self.cats.each{ |each_cat|\n each_cat.mood = \"nervous\"\n each_cat.owner = nil\n }\n \n self.dogs.each{ |each_dog|\n each_dog.mood = \"nervous\"\n each_dog.owner = nil\n }\n\n self.cats.clear\n self.dogs.clear\n end",
"def sell_pet_to_customer(shop_name, sold_pet, customer)\n #p find_pet_by_name(shop_name, sold_pet) != nil\n if sold_pet != nil\n if customer_can_afford_pet(customer, sold_pet) == true\n add_pet_to_customer(customer, sold_pet)\n increase_pets_sold(shop_name, 1)\n remove_customer_cash(customer, sold_pet[:price])\n add_or_remove_cash(shop_name, sold_pet[:price])\n end\n end\nend",
"def sell_pet_to_customer(pet_shop, pet, customer)\n\n\n if pet != nil && customer_can_afford_pet(customer, pet)\n\n add_pet_to_customer(customer, pet)\n customer_pet_count(customer)\n\n\n increase_pets_sold(pet_shop, customer_pet_count(customer))\n pets_sold(pet_shop)\n\n\n remove_customer_cash(customer, pet[:price])\n customer_cash(customer)\n\n add_or_remove_cash(pet_shop, pet[:price])\n total_cash(pet_shop)\n\n end\n\nend",
"def sell_pet_to_customer(pet_shop, pet, customer)\n if pet && customer_can_afford_pet(customer, pet) \n add_pet_to_customer(customer, pet)\n increase_pets_sold(pet_shop, 1)\n add_or_remove_cash(pet_shop, pet[:price])\n end\nend",
"def sell_pet_to_customer(pet_shop, pet, customer)\n # the customer pet count increases by 1\n if pet != nil\n customer_can_afford_pet(customer, pet)\n add_pet_to_customer(customer, pet)\n increase_pets_sold(pet_shop, 1)\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(pet_shop, pet[:price])\n end\nend",
"def sell_pet_to_customer(petshop,pet,customer)\n\n if (customer[:cash] >= pet[:price]) #&& (petshop[:pets][:name] == pet[:name])\n customer[:pets].push(pet[:name])\n end\n # return customer[:pets].count()\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 sell_pet_to_customer(pet_shop, pet, customer)\n if ((pet != nil) && customer_can_afford_pet(customer, pet))\n add_pet_to_customer(customer, pet)\n increase_pets_sold(pet_shop, customer[:pets].count())\n add_or_remove_cash(pet_shop, pet[:price])\n end\nend",
"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",
"def sell_pet_to_customer(shop, pet, customer)\n return if (pet == nil)\n if customer_can_afford_pet(customer, pet)\n add_pet_to_customer(customer, pet)\n increase_pets_sold(shop,1)\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(shop,pet[:price])\nend\n\nend",
"def sell\n \t\t\n \tend",
"def sell_pet_to_customer(pet_shop, pet, customer)\n if pet != nil && customer_can_afford_pet(customer, pet)\n remove_pet_by_name(pet_shop, pet)\n add_pet_to_customer(customer, pet)\n increase_pets_sold(pet_shop, 1)\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(pet_shop, pet[:price])\n end\nend",
"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_pet_to_customer(section, pet, customer)\n if pet && customer_can_afford_pet(customer, pet)\n add_pet_to_customer(customer, pet)\n increase_pets_sold(section, 1)\n add_or_remove_cash(section, pet[:price])\n end\nend",
"def sell_pet_to_customer(shop, pet, customer)\n if pet != nil\n if customer_can_afford_pet(customer, pet) == true\n add_pet_to_customer(customer, pet)\n add_or_remove_cash(shop, pet[:price])\n increase_pets_sold(shop, 1)\n remove_pet_by_name(shop, pet[:name])\n customer[:cash] -= pet[:price]\n end\n end\nend",
"def pets\n\t\t@pets_list\n\tend",
"def pets\n @pets\n end",
"def buy_pet(pet)\n self.pets.push(pet)\n pet.owner = self\n end",
"def sell_pet_to_customer(pet_shop_hash, new_pet, customer_hash)\n if new_pet != nil\n if customer_can_afford_pet(customer_hash, new_pet)\n remove_pet_by_name(pet_shop_hash, new_pet[:name])\n add_pet_to_customer(customer_hash, new_pet)\n remove_customer_cash(customer_hash, new_pet[:price])\n increase_pets_sold(pet_shop_hash, 1)\n add_or_remove_cash(pet_shop_hash,new_pet[:price])\n end\n end\nend",
"def sell_pet_to_customer(pet_shop, pet, customer)\n return if pet == nil\n if customer_can_afford_pet(customer, pet) == true\n add_pet_to_customer(customer, pet)\n increase_pets_sold(pet_shop, 1)\n remove_customer_cash(customer, pet[:price])\n add_or_remove_cash(pet_shop, pet[:price])\n end\nend",
"def can_sell?\n inventory.any? { |inv| inv.price > 0 }\n end",
"def sell_pet_to_customer(shop,pet,customer)\n if pet != nil && customer_can_afford_pet(customer,pet)#this result returns true anyway and so my ==true in my version was not needed\n add_pet_to_customer(customer,pet)\n remove_pet_by_name(shop,pet)\n remove_customer_cash(customer,pet[:price])\n add_or_remove_cash(shop,pet[:price])\n increase_pets_sold(shop,1)\n end\nend",
"def sell_pet_to_customer(petshop,name,customer)\n for pet in petshop[:pets]\n if pet[:name] == name\n customers[:pets].push(pet)\n petshop[:admin][:pets_sold].push(pet)\n sold[:admin][:total_cash] += amount\n end\n end\n return nil\nend",
"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 sell_pet_to_customer(hash, pet, customer)\n add_pet_to_customer(customer, pet)\n increase_pets_sold(hash, 1) #interger too specific why not pet.count.to_i?\n remove_customer_cash(customer, 900)\n add_or_remove_cash(hash, 900)\nend",
"def test_sell_pet_to_customer__pet_found\n customer = @customers[0]\n pet = find_pet_by_name(@pet_shop,\"Arthur\")# pre-exising function #9\n\n sell_pet_to_customer(@pet_shop, pet, customer)# need to define this function\n\n assert_equal(1, customer_pet_count(customer))#pre-existing\n assert_equal(1, pets_sold(@pet_shop))#pre-existing\n assert_equal(100, customer_cash(customer))#pre-existing\n assert_equal(1900, total_cash(@pet_shop))#pre-existing\n end",
"def build_pet_with_limit\n return false if pets_limit_reached?\n\n pets.build\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 buy_pet(pet_cost)\n sql = \"SELECT SUM (pets.cost) FROM pets INNER JOIN adoptions ON pets.id = adoptions.pet_id WHERE adoptions.owner_id = $1\"\n values = [@id]\n result = SqlRunner.run(sql, values).first\n @funds = @funds - result['sum'].to_i\n end",
"def sell_pet_to_customer(pet_shop, pet, customer)\n customer[:pets].count\n pet_shop[:admin][:pets_sold]\n customer[:cash]\n pet_shop[:admin][:total_cash]\nend",
"def pets #stores all of the owners pets\n @pets #expect(owner.pets).to eq({:fishes => [], :dogs => [], :cats => []})\n end",
"def pets_owned (x)\n @pets.push (x)\n end",
"def test_all_pets_by_breed__not_found\n pets = pets_by_breed(@pet_shop, \"Dalmation\")\n assert_equal(0, pets.count)\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 sell_pet_to_customer(pet_shop, pet, customer)\n if pet != nil && customer[:cash] >= pet[:price]\n customer[:pets].push(pet)\n pet_shop[:admin][:pets_sold] += 1\n customer[:cash] -= pet[:price]\n pet_shop[:admin][:total_cash] += pet[:price]\n end\nend",
"def sell_pet_to_customer(pet_shop, pet, customer)\n if\n pet_shop[:admin][:total_cash] += pet[:price]\n customer[:cash] -= pet[:price]\n else\n p \"Not enough dough :( \"\n end\n customer[:pets] << pet\n pet_shop[:admin][:pets_sold] += [:pets].count()\nend",
"def sell_pet_to_customer(pet_store, bought_pet, customer)\n if bought_pet != nil && (customer[:cash] >= bought_pet[:price])\n add_pet_to_customer(customer, bought_pet)\n increase_pets_sold(pet_store, 1)\n remove_customer_cash(customer, bought_pet[:price])\n add_or_remove_cash(pet_store, bought_pet[:price])\n end\nend",
"def take_all_bets\n\t\tno_raises = false\n\t\tplayer_seats = players.dup.select do |p| \n\t\t\tp.bankroll > 0 && !p.folded?\n\t\tend.shuffle\n\t\t\n\t\t# first in player_seats bets\n\t\tcurr_high_bet = get_opening_bet(player_seats)\n\t\t\n\t\t#A betting round ends when all active players have bet an equal amount or everyone folds to a player's bet or raise\n\t\tuntil no_raises\n\t\t\tno_raises = true\n\t\t\tplayer_seats = player_seats.rotate\n\t\t\n\t\t\tplayer_seats.each_with_index do |player, i| \n\t\t\t\tnext if player.folded?\n\t\t\t\tnext if player.raised? || player.betted?\n\t\t\t\tputs \"\\nPlayer #{i+1}, #{player.name}'s turn. Current high bet: #{curr_high_bet}. Current pot: #{@pot}.\"\n\t\t\t\tmove = player.get_move\n\t\t\t\t\n\t\t\t\tcase move\n\t\t\t\twhen :fold\n\t\t\t\t\tplayer.folded = true \n\t\t\t\twhen :see\n\t\t\t\t\tbegin\n\t\t\t\t\t\tplayer.take_bet(curr_high_bet)\n\t\t\t\t\trescue PokerError # move on to next player \n\t\t\t\t\t\tputs \"You cannot afford this bet.\".red\n\t\t\t\t\t\tplayer.folded = true\n\t\t\t\t\telse\n\t\t\t\t\t\tputs \"#{player.name}'s bankroll is now: #{player.bankroll}.\"\n\t\t\t\t\t\t@pot += curr_high_bet\n\t\t\t\t\t\tplayer.betted = true\n\t\t\t\t\tend\n\t\t\t\twhen :raise\n\t\t\t\t\tbegin\n\t\t\t\t\t\traise PokerError if curr_high_bet > player.bankroll\n\t\t\t\t\t\traise_bet = player.get_bet\n\t\t\t\t\t\traise BadInputError unless raise_bet > curr_high_bet\n\t\t\t\t\trescue BadInputError\n\t\t\t\t\t\tputs \"You must raise higher than the current bet.\".red\n\t\t\t\t\t\tretry \n\t\t\t\t\trescue PokerError\n\t\t\t\t\t\tputs \"You cannot afford this bet.\".red\n\t\t\t\t\t\tplayer.folded = true\n\t\t\t\t\telse # successful raise\n\t\t\t\t\t\tno_raises = false\n\t\t\t\t\t\tplayer.take_bet(raise_bet + curr_high_bet)\n\t\t\t\t\t\tputs \"#{player.name}'s bankroll is now: #{player.bankroll}.\"\n\t\t\t\t\t\tcurr_high_bet = raise_bet\n\t\t\t\t\t\t@pot += curr_high_bet\n\t\t\t\t\t\tplayer.raised = true\n\t\t\t\t\t\t# other players must now match raise\n\t\t\t\t\t\tplayer_seats.reject{|p| p == player}.each do |p|\n\t\t\t\t\t\t\tp.raised = false\n\t\t\t\t\t\t\tp.betted = false\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\tbreak if round_over?\n\t\tend\n\tend",
"def index\n @shelter = Shelter.first\n @pets = Pet.get_available_pets.order(:pet_type)\n if (!@cart)\n set_cart\n end\n @selectedPets = @cart.selected_pets\n end",
"def shelter_pets(options = {})\n defaults = {'id' => 1}\n options = defaults.merge(options)\n \n @petfinder.shelter_pets(options['id'], options)\n end",
"def pets_sold(petshop)\n return petshop[:admin][:pets_sold]\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 take_bets\n @players.each do |p|\n @events.handle(:pre_player_bet, p)\n\n p.hand.bet = p.place_bet\n\n @events.handle(:post_player_bet, p, p.hand.bet)\n end\n end",
"def sell_pet_to_customer(shop_hash, wanted_pet_hash, customer_hash)\n # does the shop have the right pet? (BY PET HASH NOT NAME - we have no pre-defined function for this...)\n if shop_hash[:pets].include?(wanted_pet_hash)\n # nested if - if pet available, does customer have sufficient money?\n if customer_can_afford_pet?(customer_hash, wanted_pet_hash)\n # add pet to customer's pets list:\n add_pet_to_customer(customer_hash, wanted_pet_hash)\n # increment pets_sold count\n increase_pets_sold(shop_hash, 1)\n # customer spends cash:\n remove_customer_cash(customer_hash, wanted_pet_hash[:price])\n # shops earns cash:\n add_or_remove_cash(shop_hash, wanted_pet_hash[:price])\n else\n # insufficient funds\n end\n else\n # pet not found\n end\nend",
"def resuspend_pellet(item)\n tube_label = sample_tube_label(item)\n resuspension_qty = @plan_params[:library_resuspension_qty]\n\n show do\n title \"Resuspend #{tube_label}\"\n\n note \"Take a clean #{SAMPLE_TUBE} and label it as \\\"#{tube_label}.\\\"\"\n note \"Remove the cap from the #{SAMPLE_TUBE} and place the tube in the ice bucket.\"\n\n note \"Take the #{MICROFUGE_TUBE} labeled #{tube_label} from the ice bucket.\"\n\n if resuspension_qty[:units] == MILLILITERS && resuspension_qty[:qty] > 1.0\n remainder = resuspension_qty.dup\n remainder[:qty] -= 1.0\n\n note \"Pipet 1.0 #{MILLILITERS} #{RESUSPENSION_BUFFER} into the tube.\"\n note \"Gently pipet the #{RESUSPENSION_BUFFER} up and down until \" \\\n \"the pellet is fully resuspended.\"\n note \"Pipet the resuspended yeast from the #{MICROFUGE_TUBE} to the #{SAMPLE_TUBE}.\"\n note \"Pipet an additional #{qty_display(remainder)} \" \\\n \"#{RESUSPENSION_BUFFER} into the #{SAMPLE_TUBE}.\"\n else\n note \"Pipet #{qty_display(resuspension_qty)} #{RESUSPENSION_BUFFER} into the tube.\"\n note \"Gently pipet the #{RESUSPENSION_BUFFER} up and down until \" \\\n \"the pellet is fully resuspended.\"\n note \"Pipet the resuspended yeast from the #{MICROFUGE_TUBE} to the #{SAMPLE_TUBE}.\"\n end\n\n end\n\n mark_as_resuspended(item)\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 create\n product_ids = params[:sell][:product_ids]\n user_id = params[:sell][:user_id]\n payment_options = params[:sell][:payment_options]\n \n @sell = Sell.new(:user_id => user_id, :payment_options => payment_options)\n \n #check if contains any product\n unless product_ids.nil?\n # verifica quais sao os produtos que estao contidos em product_ids\n uniq_products_ids = product_ids.uniq\n # verifica quantos sao os produtos contidos em product_ids\n uniq_products_ids.each do |product_id|\n product = Product.find(product_id)\n quantity = product_ids.count(product_id)\n # adiciona instancias de item_sold na venda, contendo os produtos e as quantidades\n item_sold = ItemSold.new(:product_id => product_id,\n :quantity => quantity,\n :value => product.sell_price)\n @sell.item_solds << item_sold\n @sell.products << product\n end\n end\n\n logger.info \"PRODUTOS ADQUIRIDOS:\"\n @sell.item_solds.each do |is|\n logger.info \"--------------------------\"\n logger.info \"name: #{is.product.name}\"\n logger.info \"value: #{is.value}\"\n logger.info \"quantity: #{is.quantity}\"\n logger.info \"--------------------------\"\n end\n\n respond_to do |format|\n if @sell.save\n format.html { redirect_to @sell, notice: 'Sell was successfully created.' }\n format.json { render json: @sell, status: :created, location: @sell }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sell.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sell_pets \n self.dogs.each do |dog|\n dog.owner = nil\n dog.mood = \"nervous\"\n self.dogs.delete(dog)\n end \n self.cats.each do |cat|\n cat.owner = nil\n cat.mood = \"nervous\"\n self.cats.delete(cat)\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 sell_pet_to_customer(pet_shop, pet, customer)\n\n return if pet == nil\n # As the pet is not found, a nil value is returned\n # Thus the previous function, breaks producing anouther nil.\n # By returning the above, it meets a criteria and allows the\n # function to run.\n\n buying = customer_can_afford_pet(customer, pet)\n\n if buying\n customer[:pets].push(pet)\n pet_shop[:admin][:total_cash] += pet[:price]\n customer[:cash] -= pet[:price]\n pet_shop[:admin][:pets_sold] += 1\n remove_pet_by_name(pet_shop, pet[:name])\n end\nend",
"def count_pet\n pets.count\n end",
"def sell_pet_to_customer(shop,the_pet,the_customer)\n if the_pet != nil\n add_pet_to_customer(the_customer,the_pet)\n shop[:admin][:pets_sold] +=1\n remove_customer_cash(the_customer,the_pet[:price])\n add_or_remove_cash(shop,the_pet[:price])\n # else\n # shop[:admin][:pets_sold] +=1\n end\nend",
"def sell_pet_to_customer(pet_shop_details, wanted_pet, customer)\n return if wanted_pet == nil || !can_customer_afford_pet?(customer, wanted_pet)\n add_pet_to_owner(customer, wanted_pet)\n remove_customer_cash(customer, wanted_pet[:price])\n add_or_remove_cash(pet_shop_details, wanted_pet[:price])\n remove_pet_by_name(pet_shop_details, wanted_pet[:name])\n pet_shop_details[:admin][:sold_pets].push(wanted_pet)\nend",
"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 buy!(buyer_planet, amount)\n raise GameLogicError.new(\"Cannot buy 0 or less! Wanted: #{amount}\") \\\n if amount <= 0\n amount = from_amount if amount > from_amount\n \n cost = (amount * to_rate).ceil\n buyer_source, bs_attr = self.class.resolve_kind(buyer_planet, to_kind)\n buyer_target, bt_attr = self.class.resolve_kind(buyer_planet, from_kind)\n if system?\n seller_target = nil\n else\n seller_target, _ = self.class.resolve_kind(planet, to_kind)\n end\n \n stats = CredStats.buy_offer(buyer_planet.player, cost) \\\n if seller_target.nil? && to_kind == KIND_CREDS\n \n buyer_has = buyer_source.send(bs_attr)\n raise GameLogicError.new(\"Not enough funds for #{buyer_source\n }! Wanted #{cost} #{bs_attr} but it only had #{buyer_has}.\"\n ) if buyer_has < cost\n \n # Used to determine whether to send notification or not.\n original_amount = from_amount\n \n # Subtract resource that buyer is paying with from him.\n buyer_source.send(:\"#{bs_attr}=\", buyer_has - cost)\n # Add resource that buyer has bought from seller.\n buyer_target.send(:\"#{bt_attr}=\", \n buyer_target.send(bt_attr) + amount)\n # Add resource that buyer is paying with to seller. Unless:\n # * its a system offer\n # * or #to_kind is creds and planet currently does not have an owner\n seller_target.send(\n :\"#{bs_attr}=\", seller_target.send(bs_attr) + cost\n ) unless seller_target.nil?\n # Reduce bought amount from offer.\n self.from_amount -= amount\n \n objects = [buyer_source, buyer_target]\n # We might not have seller target. See above.\n objects.push seller_target unless seller_target.nil?\n objects.uniq.each { |obj| self.class.save_obj_with_event(obj) }\n\n if from_amount == 0\n # Schedule creation of new system offer.\n CallbackManager.register(\n without_locking { galaxy },\n CALLBACK_MAPPINGS[from_kind],\n Cfg.market_bot_random_resource_cooldown_date\n ) if system?\n destroy!\n else\n save!\n end\n percentage_bought = amount.to_f / original_amount\n\n MarketRate.subtract_amount(galaxy_id, from_kind, to_kind, amount)\n\n # Create notification if:\n # * It's not a system notification\n # * Enough of the percentage was bought\n # * Sellers planet currently has a player.\n Notification.create_for_market_offer_bought(\n self, buyer_planet.player, amount, cost\n ) if ! system? &&\n percentage_bought >= CONFIG['market.buy.notification.threshold'] &&\n ! planet.player_id.nil?\n\n stats.save! unless stats.nil?\n\n amount\n end",
"def sell_pet_to_customer__pet_found(customer_cash, pets)\n result = pet_found(\"Arthur\")\n assert_equal([:names] ,pets)\nend",
"def sell_pet_to_customer(shop, pet, customer)\n customer[:cash] -= pet[:price]\n shop[:admin][:total_cash] += pet[:price]\n shop[:admin][:pets_sold] += 1\n customer[:pets] << shop[:pets][3]\nend",
"def sell!(amount, price)\n add_order!(:sell, amount, price)\n end",
"def total_pets\n pets.count\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 sell(amount:, price:)\n OpenOrderParser.parse(post(\"sell\", amount: amount, price: price))\n end",
"def addpets\n\t\t@petowner = Petowner.find( params[:id] )\n\t\t@all_pets_in_system = Pettype.all\n\t\t\n\tend",
"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 feedPet\n @pet.eat\n end",
"def process_won_bets\n return unless @bet.won?\n # calculate_amount is profit in case of win and in case of refund or loss it will be stake\n # TODO : Need Transaction here\n amount = calculate_amount\n amount = Wallets::Base.new(wallet).credit(amount + @bet.stake)\n wallet.ledgers.create(arguments_of_bets) unless amount.zero?\n end",
"def set_bets\n\n if player.chips == 0\n puts \"I'm sorry you run out of chips, maybe next time\"\n exit\n end\n\n puts \"#{player.name} you have a total of #{player.chips} chips\"\n puts \"how many would you like to bet\"\n answer = gets.chomp.to_i\n while answer < 0 || answer > player.chips\n set_bets\n end\n player.chips -= answer\n player.bet = answer\n\n end",
"def buy_cat(name) # expect(owner.pets[:cats].count).to eq(0)\n new_cat = Cat.new(name) # owner.buy_cat(\"Crookshanks\")\n self.pets[:cats] << new_cat # owner.pets[:cats].each { |cat| expect(cat).to be_a(Cat) }\n new_cat # expect(owner.pets[:cats].count).to eq(1)\n # = knows about its cats; Owner knows all about its pets - Owner sets name of pet, the pet can\\'t change its name\n # owner.buy_cat(\"Crookshanks\")\n # expect(owner.pets[:cats][0].name).to eq(\"Crookshanks\")\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_pet_to_customer(pet_shop, pet, customer)\n pet_shop[:admin][:pets_sold] += pet\n customer[:pets] += pet\n customer[:cash] -= pet[:price]\n pet_shop[:admin][:total_cash] += pet[:price]\n pet_shop[:pets].delete(pet)\nend",
"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 sell_pending\n end",
"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 get_bets(bet)\n\t\t#loop through ai players\n\t\t#random numbers generated in if statements create\n\t\t#the illusion of free will\n\t\tfor i in 1...@num_players\n\t\t\t#check if player has enough money and has not folded\n\t\t\tif bet <= @players[i].bank and !@players[i].folded then\n\t\t\t\t#if player has a high rank\n\t\t\t\tif @players[i].ranks[0] < 8 or rand(0..1) == 1 then\n\t\t\t\t\t@players[i].set_bet(bet)\n\t\t\t\t#if player has a pair of quite high value\n\t\t\t\telsif (@players[i].ranks[0] == 8 and @players[i].subranks[0] > 9) or rand(0..1) == 1 then\n\t\t\t\t\t@players[i].set_bet(bet)\n\t\t\t\t#bluff\n\t\t\t\telsif rand(0...10) == 1 then\n\t\t\t\t\t@players[i].set_bet(bet)\n\t\t\t\telse\n\t\t\t\t\t@players[i].fold\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t#puts \"fold #{i}\"\n\t\t\t\t@players[i].fold\n\t\t\tend \n\t\tend\n\tend",
"def sell_unambigous_cargo\n tx_log = []\n transaction_data = {side: 'sell'}\n current_hold.each do |cargo_name, cargo_amt|\n cargo_price = current_market[cargo_name]\n if cargo_amt > 0 and !Data.is_cargo_banned(cargo_name, @game.current_planet) and Cargos.can_sell(cargo_name, cargo_price)\n\n sell(cargo_name, cargo_amt, cargo_price, transaction_data)\n tx_log << \"[#{cargo_amt} #{cargo_name} at #{cargo_price} for income of #{cargo_price * cargo_amt} credits]\"\n end\n end\n if transaction_data.length > 1\n @game.take_action('trade', {transaction: transaction_data})\n Util.log(\"Selling unambigious cargo: #{tx_log.join(', ')}\")\n true\n else\n false\n end\n end",
"def add_pet_to_stock(pet_shop, new_pet)\n pet_shop[:pets].push(new_pet)\n return pet_shop[:pets].count()\nend",
"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 hunt_outcomes(food_earnings)\n\t\t\traise NotImplementedError\n\t\tend",
"def sell_all(ticker, days_ago)\n @broker.sell_all(self, ticker, days_ago)\n end",
"def buy_dog(name)\n#know sabout its dogs\n pets[:dogs] << Dog.new(name)\n end",
"def set_sell\n @sell = Sell.find(params[:id])\n end",
"def set_sell\n @sell = Sell.find(params[:id])\n end"
] |
[
"0.7185933",
"0.69073516",
"0.68372464",
"0.68290275",
"0.6668799",
"0.6603629",
"0.66026217",
"0.65897256",
"0.6563657",
"0.65608513",
"0.63159746",
"0.6314997",
"0.6294718",
"0.627704",
"0.6215362",
"0.6143786",
"0.6139594",
"0.6136496",
"0.6114417",
"0.609051",
"0.6084492",
"0.60707176",
"0.6060414",
"0.60142165",
"0.59561276",
"0.59402204",
"0.59367347",
"0.5934558",
"0.5913701",
"0.5904766",
"0.58934397",
"0.5876611",
"0.5873837",
"0.5867421",
"0.5852316",
"0.5838778",
"0.58253956",
"0.58252954",
"0.58163255",
"0.5816063",
"0.58078647",
"0.58075833",
"0.5795895",
"0.5790986",
"0.57722944",
"0.57714254",
"0.57187814",
"0.57139635",
"0.5695812",
"0.568844",
"0.5682044",
"0.56738544",
"0.5671625",
"0.5652233",
"0.56493896",
"0.5630172",
"0.55999166",
"0.5599108",
"0.5577528",
"0.55770236",
"0.5571374",
"0.5568685",
"0.55485",
"0.5537338",
"0.55323005",
"0.5530396",
"0.55157787",
"0.5504739",
"0.5502968",
"0.5483209",
"0.545492",
"0.5448086",
"0.5423853",
"0.5405521",
"0.54005474",
"0.53892326",
"0.5381568",
"0.537648",
"0.5374973",
"0.53615785",
"0.53552073",
"0.535381",
"0.53513694",
"0.53424424",
"0.53378385",
"0.5335406",
"0.53308195",
"0.53211",
"0.5319093",
"0.53115916",
"0.53044486",
"0.52894914",
"0.5283109",
"0.5282673",
"0.52780247",
"0.5273975",
"0.5273268",
"0.52729195",
"0.5269227",
"0.5269227"
] |
0.6153385
|
15
|
list_pets can list off its pets (FAILED 11)
|
def list_pets
dog_n = self.pets[:dogs].size
cat_n = self.pets[:cats].size
fish_n = self.pets[:fishes].size
"I have #{fish_n} fish, #{dog_n} dog(s), and #{cat_n} cat(s)."
#self.pets.each do |key,value|
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pets\n\t\t@pets_list\n\tend",
"def list_pets\n \"I have #{pets[:fishes].count} fish, #{pets[:dogs].count} dog(s), and #{pets[:cats].count} cat(s).\"\n end",
"def list_pets\n \"I have #{pets[:fishes].count} fish, #{pets[:dogs].count} dog(s), and #{pets[:cats].count} cat(s).\"\n end",
"def list_pets\n return \"I have #{@pets[:fishes].count} fish, #{@pets[:dogs].count} dog(s), and #{@pets[:cats].count} cat(s).\"\n end",
"def pets\n @pets\n end",
"def list_pets\n \"I have #{@pets[:fishes].count} fish, #{@pets[:dogs].count} dog(s), and #{@pets[:cats].count} cat(s).\"\n end",
"def list_adopted_pets()\n sql = \"SELECT * FROM pets INNER JOIN adoptions ON pets.id = adoptions.pet_id WHERE adoptions.owner_id = $1\"\n values = [@id]\n pets = SqlRunner.run(sql, values)\n return pets.map{|pet| Pet.new(pet)}\n end",
"def list_pets\n \"I have #{self.pets[:fishes].length} fish, #{self.pets[:dogs].length} dog(s), and #{self.pets[:cats].length} cat(s).\"\n end",
"def list_pets\n \"I have #{self.dogs.count} dog(s), and #{self.cats.count} cat(s).\"\n end",
"def list_pets\n \"I have #{self.dogs.count} dog(s), and #{self.cats.count} cat(s).\"\n end",
"def list_pets \n \"I have #{self.dogs.count} dog(s), and #{self.cats.count} cat(s).\"\n end",
"def list_pets\n # if @pets[:cats].size == 1\n # @catplural = \"\"\n # else\n # @catplural = \"'s\"\n # end\n # if @pets[:dogs].size == 1\n # @dogplural = \"\"\n # else\n # @dogplural = \"'s\"\n # end\n # \"I have #{pets[:fishes].size} fish, #{pets[:dogs].size} dog#{@dogplural}, and #{pets[:cats].size} cat#{@catplural}.\"\n \"I have #{pets[:fishes].size} fish, #{pets[:dogs].size} dog(s), and #{pets[:cats].size} cat(s).\"\n end",
"def shelter_pets(options = {})\n defaults = {'id' => 1}\n options = defaults.merge(options)\n \n @petfinder.shelter_pets(options['id'], options)\n end",
"def pets #stores all of the owners pets\n @pets #expect(owner.pets).to eq({:fishes => [], :dogs => [], :cats => []})\n end",
"def index\n @pets = current_user.pets.all\n end",
"def pets\n pet_owners.map do |pet_owner|\n pet_owner.pet\n end\n end",
"def addpets\n\t\t@petowner = Petowner.find( params[:id] )\n\t\t@all_pets_in_system = Pettype.all\n\t\t\n\tend",
"def index\n @pets = Pet.all\n end",
"def index\n @pets = Pet.all\n end",
"def get_pet_list_by_client_id(client_id)\n pet_list = []\n for pet in get_data(\"pets\")\n if client_id == pet[\"client_id\"]\n pet_list.push(pet)\n end\n end\n\n return pet_list\n end",
"def display_pets\n\t\tpets.join(\"\\n\")\n\tend",
"def show\n # load all that users pets\n @pets = @user.pets.page(params[:page]).per(3)\n end",
"def index\n @title = 'Mascotas'\n @pets = Pet.where(adpted: 'f').page(params[:page]).per(3)\n end",
"def index\n @shelter = Shelter.first\n @pets = Pet.get_available_pets.order(:pet_type)\n if (!@cart)\n set_cart\n end\n @selectedPets = @cart.selected_pets\n end",
"def list_pokemon\n puts \"\"\n puts \"See below for the list of the original Pokemon!\"\n puts \"\"\n @pokemon_objects.each.with_index(1) do |a, i|\n puts \"#{i}. #{a.name}\"\n end\n puts \"\"\n end",
"def index\n pets = pets_from_query\n\n respond_to do |format|\n format.html do\n @pets = pets.paginate(page: params[:page], per_page: 10)\n end\n format.json do\n @pets = pets\n end\n end\n end",
"def index\n @pet_items = PetItem.all\n end",
"def show\n @team = Team.find(params[:id])\n @team_pets = @team.pets\n if @team_pets.length > 0\n @pets = current_user.pets.where('id not in (?)', @team_pets)\n else\n @pets = current_user.pets\n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @team }\n end\n end",
"def list_pets\n @owner.dogs.count\n @owner.cats.count\n end",
"def list_pokemons\n\n end",
"def find_pet_by_name(pet_shop, pet_name)\n\n for pets in pet_shop[:pets]\n\n if pets[:name] == pet_name\n\n\n return pets\n\n end\n end\n\n return\n end",
"def index\n @adopted_pets = AdoptedPet.all\n end",
"def index\n @adopted_pets = AdoptedPet.all\n end",
"def index\n @postulation_pets = PostulationPet.all\n end",
"def index\n # byebug\n @user_resources = current_user.user_detail.pets\n @resources = @user_resources.page(params[:page]).per(10)\n super\n end",
"def index\n @question_pets = QuestionPet.all\n end",
"def find(options = {})\n begin\n defaults = {'animal_type' => 'dog', 'location' => '90210'}\n options = defaults.merge(options)\n @petfinder.find_pets(options['animal_type'], options['location'], options)\n rescue\n []\n end\n end",
"def index\n @pets = Pet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pets }\n end\n end",
"def find_pets_by_tags_with_http_info(tags, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PetApi.find_pets_by_tags ...'\n end\n # verify the required parameter 'tags' is set\n if @api_client.config.client_side_validation && tags.nil?\n fail ArgumentError, \"Missing the required parameter 'tags' when calling PetApi.find_pets_by_tags\"\n end\n # resource path\n local_var_path = '/pet/findByTags'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'tags'] = @api_client.build_collection_param(tags, :csv)\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(['application/xml', 'application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'Array<Pet>'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['petstore_auth']\n\n new_options = opts.merge(\n :operation => :\"PetApi.find_pets_by_tags\",\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: PetApi#find_pets_by_tags\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def total_pets\n pets.count\n end",
"def index\n @typeofpets = Typeofpet.all\n end",
"def pet_types\r\n BnetApi::make_request('/wow/data/pet/types')\r\n end",
"def love_pet\n puts \"#{@name} loves their pet #{pet.name} so much.\"\n end",
"def list_pokemon_stats\n puts(\"Name: {#name}\")\n puts(\"HP: {#hp}\")\n end",
"def index\n @pets = Pet.all\n # render 'index' => where render is a method call and 'index' is an argument\n # rails will implicitly try to render a view template with the same name as the action\n end",
"def index\n response = HTTParty.get('http://okta-api:8080/pets/v1/cats', {headers: {\"X-Token\"=> session[:oktastate][:credentials][:token]}})\n if response.code == 200\n @cats = JSON.parse(response.body)\n else\n @cats = []\n end\n end",
"def count_pet\n pets.count\n end",
"def sell_pets\n all_pets = []\n all_pets << self.cats \n all_pets << self.dogs \n all_pets.flatten.map do |each_pet|\n each_pet.mood = \"nervous\"\n each_pet.owner = nil\n end\n end",
"def find_pet_by_name(pets, pet_name)\n for pet in pets[:pets]\n if pet[:name] == pet_name\n return pet\n end\n end\n return nil\nend",
"def get_pets\n if @pet_arr == []\n pet_info = \"No pets in system.\"\n else\n pet_info = @pet_arr.inject(\"\") do |pet_info_str, animal|\n pet_info_str << \"#{animal.name_str.capitalize} (#{animal.species_str}) \"\n end\n end\n return pet_info\n end",
"def find_pets_by_tags(tags, opts = {})\n data, _status_code, _headers = find_pets_by_tags_with_http_info(tags, opts)\n data\n end",
"def index\n @peticions = Peticion.all\n end",
"def pet_count\n pets.count\n end",
"def add_pet(pet)\n\t\t@pets_list << pet\n\tend",
"def index\n @client = Client.find params[:client_id]\n @pets = @client.pets\n end",
"def find_pet_by_name(pet_shop, name)\n pets = pets\n for pet in pet_shop[:pets]\n if pet[:name] == name\n pets = pet\n nil\n end\n end\n return pets\nend",
"def index\n @pets = []\n if current_user.role.name != 'cliente'\n @pets = Pet.all\n else\n if !current_user.nil?\n id = current_user.data_id\n if !id.nil?\n @client = Client.find(id)\n @pets = @client.pets\n end\n end\n end\n end",
"def sell_pets\n Cat.all.collect do |cats|\n cats.mood=\"nervous\"\n cats.owner=nil\n end\n Dog.all.collect do |dogs|\n dogs.mood=\"nervous\"\n dogs.owner=nil\n end\n end",
"def sell_pets\n pets.each {|kind, moods|\n moods.each {|pets| pets.mood=(\"nervous\")}\n moods.clear\n }\n end",
"def index\n @pet_trues = PetTrue.all\n end",
"def sell_pets\n all_owner_pets = self.dogs + self.cats\n \n all_owner_pets.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end \n\n end",
"def mobile_pets_list\n @person= Person.includes(:caretakers, :pets).find(params[:person_id])\n #@pets = @person.pets.includes(:caretakers)\n \n # renders views/pets/mobile_pets_list.html.erb\n render :layout => false\n end",
"def index\n @pets = Pet.all\n # @users= Pet.user.all\n render json: @pets, each_serializer: PetSerializer\n \n end",
"def booking_pets_allowed_get(opts = {})\n data, _status_code, _headers = booking_pets_allowed_get_with_http_info(opts)\n data\n end",
"def index\n @petprofiles = Petprofile.all\n end",
"def sell_pets\n pets = dogs + cats\n\n pets.each do |pet|\n pet.mood = \"nervous\"\n pet.owner = nil\n end\n end",
"def find_pets_by_status(status, opts = {})\n data, _status_code, _headers = find_pets_by_status_with_http_info(status, opts)\n data\n end",
"def list_of_planets\n list = []\n @planets.length.times do |index|\n list << \"#{index+1}. #{@planets[index].name}\"\n end\n return list\n end",
"def show\n @pet = Pet.find(params[:id])\n end",
"def list\n puts \"Here is a list of all the Voters!\"\n puts \"\"\n @voters.each do |voter|\n puts \"Voter: #{voter[:name]}, #{voter[:affiliation]}\"\n end\n puts \"Here is the list of all the Politicians!\"\n puts \"\"\n @politicians.each do |politician|\n puts \"Politician: #{politician[:name]}, #{politician[:affiliation]}\"\n end\n end",
"def pets_by_breed(pet_shop, breed)\n pets_of_type_breed = []\n for pet in pet_shop[:pets]\n pets_of_type_breed << pet[:name] if pet[:breed] == breed\n end\n return pets_of_type_breed\nend",
"def list_animals \n puts \"Here are the current animals in shelter: \"\n @animals_in_shelter.each do |animal|\n puts animal.get_animal_info\n end\n end",
"def list_command\n age = get_param(\"age\\=\", \"(\\d+)\")\n type = get_param(\"type\\=\", \"([a-zA-Z]+)\")\n\n @app.list_animals(age, type)\n end",
"def sell_pets\n pets.each do |species, pet_array| #enumerate through pets hash...\n pet_array.each do |pet_object| #then enumerate through pet_array within pets hash...\n #binding.pry\n pet_object.mood = \"nervous\" #set each pet_object's mood to \"nervous\"\n end\n end #end loop\n self.pets.clear #and reset Owner instance .pets to an empty array, that is returned\n end",
"def find_pet_by_name(petshop, name)\n for pet in petshop[:pets]\n if pet[:name] == name\n return pet\n end\n end\n return nil\nend",
"def find_pet_by_name(pet_shop, pet_name)\n for pet in pet_shop[:pets]\n return pet if pet[:name] == pet_name\n end\n return nil\nend",
"def pet_params\n params.require(:pet).\n permit(:type, :name, :description, :gender, :colors, :needs_transit_home, :published, :vaccinated, :location,\n :metadata, :age, :children_friendly, :pet_friendly, :publication_type, videos: [])\n end",
"def index\n @line_pets = LinePet.all\n end",
"def set_pet\n @pet = current_user.pets.find(params[:id])\n end",
"def good_pokemon # :not_very_effective AND :no_effect_on\n good_pokemon = []\n @type.not_very_effective.each {|pokemon| good_pokemon << pokemon}\n @type.no_effect_on.each {|pokemon| good_pokemon << pokemon if !good_pokemon.include?(pokemon)}\n \n if good_pokemon.count > 0\n puts \"\"\n puts \"USE POKEMON OF THESE TYPE(S)\"\n good_pokemon.each_with_index {|pokemon, index| puts \"#{index +1}. #{pokemon.name}\"}\n end\n end",
"def customers_affordable_pets(pet_shop_details,customer)\n affordable_pets = []\n for pet in pet_shop_details[:pets]\n if can_customer_afford_pet?(customer,pet)\n affordable_pets.push(pet)\n end\n end\n return affordable_pets\nend",
"def find_pet_by_name(pet_shop, name)\n\n for animal in pet_shop[:pets]\n if animal[:name] == name\n p animal[:name]\n end\n end\n\nend",
"def summons\n return (@pets + @monsters)\n end",
"def find_pet_by_name(pet_shop, name)\n for pet in pet_shop[:pets]\n if pet[:name] == name\n return pet\n end\n end\n return nil\nend",
"def find_pet_by_name(pet_shop, name)\n for pet in pet_shop[:pets]\n if pet[:name] == pet\n return pet\n else return nil\n end\nend\nend",
"def show\n @memories = @pet.memories.paginate(:page => params[:page], :per_page => 5)\n end",
"def patients_name\n self.pets.map {|p| p.name}\n end",
"def show\n # render plain: params\n @owner = User.find_by_id(params[:id])\n # render plain: @owner.first_name\n @owner_pet =@owner.pets\n # if @owner_pet.exists?\n # render plain: @owner_pet[0].name\n # else\n # render plain: \"This user has no pets :(\"\n # end\n end",
"def show\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pet }\n end\n end",
"def show\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pet }\n end\n end",
"def pets_by_breed(pet_shop, breed)\n all_breed = []\n for l_breed in pet_shop[:pets]\n if l_breed[:breed] == breed\n all_breed.push(l_breed[:name])\n end\n end\n return all_breed\nend",
"def find_pet_by_name(pet_shop, pet_name)\n for pet in pet_shop[:pets]\n if pet[:name] == pet_name\n return pet\n end\n end\n return nil\nend",
"def find_pet_by_name(pet_shop, pet_name)\n for pet in pet_shop[:pets]\n if pet[:name] == pet_name\n return pet\n end\n end\n return nil\nend",
"def show\n @pet = Pet.find_by id: params[:id]\n end",
"def pets_by_breed(petshop,breed)\n pets=[]\n petshop[:pets].each do\n |pet| \n if pet[:breed] == breed\n pets.push(breed) \n end\n end\n return pets\n end",
"def show\n @species = Specie.find(params[:id])\n\n @pets = Pet.where(:specie_id => @species).all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: {:secie => @species, :pets => @pets } }\n end\n end",
"def pets_by_breed(petshop,breed)\n pets=[]\n for pet in petshop[:pets] do\n if pet[:breed] == breed\n pets.push(breed) \n end\n end\n return pets\n end",
"def sell_pets\n pets.each do |type, all_type|\n all_type.each do |pet|\n pet.mood = \"nervous\"\n end\n end\n pets.clear\n end",
"def list_planets\n list = \"Planets orbiting #{@star_name}:\\n\"\n @planets.each do |planet|\n list += \"* #{planet.name}\\n\"\n end\n list += \"\\n\"\n return list\n end",
"def test_should_show_list_of_children\n login_as :admin\n \n # Valid name with children.\n # TODO: Very weird, pass a name in a parameter called id.\n get :list, :id => tags(:weapons).name \n assert_response :success\n assert_template 'list'\n assert_equal assigns(:title), \"Manage Tags\"\n assert_not_nil assigns(:tags)\n end"
] |
[
"0.7706681",
"0.71577007",
"0.71577007",
"0.71334076",
"0.70857656",
"0.705761",
"0.70176697",
"0.700302",
"0.6876377",
"0.6876377",
"0.67844975",
"0.66361696",
"0.6573887",
"0.63973236",
"0.6341928",
"0.6326054",
"0.62993085",
"0.6298144",
"0.6298144",
"0.6224643",
"0.6210155",
"0.6171809",
"0.6086867",
"0.60709643",
"0.60668665",
"0.60654074",
"0.6010487",
"0.5982837",
"0.59805477",
"0.5962462",
"0.59471744",
"0.5945581",
"0.5945581",
"0.594204",
"0.5921462",
"0.59164137",
"0.58998483",
"0.58770597",
"0.58658177",
"0.5840979",
"0.5836128",
"0.58337533",
"0.580341",
"0.5802423",
"0.57965684",
"0.57869637",
"0.5778877",
"0.5774976",
"0.57726353",
"0.5746481",
"0.57427734",
"0.57426983",
"0.5725997",
"0.57219255",
"0.57157755",
"0.5694858",
"0.56903327",
"0.56863433",
"0.5685289",
"0.56651443",
"0.5600933",
"0.55868626",
"0.55728054",
"0.5558992",
"0.5555909",
"0.5551541",
"0.5547768",
"0.55147356",
"0.5498243",
"0.5497556",
"0.54861385",
"0.54781353",
"0.5470187",
"0.5467253",
"0.5462042",
"0.5455062",
"0.5435452",
"0.54318607",
"0.5430793",
"0.54294854",
"0.5404112",
"0.53944904",
"0.5394261",
"0.53889894",
"0.538344",
"0.5381983",
"0.5376946",
"0.53765935",
"0.5370067",
"0.5370067",
"0.5361475",
"0.5358945",
"0.5358945",
"0.5358644",
"0.5353475",
"0.5352331",
"0.5345366",
"0.5328725",
"0.5322426",
"0.5321987"
] |
0.6464818
|
13
|
overwrite the method of user module from mainrepo
|
def user_page name
@t[:title] = _var(:title, :www) if @t[:title] == nil
_tpl name, _var(:layout, :www).to_sym, :www
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def repo; end",
"def repo; end",
"def repo; end",
"def repo; end",
"def user_provider=(_arg0); end",
"def user; end",
"def user; end",
"def set_user; end",
"def user\n raise NotImplementedError\n end",
"def repo=(_arg0); end",
"def repo=(_arg0); end",
"def repo=(_arg0); end",
"def repo=(_arg0); end",
"def extend_user(module_name, init_method = nil)\n @user_extensions << module_name\n @user_init_methods << init_method unless init_method.nil?\n end",
"def repository; end",
"def make_user\n end",
"def user_init; end",
"def off_org_users\n \n end",
"def so_user; @_so_user ||= path_to_class('test/platform/sz/so_user'); end",
"def user_repo\n @user_repo ||= platform_klass::UserRepository.new(@platform.username)\n end",
"def user \n @user ||= @repo.config.username\n end",
"def user_provider; end",
"def username; end",
"def username; end",
"def username; end",
"def username; end",
"def update_user\n end",
"def user\n end",
"def username=(_arg0); end",
"def username=(_arg0); end",
"def username=(_arg0); end",
"def proxy_user; end",
"def current_user_method=(null) ; end",
"def user\n @user ||= @repo.config.username\n end",
"def hook_owner; end",
"def get_user\r\n \tself.user = update_user\r\n end",
"def get_users_module(config)\n return UsersPam.new(config)\nend",
"def instruct_user!\n end",
"def extended_modules; end",
"def upgrade_to_main_user\n self.is_main_user = true \n self.save \n \n admin_role = Role.find_by_name(USER_ROLE[:admin]) \n self.add_role_if_not_exists(admin_role ) \n end",
"def setup\n @user = users(:brock)\n end",
"def require_user\n end",
"def modified_by(user)\n #none by default\n end",
"def modified_by(user)\n #none by default\n end",
"def setup\n \n @user = users(:david)\n \n end",
"def username\n end",
"def user_for_vestal_versions; end",
"def supercommand!() __supercommand__ end",
"def initialize\n super(\"ssh-userauth\")\n end",
"def setup\n load_users\n end",
"def source_repo\n \"#{@user}/#{@repo}\"\n end",
"def update_user_if_save_version\n self.user = User.current if save_version?\n end",
"def load_repo_config; end",
"def autorun; end",
"def user(*args)\n super(*args) || build_user\n end",
"def overriding_user_value\n clone(:override=>:user)\n end",
"def user\n raise NotImplementedError.new(\"user() must be implemented by subclasses of AbstractChangeset.\")\n end",
"def after_install\r\n users = ::GDO::User::GDO_User\r\n users.system\r\n end",
"def admin_all_repo\n owner_name = Gitlab.config.gitolite.admin_key\n\n # @ALL repos premission for gitolite owner\n repo_name = \"@all\"\n repo = if conf.has_repo?(repo_name)\n conf.get_repo(repo_name)\n else\n ::Gitolite::Config::Repo.new(repo_name)\n end\n\n repo.add_permission(\"RW+\", \"\", owner_name)\n conf.add_repo(repo, true)\n end",
"def set_logged_in_user_in_audit_module\r\n\t AuditModule.set_current_user=(current_user)\r\n end",
"def add_user_search\n insert_into_file(\n \"#{Rails.root}/app/models/user.rb\", :after => \"---- Plugins\\n\"\n ) do\n \" include PgSearch\\n\" +\n \" multisearchable :against => [:name, :email]\\n\"\n end\n end",
"def method_missing(sym, *args, &block)\n if @repo.respond_to?(sym)\n @repo.send(sym, *args, &block)\n else\n super\n end\n end",
"def repo_root; end",
"def setup \n @user = current_user\n end",
"def saveHandin()\n if @modulesUsed.include?(\"Svn\") then\n return svnSaveHandin()\n else\n return super()\n end\n end",
"def repo_dir; end",
"def add_abstractor_user_method\n current_user_helper = options[\"current-user-helper\"].presence ||\n ask(\"What is the current_user helper called in your app? [current_user]\").presence ||\n 'current_user if defined?(current_user)'\n puts \"Defining abstractor_user method inside ApplicationController...\"\n\n abstractor_user_method = %Q{\n def abstractor_user\n #{current_user_helper}\n end\n helper_method :abstractor_user\n}\n inject_into_file(\"#{Rails.root}/app/controllers/application_controller.rb\",\n abstractor_user_method,\n :after => \"ActionController::Base\\n\")\n end",
"def set_users\n\n end",
"def define_user\n case new_resource.im_install_mode\n when 'admin'\n user = if new_resource.user.nil?\n 'root'\n else\n unless im_user_exists_unix?(new_resource.user)\n Chef::Log.fatal \"User Name provided #{new_resource.user}, does not exist\"\n raise \"User Verification 1: User Name provided #{new_resource.user}, does not exist\"\n end\n new_resource.user\n end\n user\n when 'nonAdmin', 'group'\n user = if new_resource.user.nil?\n Chef::Log.fatal \"User Name not provided! Please provide the user that should be used to install your product\"\n raise \"User Name not provided! Please provide the user that should be used to install your product\"\n else\n unless im_user_exists_unix?(new_resource.user)\n Chef::Log.fatal \"User Name provided #{new_resource.user}, does not exist\"\n raise \"User Verification 1: User Name provided #{new_resource.user}, does not exist\"\n end\n new_resource.user\n end\n user\n end\nend",
"def define_user\n case new_resource.im_install_mode\n when 'admin'\n user = if new_resource.user.nil?\n 'root'\n else\n unless im_user_exists_unix?(new_resource.user)\n Chef::Log.fatal \"User Name provided #{new_resource.user}, does not exist\"\n raise \"User Verification 1: User Name provided #{new_resource.user}, does not exist\"\n end\n new_resource.user\n end\n user\n when 'nonAdmin', 'group'\n user = if new_resource.user.nil?\n Chef::Log.fatal \"User Name not provided! Please provide the user that should be used to install your product\"\n raise \"User Name not provided! Please provide the user that should be used to install your product\"\n else\n unless im_user_exists_unix?(new_resource.user)\n Chef::Log.fatal \"User Name provided #{new_resource.user}, does not exist\"\n raise \"User Verification 1: User Name provided #{new_resource.user}, does not exist\"\n end\n new_resource.user\n end\n user\n end\nend",
"def current_user\n # super: don't change anything, i just want the exact same behavior \n # as in the method that we are overriding\n\n # what this line means is that if the user is logged in, super is true,\n # then call super treat everything normal, and ignore right hand side\n # if super == false, call right hand side\n\n # super comes from devise class\n # meanwhile the r.h.s comes from open struct class\n super || guest_user\n end",
"def user_handle; end",
"def current_user\n super || guest_user\n # super = dont change anything, I want the same feature of the method we are overriding\n end",
"def devise_modules_hook!; end",
"def call \n user\n end",
"def user\n options.user || repo.user\n end",
"def developer\n end",
"def setup\n default_repository.update_submodules(:recursive => true)\n true\n end",
"def modules; end",
"def modules; end",
"def modules; end",
"def inject_user_behavior\n file_path = \"app/models/#{model_name.underscore}.rb\"\n if File.exist?(file_path)\n inject_into_file file_path, after: /include Hydra\\:\\:User.*$/ do\n \"\\n # Connects this user object to Hyrax behaviors.\" \\\n \"\\n include Hyrax::User\" \\\n \"\\n include Hyrax::UserUsageStats\\n\"\n end\n else\n puts \" \\e[31mFailure\\e[0m Hyrax requires a user object. This \" \\\n \"generator assumes that the model is defined in the file \" \\\n \"#{file_path}, which does not exist. If you used a different \" \\\n \"name, please re-run the generator and provide that name as an \" \\\n \"argument. Such as \\b rails -g hyrax:models client\"\n end\n end",
"def edit_aux(module_type,module_id,module_name,version,opts={})\n module_location = OsUtil.module_location(module_type,module_name,version,opts)\n\n pull_if_needed = opts[:pull_if_needed]\n # check if there is repository cloned\n unless File.directory?(module_location)\n if opts[:automatically_clone] or Console.confirmation_prompt(\"Edit not possible, module '#{module_name}#{version && \"-#{version}\"}' has not been cloned. Would you like to clone module now\"+'?')\n internal_trigger = true\n omit_output = true\n response = clone_aux(module_type,module_id,version,internal_trigger,omit_output,opts)\n # if error return\n return response unless response.ok?\n pull_if_needed = false\n else\n # user choose not to clone needed module\n return\n end\n end\n # here we should have desired module cloned\n\n if pull_if_needed\n response = pull_clone_changes?(module_type,module_id,version,opts)\n return response unless response.ok?\n end\n grit_adapter = Helper(:git_repo).create(module_location)\n if edit_info = opts[:edit_file]\n #TODO: cleanup so dont need :base_file_name\n file_to_edit =\n if edit_info.kind_of?(String)\n edit_info\n else #edit_info.kind_of?(Hash) and has key :base_file_name\n base_file = edit_info[:base_file_name]\n (File.exists?(\"#{module_location}/#{base_file}.yaml\") ? \"#{base_file}.yaml\" : \"#{base_file}.json\")\n end\n OsUtil.edit(\"#{module_location}/#{file_to_edit}\")\n OsUtil.print(\"If you want to use different editor please set environment variable EDITOR and log back into dtk-shell!\", :yellow) unless ENV['EDITOR']\n else\n Console.unix_shell(module_location, module_id, module_type, version)\n end\n\n unless grit_adapter.repo_exists?\n puts \"Local module has been removed, skipping changes.\"\n return Response::Ok.new()\n end\n\n unless grit_adapter.changed?\n puts \"No changes to repository\"\n return Response::Ok.new()\n end\n\n unless file_to_edit\n grit_adapter.print_status\n end\n\n # check to see if auto commit flag\n auto_commit = ::DTK::Configuration.get(:auto_commit_changes)\n confirmed_ok = false\n\n # if there is no auto commit ask for confirmation\n unless auto_commit\n confirm_msg =\n if file_to_edit\n \"Would you like to commit changes to the file?\"\n else\n \"Would you like to commit ALL the changes?\"\n end\n confirmed_ok = Console.confirmation_prompt_simple(confirm_msg)\n end\n if (auto_commit || confirmed_ok)\n if auto_commit\n puts \"[NOTICE] You are using auto-commit option, all changes you have made will be commited.\"\n end\n commit_msg = user_input(\"Commit message\")\n\n # remove qoutes if they are not closed properly in commit_msg\n commit_msg.gsub!(/\\\"/,'') unless commit_msg.count('\"') % 2 ==0\n\n internal_trigger=true\n reparse_aux(module_location)\n\n # use_impl_id - if edit-component-module which has version use impl_id from assembly--<assembly_name> version of component instance\n opts.merge!(:force_parse => true, :update_from_includes => true, :print_dependencies => true, :use_impl_id => true)\n response = push_clone_changes_aux(module_type,module_id,version,commit_msg,internal_trigger,opts)\n\n # if error return\n return response unless response.ok?\n end\n\n #TODO: temporary took out; wil put back in\n #puts \"DTK SHELL TIP: Adding the client configuration parameter <config param name>=true will have the client automatically commit each time you exit edit mode\" unless auto_commit\n Response::Ok.new()\n end",
"def getUser ()\n return self.directory.user \n end",
"def user_name\n \"someone\"\n end",
"def loadHandinPage\n\n updateModules()\n if @modulesUsed.include?(\"Svn\") then\n svnLoadHandinPage()\n else\n super()\n end\n end",
"def current_user\n raise NotImplementedError\n end",
"def current_user\n raise NotImplementedError\n end",
"def replace_update_me\n end",
"def method_missing( name, *args )\n if !!(ret = my_data[ :\"user_#{ name }\" ])\n ret\n else\n super\n end\n end",
"def setup\n TestUtils.set_workday_default\n TestUtils.enable_module_on_project 1\n @request.session[:user_id] = 1\n end",
"def before_import ; end",
"def find_repos(user)\n user.repos\n end",
"def maintainer\n owner.username\n end",
"def module_move_up(mod) end",
"def override_execute(mod, hbsession, opts); end",
"def post_install; end",
"def customize_new_user(user)\n # user.level = User::Levels::MEMBER\n # user.can_approve_posts = false\n # user.can_upload_free = false\n # user.is_super_voter = false\n #\n # user.base_upload_limit = 10\n # user.comment_threshold = -1\n # user.blacklisted_tags = [\"spoilers\", \"guro\", \"scat\", \"furry -rating:s\"].join(\"\\n\")\n # user.default_image_size = \"large\"\n # user.per_page = 20\n # user.disable_tagged_filenames = false\n true\n end",
"def before_merge_rpx_data( from_user, to_user )\n\t\t\t\n\t\t\tend",
"def method_missing(method, *args)\n args.unshift(method.to_s)\n set_user_config args\n end",
"def drupal_user\n DrupalUsers.find_by_name(self.username)\n end"
] |
[
"0.6504564",
"0.6504564",
"0.6504564",
"0.6504564",
"0.6428444",
"0.64247566",
"0.64247566",
"0.62942475",
"0.62362826",
"0.6207774",
"0.6207774",
"0.6207774",
"0.6207774",
"0.6187236",
"0.6169578",
"0.6161174",
"0.6098005",
"0.6097198",
"0.6049912",
"0.604174",
"0.60381645",
"0.6035963",
"0.5972575",
"0.5972575",
"0.5972575",
"0.5972575",
"0.5923425",
"0.58991367",
"0.5837021",
"0.5837021",
"0.5837021",
"0.5825145",
"0.5813651",
"0.58088",
"0.57811946",
"0.57686865",
"0.5738406",
"0.57143694",
"0.56934947",
"0.5669446",
"0.56611365",
"0.56607294",
"0.56517446",
"0.56517446",
"0.5634528",
"0.5628573",
"0.56281984",
"0.56267416",
"0.56048155",
"0.5599281",
"0.55916744",
"0.55656284",
"0.55654943",
"0.5558417",
"0.55508983",
"0.5544077",
"0.55423814",
"0.55420434",
"0.5524894",
"0.5523379",
"0.5519963",
"0.55179304",
"0.551677",
"0.55060464",
"0.54965657",
"0.5496231",
"0.5487655",
"0.54861957",
"0.54854995",
"0.54854995",
"0.54833406",
"0.54824305",
"0.54705423",
"0.5467562",
"0.54597956",
"0.5453354",
"0.545325",
"0.5451605",
"0.5437513",
"0.5437513",
"0.5437513",
"0.54056054",
"0.5382051",
"0.5381176",
"0.5369786",
"0.5361964",
"0.5360636",
"0.5360636",
"0.5350471",
"0.5331992",
"0.5328967",
"0.53253865",
"0.5321935",
"0.5313948",
"0.53077316",
"0.5304888",
"0.5303709",
"0.53035086",
"0.5299814",
"0.52989024",
"0.52954364"
] |
0.0
|
-1
|
Returns the comments on the given startup.
|
def startup_comments(id)
get("1/startups/#{id}/comments")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def comments; end",
"def comments; end",
"def comments; end",
"def comments; end",
"def comments; end",
"def comments; end",
"def comments\n @docstring.all\n end",
"def comments\n\t\t\t@comments ||= read_comments\n\t\tend",
"def description\n comment_sections.first\n end",
"def comments\n out = []\n\n out << ''\n out << '#'\n out << \"# Deezy version #{app_version}\"\n out << '#'\n out << ''\n\n @conf['dhcpd']['subnets'].each do |s|\n out << '# %s/%s via %s' % [s['subnet'], s['netmask'], s['routers']]\n s['pools'].each do |p|\n exceptions = []\n p['exceptions'].each do |e|\n exceptions << \", [except: %s-%s (%s)]\" % [e['first'], e['last'], e['notes']]\n end if p['exceptions']\n out << [\n \"# #{p['first']}-#{p['last']}\",\n \"#{\" (#{p['notes']})\" if p['notes']}\",\n exceptions.join\n ].join\n end\n out << '#'\n end\n out << ''\n end",
"def get_comments\n return unless @list\n comments = \"\"\n cnt = 0\n listn = @list.size\n while cnt < listn\n if @list[cnt].code == 108\n comments += @list[cnt].parameters[0] + 10.chr\n while cnt < listn && @list[cnt + 1].code == 408\n cnt += 1\n comments += @list[cnt].parameters[0] + 10.chr\n end\n end\n cnt += 1\n end\n \n return comments\n end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def comments=(_arg0); end",
"def comments\n pull_comments\n @comments_list\n end",
"def comment_sections\n @comment_sections ||= raw ? raw.split(\"\\n\\n\") : []\n end",
"def list_comments\n hc = if has_comments_valided?\n comments(valided: true).collect do |dcom|\n next unless dcom[:ok]\n (\n (dcom[:ps] + ', le ' + dcom[:at].as_human_date).in_div(class: 'c_info') +\n traite_comments(dcom[:c]).in_div(class: 'c_content') + \"\".in_div(class: 'clear')\n ).in_div(class: 'comment')\n end.join('')\n else\n \"Aucun commentaire sur cet article pour le moment.\".in_div(class: 'italic small')\n end\n hc.prepend('<a name=\"lire_comments\"></a>')\n return hc\n end",
"def description\n comment_sections.reject do |section|\n section.modifiers.any? or section.section\n end.map(&:comment).join(\"\\n\\n\")\n end",
"def comments\n @properties[\"C\"]\n end",
"def _get_comments_from_gh()\n comments = []\n page = 1\n done = false\n until done\n puts \"Comment Page #{page}\"\n newcomments = self.client.issues_comments( REPO, { :page => page} )\n comments += newcomments\n done = newcomments == []\n page = page + 1\n end\n return comments\n end",
"def comments\n @comments\n end",
"def comments\n results = []\n return results unless @comments\n\n comment = ''\n @comments.split(\"\\n\").each do |line|\n if line =~ /^\\S/\n results << comment unless comment.empty?\n comment = line\n else\n comment += \"\\n\" + line\n end\n end\n\n results << comment unless comment.empty?\n return results\n end",
"def _zlist\n @config.ffi_delegate.comments\n end",
"def comments\n worksheets.map(&:comments).compact\n end",
"def processing_comments(opts = {})\n find_collection(\"processingComments\", opts)\n end",
"def consume_comments; end",
"def comments_from path\n path = File.expand_path(\"../lib/friendly_id/#{path}\", __FILE__)\n match = File.read(path).match(/\\n=begin(.*)\\n=end/m)[1].to_s\n match.split(\"\\n\").reject {|x| x =~ /^@/}.join(\"\\n\").strip\nend",
"def comments\n @comments\n end",
"def show_comments(post_num_input)\n puts ''\n puts '----COMMENTS----'\n BLOG[post_num_input].comments.each do |x|\n puts x.username\n puts x.comment\n puts ''\n end\n puts ''\n end",
"def pull_comments\n @scrape.extract_comments.each do |comment_text|\n comment = Comment.new(comment_text)\n add_comment(comment)\n end\n end",
"def scan\n return nil unless @data\n \n comments = []\n \n @data.scan(/(\\d+)\\s+(\\d+)[^']+'[^']+'\\(([^\\)]+)/m).each do |m|\n comments << {\n :reaktoruser_id => m[0],\n :timestamp => m[1],\n :text => m[2],\n # TODO:title ?\n }\n Log.write_log(@@log_name, \"#<comment (reaktor_id:#{m[0]}, timestamp:#{m[1]}, text:#{m[2]})>\")\n end\n return comments\n end",
"def comments\n @data['comments']\n end",
"def comments\n @data['comments']\n end",
"def comments\n @data['comments']\n end",
"def getComments(list)\r\n comments = \"\"\r\n dbg(\"Kommentarer:\")\r\n list.each { |s| \r\n dbg(\"Kommentar:\")\r\n dbg(s)\r\n dbg(s[\"comment\"])\r\n \tcomments = comments + \"<p>\" + s[\"author_name\"] + \":\" + s[\"comment\"] + \"</p>\"\r\n \tdbg(s[\"comment\"])\r\n }\r\n return comments\r\nend",
"def getComments(list)\r\n comments = \"\"\r\n dbg(\"Kommentarer:\")\r\n list.each { |s| \r\n dbg(\"Kommentar:\")\r\n dbg(s)\r\n dbg(s[\"comment\"])\r\n \tcomments = comments + \"<p>\" + s[\"author_name\"] + \":\" + s[\"comment\"] + \"</p>\"\r\n \tdbg(s[\"comment\"])\r\n }\r\n return comments\r\nend",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n @list.client.get(\"#{url}/comments\")\n end",
"def comments\n super || wells.try(:collect, &:summary).try(:join, ':')\n end",
"def getComments\r\n\t\t\t\t\treturn @comments\r\n\t\t\t\tend",
"def comments\n get_ticket_property_list(\"comments\" , Unfuddled::Comment)\n end",
"def describing_comments_inflated_view(min_date = nil)\n comments = describing_comments_text(min_date)\n\t\t\tcomments.uniq.sort.collect{|comment| \"<span style=\\\"font-size: #{expansion_function(100,comments.count(comment),2)}%\\\">#{comment}</span>\"}.join(@@comment_string_joiner)\n\t\tend",
"def comments_text\n return self.comments.inject(\"\") do |string, comment| \n string + \n (string.empty? ? \"\" : \"\\n\") +\n comment.email +\n \": \" +\n comment.message\n end\n end",
"def comments\n if @comment_feed.comments.nil?\n @comment_feed.fetch\n end\n\n @comment_feed.comments\n end",
"def comments_range; end",
"def comments_range; end",
"def comments\n if nodes = @node.xpath(\"comments\")\n nodes.map { |node| node.content }.compact\n end\n end",
"def getComments\n\t\tself.root_comments\n\tend",
"def getComments\n\t\tself.root_comments\n\tend",
"def comments\n @comments\n end",
"def comments\n @comments\n end",
"def index\n @comments = @snippet.comments\n end",
"def line_comments_option; end",
"def comments(options = {})\n @comments_list ||= CommentList.new(@id)\n return @comments_list.top_level(options)\n end",
"def startup_info\n txt = []\n txt << \"Starting up test with the following configuration:\"\n txt << MyData.env()\n txt << \n txt << \"versions:\"\n txt << \" Capybara #{Capybara::VERSION}\"\n txt << \" Poltergeist #{Capybara::Poltergeist::VERSION}\"\n txt << \" Cucumber #{Cucumber::VERSION}\"\n txt << \" Nokogiri #{Nokogiri::VERSION}\"\n return txt\nend",
"def description\n initial_comment.try(:text) || \"\"\n end",
"def one_line_description(opts={}) ; attributes['comments'] ; end",
"def comments\n client.get(\"/#{id}/comments\")\n end",
"def comments_section_title\r\n 'What are people saying?'\r\n end",
"def comments(doc)\n doc.search('.comment > font:first-child').map { |font| font.inner_text }\n end",
"def return_comment\n @comments\n end",
"def get_comments()\n return self.get_all_comments()\n #issues = @issues\n #issues.each do |issue|\n # puts \"Processing issue #{issue['number']}...\"\n # comments = client.issue_comments( REPO, issue.number ) \n # num = issue['number']\n # @comments[num] = comments\n # issue[\"comments\"] = comments\n #end\n #return @comments\n end",
"def note\n comment_list = []\n return @notes if !@notes.nil?\n for page in @pages\n next if !page || !page.list || page.list.size <= 0\n note_page = page.list.dup\n \n note_page.each do |item|\n next unless item && (item.code == 108 || item.code == 408)\n comment_list.push(item.parameters[0])\n end\n end\n @notes = comment_list.join(\"\\r\\n\")\n return @notes\n end",
"def create_comments\n puts \"\\n==========================================================================================\\n\"\n puts \" 1) Kindly place the routes in routes.rb file: \\n\\n\"\n puts \" match '/auth/:provider/callback', :to => 'sessions#create' \\n\"\n puts \" match '/signout', :to => 'sessions#destroy' , :as => :signout \\n\\n\"\n puts \" 2) Kindly place the code in the html file you need to create the social login: \\n\\n\"\n puts \" <%= render 'sessions/social_login' %> \\n\\n\"\n puts \" 3) Kindly Replace the Consumer Key and Consumer Secret of your App in the .yml files\"\n puts \"\\n==========================================================================================\\n\"\n end",
"def show\n @comments = @rfx.get_all_comments\n end",
"def list_tasks_with_comments\n all_tasks = Task.all\n all_tasks.each do |task|\n puts \"Task: \" + task.title\n task.comments.each {|c| puts \"Comment: \" + c.comment}\n end\nend",
"def first_is_comment?(page)\n\t\treturn false unless page || page.list || page.list[0]\n\t\treturn false unless page.list[0].code == 108\n\t\tindex = 1\n\t\tlist = [page.list[0].parameters[0]]\n\t\twhile page.list[index].code == 408\n\t\t\tlist << page.list[index].parameters[0]\n\t\t\tindex += 1\n\t\tend\n\t\treturn list.collect{|line|line+=\" \"}.join\n\tend",
"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 training_log_comments(id)\n get \"training_logs/#{id}comments\"\n end",
"def comments(*options)\n options.insert 0, project_id\n options.insert 1, id\n easy_finder(provider_parent(self.class)::Comment, :all, options, 2)\n end",
"def scan\n comment = RDoc::Comment.new @content, @top_level\n comment.format = 'markdown'\n\n @top_level.comment = comment\n end",
"def comment_section(comments_hash)\n return set_color('No comments', :cyan) unless comments_hash[:total] > 0\n\n sec = ['Comments', hr]\n comments_hash[:comments].each do |cmt|\n sec << comment(cmt)\n end\n\n sec.join(\"\\n\")\n end",
"def comments\n expose Challenge.comments(@oauth_token, params[:challenge_id].strip)\n end",
"def comment_sections\n return @comment_sections if @comment_sections\n\n @comment_sections = raw ? raw.split(\"\\n\\n\").collect { |s| CommentSection.new(s, [], false) } : []\n\n @comment_sections.each do |comment_section|\n comment_section.modifiers = parse_modifiers(comment_section.comment)\n comment_section.section = parse_section(comment_section.comment)\n end\n end",
"def comments\n @presentation = Presentation.in_conference(current_conference).\n find(params[:id])\n end",
"def parse_comments\n @data[4][0]\n end",
"def admin_comments_stats\n get_admin_stats \"comments\"\n end",
"def collect_first_comment\n skip_tkspace\n comment = ''.dup\n comment = RDoc::Encoding.change_encoding comment, @encoding if @encoding\n first_line = true\n first_comment_tk_kind = nil\n line_no = nil\n\n tk = get_tk\n\n while tk && (:on_comment == tk[:kind] or :on_embdoc == tk[:kind])\n comment_body = retrieve_comment_body(tk)\n if first_line and comment_body =~ /\\A#!/ then\n skip_tkspace\n tk = get_tk\n elsif first_line and comment_body =~ /\\A#\\s*-\\*-/ then\n first_line = false\n skip_tkspace\n tk = get_tk\n else\n break if first_comment_tk_kind and not first_comment_tk_kind === tk[:kind]\n first_comment_tk_kind = tk[:kind]\n\n line_no = tk[:line_no] if first_line\n first_line = false\n comment << comment_body\n tk = get_tk\n\n if :on_nl === tk then\n skip_tkspace_without_nl\n tk = get_tk\n end\n end\n end\n\n unget_tk tk\n\n new_comment comment, line_no\n end",
"def extract_comment(lines)\n lines.take_while { |line| !line.match?(FILE_MARKER) }\n .join\n end",
"def get_comments\n return Comment.where(design_problem_id: self.id).sort_by! { |x| x.created_at }.sort! { |a,b| b.created_at <=> a.created_at }\n end",
"def consume_comments\n c = comments\n discard_comments\n c\n end",
"def scan\n comment = RDoc::Comment.new @content, @top_level\n comment.format = 'rd'\n\n @top_level.comment = comment\n end",
"def commented_by(name)\n get_data(\"user/#{name}/commented\")\n end",
"def show\n @comments = Comment.where(complaint_id: @complaint).order(\"created_at DESC\")\n load_locations(@complaint)\n end",
"def chunks\n self.comment.split(\"\\n\")\n end",
"def ensure_comments_section\n if self.body.match(/^\\* COMMENT Comments$/)\n self.body[$~.end(0)..-1] = self.body[$~.end(0)..-1].gsub(/^\\* COMMENT Comments/, '')\n else\n self.body << \"\\n* COMMENT Comments\\n\"\n end\n end",
"def comments_for(url)\n get_data(\"comments/show/#{FORMAT}?url=#{url}\")\n end",
"def commentString\n if(comments.length <= 0)\n return 'No hay comentarios'\n else\n return ''\n end\n end",
"def comments\n @comments.values\n end",
"def comment\r\n file = ''\r\n MIME.mime_dirs.each { |dir|\r\n file = \"#{dir}/#{content_type}.xml\"\r\n break if File.file? file\r\n }\r\n\r\n comments = {}\r\n open(file) { |f|\r\n doc = REXML::Document.new f\r\n REXML::XPath.match(doc, '*/comment').each { |c|\r\n if att = c.attributes['xml:lang']\r\n comments[att] = c.text\r\n else\r\n comments.default = c.text\r\n end\r\n }\r\n }\r\n comments\r\n end",
"def description\n markup @comment\n end",
"def comments\n if has_comments?\n @repository.load(:comments, number).map do |item|\n Github::Issue::Comment.new(item)\n end\n else \n []\n end\n end",
"def doc_text_info\n extra_javascript 'docs'\n @bugs = sorted_bugs\n end",
"def build_comments\n I18n.available_locales.map { |l| build_comment(l) }\n end",
"def comments(options = {})\n comments_resource(options)\n end",
"def in_files\n return [] if @comments.empty?\n\n case @comments\n when Array then\n @comments.map do |comment|\n comment.file\n end\n when RDoc::Markup::Document then\n @comment.parts.map do |document|\n document.file\n end\n else\n raise RDoc::Error, \"BUG: unknown comment class #{@comments.class}\"\n end\n end",
"def show\n @comments = @resolution.comments.with_state([:draft, :published])\n end",
"def comments\n refresh if (@comments.nil? || @comments.empty?) && @comments_count > 0\n @comments ||= Array.new\n end"
] |
[
"0.62729996",
"0.62729996",
"0.62729996",
"0.62729996",
"0.62729996",
"0.62729996",
"0.6271587",
"0.6245342",
"0.6235109",
"0.6204977",
"0.6120188",
"0.6094312",
"0.6094312",
"0.6094312",
"0.6094312",
"0.6094312",
"0.6002215",
"0.5987624",
"0.59661573",
"0.59236956",
"0.58643013",
"0.58468133",
"0.5842691",
"0.5829296",
"0.5813006",
"0.57845277",
"0.5783716",
"0.57786405",
"0.5743964",
"0.5740062",
"0.57299244",
"0.5667037",
"0.5654454",
"0.5630858",
"0.5630858",
"0.5630858",
"0.5629555",
"0.5629555",
"0.56176883",
"0.56176883",
"0.56075245",
"0.56061256",
"0.5595076",
"0.559029",
"0.558142",
"0.5580785",
"0.55621624",
"0.55621624",
"0.5522085",
"0.5489023",
"0.5489023",
"0.5462106",
"0.5462106",
"0.5457124",
"0.5451585",
"0.54466194",
"0.54379493",
"0.54342514",
"0.54268736",
"0.54213023",
"0.5388043",
"0.53799665",
"0.536052",
"0.53550434",
"0.5351944",
"0.53413844",
"0.533945",
"0.5334744",
"0.53328955",
"0.5317454",
"0.53106046",
"0.52891725",
"0.5286337",
"0.5276396",
"0.52724653",
"0.5267927",
"0.5261131",
"0.5257234",
"0.5235023",
"0.5226254",
"0.5212805",
"0.52116364",
"0.5208747",
"0.5206854",
"0.5204523",
"0.5193571",
"0.5173496",
"0.5172387",
"0.51630116",
"0.51515585",
"0.51488304",
"0.5135046",
"0.5133567",
"0.51241773",
"0.51221395",
"0.5118432",
"0.5118237",
"0.5106931",
"0.51057565",
"0.51055455"
] |
0.7397307
|
0
|
Returns up to 50 startups at a time, given an Array of ids.
|
def get_startups(ids)
params = { :ids => ids.join(',') }
get("1/startups/batch", params)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def gather_user_profiles_from_ids(ids)\n ids = ids.map{|i| Integer(i) }\n profiles = []\n count = 0\n ids.each_slice(100) do |arr|\n count += 1\n puts \"On count: #{count}\"\n begin\n data = Twit.fetch_users_by_ids(arr)\n rescue Twitter::Error::TooManyRequests => err\n puts err\n puts \"Sleeping for 30\"\n sleep 30\n retry\n rescue Twitter::Error::NotFound => err\n puts err\n puts \"moving on...\"\n else\n profiles.concat(data)\n sleep 5\n end\n end\n\n return profiles\n end",
"def get_msruns_from_array_of_ids(ids)\n Msrun.all(:id => ids)\n end",
"def fetch_batch(ids)\n # ids must be complete CNs\n filter = nil\n ids.each do |id|\n filter = if filter.nil?\n obj_filter(id)\n else\n filter | obj_filter(id)\n end\n end\n admin_ldap.search(base: @base, filter: filter)\n end",
"def find_many(ids, *args)\n return [] if ids.blank?\n hashes = multi_get(ids.collect(&:to_s), *args)\n\n hashes.inject([]) do |res, (key, data)|\n res << instantiate(key, data) unless data.empty?\n end\n end",
"def find_ids(ids)\n ids.inject([]) { |x, id| x << all.find { |y| y.id == id }}\n end",
"def load_by_ids ids\n items = @api.fetch_multiple_items ids\n create_by_api_items(items)\n end",
"def start(twitter_ids)\n log(\"Starting Site Streams for Twitter IDs: #{twitter_ids}\")\n\n while twitter_ids.length > 0 do\n start_new_stream( twitter_ids.slice!(0, max_users_per_stream) )\n end\n end",
"def instantiate(ids, args = {})\n expect_args(:instantiate, args, INSTANTIATE_ARGS)\n @results ||= {}\n ids.map!(&:to_i)\n needed = (ids - @results.keys).uniq\n add_needed_to_results(needed: needed, args: args) if needed.any?\n ids.filter_map { |id| @results[id] }\n end",
"def search_results_from_ids(ids)\n where(:id => ids).preload(searchable_options[:preload]).to_a\n end",
"def fetch_records(ids)\n model.where(id: ids)\n end",
"def load_by_ids(ids, context)\n ids.map { |id| load_by_id(id, context) }\n end",
"def create_retrievals\n article_ids = RetrievalStatus.where(:source_id => id).pluck(:article_id)\n\n (0...article_ids.length).step(1000) do |offset|\n ids = article_ids[offset...offset + 1000]\n delay(priority: 2, queue: \"retrieval-status\").insert_retrievals(ids)\n end\n end",
"def associated_records(ids)\n max_ids_in_a_list = connection.ids_in_list_limit || ids.size\n records = []\n ids.each_slice(max_ids_in_a_list) do |some_ids|\n records += yield(some_ids)\n end\n records\n end",
"def user_ids\n page = 1\n per_page = 100\n user_ids = []\n puts 'collecting all user ids'\n loop do\n response = @conn.get api_url('/users'),\n { page: page, per_page: per_page }.merge(token)\n raise 'Error Retrieving user_ids' if response.status != 200\n ids = JSON.parse(response.body).collect { |u| u['id'] }\n user_ids.concat(ids)\n break if ids.size < per_page\n page += 1\n end\n puts 'returning now the user ids'\n user_ids.sort\n end",
"def get_anime(ids)\n ids = [ids] unless ids.is_a? Array\n\n ids.each_slice(100) do |batch|\n req = get(\"/api/edge/anime/?filter[id]=#{batch.join(',')}\")\n req.on_complete do |res|\n anime = JSON.parse(res.body)['data']\n anime.each { |a| yield a }\n end\n end\n end",
"def request_launch_new_instances(num=1)\n out = []\n num.times {out << launch_new_instance!}\n out\n end",
"def from_ids ids\n blocs, ranks = [], []\n blank = JSON.parse({'meta' => {'code' => 404}, 'data' => []}.to_json)\n until ids.empty?\n blocs << ids.shift(200)\n end\n blocs.each do |bloc|\n got = CNX.get(\"#{@url}#{bloc.join(',')}\")\n if got.nil? || got.empty?\n ranks << [{}]\n else\n resps = JSON.parse(got)\n ranks << resps['data']\n end\n end\n return ranks.flatten!\n end",
"def ids_in_list_limit\n 1499\n end",
"def scan_resume_all\r\n\t\tb=scan_list_uids\r\n\t\tb.each {|uuid|\r\n\t\t\tscan_resume(uuid)\r\n\t\t}\r\n\t\treturn b\r\n\tend",
"def find_tickets(*ids)\n ids.map do |id|\n tickets(id).first\n end.compact\n end",
"def fetch(ids)\n data = nil\n\n model.synchronize do\n ids.each do |id|\n redis.queue(\"HGETALL\", namespace[id])\n end\n\n data = redis.commit\n end\n\n return [] if data.nil?\n\n [].tap do |result|\n data.each_with_index do |atts, idx|\n result << model.new(Utils.dict(atts).update(:id => ids[idx]))\n end\n end\n end",
"def create_retrievals\n work_ids = Work.pluck(:id)\n existing_ids = RetrievalStatus.where(:source_id => id).pluck(:work_id)\n\n (0...work_ids.length).step(1000) do |offset|\n ids = work_ids[offset...offset + 1000] & existing_ids\n InsertRetrievalJob.perform_later(self, ids)\n end\n end",
"def make_players(id_range)\n players = []\n id_range.each do |player_id|\n players << generate_player(player_id)\n end\n players\nend",
"def walks_for_games(game_ids)\n results = []\n game_ids.each do |game_id|\n results << walks_for_game(game_id)\n end\n results\n end",
"def for_ids(ids)\n ids = mongoize_ids(ids)\n if ids.size > 1\n send(id_finder, { _id: { \"$in\" => ids }})\n else\n send(id_finder, { _id: ids.first })\n end\n end",
"def all_startups(options={})\n get(\"1/startups\", options)\n end",
"def expand_ids(*ids, **opt)\n opt[:min_id] ||= minimum_id\n opt[:max_id] ||= maximum_id\n # noinspection RubyMismatchedReturnType\n ids.flatten.flat_map { |id|\n id.is_a?(String) ? id.strip.split(/\\s*,\\s*/) : id\n }.flat_map { |id|\n expand_id_range(id, **opt) if id.present?\n }.compact.uniq\n end",
"def all_ids(opts={}, &block)\n user_id = options.delete(:user_id) || User.me.id\n\n opts = options.merge opts\n\n from = \"/users/#{user_id}#{collection_path}/search\"\n\n has_results = true\n ids = []\n\n while has_results && opts[:pages] != opts[:page] do\n params = { limit: opts[:limit],\n offset: opts[:offset] }\n\n path = \"#{from}#{query_string(params)}\"\n data = format.decode(connection.get(path, headers).body) || []\n\n\n results = data[\"results\"]\n has_results = (results.any? and results.count == opts[:limit])\n\n opts[:page ] += 1\n opts[:offset ] += opts[:limit]\n\n yield(results, data, options) if block_given?\n\n ids.concat results\n end\n\n ids\n end",
"def scan_resume_all\n\t\t\tb=scan_list_uids\n\t\t\tb.each {|uuid|\n\t\t\t\tscan_resume(uuid)\n\t\t\t}\n\t\t\treturn b\n\t\tend",
"def fetch_user_profiles(*screen_names)\n arr = []\n Array(screen_names).each_slice(100) do |batch|\n profiles = init_client.users(batch)\n arr.concat profiles.collect(&:to_h)\n end\n\n return arr\n end",
"def strikes_for_games(game_ids)\n results = []\n game_ids.each do |game_id|\n results << strikes_for_game(game_id)\n end\n results\n end",
"def find_tickets(*ids)\n ids.map do |id|\n project.tickets(id).first\n end.compact\n end",
"def search_by_product_ids(ids)\n msb_numbers = []\n\n ids.each do |id|\n j = search(id)\n msb = j['b'].collect { |e| e['Id'] }.map { |e| e.downcase }\n msb_numbers.concat(msb)\n end\n\n msb_numbers\n end",
"def fetch_many(ids, req_params = nil, eds_params = nil)\n req_params ||= params\n search_service.fetch_many(ids, req_params, eds_params)\n end",
"def find_summaries_by_ids(ids)\n @request = setup_request \"#{@@resource_url}s\"\n @request.query = { productLineIds: ids.to_s }\n @request\n end",
"def find_many(array)\n results = CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id IN (#{array.join(\",\")})\")\n \n results_as_objects(results)\n end",
"def find_ids(uris)\n uris.map { |uri| find_id(uri) }\n end",
"def multiple_from_db(ids)\n return entries if embedded?\n ids = mongoize_ids(ids)\n ids.empty? ? [] : from_database(ids)\n end",
"def find_from_search(*ids)\n unless ids.blank?\n results = {}\n ids.flatten.dice(20).each do |set|\n query = (set.map { |id| \"(id:\\\"#{id}\\\")\" }).join(' || ')\n search_results = search_for(query, :qt => 'standard', :rows => set.length)\n search_results.models.each do |result|\n results[result.id] = result\n end\n end\n ids.flatten.map { |id| results[id] }.compact\n else\n []\n end\n end",
"def find_from_search(*ids)\n unless ids.blank?\n results = {}\n ids.flatten.dice(20).each do |set|\n query = (set.map { |id| \"(id:\\\"#{id}\\\")\" }).join(' || ')\n search_results = search_for(query, :qt => 'standard', :rows => set.length)\n search_results.models.each do |result|\n results[result.id] = result\n end\n end\n ids.flatten.map { |id| results[id] }\n else\n []\n end\n end",
"def test_generate_unique_ids\n\n n = 10_000\n\n wfids = (1..n).collect { @dashboard.context.wfidgen.generate }\n\n assert_equal n, wfids.uniq.size\n end",
"def static(ids)\n new({:ids => ids\n }) \n end",
"def ids\n @ids ||= []\n end",
"def do_id_query(ids)\n responses = []\n ids.each do |k, v|\n new_key_value = map_key(k, v)\n next if new_key_value.blank? #we probably have bad ISBN, could be bad key though\n responses << get_thing(new_key_value)\n end\n selected = responses.map { |r| r['result'] }.flatten.compact.uniq\n return selected\n end",
"def add_users(ids)\n\t\t self.shared_users = ids.split(\",\").map do |id|\n \t\tUser.where(id: id.strip).first_or_create!\n \tend\n\tend",
"def ks_for_games(game_ids)\n results = []\n game_ids.each do |game_id|\n results << ks_for_game(game_id)\n end\n results\n end",
"def next_ten_hosts(db)\r\n\t\tarray1 = []\r\n\t\tarray1 << db.execute(\"SELECT name FROM playgroups WHERE id<=10\")\r\n\t\tputs \"Next ten hosts are...\"\r\n\t\tarray1[0].each do |i|\r\n\t\t\tputs i \r\n\t\t\tputs \"--------------\"\r\n\t\tend\r\n\tend",
"def delete_ids(args)\n while !args[:ids].empty? and ids = args[:ids].shift(500)\n objs = self.list(args[:class], \"id\" => ids)\n self.deletes(objs)\n end\n\n return nil\n end",
"def sellers(ids)\n list_sellers = []\n ids.each do |id|\n list_sellers << Seller.find(id)\n end\n list_sellers\n end",
"def sliced_pids(pids)\n pids.each_slice(100).to_a\n end",
"def seed_partner students, maximum\n partners = []\n random_partner_number = (0..maximum).to_a.sample\n random_partner_number.times do\n unless students.sample.nil?\n partners << students.sample.id\n end\n end\n return partners\nend",
"def all_sequentially &block\n page, per_page = 1, 5\n begin\n results = paginate(page: page, per_page: per_page, order: '_id asc')\n results.each{|o| block.call o}\n page += 1\n end until results.blank? or results.size < per_page\n end",
"def track_ids(opts = {})\n limit = opts[:limit] ? opts[:limit].to_i : 10\n offset = opts[:offset].to_i # Defaulting to 0\n\n shuffler = Smoothie::Shuffler.new(favorite_track_ids, @seed)\n return shuffler.get(:offset => offset, :limit => limit)\n end",
"def start_instances( options = {} )\n options = { :instance_id => [] }.merge(options)\n raise ArgumentError, \"No :instance_id provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n params = {}\n params.merge!(pathlist(\"InstanceId\", options[:instance_id]))\n return response_generator(:action => \"StartInstances\", :params => params)\n end",
"def find_by_ids(catalog_ids)\n @request = setup_request \"#{@@resource_url}s\"\n @request.query = { catalogIds: catalog_ids.to_s }\n @request\n end",
"def regenerate_applicability_by_ids(ids, parallel = false)\n criteria = {\n 'parallel' => parallel,\n 'repo_criteria' => { 'filters' => { 'id' => { '$in' => ids } } }\n }\n regenerate_applicability(criteria)\n end",
"def bootstrap_users\n @@bootstrap_users ||= []\n return @@bootstrap_users unless @@bootstrap_users.length == 0\n 12.times do\n u = User.gen\n @@bootstrap_users << u\n u.build_watch_collection\n end\n return @@bootstrap_users\nend",
"def load_checkins(checkin_count)\n multi = EventMachine::MultiRequest.new\n 0.upto((checkin_count / 250) + 1) do |offset|\n request = EventMachine::HttpRequest.new(\"https://api.foursquare.com/v2/users/self/checkins\").get(:query => {\n :limit => 250,\n :offset => offset * 250,\n :oauth_token => access_token\n })\n multi.add(offset, request)\n end\n\n multi.callback do\n checkins = []\n multi.responses[:callback].values.each do |req|\n checkins += JSON.parse(req.response)[\"response\"][\"checkins\"][\"items\"]\n end\n set(history_id, checkins)\n end\n end",
"def collect1 pages\n id = 'joshuabaer'\n results = []\n 1.upto pages do |page|\n results += http_get id, page\n end\n results\nend",
"def fetch(*ids, expire: 1800)\n store_data(ids_to_array(ids), expire)\n\n # Collect all fetched data and assign to global variable\n arr = []\n\n ids.each do |id|\n arr << (hgetall(id))\n end\n\n $movie_data = arr\n end",
"def get_set_of_user_ids(arr_of_user_names)\n set_of_user_ids = Set.new\n\n arr_of_user_names.each { |name|\n @url = \"http://#{$canvas_host}/api/v1/courses/#{$canvas_course_id}/users\"\n puts \"@url is #{@url}\"\n \n @payload={'search_term': name}\n puts(\"@payload is #{@payload}\")\n \n @getResponse = HTTParty.get(@url, :body => @payload.to_json, :headers => $header)\n puts(\" GET to get user has Response.code #{@getResponse.code} and getResponse is #{@getResponse}\")\n \n user_data = @getResponse.parsed_response\n \n user_data.each do |user_data_info|\n set_of_user_ids.add user_data_info[\"id\"]\n end\n }\n \n return set_of_user_ids\nend",
"def rpm_ids(id)\n criteria = {:type_ids => [Runcible::Extensions::Rpm.content_type],\n :fields => {:unit => [], :association => ['unit_id']}}\n self.unit_search(id, criteria).map { |i| i['unit_id'] }\n rescue RestClient::RequestTimeout\n self.logger.warn('Call to rpm_ids timed out')\n # lazy evaluated iterator from zero to infinite\n pages = Enumerator.new do |y|\n page = 0\n loop do\n y << page\n page += 1\n end\n end\n\n # TODO: this is hotfix, pagination support should be added to Runcible\n pages.reduce([]) do |rpm_ids, page|\n page_size = 500\n criteria = { :type_ids => [Runcible::Extensions::Rpm.content_type],\n :fields => { :unit => [], :association => ['unit_id'] },\n :limit => page_size,\n :skip => 0 + page * page_size }\n result = unit_search(id, criteria).map { |i| i['unit_id'] }\n rpm_ids.concat(result)\n if result.empty? || result.size < 500\n break rpm_ids\n else\n rpm_ids\n end\n end\n end",
"def batch_items(ids, api_url=ANN_API_URL)\n\t\t# append id to API url and send request\n\t\turl = \"#{api_url}?title=#{ids.first.to_s}\"\n\t\tids[1..-1].each do |id|\n\t\t\turl << \"/#{id.to_s}\"\n\t\tend\n\n\t\tann = fetch(url)\n\n\t\treturn [ann] if ann.is_a?(ANN_Error)\n\n\t\tall_items = ann.xpath(\"//ann/#{@@type}\")\n\t\twarnings = ann.xpath('//ann/warning')\n\n\t\treturn [ANN_Error.new(get_xml_error(ann))] if all_items.empty? and warnings.empty?\n\n\t\tall_items = all_items.map { |item| Object.const_get(\"ANN_#{@@type.capitalize}\").new(item) }\n\t\twarnings = warnings.map { |warning| ANN_Error.new(get_xml_error(warning)) }\n\n\t\tall_items.push(*warnings)\n\tend",
"def get_tracks(*ids)\n song_list = []\n ids.each do |id|\n song_list << @tracks.find {|s| s.track_id == id}\n end\n return song_list.compact\n end",
"def run\n number = options[\"number\"].to_i\n\n threads = options[\"max_threads\"].to_i\n\n factories = if options[:approved] || options[:rejected] || options[:pending] || options[:incomplete]\n build_factory_list\n else\n options[\"factory\"]\n end\n\n puts \"Starting load of #{number} enrollments per factory(s) #{factories.inspect}\"\n\n t1 = Time.zone.now\n\n if threads.zero?\n 1.upto(number) do |n|\n print \".\" if (n % 10).zero?\n factories.each { |f| FactoryGirl.create(f) }\n end\n else\n puts \"Running using #{threads} threads\"\n\n cycles = (number / threads).to_i\n\n # the remainder\n 1.upto(number - (cycles * threads)).each { factories.each { |f| FactoryGirl.create(f) } }\n\n 1.upto(cycles).map do\n 1.upto(threads).map do\n Thread.new do\n factories.each { |f| FactoryGirl.create(f) }\n ActiveRecord::Base.connection.close\n end\n end.each(&:join)\n end\n end\n\n t2 = Time.zone.now\n\n puts(\"\\nBulk load of [#{options['number'] * factories.size}] Enrollments took [#{t2 - t1}] seconds\")\n end",
"def get_ids\r\n case id\r\n when 1 then [1,2,3,4,5] # superadmin\r\n when 2 then [2] # data\r\n when 3 then [3,4,5] # centeradmin\r\n when 4 then [4,5] # teamadmin\r\n when 5 then [5] # behandler\r\n when 10 then [10,11,12,13,14,15] # login_bruger\r\n when 11 then [11] # parent\r\n when 12 then [12] # teacher\r\n when 13 then [13] # pedagogue\r\n when 14 then [14] # youth\r\n else []\r\n end\r\n end",
"def get_tasks\n\n\ttasks = Task.all.shuffle\n\n\treturned_tasks = []\n\trand(10..18).times do\n\t\treturned_tasks << tasks.pop\n\tend\n\n\treturned_tasks\nend",
"def get_results_from_ids\n @response = Entrez.ESummary(ncbi_database_name, id: @ids)\n # URL is too long, probably because there are too many results for NCBI server.\n raise SearchTooBroad.new(@ids) if @response.code == 414\n @results = parent::SearchResult.new_from_splitting_xml(xml)\n end",
"def topic_ids=(ids)\n self.topics = Topic.active.find(:all, :conditions => [\"id IN (?)\", ids.map(&:to_i)])\n end",
"def find_by_ids(ids)\n rows = data_store.get(ids)\n results = []\n rows = [] << rows unless rows.instance_of?(Array)\n\n rows.each do |row|\n results << _deserialize(row[:key], row[:data])\n end\n\n results\n end",
"def add_first_users_to_stream(client, twitter_ids)\n log(\"Adding #{twitter_ids.length} user(s) to stream: #{twitter_ids}\")\n\n # We can add up to 100 users when we first create the stream.\n client.sitestream(twitter_ids.slice!(0,100)) do |hash|\n if hash[:message][:direct_message]\n log(\"DM received: #{hash[:message][:direct_message][:sender_id]} to #{hash[:message][:direct_message][:recipient_id]}\")\n # We get DMs the user has both sent and received.\n # We only want the ones they've received.\n if hash[:for_user] == hash[:message][:direct_message][:recipient_id]\n bergcloud.direct_message(\n ::Twitter::DirectMessage.new(hash[:message][:direct_message]))\n end\n end\n end\n\n # Users 101-1000 must be added invidiually.\n # We can only add up to 25 extra users per second to a stream.\n timer = EventMachine.add_periodic_timer(0.04) do\n if id = twitter_ids.shift\n add_user_to_client(client, id)\n else\n timer.cancel\n end\n end\n\n return client\n end",
"def get_followees(ids)\n followees_resp = twitter_user.request(:get, configatron.api_call_url + \"users/lookup.json?user_id=#{ids.join(',')}\")\n \n if followees_resp.is_a?(Net::HTTPSuccess)\n get_nicknames_and_names(JSON.parse(followees_resp.body))\n end\n end",
"def get_all_results\n\t\tresult_array = []\n\t\tskip = 0\n\t\ttake = 1000\n\t\tloop do\n\t\t\tcurrent_result = get_data_from_result(execute_request(take, skip)[1])\n\t\t\tresult_array.concat(current_result)\n\t\t\tskip = skip + take\n\t\t\tbreak if current_result.size != take\n\t\tend\n\t\treturn result_array\n\tend",
"def timeseries(ids, start_at, options = {})\n ids = ids.joing(',') if ids.kind_of? Array\n get('venues/timeseries', { :venueId => ids, :startAt => start_at }.merge(options))\n end",
"def get_products(ids=[])\n ids = [ids] unless ids.is_a? Array\n return call('Product.get_products', {:ids => ids})\n end",
"def getUsers( num_users = nil )\n\n #get all users\n users = (@min_user..@max_user).to_a\n \n #limit if necessary\n if num_users\n users = users.sample( num_users )\n end\n \n #return\n users\n \n end",
"def assign_ids_on_each(start, array)\n array.nil? ? start : array.inject(start) { |n, a| a.assign_ids(n) }\n end",
"def start_generators\n threads = []\n 5.times do |idx|\n thread = Thread.new { contious_generation }\n thread[:id] = idx\n threads << thread\n end\n threads\n end",
"def find_many_file_metadata_by_ids(ids:, use_valkyrie: true)\n results = []\n ids.each do |alt_id|\n begin\n # For Wings, the id and alt_id are the same, so just use alt id querying.\n file_metadata = query_service.custom_queries.find_file_metadata_by_alternate_identifier(alternate_identifier: alt_id, use_valkyrie: use_valkyrie)\n results << file_metadata\n rescue Hyrax::ObjectNotFoundError\n next\n end\n end\n results\n end",
"def things(*ids)\n get(\"/rest/v2/things/#{ids.join(\",\")}?full\").collect { |t| Flattr::Thing.new(t) }\n end",
"def assign_id(all_ids)\r\n highest_id = all_ids.max || 10 # reserve first 10 ids for testing\r\n return highest_id + 1\r\n end",
"def multi_get(ids)\n result = CouchRest.post(SERVER.default_database.to_s +\n '/_all_docs?include_docs=true', :keys => ids)\n\n return result['rows'].collect { |row|\n row = row['doc'] if row['couchrest-type'].nil?\n\n if row and (class_name = row['couchrest-type'])\n eval(class_name.to_s).new(row) rescue row\n else\n row\n end\n }\n end",
"def records_for_bulk_index(ids, batch_size = 1000)\n transaction do\n offset = 0\n ids.each_slice(batch_size) do |id_slice|\n records = find( :all, :conditions => [\"id in (?)\", id_slice] )\n #yield records, offset\n yield find( :all, :conditions => [\"id in (?)\", id_slice] ), offset\n offset += batch_size\n end\n end\n end",
"def products(opts= {})\n current_limit = limit = opts[:limit] || 5\n products = []\n\n @profiles.each do |profile|\n products += filtered_list_for_profile(profile, opts).first(current_limit)\n current_limit = limit - products.size\n break if products.size == limit\n end\n products.uniq\n end",
"def records\n live_lookup_service.new(@ids).records\n end",
"def generate_new_employees(employee_ids)\n new_employees = []\n employee_ids.each do |ei|\n employee = Employee.find_by(employee_id: ei)\n unless employee.present?\n new_employee = Employee.new(employee_id: ei)\n new_employee.save!\n new_employees << new_employee\n end\n end\n return new_employees if new_employees.present?\n end",
"def last_ids(number); end",
"def all\n end_time = (Time.now - (30 * 60 * 60 * 24)).to_i\n all_items = Array.new\n cur_items = self\n begin\n all_items += cur_items.items\n cur_items = cur_items.next(:count => 200, :start_time => end_time)\n end until cur_items.nil?\n all_items\n end",
"def get_tweet_list(ids, page_num)\n\t\ttweets = get_timeline(ids)\n\t\ttweets[(page_num.to_i - 1) * 10, page_num.to_i * 10]\n\tend",
"def find_all_by_id(klass, ids, find_opts={})\n return ids if ids.empty?\n find_opts = Options.new(find_opts.merge(:result_klass => klass)).opts_for_find(ids)\n if AridCache.framework.active_record?(:>=, 3) # use Arel\n option_map = {\n :conditions => :where,\n :include => :includes\n }\n query = find_opts.inject(klass.scoped) do |scope, pair|\n key, value = pair\n key = option_map[key] || key\n scope.send(key, pair[1])\n end\n query = query.scoped.where(Utilities.namespaced_column(:id, klass) + ' in (?)', ids)\n # Fix http://breakthebit.org/post/3487560245/rails-3-arel-count-size-length-weirdness\n query.class_eval do\n alias_method :size, :length\n alias_method :count, :length\n end\n query\n else\n klass.find_all_by_id(ids, find_opts)\n end\n end",
"def activities(start = 0, limit = 100)\n redis.call 'LRANGE', key[:activities], start, start + limit\n end",
"def typhoeus_batch(urls)\n hydra = Typhoeus::Hydra.new(max_concurrency: 100)\n responses = []\n urls.each do |url|\n request = get_typhoeus_request(url)\n request.on_complete do |response|\n responses << response if response.success?\n end\n hydra.queue(request)\n request\n end\n hydra.run\n responses\n end",
"def instance_ids(*ids)\n ids.map do |id|\n {instance_id: id}\n end\n end",
"def calculate_ids amount, offset\n return [] if @combinations.empty? # Checked here to avoid checking in each backend.\n\n # TODO Redesign such that ids is only created (and cached) if requested.\n #\n backend.ids @combinations, amount, offset\n end",
"def user_ids=(values)\n values ||= []\n values = [ values ] unless values.is_a?(::Array)\n values = values.reject{|v| v.blank?}.map{|v| v.to_i}\n self.users = Incline::User.where(id: values).to_a\n end",
"def reserve(limit: 1000)\n record_ids = Set.new\n while record_ids.size < limit && (record_id = Searchkick.with_redis { |r| r.rpop(redis_key) })\n record_ids << record_id\n end\n record_ids.to_a\n end",
"def get_documents(ids)\n results = []\n return results unless ids\n ids.uniq.each { |id| results << Zoek::DOCUMENTS.fetch(id) }\n results\n end",
"def make_ranges(ids)\n \tint_array = ids.collect{|s| s.to_i}\n\n\tint_array = int_array.sort\n\tnew_ids = []\n\tr = []\n\tz = int_array[0].to_i\n\tr[0] = z\n\tint_array.each do |n|\n\t if n > z+1\n\t \tnew_ids << r\n\t \tr = [n]\n\t else\n\t r[1] = n\n\t \tend\n\t \tz = n\n\tend\n\tnew_ids << r\n\tnew_ids\n end",
"def sampled_traces(trace_ids)\n result = false\n traces = nil\n ZipkinQuery::Client.with_transport($config) do |client|\n traces = client.tracesExist(trace_ids)\n end\n return traces\nend",
"def for_ids(*ids)\n field = klass.fields[\"_id\"]\n ids.flatten!\n if ids.size > 1\n any_in(:_id => ids.map{ |id| field.serialize(id) })\n else\n where(:_id => field.serialize(ids.first))\n end\n end"
] |
[
"0.67651993",
"0.66166914",
"0.60484505",
"0.6021994",
"0.58882123",
"0.5844549",
"0.5763887",
"0.5762793",
"0.5753166",
"0.57400334",
"0.5730895",
"0.56570125",
"0.55848336",
"0.5583678",
"0.55628765",
"0.5545807",
"0.55302626",
"0.5518771",
"0.5465705",
"0.5456989",
"0.54452336",
"0.5440402",
"0.54137105",
"0.53977823",
"0.538767",
"0.53506666",
"0.53467155",
"0.5333264",
"0.53137",
"0.530684",
"0.5259401",
"0.52585953",
"0.52283615",
"0.522542",
"0.5219002",
"0.521055",
"0.5206256",
"0.5205935",
"0.5189046",
"0.51817024",
"0.5179967",
"0.5178553",
"0.5176178",
"0.51583123",
"0.5154597",
"0.51531285",
"0.514226",
"0.5138659",
"0.51367515",
"0.5121022",
"0.5096499",
"0.5083941",
"0.507117",
"0.5060537",
"0.505742",
"0.5053874",
"0.50400627",
"0.50248414",
"0.5014473",
"0.50064224",
"0.49935016",
"0.49875584",
"0.4983282",
"0.49825093",
"0.49776027",
"0.4976306",
"0.49680027",
"0.4965395",
"0.49566182",
"0.49506453",
"0.49450403",
"0.49327224",
"0.4919005",
"0.49081084",
"0.49018136",
"0.48991644",
"0.48967034",
"0.48941955",
"0.48935133",
"0.4891093",
"0.48896384",
"0.48891467",
"0.48879328",
"0.48774222",
"0.48737663",
"0.48731673",
"0.48677275",
"0.48676687",
"0.48669448",
"0.4859789",
"0.48569417",
"0.4855933",
"0.48550212",
"0.4838784",
"0.48262283",
"0.48199582",
"0.48171228",
"0.4810371",
"0.48089328",
"0.48067358"
] |
0.74887687
|
0
|
Returns the firehose of companies on AngelList. Results are paginated.
|
def all_startups(options={})
get("1/startups", options)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all\n endpoint = 'Companies'\n response = JSON.parse(@client.get(endpoint).body)\n companies = response.key?('Items') ? response['Items'] : []\n companies.map { |attributes| Unleashed::Company.new(@client, attributes) }\n end",
"def index\n @employees = Employee.all.order(created_at: :desc).group(\"employees.company_id, id\").paginate(page: params[:page], per_page: 15)\n @companies = Company.where(id: @employees.pluck(:company_id).uniq.sort)\n end",
"def index\n @hiring_companies = HiringCompany.all\n end",
"def filing_history_list(company_number, category = nil, items_per_page = nil, start_index = nil)\n params = {category: category}\n params[:items_per_page] = items_per_page if items_per_page\n params[:start_index] = start_index if start_index\n\n client.get(\"company/#{company_number}/officers/\", params)\n end",
"def companies\n\t\tEmpresa.all\n\tend",
"def index\n @companies = Company.all.first(50000)\n end",
"def get_information_all_companies()\n\t\tpage = 275\n\t\tbegin\n\t\t\turl = create_url(\"organizations\",\"\",page)\n\t\t\tputs \"Reading #{url}\"\n\t\t\tresult = read_url(url)\n\t\t\t#save_json(result, [\"organizations\"])\n\n\t\t\tadd_organization_info(result,\"name\")\n\t\t\tadd_organization_info(result,\"path\")\n\t\t\t\n\t\t\tnext_url = result['data']['paging']['next_page_url']\n\t\t\tpage = page + 1\n\t\tend while next_url != nil\n\t\tcreate_permalink(@paths)\n\t\tsave_json(\"\", [\"names\", \"paths\", \"permalinks\"])\n\tend",
"def index\n\t\t@companies = []\n if params[:query].nil?\n @products = []\n else\n @products = Product.search params[:query]\n @products.each do |product|\n product.companies.each do |company|\n if !@companies.include? company\n @companies << company\n end\n end\n end\n end\n\tend",
"def index\n @companies = Company.alphabetical.all\n end",
"def index\n @company_events = CompanyEvent.all\n end",
"def index\n @companies = ClientCompany.all\n end",
"def index\n @companies = Company.order(:name).page(params[:page]).per(10)\n end",
"def all_companies_information\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_company_info'])\n\t\t url_params = {}\n\t\t path = \"#{url.path}?#{url_params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\"}.join('&')}\"\n\t\t request = Net::HTTP::Get.new(path) \n\t\t response = Net::HTTP.start(url.host, url.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| \n\t\t http.request(request)\n\t\t end \n\t\t json_data = JSON.parse(response.body) rescue nil\n\t\t if !json_data.present?\n\t\t \treturn {}\n\t\t else\n\t\t return json_data\n\t\t end\n\t rescue => e\n\t \treturn {:message => 'Error in fetchng API data. Please try again.'}\t\n\t end\n\tend",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n @companies = Company.all\n end",
"def index\n\t\t@companies = Company.all\n\tend",
"def index\n\t\t@companies = Company.all\n\tend",
"def index\n @companies = Company.all\n\n end",
"def index\n @companies_info = Company.display_information\n end",
"def index\n @employees = Employee.paginate(page: params[:page]).per_page(10) # pagination (gem 'will_paginate')\n @companies = Company.all\n end",
"def companies\n company_ids = company_affiliations.with_access.map(&:company_id)\n Company.where(:id.in => company_ids)\n end",
"def list_portfolio_companies\n self.companies.map do |company_instance|\n company_instance.name\n end\n end",
"def companies\n signed_get(COMPANIES_PATH)\n end",
"def index\n @gas_companies = GasCompany.all\n end",
"def show\n @companies = Company.all\n end",
"def companies\n companies = Driver.find(params[:id]).company\n if companies.size == 0\n companies = Array.new\n end\n respond_with companies\n rescue ActiveRecord::RecordNotFound\n respond_with ActiveRecord::RecordNotFound\n end",
"def companies\n private_companies + major_companies\n end",
"def index\n @companies = Company.paginate(page: params[:page]).per_page(10) # pagination (gem 'will_paginate')\n end",
"def index\n @employees = @client.employees\n @events = fetch_events\n end",
"def index\n if request.format.to_sym == :html\n @companies = Company.page(params[:page]).order(\"LOWER(name)\")\n else\n @companies = Company.all\n end\n respond_with(@companies)\n end",
"def index\n @companies = Company.search(params[:search]).order('updated_at DESC').page(params[:page])\n end",
"def list(companies)\n companies.each {|company| puts \"#{company.name} - #{company.size}\"}\nend",
"def companies\n return [] unless basecamp\n @companies ||= basecamp.companies\n end",
"def index\n @main_companies = MainCompany.all\n end",
"def index\n @business_companies = Business::Company.all\n end",
"def index\n @companies = Company.all\n if @companies\n render json: {\n companies: @companies\n }\n else\n render json: {\n status: 500,\n errors: ['No companies']\n }\n end\n end",
"def index\n @companies = Company.all.page params[:page]\n end",
"def index\n @companies = Company.all\n @recently_added_companies = Company.order(created_at: :desc).limit(5)\n @top_five = Company.order(rating: :desc).limit(5)\n render('index')\n end",
"def index\n @company_names = CompanyName.all\n end",
"def index\n @invoced_companies = InvocedCompany.all\n end",
"def index\n @company = Company.all\n end",
"def hired\n authorize current_company, :index?\n @drivers = current_company.hired_drivers.distinct\n @drivers = @drivers.page(params[:page]).per(10)\n end",
"def index\n @producer_companies = ProducerCompany.all\n end",
"def index\n @emails = EventEmail.scoped\n\n if params.keys.include? \"company_id\"\n @emails = @emails.where(:company_id => params[:company_id])\n end\n\n if params.keys.include? \"limit\"\n @emails = @emails.limit(params[:limit])\n end\n\n respond_with @emails\n end",
"def index\n @companies = NasdaqCompany.all_companies\n respond_with(@companies)\n end",
"def index\n @rail_companies = RailCompany.all\n end",
"def index\n @companies = Company.all.order(\"created_at ASC\").paginate(page: params[:page], per_page: 15)\n end",
"def index\n @production_companies = ProductionCompany.all\n end",
"def company\n @company ||= Harvest::API::Company.new(credentials)\n end",
"def index\n @companies = companies_scope\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n session[:letter] = nil\n\n if !session[:organization]\n init_oco\n end\n if session[:organization] != '0'\n @corp_contacts = Company.where(organization_id: session[:organization]).includes(:offices, :corp_contacts).order(:name)\n else\n @corp_contacts = Company.includes(:offices, :corp_contacts).order(:name)\n end\n #@corp_contacts = Company.order('name').all(:include => [:offices, :corp_contacts])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @corp_contacts }\n end\n end",
"def index\n @visit_companies = VisitCompany.all\n end",
"def index\n @contact_companies = ContactCompany.all\n end",
"def index\n organizations = if params[:q]\n CclaSignature.search(params[:q])\n else\n Organization.includes(:ccla_signatures)\n end\n\n respond_to do |format|\n format.json do\n render json: organizations.to_json(only: [:id], methods: [:company])\n end\n end\n end",
"def index\n @customer_companies = CustomerCompany.all\n end",
"def index\n @companies = Company.all\n @top_billing = Company.ordered_by_current_bill\n\n @import = Company::Import.new\n # authorize @companies\n skip_authorization\n respond_to do |format|\n format.html\n format.csv { send_data @companies.to_csv, filename: \"companies-export-#{Time.now}-inclustaff.csv\" }\n \tend\n\n end",
"def get_expense_companies\n res = {\n :total => nil,\n :success => true,\n :data => []\n }\n entities = OrderEntity.find_all_by_order_id(params[:id], :include => [:company])\n entities.each do |e|\n res[:data].push([e.id, e.company.name])\n end\n\n render :json => res.to_json, :layout => false\n\n end",
"def index\n @company_informations = CompanyInformation.all\n end",
"def show\n @company = current_user.companies.find(params[:id])\n\n @events = @company.events.paginate(:page => 1, :page => params[:page], :per_page => 10, :order => \"created_at DESC\")\n \n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @company }\n end\n end",
"def index\n @companies = Company.all\n #result\n\n if @companies.count>0\n render :json => @companies.to_json(:include =>[:confidenceLevel,:nda,:country,:region,:state,:city,:company_type,:company_investors]), :status=>:ok\n else\n render :json => \"No companies found.\".to_json\n end\n end",
"def show\n @employees = @company.employees.all.order(\"employees.created_at ASC\").paginate(page: params[:page], per_page: 5)\n end",
"def index\n @couts = Cout.order(:code)\n @company = Company.find(1)\n end",
"def show\n\n @company = Company.find(1)\n @trucks = @company.get_trucks()\n @employees = @company.get_employees()\n end",
"def index\n @companions = Companion.all\n end",
"def index\n @company_owners = CompanyOwner.all\n end",
"def index\n @goofballs = Goofball.all\n end",
"def index\n @page_id = 'companyList'\n @banners = Banner.companies.where('start_at <= ? and end_at >= ?', Time.now, Time.now).where(:language => params[:locale] == 'en' ? [0, 1] : [0, 2])\n @company_classifies = CompanyClassify.design\n @companies = params[:company_classify_id].present? ? Company.joins(:company_classify_relations).where('company_classify_relations.company_classify_id = ?', params[:company_classify_id]).design.allow.human_order : Company.design.allow.human_order\n end",
"def firehose(query_parameters = {})\n start('statuses/firehose', query_parameters)\n end",
"def index\n @intelcompanies = IntelCompany.all\n render json: @intelcompanies.to_json(include: [:intel, :company])\n end",
"def index\n @account_companies = Account::Company.all\n end",
"def index\n @credit_companies = CreditCompany.all.page(params[:page]).per(10)\n end",
"def list(recurring: :unset, trigger_by: :unset, usage_category: :unset, limit: nil, page_size: nil)\n self.stream(\n recurring: recurring,\n trigger_by: trigger_by,\n usage_category: usage_category,\n limit: limit,\n page_size: page_size\n ).entries\n end",
"def all\n @bouncers = Bouncer.find(:all, :order => \"count DESC\")\n @title = \"All URLs\"\n @show_edit_controls = false\n render :index\n end",
"def index\n manage_filter_state\n if session[:organization] != '0'\n @companies = Company.where(organization_id: session[:organization]).includes(:organization).paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n else\n @companies = Company.includes(:organization).paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n format.js\n end\n end",
"def show\n @gastos = Gasto.all\n @company = Company.find(1)\n @locations = @company.get_locations()\n @divisions = @company.get_divisions()\n @documents = @company.get_documents()\n @cajas = Caja.all \n @employees = @company.get_employees \n @egresos = Egreso.order(:code)\n end",
"def show\n @gastos = Gasto.all\n @company = Company.find(1)\n @locations = @company.get_locations()\n @divisions = @company.get_divisions()\n @documents = @company.get_documents()\n @cajas = Caja.all \n @employees = @company.get_employees \n @egresos = Egreso.order(:code)\n end",
"def company_statistics(options={})\n path = \"#{company_path(options)}/company-statistics\"\n get(path, options)\n end",
"def index\r\n # Get all companies alphabetized\r\n #@companies = Company.order(\"LOWER(name)\")\r\n @companies = Company.order(\"LOWER(name)\").paginate(:page =>params[:page], :per_page =>10)\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @companies }\r\n end\r\n end",
"def index\n @companies = Company.all\n @com_info = Company.last\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @emails = Email.scoped\n\n if params.keys.include? \"company_id\"\n @emails = @emails.where(:company_id => params[:company_id])\n end\n\n if params.keys.include? \"limit\"\n @emails = @emails.limit(params[:limit])\n end\n\n respond_with @emails\n end",
"def index\n @pagetitle = \"Suppliers\"\n \n @companies = Company.all\n\n @path = 'suppliers'\n\n @suppliercsv = Supplier.all \n respond_to do |format|\n format.html\n format.csv { send_data @suppliercsv.to_csv }\n \n end\n\n\n end",
"def index\n @type_companies = TypeCompany.all\n end",
"def index\n if current_user.admin?\n @companies = Company.all.order(:name).page(params[:page]).per(10)\n else\n @companies = current_user.company\n end\n end",
"def index\n @ahoogahs = Ahoogah.all\n end",
"def index\n @scrap_url = 'https://abilene.craigslist.org/search/hhh?min_bedrooms=3&max_bedrooms=3&max_bathrooms=2&min_bathrooms=2'\n @homes = Home.all\n\n respond_to do |format|\n format.html\n format.csv { render json: @homes.to_csv, layout: false }\n end\n end",
"def index\n @employees = $Vendor.employees.scopied.order(\"created_at desc\").page(params[:page]).per(25)\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @employees }\n end\n end",
"def show\n\n\n @company = Company.find(1)\n\n @trucks = @company.get_trucks\n\n @employees = @company.get_employees2() \n @puntos = @company.get_puntos()\n end",
"def index\n @companies = NewCompany.where(user: current_user)\n end",
"def index\n @company_clients = CompanyClient.where(company: params[:company]).first\n end",
"def index\n \tif params[:search]\n \t\t@companies = Company.search(params[:search]).order(\"name asc\")\n \telsif params[:sort] == \"drivers.length\"\n \t\tif sort_direction == \"asc\"\n \t\t\t@companies = Company.joins(:drivers).group(\"drivers.company_id\").order(\"count(drivers.company_id) asc\")\n \t\telse\n \t\t\t@companies = Company.joins(:drivers).group(\"drivers.company_id\").order(\"count(drivers.company_id) desc\")\n \t\tend\n \telse\n\t @companies = params[:sort] == nil ? Company.all : Company.order(sort_column + \" \" + sort_direction)\n\tend\n end",
"def index\n @company_categories = CompanyCategory.all\n end",
"def index\n #import\n @filings = Filing.all\n @companies = Company.all\n end",
"def filtered_list\n companies.where('overall_employees_count < required_employee_count')\n end",
"def each_company_onethings(company_id, interval)\n\t\tbegin\n\t url = URI.parse(Rails.application.secrets[:api_endpoints]['onething']['url_indvidual_company'])\n\t\t url_params = {\"comapny_id\" => company_id, \"interval\" => interval}\n\t\t path = \"#{url.path}?#{url_params.collect { |k,v| \"#{k}=#{CGI::escape(v.to_s)}\"}.join('&')}\"\n\t\t request = Net::HTTP::Get.new(path) \n\t\t response = Net::HTTP.start(url.host, url.port, :use_ssl => false, :verify_mode => OpenSSL::SSL::VERIFY_NONE) do |http| \n\t\t http.request(request)\n\t\t end \n\t\t json_data = JSON.parse(response.body) rescue nil\n\t\t if !json_data.present?\n\t\t \treturn {}\n\t\t else\n\t\t return json_data\n\t\t end\n\t rescue => e\n\t \treturn {:message => 'Error in fetchng API data. Please try again.'}\t\n\t end\n\tend",
"def show\n @breadcrumb = 'read'\n @company = Company.find(params[:id])\n @offices = @company.offices.paginate(:page => params[:page], :per_page => per_page).order(:office_code)\n @notifications = @company.company_notifications.paginate(:page => params[:page], :per_page => per_page).order('id')\n @accounts = @company.company_bank_accounts.paginate(:page => params[:page], :per_page => per_page).order(:id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @company }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end",
"def index\n @companies = Company.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @companies }\n end\n end"
] |
[
"0.6541858",
"0.618571",
"0.60380113",
"0.5960054",
"0.5942503",
"0.5928719",
"0.5902036",
"0.58749175",
"0.58127373",
"0.5812024",
"0.5764103",
"0.57514775",
"0.5718664",
"0.5715024",
"0.5715024",
"0.5715024",
"0.5715024",
"0.5715024",
"0.5715024",
"0.57001513",
"0.57001513",
"0.5692425",
"0.56764615",
"0.56740385",
"0.56648874",
"0.5660122",
"0.5648357",
"0.56427944",
"0.5636259",
"0.55595756",
"0.55406344",
"0.55403656",
"0.55206394",
"0.5514756",
"0.55004406",
"0.54924333",
"0.5486883",
"0.54802936",
"0.5473298",
"0.545037",
"0.5449666",
"0.54395604",
"0.543329",
"0.54224336",
"0.54076445",
"0.54021347",
"0.5399364",
"0.5398513",
"0.5388172",
"0.53863037",
"0.5379438",
"0.53537124",
"0.5341265",
"0.5334958",
"0.5321294",
"0.5309928",
"0.53073484",
"0.5297505",
"0.52953035",
"0.52888995",
"0.52868307",
"0.5285827",
"0.5275255",
"0.52709305",
"0.52692384",
"0.5264817",
"0.5246301",
"0.5243166",
"0.5240563",
"0.5239033",
"0.52375185",
"0.5236219",
"0.5233465",
"0.52203625",
"0.5217588",
"0.52133954",
"0.52125794",
"0.521002",
"0.52052015",
"0.52052015",
"0.5203761",
"0.5196912",
"0.51907855",
"0.5188893",
"0.5167419",
"0.51511323",
"0.5148902",
"0.5144586",
"0.5144251",
"0.5130569",
"0.51253533",
"0.51236516",
"0.51097584",
"0.5101541",
"0.51006204",
"0.5094719",
"0.50823665",
"0.5080222",
"0.50792086",
"0.50757396",
"0.50757396"
] |
0.0
|
-1
|
Search for a startup given a URL slug. Responds like GET /startups/:id.
|
def startup_search(options={})
get("1/startups/search", options)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def search\n if Config[\"ISEARCH\"]\n incremental_search\n else\n str = getstr('/')\n do_search NEXT, str\n end\n end",
"def find(slug)\n target_url = fetch_target_url(slug)\n\n fail(Errors::SlugNotFound, slug) unless target_url\n\n to_url(slug, target_url)\n end",
"def set_startup\n @startup = Startup.find(params[:id])\n end",
"def set_startup\n @startup = Startup.find(params[:id])\n end",
"def index\n @venues = Venue.where(nil)\n @venues = @venues.starts_with(params[:starts_with]) if params[:starts_with].present?\n if params[:starts_with].blank?\n @venues = Venue.order('name ASC')\n end\n end",
"def show_startup\n authorize! :investor_connect_with_startups, current_user\n # Only allow temporary investor account access to their suggested startups\n if [2367, 2375, 2435, 2436, 2437, 2438, 2459, 2466].include?(current_user.id)\n calculate_suggested_startup_completeness\n @startup = current_user.suggested_startups(1).first\n else\n @startup = Startup.find 319\n Relationship.suggest_connection(current_user, @startup, :startup_investor)\n end\n \n if @startup.blank?\n flash[:notice] = \"Thanks, you've reviewed all of the startups currently available to you.\"\n redirect_to :action => :index\n return\n end\n\n @checkin_history = Checkin.history_for_startup(@startup)\n @screenshots = @startup.screenshots.ordered\n\n @rating = Rating.new\n @rating.startup = @startup\n @rating.interested = false\n\n @instrument = @startup.instruments.first\n @measurements = @instrument.measurements.ordered_asc.all unless @instrument.blank?\n\n @checkins = @startup.checkins.ordered\n end",
"def find(slug)\n type = slug.to_s.demodulize.classify\n\n subclasses.find do |subclass|\n subclass.name.gsub(prefix, '') == type.to_s.gsub(prefix, '')\n end || raise(TypeError.new(type, types.to_sentence))\n end",
"def find_by_title(title)\n url = SEARCH_URL+\"#{URI.escape(title)}&first=yes\"\n Kinopoisk.fetch(url, proxies: @proxies, debug: @debug).headers['Location'].to_s.match(/\\/(\\d*)\\/$/)[1]\n end",
"def part_with_slug(part_slug)\n # self.parts is usually already eager loaded so we can now just grab\n # the first element matching the title we specified.\n self.parts.detect do |part|\n part.slug_matches?(part_slug)\n end\n end",
"def find_url\n @url = Url.find_by_short_url(params[:short_url])\n \n end",
"def by_slug(slug, conditions = {})\n Pages::Finder.by_slug(slug, conditions)\n end",
"def found_using_friendly_id?\n finder_slug\n end",
"def first_wa(collections)\n collections.find{|element| element.to_s.start_with?(\"wa\")}\nend",
"def show\n @search = RestaurantSearch.friendly.find(params[:id])\n end",
"def show\n @state = State.find_by_slug(params[:state_slug])\n end",
"def show\n @publishing_house = PublishingHouse.find_by_slug(params[:id])\n end",
"def get_by_slug(slug)\n record = @dao.search({ 'slug' => slug }, { limit: 1 })\n translate(record)\n end",
"def find_by_friendly_id(id); end",
"def all_startups(options={})\n get(\"1/startups\", options)\n end",
"def find(args)\n page = page_files.select {|pf| File.basename(pf) =~ /#{args}/i }.map {|pf| new(pf)}\n page = page.first\n end",
"def cellVenue\n @venues = Venue.where(id: params[:id]) if params[:id].present?\n @venues = Venue.starts_with(params[:starts_with]) if params[:starts_with].present?\n\n end",
"def show\n @step = Step.find_by_slug(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @step }\n end\n end",
"def index\n @schools = []\n @schools = School.starts_with(params[:starts_with]) if params[:starts_with].present?\n end",
"def set_launchstart\n @launchstart = Launchstart.find(params[:id])\n end",
"def show\n @team = Team.find_by_slug(params[:id])\n\n if @team.nil?\n raise ActionController::RoutingError.new('Not Found')\n end\n end",
"def find_by_short_url(short_url)\n Url.find_by_short_url(short_url)\n end",
"def find\n\t\tputs \"Enter keyword, EX: Mexican or Mex\"\n\t\tuserKeyword = gets.chomp.downcase.strip\n\t\trestaurants = Restaurant.saved_restaurants\n\t\tfound_restaurant_array = []\n\t\t\trestaurants.each do |rest|\n\t\t\tif rest.cuisine.include?(userKeyword)\n\t\t\t\tfound_restaurant_array << rest\n\t\t\tend\n\t\tend\n\t\tif !found_restaurant_array.empty?\n\t\toutput_restaurant_table(found_restaurant_array)\n\t\telse\n\t\t\toutput_action_footer(\"oops! could not find an entry\")\n\t\tend\n\tend",
"def search_for_example\n visit('/locations?keyword=alpha%20app')\n end",
"def create\n @startup = current_user.startups.build(startup_params)\n\n respond_to do |format|\n if @startup.save\n format.html { redirect_to startups_url, notice: 'listing was successfully created.' }\n format.json { render :index, status: :created, location: @startup }\n else\n format.html { render :new }\n format.json { render json: @startup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @category = Category.find_by(slug: params[:id])\nend",
"def show_by_name\n @pin = Pin.find_by_slug(params[:slug])\n render :show\n end",
"def find_resource(param)\n Chapter.find_by!(slug: param)\n end",
"def episode_by_slug(slug)\n # Query options\n options = {\n :content_type => 'episode',\n :include => 2,\n 'fields.slug' => parse_slug(slug)\n }\n\n # Query single episode with first matching slug\n episode = $delivery.entries(options).first\n\n # Parse to object or halt if not found\n halt 404 if episode.nil?\n Episode.new(episode)\n end",
"def find_article\n @article = Article.find_by(slug: params[:article_slug])\n end",
"def show\n @tool = Tool.find_by!(slug: params[:tool])\n end",
"def get_by_location\n \tlat = params[:lat]\n \tlng = params[:lng]\n \tnext_start = params[:next_start]\n \tshops = Hotpepper.search_location(lat, lng, next_start);\n \tset_to_results(shops);\n end",
"def search_festival_scrapping(list_festival_name, year)\n # try to find festival's data for each name\n list_festival_name.each do |festival_name|\n url = \"#{Rails.configuration.behaviour['scrapping']['base_url']}#{festival_name}/\"\n\n # First we ping the URL to see if it exists\n resp = Net::HTTP.get_response(URI.parse(url))\n next unless /20\\d/ =~ resp.code\n # then we scrap\n page = Nokogiri::HTML(open(url))\n # create Festival if necessary\n if @festival.instance_of?(Festival) && @festival.valid?\n festival = @festival\n else\n name = page.css('header.entry-header.wrapper h1 span').text\n short_name = name.gsub(/ 20\\d{2}$| festival/i, '')\n params = ActionController::Parameters.new(\n festival: {\n name: name,\n short_name: short_name,\n slug: festival_name,\n url: url,\n year: year\n }\n )\n festival = Festival.create(params.require(:festival).permit!)\n end\n\n # headliners\n page.css('.placeholder2 .f_headliner .f_artist').each do |artist|\n artist_name = artist.text\n slug = artist_name.strip\n .downcase.gsub(/\\A\\p{Space}*|\\p{Space}*\\z/, '')\n # Search Artist in database before creating it\n new_artist = Artist.create_if_not_found(artist_name, slug)\n next if !new_artist.valid? || festival.artists.include?(new_artist)\n festival.festivals_artists.create_headliner(new_artist)\n end\n\n # lineup\n page.css('.lineupguide ul li').each do |artist|\n artist_name = artist.text\n slug = artist_name.strip\n .downcase.gsub(/\\A\\p{Space}*|\\p{Space}*\\z/, '')\n # Search Artist in database before creating it\n new_artist = Artist.create_if_not_found(artist_name, slug)\n next if !new_artist.valid? || festival.artists.include?(new_artist)\n festival.artists << new_artist\n end\n\n # Save and return Festival\n if festival.instance_of?(Festival) && festival.valid? && festival.save\n @festival = festival\n end\n end\n end",
"def startup\n return Startup.where(:id => self.startup_id) if self.startup_id.present?\n return self.checkin.startup if self.checkin_id.present\n nil\n end",
"def show\n\t\tif params[:slug].present?\n\t\t\trecord = ShortenedUrl.where(:short_url => params[:slug]).first\n\t\t\tif record.present?\n\t\t\t\tredirect_to \"http://#{record.url}\"\n\t\t\tend\n\t\telse\n\t\t\trender :json => {success: 0, message: 'Error'}, status: 422\n\t\tend\n\tend",
"def set_site\n @site = Site.find_by slug: params[:slug]\n end",
"def select_station\n puts \"Enter station`s title: \"\n title = gets.chomp\n Station.all.select { |station| station.title == title }[0]\n end",
"def main_page\n find_by(url: 'http://class.rambler.ru/')\n end",
"def show\n slug = params.require(:slug).to_s.strip\n\n url = repository.find(slug)\n\n head(status: 301, location: url.target_url)\n end",
"def retrieve\n if params[:query] == \"\"\n flash[:Error] = \"Please Enter Query\"\n redirect_to search_path\n else\n params[:query] = params[:query].strip\n @urls = Url.custom_search(search_params)\n if !@urls.first\n flash[:Error] = \"Not Found Anything\"\n redirect_to search_path\n else\n render 'show'\n end\n end\n end",
"def lookup!(id_or_slug)\n lookup(id_or_slug) || (raise Mongoid::Errors::DocumentNotFound.new(self, id_or_slug))\n end",
"def show\n @home = true\n\n @city = City.find(params[:id])\n\n @search = {\n city: @city.id,\n smcd: params[:smcd],\n difficulty: params[:difficulty],\n season: params[:season]\n }\n # No comment...\n @search.delete :smcd if @search[:smcd] == \"all\"\n @search.delete :smcd unless @search[:smcd]\n @search.delete :difficulty if @search[:difficulty] == \"all\"\n @search.delete :difficulty unless @search[:difficulty]\n @search.delete :season if @search[:season] == \"all\"\n @search.delete :season unless @search[:season]\n\n @recipes = Recipe.where(@search) if @search\n @recipes = Recipe.where(city: @city) unless @search\n\n @currentURL = request.url\n end",
"def find_by_title(*opts)\n find_by_titles(opts).pages.first\n end",
"def icl_find( args )\n prefix = args.downcase\n @foodDB.foodbase.each_key do | item |\n check = item.downcase\n if (check.index(prefix) == 0)\n icl_print( @foodDB.get(item) )\n end\n end\n end",
"def find_station(input) #grab their input to find their station\n Station.find_by(stations: input)\n end",
"def method_for_find\n :find_by_slug!\n end",
"def resume_search\n if params[:resume_search].present?\n @resumes = get_all_resumes \n cand_name = params[:resume_search]\n cand_details = @resumes.where( :name => cand_name )\n if cand_details.present?\n render \"index\"\n else\n flash[:danger] = \"Name \\'#{cand_name}\\' could not found in our database.\"\n redirect_to :action => \"index\" \n end\n end\n end",
"def set_listing\n @listing = Listing.find_by_slug!(params[:id])\n end",
"def slug\n fetch[:slug]\n rescue NoMethodError\n nil\n end",
"def index\n @sites = Xmt::Press::Site.all.page(params[:page])\n unless params[:key].blank?\n key = /.*#{params[:key]}.*/\n @sites = @sites.where(title: key).page(params[:page])\n end\n end",
"def index\n # debugger\n if ! params[:search].blank?\n @ticket = Ticket.find_by slug: params[:search].downcase\n redirect_to ticket_path(@ticket) unless @ticket.nil?\n end\n @tickets = Ticket.all\n\n end",
"def find_unique_slug\n UniqueSlug.new(self).find_unique\n end",
"def index\n @startups = Startup.all\n @startups = Startup.order('created_at DESC').paginate(:page => params[:page], :per_page => 6)\n end",
"def search\n words = params[:query].split(/\\s+/).reject(&:blank?)\n url = nil\n\n case words.size\n when 1\n if words.first.starts_with?('@')\n user = find_users(words.first[1..-1]).only\n url = user_url(user) if user\n else\n project = find_projects(words[0]).only.try!(:sluggable)\n url = project_url(project) if project\n end\n when 2\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n url = project_environment_bugs_url(project, env) if env\n when 3\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n bug = env.bugs.find_by_number(words[2].to_i) if env\n url = project_environment_bug_url(project, env, bug) if bug\n when 4\n project = find_projects(words[0]).only.try!(:sluggable)\n env = find_environments(project, words[1]).only if project\n bug = env.bugs.find_by_number(words[2].to_i) if env\n occurrence = bug.occurrences.find_by_number(words[3].to_i) if bug\n url = project_environment_bug_occurrence_url(project, env, bug, occurrence) if occurrence\n end\n\n url ? render(text: url) : head(:ok)\n end",
"def find_drop(slug)\n Drop.find slug\n rescue Drop::NotFound\n not_found\n end",
"def find_drop(slug)\n Drop.find slug\n rescue Drop::NotFound\n not_found\n end",
"def findAirport(startCode)\n @airports.each do |airport|\n if(airport.code == startCode.to_s)\n return airport\n end\n end\n return \"Airport not found\"\n end",
"def show\n \tif params[:id].nil?\n \t\t# search all\n \telse\n \t\t# search specific id\n \t\t@id = params[:id]\n\t\tend\n end",
"def find_territory\n Territory.find_by_slug(params[:slug])\n end",
"def find\n puts params[:search_string]\n @results = Clientworkout.where(client_name: params[:search_string])\n #@results = Clientworkout.where('lower(client_name)=?' params[:search_string])\n end",
"def production_search\n system(\"clear\")\n puts \"====================================\"\n puts \"What show would you like to explore?\"\n puts \"====================================\"\n puts \"\"\n input = gets.strip\n if input == \"exit\"\n goodbye \n else\n #Creates hash with query results as keys and urls as values\n options = Scraper.new.show_search(input)\n if options.keys.size == 0\n begin\n raise SearchError\n rescue SearchError => error\n puts error.message\n end\n else\n #Displays query results\n options.keys.each.with_index(1) {|option, index| puts \"#{index}) \\t #{option}\"}\n puts \"Which result would you like to explore?\"\n input = gets.strip.to_i\n if input.between?(1,options.keys.size)\n selection = options[options.keys[input - 1]]\n #Scrapes and instantiates production object based on selection.\n show = Scraper.new.production(\"https://www.broadwayworld.com#{selection}\")\n show.print\n else\n puts \"Input error\"\n sleep(1)\n production_search\n end\n end\n continue_prompt\n end\n end",
"def find_by_friendly_id(id)\n first_by_friendly_id(id) or raise_not_found_exception(id)\n end",
"def lookup_url\n @config.lookup_opts[:url].sub('$:id$', @params[:id].to_s)\n end",
"def search_and_show_meal(title = 'Pizza Salami')\n click_on 'All Meals'\n fill_in('query', with: title)\n click_on('Search')\n sleep(2)\n\n results = find_all(:link, text: title)\n if results.empty?\n failed('No matching results could be found for search_and_show_meal!')\n else\n results.each do |result|\n complete(\"Search test has found #{result.text}!\")\n end\n\n if page.has_link?(text: title, exact_text: true)\n complete('At least one full match has been found')\n click_link(text: title, exact_text: true, match: :first)\n elsif page.has_link?(title)\n click_link(text: title, match: :first)\n complete('At least one part match has been found')\n else\n failed('No matched for the given search_and_show_meal parameter have been found')\n end\n\n end\n\n end",
"def show\n @link = Link.find_by_slug(params[:id])\n end",
"def show\n @college_video = CollegeVideo.all.find_by slug: (params[:id])\n end",
"def starting_school(schools)\n schools.find { |school| school.id == @starting_school_id }\n end",
"def show\n @interview = Interview.find_by_slug(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @interview }\n end\n end",
"def show\n @search = Search.find(params[:id])\n @search_run = SearchRun.new\n\n\t\t# if params[:search_result]\n\n # search_terms =\n # if params[:search_result][:use_description_terms] == '1'\n # @search.description.split(' ')\n # else\n # []\n # end\n\n # search_results = @search.scan(params[:search_result][:selector], search_terms)\n\n # search_run = SearchRun.new(search_url: @website.search_url, selector: params[:search_result][:selector])\n # @search.search_runs << search_run\n\n # search_results.each do |result|\n # url = result[:url]\n\n # url = @website.base_url + result[:url] if result[:url].start_with?('/')\n\n # search_run.search_run_results << SearchRunResult.new(text: result[:text], url: url)\n # end\n\t\t# end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @search }\n end\n end",
"def search_by_name\n puts 'Enter a name to search for'\n lookup_name = gets.chomp\n result = @search.name(lookup_name)\n puts \"\\n#{formatted_search_result(result)}\"\n rescue EntryNotFoundError => e\n puts e.message\n end",
"def find_by_param!(value, args={})\n param = permalink_options[:param]\n obj = find_by_param(value, args)\n raise ::ActiveRecord::RecordNotFound unless obj\n obj\n end",
"def load_results\n FindSalon::SalonSearch.new(user_location).resolve\n end",
"def friendly_find(slugged_id)\n model.friendly.find(slugged_id)\n end",
"def show\n req=\"category_id = \"+params[:id]\n @page_title = Category.find(params[:id]).name\n @sites = Site.where(req).paginate(page: params[:page])\n render 'sites/index'\n end",
"def search_results\n @individual = Individual.by_uid( params[:'names-search-uid'] )\n if @individual\n redirect_to display_path( @individual.uid )\n else\n redirect_to :search\n end\n end",
"def index\n # (This uses Squeel DSL syntax for where clauses)\n if params[:title_like]\n filter = \"%#{params[:title_like]}%\"\n @trainings = Training.where( [\"title LIKE ?\", filter] )\n .order( 'updated_at DESC', 'title' )\n else\n @trainings = Training.order( :title ).all\n end\n render status: 200, json: @trainings\n end",
"def find_scene(prefix)\n\t\t\treturn @scenes[prefix] if @scenes.include? prefix\n\n\t\t\tprefix = prefix.downcase\n\t\t\t@scenes.select{|id, scene|\n\t\t\t\tscene.name.downcase.start_with?(prefix)\n\t\t\t}.values.max_by{|s|\n\t\t\t\ts.name\n\t\t\t}\n\t\tend",
"def lookup(id_or_slug)\n id_or_slug = id_or_slug.to_s\n\n # find plan by a specific objectid\n result = where(:_id => id_or_slug).first if BSON::ObjectId.legal?(id_or_slug)\n result ||= find_by_slug(id_or_slug) if id_or_slug.present?\n\n # make sure the plan exists\n result\n end",
"def search_in_table!(name)\n if @klass.seo_use_id\n @klass.find(name)\n else\n @klass.find_by!(:seo_url => name)\n end\n end",
"def autocomplete_sn\n render :partial => 'autocomplete', :object => Scientificname.find(:all, :conditions => ['name ILIKE ?', params[:sn] + '%' ])\n end",
"def set_location\n @location = Location.find_by(slug: params[:slug])\n end",
"def search\n @search ||= exhibit.searches.first\n # @searches ||= exhibit.searches.published.where(slug: item_ids).sort do |a, b|\n # order.index(a.slug) <=> order.index(b.slug)\n # end\n end",
"def show\n redirect_to \"index\", alert: \"Debes introducir una ciudad\" if params[:query].blank?\n find_results\n\n # FIXME: no se visualiza, test falla\n redirect_to \"index\", alert: \"No se han encontrado centros\" if @schools.nil?\n end",
"def find_by_url(url)\n find_by(url: convert_url(url))\n end",
"def index\n @hirelings = if params['hire_class'].present?\n Hireling.where(hire_class: params['hire_class'])\n else\n Hireling.all\n end\n end",
"def before_GET(req)\n super\n @term = term(req)\n @title = \"Search for #{term(req)}\"\n end",
"def set_restoran\n @restoran = Restoran.find_by_slug!(params[:id])\n end",
"def find_by_permalink(permalink, options={})\n find(permalink, find_options_for_visible(options))\n=begin \n unless result = find(:first, find_options_for_find_by_permalink(permalink))\n raise ActiveRecord::RecordNotFound, \"Couldn't find #{name} with ID=#{permalink}\"\n end\n result.friendly_id_status.name = permalink if result\n result\n=end \n end",
"def get_started_page\n get_started_pages.first\n end",
"def select_slug(slug)\n subset = @config['comics'].select {|c| c['slug'] == slug}\n\n return subset\n end",
"def find_article(title)\n path_to_article \"/wiki/Special:Search?search=#{title}\"\n end",
"def set_snippet\n @snippet = Snippet.find_by slug: params[:slug]\n end",
"def slug\n @slug ||= begin\n raw = self['identifier'].find { |id| id.start_with?('slug:') }\n Spot::Identifier.from_string(raw).value unless raw.nil?\n end\n end",
"def set_event\n @event = Event.find_by!(slug: params[:slug])\n rescue ActiveRecord::RecordNotFound\n redirect_to signup_index_path, notice: t(:event_not_found)\n end",
"def index\n @launchstarts = Launchstart.all\n end",
"def find_by_slug_id(id)\n if Moped::BSON::ObjectId.legal?(id)\n Topic.find(id)\n else\n Topic.where(:slug_pretty => id.parameterize).first\n end\n end"
] |
[
"0.54361725",
"0.53489435",
"0.5294611",
"0.5292878",
"0.5270016",
"0.5260653",
"0.52603585",
"0.52084076",
"0.52073455",
"0.51507175",
"0.5139186",
"0.5105882",
"0.5086841",
"0.50842106",
"0.50469387",
"0.50155705",
"0.49937168",
"0.49776912",
"0.49465457",
"0.49241126",
"0.49213988",
"0.49179897",
"0.4915066",
"0.4905339",
"0.4898637",
"0.4888463",
"0.48867148",
"0.4879104",
"0.4844876",
"0.48329937",
"0.4831052",
"0.48309785",
"0.48285973",
"0.4821903",
"0.48216757",
"0.4814536",
"0.48130092",
"0.48107055",
"0.4798843",
"0.4788773",
"0.47731182",
"0.47707883",
"0.4764111",
"0.47629192",
"0.47592148",
"0.4754502",
"0.4745569",
"0.47442138",
"0.4737428",
"0.47301382",
"0.4726725",
"0.469658",
"0.4690682",
"0.46902236",
"0.4687837",
"0.46864724",
"0.46863335",
"0.46857315",
"0.4678671",
"0.4678671",
"0.46784922",
"0.46686894",
"0.46528873",
"0.4652043",
"0.46375695",
"0.46375322",
"0.46361026",
"0.46359423",
"0.46280757",
"0.46223578",
"0.4608081",
"0.46074045",
"0.4602493",
"0.4597673",
"0.45971644",
"0.45970815",
"0.459541",
"0.459497",
"0.4593962",
"0.45911628",
"0.45893988",
"0.45891973",
"0.45882332",
"0.4587794",
"0.45860922",
"0.45834395",
"0.4583059",
"0.45816594",
"0.45800886",
"0.45706895",
"0.45706114",
"0.45561972",
"0.45538327",
"0.45485926",
"0.4545946",
"0.45457783",
"0.45454296",
"0.4544681",
"0.4544403",
"0.45428613"
] |
0.68186027
|
0
|
Returns a company's startup roles. If direction is outgoing, then it returns the companies which the given company is tagged in. If direction is incoming, or omitted, then it returns the users and companies which are tagged in the given company. Results are paginated.
|
def startup_roles(id, options={})
get("1/startups/#{id}/roles", options)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @roles = @company.roles.ordered\n @roles = @roles.search(params[:sSearch]) if params.try(:[], :sSearch).present?\n @roles = @roles.page(page).per(per_page)\n end",
"def roles_instance(company)\r\n company_roles.find_by(user: self, company: company)\r\n end",
"def index\n @company = Company.find(params[:company_id])\n @users = @company.users.where(\"role > 0\").paginate(:page => params[:page], :per_page => 15)\n end",
"def index\n if params[:company_id]\n @service_categories = ServiceCategory.where(:company_id => params[:company_id]).order(:order, :name)\n else\n if current_user.role_id == Role.find_by_name('Super Admin').id\n @service_categories = ServiceCategory.where(company_id: Company.where(owned: false).pluck(:id)).order(:order, :name)\n else\n @service_categories = ServiceCategory.where(:company_id => current_user.company_id).order(:order, :name)\n end\n end\n end",
"def get_roles(options = {})\n request_params = {\n per_page: options.fetch(:per_page, nil),\n page: options.fetch(:page, nil),\n include_totals: options.fetch(:include_totals, nil),\n name_filter: options.fetch(:name_filter, nil)\n }\n get roles_path, request_params\n end",
"def user_role_contacts(achived,sort_order)\n remaining_roles = []\n merge_roles = remove_county_or_country_roles\n\n merge_roles.each do |role|\n remaining_roles << contact_types[role]\n end\n\n remaining_roles = remaining_roles.flatten\n contacts = Contact.where(contact_type: { '$in': remaining_roles }).archived(achived).all.order_by(sort_order)\n contacts\n end",
"def get_external_roles\n get(\"#{url_base}/external_role_map/all?#{dc}\")[\"data\"]\n end",
"def index\n if !current_user\n @companies = Company.all.limit(5)\n else\n if current_user.role == 'user'\n @companies = Company.all.limit(5)\n else\n @companies = Company.where(user: current_user)\n end\n end\n end",
"def index\n @company = Company.find(params[:company_id])\n @roles = Role.where(:company_id => @company.id)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @roles }\n end\n end",
"def get_contacts_for_roles(achived,sort_order)\n return all_contacts(achived,sort_order) unless roles_in_contact_types?\n\n unless county_and_country_coordinators?\n return county_and_country_contacts(achived,sort_order)\n end\n\n return user_role_contacts(achived,sort_order)\n end",
"def collect_anniversary_roles\n role_names = [\"Company Admin\", \"Executive\"]\n roles = []\n role_names.each do |role_name|\n roles << Role.find_by_long_name(role_name)\n end\n return roles\n end",
"def companies\n company_ids = company_affiliations.with_access.map(&:company_id)\n Company.where(:id.in => company_ids)\n end",
"def roles_for_user login\n cu = config['user']\n role_alias = cu[login] || cu[nil]\n role_alias = [ role_alias ] unless Array === role_alias\n roles = [ ]\n role_alias.each do | ra |\n roles.concat config['roles'][ra] || [ ra ]\n end\n roles.uniq!\n roles\n end",
"def current_company\n if user_signed_in?\n @company = current_user.company\n @folders = @company.folders\n if current_user.admin?\n # excluding self\n @users = @company.users\n end\n end\n end",
"def index\r\n @q = SearchParams.new(params[:search_params] || {})\r\n @roles = Role.default_where(@q.attributes(self)).page(params[:page]).per(10)\r\n end",
"def index\n if current_user.admin?\n @companies = Company.all.order(:name).page(params[:page]).per(10)\n else\n @companies = current_user.company\n end\n end",
"def with_access_to_teams_with_any_role\n if c_level?\n organization.teams\n else\n TeamMember.includes(:team).where(user: self).collect(&:team)\n end\n end",
"def list(\n filter,\n *args,\n deadline: nil\n )\n return @roles.list(\n filter,\n *args,\n deadline: deadline,\n )\n end",
"def index\n if params[:condition] && params[:role]\n @users = User.with_role(params[:role]).tagged_with(params[:condition])\n elsif params[:condition]\n @users = User.tagged_with(params[:condition])\n elsif params[:role]\n @users = User.with_role(params[:role])\n else\n @users = User.all\n end\n\n end",
"def list(\n filter,\n *args,\n deadline: nil\n )\n req = V1::RoleListRequest.new()\n req.meta = V1::ListRequestMetadata.new()\n page_size_option = @parent._test_options[\"PageSize\"]\n if page_size_option.is_a? Integer\n req.meta.limit = page_size_option\n end\n if not @parent.snapshot_time.nil?\n req.meta.snapshot_at = @parent.snapshot_time\n end\n\n req.filter = Plumbing::quote_filter_args(filter, *args)\n resp = Enumerator::Generator.new { |g|\n tries = 0\n loop do\n begin\n plumbing_response = @stub.list(req, metadata: @parent.get_metadata(\"Roles.List\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + +@parent.jitterSleep(tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n tries = 0\n plumbing_response.roles.each do |plumbing_item|\n g.yield Plumbing::convert_role_to_porcelain(plumbing_item)\n end\n break if plumbing_response.meta.next_cursor == \"\"\n req.meta.cursor = plumbing_response.meta.next_cursor\n end\n }\n resp\n end",
"def index\n # current_user.companies.\n @incidents = Incident.all\n end",
"def index\n @acceptable_contact_roles = AcceptableContactRole.all\n end",
"def roles\n ::Syncano::QueryBuilder.new(self, ::Syncano::Resources::Role)\n end",
"def list\n # We don't use pagination here since we want to display the roles in a\n # nice tree. Additionally, there won't be more than ~100 roles in a\n # normal scenario anyway - far less!\n @roles = Role.find(:all)\n end",
"def query_roles(options = nil)\n policy = create_policy(options, AdminPolicy, default_admin_policy)\n command = AdminCommand.new\n command.query_roles(@cluster, policy)\n end",
"def organization_roles\n roles = []\n\n if Figaro.env.respond_to?(:cf_organization_add_manager) &&\n Figaro.env.cf_organization_add_manager.downcase == 'true'\n roles << 'manager'\n end\n\n if Figaro.env.respond_to?(:cf_organization_add_billing_manager) &&\n Figaro.env.cf_organization_add_billing_manager.downcase == 'true'\n roles << 'billing_manager'\n end\n\n if Figaro.env.respond_to?(:cf_organization_add_auditor) &&\n Figaro.env.cf_organization_add_auditor.downcase == 'true'\n roles << 'auditor'\n end\n\n roles\n end",
"def roles\n @users = User.order(\"user_name\").all\n end",
"def index\n @core_user_roles = Core::UserRole.find_mine(params).paginate(page: params[:page])\n end",
"def index\n client_application_id = current_user.client_application_id.to_s\n @roles = Role.where(client_application_id: client_application_id)\n end",
"def admin_for_companies\n get(\"/organizationalEntityAcls?q=roleAssignee&role=ADMINISTRATOR&state=APPROVED&count=100\")\n end",
"def collaborators\n collab_roles = accepted_roles.for_name(\"collaborator\")\n User.find_by_sql(\"SELECT * FROM users INNER JOIN roles_users ON roles_users.user_id = users.id WHERE roles_users.role_id IN (12)\")\n end",
"def directory_roles()\n return MicrosoftGraph::DirectoryRoles::DirectoryRolesRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def index\n\t\tif current_user.user_role.code == 'admin'\n\t\t\t@companies = Company.all\n\t\telse\n\t\t\t@companies = current_user.created_companies\n\t\tend\n\t\tmake_breadcrumbs\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.json { render json: @companies }\n\t\tend\n\tend",
"def list(filter=KalturaNotImplemented, pager=KalturaNotImplemented)\n\t\t\tkparams = {}\n\t\t\t# A filter used to exclude specific types of user roles\n\t\t\tclient.add_param(kparams, 'filter', filter);\n\t\t\t# A limit for the number of records to display on a page\n\t\t\tclient.add_param(kparams, 'pager', pager);\n\t\t\tclient.queue_service_action_call('userrole', 'list', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def list_roles(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'ListRoles'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :marker\n\t\t\targs[:query]['Marker'] = optional[:marker]\n\t\tend\n\t\tif optional.key? :max_items\n\t\t\targs[:query]['MaxItems'] = optional[:max_items]\n\t\tend\n\t\tself.run(args)\n\tend",
"def index\n @cms_roles = Cms::Role.all\n end",
"def roles\n roles_from_users\n end",
"def company_employee_list(company_id)\n roles = Role.where(company_id: company_id)\n workers = []\n User.where(id: roles.pluck(:user_id).uniq).each do |w|\n workers.push(\n id: w.id,\n email: w.email,\n roles: roles.where(user_id: w.id).select(:id, :name)\n )\n end\n workers\n end",
"def authorizations_for(role)\n auth_roles = roles.find(:all, :joins => :role, :include => :authorizations, :conditions => { \"roles.name\" => role.to_s })\n return nil if auth_roles.empty?\n auth_roles.collect(&:authorizations).flatten.compact\n end",
"def index\n @roles = @vendor.roles.vendor_only # TODO change to roles\n end",
"def index\n @roles = Role.page params[:page]\n end",
"def index\n\t\tif session[:role] == \"admin\"\n\t\t\t@companies = Company.all\n\t\telse\n\t\t\t@companies = Company.where({approved: true})\n\t\tend\n\tend",
"def list_employee_roles(order: nil,\n limit: nil,\n batch_token: nil)\n # Prepare query url.\n _query_builder = config.get_base_uri\n _query_builder << '/v1/me/roles'\n _query_builder = APIHelper.append_url_with_query_parameters(\n _query_builder,\n 'order' => order,\n 'limit' => limit,\n 'batch_token' => batch_token\n )\n _query_url = APIHelper.clean_url _query_builder\n\n # Prepare headers.\n _headers = {\n 'accept' => 'application/json'\n }\n\n # Prepare and execute HttpRequest.\n _request = config.http_client.get(\n _query_url,\n headers: _headers\n )\n OAuth2.apply(config, _request)\n _response = execute_request(_request)\n\n # Return appropriate response type.\n decoded = APIHelper.json_deserialize(_response.raw_body)\n _errors = APIHelper.map_response(decoded, ['errors'])\n ApiResponse.new(\n _response, data: decoded, errors: _errors\n )\n end",
"def index\n if (current_user.role == \"customer\" || current_user.role == \"supervisor\")\n if params[:org_id].present?\n add_breadcrumb 'Organizations', 'organizations_path'\n add_breadcrumb \"#{Organization.where(:id => params[:org_id])[0].company_name}\", '#' \n add_breadcrumb \"Contacts\", 'organization_contacts_path(:org_id => \"#{params[:org_id]}\")'\n @organization_contacts = OrganizationContact.where(:delflag => false, :organization_id => \"#{params[:org_id]}\").paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organization_contacts }\n end\n else\n @organization_contacts = OrganizationContact.paginate(:page => params[:page], :per_page => 5)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organization_contacts }\n end\n end \n else\n redirect_to error_users_path and return\n end\n end",
"def roles\n\t\t\t\tProxy.new connection, 'role-strategy/strategy'\n\t\t\tend",
"def list_org\n __log_activity\n __debug_route\n prm = paginator.initial_parameters.except(*Paginator::NON_SEARCH_KEYS)\n org = current_org and current_org!(prm, org)\n terms = prm.delete(:like)\n found = { list: get_accounts(*terms, **prm) }\n @list = paginator.finalize(found, **prm)\n opt = { locals: { name: org&.label } }\n respond_to do |format|\n format.html { render 'account/index', **opt }\n format.json { render 'account/index', **opt }\n format.xml { render 'account/index', **opt }\n end\n end",
"def get_roles(email)\n raise NotImplementedError, \"Please implement this in your concrete class\"\n end",
"def index\n @users = User.preload(:roles).all\n\n @users = filter_records_by(relation: @users)\n @users = simple_search(relation: @users)\n @users = sort_records(relation: @users)\n @users = filter_by_pagination(relation: @users)\n end",
"def index\n if current_user.seller?\n @conversations = current_user.seller.company.conversations\n else\n @conversations = current_user.conversations\n end\n end",
"def get_user_roles\n @roles = @user.roles.pluck(:name)\n render json: @roles\n end",
"def all_organisations_in_city(city)\n sparql = \"\n SELECT DISTINCT ?uri ?label\n WHERE \n {\n VALUES ?city { \\\"#{city}\\\" }\n GRAPH <http://data.artsapi.com/graph/organisations> {\n ?uri <http://data.artsapi.com/def/arts/locationCity> ?city .\n ?uri <http://www.w3.org/2000/01/rdf-schema#label> ?label .\n }\n }\n \"\n\n results = User.current_user.within { Tripod::SparqlClient::Query.select(sparql) }\n\n results.map { |r| [r[\"uri\"][\"value\"], r[\"label\"][\"value\"]] }\n end",
"def roles\n users.map { |item| item['roles'] }.flatten.uniq\n end",
"def advisor_companies\n companies.where(_type: AdvisorCompany)\n end",
"def taggable_ministerial_roles_container\n Rails.cache.fetch(taggable_ministerial_roles_cache_digest, expires_in: 1.day) do\n MinisterialRole.with_translations.with_translations_for(:organisations).alphabetical_by_person.map do |role|\n [\"#{role.name}, #{role.organisations.map(&:name).to_sentence} (#{role.current_person_name})\", role.id]\n end\n end\n end",
"def get_sale_agents_names(role)\n t = get_sale\n\n if !t\n return \"\"\n end\n\n if role == SaleAgent::ROLE_SELLING_AGENT\n t.get_selling_agents_names\n elsif role == SaleAgent::ROLE_SELLER_OR_HOLDER\n t.get_sellers_or_holders_names\n elsif role == SaleAgent::ROLE_BUYER\n t.get_buyers_names\n end\n end",
"def list(*args)\n params = args.extract_options!\n normalize! params\n\n response = if (user_name = params.delete(\"user\"))\n get_request(\"/users/#{user_name}/orgs\", params)\n else\n # For the authenticated user\n get_request(\"/user/orgs\", params)\n end\n return response unless block_given?\n response.each { |el| yield el }\n end",
"def index\n @companies = NewCompany.where(user: current_user)\n end",
"def index\n @company = Company.all\n if session[:group] == \"admin\"\n if params[:fillter]\n @travellers = Traveller.search(params[:fillter]).order(\"created_at DESC\").page(params[:page])\n else\n @travellers = Traveller.order(:name).page(params[:page])\n end\n else\n @company = Company.where(id:session[:company_id])\n if params[:fillter]\n @travellers = Traveller.search(params[:fillter],session[:company_id]).order(\"created_at DESC\").page(params[:page])\n else\n @travellers = Traveller.where(company_id:session[:company_id]).order(:name).page(params[:page])\n end \n end\n # if params[:search]\n # @travellers = Traveller.search(params[:search]).order(\"created_at DESC\").page(params[:page])\n # else\n # @travellers = Traveller.order(:name).page(params[:page])\n # end\n end",
"def roles\n self.dig_for_array(\"roles\")\n end",
"def index\n @users = BigAuth::User.paginate(:page => params[:page], :per_page => 100)\n @roles = BigAuth::Role.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @big_auth_users }\n end\n end",
"def contacts\n @contacts = Employee.by_company_id(params[:company_id]).by_search(params[:search]).by_contacts(current_user).paginate :page => params[:page]\n @active_employers = current_user.employers.active_employers.all\n end",
"def all\n endpoint = 'Companies'\n response = JSON.parse(@client.get(endpoint).body)\n companies = response.key?('Items') ? response['Items'] : []\n companies.map { |attributes| Unleashed::Company.new(@client, attributes) }\n end",
"def list\n @roles = Role.all(:include => [:groups, :users])\n end",
"def list(*args)\n params = arguments(args).params\n\n if (user_name = params.delete('user'))\n response = get_request(\"/users/#{user_name}/orgs\", params)\n elsif args.map(&:to_s).include?('every')\n response = get_request('/organizations', params)\n else\n # For the authenticated user\n response = get_request('/user/orgs', params)\n end\n return response unless block_given?\n response.each { |el| yield el }\n end",
"def hubssolib_get_user_roles\n user = self.hubssolib_current_user\n user ? user.user_roles.to_authenticated_roles : nil\n end",
"def get_nodes_by_role(role, includeme=true, options={})\n options = {\n :search_string => role,\n :include_me => includeme,\n :order => [:role],\n :safe_deref => nil,\n :current_node => nil,\n :one_or_all => :all\n }.merge(options)\n opsit_search(options)\n end",
"def index\n @company_users = CompanyUser.all\n end",
"def signed_in_with_roles(user)\n signed_in_with_organization_admin_role(user) if user.has_cached_role? :organization_admin, :any\n signed_in_with_organizer_role(user) if user.has_cached_role? :organizer, :any\n signed_in_with_cfp_role(user) if user.has_cached_role? :cfp, :any\n signed_in_with_info_desk_role(user) if user.has_cached_role? :info_desk, :any\n signed_in_with_volunteers_coordinator_role(user) if user.has_cached_role? :volunteers_coordinator, :any\n signed_in_with_track_organizer_role(user) if user.has_cached_role? :track_organizer, :any\n common_abilities_for_roles(user)\n end",
"def list_catalogs 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_list_catalogs_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::Retail::V2::ListCatalogsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def advisor_companies\n Company.where(:id.in => advisor_company_ids)\n end",
"def all(options = {})\n request = if options.delete(:recursive) == false\n options[\"memberships\"] = true\n else\n options[\"all\"] = true\n end\n if filter = options.delete(:filter)\n filter = [filter] unless filter.is_a?(Array)\n options[\"filter\"] = filter.map{ |obj| cast(obj, :roleid) }\n end\n\n result = JSON.parse(self[options_querystring options].get)\n if result.is_a?(Hash) && ( count = result['count'] )\n count\n else\n host = Conjur::Authz::API.host\n result.collect do |item|\n if item.is_a?(String)\n Role.new(host, self.options)[Conjur::API.parse_role_id(item).join('/')]\n else\n RoleGrant.parse_from_json(item, self.options)\n end\n end\n end\n end",
"def get_all_conversations\n response = RestClient::Request.execute method: :get,\n url: URL,\n user: USERNAME,\n password: PASSWORD,\n headers: {params: {pageSize: OBJECTS_PER_PAGE, page:ARGV[1]}},\n :content_type => :json,\n :accept => :json\n JSON(response)['conversations'][396..-1]\n end",
"def get_default_state_education_agency_roles\n [:COUNSELOR, :INSTRUCTIONAL_COORDINATOR, :SPECIALIST_CONSULTANT, :STUDENT_SUPPORT_SERVICES_STAFF, :SUPERINTENDENT]\n end",
"def roles\n response[\"roles\"]\n end",
"def get_roles_for_user_in_domain(name, domain)\n model.model['g']['g'].rm.get_roles(name, domain)\n end",
"def index\n @org_roles = OrgRole.all\n end",
"def list\n\n @roles = Role.find(:all, :order => 'name')\n\n end",
"def show\n @roles = Role.all\n @user.build_contact if @user.contact.nil?\n end",
"def company_role?(role, company)\r\n company_roles.with_role(role).where(company: company, status: 1).exists?\r\n end",
"def index\n\n # http://localhost:3000/api/users?online=false&jurist=false&lawyer=true\n\n exception_roles = [:admin, :blocked]\n\n @users = User.includes(:roles).where.not(roles: {name: exception_roles }).includes(:cities)\n\n if param? params[:online]\n\n @users = @users.where(online: true)\n\n end\n\n params_array = []\n\n # city = nil\n\n # if param? params[:city_id]\n\n # city = City.find params[:city_id]\n\n # end \n\n if param? params[:lawyer]\n\n params_array << :lawyer\n\n end\n\n if param? params[:jurist]\n \n params_array << :jurist\n\n end\n\n if param? params[:client]\n \n params_array << :client\n\n end\n\n if params_array.size > 0\n\n @users = @users.includes(:roles).where(roles: {name: params_array })\n\n end\n \n if params[:offset]\n\n collection = api_paginate(@users) do |param_collection|\n\n ActiveModel::SerializableResource.new(\n\n param_collection.to_a,\n\n set_render_options\n )\n\n end \n\n render json: collection\n\n else\n\n render( {json: @users}.merge set_render_options )\n\n end \n\n end",
"def index\n @invoced_companies = InvocedCompany.all\n end",
"def organization_teams\n get(\"/organizations/#{@default_org_slug}/teams/\")\n end",
"def index\n @domains = Domain.where(:role=>1)\n @domain = Domain.where(:role=>0)\n end",
"def index\n @companies = current_user.companies.paginate(:page => 1, :page => params[:page], :order => \"name DESC\")\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @companies }\n end\n end",
"def account_list\n return [] unless company\n [company] + company.sibling_accounts\n end",
"def index\n @cas_users = CasUser.all\n end",
"def companies\n\t\tEmpresa.all\n\tend",
"def index\n @user_company_mappings = UserCompanyMapping.all\n end",
"def all\n @roles = Array.new\n @connection.deploys.all.each do |deploy|\n deploy.roles.each do |role|\n @roles << role\n end\n end\n @roles\n end",
"def roles\n return proposed_snapshot.roles if proposed? \n return active_snapshot.roles if active?\n []\n end",
"def users\n company_ids = [self.id]\n company_ids += advisor_company_ids if advised?\n\n user_ids = UserAffiliation.where(:company_id.in => company_ids).with_access.only(:user_id).map(&:user_id)\n User.where(:id.in => user_ids).order_by(created_at: :asc)\n end",
"def list(from: :unset, to: :unset, from_carrier: :unset, to_carrier: :unset, from_country_code: :unset, to_country_code: :unset, branded: :unset, verified_caller: :unset, has_tag: :unset, start_time: :unset, end_time: :unset, call_type: :unset, call_state: :unset, direction: :unset, processing_state: :unset, sort_by: :unset, subaccount: :unset, abnormal_session: :unset, limit: nil, page_size: nil)\n self.stream(\n from: from,\n to: to,\n from_carrier: from_carrier,\n to_carrier: to_carrier,\n from_country_code: from_country_code,\n to_country_code: to_country_code,\n branded: branded,\n verified_caller: verified_caller,\n has_tag: has_tag,\n start_time: start_time,\n end_time: end_time,\n call_type: call_type,\n call_state: call_state,\n direction: direction,\n processing_state: processing_state,\n sort_by: sort_by,\n subaccount: subaccount,\n abnormal_session: abnormal_session,\n limit: limit,\n page_size: page_size\n ).entries\n end",
"def get_sites(container_types)\n @response = client.request :con, :get_content_services_by_container_type5 do\n soap.element_form_default = :unqualified \n soap.namespaces[\"xmlns:login\"] = 'http://login.ext.soap.yodlee.com'\n \n soap.body = {\n :cobrand_context => cobrand_context,\n :container_types => {\n :elements => container_types\n },\n :req_specifier => 16 # grab login forms\n }\n end\n \n @sites = @response.to_xml\n response_xml = @response.to_xml\n parse_response(response_xml)\n end",
"def find_contacts_menu_advanced\n if session[SELECTED_CONTACTS] == nil\n session[SELECTED_CONTACTS] = []\n end\n @contacts = session[SELECTED_CONTACTS]\n @role_types = RoleType.find(:all, :order => 'role_type_desc')\n end",
"def roles\r\n @roles ||= user_roles.map(&:name)\r\n end",
"def company_role_with_any_status?(role, company)\r\n company_roles.with_role(role).where(company: company).exists?\r\n end",
"def list_org\n @users = User.where(organization: true)\n\n render \"list_org\"\n end",
"def find_organizations\n Organization.all\n end",
"def pass_on_roles\n r = self.all_roles\n if self.has_access?(:superadmin)\n r = Role.get(Access.roles(:all_users))\n elsif self.has_access?(:admin)\n r = Role.get(Access.roles(:admin_roles))\n elsif self.has_access?(:centeradm)\n r = Role.get(Access.roles(:center_users))\n end\n return (r.is_a?(Array) ? r : [r])\n end",
"def pass_on_roles\n r = self.all_roles\n if self.has_access?(:superadmin)\n r = Role.get(Access.roles(:all_users))\n elsif self.has_access?(:admin)\n r = Role.get(Access.roles(:admin_roles))\n elsif self.has_access?(:centeradm)\n r = Role.get(Access.roles(:center_users))\n end\n return (r.is_a?(Array) ? r : [r])\n end"
] |
[
"0.51911014",
"0.50654566",
"0.4931237",
"0.48948213",
"0.46904027",
"0.46797135",
"0.46786702",
"0.45831951",
"0.45385292",
"0.4533901",
"0.45325634",
"0.44519255",
"0.44473284",
"0.4433605",
"0.4422826",
"0.43336686",
"0.43222022",
"0.4317427",
"0.43055034",
"0.43050846",
"0.4292843",
"0.42726448",
"0.42643934",
"0.4258548",
"0.42469835",
"0.423647",
"0.42325222",
"0.42321005",
"0.4217397",
"0.42125574",
"0.41994518",
"0.41976768",
"0.41933164",
"0.41827747",
"0.4182504",
"0.4174506",
"0.41740808",
"0.41638896",
"0.41602433",
"0.41493633",
"0.41454723",
"0.4145113",
"0.41449207",
"0.4143585",
"0.41418177",
"0.41313356",
"0.411553",
"0.41076463",
"0.4067782",
"0.40677264",
"0.4058766",
"0.40483388",
"0.40420398",
"0.40402463",
"0.40364915",
"0.40338147",
"0.40320894",
"0.40308928",
"0.4030423",
"0.40296128",
"0.40271908",
"0.402044",
"0.40144676",
"0.4008408",
"0.40034842",
"0.39917216",
"0.39890882",
"0.39885926",
"0.39882275",
"0.39880762",
"0.3986501",
"0.3982119",
"0.39758304",
"0.39751068",
"0.39703894",
"0.39654487",
"0.39615002",
"0.39609784",
"0.39465716",
"0.394655",
"0.39453867",
"0.39416564",
"0.39386347",
"0.39379612",
"0.39352542",
"0.39306852",
"0.39301485",
"0.39272666",
"0.39227864",
"0.3921666",
"0.39181098",
"0.3916153",
"0.39111072",
"0.39091763",
"0.39085862",
"0.39043117",
"0.39034545",
"0.39033267",
"0.3901754",
"0.3901754"
] |
0.4696573
|
4
|
will update the settings
|
def updateNotifications(data)
self.comment_status = data[:comment_status].to_i
self.experience_status = data[:experience_status].to_i
self.experience_p_status = data[:experience_p_status].to_i
self.feelike_status = data[:feelike_status].to_i
self.follows_status = data[:follows_status].to_i
save
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update_settings\n end",
"def update_settings(settings)\n @bridge.update_settings(settings)\n end",
"def update\n\n ok = true\n # Save settings\n @setting = Setting.get_settings\n if @setting.update(settings_params)\n # Notify to the music server the settings change\n execute_music_cmd_check_error(@setting.errors , :reload_settings)\n end\n\n if @setting.errors.any?\n render_edit\n else\n redirect_to root_path\n end\n\n end",
"def update_settings(opts = {})\n update(Settings, opts)\n end",
"def update\n if @settings.blank?\n flash.now[:alert] = I18n.t('admin.settings.edit.failure.bootstrap')\n render :show and return\n end # if\n\n result = @settings.inject(true) do |memo, setting|\n if params['settings'].has_key? setting.name\n memo &&= setting.update_attributes :value => setting.cast_value(params['settings'][setting.name])\n end # if\n end # result\n\n if result\n flash[:notice] = 'Settings were successfully updated.'\n redirect_to admin_settings_path\n else\n render :show\n end # if-else\n end",
"def update\n save_setting('program_name', Setting::NAME_CURR_PROGRAM_NAME)\n save_setting('timelapse_mode', Setting::NAME_TIMELAPSE_MODE)\n save_setting('interval', Setting::NAME_INTERVAL)\n save_setting_with('sensor_proximity', Setting::NAME_SENSOR_PROXIMITY, params['sensor_proximity'].include?('active') ? \"1\" : \"0\") if params['sensor_proximity']\n save_setting_with('sensor_vibration', Setting::NAME_SENSOR_VIBRATION, params['sensor_vibration'].include?('active') ? \"1\" : \"0\") if params['sensor_vibration']\n save_setting('sensor_time_between_photos', Setting::NAME_SENSOR_TIME_BETWEEN_PHOTOS)\n\n head :ok\n end",
"def update_settings hash\n update settings: settings.merge(hash)\n save\n end",
"def update\n # Save the settings via the concern.\n save_settings\n\n # Reload the settings.\n get_settings\n render :index\n end",
"def update_settings\n setting = company.setting_fallback\n RoomSetting.delete(setting.room_settings)\n setting.send(:create_room_settings)\n end",
"def update_default\n update_players_settings\n update_game_settings\n end",
"def update_all\n @settings = Setting.update(params[:settings].keys, params[:settings].values).reject { |p| p.errors.empty? }\n if @settings.empty?\n flash[:notice] = \"settings updated\"\n redirect_to general_settings_url\n else\n render :action => \"general\"\n end\n end",
"def update\n if current_user.full_name == \"Default Admin\"\n Shoppe::Setting.update_from_hash(params[:settings].permit!)\n redirect_to :settings, :notice => t('shoppe.settings.update_notice')\n else\n if Shoppe.settings.demo_mode?\n raise Shoppe::Error, t('shoppe.settings.demo_mode_error')\n end\n Shoppe::Setting.update_from_hash(params[:settings].permit!)\n redirect_to :settings, :notice => t('shoppe.settings.update_notice')\n end\n end",
"def edit_or_update_settings\n @title = 'Ustawienia'\n return unless request.post?\n params[:setting].each do |slug, value|\n setting = @settings.detect {|s| s.slug == slug}\n setting.update_attributes(:value => value) if setting\n end\n flash.now[:notice] = 'Ustawienia uaktualnione'\n rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotSaved\n flash.now[:alert] = 'Wystąpił błąd podczas aktualizacji ustawień'\n end",
"def set_setting\n end",
"def settings\n end",
"def update\n\t\t\n\t\tend",
"def update!(**args)\n @car_settings_capabilities = args[:car_settings_capabilities] if args.key?(:car_settings_capabilities)\n @reissue_query_after_music_setup = args[:reissue_query_after_music_setup] if args.key?(:reissue_query_after_music_setup)\n @supports_payments_settings_update = args[:supports_payments_settings_update] if args.key?(:supports_payments_settings_update)\n end",
"def set_settings_will_change\n self.settings_will_change!\n end",
"def update\n\n @plugin.setting = params[:setting]\n @plugin.name = plugin_params[:name]\n\n plugin = init_plugin\n pst = plugin.setting_test\n if pst[:success]\n @plugin.test = true\n @plugin.save\n redirect_to @plugin, notice: 'Plugin was successfully updated.'\n else\n redirect_to edit_plugin_path(@plugin), notice: pst[:error]\n end\n end",
"def update\n @settings = self.current_user.setting\n @settings.update_attributes(params[:setting])\n\n flash[:updated] = true\n rescue => ex\n handle_exception(ex)\n flash[:updated] = false\n ensure\n respond_to do |format|\n format.html do \n redirect_to settings_path(:src => SettingsIndexSource::Updated)\n end\n format.json \n end\n end",
"def update_settings(settings)\n request :put, \"_settings\", nil, settings\n end",
"def update_settings(settings)\n request :put, \"_settings\", nil, settings\n end",
"def setting; end",
"def update!(**args)\n @quiz_settings = args[:quiz_settings] if args.key?(:quiz_settings)\n end",
"def settings; end",
"def settings; end",
"def update\n \n end",
"def update\n @setting.value = !@setting.value\n\n @setting.save\n head 200, content_type: \"text/html\"\n end",
"def update\n @setting = Setting.find(params[:id])\n\n if @setting.update_attributes(params[:setting])\n save_notice(\"设置修改成功.\")\n redirect_to :controller => \"settings\"\n else\n render :action => \"index\"\n end\n end",
"def update\n @setting = Setting.find(params[:id])\n\n if @setting.update_attributes(params[:setting])\n save_notice(\"设置修改成功.\")\n redirect_to :controller => \"settings\"\n else\n render :action => \"index\"\n end\n end",
"def settings_put\n \n # expected to set ALL values in one put using checkboxes\n # for this reason, missing values are assumed FALSE\n current_user.settings(:ui).refresh = params[:refresh].to_i rescue current_user.settings(:ui).refresh\n current_user.settings(:ui).fast_refresh = params[:fast_refresh].to_i rescue current_user.settings(:ui).fast_refresh\n current_user.settings(:ui).edge = params[:edge].eql?('true') rescue false\n current_user.settings(:ui).test = params[:test].eql?('true') rescue false\n current_user.settings(:ui).debug = params[:debug].eql?('true') rescue false\n current_user.settings(:ui).milestone_roles = params[:milestone_roles].eql?('true') rescue false\n current_user.settings(:errors).expand = params[:expand].eql?('true') rescue false\n current_user.settings(:docs).sources = params[:doc_sources].eql?('true') rescue false\n current_user.save!\n #render :json=>true\n redirect_to :action => :settings\n\n end",
"def update() end",
"def update\n @settings = current_user.settings\n\n respond_to do |format|\n if @settings.save(settings_params)\n format.html { redirect_to @setting, notice: 'Setting was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render :json => @setting.errors.full_messages, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @default_check_out_duration = params[:default_check_out_duration].to_i || Settings.defaults[:default_check_out_duration]\n @clients_can_see_equipment_outside_their_groups = (params[:clients_can_see_equipment_outside_their_groups] == 'true')\n @attendants_can_self_check_out = (params[:attendants_can_self_check_out] == 'true')\n\n saved = true\n\n obj = Settings.object('default_check_out_duration')\n obj.value = @default_check_out_duration\n saved &&= obj.save\n\n obj = Settings.object('clients_can_see_equipment_outside_their_groups')\n obj.value = @clients_can_see_equipment_outside_their_groups\n saved &&= obj.save\n\n obj = Settings.object('attendants_can_self_check_out')\n obj.value = @attendants_can_self_check_out\n saved &&= obj.save\n\n respond_to do |format|\n if saved\n format.html { redirect_to settings_path, notice: 'Settings were successfully updated.' }\n # format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n # format.json { render json: @settings.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_settings\n tab = params[:tab] || \"settings\"\n @settings.update_value(params[:setting], params[:value])\n\n flash_message = I18n.t(\"administrator.flash.settings\")\n\n if params[:value] == \"Default Recording Visibility\"\n flash_message += \". \" + I18n.t(\"administrator.site_settings.recording_visibility.warning\")\n end\n\n redirect_to admin_site_settings_path(tab: tab), flash: { success: flash_message }\n end",
"def update\n if @user.tconfig.update_attributes(settings_params)\n @status = \"good\"\n @message = \"Settings updated\"\n @resource = @user.tconfig\n elsif !@user.tconfig.valid?\n @message = \"Oops! Please make sure all fields are valid!\"\n end\n\n serve_json_response\n end",
"def update_values\n end",
"def update_values\n end",
"def update\n end",
"def update\n\t\tend",
"def update\n\t\tend",
"def update ; end",
"def update\r\n\r\n end",
"def update\n updates = setting_params\n updates[:last_changed_by] = current_user.username\n @setting.update(updates)\n @setting.save\n respond_with(@setting)\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update!(**args)\n @android_settings = args[:android_settings] if args.key?(:android_settings)\n @create_time = args[:create_time] if args.key?(:create_time)\n @display_name = args[:display_name] if args.key?(:display_name)\n @ios_settings = args[:ios_settings] if args.key?(:ios_settings)\n @labels = args[:labels] if args.key?(:labels)\n @name = args[:name] if args.key?(:name)\n @testing_options = args[:testing_options] if args.key?(:testing_options)\n @waf_settings = args[:waf_settings] if args.key?(:waf_settings)\n @web_settings = args[:web_settings] if args.key?(:web_settings)\n end",
"def update\n \n end",
"def settings=(value)\n @settings = value\n end",
"def settings=(value)\n @settings = value\n end",
"def update\n #Nothing necessary\n end",
"def update_settings\n account = EvernoteAccount.find(session[:evernote_account_id])\n if params['also_sync']\n # setting that allows user to sync notes from a certain notebook\n # in addition to the notes that are automatically classified\n # as recipes by evernote\n previous_sync_from_notebook = account.sync_from_notebook\n if params['also_sync'].include?('notebook') && !params['notebook'].nil? && !params['notebook'].strip.empty?\n account.sync_from_notebook = params['notebook']\n else\n account.sync_from_notebook = nil\n end\n # if the setting has changed, need to reset our records so that it\n # can do a full sync later\n if previous_sync_from_notebook != account.sync_from_notebook\n reset_evernote_recipes account\n end\n # setting that allows users to sync notes with certain tags\n previous_sync_from_tags = account.sync_from_tags\n tag_names = params['tags'].strip.split(/\\s*,\\s*/)\n if params['also_sync'].include?('tags') && !tag_names.empty?\n account.sync_from_tags = tag_names\n else\n account.sync_from_tags = []\n end\n # if the setting has changed, need to reset our records so that it\n # can do a full sync later\n if !xor(previous_sync_from_tags, account.sync_from_tags).empty?\n reset_evernote_recipes account\n end\n else\n account.sync_from_notebook = nil\n account.sync_from_tags = []\n end\n # setting that allows user to specify a notebook to save new recipes into\n account.save_in_notebook = params[\"save_in_notebook\"]\n account.save\n redirect_to action: \"index\"\n end",
"def edit_settings(settings)\n queries = password_hash\n queries[:query][:settings] = \"#{settings.to_json}\"\n put \"/setup/api/settings\", queries\n end",
"def update_all_config\n @admin.updateConfiguration\n end",
"def update_settings(settings)\n self.email = settings[:email]\n self.password = settings[:password] unless settings[:password].empty?\n save\n end",
"def settings=(new_settings)\n settings.merge!(new_settings)\n end",
"def update\n \t\n end",
"def update\n \t\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def create\n Settings.instance.update!(update_params)\n render_json_message(:ok, message: \"Settings successfully updated!\",\n resource: Settings.instance.serialize)\n rescue\n render_json_message(:forbidden, errors: [\"Unable to update settings.\"])\n end",
"def update\n @setting = Setting.first\n respond_to do |format|\n if @setting.update(setting_params)\n format.html { redirect_to settings_path, notice: 'Your settings were successfully updated.' }\n format.json { render :show, status: :ok, location: @setting }\n else\n format.html { render :edit }\n format.json { render json: @setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @core_setting.update(core_setting_params)\n format.html { redirect_to root_path, notice: 'Настройки обновлены.' }\n\t\t\t\tformat.json { render :edit, status: :ok, location: @core_setting }\n else\n format.html { render :edit }\n format.json { render json: @core_setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n end",
"def write_settings\n Application.settings.set_value('pos', Qt::Variant.new(pos))\n Application.settings.set_value('size', Qt::Variant.new(size))\n Application.settings.sync\n end",
"def update\n respond_to do |format|\n if @o_single.update(setting_params)\n format.html { redirect_to admin_settings_url, notice: t(\"general.successfully_updated\") }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @o_single.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n result = current_user.user_settings.find(params[:id])\n\n result.update_attributes(get_params_user_setting())\n\n respond_with result\n\n end",
"def update\n\n\tend",
"def update\n\n\tend",
"def settings\n Settings.app_state = params['app_state']\n Settings.reload\n Post.update_aws_s3\n end",
"def update \n end",
"def settings\n @settings\n end",
"def update(opts); end",
"def update\n\n end",
"def save_settings\n @plugin.set_options(params[:options]) if params[:options].present? # save option values\n @plugin.set_metas(params[:metas]) if params[:metas].present? # save meta values\n @plugin.set_field_values(params[:field_options]) if params[:field_options].present? # save custom field values\n redirect_to url_for(action: :settings), notice: \"Settings Saved Successfully\"\n end",
"def update\n if @setting.update(setting_params)\n head :no_content\n else\n render json: @setting.errors, status: :unprocessable_entity\n end\n end",
"def update\n\t\t# Left empty intentionally.\n\tend",
"def update\n respond_to do |format|\n if @setting.update(setting_params)\n format.html { redirect_to main_home_path, notice: 'Setting was successfully updated.' }\n format.json { render :show, status: :ok, location: @setting }\n else\n format.html { render :edit }\n format.json { render json: @setting.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # TODO: implement update\n end",
"def update\n\n end",
"def update\n \n end"
] |
[
"0.90265507",
"0.7738973",
"0.75129527",
"0.7425245",
"0.74152315",
"0.7180644",
"0.7150864",
"0.7028868",
"0.70081246",
"0.69973284",
"0.6941449",
"0.6936152",
"0.6903238",
"0.6825875",
"0.6819927",
"0.67667764",
"0.6751343",
"0.67478555",
"0.6741506",
"0.6721444",
"0.6710519",
"0.6710519",
"0.67016894",
"0.67005354",
"0.6680657",
"0.6680657",
"0.6658133",
"0.6638122",
"0.65927535",
"0.65927535",
"0.65774167",
"0.65628195",
"0.6548877",
"0.65460235",
"0.6539966",
"0.65398717",
"0.65333265",
"0.65333265",
"0.6531445",
"0.6527758",
"0.6527758",
"0.65226686",
"0.6509997",
"0.6476699",
"0.64618844",
"0.64618844",
"0.64618844",
"0.64618844",
"0.64512455",
"0.64467245",
"0.64467245",
"0.64467245",
"0.64467245",
"0.64467245",
"0.64467245",
"0.64467245",
"0.64467245",
"0.6440962",
"0.6430761",
"0.642395",
"0.642395",
"0.6415563",
"0.64045316",
"0.6394018",
"0.63899904",
"0.63696873",
"0.6352201",
"0.6345886",
"0.6345886",
"0.6326809",
"0.6326809",
"0.6326809",
"0.6326809",
"0.6326809",
"0.6326809",
"0.6326809",
"0.6326809",
"0.6326809",
"0.6326809",
"0.6326809",
"0.63106406",
"0.6305108",
"0.63037604",
"0.62716556",
"0.62644273",
"0.6251282",
"0.62506974",
"0.6222877",
"0.6222877",
"0.6222399",
"0.62103176",
"0.620911",
"0.6208318",
"0.6206016",
"0.61993855",
"0.6192906",
"0.61882395",
"0.61836666",
"0.6180314",
"0.6179419",
"0.617753"
] |
0.0
|
-1
|
output to a file, and the streaming output handler
|
def log_and_stream(output)
write_file output, @filename if @filename
@block.call(output)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def output_to_file\n @output=:file\n end",
"def process_output(file=nil)\n output = if file\n File.new(file.to_s,'w')\n else\n STDOUT\n end\n\n yield output if block_given?\n\n output.flush\n output.close\n return nil\n end",
"def output_file\n @output\n end",
"def output(value)\n @output_file = value\n end",
"def output(file, &block)\n @outfile = File.expand_path(file)\n @block = block\n self\n end",
"def write(output_to); end",
"def write_to_output filename, content = nil # :yields: file\n self.create_output_file(filename) do |output_path|\n File.open(output_path, 'w') do |f|\n if content\n f.write(content)\n else\n yield f\n end\n end\n end\n end",
"def write_file(out_file, output)\n File.open(out_file, 'w') { |f| output.each { |l| f.write(\"#{l}\\n\") } }\n end",
"def open_output_file(&block)\r\n outfile = options[:outfile]\r\n if outfile\r\n File.open(outfile, 'w') { |f| block.call(f) }\r\n else\r\n block.call(STDOUT)\r\n end\r\n end",
"def output(filename)\r\n outs = File.new(filename , \"w\")\r\n outs.puts self.to_s\r\n outs.close\r\n end",
"def write_it( output_file, final_content )\n File.open(output_file, \"w\") {|f| f.write( final_content ) }\n end",
"def output\n # if file name not present, just output to stdout.\n return $stdout.write(yield) if option[:ofile].nil?\n\n # times of calling output\n @serial ||= 0\n # Write to file, we should disable colorize\n enabled = Util.colorize_enabled?\n Util.disable_color! if enabled\n File.binwrite(file_of(option[:ofile], @serial), yield)\n Util.enable_color! if enabled\n @serial += 1\n end",
"def write\n path = \"#{site.root}/_site/#{output_file}\"\n File.open(path, 'w') do |f|\n f.write(@output)\n end\n end",
"def output(filename)\n @output = \" #{filename}\"\n end",
"def output_file\n @output_file ||= Tempfile.new(\"#{@blast_command}_out\")\n end",
"def save_to_file\n File.open(@output, 'w+') do |file|\n file.puts HEADER if @additional_html\n file.puts @data_for_output.join(\"\\n\")\n file.puts FOOTER if @additional_html\n end\n end",
"def write_output entries, dest, options\n if dest.match /^http/\n http = Atom::HTTP.new\n\n setup_http http, options\n\n entries_to_http entries, dest, http\n elsif dest == '-'\n entries_to_stdout entries\n else\n entries_to_dir entries, dest\n end\n end",
"def output\n super(@file_format => @file_path)\n end",
"def output_to_file message\n @log_file.puts message\n @log_file.flush\n end",
"def file_output output_lines, friend\n # using 'write_to' method with given parameters\n write_to \"#{friend}.txt\" do |file|\n file.write output_lines[0]\n file.write output_lines[1]\n end\nend",
"def output=(io); end",
"def write_output_file(output_file, body)\n File.open(output_file, 'w:UTF-8') do |file|\n file.puts $HTML_header\n file.puts body\n file.puts $HTML_footer\n end\nend",
"def log_and_stream(output)\n write_file output, runlog_filename if runlog_filename\n return @block.call(output) unless @block.nil?\n \"\"\n end",
"def write_output\n # If an output directory is given, open a file & write to it\n if output = self.output\n @path_decls.each do |path, decls|\n name = snake_case(decls.name.name.to_s.dup)\n file_path = File.join(output, \"#{name}.rbs\")\n File.open(file_path, 'w') do |io|\n stdout.puts \"Writing output to file: #{file_path}\"\n RBS::Writer.new(out: io).write([decls])\n end\n end\n # If no output directory is given write to STDOUT\n else\n RBS::Writer.new(out: stdout).write(@path_decls.values)\n end\n end",
"def write_file(filepath)\n case filepath\n when 'STDOUT' then yield @stdout\n when 'STDERR' then yield @stderr\n else File.open(filepath, 'w') { |fd| yield fd }\n end\n end",
"def write_output(output, path_or_io)\n io_for(path_or_io) do |io|\n io.write(output)\n end\n end",
"def write\n\n # output to disk\n File.open(@outfile, 'w:UTF-8') { |file|\n file.write(@buffer)\n }\n end",
"def output(file_name, mode=\"a\")\n Thread.new do\n IO.raw_file(file_name, mode) do |writer|\n until self.closed && self.empty?\n sleep 0.01 if self.empty? # pass execution if empty\n self.pop{ |mem| writer[mem, @bytes] } until self.empty?\n end\n end\n end\n end",
"def writeOut\n\t\t\n\tend",
"def output(contents, filename = \"output.html\")\n out_file = File.new(filename, \"w\")\n out_file.puts(contents)\n out_file.close\n end",
"def create_output_file(content)\n\t\t\tf = File.new(@params[:output_file], 'w')\n\t\t\tf << content\n\t\t\tf.close\n\t\tend",
"def write_to(stream)\n end",
"def write_file filename, content\n path = @output_directory + filename\n File.open(path, 'w') {|f| f.write content }\n end",
"def write_output_file(filename, &block)\n file = dir(File.join(\"output\", filename))\n File.open(file, 'w') do |f|\n yield f\n end\n @touchedfiles << undir(file)\n end",
"def file_end(file, output)\n end",
"def write_to(output_file)\n file = File.open(output_file, \"w\") \n @commands.each { |command| file.write(command.to_s + \"\\n\") }\n file.close \n #raise 'not yet implemented'\n end",
"def out\n return @out if @out\n FileUtils.mkdir_p out_base unless File.exist? out_base\n @out = File.open( \"#{out_path}\", 'w' )\n end",
"def __output(*args, **opt, &block)\n __output_impl(*args, **opt, &block)\nend",
"def write_to(io, *options); end",
"def render_to_file(output_path, context, properties = {})\n File.open(output_path, 'wb') do |f|\n f.write render_to_string(context, properties)\n end\n end",
"def write!\n # 1. skip if file already exists.\n if output_file_already_exists?\n RSpec::Scaffold.log(\"- #{@output_file} - already exists\", :puts)\n return\n end\n\n # 2. ensure parent directories exist\n FileUtils.makedirs(@output_file.parent)\n\n # 3. write to file\n File.open(@output_file, 'wb') do |f| # 'wb' originally\n f << @output_text\n end\n\n RSpec::Scaffold.log(\"+ #{@output_file}\")\n\n return @output_file.to_s\n end",
"def out_file(out)\n out << \"#{File.basename(@filename)}\"\n in_file_location(out)\n end",
"def render_to_file(output_path, context, properties = T.unsafe(nil)); end",
"def write_to_file(f)\n return f.write(self.buffer)\n end",
"def file_out(e, fname, log = nil)\n attrs = e.attrs.dup\n \n # Make sure we only have one attribute, not counting time\n time = attrs.delete :time\n event = attrs.delete :event_name\n pkt = attrs.delete :pkt\n unless log or attrs.length == 1\n raise \"File output can only write one selected attribute\"\n end\n \n # Construct our output value\n value = attrs.find { true }.last.to_s\n if attrs.length == 1\n value = time.strftime \"<%Y-%m-%d %H:%M:%S> #{value}\" if time and log\n value << \"\\n\" if log\n else\n value = e.to_s\n end\n \n # Open the file (possibly for append) and write out the content.\n File.open(fname.to_s, (log.nil? ? 'w' : 'a')) { |f| f.print(value) }\n nil\n end",
"def save(file_or_stream)\n output = file_or_stream\n\n if output.is_a? String\n @root = Pathname.new(File.dirname(File.expand_path(output)))\n output = File.open(output, 'w')\n else\n @root = Pathname.new(File.expand_path(\".\"))\n end\n\n @files.each do |f|\n output.puts(merge(f))\n end\n\n output.close if file_or_stream.is_a? String\n end",
"def output_file=(new_output_file)\n @output_file = File.new(new_output_file.respond_to?(:path) ? new_output_file.path : new_output_file.to_s, 'w')\n end",
"def get_output_stream(entry, permission_int = T.unsafe(nil), comment = T.unsafe(nil), extra = T.unsafe(nil), compressed_size = T.unsafe(nil), crc = T.unsafe(nil), compression_method = T.unsafe(nil), size = T.unsafe(nil), time = T.unsafe(nil), &a_proc); end",
"def close\n out.close\n end",
"def process_outputs(args)\n @input = @generator = @window = @fill_value = nil # Cover our tracks.\n\n if (name = args[:out_file])\n IO.write(name, @output, mode: \"wb\")\n elsif (out_str = args[:out_str])\n out_str << @output\n end\n\n (_, @output = @output, nil)[0] # Return output and erase it.\n end",
"def write_file(p, file)\n File.open(browse_file(p, file), 'w') { |fh| fh.print yield }\n end",
"def generate (path)\n File.open(path, \"w\") do |f|\n @output.each do |line|\n f.puts line\n end\n end \n end",
"def close_write\n if @output.respond_to?(:close)\n @output&.close\n end\n\n @output = nil\n end",
"def to_file\n replace_with_tempfile unless @tempfile_in\n flush\n self\n end",
"def render\n File.open(@file.output_path, \"w\") { |file| file.write(super) }\n end",
"def output_file\n [\n output_root,\n feed_name,\n batch_id + \".\" + output_extension\n ].join(\"/\")\n end",
"def io_out\n raise NotImplementedError, 'Not implemented'\n end",
"def generic_write (open_arg, filename, *data_and_options) #:nodoc:\n if block_given?\n options = data_and_options[0] || {}\n\n if options[:verbose] and open_arg == 'w'\n $stderr.puts \"cat /dev/null > #{Escape.shell_single_word(filename)}\"\n end\n\n if not options[:noop]\n File.open(filename, open_arg) do |f|\n hook_write(f, filename) if options[:verbose]\n yield f\n end\n\n elsif options[:verbose]\n f = StringIO.new\n hook_write(f, filename, :rewind)\n yield f\n end\n\n else\n data, options = *parse_data_and_options(data_and_options)\n\n if options[:verbose]\n if open_arg == 'w'\n $stderr.puts AdvFileUtils.__send__(:write_echo_message, data, '>', filename)\n else\n $stderr.puts AdvFileUtils.__send__(:write_echo_message, data, '>>', filename)\n end\n end\n\n if not options[:noop]\n File.open(filename, open_arg) do |f|\n f.write(data)\n end\n end\n end\n end",
"def write_output(str, output)\n if output.is_a?(IO)\n output.puts(str)\n else\n File.open(output, 'w+') { |f| f.puts(str) }\n end\n end",
"def open_output(path)\n case path.extname\n when \".gz\"\n Zlib::GzipWriter.open(path.to_s)\n # when \".gz\"\n # ::IO.popen(\"gzip -c > #{path}\", \"w\")\n else\n path.open(\"wb\")\n end\n end",
"def write; end",
"def write; end",
"def print(line)\n if $output_filename == '__to_stdout'\n printf(\"%s\",line)\n else\n f = File.open($output_filename,'a')\n f.write(line)\n f.close()\n end\nend",
"def write_file(file_name_out, content_array)\n\n\toutput = File.new(file_name_out, 'w')\n\tcontent_array.each { |line| output.write line }\n\toutput.close\nend",
"def out(location = nil)\n configure(:out, location)\n end",
"def handleFileOutput(code)\n open('output.txt', 'w') do |f|\n f << code\n end\n puts \"Compressed file successfully saved as output.txt\\n\\n\"\nend",
"def write_output\n rows = data_to_rows\n CSV.open(@filename, 'wb') do |csv|\n rows.each {|row| csv << row}\n end\n end",
"def output(obj)\n io.puts Yajl::Encoder.encode(obj.merge('job_data' => job_for_output))\n io.flush\n end",
"def output_file(options=nil)\n temp_options(options) if options\n file = @options[:output]\n\n if @options[:fingerprint]\n @fingerprint ||= file_fingerprint\n basename = File.basename(file).split(/(\\..+)$/).join(\"-#{@fingerprint}\")\n dir = File.dirname(file)\n file = File.join(dir, basename)\n end\n\n reset_options if options\n file\n end",
"def finish_output(error = nil)\n\t\t\t\t\t\ttrailer = @output&.trailer\n\t\t\t\t\t\t\n\t\t\t\t\t\t@output = nil\n\t\t\t\t\t\t\n\t\t\t\t\t\tif error\n\t\t\t\t\t\t\tsend_reset_stream(::Protocol::HTTP2::Error::INTERNAL_ERROR)\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t# Write trailer?\n\t\t\t\t\t\t\tif trailer&.any?\n\t\t\t\t\t\t\t\tsend_headers(nil, trailer, ::Protocol::HTTP2::END_STREAM)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tsend_data(nil, ::Protocol::HTTP2::END_STREAM)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend",
"def write_file(directory, filename, output)\n FileUtils.mkdir_p directory\n\n # create full output path\n output_path = \"#{directory}/#{filename}\"\n\n # write it, char by char to avoid large mem issues\n File.open(output_path, \"wb\") do |file|\n output.each_char { |char| file.write char }\n end\n end",
"def open_out_file(filepath)\n File.open(filepath, 'wb')\n end",
"def writeOut(fname=\"out\")\n File.open(fname, \"w\").write(@mResult)\n end",
"def write_to(io)\n end",
"def write_to(io)\n end",
"def output_to_file (products_hash, brands_hash)\n\t_sales_report_header\n\t_products_header\n\tproducts_section(products_hash)\n\tend_of_section\n\t_brands_header\n\tbrands_section(brands_hash)\n\tend_of_section\n\t$report_file.puts 'THIS REPORT HAS BEEN CREATED BY MROHDE'\nend",
"def public_json_output_file(info, file)\n # format as JSON\n results = JSON.pretty_generate(info)\n\n write_output(file, results)\n\nend",
"def write(file)\n self.files.each { |l| file.puts l }\n end",
"def flush_to_file(hit_list)\n File.open($config[:output], 'a') do |file|\n file.puts(hit_list)\n end\nrescue => e\n puts \"Error writing to output file #{$config[:output]}\"\n raise e\nend",
"def output_file(file, options = {})\n options = {\n output_directory: output_directory\n }.merge(options)\n # return @output_file if @output_file\n sub_dir = options[:output_sub_dir] || Origen.file_handler.sub_dir_of(file).to_s\n sub_dir = nil if sub_dir == '.'\n filename = options[:output_file_name] || file.basename.to_s.gsub('.erb', '')\n # filename.gsub!('target', $target.id) if filename =~ /target/ && $target.id\n output = Pathname.new(\"#{options[:output_directory]}#{sub_dir ? '/' + sub_dir : ''}/#{filename}\")\n FileUtils.mkdir_p(output.dirname.to_s) unless File.exist?(output.dirname.to_s)\n # @output_file = output\n output\n end",
"def stream\n @stream ||=\n ::File.open(file, \"w+\")\n end",
"def write_raw!(pathname, output)\n FileUtils.mkdir_p(pathname.parent) unless pathname.parent.exist?\n File.open(pathname, 'w'){ |f| f << output }\n end",
"def write_file(*args)\n end",
"def hook_write (object, filename, tail_msg = nil) #:nodoc:\n object.instance_eval <<-__EOM__, __FILE__, __LINE__ + 1\n class << self\n def write (data, *args)\n $stderr.puts AdvFileUtils.__send__(:write_echo_message, data, '>>', #{filename.inspect})\n super\n ensure\n send #{tail_msg.inspect} if #{tail_msg.inspect}\n end\n end\n __EOM__\n end",
"def save_output\n\n end",
"def write_druid_response_to_file(output_path, druid_output)\n output_filename = druid_path(output_path)\n ensure_containing_dir(output_filename)\n File.open(output_filename, 'w') do |file|\n file.write(druid_output)\n end\n output_filename\n rescue StandardError => e\n Rails.logger.error(\"Unexpected error trying to write druid response to file: #{Util.exception_msg_and_backtrace_str(e)}\")\n end",
"def create_output_file filename # :yields: complete_filename\n output_path = @output_root + filename\n @logger.info \"Writing to #{output_path}#{dry_run ? \" (skipped - dry run)\" : \"\"}\" do\n unless dry_run\n folder = output_path.dirname\n folder.mkpath unless folder.directory?\n yield output_path\n end\n end\n end",
"def write(dest); end",
"def write(dest); end",
"def write(dest); end",
"def open_fastq_output(filename)\n if filename == '-'\n out_fp = STDOUT\n else\n begin\n out_fp = File.open(filename, \"w\")\n rescue Exception => err\n die \"cannot open #{filename}: #{err.to_s}\"\n end\n end\n\n if @compress\n return Zlib::GzipWriter.new(out_fp,Zlib::BEST_COMPRESSION,Zlib::DEFAULT_STRATEGY)\n else\n return out_fp\n end\n\n end",
"def write\n end",
"def write_file( fname )\n File.open(fname, \"w\") do |f|\n f << TDP.application.result\n end\n TDP.application.result = String.new\n# puts \"...written to #{fname}\"\n end",
"def output_buffer; end",
"def output_buffer; end",
"def out text\n @fileBuffer << text << \"\\n\"\nend",
"def write(outfile)\n file_out = File.open(outfile, 'w')\n\n write_header(file_out)\n write_content(file_out)\n write_footer(file_out)\n\n file_out.close\n end",
"def output \n\tFile.open(\"#{@file_out}\", \"w+\") do |f|\n\t f.puts \"#{@encrypted_text}\"\n\tend \nend",
"def write\n FileUtils.rm @out_file if File.exists? @out_file\n in_progress \"Writing archive #{@out_file} from #{@input_dir}\" do\n Zip::File.open @out_file, Zip::File::CREATE do |zipfile|\n Dir[\"#{@input_dir}/**/**\"].reject{ |f| f == @out_file || !@filter.call(f) }.each do |file|\n progress \"deflating #{file}\"\n zipfile.add(file.sub(@input_dir + '/', ''), file)\n end\n end\n end\n end",
"def write\n @log.debug('Creating temporary file...')\n tmp = Tempfile.new('oneacct_export')\n @log.debug(\"Temporary file: '#{tmp.path}' created.\")\n @log.debug('Writing to temporary file...')\n write_to_tmp(tmp, fill_template)\n copy_to_output(tmp.path, @output)\n ensure\n tmp.close(true)\n end"
] |
[
"0.70496744",
"0.6911427",
"0.677642",
"0.6775058",
"0.67674965",
"0.6717924",
"0.66240805",
"0.65162593",
"0.64997506",
"0.64211464",
"0.6414503",
"0.63471895",
"0.63361895",
"0.633134",
"0.63018715",
"0.6292471",
"0.62518466",
"0.622082",
"0.6200323",
"0.61857706",
"0.6173876",
"0.61390203",
"0.61089295",
"0.60827345",
"0.6082669",
"0.60804003",
"0.6049302",
"0.5988708",
"0.5977344",
"0.597279",
"0.59563255",
"0.5930909",
"0.59187055",
"0.5917559",
"0.58952975",
"0.5894661",
"0.58759236",
"0.5873158",
"0.58623385",
"0.5859986",
"0.5850596",
"0.5846444",
"0.5826908",
"0.5825568",
"0.5818387",
"0.5817872",
"0.5816496",
"0.5803447",
"0.5802331",
"0.5801112",
"0.5798757",
"0.5797974",
"0.5787598",
"0.57647896",
"0.5762961",
"0.57353145",
"0.5709918",
"0.570354",
"0.5701258",
"0.5698059",
"0.5697501",
"0.5697501",
"0.56902397",
"0.56697935",
"0.5658266",
"0.5651352",
"0.5650985",
"0.5645407",
"0.56381816",
"0.5635064",
"0.5634108",
"0.56334984",
"0.5630924",
"0.56247413",
"0.56247413",
"0.5619164",
"0.5603595",
"0.5596233",
"0.55950356",
"0.5579958",
"0.55739975",
"0.55733854",
"0.55649376",
"0.55584174",
"0.5556317",
"0.5549829",
"0.5546336",
"0.5542845",
"0.5542845",
"0.5542845",
"0.55254245",
"0.55184525",
"0.55180264",
"0.55029774",
"0.55029774",
"0.55015916",
"0.5500306",
"0.549983",
"0.54987603",
"0.54985136"
] |
0.729572
|
0
|
Run external command with timing information streams and logs the output of the command as well does not (currently) check exit status codes
|
def run_cmd(cmd)
ret = ""
start = Time.now.to_i
log_and_stream "<div class='command'><h4>Running #{cmd}</h4><p class='output'>"
time = Benchmark.measure do
Open3.popen3(cmd) do |inn, out, err|
output = ""
until out.eof?
# raise "Timeout" if output.empty? && Time.now.to_i - start > 300
chr = out.read(1)
output << chr
ret << chr
if chr == "\n" || chr == "\r"
log_and_stream output + "<br>"
output = ""
end
end
log_and_stream(output) unless output.empty?
log_and_stream("<span class='stderr'>STDERR: #{err.read}</span><br>") unless err.eof?
end
end
log_and_stream "</p>"
log_and_stream "<h5>Time: #{time}</h5></div>"
return ret
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _external(cmd, opts={})\n #log :info, \"cmd is ||#{cmd.inspect}||\"\n log :info, \"starting [#{cmd.join(' ')}]\" if !opts.has_key?(:silent)\n\n start = Time.now\n outfile = Tempfile.new\n pid = Process.spawn(*cmd, out: outfile.fileno, err: :out)\n SUBPROCS << pid # add to halt list\n\n begin\n _, status = Process.wait2(pid)\n rescue Errno::ECHILD\n # our subproc was killed, usually by our shutdown routine\n exit_code = 1\n else\n exit_code = status.exitstatus\n end\n\n SUBPROCS.delete(pid) # remove from halt list\n diff = format_time_diff(start)\n\n outfile.rewind\n result = outfile.read\n outfile.close!\n\n log :info, \"ran [#{cmd.join(' ')}] in #{diff}\" if !opts.has_key?(:silent)\n \n if exit_code > 0 && !$shutdown\n log :error, \"command [#{cmd.join(' ')}] returned an error (code #{exit_code}), with the following output\"\n log :error, result\n end\n\n if opts.has_key?(:timing)\n return exit_code, result, diff\n else\n return exit_code, result\n end\nend",
"def run\n stime = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n\n sys(command, path: config[:bin], stdout: stdout, stderr: stderr)\n \n etime = Process.clock_gettime(Process::CLOCK_MONOTONIC)\n\n ttime = etime-stime\n puts \"Query #{qfile} took #{ttime} seconds.\"\n\n done!\n rescue CommandFailed => e\n done! e.exitstatus\n end",
"def run_cmd(cmd, timing_metric=nil, log_errors=true)\n ret = \"\"\n exit_code = 0\n start = Time.now.to_i\n timestamp = Time.now.to_s\n plugin_state = {\n :cmd => cmd,\n :timing_metric => timing_metric,\n :start_time => start,\n :log_errors => log_errors\n }\n raise_event(:run_command_start, plugin_state)\n log_and_stream \"<div class='command'><h4>#{timestamp}: Running #{cmd}</h4>\\n<p class='output'>\"\n time = Benchmark.measure do\n Open3.popen3(cmd) do |inn, out, err, wait_thr|\n output = \"\"\n until out.eof?\n # raise \"Timeout\" if output.empty? && Time.now.to_i - start > 300\n chr = out.read(1)\n output << chr\n ret << chr\n if chr == \"\\n\" || chr == \"\\r\"\n log_and_stream output + \"<br>\"\n output = \"\"\n end\n end\n error_message = nil\n log_and_stream(output) unless output.empty?\n\n error_message = err.read unless err.eof?\n if (log_errors) then\n log_and_stream(\"<span class='stderr'>STDERR: #{error_message}</span><br>\") unless error_message.nil?\n else\n log_and_stream(\"STDERR:\" + error_message + \"<br>\") unless error_message.nil?\n end\n\n unless error_message.nil? then\n plugin_state[:error_message] = error_message\n raise_event(:run_command_error, plugin_state)\n end\n\n # Log non-zero exits\n if wait_thr.value.exitstatus != 0 then\n log_and_stream(\"<span class='stderr'>DANGER! #{cmd} had an exit value of: #{wait_thr.value.exitstatus}</span><br>\")\n exit_code = wait_thr.value.exitstatus\n end\n end\n end\n log_and_stream \"</p>\"\n log_and_stream \"<h5>Time: #{time}</h5></div>\"\n plugin_state[:exit_code] = exit_code\n plugin_state[:stdout] = ret\n plugin_state[:time] = time.real\n raise_event(:run_command_end, plugin_state)\n return { :stdout => ret, :exit_code => exit_code }\n end",
"def command_withinput(cmd, inp=nil)\n puts \"$ #{cmd}\".starsaround.blue\n\n start = Time.now\n stdout, stderr, status = Open3.capture3(cmd, :stdin_data=>inp)\n finish = Time.now\n diff = finish - start\n\n if diff > 5 then puts (\" * \".blue + (\"exec time: %.2f sec\" % diff))\n else puts (\" * \".blue + (\"exec time: %.2f sec\" % diff).black)\n end\n\n if status.exitstatus === 0 then puts (\" * \".blue + \"exit code: #{status.exitstatus}\".black)\n else puts (\" * \".blue + \"exit code: #{status.exitstatus}\".light_white)\n end\n\n unless stdout.empty?\n puts \"* * STDOUT\".starfill.green\n puts stdout.each_line.map {|l| \" * \".green + l}.join\n else\n puts \" * \".green + \"STDOUT: none\".black\n end\n\n unless stderr.empty?\n puts \"* * STDERR\".starsallaround.red\n puts stderr.each_line.map {|l| \" * \".red + l}.join\n end\n\n if status.exitstatus != 0\n raise SystemCallError.new(\"Execution of `#{cmd}` failed with error code: #{status.exitstatus}\")\n end\nend",
"def external_with_timing(cmd, opts={})\n opts[:timing] = true\n _external(cmd, opts)\nend",
"def run_test(cmd)\n tStart = Time.now\n @out = \"-- #{tStart.strftime('[%H:%M:%S]')} running: [#{cmd}] \"\n begin\n status = Timeout::timeout(@test.timeout.to_i) {\n output = `#{cmd} 2>&1`\n\t @test.output = output\n @exit_status = case @test.output\n when /#{@config['test_exit_message_passed']}/ then @config['test_exit_message_passed']\n when /#{@config['test_exit_message_failed']}/ then @config['test_exit_message_failed']\n else @config['test_exit_message_failed']\n end\n }\n rescue Timeout::Error => e\n @test.output << \"\\n\\n[ TERMINATED WITH TIMEOUT (#{@test.timeout.to_s}) ]\"\n @exit_status = @config['test_exit_message_failed']\n rescue => e\n @test.output << \"\\n\\n[ ERROR ]\\n\\n\"\n @test.output << e.inspect\n @exit_status = @config['test_exit_message_failed']\n ensure\n @obj.p(@out.to_s + @exit_status.to_s)\n @obj.p(@output) if @config['output_on']\n end\n tFinish = Time.now\n @test.execution_time = tFinish - tStart\nend",
"def run_simple(cmd, fail_on_error = true, exit_timeout = nil, io_wait_timeout = nil)\n command = run(cmd, exit_timeout, io_wait_timeout)\n @last_exit_status = process_monitor.stop_process(command)\n\n @timed_out = command.timed_out?\n\n if fail_on_error\n expect(command).to have_finished_in_time\n expect(command).to be_successfully_executed\n end\n end",
"def exec_command(command)\n log = ''\n puts \"\\n=> Executing \\\"#{command}\\\"\"\n log += \"\\n\\n=> Executing \\\"#{command}\\\"\\n\"\n Open3.popen2e(command) { |stdin, stdout_and_stderr, wait_thr|\n stdout_and_stderr.each {|line|\n puts line\n log += line\n }\n }\n return log\nend",
"def runner ( command, opts)\n puts(\"Info: Running: #{command}\") if (opts[:verbrose])\n start_time = Time.now\n system(command)\n puts(\"Info: Done in #{(Time.now - start_time)/60.0}m.\") if (opts[:verbrose])\nend",
"def runner ( command, opts)\n puts(\"Info: Running: #{command}\") if (opts[:verbrose])\n start_time = Time.now\n system(command)\n puts(\"Info: Done in #{(Time.now - start_time)/60.0}m.\") if (opts[:verbrose])\nend",
"def runner ( command, opts)\n puts(\"Info: Running: #{command}\") if (opts[:verbrose])\n start_time = Time.now\n system(command)\n puts(\"Info: Done in #{(Time.now - start_time)/60.0}m.\") if (opts[:verbrose])\nend",
"def runner ( command, opts)\n puts(\"Info: Running: #{command}\") if (opts[:verbrose])\n start_time = Time.now\n system(command)\n puts(\"Info: Done in #{(Time.now - start_time)/60.0}m.\") if (opts[:verbrose])\nend",
"def run(command,exit_on_error_with)\n info \"Running '#{command}'\"\n stdout_str, stderr_str, status = Open3.capture3(command)\n\n info stdout_str\n unless status.success?\n error stderr_str\n exit_now!(exit_on_error_with, \"There was a problem running '#{command}'\")\n end\nend",
"def time_exec(command)\n res = `(/usr/bin/time #{command}) 3>&1 1>/dev/null 2>&3`\n raise \"Expected '#{command}' to run successfully\" unless $?.success?\n\n regex = (RUBY_PLATFORM =~ /linux/) \\\n ? /.*([\\d\\.]{5,})elapsed.*/ \\\n : /.*([\\d\\.]{4,}) real.*/\n regex.match(res) { |md| return md[1].to_f * 1000 }\n\n raise \"Timing '#{command}' failed\"\nend",
"def slow_command\n EventMachine::Timer.new(3) { send_output \"This is the output.\" }\n end",
"def run_with_timeout(command, timeout, tick, inputs)\n output = ''\n output_error = []\n begin\n # Start task in another thread, which spawns a process\n stdin, stdout, stderr, thread = Open3.popen3(command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n inputs.each{|i| stdin.puts(i)}\n \n while (Time.now - start) < timeout and thread.alive?\n # Wait up to `tick` seconds for output/error data\n Kernel.select([stdout], nil, nil, tick)\n # Try to read the data\n begin\n output << stdout.read_nonblock(4096)\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n break\n end\n end\n # Give Ruby time to clean up the other thread\n sleep 1\n \n \n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n print \"gets here\"\n return nil\n end\n stderr.each{|x| output_error << x}\n ensure\n stderr.close if stderr\n stdin.close if stdin\n stdout.close if stdout\n end\n return [output, output_error]\n end",
"def stream_output(command)\n puts command\n exit_status = nil\n Open3.popen3(command) do |stdin, stdout, stderr, wait_thread|\n stdout.each { |line| puts line }\n stderr.each { |line| puts line }\n exit_status = wait_thread.value.to_i\n end\n raise %Q(The command \"#{command}\" failed.) unless exit_status == 0\nend",
"def execute(cmd)\n puts \"TRACE: executing '#{cmd}'\" if verbose\n require 'open3'\n out_err, st = Open3.capture2e(*cmd.split(' '))\n if st.exitstatus != 0\n puts \"ERROR: #{cmd} exited with #{st.exitstatus}\\n\\n#{out_err}\"\n exit st.exitstatus\n end\n out_err\nend",
"def run_with_timeout(command, target_output, timeout = SOLVER_TIMEOUT, tick = 0.5)\n output = ''\n begin\n # Start task in another thread, which spawns a process\n stdin, stderrout, thread = Open3.popen2e(command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n\n while (Time.now - start) < timeout and thread.alive?\n print '.'\n\n # Wait up to `tick` seconds for output/error data\n Kernel.select([stderrout], nil, nil, tick)\n # Try to read the data\n begin\n output << stderrout.read_nonblock(BUFFER_SIZE)\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n output = 'SHIT'\n break\n end\n\n break if target_output =~ output\n end\n # Give Ruby time to clean up the other thread\n sleep 1\n\n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n end\n ensure\n stdin.close if stdin\n stderrout.close if stderrout\n end\n return output\nend",
"def run_with_timeout(command, timeout, tick)\n output = ''\n begin\n # Start task in another thread, which spawns a process\n stdin, stderrout, thread = Open3.popen2e(command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n\n while (Time.now - start) < timeout and thread.alive?\n # Wait up to `tick` seconds for output/error data\n select([stderrout], nil, nil, tick)\n # Try to read the data\n begin\n output << stderrout.read_nonblock(4096)\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n break\n end\n end\n # Give Ruby time to clean up the other thread\n sleep 0.1\n\n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n output = \"Process timed out\"\n end\n ensure\n stdin.close if stdin\n stderrout.close if stderrout\n end\n return output\n end",
"def runCmd\n puts \" Deployed and running #{@request.data['command']} #{@request.data['arguments']}\".light_green\n print ' STDOUT'.light_cyan + ' and' + ' STDERR'.light_magenta + \":\\n\"\n\n # offset (place saving) variables\n @stdoutOffset = 0\n @stderrOffset = 0\n begin\n # get most recent task state\n # need to wait for \"task_running\" before we can ask for STDOUT/STDERR\n @taskState = JSON.parse(RestClient.get \"#{@uri}/api/history/task/#{@thisTask['taskId']['id']}\")\n @taskState[\"taskUpdates\"].each do |update|\n @taskState = update['taskState']\n end\n if @taskState == \"TASK_FAILED\"\n return 1 # failure\n end\n if @taskState == \"TASK_RUNNING\"\n sleep 1\n # print stdout\n @stdout = JSON.parse(RestClient.get \"#{@uri}/api/sandbox/#{@thisTask['taskId']['id']}/read\", {params: {path: \"stdout\", length: 30000, offset: @stdoutOffset}})['data']\n outLength = @stdout.bytes.to_a.size\n if @stdout.length > 0\n print @stdout.light_cyan\n @stdoutOffset += outLength\n end\n # print stderr\n @stderr = JSON.parse(RestClient.get \"#{@uri}/api/sandbox/#{@thisTask['taskId']['id']}/read\", {params: {path: \"stderr\", length: 30000, offset: @stderrOffset}})['data']\n errLength = @stderr.bytes.to_a.size\n if @stderr.length > 0\n print @stderr.light_magenta\n @stderrOffset += errLength\n end\n end\n end until @taskState == \"TASK_FINISHED\"\n\n return 0 # success\n end",
"def run(command, options = {:desc => '', :get_output_string => false})\n puts options[:desc]\n puts \"Executing: #{command}\"\n\n if options[:get_output_string]\n result = `#{command}`\n else\n command << \" > /dev/null\" if command # Not show output details to stdout\n result = system(command)\n end\n\n report(result)\n end",
"def run_and_examine(command)\n response = IO.popen(command).readlines\n response.each { |response_line| @errors << response_line if response_line =~ /Error/i }\n puts \">#{command}\\n#{response.join}\" if $verbose || (@errors.size > 0)\n @errors.size == 0\n end",
"def run_command_verbose(cmd_args, options)\n start = ElapsedTime.now\n\n begin\n success = run_command(cmd_args, options)\n status = success ? '✓' : '✗'\n success\n rescue Errors::TimeoutExceeded\n status = 'timeout'\n raise\n ensure\n $stderr << format(\"%s %.1fs %s\\n\", status, ElapsedTime.now - start, cmd_args.shelljoin)\n end\n end",
"def run command, *args\n formatted = Report.format_command_line command, *args\n write \">>> #{formatted}\\n\"\n Report.run_capturing_output(command, *args) do |data|\n write data\n end\n end",
"def run_with_timeout(command, timeout, tick)\n output = ''\n begin\n # Start task in another thread, which spawns a process\n stdin, stderrout, thread = Open3.popen2e(command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n\n while (Time.now - start) < timeout and thread.alive?\n # Wait up to `tick` seconds for output/error data\n Kernel.select([stderrout], nil, nil, tick)\n # Try to read the data\n begin\n output << stderrout.read_nonblock(4096)\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n break\n end\n end\n # Give Ruby time to clean up the other thread\n sleep 1\n\n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n end\n ensure\n stdin.close if stdin\n stderrout.close if stderrout\n end\n return output\nend",
"def ps_exec(command, tmp_file, c_time, output_file)\n encoding_options = {\n :invalid => :replace, # Replace invalid byte sequences\n :undef => :replace, # Replace anything not defined in ASCII\n :replace => '', # Use a blank for those replacements\n :universal_newline => false # Always break lines with \\n\n }\n print_status(\"Sending command to client...\")\n client.sys.process.execute(command, nil, {'Hidden' => 'true', 'Channelized' => true})\n sleep(c_time)\n log_file = client.fs.file.new(tmp_file, \"rb\")\n begin\n while ((data = log_file.read) != nil)\n data.strip!\n print_line(data.encode(::Encoding.find('ASCII'), encoding_options))\n end\n rescue EOFError\n ensure\n log_file.close\n end\n client.sys.process.execute(\"cmd /c del #{tmp_file}\", nil, {'Hidden' => 'true', 'Channelized' => true})\n end",
"def run_with_timeout(directory, command, timeout, tick)\n output = \"\"\n exit_code = 1\n\n Open3.popen2e(command, chdir: directory) do |_stdin, stderrout, thread|\n pid = thread.pid\n\n start = Time.now\n while ((Time.now - start) < timeout) && thread.alive?\n # Wait up to `tick` seconds for output/error data\n Kernel.select([stderrout], nil, nil, tick)\n # Try to read the data\n begin\n output << stderrout.read_nonblock(BUFFER_SIZE)\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n exit_code = wait_thread.value\n break\n end\n\n sleep(0.5)\n end\n\n exit_code = wait_thread.value\n\n # Give Ruby time to clean up the other thread\n sleep 1\n\n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n exit_code = 5\n end\n end\n\n [output, exit_code]\nend",
"def run_wrapped_cmd(cmd)\n separator = '-' * (TW - 4)\n\n puts \"Command output follows, on STDERR:\\n#{separator}\"\n ret = nil\n\n Open3.popen2e(cmd) do |_in, out, thr|\n # rubocop:disable Lint/AssignmentInCondition\n while l = out.gets do warn l end\n # rubocop:enable Lint/AssignmentInCondition\n ret = thr.value.exitstatus\n end\n\n puts separator\n ret\n end",
"def exec(command)\n cmd = Open3.popen3(command) do |i, o, e|\n i.close\n t0 = Thread.new do\n o.each_line do |line|\n $stdout.puts \" \" << line\n end\n end\n t1 = Thread.new do\n e.each_line do |line|\n $stderr.puts \" \" << line\n end\n end\n t0.join\n t1.join\n end\n end",
"def time(command)\n start = Time.now\n system(command)\n Time.now - start\nend",
"def run_with_status(*args)\n _print_command(*args)\n args.last.delete :errexit if args.last.is_a? Hash\n args.last.delete :xtrace if args.last.is_a? Hash\n pid = Process.spawn(*args)\n return Process.wait2(pid).last\nend",
"def run_for_output(cmd)\n LOG.debug \"RUNNING (for output): #{cmd}\"\n out, _status = Open3.capture2e(cmd)\n out.strip\n end",
"def run_command(*command)\n\t\t\t#stdout, stderr, status\n\t\t\treturn Open3.capture3(*command)\n\t\tend",
"def run()\n stdout_file = Tempfile::new(\"rbatch_tmpout\",RBatch::tmp_dir)\n stderr_file = Tempfile::new(\"rbatch_tmperr\",RBatch::tmp_dir)\n pid = spawn(@cmd_str,:out => [stdout_file,\"w\"],:err => [stderr_file,\"w\"])\n if @opt[:timeout] != 0\n timeout(@opt[:timeout]) do\n begin\n status = Process.waitpid2(pid)[1] >> 8\n rescue Timeout::Error => e\n raise(CmdException,\"Command timeout (over \" + @opt[:timeout] + \" sec)\" )\n end\n end\n else\n status = Process.waitpid2(pid)[1] >> 8\n end\n result = RBatch::CmdResult.new(stdout_file,stderr_file,status,@cmd_str)\n if @opt[:raise] && status != 0\n raise(CmdException,\"Command exit status is not 0. result: \" + result.to_s)\n end\n return result\n end",
"def run_local_command(command)\n stdout, stderr, status = Open3.capture3(command)\n error_message = \"Attempted to run\\ncommand:'#{command}'\\nstdout:#{stdout}\\nstderr:#{stderr}\"\n raise error_message unless status.to_i.zero?\n\n stdout\n end",
"def run_with_timeout(env, command, timeout=60*60*4, tick=2)\n out = \"\"\n err = \"\"\n begin\n # Start task in another thread, which spawns a process\n stdin, stdout, stderr, thread = Open3.popen3(env, command)\n # Get the pid of the spawned process\n pid = thread[:pid]\n start = Time.now\n\n while (Time.now - start) < timeout and thread.alive?\n # Wait up to `tick` seconds for output/error data\n rs, = Kernel.select([stdout, stderr], nil, nil, tick)\n # Try to read the data\n begin\n if !rs.nil?\n rs.each { |r|\n if r == stdout\n out << stdout.read_nonblock(4096)\n elsif r == stderr \n err << stderr.read_nonblock(4096)\n end\n }\n end\n\n rescue IO::WaitReadable\n # A read would block, so loop around for another select\n rescue EOFError\n # Command has completed, not really an error...\n break\n end\n end\n # Give Ruby time to clean up the other thread\n sleep 1\n\n if thread.alive?\n # We need to kill the process, because killing the thread leaves\n # the process alive but detached, annoyingly enough.\n Process.kill(\"TERM\", pid)\n end\n ensure\n stdin.close if stdin\n stdout.close if stdout\n stderr.close if stderr\n end\n return out.force_encoding(\"UTF-8\"), err.force_encoding(\"UTF-8\"), thread.value\nend",
"def run_with_tee(cmd)\n status, stdout, stderr = nil\n\n if windows?\n #:nocov: TODO: Test block\n system(cmd)\n status = $?.exitstatus\n #:nocov:\n else\n stdout, stderr = [$stdout, $stderr].map{ |t| StringTee.new(t) }\n status = Open4.spawn(cmd, 'stdout' => stdout, 'stderr' => stderr, 'quiet' => true)\n stdout, stderr = [stdout, stderr].map(&:string)\n end\n\n [status, stdout, stderr]\n end",
"def system_run(cmd, o={})\n opts = {:quiet => false, :sysread => 1024}.merge(o)\n buf = \"\"\n ddputs(\"Running command: #{cmd}\")\n Open3.popen3(cmd) do |stdout, stdin, stderr|\n begin\n while (chunk = stdin.readpartial(opts[:sysread]))\n buf << chunk\n unless chunk.nil? || chunk.empty?\n $stdout.write(chunk) #if debugging? || verbose?\n end\n end\n err = stderr.readlines\n $stderr.write_nonblock(err)\n rescue SystemCallError => error\n err = stderr.readlines\n $stderr.write_nonblock(err)\n rescue EOFError => error\n err = stderr.readlines\n $stderr.write_nonblock(err)\n # used to do nothing\n end\n end\n buf\n end",
"def run(cmd)\n log cmd\n system(cmd) or fail \"Command Failed: [#{cmd}]\"\n end",
"def run(cmd)\n log cmd\n system(cmd) or fail \"Command Failed: [#{cmd}]\"\n end",
"def run_command\n # run the test suite and check the result\n res, time = time_command @config.command\n if res then\n puts statusbar \"✓ All tests passed\", time, &:white_on_green\n else\n puts statusbar \"✗ Tests failed\", time, &:white_on_red\n end\n res\n end",
"def run_and_output(cmd)\n run(cmd).output\n end",
"def execute(filename, command, error)\n # Execute Command\n @result[:_task] = filename\n @result[:_timestamp]= Time.now.to_i\n # @result[:_date]\n unless @params[\"_target\"][\"remote\"].nil?\n begin \n stdout, stderr, status = Open3.capture3(*command)\n rescue Exception => e\n default_error = { \n msg: e.message,\n kind: \"test::#{filename}\",\n details: { class: e.class.to_s,\n backtrace: e.backtrace }, \n }\n @result[:_error] = default_error.merge(error)\n\n end\n @result[:_stdout] = stdout\n @result[:_sterr] = stderr\n @result[:_status] = status\n @result\n else\n @result[:_timestamp]= Time.now\n @result[:_command_start_time] = Time.now\n begin \n $results = command.call()\n @result[:_command_end_time] = Time.now\n rescue Exception => e\n @result[:_command_end_time] = Time.now\n default_error = { \n msg: e.message,\n kind: \"test::#{filename}\",\n details: { class: e.class.to_s,\n backtrace: e.backtrace }, \n }\n @result[:_error] = default_error.merge(error)\n #puts @result\n end\n # makes sure the results are at the top level of the return object\n unless $results.nil?\n $results.each do |key, value|\n @result[key] = value\n end\n end\n end\n @result\n end",
"def system_exec(cmd)\n Open3.popen3(RSpec::Support::Env.env, cmd) do |stdin, stdout, stderr, wait_thr|\n yield stdin, stdout, wait_thr if block_given?\n stdin.close\n\n @exitstatus = wait_thr && wait_thr.value.exitstatus\n @out = Thread.new { stdout.read }.value.strip\n @err = Thread.new { stderr.read }.value.strip\n end\n\n (@all_output ||= \"\") << [\n \"$ #{cmd.to_s.strip}\",\n out,\n err,\n @exitstatus ? \"# $? => #{@exitstatus}\" : \"\",\n \"\\n\"\n ].reject(&:empty?).join(\"\\n\")\n\n @out\n end",
"def with_timeout(cmd, timeout)\n\n\n # popen2e combines stdout and stderr into one IO object\n i, oe, t = Open3.popen2e(cmd) # stdin, stdout+stderr, thread\n t[:timed_out] = false\n i.close\n\n # Purposefully NOT using Timeout.rb because in general it is a dangerous API!\n # http://blog.headius.com/2008/02/rubys-threadraise-threadkill-timeoutrb.html\n Thread.new do\n sleep timeout\n if t.alive?\n suppress(Errno::ESRCH) do # 'No such process' (possible race condition)\n # NOTE: we are assuming the command will create ONE process (not handling subprocs / proc groups)\n Process.kill('TERM', t.pid)\n t[:timed_out] = true\n end\n end\n end\n\n t.value # wait for process to finish, one way or the other\n out = oe.read(10000)\n out = \"*** Empty output ***\" if out.nil?\n oe.close\n\n if t[:timed_out]\n out << \"\\n\" unless out.blank?\n out << \"*** Process failed to complete after #{timeout} seconds ***\"\n end\n\n out\n end",
"def run_command(desc, cmdline)\n\t\tin_progress = \"[....] #{desc}\"\n\n\t\t$stdout.print in_progress\n\n\t\toutput = nil\n\t\tfailed = false\n\t\tbegin\n\t\t\toutput = @command.run_command(cmdline) do |fd, l|\n\t\t\t\tnext unless @verbose\n\t\t\t\t@stdout.puts \"\\x0d\\x1b[K#{fd.to_s.send(fd == :stderr ? :cyan : purple)}: #{l}\"\n\t\t\t\t@stdout.print in_progress\n\t\t\tend\n\t\trescue Giddyup::CommandWrapper::CommandFailed => e\n\t\t\t@stdout.puts \"\\x0d[\"+\"FAIL\".red+\"] #{desc}\"\n\t\t\toutput = e.output\n\t\t\tfailed = true\n\t\telse\n\t\t\t@stdout.puts \"\\x0d[\"+\" OK \".green+\"] #{desc}\"\n\t\tend\n\n\t\tif failed and !@verbose\n\t\t\t@stdout.puts cmdline\n\t\t\t@stdout.puts output.map { |l| \"#{l[0].to_s.send(l[0] == :stderr ? :cyan : :purple)}: #{l[1]}\" }.join(\"\\n\")\n\t\tend\n\n\t\treturn output.select { |l| l[0] == :stdout }.map { |l| l[1] }.join(\"\\n\")\n\tend",
"def run\n out = \"\"\n\n begin\n PTY.spawn(command) do |stdout, stdin, pid|\n begin\n stdout.each do |line|\n out << line.strip+\"\\n\"\n print line if @tee\n end\n rescue Errno::EIO\n #Errno:EIO error probably just means that the process has finished giving output\n end\n Process.wait(pid)\n end\n rescue PTY::ChildExited\n # The child process has exited.\n end\n\n if $?.exitstatus == 0\n return Parser.parse(out) if @parse\n return out\n else\n raise \"httperf exited with status #{$?.exitstatus}\\n\\nhttperf output:\\n--------------\\n#{out}\"\n end\n end",
"def run(*params)\n opts = params.extract_options!\n command = Array.wrap(params).join(' ')\n info command unless opts[:quiet]\n\n begin\n cmdrunner = Mixlib::ShellOut.new(command, timeout: opts[:timeout] || Conveyor::Foreman.instance.config[:command_timeout] || 600)\n cmdrunner.run_command()\n\n info cmdrunner.stdout.chomp unless cmdrunner.stdout.chomp.length == 0\n\n \t\t\t\tif cmdrunner.error!\n \terror \"Error running: `#{command}`\", cmdrunner.stderr.chomp\n \t@status.fail!\n \t\t\t\telse\n \t\t\t\t\tif cmdrunner.stderr.chomp.length > 0\n \t\t\t\t\t\twarning \"Error output recieved, but no error code recieved\"\n \t\t\t\t\t\twarning cmdrunner.stderr.chomp\n \t\t\t\t\tend\n \t\t\t\tend\n\n return !cmdrunner.error!\n rescue Mixlib::ShellOut::CommandTimeout => e\n error e.class, e.message, \"Command: #{command}\"\n # raise e unless opts[:ignore_error]\n rescue => e\n error e.class, e.message, e.backtrace.join(\"\\n\")\n # raise e unless opts[:ignore_error]\n end\n end",
"def cmd_on_trgt_exec(session,cmdexe,opt,verbose)\n\tr=''\n\tsession.response_timeout=120\n\tif verbose == 1\n\t\tbegin\n\t\t\tprint_status \"\\tRunning command #{cmdexe}\"\n\t\t\tr = session.sys.process.execute(cmdexe, opt, {'Hidden' => true, 'Channelized' => true})\n\t\t\twhile(d = r.channel.read)\n\t\t\t\tprint_status(\"\\t#{d}\")\n\t\t\tend\n\t\t\tr.channel.close\n\t\t\tr.close\n\t\trescue ::Exception => e\n\t\t\tprint_status(\"Error Running Command #{cmdexe}: #{e.class} #{e}\")\n\t\tend\n\telse\n\t\tbegin\n\t\t\tprint_status \"\\trunning command #{cmdexe}\"\n\t\t\tr = session.sys.process.execute(cmdexe, opt, {'Hidden' => true, 'Channelized' => false})\n\t\t\tr.close\n\t\trescue ::Exception => e\n\t\t\tprint_status(\"Error Running Command #{cmdexe}: #{e.class} #{e}\")\n\t\tend\n\tend\nend",
"def run_local_command(command)\n require 'open3'\n stdout, stderr, status = Open3.capture3(command)\n error_message = \"Attempted to run\\ncommand:'#{command}'\\nstdout:#{stdout}\\nstderr:#{stderr}\"\n\n raise error_message unless status.to_i.zero?\n\n stdout\n end",
"def timed_sh(command)\n sh \"time #{command}\"\nend",
"def system_cmd(cmd)\n system \"echo \\\"--> Running command: '#{cmd}':\\\" >>#{LOGFILE}\"\n unless (status = system \"#{cmd} >>#{LOGFILE} 2>&1\")\n puts \"Command failed: '#{cmd}'\\n --> see #{LOGFILE} for details\"\n end\n status\n end",
"def time_command(command)\n before = Time.new\n result = system command\n after = Time.new\n return result, after - before\n end",
"def run_command(cmd)\n if config[:simulate]\n puts_and_logs \" - Simulate running \\\"#{cmd}\\\"\"\n return\n end\n if config[:debug]\n if config[:verbose]\n puts_and_logs \" - Running \\\"#{cmd}\\\"\"\n else\n logger.debug \" - Running \\\"#{cmd}\\\"\"\n end\n system cmd\n return\n end\n puts_and_logs \" - Running \\\"#{cmd}\\\"\" if config[:verbose]\n system(cmd + ' > /dev/null 2>&1')\n\n end",
"def exec(cmd)\n\t\tbegin\n\t\t\tout = cmd_exec(cmd).chomp\n\t\trescue ::Timeout::Error => e\n\t\t\tvprint_error(\"#{@peer} - #{e.message} - retrying...\")\n\t\t\tretry\n\t\trescue EOFError => e\n\t\t\tvprint_error(\"#{@peer} - #{e.message} - retrying...\")\n\t\t\tretry\n\t\tend\n\tend",
"def out(command)\n assert(system(command))\n end",
"def call(command)\n $log.debug(\"exec #{command}\")\n\n stdout, stderr, exit_status = Open3::capture3(ENV, command)\n $log.debug(\"stderr = #{stderr}\") if stderr\n $log.debug(\"stdout = #{stdout}\")\n $log.debug(\"exit status = #{exit_status}\")\n\n status = Status.from_plowshare(exit_status.exitstatus)\n $log.debug(\"status = #{status}\")\n\n return nil, status unless exit_status.success?\n return stdout, status\n end",
"def tim_get_output(subcommand, *flags)\n tim_get_command(subcommand, *flags) do |command|\n %x[#{command.join(' ')}]\n end\n end",
"def log_and_exec(_cmd, options = {})\n echo_level = options.delete(:echo_level) || :info\n Matsuri.log echo_level, \"$ #{_cmd}\".color(:green)\n exec _cmd\n end",
"def run_command(command, options={})\n timeout = options[:timeout] || 7200\n \n # default to adding a nice 19 if nothing specified\n nice = if options.key?(:nice)\n !options[:nice] ? '' : \"nice -n #{options[:nice].to_i} \"\n else\n 'nice -n 19 '\n end\n \n echo_return = (options.key?(:echo_return) && !options[:echo_return]) ? '' : '; echo $?'\n \n cmd = \"#{nice}#{command}#{echo_return}\"\n \n # logger.info \"google_speech - run_command: #{cmd}\"\n begin\n result = Timeout::timeout(timeout) {\n Open3::popen3(cmd) do |i,o,e|\n out_str = \"\"\n err_str = \"\"\n i.close # important!\n o.sync = true\n e.sync = true\n o.each{|line|\n out_str << line\n line.chomp!\n # logger.debug \"stdout: #{line}\"\n }\n e.each { |line| \n err_str << line\n line.chomp!\n # logger.debug \"stderr: #{line}\"\n }\n return out_str, err_str\n end\n }\n rescue Timeout::Error => toe\n # logger.debug \"run_command:Timeout Error - running command, took longer than #{timeout} seconds to execute: '#{cmd}'\"\n raise toe\n end\n end",
"def run_cmd cmd\n info cmd\n status = system(cmd)\n if status\n info(\"Woot! Woot! - command succeeded #{cmd}\")\n else\n error(\"Gahhhh! Bad status from #{cmd}\")\n end\n status\n end",
"def run\n system(command)\n $?\n end",
"def run\n system(command)\n $?\n end",
"def execute_cmd(cmd, timeout = new_resource.cmd_timeout)\n Chef::Log.debug('Executing: ' + cmd)\n begin\n shell_out(cmd, :timeout => timeout)\n rescue Mixlib::ShellOut::CommandTimeout\n raise CommandTimeout, command_timeout_error_message\n end\n end",
"def execute\n begin\n rout, wout = IO.pipe\n rerr, werr = IO.pipe\n stdout, stderr = nil\n\n pid = Process.spawn(command_line, :pgroup => true, :out => wout, :err => werr)\n Timeout.timeout(timeout) do\n Process.wait(pid)\n\n wout.close\n werr.close\n\n stdout = rout.readlines.join\n stderr = rerr.readlines.join\n end\n rescue Timeout::Error\n Process.kill(-9, pid)\n Process.detach(pid)\n ensure\n wout.close unless wout.closed?\n werr.close unless werr.closed?\n\n rout.close\n rerr.close\n end\n stdout\n end",
"def run(cmd)\n Open3.popen3(*cmd) do |i, o, e, t|\n i.close\n t.value\n end\n end",
"def execute_cmd(cmd, timeout = new_resource.cmd_timeout)\n Chef::Log.debug('Executing: ' + cmd)\n begin\n shell_out(cmd, :timeout => timeout)\n rescue Mixlib::ShellOut::CommandTimeout\n raise CommandTimeout, command_timeout_error_message(cmd)\n end\n end",
"def run(cmd)\n output = `#{cmd.gsub(/\\s+/, \" \")} 2>&1`\n\n unless $?.exitstatus == 0\n #Kickvideo::Notifier.deliver_processing_error(@attachment.instance, @attachment, cmd, output)\n raise Kickvideo::ProcessingError, \"Error while running #{cmd} - #{output}\"\n end\n\n output\n end",
"def run_command(command)\n time_start = Time.now\n begin\n result = `#{ command }`\n rescue\n result = 'Get an error when try to run command'\n end\n time_finished = Time.now\n duration = time_finished - time_start\n { start_time: time_start, finished_time: time_finished, duration: duration, result: result }\n end",
"def run(cmd)\n puts(cmd)\n system(cmd)\nend",
"def run(s, maxt = 10*60, errorIsOnStdout=false)\n begin\n pid, cmdin, cmdout, cmderr = Open4.popen4(s)\n rescue Exception => e\n $stderr << 'Execution of '+s+' has failed :' + e.to_s\n raise \"run failed\"\n end\n\n begin\n Timeout::timeout(maxt) do |t|\n a = Process.waitpid2(pid)\n if a[1].exitstatus != 0\n $stderr << 'Error while executing ' + s\n errorMessage = (errorIsOnStdout ? cmdout.read : cmderr.read)\n raise errorMessage.gsub(/\\n/, ' ')\n end\n end\n rescue Timeout::Error => e\n $stderr << 'Execution of '+s+' has timed out. Killing subprocess'\n begin\n Process.kill('KILL', pid)\n cmdout.close; cmdin.close; cmderr.close\n rescue Object => e\n $stderr << 'Failed killing process : ' + e.to_s\n end\n raise \"timeout\"\n end\n\n out = cmdout.read\n cmdout.close; cmdin.close; cmderr.close\n out\nend",
"def run(command)\n result = connection.exec!(command)\n puts \"[BEGIN #{@host}: #{command}]\"\n puts \" #{result}\"\n puts \"[END #{@host}: #{command}]\"\n end",
"def run_command(command)\n command = \"true\" if command.to_s.strip.empty?\n with_shell_instance do\n stdin.puts wrapped_command(command)\n stdin.close\n out, err = stdout.read, stderr.read\n out, status, _ = raw_stdout_to_parts(out)\n return status, out, err\n end\n end",
"def run\n begin\n IO.popen(@cmd_line).read\n rescue\n @logger.error(\"Failed to execute command on #{@host}\")\n \"\"\n end\n end",
"def tim_get(subcommand, *flags)\n tim_get_command(subcommand, *flags) do |command|\n system(*command)\n end\n end",
"def stream_locally(cmd,opts={})\n shell = opts[:shell] || 'bash'\n tee = opts[:tee]\n redact = opts[:redact]\n redact_replacement = opts[:redact_replacment] || '-REDACTED-'\n cmd = [shell,'-c \"',cmd.gsub(/\"/,'\\\"'),'\" 2>&1'].join(' ')\n cmd_text = redact ? redact.inject(cmd.inspect){|ct,r| ct.gsub(r,redact_replacement)} : cmd.inspect\n logger.trace %Q{executing locally: #{cmd_text}} if logger\n $stdout.sync = true\n elapsed = Benchmark.realtime do\n Open3.popen3(cmd) do |stdin, out, err, external|\n # Create a thread to read from each stream\n { :out => out, :err => err }.each do |key, stream|\n Thread.new do\n until (line = stream.gets).nil? do\n redact.each {|r| line.gsub!(r,redact_replacement)} if redact\n $stdout << line\n File.open(tee,'a') {|f| f.write(line) } if tee\n end\n end\n end\n # Don't exit until the external process is done\n external.join\n end\n if $?.to_i > 0 # $? is command exit code (posix style)\n raise Capistrano::LocalArgumentError, \"Command #{cmd_text} returned status code #{$?}\"\n end\n end\n $stdout.sync = false\n logger.trace \"\\ncommand finished in #{(elapsed * 1000).round}ms\" if logger\n end",
"def run_locally(cmd)\n logger.trace \"executing locally: #{cmd.inspect}\" if logger\n output_on_stdout = nil\n elapsed = Benchmark.realtime do\n output_on_stdout = `#{cmd}`\n end\n if $?.to_i > 0 # $? is command exit code (posix style)\n raise Capistrano::LocalArgumentError, \"Command #{cmd} returned status code #{$?}\"\n end\n logger.trace \"command finished in #{(elapsed * 1000).round}ms\" if logger\n output_on_stdout\n end",
"def run(cmd)\n #logger.trace \"executing locally: #{cmd.inspect}\" if logger\n run_locally cmd\n # puts `#{cmd}`\nend",
"def trace host\n `#{@command} #{host} 2>&1`\n end",
"def sys(str, log = nil)\n puts [str, log && log.color(:yellow)].compact.join(' > ')\n\n cmd = [str, log].compact.join(' > ')\n\n pid = Process.spawn(cmd)\n begin\n Timeout::timeout(TIMELIMIT) do\n Process.wait(pid)\n end\n rescue Timeout::Error\n puts \"command out of time, re-Run\".bright\n system(\"pkill -TERM -P #{pid}\")\n sys(str, log)\n end\nend",
"def run(command)\n puts command\n `#{command}`.tap &method(:puts)\nend",
"def launch_command(command, description)\n puts \"Je lance #{command}\"\n @log_file.puts \"\\n============================================\"\n @log_file.puts \"Lancement du test #{description}\"\n @log_file.puts '============================================'\n\n begin\n Timeout::timeout(@delay_before_timeout) { @log_file.puts `#{command}` }\n rescue Timeout::Error\n # TODO: in this case, a zombie shell still exists. How to remove it?\n `killall memcheck-x86-li`\n puts \"*** Test arrêté, exécution trop longue (> #{@delay_before_timeout} sec) ***\"\n @log_file.puts \"*** Test arrêté, exécution trop longue (> #{@delay_before_timeout} sec) ***\"\n end\n end",
"def command_interactive(cmd)\n puts String.starline.blue\n puts (\"$ #{cmd}\".blue + \" 2>&1\".yellow)\n\n stdout_empty = true\n \n start = Time.now\n begin\n PTY.spawn( cmd ) do |stdin, stdout, pid|\n begin\n puts \"* * STDOUT & STDERR\".starfill.blue\n stdin.each { |line| \n stdout_empty = false\n puts \" * \".blue + line\n }\n rescue Errno::EIO\n end\n Process.wait(pid)\n end\n rescue PTY::ChildExited\n puts \" * Strange, the child process exited...\".starsaround.red\n end\n finish = Time.now\n\n puts \" * \".blue + \"STDOUT: none\".black if stdout_empty\n\n diff = finish - start\n puts String.starline.blue\n if diff > 5 then puts (\" * \".blue + (\"exec time: %.2f sec\" % diff))\n else puts (\" * \".blue + (\"exec time: %.2f sec\" % diff).black)\n end\n\n if $?.exitstatus === 0 then puts (\" * \".blue + \"exit code: #{$?.exitstatus}\".black)\n else puts \" * exit code: #{$?.exitstatus}\".starsaround.red\n end\n\n if $?.exitstatus != 0\n unless $!.nil?\n raise SystemCallError.new(\"Execution of `#{cmd}` failed with error code: #{$!.exitstatus}\")\n else\n raise SystemCallError.new(\"Execution of `#{cmd}` failed\")\n end\n end\nend",
"def execute command\n log command\n system(command) unless @options[:test]\n end",
"def log_command(status, options = {})\n command = options[:command] || status.command\n \n log_command_line(command, status.success?)\n log_command_status(status)\n \n overall_error! if current_host && !status.success?\n end",
"def execute(command, options = {})\n options.merge! timeout: 3600, cwd: staging_dir\n shellout!(command, options)\n end",
"def csystem(cmd, err, opts = {})\n print \"Running command: #{cmd.inspect}\\n\" if opts[:debug] || opts[\"debug\"]\n if VERBOSE\n system(cmd, out: $stdout, err: $stderr)\n else\n out = `#{cmd}`\n end\n unless $?.success? || opts[:fail_ok] || opts[\"fail_ok\"]\n puts \"Error running command:\\n#{cmd.inspect}\"\n puts \"Output:\\n#{out}\\n=====\" #if out\n raise err\n end\nend",
"def execute\n final_command = \"#{@command} 2>&1\"\n puts \":: #{final_command}\"\n duration = 0\n Transcoder.logger.info(\"\\nExecuting Command: #{final_command}\\n\")\n if block_given?\n @raw_result = ''\n IO.popen(final_command) do |pipe|\n pipe.each(\"\\r\") do |line| \n new_progress, duration = parse_progress(line, duration)\n if new_progress != @progress\n @progress = new_progress\n yield @progress\n $defout.flush\n end\n @raw_result += line + \"\\r\" \n end\n end\n else\n @raw_result = `#{final_command}`\n end\n Transcoder.logger.info(\"Result: \\n#{@raw_result}\")\n parse_result(@raw_result)\n end",
"def shell_command(cmd)\n # Send the command to the session's stdin.\n shell_write(cmd + \"\\n\")\n\n timeo = 5\n etime = ::Time.now.to_f + timeo\n buff = \"\"\n\n # Keep reading data until no more data is available or the timeout is\n # reached.\n while (::Time.now.to_f < etime and (self.respond_to?(:ring) or ::IO.select([rstream], nil, nil, timeo)))\n res = shell_read(-1, 0.01)\n buff << res if res\n timeo = etime - ::Time.now.to_f\n end\n\n buff\n end",
"def system cmd, *args\n ohai \"#{cmd} #{args*' '}\".strip\n\n if ARGV.verbose?\n safe_system cmd, *args\n else\n rd, wr = IO.pipe\n pid = fork do\n rd.close\n $stdout.reopen wr\n $stderr.reopen wr\n exec(cmd, *args) rescue nil\n exit! 1 # never gets here unless exec threw or failed\n end\n wr.close\n out = ''\n out << rd.read until rd.eof?\n Process.wait\n unless $?.success?\n puts out\n raise\n end\n end\n rescue SystemCallError\n # usually because exec could not be find the command that was requested\n raise\n rescue \n raise BuildError.new(cmd, args, $?)\n end",
"def execute_command(command, &blk)\n so, se = nil\n\n time_obj = Time.now\n ts = time_obj.to_i\n dt = time_obj.strftime(\"%Y-%m-%d\")\n\n tmp_dir_base = @config.get(PATRIOT_TMP_DIR_KEY, DEFAULT_PATRIOT_TMP_DIR)\n\n # the forked variable is used for checking whether fork invocation hangs.\n # (due to https://redmine.ruby-lang.org/issues/5240 ?)\n forked = false\n until forked\n cid = do_fork(command, dt, ts, tmp_dir_base)\n tmpdir = tmp_dir(cid, dt, ts, tmp_dir_base)\n i = 0\n # If fork hangs, output directory would not be created.\n # wait at most 5 seconds for the directory created.\n until forked || i > 5\n sleep(1)\n forked = File.exist?(tmpdir)\n i = i+1\n end\n # fork hanged, kill the hanged process.\n unless forked\n # check whether cid is id of child process to avoid to kill unrelated processes\n begin\n if Process.waitpid(cid, Process::WNOHANG).nil?\n @logger.warn(\"forked process :#{cid} hanged. kill #{cid}\")\n Process.kill(\"KILL\", cid)\n @logger.warn(\"SIGKILL sent to #{cid}\")\n Process.waitpid(cid)\n @logger.warn(\"#{cid} is killed\")\n else\n raise ExternalCommandException, \"#{cid} is not a child of this\"\n end\n rescue Exception => e\n @logger.warn \"failed to kill hanged process #{cid}\"\n raise e\n end\n end\n end\n\n @logger.info \"executing #{command}: results stored in #{tmpdir}\" \n pid, status = Process.waitpid2(cid)\n so = File.join(tmpdir, \"#{cid.to_i}#{STDOUT_SUFFIX}\")\n se = File.join(tmpdir, \"#{cid.to_i}#{STDERR_SUFFIX}\")\n\n @logger.info \"#{command} is finished\" \n return so if status.exitstatus == 0\n @logger.warn \"#{command} end with exit status #{status.exitstatus}\" \n if block_given?\n yield(status, so, se)\n else\n max_err_size = @config.get(MAX_ERROR_MSG_SIZE_KEY, DEFAULT_MAX_ERROR_MSG_SIZE)\n err_size = File.stat(se).size\n err_msg = \"#{command}\\n#{se} :\"\n if err_size < max_err_size\n File.open(se){|f| err_msg = \"#{err_msg}\\n#{f.read}\"}\n else\n err_msg = \"#{err_msg} \\n the size of stderr is #{err_size} (> #{max_err_size}\" \n end\n raise ExternalCommandException, err_msg\n end\n end",
"def run(cmd)\n puts cmd\n system cmd\nend",
"def run(command)\n display command.join(\" \")\n\n IO.popen(command + [err: %i[child out]]) do |io|\n __display(io.read(128), partial: true, verbose: true) until io.eof?\n end\n\n fail StandardError, \"Error running '#{command.join(\" \")}'\" unless $?.success?\n end",
"def run(command)\n $CommandLog.info command\n \n status = POpen4::popen4(command) do |stdout, stderr|\n puts stdout.read.strip\n $Log.error stderr.read.strip\n end\n \n status && status.exitstatus == 0 ? true : false\nend",
"def run(command, verbose = false, message = nil)\n if verbose then\n puts \"#{message}\"\n puts command\n result = `#{command}`\n puts result\n return result\n else\n `#{command}`\n end\nend",
"def run(command, verbose = false, message = nil)\n if verbose then\n puts \"#{message}\"\n puts command\n result = `#{command}`\n puts result\n return result\n else\n `#{command}`\n end\nend",
"def execute(command)\n #2>&1 Redirect standard error to standard output\n system(\"#{command} > #{OUTPUT} 2>&1\")\n puts File.read(OUTPUT) if SHOW_OUTPUT\nend",
"def exec!(command, status: T.unsafe(nil), &block); end",
"def run(cmd, capture_stderr=true)\n notice \"Running: \" + cmd.color(:white)\n cmd += \" 2>&1\" if capture_stderr\n\n out = \"\"\n IO.popen(cmd) do |f|\n while l = f.gets\n out += l\n msg \" \" + l\n end\n end\n\n raise CmdFailedError.new(\"Command '#{cmd}' had exit status #{$?.to_i}\") if $? != 0\n out\n end"
] |
[
"0.7211847",
"0.7065461",
"0.7041343",
"0.67256796",
"0.6720106",
"0.667679",
"0.6659391",
"0.6583466",
"0.6563336",
"0.6563336",
"0.6563336",
"0.6563336",
"0.65072024",
"0.64922863",
"0.64795613",
"0.64740103",
"0.64442164",
"0.64410657",
"0.644074",
"0.643898",
"0.6432363",
"0.64281887",
"0.63880587",
"0.63584286",
"0.6337991",
"0.63279974",
"0.6300146",
"0.6297851",
"0.6281215",
"0.62786454",
"0.62742364",
"0.6269123",
"0.62676996",
"0.6247896",
"0.6232799",
"0.6231028",
"0.62262475",
"0.62179726",
"0.62130576",
"0.6202169",
"0.6202169",
"0.61840886",
"0.6178945",
"0.6177379",
"0.617412",
"0.6165476",
"0.6161853",
"0.6145098",
"0.61384284",
"0.61262655",
"0.6121143",
"0.6118976",
"0.6118304",
"0.6107937",
"0.6103299",
"0.61020553",
"0.6101533",
"0.60965794",
"0.60845196",
"0.6082607",
"0.6082212",
"0.6071948",
"0.6067334",
"0.6067334",
"0.6058815",
"0.60541195",
"0.6043976",
"0.60269636",
"0.602432",
"0.60218567",
"0.6010046",
"0.6009837",
"0.5998623",
"0.5996805",
"0.5978445",
"0.5975452",
"0.596316",
"0.59591764",
"0.59535986",
"0.5942433",
"0.5939425",
"0.5937404",
"0.59334224",
"0.5932932",
"0.5927015",
"0.59261346",
"0.5921223",
"0.59169626",
"0.59114486",
"0.5911113",
"0.5906133",
"0.58955246",
"0.58822304",
"0.5877619",
"0.58746755",
"0.5865575",
"0.5865575",
"0.5858403",
"0.5857668",
"0.5856374"
] |
0.662283
|
7
|
pokemon_name = [] def pokemons_names(pokemon_name) Pokemon.each do |pokemon| pokemon_name << pokemon[:name] end pokemon_name end def pokemons_names pokemon_name = [] Pokemon.each do |pokemon| pokemon_name << pokemon[:name] end pokemon_name end
|
def pokemons_names
Pokemon.collect do |pokemon|
pokemon[:name]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def all_names(pokemon)\n pokemon.map do |pokemon_data|\n pokemon_data[:name]\n end\nend",
"def list_of_names\n World.politicians.map { |p| p.name } + World.voters.map { |p| p.name}\nend",
"def get_name(pokemon)\n pokemon['species']['name']\nend",
"def list_pokemon_stats\n puts(\"Name: {#name}\")\n puts(\"HP: {#hp}\")\n end",
"def list_pokemon\n puts \"\"\n puts \"See below for the list of the original Pokemon!\"\n puts \"\"\n @pokemon_objects.each.with_index(1) do |a, i|\n puts \"#{i}. #{a.name}\"\n end\n puts \"\"\n end",
"def get_names(spicy_foods)\n spicy_foods.map { |spicy_food_hash| spicy_food_hash[:name] }\nend",
"def choose_pokemon(pokemon_array)\n pokemons << pokemon_array\n end",
"def pbPocketNames; return [\"\",\n _INTL(\"Items\"),\n _INTL(\"Medicine\"),\n _INTL(\"Jermo Balls\"),\n _INTL(\"TMs & HMs\"),\n _INTL(\"Bewwies\"),\n _INTL(\"Mail\"),\n _INTL(\"Battle Items\"),\n _INTL(\"Key Items\")\n]; end",
"def list_pokemons\n\n end",
"def animal_nicknames\n total_animals = animals.map do |animal|\n animal.nickname \n end\t\n end",
"def names\n [name]\n end",
"def ability_names(pokemon)\n\t\tability_names = []\n\t\tpokemon[\"abilities\"].each do |i|\n\t\t\tability_names.push(i[\"ability\"][\"name\"])\n\t\tend\n\t\treturn ability_names\n\tend",
"def names; end",
"def names; end",
"def names; end",
"def names; end",
"def names; end",
"def names; end",
"def names; end",
"def team_names()\n temp =[]\n game_hash.each do |location, team_data|\n #binding.pry\n temp << team_data[:team_name]\n end\n temp\nend",
"def name_all_players\n (0..num_players - 1).each { |i| @players[i].name_player('Player' + i.to_s)}\n end",
"def good_pokemon # :not_very_effective AND :no_effect_on\n good_pokemon = []\n @type.not_very_effective.each {|pokemon| good_pokemon << pokemon}\n @type.no_effect_on.each {|pokemon| good_pokemon << pokemon if !good_pokemon.include?(pokemon)}\n \n if good_pokemon.count > 0\n puts \"\"\n puts \"USE POKEMON OF THESE TYPE(S)\"\n good_pokemon.each_with_index {|pokemon, index| puts \"#{index +1}. #{pokemon.name}\"}\n end\n end",
"def patients_name\n self.pets.map {|p| p.name}\n end",
"def names name = \"\"\n find_all_by_name( name ).map(&:name)\n end",
"def get_types(pokemon)\n pokemon_types = {}\n case pokemon['types'].size\n when 1\n pokemon_types[:type1] = pokemon['types'][0]['type']['name']\n when 2\n pokemon_types[:type1] = pokemon['types'][0]['type']['name']\n pokemon_types[:type2] = pokemon['types'][1]['type']['name']\n end\n pokemon_types\nend",
"def names\n @names ||= []\n end",
"def names\n map(&:name)\n end",
"def nom_ville\n\tnom = []\n\tjson_to_ruby.each do |i| \n\t nom.push(i['name'])\n \tend\n \tnom\nend",
"def all_names; end",
"def all_names; end",
"def do_names\n animal_list = get_names()\n print_names(animal_list)\n end",
"def getPokemonTypeFromTypesObject(types)\n return types.map {|x| x['type']['name']}.compact\nend",
"def name_all_players()\n set_name()\n set_other_name()\n end",
"def players; [@hunter, @prey] end",
"def types()\n\t\t@pokemon_types = []\n\t\t@pokemon_api[\"types\"].each do |i|\n\t\t\t@pokemon_types.push(i[\"type\"][\"name\"].capitalize)\n\t\tend\n\t\treturn @pokemon_types\n\tend",
"def meat_toppings()\n\tmeat_toppings = [\"bacon\", \"pepperoni\", \"sausage\", \"anchovies\"]\nend",
"def names\n @names ||= [@name]\n end",
"def get_stats(pokemon)\n pokemon_stats = {}\n pokemon_stats[:hp] = pokemon['stats'][0]['base_stat']\n pokemon_stats[:attack] = pokemon['stats'][1]['base_stat']\n pokemon_stats[:defense] = pokemon['stats'][2]['base_stat']\n pokemon_stats[:special_attack] = pokemon['stats'][3]['base_stat']\n pokemon_stats[:special_defense] = pokemon['stats'][4]['base_stat']\n pokemon_stats[:speed] = pokemon['stats'][5]['base_stat']\n pokemon_stats\nend",
"def build_list_of_players\n [\n \"cliff\",\n \"anne\",\n \"harry\",\n \"sam\",\n \"devin\",\n \"ally\",\n \"bob\",\n \"jane\",\n \"jimmy\",\n \"dave\"\n ]\nend",
"def animal_nicknames \n self.animals.map do |animal|\n animal.nickname\n end \n end",
"def get_pokemon_JSON\n r = \n {\n :p1 => JSON.parse(self.pokeserver(self.p1)), \n :p2 => JSON.parse(self.pokeserver(self.p2)), \n :p3 => JSON.parse(self.pokeserver(self.p3)), \n :p4 => JSON.parse(self.pokeserver(self.p4)), \n :p5 => JSON.parse(self.pokeserver(self.p5)), \n :p6 => JSON.parse(self.pokeserver(self.p6)) \n }\n \n JSON.generate(r)\n end",
"def summon_captain_planet(planeteer_calls)\nplaneteer_calls.map { |string| \"#{string.capitalize}!\" }\nend",
"def summon_captain_planet(planeteer_calls) # Your code here\n planeteer_calls.map {|powers| powers.capitalize.concat(\"!\")}\nend",
"def player_numbers (team_name)\n all_jersies = [];\n lookup_by_team(team_name)[:players].map { |player|\n all_jersies << player[:number];\n }\n all_jersies; \nend",
"def names\n map(&:name)\n end",
"def team_names\n fin_arr = []\n fin_arr << game_hash[:home][:team_name]\n fin_arr << game_hash[:away][:team_name]\n fin_arr\nend",
"def genre_names\n genres.map {|genre| genre.name}\n #create empty array\n #@movie.genres\n #call genres, because @movie is the instance itself already\n #run map to get each name of each genre instance\n #return map\n end",
"def nameArray\n myset = Testresult.all\n nameArray = Array.new\n i = 0\n myset.each do |obj|\n nameArray[i] = obj.name\n i += 1\n end\n nameArray\n end",
"def names()\n names = []\n names.push \"q-\"\n return names\n end",
"def names\n Array(@name)\n end",
"def player_names\n self.players.pluck(:username).join(\", \")\n end",
"def team_names\n teams = []\n teams << game_hash[:home][:team_name]\n teams << game_hash[:away][:team_name]\n return teams\nend",
"def super_heroes\n heroes = [\"iron man\", \"hulk\", \"black widow\", \"thor\", \"captain marvel\"]\n \n heroes.map(&:capitalize)\nend",
"def team_names\n output =[]\n game_hash.each do |location, team_data|\n output.push(team_data[:team_name])\n end\n output\nend",
"def team_names()\n result = []\n game_hash.each do |side,team|\n result.push(team[:team_name])\n end\n result\nend",
"def favorite_truck_names\n #favorites.pluck(:uname)\n ['go_burger']\n end",
"def get_pets\n if @pet_arr == []\n pet_info = \"No pets in system.\"\n else\n pet_info = @pet_arr.inject(\"\") do |pet_info_str, animal|\n pet_info_str << \"#{animal.name_str.capitalize} (#{animal.species_str}) \"\n end\n end\n return pet_info\n end",
"def names\n @songs.map(&:name).uniq\n end",
"def \n \n summon_captain_planet(planeteer_calls)\n \n planeteer_calls.map { |element| element.capitalize + \"!\" }\n \nend",
"def team_names\n names = []\n game_hash.each do |location, data|\n names << data[:team_name]\n end\n names\nend",
"def team_names\n # team_array = []\n # team_array.push(game_hash[:home][:team_name])\n # team_array.push(game_hash[:away][:team_name])\n # team_array\n game_hash.map do |location, team_data|\n team_data[:team_name]\n end\nend",
"def team_names\n new_array = []\n new_array<< game_hash[:home][:team_name]\n new_array<< game_hash[:away][:team_name]\n return new_array\nend",
"def select_names\n q = make_work\n # binding.pry\n names = []\n names.push(q.collect{|xx| xx[\"drinks\"][0][\"strDrink\"]})\n #names.push(q.collect{|xx| xx[\"drinks\"][0][\"strDrink\"]})\n names.push(q.collect{|xx| xx[\"drinks\"][1][\"strDrink\"]})\n #binding.pry\n #count +=1\n # end\n \n names\n end",
"def tag_names\n self.tags.map(&:name).join(\", \")\n #The & symbol is used to tell Ruby that the following argument\n #should be given as a block to the method. So the line:\n #self.tags.map(&.:name).join(\", \") is equal to\n #self.tags.map { |t| t.name.join(\", \")}\n #So the above will iterate over tyhe collection of elf.tags\n #and build an array with the resukts of the name method\n #called on every item\n end",
"def members_list\n all_lifters.map {|lifters| lifters.name}\n end",
"def names\n self.name.split(' ')\n end",
"def animal_nicknames()\n self.animals.map() { | animal | animal.nickname }\n end",
"def names\n planet_names = []\n @planets.each do |planet|\n planet_names << planet.name\n end\n return planet_names\n end",
"def summon_captain_planet(planeteer_calls)\n newArray = []\n i = 0\n while i < planeteer_calls.length do\n newArray.push(planeteer_calls[i].concat(\"!\").capitalize) \n i += 1\n end\n newArray\nend",
"def lifter_names_gym\n lifters_gym.map do |lifter|\n lifter.name\n end\n end",
"def summon_captain_planet(planeteer_calls)\n planeteer_calls.collect {|i| i + \"!\"}.map(&:capitalize)\nend",
"def get_names\n @names\n end",
"def players_names_array \n player_names = []\n game_hash.each do |place,team|\n team.each do |attribute, data|\n next unless attribute == :players\n data.each do |player| \n player_names.push(player[:player_name])\n end\n end\n end\n player_names\nend",
"def both_team_names(game)\n both_teams = []\n both_teams << game[:home_team][:team_name]\n both_teams << game[:away_team][:team_name]\n both_teams\nend",
"def print_all_type(type_ins)\n type_ins.pokemon_array.each.with_index(1) {|p,i| puts \"#{i}. #{p.name}\"}\n end",
"def names\n case name\n when \"Road\"\n [nil, \"\", 'Circuit', \"Criterium\", \"Road\", \"Time Trial\", \"Singlespeed\", \"Tour\"]\n when \"Mountain Bike\"\n ['Downhill', 'Mountain Bike']\n else\n [name]\n end\n end",
"def team_names\n # team_array = []\n game_hash.map do |location, team_data|\n # p team_data[:team_name]\n team_data[:team_name]\n end\nend",
"def internally_screaming\n people = [\"Taylor Swift\", \"Carly Rae Jeppsen\", \"Justin Bieber\"]\n\n people.map do |name|\n \"#{name} is bad at music\"\n end\n \nend",
"def team_names\n names = []\n game_hash.each do |k, team|\n names.push(team[:team_name])\n end\n names\nend",
"def animal_nicknames\n Animals.map { |animal| animal.nickname }\n end",
"def pbCreatePokemon\n party = []\n species = [:PIKACHU,:PIDGEOTTO,:KADABRA,:GYARADOS,:DIGLETT,:CHANSEY]\n for id in species\n party.push(getConst(PBSpecies,id)) if hasConst?(PBSpecies,id)\n end\n # Species IDs of the Jermon to be created\n for i in 0...party.length\n species = party[i]\n # Generate Jermon with species and level 20\n $Trainer.party[i] = PokeBattle_Pokemon.new(species,20,$Trainer)\n $Trainer.seen[species] = true # Set this species to seen and owned\n $Trainer.owned[species] = true\n pbSeenForm($Trainer.party[i])\n end\n $Trainer.party[1].pbLearnMove(:FLY)\n $Trainer.party[2].pbLearnMove(:FLASH)\n $Trainer.party[2].pbLearnMove(:TELEPORT)\n $Trainer.party[3].pbLearnMove(:SURF)\n $Trainer.party[3].pbLearnMove(:DIVE)\n $Trainer.party[3].pbLearnMove(:WATERFALL)\n $Trainer.party[4].pbLearnMove(:DIG)\n $Trainer.party[4].pbLearnMove(:CUT)\n $Trainer.party[4].pbLearnMove(:HEADBUTT)\n $Trainer.party[4].pbLearnMove(:ROCKSMASH)\n $Trainer.party[5].pbLearnMove(:SOFTBOILED)\n $Trainer.party[5].pbLearnMove(:STRENGTH)\n $Trainer.party[5].pbLearnMove(:SWEETSCENT)\n for i in 0...party.length\n $Trainer.party[i].pbRecordFirstMoves\n end\nend",
"def show_favorite_players(fan) #this method is backend finding the players of a specifc fan\n players_array = favorite_players(fan)\n players_array.each do |player|\n puts player.name \n end\nend",
"def index\n @pokemons = current_user.pokemon.to_a.sort! { |a,b| a.dex_number <=> b.dex_number }\n end",
"def build_list_of_players\nend",
"def list_planet_names\n list_planet_names = []\n planets_collection.each do |planet_name|\n list_planet_names << planet_name.name\n end\n return list_planet_names\n end",
"def team_names\n game_hash.map do |place, team|\n team[:team_name]\n end\nend",
"def summon_captain_planet(planeteer_calls) \n planeteer_calls.map do |n| \n n.capitalize << \"!\" \n end\nend",
"def just_names(list)\n names = list.map do |c|\n c[:name]\n end\n return names\nend",
"def pt_memb_name\n {:name=>$game_party.members[@party_index_tb].name}\n end",
"def create_pokemons\n @pokemons.each do |pokemon|\n create_pokemon(pokemon) unless Pokemon.where(name: pokemon['name']).first\n end\n @pokemons.each do |pokemon|\n assign_alolan_form(pokemon) if pokemon['alolan_form']\n end\n end",
"def name_variations(name)\n variations = []\n variations.push(name)\n variations.push(name.downcase)\n variations.push(name.upcase)\n variations.push(name.gsub(/[ _-]/, ''))\n return variations\nend",
"def team_names\n team_names = []\n for location in game_hash.keys\n team_names.push(game_hash[location][:team_name])\n end\n return team_names\nend",
"def tag_names #helper method\n # gets tag names in an array\n self.tags.map { |tag| tag.name }\n end",
"def player_numbers(team_name)\n array_of_jerseys = []\n one_team_stats(team_name)[:players].each do |player, stats|\n array_of_jerseys << stats[:number]\n end\n array_of_jerseys\nend",
"def super_heroes\n heroes = [\"iron man\", \"hulk\", \"black widow\", \"thor\", \"captain marvel\"]\n capitalized_heroes = []\n\n heroes.each do |heroe|\n capitalized_heroes << heroe.capitalize\n end\n\n capitalized_heroes\nend",
"def generate_participants\n participants_list = []\n (1..8).each do |_i|\n pokemon = get_random_pokemon(rand(1..151))\n pokemon_participant = Pokemon.new(get_name(pokemon), get_types(pokemon), get_stats(pokemon))\n participants_list.push(pokemon_participant)\n end\n participants_list\nend",
"def owner_names\n self.pets.map {|p| p.owner}.pluck(:name).uniq\n end",
"def convert_all_pokemon\n pokemon_json = []\n @data.each_with_index do |pokemons, id|\n forms = []\n pokemon_json << {\n regionalId: pokemons.first.id_bis,\n db_symbol: pokemons.first.db_symbol || :__undef__,\n id: id,\n forms: forms\n }\n pokemons.each { |pokemon| forms << convert_single_pokemon(pokemon) if pokemon }\n end\n return pokemon_json\n end",
"def summon_captain_planet(planeteer_calls)\n planeteer_calls.map { |element| element.capitalize! + \"!\"}\nend",
"def team_names\n teams = []\n teams << game_hash[:home][:team_name] << game_hash[:away][:team_name]\nend"
] |
[
"0.8352148",
"0.6975621",
"0.6961352",
"0.6800399",
"0.67062896",
"0.6685342",
"0.6606104",
"0.65480524",
"0.652607",
"0.65034187",
"0.63971573",
"0.63942194",
"0.6387897",
"0.6387897",
"0.6387897",
"0.6387897",
"0.6387897",
"0.6387897",
"0.6387897",
"0.63625735",
"0.6362492",
"0.6360385",
"0.6301773",
"0.6286952",
"0.6266452",
"0.625571",
"0.62545794",
"0.62526935",
"0.6249568",
"0.6249568",
"0.62484777",
"0.6190286",
"0.61794174",
"0.6178781",
"0.61751336",
"0.6172155",
"0.6161309",
"0.61098415",
"0.61060065",
"0.6102696",
"0.61016",
"0.60958076",
"0.6088219",
"0.6071513",
"0.6067625",
"0.60586154",
"0.60582465",
"0.6056926",
"0.60486346",
"0.6037283",
"0.60324717",
"0.60245556",
"0.60236764",
"0.6013062",
"0.6011712",
"0.6010028",
"0.6008523",
"0.60082835",
"0.60072494",
"0.59974706",
"0.59865886",
"0.59736353",
"0.59721035",
"0.59656876",
"0.59626",
"0.5952953",
"0.59517556",
"0.59495795",
"0.5947632",
"0.5941489",
"0.5935761",
"0.59307086",
"0.5929681",
"0.59273255",
"0.59251857",
"0.59195244",
"0.59141237",
"0.59119886",
"0.59034437",
"0.5893418",
"0.58904773",
"0.5885595",
"0.5881207",
"0.5878482",
"0.58706754",
"0.5863485",
"0.58612806",
"0.5860565",
"0.5859614",
"0.5856177",
"0.5846309",
"0.58432436",
"0.5836774",
"0.5836719",
"0.5836193",
"0.583154",
"0.5829382",
"0.58292454",
"0.5824232",
"0.5823274"
] |
0.82182777
|
1
|
You can provide the weight as a integer percentage 40 meaning 40%, or in decimal form. Therefore, 40% would be 0.4
|
def initialize(title, weight)
@grades = []
@title = title
# If the weight is an Integer convert it to a Float,
# else if is a float then pass it on unchanged.
@weight = weight.is_a?(Fixnum) ? weight/100.0 : weight
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def bakers_percent weight\n weight / bakers_percent_100.to_f\n end",
"def weight\n 2 # ounces\n end",
"def weight; end",
"def weight=(value)\n @weight = value\n end",
"def weight\n 0\n end",
"def weight_class\n if @weight < 215\n \"Lightweight\"\n elsif @weight < 230\n \"Cruiserweight\"\n elsif @weight < 300\n \"Heavyweight\"\n elsif @weight > 300\n \"Super Heavyweight\"\n else\n \"Heavyweight\"\n end\n end",
"def weighted_score\n score * metric.weight\n end",
"def normalized_weighting\n BigDecimal(weight.to_s) / ReputationRule.sum('weight')\n end",
"def calculate_bmi_fixed\n\tweight = 140\n\theight = 66\n\n\tbmi.round(2) = weight.to_f/height\n\n\tputs \"Your BMI is \" + bmi.to_s\nend",
"def weight_in_stones\n\t\t((@weight * 2.20462) / 14).to_i\n\tend",
"def calculate(height, weight)\n bmi = (weight / height) / height.to_f;\nend",
"def calc_total_weight\n 0\n end",
"def bmi\n ( weight.to_f / ( (height.to_f)**2 ) ) * 703.0\n end",
"def weight\n return nil if mass.nil?\n mass / 1000.0\n end",
"def product_weight\n price_calculator.weight\n end",
"def shipping_weight_price(weight)\n cost = case weight\n when nil then '0'\n when 0 ... 100 then '0.29'\n when 100 ... 500 then '2.60'\n when 500 ... 2000 then '4.99'\n when 20000 ... 50000 then '8.99'\n else '29.99'\n end\n currency.amount cost\n end",
"def calculate_bmi weight, height\n (weight.to_f / (height.to_f * height.to_f)) * 703\nend",
"def weight\n return @weight\n end",
"def bmi_calc height, weight\n return (weight / height**2).to_i\nend",
"def boost\n 1.0 #self.rating / 2.0\n end",
"def calculate_bmi(height,weight)\n ( weight / ( (height/100) * (height/100) ) )\n end",
"def weighted_probability(word)\n word = (Word === word ? word : get(word))\n\n p = BigDecimal.new(1)\n p = p * probability(word)\n p = p * file_probability(word, 1)\n #p = p * lexicon_weight(word)\n #p = p * weight_length(word)\n #p = p * weight_stem(word)\n #p = p * weight_plural(word)\n p\n end",
"def set_Weight(value)\n set_input(\"Weight\", value)\n end",
"def set_Weight(value)\n set_input(\"Weight\", value)\n end",
"def bmi weight , height\n total = (weight.to_f / (height.to_f ** 2)) * 10000\n\n puts \"--> Your BMI is... #{total}\"\nend",
"def range_weighting\n if @range.include?(25, 50)\n @weight_1 = 3\n elsif @range.include?(75, 100, 150)\n @weight_1 = 2\n else\n @weight_1 = 1\n end\n end",
"def weight w=nil\n if w.nil?\n @weight\n else\n @weight = w\n end\n end",
"def calculate_weight\n update_attribute :weight, votes.sum(:value)\n weight\n end",
"def rounded_weight\n @atomic_mass.round(4)\n end",
"def weight\n product_weight * quantity\n end",
"def weight\n product_weight * quantity\n end",
"def unit_weight\n (unit_area * product_thickness * 2.5).round(2)\n end",
"def convert_lbs_to_kg(weight)\n weight * 0.45\nend",
"def weight_in_words\n wt_kg = self.E16_01.to_f # in kg\n wt_lb = self.E16_88.to_f\n wt_in_lbs = wt_lb > 0 ? wt_lb : wt_kg*2.20462262\n \"%s lbs - %d kg\" % [((wt_in_lbs < 100) ? wt_in_lbs.round(1) : wt_in_lbs.round), wt_kg]\n end",
"def weight\n return data.weight\n end",
"def final_decision_weight_ratio_pretty\n reviewer_weight = final_decision_weight_ratio * 100\n interviewer_weight = 100 - reviewer_weight\n \"R=#{'%.0f' % reviewer_weight} / I=#{'%.0f' % interviewer_weight}\"\n end",
"def measurement_weight\n [\n ['ounce'],\n ['pounds']\n ]\n end",
"def prefer_metric_weight\n data[:prefer_metric_weight]\n end",
"def weight\n num_motions.zero? ? 0.5 : total_score.fdiv(max_score)\n end",
"def convert_weight(weight)\n\t\tpounds = weight[2, 3] #Pulls the 3rd (X), 4th (Y) and 5th (Z) digit from the format 00XYZdddd where 'd' is the decimal portion of the eVS weight convention\n\t\tounces = ((('0.' + weight[5, 4]).to_f)*16).round(1).to_s\n\t\tounces = ounces.to_f.round().to_s.rjust(3, ' ') if ounces.size > 3\n\t\treturn pounds, ounces\n\tend",
"def weight_lbl_value_187_workaround\n return \"pounds\" if RUBY_VERSION =~ /^1\\.8/\n @client.label_for_measurement(:weight)\n end",
"def weighted_score\n return nil if self.points.nil?\n self.points * self.weighting / self.maximum_points\n end",
"def weight\n if @weight\n @weight\n else\n @confines.length\n end\n end",
"def weight\n if @weight\n @weight\n else\n @confines.length\n end\n end",
"def calculate_price(weight)\n \n price = self.price\n \n if self.weights.size > 0\n proper_weight = self.weights.find(\n :first,\n :conditions => [\"? BETWEEN #{connection.quote_column_name(\"min_weight\")} AND #{connection.quote_column_name(\"max_weight\")}\", weight]\n )\n price = proper_weight.price if proper_weight\n end\n \n self.calculated_price = price.to_f.round(2) + Preference.get_value('store_handling_fee').to_f\n end",
"def calc_weight(mod, acc)\n fuel = calc_fuel(mod)\n fuel <= 0 ? acc : calc_weight(fuel, acc + fuel)\nend",
"def weightPolls()\n\n end",
"def weight_in_to_lbs(weight, lbs)\n return weight.to_f * lbs\nend",
"def show_weight_label_method\n \"#{self.weight}\"\n end",
"def mass(weight)\n return weight / FREE_FALL_ACCELERATION\n end",
"def check_weights\n until ((@personal_credit_weight + @industry_weight + @biz_age_weight) == 1.0)\n puts \"Your weights do not add up to 100%. please correct this.\"\n new_weights\n end\n end",
"def minweight(w)\n @weight = w if w<@weight\n end",
"def prom_weight\n if pet_histories.length > 0\n promw= pet_histories.sum(:weight)\n promw/pet_histories.length\n else\n \"0\"\n end\n end",
"def kilo_to_pound_converter(weight_kg)\n\t \t puts \"#{weight_kg} Kilos\"\n\t @weight_lb = ( (weight_kg) * (0.453592) ).to_f + \"\\s Pounds\"\n\t end",
"def bmi_calculator(height, weight)\n\tbegin\n\t\tweight / (height * height)\n\trescue\t\t\t\t\t\t\t\t\t#防呆機制\n\t\t# wrong\n\t\t' wrong '\n\tend\nend",
"def weight\n (kyc_level == 'any' ? 0 : 10) + (group == 'any' ? 0 : 1)\n end",
"def percentage_change\n return unless starting_weight && up_by\n @percentage_change ||= up_by.to_f / starting_weight * 100\n end",
"def weighting\n self.class.weighting\n end",
"def metric\n weight = get_weight(\"kg\")\n height = get_height(\"m\")\n\n bmi = \"#{weight / (height * height)}\"\n puts \"Your BMI is: #{bmi}\"\n return bmi\nend",
"def bmi_lb(weight_lb,height_in)\n\t \tputs \"Weight should be in Pounds and Height in Inches \"\n\t \t#puts \"Weight = 10lbs ; height = 160 Inches , 1 Foot = 12 Inches\"\n\t #@bmi_calac_lb = ( (weight_lb / (height_in * height_in)).round(2) ) * 703\n\t \t@bmi_calac_lb = ( (weight_lb) / (height_in * height_in).round(2) ) * 703.06957964\n\t end",
"def reduce_weight \n @weight -= WEIGHT_INCREMENT\n # increment could be confusing and imply an increase rather than a decrease \n # but it is being reduced by increments of 10 so it makes sense??? \n # It's the best of the names that came to mind.\n end",
"def maxweight(w)\n @weight = w if w>@weight\n end",
"def get_swe_line_weight(val)\n value = val.downcase\n default = 1\n\n weights = {\n 1 => 0.25,\n 2 => 1,\n 3 => 2,\n 4 => 3,\n 'hairline' => 0.25,\n 'narrow' => 1,\n 'medium' => 2,\n 'wide' => 3\n }\n\n weights[value] || default\n end",
"def default_values\n self.weight ||= 10.0\n end",
"def battery_weight; end",
"def has_weight(weight)\n @weight = weight\n end",
"def weight\n order_lines.inject(0) { |sum, l| sum + l.weight }\n end",
"def calc_point_weight(weight, distance)\n case weight\n when 'uniform' then UNIFORM_WEIGHT\n when 'distance' then 1 / distance**2\n else UNIFORM_WEIGHT\n end\n end",
"def percentage; end",
"def test_provided_weight_example\n assert_equal 60, @system.corrected_tower.weight\n end",
"def measure() @measure ||= (nb_weight == 0.0 ? 0.0 : sum_weight / nb_weight) end",
"def total_weight\r\n\t\t@items.inject(0.0) { |sum, i| sum + i.total_unit_weight * i.quantity }\r\n\tend",
"def test_total_weight\n assert_equal(0 , @wp00.total_weight)\n assert_equal(384, @wp01.total_weight)\n assert_equal(576, @wp02.total_weight)\n end",
"def real_weight(tracking_number)\n begin\n tracking_info = fedex.track(tracking_number: tracking_number)\n package_weight = tracking_info.first.details[:package_weight]\n package_weight[:units] == 'LB' ? package_weight[:value].to_f/2.2046 : package_weight[:value]\n rescue\n 0\n end\n end",
"def weight\n @mass * @hopper.size\n end",
"def volume_to_weight(amount)\n amount = amount.to_unit\n return amount if amount.to_base.units == \"kg\"\n \n standard_unit = weight_1_description.split(\",\").first.to_unit\n \n # standard_unit.scalar is usually 1, but just in case we'll use the actual value\n weight_1.to_unit(\"grams\") * standard_unit.scalar * amount.convert_to(standard_unit.units).scalar\n end",
"def weight=(weight)\n validator = EnumAttributeValidator.new('String', [\"80#\"])\n unless validator.valid?(weight)\n fail ArgumentError, \"invalid value for \\\"weight\\\", must be one of #{validator.allowable_values}.\"\n end\n @weight = weight\n end",
"def get_weight\n ((@contents[/(?<=(Shipping Weight:<\\/b>)\\s).*(?=\\s\\()/])[/\\d*.\\d*/]).to_f.round_to(2)\n\n end",
"def google_merchant_shipping_weight\n return unless self.weight.present?\n weight_units = 'oz' # need a configuration parameter here\n format(\"%s %s\", self.weight, weight_units)\n end",
"def percent_passes; end",
"def percent_passes; end",
"def price_per_g\n\t\tself['price'].to_f / self['unit_weight'].to_f\n\tend",
"def humanWeights\n\n # Get the weights into an array and then find the width in digits of the\n # largest weight.\n\n weights = to_weights\n widths = Array.new\n weights.each { |w| widths.push(Utility.numWidth(w)) }\n theWidth = widths.max\n\n # Make a TextRect column of the weights.\n\n theFormat = \" %#{theWidth}d, # \"\n theStrs = Array.new\n weights.each { |w| theStrs.push(theFormat % w) }\n theNums = TextRect.new(theStrs)\n\n # Now make a TextRect column of the text of the rules themselves.\n\n theRules = Array.new\n @ruleTable.each_index { |i| theRules.push(@ruleTable[i][:rule].to_s) }\n\n # Now put the parts together and return the result.\n\n theNums.join!(theRules)\n theTop = TextRect.new('[')\n theTop.below!(theNums)\n theTop.below!(TextRect.new(']'))\n \n theTop\n \n end",
"def weight\n puts 'used custom getter'\n 2\n end",
"def weight()\n\t\t@pokemon_api[\"weight\"]\n\tend",
"def total_weight(dimensions)\n volumetric_weight = (dimensions['width'] * dimensions['height'] * dimensions['length']) / 5000\n volumetric_weight > dimensions['weight'] ? volumetric_weight : dimensions['weight']\n end",
"def compute_score\n\n total_score=0\n total_weights=0\n self.class.field_mappings.each do |field_name,field_config|\n if !field_config[:weight].blank?\n total_score += field_config[:weight].to_f * (self.class.blank_value?(self.send(field_name)) ? 0 : 1) # if the field is blank, it is a 0 regardless of weight, otherwise it is a 1 times its weight\n total_weights += field_config[:weight].to_f\n end\n end\n\n return ((total_score/total_weights)*100).ceil\n\n end",
"def molecular_weight\n @mw ||= begin\n mass = WATER_MASS\n each_aa do |aa|\n mass += AVERAGE_MASS[aa.to_sym]\n end\n (mass * 10).floor().to_f / 10\n end\n end",
"def weight\n @weight || @confines.length\n end",
"def weight r, h\n len_r = r.magnitude\n\n if len_r.xbetween? 0, h\n 315.0 / (64 * Math::PI * h**9) * (h**2 - len_r**2)**3\n else\n 0.0\n end\n end",
"def corrected_rating\n [(weighted_rating + 2) * 1.6666666666666667, 5.0].min\n end",
"def remaining_pints\n ((current_weight-14.25)/0.45).to_i > 0 ? ((current_weight-14.25)/0.45).to_i : 0\n end",
"def addweight(w)\n @weight += w\n end",
"def volume_weight(dimension: nil)\n factor = 5000\n volume_weight = Float((dimension.length * dimension.width * dimension.height)) / Float(factor)\n\n return volume_weight\n end",
"def weight\n\t\tweight = 0\n\t\tself.order_line_items.each do |item|\n\t\t\tweight += item.quantity * item.product.weight\n\t\tend\n\t\treturn weight\n\tend",
"def weighted_score(score, avg_score)\n #add if statement if score is 0\n if(score==0)\n return\n end\n return (avg_score + 215)/score\n end",
"def school_type_weight\n case school_type\n when 'k8'\n esd_k8_2017s ? esd_k8_2017s.total_pts.to_f * 100 : 0\n when 'hs'\n esd_hs_2016s ? esd_hs_2016s.total_pts.to_f * 100 : 0\n when 'ecs'\n if early_childhood_rating == 'Below Bronze'\n # Give Pre-K schools without a medal a score penalty\n ec_state_ratings.total_points.to_f / 15 * 100 / 2\n else\n ec_state_ratings.total_points.to_f / 15 * 100\n end\n else\n 0\n end\n end",
"def final_decision_weight_ratio\n r = read_attribute(:final_decision_weight_ratio)\n (r.nil? || r.zero?) ? 0.5 : r\n end",
"def sort_weight\n if !ec? && (excellent_schools_grade == 'N/A' || excellent_schools_grade == 'New') && recommended?\n # Put Recommended schools that don't have a grade, between C+ and C schools\n 49.5\n else\n school_type_weight\n end\n end",
"def weights(server, backend, weight=nil)\n if(weight.nil?)\n weight = @socket.execute \"get weight #{backend}/#{server}\"\n /(\\d*)\\s\\(initial\\s(\\d*)\\)/.match( weight[0])\n {:current => $1.to_i, :initial => $2.to_i}\n else\n @socket.execute \"set weight #{backend}/#{server} #{weight}\"\n end\n end"
] |
[
"0.80317044",
"0.74939483",
"0.73584646",
"0.7265818",
"0.7246008",
"0.7162207",
"0.7044672",
"0.70015055",
"0.70014066",
"0.6976318",
"0.6963033",
"0.6956574",
"0.69250095",
"0.6909406",
"0.6846733",
"0.6839247",
"0.68391454",
"0.6834041",
"0.6819097",
"0.68037474",
"0.6760116",
"0.6755186",
"0.6745889",
"0.6745889",
"0.6736814",
"0.670655",
"0.6687998",
"0.66860855",
"0.6666537",
"0.66552025",
"0.66552025",
"0.6627012",
"0.6607867",
"0.65789866",
"0.65698737",
"0.6555852",
"0.653218",
"0.6525129",
"0.652472",
"0.6522402",
"0.6520953",
"0.64972866",
"0.64860773",
"0.64860773",
"0.6477362",
"0.6475128",
"0.64667594",
"0.6459507",
"0.64508456",
"0.6436803",
"0.6405507",
"0.6404403",
"0.6395899",
"0.6393709",
"0.6393446",
"0.6388383",
"0.63865083",
"0.63806087",
"0.63769805",
"0.6358672",
"0.63577414",
"0.6356266",
"0.6354618",
"0.6347692",
"0.6340326",
"0.63383496",
"0.63356113",
"0.6331556",
"0.6318921",
"0.6315079",
"0.6311597",
"0.6306536",
"0.630568",
"0.6298508",
"0.62811595",
"0.62804705",
"0.6271846",
"0.6271769",
"0.6268055",
"0.62678736",
"0.62678736",
"0.6262307",
"0.6251642",
"0.62217075",
"0.62184",
"0.6208675",
"0.62074864",
"0.6205889",
"0.619126",
"0.6190923",
"0.6182665",
"0.61771834",
"0.6174033",
"0.6164746",
"0.6160888",
"0.61548436",
"0.6150655",
"0.6150569",
"0.6133189",
"0.6126252"
] |
0.6298062
|
74
|
Use callbacks to share common setup or constraints between actions.
|
def find_resource
@resource = resource_class.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Never trust parameters from the scary internet, only allow the white list through.
|
def resource_params
raise NotImplementedError
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \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 model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"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 url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def backend_user_params\n params.permit!\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] |
[
"0.6981269",
"0.6783559",
"0.6746007",
"0.67423046",
"0.6735905",
"0.6593568",
"0.6504213",
"0.649792",
"0.6482664",
"0.6478558",
"0.64566684",
"0.64392304",
"0.6380194",
"0.6376366",
"0.636562",
"0.63208145",
"0.63006365",
"0.63001287",
"0.6292953",
"0.62927175",
"0.62911004",
"0.6290563",
"0.6284484",
"0.62436926",
"0.6239928",
"0.62184125",
"0.62158304",
"0.6210187",
"0.6194002",
"0.61786795",
"0.61759156",
"0.617342",
"0.6162248",
"0.61528504",
"0.61527",
"0.6146735",
"0.6122714",
"0.61169004",
"0.61082125",
"0.61052656",
"0.6091036",
"0.60807735",
"0.6070328",
"0.60634184",
"0.60213035",
"0.6017676",
"0.6013606",
"0.601112",
"0.6007318",
"0.6007318",
"0.6001461",
"0.6001135",
"0.59966296",
"0.5992013",
"0.59919006",
"0.599182",
"0.5980991",
"0.59676576",
"0.5960269",
"0.59588194",
"0.59585214",
"0.59578323",
"0.5953503",
"0.5952524",
"0.59432703",
"0.5939858",
"0.59388995",
"0.59388995",
"0.5933866",
"0.5930038",
"0.5925672",
"0.5924214",
"0.59169805",
"0.59106255",
"0.5910254",
"0.59086037",
"0.5906149",
"0.5898294",
"0.58981514",
"0.5896171",
"0.58944154",
"0.58943397",
"0.5892325",
"0.5887239",
"0.58842856",
"0.5880209",
"0.5874584",
"0.58694917",
"0.5868719",
"0.58669394",
"0.5866552",
"0.58662945",
"0.5864085",
"0.58623236",
"0.5862258",
"0.58597904",
"0.58579135",
"0.58542645",
"0.5853335",
"0.58517563",
"0.5850614"
] |
0.0
|
-1
|
List institution by id
|
def show
institution = Institution.find(params[:id])
render json: { status: '200', message: "Loaded Institution with id #{params[:id]}", data: institution }, status: :ok
rescue ActiveRecord::RecordNotFound
render json: { status: '404', error: "No Institution with id #{params[:id]}", data: institution }, status: :not_found
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def institution(id = nil)\n res = Connection.get('institutions', id)\n id.nil? ? Institution.all(res) : Institution.new(res)\n end",
"def institution(id=nil)\n @institution = Plaid::Institution.new\n res = self.get('institutions',id)\n id.nil? ? @institution.instantiate_all_institutions(res) : @institution.instantiate_one_institution(res)\n end",
"def get_institution(id)\r\n # Prepare query url.\r\n _path_url = '/institutions/{id}'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'id' => id\r\n )\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n Institution.from_hash(decoded)\r\n end",
"def set_catalogs_institution\n @catalogs_institution = Catalogs::Institution.find(params[:id])\n end",
"def index\n @institucion = Institucion.where(:id => params[:institucion_id]).first\n @institucioncatalogos = Institucioncatalogo.where(:institucion_id => params[:institucion_id])\n end",
"def index\n if(current_user.super_admin?)\n @institutions = Institution.all.paginate(page: params[:page], per_page: 15)\n else\n @institutions = Institution.all.where(id: current_institution.id).paginate(page: params[:page], per_page: 15)\n end\n end",
"def institution(institution, options={})\n self.class.get(\"/Institution/#{institution}.json\", options)\n end",
"def index\n @educational_institutions = EducationalInstitution.all\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def inst_list(inst_id)\n uri = URI.parse(@url + '/' + inst_id) \n http = Net::HTTP.new(uri.host, uri.port, @proxy_addr, @proxy_port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n request.basic_auth user, passwd\n request.add_field 'X-ID-TENANT-NAME', id_domain\n http.request(request)\n end",
"def show\n @insumolabores = Insumolabore.where(:labor_id => params[:id])\n end",
"def institution\n ::HubEdos::StudentApi::V2::StudentRecord::Institution.new(@data['institution']) if @data['institution']\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution }\n end\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution }\n end\n end",
"def index\n @catalogs_institutions = Catalogs::Institution.search(params[:search]).order(\"#{sort_column} #{sort_direction}\").paginate(per_page: 15, page: params[:page])\n end",
"def index\n @cms_affiliations = Cms::Affiliation.all\n end",
"def set_institution\n @institution = current_user.institutions.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: { errors: [I18n.t('api.institution.not_found')] }, status: :not_found\n end",
"def find_institute\n @institute = Institute.find(params[:id])\n end",
"def search\n @institutions = Institution.order(:nome).where(\"nome ilike ?\", \"%#{params[:term]}%\")\n render json: @institutions.map{|institution| {:label => institution.nome, :value => institution.id}}\n end",
"def incident_list_by_id(statuspage_id)\n request :method => :get,\n :url => @url + 'incidents/' + statuspage_id\n end",
"def show\n @institution = current_institution\n end",
"def index\n @institutions = current_user.institutions\n end",
"def index\n @identities = Identity.all\n end",
"def index\n @identities = Identity.all\n end",
"def institution_param_name\n 'institution'\n end",
"def index\n @institutes = Institute.all\n authorize Institute\n end",
"def set_institution\n @institution = Institution.friendly.find(params[:id])\n authorize @institution\n end",
"def set_institution\n @institution = Institution.friendly.find(params[:id])\n authorize @institution\n end",
"def catalog\n if @sub_service_request\n @institutions = Institution.where(id: @sub_service_request.organization.parents.select{|x| x.type == 'Institution'}.map(&:id))\n else\n @institutions = Institution.order('`order`')\n end\n\n setup_catalog_calendar\n setup_catalog_news_feed\n end",
"def index\n @institucions = Institucion.search(params[:search], params[:page])\n end",
"def incident_list(statuspage_id)\n request :method => :get,\n :url => @url + 'incident/list/' + statuspage_id\n end",
"def show\n @institution_ad = InstitutionAd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institution_ad }\n end\n end",
"def index\n authorize HigherEducationInstitution\n @higher_education_institutions = HigherEducationInstitution.order(:name).search(params[:search]).page(params[:page])\n end",
"def users\n User.where(institution_id: self.id).to_a.sort_by(&:name)\n end",
"def index\n @issuing_institutions = IssuingInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @issuing_institutions }\n end\n end",
"def index\n #binding.pry\n @insta = Instum.all.includes(:user)\n end",
"def index\n @insta_accounts = InstaAccount.all\n end",
"def get_interests_by_id\n return filter_by_id(get_interests)\n end",
"def list\n session[:project]=params[:id];\n # @alumnis=Alumni.all\n @alumnis=Alumni.search(params[:search])\n end",
"def set_institution\n @institution = Institution.find params[:id]\n authorize @institution\n end",
"def index\n @admin_itineraries= City.find(session[:current_city_id]).discover.itineraries.page(params[:page]).per(10)\n end",
"def show\n @institute_admin = InstituteAdmin.includes(:profile).find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @institute_admin }\n end\n end",
"def list(id)\n get(\"lists/#{id}\").list\n end",
"def get_institution_user(id)\r\n # Prepare query url.\r\n _path_url = '/institution_users/{id}'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'id' => id\r\n )\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n InstitutionUserDetail.from_hash(decoded)\r\n end",
"def index\n @one_reg_institutions = OneRegInstitution.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @one_reg_institutions }\n end\n end",
"def index\n @institute_admins = case current_user.rc\n when 'EA'\n InstituteAdmin.includes(:profile).page(params[:page])\n when 'IA'\n InstituteAdmin.includes(:profile).where(:id=>current_user.institute_admin).page(params[:page])\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @institute_admins }\n end\n end",
"def get_institutions\r\n # Prepare query url.\r\n _path_url = '/institutions'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n decoded.map { |element| Institution.from_hash(element) }\r\n end",
"def show\n @one_reg_institution = OneRegInstitution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @one_reg_institution }\n end\n end",
"def index\n @projects = current_institute.projects\n end",
"def show\n @institution = Institution.find(params[:id])\n\n render json: @institution\n\n rescue ActiveRecord::RecordNotFound\n render json: {message: 'Resource not found'}, status: 404\n\n end",
"def index\n @invitations = Invitation.where(organization_id: current_user.organization_id).all\n end",
"def show\n @issuing_institution = IssuingInstitution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @issuing_institution }\n end\n end",
"def show\n @financial_institution = FinancialInstitution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @financial_institution }\n end\n end",
"def index\n authorize MetadataProfile\n @profiles = MetadataProfile.\n where(institution: current_institution).\n order(:name)\n end",
"def index\n @labs = Lab.all\n @lab = Lab.find_by_id(params[:lab_id])\n end",
"def index\n @issuers = Issuer.all\n end",
"def fetch_plans (id = nil)\n @plans = []\n parameters = {}\n @networks_by_plan = {}\n parameters[:_profile] = 'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/plannet-InsurancePlan' \n if(id)\n parameters[:_id] = id\n end\n\n @client.search(\n FHIR::InsurancePlan,\n search: { parameters: parameters }\n )&.resource&.entry&.map do |entry|\n @plans << {\n value: entry&.resource&.id,\n name: entry&.resource&.name\n }\n @networks_by_plan [ entry&.resource&.id] = entry&.resource&.network\n end\n @plans.sort_by! { |hsh| hsh[:name] }\n rescue => exception\n redirect_to root_path, flash: { error: 'Please specify a plan network server' }\n\n end",
"def index\n @idds = Idd.all\n end",
"def index\n @insts = Inst.all\n end",
"def index\n @universities = University.all\n end",
"def institution\n @institution ||= Institutions.institutions[institution_code.to_sym]\n end",
"def institution\n @institution ||= Institutions.institutions[institution_code.to_sym]\n end",
"def index\n @instalers = Instaler.all\n end",
"def index\n set_enrolment\n if @enrolment\n @student_ids = @enrolment.student_ids\n else\n @student_ids = StudentId.all\n @notice = \"Displaying All Ids\"\n end\n end",
"def show\n authorize @institute\n @admins = User.where(role:3,institute_id: @institute.id)\n @students = User.where(role:1,institute_id: @institute.id)\n end",
"def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end",
"def institutions(pageIndex=0, options={})\n options.merge!({:query => {:pageIndex => pageIndex}})\n self.class.get(\"/Institutions.json\", options)\n end",
"def show\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @institution }\n format.json {render :json => {\"success\"=>true,\"data\"=>@institution} }\n \n end\n end",
"def index\n @intranet_substitutos = Intranet::Substituto.all\n end",
"def index\n if user_signed_in?\n if current_user.role != 2\n redirect_to root_path\n else\n @institute_user = InstituteUser.find_by user_id: current_user.id\n @institute = Institute.find(@institute_user.institute_id)\n #@students = Student.all\n\n @query = Student.where(\"institute_id = ?\", @institute.id).ransack(params[:q])\n @institute_students = @query.result \n end\n else\n redirect_to root_path\n end\n end",
"def index\n @laboratorio_laboratorists = LaboratorioLaboratorist.all\n end",
"def show\n @institutions = @tesda_course.institutions\n end",
"def show\n @course = Course.find(params[:id])\n @enrollments = Enrollment.where(\"course_id = ?\", params[:id].to_s)\n end",
"def index\n @ids = Id.all\n end",
"def index\n authorize IndexPage\n @index_pages = IndexPage.\n where(institution: current_institution).\n order(:name)\n end",
"def set_institucioncatalogo\n @institucioncatalogo = Institucioncatalogo.find(params[:id])\n end",
"def retrieve(id)\n @client.make_request(:get, \"insurances/#{id}\", MODEL_CLASS)\n end",
"def get_laboratory(id)\n Laboratory.where(patient_id: current_resource_owner.viewable_patients).find_by(id: id)\n end",
"def show\n # Se ordenaran alfabeticamente por orden de unidad\n # @secuencia = GranUnidad.select(:id, :region_militar_id).order(:region_militar_id).ids\n @array = ActiveRecord::Base.connection.execute(\"SELECT gu.id FROM gran_unidad gu INNER JOIN region_militar rm ON gu.region_militar_id = rm.id ORDER BY rm.nombre\")\n @secuencia = []\n @array.each do |item|\n @secuencia << item[\"id\"]\n end\n @gran_unidad = GranUnidad.find(params[:id])\n @breadcrumb.push << {nombre: @gran_unidad.nombre, url: @gran_unidad}\n @unidades = @gran_unidad.unidad\n end",
"def index\n @laboratorists = Laboratorist.all\n end",
"def index\n @estadocivils = Estadocivil.all\n end",
"def show\n @issuance = Issuance.where(id: params[:id]).first\n end",
"def list \n @organizations = Organization.all\n \n render \"list\"\n end",
"def load_institutions\n # Get Solr institution pids from the SQL db.\n pid_for = {}\n query = \"select id, identifier from institutions\"\n if @inst_query.nil?\n @inst_query = @db.prepare(query)\n end\n result_set = @inst_query.execute\n result_set.each_hash do |row|\n # Sample entry: pids['miami.edu'] = 'aptrust-test:350660'\n pid_for[row['identifier']] = row['id']\n @name_of[row['id']] = row['identifier']\n end\n\n # Load institutions from Pharos and map old Solr pid to new id\n url = @base_url + '/api/v2/institutions'\n resp = api_get(url, nil)\n if resp.code != '200'\n @log.write(\"Error getting institutions from Pharos\\n\")\n @log.write(resp.body)\n exit(1)\n end\n data = JSON.parse(resp.body)\n data['results'].each do |inst|\n solr_pid = pid_for[inst['identifier']]\n @new_id_for[solr_pid] = inst['id']\n @id_for_name[inst['identifier']] = inst['id']\n puts \"#{inst['identifier']} has id #{inst['id']}\"\n end\n end",
"def managed_list(inst_id)\n uri = URI.parse(@url + \"/#{inst_id}/servers\") unless @server_name\n uri = URI.parse(@url + \"/#{inst_id}/servers/\" + @server_name) if @server_name\n http = Net::HTTP.new(uri.host, uri.port, @proxy_addr, @proxy_port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n request.add_field 'X-ID-TENANT-NAME', id_domain\n http.request(request)\n end",
"def show\n @itens = @genero.itens.group(\"itens.id\").paginate(page: params[:page], :per_page => 30)\n end",
"def index\n if params[:term] != nil\n if params[:type] != nil\n @institutions = Institution.find(:all, :conditions => [\"LOWER(nom) LIKE LOWER(?) and type_institution_id=?\", \"%#{params[:term]}%\", \"#{params[:type]}\"])\n else\n @institutions = Institution.find(:all, :conditions => [\"LOWER(nom) LIKE LOWER(?)\", \"%#{params[:term]}%\"])\n end\n else\n @institutions = current_user.parametres_cabinet.institutions.all\n end\n \n \n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @institutions }\n format.js {render :json => @institutions.map {|p| { :label => p.nom , :value => p.id}} }\n format.json {render :json => {\"success\"=>true,\"data\"=>@institutions} }\n \n end\n end",
"def in_city_id\n\t\t@studioNames = Array.new\n\t\t\n\t\tStudio.in_city(City.find(params[:id])).each do |studio|\n\t\t\t@studioNames << [studio.id, studio.to_s]\n\t\tend\n\t\t\n\t\trespond_to do |format|\n\t\t\tformat.json { render :json => @studioNames } \n\t\tend\n\tend",
"def set_financial_institutions1\n @financial_institutions1 = FinancialInstitutions1.find(params[:id])\n end",
"def index\n authorize UserGroup\n @user_groups = UserGroup.where(institution: current_institution).order(:name)\n end",
"def index\n @project = Project.find(params[:project_id])\n @integrants = User.all\n end",
"def index\n @industria = Industrium.all\n end",
"def index\n @people = current_organization.people.all\n end",
"def index\n @piiza_ids = PiizaId.all\n end",
"def index\n unless current_user.instructor\n render :nothing => true, :status => :unauthorized\n end\n\n @students = $selected_course.students.collect{|student| {name: student.first + ' ' + student.last, student_id: student.id }}\n end",
"def lasids\n render json: Student.all.pluck(:local_id) # not just active students\n end"
] |
[
"0.7553722",
"0.72237504",
"0.64025193",
"0.63459146",
"0.6315954",
"0.6314081",
"0.6272273",
"0.62659115",
"0.6217061",
"0.6211757",
"0.6166694",
"0.61565566",
"0.6101913",
"0.6101913",
"0.6101913",
"0.6101913",
"0.60868335",
"0.60868335",
"0.60103387",
"0.5995426",
"0.5979401",
"0.59691983",
"0.5965793",
"0.5948603",
"0.5947178",
"0.5940908",
"0.5874077",
"0.5874077",
"0.5839983",
"0.58384025",
"0.5776831",
"0.5776831",
"0.5773312",
"0.5765373",
"0.57560545",
"0.57556325",
"0.5745652",
"0.57278824",
"0.5721612",
"0.5716343",
"0.57151955",
"0.5687196",
"0.56537604",
"0.5647699",
"0.56449044",
"0.56249434",
"0.56213766",
"0.56196886",
"0.5619013",
"0.5614445",
"0.5610126",
"0.5600973",
"0.5598889",
"0.5588173",
"0.5584912",
"0.55835813",
"0.55808157",
"0.5568539",
"0.5560869",
"0.5560301",
"0.55553263",
"0.5547245",
"0.55472004",
"0.5521134",
"0.55183434",
"0.55183434",
"0.55125755",
"0.5507255",
"0.5494986",
"0.549324",
"0.54887974",
"0.5485598",
"0.54841083",
"0.54789096",
"0.5456962",
"0.5440865",
"0.54379517",
"0.5436872",
"0.5432979",
"0.5426169",
"0.5425893",
"0.5404744",
"0.53994805",
"0.53877366",
"0.5376146",
"0.53734255",
"0.536495",
"0.53616154",
"0.53562355",
"0.535467",
"0.5351829",
"0.53471017",
"0.53460246",
"0.5344391",
"0.53387004",
"0.53254086",
"0.5323479",
"0.5322318",
"0.5319886",
"0.5316782"
] |
0.6011277
|
18
|
Update institution by id Handling errors from not finding the id and wrong data
|
def update
institution = Institution.find(params[:id])
if institution.update(institution_params)
render json: { status: '200', message: "Updated Institution with id #{params[:id]}", data: institution }, status: :ok
else
render json: { status: '422', error: 'Institution not updated', data: institution.errors }, status: :unprocessable_entity
end
rescue ActiveRecord::RecordNotFound
render json: { status: '404', error: "No Institution with id #{params[:id]}", data: institution }, status: :not_found
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_institution\n @institution = current_user.institutions.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: { errors: [I18n.t('api.institution.not_found')] }, status: :not_found\n end",
"def update\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n if @institution.update_attributes(params[:institution])\n format.html { redirect_to @institution, notice: 'Institution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @institution.update(institution_params)\n render :show, status: :ok, location: @institution\n else\n render json: @institution.errors, status: :unprocessable_entity\n end\n end",
"def update\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n if @institution.update_attributes(params[:institution])\n format.html { redirect_to(institutions_url, :notice => 'Institution was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @institution.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @issuing_institution = IssuingInstitution.find(params[:id])\n\n respond_to do |format|\n if @issuing_institution.update_attributes(params[:issuing_institution])\n format.html { redirect_to @issuing_institution, :notice => 'Orgão Emissor atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @issuing_institution.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @one_reg_institution = OneRegInstitution.find(params[:id])\n\n respond_to do |format|\n if @one_reg_institution.update_attributes(params[:one_reg_institution])\n format.html { redirect_to @one_reg_institution, notice: 'One reg institution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @one_reg_institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @institution_ad = InstitutionAd.find(params[:id])\n\n respond_to do |format|\n if @institution_ad.update_attributes(params[:institution_ad])\n format.html { redirect_to ([:administrator, @institution_ad]), notice: 'Institution ad was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @institution_ad.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @institution.update(institution_params)\n format.html { redirect_to @institution, notice: 'Instituição atualizada com sucesso.' }\n format.json { render :show, status: :ok, location: @institution }\n else\n format.html { render :edit }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @institution.update(institution_params)\n format.html { redirect_to @admin_institution, notice: 'Institution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @admin_institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @institution = Institution.find(params[:id])\n\n respond_to do |format|\n if @institution.update_attributes(params[:institution])\n format.html { redirect_to(@institution, :notice => 'Institution was successfully updated.') }\n format.xml { head :ok }\n format.json {render :json => {\"success\"=>true,\"data\"=>@institutions} }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @institution.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def update_institution(inst_name, inst_site, inst_phone, inst_email)\n old_institution = @institutions.select { |hash| hash[:name] == inst_name }.first\n if inst_name == old_institution[:name] && inst_site == old_institution[:website] &&\n inst_phone == old_institution[:phone_number] && inst_email == old_institution[:email]\n return old_institution\n else\n inst = Institution.find_by(id: old_institution[:id])\n inst.update(website: inst_site, phone_number: inst_phone,\n email: inst_email)\n @institutions.delete_if { |hash| hash[:id] == old_institution[:id] }\n @institutions << inst\n end\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def set_institution\n @institution = Institution.find(params[:id])\n end",
"def update\n autorize! :update, @catalogs_institution\n if @catalogs_institution.update(catalogs_institution_params)\n flash[:success] = t('notices.updated_successfully')\n index\n end\n end",
"def update\n if(current_user.super_admin?)\n if @institution.update(institution_params)\n redirect_to @institution, notice: \"Institution was successfully updated.\"\n else\n render :edit, status: :unprocessable_entity\n end\n end\n end",
"def update\n @financial_institution = FinancialInstitution.find(params[:id])\n\n respond_to do |format|\n if @financial_institution.update_attributes(financial_institution_params)\n format.html { redirect_to @financial_institution, notice: 'Financial institution was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @financial_institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @counselor = Counselor.find(params[:id])\n flash[:notice] = 'Counselor was successfully updated.' if @counselor.update_attributes(params[:counselor])\n respond_with([@institution, @counselor], :location => institution_url(@institution))\n end",
"def update\n @record = @institution\n respond_to do |format|\n if @institution.update(institution_params)\n format.html { redirect_to @institution, notice: 'Institution was successfully updated.' }\n format.json { render :show, status: :ok, location: @institution }\n format.js { render :file => \"/basic/update.js.erb\" }\n else\n format.html { render :edit }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n format.js { render :file => \"/basic/update.js.erb\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @educational_institution.update(educational_institution_params)\n format.html { redirect_to @educational_institution, notice: 'Educational institution was successfully updated.' }\n format.json { render :show, status: :ok, location: @educational_institution }\n else\n format.html { render :edit }\n format.json { render json: @educational_institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @institucional = Institucional.find(params[:id])\n\n respond_to do |format|\n if @institucional.update_attributes(params[:institucional])\n format.html { redirect_to @institucional, notice: 'Institucional was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @institucional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def institution_id=(new_institution_id)\n\t\tif organisation.nil? then\n\t\t\tself.organisation_id = new_institution_id\n\t\tend\n\tend",
"def update\n @breadcrumb = 'update'\n @insurance = Insurance.find(params[:id])\n @insurance.updated_by = current_user.id if !current_user.nil?\n \n respond_to do |format|\n if @insurance.update_attributes(params[:insurance])\n format.html { redirect_to @insurance,\n notice: (crud_notice('updated', @insurance) + \"#{undo_link(@insurance)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @valores = Catalogo.all\n @institucion = Institucion.where(:id => institucioncatalogo_params['institucion_id']).first\n respond_to do |format|\n if @institucioncatalogo.update(institucioncatalogo_params)\n format.html { redirect_to institucion_institucioncatalogos_url(@institucion), notice: 'El registro se ha actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @institucioncatalogo }\n else\n format.html { render :edit }\n format.json { render json: @institucioncatalogo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_institution\n @institution = Institution.friendly.find(params[:id])\n authorize @institution\n end",
"def set_institution\n @institution = Institution.friendly.find(params[:id])\n authorize @institution\n end",
"def set_institution\n @institution = Institution.find params[:id]\n authorize @institution\n end",
"def update\n @institute = Institute.find(params[:id])\n\n respond_to do |format|\n if @institute.update_attributes(params[:institute])\n format.html { redirect_to(@institute, :notice => 'Institute was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @institute.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize HigherEducationInstitution\n respond_to do |format|\n if @higher_education_institution.update(higher_education_institution_params)\n format.html { redirect_to @higher_education_institution, notice: 'Visokošolski zavod uspešno posodobljen.' }\n format.json { render :show, status: :ok, location: @higher_education_institution }\n else\n format.html { render :edit }\n format.json { render json: @higher_education_institution.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @issuance = Issuance.where(id: params[:id]).first\n @issuance.update_attributes(issuance_params)\n if @issuance.errors.empty?\n redirect_to issuance_path(@issuance)\n else\n render \"edit\"\n end\n end",
"def update\n @alumini = Alumini.find(params[:id])\n @universities = University.all\n @university = University.find(:first,:conditions => [\"name = ?\",private_mw])\n respond_to do |format|\n if @alumini.update_attributes(params[:alumini])\n flash[:notice] = 'Alumini was successfully updated.'\n format.html { redirect_to(aluminis_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @alumini.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_educational_institution\n @educational_institution = EducationalInstitution.find(params[:id])\n end",
"def institution(id = nil)\n res = Connection.get('institutions', id)\n id.nil? ? Institution.all(res) : Institution.new(res)\n end",
"def institution(id=nil)\n @institution = Plaid::Institution.new\n res = self.get('institutions',id)\n id.nil? ? @institution.instantiate_all_institutions(res) : @institution.instantiate_one_institution(res)\n end",
"def update\n @institucion = Institucion.find(params[:id])\n\n respond_to do |format|\n if @institucion.update_attributes(params[:institucion])\n flash[:notice] = 'Institucion se ha actualizado con exito.'\n format.html { redirect_to(admin_institucions_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @institucion.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if params[:id].to_i != current_user.id\n redirect_to edit_user_path(current_user) and return\n end\n @user = User.find(params[:id])\n @my_institution = @user.institution\n if user_role_in?(:dmp_admin)\n @institution_list = InstitutionsController.institution_select_list\n else\n @institution_list = @my_institution.root.subtree.collect {|i| [\"#{'-' * i.depth} #{i.full_name}\", i.id] }\n end\n\n @roles = @user.roles.map {|r| r.name}.join(' | ')\n\n @orcid_id = params[:user][:orcid_id]\n @update_orcid_id = params[:user][:update_orcid_id]\n\n if !@orcid_id.blank?\n @orcid_id = \"http://orcid.org/\" + \"#{@orcid_id}\"\n end\n if !@update_orcid_id.blank?\n @orcid_id = \"http://orcid.org/\" + \"#{@orcid_id}\"\n end\n\n User.transaction do\n #@user.institution_id = params[:user].delete(:institution_id)\n respond_to do |format|\n if @orcid_id.blank?\n if @user.update_attributes(user_params)\n update_notifications(params[:prefs])\n # LDAP will not except for these two fields to be empty.\n #user_params[:first_name] = \" \" if user_params[:first_name].empty?\n #user_params[:last_name] = \" \" if user_params[:last_name].empty?\n update_ldap_if_necessary(@user, user_params)\n @current_user = User.find_by_id(session[:user_id])\n format.html { redirect_to edit_user_path(@user),\n notice: 'User information updated.' }\n format.json { head :no_content }\n \n else\n format.html { render 'edit'}\n format.json { head :no_content }\n \n end\n\n else\n if (@user.update_attributes(user_params) && @user.update_attribute(:orcid_id, @orcid_id))\n update_notifications(params[:prefs])\n # LDAP will not except for these two fields to be empty.\n #user_params[:first_name] = \" \" if user_params[:first_name].empty?\n #user_params[:last_name] = \" \" if user_params[:last_name].empty?\n update_ldap_if_necessary(@user, user_params)\n format.html { redirect_to edit_user_path(@user),\n notice: 'User information updated.' }\n format.json { head :no_content }\n \n else\n format.html { render 'edit'}\n format.json { head :no_content }\n \n end\n end\n end\n end\n rescue LdapMixin::LdapException\n flash[:error] = 'Error updating LDAP. Local update canceled.'\n redirect_to edit_user_path(@user)\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 import_institution(institution)\n # If no institute exists, then create one, else update the existing one\n if !Institution.exists?(name: institution[:name])\n new_institution(institution[:name], institution[:website],\n institution[:number], institution[:email])\n else\n update_institution(institution[:name], institution[:website],\n institution[:number], institution[:email])\n end\n end",
"def set_catalogs_institution\n @catalogs_institution = Catalogs::Institution.find(params[:id])\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 @analyst = Analyst.find(params[:id])\n\n if @analyst.update(params[:analyst])\n head :no_content\n else\n render json: @analyst.errors, status: :unprocessable_entity\n end\n end",
"def update\n @identity = Identity.find(params[:id])\n\n if @identity.update(identity_params)\n head :no_content\n else\n render json: @identity.errors, status: :unprocessable_entity\n end\n end",
"def update\n @institution = Institution.find(params[:id])\n authorize! :update, @institution\n\n respond_to do |format|\n if @institution.update_attributes(params[:institution].except(\"assign\",\"_destroy\"))\n if (params[:institution][:assign].to_s == \"from_action\")\n \n ass_to = User.find(params[:institution][:assigned_to]).first_name\n ass_by = User.find(params[:institution][:assigned_by]).first_name\n \n tl(\"Registration\",params[:id],'This institution has been reassigned',\n 'Assigned To: ' + ass_to + ' | Assigned By: ' + ass_by,'assign_to',params[:institution][:assigned_to]) \n \n elsif params[:institution][:notes_attributes]\n tl(\"Institution\",params[:id],'A note has been created for this institution',\n \"Note created\",'note',@institution.assigned_to)\n else\n tl(\"Institution\",params[:id],'Values of this institution has been updated',\n \"Updated\",'Update',@institution.assigned_to)\n end\n format.html { redirect_to @institution, notice: 'Institution was successfully updated.' }\n format.json { head :no_content }\n format.js\n else\n format.html { render action: \"edit\" }\n format.json { render json: @institution.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def update\n @collection = @institution.collections.find(params[:id])\n\n respond_to do |format|\n if @collection.update_attributes(params[:collection])\n format.html { redirect_to [@collection.institution, @collection], notice: 'Collection was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render layout: 'form', action: \"edit\" }\n format.json { render json: @collection.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @insurance_query = InsuranceQuery.find(params[:id])\n\n respond_to do |format|\n if @insurance_query.update_attributes(params[:insurance_query])\n payer = Payer.find_by_id(@insurance_query.payer_id)\n @insurance_query.update_attributes(payer_name: payer.payer_name, payer_code: payer.payer_code)\n \n format.html { redirect_to @insurance_query, notice: 'Insurance query was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @insurance_query.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_student(id, fields)\n list = query_student(:id => id)\n list[0].merge(fields) if list.length == 1\n save_data\n end",
"def test_edit_institution_with_invalid_name\n number_of_institution = Institution.count\n post :update,:id => institutions(:institution0).id, :institution => { :name => ''}\n assert_equal Institution.count, number_of_institution\n assert Institution.find(:all, :conditions => \"name = ''\").count == 0;\n end",
"def update\n @instituicao = Instituicao.find(params[:id])\n\n respond_to do |format|\n if @instituicao.update_attributes(params[:instituicao])\n format.html { redirect_to @instituicao, notice: 'Instituicao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @instituicao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # @insurance = load_insurance\n\n respond_to do |format|\n if @insurance.update(insurance_params)\n format.html { redirect_to @insurance, success: t('activerecord.messages.successfull.updated', data: @insurance.number) }\n format.json { render :show, status: :ok, location: @insurance }\n else\n format.html { render :edit }\n format.json { render json: @insurance.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n standard_update(Interest, params[:id], interest_params)\n end",
"def update\n enforce_permissions!('manage_collection', params[:id])\n\n @object = retrieve_object!(params[:id])\n # If a cover image was uploaded, remove it from the params hash\n cover_image = params[:digital_object]&.delete(:cover_image)\n\n @institutes = Institute.all\n @inst = Institute.new\n\n supported_licences\n\n @object.assign_attributes(update_params)\n unless @object.valid?\n flash[:alert] = t('dri.flash.alert.invalid_object', error: @object.errors.full_messages.inspect)\n render :edit\n return\n end\n\n @object.increment_version\n\n if cover_image.present?\n url = Storage::CoverImages.validate_and_store(cover_image, @object)\n if url\n @object.cover_image = url\n else\n flash[:error] = t('dri.flash.error.cover_image_not_saved')\n end\n end\n\n respond_to do |format|\n if save_and_index\n post_save do\n mint_or_update_doi(@object, doi) if doi\n end\n\n flash[:notice] = t('dri.flash.notice.updated')\n format.html { redirect_to controller: 'my_collections', action: 'show', id: @object.alternate_id }\n format.json { render json: @object }\n else\n flash[:alert] = t('dri.flash.error.unable_to_persist')\n format.html { render action: 'edit' }\n end\n end\n end",
"def test_edit_institution_with_duplicate_name\n number_of_institution = Institution.count\n post :update,:id => institutions(:institution0).id, :institution => { :name => institutions(:institution1).name}\n assert_equal Institution.count, number_of_institution\n assert_equal 1, Institution.count(:all, :conditions => \"name = 'Test state university'\");\n assert Institution.find(:all, :conditions => \"name = 'Computer Science'\").count == 0;\n end",
"def update\n @insurance_co = InsuranceCo.find(params[:id])\n\n respond_to do |format|\n if @insurance_co.update_attributes(params[:insurance_co])\n format.html { redirect_to(@insurance_co, :notice => 'Insurance co was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @insurance_co.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def institution_set(name)\n self.institution.set name\n end",
"def update\n @institute_admin = InstituteAdmin.find(params[:id])\n respond_to do |format|\n if @institute_admin.update_attributes(params[:institute_admin])\n format.html { redirect_to @institute_admin, notice: 'InstituteAdmin was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @institute_admin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(username, password, id, new_asset_obj)\n raise NotImplementedError, \"Not implemented\"\n end",
"def update\n @person = Person.find((params[:person_id]))\n params[:person_identification_doc][:rg_uf].blank? ? (params[:person_identification_doc].delete(:rg_uf)) : (params[:person_identification_doc][:rg_uf] = State.find(params[:person_identification_doc][:rg_uf]))\n params[:person_identification_doc][:vr_uf].blank? ? (params[:person_identification_doc].delete(:vr_uf)) : (params[:person_identification_doc][:vr_uf] = State.find(params[:person_identification_doc][:vr_uf]))\n params[:person_identification_doc][:rg_issuing_institution].blank? ? (params[:person_identification_doc].delete(:rg_issuing_institution)) : (params[:person_identification_doc][:rg_issuing_institution] = IssuingInstitution.find(params[:person_identification_doc][:rg_issuing_institution]))\n \n @person_identification_doc = PersonIdentificationDoc.find(params[:id])\n\n respond_to do |format|\n if @person_identification_doc.update_attributes(params[:person_identification_doc])\n format.html { redirect_to [@person,@person_identification_doc], :notice => 'Documentação atualizada.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @person_identification_doc.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @institute\n respond_to do |format|\n if @institute.update(institute_params)\n format.html { redirect_to @institute, notice: 'Institute was successfully updated.' }\n format.json { render :show, status: :ok, location: @institute }\n else\n format.html { render :edit }\n format.json { render json: @institute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def institution\n @institution ||= Institution.find(self.institution_pid)\n rescue ActiveFedora::ObjectNotFoundError => e\n logger.warn \"#{self.institution_pid} is set as the institution for #{self}, but it doesn't exist\"\n @institution = NilInstitution.new\n end",
"def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n @providerable, @name = find_polymorphic\n @provider = ProviderInsurance.find(params[:id])\n @provider.updated_user = current_user.login_name\n\n respond_to do |format|\n if @provider.update_attributes(params[:provider_insurance])\n format.html { redirect_to polymorphic_path([@providerable, @provider]), notice: 'Provider insurance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @provider.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @instituicao = Instituicao.find(params[:id])\n\n respond_to do |format|\n if @instituicao.update_attributes(params[:instituicao])\n format.html { redirect_to(@instituicao, :notice => 'Instituicao was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @instituicao.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @university = University.find(params[:university_id])\n if @university.update(university_params)\n flash[:success] = 'Information updated!'\n redirect_to @university\n else\n render 'edit'\n end\n end",
"def update\n @education = Education.where(:resource_id => current_user.id, :id => params[:id]).first\n\n respond_to do |format|\n if @education.update_attributes(params[:education])\n format.html { redirect_to(@education, :notice => 'Education was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @education.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n # Expecting the following format:\n # {\n # \"dmp\": {\n # \"dmp_id\": {\n # 'type': 'doi',\n # 'identifier': '10.234/erfere.234d'\n # },\n # \"contributor\": [{\n # \"name\": 'Jane Doe',\n # \"mbox\": 'jane.doe@example.org',\n # \"roles\": 'https://credit.org/roles/program_officer',\n # \"affiliation\": {\n # \"name\": 'National Science Foundation (NSF)'\n # },\n # }],\n # \"project\": {\n # \"start_on\": '2020-05-15 10:34:21 UCT',\n # \"end_on\": '2022-05-15 10:34:21 UCT',\n # \"funding\": [{\n # \"name\": \"Example Funder\",\n # \"funder_id\": {\n # 'typer':'ROR',\n # 'identifier': 'http://ror.org/45y4545'\n # },\n # \"grant_id\": {\n # 'type': 'url',\n # 'identifier': 'http://awards.example.org/1234'\n # }\n # \"funding_status\": \"granted\"\n # }]\n # }\n # }\n # }\n @funding = Funding.where(id: params[:id]).first\n if @funding.present? && funding_params.fetch('dmp_id', {}).any? &&\n funding_params['dmp_id']['identifier'].present? &&\n funding_params.fetch('project', {})['funding'].present?\n\n dmp = DataManagementPlan.find_by_doi(funding_params['dmp_Id']['identifier']).first\n if @funding.project.data_management_plans.first.id == dmp.id\n prepare_project_for_update(params: funding_params['project'])\n prepare_funding_for_update(params: funding_params['project']['funding'].first)\n\n if funding_params.fetch('contributor', []).any? && authorize_person_assertions\n DataManagementPlan.contributors_from_json(\n provenance: current_client[:name],\n dmp: dmp,\n json: funding_params\n )\n end\n\n if dmp.save && @funding.project.save && @funding.save\n head :no_content, location: landing_page_url(id: dmp.dois.first&.value)\n\n else\n project_errs = @funding.project.errors.collect { |e, m| { \"#{e}\": m } } || []\n funding_errs = @funding.errors.collect { |e, m| { \"#{e}\": m } } || []\n errs = (project_errs + funding_errs).join(', ')\n Rails.logger.warn \"Error saving Project + Funding during api/v0/fundings#update: #{errs}\"\n render_error errors: \"Unable to assert your Funding: #{errs}\", status: :unprocessable_entity\n end\n else\n render_error errors: 'Unauthorized', status: :unauthorized\n end\n else\n render_error errors: 'Unauthorized', status: :unauthorized\n end\n end",
"def update\n \n if @insumolabore.update(insumolabore_params)\n redirect_to labors_path, notice: 'Insumolabore was successfully updated.'\n else\n respond_to do |format|\n format.html { render :edit }\n format.json { render json: @insumolabore.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @success=true\n if Asistencium.exists?(params[:id])\n @asistencium = Asistencium.find params[:id]\n if @asistencium.update(asistencium_params)\n\n redirect_to admin_asistencias_path, notice: \"asistencium editado exitosamente\"\n else\n flash.now[:alert] = \"Ha ocurrido un error\"\n render :edit\n end\n else\n redirect_to admin_asistencias_path, alert: \"asistencium no existe\"\n end\n end",
"def update\n @insurance_type = InsuranceType.find(params[:id])\n\n respond_to do |format|\n if @insurance_type.update_attributes(params[:insurance_type])\n flash[:success] = \"Тип успешно отредактирован.\"\n format.html { redirect_to @insurance_type }\n format.json { head :no_content }\n else\n flash.now[:error] = \"Введены неверные данные!\"\n format.html { render action: \"edit\" }\n format.json { render json: @insurance_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_edit_institution_with_valid_name\n number_of_institution = Institution.count\n post :update,:id => institutions(:institution1).id, :institution => { :name => 'Biomedical Engineer'}\n assert_equal flash[:notice], 'Institution was successfully updated.'\n assert_redirected_to :action => 'show', :id => institutions(:institution1).id\n assert_equal Institution.count, number_of_institution\n assert_equal 1, Institution.count(:all, :conditions => \"name = 'Biomedical Engineer'\");\n assert Institution.find(:all, :conditions => \"name = 'Computer Science'\").count == 0;\n end",
"def update\n @university = University.find(params[:id])\n\n respond_to do |format|\n if @university.update_attributes(params[:university])\n format.html { redirect_to @university, notice: 'University was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @university.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @university = University.find(params[:id])\n\n respond_to do |format|\n if @university.update_attributes(params[:university])\n format.html { redirect_to @university, notice: 'University was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @university.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @infrastructure = Infrastructure.find(params[:id])\n checkaccountobject(\"infrastructures\",@infrastructure)\n\n respond_to do |format|\n if @infrastructure.update_attributes(params[:infrastructure])\n format.html { redirect_to @infrastructure, notice: 'Infrastructure was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @infrastructure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @consulta = Consulta.find(params[:id])\n\n if @consulta.update(params[:consulta])\n head :no_content\n else\n render json: @consulta.errors, status: :unprocessable_entity\n end\n end",
"def update\n @soil = Soil.find(params[:id])\n\n respond_to do |format|\n if @soil.update_attributes(soil_params)\n format.html { redirect_to @soil, notice: 'Soil was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @soil.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @advertise = Advertise.find(params[:id])\n authorize! :update, @advertise, :message => 'Acceso denegado.'\n campusAdvertise = Advertise.find(params[:advertise_id][:campus_ids]) rescue []\n @advertise.campuses=campusAdvertise\n respond_to do |format|\n if @advertise.update_attributes(params[:advertise])\n format.html { redirect_to @advertise, notice: t(\"activerecord.alerts.advertise.updated\") }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @advertise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_sucursal\n @institucion = Institucion.find(params[:institucion_id])\n @sucursal = Sucursal.find(params[:id]) if params[:id]\n end",
"def update\n if (user_signed_in? && ([2].include?(current_user.role)))\n @cultural_heritage_type_cultural_institution = CulturalHeritage::TypeCulturalInstitution.find(params[:id])\n @title_view = 'Tipos de Institución Cultural'\n respond_to do |format|\n if @cultural_heritage_type_cultural_institution.update_attributes(params[:cultural_heritage_type_cultural_institution])\n format.html { redirect_to(@cultural_heritage_type_cultural_institution, :notice => 'Se ha actualizado correctamente el tipo de institucion cultural.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @cultural_heritage_type_cultural_institution.errors, :status => :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to(new_user_session_path) }\n end\n end\n end",
"def update\n @dossier = Dossier.find(params[:id])\n \n respond_to do |format|\n if @dossier.update_attributes(params[:dossier])\n format.html { redirect_to(@dossier, :notice => 'Dossier was successfully updated.') }\n format.xml { head :ok }\n format.json { render :json => { :success => true, :message => \"Updated Dossier #{@dossier.id}\", :data => @dossier.attributes.merge(:institution_nom => @dossier.institution.nom, :type_etat_dossier_description => @dossier.type_etat_dossier.try(:description), :juge_mission_id => @dossier.juge_mission.try(:contact_id), :juge_controlleur_id => @dossier.juge_controlleur.try(:contact_id))}}\n \n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @dossier.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n return if auth(\"website_administrator\")\n @incident = Incident.find(params[:id])\n\n respond_to do |format|\n if @incident.update_attributes(params[:incident])\n format.html { redirect_to @incident, :notice => 'Incident was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @incident.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @aspirant = Aspirant.find(params[:id])\n\n respond_to do |format|\n if @aspirant.update_attributes(params[:aspirant])\n format.html { redirect_to @aspirant, :notice => 'Аспирант успешно изменен.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @aspirant.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @library = Library.where(id: params[:id]).first\n @library.update_attributes(library_params)\n if @library.errors.empty?\n redirect_to library_path(@library)\n else\n render \"edit\"\n end\n end",
"def update\n redirect_to(root_url) && return unless current_user.can_edit_patient_laboratories?\n\n lab = Laboratory.find_by(id: params.permit(:id)[:id])\n lab.update!(lab_type: params.permit(:lab_type)[:lab_type],\n specimen_collection: params.permit(:specimen_collection)[:specimen_collection],\n report: params.permit(:report)[:report],\n result: params.permit(:result)[:result])\n History.lab_result_edit(patient: params.permit(:patient_id)[:patient_id],\n created_by: current_user.email,\n comment: \"User edited a lab result (ID: #{lab.id}).\")\n end",
"def update\n @case = Case.find(params[:id])\n\n if current_user.district_id and !current_user.admin?\n @districts = District.where(\"id = #{current_user.district_id}\")\n @phis = Phi.where(\"district_id = #{current_user.district_id}\")\n else\n @districts = District.all\n @phis = Phi.all\n @centers = Center.all\n end\n @centers = (@phis.count == 1)? Center.where(\"phi_id = #{@phis.first.id}\") : Center.all\n @hes = He.where(:center_id => @centers.map { |id| id })\n\n @laboratories = Laboratory.all\n @agents = Agent.all\n @doctors = User.find_all_by_user_type(1)\n @nurses = User.find_all_by_user_type(2)\n\n @municipalities = Municipality.all\n @icds = Icd.all\n\n respond_to do |format|\n if @case.update_attributes(params[:case])\n format.html { redirect_to @case, notice: t(\"record_updated\") }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_instuction\n @instuction = Instuction.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @analise.update(analise_params)\n format.html { redirect_to @analise, notice: 'Analisis was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @analise.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @analysis = Analysis.find_by_id(params[:id], :include => [ :analysis_memberships => :image_dataset ] )\n \n respond_to do |format|\n if @analysis.update( analyse_params)#params[:analysis], :without_protection => true)\n flash[:notice] = 'Analysis was successfully updated.'\n format.html { redirect_to(@analysis) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @analysis.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @inschool = Inschool.find(params[:id])\n\n respond_to do |format|\n if @inschool.update_attributes(params[:inschool])\n format.html { redirect_to @inschool, notice: 'Inschool was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inschool.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @impressoras = Impressora.find(params[:id])\n\n respond_to do |format|\n if @impressoras.update_attributes(params[:impressora])\n flash[:notice] = 'SALVO COM SUCESSO'\n format.html { redirect_to(@impressoras) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @impressoras.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @instrument = Instrument.find(params[:id])\n @instrument.update(instrument_params)\n redirect_to instrument_path(@instrument)\n end",
"def update\n @user = User.find(params[:id])\n if @user.openid_url.nil? || @user.openid_url.blank?\n handle_traditional_update\n else\n handle_openid_update\n end\n \n end",
"def update\n @instructor = Instructor.find(params[:id])\n render :action => :edit unless @instructor.update_attributes(params[:instructor])\n \n end",
"def update\n @title = t('view.banks.edit_title')\n @bank = Bank.find(params[:id])\n\n respond_to do |format|\n if @bank.update_attributes(params[:bank])\n format.html { redirect_to @bank, notice: t('view.banks.correctly_updated') }\n format.json { head :ok }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bank.errors, status: :unprocessable_entity }\n end\n end\n rescue ActiveRecord::StaleObjectError\n redirect_to edit_bank_url(@bank), alert: t('view.banks.stale_object_error')\n end",
"def update\n @impressum = Impressum.find(params[:id])\n\n respond_to do |format|\n if @impressum.update_attributes(params[:impressum])\n format.html { redirect_to impressums_url, notice: 'Impressum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @impressum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @incident = Incident.find(params[:id])\n\n if @incident.update(incident_params)\n head :no_content\n else\n render json: @incident.errors, status: :unprocessable_entity\n end\n end",
"def update\n @student = Student.find(params[:student_id])\n @inschool = @student.inschools.find(params[:id])\n\n respond_to do |format|\n if @inschool.update_attributes(params[:inschool])\n format.html { redirect_to :back, notice: 'Inschool was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inschool.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @issuer = Issuer.find(params[:id])\n\n respond_to do |format|\n if @issuer.update_attributes(params[:issuer])\n format.html { redirect_to issuers_path, notice: 'Issuer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @issuer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @asignatura = Asignatura.find(params[:id])\n\n respond_to do |format|\n if @asignatura.update_attributes(params[:asignatura])\n format.html { redirect_to @asignatura, notice: 'Asignatura was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @asignatura.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @endurance = Endurance.find(params[:id])\n\n respond_to do |format|\n if @endurance.update_attributes(params[:endurance])\n format.html { redirect_to @endurance, notice: 'Endurance was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @endurance.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
[
"0.717103",
"0.7150022",
"0.71217936",
"0.70621365",
"0.70548487",
"0.6986477",
"0.69753784",
"0.6964017",
"0.6932576",
"0.6932301",
"0.6890543",
"0.6877638",
"0.6799948",
"0.6799948",
"0.6799948",
"0.6799948",
"0.6790408",
"0.67805046",
"0.6764449",
"0.66290385",
"0.6588837",
"0.6587777",
"0.6342624",
"0.6338025",
"0.63281894",
"0.62836385",
"0.62780076",
"0.62780076",
"0.6276838",
"0.6266515",
"0.62138057",
"0.62134796",
"0.6200942",
"0.6198757",
"0.61962336",
"0.6169799",
"0.6168397",
"0.6159995",
"0.6141962",
"0.6120475",
"0.6072683",
"0.607093",
"0.6061875",
"0.60613793",
"0.60509527",
"0.6048231",
"0.60339165",
"0.6025636",
"0.60251844",
"0.6014773",
"0.5998007",
"0.59962684",
"0.5984164",
"0.5980696",
"0.59531015",
"0.59487945",
"0.59405786",
"0.59370536",
"0.59177214",
"0.5916339",
"0.5910423",
"0.59096634",
"0.5905618",
"0.5900482",
"0.5896881",
"0.5877983",
"0.58734655",
"0.5869102",
"0.58684677",
"0.58652276",
"0.585149",
"0.58452237",
"0.58452237",
"0.58409005",
"0.5838319",
"0.5827547",
"0.5814202",
"0.58109516",
"0.5806346",
"0.5795391",
"0.5793409",
"0.57853657",
"0.5758335",
"0.5752947",
"0.57459575",
"0.57449234",
"0.5742931",
"0.57372946",
"0.5733687",
"0.57239",
"0.5713456",
"0.5711693",
"0.57067144",
"0.5706497",
"0.57038337",
"0.56929857",
"0.56925935",
"0.56918764",
"0.5691178",
"0.5690062"
] |
0.75500005
|
0
|
Returns boolean as to wether the specified constant is defined. Examples: const_defined? 'String' true const_defined? 'WierdClass' false const_defined? ['ActiveRecord', 'Base'] true (assuming Active Record is installed)
|
def const_defined?(klass)
klass = [klass] unless klass.kind_of? Array
klass.inject(Object) do |context, scope|
if context.const_defined?(scope)
context.const_get(scope)
else
return false
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def constant_defined?(name); end",
"def constant_is_defined?(const_name)\n const_name.to_s.sub(/\\A::/,'').split('::').inject(Object) do |namespace, name|\n begin\n result = namespace.const_get(name)\n\n # const_get looks up the inheritence chain, so if it's a class\n # in the constant make sure we found the one in our namespace.\n #\n # Can't help if the constant isn't a class...\n if result.is_a?(Module)\n expected_name = \"#{namespace}::#{name}\".gsub(/^Object::/, \"\")\n return false unless expected_name == result.to_s\n end\n\n result\n rescue NameError\n false\n end\n end\n end",
"def const_defined?(p0) end",
"def is_const_defined? type, name\n if RUBY_VERSION =~ /^1.8/\n type.const_defined? name\n else\n type.const_defined? name, false\n end\n end",
"def const_defined?(arg0)\n end",
"def loadable_const_defined?(name)\n if const_defined?(name.to_sym, false)\n true\n elsif const_path(name)\n true\n else\n false\n end\n end",
"def currently_defined?\n base_module.const_defined?(constant_name, false)\n end",
"def qualified_const_defined?(path)\n Object.const_defined?(path, false)\n end",
"def qualified_const_defined?(path)\n Object.const_defined?(path, false)\n end",
"def constant?\n true\n end",
"def global_const_defined? string\n begin\n eval string\n true\n rescue NameError\n false\n end\n end",
"def has_constants?\n @context.constants.length > 0\n end",
"def const? #:nodoc:\n attributes[\"const\"] == \"1\"\n end",
"def const_defined?(name, inherit = true)\n name = Opal.const_name!(name)\n\n ::Kernel.raise ::NameError.new(\"wrong constant name #{name}\", name) unless name =~ ::Opal::CONST_NAME_REGEXP\n\n %x{\n var module, modules = [self], module_constants, i, ii;\n\n // Add up ancestors if inherit is true\n if (inherit) {\n modules = modules.concat(Opal.ancestors(self));\n\n // Add Object's ancestors if it's a module – modules have no ancestors otherwise\n if (self.$$is_module) {\n modules = modules.concat([$Object]).concat(Opal.ancestors($Object));\n }\n }\n\n for (i = 0, ii = modules.length; i < ii; i++) {\n module = modules[i];\n if (module.$$const[#{name}] != null) { return true; }\n if (\n module.$$autoload &&\n module.$$autoload[#{name}] &&\n !module.$$autoload[#{name}].required &&\n !module.$$autoload[#{name}].success\n ) {\n return true;\n }\n }\n\n return false;\n }\n end",
"def constantize?\r\n Object.const_defined?(self) ? constantize : nil\r\n end",
"def constant?(name)\n @consts.key?(name.to_sym)\n end",
"def const?\n @attributes[\"const\"] ? @attributes[\"const\"] == \"1\" : false\n end",
"def qualified_const_defined?(path)\n names = path.sub(/^::/, '').to_s.split('::')\n\n names.inject(Object) do |mod, name|\n return false unless local_const_defined?(mod, name)\n mod.const_get name\n end\n end",
"def item_defined?(item)\n const_defined? item.constant_name\n end",
"def constant?\n case C.LLVMIsConstant(self)\n when 0 then false\n when 1 then true\n end\n end",
"def constant?\n @value.constant?\n end",
"def is_constant?\n @classified.first.instance_of? Constant\n end",
"def assert_const_defined(const_name)\n const_name.split('::').inject(Object) do |base,name|\n assert base.const_defined?(name),\n \"constant should be defined: #{const_name} (#{name})\"\n base.const_get(name)\n end\n end",
"def isConst?(val,mod,constant)\n begin\n return false if !mod.const_defined?(constant.to_sym)\n rescue\n return false\n end\n return (val==mod.const_get(constant.to_sym))\nend",
"def isConst?(val, mod, constant)\n begin\n return false if !mod.const_defined?(constant.to_sym)\n rescue\n return false\n end\n return (val == mod.const_get(constant.to_sym))\nend",
"def loaded?(constant)\n return loaded.include?(constant)\n end",
"def external_constant?(const)\n sources = object_sources(const)\n # consider methodless constants not external\n return false if sources.empty?\n !sources.any?{ |source| source.start_with?(Padrino.root) }\n end",
"def constant_excluded?(const)\n external_constant?(const) || (exclude_constants - include_constants).any?{ |excluded_constant| constant_name(const).start_with?(excluded_constant) }\n end",
"def assert_const_defined(object, constant_name, message=nil)\n _wrap_assertion do\n full_message = build_message(message,\n \"<?>.const_defined\\\\?(<?>) expected.\",\n object, constant_name)\n assert_block(full_message) do\n object.const_defined?(constant_name)\n end\n end\n end",
"def const_defined?(*args)\n raise ArgumentError, \"too many arguments (#{args.size} for 1..2)\"\n end",
"def defined?\n not undefined?\n end",
"def autoloaded?(desc)\n return false if desc.is_a?(Module) && real_mod_name(desc).nil?\n name = to_constant_name desc\n return false unless qualified_const_defined?(name)\n autoloaded_constants.include?(name)\n end",
"def autoloaded?(desc)\n # No name => anonymous module.\n return false if desc.is_a?(Module) && desc.anonymous?\n name = to_constant_name desc\n return false unless qualified_const_defined? name\n return autoloaded_constants.include?(name)\n end",
"def constant_enabled(thing)\n Fission.constants.map do |const|\n const.to_s.downcase.to_sym\n end.include?(thing.to_s.downcase.to_sym)\n end",
"def will_unload?(const_desc)\n autoloaded?(const_desc) ||\n explicitly_unloadable_constants.include?(to_constant_name(const_desc))\n end",
"def defined?\n false\n end",
"def defined?(name); end",
"def defined?(name); end",
"def constant_call?(sexp)\n if (call_site?(sexp) and array?(receiver(sexp)) and ((receiver(sexp)).first == :const))\n true\n else\n false\n end\n end",
"def keyword_constant?\n token = peek\n return false unless token\n\n token.value == \"true\" ||\n token.value == \"false\" ||\n token.value == \"null\" ||\n token.value == \"this\"\n end",
"def match?\n declaration_node_type == :const && Util::Word.match?(declaration_node_name)\n end",
"def shareable_constant_value_specified?; end",
"def definition_required?\n # We have to distinguish the false value from the non\n # existence of the variable. Therefore the ||= operator\n # can't help us.\n if @definition_required.class.kind_of?(NilClass)\n\t @definition_required = true\n else\n @definition_required\n end\n end",
"def index(value)\n constants.find { |const_name| const_get(const_name) == value } || :__undef__\n end",
"def _filtered_constants\n @caught_constants.select do |(obj, name)|\n next unless obj.const_defined?(name)\n\n begin\n location = obj.const_source_location(name)\n rescue ::ArgumentError\n next\n end\n\n next true if location.nil?\n\n path = location.first\n next false if $LOADED_FEATURES.include?(path)\n\n next true if constants_location_prefixes.nil?\n\n constants_location_prefixes&.any? { |prefix| path.start_with?(prefix) }\n end\n end",
"def safe_to_evaluate?(str)\n return true if str.strip == \"self\"\n kind = target.eval(\"defined?(#{str})\")\n kind =~ /variable|constant/\n end",
"def registered?(const)\n @@extensions.include?(const)\n end",
"def const_receiver?\n receiver&.const_type?\n end",
"def assert_not_const_defined(object, constant_name, message=nil)\n _wrap_assertion do\n full_message = build_message(message,\n \"!<?>.const_defined\\\\?(<?>) expected.\",\n object, constant_name)\n assert_block(full_message) do\n !object.const_defined?(constant_name)\n end\n end\n end",
"def defined?(value_key)\n true\n end",
"def drc_defined?\n defined?(DRCClient) && !DRCClient.config.nil?\n end",
"def is_defined!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 21 )\n\n type = IS_DEFINED\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 142:14: 'defined?'\n match( \"defined?\" )\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__, 21 )\n\n end",
"def exists?(module_name)\n const_name = module_name.to_s.camel_case\n slice_names.include?(const_name) && Object.const_defined?(const_name)\n end",
"def honeybadger_defined?\n Object.const_defined?(\"Honeybadger\")\n end",
"def valid_constant_path?(token)\n current = scope\n\n token.name.each do |segment|\n found = current.lookup(:constant, segment)\n\n if found and token.line > found.token.line\n current = found\n else\n return false\n end\n end\n\n return true\n end",
"def extension_registered?(const)\n @@extensions.include?(const)\n end",
"def extension_registered?(const)\n @@extensions.include?(const)\n end",
"def variable?\n not constant?\n end",
"def magical_data_const?\n const_scope.nil? && name == :DATA && compiler.eof_content\n end",
"def exist?(key,const)\n\t\tb = false\n\t\tkey.pile_const.each do |x|\n\t\t\tif x.is_a?(Contrainte)\n\t\t\t\tb = x.equal?(const) || b\n\t\t\tend\n\t\tend\n\t\tb\n\tend",
"def hooked?\n self.class.get(base_module, constant_name) == self\n end",
"def mark_for_unload(const_desc)\n name = to_constant_name const_desc\n if explicitly_unloadable_constants.include? name\n false\n else\n explicitly_unloadable_constants << name\n true\n end\n end",
"def optimized_access?\n const_scope == s(:cbase) && OPTIMIZED_ACCESS_CONSTS.include?(name)\n end",
"def dep_defined?\n @dep_defined\n end",
"def defined?(path, record)\n field_validator = JsonFieldValidator.new\n is_defined = field_validator.defined?(path[0], record)\n @@output.concat(field_validator.debug_output)\n unless is_defined\n @@defined_error_msg = field_validator.error_message\n end # unless\n return is_defined\n end",
"def on_constant_path(node)\n definitions = current_scope\n @in_constant_path = true\n\n # The first constant check should take data from parent scopes into\n # account. The following segments should not.\n method = :has_definition?\n\n node.children.each do |segment|\n name = segment.name\n\n unless definitions.send(method, :constant, name)\n error(\"undefined constant #{name}\", segment)\n\n break\n end\n\n definitions = definitions.lookup(:constant, name)\n method = :defines?\n end\n end",
"def class_variable_defined?(sym) end",
"def const_get(base, klass, const_name)\n if klass.const_defined?(const_name)\n klass.const_get(const_name)\n else\n nil\n end\n end",
"def const_io_stream?(logger_param)\n logger_param.is_a?(String) &&\n logger_param =~ VALID_RUBY_CONST &&\n Kernel.const_defined?(logger_param)\n end",
"def enum_defined_for?(attribute)\n context = self.eh_params[:enum_contexts][attribute.to_s]\n !!(eh_params[:db_codes][context] && eh_params[:db_codes][context][attribute.to_s])\n # Returns true if the indicated attribute has an enum defined\n end",
"def handle_constants(type, var_name, const_name, definition)\n class_name = @known_classes[var_name]\n\n return unless class_name\n\n class_obj = find_class var_name, class_name\n\n unless class_obj then\n @options.warn 'Enclosing class or module %p is not known' % [const_name]\n return\n end\n\n comment = find_const_comment type, const_name, class_name\n comment.normalize\n\n # In the case of rb_define_const, the definition and comment are in\n # \"/* definition: comment */\" form. The literal ':' and '\\' characters\n # can be escaped with a backslash.\n if type.downcase == 'const' then\n no_match, new_definition, new_comment = comment.text.split(/(\\A.*):/)\n\n if no_match and no_match.empty? then\n if new_definition.empty? then # Default to literal C definition\n new_definition = definition\n else\n new_definition = new_definition.gsub(\"\\:\", \":\")\n new_definition = new_definition.gsub(\"\\\\\", '\\\\')\n end\n\n new_definition.sub!(/\\A(\\s+)/, '')\n\n new_comment = \"#{$1}#{new_comment.lstrip}\"\n\n new_comment = self.new_comment(new_comment, @top_level, :c)\n\n con = RDoc::Constant.new const_name, new_definition, new_comment\n else\n con = RDoc::Constant.new const_name, definition, comment\n end\n else\n con = RDoc::Constant.new const_name, definition, comment\n end\n\n con.record_location @top_level\n @stats.add_constant con\n class_obj.add_constant con\n end",
"def previously_defined?\n @previously_defined\n end",
"def safe_constantize(camel_cased_word)\n begin\n constantize(camel_cased_word)\n rescue NameError => e\n raise unless e.message =~ /uninitialized constant #{const_regexp(camel_cased_word)}$/ ||\n e.name.to_s == camel_cased_word.to_s\n rescue ArgumentError => e\n raise unless e.message =~ /not missing constant #{const_regexp(camel_cased_word)}\\!$/\n end\n end",
"def find_constant(const_names)\n const_names.reduce(Object) do |mod, name|\n mod.const_get(name)\n end\n rescue NameError\n # Return nil if the constant doesn't exist.\n nil\n end",
"def safe_constantize(camel_cased_word)\n constantize(camel_cased_word)\n rescue NameError => e\n raise unless e.message =~ /(uninitialized constant|wrong constant name) #{const_regexp(camel_cased_word)}$/ ||\n e.name.to_s == camel_cased_word.to_s\n rescue ArgumentError => e\n raise unless e.message =~ /not missing constant #{const_regexp(camel_cased_word)}\\!$/\n end",
"def instance_attribute_defined?(key)\n case key\n when Symbol\n return instance_variable_defined?(\"@#{key}\")\n when String\n return instance_variable_defined?(\"@#{key}\")\n end\n end",
"def find_constant(name, base_object=self)\n begin\n const = base_object.constants.detect{|cnst| cnst == camelcase(name)}\n base_object.module_eval const\n rescue Exception => e\n puts \"#{name.camelcase} is not defined. #{e}\"\n nil\n end\n end",
"def constant_decls; end",
"def library_defined?( klass )\n library_handler.defined?(klass)\n end",
"def const_missing(const); end",
"def isStringConstant(str)\n return (str[0].to_s == \"\\\"\" and str[str.to_s.size - 1].to_s == \"\\\"\") #if statement surrounded by quotation marks of any kinds\n\n return false\nend",
"def qualified?\n meta[:qualified].equal?(true) || meta[:qualified].is_a?(Symbol)\n end",
"def is_defined_resource?\n nil\n end",
"def const_missing(cname)\n key, term, search, key = nil, name, []\n\n # if module has no name, try to parse out a namespace from #insepct.\n # (yes, this is a hack!)\n unless term\n if /#<Class:(.*?)>/ =~ self.inspect\n term = $1\n end\n end\n\n # constant might be in the module nesting\n # (too bad https://bugs.ruby-lang.org/issues/3773 was rejected)\n if term\n parts = term.to_s.split('::')\n until parts.empty?\n search << parts.join('::')\n parts.pop\n end\n end\n\n # constant might be in ancestors\n search += ancestors.map{ |anc| anc.name }\n search << \"Object\" #Object.ancestors.map{ |anc| anc.name }\n search.uniq!\n\n # look for match in $AUTOLOAD table\n search.each do |const| \n if $AUTOLOAD.key?(\"#{const}::#{cname}\".to_sym)\n key = \"#{const}::#{cname}\".to_sym\n break\n end\n end\n\n if key\n paths = $AUTOLOAD.delete(key)\n paths.each{ |path| require(path) }\n begin\n eval(key.to_s, TOPLEVEL_BINDING)\n #Object.const_get(key) # Ruby 2.0+\n rescue NameError\n const_missing_without_autoload(cname)\n end\n else\n const_missing_without_autoload(cname)\n end\n end",
"def contains?(klass)\n # Import a domain class on demand by referencing the class base name in the context\n # of this module. If the class name can be resolved, then also check that it\n # was introspected. Primitive classes like String can be resolved, but are not\n # introspected. Domain classes are introspected when the name is resolved.\n (!!const_get(klass.name.demodulize) rescue false) and @introspected.include?(klass)\n end",
"def defined?\n @object.method_defined?(@method_name) or @object.private_method_defined?(@method_name)\n end",
"def constant; end",
"def safe_constantize(camel_cased_word)\n constantize(camel_cased_word)\n rescue NameError => e\n raise if e.name && !(camel_cased_word.to_s.split(\"::\").include?(e.name.to_s) ||\n e.name.to_s == camel_cased_word.to_s)\n rescue ArgumentError => e\n raise unless /not missing constant #{const_regexp(camel_cased_word)}!$/.match(e.message)\n end",
"def value_required?\n if (@data_type == :none) || (@data_type == :global_class)\n return false\n else\n return true\n end\n end",
"def defined?(name)\n @symbols.has_key?(to_name(name)) or\n (Scope === @parent and @parent.defined?(name))\n end",
"def class_exists?(classname)\n str = classname.to_s\n eval(\"defined?(#{str}) && #{str}.is_a?(Class)\") == true\nend",
"def const_missing(cons)\n load_const(cons) || super\n end",
"def find_constant_named(name)\n @constants.find do |m|\n m.name == name || m.full_name == name\n end\n end",
"def class_exists?(class_name)\n eval(\"defined?(#{class_name}) && #{class_name}.is_a?(Class)\") == true\n end",
"def class_exists?(class_name)\n eval(\"defined?(#{class_name}) && #{class_name}.is_a?(Class)\") == true\n end",
"def class_exists?(class_name)\n eval(\"defined?(#{class_name}) && #{class_name}.is_a?(Class)\") == true\n end",
"def class_exists?(class_name)\n eval(\"defined?(#{class_name}) && #{class_name}.is_a?(Class)\") == true\n end",
"def constant\n CONSTANT \n end",
"def included_constants; end",
"def defined?(name)\n catch (:exit) do\n\n case name\n when /^#{CN_PATTERN}$/o\n return \"ClassModule\" if findExactClassMatch(name)\n \n when /^(#{CN_PATTERN})(\\.|\\#|::)(.+)/o #/\n cname, type, mname = $1, $2, $3\n\n return nil unless findExactClassMatch(cname)\n \n cl = findClass(cname)\n\n if ClassModule === cl\n return \"Method\" if cl.findExactMethod(mname, type == \"::\")\n end\n end\n end\n \n nil\n end"
] |
[
"0.7899093",
"0.77737206",
"0.7770563",
"0.7666365",
"0.7652031",
"0.75903374",
"0.7571167",
"0.7369838",
"0.7369838",
"0.7322153",
"0.72399926",
"0.7172762",
"0.713877",
"0.7135864",
"0.7074048",
"0.705255",
"0.6930371",
"0.6914746",
"0.6904092",
"0.68911463",
"0.6664005",
"0.66462255",
"0.6584221",
"0.6545987",
"0.65389097",
"0.65360886",
"0.65322393",
"0.65110236",
"0.64953476",
"0.6379994",
"0.62889487",
"0.62818795",
"0.6273268",
"0.6242813",
"0.6141621",
"0.60813385",
"0.60109806",
"0.60109806",
"0.596629",
"0.59614015",
"0.5950269",
"0.5908215",
"0.5803705",
"0.577327",
"0.5766827",
"0.56899804",
"0.5616986",
"0.5601571",
"0.557465",
"0.55616456",
"0.5523156",
"0.55120814",
"0.5469637",
"0.53918254",
"0.53866637",
"0.538286",
"0.538286",
"0.5379125",
"0.5364042",
"0.53561",
"0.5286496",
"0.5273915",
"0.52613515",
"0.52565044",
"0.52535385",
"0.5240379",
"0.5231937",
"0.51986223",
"0.519091",
"0.51826084",
"0.51268643",
"0.5105142",
"0.51011384",
"0.50950456",
"0.50927854",
"0.50850254",
"0.50848335",
"0.5069554",
"0.5058857",
"0.50565314",
"0.5047336",
"0.5045823",
"0.50384206",
"0.5030609",
"0.5024655",
"0.50222784",
"0.501473",
"0.5009408",
"0.5009144",
"0.50034076",
"0.5003155",
"0.5002957",
"0.49931931",
"0.49908197",
"0.49754283",
"0.49754283",
"0.49754283",
"0.49752393",
"0.49613315",
"0.49538553"
] |
0.74345434
|
7
|
Returns the specified class. Examples: const_get 'String' String const_get ['ActiveRecord', 'Base'] ActiveRecord::Base
|
def const_get(klass)
klass = [klass] unless klass.kind_of? Array
klass.inject(Object) do |context, scope|
context.const_get(scope)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_class(name)\n # 'self' -- the class from which get_class is called.\n self.const_get(name)\n end",
"def get_constant(basis, class_string)\n begin\n class_string.split('::').reduce(basis) do |basis, const|\n basis.const_get(const, false)\n end\n rescue NameError\n nil\n end\n\n end",
"def get_class(cname, mdl = Processor)\n mdl.const_get(cname.split(/[\\,\\_]/).map { |p| p.capitalize }.join)\n rescue NameError\n return nil\n end",
"def class_from_string(class_name)\n parts = class_name.split('::')\n constant = Object\n parts.each do |part|\n constant = constant.const_get(part)\n end\n constant\nend",
"def class_const(sym)\n self.class.const_get(sym)\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 get_class(class_name)\n Module.const_get(class_name)\n rescue\n nil\n end",
"def constantize(klass_string) \n BentoSearch::Util.constantize(klass_string) \n end",
"def const_get(base, klass, const_name)\n if klass.const_defined?(const_name)\n klass.const_get(const_name)\n else\n nil\n end\n end",
"def class_get class_name\n\t\t\t\t@monitor.synchronize do\n\t\t\t\t\tproviders.each do |p|\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\treturn p.class_get(class_name) \n\t\t\t\t\t\trescue NotExist;\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\traise \"Class '#{class_name}' doesn't exist!\"\n\t\t\t\tend\n\t\t\tend",
"def to_const\n [Module, Class].any? { |base| self.class == base } ? self : self.class\n end",
"def get_class type\n case type\n when Class\n type\n when BaseModel\n type.my_class\n when String, Symbol\n return get_class send(\"#{type}_model\") if [:subject, :object, :join].include?(type.to_sym)\n type.to_s.constantize\n else\n raise \"Can't determine a class from: #{type}\"\n end \n end",
"def clazz\n Module.const_get(name)\n rescue NameError\n nil\n end",
"def class_for_path(path)\n path.split('::').inject(Kernel) do |scope, const_name|\n scope.const_get(const_name)\n end\n end",
"def class_for_path(path)\n path.split('::').inject(Kernel) do |scope, const_name|\n scope.const_get(const_name)\n end\n end",
"def const_get(const_name)\n self.class.const_get(const_name)\n rescue\n nil\n end",
"def klass\n @klass ||= begin\n @klass_name.split('::').inject(Object){|n,i| n.const_get(i)}\n rescue NameError => e\n end\n end",
"def get_class(name)\n name.split(/::/).inject(Object) { |p, n| p.const_get(n) } \n end",
"def class_for_path(path)\n path.split('::').inject(Kernel) do |scope, const_name|\n scope.const_get(const_name)\n end\n end",
"def to_class\n Kernel.const_get(self.camelcase)\n end",
"def get_class_for(symb, default)\n (read_attribute(symb).presence || default).constantize\n end",
"def class_constant; end",
"def class_constant; end",
"def klass\n @klass ||= class_name.constantize\n end",
"def klass\n @klass ||= class_name.constantize\n end",
"def sti_class(v)\n case v\n when String, Symbol\n constantize(v) rescue self\n when nil\n self\n when Class\n v\n else\n raise(Error, \"Invalid class type used: #{v.inspect}\")\n end\n end",
"def final_type(klass, type)\n case\n when Object.const_defined?(type) ; Object.const_get(type)\n when klass.const_defined?(type) ; klass.const_get(type)\n when klass._base.const_defined?(type); klass._base.const_get(type)\n else\n raise ArgumentError.new(\"Failed to find the definition for #{type}!\")\n end\n end",
"def qualified_const_get(str)\n path = str.to_s.split('::')\n from_root = path[0].empty?\n if from_root\n from_root = []\n path = path[1..-1]\n else\n start_ns = ((Class === self)||(Module === self)) ? self : self.class\n from_root = start_ns.to_s.split('::')\n end\n until from_root.empty?\n begin\n return (from_root+path).inject(Object) { |ns,name| ns.const_get(name) }\n rescue NameError\n from_root.delete_at(-1)\n end\n end\n path.inject(Object) { |ns,name| ns.const_get(name) }\n end",
"def required_class\n return @required_class if defined?(@required_class)\n @required_class = @required_class_name.split(\"::\").inject(Object, :const_get)\n end",
"def klass(class_name)\n Atlas.const_get(class_name)\n end",
"def target_class\n # Need to do a little bit of work here as Module.const_get doesn't work\n # with nested class names, i.e. JIRA::Resource::Foo.\n #\n # So create a method chain from the class components. This code will\n # unroll to:\n # Module.const_get('JIRA').const_get('Resource').const_get('Foo')\n #\n target_class_name = self.class.name.sub(/Factory$/, '')\n class_components = target_class_name.split('::')\n\n class_components.inject(Module) do |mod, const_name|\n mod.const_get(const_name)\n end\n end",
"def get_const_by_name(name)\n consts = name.split(\"::\")\n obj = Object\n begin\n consts.each{|const| \n obj = obj.const_get(const)\n }\n rescue\n Log.logger_for(:configuration).error(\"No such class defined: #{name}\")\n end\n return obj\n end",
"def to_class\n\t\tObject.const_get(self)\n\t\t#ret = eval(self)\n\t\t#deb \"this is a class? cls=#{ret.class}\"\n\t\t#raise \"Exception its not a class!\" if ret.class.to_s != 'Class'\n\t\t#return ret\n\tend",
"def obtain(klass, root = Object)\n Thread.exclusive{\n klass.to_s.scan(/\\w+/){|part| root = root.const_get(part) }\n return root\n }\n end",
"def qualified_const_get(str)\n path = str.to_s.split('::')\n from_root = path[0].empty?\n if from_root\n from_root = []\n path = path[1..-1]\n else\n start_ns = ((Class === self)||(Module === self)) ? self : self.class\n from_root = start_ns.to_s.split('::')\n end\n until from_root.empty?\n begin\n return (from_root+path).inject(Object) { |ns,name| ns.const_get(name) }\n rescue NameError\n from_root.delete_at(-1)\n end\n end\n path.inject(Object) { |ns,name| ns.const_get(name) }\n end",
"def klass\n if @klass.is_a?(Class)\n @klass\n else\n unless /\\A(?:::)?([A-Z]\\w*(?:::[A-Z]\\w*)*)\\z/ =~ @klass.to_s\n raise NameError, \"#{@klass.inspect} is not a valid constant name!\"\n end\n \n Object.module_eval(\"::#{$1}\", __FILE__, __LINE__)\n end\n end",
"def klass\n class_name = self[\"_type\"]\n class_name ? class_name.constantize : nil\n end",
"def constantize\n names = self.split('::')\n names.shift if names.empty? || names.first.empty?\n\n constant = Object\n names.each do |name|\n constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)\n end\n constant\n end",
"def get_class(class_name)\n klass = Module.const_get(class_name)\n return nil unless klass.is_a?(Class)\n return klass\n rescue NameError\n return nil\n end",
"def get_class()\n l = get_type()\n #puts \"Type #{l.class} in #{self.class} , #{self}\"\n l.object_class()\n end",
"def get_class()\n l = get_type()\n #puts \"Type #{l.class} in #{self.class} , #{self}\"\n l.object_class()\n end",
"def constantize\n return self.to_s.split('::').reduce(Module){ |m, c| m.const_get(c) }\n end",
"def getKlass #:doc:\n @Klass = self.controller_name.classify.constantize\n @Klass\n end",
"def class_for(code_object)\n class_name = code_object.class.to_s.split('::').last\n const_get(class_name)\n end",
"def klass\n type.to_s.classify.constantize\n end",
"def get_class_ref(class_name)\n klass = Kernel\n class_name.split(\"::\").each do |name|\n if klass.const_defined? name\n klass = klass.const_get(name)\n else\n return nil\n end\n end\n klass\n end",
"def const_get_tree(tree)\n if tree.size == 1\n Object.const_get(tree.first)\n else\n tree[1..-1].inject(Object.const_get(tree.first)) { |new_base, part| new_base.const_get(part) }\n end\n rescue\n raise ArgumentError, \"Can't figure out command class name from path #{path} - tried #{tree}\"\n end",
"def klass\n @klass ||=\n if klass_name\n klass_name.constantize\n else\n nil\n end\n end",
"def determine_class_for names\n klass = names.first\n if AX.const_defined? klass, false\n AX.const_get klass\n else\n create_class *names\n end\n end",
"def klass\n @klass ||= compute_class(class_name)\n end",
"def klass\n @klass ||= compute_class(class_name)\n end",
"def klass\n @klass ||= compute_class(class_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 get_class_by_name( name )\n raise \"get_class_by_name #{name}.#{name.class}\" unless name.is_a?(Symbol)\n c = classes[name]\n #puts \"MISS, no class #{name} #{name.class}\" unless c # \" #{classes}\"\n #puts \"CLAZZ, #{name} #{c.get_type.get_length}\" if c\n c\n end",
"def resource_as_constant_name\n if klass_or_instance.is_a?(Class)\n klass_or_instance.name\n else\n klass_or_instance.class.name\n end\n end",
"def klass\n @klass ||= BSON.const_get(description)\n end",
"def constantize(str)\n Object.const_get(str)\n end",
"def klass\n object_name.classify.constantize\n end",
"def path_to_class(path, base_class=nil)\n class_name = path.classify\n klass = class_name.safe_constantize\n return klass if klass.present? && klass.kind_of?(Class)\n raise \"Class #{class_name.inspect} constant already exists as a #{klass.name} and is not a class.\" if klass.present?\n path_mod = class_module(path)\n class_mod_name = class_name.demodulize\n if base_class.present?\n klass = path_mod.const_set(class_mod_name, Class.new(base_class))\n else\n klass = path_mod.const_set(class_mod_name, Class.new)\n end\n raise \"Could not create class #{class_name.inspect} in module #{path_mod.inspect}.\" if klass.blank?\n klass\nend",
"def class_for(type)\n klass = type.to_s.classify.constantize rescue nil\n return klass if self.subclasses.include? klass\n end",
"def classize_resource(type)\n return type unless type.is_a?(Symbol) || type.is_a?(String)\n\n klass = nil\n begin\n klass = qualified_const_get(type.to_s)\n rescue NameError\n raise NameError, \"Could not find relation class #{type} (referenced as #{type} by #{self})\"\n end\n klass\n end",
"def get_classobj(classname, lang, pi)\n classname ||= \"E#{lang}\"\n base_module = pi ? Erubis::PI : Erubis\n begin\n klass = base_module.const_get(classname)\n rescue NameError\n klass = nil\n end\n unless klass\n if lang\n msg = \"-l #{lang}: invalid language name (class #{base_module.name}::#{classname} not found).\"\n else\n msg = \"-c #{classname}: invalid class name.\"\n end\n raise CommandOptionError.new(msg)\n end\n return klass\n end",
"def get_class()\n result = nil\n @cont.each { |line|\n if line =~ /\\s*\\w+\\s*=/\n result = /\\w+/.match(line)[0]\n break\n end\n }\n return result\n end",
"def to_const\n Object.const_get(camel_case)\n end",
"def model_class\n @class_name.constantize\n end",
"def to_class(model_name)\r\n Kernel.const_get(model_name.to_s.camelize)\r\n end",
"def worker_class_constantize(worker_class)\n if worker_class.is_a?(String)\n if worker_class.respond_to?(:constantize)\n worker_class.constantize\n else\n # duplicated logic from Rails 3.2.13 ActiveSupport::Inflector\n # https://github.com/rails/rails/blob/9e0b3fc7cfba43af55377488f991348e2de24515/activesupport/lib/active_support/inflector/methods.rb#L213\n names = worker_class.split('::')\n names.shift if names.empty? || names.first.empty?\n constant = Object\n names.each do |name|\n constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)\n end\n constant\n end\n else\n worker_class\n end\n rescue\n worker_class\n end",
"def service_klass(constant_string)\n if const_defined?([to_s, constant_string].join(\"::\"))\n [to_s, constant_string].join(\"::\")\n else\n provider = to_s.split(\"::\").last\n Fog::Logger.deprecation(\"Unable to load #{[to_s, constant_string].join('::')}\")\n Fog::Logger.deprecation(\n format(\n Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT,\n service: constant_string,\n provider: provider\n )\n )\n [\"Fog\", constant_string, provider].join(\"::\")\n end\n end",
"def class_for(cls)\n return nil unless cls # superclass will return nil when none\n fqn = cls.qualified_type_name\n return classes[fqn] if classes[fqn]\n classes[fqn] = JClass.parse(self, cls)\n end",
"def get(name)\n name = camelize(name) if name.downcase == name\n begin\n const_get(name)\n rescue NameError\n nil\n end\n end",
"def ns_constantize\n to_s.gsub('__', '::').constantize\n end",
"def typecast_to_class(value)\n value.to_s.constantize\n rescue NameError\n nil\n end",
"def class_from_name\n if model_name.to_s.include? \"_\"\n ns, *klass = model_name.to_s.split(\"_\").collect(&:camelize)\n begin\n \"#{ns}::#{klass.join(\"\")}\".constantize\n rescue NameError\n \"#{ns}#{klass.join(\"\")}\".constantize\n end\n else\n model_name.to_s.camelize.constantize\n end\n end",
"def const_get(model_key)\n klass = connection.define_openerp_model(model: model_key, scope_prefix: self.scope_prefix)\n klass_name = connection.class_name_from_model_key(model_key)\n klass = (self.scope_prefix ? Object.const_get(self.scope_prefix) : Object).const_defined?(klass_name) ? (self.scope_prefix ? Object.const_get(self.scope_prefix) : Object).const_get(klass_name) : connection.define_openerp_model(model: model_key, scope_prefix: self.scope_prefix)\n klass\n end",
"def object_class(klass)\n @object_classes[klass.to_s.tr('-', '_').downcase]\n end",
"def class_from_type(type)\n send(\"#{type}_class\") if respond_to?(\"#{type}_class\")\n end",
"def base_class_name\n split('::').last\n end",
"def string_to_class string\n chain = string.split \"::\"\n i=0\n res = chain.inject(Module) do |ans,obj|\n break if ans.nil?\n i+=1\n klass = ans.const_get(obj)\n # Make sure the current obj is a valid class\n # Or it's a module but not the last element,\n # as the last element should be a class\n klass.is_a?(Class) || (klass.is_a?(Module) and i != chain.length) ? klass : nil\n end\nrescue NameError\n nil\nend",
"def resource_class(klassname)\n contract_namespaces.each do |ns|\n begin\n return \"#{ns}::#{klassname}\".constantize\n rescue;end\n end\n end",
"def worker_class_constantize(worker_class)\n return worker_class unless worker_class.is_a?(String)\n Object.const_get(worker_class)\n rescue NameError => ex\n case ex.message\n when /uninitialized constant/\n worker_class\n else\n raise\n end\n end",
"def get_class(dns_query, parsed_dns)\n RECORD_CLASS[get_rdata_value(dns_query, parsed_dns, SHORT_LENGTH).to_i]\n end",
"def const_get(arg0)\n end",
"def lookup_class\r\n ObjectSpace.each_object(Class) do |obj|\r\n return obj if obj.ancestors.include?(Rails::Generator::Base) and\r\n obj.name.split('::').last == class_name\r\n end\r\n raise NameError, \"Missing #{class_name} class in #{class_file}\"\r\n end",
"def resource_to_class(resource)\n BlockScore::Util.to_constant(\"BlockScore::#{BlockScore::Util.to_camelcase(resource.to_s)}\")\nend",
"def get_resource_class\n \tresource_name.classify.constantize\n end",
"def class\n __getobj__.class\n end",
"def class_name\n self.class.to_s.split('::').last\n end",
"def get_class_by_type_and_object(type, object)\n if @configuration['types'][type] && klass = @configuration['types'][type][object]\n return get_const_by_name(klass)\n else\n Log.logger_for(:configuration).error(\"No class configuration defined for #{object} and type #{type}\")\n end\n return nil\n end",
"def get_const(subject, key)\n self.class.const_get(\"#{subject.upcase}\")[key]\n end",
"def BaseClass(name)\n name == \"string\" ? String : Object\nend",
"def BaseClass(name)\n name == \"string\" ? String : Object\nend",
"def class\n `$q(this.__native__.className)`\n end",
"def class_for_name qualified_name\n raise unless ::Class === (resolved = ::Object.const_get qualified_name, false)\n resolved\n rescue\n raise ::NameError, %(Could not resolve class for name: #{qualified_name})\n end",
"def _class\n special_attribute('@class'.freeze) || self.class.name.demodulize\n end",
"def klass_from_controller(c = controller_name)\n c.singularize.camelize.constantize\n end",
"def model_class\n class_name.constantize\n end",
"def subclasses\n constants.collect {|const_name| const_get(const_name)}.select {|const| const.class == ::Class}\n end",
"def get(base_module, constant_name)\n nest = Nest.get(base_module)\n if nest\n nest.get(constant_name)\n end\n end",
"def classname\n @classname ||= self.class.name.split(\"::\")[1..-1].join(\"::\")\n end",
"def constantize(str)\n\t\t\tnames = str.split('::')\n\t\t\tnames.shift if names.empty? || names.first.empty?\n\t\t\tconstant = Object\n\t\t\tnames.each do |name|\n\t\t\t\tconstant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)\n\t\t\tend\n\t\t\tconstant\n\t\tend"
] |
[
"0.7334412",
"0.7214519",
"0.7104253",
"0.6873072",
"0.6851775",
"0.68110424",
"0.6771656",
"0.6707184",
"0.6704635",
"0.6664223",
"0.6611103",
"0.6603974",
"0.6578395",
"0.65712726",
"0.65712726",
"0.6550021",
"0.65496194",
"0.6544749",
"0.65220696",
"0.6471819",
"0.6458103",
"0.6424212",
"0.6424212",
"0.63856685",
"0.63856685",
"0.6362266",
"0.63392395",
"0.6336829",
"0.63165987",
"0.6312857",
"0.6302245",
"0.6295604",
"0.62886715",
"0.6273091",
"0.6265792",
"0.6236019",
"0.6222871",
"0.62179565",
"0.6216351",
"0.6211487",
"0.6211487",
"0.61924374",
"0.6187614",
"0.61768365",
"0.6169617",
"0.61688745",
"0.6129523",
"0.611659",
"0.6113878",
"0.61024976",
"0.61024976",
"0.61024976",
"0.6094896",
"0.6060584",
"0.60601765",
"0.6057102",
"0.60343456",
"0.6033234",
"0.60033214",
"0.59995353",
"0.5996261",
"0.59960294",
"0.5975662",
"0.59568363",
"0.5951493",
"0.5945216",
"0.5944208",
"0.59300125",
"0.5914881",
"0.59147084",
"0.5913061",
"0.58973324",
"0.58673203",
"0.5862292",
"0.58384955",
"0.5834122",
"0.582312",
"0.58155787",
"0.58122396",
"0.58045894",
"0.5800936",
"0.5799219",
"0.57914954",
"0.57904243",
"0.57710934",
"0.5770749",
"0.57629544",
"0.5760765",
"0.5754539",
"0.57452416",
"0.57452416",
"0.5743514",
"0.57347435",
"0.5727357",
"0.5697952",
"0.5689373",
"0.568532",
"0.5685204",
"0.5680187",
"0.56773174"
] |
0.6863396
|
4
|
Removes the specified class. Examples: const_get 'String' String const_get ['ActiveRecord', 'Base'] ActiveRecord::Base
|
def const_remove(klass)
klass = [klass] unless klass.kind_of? Array
if klass.length > 1
Utility.const_get(klass[0..-2]).send :remove_const, klass.last
elsif klass.any?
Object.send :remove_const, klass.last
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy_class ( klass )\n klass = klass.name.to_s if klass.kind_of? Class\n Object.class_exec { remove_const klass } if Object.const_defined? klass\nend",
"def destroy_class ( klass )\n klass = klass.name.to_s if klass.kind_of? Class\n Object.class_exec { remove_const klass } if Object.const_defined? klass\nend",
"def force_remove_const(klass, const)\n klass.send(:remove_const, const) if klass.const_defined?(const)\n end",
"def remove_class(name = T.unsafe(nil)); end",
"def remove_class(name = T.unsafe(nil)); end",
"def remove_constant(const)\n return if constant_excluded?(const)\n base, _, object = const.to_s.rpartition('::')\n base = base.empty? ? Object : base.constantize\n base.send :remove_const, object\n logger.devel \"Removed constant #{const} from #{base}\"\n rescue NameError\n end",
"def class_delete class_name\n\t\t\t\t@monitor.synchronize do\n\t\t\t\t\tproviders.each{|p| p.class_delete class_name}\n\t\t\t\tend\n\t\t\tend",
"def deleteclass(cl)\n params = self.params\n params.delete_if { |k,v| k.to_s.match(/#{cl}::.*/) }\n write(params)\n end",
"def remove_const(sym) end",
"def remove(all = false)\n\t\tremove_subclasses if all\n\t\tObject.__send__(:remove_const, self.name)\n\t\tnil\n\tend",
"def remove_class(names = T.unsafe(nil)); end",
"def remove_class_variable(sym) end",
"def remove_class\n destroy_instance_for_course(@current_path.instance_for_course_in_path(@selected_course).id)\n end",
"def remove_app\n Object.send :remove_const, @klass.name if @klass\n @klass = nil\n end",
"def delete_class o_class\n cl = classname(o_class)\n logger.progname = 'RestDelete#DeleteClass'\n if @classes.include? cl\n begin\n \t response = @res[\"/class/#{@database}/#{cl}\"].delete\n if response.code == 204\n \t logger.info{\"Class #{cl} deleted.\"}\n @classes.delete(cl)\n end\n rescue RestClient::InternalServerError => e\n \t if get_database_classes(requery: true).include?(cl)\n \t logger.error{\"Class #{cl} still present.\"}\n \t logger.error{e.inspect}\n \t false\n \t else\n logger.error{e.inspect}\n \t true\n \t end\n rescue Exception => e\n logger.error{e.message}\n logger.error{e.inspect}\n end\n else\n cl.nil? ? logger.info{\"Class #{o_class} not present.\"} : logger.info{\"Class #{cl} not present.\"}\n end\n end",
"def remove_class(sym)\n `var el=this.__native__,klass=sym.__value__`\n `el.className=el.className.replace(new(RegExp)('(^|\\\\\\\\s)'+klass+'(?:\\\\\\\\s|$)'),'$1')`\n return self\n end",
"def remove(klass)\n self.instance.remove(klass)\n end",
"def deconstantize\n MotionSupport::Inflector.deconstantize(self)\n end",
"def deconstantize\n ActiveSupport::Inflector.deconstantize(self)\n end",
"def deconstantize\n ActiveSupport::Inflector.deconstantize(self)\n end",
"def remove_subclasses\n\t\tself.subclasses.each do |klass|\n\t\t\tfront = klass.name\n\t\t\tif /::/.match(front)\n\t\t\t\tfront,back = parts(klass.name)\n\t\t\t\tfront_class = front.split('::').inject(Object) { |o,n| o.const_get n }\n\t\t\t\tfront_class.__send__(:remove_const, back)\n\t\t\telse\n\t\t\t\tObject.__send__(:remove_const, front)\n\t\t\tend\n\t\tend\n\t\tnil\n\tend",
"def reset_constant(klass, constant, new_value)\n klass.send(:remove_const, constant)\n klass.const_set(constant, new_value)\nend",
"def remove_class c\n each do |q|\n str = q.get_attribute(\"class\")\n\n str = str.split(\" \").find_all do |n|\n n != c.to_s\n end.join(\" \")\n \n q.set_attribute(\"class\",str)\n end\n end",
"def remove_const(name)\n unless name._isSymbol\n name = Maglev::Type.coerce_to(name, String, :to_str)\n name = name.to_sym\n end\n __remove_const(name)\n end",
"def destroy_model_class(name)\n if name.is_a?(Hash) && name.size == 1\n class_name, superclass_name = *name.to_a.flatten\n else\n class_name, superclass_name = name, 'ActiveRecord::Base'\n end\n need_table = superclass_name.to_s == 'ActiveRecord::Base'\n\n table_name = class_name.to_s.underscore.pluralize\n ActiveRecord::Base.connection.drop_table(table_name) if need_table\n Object.send(:remove_const, class_name)\n end",
"def delete_by_classname(string)\n key = string.underscore.to_sym\n @config_params.delete(key)\n end",
"def delete_class(domain, klass)\n ! @backend.delete_class(:domain => domain, :class => klass).nil?\n end",
"def deconstantize\n self[0...(rindex('::') || 0)] # implementation based on the one in facets' Module#spacename\n end",
"def remove_existing_lwrp(class_name)\n [self, superclass].each do |resource_holder|\n look_in_parents = false\n if resource_holder.const_defined?(class_name, look_in_parents)\n resource_holder.send(:remove_const, class_name)\n end\n end\n end",
"def clazz\n Module.const_get(name)\n rescue NameError\n nil\n end",
"def unregister(const)\n @@extensions.delete(const)\n end",
"def clear!(klass)\n @cache.delete(klass)\n end",
"def remove(symbol_name)\n Object.send(:remove_const, symbol_name)\n end",
"def retain_class\n @retain_class ||= retain_class_name.constantize\n end",
"def constantize(klass_string) \n BentoSearch::Util.constantize(klass_string) \n end",
"def remove(klass)\n self.registered_items.delete(klass)\n end",
"def remove_class class_name\n string=\"$('##{@id}').removeClass(#{class_name.to_s.inspect})\"\n @app.dom_on_sockets.execute string\n end",
"def remove_assoc_class(in_class_name, alt_target_class = nil, short_class_name = nil)\n cns = in_class_name.to_s.split('::')\n klass = if cns.first == 'DynamicModel'\n cns[0..1].join('::').constantize\n else\n cns.first.constantize\n end\n\n short_class_name = cns.last unless alt_target_class || short_class_name\n alt_target_class ||= model_class_name.pluralize\n alt_target_class = alt_target_class.gsub('::', '')\n assoc_ext_name = \"#{short_class_name}#{alt_target_class}AssociationExtension\"\n return unless klass.constants.include?(assoc_ext_name.to_sym)\n\n klass.send(:remove_const, assoc_ext_name) if implementation_class_defined?(Object)\n rescue StandardError => e\n logger.debug \"Failed to remove #{assoc_ext_name} : #{e}\"\n end",
"def retain_class_name\n @retain_class_name ||= \"Retain::\" + my_class_name.to_s.sub(/.*::/, \"\")\n end",
"def del(x)\n case x\n when String\n del(x.to_sym)\n when Class, Module\n Object.send(:remove_const, x.name)\n when Method\n x.owner.send(:undef_method, x.name)\n when Symbol\n if Object.const_get(x)\n Object.send(:remove_const, x)\n elsif method(x)\n undef_method x\n end\n else\n raise \"Error: don't know how to 'del #{x.inspect}'\"\n end\n end",
"def del(x)\n case x\n when String\n del(x.to_sym)\n when Class, Module\n Object.send(:remove_const, x.name)\n when Method\n x.owner.send(:undef_method, x.name)\n when Symbol\n if Object.const_get(x)\n Object.send(:remove_const, x)\n elsif method(x)\n undef_method x\n end\n else\n raise \"Error: don't know how to 'del #{x.inspect}'\"\n end\n end",
"def delete(class_or_classname, record_id)\n clazz = find_or_materialize(class_or_classname)\n http_delete(\"/services/data/v#{self.version}/sobjects/#{clazz.sobject_name}/#{record_id}\")\n end",
"def deconstantize(path)\n Geode::FastInflector.deconstantize(path)\n end",
"def delete_class(klass)\n raise \"please use a Class type for the klass argument\" unless klass.is_a?(Class)\n\n deleted = {}\n map.each do |key, matchers|\n deleted_matchers = []\n matchers.delete_if do |matcher|\n # because matcher[:klass] may be a string (which needs to die), coerce both to strings to compare somewhat canonically\n if matcher[:klass].to_s == klass.to_s\n deleted_matchers << matcher\n true\n end\n end\n deleted[key] = deleted_matchers unless deleted_matchers.empty?\n map.delete(key) if matchers.empty?\n end\n deleted\n end",
"def stub_remove_const(name)\n if const_defined?(name)\n begin\n orig = const_get(name)\n remove_const(name)\n yield\n ensure\n const_set(name, orig)\n end\n else\n yield\n end\n end",
"def stub_remove_const(name)\n if const_defined?(name)\n begin\n orig = const_get(name)\n remove_const(name)\n yield\n ensure\n const_set(name, orig)\n end\n else\n yield\n end\n end",
"def remove_constant_hierarchy(*names)\n names.each do |name|\n pieces = name.split(\"::\")\n pieces.size.downto(1).each do |size|\n to_remove = pieces.pop\n const_name = pieces.join(\"::\")\n parent = Object.class_eval(const_name) || Object\n parent.send(:remove_const, to_remove)\n end\n end\nend",
"def remove(tag, klass)\n self.instance.remove(tag, klass)\n end",
"def remove(klass)\n Array(klass).each do |k|\n if k.instance_of?(Module)\n @module_formatters.delete(k)\n else\n k = k.name if k.is_a?(Class)\n @class_formatters.delete(k)\n end\n end\n self\n end",
"def remove_class(names = nil)\n kwattr_remove(\"class\", names)\n end",
"def undefine_const(*consts)\n consts.each do |const|\n if Object.const_defined?(const)\n Object.send(:remove_const, const)\n end\n end\nend",
"def get_class(cname, mdl = Processor)\n mdl.const_get(cname.split(/[\\,\\_]/).map { |p| p.capitalize }.join)\n rescue NameError\n return nil\n end",
"def reload_classes\n klasses = [:Inject]\n\n # unload classes\n Object.class_eval do\n klasses.each do |klass|\n remove_const klass.to_s if const_defined? klass.to_s\n end\n end\n\n # reload classes\n klasses.each do |klass|\n load \"#{klass.to_s.underscore}.rb\"\n end\n end",
"def remove_method\n :\"remove_#{singularize(self[:name])}\"\n end",
"def get_constant(basis, class_string)\n begin\n class_string.split('::').reduce(basis) do |basis, const|\n basis.const_get(const, false)\n end\n rescue NameError\n nil\n end\n\n end",
"def obtain(klass, root = Object)\n Thread.exclusive{\n klass.to_s.scan(/\\w+/){|part| root = root.const_get(part) }\n return root\n }\n end",
"def remove(type); end",
"def convert_to_class(klass)\n @class_cache[klass] ||= Object.const_get(camelize(klass))\n rescue NameError\n raise Traitor::Error.new(\"Tried to create a #{camelize(klass)}, but it does not exist!\")\n end",
"def class_const(sym)\n self.class.const_get(sym)\n end",
"def get_class(class_name)\n Module.const_get(class_name)\n rescue\n nil\n end",
"def final_type(klass, type)\n case\n when Object.const_defined?(type) ; Object.const_get(type)\n when klass.const_defined?(type) ; klass.const_get(type)\n when klass._base.const_defined?(type); klass._base.const_get(type)\n else\n raise ArgumentError.new(\"Failed to find the definition for #{type}!\")\n end\n end",
"def _remove_method\n :\"_remove_#{singularize(self[:name])}\"\n end",
"def clear_registration_as_constant\n # Deregister non-permanent models that are registered in the\n # constant hierarchy\n if Registration.accessible_by_name?(self)\n Registration.deregister_constant(self)\n end\n end",
"def class_from_string(class_name)\n parts = class_name.split('::')\n constant = Object\n parts.each do |part|\n constant = constant.const_get(part)\n end\n constant\nend",
"def class_get class_name\n\t\t\t\t@monitor.synchronize do\n\t\t\t\t\tproviders.each do |p|\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\treturn p.class_get(class_name) \n\t\t\t\t\t\trescue NotExist;\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\traise \"Class '#{class_name}' doesn't exist!\"\n\t\t\t\tend\n\t\t\tend",
"def const_get(klass)\n klass = [klass] unless klass.kind_of? Array\n klass.inject(Object) do |context, scope|\n context.const_get(scope)\n end\n end",
"def remove_method\n :\"remove_#{self[:name].to_s.singularize}\"\n end",
"def get_class(name)\n # 'self' -- the class from which get_class is called.\n self.const_get(name)\n end",
"def service_klass(constant_string)\n if const_defined?([to_s, constant_string].join(\"::\"))\n [to_s, constant_string].join(\"::\")\n else\n provider = to_s.split(\"::\").last\n Fog::Logger.deprecation(\"Unable to load #{[to_s, constant_string].join('::')}\")\n Fog::Logger.deprecation(\n format(\n Fog::ServicesMixin::E_SERVICE_PROVIDER_CONSTANT,\n service: constant_string,\n provider: provider\n )\n )\n [\"Fog\", constant_string, provider].join(\"::\")\n end\n end",
"def deconstantize(path)\n path.to_s[0...(path.rindex('::') || 0)] # implementation based on the one in facets' Module#spacename\n end",
"def required_class\n return @required_class if defined?(@required_class)\n @required_class = @required_class_name.split(\"::\").inject(Object, :const_get)\n end",
"def worker_class_constantize(worker_class)\n return worker_class unless worker_class.is_a?(String)\n Object.const_get(worker_class)\n rescue NameError => ex\n case ex.message\n when /uninitialized constant/\n worker_class\n else\n raise\n end\n end",
"def klass\n name.gsub(module_name+\"::\",\"\")\n end",
"def stripped_class_name\n name.demodulize\n end",
"def sti_class(v)\n case v\n when String, Symbol\n constantize(v) rescue self\n when nil\n self\n when Class\n v\n else\n raise(Error, \"Invalid class type used: #{v.inspect}\")\n end\n end",
"def unmodify_nilclass; end",
"def remove_classes(*args)\n args.each {|x| self.remove_class(x) }\n return self\n end",
"def reload_asset_classes\n list = [:Asset, :AssetPublic, :AssetPrivate]\n list.each do |sym|\n Object.send(:remove_const, sym)\n end\n list.each do |sym|\n Object.send(:load, sym.to_s.underscore)\n end\n\n end",
"def const_get(base, klass, const_name)\n if klass.const_defined?(const_name)\n klass.const_get(const_name)\n else\n nil\n end\n end",
"def remove_class name = nil\n each do |el|\n next unless el.respond_to? :get_attribute\n if name\n classes = el.get_attribute('class').to_s.split(\" \")\n el.set_attribute('class', (classes - [name]).uniq.join(\" \"))\n else\n el.remove_attribute(\"class\")\n end\n end\n self \n end",
"def class_constant; end",
"def class_constant; end",
"def path_to_class(path, base_class=nil)\n class_name = path.classify\n klass = class_name.safe_constantize\n return klass if klass.present? && klass.kind_of?(Class)\n raise \"Class #{class_name.inspect} constant already exists as a #{klass.name} and is not a class.\" if klass.present?\n path_mod = class_module(path)\n class_mod_name = class_name.demodulize\n if base_class.present?\n klass = path_mod.const_set(class_mod_name, Class.new(base_class))\n else\n klass = path_mod.const_set(class_mod_name, Class.new)\n end\n raise \"Could not create class #{class_name.inspect} in module #{path_mod.inspect}.\" if klass.blank?\n klass\nend",
"def unregister_extension(const)\n @@extensions.delete(const)\n end",
"def unregister_extension(const)\n @@extensions.delete(const)\n end",
"def delete_all\n @loaded_constants.each do |const_name|\n if Object.const_defined?(const_name)\n Object.send(:remove_const, const_name)\n end\n end\n Ichiban::HTMLCompiler::Context.clear_user_defined_helpers\n end",
"def removeClass\n\t\t# This deletes the course from the user's table\n\t\t# optone is the course name from the submitted form\n\t\tUsername.destroy_all(:course_number => params[:optone])\n\t\t# This deletes the courses from calendar to reflect course being removed\n\t\tEvent.destroy_all(:title => params[:optone])\n\tend",
"def _remove_method\n :\"_remove_#{self[:name].to_s.singularize}\"\n end",
"def remove_class(*classes)\n classes.each { |cls| `#{@el}.classList.remove(#{cls})` }\n end",
"def remove_unloadable_constants!\n log(\"removing unloadable constants\")\n autoloaded_constants.each { |const| remove_constant const }\n autoloaded_constants.clear\n Reference.clear!\n explicitly_unloadable_constants.each { |const| remove_constant const }\n end",
"def const_get(const_name)\n self.class.const_get(const_name)\n rescue\n nil\n end",
"def klass\n @klass ||= class_name.constantize\n end",
"def klass\n @klass ||= class_name.constantize\n end",
"def const_get_tree(tree)\n if tree.size == 1\n Object.const_get(tree.first)\n else\n tree[1..-1].inject(Object.const_get(tree.first)) { |new_base, part| new_base.const_get(part) }\n end\n rescue\n raise ArgumentError, \"Can't figure out command class name from path #{path} - tried #{tree}\"\n end",
"def remove_class(a_class)\n self.attr['class'] = (attr['class'] || '').split(' ')\n .map { |e| e.gsub(/\\A#{ a_class.strip }\\z/, '') }\n .join(' ')\n end",
"def resource_delete klass, resource_name\n\t\t\t\t@monitor.synchronize do\n\t\t\t\t\tproviders.each do |p|\n\t\t\t\t\t\tnext unless p.class_exist?(klass.name)\n\t\t\t\t\t\tp.resource_delete klass.name, resource_name\t\t\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend",
"def klass\n @klass ||= begin\n @klass_name.split('::').inject(Object){|n,i| n.const_get(i)}\n rescue NameError => e\n end\n end",
"def class_for_path(path)\n path.split('::').inject(Kernel) do |scope, const_name|\n scope.const_get(const_name)\n end\n end",
"def class_for_path(path)\n path.split('::').inject(Kernel) do |scope, const_name|\n scope.const_get(const_name)\n end\n end",
"def remove_by_id(clazz, id)\n client.remove(:class => clazz, :id => id)\n end"
] |
[
"0.7097662",
"0.7097662",
"0.6871307",
"0.6773116",
"0.6773116",
"0.66102207",
"0.6467323",
"0.6315427",
"0.62628007",
"0.6225008",
"0.6170541",
"0.61001974",
"0.6087947",
"0.6046526",
"0.6029146",
"0.60193866",
"0.5984087",
"0.5979203",
"0.59605956",
"0.59605956",
"0.5959502",
"0.5946639",
"0.594138",
"0.5844898",
"0.5841198",
"0.58335227",
"0.580388",
"0.57523817",
"0.5748261",
"0.5677799",
"0.56348413",
"0.5627502",
"0.56265855",
"0.56107175",
"0.5600981",
"0.5589318",
"0.5586019",
"0.5571276",
"0.5435061",
"0.5427831",
"0.5427831",
"0.5421707",
"0.5394748",
"0.5374386",
"0.53669107",
"0.53669107",
"0.53657895",
"0.53534085",
"0.5352579",
"0.53472114",
"0.5340715",
"0.53391796",
"0.533309",
"0.5317844",
"0.53172654",
"0.5283258",
"0.5283107",
"0.52752185",
"0.52696264",
"0.5261874",
"0.52487695",
"0.5248433",
"0.5244547",
"0.5227867",
"0.52112836",
"0.5210123",
"0.5198231",
"0.5189451",
"0.51697993",
"0.516168",
"0.51560575",
"0.51535684",
"0.5150067",
"0.5145289",
"0.51412743",
"0.5140005",
"0.5135372",
"0.51314133",
"0.5102638",
"0.508124",
"0.50700086",
"0.50700086",
"0.5065262",
"0.5056267",
"0.5056267",
"0.5046747",
"0.504426",
"0.5036124",
"0.5033223",
"0.50291544",
"0.50230217",
"0.5010756",
"0.5010756",
"0.5001987",
"0.50015944",
"0.49966693",
"0.49922884",
"0.49737787",
"0.49737787",
"0.4969081"
] |
0.72459763
|
0
|
end before filter methods
|
def index
if params[:show_deleted]
@users = User.order('login ASC')
else
@users = User.active.order('login ASC')
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def filter\n end",
"def apply_filter\n end",
"def filter; end",
"def filter; end",
"def filter; end",
"def filters; end",
"def filters; end",
"def filter\n super\n end",
"def filters\n end",
"def filter!; end",
"def global_filter; end",
"def after_filter; end",
"def filter_parameters; end",
"def filter_parameters; end",
"def before_filter; end",
"def add_filter\n @filter = true \n end",
"def filters=(_arg0); end",
"def filters=(_arg0); end",
"def filter_argument; end",
"def filter\n\tfilter_disabled\n\tfilter_repeated\n\tfilter_silenced\n\tfilter_dependencies\n end",
"def Filter=(arg0)",
"def strict_filters; end",
"def entry_filter; end",
"def named_filter; end",
"def filter(options={})\n super\n end",
"def filters_halted\n end",
"def filter\n @filter\n end",
"def filter_methods; end",
"def register_filter(mod); end",
"def add_filters(filters); end",
"def filtered_entries; end",
"def filter_cache; end",
"def unfiltered_content; end",
"def unfiltered_content; end",
"def unfiltered_content; end",
"def filter_generator; end",
"def before_filter(&block)\n @before_filter = block\n end",
"def filterable?; @filterable; end",
"def filter\n\t\treturn @filter\n\tend",
"def before filter\n @station.before filter\n end",
"def before_filter(&block)\n @before_filter = block\n end",
"def autofilter\n true\n end",
"def autofilter\r\n\t\tfalse\r\n\tend",
"def autofilter\r\n\t\tfalse\r\n\tend",
"def autofilter\r\n\t\tfalse\r\n\tend",
"def autofilter\r\n\t\tfalse\r\n\tend",
"def filtered_parameters; end",
"def filter_parameters=(_arg0); end",
"def filter_parameters=(_arg0); end",
"def filter_redirect; end",
"def filter_redirect; end",
"def global_filter=(_arg0); end",
"def strict_filters=(_arg0); end",
"def reset_filter!\n skip_before_action(:filter_access_filter) if method_defined?(:filter_access_filter)\n before_action :filter_access_filter\n end",
"def filter(record)\n true\n end",
"def filters\n @filters ||= {}\n end",
"def run_filters\n set_user\n authorize\n end",
"def before_processing\n end",
"def test_add_filter\n flunk\n end",
"def ts_apply_filters\n # TODO: Make filters for Thinking Sphinx\n end",
"def process_before_filter name\n filter = find_method name, @current_class\n\n if filter.nil?\n Brakeman.debug \"[Notice] Could not find filter #{name}\"\n return\n end\n\n method = filter[:method]\n\n if ivars = @tracker.filter_cache[[filter[:controller], name]]\n ivars.each do |variable, value|\n env[variable] = value\n end\n else\n processor = Brakeman::AliasProcessor.new @tracker\n processor.process_safely(method.body_list, only_ivars(:include_request_vars))\n\n ivars = processor.only_ivars(:include_request_vars).all\n\n @tracker.filter_cache[[filter[:controller], name]] = ivars\n\n ivars.each do |variable, value|\n env[variable] = value\n end\n end\n end",
"def filter(options={})\n raise NotImplementedError\n end",
"def before_filter_if_not_already_added(method)\n unless filter_already_added? method\n before_filter method\n end\n end",
"def filter(*args)\n raise NotImplementedError, 'Subclass should implement.'\n end",
"def filter_response(response, request)\n # nothing to do\n end",
"def before(&b)\n filter :before, &b\n end",
"def halted_callback_hook(filter, _); end",
"def filter(event)\n\n #Category\n category = event.get(\"category\")\n if category.nil?\n category = \"\"\n end\n\n new_category = fn_make_cate_all(category, 0) \n event.set(\"category\", new_category)\n\n service_gubun = event.get(\"service_gubun\")\n\n new_cat1 = fn_make_cate_all(category, 2) \n event.set(\"cat1\", new_cat1)\n \n new_cat2 = fn_make_cate_all(category, 4) \n event.set(\"cat2\", new_cat2)\n \n new_cat3 = fn_make_cate_all(category, 6) \n event.set(\"cat3\", new_cat3)\n \n new_cat4 = fn_make_cate_all(category, 8) \n event.set(\"cat4\", new_cat4)\n\n new_cg = \"\"\n if service_gubun == \"1\"\n new_cg = new_cat2 \n else\n new_cg = new_cat1 \n end \n event.set(\"cg\", new_cg)\n\n #Model Factory\n #deplecated : ES에서 Model-Factory 전용 Tokenizer 사용\n=begin\n if service_gubun == \"1\"\n modelnm = event.get(\"modelnm\")\n factory = event.get(\"factory\")\n if modelnm.nil?\n modelnm = \"\"\n end\n if factory.nil?\n factory = \"\"\n end\n\n model_factory = factory_all(modelnm+\" \"+factory)\n event.set(\"model_factory\", model_factory)\n end\n=end\n \n return [event]\n\nend",
"def before method_or_filter, options={}, &block\n _add_filter(:before, method_or_filter, options, block)\n end",
"def filter_rspamd\n end",
"def data_context_filter_1\r\n\r\n ckie = (RUBY_VERSION =~ /^1.8/) ? Iconv.new('UTF-8//IGNORE', 'latin1').iconv(cookies[:active_filters] || \"\") : (cookies[:active_filters] || \"\").force_encoding(Encoding::ISO_8859_1).encode!(Encoding::UTF_8)\r\n if !ckie.blank?\r\n find_hash = DevFeedback.named_scope_active_filter_method(ActiveSupport::JSON.decode(ckie))\r\n conds = find_hash[:conditions]\r\n @joins_fields = find_hash[:joins]\r\n\r\n DevFeedback.send(:with_scope, {:find => {:conditions => conds, :joins => (@joins_fields || [])}}) {\r\n yield\r\n }\r\n\r\n else\r\n yield\r\n end\r\n end",
"def filter_redirect=(_arg0); end",
"def filter_redirect=(_arg0); end",
"def filter_items\n @filter_items ||= []\n end",
"def data_context_filter_1\r\n\r\n ckie = (RUBY_VERSION =~ /^1.8/) ? Iconv.new('UTF-8//IGNORE', 'latin1').iconv(cookies[:active_filters] || \"\") : (cookies[:active_filters] || \"\").force_encoding(Encoding::ISO_8859_1).encode!(Encoding::UTF_8)\r\n if !ckie.blank?\r\n find_hash = User.named_scope_active_filter_method(ActiveSupport::JSON.decode(ckie))\r\n conds = find_hash[:conditions]\r\n @joins_fields = find_hash[:joins]\r\n\r\n User.send(:with_scope, {:find => {:conditions => conds, :joins => (@joins_fields || [])}}) {\r\n yield\r\n }\r\n\r\n else\r\n yield\r\n end\r\n end",
"def filter1(string)\n\nend",
"def filter\n setup_instance_variables\n render 'index'\n end",
"def data_context_filter_1\r\n\r\n ckie = (RUBY_VERSION =~ /^1.8/) ? Iconv.new('UTF-8//IGNORE', 'latin1').iconv(cookies[:active_filters] || \"\") : (cookies[:active_filters] || \"\").force_encoding(Encoding::ISO_8859_1).encode!(Encoding::UTF_8)\r\n if !ckie.blank?\r\n find_hash = BgWorker.named_scope_active_filter_method(ActiveSupport::JSON.decode(ckie))\r\n conds = find_hash[:conditions]\r\n @joins_fields = find_hash[:joins]\r\n\r\n BgWorker.send(:with_scope, {:find => {:conditions => conds, :joins => (@joins_fields || [])}}) {\r\n yield\r\n }\r\n\r\n else\r\n yield\r\n end\r\n end",
"def filters\n @filters ||= {}\n end",
"def filters\n @filters ||= {}\n end",
"def set_filter(opts)\n opts = check_params(opts,[:filters])\n super(opts)\n end",
"def postFetchFilter\n @filtered= Filter.new(@detail.waypoints)\n\n # caches with warnings we choose not to include.\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['includeArchived']\n @appliedFilters['--includeArchived'] = { 'f' => \"\", 't' => \"also archived\" }\n else\n # this would cause too much noise, don't advertise\n #@appliedFilters['--excludeArchived'] = { 'f' => \"\", 't' => \"not archived\" }\n @filtered.removeByElement('archived')\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Archived\")\n #\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['includeDisabled']\n @appliedFilters['-z'] = { 'f' => \"\", 't' => \"also disabled\" }\n else\n @appliedFilters['+z'] = { 'f' => \"\", 't' => \"not disabled\" }\n @filtered.removeByElement('disabled')\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Disabled\")\n\n # exclude Premium Member Only caches on request\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['noPMO']\n @appliedFilters['-O'] = { 'f' => \"\", 't' => \"no PMO\" }\n @filtered.removeByElement('membersonly')\n end\n if @option['onlyPMO']\n @appliedFilters['-Q'] = { 'f' => \"\", 't' => \"PMO\" }\n @filtered.removeByElement('membersonly', false)\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"PM-Only\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['descKeyword']\n @appliedFilters['-K'] = { 'f' => \"#{@option['descKeyword']}\", 't' => \"matching descr. keyword\" }\n @filtered.descKeyword(@option['descKeyword'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Keyword\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['difficultyMin']\n @appliedFilters['-d'] = { 'f' => \"#{@option['difficultyMin']}\", 't' => \"difficulty min\" }\n @filtered.difficultyMin(@option['difficultyMin'].to_f)\n end\n if @option['difficultyMax']\n @appliedFilters['-D'] = { 'f' => \"#{@option['difficultyMax']}\", 't' => \"difficulty max\" }\n @filtered.difficultyMax(@option['difficultyMax'].to_f)\n end\n if @option['terrainMin']\n @appliedFilters['-t'] = { 'f' => \"#{@option['terrainMin']}\", 't' => \"terrain min\" }\n @filtered.terrainMin(@option['terrainMin'].to_f)\n end\n if @option['terrainMax']\n @appliedFilters['-T'] = { 'f' => \"#{@option['terrainMax']}\", 't' => \"terrain max\" }\n @filtered.terrainMax(@option['terrainMax'].to_f)\n end\n if @option['sizeMin']\n @appliedFilters['-s'] = { 'f' => \"#{@option['sizeMin']}\", 't' => \"size min\" }\n @filtered.sizeMin(@option['sizeMin'])\n end\n if @option['sizeMax']\n @appliedFilters['-S'] = { 'f' => \"#{@option['sizeMax']}\", 't' => \"size max\" }\n @filtered.sizeMax(@option['sizeMax'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"D/T/Size\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['favFactorMin']\n @appliedFilters['-g'] = { 'f' => \"#{@option['favFactorMin']}\", 't' => \"favFactor min\" }\n @filtered.favFactorMin(@option['favFactorMin'].to_f)\n end\n if @option['favFactorMax']\n @appliedFilters['-G'] = { 'f' => \"#{@option['favFactorMax']}\", 't' => \"favFactor max\" }\n @filtered.favFactorMax(@option['favFactorMax'].to_f)\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"FavFactor\")\n\n # We filter for users again. While this may be a bit obsessive, this is in case\n # our local cache is not valid.\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['userExclude']\n @appliedFilters['-E'] = { 'f' => \"#{@option['userExclude']}\", 't' => \"not done by\" }\n @option['userExclude'].split($delimiters).each{ |user|\n @filtered.userExclude(user)\n }\n end\n if @option['userInclude']\n @appliedFilters['-e'] = { 'f' => \"#{@option['userInclude']}\", 't' => \"done by\" }\n @option['userInclude'].split($delimiters).each{ |user|\n @filtered.userInclude(user)\n }\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"User\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['attributeExclude']\n @appliedFilters['-A'] = { 'f' => \"#{@option['attributeExclude']}\", 't' => \"attr no\" }\n @option['attributeExclude'].split($delimiters).each{ |attribute|\n @filtered.attributeExclude(attribute)\n }\n end\n if @option['attributeInclude']\n @appliedFilters['-a'] = { 'f' => \"#{@option['attributeExclude']}\", 't' => \"attr yes\" }\n @option['attributeInclude'].split($delimiters).each{ |attribute|\n @filtered.attributeInclude(attribute)\n }\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Attribute\")\n\n beforeFilterTotal = @filtered.totalWaypoints\n if @option['minLongitude']\n @appliedFilters['--minLon'] = { 'f' => \"#{@option['minLongitude']}\", 't' => \"West\" }\n @filtered.longMin(@option['minLongitude'])\n end\n if @option['maxLongitude']\n @appliedFilters['--maxLon'] = { 'f' => \"#{@option['maxLongitude']}\", 't' => \"East\" }\n @filtered.longMax(@option['maxLongitude'])\n end\n if @option['minLatitude']\n @appliedFilters['--minLat'] = { 'f' => \"#{@option['minLatitude']}\", 't' => \"South\" }\n @filtered.latMin(@option['minLatitude'])\n end\n if @option['maxLatitude']\n @appliedFilters['--maxLat'] = { 'f' => \"#{@option['maxLatitude']}\", 't' => \"North\" }\n @filtered.latMax(@option['maxLatitude'])\n end\n excludedFilterTotal = beforeFilterTotal - @filtered.totalWaypoints\n showRemoved(excludedFilterTotal, \"Lat/Lon\")\n\n displayMessage \"Post-fetch filter complete, #{caches(@filtered.totalWaypoints)} left.\"\n return @filtered.totalWaypoints\n end",
"def ensure_filters\n # private_methods returns the list of private methods accessible to obj. If the all parameter is set to\n # false, only those methods in the receiver will be listed.\n private_methods(false).grep(/\\Afilter_by_/)&.each { |filter| send(filter) }\n end",
"def filter(objects) objects end",
"def filter2(string)\n\nend",
"def before(*args, &block)\n add_filter :before, &(args.empty? ? block : construct_filter(*args, &block))\n end",
"def filter\n @filter = params[:q]\n end",
"def after_filter(&block)\n @after_filter = block\n end",
"def bench_filters\n skip 'TODO'\n end",
"def allowed_filters\n []\n end",
"def filter(&block)\n filters = self.filters << yield\n metaclass.send(:define_method, :_filters) do\n filters\n end\n end",
"def filter\n\t\tchain(\n\t\t\tsuper, # Use automatic filter switching, i.e. use params[:filter] and #filter_options\n\t\t\t{:published => true}, # Only find published tags\n\t\t\tlambda { |tag| !tag.active_businesses_in_city(@city).empty? } # Only find tags with at least one active business\n\t\t)\n\tend",
"def filtered?\n filtered\n end",
"def add_terms_filters\n add_work_type_filter\n add_user_filter\n add_pseud_filter\n add_collection_filter\n end",
"def method_missing(method_name, *args)\n if m = method_name.to_s.match(/\\Apasses_filter_(\\d+)\\Z/)\n object_filter = ObjectFilter.find(m[1])\n passes_filter? object_filter\n elsif m = method_name.to_s.match(/\\AFilter: (.+)\\Z/)\n object_filter = ObjectFilter.find_by_title(m[1])\n return super unless object_filter\n passes_filter? object_filter\n else\n super(method_name, *args)\n end\n end",
"def filter_for(item)\n self.class.filter_for filter, item\n end",
"def before_filter(filter_name, options)\n [options[:only]].flatten.each do |action|\n add_filter(filter_name, action)\n end\n end",
"def before_filter_list method, klass\n controller = @tracker.controllers[klass]\n filters = []\n\n while controller\n filters = get_before_filters(method, controller) + filters\n\n controller = @tracker.controllers[controller[:parent]] ||\n @tracker.libs[controller[:parent]]\n end\n\n remove_skipped_filters filters, method, klass\n end",
"def filter\n Options.new(yield self)\n end",
"def prepare_filters\n params = instance_values.symbolize_keys\n filters = clean_params(params)\n validate_filters(filters)\n end",
"def filters\n self.class.filters\n end"
] |
[
"0.8296995",
"0.82520986",
"0.821787",
"0.821787",
"0.821787",
"0.81738895",
"0.81738895",
"0.79680437",
"0.7895059",
"0.77649826",
"0.75688267",
"0.74624014",
"0.74499047",
"0.74499047",
"0.73177344",
"0.72990304",
"0.72163707",
"0.72163707",
"0.71732414",
"0.71664345",
"0.7026175",
"0.7014873",
"0.6976029",
"0.6951629",
"0.69191474",
"0.6893728",
"0.6890642",
"0.68338364",
"0.68128276",
"0.67997855",
"0.67586166",
"0.6748083",
"0.67454946",
"0.67454946",
"0.67454946",
"0.67275894",
"0.6716985",
"0.6697302",
"0.6691205",
"0.66902333",
"0.66681254",
"0.66585714",
"0.6657175",
"0.6657175",
"0.6657175",
"0.6657175",
"0.6646501",
"0.66390616",
"0.66390616",
"0.6621895",
"0.6621895",
"0.661898",
"0.66168946",
"0.6598234",
"0.6548731",
"0.6468961",
"0.6421466",
"0.6413964",
"0.6413948",
"0.6413519",
"0.6403599",
"0.6378105",
"0.6360854",
"0.63508046",
"0.63072765",
"0.62528795",
"0.62527025",
"0.6248083",
"0.6242456",
"0.6227194",
"0.6225691",
"0.6219369",
"0.6219369",
"0.62177014",
"0.62149537",
"0.62118876",
"0.6206219",
"0.6188803",
"0.618076",
"0.618076",
"0.617032",
"0.61675465",
"0.61653644",
"0.61490387",
"0.6134306",
"0.6115326",
"0.61108685",
"0.6109586",
"0.60967493",
"0.6095512",
"0.6089479",
"0.60447323",
"0.6031684",
"0.6030321",
"0.6024938",
"0.6022779",
"0.60185987",
"0.6007005",
"0.60052043",
"0.600425",
"0.5995369"
] |
0.0
|
-1
|
setter should hit all checkers of the variable
|
def blocks_to_hit
super + (task.variable ? task.variable.checkers : [])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set; end",
"def set; end",
"def __setter__\n \"#{self}=\"\n end",
"def _setter_method\n :\"_#{self[:name]}=\"\n end",
"def x=(value)\n end",
"def _setter_method\n :\"_#{self[:name]}=\"\n end",
"def setter\r\n @setter ||= Field.setter(@name)\r\n end",
"def value=(val); end",
"def value=(newval)\n raise\n end",
"def set(value)\n raise NotImplementedError\n end",
"def proxy=(new_value); end",
"def setter\n @setter ||= \"#{name}=\"\n end",
"def watch_for_set=(_arg0); end",
"def method_missing(setter, value)\n case setter.to_s\n when /^set_(.+)/\n variable_name = \"@#{$1}\"\n if instance_variable_defined?(variable_name)\n instance_variable_set(variable_name, value)\n else\n raise NoMethodError.new(\"Undefined setter '#{setter.to_s}' for #{self.class}.\")\n end\n else\n super\n end\n end",
"def setter\n @setter ||= :\"#{@name}=\"\n end",
"def set!(*args)\n end",
"def set\n false\n end",
"def setter_method\n :\"#{self[:name]}=\"\n end",
"def checked=(_arg0); end",
"def value=(_); end",
"def instance_variable_set(p0, p1) end",
"def validator=(_); end",
"def set_value( value )\n @value = value \n end",
"def set(object, value); end",
"def setter_method\n :\"#{self[:name]}=\"\n end",
"def x=(x)\n end",
"def baz=(value)\n @baz = value\nend",
"def baz=(value)\n @baz = value\nend",
"def value!\n\t\t@mutex.synchronize {\n\t\t\t@old = true\n\n\t\t\t@value unless @exception\n\t\t}\n\tend",
"def set=(_arg0); end",
"def test_dogs_stolen_setter\n evil_henchperson = EvilHenchperson.new(name: \"Rasputin\", age: 47, gender: \"male\", \n legs: 4, eyes: 2, ears: 2, shots: true, weapon: \"magic\", depravity: 83, dogs_stolen: 893)\n \n evil_henchperson.dogs_stolen = 0\n assert_equal(0, evil_henchperson.dogs_stolen)\n end",
"def set!(resource, value)\n hook_value(resource, value) unless value.kind_of? Hooker\n super\n end",
"def value=(value)\n p assigned: value\nend",
"def safe=(_arg0); end",
"def set(*args)\n # not supported\n end",
"def set(*args)\n # not supported\n end",
"def warn=(value) @warn = true; end",
"def old_value=(_arg0); end",
"def fire\n @variable.set_value @value, @name\n super\n end",
"def ass(ex, val)\n hop_warn \"#{self.class.inspect}: assignment to this value is not supported\"\n end",
"def actual=(value)\n throw \"must be provided by subclass\"\n end",
"def set(value)\n @value = handler.sanitize(value)\n validate\n @value\n end",
"def expected_value=(arg)\n end",
"def expected_value=(arg)\n end",
"def safe_by_default=(_arg0); end",
"def offenses_to_check=(_arg0); end",
"def dirty=(_arg0); end",
"def class_variable_set(sym,val) end",
"def thing=(aThing)\r\n @thing = aThing\r\nend",
"def value=(val)\r\n @value = val\r\n @candidates = []\r\n @modified = true\r\n end",
"def hack\n self.price = 200\n end",
"def set(value)\n value\n end",
"def set_Safe(value)\n set_input(\"Safe\", value)\n end",
"def set_Safe(value)\n set_input(\"Safe\", value)\n end",
"def set_Safe(value)\n set_input(\"Safe\", value)\n end",
"def error=(value) @error = true; end",
"def foo=(x)\n @num=x\n end",
"def collectible_private= newval\n # Boolean may be coming in as string or integer\n cached_ref(true).private =\n case newval\n when Fixnum\n newval == 1\n when String\n newval == \"1\"\n when nil\n false\n else\n newval\n end\n end",
"def z=(value)\n end",
"def set?\n self == :set\n end",
"def method=(_); end",
"def y=(y)\n end",
"def inject_acl_object_getter_setter(method_name)\n inject_acl_object_check(method_name, :read)\n inject_acl_object_check(\"#{method_name}=\",:write)\n end",
"def value=(value); self.data.value = value; end",
"def set(value)\n @value = value\n #info(@name, ' = ', value.inspect, '(type:', value.class,')')\n info('value = ', value.inspect, ' (',value.class,')')\n @changeListeners.each { |l|\n l.call(value)\n }\n TraceState.property(@name, :set, {'value' => value.inspect})\n end",
"def set(value)\n @value = value\n #info(@name, ' = ', value.inspect, '(type:', value.class,')')\n info(\"#{@name} = #{value.inspect} (#{value.class})\")\n @changeListeners.each { |l|\n l.call(value)\n }\n TraceState.property(@name, :set, {'value' => value.inspect})\n end",
"def value=(value)\n if @value.class == value.class\n @value = value\n @updater = nil\n else\n raise \"Class of new value (#{value.class}) does not match class of current value (#{@value.class})\"\n end\n end",
"def __copy_on_write__(*)\n super.tap do\n new_set = __getobj__.instance_variable_get(:@set).dup\n __getobj__.instance_variable_set(:@set, new_set)\n end\n end",
"def set(value)\n # Set a name for looking up associated options like the event.\n name = self.class.value_name(value)\n\n call = self.class.value_option(name, :call) || :none\n\n if call == :instead\n call_valuemethod(name, value)\n elsif call == :none\n # They haven't provided a block, and our parent does not have\n # a provider, so we have no idea how to handle this.\n self.fail \"#{self.class.name} cannot handle values of type #{value.inspect}\" unless @resource.provider\n call_provider(value)\n else\n # LAK:NOTE 20081031 This is a change in behaviour -- you could\n # previously specify :call => [;before|:after], which would call\n # the setter *in addition to* the block. I'm convinced this\n # was never used, and it makes things unecessarily complicated.\n # If you want to specify a block and still call the setter, then\n # do so in the block.\n devfail \"Cannot use obsolete :call value '#{call}' for property '#{self.class.name}'\"\n end\n end",
"def old_value; end",
"def internals_set(attribute, internal_value)\n @_errors ||= {}\n internals_set(self.class[attribute], @_data)\n end",
"def value=(new_value)\n\t\t@value = new_value\n\t\tinform_obeservers\n\tend",
"def private=(_); end",
"def set_value new_value\n if validate_value new_value\n @value = new_value\n end\n end",
"def change_it(val)\n val = 5\nend",
"def setter?( m_name )\n ( m_name.to_s.strip =~/(.+)=$/ ) ? true : false\n end",
"def setValue(value)\n @value = value\n end",
"def initialize(value)\r\n @value = value\r\n @changeable = true\r\n default_value?\r\nend",
"def method_missing(method, *args)\n # Give OpenStruct a chance to create getters and setters for the\n # corresponding field\n super method, *args\n\n if field = setter?(method)\n # override setter logic to apply any existing sanitization rules before\n # assigning the new value to the field\n override_setter_for(field) if sanitize?(field)\n # uses the newly created setter to set the field's value and apply any\n # existing sanitization rules\n send(method, args[0])\n end\n end",
"def to_setter\n\t\t\t\t(to_getter.to_s+\"=\").to_sym\n\t\t\tend",
"def set(value)\n super(value == :true)\n end",
"def mutability=(value)\n @mutability = value\n end",
"def value=(v)\n set(v)\n end",
"def _set(name, value)\n @current_rules[name.to_s] = value\n nil\n end",
"def attribute=(name, value)\n send(\"#{name}_will_change!\") if _active_remote_track_changes? && value != self[name]\n super\n end",
"def attribute_to_set; end",
"def set_value val, key=\"\"\n oldval = @value\n if @klass == 'String'\n @value = val\n elsif @klass == 'Hash'\n #$log.debug \" Variable setting hash #{key} to #{val}\"\n oldval = @value[key]\n @value[key]=val\n elsif @klass == 'Array'\n #$log.debug \" Variable setting array #{key} to #{val}\"\n oldval = @value[key]\n @value[key]=val\n else\n oldval = @value\n @value = val\n end\n return if @update_command.nil?\n @update_command.each_with_index do |comm, ix|\n comm.call(self, *@args[ix]) unless comm.nil?\n end\n @dependents.each {|d| d.fire_property_change(d, oldval, val) } unless @dependents.nil?\n end",
"def validate_and_set(obj, attribute, value)\n if value.to_i >= 0\n obj.send(\"#{attribute}=\", value)\n validators = obj.class.validators_on(attribute)\n if !validators.empty?\n validators.each { |v| v.validate obj }\n\n unless obj.errors.full_messages.blank?\n obj.send(\"#{attribute}=\", nil)\n log_error(obj, \"#{attribute} not set because #{obj.errors.full_messages.to_sentence}.\")\n obj.errors.clear\n end\n end\n else\n log_error(obj, \"#{attribute} not set because #{value} is negative.\")\n end\n end",
"def set!(instance, value)\n instance.instance_variable_set(instance_variable_name, value)\n end",
"def set!(value)\n @mutex.synchronize do\n old_value = @value\n @value = value\n @full_condition.signal\n apply_deref_options(old_value)\n end\n end",
"def value=(value)\n self.should = value\n end",
"def attr_writer( * )\n fail \"Remember, an Entity is immutable. Use a Services::Service to mutate the underlying data.\"\n end",
"def cattr_setter_thread *names\n opts = Hash === names[-1] ? names.pop : EMPTY_HASH\n\n transform = opts[:setter_transform]\n transform = \"__val = (#{transform})\" if transform\n\n names.each do | name |\n instance_eval(expr = <<\"END\", __FILE__, __LINE__)\ndef self.#{name}= __val\n #{transform}\n Thread.current[:'#{self.name}.#{name}'] = [ __val ]\nend\nEND\n # $stderr.puts \"#{expr}\"\n end\n end",
"def set(value)\n old_value = refresh(value)\n handle_event :type => :change, :old_value => old_value, :value => @value if old_value != @value\n old_value\n end",
"def cop=(_); end",
"def cop=(_); end",
"def setA=(a)\n @a = a\n end",
"def checks=(_arg0); end",
"def set_setting\n end",
"def set_property(element, value)\n return Forbidden\n end",
"def watch_for_set; end"
] |
[
"0.67743814",
"0.67743814",
"0.6687141",
"0.6473359",
"0.6364297",
"0.63558584",
"0.635131",
"0.63388634",
"0.6333896",
"0.63212645",
"0.63179046",
"0.6286533",
"0.62589914",
"0.62398773",
"0.6228378",
"0.622298",
"0.6216064",
"0.61827826",
"0.6178179",
"0.6173674",
"0.61516863",
"0.61087114",
"0.6107095",
"0.61067617",
"0.60876834",
"0.6069427",
"0.60544187",
"0.60544187",
"0.6013053",
"0.5987543",
"0.5982298",
"0.596363",
"0.5953403",
"0.59481025",
"0.5944644",
"0.5944644",
"0.59338117",
"0.59330136",
"0.5917954",
"0.5913373",
"0.59053284",
"0.5893655",
"0.589099",
"0.589099",
"0.5882091",
"0.58736426",
"0.5861103",
"0.5843569",
"0.58434767",
"0.58349687",
"0.5820446",
"0.5813133",
"0.5801379",
"0.5801379",
"0.5801379",
"0.5800346",
"0.578814",
"0.57768875",
"0.5768527",
"0.5764492",
"0.5763951",
"0.57564193",
"0.57533383",
"0.574871",
"0.5737747",
"0.5729248",
"0.5726124",
"0.5714561",
"0.5703494",
"0.5695906",
"0.56878906",
"0.56866795",
"0.5676527",
"0.56757164",
"0.56687045",
"0.566857",
"0.5667044",
"0.566245",
"0.5662005",
"0.565682",
"0.56557524",
"0.5653361",
"0.565077",
"0.56476206",
"0.5636506",
"0.56346345",
"0.5617424",
"0.56143606",
"0.5605965",
"0.5601786",
"0.55967516",
"0.55845183",
"0.5569786",
"0.5569239",
"0.55610245",
"0.55610245",
"0.5558297",
"0.5557212",
"0.55539703",
"0.55505645",
"0.5542305"
] |
0.0
|
-1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.