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
PUT /driver_records/1 PUT /driver_records/1.json
def update @driver_record = DriverRecord.find(params[:id]) respond_to do |format| if @driver_record.update_attributes(params[:driver_record]) format.html { redirect_to @driver_record, notice: 'Driver record was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @driver_record.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n\t\t\t\trespond_with Driver.update(params[:id],params[:driver])\n\t\t\tend", "def update\n #@driver = Driver.find(params[:id])\n @driver = @event.drivers.find(params[:id])\n\n respond_to do |format|\n if @driver.update_attributes(params[:driver])\n format.html { redirect_to [@event, @driver], notice: 'Driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # Logic to edit a driver and submit to DB\n @driver = Driver.find(params[:id])\n\n respond_to do |format|\n if @driver.update_attributes(params[:driver])\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n record = Asset.find(params[:id])\n record.update_attributes(params[:record])\n \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end", "def update\n respond_to do |format|\n if @driver.update(driver_params)\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @driver.update(driver_params)\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { render :show, status: :ok, location: @driver }\n else\n format.html { render :edit }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @driver.update(driver_params)\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { render :show, status: :ok, location: @driver }\n else\n format.html { render :edit }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n record = InvoiceLineItem.find(params[:id])\n print record.to_json\n record.update_attributes(params[:record]) \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end", "def update\n @record = Asset.find(params[:id])\n @record.update_attributes(params[:@record])\n \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update \t\n record = AssetType.find(params[:id])\n record.update_attributes(params[:record])\n \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end", "def update_record\n return false if @label.to_s.empty?\n\n atts = {}\n\n atts[\"status\"] = @status if @status\n atts[\"sync_period\"] = @sync_period if @sync_period\n atts[\"service_level\"] = @service_level if @service_level\n atts[\"password\"] = @password if @password\n atts[\"provider_token\"] = @provider_token if @provider_token\n atts[\"provider_token_secret\"] = @provider_token_secret if @provider_token_secret\n atts[\"provider_consumer_key\"] = @provider_consumer_key if @provider_consumer_key\n\n response = post(\"/2.0/accounts/#{@account_id}/sources/#{@label}\", atts)\n response['success']\n end", "def update\n respond_to do |format|\n if @driver.update(driver_params)\n\n url = \"https://dvlasearch.appspot.com/DvlaSearch?apikey=#{Rails.application.credentials.dvla[:dvla_api_key]}&licencePlate=#{@driver.registration_number}\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n @hash = JSON.parse(response)\n\n if @hash.key?(\"make\")\n @driver.car_info = @hash[\"colour\"] + \" \" + @hash[\"make\"] + \" \" + @hash[\"model\"]\n else\n @driver.car_info = \"Registration number not linked to vehicle.\"\n end\n\n @driver.registration_number.upcase!\n\n @driver.save!\n\n format.html { redirect_to @driver, notice: 'Details updated successfully.' }\n format.json { render :show, status: :ok, location: @driver }\n else\n format.html { render :edit }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ride_driver.update(ride_driver_params)\n format.html { redirect_to @ride_driver, notice: 'Ride driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ride_driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @driver = @event.drivers.new(params[:driver])\n\n respond_to do |format|\n if @driver.save\n\n for i in 1..@driver.spots do\n @waitlistrider = @event.riders.find_by_waitlist(true)\n @waitlistrider.update_driver(@driver.id) if @waitlistrider\n @waitlistrider.update_waitlist if @waitlistrider\n end\n\n @driver.update_full\n\n format.html { redirect_to [@event, @driver], notice: 'Driver was successfully created.' }\n format.json { render json: @driver, status: :created, location: @driver }\n else\n format.html { render action: \"new\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_with ApidDrive.update(params[:id], params[:apid_driver])\n rescue ActiveRecord::RecordNotFound\n respond_with ApidDrive::StateChangeError\n end", "def update(resource,identifier,json)\n raise 'Not Yet Implemented'\n end", "def update_field(key,field,value)\n request :put, \"#{path_prefix}records/#{ue key}?field=#{ue field}\",\n :body => value,\n :content_type => \"application/octet-stream\"\n end", "def update(opts = {})\n raise \"No data arguments in request\" if opts[:data] == nil\n opts = filter_unsupported_options :ext_update, opts\n records = opts[:data]\n updated = []\n\n if(records.kind_of? Array)\n records.each do |r|\n begin\n @response.add_data(update_record r, opts)\n updated.push r[\"id\"]\n rescue\n @response.add_message \"Warning : Could not update record with id #{r[\"id\"]}. #{$!}\"\n raise\n end\n end\n else\n r = records \n begin\n @response.add_data(update_record r, opts)\n updated.push r[\"id\"]\n rescue\n @response.add_message \"Warning : Could not update record with id #{r[\"id\"]}. #{$!}\\r\\n\"\n end\n end\n\n if updated.length > 0\n @response.add_message \"Successfully updated #{updated.length} records with id : \" + updated.join(', ')\n success = true\n else\n @response.add_message \"No record updated.\"\n success = false\n end\n\n @response.success = success \n @response.to_hash\n end", "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 update_all records\n array = []\n records.each do |id, r|\n params = {}\n r.each do |k, v|\n params[k] = {value: v}\n end\n array.push({\n id: id,\n record: params\n })\n end\n puts \"update #{array.count} records...\"\n while array.present?\n a100 = array.shift(100)\n @api.records.update(@app_id, a100)\n end\n {}\n end", "def update\n @trip_driver = TripDriver.find(params[:id])\n\n respond_to do |format|\n if @trip_driver.update_attributes(trip_driver_params)\n format.html { redirect_to @trip_driver, notice: 'Trip driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @trip_driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update_record(mid, data)\n rid = data['rid']\n\n unless rid\n raise \"rid attribute isn't present in hash data.\"\n end\n\n url = Configuration::PROPERTIES.get_property :url\n url_get_records = Configuration::PROPERTIES.get_property :url_update_record\n\n url_get_records = url_get_records.gsub '{csk}', URI::encode(@credential[:csk])\n url_get_records = url_get_records.gsub '{aci}', URI::encode(@credential[:aci])\n url_get_records = url_get_records.gsub '{mid}', mid.to_s\n url_get_records = url_get_records.gsub '{rid}', rid.to_s\n\n params = {\n :fields => Dynamicloud::API::DynamicloudHelper.build_fields_json(data)\n }\n\n response = DynamicService::ServiceCaller.call_service url + url_get_records, params, 'post'\n\n json = JSON.parse(response)\n unless json['status'] == 200\n raise json['message']\n end\n end", "def update\n @record = Product.find(params[:id])\n @record.update_attributes(params[:product])\n \n respond_to do |format|\n format.json {\n render json: {}\n }\n end\n end", "def update\n respond_to do |format|\n if @references_vehicle_driver.update(references_vehicle_driver_params)\n format.html { redirect_to @references_vehicle_driver, notice: 'References vehicle driver was successfully updated.' }\n format.json { render :show, status: :ok, location: @references_vehicle_driver }\n else\n format.html { render :edit }\n format.json { render json: @references_vehicle_driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @record = Record.find(params[:id])\n if @record.update(record_params)\n render json: {message: \"Record updated\"}, status: :ok\n else\n render json: {error: \"Unable to update the record\"}, status: :400\n end\n end", "def update\n @record = Location.find(params[:id])\n @record.update_attributes(params[:location]) \n respond_to do |format|\n# format.html\n format.json {\n render json: {}\n }\n end\n end", "def create\n @driver_record = DriverRecord.new(params[:driver_record])\n respond_to do |format|\n if @driver_record.save\n format.html { redirect_to @driver_record, notice: 'Driver record was successfully created.' }\n format.json { render json: @driver_record, status: :created, location: @driver_record }\n else\n format.html { render action: \"new\" }\n format.json { render json: @driver_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def upsert_record\n connection.change_resource_record_sets(\n hosted_zone_id: @zone,\n change_batch: {\n changes: [\n {\n action: 'UPSERT',\n resource_record_set: {\n name: @resource[:record],\n type: @resource[:type],\n ttl: @resource[:ttl],\n resource_records: @resource[:value].map { |value| { value: value } }\n }\n }\n ]\n }\n )\n end", "def update\n respond_to do |format|\n if @driver.update(driver_params)\n # @driver.set_location_goride(params[:location])\n format.html { redirect_to @driver, notice: 'Driver was successfully updated.' }\n format.json { render :show, status: :ok, location: @driver }\n else\n format.html { render :edit }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def update_region\n Region.find(params[:record][:id]).update_attributes(params[:record])\n render :json => {}\n end", "def update\n respond_to do |format|\n if @record.update(record_params)\n format.html { redirect_to api_v1_records_url(access_token: params[:access_token]), notice: '更新しました' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @driver = Driver.find(params[:id])\n @driver.user = @current_user\n\n respond_to do |format|\n if @driver.update_attributes(params[:driver])\n format.html { redirect_to event_url(@driver.event),\n notice: 'Driver was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n expire_fragment \"event-#{@driver.event.id}\"\n end", "def update\n @record = find_record\n\n respond_to do |format|\n if @record.update_attributes(params[:record])\n format.html { redirect_to [@record.patient, @record],\n notice: 'Record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'show' }\n format.json { render json: @record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_row_resource(resource, params)\n resource.attributes = params\n resource.save\n end", "def crud_put(resource_name, service_name, primary_key_name, api_options = {})\n api_options = get_defaults(api_options)\n put '/'+resource_name+'/:'+primary_key_name do\n service = settings.send(service_name)\n\n # Must Exist\n return 404 unless service.exists_by_primary_key?(params[primary_key_name.to_sym])\n\n # Get The Data\n begin\n data = JSON.parse(request.body.read)\n rescue Exception => e\n return 422\n end\n\n # Valid Update?\n return 422 unless service.valid_update?(data)\n\n # Do Update\n record = service.update_by_primary_key(params[primary_key_name.to_sym],data)\n\n # Other Error\n return 500 if record.nil?\n\n # Return new Region\n JSON.fast_generate record\n end\n end", "def update\n respond_to do |format|\n if @driver_log.update(driver_log_params)\n format.html { redirect_to @driver_log, notice: 'Driver log was successfully updated.' }\n format.json { render :show, status: :ok, location: @driver_log }\n else\n format.html { render :edit }\n format.json { render json: @driver_log.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_recording(record_id, meta)\n meta[:recordID] = record_id\n bbb_server.send_api_request(\"updateRecordings\", meta)\n end", "def update\n Rails.logger.debug(\"method=#{request.method}\")\n #replace the Race in the db with supplied values\n race = Race.find(params[:id])\n # # DEBUG: do not chain!! update returns true/false\n race.update(race_params)\n render json: race, status: :ok\n end", "def create\n respond_with :api,:v1, ApidDriver.create_or_update(params[:apid_driver])\n end", "def update_record(http, ref)\n json = %|{\n \"kind\": \"Article\",\n \"title\": \"Sample\",\n \"text\": \"Updated text.\"\n}|\n resp = http.send_request('POST', \"/v1/Article/#{ref}\", json, { 'Content-Type' => 'application/json' })\n # Response should be an OK with a JSON body.\n assert_equal(Net::HTTPOK, resp.class, 'response not an OK')\n reply = Oj.strict_load(resp.body, symbol_keys: true)\n\n # Make sure the message has the correct fields and values.\n assert_equal(0, reply[:code], 'update reply.code should be 0 meaning no error')\n updated = reply[:updated]\n assert_equal(1, updated.length, 'update reply.updated should contain exactly one member')\n ref = updated[0]\n refute_equal(nil, ref, 'update reply record reference can not be nil')\n refute_equal(0, ref, 'update reply record reference can not be 0')\n ref\n end", "def destroy\n @driver_record = DriverRecord.find(params[:id])\n @driver_record.destroy\n\n respond_to do |format|\n format.html { redirect_to driver_records_url }\n format.json { head :no_content }\n end\n end", "def update\n record = TaxRule.find(params[:id])\n record.update_attributes(params[:record])\n \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end", "def save(attrs)\n if attrs[:id].present?\n data = @resource.update(attrs, @customer_id)\n else\n attrs.delete(:id) \n if resource_name == :customers\n data = @resource.create(attrs)\n else\n data = @resource.create(attrs, @customer_id)\n end\n end\n\n data.merge({\"open_pay_id\" => data[\"id\"]})\n end", "def update\n @recording = Recording.find(params[:id])\n\n respond_to do |format|\n if @recording.update_attributes(params[:recording])\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n end\n end\n end", "def test_update_object_by_id\r\n\t VCR.use_cassette('edit_object') do\r\n\t\t cred=JSON.parse(YAML::load_file('test/fixtures/credential.yml').to_json)\r\n\t\t json = JSON.parse(File.read(\"test/fixtures/edit_specimen.json\"))\r\n\t\t id = json[\"id\"]\r\n\t\t json[\"id\"] = \"\" #id cannot be updated\r\n\t\t result=CordraRestClient::DigitalObject.update(API_URL, id, json, cred[\"uc_1\"])\r\n\r\n\t\t #check that the result is saved\r\n\t\t assert_equal 200, result[:code]\r\n\t\t assert_equal \"OK\", result[\"message\"]\r\n\t\tend\r\n\t end", "def update\n do_patch { return } # check if patch and do submission and return early if it is a patch (submission)\n # otherwise this is a PUT of the dataset metadata\n check_status { return } # check it's in progress, clone a submitted or raise an error\n respond_to do |format|\n format.json do\n dp = if @resource\n DatasetParser.new(hash: params['dataset'], id: @resource.identifier, user: @user) # update dataset\n else\n DatasetParser.new(hash: params['dataset'], user: @user, id_string: params[:id]) # upsert dataset with identifier\n end\n @stash_identifier = dp.parse\n ds = Dataset.new(identifier: @stash_identifier.to_s) # sets up display objects\n render json: ds.metadata, status: 200\n end\n end\n end", "def update\n put :update\n end", "def update\n respond_to do |format|\n if @driver_journey.update(driver_journey_params)\n format.html { redirect_to journeys_path, notice: 'Driver journey was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @driver_journey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end", "def update\n id = params[:id]\n @physical_rack = PhysicalRack.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @physical_rack.attributes = params[:physical_rack]\n @physical_rack.audits << Audit.new(source: 'controller', action: 'update', admin_user: current_user)\n respond_to do |format|\n if @physical_rack.save\n format.html { redirect_to @physical_rack, notice: 'Physical rack was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @physical_rack.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @client.update(client_params)\n render json: @client\n end", "def jsonapi_update!(attributes)\n assign_jsonapi_attributes(attributes)\n save!\n end", "def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end", "def update \n sneaker = find_sneaker\n # update! exceptions will be handled by the rescue_from ActiveRecord::RecordInvalid code\n sneaker.update(sneaker_params)\n render json: sneaker\n end", "def update\n update_resource @ride, ride_params\n end", "def update\n @record = Record.find(params[:id])\n\n respond_to do |format|\n if @record.update_attributes(params[:record])\n format.html { redirect_to @record, :notice => 'Record was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @record.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @server_record.update(server_record_params)\n format.html { redirect_to @server_record, notice: 'Server record was successfully updated.' }\n format.json { render :show, status: :ok, location: @server_record }\n else\n format.html { render :edit }\n format.json { render json: @server_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if singular_resource?\n entity = ConnecEntity.where(group_id: @group_id, entity_name: entities_key).first\n entity ||= ConnecEntity.create(group_id: @group_id, entity_name: entities_key)\n else\n entity = ConnecEntity.where(group_id: @group_id, entity_name: entities_key, uid: params[:id]).first\n end\n \n entity.document = (entity.document || {}).merge(params[entities_key])\n \n if entity\n if entity.save\n logger.info(\"INSPECT: #{entities_key} => #{process_entity(entity.reload).to_json}\")\n render json: { entities_key => process_entity(entity.reload) }\n else\n render json: { errors: process_errors(entity.errors.full_messages, 400, entity) }, status: :bad_request\n end\n else\n render json: { errors: process_errors([\"Resource not found\"], 404) }, status: :not_found\n end\n end", "def update\n record.assign_attributes(data)\n record.save! if record.changed?\n end", "def update_metadata(params)\n @client.put(metadata_path, nil, params, \"Content-Type\" => \"application/json\")\n end", "def update\n @record = Record.find(params[:id])\n\n respond_to do |format|\n if @record.update_attributes(params[:record])\n format.html { redirect_to @record, notice: 'Record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @student.update(student_params)\n render json: @student\n else\n render json: @student.errors, status: :unprocessable_entity\n end\n end", "def save\n @client.patch(@endpoint, :content=>@changed)\n return nil\n end", "def update\n respond_to do |format|\n if @drivers_licesnse.update(drivers_licesnse_params)\n format.html { redirect_to @drivers_licesnse, notice: 'Drivers licesnse was successfully updated.' }\n format.json { render :show, status: :ok, location: @drivers_licesnse }\n else\n format.html { render :edit }\n format.json { render json: @drivers_licesnse.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if params[:file]\n file = params[:file].read\n data = JSON.parse(file)\n ActiveRecord::Base.transaction do\n @patient = Patient.find_by(case_id: data['case_id'])\n if @patient.valid?\n @patient.update_json(data)\n name = params[:file].original_filename\n path = File.join(\"Data\", \"jsons\", name)\n File.open(path, \"wb\") { |f| f.write(file) }\n end\n end\n end\n if usi_params\n usi = UsiMaterialnr.find_or_create_by(patient_id:@patient.id)\n usi.usi_id = usi_params[:usi_id]\n usi.materialnr = usi_params[:materialnr]\n usi.save\n end\n respond_to do |format|\n if @patient.update(patient_params)\n format.html { redirect_to @patient, notice: 'Patient was successfully updated.' }\n format.json { render :show, status: :ok, location: @patient }\n else\n format.html { render :edit }\n format.json { render json: @patient.errors, status: :unprocessable_entity }\n end\n end\n end", "def driver_params\n params.require(:driver).permit(:name, :age, :city_id, :company_id)\n end", "def update\n respond_to do |format|\n if @record.update(record_params)\n format.html { redirect_to @record, notice: \"#{record_class.model_name.singular.humanize} was successfully updated.\" }\n format.json { render :show, status: :ok, location: @record }\n else\n format.html { render :edit }\n format.json { render json: @record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @video_recorder.update(video_recorder_params)\n render :show, status: :ok, location: @video_recorder\n else\n render json: @video_recorder.errors, status: :unprocessable_entity\n end\n end", "def show\n @driver_record = DriverRecord.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @driver_record }\n end\n end", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(table, id, updated_record_hash)\n self.post(\"/#{table}/update/#{id}\", body: {record: updated_record_hash})\n end", "def save_record(record)\n record.save\n end", "def save_record(record)\n record.save\n end", "def update\n respond_to do |format|\n if @test_record.update(test_record_params)\n format.html { redirect_to @test_record, notice: 'Test record was successfully updated.' }\n format.json { render :show, status: :ok, location: @test_record }\n else\n format.html { render :edit }\n format.json { render json: @test_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @record.update_attributes(params[:record])\n format.html { redirect_to @record, notice: 'Record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @driver_trip_seat.update(driver_trip_seat_params)\n format.html { redirect_to @driver_trip_seat, notice: 'Driver trip seat was successfully updated.' }\n format.json { render :show, status: :ok, location: @driver_trip_seat }\n else\n format.html { render :edit }\n format.json { render json: @driver_trip_seat.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n\n respond_to do |format|\n if @entry_instrument.update_attributes(params[:entry_instrument])\n flash[:notice] = 'EntryInstrument was successfully updated.'\n format.html { redirect_to(@entry_instrument) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_instrument.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n dns_entry_response = RestClient.put('https://api.cloudflare.com/client/v4/zones/:zone_identifier/dns_records/:identifier',:content_type => :json, :accept => :json, :'x-auth-key' => session[:key] :'x-auth-email' => session[:email])\n respond_to do |format|\n if @dns_entry.update(dns_entry_params)\n format.html { redirect_to @dns_entry, notice: \"Dns entry was successfully updated.\" }\n format.json { render :show, status: :ok, location: @dns_entry }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @dns_entry.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n #Always get the current time to update\n @driver_application.updated_at = DateTime.current\n \n respond_to do |format|\n if @driver_application.update(driver_application_params)\n format.html { redirect_to @driver_application, notice: 'Driver application was successfully updated.' }\n format.json { render :show, status: :ok, location: @driver_application }\n else\n format.html { render :edit }\n format.json { render json: @driver_application.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @dummy_record = DummyRecord.find(params[:id])\n\n respond_to do |format|\n if @dummy_record.update_attributes(params[:dummy_record])\n format.html { redirect_to @dummy_record, :notice => 'Dummy record was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @dummy_record.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n document = Document.find(params[:id])\n document.update!(update_params)\n render json: {}\n end", "def update\n @name_record = @domain.name_records.get!(params[:id])\n\n respond_to do |format|\n if @name_record.update(params[:name_record])\n flash[:notice] = t('name_records.update.notice')\n format.html { redirect_to(name_records_path) }\n format.xml { head :ok }\n else\n flash[:alert] = t('name_records.update.alert')\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @name_record.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n # Logic to create a driver and submit to DB\n @driver = Driver.new(params[:driver])\n\n respond_to do |format|\n if @driver.save\n format.html { redirect_to @driver, notice: 'Driver was successfully created.' }\n format.json { render json: @driver, status: :created, location: @driver }\n else\n format.html { render action: \"new\" }\n format.json { render json: @driver.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @driverslist.update(driverslist_params)\n format.html { redirect_to @driverslist, notice: 'Driverslist was successfully updated.' }\n format.json { render :show, status: :ok, location: @driverslist }\n else\n format.html { render :edit }\n format.json { render json: @driverslist.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vehicle_service_record.update(vehicle_service_record_params)\n format.html { redirect_to @vehicle_service_record.vehicle, notice: 'Vehicle Service Record was successfully updated.' }\n format.json { render :show, status: :ok, location: @vehicle_service_record }\n else\n format.html { render :edit }\n format.json { render json: @vehicle_service_record.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @student_entity.update(student_entity_params)\n format.json { render :show, status: :ok, location: @student_entity }\n else\n format.json { render json: @student_entity.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @asset.update(price: params[:asset][:price])\n json_response(@asset,:created)\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 update\n @employee = Employee.find_by_id(params[:id])\n @employee.update_attributes({:id => params[:id],\n :name => params[:name],\n :title => params[:title],\n :status => params[:status],\n :employment_type => params[:employment_type],\n :attendance_type_id => params[:attendance_type_id],\n :hourly_rate => params[:hourly_rate],\n :location => params[:location],\n :capitalizable_group_id => params[:capitalizable_group_id],\n :leave_days => params[:leave_days],\n :commencement_date => params[:commencement_date],\n :termination_date => params[:termination_date]})\n if request.xhr?\n render :json => @employee\n end\n end", "def test_update_successful\n data = {\n firstname: \"Anh\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 200\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end", "def update\n fail_on_type_mismatch(data_params[:type])\n\n assign_record_attributes(queried_record, permitted_params_for(:update), data_params)\n\n execute_before_update_callbacks(queried_record)\n execute_before_save_callbacks(queried_record)\n\n fail RecordInvalidError.new(queried_record, engaged_field_aliases) if queried_record.errors.any?\n\n queried_record.save!\n\n execute_after_update_callbacks(queried_record)\n execute_after_save_callbacks(queried_record)\n\n render(\n json: queried_record,\n fields: query_params[:fields],\n include: query_params[:include]\n )\n end", "def update\n @person = Person.find(params[:id]) \n respond_to do |format|\n if @person.update(person_params)\n format.json { render json: @person, status: :ok }\n else\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @driver_license_type = DriverLicenseType.find(params[:id])\n\n respond_to do |format|\n if @driver_license_type.update_attributes(params[:driver_license_type])\n format.html { redirect_to @driver_license_type, notice: 'Driver license type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @driver_license_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def record_params\n params.require(:record).permit(:name, :info, :year, :performer_id)\n end", "def test_update\n #Again the delete feature from ActiveResource does not work out of the box.\n #Using custom delete function\n puts \"--create a new account--\"\n new_acct = Salesforce::Rest::Account.new(:Name => \"test numero uno\", :BillingStreet=> \"Fairway Meadows\",\n :BillingState => \"NY\", :ShippingCity => \"New York\")\n resp = new_acct.save()\n\n assert (resp.code == 201)\n j = ActiveSupport::JSON\n @sf_oid = j.decode(resp.body)[\"id\"]\n puts \"New Object created: id -> \" + @sf_oid\n\n puts \"--update that new account--\"\n serialized_json = '{\"BillingState\":\"WA\"}'\n #http = Net::HTTP.new(@rest_svr_url, 443)\n http = Net::HTTP.new('na7.salesforce.com', 443)\n http.use_ssl = true\n \n class_name = \"Account\"\n path = \"/services/data/v21.0/sobjects/#{class_name}/#{@sf_oid}\"\n headers = {\n 'Authorization' => \"OAuth \"+ @oauth_token,\n \"content-Type\" => 'application/json',\n }\n code = serialized_json\n\n \n req = Net::HTTPGenericRequest.new(\"PATCH\", true, true, path, headers)\n\n resp = http.request(req, code) { |response| }\n assert !resp.nil?\n\n puts resp.to_s\n end" ]
[ "0.66712904", "0.6377764", "0.63377064", "0.60311097", "0.5984553", "0.5977846", "0.5977846", "0.59686136", "0.59617054", "0.5920817", "0.58608276", "0.58064646", "0.5797752", "0.57845855", "0.57702583", "0.57278895", "0.56001943", "0.55585754", "0.55535144", "0.55468", "0.55448383", "0.54991853", "0.54681796", "0.54550135", "0.54506165", "0.54372805", "0.5434509", "0.5432121", "0.54216295", "0.5412458", "0.54085463", "0.53792685", "0.53784186", "0.53503376", "0.5343936", "0.53288716", "0.5325911", "0.53202754", "0.53141075", "0.5305677", "0.5305355", "0.53053075", "0.5294847", "0.5288578", "0.52643675", "0.5243443", "0.5234369", "0.5220553", "0.5197813", "0.51968306", "0.51946664", "0.5192932", "0.518644", "0.51861966", "0.5185266", "0.51849765", "0.5179632", "0.5176652", "0.51568776", "0.5148509", "0.51470006", "0.5137428", "0.5120129", "0.51112604", "0.5106672", "0.51007175", "0.50862664", "0.5079199", "0.5071894", "0.5070093", "0.5060915", "0.50579", "0.5055685", "0.50521535", "0.5049668", "0.50469697", "0.5043335", "0.5043335", "0.50362206", "0.50241786", "0.5022663", "0.50198185", "0.501697", "0.5014704", "0.50110316", "0.5009645", "0.5005835", "0.49987638", "0.49957213", "0.49934584", "0.49916813", "0.49901378", "0.49877715", "0.4987523", "0.4982824", "0.49824136", "0.4981563", "0.49806798", "0.49794728", "0.49793333" ]
0.653862
1
DELETE /driver_records/1 DELETE /driver_records/1.json
def destroy @driver_record = DriverRecord.find(params[:id]) @driver_record.destroy respond_to do |format| format.html { redirect_to driver_records_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n # Logic to delete a record\n @driver = Driver.find(params[:id])\n @driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t\t\trespond_with Driver.destroy(params[:id])\n end", "def destroy\n @driver = Driver.find(params[:id])\n @driver.destroy\n\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url }\n format.json { head :no_content }\n end\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url, notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url, notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to drivers_url, notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @record = Record.find(params[:id])\n @record.destroy\n\n respond_to do |format|\n format.html { redirect_to records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @record = Record.find(params[:id])\n @record.destroy\n\n respond_to do |format|\n format.html { redirect_to records_url }\n format.json { head :ok }\n end\n end", "def delete\n request(:delete)\n end", "def delete_record *rid\n db.delete_record rid\n end", "def destroy\n @record.destroy\n respond_to do |format|\n format.html { redirect_to records_url }\n format.json { head :no_content }\n end\n end", "def delete record\n db_name = database_name_for(record)\n coll_name = collection_name_for(record)\n case\n when id = id_for(record)\n pointer = \"/#{db_name}/#{coll_name}/#{id}\"\n res = collection_for(record).remove({:_id => id})\n if res[\"err\"]\n log.error(res[\"err\"])\n else\n log.debug(\"Deleted #{pointer}\")\n end\n when query = delete_query_for(record)\n pointer = \"/#{db_name}/#{coll_name}\"\n res = collection_for(record).remove(query)\n if res[\"err\"]\n log.error(res[\"err\"])\n else\n log.debug(\"Deleted #{res['n']} records from #{pointer}\")\n end\n end\n end", "def destroy\n @driver_log.destroy\n respond_to do |format|\n format.html { redirect_to driver_logs_url, notice: 'Driver log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ride_driver.destroy\n respond_to do |format|\n format.html { redirect_to @root }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def destroy\n @dummy_record = DummyRecord.find(params[:id])\n @dummy_record.destroy\n\n respond_to do |format|\n format.html { redirect_to dummy_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @status_record = StatusRecord.find(params[:id])\n @status_record.destroy\n\n respond_to do |format|\n format.html { redirect_to status_records_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @record.destroy\n respond_to do |format|\n format.html { redirect_to records_url }\n format.json { render :json => true }\n end\n end", "def destroy\n @health_record = HealthRecord.find(params[:id])\n @health_record.destroy\n\n respond_to do |format|\n format.html { redirect_to health_records_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @health_record.destroy\n respond_to do |format|\n format.html { redirect_to health_records_url }\n format.json { head :no_content }\n end\n end", "def deletes_to(path,opts={},&block) #:nodoc: \n crud_to(:delete,path,opts[:params] || {},opts,&block)\n end", "def delete_record(mid, rid)\n url = Configuration::PROPERTIES.get_property :url\n url_get_records = Configuration::PROPERTIES.get_property :url_delete_record\n\n url_get_records = url_get_records.gsub '{csk}', URI::encode(@credential[:csk])\n url_get_records = url_get_records.gsub '{aci}', URI::encode(@credential[:aci])\n url_get_records = url_get_records.gsub '{mid}', mid.to_s\n url_get_records = url_get_records.gsub '{rid}', rid.to_s\n\n response = DynamicService::ServiceCaller.call_service url + url_get_records, {}, 'delete'\n\n json = JSON.parse(response)\n unless json['status'] == 200\n raise json['message']\n end\n end", "def delete\n api(\"Delete\")\n end", "def delete\n\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def deleteEntityEmployee( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/employee\",params)\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def destroy\n @file_record = FileRecord.find(params[:id])\n @file_record.destroy\n\n respond_to do |format|\n format.html { redirect_to file_records_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @pay_record.destroy\n respond_to do |format|\n format.html { redirect_to pay_records_url }\n format.json { head :no_content }\n end\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def delete\n \n end", "def destroy\n record = InvoiceLineItem.find(params[:id])\n record.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def delete_row(row_id); rest_delete(\"#{link('rows')}/#{row_id}\"); nil; end", "def destroy\n @record.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_records_url(access_token: params[:access_token]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @trip_driver = TripDriver.find(params[:id])\n @trip_driver.destroy\n\n respond_to do |format|\n format.html { redirect_to trip_drivers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @server_record.destroy\n respond_to do |format|\n format.html { redirect_to server_records_url, notice: 'Server record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @driver.destroy\n respond_to do |format|\n format.html { redirect_to enterprise_drivers_path(current_user), notice: 'Driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n record = Asset.find(params[:id])\n record.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def delete(record_id)\n CONNECTION.execute(\"DELETE FROM #{get_table_name} WHERE id = #{record_id}\")\n end", "def delete!\n request! :delete\n end", "def destroy\n @test_record.destroy\n respond_to do |format|\n format.html { redirect_to test_records_url, notice: 'Test record was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(resource)\n headers = base_headers.merge('Content-Type' => 'application/json')\n url = \"#{@base_url}/#{resource}\"\n\n @logger.debug(\"DELETE request Url: #{url}\")\n @logger.debug(\"-- Headers: #{headers}\")\n\n x = HTTParty.delete(url, headers: headers)\n puts x.inspect\n x\n end", "def delete\n api_client.delete(url)\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def delete\n end", "def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end", "def delete *args, &block\n res = @conn.delete *args, &block\n handle res, parse: false\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def delete\n \n end", "def destroy\n @registro_record = RegistroRecord.find(params[:id])\n @registro_record.destroy\n\n respond_to do |format|\n format.html { redirect_to registro_records_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @record = Asset.find(params[:id])\n @record.trash\n respond_to do |format| \n format.json { head :no_content }\n end\n end", "def delete\n start { |connection| connection.request http :Delete }\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def delete(params = {})\n Client.current.delete(resource_url, params)\n end", "def deletef\n url = prefix + \"deletef\" + id_param\n return response(url)\n end", "def delete_a_record(zone_id, zone_name, domain_name, namespace, ingress_name)\n sleep 1\n client = Aws::Route53::Client.new\n\n a_record = {\n action: \"DELETE\",\n resource_record_set: {\n name: domain_name,\n alias_target: {\n # ZD4D7Y8KGAS4G this zone is the default AWS zone for ELB records, in eu-west-2\n \"hosted_zone_id\": \"ZD4D7Y8KGAS4G\",\n \"dns_name\": get_ingress_endpoint(namespace, ingress_name) + \".\",\n \"evaluate_target_health\": true,\n },\n type: \"A\",\n },\n }\n\n client.change_resource_record_sets({\n hosted_zone_id: zone_id,\n change_batch: {\n changes: [a_record],\n },\n })\nend", "def delete\n render json: Users.delete(params[\"id\"])\n end", "def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end", "def destroy\n self.class.mongo_client.database.fs.find(:_id=>BSON::ObjectId.from_string(@id)).delete_one\n end", "def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n @java_dynamic_row = JavaDynamicRow.find(params[:id])\n @java_dynamic_row.destroy\n\n respond_to do |format|\n format.html { redirect_to java_dynamic_rows_url }\n format.json { head :ok }\n end\n end", "def destroy\n @record = Umbra::Record.find(params[:id])\n @record.destroy\n\n respond_with(@record)\n end", "def destroy\n @references_vehicle_driver.destroy\n respond_to do |format|\n format.html { redirect_to references_vehicle_drivers_url, notice: 'References vehicle driver was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def delete\n execute_request('DELETE') do |uri, headers|\n HTTP.http_client.delete(uri, header: headers)\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def destroy\n dns_entry_response = RestClient.delete('https://api.cloudflare.com/client/v4/zones/:zone_identifier/dns_records/:identifier',:content_type => :json, :accept => :json, :'x-auth-key' => session[:key] :'x-auth-email' => session[:email])\n @dns_entry.destroy\n respond_to do |format|\n format.html { redirect_to dns_entries_url, notice: \"Dns entry was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_studio_client = MyStudio::Client.find(params[:id])\n @my_studio_client.destroy\n\n respond_to do |format|\n format.html { redirect_to my_studio_clients_url }\n format.json { head :ok }\n end\n end", "def delete(url, headers={})\n RestClient.delete url, headers\n end", "def delete\n RestClient.delete(url, @header) do |rso, req, res|\n setup(rso, req, res)\n end\n end", "def destroy\n @records_location = RecordsLocation.find(params[:id])\n @records_location.destroy\n\n respond_to do |format|\n format.html { redirect_to records_locations_url }\n format.json { head :no_content }\n end\n end", "def delete_record *rid\n logger.progname = \"ActiveOrient::RestDelete#DeleteRecord\"\n ridvec = []\n rid.each do |mm|\n if mm.is_a?(String)\n \t ridvec << mm if mm.rid?\n elsif mm.is_a?(Array)\n mm.each do |mmarr|\n ridvec << mmarr.rid if mmarr.is_a?(ActiveOrient::Model)\n ridvec << mmarr if mmarr.is_a?(String) && mmarr.rid?\n end\n elsif mm.is_a?(ActiveOrient::Model)\n ridvec << mm.rid\n end\n end\n ridvec.compact!\n\n unless ridvec.empty?\n ridvec.each do |rid|\n begin\n @res[\"/document/#{@database}/#{rid}\"].delete\n rescue RestClient::InternalServerError\n logger.error{\"Record #{rid} NOT deleted\"}\n rescue RestClient::ResourceNotFound\n logger.error{\"Record #{rid} does not exist in the database\"}\n else\n logger.info{\"Record #{rid} deleted\"}\n end\n end\n return ridvec\n else\n logger.info{\"No record deleted.\"}\n return nil\n end\n end", "def destroy\n @record_status = RecordStatus.find(params[:id])\n @record_status.destroy\n\n respond_to do |format|\n format.html { redirect_to record_statuses_url }\n format.json { head :no_content }\n end\n end", "def destroy_rest\n @entry_instrument = EntryInstrument.find(params[:id])\n @entry_instrument.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_instruments_url) }\n format.xml { head :ok }\n end\n end", "def delete\n delete_from_server single_url\n end", "def delete\n records = ReadLater.find_by_url(params[:url])\n records.destroy\n\n redirect_to read_laters_path\n end" ]
[ "0.7188934", "0.7096676", "0.7003741", "0.6833237", "0.6816964", "0.6704521", "0.66454375", "0.66403776", "0.66403776", "0.66403776", "0.6638277", "0.6633604", "0.66118133", "0.6610802", "0.66096276", "0.65934575", "0.6559825", "0.6555986", "0.6537249", "0.6534184", "0.65130556", "0.6501565", "0.6487121", "0.6485777", "0.64704573", "0.64704573", "0.64704573", "0.64704573", "0.6461409", "0.64463437", "0.6441565", "0.6438068", "0.6437276", "0.6408616", "0.64085233", "0.64083815", "0.6400629", "0.6398289", "0.63980174", "0.63980174", "0.63972926", "0.63941115", "0.63929737", "0.6391733", "0.63838565", "0.63819", "0.6380137", "0.6376961", "0.6373902", "0.6370175", "0.6358137", "0.6356516", "0.6354375", "0.63528943", "0.6348356", "0.6338592", "0.6330222", "0.6329504", "0.63269246", "0.63269234", "0.63269234", "0.63269234", "0.63269234", "0.63269234", "0.63269234", "0.63269234", "0.6322596", "0.6315245", "0.6314683", "0.63112634", "0.6309384", "0.63087904", "0.6308321", "0.6306832", "0.6303389", "0.62947595", "0.6293231", "0.629096", "0.6281425", "0.62775856", "0.6268792", "0.6268792", "0.62680477", "0.6267167", "0.62653774", "0.6261339", "0.62594795", "0.6254508", "0.6251602", "0.6249556", "0.6245057", "0.62424845", "0.62419134", "0.6241876", "0.62404853", "0.6238317", "0.6236333", "0.622978", "0.6227503", "0.6226629" ]
0.75246847
0
GET /users/1DIS GET /users/1.json
def show @user = User.find(params[:id]) @clock_times = @user.clock_times.all @clock_times_by_week = separate_by_weeks @clock_times puts "farg..." + @clock_times_by_week.inspect @clock_time = @user.clock_times.new respond_to do |format| format.html # show.html.erb format.json { render json: @user } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n if params[:single]\n\t url = \"#{API_BASE_URL}/users/#{params[:id]}.json\"\n\t response = RestClient.get(url)\n\t @user = JSON.parse(response.body)\n\telse\n\t url = \"#{API_BASE_URL}/users.json\"\t \n response = RestClient.get(url)\n @users = JSON.parse(response.body)\t\t \n\tend\n end", "def fetch_one_user_data\n get_url(\"/api/v1/users/#{@filter}\")\n end", "def GetUser id\n\n APICall(path: \"users/#{id}.json\")\n\n end", "def show\n begin\n user = User.find(params[:user_id])\n render json: { users: user }, status: :ok\n rescue => e\n render json: { errors: e.message}, status: 404\n end\n end", "def users(args = {})\n get(\"/users.json\",args)\n end", "def get \n render :json => User.find(params[:id])\n end", "def show\n # When a http GET request to '/users/1' is received, have it show,\n # in json format, user 1's information.\n @id = params[:id]\n @user = User.find(@id)\n render json: @user\n end", "def show\n user = User.friendly.find(params[:user_id]) \n render json: user\n end", "def show\n @users = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @users }\n end\n end", "def user_info\n @user = @github.users.get user: params[:username]\n render json: Hash[@user]\n end", "def list_users\n self.class.get('/users')\n end", "def user\n render :json=> User.find(params[:id])\n end", "def user(user_id, params = {})\n make_get_request(\"/users/#{user_id}\", params)\n end", "def get_user_details\n @user = User.find_by_id(params[:user_id])\n render json: @user\n end", "def GetUsers params = {}\n\n params = params.merge(path: 'users.json')\n APICall(params)\n\n end", "def user(user_id)\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n get(\"users/#{user_id}.json\", params)\n end", "def list_users(user_id)\n self.class.get(\"/users/#{user_id}\")\n end", "def show\n user = User.select(:id, :username, :email).find(params[:id])\n render :json => user\n end", "def show\n @users = User.all\n json_response(@users)\n end", "def show\n render json: Users.find(params[\"id\"])\n end", "def show\n user = User.find(params[:id])\n render json: user\n end", "def get_user(user_id)\n request(Route.new(:GET, '/users/%{user_id}', user_id: user_id))\n end", "def get(user_id:)\n path = '/users/{userId}'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::User\n )\n end", "def show\n user = User.find(params[:id])\n\n render json: user\n end", "def show\n user = User.find(params[:id])\n render json: user\n end", "def show\n user = User.find(params[:id])\n render json: @user\nend", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n render json: @user\n end", "def userReponses\n user=User.find(params[:userId])\n render :json=> user.response\n end", "def show\n @user = User.find(params[:id])\n render json:@user\n end", "def show\n @user = User.find(params[:id])\n render json:@user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n @user = User.find(params[:id])\n\n render json: @user\n end", "def show\n user = User.find_by(uid: params[:id])\n if user\n puts 'USER FOUND'\n render json: user\n else\n puts 'NO USER'\n render json: 'no user'.to_json\n end\n end", "def users\n get('get_users')\n end", "def user(id)\n self.class.get(\"/user/#{id}\", @options).parsed_response\n end", "def get_by_id\n \n # the user_id param comes from our route\n user = User.find(params[:user_id])\n \n if user\n render json: user, status: :ok\n else\n render json: { errors: 'User not found' }, status: :not_found\n end\n end", "def show\n @user = User.find(params[:id])\n render json: @user\nend", "def show_disposisi_user\n\t\t@user = Disposisi.where(user_id: params[:user_id]).order(id: :desc).limit(20)\n\t\trender json: @user\t\n\tend", "def show\n render json: User.find(params[\"id\"])\n end", "def show\n @user = User.find(params[:id])\n render json: {user: @user}\n end", "def for_id(user_id)\n Iterable.request(conf, \"/users/byUserId/#{user_id}\").get\n end", "def show\n render json: User.find(params[:id])\n end", "def show\n render json: User.find(params[:id])\n end", "def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response[\"user\"]\n end", "def show\n @user = User.find_by_username(params[:id])\n @no_replies = true\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def show\n user = User.find(params[:id])\n render json: user\n end", "def user_management_get_single_user id\n # the base uri for api requests\n query_builder = Configuration.BASE_URI.dup\n\n # prepare query string for API call\n query_builder << \"/v1/users/{id}\"\n\n # process optional query parameters\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\n \"id\" => id,\n }\n\n # process optional query parameters\n query_builder = APIHelper.append_url_with_query_parameters query_builder, {\n \"client_id\" => @client_id,\n \"client_secret\" => @client_secret,\n }\n\n # validate and preprocess url\n query_url = APIHelper.clean_url query_builder\n\n # prepare headers\n headers = {\n \"user-agent\" => \"IAMDATA V1\",\n \"accept\" => \"application/json\"\n }\n\n # invoke the API call request to fetch the response\n response = Unirest.get query_url, headers:headers\n\n # Error handling using HTTP status codes\n if response.code == 401\n raise APIException.new \"Unauthorized\", 401, response.raw_body\n elsif response.code == 404\n raise APIException.new \"Not Found\", 404, response.raw_body\n elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\n end\n\n response.body\n end", "def manage_users\n \t@users = User.all\n\n \trespond_to do |format|\n format.json {\n render :json => @users.as_json(:only => [:id, :username, :firstname, :lastname, :email], :methods => [:avatar_url])\n }\n format.html {\n render 'manage_users'\n }\n end\n end", "def show\n @user = ActiveRecord::Base.connection.execute(\"\n SELECT * \n FROM users \n WHERE username = '#{params[:username].downcase}' \n LIMIT 1\").first\n\n respond_to do |format|\n format.html\n format.json {render json: User.find(@user[0])}\n end\n end", "def show\n @users = User.find(params[:id])\n if @users\n respond_to do |format|\n format.json { render :json => @users }\n format.xml { render :xml => @users }\n end\n else\n head :not_found\n end\n end", "def get_user(user_id:)\n parse(JSON.parse(connection.get(\"users/#{user_id}\").body))\n end", "def show(id)\n response = request(:get, \"/users/#{id}.json\")\n response.first[1]\n end", "def get_user_info\n id = params[\"id\"]\n error_list = []\n status = 1\n json_response = {}\n user = User.find_by(id: id)\n\n if user.nil?\n error_list.append(\"Error: The specified user doesn't exist.\")\n status = -1\n else\n json_response[\"user\"] = user.get_user_json_data\n end\n\n if status == -1\n json_response[\"errors\"] = error_list\n end\n\n json_response[\"status\"] = status\n\n # Format the json_response into proper JSON and respond with it\n json_response = json_response.to_json\n\n respond_to do |format|\n format.json { render json: json_response }\n end\n end", "def show\n user = User.find_by(id: params[:id])\n render json: user, status: :ok\n end", "def index\n users = User.all\n json_response(users)\n end", "def json_show_user_profile_by_user_id\n @user = User.find(params[:user_id])\n\n respond_to do |format|\n format.json { render json: @user.as_json(only:[:email,:username]) }\n end\n end", "def user(id = nil)\n id.to_i.zero? ? get('/user') : get(\"/users/#{id}\")\n end", "def get_user_info(list)\n\trequire 'net/http'\n\tNet::HTTP.get(ENV[\"VERITAS-USER-SERVER\"] + \"/users?user_ids=#{list}\")\nend", "def show\n render :json => User.find(params[:id])\n end", "def show\n userId = params[:userId]\n user = User.find_by(id: userId)\n username = user.username\n\n result = { username: username }\n\n respond_to do |format|\n format.json { render :json => result.to_json }\n end \n \n end", "def get_user_data(uid)\n @conn.get(\"/api/v1/users/#{uid}\")\n end", "def show\n render :json => @user.to_json(:except => :_id), status: :ok\n end", "def user(user=nil)\n if user\n get(\"/users/#{user}\", {}, 3)\n else\n get(\"/user\", {}, 3)\n end\n end", "def show\n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html # show.heml.erb\n format.json { render :json => @users }\n end\n end", "def users(params = {})\n make_get_request('/account/users', params)\n end", "def index\n @users = User.all(limit: 100)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @users.as_json(user: current_user) }\n end\n end", "def index\n \n @user = User.find(current_user.id) \n\n respond_to do |format|\n format.html { render action: \"show\" }\n format.json { render json: @user }\n end\n end", "def show\n render json: get_full_user_details(user), status: :ok\n rescue => e\n log_and_render_users_controller_error(e, \"get user details failed\")\n end", "def index\n json_response(User.all) \n end", "def show\n render json: UserService.get_user(params[:id]), includes: 'questions, answers'\n end", "def show\n @user = User.find(params[:id])\n if @user\n render json: {\n user: @user\n }\n else\n render json: {\n status: 500,\n errors: ['user not found']\n }\n end\n end", "def index\n\t\t# specifying json format in the URl\n\t uri = \"#{API_BASE_URL}/users.json\"\n\t # It will create new rest-client resource so that we can call different methods of it\n\t rest_resource = RestClient::Resource.new(uri, USERNAME, PASSWORD)\n\n\t # this next line will give you back all the details in json format, \n\t #but it will be wrapped as a string, so we will parse it in the next step.\n\t users = rest_resource.get \n\n\t # we will convert the return data into an array of hash. see json data parsing here\n\t @users = JSON.parse(users, :symbolize_names => true)\n\tend", "def show_user_profile\n @user = User.find(username: params[:username])\n render json: @user\n end", "def index\n user= User.all\n render json: {users:user}\n end", "def show\n @user = User.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @user }\n end\n end", "def show\n @user = User.find(params[:id])\n render json: {\n username: @user.username,\n first_name: @user.first_name,\n last_name: @user.last_name,\n email: @user.email,\n phone_number: @user.phone_number,\n contacts: @user.contacts\n }, status: :ok\n end", "def getUser( user_id)\n params = Hash.new\n params['user_id'] = user_id\n return doCurl(\"get\",\"/user\",params)\n end", "def index\n @users = User.order_by(last_name: :desc)\n if @users\n render json: Oj.dump(json_for(@users, include: ['phones', 'cards'], meta: meta), mode: :compat)\n else\n return head :unauthorized\n end\n end", "def index\n users = User.all\n render json: { users: users }, status: :ok\n end", "def index\n @users = User.order(:idnum)\n respond_to do |format|\n format.html { render json: {:message => \"Here are the details of all #{@users.size} users.\", :users => @users }}\n end\n end", "def byUid\n @user = User.find(:all, :conditions => [ \"uid = ?\" , params[:id]])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def get_user id, options={}, headers={}\n @connection.get \"users/#{id}.json\", options, headers\n end", "def show\n # @user = User.first\n user = User.find(params[:id])\n render json: user\n end", "def query_users(options={}) path = \"/api/v2/users\"\n get(path, options, AvaTax::VERSION) end", "def show\n @user = User.find(params[:id])\n render 'api/v1/users/show'\n end", "def user_report\n user = User.find_by_username(params[:username])\n raise Discourse::InvalidParameters.new(:username) if !user\n\n ignored_ids = DiscourseFingerprint.get_ignores(user)\n\n fingerprints =\n Fingerprint\n .where(user: user)\n .where.not(value: FlaggedFingerprint.select(:value).where(hidden: true))\n .order(updated_at: :desc)\n\n user_ids =\n Fingerprint\n .matches\n .where(value: fingerprints.pluck(:value))\n .to_h { |match| [match.value, match.user_ids - [user.id]] }\n\n users = User.where(id: user_ids.values.flatten.uniq).or(User.where(id: ignored_ids))\n\n render json: {\n user: BasicUserSerializer.new(user, root: false),\n ignored_ids: ignored_ids,\n fingerprints:\n serialize_data(fingerprints, FingerprintSerializer, scope: { user_ids: user_ids }),\n users: users.map { |u| [u.id, BasicUserSerializer.new(u, root: false)] }.to_h,\n }\n end", "def show_user\n usernames = params.require(:usernames)\n\n identities = Hash[User.where(username: usernames).map { |u| [u.username, u.custom_fields[DiscourseEncrypt::PUBLIC_CUSTOM_FIELD]] }]\n\n render json: identities\n end", "def list\r\n users = User.all\r\n render json: users\r\n end", "def show\n\t\t#reactivate(params[:id])\n\t\t#print(\"we are here now\")\n\t\trender json: User.find(params[:id])\n\tend" ]
[ "0.7568498", "0.7428059", "0.7406899", "0.734745", "0.7303857", "0.70768505", "0.69802237", "0.693383", "0.6929189", "0.69154674", "0.6912279", "0.6893862", "0.68163985", "0.68140846", "0.6804745", "0.67887205", "0.6758953", "0.6754927", "0.67462033", "0.6733165", "0.6718727", "0.6717", "0.6714355", "0.6706058", "0.67031497", "0.66948974", "0.6692778", "0.6692778", "0.6692778", "0.6692778", "0.6692778", "0.6692778", "0.6692778", "0.66846263", "0.66774803", "0.66774803", "0.6673875", "0.6673875", "0.6673875", "0.6673875", "0.6673875", "0.6673875", "0.6673875", "0.6673875", "0.6669437", "0.66608894", "0.664588", "0.6641402", "0.66386855", "0.6638625", "0.6633799", "0.6630165", "0.66285205", "0.66269886", "0.6626457", "0.6619127", "0.66142297", "0.66101885", "0.65989745", "0.6598275", "0.6596167", "0.6592121", "0.6591414", "0.6589785", "0.6580784", "0.6574764", "0.6571958", "0.6571829", "0.65634704", "0.655814", "0.6555191", "0.65494347", "0.6537491", "0.65300024", "0.6526692", "0.6524479", "0.6521005", "0.65168405", "0.6514204", "0.6514065", "0.65025526", "0.64979", "0.64934015", "0.64922255", "0.6490089", "0.64871585", "0.6486266", "0.6481408", "0.6469391", "0.64638793", "0.64620596", "0.64593303", "0.6451937", "0.6451107", "0.64422435", "0.643862", "0.6435178", "0.6434155", "0.6424015", "0.64178383", "0.6416118" ]
0.0
-1
GET /users/new GET /users/new.json
def new @user = User.new respond_to do |format| format.html # new.html.erb format.json { render json: @user } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @newuser = Newuser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newuser }\n end\n end", "def new\n @usernew = Usernew.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usernew }\n end\n end", "def new\n @user = user.new\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n # When a http GET request to '/users/new' is received, have it render:\n # a view file with an empty form to create a new user.\n end", "def new\n @user = User.new\n @action = \"new\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n @users = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @users }\n end\n end", "def new2\n @user = User.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n \n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n \n end", "def new\n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n @user = User.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n @user = User.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end" ]
[ "0.82876", "0.81695044", "0.81553495", "0.8048313", "0.80221504", "0.8020816", "0.80092996", "0.7950455", "0.7929954", "0.7929954", "0.7872814", "0.7872814", "0.7872814" ]
0.7860219
97
POST /users POST /users.json
def create params[:user]["_id"] = params[:user][:name] @user = User.new(params[:user]) respond_to do |format| if @user.save() format.html { redirect_to @user, notice: 'User was successfully created.' } format.json { render json: @user, status: :created, location: @user } else format.html { render action: "new" } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_users(users)\n self.class.post('https://api.yesgraph.com/v0/users', {\n :body => users.to_json,\n :headers => @options,\n })\n end", "def CreateUser params = {}\n \n APICall(path: 'users.json',method: 'POST',payload: params.to_json)\n \n end", "def post body=nil, headers={}\n @connection.post \"users.json\", body, headers\n end", "def create\n # render json: params\n render json: Users.create(params[\"user\"])\n end", "def create_user(params:)\n parse(JSON.parse(connection.post(\"users\", params.to_json).body))\n end", "def create\n user = User.create(user_params) \n render json: user, status: :created\n end", "def create\n user = User.new(user_params)\n if user.save\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(form_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: { users: @user }, status: :created }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.new(\n username: user_params[:username],\n password: user_params[:password])\n if user.save\n create_example_collection(user)\n render json: user, except: [:password_digest, :created_at, :updated_at]\n else\n render json: {errors: user.errors.full_messages}\n end\n end", "def create\n user= User.create(user_params)\n render json: user\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n\t\t@user = User.new(users_params)\n\t\tif @user.save\n\t\t\tjson_response(@user, \"User is created Successfully.\")\n\t\telse\n\t\t\trender json: {message: @user.errors.full_messages.join(\" \")}, status: 400\n\t\tend\t\t\n\tend", "def create\n user = User.new(@user_info)\n if user.save && user.errors.empty?\n render json: { status: 200, data: UserSerializer.new(user).as_json }\n else\n render json: { status: 400, error: user.errors.full_messages }\n end\n end", "def create\n user = User.create(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors, status: :unprocessable_entity\n end\n end", "def create(options = {})\n request(:post, '/users.json', default_params(options))\n end", "def create\n @user = User.new user_params(params[:user])\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new user_params(params[:user])\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.create user_params\n \n if @user.save\n respond_with(@user) do |format|\n format.json {render}\n end\n end\n end", "def create\n @user = User.new(user_params(params))\n \n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params(params))\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params(params))\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create_user\n @user = User.new(user_params)\n if @user.save\n render json: UserSerializer.new(@user).serialized_json\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = @application.users.create(user_params)\n\n if @user.valid?\n render json: @user, status: :created, location: api_application_user_path(@application,@user)\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n user = User.create(user_params)\n if user.save\n render json: user\n else\n render json: user.errors, status: :bad\n end\n end", "def create\n r = @api.create_user(user_params)\n respond_to do |format|\n if r.code == 201\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\n else\n response = JSON.parse(r.body)\n format.html { redirect_to users_url, alert: response['message']}\n end\n end\n end", "def create\n\n puts '-----------------------create in user controller'\n\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: UserSerializer.new(@user).serialized_json\n else\n render json: { error: I18n.t('user_create_error') }, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n if @user.save\n render json: { user: @user, success: 'User registration successful' }\n else\n render json: { error: 'User registration unsuccessful' }\n end\n end", "def create\n @user = User.new(user_params)\n \n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n\t\tputs user_params\n\t\tuser = User.new(user_params)\n\t\tif user.save\n\t\t\trender json: { user: user, status: :success }\n\t\telse\n\t\t\trender json: { status: :failure, errors: user.errors.full_messages.join('') }\n\t\tend\n\tend", "def create\n\t\t@user = User.new(user_params)\n\t\tif @user.save\n\t\t\trender json: @user, status: :created, location: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def add_user(name, value)\n self.class.post(\"/users/#{name}\",\n body: value,\n headers: {\n 'Content-Type' => 'application/json; charset=UTF-8',\n Connection: 'keep-alive',\n Accept: 'application/json, text/plain, */*'\n })\n end", "def create\n user = User.new(user_params)\n\n respond_to do |format|\n if user.save\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = current_user.users.build(user_params)\n\n if @user.save\n render json: @user\n else\n @user_items = []\n end\n end", "def create\n user = User.new(user_params)\n render json: { status: 200, msg: 'User was created.', data: \"User Id #{user.id}\" } if user.save\n end", "def create\n @users = User.new(params[:user])\n\n respond_to do |format|\n if @users.save\n format.html { redirect_to @users, notice: 'Regist was successfully created.' }\n format.json { render json: @users, status: :created, location: @users }\n else\n format.html { render action: \"new\" }\n format.json { render json: @users.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.new(user_params)\n if user.save\n render :json => user, :status => :created\n else\n render :json => {:ok => false, :message => user.errors}, :status => :unprocessable_entity\n end\n end", "def create\n logger.debug user_params\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :ok\n else\n render json: @user.errors, status: :not_acceptable\n end\n end", "def create\n user = User.create(user_params)\n render json: user, message: 'user succefully create', status: 200\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n\n up = user_params\n\n if up[:name].present?\n up[:first_name] = up[:name].split(' ')[0]\n up[:last_name] = up[:name].split(' ')[1]\n up.delete :name\n end\n @user = User.new(up)\n\n respond_to do |format|\n if @user.save\n # render json: {user: user, token: token}\n\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: api_user_url(@user)}\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.new(user_params)\n if user.save\n render json: {status: \"Se creo el usuario\"}, status: :ok\n else\n render json: {status: \"Error al crear el usuario\", errors: user.errors }, status: :unprocessable_entity\n end\n end", "def create\n user = User.new(params[:user].permit(:username))\n if user.save\n render json: user\n else\n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end", "def create\n puts '>>> params:'\n puts params.inspect\n @user = User.new(params[:user])\n puts '>>> User:'\n puts @user.inspect\n\n if @user.save\n render json: @user, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n \tdata = { data: @user, status: :created, message: \"User was successfully created.\" }\n render :json => data\n else\n \tdata = { data: @user.errors, status: :unprocessable_entity }\n render :json => data\n end\n end", "def create\n user_details = params.permit(:first_name, :last_name, :email)\n success = User.create(user_details)\n\n render json: { success: success }\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: @user.as_json(only: [:email, :authentication_token]), status: :created\n else\n head(:unprocessable_entity)\n end\n end", "def create_user\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n post(\"users.json\", params)\n end", "def create\n @user = User.new(params[:user])\n\n if @user.save\n respond_to do |format|\n format.json { render :json => @user.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create user\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n if @user.save\n render :ok, json: @user.to_json\n else\n @errors = @user.errors.full_messages\n render json: { message: @errors }, status: :unauthorized\n end\n end", "def create\n puts params\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render json: @user.as_json(user: current_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 create\n user = User.new(user_params)\n if user.save\n render json: {status: 200, msg: 'User was created.'}\n else\n render json: {errors: user.errors.messages}\n end\n end", "def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, :notice => 'User was successfully created.' }\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 create\n @user = User.new({name: params[:name], email: params[:email], password: params[:password], photo: params[:photo]})\n @user.save\n render json:@user\n end", "def create\n user = User.create(user_params)\n\n if user.valid?\n render json: {user: UserSerializer.new(user), token: encode_token(user.id)}\n else\n render json: user.errors.full_messages\n end\n end", "def create\n\t\tnew_user = User.new(user_params)\n\t\tif new_user.save\n\t\t render status: 200, json: {\n\t\t \tstatus: 200,\n\t\t message:\"New User Created\",\n\t\t response: {\n\t\t name: new_user.name,\n\t\t email: new_user.email,\n\t\t id: new_user.id,\n\t\t facebook_id: new_user.facebook_id,\n\t\t device_id: new_user.device_id,\n\t\t authentication_token: new_user.authentication_token\n\t\t }\n\t\t \n\t\t }.to_json\n\t\telse\n\t\t render status: 404, json: {\n\t\t \tstatus: 404,\n\t\t errors: new_user.errors\n\t\t }.to_json\n\t\tend\n\tend", "def create\n\t\tresp = {} \n user = User.create(user_params)\n \tif user.valid?\n if user.save\n return render :json => user.as_json\n end\n end\n render json: user.errors.full_messages \n\tend", "def post_users_with_http_info(users, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: UsersApi.post_users ...'\n end\n # verify the required parameter 'users' is set\n if @api_client.config.client_side_validation && users.nil?\n fail ArgumentError, \"Missing the required parameter 'users' when calling UsersApi.post_users\"\n end\n # resource path\n local_var_path = '/users'\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'])\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(users) \n\n # return_type\n return_type = opts[:return_type] || 'User' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Bearer']\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(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: UsersApi#post_users\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create_user(options = {})\n post \"/users\", options\n end", "def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\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 create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_url, notice: 'User was successfully created.' }\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 create\n \n user = User.new(user_params)\n\n if user.save\n\n render json: {status: 200, msg: 'User was created.'}\n\n else \n render json: {\n errors: user.errors.full_messages\n }, status: :unprocessable_entity\n\n end\n\n end", "def create\n @user = User.new(params[:user])\n\n respond_to do |format|\n if @user.save \n format.html { redirect_to users_url, notice: \"User #{@user.name} was successfully created.\" }\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 create_user(body)\n post 'create_user', body\n end", "def create\n @user = User.new(user_params)\n @user.email = params[:email].downcase\n if @user.save\n render json: @user, status: 200\n else\n render json: { errors: @user.errors.full_messages }, status: 400\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json:@user\n elsif @user.errors\n render json: {error: {code: 400, server_message: @user.errors}}, status: :bad_request\n else\n render json: {error: {code: 500, message: \"Could not save user\", server_message: @user.errors}}, status: :internal_server_error\n end\n\n end", "def create\n user = User.new(user_params)\n\n if user.valid?\n user.save\n render json: {user: user, token: encode_token({user_id: user.id})}\n else\n render json: {error: \"Failed to create the user\"}\n end\n end", "def create\n @user = User.new(user_params)\n @user.save\n respond_with @user\n end", "def create\n @user = User.new(user_params)\n render json: @user && return if @user.save\n\n render json: { error: \"Unable to save user: #{@user.errors.messages}\" }, status: 400\n end", "def create_user(attributes)\n post(\"/v1/users\", attributes)\n end", "def create\n user = User.new(user_params)\n\n # if user is saved sucessfully it will return user and ith status 201 for created\n if user.save\n render json:user,status: :created\n #if request is properly served but data is wrong it ll give ubprocessable_entity with code 422\n else\n render json: user.errors, status: :unprocessable_entity\n end \n end", "def create\r\n @user = User.new(params[:user])\r\n\r\n respond_to do |format|\r\n if @user.save\r\n format.html { redirect_to users_path, notice: 'Os dados do usuário foram salvos com sucesso!' }\r\n format.json { render json: @user, status: :created, location: @user }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @user.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @user = User.new(\n first_name: params[:first_name],\n last_name: params[:last_name],\n birth_date: params[:birth_date],\n height: params[:height],\n weight: params[:weight],\n user_name: params[:user_name],\n password: params[:password],\n password_confirmation: params[:password_confirmation],\n facebook_url: params[:facebook_url],\n twitter_url: params[:twitter_url],\n instagram_url: params[:instagram_url],\n address: params[:address],\n email: params[:email]\n ) \n if @user.save!\n render 'successful.json.jb', status: :created\n else\n render 'unsuccessful.json.jb', status: :bad_request\n end\n end", "def post(hash)\n HttpClient::Preconditions.assert_class('hash', hash, Hash)\n @client.request(\"/users\").with_json(hash.to_json).post { |hash| Apidoc::Models::User.new(hash) }\n end", "def create\n user = User.create!(user_params)\n session[:user_id] = user.id\n render json: user, status: :created\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render json: {message: \"user create successfuly\"}\n else\n render json: {message: \"Error\"}\n end \n end", "def create\n # Insert new user in database\n user = User.new(user_params)\n\n if user.save\n # On success, send token information to authenticate user\n token = create_token(user.id, user.username)\n render json: {status: 200, token: token, user: user}\n # render json: @user, status: :created, location: @user\n else\n render json: user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(params[:user])\n @user.status = 'active'\n\n respond_to do |format|\n if @user.save\n format.json { render :json => @user, :status => :created }\n format.html { redirect_to(users_path) }\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 create\n @user = User.new(user_params)\n\n if @user.save\n respond_with(@user, location: users_url, notice: 'User was successfully created.')\n else\n respond_with(@user)\n end\n end", "def create\n user = User.new(user_params)\n \n if user.save\n token = JsonWebToken.encode(user_id: user.id)\n render json: { auth_token: token, user: AuthUserSerializer.new(user).serializable_hash }, status: 201\n else \n render json: { errors: user.errors.full_messages }, status: 400\n end\n end", "def create\n @user = User.new(params[:user])\n puts params[:user]\n respond_to do |format|\n if @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 create\n @user = User.new(user_params)\n\n if @user.save\n render :show, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render :show, status: :created, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n user = User.create(user_params)\n if user.valid?\n user.username.downcase\n @token = issue_token(user)\n list = List.create(name: user.username)\n list.user_id = user.id\n user.save\n list.save\n render json: { user: UserSerializer.new(user), jwt: @token }, status: :created \n else \n render json: { error: user.errors.full_messages }, status: :not_acceptable\n end \n end", "def create\n @user = User.new(user_params)\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to users_path, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user_response = API::V1::Users.authenticate params.as_json\n if user_response.success?\n json = HashWithIndifferentAccess.new(user_response.parsed_response)\n auth_response = API::V1::Auth.issue json[:data]\n respond_with auth_response.body, auth_response.code\n else\n respond_with nil, :unauthorized\n end\n end", "def create\n @user = User.new(user_params)\n\n if @user.save\n render :json => { :status => 0 }\n else\n render :json => { :status => 1, :msg => @user.errors}\n end\n end", "def create\n @user = User.new(user_params)\n if @user.save\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token }, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def create\n authorize :user, :create?\n @user = User.new(user_params)\n @user.save\n\n respond_to do |format|\n format.html\n format.json { render :json => @user, status: 200 }\n end\n end", "def post_accounts(json_hash)\n @options = {:path => '/users.json',\n :body => json_hash[:json]}.merge(@options)\n\n request(\n :expects => 201,\n :method => :post,\n :body => @options[:body]\n )\n end", "def create\n user = User.new(username: params[:username])\n if user.save\n payload = {'user_id': user.id}\n token = JWT.encode(payload, 'chatapp')\n render json: {\n user: user,\n token: token\n }\n else \n render json: { message: 'There was an error creating your account' }\n end\n end", "def create\n user = User.create!(user_params)\n if user\n session[:user_id] = user.id\n render json: user, status: :created\n else\n render json: { errors: user.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def create\r\n @user = User.new user_params\r\n\r\n if @user.save\r\n render json: @user, serializer: SessionSerializer, root: nil\r\n else\r\n render json: { errors: @user.errors }, status: :unprocessable_entity\r\n end\r\n end", "def create\n user = User.new(user_params)\n if user.save\n render json: { status: 'OK', msg: 'User was created.', error: 'nil' },\n status: :created\n else\n not_good(422)\n end\n end" ]
[ "0.77179813", "0.75206673", "0.73831296", "0.72405374", "0.719841", "0.7140812", "0.71038526", "0.7058827", "0.7041636", "0.70236504", "0.7003128", "0.70021695", "0.70021695", "0.70021695", "0.69936967", "0.6990463", "0.6980393", "0.6979075", "0.69788617", "0.69788617", "0.69762856", "0.6962628", "0.6952247", "0.69454783", "0.69454783", "0.6920555", "0.69181055", "0.691467", "0.6901315", "0.6898759", "0.689459", "0.6889815", "0.6880676", "0.6880467", "0.6880196", "0.68797004", "0.6877297", "0.686924", "0.6855058", "0.6851115", "0.6844058", "0.6814104", "0.6803589", "0.6777842", "0.6776859", "0.67678535", "0.6757897", "0.67471397", "0.6738628", "0.6734963", "0.6733872", "0.6720612", "0.6711659", "0.6670256", "0.66581875", "0.66573423", "0.6654514", "0.6638977", "0.66325235", "0.66199607", "0.6615226", "0.66148156", "0.65989614", "0.65910506", "0.65792614", "0.6578957", "0.6573529", "0.6573351", "0.6557221", "0.6553408", "0.6551572", "0.65466446", "0.6540912", "0.65399504", "0.6535891", "0.6533581", "0.6526114", "0.65116656", "0.65072525", "0.6507116", "0.6503024", "0.6490388", "0.6488653", "0.64881754", "0.6473845", "0.64722794", "0.64702916", "0.64702916", "0.6469406", "0.64682525", "0.6462379", "0.64619774", "0.646129", "0.6455196", "0.645272", "0.6448271", "0.6447503", "0.64468706", "0.64460355", "0.6441883" ]
0.6538697
74
PUT /users/1 PUT /users/1.json
def update @user = User.find(params[:id]) respond_to do |format| if @user.update_attributes(params[:user]) format.html { redirect_to @user, notice: 'User was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @user.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n render json: Users.update(params[\"id\"], params[\"user\"])\n end", "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def UpdateUser params = {}\n \n APICall(path: 'users.json',method: 'PUT',payload: params.to_json)\n \n end", "def put user_id, options={}, headers={}\n @connection.put \"users/#{user_id}.json\", options, headers\n end", "def updateUser\n options = {\n :body => params.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n results = HTTParty.put(\"http://192.168.99.101:4051/users/\"+@current_user[\"id\"].to_s, options)\n render json: results.parsed_response, status: results.code\n end", "def update\n user = User.find_by(id: params[:id])\n user.update(user_params)\n render json: user\n end", "def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.role = params[:type]\n @user.save\n render json:@user\n end", "def update\n if user.update(user_params)\n render json: user\n else\n render json: {errors: \"Cannot create user\"}, :status => 420\n end\n end", "def update\n user = @user_service.update_user(params[:id])\n render json: user, status: :ok\n end", "def update_current_logged_in_user(args = {}) \n put(\"/users.json/current\", args)\nend", "def modify_user(user)\n query_api_object Model::User, '/rest/user', user.to_hash, 'PUT'\n end", "def update \n user = User.find(params[:id])\n # byebug\n user.update(user_params)\n\n render json: user\n end", "def update\n @user = User.find(params[:id])\n @user.name = params[:name]\n @user.email = params[:email]\n @user.password = params[:password]\n @user.photo = params[:photo]\n @user.save\n render json:@user\n end", "def update\n user = find_user\n user.update!(user_params)\n render json: user\n end", "def update\n user = User.find(params[:id])\n\n # Use update with user_params to do a mass-assignment update and save. \n if user.update_attributes(user_params)\n render json: user\n else \n render json: user.errors.full_messages, status: :unprocessable_entity\n end\n end", "def update_user(user, options = {})\n put \"/users/#{user}\", options\n end", "def update_user(options)\n patch(\"/user\", options, 3)\n end", "def modify_user(user)\n query_api_object User, \"/rest/user\", user.dump(), \"PUT\"\n end", "def update\n begin\n user = User.find(params[:user_id])\n if user.update(user_params)\n render json: { users: user }, status: :ok\n else\n render json: { errors: user.errors.messages }, status: 422\n end\n rescue => e\n render json: { errors: e.message }, status: 404\n end\n end", "def update\n if @api_v1_user.update(api_v1_user_params)\n head :no_content\n else\n render json: @api_v1_user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n render json:@user\n else\n render json: { error: {code: 404, message: 'Invalid user' }}, status: :not_found\n end\n end", "def update\n user = User.find(params[:id])\n user.update(user_params)\n if user.valid?\n render json: user\n else\n render json: user.errors\n end\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update(id, params = {})\n request(:put, \"/users/#{id}\", body: params)\n end", "def update\n if @user.update(user_params)\n render json: @user\n else\n render json: {error: \"Could not update user\"}\n end\n end", "def update\n \trespond_to do |format|\n if @user.update(user_params)\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n\t \t\n end", "def update\n user = User.find(params[:id])\n if user.update(user_params)\n render json: user\n else\n render json: user.errors.full_messages\n end\n end", "def update\n if @user.update(user_params)\n render json: @user, status: 200\n else\n render json: @user.errors, status: 422\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update_attributes(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update_attributes(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update user_params(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(params[:user])\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id]) \n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User #{@user.name} was successfully created.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update(user_params)\n render json: @user, status: :ok\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n @user.update(user_params)\n render json: @current_user\n end", "def update\n user = User.find(params[:id])\n if user.update(params_user)\n render json: user, status: 200\n else\n render json: user.errors, status: 422\n end\n\n end", "def update\n\t\tif @user.update(user_params)\n\t\t\trender json: @user\n\t\telse\n\t\t\trender json: @user.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def update\n @user.update(user_params_update)\n json_response(@user)\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params[:user]))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n if @user.update(user_params)\n render json: @user, status: :ok, location: @user\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if user.update(user_params)\n render json: user, status: :ok\n else\n format.json { render json: user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend", "def update_user\n @user = User.find(params[:id])\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status :unprocessable_entity\n end\n end", "def update\n user = User.find(params[:id])\n render json: { status: 200, msg: 'User details have been updated.' } if user.update(user_params)\n end", "def update\n @user = User.find(params[:id])\n @user.update_attributes(params[:user])\n respond_with @user\n end", "def update\n @user = User.find(params[:id])\n @user.update_attributes(params[:user])\n respond_with @user\n end", "def update\n @user = V1::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = 'V1::User was successfully updated.'\n format.html { redirect_to(@user) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n if @user.id == current_api_user.id\n if @user.update(user_params)\n render json: @user.as_json(except: [:updated_at]), status: :ok\n else\n render json: @user.errors, status: :bad_request\n end\n else\n render json: '', status: :forbidden\n end\n end", "def update\n @user = User.find(params[:id])\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update \n @current_user.update(user_params)\n render json: @current_user\n end", "def update\n @user = User.find(params[:id])\n if @user.update(user_params(params))\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = selected_user\n if @user.update(users_params)\n render 'api/users/show'\n else\n render json: @user.errors.full_messages, status: 422\n end\n end", "def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.json { head :ok }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = current_api_user\n unless @user.update(user_params)\n render json: { error: @user.errors.full_messages.to_sentence }, status: :not_found\n end\n end", "def update\n respond_to do |format|\n if @user.update(form_params)\n format.json { render json: { users: @user }, status: :ok, location: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit(id, options={})\n request(:put, \"/users/#{id}.json\", default_params(options))\n end", "def update_user(id, accountId, model) path = \"/api/v2/accounts/#{accountId}/users/#{id}\"\n put(path, model, {}, AvaTax::VERSION) end", "def update\n user = User.find(params[:id])\n\n user.attributes = {\n name: params[:name]\n }\n\n user_save user\n end", "def update\n @user = current_org.users.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user.update(user_params)\n respond_with @user\n end", "def update\n user = User.find(params[:id])\n if user.update(user_params)\n render json: {\n status: 'OK',\n msg: 'User details have been updated.',\n error: 'nil'\n }, status: :accepted\n else\n not_good(406)\n end\n end", "def update\n respond_to do |format|\n if @v1_user.update(v1_user_params)\n format.html { redirect_to @v1_user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @v1_user }\n else\n format.html { render :edit }\n format.json { render json: @v1_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n authorize @user\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n\t\tif @user.update(users_params)\n \t\tjson_response(@user, \"User Update Successfully.\")\n \telse\n \t\trender json: {message: @user.errors.full_messages.join(\" \")}, status: 400\n \tend\n\tend", "def update\n @user = current_user\n if @user.update(update_user_params)\n render 'api/v1/users/show'\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { render action: \"edit\"}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def update(context, name, should)\n res = context.transport.put_request(context, \"security/users/#{name}\", keys_to_camelcase(should))\n\n context.err(name, res.body) unless res.success?\n end", "def update!(options: {})\n\t\t\tuser = User.perform_request User.api_url(\"users/#{id}\"), :put, options, true\n\n\t\t\tif user\n\t\t\t\toptions.each do |key, value|\n\t\t\t\t\tself.send(\"#{key}=\", user['data'][\"#{key}\"])\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tnil\n\t\t\tend\n\t\tend", "def update\n @user = user.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @todo = Todo.find(params[:todo][:id])\n if @todo.update_attributes(user_params)\n render json: @todo\n else\n render nothing: true, status: :bad_request\n end\n end", "def update\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to users_path }\n format.json { render :json => @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User was successfully updated.' }\n\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_name(user_id:, name:)\n path = '/users/{userId}/name'\n .gsub('{userId}', user_id)\n\n if user_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"userId\"')\n end\n\n if name.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"name\"')\n end\n\n params = {\n name: name,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'PATCH',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::User\n )\n end", "def update_current_logged_in_user(args = {}) \n id = args['id']\n temp_path = \"/users.json/current\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update_user\n @user = User.find(params[:id])\n @user.update(params[:user])\n redirect \"/users/#{@user.id}\"\nend", "def update\n @api_user = ApiUser.find(params[:id])\n\n if @api_user.update(api_user_params)\n head :no_content\n else\n render json: @api_user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_user\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user.as_json(user: current_user), notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.update(params[:user])\n end", "def update\n @user = User.find(params[:id])\n\n if @user.update(user_params)\n head :no_content\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update \n user = User.where(:id => current_user.user)\n if user.update(user_params)\n render :json => {:user => user }\n else\n render :json => {:error => user.errors.full_messages.first}\n end\nend", "def update\n @user = User.find(params[:id])\n \n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @user.update(user_params)\n render json: @user, status: :ok, location: api_application_user_path(@application,@user)\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_path, :notice => 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes_from_api(params[:user])\n format.html { redirect_to @user, :notice => 'User was successfully updated.' }\n format.json { render_for_api :user, :json => @user }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, :notice => t('user.update_success') }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @user.errors, :status=> :unprocessable_entity }\n end\n end\n end", "def 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\n user = current_user\n if user.update(update_params)\n render json: { status: { updated: \"Ok\" } }\n else\n render json: user.errors.full_messages\n end\n end", "def update\n @user = User.find(params[:id])\n if @user.update_attributes(user_params)\n redirect_to @user\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\nend", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = ::User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n flash[:notice] = \"User #{@user.username} successfully updated!\"\n format.html { redirect_to @user }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n user = User.find(params[:id])\n authorize! :update, user\n if user.update_attributes(user_params)\n render :json => {:ok => true, :message => 'successful updated'}, :head => :no_content\n else\n render :json => {:ok => false, :message => user.errors}, :status => :unprocessable_entity\n end\n end" ]
[ "0.74114245", "0.73920554", "0.73041475", "0.7254177", "0.7202618", "0.70756376", "0.70535713", "0.7029043", "0.70075685", "0.69883573", "0.6983195", "0.694263", "0.69409895", "0.692315", "0.6909438", "0.687742", "0.68486536", "0.6834162", "0.6821841", "0.6801179", "0.67703044", "0.6763487", "0.6761313", "0.6761313", "0.67482305", "0.67473894", "0.6713073", "0.6703807", "0.6693307", "0.66886777", "0.66886777", "0.66646844", "0.66617274", "0.66572624", "0.6653578", "0.66406506", "0.6625279", "0.66213304", "0.66192704", "0.6614916", "0.6612626", "0.6604333", "0.65851104", "0.65851104", "0.65785134", "0.65615654", "0.65518224", "0.65518224", "0.6549094", "0.6530534", "0.6530534", "0.65275174", "0.6523527", "0.6520384", "0.6520384", "0.6516204", "0.65145653", "0.65104014", "0.6504922", "0.6499594", "0.64987266", "0.64906204", "0.64810187", "0.64798295", "0.64702576", "0.64496434", "0.6436427", "0.6433962", "0.64330167", "0.6428237", "0.6406415", "0.6402615", "0.6399288", "0.63881207", "0.63877773", "0.6353986", "0.63537806", "0.633806", "0.63360107", "0.6334851", "0.632672", "0.63260114", "0.63179153", "0.63173646", "0.6317282", "0.6316377", "0.6316055", "0.63120025", "0.6293317", "0.62857985", "0.6282219", "0.6280316", "0.6264061", "0.62624925", "0.625522", "0.62549126", "0.62547195", "0.625327", "0.625269", "0.6252329", "0.6245382" ]
0.0
-1
DELETE /users/1 DELETE /users/1.json
def destroy @user = User.find(params[:id]) @user.destroy respond_to do |format| format.html { redirect_to users_url } format.json { head :no_content } puts "*************:" + @user.inspect format.js { render nothing: true } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteUser id\n \n APICall(path: \"users/#{id}.json\",method: 'DELETE')\n \n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def delete(id)\n request(:delete, \"/users/#{id}.json\")\n end", "def delete\n render json: Users.delete(params[\"id\"])\n end", "def delete\n @user.destroy\n respond_to do |format|\n format.html { redirect_to v1_resources_users_all_path, notice: 'User was deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n render json:@user\n end", "def destroy\n @user = V1::User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to(v1_users_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n \"\"\"\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n \"\"\"\n end", "def destroy\n debugger\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n user = User.find(params[:id]) # from url, nothing to do with table\n user.destroy\n render json: user\n end", "def destroy\n @user.destroy\n format.json { head :no_content }\n end", "def destroy\n @user.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find_by_id_or_username params[:id]\n @user.destroy\n render api_delete @user\n end", "def delete_user\n @user = User.find(params[:id])\n if @user.destroy\n render :json => @user\n else\n render :json => @user.errors.full_messages\n end\n end", "def destroy\n @user = user.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @v1_user.destroy\n respond_to do |format|\n format.html { redirect_to v1_users_url, notice: 'User was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.78750366", "0.7750983", "0.7714552", "0.760911", "0.7471576", "0.7406053", "0.7406053", "0.7368785", "0.7344947", "0.733919", "0.73272926", "0.7308574", "0.73084617", "0.73053783", "0.72965413", "0.7290662", "0.7290503", "0.7287583", "0.72832316", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.72497493", "0.7244045", "0.7240689", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024", "0.7231024" ]
0.0
-1
Print the status line and make sure there is nothing left from the last line
def print_line(line) @maxlinelength = line.length if line.length > @maxlinelength print line.ljust(@maxlinelength) << "\r" $stdout.flush end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def commit_status()\n if @status_line\n if @ping_from\n # Debug mode show final line value as history.\n puts @status_line\n else\n # Normal mode advance to the next line leaving this line as history.\n puts\n end\n STDOUT.flush\n @status_line = nil\n end\n end", "def status_line\n # prompt\n v_mm = @mode ? \"[#{@mode}] \" : ''\n cf = current_file\n @message = \" | No matches. Press ESCAPE \" if @patt && !cf\n\n clear_last_line\n\n # Print the filename at the right side of the status line\n # sometimes due to search, there is no file\n if cf\n if @debug_flag\n print_debug_info cf\n else\n # print_on_right \"#{Dir.pwd}\"\n print_filename_status_line if @filename_status_line\n end\n end\n # move to beginning of line, reset text mode after printing\n # patt and message are together, no gap, why not ? 2019-04-08 -\n if @patt && @patt != ''\n patt = \"[/#{@patt}\" + ']' # to get unfrozen string\n patt[-1] = '/i]' if @ignore_case\n end\n # bring cursor to start of line\n # add background color\n # print mode\n # print search pattern if any\n # print message if any\n # print \"\\r#{v_mm}#{patt}#{@message}\\e[m\"\n print \"\\r\\e[33;4#{@status_color}m#{v_mm}#{patt}#{@message}\\e[m\"\nend", "def status_line(line)\n @status_line = line\n unless @ping_from\n # Display this status line.\n STDOUT.write \"\\r\" # Move to the start of this line.\n STDOUT.write line # Write over it.\n STDOUT.flush\n end\n end", "def print_status\n next_run = ((@@next_task-Time.now)/60.0).round(2)\n\n print \"\\r\"\n print \"#{Time.now} #{[@chains.count,@steps_done].min}/#{@chain_count} chains active - #{@chains.sum(&:remaining_task_count)}/#{@task_count} Tasks remaining - Next task will run in #{next_run} minutes\"\n\n EM.add_timer 1, proc {\n print_status\n }\n end", "def step_status(msg = '')\n\t\toutput.print_status(\"#{pos}: #{msg}\") if (msg and msg.length > 0)\n\tend", "def print_status_message text=$status_message\n r = $status_message_row || Ncurses.LINES-1\n clear_error r, $datacolor\n # print it in centre\n printstring r, (Ncurses.COLS-text.length)/2, text, color = $promptcolor\n end", "def print_out_line\n name = @run_name\n name += \" (res: #@restart_id)\" if @restart_id\n name += \" real_id: #@real_id\" if @real_id\n beginning = sprintf(\"%2d:%d %-60s %1s:%2.1f(%s) %3s%1s\", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete, \"%\")\n if ctd\n #beginning += sprintf(\"Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20\", fusionQ, pfus, ti0, te0, ne0)\n end\n beginning += \" ---#{@comment}\" if @comment\n beginning\n end", "def print_status(msg)\n puts \"\" if verbose_mode?\n puts \"#{color('----->', 32)} #{msg}\"\n end", "def print_status\n\t\tputs \"#{status}\"\n\tend", "def status_line\n\t\tst = self.status || self.derived_status_code\n\t\treturn STATUS_LINE_FORMAT % [ st, HTTP::STATUS_NAME[st] ]\n\tend", "def status_line\n content[0]\n end", "def print_empty_line\n print_in_same_line(\" \")\n end", "def status\n @status ||= status_line.split(/: /)\n end", "def print_out_line\n\t\t\t#p ['id', id, 'ctd', ctd]\n\t\t\t#p rcp.results.zip(rcp.results.map{|r| send(r)})\n\t\t\tname = @run_name\n\t\t\tname += \" (res: #@restart_id)\" if @restart_id\n\t\t\tname += \" real_id: #@real_id\" if @real_id\n\t\t\tbeginning = sprintf(\"%2d:%d %-60s %1s:%2.1f(%s)\", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s)\n\t\t\tif @status == :Incomplete and @completed_timesteps\n\t\t\t\tbeginning += sprintf(\" %d steps \", @completed_timesteps)\n\t\t\telsif @percent_complete\n \t\t\t\tbeginning+=sprintf(\" %3s%1s \", percent_complete, \"%\")\n\t\t\tend\n\t\t\tif ctd\n\t\t\t\t#beginning += sprintf(\"Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20\", fusionQ, pfus, ti0, te0, ne0)\n\t\t\tend\n\t\t\tbeginning += \" ---#{@comment}\" if @comment\n\t\t\tbeginning\n\t\tend", "def break_after_print\n checked_puts if @prev_printed\n end", "def fresh_line?; end", "def print_out_line\n #p ['id', id, 'ctd', ctd]\n #p rcp.results.zip(rcp.results.map{|r| send(r)})\n name = @run_name\n name += \" (res: #@restart_id)\" if @restart_id\n name += \" real_id: #@real_id\" if @real_id\n beginning = sprintf(\"%2d:%d %-60s %1s:%2.1f(%s) %3s%1s\", @id, @job_no, name, @status.to_s[0,1], @run_time.to_f / 60.0, @nprocs.to_s, percent_complete, \"%\")\n if ctd and fusionQ\n beginning += sprintf(\"Q:%f, Pfusion:%f MW, Ti0:%f keV, Te0:%f keV, n0:%f x10^20\", fusionQ, pfus, ti0, te0, ne0)\n end\n beginning += \" ---#{@comment}\" if @comment\n beginning\n end", "def print_status\n super\n print_battle_commands unless battle_commands.empty?\n end", "def print_status\n super\n print_battle_commands unless battle_commands.empty?\n end", "def begin_of_line\n write_raw \"\\r\"\n end", "def print_status(string)\n\tputs \"[*] \".light_blue + \"#{string}\".white\nend", "def empty_line\r\n puts \"\\n\"\r\n end", "def blank\n print \"\\r\"\n if @last_print_msg\n print ' ' * IO.console.winsize[1]\n end\n print \"\\r\"\n end", "def put_line(line = nil)\n commit_status()\n puts line\n STDOUT.flush\n end", "def print_status(msg, color)\n cprint RESET + BOLD\n cprint WHITE + \"[ \"\n cprint \"#{ msg } \", color\n cprint WHITE + \"] \" + RESET\n end", "def print_status(msg, color)\n cprint RESET + BOLD\n cprint WHITE + \"[ \"\n cprint \"#{ msg } \", color\n cprint WHITE + \"] \" + RESET\n end", "def print_status(msg = '')\n $stderr.puts \"[*] #{msg}\"\n end", "def process_new_line\n @status.line += 1\n\n @skip_next = true if ((@cur_char == \"\\n\" && @next_char == \"\\r\") ||\n (@cur_char == \"\\r\" && @next_char == \"\\n\"))\n end", "def print_result_others(host, log_line, max_col_length)\n if log_line =~ /is running.../\n printf \"%-#{max_col_length}s %4s\\n\", host, \"[#{'OK'.green}]\"\n else\n printf \"%-#{max_col_length}s %4s\\n\", host, \"[#{'X'.red}]\"\n puts \" #{log_line}\".red\n end\n end", "def print_head\n system \"clear\"\n puts $line_break\n puts \"## ___ ___ ______________ __________ _________ ##\"\n puts \"## / _ )/ _ /_ __/_ __/ / / __/ __/ // / _/ _ \\\\ ##\"\n puts \"## / _ / __ |/ / / / / /__/ _/_\\\\ \\\\/ _ // // ___/ ##\"\n puts \"##/____/_/ |_/_/ /_/ /____/___/___/_//_/___/_/ ##\"\n puts \"## ##\"\n end", "def status_line\n @response_impl.status_line\n end", "def status\n if @check != nil\n check_status = %q{There is a check on the board:\n} + @check\n else\n check_status = \"There is no check on the board.\"\n end\n \n\n status = %q{The chess board and pieces:\n} + print_board(@board) + %q{ \nFields where white is attacking:\n} + print_board(@fields_where_white_attacks) + %q{ \nFields where black is attacking: \n} + print_board(@fields_where_black_attacks) + %q{\n} + check_status + %q{\n\n-- Next board --\n\n}\n end", "def throw_away_meaningless_line\n\t\tputs \"I have no idea what you are talking about\"\n\tend", "def say_status(message, status)\n message += '...'\n puts message + status.to_s.rjust((COLUMN_SIZE * COLUMN_NUM) - message.size)\nend", "def progress_line; end", "def status(str)\n if !Choice.choices[:quiet]\n print str\n STDOUT.flush\n end\nend", "def status\n output = StringIO.new\n output << @game.player.to_s\n output << \"\\n\"\n\n output << \"#{@game.current_room_model.description}\\n\"\n\n treasure = @game.current_room_model.treasure\n output << \"\\nThere is treasure here worth $#{treasure}.\\n\" if treasure && treasure > 0\n\n monster = @game.current_room_model.monster\n if monster\n output << \"\\nDANGER... THERE IS A MONSTER HERE....\\n\\n\"\n output << \"#{@game.current_room_model.monster}\\n\\n\"\n end\n\n if @game.current_room_model.name != \"Exit\"\n output << \"\\nWhat do you want to do? \"\n end\n \n output.string\n end", "def print_line(msg='')\n end", "def blank_line\n output \"\"\n end", "def display_status\n system('clear')\n\n puts \"#{player1.name}\\'s board:\".green\n player1.board.display\n\n puts \"\\n\\n#{player2.name}\\'s board:\".green\n player2.board.display\n\n if player1.board.count == 1\n puts \"\\n\\n#{player1.name} has #{player1.board.count} ship remaining\"\n else\n puts \"\\n\\n#{player1.name} has #{player1.board.count} ships remaining\"\n end\n\n if player2.board.count == 1\n puts \"#{player2.name} has #{player2.board.count} ship remaining\"\n else\n puts \"#{player2.name} has #{player2.board.count} ships remaining\"\n end\n end", "def clear_line; print \"\\e[2K\" end", "def print_status\n puts \"HP: #{hp}/#{max_hp}\"\n puts \"Attack: #{attack}\"\n puts \"Defense: #{defense}\"\n print \"\\n\"\n\n print \"Weapon: \"\n if (!@weapon.nil?)\n puts \"#{weapon.name}\"\n else\n puts \"none\"\n end\n\n print \"Helmet: \"\n if (!@helmet.nil?)\n puts \"#{helmet.name}\"\n else\n puts \"none\"\n end\n\n print \"\\n\"\n end", "def print_current_status\n print_guess_word_status = \"\"\n @guess_word_status.each do |letter|\n print_guess_word_status += \"#{letter} \"\n end\n puts \"\\nYou guessed #{@failed_attempts} times wrong so far. Remember, when reaching 10 you lose!\"\n puts \"Guess word status = #{print_guess_word_status}\"\n end", "def print_status(msg='')\n end", "def status(status_id)\n attrset Curses::A_REVERSE\n setpos 0, 0\n addstr ' ' * maxx\n text = Status.text(status_id)\n setpos 0, (maxx - text.length) / 2\n addstr text\n attrset(Curses::A_NORMAL)\n refresh\n end", "def last_line; end", "def last_line; end", "def last_line; end", "def last_line; end", "def last_line; end", "def last_line; end", "def last_line; end", "def clear_line!\n print \"\\r\\e[2K\"\n end", "def status_line(switch_on = true)\n if switch_on\n set_vars :_display_busy => 1, :_display_status => 1\n else # switch off\n set_vars :_display_busy => 0, :_display_status => 0\n end\n sleep 1\n exec 'redisplay;'\n end", "def print_result_rhel7(host, log_line, max_col_length)\n if log_line.split(' ')[1] == 'active'\n printf \"%-#{max_col_length}s %4s\\n\", host, \"[#{'OK'.green}]\"\n else\n printf \"%-#{max_col_length}s %4s\\n\", host, \"[#{'X'.red}]\"\n puts \" #{log_line.split(': ')[1]}\".red\n end\n end", "def print_status(game)\n cls\n\n puts game.version\n\n # Print the word with underscores instead of not guessed letters\n puts \"\\nWord: #{get_word_for_print(game.letters, game.good_letters)}\"\n # Print wrong letters separated with commas\n puts \"Mistakes: #{game.bad_letters.join(\", \")}\"\n\n # Print the image for the current number of made mistakes\n print_hangman(game.mistakes)\n\n if game.status == :lost\n # If player lost - print a message about it and show the word\n puts \"\\nGame over :(\"\n puts \"The word was: \" + game.letters.join(\"\")\n elsif game.status == :won\n # If player won - congratulate\n puts \"\\nYou won! Congratulations! :)\"\n else\n # If the game is not over, print the number of mistakes that are available to make\n if game.mistakes != 6\n puts \"You have left: #{game.mistakes_left} mistakes\"\n else\n puts \"You have left: 1 mistake. Be careful! \"\n end\n end\n end", "def status(text)\n STDERR.puts blue_term_text(text)\n end", "def draw_status_text\n draw_text(0, 0, contents_width, line_height, status_text, 1)\n end", "def status(player)\n puts player\n linebreak\n puts \"Dealer showing #{@dealer.hand.public_show}\"\n linebreak\n end", "def status\n output = \"\"\n\n output << \"You are dead!!!\"\n output << \"Game Over\"\n end", "def print_status\n puts \"HP: #{hp}/#{max_hp}\"\n puts \"Attack: #{attack}\"\n puts \"Defense: #{defense}\"\n print \"\\n\"\n\n print \"Weapon: \"\n if (!@outfit[:weapon].nil?)\n puts \"#{@outfit[:weapon].name}\"\n else\n puts \"none\"\n end\n\n print \"Helmet: \"\n if (!@outfit[:helmet].nil?)\n puts \"#{@outfit[:helmet].name}\"\n else\n puts \"none\"\n end\n\n print \"\\n\"\n end", "def now_serving(line)\n if line.length >= 1 \n puts \"Currently serving #{line.first}.\"\n line.shift\n else\n puts \"There is nobody waiting to be served!\"\nend\nend", "def status(msg = '')\n\t\toutput.print_status(msg)\n\tend", "def hline_top\n\tputs \"__________________________________________________________\"\nend", "def line\n puts \"########################################################\"\nend", "def empty_line\n end", "def at_line\n resume_pry\n end", "def print_status\n puts \"Stats:\"\n puts \"* HP: #{@stats[:hp]}/#{@stats[:max_hp]}\"\n puts \"* Attack: #{@stats[:attack]}\"\n puts \"* Defense: #{@stats[:defense]}\"\n puts \"* Agility: #{@stats[:agility]}\"\n print \"\\n\"\n\n puts \"Equipment:\"\n print \"* Weapon: \"\n puts @outfit[:weapon] ? \"#{@outfit[:weapon].name}\" : \"none\"\n\n print \"* Shield: \"\n puts @outfit[:shield] ? \"#{@outfit[:shield].name}\" : \"none\"\n\n print \"* Helmet: \"\n puts @outfit[:helmet] ? \"#{@outfit[:helmet].name}\" : \"none\"\n\n print \"* Torso: \"\n puts @outfit[:torso] ? \"#{@outfit[:torso].name}\" : \"none\"\n\n print \"* Legs: \"\n puts @outfit[:legs] ? \"#{@outfit[:legs].name}\" : \"none\"\n\n print \"\\n\"\n end", "def null_finish\n file.write(\"\\r\" + ' ' * @last_printed_length + \"\\r\")\n end", "def throw_away_meaningless_line\n puts \"I have no idea what you are talking about\"\n end", "def incomplete?\r\n ![BatchStatus::OUTPUT_READY, BatchStatus::OUTPUT_GENERATED, BatchStatus::OUTPUT_EXCEPTION].include?(status)\r\n end", "def print_error\n parts = @curr_blk.text.split('|')\n out = \"Line #{@curr_line}:\"\n\n case @curr_blk.validity\n when 1\n out += \" Could not parse line '#{@curr_blk.text}.\"\n when 2\n out += \" Invalid block number #{@curr_blk.number}, should be #{@curr_line}.\"\n when 3\n out += \" Could not parse transactions list '#{@curr_blk.text.split('|')[2]}'.\"\n when 4\n out += \" Invalid block, address #{@curr_wallet.address} has #{@curr_wallet.balance} billcoins!\"\n when 5\n out += \" Could not parse timestamp '#{@curr_blk.text.split('|')[3]}'.\"\n when 6\n out += \" Previous timestamp #{@p_s}.#{@p_ns} >= new timestamp #{@curr_blk.seconds}.#{@curr_blk.nseconds}.\"\n when 7\n h_string = @curr_blk.text.chomp('|' + parts[4])\n out += \" String '#{h_string}' hash set to #{parts[4]}, should be #{@curr_hash}.\"\n when 8\n out += \"Previous hash was #{parts[1]}, should be #{@p_h}.\"\n when 9\n out += \" Previous hash was #{parts[1]}, should be 4 characters or less.\" if parts[1].length > 4\n out += \" Block hash was #{parts[4]}, should be 4 characters or less.\" if parts[4].length > 4\n end\n\n puts out\n\n @curr_blk.validity\n end", "def status\n puts \"Player #{@playerNo}\".center(60)\n puts \"Name: #{@name}\".center(60)\n puts \"Class: #{@fightClass[:name]}\".center(60)\n puts \"Race: #{@race[:name]}\".center(60)\n puts \"HP: #{@hp}\".center(60)\n puts \"Level: #{@level}\".center(60)\n puts \"Actions: #{@actions.map(&:unCamelize).join(', ')}\".center(60)\n puts \"Attacks: #{@attacks.map(&:unCamelize).join(', ')}\".center(60)\n puts \"Inventory: #{@inventory.join(', ')}\".center(60)\n puts \"\"\n end", "def status_line\n # First line is 'Status-Line' from RFC2616 section 6.1\n # Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF\n # etc...\n return \"HTTP/#{version} #{status} #{reason}\"\n end", "def empty_line\n puts\" \" * 70\nend", "def clear_progress\n return unless show_progress\n print_no_newline(\"\\e[?25h\\e[2K\")\n @progress_msg = nil\n end", "def line(ppl)\n \n # If the line is empty...\n if ppl.length == 0\n\n # Tell us the line is empty.\n puts \"The line is currently empty.\"\n\n # If there are people in line... \n else\n crnt_ln = []\n \n ppl.each_with_index do |nm, ndx|\n ln = ndx + 1\n crnt_ln << \" #{ln}. #{nm}\"\n end\n \n crnt_ln.unshift(\"The line is currently:\")\n puts crnt_ln.join\n end\nend", "def check_unconsumed\n return if chunks.empty?\n $stderr.puts \"WARNING: line not consumed: #{@chunks}; (line: '#{@line}')\"\n end", "def render_status\n status.each do |st|\n puts \"#{st[:name]} (#{st[:id]})\"\n st[:nodes].each { |n| puts \" #{n[:name]} #{n[:condition]} #{n[:id]} #{n[:ip]}\" }\n puts '---'\n end\n\n nil\n end", "def line\n 1\n end", "def status()\n puts @status\n end", "def print_new_line\n puts ''\nend", "def clear_line\n print \"\\r%s\\r\" % ' ' * columns\n end", "def show\n \"\\t#{@line}: #{first_line}\"\n end", "def show_status\r\n puts \"Status for room #{id}:\"\r\n if @contents.empty?\r\n puts \" The room is empty.\"\r\n else\r\n puts \" Contents: #{sorted_contents.join(', ')}\"\r\n end\r\n if @exits.empty?\r\n puts \" No exits.\"\r\n else\r\n doors = []\r\n doors << 'north' if @exits[:north]\r\n doors << 'south' if @exits[:south]\r\n doors << 'east' if @exits[:east]\r\n doors << 'west' if @exits[:west]\r\n puts \" There are exits to the #{doors.join(', ')}.\"\r\n end\r\n end", "def prev_line; end", "def print_end_round\n print_separator_strong\n print_msg('round_complete')\n print_separator_strong\n end", "def game_status\n puts\n game_status_str = @game_status.join(' ')\n puts game_status_str\n end", "def ReportLine(line)\n Builtins.y2milestone(\"%1\", line)\n UI.ChangeWidget(Id(:log_view), :LastLine, Ops.add(line, \"\\n\"))\n\n nil\n end", "def printLine(env, shard, line, starttime, result)\n\n # write to the correct log\n @mutex.synchronize do\n @logs[shard].puts line\n end\n\n if line.include? 'ROLLBACK_IN_PROGRESS' or\n line.include? 'ROLLBACK_COMPLETE' or\n line.include? 'UPDATE_ROLLBACK_COMPLETE' or\n line.include? 'UPDATE_ROLLBACK_IN_PROGRESS'\n @mutex.synchronize do\n stackName = line[/^Stack [^ ]*/]\n if !result[FAILED].include? stackName\n result[FAILED] << stackName\n end\n endtime = Time.now\n time = \"#{'%.2f' % ((endtime - starttime)/60)} min\"\n puts \"[ #{time} ] #{env} #{shard} : #{line}\"\n end\n elsif line.include? 'UPDATE_COMPLETE' or\n line.include? 'CREATE_COMPLETE'\n @mutex.synchronize do\n stackName = line[/^Stack [^ ]*/]\n if !result[SUCCESS].include? stackName\n result[SUCCESS] << stackName\n end\n endtime = Time.now\n time = \"#{'%.2f' % ((endtime - starttime)/60)} min\"\n puts \"[ #{time} ] #{env} #{shard} : #{line}\"\n end\n elsif line.include? 'CREATE_IN_PROGRESS' or\n line.include? 'UPDATE_IN_PROGRESS'\n @mutex.synchronize do\n endtime = Time.now\n time = \"#{'%.2f' % ((endtime - starttime)/60)} min\"\n puts \"[ #{time} ] #{env} #{shard} : #{line}\"\n end\n end\nend", "def clear_line\n puts \"\\e[0A\\e[0G\"\n end", "def printable_status\n Statusable.printable(status)\n end", "def fresh_line?\n @content.empty? || @content[-1].eql?(NL)\n end", "def do_status\n return pretty_status(current_status)\n end", "def select_line\n buffer_current.select_current_line\n update_status_line\n end", "def print_status\n maze_copy = @maze\n @times_visited.each do |k, v|\n maze_copy[k] = \"V\" if v == 1\n maze_copy[k] = \"X\" if v == 2\n end\n maze_copy[@starting_position] = \"S\"\n maze_copy[@ending_position] = \"E\"\n maze_copy[@current_position] = \"R\"\n maze_copy.print_maze\n end", "def status_text\n if skipped?\n 'skipped'\n elsif error?\n 'error'\n else\n 'success'\n end\n end", "def print\n puts \"====== Pastes History ======\".green\n unless @links.empty?\n @links.each_with_index { |l, i| puts \"#{i+1}. #{l}\" }\n else\n puts \"your history is empty...\"\n end\n puts \"============================\".green\n end", "def status\n @command_history.last\n end", "def statuscmd\n end", "def draw_eol\n print \"\\r\\e[#{columns - 1}C#{V_SEP}\\n\"\n end" ]
[ "0.76561373", "0.73701465", "0.7199338", "0.68716294", "0.670236", "0.6658726", "0.6638777", "0.6451151", "0.6408656", "0.6394571", "0.63861805", "0.6381459", "0.63300073", "0.6328831", "0.63007075", "0.6243855", "0.6224607", "0.62158304", "0.62158304", "0.62118864", "0.6207083", "0.6200644", "0.61975944", "0.6195441", "0.61644155", "0.61644155", "0.6107785", "0.60924184", "0.6070211", "0.6061128", "0.6035534", "0.6019756", "0.6011411", "0.59958637", "0.5952693", "0.5946208", "0.5943384", "0.59280515", "0.5923595", "0.59160024", "0.5888481", "0.58867484", "0.5881407", "0.5874111", "0.58530587", "0.5835487", "0.5835487", "0.5835487", "0.5835487", "0.5835487", "0.5835487", "0.5835487", "0.5822122", "0.5815142", "0.58034605", "0.5789695", "0.5779592", "0.57681894", "0.5735107", "0.57277733", "0.5717999", "0.571513", "0.57127815", "0.5706445", "0.5701146", "0.57000726", "0.5696018", "0.5694651", "0.5674235", "0.56617004", "0.5660315", "0.5657988", "0.56548524", "0.5649872", "0.5649857", "0.564779", "0.5642034", "0.5641327", "0.5638184", "0.561571", "0.56147146", "0.56117475", "0.5598057", "0.55971235", "0.5594794", "0.55936706", "0.558669", "0.558045", "0.55792713", "0.55630106", "0.5557999", "0.55505496", "0.55492723", "0.5549025", "0.55419266", "0.55339813", "0.55320567", "0.5505069", "0.54980326", "0.54941523", "0.5493815" ]
0.0
-1
Fetch the size of an url
def fetch_filesize(url) uri = URI.parse(url) header = { 'User-Agent' => "A tiny script in ruby to analyse your videos :) - But don't worry a user is also there.", } h = Net::HTTP.new uri.host, uri.port getfile = uri.path getfile << '?' << uri.query if not uri.query.nil? res = h.request_head(getfile, header) # If this is only a redirect follow it return fetch_filesize(res['location']) if res.key? 'location' res.content_length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def content_size(url)\n Rails.cache.fetch(\"/content_size/#{url}\", expires_in: 10.minutes) do\n begin\n meta = meta_file(url)\n size_text = meta.xpath(\"//m:metalink//m:file//m:size[1]//text()\", 'm' => 'urn:ietf:params:xml:ns:metalink')\n size = Integer(size_text.to_s)\n size\n rescue OpenURI::HTTPError, RuntimeError\n # This is actualy gibibytes, not gigabytes\n return 5.gigabytes\n end\n end\n end", "def size\n @fetcher.size\n end", "def size\n easy = Curl::Easy.new\n easy.url = self.uri + \"/size\"\n easy.http_get\n\n raise(SesameException.new(easy.body_str)) unless easy.response_code == 200\n\n easy.body_str.to_i\n end", "def fetch_size(uri)\n return File.size(get_file_uri_path(uri)) if file_uri? uri\n\n uri = URI.parse uri unless URI::Generic === uri\n\n raise ArgumentError, 'uri is not an HTTP URI' unless URI::HTTP === uri\n\n http = connect_to uri.host, uri.port\n\n request = Net::HTTP::Head.new uri.request_uri\n\n request.basic_auth unescape(uri.user), unescape(uri.password) unless\n uri.user.nil? or uri.user.empty?\n\n resp = http.request request\n\n if resp.code !~ /^2/ then\n raise Gem::RemoteSourceException,\n \"HTTP Response #{resp.code} fetching #{uri}\"\n end\n\n if resp['content-length'] then\n return resp['content-length'].to_i\n else\n resp = http.get uri.request_uri\n return resp.body.size\n end\n\n rescue SocketError, SystemCallError, Timeout::Error => e\n raise FetchError, \"#{e.message} (#{e.class})\\n\\tgetting size of #{uri}\"\n end", "def size(path)\n response = with_remote do |http|\n http.head(path)\n end\n response['Content-Length'].to_i\n end", "def remote_size\n response = http_downloader.head(image_url)\n return nil unless response.status == 200 && response.content_length.present?\n\n response.content_length.to_i\n end", "def read_size(uri)\n return File.size(get_file_uri_path(uri)) if is_file_uri(uri)\n \n require 'net/http'\n require 'uri'\n u = URI.parse(uri)\n http = connect_to(u.host, u.port)\n path = (u.path == \"\") ? \"/\" : u.path\n resp = http.head(path)\n fail RemoteSourceException, \"HTTP Response #{resp.code}\" if resp.code !~ /^2/\n resp['content-length'].to_i\n end", "def size\n execute_request(:get, '/size').body.to_i\n end", "def get_file_size(options)\n url = options.fetch(:url)\n headers = options.fetch(:headers)\n file_size = options.fetch(:file_size)\n\n case url.scheme\n when 'file'\n File.size(url.path)\n when /https?/\n response = Typhoeus.head(url.to_s, headers: headers)\n length_value = response.headers['Content-Length'] || file_size\n length_value.to_i\n else\n raise URI::BadURIError, \"Unknown URI scheme: #{url.scheme}\"\n end\n end", "def get_size(path)\n read_size(@uri + path)\n end", "def remote_size\n return @remote_size if defined?(@remote_size)\n @remote_size = http_head['Content-Length'].to_i\n end", "def get_url photo\n response = HTTParty.get('https://api.flickr.com/services/rest/?method=flickr.photos.getSizes&api_key=' + KEY + '&format=json&nojsoncallback=1&photo_id=' + photo[\n \"id\"], format: :plain)\n\n data = JSON.parse response\n\n data[\"sizes\"][\"size\"]\n end", "def content_length\n stat.size\n end", "def size\n @heads['content-length'] || @size.to_s\n end", "def num_urls\n @client[:urls].count\n end", "def get_bytes_for_image(src)\n begin\n uri = URI.parse src\n req = Net::HTTP.new(uri.host, 80)\n resp = req.request_head(uri.path)\n\n if resp.content_type.include?(\"image\")\n return resp.content_length\n end\n rescue\n log \"Error getting image size for #{src} - #{$!}\"\n end\n\n return 0\n end", "def size\n headers[\"content-length\"].to_i\n end", "def determine_download_size(server, pdf)\n real_location = ''\n Net::HTTP.start(server, 80) do |http|\n # Send a HEAD request\n response = http.head(pdf) \n # Get the real location\n real_location = response['Location']\n end \n m = real_location.match(/http:\\/\\/(.*?)(\\/.*)/)\n real_server = m[1]\n real_pdf = m[2]\n Net::HTTP.start(real_server, 80) do |http|\n # Send a HEAD request\n resp = http.head(real_pdf)\n\n return nil if resp.kind_of?(Net::HTTPServerError) || resp.kind_of?(Net::HTTPClientError) \n \n bytes = resp['Content-Length'].to_i\n return bytes\n end\n end", "def size\n content.size\n end", "def size\n headers[:content_length].to_i\n end", "def num_urls\n @client[URLS_COLLECTION].count\n end", "def size\n @content.size\n end", "def size\n stats[:html]\n end", "def size\n get.size\n end", "def size\n info[\"size\"]\n end", "def size\n @info[:size]\n end", "def size\n @size ||= @request[FSIZE].to_i\n end", "def size\n\t\tstat[:size]\n\tend", "def size\n\t\tstat[:size]\n\tend", "def check_size\n c = HTTPClient.new\n ##\n # The downloaded page size\n ##\n #comp_get = c.head(@server.url)\n #byebug\n #compressed_page = comp_get.headers[\"Content-Length\"].to_i if comp_get.status == 200\n @result.passed(\"HTML: Page size #{@server.response.data.length.to_human} \") # (#{compressed_page.to_human} compressed)\")\n\n ##\n # Use this base\n ##\n base = URI.parse(\"#{@server.url.scheme}://#{@server.url.host}\")\n\n ## \n # Sum the Javascript scripts\n # Note: Need to take into account Google Analytics building a script tag that\n # this static analysis doesn't consider\n ##\n js_length = @server.response.doc.xpath('//script/@src').inject(0) do |sum, src| \n res = base.merge(URI.parse(src))\n sum + c.head(res.to_s).headers[\"Content-Length\"].to_i\n end\n\n ## This will produce incorrect results if the server doesn't support gz\n cjs_length = @server.response.doc.xpath('//script/@src').inject(0) do |sum, src| \n res = base.merge(URI.parse(src))\n sum + c.head(res.to_s + \".gz\").headers[\"Content-Length\"].to_i\n end\n @result.passed(\"HTML: Javascript size #{js_length.to_human} (Compressed: #{cjs_length.to_human})\")\n\n ##\n # Sum the CSS\n ##\n cs_length = @server.response.doc.xpath('//link/@href').select{|s| s.value[/css$/]}.inject(0) do |sum, src| \n res = base.merge(URI.parse(src))\n sum + c.head(res.to_s).headers[\"Content-Length\"].to_i\n end\n ccs_length = @server.response.doc.xpath('//link/@href').select{|s| s.value[/css$/]}.inject(0) do |sum, src| \n res = base.merge(URI.parse(src))\n sum + c.head(res.to_s + \".gz\").headers[\"Content-Length\"].to_i\n end\n @result.passed(\"HTML: Style size #{cs_length.to_human}\")\n end", "def remote_size\n @remote_size ||= request_object_size\n end", "def get_size\n\t\tend", "def size\n @list_link.size\n end", "def size\n @list_link.size\n end", "def size\n contents.size\n end", "def path_size (path)\n if Dir.exist? path\n o, e, s = Open3.capture3('du', '-s', '-b', path)\n o.split('/')[0].to_i\n end\n end", "def get_size\n return @content_objects.count\n end", "def image_size_sufficient(uri)\n # see lib/shared/shared_utilities for this customzation of Net::HTTP\n body, new_location = Net::HTTP.get_with_timeout_redirect(uri, 2) # second argument is the timeout in seconds\n if !body.nil?\n # TODO: replace Net::HTTP with http://github.com/taf2/curb/tree/master if speed is required.\n if body.size >= Nfwyd::Constants::MIN_IMAGE_SIZE # in bytes, so 10KB minimum\n return body.size, new_location\n end\n else\n log_it :info, \"got no content trying to download image=#{uri}\\n should happend occasionally. Throwing away image\"\n end\n return nil, nil\n end", "def getcontentlength\n 0\n end", "def size\n @content.bytesize\n end", "def size(full_path)\n\t\t`du -s #{Rush.quote(full_path)}`.match(/(\\d+)/)[1].to_i\n\tend", "def extract_size(io)\n io.size\n end", "def content_length; end", "def content_length; end", "def content_length; end", "def size\n File.new(self.server_path).size\n end", "def size\n\n fetch_all(:count => true)\n end", "def size(key)\n @backend.respond_to?(:_size) and return @backend._size(domain, key)\n paths = get_paths(key) or return nil\n paths_size(paths)\n end", "def get_file_size\n file = Storage.get_file(ENV['AWS_S3_DIR_PAGES'], self.issue_id, self.filename )\n return file.content_length\n end", "def get_size\n img_sizes = flickr.photos.getSizes(photo_id: @info['id']).to_a\n img = img_sizes.last\n\n # Loop down through images until appropriate sized one is found\n (img_sizes.length-2).downto(0) do |i|\n if img_sizes[i]['height'].to_i < 1000 || img_sizes[i]['width'].to_i < 1600\n img = img_sizes[i+1]\n break\n end\n end\n\n @source = img['source']\n @page = img['url']\n @height = img['height']\n @width = img['width']\n end", "def size\n return unless rels_int\n content_ds = Nokogiri::XML(rels_int.content.to_s)\n .at_xpath(\"rdf:RDF/rdf:Description[@rdf:about='info:fedora/#{pid}/content']\")\n return unless content_ds\n size = content_ds.at_xpath('//dc:extent', dc: 'http://purl.org/dc/terms/')\n return unless size\n size.text.to_i\n end", "def size(full_path)\n\t\t`du -sb #{full_path}`.match(/(\\d+)/)[1].to_i\n\tend", "def pagination_size(headers)\n if headers.key?('link')\n links = headers.fetch('link') \\\n .scan(/<(.*?)>/).flatten\n\n links.last.split('=').last.to_i\n else\n 1\n end\n end", "def size\n\t\treturn 0 if @setup.secure or @setup['no_cache'] or not FileTest::exist?( @setup['cache_path'] )\n\n\t\tFileTest.size( @setup['cache_path'] )\n\tend", "def size ; data['size'] ; end", "def size\n @size \n end", "def size\n @size \n end", "def size\n @gapi[\"size\"]\n end", "def content_length\n# stat.size\n @bson['length'] || 0\n end", "def size\n read.bytesize\n end", "def content_length\n @resource.content_length\n end", "def size\r\n @contents.size\r\n end", "def size\n @info.size\n end", "def size\n @info.size\n end", "def size\n @info.size\n end", "def _size(domain, key)\n dmid = get_dmid(domain)\n\n sql = <<-EOS\n SELECT length FROM file\n WHERE dmid = #{dmid} AND dkey = '#{@my.quote(key)}'\n LIMIT 1\n EOS\n\n res = query(sql).fetch_row\n return res[0].to_i if res && res[0]\n raise MogileFS::Backend::UnknownKeyError\n end", "def file_size\n stream.size\n end", "def get_size\n\t\treturn @size\n\tend", "def size\n @contents.bytes.size\n end", "def get_size(path)\n file = scope.get(path)\n InvalidPath.raise! {!file}\n return 0 if file.is_dir\n file.info[:size]\n end", "def size\n Integer(metadata[\"size\"]) if metadata[\"size\"]\n end", "def size\n @raw_page['totalSize'] || @raw_page['size']\n end", "def size\n @result.size\n end", "def loads_size\n @loads_size ||= @loads_on_page.map(&:object_id).size\n # @loads_on_page.size\n end", "def size\n @size.size\n end", "def size()\n @contents.size\n end", "def size\n return instance_get(:size)\n end", "def size\n blob.size\n end", "def length\n @content.length\n end", "def size\n File.size( fullpath )\n end", "def size\n stream_size * 8\n end", "def filesize; end", "def size\n size = popen(%W(du -s), full_path).first.strip.to_i\n (size.to_f / 1024).round(2)\n end", "def size()\n @requests.length\n end", "def decompressed_size; end", "def get_page_size(title)\n page_info_get_val(title, 'length')\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end", "def size\n @size\n end" ]
[ "0.81279415", "0.78865814", "0.7780762", "0.77487236", "0.76869905", "0.76749206", "0.7631035", "0.75966054", "0.7353377", "0.72136194", "0.7048881", "0.693597", "0.6932003", "0.69188637", "0.6882509", "0.68779504", "0.6874736", "0.68506676", "0.6802141", "0.6795249", "0.6780379", "0.67554706", "0.67372054", "0.67018193", "0.6691826", "0.66629636", "0.66424876", "0.66350806", "0.66350806", "0.6633978", "0.6614694", "0.6596347", "0.6577059", "0.6577059", "0.6559937", "0.6555071", "0.653417", "0.65282404", "0.6524952", "0.6519429", "0.651783", "0.6491618", "0.6491586", "0.6491586", "0.6491586", "0.6484378", "0.6482092", "0.6479046", "0.6478485", "0.647742", "0.6471488", "0.6461027", "0.64339936", "0.64121467", "0.640544", "0.6398125", "0.6398125", "0.6396327", "0.6370629", "0.6365015", "0.6346541", "0.6338913", "0.63285005", "0.63285005", "0.63285005", "0.63221127", "0.6305795", "0.6288331", "0.62846357", "0.6274804", "0.627421", "0.62544876", "0.6252307", "0.62500924", "0.62352985", "0.6227228", "0.62164783", "0.6211039", "0.6209914", "0.62097216", "0.62055355", "0.6197994", "0.61881036", "0.6186412", "0.6183688", "0.6173641", "0.6171693", "0.6171693", "0.6171693", "0.6171693", "0.6171693", "0.6171693", "0.6171693", "0.6171693", "0.6171693", "0.6171693", "0.6171693", "0.6171693", "0.6171693", "0.6171693" ]
0.81690514
0
Doing everything to fetch the video to the HDD (Don't look at this if you are easyly confusable.)
def download_file(url, filename, start = 0) # Define some default values uri = URI.parse(url) len = start size = start perc = 0 header = { 'User-Agent' => "A tiny script in ruby to fetch your videos :) - But don't worry a user is also there.", } header['Range'] = "bytes=#{start}-" if start > 0 start = DateTime.now.strftime('%s').to_i begin # Open the target file File.open(filename, 'a') do |file| # Start the download h = Net::HTTP.new uri.host, uri.port getfile = uri.path getfile << '?' << uri.query if not uri.query.nil? h.request_get(getfile, header) do |r| # If there is a redirect header follow it and continue downloading there return download_file(r['location'], filename) if r.key? 'location' # Read the download size len = len + r.content_length if not r.content_length.nil? r.read_body do |s| # Write the downloded part to the file file.write s if not /2[0-9][0-9]/.match(r.code).nil? file.flush # Calculate downloaded size size = size + s.length len = size if r.content_length.nil? # Do some calculations for the nice status line perc = (size.to_f / len.to_f * 100).to_i if len > 0 lines = (perc / 4).to_i timegone = DateTime.now.strftime('%s').to_i - start bps = size.to_f / timegone.to_f sleft = ((len - size).to_f / bps).to_i print_line "DL: #{filename} - [#{'=' * lines}#{' ' * (25 - lines)}] #{perc}% (#{transform_byte(size)} / #{transform_byte(len)}) ETA: #{transform_secs(sleft)}" end end end rescue Exception => ex if @debug print_line "\a\a\a" << ex.message sleep 2 end if ex.message.include? 'Interupt' print_line "You interupted me. Skipping this file..." return end # Something went wrong? Simply try again... (Hope the user want this to...) print_line "Connection failture. Trying again..." return download_file(url, filename, size) end # Finished but did not got everything? Should not happen. Try to get the rest if size < len return download_file(url, filename, size) end # Tell the user that we are done :) print_line "Completed. See your file at #{filename}" puts end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_video\n\t\t# preview_video_url = \"https://video.tvspielfilm.de/ivideo/video/10/9700610_1.mp4\"\n\n\t\tif preview_video_url.present?\t\n\t\t\tfilename = Pathname.new(preview_video_url).basename\n\t\t\tfilename = filename.to_s rescue \"#{Time.now.to_i}.mp4\"\n\t\t\t\n\t\t\tfilename = \"#{id}_#{filename}\"\n\n\t\t\tnew_file_path = \"#{Rails.root.to_s}/public/videos/#{filename}\"\n\t\t\topen(new_file_path, \"wb\") do |file| \n\t\t\t file.print open(preview_video_url).read\n\t\t\tend\n\t\t\tupload_video_at_s3(filename, new_file_path) \n\t\tend\n\tend", "def save_external_video_locally\n #self.save_file_locally\n end", "def fetch_video\n \t @video=UnvlogIt.new(url)\n \t self.embed_url=@video.embed_html(300, 169)\n \t self.thumb_url=@video.thumbnail\n end", "def download\n get_metadata\n check_prog_id\n generate_filename\n download_stream\n ffmpeg\n tag\n cleanup\n end", "def download_all_videos_from_pl id,d_name\n\tmy_directory = \"#{@dir}#{d_name}\"\n\n\t videos_already_saved_array = get_all_titles_from_dir my_directory\n\n\t videos_already_saved_titles, videos_already_saved_paths = \n\t \t\t\t\t\tvideos_already_saved_array.map{|e| e[0]}, videos_already_saved_array.map{|e| e[2]}\n\n\t@current_playlist_video_titles.each do |v|\n\t\t\tsource = 'youtube'\n\t\t\tindex = @current_playlist_video_titles.index(v)\n\t\t\tp index\n\t\t\tvid = @current_playlist_video_ids[index]\n\t\t\tp vid\n\n\t\tif !videos_already_saved_titles.include?(v)\t\n\t\t\t\n\t\t\tvideo_string = \"http://www.youtube.com/watch?v=#{vid}\"\n\t\t\tdownload_video = \"viddl-rb #{video_string} -d 'aria2c' -s '#{my_directory}'\"\n\n\t\t\tcaptured_stdout = ''\n\t\t\tcaptured_stderr = ''\n\t\t\tstdin, stdout, stderr, wait_thr = Open3.popen3(\"#{download_video}\")\n\t\t\tpid = wait_thr.pid\n\t\t\tstdin.close\n\t\t\tcaptured_stdout = stdout.gets(nil)\n\t\t\taborted = captured_stdout.include? \"Download aborted\"\n \t\t\t# captured_stderr = stderr.read\n\t\t\twait_thr.value # Process::Status object returned\n\n\t# extract the info we need\n\t\t\tputs \"STDOUT: \" + captured_stdout\n\t\t\t# puts \"STDERR: \" + captured_stderr\n\n\t\t\t# go to Vimeo to download if it doesnt work\n\t\t\tif aborted\n\t\t\t\tartist_match_results = match_best v, @rule_artists\n\t\t\t\t@song_artist = artist_match_results[0]\n\t\t\t\tremaining_words = artist_match_results[1]\n\t\t\t\tsong_match_results = match_best remaining_words, @rule_titles\n\t\t\t\t@song_title = song_match_results[0]\n\n\t\t\t\tsource='vimeo'\n\t\t\t\tget_vimeo_manually @song_artist,@song_title,@mydir,\"vimeo\"\n\t\t\t\t# Process.kill(\"KILL\", stream.pid)\n\t\t\t\t# get_vimeo_manually v,my_directory,source \n\t\t\tend\n\n\t\t\tp \"already have it\" if videos_already_saved_titles.include?(v)\n\t\tend\n\n\n\tend\n\n\t\nend", "def getVideoURL\n if (request.post?)\n cVideoID = self.findKeyInJSON(params[:params], \"VideoID\", 2)\n cOS = self.findKeyInJSON(params[:params], \"OS\", 2)\n \n case cOS.to_s\n when \"100\"\n # We have that file stored in S3 yet?\n # Check it later!\n # Just hard-code it\n returnFileName = \"http://ec2-50-112-145-58.us-west-2.compute.amazonaws.com:1935/vods3/_definst_/mp4:s3/\"\n returnFileName += cVideoID + \".mov\"\n returnFileName += \"/playlist.m3u8\"\n when \"101\"\n # android\n returnFileName = \"rtsp://ec2-50-112-145-58.us-west-2.compute.amazonaws.com:1935/vod/_definst_/mp4:s3/\"\n returnFileName += cVideoID + \".mov\"\n else\n # ignore\n end\n \n # Update Video Played Count\n begin\n b = Videotemp.find(cVideoID)\n if(b.playedCount == nil || b.playedCount == '')\n playedCount = 1\n else\n playedCount = b.playedCount\n playedCount = playedCount.to_i + 1\n end\n b.playedCount = playedCount.to_i\n b.save\n rescue Exception => e\n # ignore\n end\n \n # Return JSON response\n cRequestID = self.findKeyInJSON(params[:params], \"RequestID\", 1)\n rData = {\"VideoStreamUrl\" => returnFileName}\n self.jsonRender(rData, 'WOWZA URL', cRequestID, '100')\n end\n end", "def download\n @video = Video.find(params[:id])\n send_file(RAILS_ROOT+\"/public\"+@video.video.url.split(\"?\")[0], :disposition => 'inline', :stream => false)\n end", "def take\n check\n `adb pull /dev/graphics/fb0 fb0`\n `dd bs=1920 count=800 if=fb0 of=fb0b`\n `ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb565 -s 480x800 -i fb0 -f image2 -vcodec png #{@destination_folder}/#{@prefix}#{@no}.png`\n `rm fb0b`\n end", "def queue_video(file)\n if video?(file) or contains_any?(file, :avi, :mpg, :mkv, :rm, :mp4)\n puts ''\n puts file\n local = \"/Volumes/Samba/clamps/\"\n dir = prompt_for_path(local)\n \n remote_path = \"#{ REMOTE_VIDEO_PATH }#{ dir[local.length, dir.length] }#{ Pathname.new(file).basename }\"\n QUEUE << [ file, remote_path ]\n end\nend", "def downloaded_video_path\n \"/songs/#{self.id}.mpg\"\n end", "def stream\n\t\tvideo = Video.find(params[:id])\n\n\t\tif video.file.attached?\n\t\t\tfile_path = ActiveStorage::Blob.service.send(:path_for, video.file.blob.key)\n\t\t\tfile_type = video.file.content_type\n\t\telse\n\t\t\tfile_path = Rails.root.to_s + \"/public/defaultVideo.mp4\"\n\t\t\tfile_type = \"video/mp4\"\n\t\tend\n\n\t\t# rails doesnt support file partial requests by default\n\t\t# gem: send_file_with_range\n\t\tsend_file(\n\t\t\tfile_path,\n\t\t\trange: true,\n\t\t\tbuffer_size: 500_000,\n\t\t\tdisposition: \"inline\",\n\t\t\ttype: file_type)\n\tend", "def download_stream\n\n #Read the AIS data from C4. This gives the info required to get the flv via rtmpdump\n doc = download_ais(@mp4_program_id)\n\n #Parse it - the inspiration for this comes from http://code.google.com/p/nibor-xbmc-repo/ too.\n token = (doc/\"//token\").text\n epid = (doc/\"//e\").text\n cdn = (doc/\"//cdn\").text\n streamUri = (doc/\"//streamuri\").text\n decoded_token = decode_token(token)\n\n if cdn == 'll'\n file = streamUri.split(\"/e1/\")[1]\n out_file = file.split(\"/\")[1].gsub(\".mp4\",\".flv\")\n auth = \"e=#{epid}&h=#{decoded_token}\"\n\n rtmpUrl = \"rtmpe://ll.securestream.channel4.com/a4174/e1\"\n app = \"a4174/e1\"\n playpath = \"/#{file}?#{auth}\"\n\n else\n file = streamUri.split(\"/4oD/\")[1]\n fingerprint = (doc/\"//fingerprint\").text\n slist = (doc/\"//slist\").text\n auth = \"auth=#{decoded_token}&aifp=#{fingerprint}&slist=#{slist}\"\n\n rtmpUrl = streamUri.match('(.*?)mp4:')[1].gsub(\".com/\",\".com:1935/\")\n rtmpUrl += \"?ovpfv=1.1&\" + auth\n\n app = streamUri.match('.com/(.*?)mp4:')[1]\n app += \"?ovpfv=1.1&\" + auth\n\n playpath = streamUri.match('.*?(mp4:.*)')[1]\n playpath += \"?\" + auth\n\n end\n\n @log.debug \"rtmpUrl: #{rtmpUrl} app: #{app} playpath: #{playpath}\"\n\n #build rtmpdump command\n command = \"rtmpdump --rtmp \\\"#{rtmpUrl}\\\" \"\n command += \"--app \\\"#{app}\\\" \"\n command += \"--playpath \\\"#{playpath}\\\" \"\n command += \"-o \\\"#{@out_file}.flv\\\" \"\n command += '-C O:1 -C O:0 '\n command += '--flashVer \"WIN 10,3,183,7\" '\n command += '--swfVfy \"http://www.channel4.com/static/programmes/asset/flash/swf/4odplayer-11.35.swf\" '\n @log.debug command\n\n @log.info \"Downloading file for Program ID #{@mp4_program_id} - saving to #{@out_file}.flv\"\n success = system(command)\n\n if not success\n raise \"Something went wrong running rtmpdump :(. Your file may not have downloaded.\"\n end\n\n @log.info \"Download complete.\"\n\n end", "def show; @video.show; end", "def convert_video_to_AVI(filename, path, content, url)\n logger.debug \"Convert the video ( #{filename} ) path ( #{path}) from content type of #{content} to H264\"\n File.new(File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.avi\"), File::CREAT | File::TRUNC| File::RDWR, 0644)\n videoavi = File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.avi\")\n system(\"ffmpeg -i #{url} -acodec copy -vcodec copy #{videoavi} -y\")\n return videoavi\n end", "def addWebCam()\n pathToWebcam = \"#{$PATHTOPUBLISHED}/#{@meetingData.meetingId}/video/webcams.webm\"\n pathToIntermediates= \"#{$PATHTOGENERATEINTERMEDIATES}/#{@meetingData.meetingId}\"\n\n # resize the webcam video\n puts \" Resizing webcam recording \"\n system \"ffmpeg -i #{pathToWebcam} -vcodec libx264 -vf scale=200:-1 #{pathToIntermediates}/webcamResized.mp4 -loglevel quiet\"\n \n # create a directory to store the final video(inside the published)\n pathToCompleteRecording=\"#{$PATHTOPUBLISHED}/#{@meetingData.meetingId}/completeVideo\"\n createDirectoryIfNotExists(pathToCompleteRecording)\n\n puts \"Adding webcam into final video\"\n #merge it with the presentation+deskshare video\n system \"ffmpeg -i #{pathToIntermediates}/output.mp4 -i #{pathToIntermediates}/webcamResized.mp4 -filter_complex \\' overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-10 \\' #{pathToCompleteRecording}/finalcut.mp4 -loglevel quiet\"\n end", "def create \n @video = Video.new() #get the attachemnt and create a video object with it\n\n if @video.save #if it saves then get the urll\n @video.create_url(params[:filepath]) \n\n if signed_in? #if the user is signed in add the video to their account\n current_user.videos << @video \n\n else #if they arent't uses sessions and a delete key\n @video.session_id = SecureRandom.urlsafe_base64(15) \n @video.delete_key = SecureRandom.urlsafe_base64(30) \n session[:owned_videos] ||= [] #if the current session doesn't have any owned_videos then create the array\n session[:owned_videos] << @video.session_id #add videos session id to array\n end\n\n @video.save \n send_to_heywatch @video\n render json: {url: \"/videos/#{@video.id}\"}\n else #error saving the video take them back to try again TODO show errors\n redirect_to \"/\"\n \n end\n end", "def download(filename = nil)\n self.get_info\n return nil if @deleted\n resp = nil\n Net::HTTP.start('www.nicovideo.jp') do |http|\n resp = http.get('/watch/' + @video_id,\n {'Cookie' => 'user_session=' + @user_session.session_id})\n end\n adc = {}\n resp.each do |k, v|\n if k.downcase == 'set-cookie'\n z = v.split(';')\n z.map!{|cp| cp.gsub(/(^ +)|( +$)/, '')}\n hsh = {}\n z.each do |ckchr|\n ckchra = ckchr.split('=', 2)\n hsh[ckchra[0]] = ckchra[1]\n end\n hsh.each do |nk, nv|\n adc[nk] = nv unless ['expires', 'path', 'domain', 'secure'].include?(nk)\n end\n end\n end\n movie_url = access_getflv_api['url'][0]\n return if movie_url == nil\n resp3 = nil\n huri = URI.parse(movie_url)\n cks = {'user_session' => @user_session.session_id}.merge(adc)\n ckarr = []\n cks.each do |ckk, ckv|\n ckarr.push(ckk + '=' + ckv)\n end\n ckstr = ckarr.join('; ')\n Net::HTTP.start(huri.host) do |http|\n resp3 = http.get(huri.request_uri, {'Cookie' => ckstr})\n end\n return unless resp3.code.to_i == 200\n if filename == nil\n return resp3.body\n elsif filename.respond_to?(:write)\n filename.write(resp3.body)\n else\n File.open(filename, 'wb') do |file|\n file.write resp3.body\n end\n end\n end", "def get_datas\n tnurl=\"/images/no-image.jpg\"\n if self.source_url.match(/(youtube.com*)/)\n vid=self.source_url.match(/=([A-Za-z0-9]*)/) ? self.source_url.match(/=([A-Za-z0-9\\d_\\-]*)/)[0].gsub(/=/,'') : self.source_url\n unless vid.blank?\n \n client=YouTubeIt::Client.new(:dev_key => YOUTUBE_API_KEY)\n \n \n begin\n youtube_data=client.video_by(vid)\n rescue\n youtube_data=nil\n self.errors.add(:source_url, \"Invalid video url, removed from youtube\")\n self.source_url=nil\n end \n \n \n unless youtube_data.nil? \n self.title= self.title.blank? ? youtube_data.title : self.title\n self.description= self.description.blank? ? youtube_data.description : self.description\n tnurl=youtube_data.thumbnails[0].url\n self.media_content_url=youtube_data.media_content[0].url\n end\n end\n self.provider=\"youtube\"\n elsif self.source_url.match(/(vimeo.com*)/)\n tnurl='/images/video/vimeo.png' \n vid=self.source_url.match(/vimeo.com\\/([^&]+)/)[1]\n unless vid.blank?\n vimeo_data=Vimeo::Simple::Video.info(vid)\n if vimeo_data && vimeo_data.size>0\n tnurl=vimeo_data[0][\"thumbnail_medium\"]\n self.title= self.title.blank? ? vimeo_data[0][\"title\"] : self.title\n self.description= self.description.blank? ? vimeo_data[0][\"description\"] : self.description\n end\n end\n\n #self.media_content_url=\"/videos/#{self.id}\"\n\n\n self.media_content_url=\"http://www.vimeo.com/moogaloop.swf?clip_id=#{vid}&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=\"\n self.provider=\"vimeo\"\n elsif self.source_url.match(/(dailymotion.com*)/)\n self.provider=\"dailymotion\" \n tnurl='/images/video/dailymotion.png' \n elsif self.source_url.match(/(myspace.com*)/)\n self.provider=\"myspace\" \n tnurl='/images/video/myspace.png' \n end\n\n self.thumbnail_url=tnurl\n\n\n end", "def http_test_3\n File.open('http_test_3.mp4', 'wb') do |f|\n f.write RestClient.get(URL)\n end\nend", "def http_test_4\n Net::HTTP.start('download.openbricks.org') do |http|\n f = File.open('http_test_4.mp4', 'wb')\n begin\n http.request_get('/sample/H2645/big_buck_bunny_480p_H264_AAC_25fps_1800K.MP4') do |resp|\n resp.read_body do |segment|\n f.write segment\n end\n end\n ensure\n f.close\n end\n end\nend", "def path_to_video(source, options = T.unsafe(nil)); end", "def show\n @video = Video.find(params[:id])\n @profesor = @video.profesor\n @observador = @video.observador\n delete_key = @video.attach_file_name\n end", "def viddler_files(viddler_id, episode_id)\n # @viddler ||= Viddler::Client.new(viddler_id)\n @viddler = Viddler::Client.new(viddler_id)\n # traceout(\"instantiate viddler wtih #{viddler_id}\")\n # puts @viddler.inspect\n @viddler.authenticate! ENV['VIDDLER_USER'], ENV['VIDDLER_PASSWORD']\n videoData = @viddler.get 'viddler.videos.getDetails', :video_id => \"#{episode_id}\"\n # traceout(videoData)\n return videoData\n end", "def videos_test\n end", "def video\n \"#{self.video_file_name}\"\n end", "def fetch_video_o_url(id:)\n require 'typhoeus'\n auth_url = 'https://www.flickr.com/video_download.gne?id=' + id\n dl_url = nil\n request = Typhoeus::Request.new(auth_url, headers: {Cookie: @config['cookie']})\n request.on_complete do |response|\n dl_url = response.headers['location']\n end\n request.run\n return dl_url\n end", "def show_video\n\t\t@video = OldFlashFile.find(params[:id]) \n\t\tif @video\n\t\t@status=request.protocol+request.host_with_port+@video.video.url\n\t\telse\n\t\t@status = {\"status-msg\"=>\"Video not exist\"}\n\t\tend\n\n render :json =>@status.to_json\n\t\tend", "def streaming_video_url\n # TODO figure out how to remove the need for this stupid hack\n # paperclip adds the cache buster to the URL automatically, I need\n # it to go away, probably a really easy paperclip option, but not\n # finding it at the moment.\n unless streaming_video.nil?\n streaming_video.data.url.split(\"?\")[0]\n else\n nil\n end\n end", "def video_url\n \"http://video.ted.com/#{videoID}\"\n end", "def upload(file)\n logger.info 'Downloading video...'\n path = file.download.path\n movie = FFMPEG::Movie.new(path)\n @mp4_path = encode('mp4', movie, '-vcodec libx264 -strict -2')\n @webm_path = encode('webm', movie, '-vcodec libvpx -acodec libvorbis -f webm -deadline realtime -s 640x480')\n end", "def create\n @video = Video.new(params[:video])\n video_file = params[:video_file]\n img_file = params[:img_file]\n\n if video_file != nil\n videoid = Utils.videoid\n @video.video_url = \"http://10.10.140.70:5000/files/\"+Utils.upload(video_file, videoid)\n @video.video_id = videoid\n end\n if img_file != nil\n @video.video_img =\"http://10.10.140.70:5000/files/\"+Utils.upload(img_file, nil)\n end\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to today_videos_path }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def saveDeviceMediaInfo (result)\n path = Pathname.new(File.dirname(__FILE__)).realpath\n time = Time.now.strftime(\"%F %H.%M\")\n name = \"#{time} Device_Info.txt\"\n file = File.new(\"#{path}/../../DataSave/DeviceInfo/#{name}\", \"a+\")\n\n\tfile.puts \"============================Device_Media_info===========================\"\n\tresult.each do |source|\n\t file.puts \"Stream Name : #{source[:name]}\"\n\t file.puts \"Profile Name : #{source[:token]}\"\n\n\t if source.has_key? :video_source_configuration\n\t\t file.puts \"Video Source Configuration \"\n\t\t file.puts \" Configuration Name : #{source[:video_source_configuration][:name]}\"\n\t\t file.puts \" Configuration Token : #{source[:video_source_configuration][:token]}\"\n\t\t file.puts \" Source Use Conut : #{source[:video_source_configuration][:use_count]}\"\n\t\t file.puts \" Source Token : #{source[:video_source_configuration][:source_token]}\"\n\t\t if source[:video_source_configuration].has_key? :bounds\n\t\t \tfile.puts \" Source Resolution Width : #{source[:video_source_configuration][:bounds][:width]}\"\n\t\t \tfile.puts \" Source Resolution Height : #{source[:video_source_configuration][:bounds][:height]}\"\n\t\t\tend\n\t\tend\n\n\t\tif source.has_key? :video_encoder_configuration\n\t\t file.puts \"Video Encoder Configuration \"\n\t\t file.puts \" Configuration Name : #{source[:video_encoder_configuration][:name]}\"\n\t\t file.puts \" Configuration Token : #{source[:video_encoder_configuration][:token]}\"\n\t\t file.puts \" Encoder Use Conut : #{source[:video_encoder_configuration][:use_count]}\"\n\t\t file.puts \" Encoding : #{source[:video_encoder_configuration][:encoding]}\"\n\t\t file.puts \" Video Quality : #{source[:video_encoder_configuration][:quality]}\"\n\t\t \tfile.puts \" Session Timeout : #{source[:video_encoder_configuration][:session_timeout]}\"\n\t\t if source[:video_encoder_configuration].has_key? :resolution\n\t\t\t file.puts \" Encoder Resolution Width : #{source[:video_encoder_configuration][:resolution][:width]}\"\n\t\t\t file.puts \" Encoder Resolution Height : #{source[:video_encoder_configuration][:resolution][:height]}\"\n\t\t\tend\n\t\t\tif source[:video_encoder_configuration].has_key? :rate_control\n\t\t\t file.puts \" Frame Rate limit : #{source[:video_encoder_configuration][:rate_control][:frame_rate_limit]}\"\n\t\t\t file.puts \" Encoding Interval : #{source[:video_encoder_configuration][:rate_control][:encoding_interval]}\"\n\t\t\t file.puts \" Bitrate Limit : #{source[:video_encoder_configuration][:rate_control][:bitrate_limit]}\"\n\t\t\tend\n\t\t\tif source[:video_encoder_configuration].has_key? :H264\n\t\t\t file.puts \" Gov Length : #{source[:video_encoder_configuration][:H264][:gov_length]}\"\n\t\t\t file.puts \" H264 Profile : #{source[:video_encoder_configuration][:H264][:h264_profile]}\"\n\t\t\tend\n\t\t\tif source[:video_encoder_configuration].has_key? :multicast\n\t\t\t\tif source[:video_encoder_configuration][:multicast].has_key? :address\n\t\t\t\t\tfile.puts \" Type : #{source[:video_encoder_configuration][:multicast][:address][:type]}\"\n\t\t\t\t\tfile.puts \" Multicast Address : #{source[:video_encoder_configuration][:multicast][:address][:ipv4_address]}\"\n\t\t\t\tend\n\t\t\t file.puts \" Pott : #{source[:video_encoder_configuration][:multicast][:port]}\"\n\t\t\t file.puts \" TTL : #{source[:video_encoder_configuration][:multicast][:ttl]}\"\n\t\t\t file.puts \" Auto Start Status : #{source[:video_encoder_configuration][:multicast][:auto_start]}\"\n\t\t\tend\n\t\tend\n\n\t\tif source.has_key? :video_analytics_configuration\n\t\t file.puts \"Video Analytics Configuration \"\n\t\t file.puts \" Configuration Name : #{source[:video_analytics_configuration][:name]}\"\n\t\t file.puts \" Configuration Token : #{source[:video_analytics_configuration][:token]}\"\n\t\t file.puts \" Analytice Use Count : #{source[:video_analytics_configuration][:use_count]}\"\n\t\t if source[:video_analytics_configuration][:analytics_engine_configuration].has_key? :analytics_module\n\t\t\t source[:video_analytics_configuration][:analytics_engine_configuration][:analytics_module].each do |mod|\n\t\t\t file.puts \" Analytics Module Name : #{mod[:name]}\"\n\t\t\t file.puts \" Analytics Module Type : #{mod[:type]}\"\n\t\t\t end\n\t\t\tend\n\t\tend\n\t file.puts \"========================================================================\" unless source == result[result.count - 1]\n\tend\n\tfile.puts \"============================Device_Media_info_End=======================\"\n\n\tfile.close\nend", "def create\n if !params[:video][:video].nil?\n videoName = params[:video][:video].original_filename.gsub(/\\s/,'_') \n @video = Video.new({:title => params[:video][:title], :video => \"/worshipvideos/#{videoName}\"})\n else\n @video = Video.new({:title => params[:video][:title]})\n end\n\n if !params[:video][:video].nil?\n tmp = params[:video][:video].tempfile\n file = File.join(\"public/worshipvideos\", videoName)\n FileUtils.cp tmp.path, file\n FileUtils.rm tmp\n end\n\n respond_to do |format|\n if @video.save\n if !params[:video][:video].nil?\n #logger.debug \"./createVideoPics.sh '#{videoName}'\"\n #fork do\n #system(\"./createVideoPics.sh '#{videoName}'\")\n #exec(\"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:20 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_1.jpg'\")\n #logger.debug \"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:20 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_1.jpg'\"\n #exec(\"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:40 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_2.jpg'\")\n #logger.debug \"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:00:40 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_2.jpg'\"\n #exec(\"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:01:00 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_3.jpg'\")\n #logger.debug \"ffmpeg -i 'public/worshipvideos/#{videoName}' -an -ss 00:01:00 -r 1 -vframes 1 -f mjpeg -y 'app/assets/images/worship_pics/#{videoName}_3.jpg'\"\n #end\n\n @video.update_attribute(\"pic1\", \"worship_pics/#{videoName}_1.jpg\")\n @video.update_attribute(\"pic2\", \"worship_pics/#{videoName}_2.jpg\")\n @video.update_attribute(\"pic3\", \"worship_pics/#{videoName}_3.jpg\")\n end\n\n format.html { redirect_to @video, notice: 'Video was successfully created.' }\n format.json { render json: @video, status: :created, location: @video }\n else\n format.html { render action: \"new\" }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end", "def videos_upload\n\n file_extname = File.extname self.file_upload.original_filename\n new_file_name = \"#{Time.now.strftime(\"%Y%m%d%H%M%S\")}#{self[:employee_id]}#{file_extname}\"\n folder_path = \"/videos/#{Time.now.strftime(\"%Y\") }/#{Time.now.strftime(\"%m\") }/#{Time.now.strftime(\"%d\") }/\"\n url_path = folder_path + new_file_name\n full_folder_path = \"#{Rails.root.to_s}/public#{folder_path}\"\n new_file_path = \"#{Rails.root.to_s}/public#{url_path}\"\n unless File.exist? full_folder_path\n `mkdir -p #{full_folder_path}`\n end\n\n Dir.mkdir(full_folder_path) unless File.exists?(full_folder_path)\n\n if !self.file_upload.original_filename.empty?\n self.status = Document::ENCODE_PROCESS\n self.original = url_path\n #`touch #{new_file_path}`\n File.open(new_file_path, \"wb\") do |f|\n f.write(self.file_upload.read)\n f.close\n end\n self.save!\n # async encoding video files\n begin\n Backburner.enqueue Document, \"#{Rails.root.to_s}/public\", url_path, self.id\n rescue => ex\n puts 'async task fail'\n puts ex\n self.status = Document::ENCODE_FAILED\n self.save\n end\n end\n\n end", "def convert_command\n @original_video_filename = compute_original_local_filename\n @flv_filename = \"#{@original_video_filename}.flv\"\n @flv_url = \"#{public_filename}.flv\"\n \n if is_mov?\n command = \"/opt/ffmpeg/ffmpeg -y -i #{@original_video_filename} -target ntsc-dvd #{@flv_filename}\" \n else\n command = \"/opt/ffmpeg/ffmpeg -y -i #{@original_video_filename} #{@flv_filename}\"\n end\n command.gsub!(/\\s+/, \" \")\n end", "def generateVideos()\n #GENERATE AN INTERMEDIARY DIRECTORY WHERE WE'D STORE THE VIDEO FRAGMENTS\n pathToIntermediates=\"#{$PATHTOGENERATEINTERMEDIATES}/#{@meetingData.meetingId}\"\n puts \"generating intermediate videos in #{pathToIntermediates}\"\n createDirectoryIfNotExists(pathToIntermediates)\n \n dsPath=\"#{$PATHTOPUBLISHED}/#{@meetingData.meetingId}/deskshare\"\n presentationPath=\"#{$PATHTOPUBLISHED}/#{@meetingData.meetingId}/presentation\"\n \n #Scale to optimal resolution\n maxW=0\n maxH=0\n if Dir.exist?dsPath then\n maxW, maxH = getMaxResolution(dsPath)\n else \n maxW, maxH = getMaxResolution()\n end\n\n\n @objects.each_with_index{\n |val, index|\n puts \"Generating a #{val.class} video in interval [#{val.start_timestamp}, #{val.stop_timestamp}]\"\n val.generateVideo(pathToIntermediates, index, maxW, maxH)\n } \n end", "def video_asset_path(type)\n path = String.new\n unless @afdoc.external_video(:h264).first.nil?\n filename = @afdoc.external_video(:h264).first.datastreams[\"descMetadata\"].get_values(:name)\n path = File.join(@afdoc.pid.gsub(/:/,\"_\"),\"data\",filename)\n end\n return path\n end", "def fetchfilm parturl, _file=nil\n return nil unless parturl\n table = \"movie\"\n if parturl.index(\"&\")\n #$log.warn \"Cannot handle ampersand in URL. please correct #{parturl}\"\n $stderr.puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\"\n $stderr.puts \"Cannot handle ampersand in URL. please correct #{parturl}\"\n $stderr.puts \"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\"\n return nil\n end\n # remove HOST and keep last part\n if parturl.index OLDHOST\n parturl = parturl[OLDHOST.length..-1]\n end\n if parturl.index HOST\n parturl = parturl[HOST.length..-1]\n end\n if parturl.index(\"http:\") or parturl.index(\"https:\")\n # added this block 2015-12-30 \n $stderr.puts \">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\"\n $stderr.puts \"Don't know how to handle this host : #{parturl}. Pls use #{HOST} if you must.\"\n $stderr.puts \"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\"\n #$log.error \"Don't know how to handle #{parturl}\"\n #exit(1)\n return nil\n end\n #inserting = false\n return nil if parturl.nil? || parturl.strip == \"\"\n parturl = parturl.chomp\n #nid = counter + starting\n nid = nil\n upperurl = parturl.upcase\n key = converturl parturl\n id = $db.get_first_value %Q[select rowid from #{table} where upper(url) = \"#{upperurl}\";]\n # in some cases the data on wiki has changed a lot, so we are forcing a download\n unless $opt_force\n if id.nil?\n id = $db.get_first_value %Q[select url from #{table} where upper(canonical) = \"#{upperurl}\";]\n if id\n $stderr.puts color(\"ERROR: FOUND another url with similar canonical : #{id} skipping ..\",\"red\");\n return nil\n end\n # NOTE 2016-02-28 - this can prevent me from downloading a movie with same name but different\n # year. I should check title + year at point of updating in db. or key + year.\n id = $db.get_first_value \"select rowid from #{table} where key = '#{key}';\"\n if id\n tmp = $db.get_first_value \"select url from #{table} where key = '#{key}';\"\n $stderr.puts color(\"ERROR: FOUND another row with similar KEY #{key}: #{id} #{tmp} , skipping ..\",\"red\");\n #$log.warn \"XXX: FOUND another row with similar KEY #{key}: #{id} #{tmp} , SKIPPING ..\"\n return nil\n end\n else\n $stderr.puts color(\"ERROR: FOUND another row with #{parturl} ... skipping\",\"red\");\n return nil\n end\n end\n id = nid\n url = HOST + parturl.strip\n #\n # BUG: still fails if ampersand in URL regardless of single or double quote\n # TODO maybe we need to try Shellwords.escape since i am able to do it with wget on commandline\n text = %x[wget -q -O - \"#{url}\"] \n # 2015-12-29 - sometimes the URL is wrong, so we get a blank. The file has zero bytes\n # so we should check here\n if text.nil? or text.chomp == \"\"\n $stderr.puts color(\"ERROR: =========== url is wrong or internet down, no data received #{url}. pls check ...\", \"red\")\n #$my_errors << \"no data fetched for #{parturl} pls check/correct.\"\n sleep(60)\n return nil\n end\n # 2016-03-08 - write to a temp folder and only copy to real name if file passes disambiguation check\n tmpfile = _file.sub(\"wiki\", \"tmp\")\n File.open(tmpfile,\"w\") {|f2| f2.write(text) }\n\n _ff = Shellwords.escape(tmpfile)\n type = `file #{_ff}`\n\n # check if its a zip\n # SOMETime it comes in zip format. how do contreol that ?\n # if file says zipped then add gz extension and do a gunzip\n if type.index \"gzip\"\n $stderr.puts color(\" gzip found, expanding\", \"blue\")\n FileUtils.mv tmpfile, \"#{tmpfile}.gz\"\n system \"gunzip #{_ff}.gz\"\n #text = File.readlines(_file).join(\"\\n\")\n end\n\n # 2016-03-08 - check if disambiguation page\n ret = %x[ ./oldprogs/grepdisambiguation.sh \"#{tmpfile}\" ]\n if ret and ret.size > 3\n $stderr.puts color(\" ERROR: This (#{tmpfile} is a disambiguation page, aborting ...\", \"red\" ) \n return nil\n end\n # all okay, move file to real folder\n FileUtils.mv tmpfile, _file\n #\n # TODO 2016-03-06 - 13:09 extract canonical and compare with parturl\n # If different then change html path removing HOST and calling uri_to_filename \n # Then change parturl and write to file so next program can pick up and adjust url, htmlpath and ymlpath.\n # We check after writing since the string could be in zip format.\n # This could fail, we may need to use _ff instead here and in parsedoc\n canonical = %x[ ./oldprogs/grepcanonical.sh -h \"#{_file}\" ]\n\n # 2016-03-08 - read file and check for canonical. if so return error do not update table.\n if canonical && canonical.size > 2\n canonical = canonical.chomp\n if ( (canonical != parturl) && (URI.decode(canonical) != parturl) )\n suggestedurl = URI.decode(canonical);\n # 2016-03-08 - if canon link contains disambiguation or '#' then return error\n if suggestedurl.index(\"disambiguation\") or suggestedurl.index(\"#\")\n $stderr.puts color(\" ERROR: This (#{suggestedurl} is a disambiguation page, aborting ...\", \"red\", \"reverse\") \n return nil\n end\n $stderr.puts color(\" WARNING: canonical does not match url, should change name #{parturl} != #{canonical}...\",\"red\");\n $stderr.puts color(\" WARNING: we should rename file and url to: #{suggestedurl} and change the parturl in file and caller \",\"red\");\n # if this works out, we can change the name of the file. and write new url and html path to a yml file.\n end\n end\n return _file\nend", "def video_path(source, options = T.unsafe(nil)); end", "def smart_video_preview\n vp = Tempfile.new([\"video-preview\", \".png\"], binmode: true)\n\n # https://ffmpeg.org/ffmpeg.html#Main-options\n # https://ffmpeg.org/ffmpeg-filters.html#thumbnail\n output = shell!(\"ffmpeg -i #{file.path.shellescape} -vf thumbnail=300 -frames:v 1 -y #{vp.path.shellescape}\")\n Rails.logger.debug(output)\n\n MediaFile.open(vp)\n end", "def smart_video_preview\n vp = Tempfile.new([\"video-preview\", \".png\"], binmode: true)\n\n # https://ffmpeg.org/ffmpeg.html#Main-options\n # https://ffmpeg.org/ffmpeg-filters.html#thumbnail\n output = shell!(\"ffmpeg -i #{file.path.shellescape} -vf thumbnail=300 -frames:v 1 -y #{vp.path.shellescape}\")\n Rails.logger.debug(output)\n\n MediaFile.open(vp)\n end", "def harvest_video_data(image)\n response = Typhoeus.get(image.video_url, followlocation: true)\n\n if response.success?\n raise \"Invalid content type: \" + response.headers['Content-Type'] unless (response.headers['Content-Type'] == 'video/mp4')\n elsif response.timed_out?\n raise \"Request timed out\"\n elsif response.code == 0\n raise \"Could not get an HTTP response\"\n else\n raise \"HTTP request failed: \" + response.code.to_s\n end\n\n response.body\n end", "def create\n\n @video = Video.new(video_params)\n file = @video.video.tempfile\n\n video = Panda::Video.create(:file => file)\n # binding.pry\n video.encodings['h264'].reload\n\n until video.encodings['h264'].status == 'success'\n video.encodings['h264'].reload\n end\n\n video.encodings['h264'].encoding_progress\n @video.video = video.encodings['h264'].url\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to @video, notice: 'video was successfully created.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end", "def download(title, videoUrl)\n puts \"Video is at #{videoUrl}\\n\\n\"\n cmd = \"youtube-dl -o #{Shellwords.escape(title)}.mp4 #{Shellwords.escape(videoUrl)}\"\n puts \"Running #{cmd}\"\n system(cmd)\nend", "def get_video_codec \n send_cmd(\"get_video_codec\")\n end", "def convert_video_to_H264(filename, path, content, url)\n logger.debug \"Convert the video ( #{filename} ) path ( #{path}) from content type of #{content} to H264\"\n File.new(File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.h264\"), File::CREAT | File::TRUNC| File::RDWR, 0644)\n videoh264 = File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.h264\")\n system(\"ffmpeg -i #{url} -an -vcodec libx264 -crf 23 #{videoh264} -y\")\n return videoh264\n end", "def savevid\n tmp = params[:vids][:video].tempfile\n #require 'ftools'\n file = File.join(\"app/assets/videos\", params[:vids][:video].original_filename) # use public if you want\n FileUtils.cp tmp.path, file\n\n redirect_to \"/admin\"\nend", "def show\n @room = @video.room\n authorize! @room\n @stream_url_ready = S3_BUCKET_HLS.object(\"#{ENV[\"SERVER_STAGE\"]}/stream/#{@video.s3_key}/index.m3u8\").exists?\n @page_title = @video.title\n end", "def perform(url = nil)\n # 以此影片為範例,出處: Videvo\n url = 'https://cdn.videvo.net/videvo_files/video/free/2013-05/originalContent/DigitalCountdownTimerVidevo.mov'\n video_name = parse_video_name(url)\n video_file_path(video_name)\n download_video(url)\n converter\n rescue StandardError => e\n logger.error \"[Video::HandleVideoWorker] ERROR:\\n #{e.inspect}\\n #{e.backtrace}\"\n end", "def run\n begin\n prepare_for_conversion\n\n Queue.run *FORMATS.map{ |format| proc{ convert_to(format) } }, close_connection_before_execution: true\n \n mp4_file_info = Info.new output_path(:mp4)\n webm_file_info = Info.new output_path(:webm)\n \n unless similar_durations?(mp4_file_info.duration, webm_file_info.duration) \n raise Error.new( 'output videos have different duration', \n model_id: model_id, mp4_duration: mp4_file_info.duration, webm_duration: webm_file_info.duration )\n end\n \n cover_path = File.join output_folder, COVER_FORMAT % output_filename_without_extension\n extract_cover output_path(:mp4), cover_path, mp4_file_info.duration\n \n thumb_path = File.join output_folder, THUMB_FORMAT % output_filename_without_extension\n extract_thumb cover_path, thumb_path, *THUMB_SIZES\n \n rescue StandardError => e\n FileUtils.rm_rf output_folder\n \n input_path = \n if File.exists? temp_path\n temp_path\n elsif File.exists? uploaded_path\n uploaded_path\n end\n FileUtils.cp input_path, create_log_folder if input_path\n\n if model.present? and model.user_id.present?\n Notification.send_to(\n model.user_id,\n I18n.t('notifications.video.upload.failed.title'),\n I18n.t('notifications.video.upload.failed.message', :item => model.title),\n ''\n )\n model.destroyable_even_if_not_converted = true\n model.destroy\n end\n\n raise e\n end\n \n model.converted = true\n model.rename_media = true\n model.mp4_duration = mp4_file_info.duration\n model.webm_duration = webm_file_info.duration\n model.media = output_filename_without_extension\n model[:media] = output_filename_without_extension\n model.save!\n\n #FileUtils.rm temp_path\n FileUtils.rm_r temp_folder\n\n Notification.send_to(\n model.user_id,\n I18n.t('notifications.video.upload.ok.title'),\n I18n.t('notifications.video.upload.ok.message', :item => model.title),\n ''\n )\n end", "def create_locally\n write_file(@video_file, @video_name)\n write_file(@poster_file, @poster_name)\n end", "def set_video\n \n @video = Video.find(params[:id])\n \n end", "def index\n @settings = Setting.all\n #IF the system platform is MAC OS X\n if ServerSerialPort::Application.config.PLATFORM == 2\n value = `imagesnap -l`\n @cameras = value.split(\"\\n\")\n end\n\n @camera = \"/dev/video0\"\n \n end", "def video\n first_stream_of :video\n end", "def save! target=\"./Videos of me\"\n filename = File.join(target, \"#{@name}#{File.extname(@url)}\")\n\n data = Faceoff.download(@url)\n\n Faceoff.safe_save(filename) do |file|\n file.write data\n end\n end", "def show\n # if not @video.view_grabber_working?\n # Resque.enqueue(VideoViewsGrabberJob, @video.id)\n # end\n end", "def store_video\n ActiveRecord::Base.transaction do\n @video = Video.create(video_path: @video_url, description: @description, released: @released, title: @video_title, poster_path: @poster_url, producer: @producer)\n\t\t\t@latest = Latest.create(media_id: @video.id, title: @video_title, description: @description, released: @released, media_poster: @poster_url, media_producer: @producer, media_type: @type)\n end\n end", "def update\n @video = Video.find(params[:id])\n video_file = params[:video_file]\n img_file = params[:img_file]\n\n if video_file != nil\n videoid = Utils.videoid\n @video.video_url = \"http://#{Constants::UPLOAD_IP}/files/videos/\"+Utils.upload(video_file, videoid)\n end\n\n if img_file != nil\n @video.video_img =\"http://#{Constants::UPLOAD_IP}/files/images/\"+Utils.upload(img_file, nil)\n end\n\n respond_to do |format|\n if @video.update_attributes(params[:video])\n format.html { redirect_to channel_videos_path }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def videostab(path_to_video, width, height, crop, tracking_mode)\n\t# from true/false to 1/0\n\ttracking_mode = tracking_mode && 1 || 0\n\tpython_output = `python #{PYNAME} #{path_to_video} #{width} #{height} #{crop} #{tracking_mode}`\n\tputs \"The output from #{PYNAME} is: #{python_output}\"\nend", "def convert_video_to_flv(filename, path, content, url)\n logger.debug \"Convert the video ( #{filename} ) path ( #{path}) from content type of #{content} to flv\"\n File.new(File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.flv\"), File::CREAT | File::TRUNC| File::RDWR, 0644)\n videoflv = File.join(Rails.root, 'public' , 'system', File.dirname(path), \"#{filename}.flv\")\n system(\"ffmpeg -i #{url} -r 25 -ar 44100 -vcodec flv -ab 32 -y -f flv -s 320x240 #{videoflv}\")\n return videoflv\n end", "def get_video_resolution \n send_cmd(\"get_video_resolution\")\n end", "def update\n @video = Video.find(params[:id])\n video_file = params[:video_file]\n img_file = params[:img_file]\n\n if video_file != nil\n videoid = Utils.videoid\n @video.video_url = \"http://10.10.140.70:5000/files/\"+Utils.upload(video_file, videoid)\n end\n\n if img_file != nil\n @video.video_img =\"http://10.10.140.70:5000/files/\"+Utils.upload(img_file, nil)\n end\n respond_to do |format|\n if @video.update_attributes(params[:video])\n format.html { redirect_to today_videos_path }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def execute\n check_quota\n authorize\n upload\n raise UploadError.new, \"Validation of chunks failed.\" unless valid?\n complete\n\n return video_id\n end", "def timelapse\n raise NoSnapshotError if Dir.glob(saving_path+'/*.jpg').count.zero?\n\n puts \"Generate video...\"\n MovieMaker.build\n puts \"Video is ready.\"\n end", "def main\n doc = Nokogiri::HTML(open(START_URI))\n dirs_to_search = doc.css('a').map{|x|x[:href]}.grep(%r{/SolaceSounds/SolaceSounds})\n\n streams_to_rip = []\n\n dirs_to_search.each do |dir|\n puts \"Searching #{HOST}#{dir}\"\n\n # don't overwhelm the server\n sleep 1\n\n subdir = Nokogiri::HTML(open(HOST + dir))\n streams_to_grab = subdir.css('a').map{|x|x[:href]}.grep(%r{\\.mp3})\n streams_to_rip.concat(streams_to_grab)\n end\n\n # we've found all of the mp3 streams, now we grab them\n streams_to_rip.each do |url|\n if stream_already_downloaded(url)\n puts \"skipping url: #{url}\"\n next\n end\n rip_stream(url)\n move_ripped_file(url)\n set_mp3_tags(url)\n end\nend", "def create\n @video = Video.new(video_params.merge(:owner => current_user))\n @original = nil\n if (@video.errors[:video_exists])\n @original = Video.where(:external_id => @video.external_id, :type => @video.type).first\n end\n if @video.save\n render :json => @video, :include => ALL_INCLUDES\n else\n render :json => @video.errors, status: :unprocessable_entity\n end\n end", "def create_black_video(movie, visual)\n #Render an image and create a video file from it\n @generated_videos += 1\n filename = movie.project.trimmed + \"/generated-#{@generated_videos}.avi\"\n cmd = @settings['still_video'].dup\n length = visual.end_point - visual.start_point\n cmd.sub!('<frames>', length.to_frames(25).to_s)\n cmd.sub!('<source>', VREConfig.instance.vre_root + \"resources/black_box.png\")\n cmd.sub!('<resolution>', movie.resolution)\n cmd.sub!('<target>', filename)\n system(cmd)\n visual.file = filename\n visual.type = \"video\"\n visual.mute = true\n filename\n end", "def set_video\n @video = Video.find(params[:id])\n\n end", "def create\n @channel = params[:forminfo]\n @video = Video.new(params[:video])\n video_file = params[:video_file]\n img_file = params[:img_file]\n @video.video_type = params[:video_type]\n @video.video_id = Utils.videoid\n\n if video_file != nil\n @video.video_url = \"http://#{Constants::UPLOAD_IP}/files/videos/\"+Utils.upload(video_file, videoid)\n end\n\n if img_file != nil\n @video.video_img =\"http://#{Constants::UPLOAD_IP}/files/images/\"+Utils.upload(img_file, nil)\n end\n @video.cid = @channel\n respond_to do |format|\n if @video.save\n format.html { redirect_to channel_videos_path }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def set_video\n @video = Video.find_by(id: params[:id], user_id: get_user_id)\n end", "def getVideos(oStatsProxy, iMechanizeAgent)\n # Get the videos page\n lVideosPage = iMechanizeAgent.get('http://www.myspace.com/my/videos')\n # Screen scrap it\n # List of videos read (used for display)\n lLstVideosRead = []\n lVideosPage.root.css('table.myUploadsList tr').each do |iVideoNode|\n lVideoTitle = iVideoNode.css('td.summary h2 a').first.content\n lStatsNodes = iVideoNode.css('td.controls div.text span')\n lNbrPlays = Integer(lStatsNodes[1].content)\n lNbrComments = Integer(lStatsNodes[2].content)\n lMatch = lStatsNodes[3].content.match(/^(\\d*)% \\((\\d*) vote/)\n lRating = Integer(lMatch[1])\n lNbrLikes = Integer(lMatch[2])\n oStatsProxy.add_stat(lVideoTitle, 'Video plays', lNbrPlays)\n oStatsProxy.add_stat(lVideoTitle, 'Video comments', lNbrComments)\n oStatsProxy.add_stat(lVideoTitle, 'Video likes', lNbrLikes)\n oStatsProxy.add_stat(lVideoTitle, 'Video rating', lRating)\n lLstVideosRead << lVideoTitle\n end\n log_debug \"#{lLstVideosRead.size} videos read: #{lLstVideosRead.join(', ')}\"\n end", "def url_to_video(source, options = T.unsafe(nil)); end", "def show\n @video = Video.find(params[:id])\n end", "def newMediaObject(_, _, _, data)\n path = Media.save(@db.src_path, data['name'], data['bits'])\n\n run_user_cmd\n {\n 'url' => path\n }\n end", "def video\n\t\tVideo.find(self.video_id)\n\tend", "def convert_command\n\t\t\tflv = File.join(File.dirname(self.video.path), \"#{self.video_file_name}.flv\")\n\t\t\tmpeg4 = File.join(File.dirname(self.video.path), \"#{self.video_file_name}.mp4\")\n\t\t\tFile.open(flv, 'w')\n\t\t\tFile.open(mpeg4, 'w')\n\t\t\t#command = \"cd log/ && ffmpeg -i #{ self.video.path } -ar 22050 -ab 32 -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y #{ flv }; ffmpeg -i #{ self.video.path } -an -pass 1 -vcodec libx264 -vpre fastfirstpass -b 1024k -bt 1024k -threads 0 -y #{ mpeg4 }\"\n\t\t\tcommand = \"cd log/ && ffmpeg -i '#{ self.video.path }' -ar 22050 -ab 32 -s 480x360 -vcodec flv -r 25 -qscale 8 -f flv -y '#{ flv }'; ffmpeg -threads 4 -i '#{ self.video.path }' -r 29.97 -vcodec libx264 -flags +loop -cmp +chroma -deblockalpha 0 -deblockbeta 0 -crf 24 -bt 256k -refs 1 -coder 0 -subq 5 -g 250 -keyint_min 25 -level 30 -qmin 10 -qmax 51 -sc_threshold 40 -i_qfactor 0.71 -acodec libfaac -ab 128k -ar 48000 -ac 2 '#{ mpeg4 }'\"\n\n\t\t\tcommand.gsub!(/\\s+/, \" \")\n\t\t\tlogger.debug command\n\t\tend", "def perform(video_id)\n video = Video.get(video_id)\n flv_video = FFMPEG::Movie.new(video.flv)\n options = {\n resolution: flv_video.resolution,\n video_bitrate: flv_video.video_bitrate,\n audio_bitrate: flv_video.audio_bitrate\n }\n mp4_video = flv_video.transcode('uploads/' + video.id.to_s + '.mp4', options)\n video.update(mp4: mp4_video.path)\n end", "def get_media_content\n begin\n video_sql = \"SELECT * FROM mediacontent\";\n video_sql += \" WHERE ContentTypeID = 1\";\n video_sql += \" AND ( iPodVideo IS NOT NULL AND iPodVideo != '') AND (iPodVideo LIKE '%mp4') ORDER BY RecordDate ASC\";\n message_video_content_data = Immutable.dbh.execute(video_sql);\n\n return message_video_content_data;\n rescue DBI::DatabaseError => e\n Immutable.log.error \"Error code: #{e.err}\"\n Immutable.log.error \"Error message: #{e.errstr}\"\n Immutable.log.error \"Error SQLSTATE: #{e.state}\"\n abort('An error occurred while getting message video content data from DB, Check migration log for more details');\n end\n end", "def video_url(source, options = T.unsafe(nil)); end", "def mergeVideos()\n pathToIntermediates=\"#{$PATHTOGENERATEINTERMEDIATES}/#{@meetingData.meetingId}\"\n vidList=\"#{pathToIntermediates}/vidList.txt\"\n # Create a txt file with the lists of all videos to concatenate\n system \"echo >#{vidList}\"\n (0...@objects.length).each do |e|\n system \"echo file \\'#{pathToIntermediates}/vid-#{e}.mp4\\' >> #{vidList}\" \n end\n # Concatenate videos from the txt file\n system \"ffmpeg -f concat -safe 0 -i #{vidList} -c copy #{pathToIntermediates}/output.mp4 -loglevel quiet\"\n end", "def set_video\n @video = Video.find(params[:id])\n end", "def set_video\n @video = Video.find(params[:id])\n end", "def set_video\n @video = Video.find(params[:id])\n end", "def sprint_process_media(doc)\n srcs = Array.new\n # collect all the images in the document, even though\n # they are <img> tag some might actually refer to video.\n # To know the link refers to vide one must look at the \n # content type on the http GET response.\n imgs = doc.search(\"/html/body//img\")\n imgs.each do |i|\n src = i.attributes['src']\n # we don't want to double fetch content and we only\n # want to fetch media from the content server, you get\n # a clue about that as there is a RECIPIENT in the URI path\n # of real content\n next unless /mmps\\/RECIPIENT\\//.match(src)\n next if srcs.detect{|s| s.eql?(src)}\n srcs << src\n end\n\n #we've got the payload now, go fetch them\n cnt = 0\n srcs.each do |src|\n begin\n \n url = URI.parse(CGI.unescapeHTML(src))\n unless @is_video\n query={}\n url.query.split('&').each{|a| p=a.split('='); query[p[0]] = p[1]}\n query.delete_if{|k, v| k == 'limitsize' or k == 'squareoutput' }\n url.query = query.map{|k,v| \"#{k}=#{v}\"}.join(\"&\")\n end\n # sprint is a ghetto, they expect to see &amp; for video request\n url.query = url.query.gsub(/&/, \"&amp;\") if @is_video\n\n res = Net::HTTP.get_response(url)\n rescue StandardError => err\n log(\"#{self.class} processing error, #{$!}\", :error)\n next\n end\n\n # if the Sprint content server uses response code 500 when the content is purged\n # the content type will text/html and the body will be the message\n if res.content_type == 'text/html' && res.code == \"500\"\n log(\"Sprint content server returned response code 500\", :error)\n next\n end\n\n # setup the file path and file\n base = /\\/RECIPIENT\\/([^\\/]+)\\//.match(src)[1]\n type = res.content_type\n file_name = \"#{base}-#{cnt}.#{self.class.default_ext(type)}\"\n file = File.join(msg_tmp_dir(),File.basename(file_name))\n\n # write it and add it to the media hash\n type, file = sprint_write_file(type, res.body, file)\n add_file(type, file) unless type.nil? || file.nil?\n cnt = cnt + 1\n end\n\n end", "def test02()\n sourceMovie = File.join($directory, \"images/418_clip5_sd.m4v\")\n begin \n # Create the list of commands object, ready to have commands added to it.\n theCommands = CommandModule::SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n\n # 1. Create a movie importer, get the movie importers base object reference.\n movieImporterName = SecureRandom.uuid\n\n movieObject = theCommands.make_createmovieimporter(sourceMovie,\n name: movieImporterName,\n addtocleanup: false)\n\n # 2. Create the get_objectproperty command and get the track id.\n getReferenceCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :trackid)\n getReferenceCommand.add_option(key: :track,\n value: { trackindex: 0, mediatype: :vide })\n theCommands.add_command(getReferenceCommand)\n theResult = Smig.perform_commands(theCommands)\n trackID = { trackid: theResult.to_i } \n\n # 3. Get the media type of the track.\n getMediaTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :mediatype)\n getMediaTypeCommand.add_option(key: :track, value: trackID)\n res = Smig.perform_command(getMediaTypeCommand)\n raise 'First video track doesn\\'t have media type vide' unless res.eql? 'vide'\n\n # 4. Get the media type of the track.\n getIsTrackEnabled = CommandModule.make_get_objectproperty(movieObject,\n property: :trackenabled)\n getIsTrackEnabled.add_option(key: :track, value: trackID)\n res = Smig.perform_command(getIsTrackEnabled)\n raise 'Track with track id #{trackID} enabled is not YES' unless res.eql? 'YES'\n\n # 5. Get the track time range.\n getTrackTimeRange = CommandModule.make_get_objectproperty(movieObject,\n property: :timerange)\n getTrackTimeRange.add_option(key: :track, value: trackID)\n res = Smig.perform_command(getTrackTimeRange)\n timeRange = '{\"start\":{\"flags\":1,\"value\":0,\"timescale\":600,\"epoch\":0},' +\n '\"duration\":{\"flags\":1,\"value\":9000,\"timescale\":600,\"epoch\":0}}'\n raise \"Track with track id #{trackID} time range #{res}\" unless res.eql? timeRange\n\n # 6. Get the track natural size.\n getTrackNaturalSize = CommandModule.make_get_objectproperty(movieObject,\n property: :naturalsize)\n getTrackNaturalSize.add_option(key: :track, value: trackID)\n res = Smig.perform_command(getTrackNaturalSize)\n natSize = '{\"width\":400,\"height\":252}'\n raise \"Track with id #{trackID} natural size #{res}\" unless res.eql? natSize\n\n # 7. Get the nominal frame rate.\n getFrameRate = CommandModule.make_get_objectproperty(movieObject,\n property: :framerate)\n getFrameRate.add_option(key: :track, value: trackID)\n res = Smig.perform_command(getFrameRate).to_f\n raise \"Track with id #{trackID} frame rate #{res}\" unless res.eql? 10.0\n\n # 8. Get whether frames need reordering.\n getRequiresFrameReordering = CommandModule.make_get_objectproperty(movieObject,\n property: :requiresframereordering)\n getRequiresFrameReordering.add_option(key: :track, value: trackID)\n res = Smig.perform_command(getRequiresFrameReordering)\n raise \"Track with id #{trackID} frame reorder #{res}\" unless res.eql? \"NO\"\n\n # 8. Get min frame rate duration.\n getMinFramerateDuration = CommandModule.make_get_objectproperty(movieObject,\n property: :minframeduration)\n getMinFramerateDuration.add_option(key: :track, value: trackID)\n res = Smig.perform_command(getMinFramerateDuration)\n duration = '{\"flags\":1,\"value\":60,\"timescale\":600,\"epoch\":0}'\n raise \"Track with id #{trackID} min frame duration #{res}\" unless res.eql? duration\n \n # 9. Get the affine transform for the track. Usually identity.\n getAffineTransform = CommandModule.make_get_objectproperty(movieObject,\n property: :affinetransform)\n getAffineTransform.add_option(key: :track, value: trackID)\n res = Smig.perform_command(getAffineTransform)\n transform = '{\"m12\":0,\"m21\":0,\"m22\":1,\"tY\":0,\"m11\":1,\"tX\":0}'\n raise \"Track with id #{trackID} affine transform #{res}\" unless res.eql? transform\n\n # 10. Get track segment mappings for the track.\n getTrackSegmentMappings = CommandModule.make_get_objectproperty(movieObject,\n property: :tracksegmentmappings)\n getTrackSegmentMappings.add_option(key: :track, value: trackID)\n res = Smig.perform_command(getTrackSegmentMappings)\n mappings = '[{\"sourcetimerange\":{\"start\":{\"flags\":1,\"value\":0,\"timescale\"' +\n ':600,\"epoch\":0},\"duration\":{\"flags\":1,\"value\":9000,\"timescale\"' +\n ':600,\"epoch\":0}},\"targettimerange\":{\"start\":{\"flags\":1,\"value\"' +\n ':0,\"timescale\":600,\"epoch\":0},\"duration\":{\"flags\":1,\"value\":9000' +\n ',\"timescale\":600,\"epoch\":0}}}]'\n raise \"Track with id #{trackID} segment mappings #{res}\" unless res.eql? mappings\n\n # 11. Get track metadata.\n getTrackMetadata = CommandModule.make_get_objectproperty(movieObject,\n property: :metadata)\n getTrackMetadata.add_option(key: :track, value: trackID)\n res = Smig.perform_command(getTrackMetadata)\n metadata = '[]'\n raise \"Track with id #{trackID} metadata #{res}\" unless res.eql? metadata\n\n # 12. Get properties of the audio track\n audioTrackID = { mediatype: :soun, trackindex: 0 }\n getTrackMetadata = CommandModule.make_get_objectproperties(movieObject,\n saveresultstype: :jsonstring)\n getTrackMetadata.add_option(key: :track, value: audioTrackID)\n res = Smig.perform_command(getTrackMetadata)\n properties = '{\"preferredvolume\":1,\"mediatype\":\"soun\",\"timerange\":{\"start\":' +\n '{\"flags\":1,\"value\":0,\"timescale\":600,\"epoch\":0},\"duration\":{\"flags\":1,' +\n '\"value\":8973,\"timescale\":600,\"epoch\":0}},\"trackid\":1,\"languagecode\":\"und\",' +\n '\"languagetag\":\"\",\"trackenabled\":true}'\n raise \"First audio track properties #{res}\" unless res.eql? properties\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts \"Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n ensure\n # 13. Close the movie object\n Smig.close_object_nothrow(movieObject)\n end\nend", "def run\n @old_media = video.media.try(:dup)\n compose\n @old_media.paths.values.each{ |p| FileUtils.rm_f p } if @old_media\n rescue StandardError => e\n if @old_media\n video.media = @old_media.to_hash\n video.converted = true\n if old_fields = video.try(:metadata).try(:old_fields)\n video.title = old_fields['title'] if old_fields['title'].present?\n video.description = old_fields['description'] if old_fields['description'].present?\n video.tags = old_fields['tags'] if old_fields['tags'].present?\n end\n video.save!\n video.enable_lessons_containing_me\n Notification.send_to(\n video.user_id,\n I18n.t('notifications.video.compose.update.failed.title'),\n I18n.t('notifications.video.compose.update.failed.message', :item => video.title, :link => ::Video::CACHE_RESTORE_PATH),\n ''\n )\n else\n video.destroyable_even_if_not_converted = true\n video.destroy\n Notification.send_to(\n video.user_id,\n I18n.t('notifications.video.compose.create.failed.title'),\n I18n.t('notifications.video.compose.create.failed.message', :item => video.title, :link => ::Video::CACHE_RESTORE_PATH),\n ''\n )\n end\n\n raise e\n end", "def capture!\n @capture = CvCapture.open(@movie_url)\n end", "def create\n if video = Video.create(:uid => params[:video_uid], :remote_ip => request.remote_ip)\n @success = true\n \n # create the URL of the video\n video_url = \"#{BLEEOO_HOST}/videos/#{params[:video_uid]}\" \n begin \n bitly = Bitly.new(BITLY_USER, BITLY_API_KEY)\n logger.info(\"url: #{video_url}\")\n puts \"url: #{video_url}\"\n url = bitly.shorten(video_url)\n @short_url = url.short_url\n rescue \n @short_url = \"\"\n end\n \n video.short_link = @short_url\n video.save\n \n else\n @success = false \n end\n \n logger.info(\"success == #{@success}\")\n # respond_to do |format|\n # format.html\n # format.js {render :json => {:success => @success, :short_url => @short_url}.to_json }\n # end\n \n render :nothing => true, :json => {:success => @success, :short_url => @short_url}.to_json and return\n \n end", "def detect_face_and_timestamps(filename)\n create_faces_directory\n cmd = detect_command filename\n logger.info cmd\n puts cmd\n success = system(cmd + \" > #{Rails.root}/log/detection.log\")\n if success && $?.exitstatus == 0\n parse_xml_add_tagees_and_timesegments(get_timestamps_xml_file_name)\n File.delete get_timestamps_xml_file_name\n logger.info \"----- setting video_thumbnail to \" + thumb_path_big\n self.video_thumbnail = File.open(thumb_path_big)\n File.delete(thumb_path_big) if File.exist?(thumb_path_big)\n File.delete(thumb_path_small) if File.exist?(thumb_path_small)\n else\n self.failed!\n end\n end", "def mp4(id)\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/files/%i/mp4' % [id]).mp4\n end", "def do_video_job(*inputs)\n puts \"Creating output movie: #{@output}\"\n do_system(\"cp\", inputs.first, @output) # FIXME\n # TODO: http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20concatenate%20%28join,%20merge%29%20media%20files\n # do_system\n # dir & .work -> output to: @output\n end", "def set_physical_video\n @physical_video = PhysicalVideo.find(params[:id])\n end", "def get_videos_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaVideosApi.get_videos ...\"\n end\n # resource path\n local_var_path = \"/media/videos\"\n\n # query parameters\n query_params = {}\n query_params[:'exclude_flagged'] = opts[:'exclude_flagged'] if !opts[:'exclude_flagged'].nil?\n query_params[:'filter_videos_by_uploader'] = opts[:'filter_videos_by_uploader'] if !opts[:'filter_videos_by_uploader'].nil?\n query_params[:'filter_category'] = opts[:'filter_category'] if !opts[:'filter_category'].nil?\n query_params[:'filter_tagset'] = opts[:'filter_tagset'] if !opts[:'filter_tagset'].nil?\n query_params[:'filter_videos_by_name'] = opts[:'filter_videos_by_name'] if !opts[:'filter_videos_by_name'].nil?\n query_params[:'filter_videos_by_contributor'] = opts[:'filter_videos_by_contributor'] if !opts[:'filter_videos_by_contributor'].nil?\n query_params[:'filter_videos_by_author'] = opts[:'filter_videos_by_author'] if !opts[:'filter_videos_by_author'].nil?\n query_params[:'filter_has_author'] = opts[:'filter_has_author'] if !opts[:'filter_has_author'].nil?\n query_params[:'filter_has_uploader'] = opts[:'filter_has_uploader'] if !opts[:'filter_has_uploader'].nil?\n query_params[:'filter_related_to'] = opts[:'filter_related_to'] if !opts[:'filter_related_to'].nil?\n query_params[:'filter_friends'] = opts[:'filter_friends'] if !opts[:'filter_friends'].nil?\n query_params[:'filter_disposition'] = opts[:'filter_disposition'] if !opts[:'filter_disposition'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourceVideoResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaVideosApi#get_videos\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def render_video_directly options={}\n # render video player\n content_tag(:div) do\n options[:value].collect do |video_md5|\n l1 = video_md5[0..1]\n l2 = video_md5[2..3]\n content_tag(:video,\n content_tag(:source, \"I'm sorry; your browser doesn't support HTML5 video in MP4 with H.264.\",\n src: \"https://cspace-prod-02.ist.berkeley.edu/#TENANT#_nuxeo/data/#{l1}/#{l2}/#{video_md5}\",\n id: 'video_md5',\n type: 'video/mp4'),\n controls: 'controls',\n style: 'width: 640px;')\n end.join.html_safe\n end\n end", "def gen_video_dir()\n dir = \"#{Rails.root}/public/secure/video/#{@folder}\"\n if Dir.exist? dir\n dir\n else\n dir if FileUtils.mkdir_p dir\n end\n end", "def producer_public_videos(page_token = '')\n\n @producer_public_videos ||= begin\n result = []\n\n channels_response = get_channel_data\n uploads_list_id = channels_response.data.items.first['contentDetails']['relatedPlaylists']['uploads']\n\n public_uploads = get_public_uploads(uploads_list_id, page_token) \n playlist_items = public_uploads.items\n video_ids = playlist_items.map { |item| item[\"snippet\"][\"resourceId\"][\"videoId\"] }\n\n metadata_list = get_metadata(video_ids)\n duration_hash = metadata_list.map do |metadata|\n { metadata[\"id\"] => metadata[\"contentDetails\"][\"duration\"] }\n end.reduce(&:merge)\n\n view_hash = metadata_list.map do |metadata|\n { metadata[\"id\"] => metadata[\"statistics\"][\"viewCount\"] }\n end.reduce(&:merge)\n\n { \n :next_page_token => public_uploads.next_page_token, \n :items => serialize_playlist_items(playlist_items, duration_hash, view_hash)\n }\n end\n end", "def set_video\n @video = Video.find_by id: params[:id]\n end", "def generate_black_video(movie, visual)\n #Render an image and create a video file from it\n @generated_videos += 1\n filename = movie.project.trimmed + \"/generated-#{@generated_videos}.avi\"\n cmd = @settings['still_video'].dup\n length = visual.end_point - visual.start_point\n cmd.sub!('<frames>', length.to_frames(25).to_s)\n cmd.sub!('<source>', VREConfig.instance.vre_root + \"resources/black_box.png\")\n cmd.sub!('<resolution>', movie.resolution)\n cmd.sub!('<target>', filename)\n system(cmd)\n filename\n end", "def create\n @video = Video.new(video_params)\n @video.relateds.build\n @video.resources.build\n # obtain video metadata using the Wistia API\n Rails.logger.info(\"obtaining metadata from Wistia API for #{@video.wistia}\")\n media = Wistia::Media.find(@video.wistia)\n @video.title = media.name\n @video.description = ActionController::Base.helpers.strip_tags(media.description)\n @video.duration = (media.duration.to_i / 60) % 60\n @video.thumbnail_url = media.thumbnail.url\n\n respond_to do |format|\n if @video.save\n format.html { redirect_to videos_path, notice: 'Created video listing.' }\n format.json { render :show, status: :created, location: @video }\n else\n format.html { render :new }\n format.json { render json: @video.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n #@videos = Video.all\n Video.delete_database_and_files_on_server\n @video = Video.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @videos }\n end\n end" ]
[ "0.6857345", "0.65862954", "0.64283955", "0.637391", "0.63454497", "0.6229927", "0.6198828", "0.6177422", "0.61542165", "0.61429685", "0.60249317", "0.60194224", "0.5987404", "0.59856683", "0.5982497", "0.59382236", "0.5936411", "0.59192616", "0.59005713", "0.58758307", "0.5865143", "0.58559453", "0.5842999", "0.5803397", "0.5781024", "0.5750359", "0.57268846", "0.5720134", "0.5701676", "0.5697996", "0.56869984", "0.5683401", "0.5683144", "0.5681944", "0.56703", "0.5661922", "0.5659471", "0.5652765", "0.5651715", "0.5637287", "0.5637287", "0.5624897", "0.56195295", "0.5616142", "0.5611396", "0.56042105", "0.55849326", "0.55701137", "0.5562054", "0.5561061", "0.55381894", "0.55323297", "0.553087", "0.55303925", "0.5527639", "0.55257803", "0.5522118", "0.5506513", "0.5496549", "0.54895025", "0.5488675", "0.54728234", "0.5457727", "0.54496723", "0.5446567", "0.544109", "0.54369044", "0.54172117", "0.5406903", "0.5406821", "0.5406778", "0.5405521", "0.5402281", "0.5396414", "0.5388629", "0.5388421", "0.53869927", "0.53842056", "0.5383079", "0.5376675", "0.5370819", "0.5370819", "0.5370819", "0.53497463", "0.5348175", "0.5346587", "0.5344944", "0.5339653", "0.5339653", "0.53284365", "0.53228444", "0.5321291", "0.5308857", "0.53064615", "0.5304859", "0.5302772", "0.53021175", "0.53009146", "0.52955306", "0.5295406" ]
0.53658766
83
Transforms the float number to something with max. 2 digits after the colon
def two_digits(number) (number * 100.0).to_i.to_f / 100.0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def number_with_precision\n\t\t\"%.2f\" % number\n\tend", "def float2maxima(value)\n str = value.to_s ;\n str.gsub!(/^0\\./,'.') ;\n str.gsub!(/^-0\\./,'-.') ;\n return str ;\n end", "def number_with_lformat(number)\n number_with_precision(number.to_f, :precision => 2, :separator => \".\", :delimiter => \",\")\n end", "def reformat(number)\n num_without_decimal = number.gsub('.','') \n unless num_without_decimal.length == 4\n num_without_decimal = '0' + num_without_decimal \n end\n num_without_decimal\n end", "def _f(str)\n _n(str).gsub(/([\\d]+\\.?)(.*)/, '\\2')\n end", "def massage(value)\n value.to_f\n end", "def float_time_to_hhmmss(float_time)\n return if float_time.class == String\n if (float_time && float_time > 0)\n min = float_time.floor\n mm = (min % 60).floor\n hh = (min / 60).floor\n ss = ((float_time - min) * 60).round\n\n if float_time < 10.0\n return \"#{format('%01d', mm)}:#{format('%02d', ss)}\"\n elsif float_time < 60.0\n return \"#{format('%02d', mm)}:#{format('%02d', ss)}\"\n else\n return \"#{hh.to_s}:#{format('%02d', mm)}:#{format('%02d', ss)}\"\n end\n else\n return \"\"\n end\n end", "def number_with_formatting\n number_without_formatting\n end", "def number_with_formatting\n number_without_formatting\n end", "def format_to_float(str)\n return str.to_f if !str.include?(\":\")\n \n array = str.split(\":\").reverse!\n total = 0.0\n array.each_with_index do |x, i|\n if i == 0\n total += x.to_f\n else\n total += (x.to_f * (60 ** i))\n end\n end\n \n total\n end", "def to_rep(val)\n val.to_f\n end", "def number_with_formatting\n if /^(.*)(.{6})(.{6})(.{6})(.{6})(.{6})/i.match(number_without_formatting)\n \"#{$1}-#{$2}-#{$3}-#{$4}-#{$5}-#{$6}\"\n else\n number_without_formatting\n end\n end", "def number_format(num)\n \n return num.to_s.gsub(/(\\d)(?=\\d{3}+(\\.\\d*)?$)/, '\\1,')\n \n end", "def format_number(number)\n number.to_s.reverse.gsub(/...(?=.)/,'\\&,').reverse\nend", "def float_shortest_dec(x)\n Numerals::Format[:short].write(x)\nend", "def to_s\n sprintf(\"%.02f\", to_f)\n end", "def format_number(num)\n sprintf(\"%.2f\",num)\n end", "def convert_dimension(value)\n\t\twholeNum = value[0,3] #Pulls the whole number portion of the eVS dimension/size convention\n\t\tdecimal = value[3, 2] #Pulls the decimal portion\n\t\treturn \"#{wholeNum}.#{decimal}\".to_f.round.to_s\n\tend", "def priceify_number(number)\n format('%.2f', number)\n end", "def format_numeric(val, istruct)\n return istruct.nil_text if val.nil?\n return val.secs_to_hms if istruct.hms\n\n if istruct.commas\n # Commify the whole number part if not done already.\n result = val.commas(istruct.post_digits)\n else\n result = val.round(istruct.post_digits).to_s\n match = result.match(/\\.(\\d+)\\z/)\n if match && match[1]&.size < istruct.post_digits\n # Add trailing zeros to pad out post_digits\n n_zeros = [istruct.post_digits - match[1].size, 0].max\n zeros = '0' * n_zeros\n result = result + zeros\n end\n result\n end\n\n if istruct.pre_digits.positive?\n match = result.match(/\\A([\\d,]+)(\\.\\d+)?\\z/)\n whole_part = match[1]\n frac_part = match[2]\n n_zeros = [istruct.pre_digits - whole_part.gsub(',', '').size, 0].max\n result =\n if n_zeros.positive?\n if istruct.commas\n # Insert leading zeros with commas\n pre_comma_match = whole_part.match(/\\A(\\d+),/)\n if pre_comma_match\n n_partial_zeros = 3 - pre_comma_match[1].size\n whole_part = \"0\" * n_partial_zeros + whole_part\n n_zeros -= n_partial_zeros\n end\n zeros = ''\n if n_zeros.positive?\n zeros = \"0\" * n_zeros\n if n_zeros > 3 && istruct.commas\n zeros = zeros.reverse.gsub!(/([0-9]{3})/, \"\\\\1,\").reverse\n end\n end\n \"#{zeros},#{whole_part}#{frac_part}\"\n else\n # Insert leading zeros without commas\n zeros = \"0\" * n_zeros\n \"#{zeros}#{whole_part}#{frac_part}\"\n end\n else\n \"#{whole_part}#{frac_part}\"\n end\n else\n result\n end\n if istruct.currency\n result = \"#{FatTable.currency_symbol}#{result}\"\n end\n result\n end", "def format_num(num); number_with_delimiter(num) end", "def set_last_digits\n if number\n number.to_s.gsub!(/\\s/,'')\n self.digits ||= number.to_s.length <= 4 ? number : number.to_s.slice(-4..-1)\n end\n end", "def compress_number(num, precision=2)\n if precision > 0\n num_string = sprintf(\"%0.#{precision}f\", num)\n else\n num_string = sprintf(\"%d\", num.round)\n end\n if(num_string =~ /^00$/)\n num_string = \"0 \"\n end\n\n return num_string\n end", "def formatOunces(value)\n\t\twholeNum = value[1, 4] #Pulls the 2nd (A), 3rd (B), 4th (C) and 5th (D) digit from the format 0ABCDdddd where 'd' is the decimal portion of the eVS weight convention\n\t\tdecimal = value[5, 4] #Pulls the decimal portion\n\t\treturn (\"#{wholeNum}.#{decimal}\".to_f * 16.0).round(4).to_s\n\tend", "def normalize\n return 0 if input.blank?\n @output ||= begin\n hours, minutes, seconds = input.split(\":\")\n if minutes.nil? && seconds.nil? # format is just \"32.23\"\n seconds = hours\n hours = nil\n elsif seconds.nil? # format is just \"2:32.23\"\n seconds = minutes\n minutes = hours\n hours = nil\n end\n (hours.to_i * 3600) + (minutes.to_i * 60) + seconds.to_f\n end\n end", "def lap_time_to_float(time)\n time = time.split( /:|\\./ )\n time[1].to_f + ( time[0].to_i * 60 ) + \"0.#{time[2]}\".to_f\n end", "def decimal_places_suffix\n \"\"\n end", "def set_last_digits\n end", "def float_dec(x)\n Numerals::Format[:free, :exact_input].write(x)\nend", "def number_with_precision(number, precision=3)\n \"%01.#{precision}f\" % number\n rescue\n number\n end", "def formatOunces(value)\n\t\t\twholeNum = value[1, 4] #Pulls the 2nd (A), 3rd (B), 4th (C) and 5th (D) digit from the format 0ABCDdddd where 'd' is the decimal portion of the eVS weight convention\n\t\t\tdecimal = value[5, 4] #Pulls the decimal portion\n\t\t\treturn (\"#{wholeNum}.#{decimal}\".to_f * 16.0).round(4).to_s\n\t\tend", "def thousands_separator; end", "def to_s(separator=\":\")\n return self.to_a.collect {|x| x.to_s.rjust(2).gsub(/ /, \"0\")}.join(\":\")\n end", "def format_without_trailing_zeroes(numeric_value)\n s = format('%<num>f', num: numeric_value)\n i = s.to_i\n f = s.to_f\n i == f ? i.to_s : f.to_s\n end", "def t2f(time) \n time.strftime('%H.%M').to_f\n end", "def format_number\n number.to_s.gsub(/\\s+/,'') =~ FORMAT_REGEXP\n [$1,$2.to_s.split(/(...)/).map{|x| x.empty? ? nil : x}].flatten.compact.join(' ')\n end", "def post_process_float( val )\n\t\t\treturn Float( val.to_s )\n\t\tend", "def format_time(time)\n time = time.to_f * 1_000\n [0, time.to_i].max\n end", "def timeConvert(num)\n\t\n\treturn \"#{num/60}:#{num%60}\"\nend", "def format(precise: false)\n return '-' if @ms.nil?\n\n return Kernel.format('%02d:%02d:%02d.%03d', hours, minutes, seconds, milliseconds) if precise\n Kernel.format('%02d:%02d:%02d', hours, minutes, seconds)\n end", "def numberFormat( number, separator = ',', decimal_point = nil, prec=2 )\n prefix='';\n if( number < 0 )then\n number *= -1.0;\n prefix = '-';\n end\n if( (decimal_point == nil) or (prec == 0)) then\n num_parts = [ number.to_i.to_s ];\n else\n num_parts = sprintf( \"%0.#{prec}f\", number ).split('.')\n end\n x = num_parts[0].reverse.scan(/.{1,3}/).join(separator).reverse \n x << decimal_point + num_parts[1] if num_parts.length == 2 \n return prefix+x \nend", "def time_transformer(time)\n if time < 10\n \"0\" + time.to_s\n else\n time.to_s\n end\nend", "def f(natural_number)\n string = natural_number.to_s\n string.reverse!\n \"0.#{string}\"\nend", "def international_toll_free_number\n FFaker.numerify('800 ### ####')\n end", "def float_significant_dec(x)\n Numerals::Format[:free].write(x)\nend", "def __s2f(other)\n return other if other.is_a? Numeric\n if /^0[Xx][0-9a-fA-F]+$/ =~ other\n other.to_i(0).to_f\n else\n other.to_f\n end\n end", "def to_s\n \"#{( \"%.f\" % @value )}#{'%'} \"\n end", "def conversion_precision; end", "def routing_number_with_format; end", "def number\n number = number.to_s\n if number.includes?('.')\n number = number.to_f\n else\n number = number.to_i\n end\nend", "def to_c(number)\n number_with_precision(number, :precision => 2, :delimiter => '.', :separator => ',') + ' kn' \n end", "def convert( fahrenheit )\n puts format( \"%.2f\", ( fahrenheit.to_f - 32 )/ 1.8000 )\nend", "def nformat( n )\n # FIXME by locale\n return numberFormat( n, ',','.', 1 );\nend", "def to_s\n \"%02d:%02d:%02d:%02d\" % _nudge\n end", "def format_time(time)\n first_colon = time.index(':')\n if first_colon.nil? \n #if it's not a time\n return time\n end\n second_colon = time.index(':', first_colon + 1)\n result = time[0, first_colon]\n if result.length < 2\n result = \"0#{result}\"\n end\n if second_colon.nil?\n second_colon = time.length\n end\n result += time[first_colon, second_colon - first_colon]\n return result\nend", "def to_human(len = 3)\n\n\t\tunit = ''\n\t\tn = self\n\t\tn = self.to_f unless n.is_a? Numeric\n\n\t\tif n > 1100\n\t\t\tn /= 1000.0\n\t\t\tunit = 'k'\n\t\tend\n\n\t\tif n > 1100\n\t\t\tn /= 1000.0\n\t\t\tunit = 'm'\n\t\tend\n\n\t\tif n > 1100\n\t\t\tn /= 1000.0\n\t\t\tunit = 'T'\n\t\tend\n\n\t\t# now we have the unit and the number we want to format it in a \n\t\t# nice way so there is a consistant number of characters\n\t\ts = n.to_s\n\t\tif s.length > len\n\t\t\ts = s[0..len]\n\t\t\ts.chop! if s[-1] == '.'\n\t\tend\n\n\t\t\"#{s}#{unit}\"\n\tend", "def format_number(number)\n whole, decimal = number.to_s.split('.')\n if whole.to_i < -999 || whole.to_i > 999\n whole.reverse!.gsub!(/(\\d{3})(?=\\d)/, '\\\\1,').reverse!\n end\n [whole, decimal].compact.join('.')\nend", "def time2float time_string\n if time_string =~ /:/\n hours, minutes = time_string.split(':')\n hours.to_f + (minutes.to_f / 60.0)\n else\n time_string.to_f\n end\n end", "def display_number\n \"XXXX-XXXX-XXXX-#{last_digits}\"\n end", "def display_number\n \"XXXX-XXXX-XXXX-#{last_digits}\"\n end", "def to_mb( val ) \n return 0 unless val\n return (\"%5.2f\" % val ) if val < 1_000_000\n \"%5.2f Mb\" % (val/1_000_000.0)\n end", "def human_round number, base_precision = 0\n #FIXME there is an algorithm for this. What is it?\n precision = base_precision\n if number < 10\n precision = base_precision + 1\n end\n if number < 1\n precision = base_precision + 2\n end\n f_number = sprintf \"%.#{precision}f\", number\nend", "def float_format(string)\n custom = split_float string\n output_array = add_commas custom[:integer_part]\n output_array.join + \".\" + custom[:decimal_part]\nend", "def format_amount(amount)\n (\"%.2f\" % amount).gsub('.','').rjust(12,'0')\n end", "def get_float_time(time)\n if time\n if time.scan(/(?=:)/).count == 2\n hh, mm, ss = time.split(':')\n else\n hh = 0\n mm, ss = time.split(':')\n end\n return (hh.to_i * 60) + mm.to_i + (ss.to_i / 60.0)\n else\n return 0\n end\n end", "def format_number(number)\n number = 0 if number.nil?\n number.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\n end", "def format_str(value)\n value ||= '<none>'\n value = fmt ? (fmt % [value]) : value\n if max_length && (value.is_a? String) && value.length > max_length\n value = value[0..(max_length - 4)]\n value += ('.' * (max_length - value.length))\n end\n value\n end", "def break_number(num,short_scale)\n first_slice = (num.to_s.size - short_scale.to_s.size ) if num == short_scale\n first_slice = (num.to_s.size - (short_scale.to_s.size - 3) ) if num < short_scale\n first = num.to_s.slice(0..first_slice)\n second = num.to_s.slice(first.size..num.to_s.size)[0]\n return first,second\n end", "def FormatFloat(value)\n return '%.1f' % value\n end", "def canonicalize!\n # Can't use simple %f transformation due to special requirements from\n # N3 tests in representation\n @string = begin\n i, f = @object.to_s('F').split('.')\n i.sub!(/^\\+?0+(\\d)$/, '\\1') # remove the optional leading '+' sign and any extra leading zeroes\n f = f[0, 16] # truncate the fractional part after 15 decimal places\n f.sub!(/0*$/, '') # remove any trailing zeroes\n f = '0' if f.empty? # ...but there must be a digit to the right of the decimal point\n \"#{i}.#{f}\"\n end\n @object = BigDecimal(@string) unless @object.nil?\n self\n end", "def canonicalize!\n # Can't use simple %f transformation due to special requirements from\n # N3 tests in representation\n @string = begin\n i, f = @object.to_s('F').split('.')\n i.sub!(/^\\+?0+(\\d)$/, '\\1') # remove the optional leading '+' sign and any extra leading zeroes\n f = f[0, 16] # truncate the fractional part after 15 decimal places\n f.sub!(/0*$/, '') # remove any trailing zeroes\n f = '0' if f.empty? # ...but there must be a digit to the right of the decimal point\n \"#{i}.#{f}\"\n end\n @object = BigDecimal(@string) unless @object.nil?\n self\n end", "def convert_3_digits_number(value)\n word = ''\n division_result = value / 100\n mod_result = value % 100\n\n if division_result > 0\n word = \"#{LESS_THAN_20[division_result]} hundred\"\n word = \"#{word} \" if mod_result > 0\n end\n\n word = \"#{word}#{convert_2_digits_number(mod_result)}\" if mod_result > 0\n word\n end", "def format(item)\n\t\titem = \"%.2f\" % item\n\t\treturn item\n\tend", "def format_score(score)\n (score / 2).floor if score\n end", "def format_number(number)\n number.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\nend", "def to_time(number)\n n = number.to_s.split(\".\") # 1.25 [0]=> 1, [1]=> 25\n num = n[0]\n dec = n[1]\n case dec\n when \"75\"\n final_number = \"#{num}.45\"\n when \"5\"\n final_number = \"#{num}.30\"\n when \"25\"\n final_number = \"#{num}.15\"\n else\n final_number = number\n end\n end", "def scientificNotation(num)\r\n data = \"%.16e\" % num\r\n result = (data.split(\"e+\")[1].to_i() > 20) ? (data): (num)\r\n return result\r\n end", "def str_val(val, pre = \"\")\n (\"#{pre}#{\"%.8f\" % (val / 1e8)}\").rjust(20)\nend", "def solve(n)\n if n.to_s.length >= 6\n num = n.to_s[0..-3] + '.' + n.to_s[-2..-1]\n int_length = num.index('.')\n until int_length <= 3\n comma_idx = int_length - 3\n num = num[0...comma_idx] + ',' + num[comma_idx..-1]\n int_length -= 3\n end\n return num\n else\n return (n.to_f / 100).to_s\n end\nend", "def convert_i_f(value)\n if (value =~ /\\./)\n value = value.to_f\n elsif\n value = value.to_i\n end\n return value\nend", "def format_value_to_float(value)\n value.to_s\n end", "def format_number(number)\n whole, decimal = number.to_s.split(\".\")\n num_groups = whole.chars.to_a.reverse.each_slice(3)\n whole_with_commas = num_groups.map(&:join).join(',').reverse\n [whole_with_commas, decimal].compact.join(\".\")\nend", "def format_number(number)\n whole, decimal = number.to_s.split(\".\")\n num_groups = whole.chars.to_a.reverse.each_slice(3)\n whole_with_commas = num_groups.map(&:join).join(',').reverse\n [whole_with_commas, decimal].compact.join(\".\")\nend", "def terse_hours( hours )\n return hours.precision( 2 ).to_s.chomp( '0' ).chomp( '0' ).chomp( '.' )\n end", "def fixnum\n Util.from_bytes :fixnum, value\n end", "def to_f()\n @sec.to_f ;\n end", "def nice_number(number)\n confline = (!session or !session[:nice_number_digits]) ? Confline.get_value(\"Nice_Number_Digits\") : session[:nice_number_digits]\n nice_number_digits = (confline and confline.to_s.length > 0) ? confline.to_i : 2\n n = \"\"\n n = sprintf(\"%0.#{nice_number_digits}f\", number.to_d) if number\n if session\n session[:nice_number_digits] = nice_number_digits\n n = n.gsub('.', session[:global_decimal]) if session[:change_decimal]\n end\n n\n end", "def str_zero(n)\n n.to_s.sub(/\\.?0+$/, '')\nend", "def from_german_to_f\n self.gsub(',', '.').to_f\n end", "def convert_to(time_as_float)\n Duration.create(time_as_float.to_s, '%S.%N')\n end", "def delimited_number(value, symbol: '', delimiter: ',', no_decimals: 2)\n val = value.nil? ? 0.0 : value\n parts = format(\"#{symbol}%.#{no_decimals}f\", val).split('.')\n parts[0] = parts.first.reverse.gsub(/([0-9]{3}(?=([0-9])))/, \"\\\\1#{delimiter}\").reverse\n parts.join('.')\n end", "def to_s; \"#{@len}.#{@scale}\" end", "def toll_free_number\n FFaker.numerify('1800 ### ####')\n end", "def format(number)\n \tif number.to_s.include? '255' and not number.to_s.include? '+'\n \t number = \"+#{number}\"\n \tend\n\n \treturn number\n end", "def number_f\n return @number_f\n end", "def format; :n3; end", "def duration_converter(ableton_value)\n\t\tif ableton_value.to_f < 4\n\t\t\t((1/ableton_value.to_f) * 4).to_i.to_s + 'n'\n\t\telse\n\t\t\t(ableton_value.to_f/4).to_i.to_s + 'm'\n\t\tend\n\tend", "def decimal_limit; end", "def transform_track_number ( number )\n\t\t# puts \"transform_track_number: input #{number} #{number.to_s}\"\n\t\t_number = number.to_s + \"/\" + (@renumber_start_at + @total_tracks -1 ).to_s\n\tend", "def fancy_number(num)\n \"$\" + num.to_s.reverse.scan(/\\d{3}|.+/).join(\",\").reverse\n end", "def formatted_number(decimal)\n decimal.truncate(NUM_DECIMAL_PLACES).to_s(FLOATING_POINT_NOTATION)\n end" ]
[ "0.6582721", "0.6469831", "0.6390959", "0.625258", "0.6171198", "0.60232675", "0.60074866", "0.5983188", "0.5983188", "0.5952108", "0.5894121", "0.58310544", "0.5828855", "0.5824589", "0.5810024", "0.57838947", "0.57730305", "0.5740375", "0.57302934", "0.5701605", "0.56780225", "0.5669495", "0.56528634", "0.5646671", "0.56465006", "0.56329614", "0.562696", "0.56137496", "0.56084156", "0.5606104", "0.55996454", "0.5597974", "0.55808324", "0.5578315", "0.5573891", "0.5553438", "0.55446655", "0.55445606", "0.5529983", "0.5517436", "0.55126584", "0.55040073", "0.5501132", "0.5494317", "0.5491968", "0.54899657", "0.54859704", "0.5475552", "0.54619277", "0.544443", "0.544435", "0.5438395", "0.5434406", "0.542448", "0.5423629", "0.5422356", "0.54159474", "0.5406288", "0.5406005", "0.5406005", "0.5395781", "0.53903043", "0.5384204", "0.53822297", "0.5375755", "0.53749883", "0.53713787", "0.53624254", "0.5361519", "0.53516746", "0.53516746", "0.53515023", "0.53514296", "0.53499645", "0.53416306", "0.53363746", "0.5332486", "0.5331435", "0.53240985", "0.5315122", "0.53120655", "0.5311927", "0.5311927", "0.5310165", "0.52984494", "0.52982295", "0.52948254", "0.5293392", "0.52833116", "0.5267257", "0.5266357", "0.5258351", "0.5248904", "0.52432597", "0.5232479", "0.5226932", "0.5220094", "0.52198535", "0.5215464", "0.52060086", "0.5205957" ]
0.0
-1
No one wants to read 123secs so tell them what this is in human readable time
def transform_secs(seconds) time = '' h = (seconds.to_f / 3600.0).floor seconds = seconds - (h * 3600) time << "#{h.to_s.rjust(2, '0')}:" if h > 0 m = (seconds.to_f / 60.0).floor seconds = seconds - (m * 60) time << "#{m.to_s.rjust(2, '0')}:" time << "#{seconds.to_s.rjust(2, '0')}" time end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_time # :nodoc:\n\t rt_sec, rt_usec = rio.read(TIME_SIZE).unpack('VV')\n\t Time.at(rt_sec, rt_usec)\n\tend", "def read_time\n (number_of_words.to_f / WORDS_PER_MINUTE).ceil\n end", "def tv_sec() end", "def sec() time[2] end", "def time\n a=[1, 1000, 60000, 3600000]*2\n ms = duration\n \"%02d\" % (ms / a[3]).to_s << \":\" << \n \"%02d\" % (ms % a[3] / a[2]).to_s << \":\" << \n \"%02d\" % (ms % a[2] / a[1]).to_s #<< \".\" << \n #\"%03d\" % (ms % a[1]).to_s\n end", "def tt(time, format=:short); '13:37'; end", "def seconds\n _nudge[2]\n end", "def prep_time_passed\n return \"7:34\"\n end", "def parse_time\n s0 = @scanner.pos\n if match_str('(') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s3 = parse_ms\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str('/') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s5 = parse_hms\n s5 = parse_ms(with_hour: true) if s5 == :failed\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str(')') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'now' => s3, 'total' => s5 }\n end\n end\n end\n end\n end\n s0\n end", "def time_str\n Time.at(time[0..-4].to_f + time[-3..-1].to_f / 1000)\n .strftime(\"%M:%S.%L\")\n end", "def print_time( fmt )\n printf( fmt, utime, stime )\n end", "def utime(*) end", "def time_as_human\n return Knj::Strings.secs_to_human_time_str(self.time_total, :secs => false)\n end", "def call_time(time)\n time.to_s[0..-7]\n end", "def time(text)\n if time?(text)\n Nickel.parse(text).occurrences[0].start_time.to_time\n else\n clean_text = clear_text(text)\n if time?(clean_text)\n Nickel.parse(clean_text).occurrences[0].start_time.to_time\n end\n end\n end", "def pretty_runtime\n return nil if total_time.nil?\n t = total_time / 1000\n minutes = t / 60\n seconds = t - 60 * minutes\n sprintf '%d:%02d', minutes, seconds\n end", "def runtime\n details.at(\"div.subtext time[itemprop='duration']\")['datetime'].gsub(/[^\\d+]/, '').to_i rescue nil\n end", "def cstime(*) end", "def reading_time(index)\n words_per_second = 270 / 60\n total_words = description(index).scan(/\\s+/).count\n article_time_seconds = total_words / words_per_second\n article_time_minutes = (article_time_seconds / 60).round\n\n return \"less than a minute read\" unless article_time_minutes > 0\n \"#{article_time_minutes} min read\"\n end", "def time_sec; Time.now.sec; end", "def p(s) puts \"-- #{Time.now.strftime('[%H:%M:%S]')} #{s}\" end", "def p(s) puts \"-- #{Time.now.strftime('[%H:%M:%S]')} #{s}\" end", "def sbv_time(t)\r\n i = t.to_i\r\n \"%d:%02d:%02d.%03d\" % [i/3600, i/60%60, i%60, (t*1000).to_i%1000]\r\nend", "def read_time fn=nil\n time = read_single_line(fn)\n if time.size == 2 # vector of two integers\n time.map { |t| t.to_i }\n else # single number\n single = time.first\n single =~ float_re ? single.to_f : single.to_i\n [single, nil]\n end\n end", "def print_time()\n puts \"\", @time_info\n end", "def say_time(time, escapeDigits=ALL_SPECIAL_DIGITS) \r\n\t #calc the number of seconds elapsed since epoch (00:00:00 on January 1, 1970) \r\n diff = time.to_i\r\n\t\tmsg = \"SAY TIME #{diff} #{escape_digit_string(escapeDigits)}\"\r\n\t\tsend(msg)\r\n\t\treturn get_int_result()\r\n\tend", "def print_time(nbr_secs)\n secs = nbr_secs.to_i\n mins = secs / 60\n hours = mins / 60\n return \"#{hours}:#{sprintf('%.2d',mins % 60)}:#{sprintf('%.2d',secs % 60)}\"\n end", "def time; end", "def time; end", "def time; end", "def time; end", "def time; end", "def time; end", "def time; end", "def time; end", "def time; end", "def sec\n @sec ||= time_parts[2]\n end", "def time(text)\n scan(text, TIME, :time)\n end", "def get_timing\r\n (time_swam.minutes.to_i > 0 ? \"#{time_swam.minutes.to_i}'\" : '') +\r\n format('%02.0f\"', time_swam.seconds.to_i) +\r\n format('%02.0f', time_swam.hundreds.to_i)\r\n end", "def tv_usec() end", "def time()\n return _request([\n 'time',\n '0'\n ])[0]\n end", "def time_string\n time = Time.new(0)\n convert = time + seconds\n convert.asctime.split(\" \")[3]\n end", "def cstime=(*) end", "def parse_time(row)\n raw_time = row[1]\n if raw_time\n time = \"#{raw_time[0..4]}#{raw_time[-2..-1].downcase!}\"\n\n # remove leading 0\n time = time[1..-1] if time[0] === '0'\n time\n else\n nil\n end\nend", "def ctime() end", "def seconds ; return aseconds % SPM ; end", "def ctime() end", "def ctime() end", "def reqn\n t = Time.now\n msec = t.to_f.to_s.match(/\\.(\\d\\d)/)[1] rescue '00'\n t.strftime('%Y%m%d%H%M%S') + msec\n end", "def time\n reply.documents[0][TIME]\n end", "def get_timing( time_swam = @time_swam )\r\n (time_swam.minutes.to_i > 0 ? \"#{time_swam.minutes.to_i}'\" : '') +\r\n format('%02.0f\"', time_swam.seconds.to_i) +\r\n format('%02.0f', time_swam.hundreds.to_i)\r\n end", "def show_time(string)\n return unless string && timing?\n\n if @@message_callback\n @@message_callback.call(:info, string)\n else\n $stderr.puts \"#{GREEN}#{string}#{RESET}\"\n end\n end", "def timelong( time )\n time.strftime('%Y-%m-%d %H:%M:%S') if time\n end", "def extra_dmdsecs\n \"\"\n end", "def timing_ms\n return nil if timing.nil?\n (timing * 1000).to_i\n end", "def sec\n return @t_sec\n end", "def get_time\n\t\t@time.inspect\n\tend", "def time_unit\n return \"1sec\"\n end", "def timestring(time)\n time.strftime(\"%Y/%m/%d %H:%M:%S\") + \".#{time.usec}\"[0..3]\n end", "def nice_time\n Time.at(time).utc.strftime('%-M:%Ss')\n end", "def parse_seconds(time)\n sounds_for_number(time.strftime(\"%S\"))\n end", "def sys_time()\n time_now = Time.now.to_s\n time = time_now[11..18] #get h,m,s \n return time\nend", "def stime(*) end", "def timeofday(input)\n input = input % 1440\n hour, min = input.divmod(60)\n format('%02d:%02d', hour, min)\nend", "def ctime\n end", "def report_time time\n end", "def time\n moment % 1\n end", "def asctime() end", "def time(context)\n if @time.eval(context).is_a?(String)\n case @units\n when \"s\"\n @time.eval(context)\n else\n raise \"Invalid units\"\n end\n else\n (\"%.2f\" % case @units\n when \"s\"\n @time.eval(context)\n when \"ms\"\n @time.eval(context).to_f / 1000\n end).sub(/^0+/, \"\") + \"(sec)\"\n end\n end", "def str_elapsed(t)\n seconds = Time.now.to_i - t\n return \"now\" if seconds <= 1\n\n length,label = time_lengths.select{|length,label| seconds >= length }.first\n units = seconds/length\n \"#{units} #{label}#{'s' if units > 1} ago\"\nend", "def parse_time(time)\n time = \"0#{time}\" if time.match(/^\\d:\\d\\d/)\n time = time.gsub(/u/, '') if utime?\n time = time.gsub(/s/, '') if stime?\n\n time\n end", "def met_at\n return Time.parse(read) if met?\n nil\n end", "def time\n Time.at(data[\"time_ms\"].to_f/1000)\n end", "def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end", "def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end", "def time\n Integer(connection.write(\"get_time\", false))\n rescue ArgumentError\n 0\n end", "def humanize_time(seconds)\n\tminutes = seconds / 60\n \t[[60, :m], [24, :h], [100000, :d]].map{ |count, name|\n if minutes > 0\n minutes, n = minutes.divmod(count)\n \"#{n.to_i}#{name}\"\n end\n }.compact.reverse.join('')\nend", "def starttime; Time.parse(@starttime_str); end", "def get_time\n\t\tsynchronized do\n\t\t\t@vlc.puts \"get_time\"\n\t\t\t@vlc.gets.to_i\n\t\tend\n\tend", "def grabTime(str)\n if /(\\,\\s)(\\d.+\\.\\m\\.)/.match(str)\n /(\\,\\s)(\\d.+\\.\\m\\.)/.match(str)[2]\n else\n \"Ongoing\"\n end\n end", "def time\n\t\t\t\tDateTime.strptime(block_nTime.to_s, \"%s\").to_s\n\t\t\tend", "def proper_time(time)\n\tTime.at(time).gmtime.strftime('%R:%S')\nend", "def pretty_time(num_seconds)\n\ttemp = num_seconds\t\n\n\thours = temp/3600\n\ttemp = temp%3600\n\n\tminutes = temp/60\n\ttemp = temp%60\n\n\tif hours > 0\n\t\treturn \"#{hours} Hours, #{minutes} Minutes, and #{temp} Seconds\"\n\telsif minutes > 0\n\t\treturn \"#{minutes} Minutes and #{temp} Seconds\"\n\telse\n\t\treturn \"#{temp} Seconds\"\n\tend\nend", "def seconds\n value_parts[2]\n end", "def seconds\n value_parts[2]\n end", "def output_time(stat)\n timemsec = stat[@timekey]\n return '[NOT AVAILABLE] ' if timemsec.nil? || timemsec == 0\n time = Time.at(timemsec / 1000)\n # Outputs UTC. To output in the local timezone,\n # call time.localtime.strftime\n time.utc.strftime('%Y-%m-%d %H:%M')\n end", "def time()\n return self._request([\n 'time',\n '0'\n ])[0]\n end", "def fix_time(time=nil)\n if time == nil\n # no full time, use current\n hh, mn, ss = Time.now.strftime(\"%H:%M:%S\").split(':')\n elsif time.size == 3\n # we got full time\n hh = time[0].rjust(2,'0')\n mn = time[1].rjust(2,'0')\n ss = time[2].rjust(2,'0')\n elsif time.size == 2\n # we got full time minus seconds\n hh = time[0].rjust(2,'0')\n mn = time[1].rjust(2,'0')\n ss = Time.now.strftime(\"%S\")\n end\n return hh, mn, ss\n end", "def usec() end", "def display_time(secs)\n [[60, :s], [60, :m], [9999, :h]].map do |count, name|\n if secs > 0\n secs, n = secs.divmod(count)\n\n \"#{n.to_i}#{name}\" unless n.to_i == 0\n end\n end.compact.reverse.join(' ')\n end", "def estimated_reading_time\n estimate = content.split(/\\s+/).length / AVERAGE_WPM\n \"#{estimate >= 1 ? estimate : '< 1'} min read\"\n end", "def test_check_good_time\n assert_output '' do\n time = '1553188611.560418000'\n prev_time = '1553188612.100418000'\n line_num = 0\n @verify.check_time(time, prev_time, line_num)\n end\n end", "def tout_time(tout)\n current_time = Time.now.utc\n tout = Time.parse(tout)\n seconds = (current_time - tout).to_i\n if seconds >= 60\n minutes = seconds / 60\n if minutes >= 60\n hours = minutes / 60\n if hours >= 24\n days = hours / 24\n return days.to_s + \" days\"\n else\n return hours.to_s + \" hours\"\n end\n else\n return minutes.to_s + \" mins\"\n end\n else\n return seconds.to_s + \" seconds\"\n end\n end", "def nice_time(time)\n time = time.to_i\n return \"\" if time == 0\n t = \"\"\n h = time / 3600\n m = (time - (3600 * h)) / 60\n s = time - (3600 * h) - (60 * m)\n t = good_date(h) + \":\" + good_date(m) + \":\" + good_date(s)\n end", "def time_class; end", "def short_display_time\n\t\tself.timestamp.strftime(\"%b %d %-l:%M %p\") + (self.is_full? ? \" (Waitlist)\" : \"\")\n\tend", "def time_in_ms(time)\n time_string = time.split(':')\n\n milliseconds = time_string.last.split('.').last\n totalmilliseconds = time_string.last.split('.').first.to_i * 1000 + milliseconds.to_i\n minutes = time_string.first.to_i * 60000\n return totalmilliseconds + minutes\nend", "def shortened_time\n Time.now.to_i.to_s.split(\"\")[6..8].join\n end", "def time_string(secs)\n dhms = ([secs / 86400] + Time.at(secs).utc.strftime('%H|%M|%S').split(\"|\").map(&:to_i)).zip(['day', 'hour', 'minute', 'second'])\n dhms.shift while dhms[0][0] == 0\n dhms.pop while dhms[-1][0] == 0\n dhms.map! { |(v, s)| \"#{v} #{s}#{v == 1 ? nil : 's'}\" }\n return dhms[0] if dhms.size == 1\n \"#{dhms[0..-2].join(', ')} and #{dhms[-1]}\"\n end", "def extract_ts(chunks)\n ts = chunks[fmt.index('t')]\n return parse_time(ts) if valid_timestamp?(ts)\n rescue TypeError\n Time.now.utc.to_i\n end", "def timing(stat, ms, sample_rate=1); send stat, ms, 'ms', sample_rate end" ]
[ "0.6949369", "0.6926923", "0.69215083", "0.6906641", "0.6809054", "0.67765385", "0.6753894", "0.6739984", "0.6722098", "0.66422457", "0.6477977", "0.64709616", "0.64535004", "0.6431178", "0.64310145", "0.64257765", "0.6413693", "0.64007914", "0.6389182", "0.636378", "0.6349528", "0.6349528", "0.63104707", "0.63095456", "0.630804", "0.6301389", "0.62958974", "0.62944335", "0.62944335", "0.62944335", "0.62944335", "0.62944335", "0.62944335", "0.62944335", "0.62944335", "0.62944335", "0.6291428", "0.62905675", "0.6281225", "0.62798655", "0.62769765", "0.6266338", "0.6252724", "0.6229292", "0.6222345", "0.6221038", "0.62202555", "0.62202555", "0.62199104", "0.6211565", "0.61874396", "0.6185994", "0.6185374", "0.6182492", "0.61809325", "0.6169337", "0.6166971", "0.6163471", "0.6158156", "0.61580837", "0.6141978", "0.6138961", "0.61294466", "0.6126935", "0.6125896", "0.61180097", "0.61176634", "0.61146945", "0.6113191", "0.61121017", "0.6109768", "0.6106533", "0.6097241", "0.60966635", "0.60966635", "0.60966635", "0.60963833", "0.60942465", "0.6087045", "0.6078475", "0.6074618", "0.60626763", "0.60611343", "0.6061134", "0.6061134", "0.60591525", "0.6048053", "0.60468614", "0.6044028", "0.60401917", "0.6037205", "0.6035015", "0.6018907", "0.601843", "0.60123444", "0.60104537", "0.6008749", "0.6008576", "0.60017794", "0.5992341", "0.5990665" ]
0.0
-1
Transform amount of bytes in humanreadable format
def transform_byte(byte) byte = byte.to_f return two_digits(byte / 1073741824).to_s << " GB" if byte > 1073741824 return two_digits(byte / 1048576).to_s << " MB" if byte > 1048576 return two_digits(byte / 1024).to_s << " KB" if byte > 1024 return two_digits(byte).to_s << " B" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def human_bytes(bytes)\n number_to_human bytes, units: BYTE_UNITS\n end", "def human_bytes(bytes)\n s = ['bytes', 'kb', 'MB', 'GB', 'TB', 'PB'];\n #indicates if thousands, millions ...\n place = (Math.log(bytes)/Math.log(1024)).floor\n (bytes/(1024 ** place.floor)).to_s+\" \"+s[place];\n end", "def btog(bytes)\n return bytes / 1024 / 1024 / 1024\nend", "def human_bytes(bytes, precision = 0)\n return 0.to_s if bytes < 1\n {T: 1000*1000*1000*1000, G: 1000*1000*1000, M: 1000*1000, K: 1000, B: 1}.each do |unit, value|\n return \"#{(bytes.to_f/value).round(precision)}#{unit}\" if bytes >= value\n end\n end", "def bits_to_human_readable(num)\n ['bytes','KB','MB','GB','TB'].each do |x|\n if num < 1024.0\n return \"#{num.to_i} #{x}\"\n else\n num = num/1024.0\n end\n end\n end", "def format_size(bytes)\n sprintf \"%0.1fG\", bytes.to_f / 10**9\nend", "def bits_to_human_readable(num)\n ['bytes','KB','MB','GB','TB'].each do |x|\n if num < 1024.0\n return \"#{num.to_i} #{x}\"\n else\n num = num/1024.0\n end\n end\n end", "def number_to_human_size(bytes, options = {})\n NumberToHumanSize.convert(bytes, options)\n end", "def to_s\n format(\"%16d bytes %-10s %-60s\", size.to_i, id, name)\n end", "def as_readable_bytes\n converted_value = self\n\n if self.to_i < 1024\n exponent = 0\n else\n max_exp = UNITS.size - 1\n\n # Convert to base\n exponent = (Math.log(self) / Math.log(1024)).to_i\n # We need this to avoid overflow for the highest unit\n exponent = max_exp if exponent > max_exp\n\n converted_value = self / (1024 ** exponent)\n end\n\n \"#{converted_value} #{UNITS[ exponent ]}\"\n end", "def as_byte_size(bytes)\n bytes = bytes.to_f\n i = BYTE_RANGE.length - 1\n while bytes > 512 && i > 0\n i -= 1\n bytes /= 1024\n end\n ((bytes > 9 || bytes.modulo(1) < 0.1 ? '%d' : '%.1f') % bytes) + ' ' + BYTE_RANGE[i]\n end", "def as_size2( s = nil )\n prefix = %W(ТиБ ГиБ МиБ КиБ Б)\n s = (s || self).to_f\n i = prefix.length - 1\n while s > 512 && i > 0\n s /= 1024\n i -= 1\n end\n ((s > 9 || s.modulo(1) < 0.1 ? '%d' : '%.1f') % s) + ' ' + prefix[i]\n end", "def _pack_raw(n, size)\n n.to_s(16).rjust(2 * size, \"0\").scan(/../).reverse.map{ |b|\n [b].pack('H*')[0]\n }.join.force_encoding(\"ascii-8bit\")\nend", "def to_s; \"#{@len}.#{@scale}\" end", "def human_size\n count = 0\n n = size\n while n >= 1024 and count < 4\n n /= 1024.0\n count += 1\n end\n format(\"%.1f\",n) + %w(B kB MB GB TB)[count]\n end", "def human_size size_bytes\n size = size_bytes\n type = \"B\"\n\n %w{KB MB GB}.each do |t|\n if size > 1024\n size = size/1024\n type = t\n else\n break\n end\n end\n\n \"#{size}#{type}\"\nend", "def to_s\n require 'stringio'\n\n sb = StringIO.new\n each { |block3|\n sb << block3.map { |block4|\n format(\"%0#{1 << BLOCK4}b\", (block4 || 0)).reverse }.join\n }\n\n # At max there will be just 1 block of extra bits\n # So we are cutting at exactly @size\n sb.string[0...@size]\n end", "def to_s\n \"%0#{size}b\" % number\n end", "def number_to_human_size(number)\n base = 1024\n\n if number.to_i < base\n \"#{number} bytes\"\n else\n number = number.to_f\n max_exp = STORAGE_UNITS.size - 1\n exponent = (Math.log(number) / Math.log(base)).to_i # Convert to base\n exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit\n number /= base ** exponent\n\n unit_key = STORAGE_UNITS[exponent]\n\n \"#{number.round(2)} #{unit_key.to_s}\"\n end\n\n end", "def to_storage(bytes)\n case bytes\n when 0\n \"empty\"\n when 1..1.kilobyte-1\n bytes.to_s + \" b\"\n when 1.kilobyte..1.megabyte-1\n (bytes.to_f/1.kilobyte).round(2).to_s + \" Kb\"\n when 1.megabyte..1.gigabyte-1\n (bytes.to_f/1.megabyte).round(2).to_s + \" Mb\"\n when 1.gigabyte..1.terabyte-1\n (bytes.to_f/1.gigabyte).round(2).to_s + \" Gb\"\n else\n \"File is very long\"\n end\n end", "def to_human_size(options = {})\n number = Float(self)\n\n storage_units_format = \"%n %u\"\n\n if number.to_i < 1024\n unit = UNIT_NAMES[:byte][:other]\n storage_units_format.gsub(/%n/, number.to_i.to_s).gsub(/%u/, unit)\n else\n max_exp = STORAGE_UNITS.size - 1\n exponent = (Math.log(number) / Math.log(1024)).to_i # Convert to base 1024\n exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit\n number /= 1024 ** exponent\n\n unit_key = STORAGE_UNITS[exponent]\n unit = UNIT_NAMES[unit_key.to_sym]\n\n formatted_number = \"%.02f\" % number\n storage_units_format.gsub(/%n/, formatted_number).gsub(/%u/, unit)\n end\n end", "def to_s\n if @reverse_byte\n @field.bytes.collect { |ea| (\"%08b\" % ea).reverse }.join[0, @size]\n else\n @field.bytes.collect { |ea| (\"%08b\" % ea) }.join[0, @size]\n end\n end", "def to_s\n if value < 0\n sprintf(\"%0*.*o\", size + 3, size + 3, value).slice(3..-1)\n else\n sprintf(\"%0*.*o\", size, size, value)\n end\n end", "def bytesize\n @field.bytesize\n end", "def to_s(base=2)\n n = Bits.power_of_two(base)\n if n\n digits = (size+n-1)/n\n #{ }\"%0#{digits}d\" % @v.to_s(base)\n Numerals::Format[:fix, base: base].set_leading_zeros(digits).write(@v)\n else\n @v.to_s(base)\n end\n end", "def human_filesize(value)\n {\n 'B' => 1024,\n 'KB' => 1024 * 1024,\n 'MB' => 1024 * 1024 * 1024,\n 'GB' => 1024 * 1024 * 1024 * 1024,\n 'TB' => 1024 * 1024 * 1024 * 1024 * 1024\n }.each_pair { |e, s| return \"#{(value.to_f / (s / 1024)).round(1)} #{e}\" if value.to_i < s }\n end", "def size_to_s\n case\n when size == 0 then 'Empty'\n when size >= PETABYTE then size_to_f( PETABYTE ) + 'P'\n when size >= TERABYTE then size_to_f( TERABYTE ) + 'T'\n when size >= GIGABYTE then size_to_f( GIGABYTE ) + 'G'\n when size >= MEGABYTE then size_to_f( MEGABYTE ) + 'M'\n when size >= KILOBYTE then size_to_f( KILOBYTE ) + 'K'\n else size + 'B'\n end\n end", "def blocks_to_bytes(block_size, qty)\n size = ( block_size / 1024 ) * qty\n if size < 1000\n output = \"#{size} KB\"\n elsif size < 1000000\n output = \"#{size / 1000} MB\"\n elsif size < 1000000000\n output = \"#{size / 1000000} GB\"\n else\n output = \"#{size / 1000000000} TB\"\n end\n\n return output\nend", "def to_s\r\n\t\tbuffer_as_integer_basic_file(@contents)\r\n\tend", "def bytes_to_mb bytes=0\n bytes / MEGABYTE\n end", "def filesize_format(int)\n int\n end", "def to_n_pck\n name = @name.ljust(5, '_')\n # format(\"%02d#{name}\", @id) # old 2 byte ids\n \"#{@id}#{@score}#{name}\" # new 1 byte id\n end", "def bytesize(enc)\n end", "def bytes_from_nice_bytes( nice_bytes )\n parts = nice_bytes.downcase.split( /(kb|mb|gb)/ )\n n = Float( parts.first )\n if parts[ 1 ]\n case parts[ 1 ]\n when 'kb'\n n * Numeric::KILO.to_i\n when 'mb'\n n * Numeric::MEGA.to_i\n when 'gb'\n n * Numeric::GIGA.to_i\n end\n else\n n\n end\nend", "def pack_format\n \"a#{width}\"\n end", "def to_s\n pad_field :data\n recalc_block_len\n super\n end", "def pack_percent value\r\n pack_data(value * 65536)\r\nend", "def to_mb\n self / 1048576\n end", "def print_statistics(bv)\n diff = bv.length- encode(bv).length\n percent_reduction = (1 - (bv.length - diff).to_f/bv.length) * 100\n puts \"Original Length: #{bv.length}\"\n puts \"Encoded Length: #{encode(bv).length}\"\n puts \"Characters saved: #{diff}\"\n puts \"Percent Reduction: #{percent_reduction}%\"\n diff\nend", "def make_content_of_size(size)\n \"x\" * size\nend", "def bytes\n @number\n end", "def convert_size(block_size,blocks)\n size = block_size * blocks\n if size > SIZE_GB\n return [(size / SIZE_GB).to_i,\"GB\"]\n else\n return [(size / SIZE_MB).to_i,\"MB\"]\n end\n end", "def bytes(value)\n if value.is_a?(String)\n value =~ /([\\d\\.]+)\\s*(\\w*)/i\n size = $1.to_f\n unit = $2.strip.upcase if $2\n power = case unit\n when \"B\", \"\" then 0\n when \"K\", \"KB\" then 1\n when \"M\", \"MB\" then 2\n when \"G\", \"GB\" then 3\n when \"T\", \"TB\" then 4\n else raise UnitError\n end\n factor = 1024**power\n (size*factor).round\n elsif value.is_a?(Float)\n value.round\n elsif value.is_a?(Integer)\n value\n else\n raise ArgumentError\n end\n end", "def to_s\n\t\toutput = \"\"\n\t\t(0...@max_block).each do |i|\n\t\t\tif @decoded[i].nil?\n\t\t\t\toutput << \" \"\n\t\t\telse\n\t\t\t\toutput << \"O\"\n\t\t\tend\n\t\tend\n\t\toutput << \"\\n\\nTotal decoded:#{@num_valid}, Encoded heap size:#{@encoded.length}, Total needed:#{@max_block}, percentage:#{@num_valid/@max_block.to_f * 100}\"\n\t\treturn output\n\tend", "def bytes_from_kb kb\n\tb = (kb * 1024.0).round\nend", "def to_s22\n \tinteger=self.to_i\n \trval=''\n 22.times do\n c=(integer & 0x3F)\n rval+=@@chars64[c]\n integer =integer >> 6\n end\n return rval.reverse\n end", "def format_size(obj) #:nodoc:\n \"#{f(obj.size)} items\"\n end", "def human_filesize(filename)\n size = File.size(filename)\n case\n when size < 2**10 then '%d bytes' % size\n when size < 2**20 then '%.1fK' % (1.0 * size / 2**10)\n when size < 2**30 then '%.1fM' % (1.0 * size / 2**20)\n else '%.1fG' % (1.0 * size / 2**30)\n end\nend", "def unit2raw(str)\n val, unit = str.split()\n\n if unit.casecmp(\"kb\")\n ret = val.to_i * 1024\n elsif unit.casecmp(\"mb\")\n ret = val.to_i * 1024 * 1024\n elsif unit.casecmp(\"gb\")\n ret = val.to_i * 1024 * 1024 * 1024\n end\n \n return ret.to_s\nend", "def to_mb( val ) \n return 0 unless val\n return (\"%5.2f\" % val ) if val < 1_000_000\n \"%5.2f Mb\" % (val/1_000_000.0)\n end", "def to_str\n bytes\n end", "def to_str\n bytes\n end", "def to_str\n bytes\n end", "def to_bytes; end", "def to_bytes; end", "def file_size_string(fs)\n # n cuts off all decimal places after the second\n n = lambda{|f| f.to_s[/.*\\..{0,2}/] } \n if fs < 1024\n \"#{n.call(fs)} Bytes\"\n elsif fs <= 1024**2\n \"#{n.call(fs/1024.0)} KBytes\"\n elsif fs <= 1024**3\n \"#{n.call(fs/1024.0**2)} MBytes\"\n elsif fs <= 1024**4\n \"#{n.call(fs/1024.0**3)} GBytes\"\n end\n end", "def to_bytes\n data = items_to_bytes\n all_data = [@data_size, @next_page, @max, @min, @id, 0] + data\n $logger.logs [:data_size, @data_size, :next_page , @next_page, :max, @max, :min, @min, :id, @id].join(\",\")\n $logger.logs \"data: #{data.join(\",\")}\"\n all_data.pack('L*')\n end", "def numeric_bytes_to_hex_string(bytes)\r\n string_bytes = bytes.map do |byte|\r\n string = byte.to_s(16).upcase\r\n string = \"0#{string}\" if byte < 0x10\r\n string\r\n end\r\n string_bytes.join\r\n end", "def human_size\n number_to_human_size size\n end", "def display(b)\n\tif b < 1000\n\t\tputs \"#{b} bytes\"\n\telsif b < 1000000\n\t\ta = b.to_f\n\t\ta = a/1000\n\t\ta = a.round(1)\n\t\tputs \"#{a} kB\"\n\telsif b < 1000000000\n\t\ta = b.to_f\n\t\ta = a/1000000\n\t\ta = a.round(1)\n\t\tputs \"#{a} MB\"\n\telsif b < 1000000000000\n\t\ta = b.to_f\n\t\ta = a/1000000000\n\t\ta = a.round(1)\n\t\tputs \"#{a} GB\"\n\telse\n\t\ta = b.to_f\n\t\ta = a/1000000000000\n\t\ta = a.round(1)\n\t\tputs \"#{a} TB\"\n\tend\nend", "def total_file_size_human_readable\n total = self.total_file_size\n ActiveSupport::NumberHelper::NumberToHumanSizeConverter.convert( total, precision: 3 )\n end", "def bytesize\n case value\n when NilClass\n 0\n when String\n @value.bytesize\n else\n @s ||= Marshal.dump(@value).bytesize\n end\n end", "def convert_int(int)\n [int].pack('s>')\n end", "def size\n ['o', 'k', 'G'].inject(super.to_f) do |s, unit|\n # recusively divide by 1024 until...\n if s.is_a?(Float) && s >= 1024\n s = s / 1024\n # we format it here with the unit\n elsif !s.is_a?(String)\n s = \"#{s.to_s.gsub(/(\\.\\d{3})\\d+$/, \"\\\\1\")} #{unit}\"\n end\n s\n end\n end", "def convert_to_bytes(size, unit)\n size.to_f * UNITS_FACTOR[unit]\n end", "def to_s(); self.unpad[0] end", "def dump_bytes(label:, data:, per_line: 16, format: '$%02X')\n print \"#{label}:\"\n puts data.each_slice(per_line).map { |line|\n \"\\t.byte \" +\n line.map {|byte| format % byte }.join(',')\n }.join \"\\n\"\n print \"\\n\"\n end", "def bytes_representation_of(megabytes)\n megabytes * 1024 * 1024\n end", "def bytesize_of(member)\n self.class.bytesize_of(member)\n end", "def bytesize\n stream_size\n end", "def display_size\n s = self.body.size\n\n if s > 1024 * 1024\n return sprintf(\"%.1f\", s.to_f / 1024 / 1024) + 'M'\n else\n return (s / 1024).to_s + 'K'\n end\n end", "def human_readable_file_size(num, type='file')\n string = ''\n factor = 1024\n suffixes = ['KB', 'MB', 'GB', 'TB']\n if type == 'base10'\n factor = 1000\n suffixes = ['', 'K', 'M', 'B']\n end\n\n if num < factor\n string = \"#{num}#{suffixes[0]}\"\n elsif num < factor**2\n string = \"#{((num) / factor).round(1)}#{suffixes[1]}\"\n elsif num < factor**3\n string = \"#{((num) / (factor*factor)).round(1)}#{suffixes[2]}\"\n else\n string = \"#{((num) / (factor*factor*factor)).round(1)}#{suffixes[3]}\"\n end\n\n return string\nend", "def number\n \"#{self.id}\".rjust(8, \"0\")\n end", "def number\n \"#{self.id}\".rjust(8, \"0\")\n end", "def number\n \"#{self.id}\".rjust(8, \"0\")\n end", "def to_filesize(size)\n # size = '0' if size.nil?\n size = size.to_s\n\n units = {\n 'B' => 1.0 / (1024 * 1024),\n 'K' => 1.0 / 1024,\n 'M' => 1,\n 'G' => 1024,\n 'T' => 1024 * 1024\n }\n\n unit = size[-1]\n unit = 'B' unless units.key?(unit)\n\n \"#{size[0..-1].to_f * units[unit]}M\"\n end", "def to_s\n value.unpack('B*').first[0...size]\n end", "def filesize_format\n FILESIZE_FORMAT.each do |format, size|\n return format % (self.to_f / size) if self >= size\n end\n\n self.to_s\n end", "def to_s\n packet = build_packet\n @packet_size = packet.length\n return [@packet_size].pack(\"V\") + packet\n end", "def input_to_bytes(size)\n case size\n when /g|gb/i\n size.to_i.gb.to_bytes.to_i\n when /m|mb/i\n size.to_i.mb.to_bytes.to_i\n when /t|tb/i\n size.to_i.tb.to_bytes.to_i\n else\n size.to_i.gb.to_bytes.to_i\n end\n end", "def n_to_s( n )\n s = \"\"\n while( n > 0 )\n s = ( n & 0xFF ).chr + s\n n >>= 8\n end\n s\n end", "def to_tb\n self / 1099511627776\n end", "def encrypt message\n raw = message.bytes.reverse!\n raw << raw.size\n # strip_leading_zero_bytes raw\n raw.each do |item|\n puts item\n end\nend", "def byte32(data, size=32)\n return data.to_s.rjust(size*2, '0') # Add zeros to the left\n end", "def to_s\r\n @bitstring.reverse.scan(/.{1,8}/).map {|s| s.reverse}.reverse.map {|bin| \"\" << bin.to_i(2)}.join\r\n end", "def convert_truncatable_string obj\n make_truncatable_string obj.value, obj.truncated_byte_count\n end", "def pretty_memsize(memsize, unit=nil)\n un = nil\n case unit\n when nil\n un = 1\n when \"k\"\n un = 1_000\n when \"m\"\n un = 1_000_000\n when \"g\"\n un = 1_000_000_000\n else\n raise \"Error! Invalid unit '#{unit}'\"\n end\n\n res = memsize.to_i * un\n len = res.to_s.size \n\n if len < 4 \n return res.to_s + \" B\"\n elsif len < 7\n return (res/1_000).to_i.to_s + \" kB\"\n elsif len < 10\n return (res/1_000_000).to_i.to_s + \" MB\"\n elsif len < 13\n return (res/1_000_000_000).to_i.to_s + \" GB\"\n elsif len < 16\n return (res/1_000_000_000_000).to_i.to_s + \" TB\"\n elsif len < 19\n return (res/1_000_000_000_000_000).to_i.to_s + \" PB\"\n elsif len < 22\n return (res/1_000_000_000_000_000_000).to_i.to_s + \" EB\"\n else\n return (res/1_000_000_000_000_000_000_000).to_i.to_s + \" ZB\"\n end\nend", "def fmtstr_target_short(value, num_printed)\n\t\tif value < num_printed\n\t\t\treturn (0x10000 - num_printed) + value\n\t\tend\n\t\treturn value - num_printed\n\tend", "def convert_bytes_to_unit(data:, unit:)\n case unit\n when 'kb' then @usage = data.to_i / 1024\n when 'mb' then @usage = data.to_i / 1024 / 1024\n when 'gb' then @usage = data.to_i / 1024 / 1024 / 1024\n end\n end", "def to_human(len = 3)\n\n\t\tunit = ''\n\t\tn = self\n\t\tn = self.to_f unless n.is_a? Numeric\n\n\t\tif n > 1100\n\t\t\tn /= 1000.0\n\t\t\tunit = 'k'\n\t\tend\n\n\t\tif n > 1100\n\t\t\tn /= 1000.0\n\t\t\tunit = 'm'\n\t\tend\n\n\t\tif n > 1100\n\t\t\tn /= 1000.0\n\t\t\tunit = 'T'\n\t\tend\n\n\t\t# now we have the unit and the number we want to format it in a \n\t\t# nice way so there is a consistant number of characters\n\t\ts = n.to_s\n\t\tif s.length > len\n\t\t\ts = s[0..len]\n\t\t\ts.chop! if s[-1] == '.'\n\t\tend\n\n\t\t\"#{s}#{unit}\"\n\tend", "def h(number)\n number.to_s(16)\n end", "def display_size(size)\n size = number_to_human_size(size.to_i + 1) if size.is_a?(Numeric) || size =~ /^[0-9]+$/ # assumes bytes\n size.to_s\n end", "def number_to_human_size(number, options = {})\n SitemapGenerator::Utilities.symbolize_keys!(options)\n\n number = begin\n Float(number)\n rescue ArgumentError, TypeError\n if options[:raise]\n raise InvalidNumberError, number\n else\n return number\n end\n end\n\n defaults = {\n :separator => \".\",\n :delimiter => \",\",\n :precision => 3,\n :significant => false,\n :strip_insignificant_zeros => false\n }\n human = {\n :delimiter => \"\",\n :precision => 3,\n :significant => true,\n :strip_insignificant_zeros => true\n }\n defaults = defaults.merge(human)\n options = SitemapGenerator::Utilities.reverse_merge(options, defaults)\n #for backwards compatibility with those that didn't add strip_insignificant_zeros to their locale files\n options[:strip_insignificant_zeros] = true if not options.key?(:strip_insignificant_zeros)\n\n storage_units_format = \"%n %u\"\n\n if number.to_i < 1024\n unit = number.to_i > 1 || number.to_i == 0 ? 'Bytes' : 'Byte'\n storage_units_format.gsub(/%n/, number.to_i.to_s).gsub(/%u/, unit)\n else\n max_exp = STORAGE_UNITS.size - 1\n exponent = (Math.log(number) / Math.log(1024)).to_i # Convert to base 1024\n exponent = max_exp if exponent > max_exp # we need this to avoid overflow for the highest unit\n number /= 1024 ** exponent\n\n unit_key = STORAGE_UNITS[exponent]\n units = {\n :byte => \"Bytes\",\n :kb => \"KB\",\n :mb => \"MB\",\n :gb => \"GB\",\n :tb => \"TB\"\n }\n unit = units[unit_key]\n formatted_number = number_with_precision(number, options)\n storage_units_format.gsub(/%n/, formatted_number).gsub(/%u/, unit)\n end\n end", "def decode\n \"#{@width}%x#{@height}+#{offset_x}+#{offset_y}\"\n end", "def s_to_n( s )\n n = 0\n s.each_byte do |b|\n n = n * 256 + b\n end\n n\nend", "def to_s(base = 2)\n case base \n when 2\n inject(\"\") { |a, b| a + \"%0#{@bits}b \" % b }.strip\n when 10\n self.inject(\"\") { |a, b| a + \"%1d \" % b }.strip\n else\n raise(ArgumentError, \"unsupported base\")\n end\n end", "def bytes; end", "def s_to_n( s )\n n = 0\n s.each_byte do |b| \n n = n * 256 + b \n end\n n\n end", "def inspect\n \"%-40s @ 0x%08x [%d kB] => %s\" % [self.path.yellow, off_len_low, data_len_low>>10, main_type]\n end" ]
[ "0.70848453", "0.70743954", "0.6750771", "0.6711211", "0.66790736", "0.66623867", "0.6643506", "0.6584201", "0.6547346", "0.6420426", "0.6404685", "0.6282758", "0.62650555", "0.62376094", "0.6218412", "0.621097", "0.6174452", "0.6171634", "0.61682737", "0.61593324", "0.6157", "0.6091309", "0.6073419", "0.6040379", "0.5971946", "0.596723", "0.5907114", "0.589212", "0.5877796", "0.58564913", "0.58509266", "0.57629925", "0.57610595", "0.57582873", "0.5751953", "0.5746815", "0.57084775", "0.5707907", "0.57038796", "0.5700911", "0.56870246", "0.5670353", "0.56646883", "0.5664507", "0.56572014", "0.5641956", "0.56371677", "0.56257045", "0.56132513", "0.559746", "0.5584895", "0.5584895", "0.5584895", "0.5578423", "0.5578423", "0.5577554", "0.5573793", "0.5569428", "0.5564496", "0.5555586", "0.5535038", "0.5534127", "0.55281067", "0.55224586", "0.55192864", "0.5516709", "0.55138975", "0.5513137", "0.55112684", "0.55052745", "0.55002034", "0.5499408", "0.54898405", "0.54898405", "0.54898405", "0.5489442", "0.5488656", "0.54873914", "0.54868424", "0.54839396", "0.54808867", "0.5479452", "0.54750377", "0.5473057", "0.5441085", "0.54396856", "0.54271865", "0.54207224", "0.542046", "0.5411707", "0.54068947", "0.5405948", "0.5405519", "0.5403909", "0.5392776", "0.53880584", "0.53864354", "0.53860086", "0.53734004" ]
0.73856795
0
Wheter this user is a super admin. Short for has_permission(:is_super_admin)
def is_super_admin? ((!user_group_id.nil?) && has_permission(:is_super_admin)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_super_admin?\n user_type == 'super_admin'\n end", "def is_super_admin?\n self.is_admin?\n end", "def is_super_admin?\n if admin_type == 1\n return true\n else\n return false\n end\n end", "def is_superadmin\n user = UserAdmin.find_by_user_id(current_user.id)\n if user and user.level == 3\n return true || false\n end\n end", "def is_super_admin\n return self.role == :super_admin.to_s\n end", "def superadmin?\n current_user.has_role? :superadmin\n end", "def super_admin?\n self.role.role_name == \"super_admin\"\n end", "def superadmin?\n\t\trole == \"superadmin\"\n\tend", "def super_admin?\n self.role == \"Super Admin\"\n end", "def is_super_user?\n @super_user\n end", "def super_admin?\n admin\n end", "def super_admin?\n #logged_in? && current_user.has_role?('super_admin')\n logged_in? && (current_user.roles.map{|role| role.name}).include?('super_admin')\n end", "def is_current_super_admin?\n if current_admin \n if current_admin.super_admin?\n return true\n else \n return false\n end \n else \n return false\n end \n end", "def admin?\n super_user?\n end", "def is_admin?\n determine_user_role\n if @admin_user || @superadmin_user\n return true\n else\n return false\n end\n end", "def superadmin?\n return true if login_name == \"root\" or login_name == \"administrator\"\n return false\n end", "def super_user? \n current_user.role.role == \"Super\" \n end", "def is_superuser?\n superuser? && supermode?\n end", "def authorized_to_act_as_superuser?\n member_of? Ddr::Auth.superuser_group\n end", "def is_admin?(user)\n user.admin > 0\n end", "def superuser?\n member_of_group?(\"Superusers\")\n end", "def is_superuser?(*args)\n\t\t\tself.role_names.include?('superuser')\n\t\tend", "def is_admin?\n user_type == 'super_admin' || user_type == 'admin'\n end", "def is_superuser?(*args)\n\t\tself.role_names.include?('superuser')\n\tend", "def is_superadmin=(value)\n value = ActiveModel::Type::Boolean.new.cast(value)\n if value\n add_role :superadmin\n else\n remove_role :superadmin\n end\n end", "def verify_super_admin(user)\n if user.role.blank? || user.role.nome != \"SuperAdmin\"\n return true\n end\n\n if current_user.role.nome == \"SuperAdmin\"\n return true\n end\n\n return false\n end", "def is_user_admin?\n user_active && user_active.permission_level == 2\n end", "def is_admin?\n self.is_admin == \"true\"\n end", "def normal_user?\n self.admin ==false\n end", "def admin_user?\n self.admin ==true\n end", "def is_admin?\n is_admin == 1\n end", "def admin_access?\n admin?\n end", "def current_user_is_admin\n\t\ttrue if current_user.admin == 't'\n\tend", "def superuser?\n env && env.key?(\"warden\") && env[\"warden\"].authenticate?(scope: :superuser)\n end", "def user_admin?\n user_logged_in? && @current_user.type == 'Admin'\n end", "def super?\n logged_in? && current_user.super\n end", "def admin?\n if user_signed_in? && current_user.user_level == 1\n return true\n end\n return false\n end", "def is_admin? \n return (user_signed_in? and current_user.role == 1)\n end", "def is_admin?\n if user_signed_in?\n return current_user.is_admin\n else\n return false\n end\n end", "def is_admin\n if self.role_as_admin.size > 0\n return true\n else\n return false\n end\n end", "def super_user?\n super_user\n end", "def admin_user?\n if current_user != nil\n !!current_user.admin\n end\n end", "def is_super?\n state = false\n roles.each do |role|\n state = true if role.name.eql?(ENV['SUPER_N'] || ENV['SUPER_C']) && user_roles.find_by(role_id: role.id, active: true)\n end\n state\n end", "def is_admin?\n current_user and current_user.is_admin?\n end", "def admin_user?\n\t\treturn self.user_category == \"admin\"\n\tend", "def is_admin?\n ((!user_group_id.nil?) && has_permission(:is_admin))\n end", "def must_be_super_admin\n unless current_user.role.name.eql?('Super Admin')\n flash[:error] = \"Access denied.\"\n redirect_to root_url\n end\n end", "def isAdmin?\n if session[:perm] == 1\n return true;\n else\n return false;\n end\n end", "def is_admin?\n level >= USER_LEVELS[\"system_admin\"]\n end", "def admin?\n @user.admin?\n end", "def admin_user?\n current_user.admin\n end", "def admin?\n self.admin_user\n end", "def is_admin\n current_user.admin?\n end", "def is_admin_user?\n if user_signed_in? == false\n @is_admin = false\n else\n @is_admin = (current_user.email == \"jpwendt@asu.edu\")\n end\n end", "def admin_authorized?\n\t\tif @user\n\t\t\t@user.level >= ADMIN_USER_LEVEL \n\t\telse\n\t\t\tnil\n\t\tend\n\tend", "def current_user_is_admin?\n signed_in? && current_user.admin?\n end", "def admin?\n user.admin?\n end", "def user_accessible?\n is_admin\n end", "def is_admin\n user = UserAdmin.find_by_user_id(current_user.id)\n if user and user.level > 1\n return true || false\n end\n end", "def is_admin\n return [:admin.to_s, :super_admin.to_s].include?(self.role)\n end", "def is_admin?\n signed_in? && current_user.admin?\n end", "def is_admin?\n @is_admin.nil? ? (@is_admin = (has_role?(:admin) || is_sysadmin?)) : @is_admin\n end", "def is_admin?\n current_user && current_user.try(:admin?)\n end", "def sys_admin?\n self.user && self.user.role_names.include?('admin') ? true : false\n end", "def admin_user\n @current_user.admin?\n end", "def user_is_admin\n unless logged_in? and is_admin?\n respond_with_error(\n \"You must have admin permissions to perform this action.\", \n root_path)\n end\n end", "def admin?\n user_signed_in? && current_user.admin?\n end", "def accessible?(context)\n # context[:current_user].is_super_admin?\n true\n end", "def admin_user?\n (current_user.role == 'admin') if logged_in?\n end", "def admin?\n current_user.admin?\n end", "def is_admin?\n current_user && current_user.admin\n end", "def is_admin?\n current_user && current_user.admin?\n end", "def is_admin?\n admin?\n end", "def is_super\n if !is_super?\n flash[:danger] = \"Unauthorized. You are not a super user.\"\n redirect_to home_path\n end\n end", "def can_super_admin?\n return self.can_add_orgs? || self.can_grant_api_to_orgs? || self.can_change_org?\n end", "def is_admin?\n !!current_user.admin if !!current_user\n end", "def is_admin?\n current_user ? current_user.login == 'admin' : false\n end", "def is_admin?\n if @is_admin.nil?\n @is_admin = (current_user.has_role?('admin') == true)\n end\n \n @is_admin\n end", "def is_admin\n admin?\n end", "def is_admin?\n\t\treturn self.usertype == \"admin\"\n\tend", "def admin?\n return ( self.user_type == User::USER_TYPE_ADMIN )\n end", "def user_is_admin?\n\tbegin\n\t `gpresult /r /scope user`.split.include? \"Admin\"\n\trescue\n\t false\n\tend\n end", "def is_admin\n\t\t\tif @admin == \"TRUE\"\n\t\t\t\treturn true\n\t\t\tend\n\t\t\treturn false\n\t\tend", "def is_admin?\n self.admin\n end", "def is_admin?\n self.admin\n end", "def is_admin?\n self.admin\n end", "def is_admin?\n self.admin\n end", "def is_admin?\n\t\tself.admin\n\tend", "def has_admin_access?\n admin? || moderator?\n end", "def is_administrator?(user)\n user.admin == 2\n end", "def current_user_is_admin?\n current_user && current_user.is_admin\n end", "def is_admin?\n current_user && current_user.admin?\n end", "def can_edit_user?(user)\n if self.has_role?('superuser')\n return true\n elsif !self.has_role?('admin')\n return false\n end\n return !(user.has_role?('superuser') || user.has_role?('admin'))\n end", "def admin?\n @current_user.admin?\n end", "def is_admin?\n if valid_session?\n current_user.admin == true\n end\n end", "def has_admin?\n has_auth? && current_person.is_admin\n end", "def admin?\n User.admin_logged_in?\n end", "def is_admin?\n true if admin_rights == \"true\"\n end", "def average_roles_has_super_user?\n return self.roles_as(:identifiers).include?(AverageRoles.configuration.super_user) unless AverageRoles.configuration.super_user == nil\n return false\n end", "def admin?\n super? or group_name == 'admin'\n end" ]
[ "0.8697247", "0.8686085", "0.8585433", "0.8503495", "0.8499921", "0.8472378", "0.83544934", "0.8305156", "0.82714045", "0.8228453", "0.8224789", "0.8162704", "0.8150583", "0.8124374", "0.80108666", "0.7961289", "0.79499114", "0.79121536", "0.7907736", "0.78979313", "0.78956825", "0.7893797", "0.789054", "0.7859447", "0.78588223", "0.7800721", "0.7776518", "0.7746587", "0.7705438", "0.7674403", "0.7626579", "0.76258665", "0.7612531", "0.76094085", "0.7580513", "0.7578729", "0.75626343", "0.7561272", "0.7553365", "0.75497967", "0.75469095", "0.7541601", "0.7531335", "0.75282836", "0.7519488", "0.7506515", "0.7498143", "0.7495268", "0.7495264", "0.7488481", "0.74871445", "0.7486403", "0.74842346", "0.7481402", "0.74771607", "0.7464507", "0.74607676", "0.7454705", "0.7451726", "0.7448774", "0.744158", "0.74405813", "0.743395", "0.7433062", "0.7430399", "0.743034", "0.7423683", "0.7416164", "0.7415097", "0.74051815", "0.73962563", "0.7395811", "0.7394352", "0.739391", "0.7392198", "0.7391404", "0.73882395", "0.7387729", "0.73799515", "0.7376328", "0.7374982", "0.73746586", "0.7373655", "0.73711866", "0.73711866", "0.73711866", "0.73711866", "0.7369318", "0.73639923", "0.73550016", "0.73533833", "0.7348079", "0.7348077", "0.7345639", "0.734019", "0.73394734", "0.73393255", "0.7337601", "0.7335404", "0.7331296" ]
0.8830652
0
Whether this user is an admin. Short for has_permission(:is_admin)
def is_admin? ((!user_group_id.nil?) && has_permission(:is_admin)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def admin?\n user_signed_in? && current_user.admin?\n end", "def admin_user?\n if current_user != nil\n !!current_user.admin\n end\n end", "def is_admin?(user)\n user.admin > 0\n end", "def admin?\n current_user.admin?\n end", "def is_admin?\n determine_user_role\n if @admin_user || @superadmin_user\n return true\n else\n return false\n end\n end", "def is_admin?\n self.is_admin == \"true\"\n end", "def is_admin?\n current_user and current_user.is_admin?\n end", "def user_admin?\n user_logged_in? && @current_user.type == 'Admin'\n end", "def admin?\n logged_in? && current_user.admin\n end", "def admin?\n return ( self.user_type == User::USER_TYPE_ADMIN )\n end", "def is_admin?\n if user_signed_in?\n return current_user.is_admin\n else\n return false\n end\n end", "def admin?\n user = check_user\n user.role == User.role_types['Admin']\n end", "def admin?\n if(@current_user)\n @current_user.admin?\n end\n end", "def admin_access?\n admin?\n end", "def admin?\n @user = current_user.is_admin?\n end", "def is_admin? \n return (user_signed_in? and current_user.role == 1)\n end", "def admin?\n @user.admin?\n end", "def admin_user?\n (current_user.role == 'admin') if logged_in?\n end", "def admin?\n\t\tcurrent_user.try(:admin)\n\tend", "def admin?\n user.admin?\n end", "def admin?\n\t\tself.public_admin? || self.private_admin?\n\tend", "def admin?\n @current_user.admin?\n end", "def admin?\n role == :admin\n end", "def admin\n is_user_in_role(ADMIN_ROLE_ID)\n end", "def is_admin?\n if @is_admin.nil?\n @is_admin = (current_user.has_role?('admin') == true)\n end\n \n @is_admin\n end", "def is_user_admin?\n user_active && user_active.permission_level == 2\n end", "def admin?\n\t\thas_role?(:admin)\n\tend", "def is_admin?\n current_user && current_user.try(:admin?)\n end", "def admin? \n (logged_in? && current_member.admin?) ? true : false\n end", "def is_admin?\n user_type == 'super_admin' || user_type == 'admin'\n end", "def is_admin?\n @is_admin.nil? ? (@is_admin = (has_role?(:admin) || is_sysadmin?)) : @is_admin\n end", "def is_admin\n\t\t\tif @admin == \"TRUE\"\n\t\t\t\treturn true\n\t\t\tend\n\t\t\treturn false\n\t\tend", "def admin?\n if user_signed_in? && current_user.user_level == 1\n return true\n end\n return false\n end", "def is_admin?\n is_admin == 1\n end", "def is_admin?\n role = self.role\n\n if(role == 'admin')\n return true\n else\n return false\n end\n end", "def is_admin\n if self.role_as_admin.size > 0\n return true\n else\n return false\n end\n end", "def admin_user\n @current_user.admin?\n end", "def is_admin?\n return true if is_logged_in? && (current_user.admin? || current_admin)\n end", "def admin?\n user_role_id == UserRole::ADMIN\n end", "def admin_user?\n member_type == MEMBER_TYPE[:admin]\n end", "def is_admin?\n !!current_user.admin if !!current_user\n end", "def is_admin\n user = UserAdmin.find_by_user_id(current_user.id)\n if user and user.level > 1\n return true || false\n end\n end", "def admin?\n User.admin_logged_in?\n end", "def admin?\n @current_user && @current_user.has_role?(:admin)\n end", "def admin?\n role?(UserRoles::ADMIN)\n end", "def admin_user?\n current_user.admin\n end", "def has_admin?\n has_auth? && current_person.is_admin\n end", "def admin?\n self.user_type == TYPES[:admin]\n end", "def admin?\n has_role?(:admin)\n end", "def admin_user?\n self.admin ==true\n end", "def is_admin?\n current_user && current_user.admin\n end", "def is_admin?(user_id)\n\t\treturn admin == user_id\n\tend", "def is_admin?\n admin?\n end", "def is_admin?\n\t\tself.admin\n\tend", "def admin?\n self.admin\n end", "def admin?\n current_user.admin?\n end", "def admin?\n has_role?(:admin) || has_role?(:admin, :any)\n end", "def isAdmin?\n return @is_admin\n end", "def admin?\n\t\tuser_session.admin?\n\tend", "def admin?(user)\n user.role_names.include?('cmsadmin')\n end", "def is_admin?\n current_user && current_user.admin?\n end", "def is_admin\n admin?\n end", "def is_admin?\n return false if !current_user\n current_user.admin?\n end", "def admin?\n application_user.admin\n end", "def is_admin?\n self.role == ROLES[:admin]\n end", "def isAdmin?\n if session[:perm] == 1\n return true;\n else\n return false;\n end\n end", "def user_is_admin\n unless logged_in? and is_admin?\n respond_with_error(\n \"You must have admin permissions to perform this action.\", \n root_path)\n end\n end", "def is_admin?\n self.admin\n end", "def is_admin?\n self.admin\n end", "def is_admin?\n self.admin\n end", "def is_admin?\n self.admin\n end", "def is_admin?\n if valid_session?\n current_user.admin == true\n end\n end", "def is_admin?\n signed_in? && current_user.admin?\n end", "def is_admin?\n logged_in? && current_user && current_user.admin\n end", "def is_admin?\n return false unless logged_in?\n user = User.find_by_id(current_user)\n user.userstatus.status == \"admin\" ? true : false\n end", "def admin?\n if self.role == 'admin'\n true\n else\n false\n end\n end", "def admin?\n logged_in? && current_user.admin?\n end", "def admin?\n logged_in? and current_user.admin?\n end", "def is_admin\n current_user.admin?\n end", "def admin?\n logged_in? && current_user.has_role?(:admin)\n end", "def admin?\n logged_in? && current_user.has_role?(:admin)\n end", "def admin?\n logged_in? && current_user.has_role?(:admin)\n end", "def admin?\n logged_in? && current_user.has_role?(:admin)\n end", "def admin?\n logged_in? && current_user.has_role?(:admin)\n end", "def admin?\r\n has_role?(\"admin\")\r\n end", "def current_user_is_admin\n\t\ttrue if current_user.admin == 't'\n\tend", "def admin?\n self.admin_user\n end", "def current_user_is_admin?\n signed_in? && current_user.admin?\n end", "def is_admin?\n admin\n end", "def is_admin?\n admin\n end", "def is_admin?(user)\n return false if Access::Core.is_guest?(user)\n\n user.has_role?(:admin)\n end", "def is_admin?\n current_user.role.eql?(\"admin\")\n end", "def admin_authorized?\n\t\tif @user\n\t\t\t@user.level >= ADMIN_USER_LEVEL \n\t\telse\n\t\t\tnil\n\t\tend\n\tend", "def is_admin_user?\n if user_signed_in? == false\n @is_admin = false\n else\n @is_admin = (current_user.email == \"jpwendt@asu.edu\")\n end\n end", "def is_admin?\n\t\treturn self.usertype == \"admin\"\n\tend", "def has_admin_access?\n admin? || moderator?\n end", "def is_admin?\n true if admin_rights == \"true\"\n end", "def is_admin?\n if logged_in?\n current_user.role == \"Admin\"\n end\n end", "def admin_user?\n\t\treturn self.user_category == \"admin\"\n\tend", "def is_admin? (user)\n get_admins.any? {|admin|\n user =~ admin\n } && user.authed?\n end" ]
[ "0.86431015", "0.8620019", "0.8609989", "0.8607026", "0.85214525", "0.8516616", "0.8508861", "0.8483408", "0.8480497", "0.8472581", "0.8457309", "0.8447519", "0.84435105", "0.8438134", "0.843688", "0.8429784", "0.8428747", "0.8387753", "0.8387197", "0.8365594", "0.8360546", "0.8342345", "0.83355814", "0.8332759", "0.83261144", "0.8320853", "0.83194715", "0.8313938", "0.83116597", "0.83014196", "0.82928157", "0.82927096", "0.8291494", "0.82911915", "0.8291122", "0.828589", "0.8285246", "0.8280409", "0.8267307", "0.8267002", "0.82664144", "0.8257597", "0.8257554", "0.8254309", "0.82501745", "0.824628", "0.8244073", "0.8236569", "0.8233784", "0.82259434", "0.82258934", "0.8225827", "0.822477", "0.82232094", "0.82133263", "0.82118034", "0.8211394", "0.8202793", "0.8198962", "0.81966764", "0.81952524", "0.8190954", "0.8177924", "0.8177498", "0.8170344", "0.81628364", "0.81627303", "0.815992", "0.815992", "0.815992", "0.815992", "0.8156975", "0.8156077", "0.8155279", "0.8154196", "0.81529486", "0.8145045", "0.81443673", "0.8137315", "0.8132543", "0.8132543", "0.8132543", "0.8132543", "0.8132543", "0.8132436", "0.8121799", "0.8120916", "0.8107876", "0.8105296", "0.8105296", "0.8100796", "0.80928016", "0.8088678", "0.80877954", "0.80868524", "0.8082383", "0.807814", "0.8076292", "0.8074818", "0.80744296" ]
0.83427614
21
true if has booking between 2 dates (format date or string)
def has_bookings_at_period(checkin_date, checkout_date) # convert to date if string checkin_date = Date.parse(checkin_date) if checkin_date.is_a? String checkout_date = Date.parse(checkout_date) if checkout_date.is_a? String # if no consistency in period return true if checkout_date < checkout_date # prevent charging dataset for more than 100 days long return true if (checkout_date-checkin_date) >= 100 # raise error ? self.bookings.each do |booking| (booking.checkin..booking.checkout).each do |d| # booking for this outfit at these dates return true if (checkin_date..checkout_date).include? d end end # no booking at this date return false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def availability?(start_date, end_date)\n start_date = Date.parse(start_date)\n end_date = Date.parse(end_date)\n bookings = self.get_bookings(id: self.id)\n if bookings.length > 0\n bookings.each do |booking|\n if (start_date > booking.start_date && start_date < booking.end_date) || (end_date > booking.start_date && end_date < booking.end_date)\n false\n end\n end\n true\n end\n end", "def date_between?(date, from, to)\n date = date.strftime(\"%Y-%m-%d\") if date.class == Time || date.class == Date\n from = from.strftime(\"%Y-%m-%d\") if from.class == Time || from.class == Date\n to = to.strftime(\"%Y-%m-%d\") if to.class == Time || to.class == Date\n time_pattern = /\\d{4}-\\d{2}-\\d{2}/\n raise ArgumentError if date.scan(time_pattern).empty?\n raise ArgumentError if from.scan(time_pattern).empty?\n raise ArgumentError if to.scan(time_pattern).empty?\n date >= from && date <= to\n end", "def conflicts_with_date?(date)\n date.between(self.start_date, self.end_date)\n end", "def available?(span_start, span_end)\n if span_start.class != Date \n start_date = Date.parse(span_start) \n else \n start_date = span_start\n end\n if span_end.class != Date\n end_date = Date.parse(span_end)\n else\n end_date = span_end\n end\n if self.reservations.any?{ |reservation| reservation.checkout > start_date && reservation.checkout < end_date || reservation.checkin > start_date && reservation.checkout < end_date || reservation.checkin > start_date && reservation.checkin < end_date } === false\n return true\n else \n false\n end\n end", "def valid_start_and_end_dates?\n return false unless start.present? && self.end.present?\n start <= self.end\n end", "def bookable?(date)\n date < booking_date_limit\n end", "def available?(start_date, end_date)\n unless self.reservations.any? { |res| start_date.to_date.between?(res.checkin, res.checkout) || end_date.to_date.between?(res.checkin, res.checkout)} \n true\n end\n end", "def correct_dates?(object)\n object.date_from <= object.date_to\n end", "def date_in_range?(first, date, last)\n first <= date && date <= last\n end", "def is_available_between(start_date, end_date)\n number_of_booking = self.bookings.where('(? <= bookings.start_date AND bookings.start_date <= ?)\n OR (? <= bookings.end_date AND bookings.end_date <= ?)\n OR (bookings.start_date <= ? AND ? <= bookings.end_date)\n OR (bookings.start_date <= ? AND ? <= bookings.end_date)',\n start_date, end_date, start_date, end_date, start_date, start_date, end_date, end_date).count\n\n return number_of_booking <= 0\n end", "def correct?\n starts_at < ends_at && starts_at.to_date == ends_at.to_date\n end", "def date_include?(date_range)\n # if date >= @checkin_date && date <= @checkout_date\n start_date = date_range.checkin_date\n end_date = date_range.checkout_date\n\n if start_date >= @checkin_date && end_date <= @checkout_date\n return true\n else\n return false\n end\n end", "def between_dates(sd, es)\n return true if sd <= self.start_date && es >= self.end_date \n return false\n end", "def between?(first_day, last_day)\n ((self.ends_at.to_date >= first_day) && (self.ends_at.to_date <= last_day)) || ((self.starts_at.to_date >= first_day) && (self.starts_at.to_date <= last_day))\n end", "def checkIfBooked\n booking_start_time = Time.parse(get_booking[\"date\"].to_s)\n hours_booked = get_booking[\"hours_booked\"].to_i\n booking_stop_time = booking_start_time + (3600 * hours_booked)\n dates_booked = get_tutor[\"dates_booked\"]\n lesson_block = 14400\n bookings_array = []\n dates_booked.each do |date|\n start_time = Time.parse(date[\"date\"].to_s)\n stop_time = start_time + lesson_block\n if(booking_start_time >= start_time && booking_start_time <= stop_time)\n bookings_array.push(date)\n elsif(start_time >= booking_start_time && start_time <= booking_stop_time)\n bookings_array.push(date)\n end\n \n end\n if(bookings_array.length >= 1)\n return true\n else\n return false\n end\n end", "def is_date_range_visible(from_date, to_date)\n found = false\n if (date_from.text.include? from_date) && (date_to.text.include? to_date)\n found = true\n end\n found\n end", "def check_date_ranges\n today = Date.today\n !!today.between?(start_date.to_date, end_date.to_date)\n end", "def is_date_range?\n start_time.present? && end_time.present?\n end", "def validate_date?(start_date,end_date)\n\t\tstart_date <= end_date\n\tend", "def include?(date)\n unless date.instance_of?(Date)\n raise ArgumentError, \"Parameters must be of class Date\"\n end\n\n return date >= @start_date && date < @end_date\n end", "def available?(date_range)\n if reservations.length == 0\n return true\n end\n if reservations.any? {|r| r.overlap?(date_range)}\n return false\n else\n return true\n end\n end", "def check_overlapping_dates\n\t # compare this new booking againsts existing bookings\n\t listing.reservations.each do |old_reservation|\n\t if overlap?(self, old_reservation)\n\t return errors.add(:overlapping_dates, \"The booking dates conflict with existing bookings\") \n\t end\n\t end\n\tend", "def date_range_overlap?(start_date_one, end_date_one, start_date_two, end_date_two)\n if start_date_one < end_date_two && start_date_two < end_date_one\n return true\n else\n return false\n end\n end", "def overlaps(other_date_range)\n if contains(other_date_range.start_date) || contains(other_date_range.end_date)\n true\n elsif other_date_range.contains(@start_date) && other_date_range.contains(@end_date)\n true\n else\n false\n end\n end", "def overlapping_dates\n reservation = Reservation.find(params[:id])\n space = reservation.space\n\n start_date = reservation.start_date.to_date\n end_date = reservation.end_date.to_date\n\n confirmed_bookings = space.reservations.where(approved: true)\n\n check = confirmed_bookings.where('? <= DATE(start_date) AND DATE(end_date) <= ?', start_date, end_date)\n return unless check.any?\n\n flash[:danger] = 'You already confirmed another booking request with overlapping dates.'\n redirect_to your_reservations_path\n end", "def check_overlapping_dates\n # compare this new reservation againsts existing reservations\n if start_date.present? and end_date.present?\n listing.reservations.each do |old_reservation|\n if overlap?(self, old_reservation)\n return errors.add(:The_dates_are_not_available, \"\")\n end\n end\n end\n end", "def check_overlapping_dates\n #compare this new reservation against existing reservations\n listing.reservations.each do |old_booking|\n if overlap?(self, old_booking)\n return errors.add(:overlapping_dates, \"The booking dates are not available\")\n end\n end\n\n end", "def date_overlap?(date_range)\n #(@checkin_date - end_date) * (start_date - @checkout_date) >= 0\n # Will this method work?\n start_date = date_range.checkin_date\n end_date = date_range.checkout_date\n\n if (start_date <= @checkout_date) && (end_date > @checkin_date)\n return true\n else\n return false\n # raise ArgumentError.new(\"#{start_date} and #{end_date} are outside the date range\")\n end\n end", "def overlaps?(other)\n start <= other.end_date && other.start <= self.end_date\n end", "def check_overlapping_dates\n # compare this new booking againsts existing bookings\n listing.bookings.each do |old_booking|\n if overlap?(self, old_booking)\n return errors.add(:overlapping_dates, \"The booking dates conflict with existing bookings\") \n end\n end\n\n end", "def overlap?(input_range)\n a = self.start_date >= input_range.end_date\n b = self.end_date <= input_range.start_date\n return a || b ? false : true \n end", "def overlaps?(other)\n\t\tself.start_date < other.end_date && other.start_date < self.end_date\n\tend", "def has_valid_format?(record)\n return (is_date?(record.start_at) and is_date?(record.end_at))\n end", "def check_dates\n dates_already_booked = [date_in, date_out]\n body.bookings.each do |b|\n dates_already_booked << b.date_in\n dates_already_booked << b.date_out\n end\n dates_already_booked.sort!\n idx_in = dates_already_booked.index(date_in)\n idx_out = dates_already_booked.index(date_out)\n if idx_in + 1 == idx_out && idx_in % 2 == 0\n true\n else\n throw(:abort)\n end\n end", "def date_within(d)\n\t\treturn (start_date <= d) && (d <= stop_date)\n\tend", "def include?(new_date)\n return start_date <= new_date && end_date > new_date\n end", "def overlaps?(another)\n (start_date - another.end_date) * (another.start_date - end_date) >= 0\n end", "def date_start_before_end?(start_date, end_date)\n return true if start_date.blank? || end_date.blank?\n return true unless date_parsable?(end_date) && date_parsable?(start_date)\n\n Date.parse(end_date) >= Date.parse(start_date)\n end", "def overlap(dates)\n (out_date <= dates.in_date || in_date >= dates.out_date)\n end", "def contains(date)\n if (date >= @start_date) && (date < @end_date)\n return true\n else\n date < @start_date || date >= @end_date\n return false\n end\n end", "def contains?(date_or_time)\n starts_on <= date_or_time && date_or_time < ends_on\n end", "def overlaps?(other)\n \t((start_date - other.end_date) * (other.start_date - end_date)) >= 0\n \tend", "def matches? invoice\n invoice.order_date.between?(time_range.first, time_range.last)\n end", "def rule_date_range_validation\n if self and self.from_date > self.to_date\n return [false,\"from_date should be less than to_date\"]\n else\n return true\n end\n end", "def check_overlap\n bookings = @parking_space.booking.all\n booking = booking_params.values\n for currentBooking in bookings\n if booking.at(3).to_i < currentBooking.finish_time.to_i && currentBooking.start_time.to_i < booking.at(4).to_i\n return true\n end \n end\n return false\n end", "def is_available?(date, start_time)\n\t\tcase date.wday\n\t\t\twhen 1\n\t\t\t\tself.monday_available_from <= start_time && start_time <= self.monday_available_to\n\t\t\twhen 2\n\t\t\t\tself.tuesday_available_from <= start_time && start_time <= self.tuesday_available_to\n\t\t\twhen 3\n\t\t\t\tself.wednesday_available_from <= start_time && start_time <= self.wednesday_available_to\n\t\t\twhen 4\n\t\t\t\tself.thursday_available_from <= start_time && start_time <= self.thursday_available_to\n\t\t\twhen 5\n\t\t\t\tself.friday_available_from <= start_time && start_time <= self.friday_available_to\n\t\t\twhen 6\n\t\t\t\tself.saturday_available_from <= start_time && start_time <= self.saturday_available_to\n\t\t\twhen 7\n\t\t\t\tself.sunday_available_from <= start_time && start_time <= self.sunday_available_to\n\t\t\telse\n\t\t\t\tfalse\n\t\tend\n\tend", "def attendance_between_dates_condition\n\t\t\"attendances.attendance_on BETWEEN '#{start_on}' AND '#{end_on}'\"\n\tend", "def overlap?(new_start_date, new_end_date)\n return(start_date <= new_end_date && end_date >= new_start_date) \n end", "def registration_dates_given?\n if registration_start_date.blank? || registration_end_date.blank?\n false\n else\n true\n end\n end", "def booking_range\n ary = [I18n.localize(begin_date, format: DATE_AND_TIME)]\n if same_day?(begin_date, end_date)\n ary << I18n.localize(end_date, format: '%R') # example: 09:00\n else\n ary << I18n.localize(end_date, format: DATE_AND_TIME)\n end\n ary.join ' - '\n end", "def availability(room_number, end_date, start_date)\n\n @reservations.each do |reservation|\n\n # i am trying to look throught all the reservation instances and\n # see what dates are available to reserve a reservation.\n\n if room_number == reservation.room_number && reservation.does_overlap(end_date,start_date)\n\n # if reservation.start_date == start_date && reservation.end_date == end_date\n # return false\n # elsif reservation.start_date > start_date && reservation.start_date < end_date\n # next #true\n # elsif reservation.start_date < start_date && reservation.start_date < end_date\n # next #true\n # elsif reservation.start_date > start_date && reservation.start_date > end_date\n # next #false , i think i need only\n # else\n # end\n\n\n\n\n\n end\n\n end\nend", "def confirm_date(start_date, end_date)\n confirm = 0\n for booking in @bookings\n if start_date >= booking[0] && start_date < booking[1]\n confirm += 1\n elsif end_date > booking[0] && end_date <= booking[1]\n confirm += 1\n elsif start_date <= booking[0] && end_date >= booking[1]\n confirm += 1\n end\n end\n return confirm\n # if confirmation is 1 then there is a clash. 0 if not.\n end", "def booked_date_range\n { from: :start_date, to: :end_date }\n end", "def active?\n (start_date <= DateTime.now) and (DateTime.now <= end_date)\n end", "def booking_deadline_has_passed?\n Date.current > deadline\n end", "def between?(p0, p1) end", "def check_dates\n if start_end_dates.count > 0 && !start_end_dates.nil?\n start_end_dates.each do |d|\n return true if d.check_date_ranges\n end\n\n false\n else\n true\n end\n end", "def includes?(date)\n false\n end", "def is_conflict?(param_start, param_end, room_object)\n check = room_object.reservations.where(\"(? < start_date AND end_date < ?) AND status = ?\", param_start, param_end, 1)\n check.size > 0 ? true : false\n end", "def between?(x,y) end", "def open?\n (start_date..end_date).cover?(Date.current)\n end", "def dates_valid?\n date_check(params[:start_date]) && date_check(params[:end_date]) && dates_sequential?\n end", "def cover?(other_period)\n inside?(other_period.starts_at) || inside?(other_period.ends_at)\n end", "def active?\n today = Time.now.strftime('%Y-%m-%d %H:%M')\n today >= self.begin_date.strftime('%Y-%m-%d 06:00') && today <= self.end_date.strftime('%Y-%m-%d 23:59')\nend", "def date_time_check?\n booking_date_time = booking_date.to_datetime\n booking = Booking.where(\"cleaner_id = ? and booking_date > ? and booking_date < ?\", cleaner_id, booking_date_time - 2.hours, booking_date_time + 2.hours)\n if booking.present?\n errors.add('Sorry', \"This Cleaner #{cleaner.first_name} is not available in your select time\")\n end\n end", "def create\n # Check for dates/times overlapping\n puts current_user[:id], \"CURRENT USER\"\n overlap = Booking.where('end_date > ? AND start_date < ?', booking_params[:start_date], booking_params[:end_date])\n\n # If room is free, create booking\n if overlap.length.zero? \n booking = Booking.create!(booking_params)\n render json: { status: 'SUCCESS', message: 'Booking created', data: booking }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Cannot create booking, date already booked' }, status: :unprocessable_entity\n end\n end", "def contains?(date_or_time)\n \t# TODO We need to make sure time zones are properly handled, probably!\n\n \tstarts_on <= date_or_time && date_or_time < ends_on\n end", "def active?(date=Time.now)\n date < self.end_date && date > self.start_date\n end", "def valid_dates?\n if enddate && startdate && enddate <= startdate\n errors.add(:enddate, \"is before startdate\")\n end\n end", "def are_reservable?\n reservable = true\n @restaurant.tables.find_each do |table|\n table.bookings.find_each do |booking|\n next unless @end_date.between?(booking.start_time, booking.end_time) ||\n @start_date.between?(booking.start_time, booking.end_time)\n reservable = false\n end\n end\n reservable\n end", "def build_condition_for_date(start_date, end_date, start_date_string=\"created_at\", end_date_string=\"created_at\")\n\t\t\" #{start_date_string} >= '#{start_date.to_time}' and #{end_date_string} <= '#{end_date.to_time + 1.day}' \" if validate_date?(start_date,end_date)\n\tend", "def now?\n start_date <= Time.now and end_date >= Time.now\n end", "def is_target_date? ( date ) \n d = date.to_date\n check = false\n if d >= @dStart.to_date && d <= @dEnd.to_date\n check = true\n end\n return check\n end", "def date_restricted?\n\n now = Date.today\n\n !((valid_from.nil? or now >= valid_from) and (valid_until.nil? or now <= valid_until))\n\n end", "def exact_date?(options = {})\n from_date(options) == to_date(options)\n end", "def open\n return start_date <= Time.now.to_date && end_date >= Time.now.to_date\n end", "def check_dates\n # TODO the init_time must be less then the end_time\n true\n end", "def test_date date\n res = true\n res = res && @min_date_filter <= date if @min_date_filter\n res = res && @max_date_filter >= date if @max_date_filter\n res\n end", "def meeting_conflict?(other)\n return false if self.start_time.nil? or other.start_time.nil?\n section_days = other.days.split(\"\")\n section_days.each do |day|\n if( self.days.include?(day) )\n if (self.start_time.to_i >= other.start_time.to_i and self.start_time.to_i <= other.end_time.to_i) or \n (other.start_time.to_i >= self.start_time.to_i and other.start_time.to_i <= self.end_time.to_i)\n return true\n end \n end\n end\n return false\n end", "def booking_response_for(begins_at, ends_at)\n \"You wish to book the car #{Formatters::Booking.new(OpenStruct.new(begins_at: begins_at, ends_at: ends_at)).format}? Reply with 'confirm', try another 'book from X to Y', or 'abandon'.\"\n end", "def date_range_valid?(start_date, end_date)\n\tif start_date > end_date\n\t\tputs \"Start date must be before end date\"\n\t\treturn false\n\telsif start_date + MAX_DAYS < end_date\n\t\tputs \"\\n No more than #{MAX_DAYS}. Be nice to the remote server.\"\n\t\treturn false\n\tend\n\treturn true\nend", "def reservation_dates_must_make_sense\n\t if end_date <= start_date\n\t\t errors.add(:start_date, \"has to be before the end date\")\n\t end\n\tend", "def available_for?(reservation)\n return false if staff_only? && !reservation.staff? # TODO handle staff reservations properly\n return false unless ready_for_checkout?\n return false if reservation.start_date.blank? || reservation.end_date.blank?\n if reservation.staff?\n reservation_start_date_with_buffer = reservation.start_date + 1.second\n reservation_end_date = reservation.end_date - 1.second\n else\n reservation_start_date_with_buffer = reservation.start_date - 1.day - (category.buffer_days_between_checkouts.to_i * 1.day)\n reservation_end_date = reservation.end_date\n end\n conditions = [['(start_date <= :start_date AND end_date >= :end_date)'],\n ['(start_date <= :end_date AND end_date >= :end_date)'],\n ['(start_date <= :start_date AND end_date >= :end_date)'],\n ['(start_date >= :start_date AND end_date <= :end_date)'],\n ['(start_date >= :start_date AND start_date <= :end_date)'],\n \t\t['(end_date >= :start_date AND end_date <= :end_date)']]\n reservations.find(:all, :conditions => [\"submitted = true\n AND equipment_reservation_id != #{reservation.id} \n AND (#{conditions.join(\" OR \")})\", \n { :start_date => reservation_start_date_with_buffer, :end_date => reservation_end_date }]).empty?\n end", "def specific?\n starts_at.is_a?(Time) && ends_at.is_a?(Time)\n end", "def between?(inclusive, start, stop, event)\n ((after?(inclusive, start, event)) &&\n (before?(inclusive, stop, event)))\nend", "def active\n today = Date.today\n before = (start_date <=> today) == 1\n after = (today <=> end_date) == 1\n\n outside_range = (before or after)\n no_dates = (start_date.nil? and end_date.nil?)\n\n (!outside_range or no_dates)\n end", "def same_day?\n start_date == end_date\n end", "def is_date_valid?\n\t\tunless self.date_of_booking >= Time.zone.now.beginning_of_day \n\t\t\tself.errors[:date_validation] << \"=> You can't book resource for previous day\"\n\t\tend\n\tend", "def validate_dates\n if start_at && end_at\n errors.add(:end_at, 'should be greater than start date') if end_at <= start_at\n end\n end", "def dates_in_order?(date1, date2)\n return true if date1.nil? or date2.nil? or date2 >= date1\n false\n end", "def one_day?\n @start_date == @end_date\n end", "def valid_end_date?\n if @end_date >= @start_date\n return true\n else\n return [false, \"Start date must be before end date\"]\n end\nend", "def overlaps_with?(other_meeting) \n if day == other_meeting.day\n if (other_meeting.start_time < end_time) && (other_meeting.end_time > start_time)\n return true\n end\n end\n return false\n end", "def dates_within_conference_dates\n return unless start_date && end_date && program.try(:conference).try(:start_date) && program.try(:conference).try(:end_date)\n\n errors.add(:start_date, \"can't be outside of the conference's dates (#{program.conference.start_date}-#{program.conference.end_date})\") unless (program.conference.start_date..program.conference.end_date).cover?(start_date)\n errors.add(:end_date, \"can't be outside of the conference's dates (#{program.conference.start_date}-#{program.conference.end_date})\") unless (program.conference.start_date..program.conference.end_date).cover?(end_date)\n end", "def include?(other_period)\n inside?(other_period.starts_at) && inside?(other_period.ends_at)\n end", "def validate_for_another_reservation\n if start_at && end_at && BUSY_STATUSES.include?(self.status)\n errors.add(:start_at, 'Another reservation already exists for these dates.') if exists_other_reservations_in_same_period?\n end\n end", "def active?\n start_date <= Date.today and finish_date >= Date.today\n end", "def date_valid?(date)\n valid_dates = Date.parse(DATA_START_DATE)..Date.today\n if valid_dates.cover?(date)\n return true\n else\n puts \"\\nDate must be after #{DATA_START_DATE} and before today.\"\n return false\n end\nend", "def is_target_date?(date) \n d = date.to_date\n check = false\n if d >= @dStart && d <= @dEnd\n check = true\n end\n return check\n end", "def available?(date)\n availability.occurs_at?(date)\n end" ]
[ "0.7811179", "0.7527403", "0.73640716", "0.7221717", "0.72079784", "0.71533626", "0.7150685", "0.714059", "0.7134902", "0.71034175", "0.7064304", "0.70228076", "0.7005362", "0.699471", "0.69600844", "0.69454503", "0.69338346", "0.68948674", "0.6894289", "0.6885256", "0.6848892", "0.6821307", "0.6815954", "0.6803132", "0.67895335", "0.676151", "0.67508674", "0.67408854", "0.67208725", "0.671059", "0.6701243", "0.6692931", "0.6679751", "0.6675529", "0.6669407", "0.6652676", "0.66433656", "0.6600747", "0.6586871", "0.6555828", "0.6551263", "0.65350693", "0.65067524", "0.64989114", "0.64783263", "0.6455031", "0.6443157", "0.6442347", "0.6431204", "0.6382752", "0.6376512", "0.6362859", "0.6325754", "0.6324028", "0.63081604", "0.6300698", "0.629498", "0.6291793", "0.6287841", "0.6277403", "0.62689996", "0.6266049", "0.62623364", "0.625894", "0.6256427", "0.6254007", "0.6250888", "0.6240738", "0.622496", "0.62218887", "0.62116057", "0.62110734", "0.6210791", "0.61927915", "0.61919445", "0.6181342", "0.61797625", "0.6179577", "0.6172022", "0.61564815", "0.61560374", "0.61441624", "0.61429197", "0.61428595", "0.6135774", "0.6129635", "0.612359", "0.6119894", "0.6115478", "0.6113403", "0.6109943", "0.6107935", "0.61055756", "0.6103169", "0.61015284", "0.60937756", "0.6087781", "0.60852814", "0.6079842", "0.6079757" ]
0.64822793
44
Render and deliver the chart
def getchart() # The data for the chart dataY0 = [4, 4.5, 5, 5.25, 5.75, 5.25, 5, 4.5, 4, 3, 2.5, 2.5] dataX0 = [Time.mktime(1997, 1, 1), Time.mktime(1998, 6, 25), Time.mktime(1999, 9, 6), Time.mktime(2000, 2, 6), Time.mktime(2000, 9, 21), Time.mktime(2001, 3, 4 ), Time.mktime(2001, 6, 8), Time.mktime(2002, 2, 4), Time.mktime(2002, 5, 19), Time.mktime(2002, 8, 16), Time.mktime(2002, 12, 1), Time.mktime(2003, 1, 1)] dataY1 = [7, 6.5, 6, 5, 6.5, 7, 6, 5.5, 5, 4, 3.5, 3.5] dataX1 = [Time.mktime(1997, 1, 1), Time.mktime(1997, 7, 1), Time.mktime(1997, 12, 1), Time.mktime(1999, 1, 15), Time.mktime(1999, 6, 9), Time.mktime(2000, 3, 3 ), Time.mktime(2000, 8, 13), Time.mktime(2001, 5, 5), Time.mktime(2001, 9, 16 ), Time.mktime(2002, 3, 16), Time.mktime(2002, 6, 1), Time.mktime(2003, 1, 1)] # Create a XYChart object of size 500 x 270 pixels, with a pale blue (e0e0ff) # background, black border, 1 pixel 3D border effect and rounded corners c = ChartDirector::XYChart.new(600, 300, 0xe0e0ff, 0x000000, 1) c.setRoundedFrame() # Set the plotarea at (55, 60) and of size 520 x 200 pixels, with white (ffffff) # background. Set horizontal and vertical grid lines to grey (cccccc). c.setPlotArea(50, 60, 525, 200, 0xffffff, -1, -1, 0xcccccc, 0xcccccc) # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9 # pts Arial Bold font. Set the background and border color to Transparent. c.addLegend(55, 32, false, "arialbd.ttf", 9).setBackground( ChartDirector::Transparent) # Add a title box to the chart using 15 pts Times Bold Italic font. The text is # white (ffffff) on a deep blue (000088) background, with soft lighting effect # from the right side. c.addTitle("Long Term Interest Rates", "timesbi.ttf", 15, 0xffffff).setBackground( 0x000088, -1, ChartDirector::softLighting(ChartDirector::Right)) # Set the y axis label format to display a percentage sign c.yAxis().setLabelFormat("{value}%") # Add a red (ff0000) step line layer to the chart and set the line width to 2 # pixels layer0 = c.addStepLineLayer(dataY0, 0xff0000, "Country AAA") layer0.setXData(dataX0) layer0.setLineWidth(2) # Add a blue (0000ff) step line layer to the chart and set the line width to 2 # pixels layer1 = c.addStepLineLayer(dataY1, 0x0000ff, "Country BBB") layer1.setXData(dataX1) layer1.setLineWidth(2) # Output the chart send_data(c.makeChart2(ChartDirector::PNG), :type => "image/png", :disposition => "inline") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def render_chart\n assert_privileges(\"view_graph\")\n\n if params[:report]\n rpt = MiqReport.for_user(current_user).find_by(:name => params[:report])\n rpt.generate_table(:userid => session[:userid])\n else\n rpt = if session[:report_result_id]\n MiqReportResult.for_user(current_user).find(session[:report_result_id]).report_results\n elsif session[:rpt_task_id].present?\n MiqTask.find(session[:rpt_task_id]).task_results\n else\n @report\n end\n end\n\n rpt.to_chart(settings(:display, :reporttheme), true, MiqReport.graph_options)\n rpt.chart\n end", "def show\n @chart_data0 = make_chart_data(@progress.company_name,0)\n @chart_data1 = make_chart_data(@progress.company_name,1)\n @chart_data2 = make_chart_data(@progress.company_name,2)\n end", "def chart(reload_cache = false)\n return body.html_safe if body? && !reload_cache\n \n chart_code = nil\n \n opts = {\n :title => legend,\n :renderTo => \"chart-#{(0...16).map{65.+(rand(25)).chr}.join}\"\n }\n \n hc = Highchart.new(opts, csv)\n hc.transpose = transpose\n \n chart_code = \"<div id=\\\"#{opts[:renderTo]}\\\" style=\\\"height:#{height}px;width:#{width}px;\\\"></div>\"\n chart_code << hc.render\n\n if new_record?\n self.body = chart_code\n else\n update_attributes(:body => chart_code)\n end\n return body.html_safe\n end", "def show_chart\n render :partial => 'charts', :project => @project\n end", "def getchart()\n # The data for the chart\n data0 = [32, 39, 23, 28, 41, 38, 26, 35, 29]\n data1 = [50, 55, 47, 34, 47, 53, 38, 40, 51]\n\n # The labels for the chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"]\n\n # Create a XYChart object of size 600 x 300 pixels, with a pale red (ffdddd)\n # background, black border, 1 pixel 3D border effect and rounded corners.\n c = ChartDirector::XYChart.new(600, 300, 0xffdddd, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is white (ffffff)\n # on a dark red (880000) background, with soft lighting effect from the right\n # side.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance \" \\\n \"Enhancer <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x880000, -1, ChartDirector::softLighting(ChartDirector::Right\n ))\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Energy Concentration (KJ per liter)\")\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a spline layer to the chart\n layer = c.addSplineLayer()\n\n # Set the default line width to 2 pixels\n layer.setLineWidth(2)\n\n # Add a data set to the spline layer, using blue (0000c0) as the line color, with\n # yellow (ffff00) circle symbols.\n layer.addDataSet(data1, 0x0000c0, \"Target Group\").setDataSymbol(\n ChartDirector::CircleSymbol, 9, 0xffff00)\n\n # Add a data set to the spline layer, using brown (982810) as the line color, with\n # pink (f040f0) diamond symbols.\n layer.addDataSet(data0, 0x982810, \"Control Group\").setDataSymbol(\n ChartDirector::DiamondSymbol, 11, 0xf040f0)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 250,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def div\n @adapter.generate_body(@chart)\n end", "def getchart()\n # The data for the bar chart\n data0 = [100, 125, 156, 147, 87, 124, 178, 109, 140, 106, 192, 122]\n data1 = [122, 156, 179, 211, 198, 177, 160, 220, 190, 188, 220, 270]\n data2 = [167, 190, 213, 267, 250, 320, 212, 199, 245, 267, 240, 310]\n labels = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sept\", \"Oct\",\n \"Nov\", \"Dec\"]\n\n # Create a XYChart object of size 580 x 280 pixels\n c = ChartDirector::XYChart.new(580, 280)\n\n # Add a title to the chart using 14 pts Arial Bold Italic font\n c.addTitle(\"Product Revenue For Last 3 Years\", \"arialbi.ttf\", 14)\n\n # Set the plot area at (50, 50) and of size 500 x 200. Use two alternative\n # background colors (f8f8f8 and ffffff)\n c.setPlotArea(50, 50, 500, 200, 0xf8f8f8, 0xffffff)\n\n # Add a legend box at (50, 25) using horizontal layout. Use 8pts Arial as font,\n # with transparent background.\n c.addLegend(50, 25, false, \"arial.ttf\", 8).setBackground(\n ChartDirector::Transparent)\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Draw the ticks between label positions (instead of at label positions)\n c.xAxis().setTickOffset(0.5)\n\n # Add a multi-bar layer with 3 data sets\n layer = c.addBarLayer2(ChartDirector::Side)\n layer.addDataSet(data0, 0xff8080, \"Year 2003\")\n layer.addDataSet(data1, 0x80ff80, \"Year 2004\")\n layer.addDataSet(data2, 0x8080ff, \"Year 2005\")\n\n # Set 50% overlap between bars\n layer.setOverlapRatio(0.5)\n\n # Add a title to the y-axis\n c.yAxis().setTitle(\"Revenue (USD in millions)\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def render\n labels = []\n values = []\n @data.each do |label, value|\n labels << CGI::escape(label)\n values << (value > 0 ? value * 100 / @max : value).round.to_s\n end\n params = {:cht => 'p', :chs => \"#{width}x#{height}\", :chd => \"t:#{values.join(',')}\", :chl => labels.join('|') }\n params['chco'] = color if color\n\n url = \"http://chart.apis.google.com/chart?#{to_query(params)}\"\n\n alt_msg = \"This pie chart is generated by Google Charts. You must be connected to the Internet to view this chart.\"\n html = \"<img id=\\\"pie_chart_image\\\" src=\\\"#{url}\\\" alt=\\\"#{alt_msg}\\\"/>\"\n return html\n end", "def getchart()\n # The data for the chart\n data0 = [42, 49, ChartDirector::NoValue, 38, 64, 56, 29, 41, 44, 57]\n data1 = [65, 75, 47, 34, 42, 49, 73, ChartDirector::NoValue, 90, 69, 66, 78]\n data2 = [ChartDirector::NoValue, ChartDirector::NoValue, 25, 28, 38, 20, 22,\n ChartDirector::NoValue, 25, 33, 30, 24]\n labels = [\"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\", \"Jul\", \"Aug\", \"Sep\", \"Oct\",\n \"Nov\", \"Dec\"]\n\n # Create a XYChart object of size 600 x 360 pixels. Set background color to\n # brushed silver, with a 2 pixel 3D border. Use rounded corners.\n c = ChartDirector::XYChart.new(600, 360, ChartDirector::brushedSilverColor(),\n ChartDirector::Transparent, 2)\n c.setRoundedFrame()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. #Set top/bottom\n # margins to 6 pixels.\n title = c.addTitle(\"Product Line Global Revenue\", \"timesbi.ttf\", 18)\n title.setMargin2(0, 0, 6, 6)\n\n # Add a separator line just under the title\n c.addLine(10, title.getHeight(), c.getWidth() - 11, title.getHeight(),\n ChartDirector::LineColor)\n\n # Add a legend box where the top-center is anchored to the horizontal center of\n # the chart, just under the title. Use horizontal layout and 10 points Arial Bold\n # font, and transparent background and border.\n legendBox = c.addLegend(c.getWidth() / 2, title.getHeight(), false, \"arialbd.ttf\",\n 10)\n legendBox.setAlignment(ChartDirector::TopCenter)\n legendBox.setBackground(ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Tentatively set the plotarea at (70, 75) and of 460 x 240 pixels in size. Use\n # transparent border and black (000000) grid lines\n c.setPlotArea(70, 75, 460, 240, -1, -1, ChartDirector::Transparent, 0x000000, -1)\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Show the same scale on the left and right y-axes\n c.syncYAxis()\n\n # Set y-axis tick density to 30 pixels. ChartDirector auto-scaling will use this\n # as the guideline when putting ticks on the y-axis.\n c.yAxis().setTickDensity(30)\n\n # Set all axes to transparent\n c.xAxis().setColors(ChartDirector::Transparent)\n c.yAxis().setColors(ChartDirector::Transparent)\n c.yAxis2().setColors(ChartDirector::Transparent)\n\n # Set the x-axis margins to 15 pixels, so that the horizontal grid lines can\n # extend beyond the leftmost and rightmost vertical grid lines\n c.xAxis().setMargin(15, 15)\n\n # Set axis label style to 8pts Arial Bold\n c.xAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis2().setLabelStyle(\"arialbd.ttf\", 8)\n\n # Add axis title using 10pts Arial Bold Italic font\n c.yAxis().setTitle(\"Revenue in USD millions\", \"arialbi.ttf\", 10)\n c.yAxis2().setTitle(\"Revenue in USD millions\", \"arialbi.ttf\", 10)\n\n # Add the first line. The missing data will be represented as gaps in the line\n # (the default behaviour)\n layer0 = c.addLineLayer2()\n layer0.addDataSet(data0, 0xff0000, \"Quantum Computer\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer0.setLineWidth(3)\n\n # Add the second line. The missing data will be represented by using dash lines to\n # bridge the gap\n layer1 = c.addLineLayer2()\n layer1.addDataSet(data1, 0x00ff00, \"Atom Synthesizer\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer1.setLineWidth(3)\n layer1.setGapColor(c.dashLineColor(0x00ff00))\n\n # Add the third line. The missing data will be ignored - just join the gap with\n # the original line style.\n layer2 = c.addLineLayer2()\n layer2.addDataSet(data2, 0xff6600, \"Proton Cannon\").setDataSymbol(\n ChartDirector::GlassSphere2Shape, 11)\n layer2.setLineWidth(3)\n layer2.setGapColor(ChartDirector::SameAsMainColor)\n\n # layout the legend so we can get the height of the legend box\n c.layoutLegend()\n\n # Adjust the plot area size, such that the bounding box (inclusive of axes) is 15\n # pixels from the left edge, just under the legend box, 16 pixels from the right\n # edge, and 25 pixels from the bottom edge.\n c.packPlotArea(15, legendBox.getTopY() + legendBox.getHeight(), c.getWidth() - 16,\n c.getHeight() - 25)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::JPG), :type => \"image/jpeg\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the chart\n data0 = [100, 100, 100, 100, 100]\n data1 = [90, 85, 85, 80, 70]\n data2 = [80, 65, 65, 75, 45]\n\n # The labels for the chart\n labels = [\"Population<*br*><*font=arial.ttf*>6 millions\",\n \"GDP<*br*><*font=arial.ttf*>120 billions\",\n \"Export<*br*><*font=arial.ttf*>25 billions\",\n \"Import<*br*><*font=arial.ttf*>24 billions\",\n \"Investments<*br*><*font=arial.ttf*>20 billions\"]\n\n # Create a PolarChart object of size 480 x 460 pixels. Set background color to\n # silver, with 1 pixel 3D border effect\n c = ChartDirector::PolarChart.new(480, 460, ChartDirector::silverColor(),\n 0x000000, 1)\n\n # Add a title to the chart using 15 pts Times Bold Italic font. The title text is\n # white (ffffff) on a deep green (008000) background\n c.addTitle(\"Economic Growth\", \"timesbi.ttf\", 15, 0xffffff).setBackground(0x008000)\n\n # Set plot area center at (240, 270), with 150 pixels radius\n c.setPlotArea(240, 270, 150)\n\n # Use 1 pixel width semi-transparent black (c0000000) lines as grid lines\n c.setGridColor(0xc0000000, 1, 0xc0000000, 1)\n\n # Add a legend box at top-center of plot area (240, 35) using horizontal layout.\n # Use 10 pts Arial Bold font, with silver background and 1 pixel 3D border effect.\n b = c.addLegend(240, 35, false, \"arialbd.ttf\", 10)\n b.setAlignment(ChartDirector::TopCenter)\n b.setBackground(ChartDirector::silverColor(), ChartDirector::Transparent, 1)\n\n # Add area layers of different colors to represent the data\n c.addAreaLayer(data0, 0xcc8880, \"Year 2004\")\n c.addAreaLayer(data1, 0xffd080, \"Year 1994\")\n c.addAreaLayer(data2, 0xa0bce0, \"Year 1984\")\n\n # Set the labels to the angular axis as spokes.\n c.angularAxis().setLabels(labels)\n\n # Set radial axis from 0 - 100 with a tick every 20 units\n c.radialAxis().setLinearScale(0, 100, 20)\n\n # Just show the radial axis as a grid line. Hide the axis labels by setting the\n # label color to Transparent\n c.radialAxis().setColors(0xc0000000, ChartDirector::Transparent)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the bar chart\n data0 = [100, 125, 245, 147, 67]\n data1 = [85, 156, 179, 211, 123]\n data2 = [97, 87, 56, 267, 157]\n\n # The labels for the bar chart\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # Create a XYChart object of size 500 x 320 pixels\n c = ChartDirector::XYChart.new(500, 320)\n\n # Set the plotarea at (100, 40) and of size 280 x 240 pixels\n c.setPlotArea(100, 40, 280, 240)\n\n # Add a legend box at (400, 100)\n c.addLegend(400, 100)\n\n # Add a title to the chart using 14 points Times Bold Itatic font\n c.addTitle(\"Weekday Network Load\", \"timesbi.ttf\", 14)\n\n # Add a title to the y axis. Draw the title upright (font angle = 0)\n c.yAxis().setTitle(\"Average\\nWorkload\\n(MBytes\\nPer Hour)\").setFontAngle(0)\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a stacked bar layer and set the layer 3D depth to 8 pixels\n layer = c.addBarLayer2(ChartDirector::Stack, 8)\n\n # Add the three data sets to the bar layer\n layer.addDataSet(data0, 0xff8080, \"Server # 1\")\n layer.addDataSet(data1, 0x80ff80, \"Server # 2\")\n layer.addDataSet(data2, 0x8080ff, \"Server # 3\")\n\n # Enable bar label for the whole bar\n layer.setAggregateLabelStyle()\n\n # Enable bar label for each segment of the stacked bar\n layer.setDataLabelStyle()\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the chart\n data = [100, 125, 260, 147, 67]\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # Create a XYChart object of size 200 x 180 pixels\n c = ChartDirector::XYChart.new(200, 180)\n\n # Set the plot area at (30, 10) and of size 140 x 130 pixels\n c.setPlotArea(30, 10, 140, 130)\n\n # Ise log scale axis if required\n if params[\"img\"] == \"1\"\n c.yAxis().setLogScale3()\n end\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Add a color bar layer using the given data. Use a 1 pixel 3D border for the\n # bars.\n c.addBarLayer3(data).setBorderColor(-1, 1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the area chart\n data = [3.0, 2.8, 4.0, 5.5, 7.5, 6.8, 5.4, 6.0, 5.0, 6.2, 7.5, 6.5, 7.5, 8.1, 6.0,\n 5.5, 5.3, 3.5, 5.0, 6.6, 5.6, 4.8, 5.2, 6.5, 6.2]\n\n # The labels for the area chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 300 x 180 pixels. Set the background to pale\n # yellow (0xffffa0) with a black border (0x0)\n c = ChartDirector::XYChart.new(300, 180, 0xffffa0, 0x000000)\n\n # Set the plotarea at (45, 35) and of size 240 x 120 pixels. Set the background to\n # white (0xffffff). Set both horizontal and vertical grid lines to black (&H0&)\n # dotted lines (pattern code 0x0103)\n c.setPlotArea(45, 35, 240, 120, 0xffffff, -1, -1, c.dashLineColor(0x000000,\n 0x000103), c.dashLineColor(0x000000, 0x000103))\n\n # Add a title to the chart using 10 pts Arial Bold font. Use a 1 x 2 bitmap\n # pattern as the background. Set the border to black (0x0).\n c.addTitle(\"Snow Percipitation (Dec 12)\", \"arialbd.ttf\", 10).setBackground(\n c.patternColor([0xb0b0f0, 0xe0e0ff], 2), 0x000000)\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"mm per hour\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 3 labels on the x-axis.\n c.xAxis().setLabelStep(3)\n\n # Add an area layer to the chart\n layer = c.addAreaLayer()\n\n # Load a snow pattern from an external file \"snow.png\".\n snowPattern = c.patternColor2(File.dirname(__FILE__) + \"/snow.png\")\n\n # Add a data set to the area layer using the snow pattern as the fill color. Use\n # deep blue (0x0000ff) as the area border line color (&H0000ff&)\n layer.addDataSet(data).setDataColor(snowPattern, 0x0000ff)\n\n # Set the line width to 2 pixels to highlight the line\n layer.setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the bar chart\n data0 = [44, 55, 100]\n data1 = [97, 87, 167]\n data2 = [156, 78, 147]\n data3 = [125, 118, 211]\n\n # The labels for the bar chart. The labels contains embedded images as icons.\n labels = [\"<*img=service.png*><*br*>Service\",\n \"<*img=software.png*><*br*>Software\", \"<*img=computer.png*><*br*>Hardware\"]\n\n # Create a XYChart object of size 600 x 350 pixels, using 0xe0e0ff as the\n # background color, 0xccccff as the border color, with 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(600, 350, 0xe0e0ff, 0xccccff, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Add a title to the chart using 14 points Times Bold Itatic font and light blue\n # (0x9999ff) as the background color\n c.addTitle(\"Business Results 2001 vs 2002\", \"timesbi.ttf\", 14).setBackground(\n 0x9999ff)\n\n # Set the plotarea at (60, 45) and of size 500 x 210 pixels, using white\n # (0xffffff) as the background\n c.setPlotArea(60, 45, 500, 210, 0xffffff)\n\n # Swap the x and y axes to create a horizontal bar chart\n c.swapXY()\n\n # Add a title to the y axis using 11 pt Times Bold Italic as font\n c.yAxis().setTitle(\"Revenue (millions)\", \"timesbi.ttf\", 11)\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Disable x-axis ticks by setting the tick length to 0\n c.xAxis().setTickLength(0)\n\n # Add a stacked bar layer to the chart\n layer = c.addBarLayer2(ChartDirector::Stack)\n\n # Add the first two data sets to the chart as a stacked bar group\n layer.addDataGroup(\"2001\")\n layer.addDataSet(data0, 0xaaaaff, \"Local\")\n layer.addDataSet(data1, 0x6666ff, \"International\")\n\n # Add the remaining data sets to the chart as another stacked bar group\n layer.addDataGroup(\"2002\")\n layer.addDataSet(data2, 0xffaaaa, \"Local\")\n layer.addDataSet(data3, 0xff6666, \"International\")\n\n # Set the sub-bar gap to 0, so there is no gap between stacked bars with a group\n layer.setBarGap(0.2, 0)\n\n # Set the bar border to transparent\n layer.setBorderColor(ChartDirector::Transparent)\n\n # Set the aggregate label format\n layer.setAggregateLabelFormat(\"Year {dataGroupName}\\n{value} millions\")\n\n # Set the aggregate label font to 8 point Arial Bold Italic\n layer.setAggregateLabelStyle(\"arialbi.ttf\", 8)\n\n # Reverse 20% space at the right during auto-scaling to allow space for the\n # aggregate bar labels\n c.yAxis().setAutoScale(0.2)\n\n # Add a legend box at (310, 300) using TopCenter alignment, with 2 column grid\n # layout, and use 8 pts Arial Bold Italic as font\n legendBox = c.addLegend2(310, 300, 2, \"arialbi.ttf\", 8)\n legendBox.setAlignment(ChartDirector::TopCenter)\n\n # Set the format of the text displayed in the legend box\n legendBox.setText(\"Year {dataGroupName} {dataSetName} Revenue\")\n\n # Set the background and border of the legend box to transparent\n legendBox.setBackground(ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # Use random table to generate a random series. The random table is set to 1 col x\n # 51 rows, with 9 as the seed\n rantable = ChartDirector::RanTable.new(9, 1, 51)\n\n # Set the 1st column to start from 100, with changes between rows from -5 to +5\n rantable.setCol(0, 100, -5, 5)\n\n # Get the 1st column of the random table as the data set\n data = rantable.getCol(0)\n\n # Create a XYChart object of size 600 x 300 pixels\n c = ChartDirector::XYChart.new(600, 300)\n\n # Set the plotarea at (50, 35) and of size 500 x 240 pixels. Enable both the\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(50, 35, 500, 240).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart using 18 point Times Bold Itatic font.\n c.addTitle(\"LOWESS Generic Curve Fitting Algorithm\", \"timesbi.ttf\", 18)\n\n # Set the y axis line width to 3 pixels\n c.yAxis().setWidth(3)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Server Load (TPS)\", \"arialbi.ttf\", 12)\n\n # Set the x axis line width to 3 pixels\n c.xAxis().setWidth(3)\n\n # Set the x axis scale from 0 - 50, with major tick every 5 units and minor tick\n # every 1 unit\n c.xAxis().setLinearScale(0, 50, 5, 1)\n\n # Add a blue layer to the chart\n layer = c.addLineLayer2()\n\n # Add a red (0x80ff0000) data set to the chart with square symbols\n layer.addDataSet(data, 0x80ff0000).setDataSymbol(ChartDirector::SquareSymbol)\n\n # Set the line width to 2 pixels\n layer.setLineWidth(2)\n\n # Use lowess for curve fitting, and plot the fitted data using a spline layer with\n # line width set to 3 pixels\n c.addSplineLayer(ChartDirector::ArrayMath.new(data).lowess().result(), 0x0000ff\n ).setLineWidth(3)\n\n # Set zero affinity to 0 to make sure the line is displayed in the most detail\n # scale\n c.yAxis().setAutoScale(0, 0, 0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the chart\n data0 = [90, 60, 85, 75, 55]\n data1 = [60, 80, 70, 80, 85]\n\n # The labels for the chart\n labels = [\"Speed\", \"Reliability\", \"Comfort\", \"Safety\", \"Efficiency\"]\n\n # Create a PolarChart object of size 480 x 380 pixels. Set background color to\n # gold, with 1 pixel 3D border effect\n c = ChartDirector::PolarChart.new(480, 380, ChartDirector::goldColor(), 0x000000,\n 1)\n\n # Add a title to the chart using 15 pts Times Bold Italic font. The title text is\n # white (ffffff) on a deep blue (000080) background\n c.addTitle(\"Space Travel Vehicles Compared\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x000080)\n\n # Set plot area center at (240, 210), with 150 pixels radius, and a white (ffffff)\n # background.\n c.setPlotArea(240, 210, 150, 0xffffff)\n\n # Add a legend box at top right corner (470, 35) using 10 pts Arial Bold font. Set\n # the background to silver, with 1 pixel 3D border effect.\n b = c.addLegend(470, 35, true, \"arialbd.ttf\", 10)\n b.setAlignment(ChartDirector::TopRight)\n b.setBackground(ChartDirector::silverColor(), ChartDirector::Transparent, 1)\n\n # Add an area layer to the chart using semi-transparent blue (0x806666cc). Add a\n # blue (0x6666cc) line layer using the same data with 3 pixel line width to\n # highlight the border of the area.\n c.addAreaLayer(data0, 0x806666cc, \"Model Saturn\")\n c.addLineLayer(data0, 0x6666cc).setLineWidth(3)\n\n # Add an area layer to the chart using semi-transparent red (0x80cc6666). Add a\n # red (0xcc6666) line layer using the same data with 3 pixel line width to\n # highlight the border of the area.\n c.addAreaLayer(data1, 0x80cc6666, \"Model Jupiter\")\n c.addLineLayer(data1, 0xcc6666).setLineWidth(3)\n\n # Set the labels to the angular axis as spokes.\n c.angularAxis().setLabels(labels)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the bar chart\n data = [450, 560, 630, 800, 1100, 1350, 1600, 1950, 2300, 2700]\n\n # The labels for the bar chart\n labels = [\"1996\", \"1997\", \"1998\", \"1999\", \"2000\", \"2001\", \"2002\", \"2003\", \"2004\",\n \"2005\"]\n\n # Create a XYChart object of size 600 x 360 pixels\n c = ChartDirector::XYChart.new(600, 360)\n\n # Add a title to the chart using 18pts Times Bold Italic font\n c.addTitle(\"Annual Revenue for Star Tech\", \"timesbi.ttf\", 18)\n\n # Set the plotarea at (60, 40) and of size 500 x 280 pixels. Use a vertical\n # gradient color from light blue (eeeeff) to deep blue (0000cc) as background. Set\n # border and grid lines to white (ffffff).\n c.setPlotArea(60, 40, 500, 280, c.linearGradientColor(60, 40, 60, 280, 0xeeeeff,\n 0x0000cc), -1, 0xffffff, 0xffffff)\n\n # Add a multi-color bar chart layer using the supplied data. Use soft lighting\n # effect with light direction from left.\n c.addBarLayer3(data).setBorderColor(ChartDirector::Transparent,\n ChartDirector::softLighting(ChartDirector::Left))\n\n # Set x axis labels using the given labels\n c.xAxis().setLabels(labels)\n\n # Draw the ticks between label positions (instead of at label positions)\n c.xAxis().setTickOffset(0.5)\n\n # Add a title to the y axis with 10pts Arial Bold font\n c.yAxis().setTitle(\"USD (millions)\", \"arialbd.ttf\", 10)\n\n # Set axis label style to 8pts Arial Bold\n c.xAxis().setLabelStyle(\"arialbd.ttf\", 8)\n c.yAxis().setLabelStyle(\"arialbd.ttf\", 8)\n\n # Set axis line width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The XY data of the first data series\n dataX0 = [50, 55, 37, 24, 42, 49, 63, 72, 83, 59]\n dataY0 = [3.6, 2.8, 2.5, 2.3, 3.8, 3.0, 3.8, 5.0, 6.0, 3.3]\n\n # The XY data of the second data series\n dataX1 = [50, 55, 37, 24, 42, 49, 63, 72, 83, 59]\n dataY1 = [1.6, 1.8, 0.8, 0.5, 1.3, 1.5, 2.3, 2.4, 2.9, 1.5]\n\n # Create a XYChart object of size 450 x 420 pixels\n c = ChartDirector::XYChart.new(450, 420)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with white background\n # and a light grey border (0xc0c0c0). Turn on both horizontal and vertical grid\n # lines with light grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 point Times Bold Itatic font.\n c.addTitle(\"Server Performance\", \"timesbi.ttf\", 18)\n\n # Add titles to the axes using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Response Time (sec)\", \"arialbi.ttf\", 12)\n c.xAxis().setTitle(\"Server Load (TPS)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.yAxis().setWidth(3)\n c.xAxis().setWidth(3)\n\n # Add a scatter layer using (dataX0, dataY0)\n c.addScatterLayer(dataX0, dataY0, \"Server AAA\", ChartDirector::DiamondSymbol, 11,\n 0x008000)\n\n # Add a trend line layer for (dataX0, dataY0)\n c.addTrendLayer2(dataX0, dataY0, 0x008000).setLineWidth(3)\n\n # Add a scatter layer for (dataX1, dataY1)\n c.addScatterLayer(dataX1, dataY1, \"Server BBB\", ChartDirector::TriangleSymbol, 9,\n 0x6666ff)\n\n # Add a trend line layer for (dataX1, dataY1)\n c.addTrendLayer2(dataX1, dataY1, 0x6666ff).setLineWidth(3)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The (x, y) data for the first line\n dataX0 = [20, 90, 40, 30, 12]\n dataY0 = [10, 40, 75, 54, 20]\n\n # The (x, y) data for the second line\n dataX1 = [10, 40, 75, 54, 60]\n dataY1 = [50, 90, 40, 30, 10]\n\n # Create a XYChart object of size 450 x 450 pixels\n c = ChartDirector::XYChart.new(450, 450)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with white background\n # and a light grey border (0xc0c0c0). Turn on both horizontal and vertical grid\n # lines with light grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font\n c.addTitle(\"Reaction Path\", \"timesbi.ttf\", 18)\n\n # Add a title to the y axis using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Temperature (Celcius)\", \"arialbi.ttf\", 12)\n\n # Set the y axis line width to 3 pixels\n c.yAxis().setWidth(3)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Pressure (Pa)\", \"arialbi.ttf\", 12)\n\n # Set the x axis line width to 3 pixels\n c.xAxis().setWidth(3)\n\n # Add a red (0xff3333) line layer using dataX0 and dataY0\n layer1 = c.addLineLayer(dataY0, 0xff3333, \"Compound AAA\")\n layer1.setXData(dataX0)\n\n # Set the line width to 3 pixels\n layer1.setLineWidth(3)\n\n # Use 9 pixel square symbols for the data points\n layer1.getDataSet(0).setDataSymbol(ChartDirector::SquareSymbol, 9)\n\n # Add custom text labels to the first and last point on the scatter plot using\n # Arial Bold font\n layer1.addCustomDataLabel(0, 0, \"Start\", \"arialbd.ttf\")\n layer1.addCustomDataLabel(0, 4, \"End\", \"arialbd.ttf\")\n\n # Add a green (0x33ff33) line layer using dataX1 and dataY1\n layer2 = c.addLineLayer(dataY1, 0x33ff33, \"Compound BBB\")\n layer2.setXData(dataX1)\n\n # Set the line width to 3 pixels\n layer2.setLineWidth(3)\n\n # Use 11 pixel diamond symbols for the data points\n layer2.getDataSet(0).setDataSymbol(ChartDirector::DiamondSymbol, 11)\n\n # Add custom text labels to the first and last point on the scatter plot using\n # Arial Bold font\n layer2.addCustomDataLabel(0, 0, \"Start\", \"arialbd.ttf\")\n layer2.addCustomDataLabel(0, 4, \"End\", \"arialbd.ttf\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the line chart\n data0 = [410, 420, 500, 590]\n data1 = [500, 370, 680, 850]\n labels = [\"Q1\", \"Q2\", \"Q3\", \"Q4\"]\n\n # Create a XYChart object of size 600 x 400 pixels\n c = ChartDirector::XYChart.new(600, 400)\n\n # Add a title to the chart using 18 pts Times Bold Italic font\n title = c.addTitle(\"Product Line Global Revenue\", \"timesbi.ttf\", 18)\n\n # Tentatively set the plotarea at (50, 55) and of (chart_width - 100) x\n # (chart_height - 150) pixels in size. Use a vertical gradient color from sky blue\n # (aaccff) t0 light blue (f9f9ff) as background. Set both horizontal and vertical\n # grid lines to dotted semi-transprent black (aa000000).\n plotArea = c.setPlotArea(50, 55, c.getWidth() - 100, c.getHeight() - 150,\n c.linearGradientColor(0, 55, 0, 55 + c.getHeight() - 150, 0xaaccff, 0xf9fcff),\n -1, -1, c.dashLineColor(0xaa000000, ChartDirector::DotLine), -1)\n\n # Set y-axis title using 12 points Arial Bold Italic font, and set its position 10\n # pixels from the axis.\n c.yAxis().setTitle(\"Revenue (USD millions)\", \"arialbi.ttf\", 12)\n c.yAxis().setTitlePos(ChartDirector::Left, 10)\n\n # Set y-axis label style to 10 points Arial Bold and axis color to transparent\n c.yAxis().setLabelStyle(\"arialbd.ttf\", 10)\n c.yAxis().setColors(ChartDirector::Transparent)\n\n # Set y-axis tick density to 30 pixels. ChartDirector auto-scaling will use this\n # as the guideline when putting ticks on the y-axis.\n c.yAxis().setTickDensity(30)\n\n # Add a bar layer to the chart with side layout\n layer = c.addBarLayer2(ChartDirector::Side)\n\n # Add two data sets to the bar layer\n layer.addDataSet(data0, 0xff6600, \"FY 2007\")\n layer.addDataSet(data1, 0x0088ff, \"FY 2008\")\n\n # Use soft lighting effect with light direction from the left\n layer.setBorderColor(ChartDirector::Transparent, ChartDirector::softLighting(\n ChartDirector::Left))\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Convert the labels on the x-axis to a CDMLTable\n table = c.xAxis().makeLabelTable()\n\n # Set the default left/right margins to 5 pixels and top/bottom margins to 3\n # pixels. Set the default font size to 10 points\n cellStyle = table.getStyle()\n cellStyle.setMargin2(5, 5, 4, 3)\n cellStyle.setFontSize(10)\n\n # Set the first row to use Arial Bold font, with a light grey (eeeeee) background.\n firstRowStyle = table.getRowStyle(0)\n firstRowStyle.setFontStyle(\"arialbd.ttf\")\n firstRowStyle.setBackground(0xeeeeee, ChartDirector::LineColor)\n\n #\n # We can add more information to the table. In this sample code, we add the data\n # series and the legend icons to the table.\n #\n\n # Add 3 more rows to the table. Set the background of the 2nd row to light grey\n # (eeeeee).\n table.appendRow()\n table.appendRow().setBackground(0xeeeeee, ChartDirector::LineColor)\n table.appendRow()\n\n # Put the values of the 2 data series in the first 2 rows. Put the percentage\n # differences in the 3rd row.\n 0.upto(data0.length - 1) do |i|\n table.setText(i, 1, (data0[i]).to_s)\n table.setText(i, 2, (data1[i]).to_s)\n\n percentageDiff = 100.0 * (data1[i] - data0[i]) / data0[i]\n\n # Use red or green color depending on whether the difference is positive or\n # negative\n formatString = \"<*color=008800*>+{value|1}%\"\n if percentageDiff < 0\n formatString = \"<*color=cc0000*>{value|1}%\"\n end\n table.setText(i, 3, c.formatValue(percentageDiff, formatString))\n end\n\n # Insert a column on the left for the legend icons using Arial Bold font.\n table.insertCol(0).setFontStyle(\"arialbd.ttf\")\n\n # The top cell is set to transparent, so it is invisible\n table.getCell(0, 0).setBackground(ChartDirector::Transparent,\n ChartDirector::Transparent)\n\n # The next 2 cells are set to the legend icons and names of the 2 data series\n table.setText(0, 1, sprintf(\"%s FY 2007\", layer.getLegendIcon(0)))\n table.setText(0, 2, sprintf(\"%s FY 2008\", layer.getLegendIcon(1)))\n\n # The last cell is set to \"Change\"\n table.setText(0, 3, \"Change\")\n\n # Append a column on the right for the total values.\n table.appendCol()\n\n # Put \"Total\" in the top cell as the heading of this column\n table.setText(table.getColCount() - 1, 0, \"Total\")\n\n # The next two cells are the total of the data series\n total0 = ChartDirector::ArrayMath.new(data0).sum()\n total1 = ChartDirector::ArrayMath.new(data1).sum()\n table.setText(table.getColCount() - 1, 1, total0.to_s)\n table.setText(table.getColCount() - 1, 2, total1.to_s)\n\n # The last cell is the percentage differences of the total\n totalPercentageDiff = (total1 - total0) / total0 * 100\n\n # Use red or green color depending on whether the difference is positive or\n # negative\n totalFormatString = \"<*color=008800*>+{value|1}%\"\n if totalPercentageDiff < 0\n totalFormatString = \"<*color=cc0000*>{value|1}%\"\n end\n table.setText(table.getColCount() - 1, 3, c.formatValue(totalPercentageDiff,\n totalFormatString))\n\n #\n # We now demonstrate how to adjust the plot area positions, to allow space for the\n # newly inserted left and right columns in the table.\n #\n\n # We layout the axis first in order to get the axis metrics (including table\n # metrics)\n c.layoutAxes()\n\n # If the first column is wider than the left y-axis, we need to reserve for some\n # left margin to ensure the first column stays within the chart.\n leftMargin = 0\n if table.getColWidth(0) > c.yAxis().getThickness()\n leftMargin = table.getColWidth(0) - c.yAxis().getThickness()\n end\n\n # Similarly, we need to reserve some right margin for the last column\n rightMargin = table.getColWidth(table.getColCount() - 1)\n\n # Adjust the plot area size, such that the bounding box (inclusive of axes) using\n # the given left and right margin, plus 2 more pixels. Put the plot area 10 pixels\n # below the title and use 2 pixels as the bottom margin. from the left, right and\n # bottom edge, and is just under the legend box.\n c.packPlotArea(leftMargin + 2, title.getHeight() + 10, c.getWidth(\n ) - 3 - rightMargin, c.getHeight() - 3)\n\n # After determining the exact plot area position, we may adjust title position so\n # that it is centered relative to the plot area (instead of the chart)\n title.setPos(plotArea.getLeftX() + (plotArea.getWidth() - title.getWidth()) / 2,\n title.getTopY())\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the bar chart\n data0 = [100, 125, 245, 147, 67]\n data1 = [85, 156, 179, 211, 123]\n data2 = [97, 87, 56, 267, 157]\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # Create a XYChart object of size 400 x 240 pixels\n c = ChartDirector::XYChart.new(400, 240)\n\n # Add a title to the chart using 10 pt Arial font\n c.addTitle(\" Average Weekday Network Load\", \"\", 10)\n\n # Set the plot area at (50, 25) and of size 320 x 180. Use two alternative\n # background colors (0xffffc0 and 0xffffe0)\n c.setPlotArea(50, 25, 320, 180, 0xffffc0, 0xffffe0)\n\n # Add a legend box at (55, 18) using horizontal layout. Use 8 pt Arial font, with\n # transparent background\n c.addLegend(55, 18, false, \"\", 8).setBackground(ChartDirector::Transparent)\n\n # Add a title to the y-axis\n c.yAxis().setTitle(\"Throughput (MBytes Per Hour)\")\n\n # Reserve 20 pixels at the top of the y-axis for the legend box\n c.yAxis().setTopMargin(20)\n\n # Set the x axis labels\n c.xAxis().setLabels(labels)\n\n # Add a multi-bar layer with 3 data sets and 3 pixels 3D depth\n layer = c.addBarLayer2(ChartDirector::Side, 3)\n layer.addDataSet(data0, 0xff8080, \"Server #1\")\n layer.addDataSet(data1, 0x80ff80, \"Server #2\")\n layer.addDataSet(data2, 0x8080ff, \"Server #3\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def show\n if valid_chart?\n render status: :ok,\n json: { success: true, data: Metrics.new(chart, metadata).render }.to_json\n else\n render json: { success: false, error: 'Chart not found.' }\n end\n end", "def show\n akt_zeit\n #chart_kurven\n highchart_kurven\n init_diaquenauswahl\n # macht folgende Zeile �berfl�ssig\n #@diagramm = Diagramm.find(params[:id])\n @titelzeile = @diagramm.name + \" - KabDiag\"\n respond_to do |format|\n format.html {\n }\n format.json {\n p @chart\n render :inline => @chart.render #, :layout => false\n }\n end\n end", "def getchart()\n # 4 data points to represent the cash flow for the Q1 - Q4\n data = [230, -140, 220, 330]\n\n # We want to plot a waterfall chart showing the 4 quarters as well as the total\n labels = [\"1st Quarter\", \"2nd Quarter\", \"3rd Quarter\", \"4th Quarter\", \"Total\"]\n\n # The top side of the bars in a waterfall chart is the accumulated data. We use\n # the ChartDirector ArrayMath utility to accumulate the data. The \"total\" is\n # handled by inserting a zero point at the end before accumulation (after\n # accumulation it will become the total).\n boxTop = ChartDirector::ArrayMath.new(data).insert2(0, 1, data.length).acc(\n ).result()\n\n # The botom side of the bars is just the top side of the previous bar. So we\n # shifted the top side data to obtain the bottom side data.\n boxBottom = ChartDirector::ArrayMath.new(boxTop).shift(1, 0).result()\n\n # The last point (total) is different. Its bottom side is always 0.\n boxBottom[boxBottom.length - 1] = 0\n\n # In this example, we want to use different colors depending on the data is\n # positive or negative.\n posColor = 0x00ff00\n negColor = 0xff0000\n\n # Create a XYChart object of size 500 x 280 pixels. Set background color to light\n # blue (ccccff), with 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(500, 300, 0xccccff, 0x000000, 1)\n\n # Add a title to the chart using 13 points Arial Bold Itatic font, with white\n # (ffffff) text on a deep blue (0x80) background\n c.addTitle(\"Corporate Cash Flow - Year 2004\", \"arialbi.ttf\", 13, 0xffffff\n ).setBackground(0x000080)\n\n # Set the plotarea at (55, 50) and of size 430 x 215 pixels. Use alternative\n # white/grey background.\n c.setPlotArea(55, 50, 430, 215, 0xffffff, 0xeeeeee)\n\n # Add a legend box at (55, 25) using 8 pts Arial Bold font with horizontal layout,\n # with transparent background and border color.\n b = c.addLegend(55, 25, false, \"arialbd.ttf\", 8)\n b.setBackground(ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Add keys to show the colors for positive and negative cash flows\n b.addKey(\"Positive Cash Flow\", posColor)\n b.addKey(\"Negative Cash Flow\", negColor)\n\n # Set the labels on the x axis using Arial Bold font\n c.xAxis().setLabels(labels).setFontStyle(\"arialbd.ttf\")\n\n # Set the x-axis ticks and grid lines to be between the bars\n c.xAxis().setTickOffset(0.5)\n\n # Use Arial Bold as the y axis label font\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"USD (in millions)\")\n\n # Add a box-whisker layer to represent the waterfall bars\n layer = c.addBoxWhiskerLayer(boxTop, boxBottom)\n\n # Color the bars depending on whether it is positive or negative\n 0.upto(boxTop.length - 1) do |i|\n if boxTop[i] >= boxBottom[i]\n layer.setBoxColor(i, posColor)\n else\n layer.setBoxColor(i, negColor)\n end\n end\n\n # Put data labels on the bars to show the cash flow using Arial Bold font\n layer.setDataLabelFormat(\"{={top}-{bottom}}M\")\n layer.setDataLabelStyle(\"arialbd.ttf\").setAlignment(ChartDirector::Center)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the bar chart\n data = [85, 156, 179.5, 211, 123]\n\n # The labels for the bar chart\n labels = [\"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\"]\n\n # The colors for the bar chart\n colors = [0xb8bc9c, 0xa0bdc4, 0x999966, 0x333366, 0xc3c3e6]\n\n # Create a XYChart object of size 300 x 220 pixels. Use golden background color.\n # Use a 2 pixel 3D border.\n c = ChartDirector::XYChart.new(300, 220, ChartDirector::goldColor(), -1, 2)\n\n # Add a title box using 10 point Arial Bold font. Set the background color to\n # metallic blue (9999FF) Use a 1 pixel 3D border.\n c.addTitle(\"Daily Network Load\", \"arialbd.ttf\", 10).setBackground(\n ChartDirector::metalColor(0x9999ff), -1, 1)\n\n # Set the plotarea at (40, 40) and of 240 x 150 pixels in size\n c.setPlotArea(40, 40, 240, 150)\n\n # Add a multi-color bar chart layer using the given data and colors. Use a 1 pixel\n # 3D border for the bars.\n c.addBarLayer3(data, colors).setBorderColor(-1, 1)\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def chart\n case param_context(:chart_type)\n when 'cities' then\n @cities = city_count_data.to_a # build the data here, or pull it from an endpoint in the JS, but not both\n render 'cities_chart'\n when 'countries' then\n @countries = country_count_data.to_a # build the data here, or pull it from an endpoint in the JS, but not both\n render 'countries_chart'\n when 'years' then\n @years = year_count_data.to_a\n render 'years_chart'\n else\n flash[:error] = 'Unknown chart type'\n redirect_to events_path\n end\n end", "def getchart()\n #\n # We use a random number generator to simulate the data from 9:30am to 4:30pm\n # with one data point every 4 minutes. The total number of points during that\n # period is 106. (7 hours x 15 points/hour + 1)\n #\n noOfPoints = 106\n\n # Assume we have not reached the end of the day yet, and only 85 points are\n # available. Create a random table object of 1 col x 85 rows, using 9 as seed.\n rantable = ChartDirector::RanTable.new(9, 1, 85)\n\n # Set the 1st column to start with 1800 and with random delta from -5 to 5.\n rantable.setCol(0, 1800, -5, 5)\n\n # Get the data as the 1st column of the random table\n data = rantable.getCol(0)\n\n # The x-axis labels for the chart\n labels = [\"-\", \"10am\", \"-\", \" \", \"-\", \"12am\", \"-\", \" \", \"-\", \"2pm\", \"-\", \" \", \"-\",\n \"4pm\", \"-\"]\n\n #\n # Now we obtain the data into arrays, we can start to draw the chart using\n # ChartDirector\n #\n\n # Create a XYChart object of size 180 x 180 pixels with a blue background\n # (0x9c9cce)\n c = ChartDirector::XYChart.new(180, 180, 0x9c9cce)\n\n # Add titles to the top and bottom of the chart using 7.5pt Arial font. The text\n # is white 0xffffff on a deep blue 0x31319C background.\n c.addTitle2(ChartDirector::Top, \"STAR TECH INDEX 2003-01-28\", \"arial.ttf\", 7.5,\n 0xffffff, 0x31319c)\n c.addTitle2(ChartDirector::Bottom, \"LATEST STI:1809.41 (+14.51)\", \"arial.ttf\",\n 7.5, 0xffffff, 0x31319c)\n\n # Set the plotarea at (31, 21) and of size 145 x 124 pixels, with a pale yellow\n # (0xffffc8) background.\n c.setPlotArea(31, 21, 145, 124, 0xffffc8)\n\n # Add custom text at (176, 21) (top right corner of plotarea) using 11pt Times\n # Bold Italic font/red (0xc09090) color\n c.addText(176, 21, \"Chart Demo\", \"timesbi.ttf\", 11, 0xc09090).setAlignment(\n ChartDirector::TopRight)\n\n # Use 7.5 pts Arial as the y axis label font\n c.yAxis().setLabelStyle(\"\", 7.5)\n\n # Set the labels on the x axis by spreading the labels evenly between the first\n # point (index = 0) and the last point (index = noOfPoints - 1)\n c.xAxis().setLinearScale(0, noOfPoints - 1, labels)\n\n # Use 7.5 pts Arial as the x axis label font\n c.xAxis().setLabelStyle(\"\", 7.5)\n\n # Add a deep blue (0x000080) line layer to the chart\n c.addLineLayer(data, 0x000080)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data with error information\n data = [42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60,\n 70, 76, 63, 67, 75, 64, 51]\n errData = [5, 6, 5.1, 6.5, 6.6, 8, 5.4, 5.1, 4.6, 5.0, 5.2, 6.0, 4.9, 5.6, 4.8,\n 6.2, 7.4, 7.1, 6.0, 6.6, 7.1, 5.3, 5.5, 7.9, 6.1]\n\n # The labels for the chart\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 600 x 300 pixels, with a light grey (eeeeee)\n # background, black border, 1 pixel 3D border effect and rounded corners.\n c = ChartDirector::XYChart.new(600, 300, 0xeeeeee, 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 55) and of size 520 x 195 pixels, with white (ffffff)\n # background. Set horizontal and vertical grid lines to grey (cccccc).\n c.setPlotArea(55, 55, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is on a light grey\n # (dddddd) background, with glass lighting effect.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Molecular \" \\\n \"Temperature Control <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15\n ).setBackground(0xdddddd, 0, ChartDirector::glassEffect())\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Temperature\")\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.\n c.xAxis().setLabelStep(3, 1)\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a line layer to the chart\n lineLayer = c.addLineLayer2()\n\n # Add a blue (0xff) data set to the line layer, with yellow (0xffff80) diamond\n # symbols\n lineLayer.addDataSet(data, 0x0000ff).setDataSymbol(ChartDirector::DiamondSymbol,\n 12, 0xffff80)\n\n # Set the line width to 2 pixels\n lineLayer.setLineWidth(2)\n\n # Add a box whisker layer to the chart. Use the upper and lower mark of the box\n # whisker layer to act as error zones. The upper and lower marks are computed\n # using the ArrayMath object.\n errLayer = c.addBoxWhiskerLayer(nil, nil, ChartDirector::ArrayMath.new(data).add(\n errData).result(), ChartDirector::ArrayMath.new(data).sub(errData).result(),\n data, ChartDirector::Transparent, 0xbb6633)\n\n # Set the line width to 2 pixels\n errLayer.setLineWidth(2)\n\n # Set the error zone to occupy half the space between the symbols\n errLayer.setDataGap(0.5)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 247,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def makeChart(*options)\n\ndisplay = \"\n<div class='charts last'>\n\n<div class='left'>\n\n\n<div id='placeholder' style='width:400px;height:200px;'></div>\n<div id='overview' style='width:400px;height:50px'></div>\n<p id='overviewLegend' style='margin-left:10px'></p>\n\n<p> Try zooming. Click and drag to select a zone.</p>\n</div>\n\n<div class='right'>\n\nWeight Chart<br/>\n<div id='miniWeight' style='width:350px;height:100px;'></div>\nWater Chart<br/>\n<div id='miniWater' style='width:350px;height:100px;'></div>\n\n\nCalories Eaten<br/>\n<div id='miniCalorie' style='width:350px;height:100px;'></div>\nFitness (Calories burned not to include resting metabolism)<br/>\n<div id='miniFitness' style='width:350px;height:100px;'></div><br/>\n\nMeasurements (Total inches)<br/>\n<div id='miniMeasures' style='width:350px;height:100px;'></div>\n\n\n</div>\n\n\n\n\n<div class='last'></div>\n<script id='source' language='javascript' type='text/javascript'>\n\n\n$(function () {\nvar options = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { \n show: true, \n container: $('#overviewLegend'),\n noColumns: 2,\n }\n};\n\nvar options_overview = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { show: false}\n};\n\n\nvar plot = $.plot($('#placeholder'), \n[ #{@chartable.to_chart } ], options);\n\n\n\n\nvar overview = $.plot($('#overview'), \n[ #{@chartable.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n\n\n\n\nvar overview_1 = $.plot($('#miniWeight'), \n[ #{@miniWeight.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_2 = $.plot($('#miniWater'), \n[ #{@miniWater.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_3 = $.plot($('#miniCalorie'), \n[ #{@miniCalorie.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_4 = $.plot($('#miniFitness'), \n[ #{@miniFitness.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_5 = $.plot($('#miniMeasures'), \n[ #{@miniMeasures.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n// now connect the two\nvar internalSelection = false;\n\n$('#placeholder').bind('selected', function (event, area) {\n // do the zooming\n plot = $.plot($('#placeholder'), \n [#{@chartable.to_chart}],\n $.extend(true, {}, options, {\n xaxis: { min: area.x1, max: area.x2 }\n }));\n \n if (internalSelection)\n return; // prevent eternal loop\n internalSelection = true;\n overview.setSelection(area);\n internalSelection = false;\n});\n\n$('#overview').bind('selected', function (event, area) {\n if (internalSelection)\n return;\n internalSelection = true;\n plot.setSelection(area);\n internalSelection = false;\n});\n\n\n});\n</script>\n\"\n\nend", "def getchart()\n # The data for the area chart\n data0 = [42, 49, 33, 38, 51, 46, 29, 41, 44, 57, 59, 52, 37, 34, 51, 56, 56, 60,\n 70, 76, 63, 67, 75, 64, 51]\n data1 = [50, 55, 47, 34, 42, 49, 63, 62, 73, 59, 56, 50, 64, 60, 67, 67, 58, 59,\n 73, 77, 84, 82, 80, 84, 89]\n data2 = [87, 89, 85, 66, 53, 39, 24, 21, 37, 56, 37, 22, 21, 33, 13, 17, 4, 23,\n 16, 25, 9, 10, 5, 7, 6]\n labels = [\"0\", \"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"11\", \"12\",\n \"13\", \"14\", \"15\", \"16\", \"17\", \"18\", \"19\", \"20\", \"21\", \"22\", \"23\", \"24\"]\n\n # Create a XYChart object of size 350 x 230 pixels\n c = ChartDirector::XYChart.new(350, 230)\n\n # Set the plotarea at (50, 30) and of size 250 x 150 pixels.\n c.setPlotArea(50, 30, 250, 150)\n\n # Add a legend box at (55, 0) (top of the chart) using 8 pts Arial Font. Set\n # background and border to Transparent.\n c.addLegend(55, 0, false, \"\", 8).setBackground(ChartDirector::Transparent)\n\n # Add a title to the x axis\n c.xAxis().setTitle(\"Network Load for Jun 12\")\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"MBytes\")\n\n # Set the labels on the x axis.\n c.xAxis().setLabels(labels)\n\n # Display 1 out of 2 labels on the x-axis. Show minor ticks for remaining labels.\n c.xAxis().setLabelStep(2, 1)\n\n # Add three area layers, each representing one data set. The areas are drawn in\n # semi-transparent colors.\n c.addAreaLayer(data2, 0x808080ff, \"Server #1\", 3)\n c.addAreaLayer(data0, 0x80ff0000, \"Server #2\", 3)\n c.addAreaLayer(data1, 0x8000ff00, \"Server #3\", 3)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def basic_chart\n \n end", "def drawChart()\n # The moving average periods selected by the user.\n avgPeriod1 = 0\n avgPeriod1 = params[\"movAvg1\"].to_i\n avgPeriod2 = 0\n avgPeriod2 = params[\"movAvg2\"].to_i\n\n if avgPeriod1 < 0\n avgPeriod1 = 0\n elsif avgPeriod1 > 300\n avgPeriod1 = 300\n end\n\n if avgPeriod2 < 0\n avgPeriod2 = 0\n elsif avgPeriod2 > 300\n avgPeriod2 = 300\n end\n\n # We need extra leading data points in order to compute moving averages.\n extraPoints = 20\n if avgPeriod1 > extraPoints\n extraPoints = avgPeriod1\n end\n if avgPeriod2 > extraPoints\n extraPoints = avgPeriod2\n end\n\n # Get the data series to compare with, if any.\n compareKey = (params[\"CompareWith\"] || \"\").strip\n @compareData = nil\n if getData(compareKey, extraPoints)\n @compareData = @closeData\n end\n\n # The data series we want to get.\n tickerKey = (params[\"TickerSymbol\"] || \"\").strip\n if !getData(tickerKey, extraPoints)\n return errMsg(\"Please enter a valid ticker symbol\")\n end\n\n \n\n # Check if there is any valid data\n if extraPoints >= @timeStamps.length\n # No data - just display the no data message.\n return errMsg(\"No data available for the specified time period\")\n end\n\n # In some finance chart presentation style, even if the data for the latest day is\n # not fully available, the axis for the entire day will still be drawn, where no\n # data will appear near the end of the axis.\n # if @resolution < 86400\n # # Add extra points to the axis until it reaches the end of the day. The end of\n # # day is assumed to be 16:00 (it depends on the stock exchange).\n # lastTime = @timeStamps[@timeStamps.length - 1]\n # extraTrailingPoints = ((16 * 3600 - lastTime % 86400) / @resolution).to_i\n # 0.upto(extraTrailingPoints - 1) do |i|\n # @timeStamps.push(lastTime + @resolution * (i + 1))\n # end\n # end\n\n #\n # At this stage, all data are available. We can draw the chart as according to\n # user input.\n #\n\n #\n # Determine the chart size. In this demo, user can select 4 different chart sizes.\n # Default is the large chart size.\n #\n width = 780\n mainHeight = 255\n indicatorHeight = 80\n\n size = params[\"ChartSize\"]\n if size == \"S\"\n # Small chart size\n width = 450\n mainHeight = 160\n indicatorHeight = 60\n elsif size == \"M\"\n # Medium chart size\n width = 620\n mainHeight = 215\n indicatorHeight = 70\n elsif size == \"H\"\n # Huge chart size\n width = 1000\n mainHeight = 320\n indicatorHeight = 90\n end\n\n # Create the chart object using the selected size\n m = ChartDirector::FinanceChart.new(width)\n\n # Set the data into the chart object\n m.setData(@timeStamps, @highData, @lowData, @openData, @closeData, @volData,\n extraPoints)\n #debugger\n #\n # We configure the title of the chart. In this demo chart design, we put the\n # company name as the top line of the title with left alignment.\n #\n m.addPlotAreaTitle(ChartDirector::TopLeft, tickerKey)\n\n # We displays the current date as well as the data resolution on the next line.\n resolutionText = \"\"\n if @resolution == 30 * 86400\n resolutionText = \"Monthly\"\n elsif @resolution == 7 * 86400\n resolutionText = \"Weekly\"\n elsif @resolution == 86400\n resolutionText = \"Daily\"\n elsif @resolution == 900\n resolutionText = \"15-min\"\n end\n\n m.addPlotAreaTitle(ChartDirector::BottomLeft, sprintf(\n \"<*font=arial.ttf,size=8*>%s - %s chart\", m.formatValue(Time.new,\n \"mmm dd, yyyy\"), resolutionText))\n\n # A copyright message at the bottom left corner the title area\n m.addPlotAreaTitle(ChartDirector::BottomRight,\n \"<*font=arial.ttf,size=8*>(c) Advanced Software Engineering\")\n\n #\n # Add the first techical indicator according. In this demo, we draw the first\n # indicator on top of the main chart.\n #\n addIndicator(m, params[\"Indicator1\"], indicatorHeight)\n\n #\n # Add the main chart\n #\n m.addMainChart(mainHeight)\n\n #\n # Set log or linear scale according to user preference\n #\n if params[\"LogScale\"] == \"1\"\n m.setLogScale(true)\n end\n\n #\n # Set axis labels to show data values or percentage change to user preference\n #\n if params[\"PercentageScale\"] == \"1\"\n m.setPercentageAxis()\n end\n\n #\n # Draw any price line the user has selected\n #\n mainType = params[\"ChartType\"]\n if mainType == \"Close\"\n m.addCloseLine(0x000040)\n elsif mainType == \"TP\"\n m.addTypicalPrice(0x000040)\n elsif mainType == \"WC\"\n m.addWeightedClose(0x000040)\n elsif mainType == \"Median\"\n m.addMedianPrice(0x000040)\n end\n\n #\n # Add comparison line if there is data for comparison\n #\n if @compareData != nil\n if @compareData.length > extraPoints\n m.addComparison(@compareData, 0x0000ff, compareKey)\n end\n end\n\n #\n # Add moving average lines.\n #\n addMovingAvg(m, params[\"avgType1\"], avgPeriod1, 0x663300)\n addMovingAvg(m, params[\"avgType2\"], avgPeriod2, 0x9900ff)\n\n #\n # Draw candlesticks or OHLC symbols if the user has selected them.\n #\n if mainType == \"CandleStick\"\n m.addCandleStick(0x33ff33, 0xff3333)\n elsif mainType == \"OHLC\"\n m.addHLOC(0x008800, 0xcc0000)\n end\n\n #\n # Add parabolic SAR if necessary\n #\n if params[\"ParabolicSAR\"] == \"1\"\n m.addParabolicSAR(0.02, 0.02, 0.2, ChartDirector::DiamondShape, 5, 0x008800,\n 0x000000)\n end\n\n #\n # Add price band/channel/envelop to the chart according to user selection\n #\n bandType = params[\"Band\"]\n if bandType == \"BB\"\n m.addBollingerBand(20, 2, 0x9999ff, 0xc06666ff)\n elsif bandType == \"DC\"\n m.addDonchianChannel(20, 0x9999ff, 0xc06666ff)\n elsif bandType == \"Envelop\"\n m.addEnvelop(20, 0.1, 0x9999ff, 0xc06666ff)\n end\n\n #\n # Add volume bars to the main chart if necessary\n #\n if params[\"Volume\"] == \"1\"\n m.addVolBars(indicatorHeight, 0x99ff99, 0xff9999, 0xc0c0c0)\n end\n\n #\n # Add additional indicators as according to user selection.\n #\n addIndicator(m, params[\"Indicator2\"], indicatorHeight)\n addIndicator(m, params[\"Indicator3\"], indicatorHeight)\n addIndicator(m, params[\"Indicator4\"], indicatorHeight)\n\n return m\n end", "def getchart()\n # The x and y coordinates of the grid\n dataX = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]\n dataY = [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]\n\n # The values at the grid points. In this example, we will compute the values using\n # the formula z = sin((x - 0.5) * 2 * pi) * sin((y - 0.5) * 2 * pi)\n dataZ = Array.new((dataX.length) * (dataY.length))\n 0.upto(dataY.length - 1) do |yIndex|\n y = (dataY[yIndex] - 0.5) * 2 * 3.1416\n 0.upto(dataX.length - 1) do |xIndex|\n x = (dataX[xIndex] - 0.5) * 2 * 3.1416\n dataZ[yIndex * (dataX.length) + xIndex] = Math.sin(x) * Math.sin(y)\n end\n end\n\n # Create a SurfaceChart object of size 720 x 540 pixels\n c = ChartDirector::SurfaceChart.new(720, 540)\n\n # Add a title to the chart using 20 points Times New Roman Italic font\n c.addTitle(\"Quantum Wave Function\", \"timesi.ttf\", 20)\n\n # Set the center of the plot region at (360, 245), and set width x depth x height\n # to 360 x 360 x 270 pixels\n c.setPlotRegion(360, 245, 360, 360, 270)\n\n # Set the elevation and rotation angles to 20 and 30 degrees\n c.setViewAngle(20, 30)\n\n # Set the data to use to plot the chart\n c.setData(dataX, dataY, dataZ)\n\n # Spline interpolate data to a 80 x 80 grid for a smooth surface\n c.setInterpolation(80, 80)\n\n # Set surface grid lines to semi-transparent black (dd000000)\n c.setSurfaceAxisGrid(0xdd000000)\n\n # Set contour lines to semi-transparent white (80ffffff)\n c.setContourColor(0x80ffffff)\n\n # Add a color axis (the legend) in which the left center is anchored at (645,\n # 270). Set the length to 200 pixels and the labels on the right side. Use smooth\n # gradient coloring.\n c.setColorAxis(645, 270, ChartDirector::Left, 200, ChartDirector::Right\n ).setColorGradient()\n\n # Set the x, y and z axis titles using 10 points Arial Bold font\n c.xAxis().setTitle(\"x/L(x)\", \"arialbd.ttf\", 10)\n c.yAxis().setTitle(\"y/L(y)\", \"arialbd.ttf\", 10)\n c.zAxis().setTitle(\"Wave Function Amplitude\", \"arialbd.ttf\", 10)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::JPG), :type => \"image/jpeg\",\n :disposition => \"inline\")\n end", "def index\n @title = get_title\n\n @show_conditions = false\n\n if show_date_condition\n @date_condition = true\n @show_conditions = true\n else\n @date_condition = false\n end\n\n if show_pages\n @show_pages = true\n end\n\n unless get_grouping_options.empty?\n @grouping_options = RedmineCharts::GroupingUtils.to_options(get_grouping_options)\n @show_conditions = true\n else\n @grouping_options = []\n end\n\n unless get_conditions_options.empty?\n @conditions_options = RedmineCharts::ConditionsUtils.to_options(get_conditions_options, @project.id)\n @show_conditions = true\n else\n @conditions_options = []\n end\n \n @show_left_column = @show_conditions\n\n unless get_help.blank?\n @help = get_help\n @show_left_column = true\n else\n @help = nil\n end\n\n @range = RedmineCharts::RangeUtils.from_params(params)\n @pagination = RedmineCharts::PaginationUtils.from_params(params)\n @grouping = RedmineCharts::GroupingUtils.from_params(get_grouping_options, params)\n @conditions = RedmineCharts::ConditionsUtils.from_params(get_conditions_options, @project.id, params)\n\n @data = data\n\n render :template => \"charts/index\"\n end", "def to_html\n @chart.to_html\n end", "def getchart()\n # The XYZ points for the bubble chart\n dataX0 = [170, 300, 1000, 1700]\n dataY0 = [16, 69, 16, 75]\n dataZ0 = [52, 105, 88, 140]\n\n dataX1 = [500, 1000, 1300]\n dataY1 = [40, 58, 85]\n dataZ1 = [140, 202, 84]\n\n # Create a XYChart object of size 540 x 480 pixels\n c = ChartDirector::XYChart.new(540, 480)\n\n # Set the plotarea at (70, 65) and of size 400 x 350 pixels. Turn on both\n # horizontal and vertical grid lines with light grey color (0xc0c0c0)\n c.setPlotArea(70, 65, 400, 350, -1, -1, ChartDirector::Transparent, 0xc0c0c0, -1)\n\n # Add a legend box at (70, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(70, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Product Comparison Chart\", \"timesbi.ttf\", 18)\n\n # Add titles to the axes using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Capacity (tons)\", \"arialbi.ttf\", 12)\n c.xAxis().setTitle(\"Range (miles)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Add (dataX0, dataY0) as a scatter layer with red (ff3333) glass spheres, where\n # the sphere size is modulated by dataZ0. This creates a bubble effect.\n c.addScatterLayer(dataX0, dataY0, \"Technology AAA\",\n ChartDirector::GlassSphere2Shape, 15, 0xff3333).setSymbolScale(dataZ0)\n\n # Add (dataX1, dataY1) as a scatter layer with blue (0000ff) glass spheres, where\n # the sphere size is modulated by dataZ1. This creates a bubble effect.\n c.addScatterLayer(dataX1, dataY1, \"Technology BBB\",\n ChartDirector::GlassSphere2Shape, 15, 0x0000ff).setSymbolScale(dataZ1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # Sample data for the Box-Whisker chart. Represents the minimum, 1st quartile,\n # medium, 3rd quartile and maximum values of some quantities\n q0Data = [40, 45, 40, 30, 20, 50, 25, 44]\n q1Data = [55, 60, 50, 40, 38, 60, 51, 60]\n q2Data = [62, 70, 60, 50, 48, 70, 62, 70]\n q3Data = [70, 80, 65, 60, 53, 78, 69, 76]\n q4Data = [80, 90, 75, 70, 60, 85, 80, 84]\n\n # The labels for the chart\n labels = [\"Group A\", \"Group B\", \"Group C\", \"Group D\", \"Group E\", \"Group F\",\n \"Group G\", \"Group H\"]\n\n # Create a XYChart object of size 550 x 250 pixels\n c = ChartDirector::XYChart.new(550, 250)\n\n # Set the plotarea at (50, 25) and of size 450 x 200 pixels. Enable both\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(50, 25, 450, 200).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart\n c.addTitle(\"Computer Vision Test Scores\")\n\n # Set the labels on the x axis and the font to Arial Bold\n c.xAxis().setLabels(labels).setFontStyle(\"arialbd.ttf\")\n\n # Set the font for the y axis labels to Arial Bold\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # Add a Box Whisker layer using light blue 0x9999ff as the fill color and blue\n # (0xcc) as the line color. Set the line width to 2 pixels\n c.addBoxWhiskerLayer(q3Data, q1Data, q4Data, q0Data, q2Data, 0x9999ff, 0x0000cc\n ).setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The data for the upper and lower bounding lines\n upperY = [60, 60, 100, 100, 60, 60]\n lowerY = [40, 40, 80, 80, 40, 40]\n zoneX = [0, 2.5, 3.5, 5.5, 6.5, 10]\n\n # The data for the spline curve\n curveY = [50, 44, 54, 48, 58, 50, 90, 85, 104, 82, 96, 90, 74, 52, 35, 58, 46, 54,\n 48, 52, 50]\n curveX = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5,\n 9, 9.5, 10]\n\n # Create a XYChart object of size 600 x 300 pixels, with a light grey (cccccc)\n # background, black border, and 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(600, 300, 0xcccccc, 0x000000, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white\n # background. Turn on both horizontal and vertical grid lines with light grey\n # color (cccccc)\n c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is white (ffffff)\n # on a black background, with a 1 pixel 3D border.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance \" \\\n \"Enhancer <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x000000, -1, 1)\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Temperature\")\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a purple (800080) spline layer to the chart with a line width of 2 pixels\n splineLayer = c.addSplineLayer(curveY, 0x800080, \"Molecular Temperature\")\n splineLayer.setXData(curveX)\n splineLayer.setLineWidth(2)\n\n # Add a line layer to the chart with two dark green (338033) data sets, and a line\n # width of 2 pixels\n lineLayer = c.addLineLayer2()\n lineLayer.addDataSet(upperY, 0x338033, \"Target Zone\")\n lineLayer.addDataSet(lowerY, 0x338033)\n lineLayer.setXData(zoneX)\n lineLayer.setLineWidth(2)\n\n # Color the zone between the upper zone line and lower zone line as\n # semi-transparent light green (8099ff99)\n c.addInterLineLayer(lineLayer.getLine(0), lineLayer.getLine(1), 0x8099ff99,\n 0x8099ff99)\n\n # If the spline line gets above the upper zone line, color to area between the\n # lines red (ff0000)\n c.addInterLineLayer(splineLayer.getLine(0), lineLayer.getLine(0), 0xff0000,\n ChartDirector::Transparent)\n\n # If the spline line gets below the lower zone line, color to area between the\n # lines blue (0000ff)\n c.addInterLineLayer(splineLayer.getLine(0), lineLayer.getLine(1),\n ChartDirector::Transparent, 0x0000ff)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 250,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def to_html(input_args=Hash.new)\n #puts \"to_html arg #{input_args}\"\n\n reset_chart(input_args)\n \n open_tag('script',script_content)\n open_tag('div',\"\",class: get_chart_size(input_args[:size])[:column]) do\n if @id\n if @do_not_save_chart\n open_tag('small',\"user generated json has no chart expand function\") \n else \n open_tag('small') do\n #open_tag('span','',class: 'chart_btn') do\n # open_tag('a',\"Expand\",href: \"/chart_expand/#{chart_url}\")\n #end\n #if @args[:time] # if time chart, srg wants to button user can click to show status last month\n # open_tag('span','',class: 'chart_btn') do\n # open_tag('a',\"last month\",href: \"/chart_last_month/#{chart_url}\")\n # end\n #end\n if @args[:title] # jason 111516, intentionally write the chart's title here. this one is useful when there are a lot of chart and people can search chart by using browser's search function\n open_tag('span',\"#{@args[:title]}\");\n end\n open_tag('span','',id: 'tooltip_info') do # this field gets populated when user hovers on tool tip\n end\n end\n end\n end\n open_tag('div',\"\",class: get_chart_size(input_args[:size])[:css]) do\n open_tag('canvas',\"\",id: \"#{@chart_id}\" ) do # matches the javascript code which expect to populate LineChart\n end \n end \n end\n @out\n end", "def getchart()\n # The XYZ points for the bubble chart\n dataX0 = [150, 300, 1000, 1700]\n dataY0 = [12, 60, 25, 65]\n dataZ0 = [20, 50, 50, 85]\n\n dataX1 = [500, 1000, 1300]\n dataY1 = [35, 50, 75]\n dataZ1 = [30, 55, 95]\n\n # Create a XYChart object of size 450 x 420 pixels\n c = ChartDirector::XYChart.new(450, 420)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with a light grey\n # border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light\n # grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Product Comparison Chart\", \"timesbi.ttf\", 18)\n\n # Add a title to the y axis using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Capacity (tons)\", \"arialbi.ttf\", 12)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Range (miles)\", \"arialbi.ttf\", 12)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Add (dataX0, dataY0) as a scatter layer with semi-transparent red (0x80ff3333)\n # circle symbols, where the circle size is modulated by dataZ0. This creates a\n # bubble effect.\n c.addScatterLayer(dataX0, dataY0, \"Technology AAA\", ChartDirector::CircleSymbol,\n 9, 0x80ff3333, 0x80ff3333).setSymbolScale(dataZ0)\n\n # Add (dataX1, dataY1) as a scatter layer with semi-transparent green (0x803333ff)\n # circle symbols, where the circle size is modulated by dataZ1. This creates a\n # bubble effect.\n c.addScatterLayer(dataX1, dataY1, \"Technology BBB\", ChartDirector::CircleSymbol,\n 9, 0x803333ff, 0x803333ff).setSymbolScale(dataZ1)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # Sample data for the Box-Whisker chart. Represents the minimum, 1st quartile,\n # medium, 3rd quartile and maximum values of some quantities\n q0Data = [40, 45, 35]\n q1Data = [55, 60, 50]\n q2Data = [62, 70, 60]\n q3Data = [70, 80, 65]\n q4Data = [80, 90, 75]\n\n # The labels for the chart\n labels = [\"<*img=robot1.png*><*br*>Bipedal Type\",\n \"<*img=robot2.png*><*br*>Wolf Type\", \"<*img=robot5.png*><*br*>Bird Type\"]\n\n # Create a XYChart object of size 540 x 320 pixels\n c = ChartDirector::XYChart.new(540, 320)\n\n # swap the x and y axes to create a horizontal box-whisker chart\n c.swapXY()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (75, 25) and of size 440 x 270 pixels. Enable both\n # horizontal and vertical grids by setting their colors to grey (0xc0c0c0)\n c.setPlotArea(75, 25, 440, 270).setGridColor(0xc0c0c0, 0xc0c0c0)\n\n # Add a title to the chart\n c.addTitle(\" Robot Shooting Accuracy Scores\")\n\n # Set the labels on the x axis and the font to Arial Bold\n c.xAxis().setLabels(labels).setFontStyle(\"arialbd.ttf\")\n\n # Disable x axis ticks by setting the length to 0\n c.xAxis().setTickLength(0)\n\n # Set the font for the y axis labels to Arial Bold\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # Add a Box Whisker layer using light blue 0x9999ff as the fill color and blue\n # (0xcc) as the line color. Set the line width to 2 pixels\n c.addBoxWhiskerLayer2(q3Data, q1Data, q4Data, q0Data, q2Data).setLineWidth(2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def show\n respond_to do |format|\n format.html # show.html.haml\n format.json { render json: @chart }\n end\n end", "def getchart()\n # Some ChartDirector built-in symbols\n symbols = [ChartDirector::CircleShape, ChartDirector::GlassSphereShape,\n ChartDirector::GlassSphere2Shape, ChartDirector::SolidSphereShape,\n ChartDirector::SquareShape, ChartDirector::DiamondShape,\n ChartDirector::TriangleShape, ChartDirector::RightTriangleShape,\n ChartDirector::LeftTriangleShape, ChartDirector::InvertedTriangleShape,\n ChartDirector::StarShape(3), ChartDirector::StarShape(4),\n ChartDirector::StarShape(5), ChartDirector::StarShape(6),\n ChartDirector::StarShape(7), ChartDirector::StarShape(8),\n ChartDirector::StarShape(9), ChartDirector::StarShape(10),\n ChartDirector::PolygonShape(5), ChartDirector::Polygon2Shape(5),\n ChartDirector::PolygonShape(6), ChartDirector::Polygon2Shape(6),\n ChartDirector::CrossShape(0.1), ChartDirector::CrossShape(0.2),\n ChartDirector::CrossShape(0.3), ChartDirector::CrossShape(0.4),\n ChartDirector::CrossShape(0.5), ChartDirector::CrossShape(0.6),\n ChartDirector::CrossShape(0.7), ChartDirector::Cross2Shape(0.1),\n ChartDirector::Cross2Shape(0.2), ChartDirector::Cross2Shape(0.3),\n ChartDirector::Cross2Shape(0.4), ChartDirector::Cross2Shape(0.5),\n ChartDirector::Cross2Shape(0.6), ChartDirector::Cross2Shape(0.7)]\n\n # Create a XYChart object of size 450 x 400 pixels\n c = ChartDirector::XYChart.new(450, 400)\n\n # Set the plotarea at (55, 40) and of size 350 x 300 pixels, with a light grey\n # border (0xc0c0c0). Turn on both horizontal and vertical grid lines with light\n # grey color (0xc0c0c0)\n c.setPlotArea(55, 40, 350, 300, -1, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font.\n c.addTitle(\"Built-in Symbols\", \"timesbi.ttf\", 18)\n\n # Set the axes line width to 3 pixels\n c.xAxis().setWidth(3)\n c.yAxis().setWidth(3)\n\n # Ensure the ticks are at least 1 unit part (integer ticks)\n c.xAxis().setMinTickInc(1)\n c.yAxis().setMinTickInc(1)\n\n # Add each symbol as a separate scatter layer.\n 0.upto(symbols.length - 1) do |i|\n c.addScatterLayer([i % 6 + 1], [(i / 6 + 1).to_i], \"\", symbols[i], 15)\n end\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # Data for the chart\n data0 = [5, 3, 10, 4, 3, 5, 2, 5]\n data1 = [12, 6, 17, 6, 7, 9, 4, 7]\n data2 = [17, 7, 22, 7, 18, 13, 5, 11]\n\n labels = [\"North\", \"North<*br*>East\", \"East\", \"South<*br*>East\", \"South\",\n \"South<*br*>West\", \"West\", \"North<*br*>West\"]\n\n # Create a PolarChart object of size 460 x 500 pixels, with a grey (e0e0e0)\n # background and 1 pixel 3D border\n c = ChartDirector::PolarChart.new(460, 500, 0xe0e0e0, 0x000000, 1)\n\n # Add a title to the chart at the top left corner using 15pts Arial Bold Italic\n # font. Use a wood pattern as the title background.\n c.addTitle(\"Polar Area Chart Demo\", \"arialbi.ttf\", 15).setBackground(\n c.patternColor(File.dirname(__FILE__) + \"/wood.png\"))\n\n # Set center of plot area at (230, 280) with radius 180 pixels, and white (ffffff)\n # background.\n c.setPlotArea(230, 280, 180, 0xffffff)\n\n # Set the grid style to circular grid\n c.setGridStyle(false)\n\n # Add a legend box at top-center of plot area (230, 35) using horizontal layout.\n # Use 10 pts Arial Bold font, with 1 pixel 3D border effect.\n b = c.addLegend(230, 35, false, \"arialbd.ttf\", 9)\n b.setAlignment(ChartDirector::TopCenter)\n b.setBackground(ChartDirector::Transparent, ChartDirector::Transparent, 1)\n\n # Set angular axis using the given labels\n c.angularAxis().setLabels(labels)\n\n # Specify the label format for the radial axis\n c.radialAxis().setLabelFormat(\"{value}%\")\n\n # Set radial axis label background to semi-transparent grey (40cccccc)\n c.radialAxis().setLabelStyle().setBackground(0x40cccccc, 0)\n\n # Add the data as area layers\n c.addAreaLayer(data2, -1, \"5 m/s or above\")\n c.addAreaLayer(data1, -1, \"1 - 5 m/s\")\n c.addAreaLayer(data0, -1, \"less than 1 m/s\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def show_graph\n url_for_data = url_for(controller.params.merge(:action => :data)).gsub('&amp;', '&')\n relative_url_path = ActionController::Base.respond_to?(:relative_url_root) ? ActionController::Base.relative_url_root : ActionController::AbstractRequest.relative_url_root\n html, div_name = controller.open_flash_chart_object_and_div_name('100%', '400', url_for_data, true, \"#{relative_url_path}/\")\n\n html << '<script type=\"text/javascript\">' << \"\\n\"\n html << \"var charts_to_image_title = '#{h(controller.title)}';\\n\" \n html << \"var charts_to_image_id = '#{div_name}';\\n\"\n html << '</script>'\n\n html\n end", "def simple_chart\n \n end", "def render data\n @renderer.render(data)\n end", "def getchart()\n # The tasks for the gantt chart\n labels = [\"Market Research\", \"Define Specifications\", \"Overall Archiecture\",\n \"Project Planning\", \"Detail Design\", \"Software Development\", \"Test Plan\",\n \"Testing and QA\", \"User Documentation\"]\n\n # The task index, start date, end date and color for each bar\n taskNo = [0, 0, 1, 2, 3, 4, 5, 6, 6, 7, 8, 8]\n startDate = [Time.mktime(2004, 8, 16), Time.mktime(2004, 10, 4), Time.mktime(2004,\n 8, 30), Time.mktime(2004, 9, 13), Time.mktime(2004, 9, 20), Time.mktime(2004,\n 9, 27), Time.mktime(2004, 10, 4), Time.mktime(2004, 10, 4), Time.mktime(2004,\n 10, 25), Time.mktime(2004, 11, 1), Time.mktime(2004, 10, 18), Time.mktime(\n 2004, 11, 8)]\n endDate = [Time.mktime(2004, 8, 30), Time.mktime(2004, 10, 18), Time.mktime(2004,\n 9, 13), Time.mktime(2004, 9, 27), Time.mktime(2004, 10, 4), Time.mktime(2004,\n 10, 11), Time.mktime(2004, 11, 8), Time.mktime(2004, 10, 18), Time.mktime(\n 2004, 11, 8), Time.mktime(2004, 11, 22), Time.mktime(2004, 11, 1),\n Time.mktime(2004, 11, 22)]\n colors = [0x00cc00, 0x00cc00, 0x00cc00, 0x0000cc, 0x0000cc, 0xcc0000, 0xcc0000,\n 0x0000cc, 0xcc0000, 0xcc0000, 0x00cc00, 0xcc0000]\n\n # Create a XYChart object of size 620 x 325 pixels. Set background color to light\n # red (0xffcccc), with 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(620, 325, 0xffcccc, 0x000000, 1)\n\n # Add a title to the chart using 15 points Times Bold Itatic font, with white\n # (ffffff) text on a dark red (800000) background\n c.addTitle(\"Mutli-Color Gantt Chart Demo\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x800000)\n\n # Set the plotarea at (140, 55) and of size 460 x 200 pixels. Use alternative\n # white/grey background. Enable both horizontal and vertical grids by setting\n # their colors to grey (c0c0c0). Set vertical major grid (represents month\n # boundaries) 2 pixels in width\n c.setPlotArea(140, 55, 460, 200, 0xffffff, 0xeeeeee, ChartDirector::LineColor,\n 0xc0c0c0, 0xc0c0c0).setGridWidth(2, 1, 1, 1)\n\n # swap the x and y axes to create a horziontal box-whisker chart\n c.swapXY()\n\n # Set the y-axis scale to be date scale from Aug 16, 2004 to Nov 22, 2004, with\n # ticks every 7 days (1 week)\n c.yAxis().setDateScale(Time.mktime(2004, 8, 16), Time.mktime(2004, 11, 22),\n 86400 * 7)\n\n # Set multi-style axis label formatting. Month labels are in Arial Bold font in\n # \"mmm d\" format. Weekly labels just show the day of month and use minor tick (by\n # using '-' as first character of format string).\n c.yAxis().setMultiFormat(ChartDirector::StartOfMonthFilter(),\n \"<*font=arialbd.ttf*>{value|mmm d}\", ChartDirector::StartOfDayFilter(),\n \"-{value|d}\")\n\n # Set the y-axis to shown on the top (right + swapXY = top)\n c.setYAxisOnRight()\n\n # Set the labels on the x axis\n c.xAxis().setLabels(labels)\n\n # Reverse the x-axis scale so that it points downwards.\n c.xAxis().setReverse()\n\n # Set the horizontal ticks and grid lines to be between the bars\n c.xAxis().setTickOffset(0.5)\n\n # Add some symbols to the chart to represent milestones. The symbols are added\n # using scatter layers. We need to specify the task index, date, name, symbol\n # shape, size and color.\n c.addScatterLayer([1], [Time.mktime(2004, 9, 13)], \"Milestone 1\",\n ChartDirector::Cross2Shape(), 13, 0xffff00)\n c.addScatterLayer([3], [Time.mktime(2004, 10, 4)], \"Milestone 2\",\n ChartDirector::StarShape(5), 15, 0xff00ff)\n c.addScatterLayer([5], [Time.mktime(2004, 11, 8)], \"Milestone 3\",\n ChartDirector::TriangleSymbol, 13, 0xff9933)\n\n # Add a multi-color box-whisker layer to represent the gantt bars\n layer = c.addBoxWhiskerLayer2(startDate, endDate, nil, nil, nil, colors)\n layer.setXData(taskNo)\n layer.setBorderColor(ChartDirector::SameAsMainColor)\n\n # Divide the plot area height ( = 200 in this chart) by the number of tasks to get\n # the height of each slot. Use 80% of that as the bar height.\n layer.setDataWidth((200 * 4 / 5 / (labels.length)).to_i)\n\n # Add a legend box at (140, 265) - bottom of the plot area. Use 8 pts Arial Bold\n # as the font with auto-grid layout. Set the width to the same width as the plot\n # area. Set the backgorund to grey (dddddd).\n legendBox = c.addLegend2(140, 265, ChartDirector::AutoGrid, \"arialbd.ttf\", 8)\n legendBox.setWidth(461)\n legendBox.setBackground(0xdddddd)\n\n # The keys for the scatter layers (milestone symbols) will automatically be added\n # to the legend box. We just need to add keys to show the meanings of the bar\n # colors.\n legendBox.addKey(\"Market Team\", 0x00cc00)\n legendBox.addKey(\"Planning Team\", 0x0000cc)\n legendBox.addKey(\"Development Team\", 0xcc0000)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def charting\n check_state_and_update\n @titles = Title.build_horizontal_collection(@task.id,current_user.id)\n \n respond_to do |format| \n format.html \n end\n end", "def chart(template, *options, &block)\n # Access the actual chart object\n Compendium::Presenters::Chart.new(template, self, *options, &block)\n end", "def show\n unless parent.chart\n parent.update_attributes chart: Chart.find_or_create(parent.dob)\n end\n @chart = parent.chart\n @name = parent.full_name\n\n @chart = Chart.find(params[:id])\n respond_with(@chart)\n \n respond_to do |format|\n format.html\n # format.html { render :layout => 'chart' }\n format.pdf {\n pdf = ChartPdf.new(@chart, @name, view_context)\n send_data pdf.render, filename: \"#{parent.friendly_id}-natal-chart.pdf\", type: \"application/pdf\", disposition: 'inline'\n }\n end\n end", "def render_chart_html(chart_swf,str_url,str_xml,chart_id,chart_width,chart_height,debug_mode,&block)\n chart_width=chart_width.to_s\n chart_height=chart_height.to_s\n \n debug_mode_num=\"0\"\n if debug_mode==true\n debug_mode_num=\"1\"\n end \n str_flash_vars=\"\"\n if str_xml==\"\"\n str_flash_vars=\"chartWidth=\"+chart_width+\"&chartHeight=\"+chart_height+\"&debugmode=\"+debug_mode_num+\"&dataURL=\"+str_url\n logger.info(\"The method used is setDataURL.The URL is \" + str_url)\n else\n str_flash_vars=\"chartWidth=\"+chart_width+\"&chartHeight=\"+chart_height+\"&debugmode=\"+debug_mode_num+\"&dataXML=\"+str_xml\n logger.info(\"The method used is setDataXML.The XML is \" + str_xml)\n end\n concat(\"\\t\\t<!-- START Code Block for Chart -->\\n\\t\\t\",block.binding)\n \n object_attributes={:classid=>\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\"}\n object_attributes=object_attributes.merge(:codebase=>\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\")\n object_attributes=object_attributes.merge(:width=>chart_width)\n object_attributes=object_attributes.merge(:height=>chart_height)\n object_attributes=object_attributes.merge(:id=>chart_id)\n \n param_attributes1={:name=>\"allowscriptaccess\",:value=>\"always\"}\n param_tag1=content_tag(\"param\",\"\",param_attributes1)\n \n param_attributes2={:name=>\"movie\",:value=>chart_swf}\n param_tag2=content_tag(\"param\",\"\",param_attributes2)\n \n param_attributes3={:name=>\"FlashVars\",:value=>str_flash_vars}\n param_tag3=content_tag(\"param\",\"\",param_attributes3)\n \n param_attributes4={:name=>\"quality\",:value=>\"high\"}\n param_tag4=content_tag(\"param\",\"\",param_attributes4)\n \n embed_attributes={:src=>chart_swf}\n embed_attributes=embed_attributes.merge(:FlashVars=>str_flash_vars)\n embed_attributes=embed_attributes.merge(:quality=>\"high\")\n embed_attributes=embed_attributes.merge(:width=>chart_width)\n embed_attributes=embed_attributes.merge(:height=>chart_height).merge(:name=>chart_id)\n embed_attributes=embed_attributes.merge(:allowScriptAccess=>\"always\")\n embed_attributes=embed_attributes.merge(:type=>\"application/x-shockwave-flash\")\n embed_attributes=embed_attributes.merge(:pluginspage=>\"http://www.macromedia.com/go/getflashplayer\")\n \n embed_tag=content_tag(\"embed\",\"\",embed_attributes)\n \n concat(content_tag(\"object\",\"\\n\\t\\t\\t\\t\"+param_tag1+\"\\n\\t\\t\\t\\t\"+param_tag2+\"\\n\\t\\t\\t\\t\"+param_tag3+\"\\n\\t\\t\\t\\t\"+param_tag4+\"\\n\\t\\t\\t\\t\"+embed_tag+\"\\n\\t\\t\",object_attributes),block.binding)\n concat(\"\\n\\t\\t<!-- END Code Block for Chart -->\\n\",block.binding)\n end", "def feedbackchart\n \n end", "def getchart()\n # The value to display on the meter\n value = 75.35\n\n # Create an LinearMeter object of size 250 x 75 pixels, using silver background\n # with a 2 pixel black 3D depressed border.\n m = ChartDirector::LinearMeter.new(250, 75, ChartDirector::silverColor(), 0, -2)\n\n # Set the scale region top-left corner at (15, 25), with size of 200 x 50 pixels.\n # The scale labels are located on the top (implies horizontal meter)\n m.setMeter(15, 25, 220, 20, ChartDirector::Top)\n\n # Set meter scale from 0 - 100, with a tick every 10 units\n m.setScale(0, 100, 10)\n\n # Set 0 - 50 as green (99ff99) zone, 50 - 80 as yellow (ffff66) zone, and 80 - 100\n # as red (ffcccc) zone\n m.addZone(0, 50, 0x99ff99)\n m.addZone(50, 80, 0xffff66)\n m.addZone(80, 100, 0xffcccc)\n\n # Add a blue (0000cc) pointer at the specified value\n m.addPointer(value, 0x0000cc)\n\n # Add a label at bottom-left (10, 68) using Arial Bold/8 pts/red (c00000)\n m.addText(10, 68, \"Temperature C\", \"arialbd.ttf\", 8, 0xc00000,\n ChartDirector::BottomLeft)\n\n # Add a text box to show the value formatted to 2 decimal places at bottom right.\n # Use white text on black background with a 1 pixel depressed 3D border.\n m.addText(238, 70, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomRight).setBackground(0, 0, -1)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def render_data(data)\n # calculate quartiles for plot, use this as data\n @data_quartiles = DATA.collect { |row|\n data = quartiles(row[1])\n OpenStruct.new(\n :name => row[0],\n :q0 => data[0],\n :q1 => data[1],\n :q2 => data[2],\n :q3 => data[3],\n :q4 => data[4],\n :index => 0\n ) \n }\n # NOTE: need index to lay out coloumns horizontally\n @data_quartiles.each_with_index { |d, i|\n d.index = i\n }\n # find limits of data so we know where axes are\n data_min = @data_quartiles.collect { |col| col.q0 }.min()\n data_max = @data_quartiles.collect { |col| col.q4 }.max()\n bounds = bounds([data_min, data_max])\n plot_range = bounds[1] - bounds[0]\n\n \n # make area for plotting\n # left, etc. set padding so actual size is ht/wt + padding\n vis = pv.Panel.new()\n .width(@canvas_wt)\n .height(@canvas_ht)\n .margin(@margin)\n .left(30)\n .bottom(20)\n .top(10)\n .right(10)\n \n # adhoc guess at bar width\n bar_width = @plot_wt / @data_quartiles.size() * 0.8\n \n # scaling to position datapoints in plot\n vert = pv.Scale.linear(bounds[0], bounds[1]).range(0, @plot_ht)\n horiz = pv.Scale.linear(0, @data_quartiles.size()).range(0, @plot_wt)\n\n # where to draw labels on graph\n label_ticks = vert.ticks.each_slice(4).map(&:first)\n\n # make horizontal lines:\n # - what values are drawn\n # - where the bottom of it appears\n # - what color to make the line\n # - the width of the line\n # - antialias it?\n # - add a label\n # - where does label appear relative to line\n # - how is the text aligned in own space\n # - align text vertically (\"top\" looks like \"middle\")\n # - what appears in the label\n vis.add(pv.Rule)\n .data(vert.ticks()) \n .bottom(lambda {|d| vert.scale(d)}) \n .strokeStyle(lambda { |d| label_ticks.member?(d) ? \"black\" : \"lightblue\" })\n .line_width(lambda { |d| label_ticks.member?(d) ? 0.5 : 0.1 })\n .antialias(true)\n .add(pv.Label) \n .left(0) \n .textAlign(\"right\")\n .textBaseline(\"top\")\n .text(lambda {|d| label_ticks.member?(d) ? sprintf(\"%0.2f\", d) : '' }) \n \n # y (vertical) axis\n vis.add(pv.Rule)\n .data([0])\n .left(horiz.scale(0))\n .bottom(@margin)\n .strokeStyle(\"black\")\n \n # make the main body of boxplot\n vis.add(pv.Rule)\n .data(@data_quartiles)\n .left(lambda {|d| horiz.scale(d.index + 0.5) })\n .bottom(lambda {|d| vert.scale(d.q1)})\n .lineWidth(bar_width)\n .height(lambda {|d| vert.scale(d.q3) - vert.scale(d.q1)})\n .strokeStyle(@bar_clr)\n\n # add bottom labels\n vis.add(pv.Label)\n .data(@data_quartiles)\n .left(lambda {|d| horiz.scale(d.index + 0.5) })\n .bottom(0)\n .text_baseline(\"top\")\n .text_margin(15)\n .textAlign(\"center\")\n .text(lambda {|d| d.name })\n\n # make the whisker \n vis.add(pv.Rule)\n .data(@data_quartiles)\n .left(lambda {|d| horiz.scale(d.index + 0.5)})\n .bottom(lambda {|d| vert.scale(d.q0)})\n .lineWidth(1)\n .height(lambda {|d| vert.scale(d.q4) - vert.scale(d.q0)})\n .strokeStyle(@bar_clr)\n\n # make the median line \n vis.add(pv.Rule)\n .data(@data_quartiles)\n .left(lambda {|d| horiz.scale(d.index + 0.5)})\n .bottom(lambda {|d| vert.scale(d.q2)})\n .height(1)\n .lineWidth(bar_width)\n .strokeStyle(\"white\")\n \n vis.render()\n return vis.to_svg()\n end", "def chart\n data = case params[:kind]\n when 'number_of_users'\n @title = 'Number of users '\n User.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_loves'\n @title = 'Number of Loves'\n ActsAsVotable::Vote.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_comments'\n @title = 'Number of comments'\n Comment.unscoped.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'number_of_shares'\n @title = 'Number of shares'\n Share.group('DATE_TRUNC(\\'month\\', created_at)').count\n when 'monthly_active_users'\n @title = 'Monthly active users'\n votes = ActsAsVotable::Vote.group('DATE_TRUNC(\\'month\\', created_at)').count\n comments = Comment.unscoped.group('DATE_TRUNC(\\'month\\', created_at)').count\n shares = Share.group('DATE_TRUNC(\\'month\\', created_at)').count\n votes\n .merge(comments) { |k, a_value, b_value| a_value + b_value }\n .merge(shares) { |k, a_value, b_value| a_value + b_value }\n when 'joined_last_month'\n @title = 'Joined last month'\n User.group('DATE_TRUNC(\\'day\\', created_at)').where(created_at: Date.today.beginning_of_month..Date.today.end_of_month).count\n else #net_promoter_score\n @title = 'Net promoter score'\n PhoneNumberInvitation.uniq.group('DATE_TRUNC(\\'month\\', created_at)').count(:user_id)\n end\n\n # data manipulation\n @data = []\n prev_key, year = nil, Time.current.year\n data.sort.each do |k ,v|\n k = k.to_date\n if params[:kind] == 'joined_last_month'\n (prev_key.next...k).each{|d| @data << [d.strftime('%d'), 0, \"#{d.to_s(:long)} = 0\"] } if prev_key.present?\n @data << [k.strftime('%d'), v, \"#{k.to_s(:long)} = #{v}\"]\n else\n k = k.beginning_of_month\n (prev_key.next..k.yesterday).select{|d| d.day == 1 }.each{|d| @data << [d.strftime(year == d.year ? '%m' : '%y/%-m'), 0, \"#{d.strftime(\"%B, %Y\")} = 0\"] } if prev_key.present?\n @data << [k.strftime(year == k.year ? '%m' : '%y/%-m'), v, \"#{k.strftime(\"%B, %Y\")} = #{v}\"]\n end\n prev_key = k\n end\n\n render partial: 'chart'\n end", "def getchart()\n # The data for the pie chart\n data = [25, 18, 15, 12, 8, 30, 35]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Insurance\", \"Facilities\",\n \"Production\"]\n\n # Create a PieChart object of size 360 x 300 pixels\n c = ChartDirector::PieChart.new(360, 300)\n\n # Set the center of the pie at (180, 140) and the radius to 100 pixels\n c.setPieSize(180, 140, 100)\n\n # Add a title to the pie chart\n c.addTitle(\"Project Cost Breakdown\")\n\n # Draw the pie in 3D\n c.set3D()\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Explode the 1st sector (index = 0)\n c.setExplode(0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def render_chart_data\n data = self.rounds.map do |r|\n { x: map_time_to_num(r.time_of_day), y: MachineRound.find_by(machine_id: self.id, round_id: r.id).data.to_f }\n end\n end", "def show\n @chart = Chart.find(params[:id])\n @chartnodes = @chart.chartnodes\n data = @chart.chartnodes.map {|node| [node.xaxis, node.yaxis]}.transpose\n if @chart.charttype == 'column'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'column',:name=> @chart.name,:data=> data[1])\n end\n elsif @chart.charttype == 'spline'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'spline',:name=> @chart.name,:data=> data[1])\n f.plot_options( :spline => {\n :dataLabels => {\n :enabled => true\n }})\n f.tooltip( :crosshairs => true, :shared => true)\n end\n elsif @chart.charttype == 'pie'\n @h1 = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 200, 60, 170]} )\n series = {\n :type=> 'pie',\n :name=> @chart.name,\n :data=> data.transpose\n }\n f.series(series)\n f.options[:title][:text] = \"Browser share\"\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n #:cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chart }\n end\n end", "def create\n @chart = Chart.new(params[:chart])\n flash[:notice] = 'Chart was successfully created.' if @chart.save\n respond_with(@chart)\n end", "def getchart()\n # The value to display on the meter\n value = 27.48\n\n # Create an AngularMeter object of size 200 x 115 pixels, with silver background\n # color, black border, 2 pixel 3D border border and rounded corners\n m = ChartDirector::AngularMeter.new(200, 115, ChartDirector::silverColor(),\n 0x000000, 2)\n m.setRoundedFrame()\n\n # Set the meter center at (100, 100), with radius 85 pixels, and span from -90 to\n # +90 degress (semi-circle)\n m.setMeter(100, 100, 85, -90, 90)\n\n # Meter scale is 0 - 100, with major tick every 20 units, minor tick every 10\n # units, and micro tick every 5 units\n m.setScale(0, 100, 20, 10, 5)\n\n # Set 0 - 60 as green (66FF66) zone\n m.addZone(0, 60, 0, 85, 0x66ff66)\n\n # Set 60 - 80 as yellow (FFFF33) zone\n m.addZone(60, 80, 0, 85, 0xffff33)\n\n # Set 80 - 100 as red (FF6666) zone\n m.addZone(80, 100, 0, 85, 0xff6666)\n\n # Add a text label centered at (100, 60) with 12 pts Arial Bold font\n m.addText(100, 60, \"PSI\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n\n # Add a text box at the top right corner of the meter showing the value formatted\n # to 2 decimal places, using white text on a black background, and with 1 pixel 3D\n # depressed border\n m.addText(156, 8, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff\n ).setBackground(0x000000, 0, -1)\n\n # Add a semi-transparent blue (40666699) pointer with black border at the\n # specified value\n m.addPointer(value, 0x40666699, 0x000000)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def new\n @chart = Chart.new\n respond_with(@chart)\n end", "def getchart()\n # The data for the pie chart\n data = [72, 18, 15, 12]\n\n # The depths for the sectors\n depths = [30, 20, 10, 10]\n\n # The labels for the pie chart\n labels = [\"Sunny\", \"Cloudy\", \"Rainy\", \"Snowy\"]\n\n # The icons for the sectors\n icons = [\"sun.png\", \"cloud.png\", \"rain.png\", \"snowy.png\"]\n\n # Create a PieChart object of size 400 x 310 pixels, with a blue (CCCCFF) vertical\n # metal gradient background, black border, 1 pixel 3D border effect and rounded\n # corners\n c = ChartDirector::PieChart.new(400, 310, ChartDirector::metalColor(0xccccff, 0),\n 0x000000, 1)\n c.setRoundedFrame()\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the center of the pie at (200, 180) and the radius to 100 pixels\n c.setPieSize(200, 180, 100)\n\n # Add a title box using 15 pts Times Bold Italic font, on a blue (CCCCFF)\n # background with glass effect\n c.addTitle(\"Weather Profile in Wonderland\", \"timesbi.ttf\", 15).setBackground(\n 0xccccff, 0x000000, ChartDirector::glassEffect())\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Add icons to the chart as a custom field\n c.addExtraField(icons)\n\n # Configure the sector labels using CDML to include the icon images\n c.setLabelFormat(\n \"<*block,valign=absmiddle*><*img={field0}*> <*block*>{label}\\n{percent}%\" \\\n \"<*/*><*/*>\")\n\n # Draw the pie in 3D with variable 3D depths\n c.set3D2(depths)\n\n # Set the start angle to 225 degrees may improve layout when the depths of the\n # sector are sorted in descending order, because it ensures the tallest sector is\n # at the back.\n c.setStartAngle(225)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The value to display on the meter\n value = 45.17\n\n # Create an AugularMeter object of size 200 x 200 pixels, with silver background,\n # black border, 2 pixel 3D depressed border and rounded corners.\n m = ChartDirector::AngularMeter.new(200, 200, ChartDirector::silverColor(),\n 0x000000, -2)\n m.setRoundedFrame()\n\n # Set the meter center at (100, 100), with radius 85 pixels, and span from -135 to\n # +135 degress\n m.setMeter(100, 100, 85, -135, 135)\n\n # Meter scale is 0 - 100, with major tick every 10 units, minor tick every 5\n # units, and micro tick every 1 units\n m.setScale(0, 100, 10, 5, 1)\n\n # Disable default angular arc by setting its width to 0. Set 2 pixels line width\n # for major tick, and 1 pixel line width for minor ticks.\n m.setLineWidth(0, 2, 1)\n\n # Set the circular meter surface as metallic blue (9999DD)\n m.addRing(0, 90, ChartDirector::metalColor(0x9999dd))\n\n # Add a blue (6666FF) ring between radii 88 - 90 as decoration\n m.addRing(88, 90, 0x6666ff)\n\n # Set 0 - 60 as green (99FF99) zone, 60 - 80 as yellow (FFFF00) zone, and 80 - 100\n # as red (FF3333) zone\n m.addZone(0, 60, 0x99ff99)\n m.addZone(60, 80, 0xffff00)\n m.addZone(80, 100, 0xff3333)\n\n # Add a text label centered at (100, 135) with 15 pts Arial Bold font\n m.addText(100, 135, \"CPU\", \"arialbd.ttf\", 15, ChartDirector::TextColor,\n ChartDirector::Center)\n\n # Add a text box centered at (100, 165) showing the value formatted to 2 decimal\n # places, using white text on a black background, and with 1 pixel 3D depressed\n # border\n m.addText(100, 165, m.formatValue(value, \"2\"), \"Arial\", 8, 0xffffff,\n ChartDirector::Center).setBackground(0x000000, 0x000000, -1)\n\n # Add a semi-transparent blue (40333399) pointer at the specified value\n m.addPointer(value, 0x40333399)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def render(data)\n\n\t\t@minX = data.map { |(x,y,str)| x }.min\n\t\t@maxX = data.map { |(x,y,str)| x }.max\n\n\t\t@minY = data.map { |(x,y,str)| y }.min\n\t\t@maxY = data.map { |(x,y,str)| y }.max\n\n\t\t%(<svg viewBox=\"0 0 #{width} #{height}\" xmlns=\"http://www.w3.org/2000/svg\">) +\n\t\taxes +\n\t\tdata.map do |(x,y,str)|\n\t\t\tcircleAndLabel(x, y, str)\n\t\tend.join +\n\t\t%(</svg>)\n\n\tend", "def getchart()\n # The data for the pie chart\n data = [21, 18, 15, 12, 8, 24]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Facilities\", \"Production\"]\n\n # The colors to use for the sectors\n colors = [0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222, 0x009900]\n\n # Create a PieChart object of size 600 x 360 pixels.\n c = ChartDirector::PieChart.new(600, 360)\n\n # Use the white on black palette, which means the default text and line colors are\n # white\n c.setColors(ChartDirector::whiteOnBlackPalette)\n\n # Use a vertical gradient color from deep blue (000066) to blue (0000cc) as\n # background. Use rounded corners of 20 pixels radius. Enable soft drop shadow.\n c.setBackground(c.linearGradientColor(0, 0, 0, c.getHeight(), 0x000066, 0x0000cc))\n c.setRoundedFrame(0xffffff, 20)\n c.setDropShadow()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. Add 16 pixels top\n # margin to the title.\n c.addTitle(\"Exploded Pie Chart Demonstration\", \"timesbi.ttf\", 18).setMargin2(0, 0,\n 16, 0)\n\n # Set the center of the pie at (300, 195) and the radius to 110 pixels\n c.setPieSize(300, 195, 110)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the sector colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Use local gradient shading for the sectors, with 5 pixels wide semi-transparent\n # white (bbffffff) borders\n c.setSectorStyle(ChartDirector::LocalGradientShading, 0xbbffffff, 5)\n\n # Use the side label layout method\n c.setLabelLayout(ChartDirector::SideLayout)\n\n # Use 10pt Arial Bold as the default label font. Set the label box background\n # color the same as the sector color. Use soft lighting effect with light\n # direction from right. Use 8 pixels rounded corners.\n t = c.setLabelStyle(\"arialbd.ttf\", 10, 0x000000)\n t.setBackground(ChartDirector::SameAsMainColor, ChartDirector::Transparent,\n ChartDirector::softLighting(ChartDirector::Right, 0))\n t.setRoundedCorners(8)\n\n # Set the sector label format. The label is centered in a 110 pixels wide bounding\n # box. It consists of two lines. The first line is the sector name. The second\n # line shows the data value and percentage.\n c.setLabelFormat(\n \"<*block,halign=center,width=110*>{label}\\n<*font=arial.ttf,size=8*>US$ \" \\\n \"{value}M ({percent}%)<*/*>\")\n\n # Explode all sectors 10 pixels from the center\n c.setExplode(-1, 10)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def data\n chart =OpenFlashChart.new\n\n data = get_data\n\n get_converter.convert(chart, data)\n \n if show_y_axis\n y = YAxis.new\n y.set_range(0,(data[:max]*1.2).round,(data[:max]/get_y_axis_labels).round) if data[:max]\n chart.y_axis = y\n end\n\n if show_x_axis\n x = XAxis.new\n x.set_range(0,data[:count] > 1 ? data[:count] - 1 : 1,1) if data[:count]\n if data[:labels]\n labels = []\n if get_x_axis_labels > 0\n step = (data[:labels].size/get_y_axis_labels).to_i\n step = 1 if step == 0\n else\n step = 1\n end\n data[:labels].each_with_index do |l,i|\n if i % step == 0\n labels << l\n else\n labels << \"\"\n end\n end\n x.set_labels(labels)\n end\n chart.x_axis = x\n else\n x = XAxis.new\n x.set_labels([\"\"])\n chart.x_axis = x\n end\n\n unless get_x_legend.nil?\n legend = XLegend.new(get_x_legend)\n legend.set_style('{font-size: 12px}')\n chart.set_x_legend(legend)\n end\n\n unless get_x_legend.nil?\n legend = YLegend.new(get_y_legend)\n legend.set_style('{font-size: 12px}')\n chart.set_y_legend(legend)\n end\n\n chart.set_bg_colour('#ffffff');\n\n chart.to_s\n end", "def render\n Vedeu.renderers.render(output) if Vedeu.ready?\n end", "def index\n @student = Student.where(:usuario_id => @session_student.id).first\n @team = Team.where(:id => @student.team_id).first\n \n @sprints = Sprint.joins(:stories).where(:stories => {:project_id => @team.project_id})\n \n graphs = Array.new(@sprints.length)\n @charts = Array.new(@sprints.length)\n j=0\n @sprints.each do |s|\n date1 = s.fechainicio\n date2 = s.fechafin\n @as = (date1..date2).to_a\n @stories = Story.joins(:sprints).where(:sprints => {:id => s.id})\n task=0\n @stories.each do |st|\n @tasks = Task.where(:story_id => st.id)\n @tasks.each do |t|\n task += t.estimadoinicial\n end\n end\n graphs[j] = GoogleVisualr::DataTable.new\n graphs[j].new_column('string', 'Tiempo')\n graphs[j].new_column('number', 'Estimado inicial')\n graphs[j].new_column('number', 'Trabajo remanente')\n graphs[j].add_rows(@as.length)\n \n i=0\n work=0\n workt=0\n diff=0\n tot = task / Float(@as.length-1) \n last=@as.last\n @as.each do |a|\n @stories.each do |st|\n @tasks = Task.where(:story_id => st.id)\n @tasks.each do |t|\n @works = Workdetail.where(\"task_id = ? AND fecha = ?\", t.id, a)\n @works.each do |w|\n work += w.hrsporterminar\n workt += w.hrstrabajadas\n end\n end\n end\n\n diff = work - workt\n graphs[j].set_cell(i, 0, a.to_s)\n if i == 0 \n graphs[j].set_cell(i, 1, task)\n suma = task + diff\n graphs[j].set_cell(i, 2, suma)\n elsif a == last \n graphs[j].set_cell(i, 1, 0)\n graphs[j].set_cell(i, 2, 0)\n else \n graphs[j].set_cell(i, 1, task-=tot)\n suma = task + diff\n graphs[j].set_cell(i, 2, suma) \n end\n i+=1\n work=0\n workt=0\n end\n opts = { :width => 600, :height => 400, :title => 'Burndown chart - ' + s.comentario, :colors => ['#3366cc', '#dc3912'], :legend => 'right',:backgroundColor => '#f5f5f5', :vAxis => {:title => \"Esfuerzo\"}, :hAxis => {:title => \"Tiempo\" } }\n @charts[j] = GoogleVisualr::Interactive::LineChart.new(graphs[j], opts)\n j+=1\n end\n \n \n\n \n\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @charts }\n end\n end", "def summary_chart\n timespan = params[:timespan].nil? ? 7 : params[:timespan].to_i\n\n summary_chart=OpenFlashChart.new(\"Absenteeism Rates (Last #{timespan} days)\")\n summary_chart.bg_colour = \"#FFFFFF\"\n\n lines=current_user.school_districts.map do |d|\n line=LineHollow.new\n line.text = d.name\n line.values = recent_data(d, timespan)\n line\n end\n max=current_user.school_districts.map{|d| d.recent_absentee_rates(timespan).max{|a,b| a=0 if a.nil?; b=0 if b.nil?; a <=> b} }.max\n xa= XAxis.new\n xa.labels=XAxisLabels.new(:labels => generate_time_labels(timespan), :rotate => 315, :visible_steps => 7, :size => 18)\n xa.steps = 7\n summary_chart.set_x_axis xa\n\n summary_chart.y_axis = YAxis.new(\n :steps => 2,\n :min => 0,\n :max => max\n )\n\n lines.each do |l|\n summary_chart.add_element(l)\n end\n render :text => summary_chart.to_s, :layout => false\n end", "def spark\n @investigation = Investigation.find(params[:id])\n @data = []\n @data << resource.activities.seven_days_ago.count\n @data << resource.activities.six_days_ago.count\n @data << resource.activities.five_days_ago.count\n @data << resource.activities.four_days_ago.count\n @data << resource.activities.three_days_ago.count\n @data << resource.activities.two_days_ago.count\n @data << resource.activities.one_day_ago.count\n #@data << Activity.today.count(:conditions=>['investigation_id = ?', id])\n \n #render :partial=>'spark', :locals=>{:data => @data}\n \n session[:return_to] = '/investigations/' +@investigation.to_param.to_s\n \n #debugger\n send_data(Sparklines.plot(\n @data,\n :type => 'smooth',\n :height=>20,\n :line_color=>'lightgrey',\n :underneath_color => 'lightgrey',\n :min => 0,\n :dot_values => true,\n :step => 10 \n \n ), \n :disposition => 'inline', \n :type => 'image/png', \n :filename => Date.today.to_s + \"-investigation-\" + @investigation.object_id.to_s + \"-sparkline.png\")\n \n \n \n end", "def show\n @verification_state = @project.verification_state\n\n unless @project.transactions.empty?\n charts_to_date = @project.transactions.order('date').last.date\n charts_from_date = (charts_to_date - 90.days).beginning_of_month\n chart_params = 'from_date=' + date_value(charts_from_date) +\n '&to_date=' + date_value(charts_to_date) +\n '&show_total=true';\n end\n chart_account_ids = @project.accounts.map{ |a| \"account_ids[]=#{a.id}\" }.join('&')\n\n @balance_chart_url = \"#{project_path(@project)}/reports/balance_data/?#{chart_params}\"\n @spend_chart_url = \"#{project_path(@project)}/reports/spend_data/?#{chart_params}&#{chart_account_ids}\"\n @income_outgoings_chart_url = \"#{project_path(@project)}/reports/income_outgoings_data/?#{chart_params}&#{chart_account_ids}\"\n end", "def render(options = {}, &block)\n\t\t\t\t@options[:global] = options\n\n\t\t\t\t# Hash\n\t\t\t\thash = 1\n\n\t\t\t\t# Parse axes\n\t\t\t\t@options[:global][:x_axis] = parse_axis(@options[:global][:x_axis])\n\t\t\t\t@options[:global][:y_axis] = parse_axis(@options[:global][:y_axis])\n\n\t\t\t\t# Call nested block to capture parts and its options\n\t\t\t\tunused = @template.capture(self, &block).to_s\n\n\t\t\t\t# Render parts\n\t\t\t\tresult = \"\"\n\t\t\t\tresult += %{\n\t\t\t\t\t<table id=\"statistics-#{hash}\" class=\"table statistics\">\n\t\t\t\t\t\t#{render_parts}\n\t\t\t\t\t</table>\n\t\t\t\t}\n\t\t\t\treturn result.html_safe\n\t\t\tend", "def getchart()\n # The value to display on the meter\n value = 4.75\n\n # Create an AugularMeter object of size 110 x 110 pixels, using silver background\n # color with a black 2 pixel 3D depressed border.\n m = ChartDirector::AngularMeter.new(110, 110, ChartDirector::silverColor(),\n 0x000000, -2)\n\n # Set meter appearance according to a parameter\n if params[\"img\"] == \"0\"\n # Set the meter center at bottom left corner (15, 95), with radius 85 pixels.\n # Meter spans from 90 - 0 degrees.\n m.setMeter(15, 95, 85, 90, 0)\n # Add a label to the meter centered at (35, 75)\n m.addText(35, 75, \"VDC\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at top right corner (103, 7)\n m.addText(103, 7, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::TopRight).setBackground(0, 0, -1)\n elsif params[\"img\"] == \"1\"\n # Set the meter center at top left corner (15, 15), with radius 85 pixels.\n # Meter spans from 90 - 180 degrees.\n m.setMeter(15, 15, 85, 90, 180)\n # Add a label to the meter centered at (35, 35)\n m.addText(35, 35, \"AMP\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at bottom right corner (103, 103)\n m.addText(103, 103, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomRight).setBackground(0, 0, -1)\n elsif params[\"img\"] == \"2\"\n # Set the meter center at top right corner (15, 95), with radius 85 pixels.\n # Meter spans from 270 - 180 degrees.\n m.setMeter(95, 15, 85, 270, 180)\n # Add a label to the meter centered at (75, 35)\n m.addText(75, 35, \"KW\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at bottom left corner (7, 103)\n m.addText(7, 103, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::BottomLeft).setBackground(0, 0, -1)\n else\n # Set the meter center at bottom right corner (95, 95), with radius 85 pixels.\n # Meter spans from 270 - 360 degrees.\n m.setMeter(95, 95, 85, 270, 360)\n # Add a label to the meter centered at (75, 75)\n m.addText(75, 75, \"RPM\", \"arialbd.ttf\", 12, ChartDirector::TextColor,\n ChartDirector::Center)\n # Add a text box to show the value at top left corner (7, 7)\n m.addText(7, 7, m.formatValue(value, \"2\"), \"arial.ttf\", 8, 0xffffff,\n ChartDirector::TopLeft).setBackground(0, 0, -1)\n end\n\n # Meter scale is 0 - 10, with a major tick every 2 units, and minor tick every 1\n # unit\n m.setScale(0, 10, 2, 1)\n\n # Set 0 - 6 as green (99ff99) zone, 6 - 8 as yellow (ffff00) zone, and 8 - 10 as\n # red (ff3333) zone\n m.addZone(0, 6, 0x99ff99, 0x808080)\n m.addZone(6, 8, 0xffff00, 0x808080)\n m.addZone(8, 10, 0xff3333, 0x808080)\n\n # Add a semi-transparent black (80000000) pointer at the specified value\n m.addPointer(value, 0x80000000)\n\n # Output the chart\n send_data(m.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The (x, y, z) coordinates of the scattered data\n dataX = [0.5, 1.9, 4.9, 1.0, 8.9, 9.8, 5.9, 2.9, 6.8, 9.0, 0.0, 8.9, 1.9, 4.8,\n 2.4, 3.4, 7.9, 7.5, 4.8, 7.5, 9.5, 0.4, 8.9, 0.9, 5.4, 9.4, 2.9, 8.9, 0.9,\n 8.9, 10.0, 1.0, 6.8, 3.8, 9.0, 5.3, 6.4, 4.9, 4.5, 2.0, 5.4, 0.0, 10.0, 3.9,\n 5.4, 5.9, 5.8, 0.3, 4.4, 8.3]\n dataY = [3.3, 3.0, 0.7, 1.0, 9.3, 4.5, 8.4, 0.1, 0.8, 0.1, 9.3, 1.8, 4.3, 1.3,\n 2.3, 5.4, 6.9, 9.0, 9.8, 7.5, 1.8, 1.4, 4.5, 7.8, 3.8, 4.0, 2.9, 2.4, 3.9,\n 2.9, 2.3, 9.3, 2.0, 3.4, 4.8, 2.3, 3.4, 2.3, 1.5, 7.8, 4.5, 0.9, 6.3, 2.4,\n 6.9, 2.8, 1.3, 2.9, 6.4, 6.3]\n dataZ = [6.6, 12.5, 7.4, 6.2, 9.6, 13.6, 19.9, 2.2, 6.9, 3.4, 8.7, 8.4, 7.8, 8.0,\n 9.4, 11.9, 9.6, 15.7, 12.0, 13.3, 9.6, 6.4, 9.0, 6.9, 4.6, 9.7, 10.6, 9.2,\n 7.0, 6.9, 9.7, 8.6, 8.0, 13.6, 13.2, 5.9, 9.0, 3.2, 8.3, 9.7, 8.2, 6.1, 8.7,\n 5.6, 14.9, 9.8, 9.3, 5.1, 10.8, 9.8]\n\n # Create a XYChart object of size 450 x 540 pixels\n c = ChartDirector::XYChart.new(450, 540)\n\n # Add a title to the chart using 15 points Arial Italic font\n c.addTitle(\" Contour Chart with Scattered Data\", \"ariali.ttf\", 15)\n\n # Set the plotarea at (65, 40) and of size 360 x 360 pixels. Use semi-transparent\n # black (c0000000) for both horizontal and vertical grid lines\n c.setPlotArea(65, 40, 360, 360, -1, -1, -1, 0xc0000000, -1)\n\n # Set x-axis and y-axis title using 12 points Arial Bold Italic font\n c.xAxis().setTitle(\"X-Axis Title Place Holder\", \"arialbi.ttf\", 10)\n c.yAxis().setTitle(\"Y-Axis Title Place Holder\", \"arialbi.ttf\", 10)\n\n # Set x-axis and y-axis labels to use Arial Bold font\n c.xAxis().setLabelStyle(\"arialbd.ttf\")\n c.yAxis().setLabelStyle(\"arialbd.ttf\")\n\n # When x-axis and y-axis color to transparent\n c.xAxis().setColors(ChartDirector::Transparent)\n c.yAxis().setColors(ChartDirector::Transparent)\n\n # Add a scatter layer to the chart to show the position of the data points\n c.addScatterLayer(dataX, dataY, \"\", ChartDirector::Cross2Shape(0.2), 7, 0x000000)\n\n # Add a contour layer using the given data\n layer = c.addContourLayer(dataX, dataY, dataZ)\n\n # Move the grid lines in front of the contour layer\n c.getPlotArea().moveGridBefore(layer)\n\n # Add a color axis (the legend) in which the top center is anchored at (245, 455).\n # Set the length to 330 pixels and the labels on the top side.\n cAxis = layer.setColorAxis(245, 455, ChartDirector::TopCenter, 330,\n ChartDirector::Top)\n\n # Add a bounding box to the color axis using the default line color as border.\n cAxis.setBoundingBox(ChartDirector::Transparent, ChartDirector::LineColor)\n\n # Add a title to the color axis using 12 points Arial Bold Italic font\n cAxis.setTitle(\"Color Legend Title Place Holder\", \"arialbi.ttf\", 10)\n\n # Set color axis labels to use Arial Bold font\n cAxis.setLabelStyle(\"arialbd.ttf\")\n\n # Set the color axis range as 0 to 20, with a step every 2 units\n cAxis.setLinearScale(0, 20, 2)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def getchart()\n # The (x, y, z) coordinates of the scattered data\n dataX = [0.5, 1.9, 4.9, 1.0, 8.9, 9.8, 5.9, 2.9, 6.8, 9.0, 0.0, 8.9, 1.9, 4.8,\n 2.4, 3.4, 7.9, 7.5, 4.8, 7.5, 9.5, 0.4, 8.9, 0.9, 5.4, 9.4, 2.9, 8.9, 0.9,\n 8.9, 10.0, 1.0, 6.8, 3.8, 9.0, 5.3, 6.4, 4.9, 4.5, 2.0, 5.4, 0.0, 10.0, 3.9,\n 5.4, 5.9, 5.8, 0.3, 4.4, 8.3]\n dataY = [3.3, 3.0, 0.7, 1.0, 9.3, 4.5, 8.4, 0.1, 0.8, 0.1, 9.3, 1.8, 4.3, 1.3,\n 2.3, 5.4, 6.9, 9.0, 9.8, 7.5, 1.8, 1.4, 4.5, 7.8, 3.8, 4.0, 2.9, 2.4, 3.9,\n 2.9, 2.3, 9.3, 2.0, 3.4, 4.8, 2.3, 3.4, 2.3, 1.5, 7.8, 4.5, 0.9, 6.3, 2.4,\n 6.9, 2.8, 1.3, 2.9, 6.4, 6.3]\n dataZ = [6.6, 12.5, 7.4, 6.2, 9.6, 13.6, 19.9, 2.2, 6.9, 3.4, 8.7, 8.4, 7.8, 8.0,\n 9.4, 11.9, 9.6, 15.7, 12.0, 13.3, 9.6, 6.4, 9.0, 6.9, 4.6, 9.7, 10.6, 9.2,\n 7.0, 6.9, 9.7, 8.6, 8.0, 13.6, 13.2, 5.9, 9.0, 3.2, 8.3, 9.7, 8.2, 6.1, 8.7,\n 5.6, 14.9, 9.8, 9.3, 5.1, 10.8, 9.8]\n\n # Create a SurfaceChart object of size 680 x 550 pixels. Set background to brushed\n # silver and border to grey (888888). Set the top-left and bottom-right corners to\n # rounded corners with 20 pixels radius.\n c = ChartDirector::SurfaceChart.new(680, 550, ChartDirector::brushedSilverColor(),\n 0x888888)\n c.setRoundedFrame(0xffffff, 20, 0, 20, 0)\n\n # Add a title to the chart using 20 points Times New Roman Italic font. Set\n # top/bottom margin to 8 pixels.\n title = c.addTitle(\"Surface Created Using Scattered Data Points\", \"timesi.ttf\", 20\n )\n title.setMargin2(0, 0, 8, 8)\n\n # Add a 2 pixel wide black (000000) separator line under the title\n c.addLine(10, title.getHeight(), c.getWidth() - 10, title.getHeight(), 0x000000, 2\n )\n\n # Set the center of the plot region at (290, 235), and set width x depth x height\n # to 360 x 360 x 180 pixels\n c.setPlotRegion(290, 235, 360, 360, 180)\n\n # Set the elevation and rotation angles to 45 and -45 degrees\n c.setViewAngle(45, -45)\n\n # Set the perspective level to 30\n c.setPerspective(30)\n\n # Set the data to use to plot the chart\n c.setData(dataX, dataY, dataZ)\n\n # Add a color axis (the legend) in which the top right corner is anchored at (660,\n # 80). Set the length to 200 pixels and the labels on the right side.\n cAxis = c.setColorAxis(660, 80, ChartDirector::TopRight, 200, ChartDirector::Right\n )\n\n # Set the color axis title with 12 points Arial Bold font\n cAxis.setTitle(\"Z Title Placeholder\", \"arialbd.ttf\", 12)\n\n # Add a bounding box with light grey (eeeeee) background and grey (888888) border.\n # Set the top-left and bottom-right corners to rounded corners of 10 pixels\n # radius.\n cAxis.setBoundingBox(0xeeeeee, 0x888888)\n cAxis.setRoundedCorners(10, 0, 10, 0)\n\n # Set surface grid lines to semi-transparent black (cc000000)\n c.setSurfaceAxisGrid(0xcc000000)\n\n # Set contour lines to semi-transparent white (80ffffff)\n c.setContourColor(0x80ffffff)\n\n # Set the walls to black in color\n c.setWallColor(0x000000)\n\n # Set the xyz major wall grid lines to white (ffffff), and minor wall grid lines\n # to grey (888888)\n c.setWallGrid(0xffffff, 0xffffff, 0xffffff, 0x888888, 0x888888, 0x888888)\n\n # Set the wall thickness to 0\n c.setWallThickness(0, 0, 0)\n\n # Show only the xy wall, and hide the yz and zx walls.\n c.setWallVisibility(true, false, false)\n\n # Set the x, y and z axis titles using 12 points Arial Bold font\n c.xAxis().setTitle(\"X Title\\nPlaceholder\", \"arialbd.ttf\", 12)\n c.yAxis().setTitle(\"Y Title\\nPlaceholder\", \"arialbd.ttf\", 12)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::JPG), :type => \"image/jpeg\",\n :disposition => \"inline\")\n end", "def render_donut_chart(dataset)\n ChartRenderer::Donut.render(dataset)\n end", "def getchart()\n # The data for the pie chart\n data = [21, 18, 15, 12, 8, 24]\n\n # The labels for the pie chart\n labels = [\"Labor\", \"Licenses\", \"Taxes\", \"Legal\", \"Facilities\", \"Production\"]\n\n # The colors to use for the sectors\n colors = [0x66aaee, 0xeebb22, 0xbbbbbb, 0x8844ff, 0xdd2222, 0x009900]\n\n # Create a PieChart object of size 600 x 320 pixels. Use a vertical gradient color\n # from light blue (99ccff) to white (ffffff) spanning the top 100 pixels as\n # background. Set border to grey (888888). Use rounded corners. Enable soft drop\n # shadow.\n c = ChartDirector::PieChart.new(600, 320)\n c.setBackground(c.linearGradientColor(0, 0, 0, 100, 0x99ccff, 0xffffff), 0x888888)\n c.setRoundedFrame()\n c.setDropShadow()\n\n # Add a title using 18 pts Times New Roman Bold Italic font. Add 16 pixels top\n # margin to the title.\n c.addTitle(\"Pie Chart With Legend Demonstration\", \"timesbi.ttf\", 18).setMargin2(0,\n 0, 16, 0)\n\n # Set the center of the pie at (160, 165) and the radius to 110 pixels\n c.setPieSize(160, 165, 110)\n\n # Draw the pie in 3D with a pie thickness of 25 pixels\n c.set3D(25)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the sector colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Use local gradient shading for the sectors\n c.setSectorStyle(ChartDirector::LocalGradientShading)\n\n # Use the side label layout method, with the labels positioned 16 pixels from the\n # pie bounding box\n c.setLabelLayout(ChartDirector::SideLayout, 16)\n\n # Show only the sector number as the sector label\n c.setLabelFormat(\"{={sector}+1}\")\n\n # Set the sector label style to Arial Bold 10pt, with a dark grey (444444) border\n c.setLabelStyle(\"arialbd.ttf\", 10).setBackground(ChartDirector::Transparent,\n 0x444444)\n\n # Add a legend box, with the center of the left side anchored at (330, 175), and\n # using 10 pts Arial Bold Italic font\n b = c.addLegend(330, 175, true, \"arialbi.ttf\", 10)\n b.setAlignment(ChartDirector::Left)\n\n # Set the legend box border to dark grey (444444), and with rounded conerns\n b.setBackground(ChartDirector::Transparent, 0x444444)\n b.setRoundedCorners()\n\n # Set the legend box margin to 16 pixels, and the extra line spacing between the\n # legend entries as 5 pixels\n b.setMargin(16)\n b.setKeySpacing(0, 5)\n\n # Set the legend box icon to have no border (border color same as fill color)\n b.setKeyBorder(ChartDirector::SameAsMainColor)\n\n # Set the legend text to show the sector number, followed by a 120 pixels wide\n # block showing the sector label, and a 40 pixels wide block showing the\n # percentage\n b.setText(\n \"<*block,valign=top*>{={sector}+1}.<*advanceTo=22*><*block,width=120*>\" \\\n \"{label}<*/*><*block,width=40,halign=right*>{percent}<*/*>%\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def sample\n chart = Chart.new(title: 'Title', type: :bar)\n draw = chart.draw(color: :green, label: 'Label 1')\n draw.data(position: 'Week 1', value: 20).data(position: 'Week 2', value: 5).data(position: 'Week 3', value: 35)\n draw.store\n draw = chart.draw(color: :red, label: 'Label 2', type: :line, fill: true)\n draw.data(position: 'Week 0', value: 15).data(position: 'Week 2', value: 30)\n draw.store\n chart.render\n end", "def show\n @mpg_chart = open_flash_chart_object(630, 400, mpg_chart_path(@current_user, @vehicle), true, AppConfig.open_flash_chart_base)\n @cpg_chart = open_flash_chart_object(630, 400, cpg_chart_path(@current_user, @vehicle), true, AppConfig.open_flash_chart_base)\n @cpm_chart = open_flash_chart_object(630, 400, cpm_chart_path(@current_user, @vehicle), true, AppConfig.open_flash_chart_base)\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @vehicle }\n end\n end", "def render_chart_html(chart_swf,str_url,str_xml,chart_id,chart_width,chart_height,debug_mode,&block)\n chart_width=chart_width.to_s\n chart_height=chart_height.to_s\n debug_mode_num=\"0\"\n if debug_mode==true\n debug_mode_num=\"1\"\n end\n str_flash_vars=\"\"\n if str_xml==\"\"\n str_flash_vars=\"chartWidth=\"+chart_width+\"&chartHeight=\"+chart_height+\"&debugmode=\"+debug_mode_num+\"&dataURL=\"+str_url\n logger.info(\"The method used is setDataURL.The URL is \" + str_url)\n else\n str_flash_vars=\"chartWidth=\"+chart_width+\"&chartHeight=\"+chart_height+\"&debugmode=\"+debug_mode_num+\"&dataXML=\"+str_xml\n logger.info(\"The method used is setDataXML.The XML is \" + str_xml)\n end\n object_attributes={:classid=>\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\"}\n object_attributes=object_attributes.merge(:codebase=>\"http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\")\n object_attributes=object_attributes.merge(:width=>chart_width)\n object_attributes=object_attributes.merge(:height=>chart_height)\n object_attributes=object_attributes.merge(:id=>chart_id)\n param_attributes1={:name=>\"allowscriptaccess\",:value=>\"always\"}\n param_tag1=content_tag(\"param\",\"\",param_attributes1)\n param_attributes2={:name=>\"movie\",:value=>chart_swf}\n param_tag2=content_tag(\"param\",\"\",param_attributes2)\n param_attributes3={:name=>\"FlashVars\",:value=>str_flash_vars}\n param_tag3=content_tag(\"param\",\"\",param_attributes3)\n param_attributes4={:name=>\"quality\",:value=>\"high\"}\n param_tag4=content_tag(\"param\",\"\",param_attributes4)\n param_attributes5={:name=>\"wmode\",:value=>\"transparent\"}\n param_tag5=content_tag(\"param\",\"\",param_attributes5)\n embed_attributes={:src=>chart_swf}\n embed_attributes=embed_attributes.merge(:FlashVars=>str_flash_vars)\n embed_attributes=embed_attributes.merge(:quality=>\"high\")\n embed_attributes=embed_attributes.merge(:width=>chart_width)\n embed_attributes=embed_attributes.merge(:wmode=>'transparent')\n embed_attributes=embed_attributes.merge(:height=>chart_height).merge(:name=>chart_id)\n embed_attributes=embed_attributes.merge(:allowScriptAccess=>\"always\")\n embed_attributes=embed_attributes.merge(:type=>\"application/x-shockwave-flash\")\n embed_attributes=embed_attributes.merge(:pluginspage=>\"http://www.macromedia.com/go/getflashplayer\")\n embed_tag=content_tag(\"embed\",\"\",embed_attributes)\n concat(content_tag(\"object\",\"\\n\\t\\t\\t\\t\"+param_tag1+\"\\n\\t\\t\\t\\t\"+param_tag2+\"\\n\\t\\t\\t\\t\"+param_tag3+\"\\n\\t\\t\\t\\t\"+param_tag4+\"\\n\\t\\t\\t\\t\"+param_tag5+\"\\n\\t\\t\\t\\t\"+embed_tag+\"\\n\\t\\t\",object_attributes),block.binding)\n end", "def show\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chart }\n end\n end", "def show\n @chart = Chart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @chart }\n end\n end", "def index\n @projects = Project.all\n @statuses = Status.all\n i = 0\n j=0\n cont=0\n graphs = Array.new(@projects.length)\n @charts = Array.new(@projects.length) \n @projects.each do |p|\n graphs[j] = GoogleVisualr::DataTable.new\n graphs[j].new_column('string', 'Estatus') \n graphs[j].new_column('number', 'Hours per Day')\n graphs[j].add_rows(4)\n graphs[j].set_cell(0, 0, 'No Iniciado' )\n graphs[j].set_cell(1, 0, 'Aceptado' )\n graphs[j].set_cell(2, 0, 'No Aceptado' )\n graphs[j].set_cell(3, 0, 'Listo' )\n @statuses.each do |st|\n s = Story.where(\"status_id = ? AND project_id = ?\", st.id, p.id)\n graphs[j].set_cell(i, 1, s.length )\n cont+=s.length\n i+=1\n end\n opts = { :width => 600, :height => 400, :title => p.nombre + ' - Total Features: '+ cont.to_s, :colors => ['#dc3912', '#109618', '#ff9900', '#3366cc'], :is3D => true, :backgroundColor => '#f5f5f5' }\n @charts[j] = GoogleVisualr::Interactive::PieChart.new(graphs[j], opts)\n i = 0\n cont = 0\n j+=1\n end\n \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @charts }\n end\n end", "def show\n \n @end_at = Date.today\n @start_at = @end_at - 6\n @categories = @start_at.upto(@end_at).to_a\n\n \t#Sales Historyグラフ\n @sales_data = [500, 600, 300, 100, 200, 400, 700,500, 600, 300, 100, 200, 400, 700,100, 200, 400, 700,500, 600, 600, 300, 100, 200,]\n @sales_history = LazyHighCharts::HighChart.new(\"graph\") do |f|\n f.title(:text => \"Sales History\", :align =>\"left\")\n f.chart(:type => \"column\")\n f.xAxis(:categories => @categories)\n f.series(:name => \"Sales\", :data => @sales_data)\n\t end\n\n#Order Historyのグラフ\n @order_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @order_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @order_data)\n end\n\n#Price Historyのグラフ\n @price_data = [80, 60, 30, 10, 40, 50, 90,60, 30, 10, 40, 50, 90,50, 90,60, 30, 10, 40, 50,]\n @price_history = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(text: 'Order History',:align =>\"left\")\n f.xAxis(:categories => @categories)\n f.series(name: 'Order', :data => @price_data)\n end\n \n \n end", "def render\n generate_content\n @pdf.render\n end", "def render(renderer)\n output = Renderer.const_get(renderer).new(@grid.width, @grid.height, @options)\n\n for e in @figures\n output.render(e) \n end\n output.render_finish\n end", "def getchart()\n # The data for the pie chart\n data = [18, 45, 28]\n\n # The labels for the pie chart\n labels = [\"Marble\", \"Wood\", \"Granite\"]\n\n # The icons for the sectors\n texture = [\"marble3.png\", \"wood.png\", \"rock.png\"]\n\n # Create a PieChart object of size 400 x 330 pixels, with a metallic green\n # (88EE88) background, black border and 1 pixel 3D border effect\n c = ChartDirector::PieChart.new(400, 330, ChartDirector::metalColor(0x88ee88),\n 0x000000, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set donut center at (200, 160), and outer/inner radii as 120/60 pixels\n c.setDonutSize(200, 160, 120, 60)\n\n # Add a title box using 15 pts Times Bold Italic font and metallic deep green\n # (008000) background color\n c.addTitle(\"Material Composition\", \"timesbi.ttf\", 15).setBackground(\n ChartDirector::metalColor(0x008000))\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the colors of the sectors to the 3 texture patterns\n c.setColor(ChartDirector::DataColor + 0, c.patternColor2(texture[0]))\n c.setColor(ChartDirector::DataColor + 1, c.patternColor2(texture[1]))\n c.setColor(ChartDirector::DataColor + 2, c.patternColor2(texture[2]))\n\n # Draw the pie in 3D with a 3D depth of 30 pixels\n c.set3D(30)\n\n # Use 12 pts Arial Bold Italic as the sector label font\n c.setLabelStyle(\"arialbi.ttf\", 12)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def render_charts?\n @render_charts\n end", "def render\n render_background\n\n render_heat_maps\n\n render_star\n render_target\n render_hills\n render_walls\n\n render_paths\n end", "def new\n @chart = Chart.new\n\n respond_to do |format|\n # format.html # new.html.erb\n format.html # new.html.haml\n format.json { render json: @chart }\n end\n end", "def to_ly\n template_dir = File.join(File.dirname(__FILE__), '../../templates/')\n template_path = File.join(template_dir, 'chartup.ly.erb')\n template = File.read(template_path)\n renderer = ERB.new(template)\n rendered = renderer.result(binding)\n end", "def index\n respond_to do |format|\n format.html do\n @data = json_for_bar_chart(@moving)\n end\n format.csv do\n csv = MovingCsv.new(@moving)\n send_data csv.data, csv.config\n end\n end\n end", "def getchart()\n # Data for outer ring\n data = [88, 124, 96]\n\n # Data for inner ring\n data2 = [77, 87, 45]\n\n # Labels for the sectors\n labels = [\"Hardware\", \"Software\", \"Services\"]\n\n # Colors for the sectors\n colors = [0xff9999, 0x9999ff, 0x66ff66]\n\n #\n # Create the main chart, which contains the chart title, the outer ring, and the\n # legend box\n #\n\n # Create a PieChart object of size 450 x 360 pixels, with transparent background\n c = ChartDirector::PieChart.new(450, 360)\n\n # Add a title to the chart with 18pts Times Bold Italic font\n c.addTitle(\"Concentric Donut Chart\", \"timesbi.ttf\", 18)\n\n # Set donut center at (160, 200), and outer/inner radii as 150/100 pixels\n c.setDonutSize(160, 200, 150, 100)\n\n # Add a label at the bottom-right corner of the ring to label the outer ring Use\n # 12pts Arial Bold Italic font in white (ffffff) color, on a green (008800)\n # background, with soft lighting effect and 5 pixels rounded corners\n t = c.addText(260, 300, \" Year 2006 \", \"arialbi.ttf\", 12, 0xffffff)\n t.setBackground(0x008800, ChartDirector::Transparent, ChartDirector::softLighting(\n ))\n t.setRoundedCorners(5)\n\n # Set the legend box at (320, 50) with 12 pts Arial Bold Italic font, with no\n # border\n c.addLegend(320, 50, true, \"arialbi.ttf\", 13).setBackground(\n ChartDirector::Transparent, ChartDirector::Transparent)\n\n # Set the pie data and the pie labels\n c.setData(data, labels)\n\n # Set the pie colors\n c.setColors2(ChartDirector::DataColor, colors)\n\n # Set pie border color to white (ffffff)\n c.setLineColor(0xffffff)\n\n # Set pie label to value in $###M format, percentage in (##.#%) format, in two\n # lines.\n c.setLabelFormat(\"${value}M<*br*>({percent|1}%)\")\n\n # Use 10pts Airal Bold for the sector labels\n c.setLabelStyle(\"arialbd.ttf\", 10)\n\n # Set the label position to -25 pixels from the sector (which would be internal to\n # the sector)\n c.setLabelPos(-25)\n\n #\n # Create the inner ring.\n #\n\n # Create a PieChart object of size 280 x 320 pixels, with transparent background\n c2 = ChartDirector::PieChart.new(280, 320, ChartDirector::Transparent)\n\n # Set donut center at (110, 110), and outer/inner radii as 100/50 pixels\n c2.setDonutSize(110, 110, 100, 50)\n\n # Add a label at the center of the ring to label the inner ring. Use 12pts Arial\n # Bold Italic font in white (ffffff) color, on a deep blue (0000cc) background,\n # with soft lighting effect and 5 pixels rounded corners\n t2 = c2.addText(110, 110, \" Year 2005 \", \"arialbi.ttf\", 12, 0xffffff,\n ChartDirector::Center)\n t2.setBackground(0x0000cc, ChartDirector::Transparent,\n ChartDirector::softLighting())\n t2.setRoundedCorners(5)\n\n # Set the pie data and the pie labels\n c2.setData(data2, labels)\n\n # Set the pie colors\n c2.setColors2(ChartDirector::DataColor, colors)\n\n # Set pie border color to white (ffffff)\n c2.setLineColor(0xffffff)\n\n # Set pie label to value in $###M format, percentage in (##.#%) format, in two\n # lines.\n c2.setLabelFormat(\"${value}M<*br*>({percent|1}%)\")\n\n # Use 10pts Airal Bold for the sector labels\n c2.setLabelStyle(\"arialbd.ttf\", 10)\n\n # Set the label position to -25 pixels from the sector (which would be internal to\n # the sector)\n c2.setLabelPos(-25)\n\n # merge the inner ring into the outer ring at (50, 90)\n c.makeChart3().merge(c2.makeChart3(), 50, 90, ChartDirector::TopLeft, 0)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def show\n if @city.statistics.size > 2\n sdate = @city.statistics.keys[1].to_date\n edate = @city.statistics.keys.last.to_date\n stime = Time.new(sdate.year, sdate.month, sdate.day, 0, 0, 0, @city.zone)\n etime = Time.new(edate.year, edate.month, edate.day, 0, 0, 0, @city.zone)\n\n data = @city.statistics.values[1...-1].map{|s| s[:total]}\n interval = 1.day\n\n @count = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(:text => \"Medias Count\")\n f.xAxis(type: \"datetime\", maxZoom: (etime - stime).to_i)\n f.series(\n name: \"count\", \n yAxis: 0, \n data: data,\n pointStart: stime,\n pointInterval: interval\n )\n\n f.yAxis [\n {:title => {:text => \"count\", :margin => 70}, min: 0 },\n ]\n\n f.legend(:align => 'right', :verticalAlign => 'top', :y => 75, :x => -50, :layout => 'vertical',)\n f.chart({:defaultSeriesType=>\"spline\"})\n end\n\n distributions = @city.statistics.values[1...-1].map{|s| s[:distribution]}\n distribution_data = distributions.inject([]) do |res, d|\n d.each_with_index do |c, i|\n res[i] ||= []\n res[i] << c\n end\n res\n end\n distribution_data.each{ |d| d.extend(DescriptiveStatistics) }\n\n @distribution = LazyHighCharts::HighChart.new('graph') do |f|\n f.title(:text => \"Medias Distribution\")\n f.xAxis(\n categories: 24.times.map{ |h| (\"%02d\" % h) + \":00\" }\n )\n f.series(\n name: 'mean',\n yAxis: 0,\n data: distribution_data.map(&:mean)\n )\n f.series(\n name: 'standard eviation',\n yAxis: 0,\n data: distribution_data.map(&:standard_deviation)\n )\n f.yAxis [\n {min: 0}\n ]\n f.legend(:align => 'right', :verticalAlign => 'top', :y => 150, :x => -50, :layout => 'vertical',)\n f.chart({:defaultSeriesType=>\"spline\"})\n end\n end\n end", "def index\n @charts = Chart.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @charts }\n end\n end", "def emissions_chart_data\n data = ::Api::Charts::CPAssessment.new(@cp_assessment, params[:view]).emissions_data\n\n render json: data.chart_json\n end", "def show\n @visualization = Visualization.find(params[:id])\n @project = Project.find_by_id(@visualization.project_id)\n tmp = JSON.parse(@visualization.data)\n param_vis = param_vis_check(params)\n\n # The finalized data object\n @data = {\n savedData: @visualization.data,\n savedGlobals: @visualization.globals,\n defaultVis: param_vis || tmp['defaultVis'],\n relVis: tmp['relVis']\n }\n\n recur = params.key?(:recur) ? params[:recur] == 'true' : false\n\n options = {}\n\n # Detect presentation mode (and force embed)\n if params.try(:[], :presentation) and params[:presentation]\n @presentation = true\n options[:presentation] = 1\n params[:embed] = true\n else\n @presentation = false\n end\n\n respond_to do |format|\n format.html do\n if params.try(:[], :embed) and params[:embed]\n options[:isEmbed] = 1\n options[:startCollapsed] = 1\n @globals = { options: options }\n render 'embed', layout: 'embedded'\n else\n @layout_wide = true\n render\n end\n end\n format.json { render json: @visualization.to_hash(recur) }\n end\n end", "def render(options = {})\n options[:theme] ||= theme\n options[:value_formatter] ||= value_formatter\n options[:point_markers] ||= point_markers\n options[:size] ||= (options[:width] ? [options[:width], (options.delete(:width) * 0.6).to_i] : [600, 360])\n options[:title] ||= title\n options[:layers] ||= layers\n options[:min_value] ||= bottom_value(:padded)\n options[:max_value] ||= top_value\n options[:graph] ||= self\n \n\n # Removed for now.\n # Added for making smaller fonts more legible, but may not be needed after all.\n #\n # if options[:as] && (options[:size][0] <= 300 || options[:size][1] <= 200)\n # options[:actual_size] = options[:size]\n # options[:size] = [800, (800.to_f * (options[:actual_size][1].to_f / options[:actual_size][0].to_f))]\n # end\n \n svg = ( options[:renderer].nil? ? self.renderer.render( options ) : options[:renderer].render( options ) )\n \n # SVG to file.\n if options[:to] && options[:as].nil?\n File.open(options[:to], 'w') { |file|\n file.write(svg)\n }\n end\n \n options[:as] ? rasterizer.rasterize(svg, options) : svg\n end", "def render_visualizations\n if @google_visualizations\n package_list = @visualization_packages.uniq.collect do |p|\n package = p.to_s.camelize.downcase\n package = \"corechart\" if [\"areachart\", \"barchart\", \"columnchart\", \"linechart\", \"piechart\"].include?(package)\n \"\\'#{package}\\'\"\n end\n output = %Q(\n <script type=\"text/javascript\">\n google.load('visualization', '1', {'packages':[#{package_list.uniq.join(',')}]});\n google.setOnLoadCallback(drawCharts);\n var chartData = {};\n var visualizationCharts = {};\n function drawCharts() { )\n @google_visualizations.each do |id, vis|\n output += generate_visualization(id, vis[0], vis[1], vis[2])\n end\n output += \"} </script>\"\n raw(output + \"<!-- Rendered Google Visualizations /-->\")\n else\n raw(\"<!-- No graphs on this page /-->\") if debugging?\n end\n end" ]
[ "0.73793256", "0.71304905", "0.70487463", "0.7032319", "0.69694126", "0.69295007", "0.69255656", "0.69129133", "0.69128174", "0.68344223", "0.6826156", "0.68255234", "0.6810791", "0.6803158", "0.6785608", "0.67432153", "0.67410535", "0.6721165", "0.67112935", "0.67078435", "0.6697408", "0.6694526", "0.66844934", "0.6669086", "0.66498214", "0.6644496", "0.6642862", "0.66307795", "0.66203713", "0.6614862", "0.6612074", "0.6604545", "0.6592078", "0.6572745", "0.65562654", "0.655061", "0.6541065", "0.6520348", "0.6504808", "0.65044636", "0.64758027", "0.642083", "0.6409502", "0.6404182", "0.63919765", "0.6373785", "0.63565576", "0.63292044", "0.6296632", "0.629054", "0.62797964", "0.6279565", "0.62732774", "0.627204", "0.6267767", "0.6224489", "0.6216721", "0.6206906", "0.61988264", "0.6195612", "0.6183519", "0.6168284", "0.61641324", "0.61579525", "0.6103996", "0.6084124", "0.60793704", "0.60564435", "0.60508657", "0.6039847", "0.60299486", "0.60267574", "0.6020392", "0.6010361", "0.6005969", "0.6005969", "0.5989297", "0.5983206", "0.5967487", "0.5963167", "0.5958017", "0.5946903", "0.5946903", "0.5941361", "0.5933201", "0.59266156", "0.5926038", "0.58960915", "0.5890225", "0.5889224", "0.5888658", "0.5886179", "0.58703774", "0.5862211", "0.586023", "0.58407414", "0.5834475", "0.5822056", "0.58217597", "0.58150065" ]
0.66887486
22
Print the version of iTunes
def show_version puts "iTunes version: #{@iTunes.version}" @logger.info "iTunes version: #{@iTunes.version}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def print_version()\n (version,packager,name) = get_version()\n puts name+\" v. \"+version+\" \"+packager\n exit\nend", "def print_version\n puts VERSION\n \n exit\n end", "def show_version\n puts format('JRubyArt version %s', JRubyArt::VERSION)\n end", "def print_version_info()\n puts \"Versão: \" + $version_info[:version].to_s + \" \" + $version_info[:date].to_s\n puts \"-----\"\nend", "def show_elf_version\n\t\t\tver_str = \"#{@elf_version}\"\n\t\t\tver_str += \" (current)\" if @elf_version == 1\n\t\t\tputs \" Version: #{ver_str}\"\n\t\tend", "def version\n Airplay.configuration.load\n v = Airplay::CLI::VERSION\n puts <<-EOS\n\n i@@@@@@@@@@@@@@@@@@@@@@@@@\n i80000000000000000000000000000\n i80000000000000000000000000000000G\n i8000000000000000000000000000000000000\n i80000000000000000000000000000000000000000\n @00000 @0000000000000000000000000000000000000@ 000000@\n @0000008 @000000000000000000000000000000000@ 80000000@\n @001 @00000000000000000000000000000@ 100@\n @001 @0000000000000000000000000@ 100@\n @001 80000000000000000000008 t00@\n @001 8000000000000000008 t00@\n @001 800000000000008 t00@\n @001 G000000000G t00@\n @001 G00000G t00@\n @001 L0L t00@\n @001 t00@\n @001 air t00@\n @001 #{v} t00@\n @001 t00@\n @001 t00@\n @001 100@\n @00000000000000000000000000000000000000000000000000000G000@\n @000000000000000000000000000000000000000000000000000000000@\n\n EOS\n end", "def show_file_version\n\t\t\tputs \" Version: #{@elf_version.to_h}\"\n\t\tend", "def print_version()\n (version,packager,name) = get_version()\n puts name+\" v. \"+version+\" \"+packager\nend", "def print_version()\n puts\n string = get_version()\n puts string\n puts\n return\nend", "def print_version(script)\n (version,packager,name) = get_version(script)\n puts name+\" v. \"+version+\" \"+packager\n exit\nend", "def output_version\n puts \"#{File.basename(__FILE__)} version #{VERSION}\"\n end", "def output_version\n puts \"#{File.basename($0)} version #{BM_VERSION}\"\n end", "def version\n \"\\e[36mThis program is currently in version number: #{v_num}\\e[0m\"\n end", "def print_version()\n puts\n file_array = IO.readlines $0\n version = file_array.grep(/^# Version/)[0].split(\":\")[1].gsub(/^\\s+/,'').chomp\n packager = file_array.grep(/^# Packager/)[0].split(\":\")[1].gsub(/^\\s+/,'').chomp\n name = file_array.grep(/^# Name/)[0].split(\":\")[1].gsub(/^\\s+/,'').chomp\n puts name+\" v. \"+version+\" \"+packager\n puts\n return\nend", "def ver\n if v = version\n str = +\"#{program_name} #{[v].join('.')}\"\n str << \" (#{v})\" if v = release\n str\n end\n end", "def title\n puts \"\\nTalia Digital Library system. Version: #{TaliaCore::Version::STRING}\" \n puts \"http://www.muruca.org/\\n\\n\"\n end", "def version(version)\n @io.puts \"v#{version}\"\n @io.puts\n end", "def print_version\n version=\"unknown\"\n version_file=\"lib/version.rb\"\n\n if File.exist?(version_file)\n require_relative \"version.rb\"\n version=get_version\n end\n\n puts \"Version: #{version}\\n\"\n exit 2\n end", "def show_version\n abort \"#{option_parser.program_name} v#{VERSION} on #{RUBY_DESCRIPTION}\"\n end", "def info_apk\n a = publisher.info_apk\n puts \"\\n#{a.title} - #{a.short_description}\"\n puts '---'\n puts a.full_description\n puts\n end", "def version\n puts \"Version 1.1\"\nend", "def print_version()\n puts\n file_array = IO.readlines $0\n version = file_array.grep(/^# Version/)[0].split(\":\")[1].gsub(/^\\s+/,'').chomp\n packager = file_array.grep(/^# Packager/)[0].split(\":\")[1].gsub(/^\\s+/,'').chomp\n name = file_array.grep(/^# Name/)[0].split(\":\")[1].gsub(/^\\s+/,'').chomp\n puts name+\" v. \"+version+\" \"+packager\n puts\nend", "def version\n puts \"v0.3\"\n end", "def version(version)\n @io.puts \"*v#{version}*\"\n @io.puts\n # Hacking in the overview file\n if File.exist?('OVERVIEW.md')\n @io.puts IO.read('OVERVIEW.md')\n @io.puts\n end\n end", "def version\n send_command(:getinfo, 'version')\n reply = read_reply.split('=').last\n read_reply # skip \"250 OK\"\n reply\n end", "def showInformation()\n print(\"Starting up the scraper for the RAND Terrorism Incident Database. The flashing numbers that will appear represent written incidents. It will take a few moments for the initial program to load... \\n\");\nend", "def version\n str = if product = detect_product('Version')\n product.version\n elsif os =~ /iOS ([\\d\\.]+)/ && browser == \"Safari\"\n $1.tr('_', '.')\n else\n BuildVersions[build.to_s]\n end\n\n Version.new(str)\n end", "def to_s\n\t\tgetUIversion().to_s\n\tend", "def to_s\n\t\tgetUIversion().to_s\n\tend", "def list\n puts \"➔ Listing all APK! Current #{publisher.current_version} - #{publisher.apk_date}\"\n versions = publisher.list_apks\n versions.each do |a|\n color = publisher.current_version == a.version_code ? :green : :black\n puts Paint[\"#{a.version_code} ➔ #{a.binary.sha1}\", color]\n end\n end", "def version\n output = @filer.invoke(\"system-get-version\")\n if(output.results_errno() != 0)\n r = output.results_reason()\n raise \"Failed : \\n\" + r\n else \n output.child_get_string(\"version\")\n end\n end", "def init\n @flavor = 'mac_os_x'\n @release = `sw_vers -productVersion`\n end", "def version\n cmd(COMMANDS[:version], 2)\n end", "def display_version(arg=nil)\n set_or_return(\n :display_version,\n arg,\n :kind_of => [ String ]\n )\n end", "def version\n p\n version = File.read(HOSTER_PATH+\"/hoster.version\")\n puts PROGNAME + \" version \" + version\nend", "def to_s\n getUIversion().to_s\n end", "def to_s\n getUIversion().to_s\n end", "def to_s\n getUIversion().to_s\n end", "def to_s\n getUIversion().to_s\n end", "def to_s\n getUIversion().to_s\n end", "def print_catalog\n puts @name + \" Catalog\"\n puts Time.now.to_s\n\n # print all books as a table\n format = '%-15s %-15s %-30s %-20s %s'\n puts format % ['Book Number', 'ISBN', 'Title', 'Author', 'Available']\n self.each_with_index do |book, i|\n puts format % [ i+1, book.isbn, book.title, book.author, book.available ]\n end\n end", "def version\n Launcher::Log.info Launcher::VERSION\n end", "def version()\n $stderr.puts WOL_VERSION\n $stderr.puts 'Written by Kevin R. Bullock.'\n $stderr.puts\n $stderr.puts 'Copyright (C) 2004 Kevin R. Bullock.'\n $stderr.puts 'This is free software; see the source for copying conditions. There is NO'\n $stderr.puts 'warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.'\n end", "def version\n execute_string(\"-version\")\n end", "def display_product\n STDOUT.puts \"--\"*50\n STDOUT.puts \"title: \\t\\t#{$title}\"\n STDOUT.puts \"seller: \\t#{$seller}\"\n STDOUT.puts \"price: \\t\\t#{$price}\"\n STDOUT.puts \"stars: \\t\\t#{$stars}\"\n STDOUT.puts \"reviews: \\t#{$reviews}\"\n STDOUT.puts \"image url: \\t#{$image_href}\"\n STDOUT.puts \"product url: \\t#{$url}\"\n end", "def to_s\n getUIversion.to_s\n end", "def version\n @instruments_version ||= lambda do\n version_string = pbuddy.plist_read('CFBundleShortVersionString',\n path_to_instruments_app_plist)\n RunLoop::Version.new(version_string)\n end.call\n end", "def get_version(apps)\n apps.each do |app|\n if File.exists?(\"#{app}/Contents/Info.plist\")\n short = app.sub(/\\/Applications\\//, '')\n vers = `/usr/bin/defaults read \"#{app}\"/Contents/Info CFBundleShortVersionString`.chomp\n res = puts \"#{short}: #{vers}\"\n $?.success? ? res : \"ERROR: could not get version\"\n else\n puts \"#{app} is not installed.\"\n end\n end\nend", "def show_help\n puts HELP_INSTALL\n end", "def version(arguments, options)\n puts \"baretest executable version #{Version}\",\n \"library version #{BareTest::VERSION}\",\n \"ruby version #{RUBY_VERSION}\",\n \"\"\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def version\n \"Version: #{VERSION.split[1]} Created on: \" +\n \"#{REVISION_DATE.split[1]} by #{AUTHOR}\"\n end", "def print_isbn\n lista = \"\"\n num_isbns.each do |isbn|\n count = 0\n lista += \"ISBN-\" + isbn.delete('^0-9').size.to_s + \": \" + isbn\n lista += \"\\n\\t\" if count != num_isbns.size\n end\n lista\n end", "def print_isbn\n lista = \"\"\n num_isbns.each do |isbn|\n count = 0\n lista += \"ISBN-\" + isbn.delete('^0-9').size.to_s + \": \" + isbn\n lista += \"\\n\\t\" if count != num_isbns.size\n end\n lista\n end", "def print_songs\n songs.each do |song|\n puts \"#{song.name}\"\n end\n end", "def to_s\n \"#{output}\\n[#{version}]\"\n end", "def version\n build_string\n end", "def print_songs\n songs.each { |song| puts \"#{song.name}\" }\n end", "def apk_pri\n puts \"\\nPrint Apks:\"\n @apks.each do |apk|\n puts apk.index.to_s + \"\\t\" + (apk.fname + (' ' * 30))[0, 30] + \"\\t\" + apk.size.to_s + \"\\t\" + apk.mtime.to_s\n end\n end", "def to_s\n \"#<Xcode #{version.to_s}>\"\n end", "def version\n api_execute('/version', :get).body\n end", "def osx_version_txt t\n create_version_file t\nend", "def osx_version_txt t\n create_version_file t\nend", "def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end", "def print_songs\n songs.each {|song| puts song.name}\n end", "def version\n echo_rosh_command\n\n @version ||= adapter.current_version\n end", "def name_pri\n puts \"\\nPrint Names:\"\n @apks.each do |apk|\n puts apk.fname\n end\n end", "def print_current(options={})\n software, version = parse_software_args((options[:software]||options[:package]), options[:version])\n options[:echo] = true #print output\n run_command(\"#{command} current #{software}\", options, &block)\n end", "def tell_iTunes_to( command )\n return \"osascript -e 'tell application \\\"iTunes\\\" to \" + command + \"'\"\n end", "def print_console_products_ascii\n\tputs products_ascii\nend", "def run(context)\n if context[SHOW_VERSION_KEY]\n @output.puts(@version_string)\n else\n yield\n end\n end", "def list_books\n puts \"\"\n puts \"Current Catalogue:\"\n puts \"\"\n puts \"A-G:\"\n \t@shelf_ag.to_s\n \tputs \"H-P:\"\n \t@shelf_hp.to_s\n \tputs \"Q-Z:\"\n \t@shelf_qz.to_s\n end", "def print_usage(options)\n puts\n puts \"Usage: \"+$0+\" -[\"+options+\"]\"\n puts\n puts \"-V:\\tDisplay version information\"\n puts \"-h:\\tDisplay usage information\"\n puts \"-v:\\tVerbose output\"\n puts \"-d:\\tDownload latest build but don't install\"\n puts \"-i:\\tDownload and install latest build\"\n puts \"-u:\\tUpdate application to latest build\"\n puts \"-l:\\tGet local build date for application\"\n puts \"-r:\\tGet remote build date for application\"\n puts \"-p:\\tGet URL of download for latest package\"\n puts \"-c:\\tCompare local and remote build dates\"\n puts \"-a:\\tShow available packages\"\n puts \"-g:\\tUpdate Gatekeeper and Quarantine information so application can run\"\n puts \"-z:\\tClean up temporary directory (delete files older than \"+$mtime+\" days)\"\n puts \"-Z:\\tRemove existing application\"\n puts \"-C:\\tRemove crash reporter file\"\n puts \"-P:\\tPerform post install\"\n puts \"-q:\\tQuit application\"\n puts \"-s:\\tStart application\"\n puts\nend", "def to_s\n @version\n end", "def version\n @version_helper.to_s\n end", "def version\n @version_helper.to_s\n end", "def print_songs\n songs.each {|song| puts song.name}\n end", "def get_aozora_version_number\n `/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' ../AnimeNow/Info.plist`.strip\nend", "def productVersion \n \"productVersion\" \n end", "def display_book\n\t\tputs \"Author: #@author, Title: #@title, Publisher: #@publisher, Year: #@year, Location: Shelf: #@shelf_num\"\n\tend", "def read_device_version()\n start_command('F83', false, @status_debug_msg)\n end", "def title\n \"#{artist.name} - #{name} [#{release.catalog_number}]\"\n end", "def versionString()\n\t\t\t\treturn \"#{major}.#{minor}.#{build}\"\n\t\t\tend", "def print_old_list(app_file_list,rm_file)\n if !File.directory?($itunes_dir) and !File.symlink?($itunes_dir)\n puts \"Could not find iTunes directory \"+$itunes_dir\n exit\n end\n app_dir = $itunes_dir+\"/iTunes Media/Mobile Applications\"\n if !File.directory?(app_dir) and !File.symlink?(app_dir)\n puts \"Could not find Mobile Applications directory \"+app_dir\n exit\n end\n app_list = {}\n app_file_list.each do |file_name|\n if file_name.match(/ipa$/)\n file_info = file_name.split(/(\\s+)/)\n if file_info[-3].match(/[0-9]\\./) and file_info[-1].match(/\\.ipa/)\n app_name = file_info[0..-5].join\n app_ver = file_info[-3]\n else\n app_name = file_info[0..-3].join\n app_ver = file_info[-1].split(/\\./)[0..-2].join(\".\")\n end\n if !app_list[app_name]\n app_list[app_name] = app_ver\n lat_ver = app_ver\n else\n cur_ver = app_list[app_name]\n versions = [ cur_ver, app_ver ]\n lat_ver = versions.map{ |v| (v.split '.').collect(&:to_i) }.max.join '.'\n end\n app_list[app_name] = lat_ver\n end\n end\n app_file_list.each do |file_name|\n if file_name.match(/ipa$/)\n file_info = file_name.split(/(\\s+)/)\n if file_info[-3].match(/[0-9]\\./) and file_info[-1].match(/\\.ipa/)\n app_name = file_info[0..-5].join\n app_ver = file_info[-3]\n else\n app_name = file_info[0..-3].join\n app_ver = file_info[-1].split(/\\./)[0..-2].join(\".\")\n end\n lat_ver = app_list[app_name]\n if lat_ver != app_ver\n app_file = app_dir+\"/\"+file_name\n if rm_file == \"y\"\n puts \"Deleting: \"+app_file\n File.delete(app_file)\n else\n puts \"Application: \"+app_name\n puts \"Newest: \"+lat_ver\n puts \"Older: \"+app_ver\n end\n end\n end\n end\n return\nend", "def get_version_short_string(path)\n plist_hash = info_plist_to_hash path\n plist_hash['CFBundleShortVersionString']\nend", "def print_help()\n puts \"\\nusage: spotty [args]\"\n puts \"A command line interface to Spotify on Mac OS X.\"\n puts \"Available commands:\"\n puts \"play - Play a song if it's paused or stopped.\\n\"\n puts \"pause - Pause a song if it's playing.\\n\"\n puts \"toggleplaying - Toggle the song between playing and paused.\"\n puts \"Aliases: playpause, tp, pp\\n\"\n puts \"next - Skip the currently playing song\\n\"\n puts \"previous - Restart the current song or go back to the previously playing song.\\n\"\n puts \"Aliases: prev\\n\"\n puts \"playing? - Is Spotify playing any music right now?\"\n puts \"Aliases: p?\\n\"\n puts \"nowplaying - Print the currently playing song.\"\n puts \"Format: <song name> by <song artist>\"\n puts \"Aliases: np\\n\"\n puts \"help - Print this help page.\"\n puts \"\\n\\nThank you for using spotty!\"\nend", "def print_version\n puts \"nginx_statisic version 0.4.0\".yellow\n puts \"Created by Benjamin Held (May 2016)\".yellow\nend", "def print_inventory inventory\n\tinventory.each_with_index do |items, index|\n\tputs \"#{index+1}\" + \".\" + \"#{items[0]}\" + \"-\" + \"#{items[1]}\"\nend\nend", "def listinfo\n puts \"排名:#{@no}\"\n puts \"月份:#{@month}\" if @month\n puts \"标签: #{@subtag}\" if @subtag\n puts \"标题:#{@title}\"\n puts \"集数:#{@episode}\" if @episode\n puts \"链接:#{@link}\"\n puts \"<bilibili独家哟!>\" if @bilibilionly_flag\n puts \"--------------------\"\n end", "def to_s\n \"Mac OS 10.4 (Tiger)\"\n end", "def version\n VersionInfo.new(command(\"Browser.getVersion\"))\n end", "def version\n puts \"You're running imgurr #{Imgurr::VERSION}.\"\n end", "def ipb_usage\n puts \"Available Options for I.P.B. Menu: \".underline.white\n puts \"back \".light_yellow + \" => \".white + \"Return to Main Menu\".light_red\n puts \"check\".light_yellow + \" => \".white + \"IPB <= 3.3.4 Unserialized RCE Check\".light_red\n puts \"exploit\".light_yellow + \" => \".white + \"IPB <= 3.3.4 Unserialized RCE Exploit\".light_red\nend", "def display_releases(releases)\n url = \"\"\n releases.each do |release|\n puts \"\\n\\n#{release.name} by #{release.artist} on #{release.label}\\n\"\n release.tracks.each_with_index do |track, index|\n puts \"-#{track.name}\"\n url = track.url\n end\n end\n end", "def version\n render json: { result: 'Ok', version: '1', protocol: 'EBUio-PlugIt' }\n end", "def info\n puts \"The name and the price will be printed\"\n end", "def print_songs\n songs.each do |song|\n puts song.name\n end\n end", "def print_songs\n songs.each do |song|\n puts song.name\n end\n end", "def to_s\n @version\n end" ]
[ "0.65963435", "0.6577111", "0.65505254", "0.65398264", "0.6528015", "0.64972866", "0.6479126", "0.6469703", "0.64344853", "0.628872", "0.6227733", "0.6093266", "0.60480416", "0.6046116", "0.5966573", "0.59488386", "0.59069866", "0.58627456", "0.58528763", "0.58112365", "0.5782745", "0.57543296", "0.5708571", "0.56807584", "0.56484306", "0.56403625", "0.56294143", "0.56110924", "0.56110924", "0.5579933", "0.55798554", "0.5546372", "0.55411804", "0.55160433", "0.5507667", "0.5498388", "0.5498388", "0.5498388", "0.5498388", "0.5498388", "0.5483515", "0.5483135", "0.5460812", "0.5447448", "0.5432713", "0.5418267", "0.5412185", "0.5390367", "0.53886974", "0.53845036", "0.53737587", "0.53737587", "0.5371572", "0.53631604", "0.53631604", "0.5354719", "0.53496116", "0.53461576", "0.533772", "0.53282803", "0.5313562", "0.53012574", "0.5290753", "0.5290753", "0.5272516", "0.5261404", "0.526062", "0.5254379", "0.5254103", "0.5249526", "0.52476484", "0.52280223", "0.51991266", "0.5195669", "0.51930064", "0.51864386", "0.51864386", "0.5186314", "0.51856583", "0.51818806", "0.51781285", "0.51666844", "0.5165804", "0.51652694", "0.51647425", "0.5161626", "0.51578724", "0.51576614", "0.515649", "0.5144807", "0.51434255", "0.51365805", "0.5132431", "0.51235825", "0.5118861", "0.5109707", "0.51075244", "0.50973785", "0.50973785", "0.5095856" ]
0.8646498
0
Get a list of all possible iTunes sources
def sources @iTunes.sources.each do |source| @sources << source end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sources\n @sources.names\n end", "def get_sources\n @page.all(input_elements[:sources_list])\n end", "def sources\n []\n end", "def sources\n @sources ||= []\n end", "def sources\n @sources ||= AVAILABLE_SOURCES.each_with_object({}) do |source_class, list|\n source = source_class.new\n list[source.id.to_s] = {\n 'name' => source.name,\n 'website' => source.website,\n 'notes' => source.notes,\n 'class' => source.class\n }\n end\n end", "def sources\n s = Set.new\n experiments.each { |experiment| s.merge(experiment.sources) }\n s.to_a\n end", "def sources\n filter.sources\n end", "def sources\n sort!\n @sources\n end", "def all_sources\n @normal_sources + @extensions + @replacements\n end", "def data_sources\n src.collect{|v| v['source']}\n end", "def sources\n %w[\n sample_source\n ]\nend", "def list_sources\n sources = Profile.get_guardian_headlines\n # prints out numbered articles\n sources.each do |key, value|\n puts ColorizedString[\"#{key}.\"].red + \" #{value[0]}\"\n end\n # asks for input\n input = choose_source(sources)\n choice = sources[input][0]\n print ColorizedString[\"You have chosen:\"].red\n puts ColorizedString[\" #{choice}\"].underline\n sources[input][1]\n end", "def sources\n IITSourceCollection.new(@ole.Sources)\n end", "def find_sources\n names = \"\"\n Googlenews.items(100).each do |report|\n name = report['title'].match(/ - ([\\w. ]+)/)[1]\n names << name\n unless Source.find_by_name(name)\n source = Source.new({\n :name => name\n })\n source.save\n end\n end\n render :text => names\n end", "def get_sources\n response = execute_get(\"/reference/source\")\n Source.from_array(decode(response))\n end", "def get_all_sources_info\n source_info = {}\n METADATA_FIELDS.keys.each { |ns|\n source_info[ns] = get_metadata_source_info(ns)\n }\n source_info\n end", "def sources_for(r)\n return if r[:source].to_s.empty?\n [{ url: r[:source] }]\n end", "def list(sources=DEFAULT_SOURCES, options)\n options = DEFAULT_OPTIONS.merge!(options)\n sources.collect do |source|\n source.list(options)\n end.flatten.uniq\n end", "def test_source_list\n assert_equal PROPER_SOURCES, @installer.sources\n end", "def urls\n @gapi.source_uris\n end", "def hardcoded_songs\n [\n Song.new(\"Maroon 5 - This love\", [13, 68, 13, 68, 13, 45, 68, 13]),\n Song.new(\"Ben l'oncle soul - Seven nation army\", [68, 13, 0, 68, 13, 0, 68]),\n Song.new(\"Ornatos Violeta - Para de olhar para mim\", [77, 125, 93, 77])\n ]\n end", "def all_sources\n result = Set.new\n sources.each do |ev|\n result << ev\n result.merge(ev.all_sources)\n end\n result\n end", "def test_sources\n # just get whatever length fortunes\n LinuxFortune.short=false\n LinuxFortune.long=false\n\n sources = LinuxFortune.get_sources\n assert !sources.nil? and sources.size > 0\n end", "def sources\n @_configuration.fetch('sources') { DEFAULT_SOURCES }\n end", "def sources\n @sources = Dir.glob(File.join(@test_cases_path,\"**\",\"*.txt\")).sort\n @sources\n end", "def default_sources\n self.class.default_sources.map{ |src| File.join(root, src) }\n end", "def sources\n files(!p?)\n end", "def prepare_sources\n SOURCES.each_pair do |suite, url|\n prepare_source_for(url, @freshen)\n end\n end", "def all_songs\n end", "def info_sources\n @queue << \"i so\"\n end", "def sources\n sources = %w(UPSLoad UPSBatteryCharge UPSBatteryVoltage UPSInputVoltage UPSOutputVoltage)\n return sources\n end", "def sources\n @sources ||= SourcePool.new\n end", "def test_fortune_from_all_named_fortune_sources\n sources = LinuxFortune.get_sources\n fortunes = []\n fortunes << LinuxFortune.generate( sources )\n assert !fortunes.empty?\n end", "def watched_sources\n @watched_sources\n end", "def sources\n source_paths\n end", "def update\n STDOUT.sync = true\n tracks = []\n\n app = Appscript.app.by_name(\"iTunes\", Tunes) \n\n iTunes_tracks = app.selection.get\n if iTunes_tracks.count == 0\n iTunes_tracks = app.library_playlists[1].tracks.get\n end\n\n print \"Reading #{iTunes_tracks.count} tracks \"\n iTunes_tracks.each do | iTunes_track |\n begin\n if iTunes_track.kind.get == 'Matched AAC audio file'\n track = Track.new(iTunes_track)\n unless track.valid?\n tracks << track\n print '*' if ((tracks.count % WORK_SIZE) == 0)\n end\n end\n rescue StandardError => e\n puts e\n end\n end\n puts ''\n\n # all 2 char countries codes lots currently not valid %w(AF AX AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO BQ BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CD CK CR CI HR CU CW CY CZ DK DJ DM DO EC EG SV GQ ER EE ET FK FO FJ FI FR GF PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM VA HN HK HU IS IN ID IR IQ IE IM IL IT JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MK MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NL NC NZ NI NE NG NU NF MP NO OM PK PW PS PA PG PY PE PH PN PL PT PR QA RE RO RU RW BL SH KN LC MF PM VC WS SM ST SA SN RS SC SL SG SX SK SI SB SO ZA GS SS ES LK SD SR SJ SZ SE CH SY TW TJ TZ TH TL TG TK TO TT TN TR TM TC TV UG UA AE GB US UM UY UZ VU VE VN VG VI WF EH YE ZM ZW)\n\n countries = %w(AU US GB FR DE CA IT JP DZ AO AI AG AR AM AT AZ BS BH BD BB BY BE BZ BM BO BW BR BN BG CM KY CL CN CO CR CI HR CY CZ DK DM DO EC EG SV EE ET FI GH GR GD GT GY HN HK HU IS IN ID IE IL JM JO KZ KE KR KW LV LB LY LI LT LU MO MK MG MY MV ML MT MU MX MD MS MM NP NL NZ NI NE NG NO OM PK PA PY PE PH PL PT QA RO RU KN LC VC SA SN RS SG SK SI ZA ES LK SR SE CH TW TZ TH TT TN TR TC UG UA AE UY UZ VE VN VG YE)\n\n puts \"Found #{tracks.count} matched tracks\"\n countries.each do | country |\n print \"Querying #{country} store for #{tracks.count} tracks \"\n counter = 0\n tracks.dup.each.each_slice(WORK_SIZE) do | subtracks |\n ids = subtracks.map { | track | track.iTunes_id }\n iTunesUrl = \"http://itunes.apple.com/lookup?id=#{ids.join(',')}&country=#{country}\"\n # puts \"QUERY: #{iTunesUrl}\"\n iTunesHash = JSON.parse(open(iTunesUrl).read)\n print '*'\n iTunesHash['results'].each do | result |\n result_id = result['trackId']\n subtracks.each do | track |\n if result_id == track.iTunes_id\n result['year'] = Date.parse(result['releaseDate']).year if update_year\n track.update_track(result, update_year, dry_run, verbose) \n tracks.delete(track)\n counter += 1\n break\n end\n end\n end\n end\n puts \" #{counter} updated\"\n break if tracks.empty?\n end\n\n puts \"Couldn't find meatadata for #{tracks.count} tracks\" if tracks.count != 0\n end", "def data_sources\n []\n end", "def get_sources(workdir)\n @sources.each do |source|\n cur_source = Vanagon::Component::Source.source(source.url, { :ref => source.ref, :sum => source.sum }, workdir)\n cur_source.fetch\n cur_source.verify\n end\n end", "def index\n @sources = Source.all\n end", "def setups(filter=\"\")\n debug \"Systematic#setups(#{filter})\"\n setups = []\n strategies(filter).each do |strategy|\n debug \"Systematic#setups strategy=#{strategy}\"\n strategy.watchlist.each do |setup|\n sec_id, ticker = strategy.parse_setup(setup)\n setups << strategy.config_buy_entry(setup) if strategy.buy?(sec_id)\n end\n end\n puts \"setups=#{setups}\"\n setups\n end", "def get_itunes_categories\n itunes_categories_raw = YAML::load( File.open( \"#{RAILS_ROOT}/config/iTunes.yml\" ) )\n itunes_categories = []\n itunes_categories_raw.keys.sort.each do |cat|\n itunes_categories.push cat => itunes_categories_raw[cat]\n end\n return itunes_categories\n end", "def get_app_file_list()\n if !File.directory?($itunes_dir) and !File.symlink?($itunes_dir)\n puts \"Could not find iTunes directory \"+$itunes_dir\n exit\n end\n app_dir = $itunes_dir+\"/iTunes Media/Mobile Applications\"\n if !File.directory?(app_dir) and !File.symlink?(app_dir)\n puts \"Could not find Mobile Applications directory \"+app_dir\n exit\n end\n file_list = Dir.entries(app_dir)\n return file_list\nend", "def list_songs \n self.lib.songs.each do |song|\n puts song.to_s_simple\n end\n end", "def sources\n unless @sources\n\trequire_gem(\"sources\")\n\t@sources = Gem.sources\n end\n @sources\n end", "def sources #:nodoc:\n @sources.map{ |source| source.call }.flatten\n end", "def sources_data\n sources_url = Api.gnews_path('sources')\n call_gnews_url(sources_url).parse\n end", "def sources\n @settings.sources.to_a.inject({}) do |result, (source_id, source)|\n result[source_id] = source[:adapter].configuration\n result\n end\n end", "def tracks\n @tracks ||= begin\n assets_directory = File.join File.expand_path('../../../', __FILE__), 'assets'\n\n Dir.glob(File.join(assets_directory, '*.mp3')).map do |file|\n \"http://#{ip}:#{Ghosty::Settings.port}/#{File.basename(file)}\"\n end\n end\n end", "def albums\n Dir[_(\"*\")].collect do |alb| \n album(File.basename(alb))\n end\n end", "def get_sources(opts = {})\n data, _status_code, _headers = get_sources_with_http_info(opts)\n data\n end", "def sources(sources = nil)\n @sources.assign(sources) if sources\n @sources\n end", "def sources(opts)\n if opts.edit\n path = File.expand_path(Config.instance.options['sources']['path'])\n Config.instance.open_file(path)\n else\n sources = Sources.instance\n sources.parse(@sources)\n sources_list_dl(sources, opts)\n end\n end", "def find_all_storenames\n\n WiStore.find(:all).collect do |store|\n store.name\n end\n end", "def test_fortune_from_each_source\n sources = LinuxFortune.get_sources\n fortunes = []\n sources.each do |src|\n fortunes << src.fortune\n assert fortunes.size > 0\n #puts \"#{fortunes.last.source} --- #{src.fullpath}\"\n assert fortunes.last.source == src.fullpath\n end\n end", "def catalogs\n [\"#{unit.id}-#{environment}.plist\"]\n end", "def get_sources(workdir) # rubocop:disable Metrics/AbcSize\n sources.each do |source|\n src = Vanagon::Component::Source.source(\n source.url, workdir: workdir, ref: source.ref, sum: source.sum\n )\n src.fetch\n src.verify\n if source.erb\n erb_file(src.file, File.join(File.dirname(src.file), File.basename(src.file, \".erb\")), true)\n end\n # set src.file to only be populated with the basename instead of entire file path\n src.file = File.basename(src.url)\n extract_with << src.extract(platform.tar) if src.respond_to? :extract\n end\n end", "def all_works\n [ScannedResource, ScannedMap, RasterResource, VectorResource, Numismatics::Issue, Playlist]\n end", "def sources\n return @sources if @sources\n\n @sources = ['_config.yml']\n @sources << flags.split(' ').map do |flag|\n file = File.join(@site.config['source'], flag.split('=').last)\n file if File.exist? file\n end\n\n @sources << posts.map(&:path)\n\n @sources = @sources.flatten.compact\n end", "def sources(source: nil)\n params = {\n source: source\n }.compact\n\n _get(\"/account/sources\", params) { |json| json }\n end", "def source_type_options_all\n options = []\n Description.all_source_types.each do |type|\n options << [:\"form_description_source_#{type}\".l, type]\n end\n options\n end", "def build_sources\n sources = [File.join(source_dir, 'jasmine-webos-core.js'),\n File.join(source_dir, 'proxy-app-assistant.js')]\n\n sources += Dir.glob(\"#{source_dir}/**/*.js\").reject { |f| sources.include?(f) }.sort\n sources += Dir.glob(\"#{plugin_dir}/spec/helpers/*.js\")\n sources\nend", "def possible_plays\n [:paper, :rock, :scissors, :spock, :lizard]\n end", "def sources\n source_array = []\n self.questions.each do |q|\n if q.class == MatrixQuestion\n q.choice_questions.each {|cq| source_array << [\"#{cq.question_content.id},QuestionContent\", \"#{q.question_content.statement}: #{cq.question_content.statement}(matrix answer)\"]}\n else\n source_array << [\"#{q.question_content.id},QuestionContent\", \"#{q.question_content.statement}(Question)\"]\n end\n end\n source_array\n end", "def sources\n [root_source] + reference_sources\n end", "def search_sources(opts = {})\n data, _status_code, _headers = search_sources_with_http_info(opts)\n data\n end", "def sounds_list(params = {})\n get \"sounds\", params\n end", "def plays_genres\n genres = Array.new\n self.genres.each do |genre|\n genres << genre.printable\n end\n genres.uniq\n end", "def all_chans_zipped\n new_list = []\n Snd.sounds.each do |snd|\n channels(snd).times do |chn|\n new_list.push([snd, chn])\n end\n end\n new_list\n end", "def index\n @founding_sources = FoundingSource.all\n end", "def genres\n songs.collect{|song| song.genre}.uniq\n end", "def get_suggestions(*artists)\n list = Echowrap.playlist_static(artist: artists, \n type: 'catalog',\n results: 100, \n limited_interactivity: true,\n seed_catalog: ECHONEST_KEYS['TASTE_PROFILE_ID'])\n final_list = []\n list.each do |song|\n final_list << PL.db.get_song_by_echonest_id(song.id) unless !PL.db.get_song_by_echonest_id(song.id)\n end\n final_list\n end", "def songs\n @songs ||= Song.where(:artist => info(:name))\n end", "def genres\n songs.map{|song|song.genre}.uniq\n end", "def genres \n songs.collect{ |s| s.genre }.uniq #returns collection of genres for all of the artist's songs/ does not return duplicate genres/ collects genres\n end", "def component_sources component,platform\n @component_sources||={}\n hp_dir=File.join(@base_dir,'src','hand',platform,component)\n hc_dir=File.join(@base_dir,'src','hand','common',component)\n gp_dir=File.join(@base_dir,'src','gen',platform,component)\n gc_dir=File.join(@base_dir,'src','gen','common',component)\n @component_sources[\"#{component}_#{platform}\"]||=FileList[\"#{hp_dir}/*.c\",\"#{hc_dir}/*.c\",\"#{gp_dir}/*.c\",\"#{gc_dir}/*.c\"]\n return @component_sources[\"#{component}_#{platform}\"]\n end", "def source_array\n @source_array ||=\n if new_resource.source.nil?\n package_name_array.map { nil }\n else\n [ new_resource.source ].flatten\n end\n end", "def get_all_character_uris\n\t\t\tget_all_character_apis.map { |api| uri(api) }\n end", "def included_sources\n return @included_sources\n end", "def sources\n @sources ||= ApiFactory.new 'Repos::Sources'\n end", "def scrobbles\n tracks_url_for(@user) { |url| tracks_for_url(url) }.flatten\n end", "def available_raws\n raws.keys\n end", "def browser_sources\n sources = [File.join(source_dir, 'jasmine-webos-core.js'),\n File.join(plugin_dir, 'spec/helpers/test-mojo.js')]\n sources += Dir.glob(\"#{source_dir}/browser/**/*.js\")\n sources += Dir.glob(\"#{plugin_dir}/spec/helpers/*.js\")\n sources.uniq\nend", "def get_tracks_list\n return map { |iter| iter[TTV_XLINK] }\n end", "def list\n for song in self.songs\n puts song.name\n end\n end", "def songs\n # @@songs.select { |song| song.name == @name }\n @songs\n end", "def account_sources(source)\n get('account/sources', {'source' => source})\n end", "def get_source_list(cc)\n src = %w{\n src/common/filter.c \n src/common/knote.c \n src/common/kevent.c\n src/common/kqueue.c\n }\n\n if Platform.is_solaris?\n src.push 'src/solaris/kevent.c',\n 'src/solaris/timer.c'\n 'src/solaris/user.c'\n end\n\n if Platform.is_linux?\n src.push 'src/posix/kevent.c',\n 'src/posix/signal.c',\n 'src/linux/proc.c',\n 'src/linux/socket.c',\n 'src/posix/user.c',\n 'src/linux/vnode.c',\n 'src/linux/eventfd.c'\n\n # Android does not have timerfd support\n if SystemType.host =~ /android/\n src.push 'src/posix/timer.c'\n else\n src.push 'src/linux/timer.c'\n end \n end\n\n src\nend", "def provides\n sort!\n sources.map {|s| s.provides }.flatten\n end", "def items\n return [\n {\n :source => \"~/Dropbox/Airtype/dotfiles/emacs/.emacs.d\",\n :target => \"~/.emacs.d\"\n },\n {\n :source => \"~/Dropbox/Airtype/dotfiles/emacs/.emacs\",\n :target => \"~/.emacs\"\n },\n {\n :source => \"~/Dropbox/Airtype/todo.org\",\n :target => \"~/Desktop/todo.org\"\n }\n ]\nend", "def sources_list_dl(sources, opts)\n mods = opts.categories ? sources.parse_mods(opts.categories) : nil\n sources.apply_mods(mods) if mods\n\n if opts.download\n Storage.instance.download_sources\n else\n IO.instance.sources_print(sources.sources)\n end\n end", "def main\n doc = Nokogiri::HTML(open(START_URI))\n dirs_to_search = doc.css('a').map{|x|x[:href]}.grep(%r{/SolaceSounds/SolaceSounds})\n\n streams_to_rip = []\n\n dirs_to_search.each do |dir|\n puts \"Searching #{HOST}#{dir}\"\n\n # don't overwhelm the server\n sleep 1\n\n subdir = Nokogiri::HTML(open(HOST + dir))\n streams_to_grab = subdir.css('a').map{|x|x[:href]}.grep(%r{\\.mp3})\n streams_to_rip.concat(streams_to_grab)\n end\n\n # we've found all of the mp3 streams, now we grab them\n streams_to_rip.each do |url|\n if stream_already_downloaded(url)\n puts \"skipping url: #{url}\"\n next\n end\n rip_stream(url)\n move_ripped_file(url)\n set_mp3_tags(url)\n end\nend", "def files_from_sources(sources)\n ext_glob = Array(self.class.source_ext).join(',')\n sources.flatten.map { |source| File.directory?(source) ? FileList[\"#{source}/**/*.{#{ext_glob}}\"] : source }.\n flatten.reject { |file| File.directory?(file) }.map { |file| File.expand_path(file) }.uniq\n end", "def get_source_and_collection\n source_uri = N::URI.from_encoded(params[:source])\n collection_uri = N::URI.from_encoded(params[:collection])\n source = TaliaCore::ActiveSource.find(source_uri)\n collection = TaliaCollection.find(collection_uri)\n @source_id = params[:source]\n @source = TaliaSource.find(source.id)\n [ source, collection ]\n end", "def files\n @files ||= preferred_sources([@path])\n end", "def genres\n @songs.collect do |song|\n song.genre\n end.uniq\n end", "def list_songs_by_band(term)\n response = search_itunes(term)\n results = response[\"results\"]\n results.each do |song|\n puts song[\"trackName\"]\n end\nend", "def genres\n search_by_text('жанры').split(', ')\n end", "def list(all = false)\n list = {}\n\n file = all ? 'specs' : 'latest_specs'\n\n Gem.sources.each do |source_uri|\n source_uri = URI.parse source_uri\n\n if all and @specs.include? source_uri then\n list[source_uri] = @specs[source_uri]\n elsif @latest_specs.include? source_uri then\n list[source_uri] = @latest_specs[source_uri]\n else\n specs = load_specs source_uri, file\n\n cache = all ? @specs : @latest_specs\n\n cache[source_uri] = specs\n list[source_uri] = specs\n end\n end\n\n list\n end", "def songs\n MusicImporter.new(path).print_songs\n end", "def genres\n @songs.collect{|song| song.genre }.uniq\n end" ]
[ "0.6552776", "0.6322853", "0.6287629", "0.6234077", "0.6230914", "0.6189557", "0.61244214", "0.60867286", "0.59995264", "0.59594893", "0.59584624", "0.5896845", "0.585722", "0.58501995", "0.58476985", "0.5754696", "0.5724293", "0.57051915", "0.5647997", "0.5635674", "0.5615903", "0.56019104", "0.55977964", "0.5561476", "0.55613613", "0.5538547", "0.5493095", "0.54899406", "0.5488291", "0.5466969", "0.5462855", "0.5433404", "0.54294676", "0.53940153", "0.5374999", "0.5372434", "0.53504443", "0.5341927", "0.53348964", "0.53273463", "0.5323295", "0.5302785", "0.5277311", "0.5262876", "0.525537", "0.5247024", "0.5242078", "0.52413875", "0.5225704", "0.52139235", "0.51852435", "0.51829714", "0.5157922", "0.51482105", "0.51417464", "0.51254785", "0.5097715", "0.5093366", "0.50883865", "0.508727", "0.5080938", "0.50768477", "0.507678", "0.5058859", "0.5054783", "0.5051112", "0.50502574", "0.5036297", "0.503118", "0.50288725", "0.50225186", "0.5004505", "0.50035405", "0.49978045", "0.49957207", "0.4994084", "0.49923116", "0.4991678", "0.49912363", "0.4982247", "0.49816298", "0.4978792", "0.49653557", "0.4962979", "0.49579668", "0.49479198", "0.49462277", "0.4943181", "0.4922975", "0.49228483", "0.491389", "0.49106577", "0.49098545", "0.4909785", "0.4909577", "0.48992947", "0.48982504", "0.48979864", "0.48973167", "0.48939836" ]
0.83333707
0
Find a playlist by its name
def find_playlist_by_name name @playlists.each do |playlist| return playlist.index if name == playlist.name end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_playlist\n @playlist = Playlist.find(params[:id])\n end", "def item_find\n find(playlist_url(@response.old_index))\n end", "def find_by_name(name)\r\n @internal_list.find {|album| album.name == name}\r\n end", "def find_playlists_for_song(song_name)\n track_array = self.find_track_ids_for_song_name(song_name)\n # This array contains matching playlists id for track_ids\n matching_playlists_array = []\n # Enumerate through each track id for the song name \n track_array.each do |a_track_id|\n\n # Enumerate through playlists\n self.lib.playlists.each_value do |playlist|\n if playlist.track_ids.include?(a_track_id)\n matching_playlists_array << playlist.metadata['playlist_id']\n end\n end \n end \n puts matching_playlists_array\n matching_playlists_array\n end", "def find_song_by_title(songs, title)\n songs.find do |song|\n song[:title] == title\n end\n end", "def find_by_name(name)\n #@@artist.detect{|a| a.name == name}\n all.detect{|a| a.name == name}\n end", "def find(name)\n list[name]\n end", "def find(name, protocol_folder = nil)\n end", "def get_playlist!(user, playlist_title)\n playlist = user.playlists.select { |p| p.name == playlist_title} \n tracks = self.get_tracks!\n\n if playlist.empty?\n # Let's make a new playlist then!\n playlist = user.create_playlist!(playlist_title) \n playlist.add_tracks!(tracks) \n else\n # Pre-existing playlist\n # @todo This is pretty damn ugly!\n id = playlist.map { |p| p.id } \n playlist = RSpotify::Playlist.find(user.id, id.first)\n tracks = tracks & playlist.tracks\n playlist.add_tracks!(tracks) unless tracks.empty?\n end\n\n return playlist.uri\n end", "def item_by_name\n IITPlaylist.new(@ole.ItemByName)\n end", "def find_player(name)\n for footballer in @players\n return footballer if @players.include?(name)\n end\n end", "def show\n @playlist = Playlist.includes(:items).find(params[:id])\n end", "def playlist\n split_and_hash(send_request('playlistinfo'))\n end", "def find(name); end", "def find_by_name(name)\n return nil unless name.present?\n names.select {|e| e == name}\n end", "def kind\n :playlist\n end", "def find_player(name)\n all_players.find {|player| name == player.fetch(:player_name)}\nend", "def player_by_name name\n @players.select {|p| p.name == name}.first\n end", "def set_playlist\n\t\tnot_found('playlist') and return unless Playlist.exists? params[:id]\n\t\t@playlist = Playlist.find(params[:id])\n\tend", "def find_by_name(name)\n find_by('name', name)\n end", "def find_by_name(name)\n end", "def search_for_track_name(tracks, search_name)\n\tfound_index = -1\n\ti = 0\n\twhile i < tracks.length\n\t\ttrack = tracks[i]\n\t\tif track.name.downcase.chomp.include? search_name.chomp.downcase\n\t\t\tfound_index = i\n\t\tend\n\t\ti = i + 1\n\tend\n\n found_index\nend", "def set_playlist\n @playlist = Playlist.find_by(id:params[:id])\n end", "def find_by_name(name)\n # this works because of `def item.=='\n item = @set.find { |c| c == name }\n item\n end", "def player(player_name)\n players.find{|player| player.name == player_name}\n end", "def have_song(room, song)\n for track in room.get_song_list\n if track == song\n return song\n end\n end\n return \"Song not available.\"\n end", "def playlist_id\n @ole.playlistID\n end", "def playlist_id\n @ole.playlistID\n end", "def playlist_id\n @ole.playlistID\n end", "def playlist_id\n @ole.playlistID\n end", "def show\n\t\t@playlist = Playlist.find(params[:id])\n\tend", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def search_song\n puts \"Enter the song name:\"\n song = get_user_input.titleize\n song_instance = Song.find_by(name: song)\n while !song_instance do\n puts \"Invalid, try again:\"\n song = get_user_input.titleize\n song_instance = Song.find_by(name: song)\n end\n return song_instance.name\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def set_playlist\n @playlist = Playlist.find(params[:playlist_id])\n end", "def set_playlist\n @playlist = Playlist.find params[:id]\n end", "def list(name)\n lists.find { |list| ::File.basename(list.url) == name }\n end", "def set_playlist\n @playlist = Playlist.find(params[:id])\n end", "def find_by_name(name)\n for item in self.collection\n return item if item.name == name\n end\n\n # didn't find item in collection, return nil\n return nil\n end", "def playlist(options={})\n get(:session, {:method => \"radio.getPlaylist\"}.merge(options))\n end", "def search_for_track_name(tracks, search_string)\nputs (\"Searching for track: \" + search_string)\nfound_index = -1\ni = 0\n\twhile (i < tracks.length)\n\t\t\t# track = tracks[i]\n\t\t\tif (tracks[i].name.chomp == search_string.chomp)\n\t\t\t\tfound_index = i\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\tfound_index\nend", "def search_for_title(name)\n raise 'You are trying to search a file with NO name' if name.nil? || name.empty?\n client = google_api_client\n result = client.list_files(page_size: 1,\n q: \"name contains '#{ name }' and '#{ find_public_folder }' in parents\",\n fields: 'files(id, name)'\n )\n if result.files.length > 0\n result.files[0].id\n else\n nil\n end\n end", "def find_item(name)\n items.find do |item|\n item.name == name ||\n item.short_name.gsub('…','') == name.gsub('…','')\n end\n end", "def search_all_playlists # allows users to select from all playlists \n choices = self.create_choices_hash(Playlist.all)\n action = @@prompt.select(\"Choose a playlist:\", choices)\n if action == choices.size\n self.search_playlists\n else\n playlist = Playlist.find_by_name(choices.key(action)).first\n self.playlist_options(playlist)\n end\n end", "def find_player_by_name!(name)\n find_player_by_name(name) || raise(MissingTarget, name)\n end", "def playlist(url: nil, owner_id: nil, playlist_id: nil, access_hash: nil,\n up_to: MAXIMUM_PLAYLIST_SIZE)\n owner_id, playlist_id, access_hash = Utility::PlaylistUrlParser.call(url) if url\n return if owner_id.nil? || playlist_id.nil?\n\n Utility::PlaylistLoader.call(agent, id, owner_id, playlist_id, access_hash, up_to)\n end", "def show_songs_in_playlist\n \n file_name = params[:file_name]\n\n @song_list = []\n File.read(\"#{Rails.root}/public/Playlist/#{params[:file_name]}\").each_line do |line|\n @song_list << line.chop\n end\n end", "def find(data)\n @items.each do |item|\n return item if item.title == data\n end\n return nil\n end", "def find(query = '', type: :audio)\n return [] if query.empty?\n\n page = Request::Search.new(query, id)\n page.call(agent)\n\n case type\n when :audio, :audios then page.audios\n when :playlist, :playlists then page.playlists\n else []\n end\n end", "def playlist\n {\n name: name,\n format: FORMAT,\n output_keys: output_keys\n }\n end", "def search_for_track_name(tracks, search_string)\n # search_string = gets.chomp \n index = 0\n while (index < tracks.length)\n if (tracks[index].name == search_string)\n return index\n end\n \tindex += 1 \n end \n return -1\nend", "def add_song_by_name(name)\n song = Song.new(name)\n add_song(song)\n \n # -TEST-\n # adele.add_song_by_name(\"Rolling in the Deep\")\n # expect(adele.songs.last.name).to eq(\"Rolling in the Deep\")\n # expect(adele.songs.last.artist).to eq(adele)\n end", "def playlist_params\n params.require(:playlist).permit(:name)\n end", "def find_song(artist, url_slug)\n\n\t\tartist.songs.uniq.each do |song|\n\t\t\tif song.song_url_slug == url_slug\n\t\t\t\t@song = song\n\n\t\t\telse\n\n\t\t\tend\n\t\tend\n\tend", "def player(name)\n players.detect { |p| p.name == name }\n end", "def search(cmd)\n songs = select_songs_with cmd\n\n if songs.empty?\n failure('It matches not even one')\n else\n playlists[:focus] <= songs\n playlists[:search] <= songs\n success(songs: songs, response_type: :songs)\n end\n end", "def update_playlist(id, new_name = nil, new_description = nil, new_public = nil)\n update_playlists [{id: id, name: new_name, description: new_description, public: new_public}][0]\n end", "def create_playlist(name)\n uri = 'https://api.deezer.com/user/me/playlists'\n headers = {params: {access_token: @access_token, title: name}}\n RestWrapper.perform_request(uri, :post, headers)\n end", "def set_playlist_song\n @playlist_song = PlaylistSong.find(params[:id])\n end", "def find_song_by_name(user_input, songs)\n songs.each { |song| return true if user_input == song }\n\n false\nend", "def find_by_name(name)\n Discovery.find_by_name(name)\n end", "def find_by_name(name = nil, &block)\n all.find { |p| p.name == name.to_s }\n end", "def search_video(aTitle)\n result = catalogue.find { |video| video.title.strip == aTitle.strip }\n if result.nil?\n msg = \"Video with title '#{aTitle}' isn't in the catalogue.\"\n $stderr.puts msg\n end\n\n return result\n end", "def song_plays\n SongPlay.where(:song_path => path)\n end", "def find(name)\n m = match(name)\n m.count == 1 ? m[0] : nil\n end", "def playlist\n connection.write(\"playlist\")\n end", "def selected_playlist(value)\n @ole.SelectedPlaylist = value\n nil\n end", "def add_song_by_name(name)\n song = Song.new(name)\n @songs << song\n song.artist = self\n end", "def add_song_by_name(name)\n song = Song.new(name)\n @songs << song\n song.artist = self\n end", "def playlist_params\n params.require(:playlist).permit(:name, :player_id)\n end", "def find name\n object = objects.find { |o| o.name == name.to_s }\n end", "def search_songs(query)\n search('Songs', query)\n end", "def find(name)\n vertices.each do |vertex|\n return vertex if vertex.name == name\n end\n nil\n end", "def songs\n # @@songs.select { |song| song.name == @name }\n @songs\n end", "def playlist_items_list_by_playlist_id(service, part, **params)\n\n params = params.delete_if { |p, v| v == ''}\n response = service.list_playlist_items(part, params)\n # print_results(response)\n \nend", "def playlist_params\n params.require(:playlist).permit(:name)\n end", "def find_by_name(id)\n end", "def find_item (name)\n\tnamespace = self\n\twhile namespace\n\t break if namespace.has_key? name\n\t namespace = namespace.parent\n\tend\n\tnamespace\n end", "def find_by_name(planet)\n @planets.each do |item|\n if item.name.downcase == planet.downcase\n return item\n end\n end\n return false\n end", "def search_song\n song_query = @prompt.ask('What is the name of the song?'.colorize(:light_green))\n tracks = RSpotify::Track.search(song_query, limit: 5)\n cleaned_results = []\n tracks.each { |t| cleaned_results << \"#{t.name} by #{t.artists[0].name}\" }\n system('clear')\n cleaned_results << 'Back'\n selection = @prompt.select('Please select one of the search results:', cleaned_results).split(' by ')\n add_to_list if selection[0] == 'Back'\n store_song(selection)\n end", "def get_current_playlist\n\t\t@current_playlist ||= if params[:playlist_id].present?\n\t\t\tPlaylist.find(params[:playlist_id])\n\t\tend\n\tend", "def choose_lastfm_playlist\n last_created_playlist = playlists.last\n last_created_playlist[:tracks_count] >= DEEZER_MAX_PLAYLIST_TRACKS ? create_lastfm_playlist : last_created_playlist[:id]\n end", "def find_player(players, name)\n players.find do |player|\n player[:player_name] == name\n end\nend", "def add_song_by_name(name)\n song = Song.new(name)\n song.artist = self\n end", "def add_song_by_name(name)\n song = Song.new(name)\n song.artist = self\n end", "def set_Playlist(value)\n set_input(\"Playlist\", value)\n end", "def playlist\n IITPlaylist.new(@ole.Playlist)\n end", "def add_song_by_name(name)\n song = Song.new(name)\n song.artist = self\n @songs << song\n @@song_count += 1\n end", "def find_by_user\n playlists_by_user = Playlist.where(\"user_id = #{session[:user_id]}\")\n if playlists_by_user\n render json: { status: 200, playlists_by_user: playlists_by_user }\n else\n render json: { status: 500 }\n end\n end" ]
[ "0.69710803", "0.6940758", "0.68536437", "0.67400104", "0.647235", "0.643509", "0.6434064", "0.6405076", "0.6315739", "0.6255049", "0.6187526", "0.6138805", "0.6124344", "0.6102551", "0.60900825", "0.60815686", "0.60704964", "0.60665536", "0.60312784", "0.60115546", "0.6009602", "0.5998971", "0.59656745", "0.5953101", "0.5926896", "0.59187055", "0.59042454", "0.59042454", "0.59042454", "0.59042454", "0.59026116", "0.5900094", "0.5900094", "0.5900094", "0.58755106", "0.58735305", "0.58735305", "0.58735305", "0.58735305", "0.58735305", "0.58735305", "0.58735305", "0.58735305", "0.58735305", "0.58735305", "0.58521116", "0.5851693", "0.583399", "0.58330655", "0.5799782", "0.57985574", "0.5795873", "0.57794195", "0.57575697", "0.57520485", "0.5740915", "0.5731319", "0.5729639", "0.5729083", "0.57248634", "0.5723819", "0.5720089", "0.571125", "0.5710562", "0.5701589", "0.56826", "0.5679755", "0.56678927", "0.565953", "0.5634763", "0.5626331", "0.56231654", "0.56177515", "0.56163216", "0.5595441", "0.55886614", "0.5586069", "0.5573436", "0.5563549", "0.5555448", "0.55547917", "0.55431974", "0.554245", "0.55394274", "0.5530732", "0.55306846", "0.55302364", "0.5524077", "0.5518545", "0.55147886", "0.5513011", "0.55111295", "0.5501918", "0.5492508", "0.54922307", "0.54922307", "0.5477067", "0.54759675", "0.5472087", "0.5468828" ]
0.7819258
0
Find all the tracks with an empty location (aka path)
def find_dead_tracks playlist playlist.fileTracks.each do |track| next unless track.location == nil puts "Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}" @logger.info "Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}" #@dead_track_list << track end #return @dead_track_list end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def songs_never_played\n return @tracks.find_all {|s| s.play_count == 0}\n end", "def test_track_id_nil\n oh = LIBRARY.tracks.find_all {|s| s.track_id == nil}\n assert oh.none?\n end", "def get_empty_location()\n for i in 10..20\n if self.players.where(:location => i).length == 0\n return i\n end\n end\n end", "def get_empty_locs\n empty = []\n @board.each { |index, spot| empty.push(index) if spot.nil? }\n return empty\n end", "def get_tracks\n\t\ttracks = @client.get('/tracks', :limit => 6)\n\t\ttracks.each do |track|\n\t\t\tuser = @client.get('/users/' + track.user_id.to_s)\n\t\t\t\tif user.city.present? && user.country.present?\n\t\t\t\t\tgeocoding = Geocoder.search(\"#{user.city}, #{user.country}\").first\n\t\t\t\t\t# track.delete_if {geocoding.nil?}\n\t\t\t\t\tif geocoding\n\t\t\t\t\t\tlat = geocoding.data[\"geometry\"][\"location\"][\"lat\"] ? geocoding.data[\"geometry\"][\"location\"][\"lat\"] : ['51']\n\t\t\t\t\t\tlng = geocoding.data[\"geometry\"][\"location\"][\"lng\"] ? geocoding.data[\"geometry\"][\"location\"][\"lng\"] : ['0.1']\n\t\t\t\t\tend\n\t\t\t\t\t@filtered_tracks << { track: track, user: user, coordinates: [lat, lng] }\n\t\t\t\tend\n\t\tend\n\t\t@filtered_tracks\n\tend", "def search_for_no_results\n visit('/locations?keyword=asdfdsggfdg')\n end", "def track_ids\n tracks || []\n end", "def find_songs_without_key(a_key)\n songs_without_key = self.lib.songs.find_all do |song|\n song.metadata.has_key?(a_key) == false\n end\n songs_without_key\n end", "def clear\n @track = []\n home\n end", "def clear\n home\n self.track = []\n end", "def test_find_route_empty\n @south_america = Init.set_up_map('../JSON/test_data.json')\n santiago = @south_america.vertices[@south_america.metros['santiago']]\n route = santiago.find_route(@south_america.metros['bogota'])\n assert_equal(0, route.length)\n assert_instance_of(Array, route)\n end", "def rem_dead_tracks playlist\n begin\n\t playlist.fileTracks.each do |track|\n\t #puts \"#{track.index}: #{track.location}\"\n\t next unless track.location == nil \n\t puts \"Deleting dead track: #{track.artist} - #{track.album} - #{track.name}\"\n\t @logger.info \"Deleting dead track: #{track.artist} - #{track.album} - #{track.name}\"\n\t track.delete\n\t end\n\t rescue Exception => e\n puts e.message\n end\n end", "def current_track_ids\n tracks.where.not(id: nil).ids\n end", "def track_artists\n @tracks.collect{ |t| t.artist }.compact.uniq\n end", "def prune\r\n NavLocationLens.new @nav, @locs.uniq\r\n end", "def get_tracks!\n tracks = RSpotify::Track.search(self.keyword, limit: 50, offset: 0).sort_by(&:popularity)\n\n tracks.delete_if { |t| t.popularity < 45 }\n tracks = tracks.uniq { |t| t.artists.first.name } \n\n raise 'The playlist could not be generated' if tracks.size < 4\n return tracks.reverse\n end", "def locations_around\n locations_within_proximity.where.not(id: id)\n end", "def test_locations_is_empty\n\t\tassert_equal [], @road.locations\n\tend", "def pick_empty(locations)\n locations.each do |location|\n return location if @board.square(*location).nil?\n end\n nil\n end", "def test_that_you_may_filter_to_single_track\n getting '/v2/exercises?tracks=fruit'\n\n returns_tracks %w( fruit )\n end", "def empty_tracks_into_output(track)\n until track.empty?\n output_text << end_track(track1)\n output_text << end_track(track2)\n output_text << end_track(track3)\n end\n end", "def track_types\n [\"null_track\"]\n end", "def test_location_no_neighbors\n assert_equal @l1.neighbors, [] # pass\n end", "def get_tracks search\n sa = search.split(' ')\n\n if sa.size > 1\n case sa.first\n when 'u' \n sa.shift\n @sc_client.User.find(sa.join('-')).tracks\n when 't'\n sa.shift\n @sc_client.Track.find(:all,:params => { :q => sa.join('-') } )\n else\n @sc_client.Track.find(:all,:params => { :q => sa.join('-')} )\n end\n else\n @sc_client.Track.find(:all,:params => { :q => search } )\n end\n end", "def clearTrack\n @points = []\n end", "def search_for_location_without_address\n visit('locations?org_name=Location+with+no+phone')\n end", "def song_plays\n SongPlay.where(:song_path => path)\n end", "def audio_tracks\n tracks.select { |t| t.audio? }\n end", "def audio_tracks\n tracks.select { |t| t.audio? }\n end", "def test_location_connections_empty\n assert @loc1.neighbors.empty?\n end", "def delete_blank_paths\n self.each { |v| v.delete_blank_paths if v.respond_to?(:delete_blank_paths) }\n self.delete_blanks\n end", "def empty?\n @directions.empty?\n end", "def all_artists\n (track_artists() + artist()).compact.uniq\n end", "def locations\n # blank\n end", "def video_tracks\n tracks.select { |t| t.video? }\n end", "def video_tracks\n tracks.select { |t| t.video? }\n end", "def ignorable_paths\n []\n end", "def ids_not_in_loc\n @ids_not_in_loc ||= begin\n keys_films_dis = films_dis.keys.sort\n keys_films_loc = films_loc.keys.sort\n films_out = Array::new\n while fid_dis = keys_films_dis.shift\n cur_loc = keys_films_loc.first\n if cur_loc.nil?\n films_out << fid_dis\n elsif fid_dis < cur_loc\n films_out << fid_dis\n else\n cur_loc = keys_films_loc.shift\n until fid_dis == cur_loc\n films_out << cur_loc\n cur_loc = keys_films_loc.shift\n end\n end\n end\n films_out\n end\n end", "def tracks\n search_children children\n end", "def paths_forced_not_null_by_filters\n @filters.map {|filter| filter.arguments_forced_not_null.map {|dp| dp.ancestors}}.flatten.uniq\n end", "def a_track\n @track = []\n end", "def empty_location?(location)\n return @state[location[0]][location[1]] == nil\n end", "def find_empty_positions\n empty_positions = Set.new\n (0..@board.size-1).each {|i|\n (0..@board[i].count-1).each {|j|\n if @board[i][j] == '[ ]'\n empty_positions.add([i, j])\n end\n }\n }\n empty_positions\n end", "def empty?\n coordinates.empty?\n end", "def query\n { :locations => [] }\n end", "def initialize dir, tracks\n @path = dir\n\n @files = tracks.map { |e| e }\n\n @selected_files = @files.slice(0, @files.size).to_set\n end", "def locations\n unless defined?(@locations)\n @locations=[]\n for loc in Location.order(\"id ASC\").includes(:bottom_right_coordinate, :top_left_coordinate)\n @locations << loc if do_overlap_with?(loc.area)\n end \n end \n @locations\n end", "def tracked_files\n all_files.reject { |f| ignore_matcher.matched?(f) }\n end", "def party_tracks\n party_tracks = []\n songs_ordered.each do |song|\n party_tracks << song.track_key.gsub(\"spotify:track:\",\"\")\n end\n party_tracks.join(',')\n end", "def empty?\n @artists.empty?\n end", "def search_unknown\n BFS.search(UnknownFinder.new(@droid, @map))\n end", "def cleanup()\n Track.where(scanned: false).delete_all()\n Disc.delete_all(\"id NOT IN (SELECT DISTINCT(disc_id) FROM tracks)\")\n Album.delete_all(\"id NOT IN (SELECT DISTINCT(album_id) FROM tracks)\")\n Artist.delete_all(\"id NOT IN (SELECT DISTINCT(artist_id) FROM tracks)\")\n end", "def find_empty_batch\n batches.empty_batch\n end", "def find_location\n @locations = Location.where('trip_id IS ?', nil).order(created_at: :desc).paginate(page: params[:page], per_page: 15)\n end", "def empty_neighbours point\n neighbours(point).select do |(x, y)|\n at(x, y) < 0\n end\n end", "def params_without_locations\n return tour_params.except(\n # Locations in the itinerary are not stored in the tour itself\n # But rather in explicit relationships\n # This way, if we change the number of possible locations in the tour\n # we do not need to change anything about our models\n :location1,\n :location2,\n :location3,\n :location4,\n :location5,\n :location6,\n :location7,\n :location8,\n :location9,\n :location10\n )\n end", "def songs\n @songs ||= Song.where(:artist => info(:name))\n end", "def find_none(conditions={}, &block)\n all.select { |item| match_none(item, conditions, &block) }\n end", "def songs_found\n get_songs\n return @songs\n end", "def find_empty\n @file.each do |item|\n # Find items without field\n if !item[@check_field]\n @broken_ids.push(item[@id_field])\n\n # Find empty items\n elsif item[@check_field].empty?\n @broken_ids.push(item[@id_field])\n end\n end\n\n return JSON.pretty_generate(@broken_ids)\n end", "def autocomplete_known_uri_predicates\n @known_uris = search_known_uris_by_name_or_uri(params[:term])\n @known_uris.delete_if{ |ku| ku.uri_type_id != UriType.measurement.id || ! EOL::Sparql.connection.all_measurement_type_known_uris.include?(ku) }\n render_autocomplete_results\n end", "def text_tracks\n tracks.select { |t| t.text? }\n end", "def text_tracks\n tracks.select { |t| t.text? }\n end", "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 locations\n\t\t[]\n\tend", "def list_dubious_locations # :nologin:\n query = create_query(:Location, :all, :by => :name)\n show_selected_locations(query, :link_all_sorts => true,\n :action => :list_dubious_locations, :num_per_page => 1000)\n end", "def absolute_non_audio_file_paths\n @absolute_non_audio_file_paths ||= absolute_file_paths.reject { |p| audio_files.map(&:path).include?(p) }\n end", "def empty_spots\n spots = []\n\n board.each_with_index do |row, row_num|\n row.each_with_index do |column, column_num|\n if (!row && !column)\n empty_spot = {'row' => row_num, 'column' => column_num}\n spots.push(empty_spot)\n end\n end\n end\n\n spots\n end", "def map_locs\n [(lat.nil? ? nil : location)]\n end", "def search_tracks(terms, base = nil)\n return search_tracks_strict(terms, base) if terms.is_a?(Hash)\n\n terms = [terms] unless terms.is_a?(Enumerable)\n\n sql = 'title LIKE ? OR default_title LIKE ?' \\\n ' OR artist LIKE ? OR album LIKE ?'\n\n tracks = base.nil? ? Track.all : base\n terms.each do |term|\n escaped = escape_like(term)\n res = tracks.where(sql, *([escaped] * 4))\n\n return res if res.empty?\n tracks = res\n end\n\n tracks\n end", "def tracks=(tracks)\n tracks.each do |track|\n raise \"A track in the given array does not belong to this album.\" if !track.album.equal?(self)\n end\n \n @tracks = tracks\n end", "def ships\n MyShip.where(\"location ~= POINT(?)\", self.location)\n end", "def empty?\n @path.size == 0\n end", "def all_playlists\n playlists.unscope(where: :type).where(\"playlists.type IS NULL OR playlists.type = ?\", \"FavoritePlaylist\").order(:type)\n end", "def track_end track\n unless File.file?( extract_pth( track[:dict], \"Location\" ) )\n super track\n end\n end", "def empty?\n prune\n @store.empty?\n end", "def clear\n @known = []\n end", "def empty?\n self.results.empty?\n end", "def test_playlist_is_empty()\n assert_equal(0, @room.room_playlist())\n end", "def all\r\n\t\t\t\tself.find(:all, :conditions => 'parent_id IS NOT NULL', :order => 'path ASC')\r\n\t\t\tend", "def visit_location_with_no_address\n visit('locations/location-with-no-phone')\n end", "def clear!\n @paths = []\n end", "def checkInPlayList(tracks)\n\tuser = User.find(session[:user_id])\n\tplaylist = user.songs\n\tmySearchObj = {}\n\tmySearchArr = []\n tracks.each do |track|\n\t\tmySearchObj = {:title => track.title, :songid => track.id }\n\t\tif playlist.any?{|song| song.songid.to_i == track.id.to_i}\n\t\t\tmySearchObj[:inPlaylist] = true\n\t\telse \n\t\t\tmySearchObj[:inPlaylist] = false\n\t\tend\n\t mySearchArr.push(mySearchObj)\n\tend\n return mySearchArr\nend", "def search_tracks(search)\n return false if search.blank?\n result = self.class.get(\"/search?q=track:#{search}&type=track&limit=20\")\n result = result[\"tracks\"][\"items\"].map do |t| {\n artist: t[\"artists\"].first[\"name\"],\n album: t['album']['name'],\n track: t['name'],\n popularity: t['popularity']\n }\n end\n\n result = JSON.parse result.to_json\n end", "def related_songs\n unless self.spotify_track_id.nil?\n related_artists = self.spotify_track.artists.first.related_artists\n\n related_artists.shuffle[0..4].map do |artist|\n artist.top_tracks('IE').shuffle.first\n end.flatten\n else\n Array.new\n end\n\n\n end", "def _find_non_empty_plugins_scope(scope)\n fail \"NO PLUGIN SCOPE\" if scope.nil?\n _find_non_empty_scope(:plugin, scope)\n end", "def tracks\n reload\n @tracks\n end", "def test_room_starts_with_no_songs\n assert_equal(0, @room.song_count())\n end", "def test_nodes_is_empty\n\t\tassert_equal [], @location.nodes\n\tend", "def test_make_paths_nmap_empty\n @grapher.nmap = []\n assert_equal [], @grapher.make_paths\n end", "def songs \n Song.all.select do |e|\n e.artist == self\n end\n end", "def proper_items\n items.where.not(sort: ['self', 'pdf_destination'])\n .where.not(start_time: nil)\n end", "def tracks\n args = [country]\n args << {:location => city} if city\n link :top_tracks, :Track, *args\n end", "def search_tracks(q, page=1)\n \t response_body = get_body(http_get(\"http://ws.spotify.com/search/1/track.json?q=#{CGI.escape(q)}&page=#{page}\"))\n \t json = ActiveSupport::JSON.decode(response_body)\n to_tracks(json[\"tracks\"])\n \tend", "def checkout_locations\n locations = kits.collect { |k| k.location }\n locations.uniq!\n locations.select { |l| l.business_hours.count > 0 }\n end", "def search( params )\n xml = LastFM.get( \"track.search\", params )\n xml.find('results/trackmatches/track').map do |track|\n LastFM::Track.from_xml( track )\n end\n end", "def songs\n Song.all.select {|s| s.artist == self}\n end", "def empty?\n @vertices.empty?\n end", "def empty?\n @vertices.empty?\n end", "def is_tracks_collection_start\n return ( 'tracks' == @top_level_key ) &&\n ( \"/plist/dict/dict\" == @breadcrumb )\n end" ]
[ "0.6371481", "0.629223", "0.6066787", "0.60268354", "0.5981722", "0.5958237", "0.58627117", "0.55814177", "0.5577122", "0.550616", "0.5488234", "0.5453588", "0.5451669", "0.541234", "0.53852075", "0.5383593", "0.5358553", "0.53521633", "0.5313146", "0.527729", "0.5251823", "0.5250211", "0.5249351", "0.5212226", "0.51937693", "0.518738", "0.5168895", "0.5167404", "0.5167404", "0.51541394", "0.5150126", "0.51308334", "0.51159453", "0.50798845", "0.50658613", "0.50658613", "0.5064582", "0.5056005", "0.50557595", "0.5053912", "0.5024348", "0.5016884", "0.50092244", "0.50029755", "0.4998034", "0.49909168", "0.4983172", "0.4981185", "0.49714297", "0.49691048", "0.49645233", "0.49457642", "0.49272326", "0.4918369", "0.49170986", "0.49101576", "0.49093112", "0.49023762", "0.4897126", "0.48929566", "0.48915055", "0.48820755", "0.48820755", "0.4869448", "0.48614964", "0.48602948", "0.4858915", "0.48557678", "0.48526192", "0.48476243", "0.48377746", "0.4832259", "0.4822401", "0.48193365", "0.48084393", "0.48042032", "0.4802245", "0.47979853", "0.47848424", "0.47823447", "0.47810847", "0.47791582", "0.47751555", "0.47691017", "0.4764983", "0.47624016", "0.47571525", "0.4756121", "0.47503588", "0.47496167", "0.47466946", "0.47466603", "0.47419178", "0.47413474", "0.47394574", "0.47348905", "0.47302496", "0.47184807", "0.47184807", "0.47176316" ]
0.59118336
6
Return the number of dead tracks
def count_dead_tracks @dead_track_list.length end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def track_count\n return @tracks.length\n end", "def track_count\n self.tracks.count\n end", "def num_of_tracks\n\t\t@tracks.count\t \n\tend", "def incomplete_count\n incomplete.count\n end", "def number_of_tracklists\n tracklists.size\n end", "def track_count\n @ole.TrackCount\n end", "def number_of_tracks(talks)\n @total_talks_time = Talk.computeTotalTime(talks)\n\n quotient = @total_talks_time / Track.maxTrackTime\n if @total_talks_time - (quotient * Track.maxTrackTime) >= Track.minTrackTime\n @number_of_tracks = quotient + 1\n else\n @number_of_tracks = quotient\n end\n end", "def num_players_missing\n num_players - game_players.count\n end", "def games_played\n games.size\n end", "def games_played\n games.size\n end", "def live_count\n @@units.select{|k,unit| unit.type == self::TYPE && unit.alive?}.length\n end", "def missing_count\n @missing_count ||= current_patient.records.status(Record::MISSING).count\n end", "def dead\n @dead ||= count('dead')\n end", "def not_visitors_count\n self.not_visitors.count\n end", "def find_dead_tracks playlist\n playlist.fileTracks.each do |track|\n next unless track.location == nil\n puts \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n @logger.info \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n #@dead_track_list << track\n end\n \n #return @dead_track_list\n end", "def songs_never_played\n return @tracks.find_all {|s| s.play_count == 0}\n end", "def games_played\n self.results.to_a.count\n end", "def shots_missed\n self.positions.where(water: true, shooted: true).count\n end", "def get_total_games_played\n return games.size\n end", "def count_incomplete\n return self.incomplete_tests.size\n end", "def no_of_losses\n @participants&.where(status: 'loss').count\n end", "def lots_count\t\t\n lots.count\n end", "def get_total_games_played\n\t\treturn games.size\n\tend", "def song_count\n return @songs.count\n end", "def num_known\n @num_known ||= worth_counting { count_known }\nend", "def number_of_songs()\n return songs.length\n end", "def number_of_songs()\n return songs.length\n end", "def uncovered_count\n not_covered_enough.select do |_, hits|\n CoverageStat.coverage_percent(hits).zero?\n end.size\n end", "def tracking_total_count\n link_tracking.count\n end", "def get_total_snpinfo_boxes\n return @snpinfo_tracks.length\n end", "def num_known\n @num_known ||= smart_count { count_known }\nend", "def songs_count\n \t@songs.count\n end", "def unknown_count\n (select &:unknown?).count\n end", "def song_count\n @song_count = 0 if @song_count.nil?\n @song_count\n end", "def count \n trips.length\n end", "def count_songs\n @songs.size\n end", "def hand_count\n @hand_count ||= 0\n end", "def hand_count\n @hand_count ||= 0\n end", "def num_not_advertised\n @hops.find_all { |hop| hop.prefix.nil? }.size\n end", "def track_count(value)\n @ole.TrackCount = value\n nil\n end", "def song_count\n self.songs.count\n end", "def off_times\n load_curve.count(&:zero?)\n end", "def playlist_count()\n return @playlist.length\n end", "def dinosaur_count\n @@count += 1\n end", "def playlist_count\n return @playlists.length\n end", "def start_track\r\n 0\r\n end", "def total_matches_played\n count = 0\n\n matches.each do |match|\n unless match.finalized_date == nil \n count += 1\n end\n end\n\n count\n end", "def game_objects_count\n @game_objects.count\n end", "def songs_count\n value = 0\n packs.each do |pack|\n value += pack.songs.count\n end\n value += songs.count\n end", "def taken(player)\n @taken[player].size\n end", "def rem_dead_tracks playlist\n begin\n\t playlist.fileTracks.each do |track|\n\t #puts \"#{track.index}: #{track.location}\"\n\t next unless track.location == nil \n\t puts \"Deleting dead track: #{track.artist} - #{track.album} - #{track.name}\"\n\t @logger.info \"Deleting dead track: #{track.artist} - #{track.album} - #{track.name}\"\n\t track.delete\n\t end\n\t rescue Exception => e\n puts e.message\n end\n end", "def num_non_responsive\n @hops.find_all { |hop| !hop.ping_responsive }.size\n end", "def data_count\n @episodes.sum { |_, v| v.length }\n end", "def long_tracks\n @tracks.select { |track| track.duration_ms > 240_000 }\n end", "def river_count\n return @fishes.count\nend", "def outdated_count\n outdated.count\n end", "def song_count\n self.lib.songs.count\n end", "def remaining_players\n losses.count { |_, v| v < MAX_LOSS_COUNT}\n end", "def played_count\n @ole.PlayedCount\n end", "def dinosaurus_count\n @@count += 1\n end", "def check_in_count()\n return @guests.length #guests array length\n end", "def count_passing\n return self.passing_tests.size\n end", "def hole_count\n holes.count\n end", "def dinosaurii_count\n @@count += 1\n end", "def count_pokemon(include_dead = true)\n return @boxes.sum do |box|\n box.count { |pokemon| pokemon && (include_dead || !pokemon.dead?) }\n end\n end", "def get_players_num\n\t\treturn @players.length\n\tend", "def ts_holds_count\n ts_holds = holds.where.not(status: ['cancelled'])\n ts_holds.present? ? ts_holds.sum(:quantity) : nil\n end", "def games_played\n @games_played = @games_played += 1\n end", "def number_of_events\n self.events.length\n end", "def count\n @forest.count(&:negative?)\n end", "def song_count\n # @artist = self\n # @artist.songs.count\n self.songs.count\n end", "def local_goals_live\n comments = self.details.goals.find(:all, :conditions =>\n {:club_id => self.local})\n count = 0\n\n comments.each do |c|\n if c.minute <= self.minute\n count += 1\n end\n end\n\n return count;\n\n end", "def count\n @deck.count\n end", "def view_count\n internal_video.view_count\n end", "def count\r\n @pitches.size\r\n end", "def count_ai_battler\n count = -1\n @battle_info.parties.each do |bank|\n count += bank.size\n end\n log_debug(\"Found #{count} AI\")\n return count\n end", "def backer_count\n self.pledges.count\n end", "def number_readied\n readied_cards.count\n end", "def remaining_count\n raw_history['results_remaining']\n end", "def amount_kills\n mutations.select(&:success?).length\n end", "def track_ids\n tracks || []\n end", "def num_votes \n @scores.reject { |a| a[:option] == 'absent' }.count\n end", "def pitch_counts\n games = pitcher_games\n pitches = pitches_for_games(games)\n counts = pitches.collect{|pitches| pitches.size}\n counts\n end", "def running_count(tracking_key)\n Resque.redis.get(running_count_key(tracking_key)).to_i\n end", "def track\n departure.track_number || TRACK_PLACEHOLDER\n end", "def tbs_turn_count\n $game_troop.turn_count\n end", "def total_hard_brakes\n self.inject(0) do |accum,trip|\n accum += trip.hard_brakes_count\n accum\n end\n end", "def trades_count\n trades.count\n end", "def find_alive(players)\n alive = []\n players.each do |player|\n alive << player if player[:is_shot] == false\n end\n alive.length\nend", "def badge_counter\n @badges.count { |badge| badge == true }\n end", "def guest_goals_live\n comments = self.details.goals.find(:all, :conditions =>\n {:club_id => self.guest})\n count = 0\n\n comments.each do |c|\n if c.minute <= self.minute\n count += 1\n end\n end\n\n return count;\n end", "def tally_frames(old=0)\n if !tss.empty?\n # puts \"returning hits count #{hits.count}\"\n return hits.count\n else\n result=0\n snd.each do |sn|\n result += hits.count*sn.tally_frames(old)\n end\n # puts \"all in result #{result}\"\n return result\n end\n end", "def count\n @deck.size\n end", "def num_missed_calls\n missed_contacts.count\n end", "def number_of_bettors\n if defined? @recent_goal.bets.count\n @recent_goal.bets.count\n else\n 0\n end \n end", "def count_jobs\n \tself.bugs.bug_has_closed.count\n end", "def nbSongs(xml)\n nbSongs = 0\n xml.xpath(\"//TrackNumber\").each { |track| nbSongs = nbSongs + 1}\n return nbSongs\nend", "def num_unknown\n @num_unknown ||= num_researched - num_known\nend", "def known_viruses_count_changes(scan)\n rows = scan.get_scans_for_last(30.days)\n last_count = nil\n rows.collect do |row|\n diff = row.known_viruses - last_count rescue 0;\n last_count = row.known_viruses;\n [row.complete.to_i * 1000, diff]\n end\nend", "def smoking_progress\n Smoke.by_user(self.id).where(:counted => 0, created_at: 3.days.ago..Time.now).count\n\n # TODO\n #return ['smoked', 3]\n #return ['smoked', 7]\n #return ['smoked', 30]\n #return ['stopped', 3]\n #return ['stopped', 7]\n #return ['stopped', 30]\n\n end" ]
[ "0.7729222", "0.7510872", "0.74920726", "0.6840377", "0.6794566", "0.6771973", "0.6727374", "0.6718701", "0.6544453", "0.6544453", "0.64508843", "0.64395803", "0.6374396", "0.63047314", "0.6283432", "0.6241958", "0.6239872", "0.62331903", "0.62202245", "0.6212775", "0.6198936", "0.61754626", "0.6174449", "0.61699057", "0.61598504", "0.6147002", "0.6147002", "0.6142529", "0.61191744", "0.6063036", "0.60520816", "0.6050722", "0.60076934", "0.5999919", "0.5958828", "0.5937533", "0.592992", "0.592992", "0.5900174", "0.588671", "0.58864313", "0.5882472", "0.58788073", "0.5877271", "0.5874732", "0.5872166", "0.5870939", "0.5858502", "0.5856046", "0.58430856", "0.5837521", "0.5836319", "0.58097005", "0.5803793", "0.5797349", "0.57897973", "0.57818836", "0.5779128", "0.57790166", "0.5776808", "0.57507956", "0.5735512", "0.5734919", "0.5728317", "0.5728189", "0.5722677", "0.571992", "0.57106715", "0.5705592", "0.56966287", "0.5693211", "0.5690019", "0.5687145", "0.5682701", "0.5675928", "0.56719285", "0.56632733", "0.5660911", "0.56513065", "0.5649534", "0.5644613", "0.56428444", "0.56379205", "0.5635532", "0.56347215", "0.5633119", "0.563038", "0.56289047", "0.5625914", "0.5615263", "0.5611494", "0.5607724", "0.5607367", "0.5607055", "0.5603065", "0.5602856", "0.5599229", "0.5597932", "0.5596193", "0.55942166" ]
0.90659004
0
Remove tracks from the track_list from the iTunes database
def rem_dead_tracks playlist begin playlist.fileTracks.each do |track| #puts "#{track.index}: #{track.location}" next unless track.location == nil puts "Deleting dead track: #{track.artist} - #{track.album} - #{track.name}" @logger.info "Deleting dead track: #{track.artist} - #{track.album} - #{track.name}" track.delete end rescue Exception => e puts e.message end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_tracks(tracks)\n\n tracks.each do |track|\n self.tracks.destroy(track) # remove association\n end\n\n tracks\n end", "def remove_track_from_tracklist(playlist_id=1439475515)\n \t url = \"playlist/#{playlist_id}/tracks\"\n request_data = {:params=>{'access_token' => Setting.access_token,\"songs\"=>\"118584990\"}}\n Deezer.oauth_delete(url,request_data)\n \n \t end", "def cleanup()\n Track.where(scanned: false).delete_all()\n Disc.delete_all(\"id NOT IN (SELECT DISTINCT(disc_id) FROM tracks)\")\n Album.delete_all(\"id NOT IN (SELECT DISTINCT(album_id) FROM tracks)\")\n Artist.delete_all(\"id NOT IN (SELECT DISTINCT(artist_id) FROM tracks)\")\n end", "def remove\n empty if @playlist.length <= 0\n item_names = @playlist.map { |item| \"#{item['name']} by #{item['artist']}\" }\n item_names << 'Back'\n selection = @prompt.select('Which track would you like to remove?', item_names).split(' by ')\n menu if selection == 'Back'\n @playlist.each_with_index do |item, index|\n @user.playlist.delete_at(index) if item['name'] == selection[0]\n end\n update_playlist\n end", "def remove_track(*args)\n commit('removeTrack', *args)\n end", "def removeFromPlaylist(playlist,index,count,tracks)\n method = 'removeFromPlaylist'\n type = TODO\n args = {:playlist=>playlist,:index=>index,\n :count=>count,:tracks=>Rdio::keys(tracks)}\n return_object type,method,args,true\n end", "def remove(album)\r\n found = find_by_name(album.name)\r\n @internal_list.delete(found) unless found.nil?\r\n \r\n self\r\n end", "def remove_song(song)\n @song_list.delete(song)\n end", "def remove_notes_collection(remove_list)\n \n remove_list.each do |upload_id|\n upload = Upload.find(upload_id)\n if ( @collection.uploads.include?(upload) )\n @collection.uploads.delete(upload)\n end\n end\n end", "def delete(update_all_tracks)\n @ole.Delete(update_all_tracks)\n end", "def test_remove_song_from_room\n @room.remove_song(@song2)\n assert_equal(2, @tracklist.length())\n end", "def remove(*song)\n\t\tsong.each do |num|\n\t\t\tif @contents.include?(num) == false #order matters here or else you get statement due to delete destructiveness\n\t\t\t\tputs \"You don't have this song in your playlist to delete.\"\n\t\t\tend\n\t\t\tif @contents.include?(num)\n\t\t\t\t@num_of_tracks -= 1\n\t\t\t\t@contents.delete(num)\n\t\t\tend\n\t\tend\n\tend", "def remove_from_hot_list\n self.update_attribute(:added_to_hot_list, nil)\n end", "def clear\n @track = []\n home\n end", "def remove_notes(remove_list)\n \n remove_list.each do |upload_id|\n upload = Upload.find(upload_id)\n if ( @document.uploads.include?(upload) )\n @document.uploads.delete(upload)\n end\n end\n end", "def clear\n home\n self.track = []\n end", "def remove_videos_from_db\n Video.delete_all(\"cart_id = 1\" )\n end", "def remove(tracker_ids, wfid)\n\n return if tracker_ids.empty?\n\n doc ||= @context.storage.get_trackers(wfid)\n\n return if (doc['trackers'].keys & tracker_ids).empty?\n\n doc['wfid'] = wfid\n # a little helper for some some storage implementations like ruote-swf\n # they need to know what workflow execution is targetted.\n\n tracker_ids.each { |ti| doc['trackers'].delete(ti) }\n r = @context.storage.put(doc)\n\n remove(tracker_ids, wfid) if r\n # the put failed, have to redo the work\n end", "def destroy\n @album = @track.album\n @track.destroy\n redirect_to album_tracks_url(@album)\n end", "def delete_list(list)\n @lists[list.title].delete(list.title)\n end", "def remove_song(number, urls)\n songs.each do |song|\n if song.song_number.eql?(number.to_i)\n song.delete\n elsif song.song_number > number.to_i\n song.song_number -= 1\n song.url = urls.shift.to_s\n song.save\n end\n end\n end", "def remove_song_from_playlist(song)\n @playlist.delete(song)\n end", "def remove_song\n if self.yes?\n Song.decrement_counter(:yes_count, song.id)\n else\n Song.decrement_counter(:no_count, song.id)\n end\n end", "def destroy\n @playlists_track.destroy\n respond_to do |format|\n format.html { redirect_to playlists_tracks_url }\n format.json { head :no_content }\n end\n end", "def delete\n Song.transaction do\n self.status = :deleted\n self.save!\n\n # sets deleted = 0\n self.mixes.destroy_all\n\n # actually deletes\n self.mlabs.destroy_all\n self.featurings.destroy_all\n end\n end", "def destroy\n @track = Track.find(params[:id])\n @track.destroy\n redirect_to track_url(@track.track_id)\n end", "def find_dead_tracks playlist\n playlist.fileTracks.each do |track|\n next unless track.location == nil\n puts \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n @logger.info \"Dead track: #{track.databaseID}: #{track.artist}/#{track.album}/#{track.name}\"\n #@dead_track_list << track\n end\n \n #return @dead_track_list\n end", "def tracks\n reload\n @tracks\n end", "def get_tracks!\n tracks = RSpotify::Track.search(self.keyword, limit: 50, offset: 0).sort_by(&:popularity)\n\n tracks.delete_if { |t| t.popularity < 45 }\n tracks = tracks.uniq { |t| t.artists.first.name } \n\n raise 'The playlist could not be generated' if tracks.size < 4\n return tracks.reverse\n end", "def delete_all\n len = length\n while(len) do\n delete_track(0)\n len -= 1\n end\n end", "def remove_from_list(database, item)\n $database.execute(\"DELETE FROM shopping WHERE item = (?)\", [item])\nend", "def track_ids\n tracks || []\n end", "def remove_tracks_from_playlist(playlist_entry_ids)\n url = 'plentriesbatch'\n\n mutations = playlist_entry_ids.map { |id| {delete: id}}\n options = {\n body: {\n mutations: mutations\n }.to_json\n }\n\n make_post_request url, options\n end", "def remove_from_list\n if in_list?\n decrement_positions_on_lower_items\n set_list_position(nil)\n end\n end", "def remove_note_list()\n remove_upload_ids = []\n @collection.uploads.each do |upload|\n remove_upload_ids << upload\n end\n \n return remove_upload_ids\n end", "def destroy\n\t\tplayitems = params[:items]\n\t\t@playlist = PlaylistMedia.find(playitems[0]).playlist\n\t\t@playitems = true\t# Prevents being made a droppable\n\t\t\n\t\tPlaylistMedia.where('id IN (?)', playitems).update_all(:deleted => true, :updated_at => Time.now)\n\t\tPlaylistMedia.where('id IN (?) AND deleted = ? AND published = ?', playitems, true, false).destroy_all\t# Delete any that needed \n\n\t\trespond_with(@playlist) do |format|\n\t\t\tformat.js { render :action => 'update_playlist', :layout => false }\n\t\tend\n\tend", "def remove_item(item, list)\n\t# steps: delete the item if it exists\n\tlist.delete_if {|list_item| list_item == item.to_sym}\n\t# output: updated list\n\tlist\nend", "def remove(list,item)\r\n\tlist.delete(item)\r\n\tlist\r\nend", "def remove_song(song)\n return if Song.find_by_id(song).nil?\n songs.delete(song)\n end", "def remove(list, item)\n\tlist.delete(item)\n\tlist\nend", "def remove_from_list\n return unless in_list?\n decrement_positions_on_lower_items\n set_my_position nil\n end", "def test_remove_song_from_playlist()\n @room_1.add_song_to_playlist(@song_1)\n @room_1.add_song_to_playlist(@song_2)\n @room_1.remove_song_from_playlist(@song_1)\n assert_equal(1, @room_1.playlist_count())\n @room_1.remove_song_from_playlist(@song_4)\n assert_equal(1, @room_1.playlist_count())\n @room_1.remove_song_from_playlist(@song_2)\n assert_equal(0, @room_1.playlist_count)\n end", "def tracks\n track_ids = REDIS.smembers tracks_key\n track_ids.map!{|track_id| Track.get(self, track_id)}.sort!\n end", "def remove_from\n begin\n study = Study.find(params[:study_id])\n unless study.user_id != session[:user_id] || study.active\n params[:items].each do |i|\n item = Item.find(i)\n unless item.study_id != params[:study_id].to_i\n item.destroy\n end\n end\n end\n rescue\n \n ensure\n redirect_to(edit_study_path(params[:study_id]))\n end\n end", "def delete\n blacklight_items.each do |r|\n solr.delete_by_id r[\"id\"]\n solr.commit\n end\n end", "def remove_from_list(item,list)\n list.delete(item)\nend", "def tracks=(tracks)\n tracks.each do |track|\n raise \"A track in the given array does not belong to this album.\" if !track.album.equal?(self)\n end\n \n @tracks = tracks\n end", "def clean\n @songs = Songs.clean\n end", "def remove_from_pokemon_shop(symbol_of_shop, remove_list_mon, param_form = [], list_quantity_to_remove = [])\n return unless mon_shop_param_legit?(symbol_of_shop,\n list_id: remove_list_mon,\n list_param: param_form,\n list_quantity: list_quantity_to_remove)\n return unless @pokemon_shop_list.key?(symbol_of_shop)\n\n pkm_list = @pokemon_shop_list[symbol_of_shop]\n remove_list_mon.each_with_index do |id, index|\n form = param_form[index].is_a?(Hash) ? param_form[index][:form].to_i : 0\n result = pkm_list.find_index { |hash| hash[:id] == id && hash[:form].to_i == form }\n next unless result\n\n pkm_list[result][:quantity] -= (list_quantity_to_remove[index].nil? ? 999 : list_quantity_to_remove[index])\n pkm_list.delete_at(result) if pkm_list[result][:quantity] <= 0\n end\n @pokemon_shop_list[symbol_of_shop] = pkm_list\n sort_pokemon_shop(symbol_of_shop)\n end", "def remove(list, item)\r\n list.delete(item)\r\n list\r\nend", "def list_remover(list,item) #takes 2 arguments, 1 list and name of an item\n\tlist.delete(item)\t\n\t\nend", "def destroy\n event.events_songs.each do |e|\n e.destroy\n end\n event.destroy\n redirect_to events_url\n end", "def delete\n\t\tif params[:position]\n\t\t\titem = Playlist.where(params[:position])[0] \n\t\t\titem.remove_from_list\n\t\t\titem.delete\n\t\t\t@position = params[:position]\n\t\telse\n\t\t\tPlaylist.delete_all\n\t\tend\n\tend", "def destroy\n @song.destroy\n end", "def remove_item(list, item)\n\tlist.delete(item)\n\tlist\nend", "def remove(list, food_item)\n\tlist.delete(food_item)\n\tlist\nend", "def delete_artist(library_hash, art)\n library_hash.each do |artist, song|\n if artist == art\n library_hash.delete(artist)\n end\n end\nend", "def remove list\n remove = @watch.objects.find { |obj| obj.name == \"remove\" }\n\n obix = OBIX::Builder.new do |obix|\n obix.obj is: \"obix:WatchIn\" do |obix|\n obix.list name: \"hrefs\" do |obix|\n list.each do |item|\n obix.uri val: item\n end\n end\n end\n end\n\n remove.invoke obix.object\n end", "def update\n songs_to_remove = @music_disc.songs.select {|song| !music_disc_params[:music_category_ids].include?(song.music_category.id.to_s)}\n songs_to_remove.each do | song |\n @music_disc.songs.delete(song)\n end\n respond_to do |format|\n if @music_disc.update(music_disc_params)\n format.html { redirect_to @music_disc }\n format.json { render :show, status: :ok, location: @music_disc }\n else\n format.html { render :edit }\n format.json { render json: @music_disc.errors, status: :unprocessable_entity }\n end\n end\n end", "def tracks=(tracks)\n reload\n @tracks = track\n @current_track_index = 0\n save\n end", "def remove_item (item,list)\nlist.delete(item)\nlist\nend", "def remove_from_list\n if in_list?\n decrement_positions_on_lower_items\n set_my_position nil\n end\n end", "def remove_from_list(list, item)\n\tlist.delete(item)\nend", "def remove_from_list\n # if in_list?\n # decrement_positions_on_lower_items\n # update_attribute position_column, nil\n # end \n return unless in_list?\n decrement_positions_on_lower_items\n update_attribute position_column, nil \n end", "def remove_note_list()\n remove_upload_ids = []\n @document.uploads.each do |upload|\n remove_upload_ids << upload\n end\n \n return remove_upload_ids\n end", "def destroy\n @list_id = @item.list.id\n @item.destroy\n @items = List.find(@list_id).items.order(\"id ASC\")\n end", "def unlove( params )\n LastFM.requires_authentication\n LastFM.post( \"track.unlove\", params )\n end", "def add_songs tracklist, playlist_object\n playlist_object.add_tracks!(tracklist)\n end", "def remove list\n list_action list, \"remove\"\n end", "def remove_all()\n @items.clear()\n end", "def remove_item(list, item_name)\n\tlist.delete(item_name)\n\tlist\nend", "def remove_item(list, item_name)\n\tlist.delete(item_name)\n\tlist\nend", "def remove_item(list, item_name)\n\tlist.delete(item_name)\n\tlist\nend", "def remove_data!\n connector.remove_torrent @ids, true\n @deleted = true\n end", "def remove(list, item_name)\r\n\tlist.delete(item_name)\r\n\tp list\r\nend", "def clear\n playlist_control :delete\n end", "def remove_items(shopping_list, item)\n shopping_list.delete(item)\nend", "def delete_song(db, song)\n db.execute(\"DELETE FROM music WHERE song=(?)\", [song])\nend", "def one_week_wonders(songs)\n songs.each_with_index do |el, index|\n if el == songs[index + 1]\n songs.delete(el)\n end\n end\n songs.uniq\nend", "def deleteItems\n self.items.each do |item|\n item.delete\n end\n end", "def remove (list, item)\n\tlist.delete(item)\nend", "def remove(list, item_name)\n\tlist.delete(item_name)\nend", "def remove_item(item, list)\n\tlist.delete_if do |i|\n\t\ti == item \n\tend\nend", "def remove_item!(list, item)\r\n list.delete(item)\r\n list\r\nend", "def remove_from_list(list, item)\n list.delete(item)\n p list\nend", "def a_track\n @track = []\n end", "def remove_item(list, item)\r\n\tlist.delete(item)\r\n\treturn list\r\nend", "def remove_item(list, item)\r\n list.delete(item)\r\n list\r\nend", "def remove(list, item)\n\tlist.delete(item)\nend", "def remove_item(list, item_name)\r\n list.delete(item_name)\r\n list\r\nend", "def destroy\n @track.destroy\n render json: { message: I18n.t('track.destroy') }\n end", "def remove_item(list,item)\r\n\r\n list.delete(item)\r\n list\r\nend", "def destroy\n @music.destroy\n redirect_to musics_path\n end", "def destroy\n @music = Music.find(params[:id])\n @music.favorites.destroy_all\n @music.destroy\n \n render :nothing => true\n end", "def remove_item_from_list(grocery_list, item) \n grocery_list.delete(item) \n grocery_list \nend", "def remove_item(list, name)\n list.delete(normalize_string(name))\n return list\nend", "def remove_item(list, item)\n list.delete(item)\n list\nend", "def remove_item(list, item)\n list.delete(item)\n list\nend", "def remove_observation(obs)\n return unless observations.include?(obs)\n\n observations.delete(obs)\n obs.reload.turn_off_specimen_if_no_more_records\n obs.log(:log_collection_number_removed, name: format_name, touch: true)\n destroy if observations.empty?\n end", "def remove(*items)\n notify_will_change! if items.count > 0\n items.each do |item|\n collection.delete item\n end\n @collection\n end" ]
[ "0.73032564", "0.69318926", "0.6711813", "0.66769016", "0.6638574", "0.66019875", "0.6216058", "0.613805", "0.6134288", "0.605465", "0.6035624", "0.600622", "0.59619135", "0.59495777", "0.5910261", "0.58891296", "0.5883125", "0.585527", "0.58225507", "0.58147", "0.57582915", "0.57379436", "0.56891", "0.5656948", "0.5651644", "0.56438977", "0.56374633", "0.5631094", "0.56176156", "0.56080925", "0.5603254", "0.55861646", "0.556237", "0.5534195", "0.55331653", "0.55039924", "0.5496837", "0.5490886", "0.5473401", "0.5464942", "0.5455499", "0.5435484", "0.5433459", "0.5428692", "0.5427152", "0.54259443", "0.5425474", "0.541629", "0.54109067", "0.53983396", "0.539391", "0.53925925", "0.53857255", "0.5381888", "0.5381107", "0.53789985", "0.5369914", "0.53673375", "0.53654397", "0.5364865", "0.53575045", "0.5356669", "0.5356339", "0.5346708", "0.53467035", "0.5344069", "0.53414774", "0.5339897", "0.53318435", "0.532969", "0.53259295", "0.53259295", "0.53259295", "0.532554", "0.5322289", "0.5322175", "0.5320487", "0.53177273", "0.5312233", "0.5310435", "0.53083205", "0.5303335", "0.5296615", "0.5296568", "0.5295224", "0.5291809", "0.52894634", "0.5285186", "0.5270007", "0.5268332", "0.5261618", "0.525924", "0.5256668", "0.5255204", "0.52521765", "0.52517587", "0.52378243", "0.52378243", "0.5237405", "0.5236661" ]
0.6958975
1
This is a nasty hack. If we didn't have PORO models, we could just use ApplicationRecord.descendants, but that wouldn't pick up e.g. CaseRequest Grepping through the source code seemed to be the most pragmatic solution so that developers don't need to remember to add new classes to a list for mutation testing, but it's not ideal
def grep_model_files_for_classes re = /class (?<klass>\w+)/ Dir.glob(Rails.root.join('app/models/*.rb')). map { |f| File.readlines(f).grep(/\bclass /) }.flatten. map { |s| re.match(s)[:klass] }.map(&:constantize). reject do |klass| klass.respond_to?(:abstract_class?) && klass.abstract_class? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def makena_classes\n Rails.application.eager_load!\n pass = ActiveRecord::Base.descendants.map{|a| a.to_s}\n pass.shift\n pass\n end", "def models\n children = []\n Mongoid.models.each do |model|\n children << model.to_s\n model.descendants.each do |child|\n inh = [child.to_s]\n sk = child.superclass\n while sk != model\n inh << sk.to_s\n sk = sk.superclass\n raise '!' if sk == Object\n end\n\n children << ' ' + inh.reverse.join(' < ')\n end\n end\n children\nend", "def models\n work_classes + collection_classes\n end", "def use_with_class_names\n (\n DynamicModel.model_names +\n ExternalIdentifier.model_names +\n ActivityLog.model_names +\n Master::PrimaryAssociations\n )\n .map { |m| m.to_s.singularize }\n .select { |m| m != 'master' }\n end", "def subtypes(allow_caching = true)\n my_node(allow_caching).subclasses.collect { |st| SourceClass.new(st.uri) }\n end", "def to_class\n\t\t@model.classes.map { |kname, klass| klass.to_class( @model ) } +\n\t\t\t@model.find_through.map { |t| t.to_class }\n\tend", "def subclasses; end", "def subclasses; end", "def class_names\n descendants.map(&:name)\n end", "def resolve_polymorphic_relations(klass)\n generated = []\n\n for r in klass.relations\n if r.polymorphic?\n target_dm = r.target_class.demodulize\n\n # Replace the target class by either creating or getting the\n # polymorphic child if it already exists.\n\n r[:target_class] = if r.owner_class.constants.include?(target_dm)\n r.owner_class.const_get(target_dm)\n else\n child = Class.new(r.target_class)\n child.ann(:self, :polymorphic => :child)\n # Specialize of the polymorphic relation.\n cr = child.relation(child.ann(:self, :polymorphic_relation))\n cr.options.delete(:polymorphic)\n cr.options.delete(:target_plural_name)\n cr.options.delete(:target_singular_name)\n cr.options[:target_class] = klass\n r.owner_class.const_set(target_dm, child)\n end\n\n r.resolve_polymorphic\n\n generated << r[:target_class]\n end\n end\n\n return generated\n end", "def model_classes\n ModelClassCollector.new(configuration, mode_map.keys).collect\n end", "def new_classes(snapshot)\n self.classes do |klass|\n if !snapshot.include?(klass)\n klass\n end\n end\n end", "def subclasses\n @subclasses ||= []\n end", "def objects_of_class(name)\n find_all { |r| name === r['class'] }\n end", "def model_classes\n @opts[:models]\n end", "def fetch_model_list\n if parent_model\n return parent_model.send(\"#{model_name.pluralize.downcase}\")\n else\n return model_name.camelize.constantize.find(:all)\n end\n end", "def descendants_with_active_validation\n [].tap do |descendants|\n k = base_class.superclass\n while k.respond_to?(:active_validation) && k.instance_methods.include?(:manifest)\n descendants << k\n k = k.superclass\n end\n end\n end", "def _subclasses\n @_subclasses ||= []\n end", "def subclasses\n @subclasses ||= []\n end", "def assert_generated_model_for(name, parent = \"ActiveRecord::Base\")\n assert_generated_class \"app/models/#{name.to_s.underscore}\", parent do |body|\n yield body if block_given?\n end\n end", "def descendants\n model_base_class.where(descendant_conditions)\n end", "def find_models\n raise_must_override\n end", "def list_known_classes\n end", "def find_finder_class_for record #:nodoc: \n class_hierarchy = [record.class]\n\n while class_hierarchy.last != @klass && class_hierarchy.last.superclass\n class_hierarchy.push(class_hierarchy.last.superclass)\n end\n \n class_hierarchy.detect { |klass| !klass.abstract_class? }\n end", "def classes\n self\n end", "def descendants\n Base.descendants\n end", "def models\n [::AdminSet, Hyrax::AdministrativeSet, ::Collection, Hyrax.config.collection_class].uniq.compact\n end", "def models!\n # load '../db/schema.rb'\n \n models = Object.constants.map {|c| Object.const_get(c)}.select {|c| c.is_a?(Class) && c.superclass == ActiveRecord::Base}\n models = models.map(&:to_s)\n \n # This erases the class definitions, as long as nothing ELSE is holding onto a ref -- possibly controllers?\n models.each do |c|\n Object.instance_eval {remove_const c}\n end\n \n # Allow Kernel.require to re-load these models when references to them crop up\n # \"tableize.singularize\" is effective, but not airtight\n models.each do |c|\n $\".reject! {|x| x =~ /app\\/models\\/#{c.tableize.singularize}/}\n end\n \n # Hopefully the auto-loader can do the rest of the work for us\n \n # TODO: What about those pesky namespaced models and controllers?\n end", "def requested_models(requested_model)\n case requested_model\n when /^(.+)[(](.+)[)]$/ #handle model(with associations), i.e. Image(for scene A)\n base_model = $1.classify.constantize\n scopes = $2.split(',')\n models = base_model\n\n scopes.each do |scope|\n models = models.send(scope.strip)\n end\n\n models.all\n\n when String #is name\n requested_model.singularize.constantize.all\n else\n requested_model.all\n end\nend", "def models\n %w(\n C100Application\n Applicant\n Solicitor\n User\n PaymentIntent\n CompletedApplicationsAudit\n ).freeze\nend", "def classes\n [self]\n end", "def subclasses\n @subclasses ||= Set.new\n end", "def instantiate_subclasses(klass); end", "def get_classes( obj )\n cls = obj.class\n print cls.to_s\n while cls.superclass != nil\n cls = cls.superclass\n print ' < ' + cls.to_s\n end\nend", "def descendants(klass, generations=nil)\n subclass = []\n \n ObjectSpace.each_object(Class) do |c|\n next if c == klass\n \n ancestors = c.ancestors[0 .. (generations || -1)]\n subclass << c if ancestors.include?(klass)\n\n ancestors = c.singleton_class.ancestors[0 .. (generations || -1)]\n subclass << c if ancestors.include?(klass)\n end\n\n if klass.instance_of?(Module)\n # descendants of module are also modules which include the module\n ObjectSpace.each_object(Module) do |c|\n next if c == klass\n\n ancestors = c.ancestors[0 .. (generations || -1)]\n subclass << c if ancestors.include?(klass)\n end\n end\n\n subclass.uniq\n end", "def observed_descendants\n observed_classes.sum([]) { |klass| klass.descendants }\n end", "def unpack\n all.each do |model|\n klass = model.name.split('::').last\n Kernel.const_set(klass, model) unless Kernel.const_defined?(klass)\n end\n end", "def unpack\n all.each do |model|\n klass = model.name.split('::').last\n Kernel.const_set(klass, model) unless Kernel.const_defined?(klass)\n end\n end", "def discover_models\n all_models = []\n Dir.chdir(File.join(Rails.root, \"app/models\")) do\n Dir[\"**/*.rb\"].each do |m|\n class_name = m.sub(/\\.rb$/,\"\").camelize\n klass = class_name.split(\"::\").inject(Object){ |klass,part| klass.const_get(part) }\n all_models << \"#{class_name}\" if klass < ActiveRecord::Base && !klass.abstract_class?\n end\n end\n return all_models\n end", "def crazy_model_classes\n [:Task, :Subtask, :TaskConnection, :Photo]\nend", "def subclasses\n @subclasses\n end", "def classes; end", "def classes\n @classes\n end", "def get_polymorphic_as_associations_classes(model, reflection)\n classes = []\n @polymorphic_as_reflections.each do |poly_as_reflection|\n if poly_as_reflection.send(:options)[:as] == reflection.send(:name)\n if poly_as_reflection.active_record.send(:compute_type, poly_as_reflection.send(:class_name)).to_s == model.to_s\n classes << poly_as_reflection.active_record.to_s.constantize\n end\n end\n end\n classes\n end", "def initialize\n self.models = Hash[\n MongoMapper::Document.descendants.select { |c| c.name }.map { |c|\n [c.name.tableize, c]\n }\n ]\n end", "def hook_model_klass\n fail 'child class to return a model klass here'\n end", "def generate_objective_c_classes\n @classes = []\n resources_from_schema.collect do |resource_hash|\n Resource.new(resource_hash).tap do |resource|\n # Generate the query classes first\n resource.queries.each do |query|\n # Query objects do not get cached in core data\n to_objective_c_class node:query[\"type\"], cached:false\n end\n # Generate the resource classes next\n klass = to_objective_c_class node:resource.hash[:type], cached:resource.cached?\n # Mark this class as being a REST resource\n klass.resource = resource\n end\n end\n end", "def fill_model(classnode = ::ObjectBrowser::create_class_tree(), parent = nil)\n node = insert_node(parent, :class, classnode.klass.to_s, \"#<#{classnode.klass.id.to_s(16)}>\", classnode.klass)\n classnode.objects.each do | object |\n insert_node(node, :object, \"#<#{object.id.to_s(16)}>\", \"#<#{object.id.to_s(16)}>\", object)\n end\n classnode.subclasses.to_a.sort_by{|k,s| k.to_s}.each do | klass, subclass | fill_model(subclass, node) end\n end", "def parent_models\n models.group_by(&:table_name).each_value.flat_map do |models|\n models.reject { |model| models.include?(model.superclass) }\n end\n end", "def authorizable_classes\n [].tap do |result|\n ObjectSpace.each_object(Class) do |c|\n next unless c.superclass == ApplicationRecord\n result << c if c.ancestors.include?(Record::Authorizable)\n end\n end\n end", "def model_class\n self.name.gsub(/Test$/, '').constantize\n end", "def orbserved_classes\n\t\t\t@orbserved_classes ||= Set.new\n\t\tend", "def model_classes(classes = Map.model_classes)\n nested_hash = classes.each_with_object({}) do |klass, hash|\n hash[klass] = Node.new(klass)\n end\n nested_hash.each do |klass, node|\n node.parent = parent = nested_hash[klass.superclass]\n parent.children << node if parent\n end\n nested_hash.values.select { |v| v.parent.nil? }\n end", "def models\n @models ||= self.model_names.map {|x| x.constantize}\n end", "def provided_models\n if model = explicit_fullfilled_model\n [model[0]] + model[1]\n else\n models = self.model.fullfilled_model\n if (task_class = models.find { |m| m.kind_of?(Class) })\n [task_class] + models.find_all { |m| !task_class.has_ancestor?(m) }\n else\n models\n end\n end\n end", "def test_uses_given_parent\n Object.const_set(:ApplicationSerializer, Class.new)\n run_generator [\"Account\", \"--parent=MySerializer\"]\n assert_file \"app/serializers/account_serializer.rb\", /class AccountSerializer < MySerializer/\n ensure\n Object.send :remove_const, :ApplicationSerializer\n end", "def all_models_superclass\n ActiveRecord::VERSION::MAJOR >= 5 ? ApplicationRecord : ActiveRecord::Base\n end", "def record_class_definitions\n extant, novel = [], []\n ObjectSpace.each_object(Class) { |k| extant << k }\n yield\n ObjectSpace.each_object(Class) { |k| novel << k if !extant.include?(k) }\n novel\n end", "def form_objects\n BaseForm.descendants.map(&:name).grep(/^Steps::/)\nend", "def force_load_models\n ClassEntry\n SingletonMethodEntry\n InstanceMethodEntry\n end", "def simple_classes\n _simple_classes\n end", "def model\n if object[inheritance_column]\n object[inheritance_column].constantize\n else\n original_class\n end\n end", "def reload\n klasses = if @reflection.polymorphic?\n @reflection.active_record.distinct.order(reflection.foreign_type).pluck(reflection.foreign_type).map(&:safe_constantize)\n else\n [@reflection.klass]\n end\n @models = klasses.map { |k| @dump.model_for(k) }\n end", "def descendants\n model_base_class.scoped(:conditions => descendant_conditions)\n end", "def find_finder_class_for(record)\n class_hierarchy = [record.class]\n\n while class_hierarchy.first != @klass\n class_hierarchy.unshift(class_hierarchy.first.superclass)\n end\n\n class_hierarchy.detect { |klass| !klass.abstract_class? }\n end", "def entity_classes\n @entity_classes ||= []\n end", "def know_it_all(object)\n object.class\nend", "def instantiate_subclasses(klass)\n klass.descendants.sort.map do |c|\n c.new(config)\n end\n end", "def instantiate_subclasses(klass)\n klass.descendants.sort.map do |c|\n c.new(config)\n end\n end", "def defined_classes\n # TODO: check content type before scanning\n content.scan(/\\s*class\\s+([A-Za-z0-9_\\.]*)/).flatten\n end", "def model_name\n described_class.to_s.underscore\nend", "def find_finder_class_for(record) #:nodoc:\n class_hierarchy = [record.class]\n\n while class_hierarchy.first != @klass\n class_hierarchy.insert(0, class_hierarchy.first.superclass)\n end\n\n class_hierarchy.detect { |klass| !klass.abstract_class? }\n end", "def check_foreing_models\n parent_ids.each do |attr|\n next if attr !~ /(.*)_id$/\n k= $1.camelize\n begin; foreing_models[attr]= k.singularize.constantize\n rescue\n end\n end\n end", "def specializations\n @specializations ||= Specialization.from_models(self, @models)\n end", "def classes\n return [] unless classes = self[\"class\"]\n classes.strip.split(/\\s+/)\n end", "def all_questions_descendants\n # source .descendants is very fast with no db hits! why? How can we use it? It's type is ActiveRecord::Association::CollectionProxy\n ([source] + source.descendants)\n end", "def model_class\n class_name.constantize\n end", "def superclasses(c)\n result = [c]\n while s = c.superclass #rubocop:disable Lint/AssignmentInCondition\n result << s\n c = s\n end\n result\n end", "def model_instances(subclass_sym)\n\t\traise \"model_instances called for nil symbol\" if subclass_sym.nil?\n\n\t\ttable_class = table_class(subclass_sym)\n\t\tsubclass = self.namespaced_class(subclass_sym)\n\t\tcmd = \"self.#{table_class.to_s.pluralize.downcase}.where{self.type == #{subclass}.to_s}\"\n\t\tself.instance_eval(cmd)\n\tend", "def all_models\n Dir[\"#{RAILS_ROOT}/app/models/*.rb\"].collect{|file|File.basename(file).sub(/\\.rb$/, '')}.sort.reject{|model| (! model.camelize.constantize.ancestors.include?(self)) rescue true}\n end", "def sanitize_model_class( model )\n model.name.split(\"::\").last\n end", "def define_classes klasses\n klasses.each do |klassname|\n klass = klassname.gsub(/\\b('?[a-z])/) { $1.capitalize } #make uppercase\n #could check to see if not already define but at the minute not important\n #if (eval \"defined? #{klass}\") != \"constant\"\n eval \"class #{klass} < DynAttrClass \\n end\"\n #end\n end\nend", "def classes\n @classes.values\n end", "def classes\n @classes.values\n end", "def self_and_descendants_from_active_record\n [self]\n end", "def models\n [::AdminSet, Hyrax::AdministrativeSet, ::Collection, Hyrax.config.collection_class].uniq.compact\n end", "def inherited(klass)\n return unless klass.name\n\n type = klass.name.gsub(/([A-Z])/) { |a| \"_#{a.downcase}\" }.gsub(\"::\", \"/\")[1..-1].intern\n klass.star_type(type)\n end", "def process_class exp\n name = class_name(exp.class_name)\n parent = class_name(exp.parent_name)\n\n # If inside an inner class we treat it as a library.\n if @current_class\n Railroader.debug \"[Notice] Treating inner class as library: #{name}\"\n Railroader::LibraryProcessor.new(@tracker).process_library exp, @file_name\n return exp\n end\n\n handle_class exp, @tracker.models, Railroader::Model\n end", "def list_objects\n objects = @model_class.method(:list).arity == 0 ? @model_class.list : @model_class.list(true)\n objects.map { |obj| Array(obj).find { |o| o.is_a?(@model_class) } }\n end", "def boot_classes\n classes = space.classes\n type_names.each do |name , vars|\n cl = object_with_type Parfait::Class\n cl.instance_type = @types[name]\n @types[name].object_class = cl\n @types[name].instance_methods = object_with_type Parfait::List\n cl.instance_methods = object_with_type Parfait::List\n #puts \"instance_methods is #{cl.instance_methods.class}\"\n cl.name = name\n classes[name] = cl\n end\n # superclasses other than default object\n supers = { :Object => :Kernel , :Kernel => :Value,\n :Integer => :Value , :BinaryCode => :Word }\n type_names.each do |classname , ivar|\n next if classname == :Value # has no superclass\n clazz = classes[classname]\n super_name = supers[classname] || :Object\n clazz.set_super_class_name super_name\n end\n end", "def child_class\n Objekt\n end", "def genCaseClasses(model, outRoot)\n firstRec = model.records.values.first\n raise ArgumentError, \"No records defined in the model #{model.sources.masterPath}\" unless firstRec\n\n scalaPackage, base, packagePath = assertNamespace(firstRec.name)\n scalaPackage = self.scalaNs(scalaPackage)\n destDir = File.join(outRoot, packagePath, SCALA_SUBPACKAGE) # keep this in sync with scalaNs\n FileUtils.mkdir_p destDir\n out = File.open(File.join(destDir, 'Model.scala'), 'wb')\n begin\n out.puts %<package #{scalaPackage}\n\nimport java.time.ZonedDateTime\nimport scala.math.BigDecimal\nimport scala.collection.immutable.Set\nimport scala.collection.immutable.List\nimport scala.collection.Seq\n\n/**\n * This content is generated by DataMeta, do not edit manually!\n */\n>\n\n (model.enums.values + model.records.values).each {|e|\n case\n when e.kind_of?(DataMetaDom::Record)\n self.genEntity model, out, e, scalaPackage\n when e.kind_of?(DataMetaDom::Mappings)\n raise ArgumentError, \"For name #{e.name}: Mappings can not be generated to a case class\"\n when e.kind_of?(DataMetaDom::Enum)\n self.genEnumWorded out, e\n when e.kind_of?(DataMetaDom::BitSet)\n raise ArgumentError, \"For name #{e.name}: BitsSets can not be generated to a case class\"\n else\n raise \"Unsupported Entity: #{e.inspect}\"\n end\n }\n ensure\n out.close\n end\n end", "def class_tree\n @class_tree ||= generate_class_tree\n end", "def elements\n model = self.model.constantize\n model.respond_to?(:generic_listing_elements) ? model.generic_listing_elements : model.all\n end", "def children\n\t\treturn self.search( :one, '(objectClass=*)' )\n\tend", "def model_class\n @class_name.constantize\n end", "def all_classes_in_gem_named(gem)\n self.all_classes.select { |klass| klass.belongs_to?(gem) }\n end", "def descendents\n ObjectSpace.each_object(Class).select do |object|\n object < self\n end\n end", "def instantiate_subclasses(klass)\n klass.descendants.select { |c| !safe || c.safe }.tap do |result|\n result.sort!\n result.map! { |c| c.new(config) }\n end\n end", "def all_classes_implementing(selector)\n self.all_classes.select { |klass| klass.includes_selector?(selector) }\n end" ]
[ "0.70746", "0.6688687", "0.62822956", "0.6050729", "0.6009372", "0.59131706", "0.5895144", "0.5895144", "0.58925205", "0.5885518", "0.5838802", "0.5833704", "0.5832198", "0.58307815", "0.58263284", "0.58234364", "0.5816049", "0.58147687", "0.57984734", "0.5789123", "0.578812", "0.5774164", "0.5762547", "0.5750997", "0.5743692", "0.57358193", "0.5727055", "0.5712349", "0.56948227", "0.56869376", "0.5679835", "0.56771404", "0.56683904", "0.5665697", "0.5665184", "0.5662796", "0.56620544", "0.56620544", "0.5659162", "0.56531614", "0.5645195", "0.56405336", "0.563831", "0.56379336", "0.5630639", "0.56256247", "0.5617597", "0.56024927", "0.56002223", "0.5591608", "0.55795234", "0.55769867", "0.556292", "0.5539984", "0.5539781", "0.5535593", "0.55338275", "0.55313843", "0.5519475", "0.5517146", "0.54979444", "0.5492715", "0.5486629", "0.548445", "0.5482903", "0.54695946", "0.54666", "0.5463766", "0.5463766", "0.5451748", "0.5445576", "0.54394126", "0.54351264", "0.54336333", "0.54334337", "0.5433009", "0.5427841", "0.5418569", "0.5415152", "0.54047906", "0.5399678", "0.53950983", "0.53820175", "0.53820175", "0.5369651", "0.5362659", "0.53613263", "0.5357172", "0.53561246", "0.5347804", "0.5344824", "0.5342692", "0.5342581", "0.5341978", "0.53415537", "0.5341118", "0.5337393", "0.53349346", "0.5334908", "0.5330514" ]
0.6335589
2
Load the dependencies file.
def load source = self.depfile.read self.instance_eval( source, self.depfile.to_s, 1 ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_dependencies\n dependencies.each { |dependency| dependency }\n end", "def load_dependencies( file_list, force_require=true )\r\n loader = DependencyLoader.new( file_list, force_require )\r\n loader.load_dependencies\r\nend", "def load!\n contents = File.read(filepath).strip\n hash = parse(contents)\n\n hash[:dependencies].each do |name, options|\n # Dynamically calculate paths relative to the Berksfile if a path is given\n options[:path] &&= File.expand_path(options[:path], File.dirname(filepath))\n\n begin\n add(Berkshelf::Dependency.new(berksfile, name.to_s, options))\n rescue Berkshelf::CookbookNotFound\n # It's possible that a source is locked that contains a path location, and\n # that path location was renamed or no longer exists. When loading the\n # lockfile, Berkshelf will throw an error if it can't find a cookbook that\n # previously existed at a path location.\n end\n end\n end", "def require_dependencies\n deps_file = (RUBYCOCOA_ROOT + 'config/dependencies.rb').to_s\n Rucola::Dependencies.load(deps_file).require!\n end", "def load()\n\n checkFileExists()\n loadConfigs()\n checkConfigs() \n end", "def load_dependencies(options = {})\n load_config(options)\n Merb::BootLoader::BuildFramework.run\n Merb::BootLoader::Dependencies.run\n Merb::BootLoader::BeforeAppRuns.run\n end", "def load_dependencies(options = {})\n load_config(options)\n Merb::BootLoader::BuildFramework.run\n Merb::BootLoader::Dependencies.run\n Merb::BootLoader::BeforeAppLoads.run\n end", "def load_dependencies\n result = zh_client.dependencies(repo_name)\n\n result[\"dependencies\"].each do |hash|\n blocking = add_or_find(hash[\"blocking\"])\n blocked = add_or_find(hash[\"blocked\"])\n\n add_edge(blocked, blocking)\n end\n end", "def load_gemdeps(path)\n gf = GemDepedencyAPI.new(self, path)\n gf.load\n end", "def call(filename = \"dependencies.yml\")\n dependencies = Set.new\n $/=\"\\n\\n\"\n File.open(filename, \"r\").each do |object|\n begin\n dependencies << Dependency.deserialize(object)\n rescue\n raise $!, \"Could not load object from #{filename}\", $!.backtrace\n end\n end\n dependencies\n end", "def load_model(file)\n begin\n require_dependency(file)\n rescue Exception => e\n Logger.new($stdout).warn(e.message)\n end\n end", "def load\n return unless File.exist? @config_path\n @files = YAML.load_file(@config_path)['files'].collect do |file|\n GistDep::File.load file\n end\n end", "def add_elm_dependencies(filename, load_path, context)\n File.read(filename).each_line.flat_map do |line|\n # e.g. `import Quiz.QuestionStore exposing (..)`\n match = line.match(/^import\\s+([^\\s]+)/)\n\n next [] if match.nil?\n\n # e.g. Quiz.QuestionStore\n module_name = match.captures[0]\n\n # e.g. Quiz/QuestionStore\n dependency_logical_name = module_name.gsub(\".\", \"/\")\n\n # e.g. ~/NoRedInk/app/assets/javascripts/Quiz/QuestionStore.elm\n dependency_filepath = load_path + \"/\" + dependency_logical_name + \".elm\"\n\n # If we don't find the dependency in our filesystem, assume it's because\n # it comes in through a third-party package rather than our sources.\n if File.file? dependency_filepath\n context.depend_on(dependency_logical_name)\n end\n end\n end", "def load_model(file)\n require_dependency(file)\n end", "def load(filename)\n @filename = filename.to_s\n mode = :in_header\n IO.readlines(@filename).each do |line|\n case mode\n when :in_header\n if line =~ %r{^\\s*gem\\.}\n mode = :in_dev_body\n case line\n when %r{^\\s*gem\\.add_development_dependency}\n @dev_dependencies << line\n when %r{^\\s*gem\\.add_dependency}\n @gem_dependencies << line\n else\n @body << line\n end\n else\n @header << line\n end\n when :in_dev_body\n if line =~ %r{^\\s*end}\n mode = :in_footer\n @footer << line\n else\n case line\n when %r{^\\s*gem\\.add_development_dependency}\n @dev_dependencies << line\n when %r{^\\s*gem\\.add_dependency}\n @gem_dependencies << line\n else\n @body << line\n end\n end\n when :in_footer\n @footer << line\n end\n end\n end", "def load_dependencies\r\n @local_gems.each do |gem_info|\r\n gem_file_name = gem_info.gem_file\r\n gem_name = installed_as_name_for( short_form_of_gem_name( gem_file_name ) )\r\n @required_gem_names.delete gem_file_name\r\n end\r\n @required_gem_paths.each do |gem_path|\r\n gem_short_name = short_form_of_gem_name gem_path\r\n if @required_gem_names.include? gem_short_name\r\n puts \"installing #{gem_path}\"\r\n installer = @force_require ? PreloadingInstaller.new( gem_path, @local_gems ) : Installer.new( gem_path )\r\n installer.install\r\n end\r\n end\r\n end", "def require_load_paths\n load_paths.each { |path| Padrino.require_dependencies(File.join(self.root, path)) }\n end", "def load\r\n\t\tload_file\r\n\t\tconfigure\r\n\tend", "def load_required\n Dir[\"#{folder}/**/*.rb\"].each{|m|load m}\n end", "def load\n require_dependencies\n load_directory :lib\n load_directory :models\n load_directory :routes\n self\n end", "def enable_dependency_loading; end", "def enable_dependency_loading; end", "def dependencies\n @dependencies ||= Payload::RailsLoader.load\n end", "def require(options={})\n options[:require] = true\n load(options)\n end", "def initialize config_path = 'gist-dep.yml'\n @files = []\n @config_path = config_path\n load\n end", "def load_model(file)\n if defined?(require_dependency)\n require_dependency(file)\n else\n require(file)\n end\n end", "def load!\n if config_file\n load_from_config_file(config_file)\n\n if @config_from_file\n get_formatters_from_config_file\n #get_file_sets_from_config_file unless @runtime_file_list\n get_file_sets_from_config_file\n end\n else\n log 'Creating default file set...'\n @file_sets = { default: FileSet.new(@runtime_file_list) }\n end\n\n get_output_file_from_cli_opts\n get_formatters_from_cli_opts\n get_file_sets_from_cli_opts\n get_style_from_cli_opts\n end", "def load_gemdeps(path, without_groups = [], installing = false)\n @git_set = Gem::Resolver::GitSet.new\n @vendor_set = Gem::Resolver::VendorSet.new\n @source_set = Gem::Resolver::SourceSet.new\n\n @git_set.root_dir = @install_dir\n\n lock_file = \"#{File.expand_path(path)}.lock\".dup.tap(&Gem::UNTAINT)\n begin\n tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file lock_file\n parser = tokenizer.make_parser self, []\n parser.parse\n rescue Errno::ENOENT\n end\n\n gf = Gem::RequestSet::GemDependencyAPI.new self, path\n gf.installing = installing\n gf.without_groups = without_groups if without_groups\n gf.load\n end", "def load_dependencies\n require 'f5-icontrol'\n end", "def load(environment=nil)\n load_from_file(file, environment)\n end", "def load(config_file = nil)\n config_file ||= File.join(APP_DIR, \"config.rb\")\n if File.exists? config_file\n require config_file\n check_requirements\n else\n puts \"Could not find config.rb file in directory: #{APP_DIR}\"\n exit(1)\n end\n end", "def load_lab_app_lib_files\n libFiles = File.dirname(__FILE__) + \"/../lib/*.rb\"\n Dir[libFiles].each do |file|\n fullpath = File.expand_path(file)\n puts \"Loading your file #{fullpath}\"\n require fullpath\n end\n end", "def initialize_repository\n super\n return unless @file.exists?\n\n begin\n packages_data = @file.read\n unless packages_data.is_a?(Array)\n raise UnexpectedValueError,\n 'Could not parse package list from the repository'\n end\n rescue => e\n raise InvalidRepositoryError,\n \"Invalid repository data in #{@file.path}, \\\n packages could not be loaded: \\\n [#{e.class}] #{e.message}\"\n end\n\n loader = ::Composer::Package::Loader::HashLoader.new(nil, true)\n packages_data.each do |package_data|\n package = loader.load(package_data)\n add_package(package)\n end\n\n end", "def initialize file\r\n @file = file\r\n @new_depends = {}\r\n @source_files = []\r\n @flat_depends = {}\r\n\r\n if File.exist? @file\r\n load_depends @file\r\n end\r\n\r\n # If the clean target is defined add the dependancy file\r\n # to it.\r\n if defined? CLEAN && CLEAN.is_a(Rake::FileList)\r\n CLEAN.add @file\r\n end\r\n\r\n # Save the dependancies at exit if they have changed\r\n # since last invocation.\r\n at_exit do\r\n if has_changes?\r\n write_depends\r\n end\r\n end\r\n end", "def dependency(lib = nil)\n lib ? require(lib) : yield\n rescue LoadError, NameError => e\n self.load_error = e\n end", "def initialize(file=nil)\n @files = []\n @deps = []\n @libs = []\n @inc_paths = []\n @lib_paths = []\n from_s Utils::read_file file if !file.nil?\n end", "def load\n end", "def load\n end", "def load\n end", "def load_packages\n packages = []\n return packages unless File.readable?(PACKAGES)\n File.open(PACKAGES, 'r') do |f|\n f.each_line do |line|\n next unless line =~ /\\S/\n line.chomp!\n packages.push(line)\n end\n end\n\n packages\n end", "def require_dependency(file_name, message = \"No such file to load -- %s.rb\")\n file_name = file_name.to_path if file_name.respond_to?(:to_path)\n unless file_name.is_a?(String)\n raise ArgumentError, \"the file name must either be a String or implement #to_path -- you passed #{file_name.inspect}\"\n end\n\n Dependencies.depend_on(file_name, message)\n end", "def add_to_dependency_load_paths #:nodoc:\n Dependencies.load_paths.concat(load_paths)\n end", "def load!\n metadata # force lazy evaluation to occur\n\n # re-raise any exception that occurred when reading the metadata\n raise_metadata_error!\n\n load_all_files\n\n remove_ignored_files\n\n if empty?\n raise Exceptions::CookbookNotFoundInRepo, \"The directory #{cookbook_path} does not contain a cookbook\"\n end\n\n cookbook_settings\n end", "def load!\n if(path)\n if(File.directory?(path))\n conf = Dir.glob(File.join(path, '*')).sort.inject(Smash.new) do |memo, file_path|\n memo.deep_merge(load_file(file_path))\n end\n elsif(File.file?(path))\n conf = load_file(path)\n else\n raise Errno::ENOENT.new path\n end\n conf\n end\n end", "def loadFile(filename)\n\t\t\tdescname = filename.basename.sub_ext(\"\").to_s + \"Desc\"\n\t\t\tif(!@loaded.include?(descname))\n\t\t\t\t@loaded << descname\n\n\t\t\t\tfilename = filename.to_s\n\t\t\t\tlast = $mec_mgr\n\n\t\t\t\t$mec_mgr = self\n\t\t\t\trequire(filename)\n\t\t\t\t$mec_mgr = last\n\t\t\t\t\n\t\t\t\tdesc = begin\n\t\t\t\t\tMakeRbExt.const_get(descname)\n\t\t\t\trescue NameError\n\t\t\t\t\traise(\"File `#{filename}' should contain a ruby module `#{descname}', but doesn't\")\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tdesc.register(@settings)\n\t\t\tend\n\t\tend", "def load_dependencies\n begin\n require 'cairo'\n rescue LoadError\n require 'rubygems'\n begin\n require 'cairo'\n rescue LoadError\n puts \"Compass::Canvas\\n_______________\\n\\n\"\n puts \"Unable to load Cairo backend. Please install it with the following command:\\n\\n\"\n puts \" gem install cairo\\n\\n\"\n puts \"For more information, please visit https://github.com/rcairo/rcairo\"\n raise\n end\n end\n end", "def load(file_path); end", "def load(file_path); end", "def add_elm_dependencies(filepath, context)\n # Turn e.g. ~/NoRedInk/app/assets/javascripts/Quiz/QuestionStoreAPI.js.elm\n # into just ~/NoRedInk/app/assets/javascripts/\n dirname = context.pathname.to_s.gsub Regexp.new(context.logical_path + \".+$\"), \"\"\n\n File.read(filepath).each_line do |line|\n # e.g. `import Quiz.QuestionStore exposing (..)`\n match = line.match(/^import\\s+([^\\s]+)/)\n\n unless match.nil?\n # e.g. Quiz.QuestionStore\n module_name = match.captures[0]\n\n # e.g. Quiz/QuestionStore\n dependency_logical_name = module_name.gsub(\".\", \"/\")\n\n # e.g. ~/NoRedInk/app/assets/javascripts/Quiz/QuestionStore.elm\n dependency_filepath = dirname + dependency_logical_name + \".elm\"\n\n # If we don't find the dependency in our filesystem, assume it's because\n # it comes in through a third-party package rather than our sources.\n if File.file? dependency_filepath\n context.depend_on dependency_logical_name\n\n add_elm_dependencies dependency_filepath, context\n end\n end\n end\n end", "def dependencies; end", "def dependencies; end", "def dependencies; end", "def load_packages\n pattern = File.expand_path(File.join(\"..\", \"*.rb\"), File.dirname(__FILE__)) \n Dir[pattern].each {|f| load f}\n end", "def load_graph\n # Create new graph\n @graph = Nanoc3::DirectedGraph.new([ nil ] + @items)\n\n # Get store\n return if !File.file?(self.filename)\n store = PStore.new(self.filename)\n\n # Load dependencies\n store.transaction do\n # Verify version\n return if store[:version] != STORE_VERSION\n\n # Load vertices\n @previous_items = store[:vertices].map do |v|\n @items.find { |i| i.identifier == v }\n end\n\n # Load edges\n store[:edges].each do |edge|\n from_index, to_index = *edge\n from, to = @previous_items[from_index], @previous_items[to_index]\n @graph.add_edge(from, to)\n end\n end\n end", "def load\n end", "def dependencies(path)\r\n deps = []\r\n open(path) do |file|\r\n deps = file.read.scan(/ [^\\s|\\\\]+/).collect { |s| s.strip }\r\n end\r\n deps.reject!{|s| s.include?(\"/opt\") || s.include?(\"/usr\") || s.include?(\"include/boost\")}\r\n deps\r\nend", "def load; end", "def load; end", "def load; end", "def load_file(file); end", "def load(filename)\n end", "def initialize(berksfile)\n @berksfile = berksfile\n @filepath = File.expand_path(\"#{berksfile.filepath}.lock\")\n @dependencies = {}\n\n load! if File.exists?(@filepath)\n end", "def require_files\n @load_paths.each do |path|\n Dir[\"#{path}/**/*\"].each do |f|\n require f\n end\n end\n end", "def load!\n activate!\n\n @require_paths.each do |path|\n begin\n require path\n rescue LoadError => error\n log \"dm-visualizer: unable to load #{path}\"\n log \"dm-visualizer: #{error.message}\"\n end\n end\n\n @require_globs.each do |glob|\n @include_dirs.each do |dir|\n Dir[File.join(dir,glob)].each do |path|\n relative_path = path[(dir.length + 1)..-1]\n\n begin\n require relative_path\n rescue LoadError => error\n log \"dm-visualizer: unable to load #{relative_path} from #{dir}\"\n log \"dm-visualizer: #{error.message}\"\n end\n end\n end\n end\n\n deactivate!\n return true\n end", "def load_factories_if_file(path)\n Kernel.load(\"#{path}.rb\") if File.exists?(\"#{path}.rb\")\n end", "def load\n @provider_dir = Path.provider\n\n # load base\n base_services = load_all_json(Path.named_path([:service_config, '*'], Path.provider_base))\n base_tags = load_all_json(Path.named_path([:tag_config, '*'], Path.provider_base))\n base_common = load_json(Path.named_path(:common_config, Path.provider_base))\n base_provider = load_json(Path.named_path(:provider_config, Path.provider_base))\n\n # load provider\n provider_path = Path.named_path(:provider_config, @provider_dir)\n common_path = Path.named_path(:common_config, @provider_dir)\n Util::assert_files_exist!(provider_path, common_path)\n @services = load_all_json(Path.named_path([:service_config, '*'], @provider_dir))\n @tags = load_all_json(Path.named_path([:tag_config, '*'], @provider_dir))\n @nodes = load_all_json(Path.named_path([:node_config, '*'], @provider_dir))\n @common = load_json(common_path)\n @provider = load_json(provider_path)\n @secrets = load_json(Path.named_path(:secrets_config, @provider_dir))\n\n # inherit\n @services.inherit_from! base_services\n @tags.inherit_from! base_tags\n @common.inherit_from! base_common\n @provider.inherit_from! base_provider\n @nodes.each do |name, node|\n @nodes[name] = apply_inheritance(node)\n end\n\n # validate\n validate_provider(@provider)\n end", "def load_libs; end", "def load_local\n files = lookup(CONFIG_FILE)\n file = files.find{ |f| File.file?(f) }\n new(*file)\n\n #if file\n # paths = [file]\n #else\n # dir = lookup(CONFIG_DIR).find{ |f| File.directory?(f) }\n # paths = dir ? Dir.glob(File.join(dir, '**/*')) : []\n #end\n #files = paths.select{ |path| File.file?(path) }\n end", "def load(file); end", "def load_setup\n setupFile = @properties[\"config/setup_file\"]\n return unless (setupFile and File.exist?(setupFile))\n file = File.new(setupFile)\n setup = file.read\n file.close\n instance_eval(setup)\n end", "def load_manifest\n files = [config.manifest_path, config.assets_manifest_path].select(&:exist?)\n files.map { |path| JSON.parse(path.read) }.inject({}, &:merge).tap(&method(:resolve_references))\n end", "def load_gemspec\n\n text = File.read(gemspec_file)\n if text =~ /\\A---/ \n require 'yaml'\n spec = YAML.load(text)\n else\n #spec = eval(text) #, gemspec_file)\n spec = ::Gem::Specification.load(gemspec_file)\n end\n\n data = {}\n data[:name] = spec.name\n data[:version] = spec.version.to_s\n data[:date] = spec.date\n\n data[:paths] = {\n 'load' => spec.require_paths \n }\n\n data[:requirements] = []\n\n spec.runtime_dependencies.each do |dep|\n req = { \n 'name' => dep.name,\n 'version' => dep.requirement.to_s\n }\n data[:requirements] << req\n end\n\n spec.development_dependencies.each do |dep|\n req = { \n 'name' => dep.name,\n 'version' => dep.requirement.to_s,\n 'development' => true\n }\n data[:requirements] << req\n end\n\n update(data)\n end", "def add_dep file, deps\r\n @flat_depends[file] = deps\r\n end", "def load_repo_config; end", "def load(file)\r\n if file.starts_with? '.'\r\n bootstrap_path = File.dirname(self.context().config.bootstrap_file)\r\n file = File.join(bootstrap_path, File.basename(file))\r\n end\r\n source_code = load_script_resource(file) # does *safe* IO\r\n load_service(file, source_code)\r\n end", "def dependencies(use_cache: false, debug: false)\n @dependencies ||= {}\n @loadbalancers ||= []\n @firewall_rules ||= []\n\n if @config.nil?\n return [@dependencies, @vpc, @loadbalancers]\n end\n if use_cache and @dependencies.size > 0\n return [@dependencies, @vpc, @loadbalancers]\n end\n @config['dependencies'] = [] if @config['dependencies'].nil?\n\n loglevel = debug ? MU::NOTICE : MU::DEBUG\n\n # First, general dependencies. These should all be fellow members of\n # the current deployment.\n @config['dependencies'].each { |dep|\n @dependencies[dep['type']] ||= {}\n next if @dependencies[dep['type']].has_key?(dep['name'])\n handle = @deploy.findLitterMate(type: dep['type'], name: dep['name']) if !@deploy.nil?\n if !handle.nil?\n MU.log \"Loaded dependency for #{self}: #{dep['name']} => #{handle}\", loglevel\n @dependencies[dep['type']][dep['name']] = handle\n else\n # XXX yell under circumstances where we should expect to have\n # our stuff available already?\n end\n }\n\n # Special dependencies: my containing VPC\n if self.class.can_live_in_vpc and !@config['vpc'].nil?\n @vpc, @nat = myVpc(@config['vpc'], loglevel: loglevel, debug: debug)\n elsif self.class.cfg_name == \"vpc\"\n @vpc = self\n end\n\n # Special dependencies: LoadBalancers I've asked to attach to an\n # instance.\n if @config.has_key?(\"loadbalancers\")\n @loadbalancers = [] if !@loadbalancers\n @config['loadbalancers'].each { |lb|\n MU.log \"Loading LoadBalancer for #{self}\", MU::DEBUG, details: lb\n if @dependencies.has_key?(\"loadbalancer\") and\n @dependencies[\"loadbalancer\"].has_key?(lb['concurrent_load_balancer'])\n @loadbalancers << @dependencies[\"loadbalancer\"][lb['concurrent_load_balancer']]\n else\n if !lb.has_key?(\"existing_load_balancer\") and\n !lb.has_key?(\"deploy_id\") and !@deploy.nil?\n lb[\"deploy_id\"] = @deploy.deploy_id\n end\n lbs = MU::MommaCat.findStray(\n @config['cloud'],\n \"loadbalancer\",\n deploy_id: lb[\"deploy_id\"],\n cloud_id: lb['existing_load_balancer'],\n name: lb['concurrent_load_balancer'],\n region: @config[\"region\"],\n calling_deploy: @deploy,\n dummy_ok: true\n )\n @loadbalancers << lbs.first if !lbs.nil? and lbs.size > 0\n end\n }\n end\n\n # Munge in external resources referenced by the existing_deploys\n # keyword\n if @config[\"existing_deploys\"] && !@config[\"existing_deploys\"].empty?\n @config[\"existing_deploys\"].each { |ext_deploy|\n if ext_deploy[\"cloud_id\"]\n found = MU::MommaCat.findStray(\n @config['cloud'],\n ext_deploy[\"cloud_type\"],\n cloud_id: ext_deploy[\"cloud_id\"],\n region: @config['region'],\n dummy_ok: false\n ).first\n \n MU.log \"Couldn't find existing resource #{ext_deploy[\"cloud_id\"]}, #{ext_deploy[\"cloud_type\"]}\", MU::ERR if found.nil?\n @deploy.notify(ext_deploy[\"cloud_type\"], found.config[\"name\"], found.deploydata, mu_name: found.mu_name, triggering_node: @mu_name)\n elsif ext_deploy[\"mu_name\"] && ext_deploy[\"deploy_id\"]\n MU.log \"#{self}: Importing metadata for #{ext_deploy[\"cloud_type\"]} #{ext_deploy[\"mu_name\"]} from #{ext_deploy[\"deploy_id\"]}\", MU::DEBUG\n found = MU::MommaCat.findStray(\n @config['cloud'],\n ext_deploy[\"cloud_type\"],\n deploy_id: ext_deploy[\"deploy_id\"],\n mu_name: ext_deploy[\"mu_name\"],\n region: @config['region'],\n dummy_ok: false\n ).first\n \n if found.nil?\n MU.log \"Couldn't find existing resource #{ext_deploy[\"mu_name\"]}/#{ext_deploy[\"deploy_id\"]}, #{ext_deploy[\"cloud_type\"]}\", MU::ERR\n else\n @deploy.notify(ext_deploy[\"cloud_type\"], found.config[\"name\"], found.deploydata, mu_name: ext_deploy[\"mu_name\"], triggering_node: @mu_name, no_write: true)\n end\n else\n MU.log \"Trying to find existing deploy, but either the cloud_id is not valid or no mu_name and deploy_id where provided\", MU::ERR\n end\n }\n end\n\n if @config['dns_records'] && !@config['dns_records'].empty?\n @config['dns_records'].each { |dnsrec|\n if dnsrec.has_key?(\"name\")\n if dnsrec['name'].start_with?(@deploy.deploy_id.downcase) && !dnsrec['name'].start_with?(@mu_name.downcase)\n MU.log \"DNS records for #{@mu_name} seem to be wrong, deleting from current config\", MU::WARN, details: dnsrec\n dnsrec.delete('name')\n dnsrec.delete('target')\n end\n end\n }\n end\n\n return [@dependencies, @vpc, @loadbalancers]\n end", "def load_file(filename); end", "def load_file(filename); end", "def load_pre_requisites\n if @yaml.nil?\n @log.info \"No configuration file specified --> returning.\"\n else\n build_catalog(\"staff\", @yaml[\"STAFF_CATALOG\"])\n build_catalog(\"student\", @yaml[\"STUDENT_CATALOG\"])\n @pre_requisites\n end\n end", "def compile_libraries\n events.library_load_start(count_files_by_segment(:libraries))\n cookbook_order.each do |cookbook|\n eager_load_libraries = cookbook_collection[cookbook].metadata.eager_load_libraries\n if eager_load_libraries == true # actually true, not truthy\n load_libraries_from_cookbook(cookbook)\n else\n $LOAD_PATH.unshift File.expand_path(\"libraries\", cookbook_collection[cookbook].root_dir)\n if eager_load_libraries # we have a String or Array<String> and not false\n load_libraries_from_cookbook(cookbook, eager_load_libraries)\n end\n end\n end\n events.library_load_complete\n end", "def load(filename)\n\t\tend", "def process_dependencies(data)\n import_paths = data.scan(IMPORT_SCANNER).flatten.compact.uniq\n import_paths.each do |path|\n pathname = begin\n #TODO: use resolve to partialize paths\n context.resolve(path)\n rescue Sprockets::FileNotFound\n nil\n end\n \n unless pathname.nil? || passthrough?(pathname)\n # mark dependency in Sprockets context\n context.depend_on(path)\n # recurse for more dependencies\n process_dependencies File.read(pathname)\n end\n end\n end", "def load(path); end", "def load\n if File.exists? @file\n @main = YAML::load_file @file\n else\n self.load_defaults\n end\n end", "def lookup!\n $LOAD_PATH.each do |base|\n Dir[File.join(base, *file_lookup_paths)].each do |path|\n path = path.delete_prefix(\"#{base}/\")\n require path\n rescue Exception\n # No problem\n end\n end\n end", "def load\n if File.exist?(@file_path)\n\n @_cache = JSON File.open(@file_path, &:read).strip\n else\n $stderr.puts \"#{@file_path} does not exist\"\n end\n end", "def dependencies(recurse: true)\n return @dependencies if @dependencies\n depends = yaml['depends']\n if depends.nil? || depends.empty?\n @dependencies = nil\n else\n @dependencies = depends.map do |name, dependency|\n reader = StackFileLoader.for(dependency['stack'], self)\n deps = { 'name' => name, 'stack' => reader.source, 'variables' => dependency.fetch('variables', Hash.new) }\n if recurse\n child_deps = reader.dependencies\n deps['depends'] = child_deps unless child_deps.nil?\n end\n deps\n end\n end\n end", "def load(force_load = false)\n if not @deploys || force_load\n @deploys = begin\n deploys = Array.new\n hosts = @connection.hosts.all\n hosts.each do |host|\n deploy = Deploy.new(@connection)\n deploy.retrieve(host.name)\n if deploy.name\n host.add_deploy(deploy)\n deploys << deploy\n end\n end\n deploys\n end\n end\n @deploys\n end", "def dependencies\n @dependencies ||= {}\n end", "def load\n instance_eval File.read(@path).tap(&Gem::UNTAINT), @path, 1\n\n self\n end", "def load(options={})\r\n @before_load_proc = options[:before_load]\r\n @after_load_proc = options[:after_load]\r\n files = @file_provider.call \r\n @num_files = files.size\r\n @files_added = []\r\n @files_changed = []\r\n @files_removed = []\r\n @change_detector.check_files(files)\r\n @progress_monitor = ProgressMonitor.new(options[:on_progress], @files_added + @files_changed)\r\n @files_added.each {|f| file_added(f)}\r\n @files_changed.each {|f| file_changed(f)}\r\n @files_removed.each {|f| file_removed(f)}\r\n @resolver.resolve_model(@model)\r\n end", "def depends_on(*args)\n @depends_on ||= DSL::DependsOn.new\n return @depends_on if args.empty?\n\n begin\n @depends_on.load(*args)\n rescue RuntimeError => e\n raise CaskInvalidError.new(cask, e)\n end\n @depends_on\n end", "def require_or_load(file_name)\n if !associations_loaded.include?(file_name)\n associations_loaded << file_name\n reload_associations ? load(\"#{file_name}.rb\") : require(file_name)\n end\n end", "def load(wrap=false)\n resolve_load_path\n load_file(wrap)\n end", "def load\n end", "def load\n end", "def get_dependencies_from_path(metadata_path)\n metadata = JSON.parse(File.read(metadata_path), symbolize_names: true)\n get_dependencies_from_metadata(metadata)\n end", "def load!\n return false if loaded?\n @_called_from = first_caller\n Padrino.set_encoding\n Padrino.set_load_paths(*load_paths) # We set the padrino load paths\n Padrino::Logger.setup! # Initialize our logger\n Padrino.require_dependencies(\"#{root}/config/database.rb\", :nodeps => true) # Be sure to don't remove constants from dbs.\n Padrino::Reloader.lock! # Now we can remove constant from here to down\n Padrino.before_load.each(&:call) # Run before hooks\n Padrino.dependency_paths.each { |path| Padrino.require_dependencies(path) }\n Padrino.after_load.each(&:call) # Run after hooks\n Padrino::Reloader.run!\n Thread.current[:padrino_loaded] = true\n end", "def load_libs\n loadQueue = []\n Pathname.glob './lib/*.rb' do |script|\n require script.to_s\n scriptfolder = Pathname.new(script.to_s.gsub('.rb', ''))\n next if not scriptfolder.directory?\n\n loadQueue += scriptfolder.children(true).find_all {|file| file.to_s[-3..-1] == '.rb'}\n end\n \n # load the children\n loadQueue.each {|file| require file.to_s }\n end", "def load\r\n \r\n end" ]
[ "0.76913065", "0.76774323", "0.73476964", "0.71030635", "0.7047796", "0.6935037", "0.68620163", "0.68116766", "0.66445124", "0.6644166", "0.65944886", "0.65821755", "0.65745914", "0.653909", "0.65299064", "0.645695", "0.6456933", "0.6388073", "0.63791734", "0.6330047", "0.6326147", "0.6326147", "0.6161962", "0.6116935", "0.61089253", "0.6050151", "0.60367936", "0.6030394", "0.6011094", "0.5990069", "0.59766227", "0.59503603", "0.5947667", "0.59098315", "0.59060305", "0.59033614", "0.5902955", "0.5902955", "0.5902955", "0.5887568", "0.5880117", "0.58706003", "0.5869136", "0.58683115", "0.58504355", "0.5835418", "0.5829808", "0.5829808", "0.5829211", "0.5813554", "0.5813554", "0.5813554", "0.5806792", "0.579703", "0.5795991", "0.57900286", "0.577797", "0.577797", "0.577797", "0.5777719", "0.57496846", "0.57461286", "0.57344806", "0.57165295", "0.5705836", "0.56987375", "0.5695676", "0.5689346", "0.5688101", "0.56738937", "0.5673418", "0.5671608", "0.5669038", "0.5666094", "0.5659846", "0.56598276", "0.56594104", "0.56594104", "0.5658878", "0.56552356", "0.565503", "0.5653461", "0.56491554", "0.5642904", "0.5635841", "0.563579", "0.5630748", "0.56255496", "0.56203854", "0.56170356", "0.5615432", "0.5614125", "0.5610582", "0.5602885", "0.5595011", "0.5595011", "0.5592656", "0.5588721", "0.55885196", "0.55799" ]
0.7262908
3
Gem Dependency API methods Declare a dependency on a gem. Ignores every option except :group.
def gem( name, *requirements, **options ) if options[:group] == :development || options[:groups]&.include?( :development ) || self.current_groups.include?( :development ) requirements.push( :development ) end dependency = Gem::Dependency.new( name, *requirements ) self.dependencies.add( dependency ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gem(name, *reqs)\n if dep = @dependency_names[name]\n dep.requirement.concat reqs\n else\n dep = Gem::Dependency.new name, *reqs\n @dependency_names[name] = dep\n @dependencies << dep\n end\n end", "def gem(name, *reqs)\n @dependencies << Gem::Dependency.new(name, reqs)\n end", "def gem(name, *reqs)\n @dependencies << Gem::Dependency.new(name, reqs)\n end", "def depend_on( name, version = nil )\n spec = Gem::Specification.find_by_name(name)\n version = spec.version.to_s if version.nil? and !spec.nil?\n\n PROJ.gem.dependencies << case version\n when nil; [name]\n when %r/^\\d/; [name, \">= #{version}\"]\n else [name, version] end\nend", "def depends_on(package, *version)\n dependencies << [ package, *version ]\n end", "def gemspec(options = {})\n name = options.delete(:name) || '{,*}'\n path = options.delete(:path) || '.'\n development_group = options.delete(:development_group) || :development\n\n spec = find_gemspec name, path\n\n groups = gem_group spec.name, {}\n\n self_dep = Gem::Dependency.new spec.name, spec.version\n\n add_dependencies groups, [self_dep]\n add_dependencies groups, spec.runtime_dependencies\n\n @dependencies[spec.name] = Gem::Requirement.source_set\n\n spec.dependencies.each do |dep|\n @dependencies[dep.name] = dep.requirement\n end\n\n groups << development_group\n\n add_dependencies groups, spec.development_dependencies\n\n @vendor_set.add_vendor_gem spec.name, path\n gem_requires spec.name, options\n end", "def gem\n if dependency\n GemsBond::Gem.new(dependency)\n else\n unknown_dependency = Bundler::Dependency.new(@name, nil)\n GemsBond::Gem.new(unknown_dependency, unknown: true)\n end\n end", "def depend_on( name, version = nil )\n spec = Gem.source_index.find_name(name).last\n version = spec.version.to_s if version.nil? and !spec.nil?\n\n PROJ.gem.dependencies << case version\n when nil; [name]\n when %r/^\\d/; [name, \">= #{version}\"]\n else [name, version] end\nend", "def gemspec( * )\n\t\traise \"Circular dependency: can't depend on the gemspec to build itself\"\n\tend", "def add_dependencies(groups, dependencies) # :nodoc:\n return unless (groups & @without_groups).empty?\n\n dependencies.each do |dep|\n @set.gem dep.name, *dep.requirement.as_list\n end\n end", "def depends_on(pkg)\n autobuild.depends_on(pkg.autobuild)\n end", "def version_required(gem_def)\n return Gem::Dependency.instance_methods.map(&:to_sym).include?(:requirement) ? gem_def.requirement : gem_def.version_requirements\nend", "def gem_requires(name, options) # :nodoc:\n if options.include? :require\n if requires = options.delete(:require)\n @requires[name].concat Array requires\n end\n else\n @requires[name] << name\n end\n raise ArgumentError, \"Unhandled gem options #{options.inspect}\" unless options.empty?\n end", "def add_dependency id, version, target_framework = '', group = true\n guard_groups_or_not group\n extra = (target_framework || '') == '' ? '' : \"|#{target_framework}\"\n @has_group ||= group\n @dependencies[\"#{id}#{extra}\"] = IdVersion.new id, version, group, target_framework\n end", "def standard_dependency(code, group, base_artifact, target_version, options = {})\n artifacts = []\n\n options = options.dup\n\n standard_suffixes = %w(\n shared:jar\n model:jar model-qa-support:jar\n replicant-shared:jar replicant-qa-support:jar\n gwt:jar gwt-qa-support:jar\n server:war\n server:jar server-qa-support:jar\n db:jar\n integration-qa-support:jar\n sync_model:jar\n soap-client:jar soap-qa-support:jar\n )\n\n %W(#{group} #{group}.pg).each do |g|\n ((options[:additional_artifacts] || []) + %W(domains-#{base_artifact}:json) + standard_suffixes).\n each do |artifact_suffix|\n artifacts << \"#{g}:#{base_artifact}-#{artifact_suffix}\"\n end\n end\n\n desc \"Update the #{code} dependencies in build.yaml\"\n command(:\"patch_#{code}_dep\") do |app|\n patch_versions(app, artifacts, target_version, options)\n end\n end", "def require_gems; end", "def require_gem(gem)\n dep = fetch(:required_gems)\n dep ||= []\n if gem.respond_to?(:each)\n dep += gem\n else\n dep << gem\n end\n set(:required_gems, dep)\n end", "def dependency name, version, type = :runtime\n raise \"Unknown dependency type: #{type}\" unless\n [:runtime, :dev, :development, :developer].include? type\n\n ary = if type == :runtime then\n extra_deps\n else\n extra_dev_deps\n end\n\n ary << [name, version]\n end", "def library_project(dependencies, group, name, version, options = {:exclude => [\"META-INF/MANIFEST.MF\"], :include => [], :manifest => {}})\n options[:manifest] ||= {} \n options[:include] ||= []\n options[:exclude] ||= []\n deps_as_str = []\n # We create an object and we extend with the module so we can get access to the walk_libs method.\n walker = Object.new \n walker.extend Buildr4OSGi::BuildLibraries::LibraryProject\n walker.walk_libs(dependencies) {|lib|\n deps_as_str << lib.to_spec\n }\n deps_as_str = deps_as_str.flatten.inspect\n exclusion = options[:exclude].collect {|exclusion| \".exclude(#{exclusion.inspect})\"}.join if options[:exclude]\n inclusion = options[:include].collect {|inclusion| \".include(#{inclusion.inspect})\"}.join if options[:include]\n exclusion ||= \"\"\n inclusion ||= \"\"\n eval %{\n desc \"#{name}\"\n define \"#{name}\" do\n project.extend Buildr4OSGi::LibraryProject\n #{\"project.version = \\\"#{version}\\\"\" if version}\n #{\"project.group = \\\"#{group}\\\"\" if group}\n\n package(:library_project).tap {|jar|\n jar.enhance {|task|\n walk_libs(#{deps_as_str}) {|lib|\n lib.invoke # make sure the artifact is present.\n task.merge(lib)#{exclusion}#{inclusion}\n }\n }\n entries = []\n names = []\n walk_libs(#{deps_as_str}) {|lib|\n names << lib.to_spec \n lib.invoke # make sure the artifact is present.\n Zip::ZipFile.foreach(lib.to_s) {|entry| \n if /.*\\\\.class$/.match(entry.name)\n add_to_entries = true\n [#{options[:exclude].inspect}].flatten.each {|excluded|\n add_to_entries &&= !entry.name.match(excluded)\n }\n [#{options[:include].inspect}].flatten.each {|included|\n add_to_entries &&= included.match(entry.name)\n }\n entries << entry.name.sub(/(.*)\\\\/.*.class$/, '\\\\1').gsub(/\\\\//, '.') if add_to_entries\n end\n }\n }\n lib_manifest = { \n \"Bundle-Version\" => \"#{version}\",\n \"Bundle-SymbolicName\" => project.name,\n \"Bundle-Name\" => names.join(\", \"),\n \"Bundle-Vendor\" => \"Intalio, Inc.\"\n }\n lib_manifest[\"Export-Package\"] = entries.uniq.sort.join(\",\") unless entries.empty?\n lib_manifest[\"Bundle-ManifestVersion\"] = \"2\"\n jar.with :manifest => lib_manifest.merge(#{options[:manifest].inspect})\n \n \n }\n package(:sources).tap do |task|\n task.enhance do\n walk_libs(#{deps_as_str}) {|lib|\n lib_src = Buildr::artifact(lib.to_hash.merge(:classifier => \"sources\"))\n lib_src.extend Buildr4OSGi::SkipSourceDownload\n lib_src.invoke # make sure the artifact is present.\n \n task.merge(lib_src)#{exclusion}#{inclusion} if File.exist?(lib_src.to_s)\n }\n end\n end\n end\n }\n end", "def require!\n super do\n gem @gem_name, @version if @version\n end\n end", "def gem_dependencies(list, gem_dependencies, options = {})\n gem_dependencies.each do |gd|\n if options['excludes'] && options['excludes'].to_s.split(',').include?(gd.name)\n next\n end\n\n gs = gd.matching_specs.first\n if gs\n unless list[gs.name]\n list[gs.name] = gs\n unless gs.dependencies.empty?\n list = gem_dependencies(list, gs.dependencies, options)\n end\n end\n else\n unless list[gd.name]\n list[gd.name] = Gem::Specification.new(\n gd.name,\n gd.requirements_list.last.scan(/[\\d\\.\\w]+/).first\n )\n rm_dep = remote_dependencies(gd.name, gd.requirements_list.last)\n unless rm_dep.empty?\n list = gem_dependencies(list, rm_dep, options)\n end\n end\n end\n end\n\n list\n end", "def package_depends_on\n depends_on\n end", "def dependency\n @dependency ||= Bundler.load.gems.find { |dep| dep.name == @name }\n end", "def gem(name, *requirements)\n options = requirements.pop if requirements.last.kind_of?(Hash)\n options ||= {}\n\n options[:git] = @current_repository if @current_repository\n\n source_set = false\n\n source_set ||= gem_path name, options\n source_set ||= gem_git name, options\n source_set ||= gem_git_source name, options\n source_set ||= gem_source name, options\n\n duplicate = @dependencies.include? name\n\n @dependencies[name] =\n if requirements.empty? and not source_set\n Gem::Requirement.default\n elsif source_set\n Gem::Requirement.source_set\n else\n Gem::Requirement.create requirements\n end\n\n return unless gem_platforms name, options\n\n groups = gem_group name, options\n\n return unless (groups & @without_groups).empty?\n\n pin_gem_source name, :default unless source_set\n\n gem_requires name, options\n\n if duplicate\n warn <<-WARNING\nGem dependencies file #{@path} requires #{name} more than once.\n WARNING\n end\n\n @set.gem name, *requirements\n end", "def required(gem_name, gem_install_name = nil)\n Required::required gem_name, gem_install_name\nend", "def dependencies(pkg)\n pkg.resolve_optional_dependencies\n deps_rock_packages = pkg.dependencies.map do |pkg_name|\n debian_name(Autoproj.manifest.package(pkg_name).autobuild)\n end.sort\n\n pkg_osdeps = Autoproj.osdeps.resolve_os_dependencies(pkg.os_packages)\n # There are limitations regarding handling packages with native dependencies\n #\n # Currently gems need to converted into debs using gem2deb\n # These deps dependencies are updated here before uploading a package\n # \n # Generation of the debian packages from the gems can be done in postprocessing step\n # i.e. see convert_gems\n \n deps_osdeps_packages = []\n native_package_manager = Autoproj.osdeps.os_package_handler\n _, native_pkg_list = pkg_osdeps.find { |handler, _| handler == native_package_manager }\n\n deps_osdeps_packages += native_pkg_list if native_pkg_list\n\n # Update global list\n @osdeps += deps_osdeps_packages\n\n non_native_handlers = pkg_osdeps.collect do |handler, pkg_list|\n if handler != native_package_manager\n [handler, pkg_list]\n end\n end.compact\n\n non_native_handlers.each do |pkg_handler, pkg_list|\n # Convert native ruby gems package names to rock-xxx \n if pkg_handler.kind_of?(Autoproj::PackageManagers::GemManager)\n pkg_list.each do |name,version|\n @ruby_gems << [name,version]\n deps_osdeps_packages << debian_ruby_name(name)\n end\n else\n raise ArgumentError, \"cannot package #{pkg.name} as it has non-native dependencies (#{pkg_list}) -- #{pkg_handler.class} #{pkg_handler}\"\n end\n end\n\n # Remove duplicates\n @osdeps.uniq!\n @ruby_gems.uniq!\n\n # Return rock packages and osdeps\n [deps_rock_packages, deps_osdeps_packages]\n end", "def parse_dependency(name, op) # :nodoc:\n return Gem::Dependency.new name, op unless peek[0] == :text\n\n version = get(:text).value\n\n requirements = [\"#{op} #{version}\"]\n\n while peek.type == :comma do\n get :comma\n op = get(:requirement).value\n version = get(:text).value\n\n requirements << \"#{op} #{version}\"\n end\n\n Gem::Dependency.new name, requirements\n end", "def gem_group(name, options) # :nodoc:\n g = options.delete :group\n all_groups = g ? Array(g) : []\n\n groups = options.delete :groups\n all_groups |= groups if groups\n\n all_groups |= @current_groups if @current_groups\n\n all_groups\n end", "def install_gem(gem_name, options = {})\n if options[:group]\n gem gem_name, group: options[:group]\n else\n gem gem_name\n end\n run_command \"gem install #{gem_name}\"\n run_command 'bundle install --local'\nend", "def missing_deps_for(gem)\n # Comparison by name here assuming if it is in existing spec,\n # spec author will have ensured versions are correct for their purposes\n gem.deps.select { |dep| requirements_for_gem(dep.name).empty? }\n end", "def dependency(dep, ver = nil)\n @dep_loader.add_dependency dep, ver\n end", "def use(*specs)\n named = specs.flatten.inject({}) do |seen, spec|\n if Hash === spec && (spec.keys & ActsAsArtifact::ARTIFACT_ATTRIBUTES).empty?\n spec.each_pair do |name, spec|\n if ArtifactNamespace === spec # create as subnamespace\n raise ArgumentError.new(\"Circular reference\") if self == spec\n registry[name.to_sym] = spec\n elsif Numeric === spec || (String === spec && VersionRequirement.version?(spec))\n artifact = ArtifactRequirement.allocate\n artifact.name = name\n artifact.version = spec.to_s\n seen[artifact.name] ||= artifact\n elsif Symbol === spec\n self.alias name, spec\n elsif Array === spec # a group\n seen[name] ||= spec.map { |s| ArtifactRequirement.new(s) }\n else\n artifact = ArtifactRequirement.new(spec)\n artifact.name = name\n seen[artifact.name] ||= artifact\n end\n end\n else\n if Symbol === spec\n artifact = get(spec).dclone\n else\n artifact = ArtifactRequirement.new(spec)\n end\n seen[artifact.name] ||= artifact\n end\n seen\n end\n named.each_pair do |name, artifact|\n is_group = Array === artifact\n artifact = [artifact].flatten.map do |artifact|\n unvers = artifact.unversioned_spec\n previous = get(unvers, false) || get(name, false)\n if previous # have previous on current namespace\n if previous.requirement # we must satisfy the requirement\n if unvers\n satisfied = previous.satisfied_by?(artifact)\n else # we only have the version\n satisfied = previous.requirement.satisfied_by?(artifact.version)\n end\n raise \"Unsatisfied dependency #{previous} \" +\n \"not satisfied by #{artifact}\" unless satisfied\n previous.version = artifact.version # OK, set new version\n artifact = previous # use the same object for aliases\n else # not a requirement, set the new values\n unless artifact.id == previous.id && name != previous.name\n previous.copy_attrs(artifact)\n artifact = previous\n end\n end\n else\n if unvers.nil? && # we only have the version\n (previous = get(unvers, true, false, false))\n version = artifact.version\n artifact.copy_attrs(previous)\n artifact.version = version\n end\n artifact.requirement = nil\n end\n artifact.selected!\n end\n artifact = artifact.first unless is_group\n if is_group\n names = artifact.map do |art|\n unv = art.unversioned_spec\n registry[unv] = art\n unv\n end\n group(name, *(names + [{:namespace => self}]))\n elsif artifact.id\n unvers = artifact.unversioned_spec\n registry[name] = artifact\n registry.alias unvers, name\n else\n registry[name] = artifact\n end\n end\n self\n end", "def depended(pkg)\n abort 'No such package exists.' unless @pkg.key?(pkg)\n warn 'Warning: A option to display obsolete package is available only for finding orphan.' if @include_obsolete\n\n sputs \"Package(s) depended on #{pkg}\"\n putpkg(getdeps(pkg))\n end", "def dependencies=(_arg0); end", "def bundler_dependencies_for(bundler_runtime, *groups); end", "def dependencies; end", "def dependencies; end", "def dependencies; end", "def gemspec?; end", "def requirement\n @dependency.requirement\n end", "def gem(*args)\n options = args.extract_options!\n name, version = args\n\n # Set the message to be shown in logs. Uses the git repo if one is given,\n # otherwise use name (version).\n parts, message = [ name.inspect ], name\n if version ||= options.delete(:version)\n parts << version.inspect\n message << \" (#{version})\"\n end\n message = options[:git] if options[:git]\n\n log :gemfile, message\n\n parts_without_group = parts.clone\n options.each do |option, value|\n str = \"#{option}: #{value.inspect}\"\n parts << str\n parts_without_group << str unless option == :group\n end\n\n in_root do\n if options.key?(:group)\n # remove brackets if any and prepend colon if missing\n group = options[:group].inspect.scan(/[[^\\[\\]]]/).join.to_sym\n\n group_definition = \"group #{group} do\"\n str = \"gem #{parts_without_group.join(\", \")}\"\n return if append_to_gem_group(group_definition, str.gsub(/\\\"/, '\\''))\n end\n\n str = \"gem #{parts.join(\", \")}\"\n str = \" \" + str if @in_group\n str = \"\\n\" + str\n append_file \"Gemfile\", str.gsub(/\\\"/, '\\'')\n end\nend", "def build_gem; end", "def add_dependencies\n self.extra_deps = normalize_deps extra_deps\n self.extra_dev_deps = normalize_deps extra_dev_deps\n\n case name\n when \"hoe\" then\n # do nothing? these deps are already in the hoe spec in the Rakefile\n else\n version = VERSION.split(/\\./).first(2).join(\".\")\n dependency \"hoe\", \"~> #{version}\", :development\n end\n\n seen = {}\n\n extra_deps.each do |dep|\n next if seen[dep.first]\n seen[dep.first] = true\n\n spec.add_dependency(*dep)\n end\n\n extra_dev_deps.each do |dep|\n next if seen[dep.first]\n seen[dep.first] = true\n\n spec.add_development_dependency(*dep)\n end\n end", "def gem(name, requirement = nil)\n gems << Gem.new(name, requirement)\n end", "def requires(package, *args)\n @packages << [package, args]\n end", "def expand_dependency(dependency, parent)\n\t\t\t\t# The job of this function is to take a dependency and turn it into 0 or more provisions. The dependency could be a normal fully-qualified name or a wildcard. It's not clear at which point pattern matching should affect dependency resolution, but it seems logical since it depends on the available provisions that it's done here.\n\t\t\t\t# Another benefit is that it introduces a fixed point of reference for expanding dependencies. When the resolver invokes this method, it can be assured that it will return the same result.\n\t\t\t\tif dependency.wildcard?\n\t\t\t\t\treturn expand_wildcard(dependency, parent)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t# Mostly, only one package will satisfy the dependency...\n\t\t\t\tviable_providers = @providers.select{|provider| provider.provides? dependency}\n\t\t\t\t\n\t\t\t\t# puts \"** Found #{viable_providers.collect(&:name).join(', ')} viable providers.\"\n\t\t\t\t\n\t\t\t\tif viable_providers.size == 1\n\t\t\t\t\tprovider = viable_providers.first\n\t\t\t\t\tprovision = provision_for(provider, dependency)\n\t\t\t\t\t\n\t\t\t\t\t# The best outcome, a specific provider was named:\n\t\t\t\t\treturn [provision]\n\t\t\t\telsif viable_providers.size > 1\n\t\t\t\t\t# ... however in some cases (typically where aliases are being used) an explicit selection must be made for the build to work correctly.\n\t\t\t\t\texplicit_providers = filter_by_selection(viable_providers)\n\t\t\t\t\t\n\t\t\t\t\t# puts \"** Filtering to #{explicit_providers.collect(&:name).join(', ')} explicit providers.\"\n\t\t\t\t\t\n\t\t\t\t\tif explicit_providers.size != 1\n\t\t\t\t\t\t# If we were unable to select a single package, we may use the priority to limit the number of possible options:\n\t\t\t\t\t\texplicit_providers = viable_providers if explicit_providers.empty?\n\t\t\t\t\t\t\n\t\t\t\t\t\texplicit_providers = filter_by_priority(explicit_providers)\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tif explicit_providers.size == 0\n\t\t\t\t\t\t# No provider was explicitly specified, thus we require explicit conflict resolution:\n\t\t\t\t\t\t@conflicts[dependency] = viable_providers\n\t\t\t\t\telsif explicit_providers.size == 1\n\t\t\t\t\t\tprovider = explicit_providers.first\n\t\t\t\t\t\tprovision = provision_for(provider, dependency)\n\t\t\t\t\t\t\n\t\t\t\t\t\t# The best outcome, a specific provider was named:\n\t\t\t\t\t\treturn [provision]\n\t\t\t\t\telse\n\t\t\t\t\t\t# Multiple providers were explicitly mentioned that satisfy the dependency.\n\t\t\t\t\t\t@conflicts[dependency] = explicit_providers\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn []\n\t\t\tend", "def depend(location, type, *args)\n if type == :gemfile\n registry = GemInstaller::Registry.new\n config_builder = registry.config_builder\n path = args.pop\n config_builder.config_file_paths = path\n config = config_builder.build_config\n gems = config.gems\n \n gems.each do |agem|\n # gem() function defined in Capistrano's RemoteDependency class\n options = pluck_accessor_hash(agem, [:platform, :install_options, :check_for_upgrade, :no_autogem, :fix_dependencies])\n depend_without_gemfile(location, :gem, agem.name, agem.version, options)\n end\n else\n depend_without_gemfile(location, type, *args)\n end\n end", "def add_dependency(name)\n dependencies[name]\n end", "def cmake_package(options, &block)\n package_common(:cmake, options) do |pkg|\n pkg.depends_on 'cmake'\n common_make_based_package_setup(pkg)\n yield(pkg) if block_given?\n end\nend", "def excludes_dep?(gem_name)\n excluded_deps.any? { |d| d.name == gem_name }\n end", "def dependency_target\n self.name == \"hoe\" ? extra_deps : extra_dev_deps\n end", "def set_package_system_dependency\n @package_system_dependency = PackageSystemDependency.find(params[:id])\n end", "def gem_requirements_from_array(what, array)\n array.map do |dep|\n Gem::Dependency.new(what, *dep)\n end\n end", "def add_dependency(path, dependency); end", "def private_gem(name)\n gem name, '0.3.0', git: \"https://#{ENV['GITHUB_TOKEN']}:x-oauth-basic@github.com/mharris717/#{name}.git\", branch: :master\nend", "def load_gemdeps(path, without_groups = [], installing = false)\n @git_set = Gem::Resolver::GitSet.new\n @vendor_set = Gem::Resolver::VendorSet.new\n @source_set = Gem::Resolver::SourceSet.new\n\n @git_set.root_dir = @install_dir\n\n lock_file = \"#{File.expand_path(path)}.lock\".dup.tap(&Gem::UNTAINT)\n begin\n tokenizer = Gem::RequestSet::Lockfile::Tokenizer.from_file lock_file\n parser = tokenizer.make_parser self, []\n parser.parse\n rescue Errno::ENOENT\n end\n\n gf = Gem::RequestSet::GemDependencyAPI.new self, path\n gf.installing = installing\n gf.without_groups = without_groups if without_groups\n gf.load\n end", "def version_constraint(gem_name); end", "def require_matched_dependency_version\n false\n end", "def add_development_dependency(gem, *requirements)\n add_dependency_with_type(gem, :development, requirements)\n end", "def register_dependency(dep, version)\n GemDependency.create!(\n laser_gem: self,\n dependency: dep,\n version: version,\n )\n self.reload\n end", "def need(*specs)\n named = specs.flatten.inject({}) do |seen, spec|\n if Hash === spec && (spec.keys & ActsAsArtifact::ARTIFACT_ATTRIBUTES).empty?\n spec.each_pair do |name, spec|\n if Array === spec # a group\n seen[name] ||= spec.map { |s| ArtifactRequirement.new(s) }\n else\n artifact = ArtifactRequirement.new(spec)\n artifact.name = name\n seen[artifact.name] ||= artifact\n end\n end\n else\n artifact = ArtifactRequirement.new(spec)\n seen[artifact.name] ||= artifact\n end\n seen\n end\n named.each_pair do |name, artifact|\n if Array === artifact # a group\n artifact.each do |a|\n unvers = a.unversioned_spec\n previous = registry[unvers]\n if previous && previous.selected? && a.satisfied_by?(previous)\n a.version = previous.version\n end\n registry[unvers] = a\n end\n group(name, *(artifact.map { |a| a.unversioned_spec } + [{:namespace => self}]))\n else\n unvers = artifact.unversioned_spec\n previous = registry.get(unvers, true)\n if previous && previous.selected? && artifact.satisfied_by?(previous)\n artifact.version = previous.version\n artifact.selected!\n end\n registry[unvers] = artifact\n registry.alias name, unvers unless name.to_s[/^\\s*$/]\n end\n end\n self\n end", "def add_dependency_group(dependency_group)\n @dependency_groups.push dependency_group.to_sym\n\n dependency_group\n end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def depends(name)\n @dependencies << name unless @dependencies.include?(name)\n end", "def add_dependency(name, version_requirement=nil, repository=nil)\n validate_name(name)\n validate_version_range(version_requirement) if version_requirement\n\n if dup = @data['dependencies'].find { |d| d.full_module_name == name && d.version_requirement != version_requirement }\n raise ArgumentError, \"Dependency conflict for #{full_module_name}: Dependency #{name} was given conflicting version requirements #{version_requirement} and #{dup.version_requirement}. Verify that there are no duplicates in the metadata.json or the Modulefile.\"\n end\n\n dep = Dependency.new(name, version_requirement, repository)\n @data['dependencies'].add(dep)\n\n dep\n end", "def autotools_package(options, &block)\n package_common(:autotools, options) do |pkg|\n pkg.depends_on 'autotools'\n common_make_based_package_setup(pkg)\n yield(pkg) if block_given?\n end\nend", "def gem_group(*names, &block)\n options = names.extract_options!\n str = names.map(&:inspect)\n str << quote(options) unless options.empty?\n str = str.join(\", \")\n log :gemfile, \"group #{str}\"\n\n in_root do\n append_file \"Gemfile\", \"\\ngroup #{str} do\", force: true\n with_indentation(&block)\n append_file \"Gemfile\", \"\\nend\\n\", force: true\n end\n end", "def remote_dependencies(gem_name, _version)\n conn = Faraday.new(url: 'https://rubygems.org') do |h|\n h.headers[:content_type] = 'application/x-www-form-urlencoded'\n h.request :url_encoded\n h.adapter :excon\n end\n response = conn.get(\"/api/v1/gems/#{gem_name}.json\")\n dep_list = MultiJson.load(response.body)\n dep_list['dependencies'].values.flatten.map do |j|\n Gem::Dependency.new(\n j['name'],\n Gem::Requirement.new(j['requirements'].split(','))\n )\n end\n end", "def core_fetch_dependency(package_name, vers, type, verbose)\n prerelease = false\n if vers == '>= 0-pre'\n prerelease = true\n vers = '>= 0'\n else\n prerelease = vers =~ /[a-zA-Z]/\n end\n\n dep = LibGems::Dependency.new(package_name, vers, type)\n cur_installed = LibGems.source_index.search(dep)\n\n begin\n installed = BPM::Remote.new.install(package_name, vers, prerelease)\n rescue LibGems::GemNotFoundException\n # If we have it locally but not remote, that's ok\n installed = []\n end\n\n cur_installed.each do |ci|\n installed.reject! { |i| ci.name == i.name && ci.version == i.version }\n end\n\n installed.each do |i|\n say \"~ Fetched #{i.name} (#{i.version}) from remote\"\n end\n\n end", "def missing_dev_deps_for(gem)\n # Same note as in #missing_deps_for above\n gem.dev_deps.select { |dep| build_requirements_for_gem(dep.name).empty? }\n end", "def cask(name); dep name, :template => \"icelab:cask\"; end", "def build_component(dependency)\n super.merge({\n \"scope\": dependency[:scope]\n })\n end", "def build_requirements_for_gem(gem_name)\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| r.gem_name == gem_name }\n end", "def activate_publish_deps\n dependency \"rdoc\", [\">= 4.0\", \"< 7\"], :developer if need_rdoc\n end", "def direct_dependencies; end", "def custom_gem(name, options = Hash.new)\n local_path = File.expand_path \"../vendor/#{name}\", __FILE__\n\n if File.exist? local_path\n options = options.merge :path => local_path\n options.delete_if do |key, _|\n [:github, :branch].include? key\n end\n end\n\n gem name, options\nend", "def extra_gem_build_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_build_requirements - gem_reqs\n end", "def extra_gem_build_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_build_requirements - gem_reqs\n end", "def needpackage *args\n\t\tpackage *args\n\tend", "def install_gem; end", "def require(feature=nil)\n @requires << feature if feature\n @requires\n end", "def depend_on(dependant, env = environment.name, requirement = nil)\n fail('Dependant cannot be nil') if dependant.nil? || dependant.eql?('')\n fail('Environment cannot be nil') if env.nil? || env.eql?('')\n dep = if dependant == :all\n if env == :all\n Stacks::Dependencies::MultiServiceDependency.new(self,\n Stacks::Dependencies::AllKubernetesSelector.new(requirement),\n requirement)\n else\n fail('Selection by a specific environment not yet support for :all dependency')\n end\n elsif dependant.is_a?(Array)\n selectors = dependant.map { |d| Stacks::Dependencies::ServiceSelector.new(d, env) }\n Stacks::Dependencies::SingleServiceDependency.new(self,\n Stacks::Dependencies::MultiSelector.new(selectors),\n requirement)\n else\n Stacks::Dependencies::SingleServiceDependency.new(self,\n Stacks::Dependencies::ServiceSelector.new(dependant, env),\n requirement)\n end\n\n @depends_on << dep unless @depends_on.include? dep\n end", "def bower_version(library)\n BOWER[\"dependencies\"][library] || BOWER[\"devDependencies\"][library]\nend", "def package_ruby(pkg, options) \n # update dependencies in any case, i.e. independant if package exists or not\n deps = dependencies(pkg)\n Dir.chdir(pkg.srcdir) do\n begin\n logname = \"obs-#{pkg.name.sub(\"/\",\"-\")}\" + \"-\" + Time.now.strftime(\"%Y%m%d-%H%M%S\").to_s + \".log\"\n gem = FileList[\"pkg/*.gem\"].first\n if not gem \n Packager.info \"Debian: creating gem from package #{pkg.name}\"\n if !system(\"rake gem 2> #{File.join(OBS_LOG_DIR, logname)}\")\n raise \"Debian: failed to create gem from RubyPackage #{pkg.name}\"\n Packager.warn \" check: #{File.expand_path(logname)}\"\n end\n end\n\n gem = FileList[\"pkg/*.gem\"].first\n\n # Make the naming of the gem consistent with the naming schema of\n # rock packages\n #\n # Make sure the gem has the fullname, e.g.\n # tools-metaruby instead of just metaruby\n gem_rename = gem.sub(basename(pkg.name), canonize(pkg.name))\n if gem != gem_rename\n Packager.info \"Debian: renaming #{gem} to #{gem_rename}\"\n FileUtils.mv gem, gem_rename\n gem = gem_rename\n end\n\n Packager.debug \"Debian: copy #{gem} to #{packaging_dir(pkg)}\"\n FileUtils.cp gem, packaging_dir(pkg)\n gem_final_path = File.join(packaging_dir(pkg), File.basename(gem))\n\n # Prepare injection of dependencies\n options[:deps] = deps\n convert_gem(gem_final_path, options)\n # register gem with the correct naming schema\n # to make sure dependency naming and gem naming are consistent\n @ruby_rock_gems << debian_name(pkg)\n rescue Exception => e\n raise \"Debian: failed to create gem from RubyPackage #{pkg.name} -- #{e.message}\\n#{e.backtrace.join(\"\\n\")}\"\n end\n end\n end", "def install_from_gemdeps(options, &block)\n gemdeps = options[:gemdeps]\n\n @install_dir = options[:install_dir] || Gem.dir\n @prerelease = options[:prerelease]\n @remote = options[:domain] != :local\n @conservative = true if options[:conservative]\n\n gem_deps_api = load_gemdeps gemdeps, options[:without_groups], true\n\n resolve\n\n if options[:explain]\n puts \"Gems to install:\"\n\n sorted_requests.each do |spec|\n puts \" #{spec.full_name}\"\n end\n\n if Gem.configuration.really_verbose\n @resolver.stats.display\n end\n else\n installed = install options, &block\n\n if options.fetch :lock, true\n lockfile =\n Gem::RequestSet::Lockfile.build self, gemdeps, gem_deps_api.dependencies\n lockfile.write\n end\n\n installed\n end\n end", "def requires(plugin, include: true)\n unless [true, false, :before, :after].include?(include)\n raise ArgumentError, \"requires 'include' keyword argument must be one of: true, false, :before or :after\"\n end\n dependencies[plugin] = include\n end", "def optional(*args)\n normalize_list(args).each do |dependency|\n @available.add_optional(dependency)\n end\n end", "def gem_if_necessary(gem)\n grep = args = nil\n if gem =~ /(.*)-(\\d+\\.\\d+\\.\\d+)$/\n gem, version = $1, $2\n grep = \"^#{gem}.*#{version}\"\n args = \" --version #{version}\"\n else\n grep = \"^#{gem}\"\n end\n if fails?(\"gem list #{gem} | grep '#{grep}'\")\n banner \"#{gem}...\"\n run \"gem install #{gem} #{args} --no-rdoc --no-ri\"\n return true\n end\n false\n end", "def build_dependency\n npm_install\nend", "def version_dependency\n source_options[:from_dependency]\n end", "def required_by(dependency, dependent_name)\n dependencies_by_requirer_name[dependent_name] ||= []\n dependencies_by_requirer_name[dependent_name] << dependency\n dependencies << dependency\n\n if acceptable_versions.empty?\n message = \"Unable to satisfy the following requirements:\\n\\n\"\n dependencies_by_requirer_name.each do |name, dependencies|\n dependencies.each do |dep|\n message << \"- `#{dep}` required by `#{name}`\\n\"\n end\n end\n raise Informative, message\n end\n end", "def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end", "def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end" ]
[ "0.6867321", "0.6728805", "0.6728805", "0.6662304", "0.6561729", "0.6559748", "0.6436301", "0.639025", "0.6329641", "0.6286518", "0.62733144", "0.6232861", "0.62017846", "0.61180526", "0.6117555", "0.6104101", "0.6091112", "0.6083656", "0.6057914", "0.6037483", "0.59764814", "0.5951442", "0.5949573", "0.59386265", "0.59225196", "0.5922276", "0.59133613", "0.5912027", "0.5906891", "0.58622277", "0.582114", "0.58134717", "0.58102", "0.5804656", "0.5801796", "0.57958007", "0.57958007", "0.57958007", "0.57764685", "0.57756835", "0.5755678", "0.5741722", "0.5718436", "0.5701487", "0.5696324", "0.5693717", "0.56909657", "0.56770986", "0.56701964", "0.5645104", "0.5629056", "0.5607843", "0.56039226", "0.55981725", "0.5586831", "0.55850375", "0.5580885", "0.55792046", "0.5578506", "0.5572616", "0.55676293", "0.55610025", "0.5555951", "0.5555951", "0.5555951", "0.5555951", "0.5555951", "0.5555951", "0.5555951", "0.5555951", "0.55492413", "0.55445975", "0.5539374", "0.5539251", "0.5531778", "0.5531399", "0.5531013", "0.55250806", "0.5520899", "0.55137324", "0.5511354", "0.5505795", "0.5501034", "0.5500402", "0.5500402", "0.54952425", "0.5480784", "0.5480494", "0.54794043", "0.54779637", "0.5475483", "0.5456966", "0.545405", "0.54496723", "0.54413253", "0.5430494", "0.54278874", "0.54270035", "0.54233414", "0.54233414" ]
0.7401856
0
Declare a group block.
def group( *names ) options = names.pop if names.last.is_a?( Hash ) previous_groups = self.current_groups.dup self.current_groups.replace( names ) yield ensure self.current_groups.replace( previous_groups ) if previous_groups end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def group(name, &block)\n namespace = Namespace.new(name, &block)\n @blocks << namespace\n namespace\n end", "def group(name = nil, &block)\n make_child(name, nil, &block)\n end", "def group!( &block )\n\t\tn = new!( true )\n\t\tblock.call(n)\n\t\tn\n\tend", "def group(name, &blk)\n add_child(:groups, Hubcap::Group.new(self, name, &blk))\n end", "def create_group\n group new_resource.group do\n gid new_resource.gid\n system true\n end\n end", "def group name, &block\n Tagz.tag :div, { :class => \"group-#{name}\" }, &block\n end", "def begin_group kind\n end", "def begin_group(kind); end", "def group(name, &block)\n # Get group\n group = name if name.kind_of? Salticid::Group \n name = name.to_s\n group ||= @groups.find{|g| g.name == name}\n group ||= Salticid::Group.new(name, :salticid => self)\n\n # Store\n @groups |= [group]\n\n # Run block\n if block_given?\n group.instance_exec &block\n end\n\n group\n end", "def using_group(group, &_block)\n older_group = current_group\n\n begin\n self.current_group = group\n yield\n ensure\n self.current_group = older_group\n end\n end", "def group_builder; end", "def create_block(g, mod)\n pos(g)\n\n state = g.state\n state.scope.nest_scope self\n\n args = make_arguments(mod)\n\n blk = new_generator g, @name, args\n\n blk.push_state self\n\n blk.state.push_super state.super\n blk.state.push_eval state.eval\n\n blk.definition_line(@line)\n\n blk.state.push_name blk.name\n\n pos(blk)\n\n blk.state.push_block\n blk.push_modifiers\n blk.break = nil\n blk.next = nil\n blk.redo = blk.new_label\n blk.redo.set!\n\n # order matters quite a lot here\n args.bytecode(blk)\n\n recv = receiver_pattern(mod)\n if recv.binds?\n blk.push_self\n recv.deconstruct(blk, mod)\n end\n\n args.deconstruct_patterns(blk, mod)\n\n mod.compile(blk, @body)\n\n blk.pop_modifiers\n blk.state.pop_block\n\n blk.ret\n blk.close\n blk.pop_state\n\n blk.splat_index = args.splat_index\n blk.local_count = local_count\n blk.local_names = local_names\n\n g.create_block blk\n end", "def group(group_name, &block)\n group_key = group_name.to_s\n\n @current_nesting_level[group_key] ||= {}\n\n if block_given?\n within_group(group_key) do\n instance_eval &block\n end\n end\n end", "def group(name)\n @_group = name\n end", "def lex_grouphead re\n end_group if group\n self.state = :group\n self.group = Group.new re\n end", "def block(name, &block)\n klass = SuperbTextConstructor.block(name, &block)\n @blocks << klass\n klass\n end", "def createGroup\n call :createGroup\n end", "def create_group(attributes)\n BrickFTP::API::Group.create(attributes)\n end", "def create_group(attributes)\n BrickFTP::API::Group.create(attributes)\n end", "def bp_group options, &block\n label = options[:label].blank? ? \"\" : options[:label]\n id = options[:id].blank? ? \"\" : options[:id]\n style = options[:style].blank? ? \"\" : options[:style]\n\n out = content_tag :li, :class => bp_class(\"group #{options[:class]}\"), :id => \"#{id}\", :style => style do\n content_tag :fieldset do\n fieldset = label.blank? ? \"\" : content_tag(:legend, label, :class => \"label\")\n fieldset += content_tag(:ol, capture(&block))\n fieldset.html_safe\n end\n end\n\n bp_html_print out\n end", "def group(options ={}, &block)\n @template.form_group(options, &block)\n end", "def group\n @group ||= Interface::Group.new(self)\n end", "def gem_group(*names, &block)\n name = names.map(&:inspect).join(', ')\n log :gemfile, \"group #{name}\"\n\n in_root do\n append_file 'Gemfile', \"\\ngroup #{name} do\", force: true\n\n @in_group = true\n instance_eval(&block)\n @in_group = false\n\n append_file 'Gemfile', \"\\nend\\n\", force: true\n end\n end", "def create_a_block(group_name, num_of_rooms: 5, start_date: Date.today, end_date: Date.today + 2, room_rate: 175)\n if num_of_rooms > 5\n raise ArgumentError.new(\"Only 5 rooms per block.\")\n end\n\n list = Room.all_available_rooms(rooms, start_date: start_date, end_date: end_date)\n\n if list.length < num_of_rooms\n raise ArgumentError.new(\"Not enough rooms available. Only #{list.length} room(s) available.\")\n else\n final_list = list[0...num_of_rooms]\n end\n\n new_block = Block.new(group_name, final_list, start_date: start_date, end_date: end_date, room_rate: room_rate)\n\n blocks << new_block\n\n final_list.each do |room_number|\n room = Room.find_room(rooms, room_number)\n room.change_status_of_room(rooms, room_number, start_date: start_date, end_date: end_date)\n end\n\n return new_block\n end", "def begin_group kind\n @out << (@span_for_kinds[@last_opened ? [kind, *@opened] : kind] || '<span>')\n @opened << kind\n @last_opened = kind if @set_last_opened\n end", "def create_group name, lights, &block\n\t\t\traise \"No group name was given\" unless name.is_a?(String) && name.length > 0\n\t\t\traise \"No lights were given\" unless lights.is_a?(Array) && lights.length > 0\n\n\t\t\tlight_ids = []\n\t\t\tlights.each do |l|\n\t\t\t\traise \"All given lights must be NLHue::Light objects\" unless l.is_a?(Light)\n\t\t\t\traise \"Light #{l.id} (#{l.name}) is not from this bridge.\" if l.bridge != self\n\n\t\t\t\tlight_ids << l.id.to_s\n\t\t\tend\n\n\t\t\tgroup_data = { :lights => light_ids, :name => name }.to_json\n\t\t\tpost_api '/groups', group_data, :lights do |response|\n\t\t\t\tstatus, result = check_json response\n\n\t\t\t\tbegin\n\t\t\t\t\tresult = result.first if result.is_a? Array\n\n\t\t\t\t\tif status && result['success']\n\t\t\t\t\t\tid = result['success']['id'].split('/').last.to_i\n\t\t\t\t\t\traise \"Invalid ID received for new group: '#{result['success']['id']}'\" unless id > 0\n\n\t\t\t\t\t\tgroup = Group.new(self, id, { 'name' => name, 'lights' => light_ids, 'action' => {} })\n\t\t\t\t\t\tgroup.update do |upstatus, upresult|\n\t\t\t\t\t\t\tif upstatus\n\t\t\t\t\t\t\t\t@groups[id] = group\n\t\t\t\t\t\t\t\tBridge.notify_bridge_callbacks self, true\n\t\t\t\t\t\t\t\tyield true, group if block_given?\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tyield upstatus, upresult if block_given?\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\traise result\n\t\t\t\t\tend\n\t\t\t\trescue => e\n\t\t\t\t\tyield false, e if block_given?\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def async_group &block\n em_get( \"/clients/#{uuid}/group\") do |response|\n group = Group.new( response[:content] )\n block.call( group )\n end\n end", "def group\n @group ||= Group.new @instance, group_id\n end", "def create_group(group_node)\n name_ru = group_node.text.delete(\"0-9\")\n Group.create(name_ru: name_ru)\n end", "def add_group(name)\n return nil unless @document\n group = Xcodeproj::Workspace::GroupReference.new(name)\n elem = @document.root.add_element(group.to_node)\n yield group, elem if block_given?\n group\n end", "def define &block\n new block\n end", "def define(name, options={}, &block)\n # Check if a block by this name is already defined.\n if blocks[name.to_sym].nil?\n # Store the attributes of the defined block in a container for later use\n block_container = BuildingBlocks::Container.new\n block_container.name = name\n block_container.options = options\n block_container.block = block\n \n blocks[name.to_sym] = block_container \n end\n \n nil\n end", "def gem_group(*names, &block)\n options = names.extract_options!\n str = names.map(&:inspect)\n str << quote(options) unless options.empty?\n str = str.join(\", \")\n log :gemfile, \"group #{str}\"\n\n in_root do\n append_file \"Gemfile\", \"\\ngroup #{str} do\", force: true\n with_indentation(&block)\n append_file \"Gemfile\", \"\\nend\\n\", force: true\n end\n end", "def register_group(object, group = T.unsafe(nil)); end", "def start_new_block_element(attrs)\n @current_block = {\n formatting_spans: [],\n paragraph_classes: [],\n }.merge(attrs)\n @block_elements << @current_block\n end", "def group; end", "def group name\n TetCore.group(name) { yield }\nend", "def new\n\t\t@block = Block.new\n\tend", "def create\n @contentBlock = ContentBlock.new(:contentType_id => params[:content_block][:contentType_id], :style_id => params[:content_block][:style_id], \n :content => params[:content_block][:content])\n @contentBlock.save\n\n @group = Group.new(group_params)\n respond_to do |format|\n if @group.save\n @group.update_attributes(chunk_id: @contentBlock.id)\n sync_character_tags()\n sync_storyline_tags()\n format.html { redirect_to @group, notice: 'Group was successfully created.' }\n format.json { render :show, status: :created, location: @group }\n else\n format.html { render :new }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end", "def block_definition(block_node)\n buff_code \"__blocks['#{block_node.name}'] = __create_block('#{block_node.name}', #{location_node(block_node)}) do\"\n\n code_indent do\n visit_node_children(block_node)\n end\n\n buff_code 'end'\n end", "def new\n @group = Group.new\n end", "def group\n nil\n end", "def group(groupName, &block)\n ns = NodeSet[groupName.to_s]\n if (ns == nil)\n warn \"Undefined node set '#{groupName}'\"\n return EmptyGroup.new\n end\n return RootNodeSetPath.new(ns, nil, nil, block)\n end", "def new_group(group_data)\n [:id, :name].each { |attr| raise(ArgumentError, \"Missing or Invalid Parameter(s)\") unless group_data.key?(attr) }\n set_values group_data\n end", "def create(group_hash)\n # Check arguments\n if !group_hash[:name]\n return OpenNebula::Error.new(\"Group name not defined\")\n end\n\n if group_hash[:group_admin]\n if group_hash[:group_admin][:name] && !group_hash[:group_admin][:password]\n error_msg = \"Admin user password not defined\"\n return OpenNebula::Error.new(error_msg)\n end\n end\n\n # Allocate group\n rc = allocate(group_hash[:name])\n return rc if OpenNebula.is_error?(rc)\n\n # Set group ACLs to create resources\n rc, msg = create_default_acls(group_hash[:resources])\n\n if OpenNebula.is_error?(rc)\n delete\n error_msg = \"Error creating group ACL's: #{rc.message}\"\n return OpenNebula::Error.new(error_msg)\n end\n\n # Set group ACLs to share resources\n if group_hash[:shared_resources]\n acls = Array.new\n acls << \"@#{id} #{group_hash[:shared_resources]}/@#{id} USE\"\n\n rc, msg = create_group_acls(acls)\n\n if OpenNebula.is_error?(rc)\n self.delete\n error_msg = \"Error creating group ACL's: #{rc.message}\"\n return OpenNebula::Error.new(error_msg)\n end\n end\n\n # Create associated group admin if needed\n rc = create_admin_user(group_hash)\n\n if OpenNebula.is_error?(rc)\n delete\n error_msg = \"Error creating admin user: #{rc.message}\"\n return OpenNebula::Error.new(error_msg)\n end\n\n sunstone_attrs = []\n\n # Add Sunstone views for the group\n if group_hash[:views]\n sunstone_attrs << \"VIEWS=\\\"#{group_hash[:views].join(\",\")}\\\"\"\n end\n\n if group_hash[:default_view]\n sunstone_attrs << \"DEFAULT_VIEW=\\\"#{group_hash[:default_view]}\\\"\"\n end\n\n # And the admin views\n if group_hash[:admin_views]\n sunstone_attrs << \"GROUP_ADMIN_VIEWS=\\\"#{group_hash[:admin_views].join(\",\")}\\\"\"\n else\n sunstone_attrs << \"GROUP_ADMIN_VIEWS=#{GROUP_ADMIN_SUNSTONE_VIEWS}\"\n end\n\n if group_hash[:default_admin_view]\n sunstone_attrs << \"GROUP_ADMIN_DEFAULT_VIEW=\\\"#{group_hash[:default_admin_view]}\\\"\"\n else\n sunstone_attrs << \"GROUP_ADMIN_DEFAULT_VIEW=#{GROUP_ADMIN_SUNSTONE_VIEWS}\"\n end\n\n do_update = false\n\n if sunstone_attrs.length > 0\n do_update = true\n\n update_str = \"SUNSTONE=[#{sunstone_attrs.join(\",\\n\")}]\\n\"\n end\n\n opennebula_attrs = []\n\n # Persistency attributes for new images\n if group_hash[:opennebula]\n if group_hash[:opennebula][:default_image_persistent]\n opennebula_attrs << \"DEFAULT_IMAGE_PERSISTENT=\\\"\"\\\n \"#{group_hash[:opennebula][:default_image_persistent]}\\\"\"\n end\n\n if group_hash[:opennebula][:default_image_persistent_new]\n opennebula_attrs << \"DEFAULT_IMAGE_PERSISTENT_NEW=\\\"\"\\\n \"#{group_hash[:opennebula][:default_image_persistent_new]}\\\"\"\n end\n end\n\n if opennebula_attrs.length > 0\n do_update = true\n\n update_str += \"OPENNEBULA=[#{opennebula_attrs.join(\",\\n\")}]\\n\"\n end\n\n if do_update\n rc = update(update_str, true)\n\n if OpenNebula.is_error?(rc)\n delete\n error_msg = \"Error updating group template: #{rc.message}\"\n return OpenNebula::Error.new(error_msg)\n end\n end\n\n return 0\n end", "def initialize\n super(Network.generate_id(\"block_\"))\n end", "def block_name_declaration(block_name)\n buff_code \"#{block_name} = __blocks.delete('#{block_name}') { __create_block('#{block_name}') }\"\n end", "def group(node, tag)\r\n end", "def new\n \t@group = Group.new\n end", "def grouped hash = nil, &block\n @grouped = block\n @current_group_hash = hash\n\n # get current group from grouper and set response (unless the group hash is unchanged)\n\n async_group { |group| update_grouped( group ) }\n\n # wait for another client to update the group with an environment update or by signing off\n # if that did not happen after 60s, get group info and set response even if group hash is unchanged\n\n @peek_timer = EM::Timer.new(60) do\n async_group { |group| update_grouped( group, true ) }\n end\n end", "def new_block_el(*args)\n el = Element.new(*args)\n if @block_ial\n el.options[:ial] = @block_ial\n @block_ial = nil\n end\n el\n end", "def group(path, name)\n RubyAem::Resources::Group.new(@client, path, name)\n end", "def group\n nil\n end", "def group\n nil\n end", "def group\n nil\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def new\n @group = Group.new\n end", "def group(*groups)\n @current_groups = groups\n\n yield\n\n ensure\n @current_groups = nil\n end", "def new_block_el(*args); end", "def define_group(name, desc, priority)\n parameters_groups[name.to_sym] =\n { desc: _t(desc), priority: priority }\n end", "def instructor_create_grp(course, group)\n load_course_grps course\n\n # Create new group set\n logger.info \"Creating new group set called '#{group.group_set}'\"\n (button = button_element(xpath: '//button[@id=\"add-group-set\"]')).when_present Utils.short_wait\n js_click button\n wait_for_element_and_type(text_area_element(id: 'new_category_name'), group.group_set)\n checkbox_element(id: 'enable_self_signup').check\n button_element(id: 'newGroupSubmitButton').click\n link_element(xpath: \"//a[@title='#{group.group_set}']\").when_present Utils.short_wait\n\n # Create new group within the group set\n logger.info \"Creating new group called '#{group.title}'\"\n js_click button_element(class: 'add-group')\n wait_for_element_and_type(edit_group_name_input_element, group.title)\n button_element(id: 'groupEditSaveButton').click\n link_element(xpath: \"//a[contains(.,'#{group.title}')]\").when_present Utils.short_wait\n (link = link_element(xpath: \"//a[contains(.,'#{group.title}')]/../following-sibling::div[contains(@class,'group-actions')]//a\")).when_present Utils.short_wait\n logger.info \"Group ID is '#{group.site_id = link.attribute('id').split('-')[1]}'\"\n end", "def create_group(stream, group)\n stream = stream_name(stream)\n connection.xgroup(:create, stream, \"#{stream}-#{group}\", '$',\n mkstream: true)\n end", "def <<(group) \n @groups[group.name] = group\n end", "def add_block name, hash\n\t\t\t@blocks ||= {}\n\t\t\t@blocks[name] = hash\n\t\tend", "def initialize(name=nil)\n # Create the record grouping\n super()\n @records[Elements] = Elements.new\n @records[GRT_ENDSTR] = Record.new(GRT_ENDSTR)\n\n # set the name\n self.name = name unless name.nil?\n\n # Set create/modify time to the current time\n now = Time.now\n self.create_time = now\n self.modify_time = now\n\n yield self if block_given?\n end", "def on_block(node)\n builder = DefinitionBuilder::RubyBlock.new(node, current_scope)\n definition = builder.build\n\n associate_node(node, definition)\n\n push_scope(definition)\n end", "def group(value)\n attributes[:group] = value\n end", "def add_group( group )\n type_check( group, Elements::Group )\n assert( !name_defined?(name), \"name [#{name}] is already in use\" )\n \n @groups[group.name] = group\n end", "def initialize(parent, name, &blk)\n @name = name.to_s\n @parent = parent\n unless @parent || kind_of?(Hubcap::Hub)\n raise(Hubcap::GroupWithoutParent, self.inspect)\n end\n @cap_attributes = {}\n @cap_roles = []\n @puppet_roles = {}\n @params = {}\n @extra_attributes = {}\n @hosts = {}\n @children = []\n instance_eval(&blk) if blk && processable?\n end", "def define_command_group name, opts = nil, &blk\n opts = _take_doc(opts)\n # $stderr.puts \"@target = #{@target.inspect}\"\n # $stderr.puts \"define_command_group #{name.inspect}, #{opts.inspect}\"\n \n cmd = _command_manager.define_command_group(name, opts)\n\n cmd._defined_in = @plugin\n\n # @plugin.commands << cmd\n\n _with_target cmd.subcommands, &blk\n\n cmd\n end", "def start_new_block\n if (@block_buffer)\n add_block(@block_buffer)\n @block_buffer = nil\n end\n end", "def field_group(name, locals={}, options={}, &block)\n locals = locals.merge name: name\n\n args = options.merge layout: 'field_group', locals: locals\n\n render args, &block\n end", "def set_main_group(group)\r\n #@main_group = group\r\n\t\t@groups[10] = group\r\n\tend", "def fieldset(&block)\n @g.fieldset(block)\n end", "def method_missing(m, options={}, &block) \n # If the specified block group has already been defined, it is simply returned here for iteration.\n # It will consist of all the blocks used in this block group that have yet to be rendered,\n # as the call for their use occurred before the template was rendered (where their definitions likely occurred)\n return self.block_groups[m] unless self.block_groups[m].nil?\n \n # Allows for nested block groups, store the current block positions array and start a new one\n original_block_positions = self.block_positions\n self.block_positions = []\n self.block_groups[m] = self.block_positions\n \n # Capture the contents of the block group (this will only capture block definitions and block uses)\n view.capture(global_options.merge(options), &block) if block_given?\n \n # restore the original block positions array\n self.block_positions = original_block_positions\n nil\n end", "def add_block(block)\n return if ilp.has_variable?(block)\n ilp.add_variable(block)\n lhs = block_frequency(block) + [[block, -1]]\n ilp.add_constraint(lhs,\"equal\",0,\"block_#{block.qname}\", :structural)\n end", "def set_group(param)\n @group = param\n end", "def begin_block(name, opts)\n @block_name_stack << name\n @block_opts_stack << opts\n @block_break_type_stack << \"entry-break\"\n end", "def block_class() Block; end", "def group\n @group\n end", "def add_group(group, gid=nil)\n\t\t\tend", "def block(name=\"block\", &proc)\n gen = self.class.new(@library, @module, @function, @function.add_block(name))\n gen.instance_eval(&proc)\n return gen\n end", "def package(id, &block)\n unless block\n raise InvalidValue.new(:package, \"have a block\")\n end\n\n packagers[id] << block\n end", "def set_group\n data[:group]\n end", "def group(*args, &block)\n raise ArgumentError, 'no block given' unless block\n\n `#{@native}.group.apply(#{@native}, args)`\n\n begin\n if block.arity == 0\n instance_exec(&block)\n else\n yield(self)\n end\n ensure\n `#{@native}.groupEnd()`\n end\n end", "def new_group(name, sub_group_path = nil)\n group = project.new(PBXGroup)\n group.name = name\n\n target = find_subpath(sub_group_path, true)\n target.children << group\n group\n end", "def new_group(name, sub_group_path = nil)\n group = project.new(PBXGroup)\n group.name = name\n\n target = find_subpath(sub_group_path, true)\n target.children << group\n group\n end", "def block_node; end", "def block_node; end", "def assign_group\n return unless group.nil?\n\n self.group = Group.find_by(name: 'Pilot')\n end", "def register_block_for(type, &blk); end", "def add(name, &block)\n blocks[name.to_sym] = block\n end", "def __mk_group(gdoc)\n @disp_dic.ext_grp unless @disp_dic.is_a? Disp::Grouping\n gatt = gdoc.to_h\n return if gatt[:enable] == 'false'\n sub = @disp_dic.add_grp(gatt.delete(:id), gatt.delete(:label))\n gdoc.each { |e| __mk_sub_db(e, sub, gatt.dup) }\n end", "def group\n @header.group\n end", "def group\n override_attr(:group, super)\n end", "def process_simple_block_opener(tk)\n return unless [TkLBRACE, TkDO, TkBEGIN, TkELSE].include?(tk.class) &&\n # Make sure hashes are parsed as hashes, not as blocks\n (@last_ns_tk.nil? || @last_ns_tk.lex_state != EXPR_BEG)\n\n @level += 1\n @state = :block\n @block_num += 1\n if @block.nil?\n @block = TokenList.new\n tokens = [tk, TkStatementEnd.new(tk.line_no, tk.char_no)]\n tokens = tokens.reverse if TkBEGIN === tk.class\n @statement.concat(tokens)\n else\n @statement << tk\n end\n\n true\n end", "def allocate(groupname)\n super(GROUP_METHODS[:allocate], groupname)\n end", "def allocate(groupname)\n super(GROUP_METHODS[:allocate], groupname)\n end" ]
[ "0.78581864", "0.7367328", "0.721182", "0.6974353", "0.662404", "0.64993775", "0.64918506", "0.648655", "0.6374337", "0.6291941", "0.6258515", "0.6253804", "0.6122607", "0.60891384", "0.6083531", "0.60789657", "0.60784197", "0.6044039", "0.6043522", "0.6039209", "0.6030055", "0.60084987", "0.59961843", "0.5991404", "0.5981801", "0.59507513", "0.59318393", "0.5912055", "0.5907548", "0.5901939", "0.58823234", "0.5878759", "0.58436483", "0.5835241", "0.58261395", "0.582518", "0.58137184", "0.57986194", "0.57814705", "0.5778108", "0.5772436", "0.57715994", "0.57558054", "0.5743617", "0.5729734", "0.57269466", "0.572206", "0.57176954", "0.5701052", "0.5686882", "0.56865346", "0.5677347", "0.5658015", "0.5658015", "0.5658015", "0.56554925", "0.56554925", "0.56554925", "0.56554925", "0.56554925", "0.5655122", "0.5654634", "0.5643971", "0.5630665", "0.56297415", "0.56283444", "0.5610466", "0.56060743", "0.5605722", "0.56036", "0.5601122", "0.55965316", "0.5591038", "0.5582332", "0.5580863", "0.5568139", "0.55494446", "0.55477315", "0.5545318", "0.5539634", "0.5539466", "0.55375075", "0.55354655", "0.55285186", "0.55241686", "0.55216163", "0.5521475", "0.5520607", "0.551889", "0.551889", "0.55146945", "0.55146945", "0.5513036", "0.55089784", "0.5502143", "0.54817754", "0.5478428", "0.5477031", "0.54726213", "0.5468666", "0.5468666" ]
0.0
-1
Raise, as the gemdeps file should be the authoritative source.
def gemspec( * ) raise "Circular dependency: can't depend on the gemspec to build itself" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_bad_chicken_deps\n check_deps_fail \"notapackage\" => :chicken if which('csc')\n end", "def test_bad_chicken_deps\n check_deps_fail \"notapackage\" => :chicken if which('csc')\n end", "def validate!\n File.exist?(gemfile) or raise MissingGemfile, \"Gemfile not found: #{gemfile}\"\n contents = File.read(gemfile)\n contents.include?('gemika') or raise UnusableGemfile, \"Gemfile is missing gemika dependency: #{gemfile}\"\n end", "def missing_deps_for(gem)\n # Comparison by name here assuming if it is in existing spec,\n # spec author will have ensured versions are correct for their purposes\n gem.deps.select { |dep| requirements_for_gem(dep.name).empty? }\n end", "def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end", "def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end", "def dep_check\n $gems_required.each do |current_gem|\n begin\n if current_gem.include? \",\"\n tokens = current_gem.split(\",\")\n gem tokens[0], tokens[1]\n else\n gem current_gem\n end\n rescue Gem::LoadError\n if current_gem.include? \",\"\n $gems_missing_version << current_gem\n else\n $gems_missing << current_gem\n end\n end\n end\n if $gems_missing.length == 0 && $gems_missing_version.length == 0\n return true\n else\n return false\n end\nend", "def valid_gemspec?; end", "def validate_gemspec; end", "def gemspec?; end", "def require_gems; end", "def raise_if_conflicts # :nodoc:\n if has_conflicts?\n raise Gem::ConflictError.new self, conflicts\n end\n end", "def test_bad_node_deps\n check_deps_fail \"notapackage\" => :node if which('node')\n end", "def test_bad_node_deps\n check_deps_fail \"notapackage\" => :node if which('node')\n end", "def version_constraint(gem_name); end", "def test_bad_chicken_deps\n check_deps_fail BadChickenBall unless `/usr/bin/which csc`.chomp.empty?\n end", "def _dependency_error(req, src, msg)\n raise LoadError, sprintf(msg, req, src)\n end", "def test_bad_rubinius_deps\n check_deps_fail BadRubiniusBall unless `/usr/bin/which rbx`.chomp.empty?\n end", "def install_dependencies\n raise 'Not implemented'\n end", "def handle_bundler_errors(error)\n path_regex =\n Regexp.escape(SharedHelpers::BUMP_TMP_DIR_PATH) + \"\\/\" +\n Regexp.escape(SharedHelpers::BUMP_TMP_FILE_PREFIX) + \"[^/]*\"\n msg =\n error.error_class + \" with message: \" +\n error.error_message.gsub(/#{path_regex}/, \"dependabot_tmp_dir\")\n\n case error.error_class\n when \"Bundler::Dsl::DSLError\", \"Bundler::GemspecError\"\n # We couldn't evaluate the Gemfile, let alone resolve it\n raise Dependabot::DependencyFileNotEvaluatable, msg\n when \"Bundler::Source::Git::MissingGitRevisionError\"\n gem_name =\n error.error_message.match(GIT_REF_REGEX).\n named_captures[\"path\"].\n split(\"/\").last\n raise GitDependencyReferenceNotFound, gem_name\n when \"Bundler::PathError\"\n gem_name =\n error.error_message.match(PATH_REGEX).\n named_captures[\"path\"].\n split(\"/\").last.split(\"-\")[0..-2].join\n raise Dependabot::PathDependenciesNotReachable, [gem_name]\n when \"Bundler::Source::Git::GitCommandError\"\n if error.error_message.match?(GIT_REGEX)\n # We couldn't find the specified branch / commit (or the two\n # weren't compatible).\n gem_name =\n error.error_message.match(GIT_REGEX).\n named_captures[\"path\"].\n split(\"/\").last.split(\"-\")[0..-2].join\n raise GitDependencyReferenceNotFound, gem_name\n end\n\n bad_uris = inaccessible_git_dependencies.map { |s| s.source.uri }\n raise unless bad_uris.any?\n\n # We don't have access to one of repos required\n raise Dependabot::GitDependenciesNotReachable, bad_uris\n when \"Bundler::GemNotFound\", \"Gem::InvalidSpecificationException\",\n \"Bundler::VersionConflict\"\n # Bundler threw an error during resolution. Any of:\n # - the gem doesn't exist in any of the specified sources\n # - the gem wasn't specified properly\n # - the gem was specified at an incompatible version\n raise Dependabot::DependencyFileNotResolvable, msg\n when \"Bundler::Fetcher::AuthenticationRequiredError\"\n regex = /bundle config (?<source>.*) username:password/\n source = error.error_message.match(regex)[:source]\n raise Dependabot::PrivateSourceNotReachable, source\n when \"Bundler::Fetcher::BadAuthenticationError\"\n regex = /Bad username or password for (?<source>.*)\\.$/\n source = error.error_message.match(regex)[:source]\n raise Dependabot::PrivateSourceNotReachable, source\n when \"Bundler::Fetcher::CertificateFailureError\"\n regex = /verify the SSL certificate for (?<source>.*)\\.$/\n source = error.error_message.match(regex)[:source]\n raise Dependabot::PrivateSourceCertificateFailure, source\n when \"Bundler::HTTPError\"\n regex = /Could not fetch specs from (?<source>.*)$/\n raise unless error.error_message.match?(regex)\n source = error.error_message.match(regex)[:source]\n raise if source.include?(\"rubygems\")\n raise Dependabot::PrivateSourceNotReachable, source\n else raise\n end\n end", "def handle_bundler_errors(error)\n path_regex =\n Regexp.escape(SharedHelpers::BUMP_TMP_DIR_PATH) + \"\\/\" +\n Regexp.escape(SharedHelpers::BUMP_TMP_FILE_PREFIX) + \"[^/]*\"\n msg =\n error.error_class + \" with message: \" +\n error.error_message.gsub(/#{path_regex}/, \"dependabot_tmp_dir\")\n\n case error.error_class\n when \"Bundler::Dsl::DSLError\", \"Bundler::GemspecError\"\n # We couldn't evaluate the Gemfile, let alone resolve it\n raise Dependabot::DependencyFileNotEvaluatable, msg\n when \"Bundler::Source::Git::MissingGitRevisionError\"\n gem_name =\n error.error_message.match(GIT_REF_REGEX).\n named_captures[\"path\"].\n split(\"/\").last\n raise GitDependencyReferenceNotFound, gem_name\n when \"Bundler::PathError\"\n gem_name =\n error.error_message.match(PATH_REGEX).\n named_captures[\"path\"].\n split(\"/\").last.split(\"-\")[0..-2].join\n raise Dependabot::PathDependenciesNotReachable, [gem_name]\n when \"Bundler::Source::Git::GitCommandError\"\n if error.error_message.match?(GIT_REGEX)\n # We couldn't find the specified branch / commit (or the two\n # weren't compatible).\n gem_name =\n error.error_message.match(GIT_REGEX).\n named_captures[\"path\"].\n split(\"/\").last.split(\"-\")[0..-2].join\n raise GitDependencyReferenceNotFound, gem_name\n end\n\n bad_uris = inaccessible_git_dependencies.map { |s| s.source.uri }\n raise unless bad_uris.any?\n\n # We don't have access to one of repos required\n raise Dependabot::GitDependenciesNotReachable, bad_uris\n when \"Bundler::GemNotFound\", \"Gem::InvalidSpecificationException\",\n \"Bundler::VersionConflict\"\n # Bundler threw an error during resolution. Any of:\n # - the gem doesn't exist in any of the specified sources\n # - the gem wasn't specified properly\n # - the gem was specified at an incompatible version\n raise Dependabot::DependencyFileNotResolvable, msg\n when \"Bundler::Fetcher::AuthenticationRequiredError\"\n regex = /bundle config (?<source>.*) username:password/\n source = error.error_message.match(regex)[:source]\n raise Dependabot::PrivateSourceAuthenticationFailure, source\n when \"Bundler::Fetcher::BadAuthenticationError\"\n regex = /Bad username or password for (?<source>.*)\\.$/\n source = error.error_message.match(regex)[:source]\n raise Dependabot::PrivateSourceAuthenticationFailure, source\n when \"Bundler::Fetcher::CertificateFailureError\"\n regex = /verify the SSL certificate for (?<source>.*)\\.$/\n source = error.error_message.match(regex)[:source]\n raise Dependabot::PrivateSourceCertificateFailure, source\n when \"Bundler::HTTPError\"\n regex = /Could not fetch specs from (?<source>.*)$/\n raise unless error.error_message.match?(regex)\n source = error.error_message.match(regex)[:source]\n raise if source.include?(\"rubygems.org\")\n raise Dependabot::PrivateSourceTimedOut, source\n else raise\n end\n end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def gemspec; end", "def raise_expected_version_error!\n self.raise_expected_version_error = true\n nil\n end", "def require_with_grace(r) require r; rescue LoadError; block_given? ? yield : abort(\"#{$!.message}\\n\\n try executing: gem install '#{r}'\") end", "def missing_dev_deps_for(gem)\n # Same note as in #missing_deps_for above\n gem.dev_deps.select { |dep| build_requirements_for_gem(dep.name).empty? }\n end", "def validate_dependencies\n Spiceweasel::Log.debug(\"cookbook validate_dependencies: '#{@dependencies}'\")\n @dependencies.each do |dep|\n unless member?(dep)\n STDERR.puts \"ERROR: Cookbook dependency '#{dep}' is missing from the list of cookbooks in the manifest.\"\n exit(-1)\n end\n end\n end", "def test_bad_jruby_deps\n check_deps_fail \"notapackage\" => :jruby if which('jruby')\n end", "def test_bad_jruby_deps\n check_deps_fail \"notapackage\" => :jruby if which('jruby')\n end", "def check_gem # --- CHECK FOR MISSING GEMS\n begin\n\t gem 'em-websocket'\n rescue Gem::LoadError\n\t puts \"IT APPEARS YOU ARE MISSING THE SOCKET GEM\"\n puts \"TO INSTALL IT TYPE 'gem install em-websocket'\"\n\telse\n\t\t#donothing\n\tend\n\n\tbegin\n\t\tgem 'net-ping', '>=1.7.8'\n\trescue Gem::LoadError\n\t\tputs \"IT APPEARS THAT YOU ARE MISSING THE NET-PING GEM\"\n puts \"TO INSTALL IT TYPE 'gem install net-ping'\"\n\telse\n\t\t#donothing\n\tend\nend", "def gem(gem_name, *version_requirements)\n if gem_name =='i18n'\n puts \"skipping loading the i18n gem ...\"\n return\n end\n super(gem_name, *version_requirements)\nend", "def dependencies; end", "def dependencies; end", "def dependencies; end", "def with_optional_dependency\n yield if block_given?\nrescue LoadError # rubocop:disable Lint/SuppressedException\nend", "def with_optional_dependency\n yield if block_given?\nrescue LoadError # rubocop:disable Lint/SuppressedException\nend", "def load_gemdeps(path)\n gf = GemDepedencyAPI.new(self, path)\n gf.load\n end", "def handle_composer_errors(error)\n if error.message.start_with?(\"Failed to execute git clone\")\n dependency_url =\n error.message.match(/--mirror '(?<url>.*?)'/).\n named_captures.fetch(\"url\")\n raise Dependabot::GitDependenciesNotReachable, dependency_url\n elsif error.message.start_with?(\"Failed to clone\")\n dependency_url =\n error.message.match(/Failed to clone (?<url>.*?) via/).\n named_captures.fetch(\"url\")\n raise Dependabot::GitDependenciesNotReachable, dependency_url\n elsif error.message.start_with?(\"Could not parse version\")\n raise Dependabot::DependencyFileNotResolvable, error.message\n elsif error.message.include?(\"requested PHP extension\")\n extensions = error.message.scan(/\\sext\\-.*?\\s/).map(&:strip).uniq\n msg = \"Dependabot's installed extensions didn't match those \"\\\n \"required by your application. Please add the following \"\\\n \"extensions to the platform config in your composer.json: \"\\\n \"#{extensions.join(', ')}.\\n\\n\"\\\n \"The full error raised was:\\n\\n#{error.message}\"\n raise Dependabot::DependencyFileNotResolvable, msg\n elsif error.message.include?(\"package requires php\")\n raise Dependabot::DependencyFileNotResolvable, error.message\n elsif error.message.include?(\"requirements could not be resolved\")\n # We should raise a Dependabot::DependencyFileNotResolvable error\n # here, but can't confidently distinguish between cases where we\n # can't install and cases where we can't update. For now, we\n # therefore just ignore the dependency.\n nil\n elsif error.message.include?(\"URL required authentication\") ||\n error.message.include?(\"403 Forbidden\")\n source =\n error.message.match(%r{https?://(?<source>[^/]+)/}).\n named_captures.fetch(\"source\")\n raise Dependabot::PrivateSourceAuthenticationFailure, source\n elsif error.message.start_with?(\"Allowed memory size\")\n raise \"Composer out of memory\"\n elsif error.message.start_with?(\"Package not found in updated\") &&\n !dependency.top_level?\n # If we can't find the dependency in the composer.lock after an\n # update, but it was originally a sub-dependency, it's because the\n # dependency is no longer required and is just cruft in the\n # composer.json. In this case we just ignore the dependency.\n nil\n else\n raise error\n end\n end", "def update_gems\n gemfile = File.read('Gemfile')\n included_gems = %w[cocina-models dor-services-client sdr-client].filter { |gem_name| gemfile.include?(gem_name)}\n ErrorEmittingExecutor.execute(\"bundle update #{included_gems.join(' ')}\") unless included_gems.empty?\nend", "def load_dependencies\r\n @local_gems.each do |gem_info|\r\n gem_file_name = gem_info.gem_file\r\n gem_name = installed_as_name_for( short_form_of_gem_name( gem_file_name ) )\r\n @required_gem_names.delete gem_file_name\r\n end\r\n @required_gem_paths.each do |gem_path|\r\n gem_short_name = short_form_of_gem_name gem_path\r\n if @required_gem_names.include? gem_short_name\r\n puts \"installing #{gem_path}\"\r\n installer = @force_require ? PreloadingInstaller.new( gem_path, @local_gems ) : Installer.new( gem_path )\r\n installer.install\r\n end\r\n end\r\n end", "def validate_dependencies # :nodoc:\n warning_messages = []\n @specification.dependencies.each do |dep|\n prerelease_dep = dep.requirements_list.any? do |req|\n Gem::Requirement.new(req).prerelease?\n end\n\n warning_messages << \"prerelease dependency on #{dep} is not recommended\" if\n prerelease_dep && !@specification.version.prerelease?\n\n open_ended = dep.requirement.requirements.all? do |op, version|\n not version.prerelease? and (op == '>' or op == '>=')\n end\n\n if open_ended\n op, dep_version = dep.requirement.requirements.first\n\n segments = dep_version.segments\n\n base = segments.first 2\n\n recommendation = if (op == '>' || op == '>=') && segments == [0]\n \" use a bounded requirement, such as '~> x.y'\"\n else\n bugfix = if op == '>'\n \", '> #{dep_version}'\"\n elsif op == '>=' and base != segments\n \", '>= #{dep_version}'\"\n end\n\n \" if #{dep.name} is semantically versioned, use:\\n\" \\\n \" add_#{dep.type}_dependency '#{dep.name}', '~> #{base.join '.'}'#{bugfix}\"\n end\n\n warning_messages << [\"open-ended dependency on #{dep} is not recommended\", recommendation].join(\"\\n\") + \"\\n\"\n end\n end\n if warning_messages.any?\n warning_messages.each {|warning_message| warning warning_message }\n end\n end", "def gemspecs; end", "def check_dependencies!(dep)\n depend_on(dep)\n depend_on_asset(dep)\n rescue Sprockets::FileNotFound\n end", "def validate_gemspec\n Juwelier::Commands::ValidateGemspec.build_for(self).run\n end", "def require_dependency_with_check(dependency)\n begin\n require dependency\n rescue LoadError => e\n puts \"You need to install #{dependency} before we can proceed\"\n end\nend", "def conscientious_require; end", "def test_bad_node_deps\n check_deps_fail BadNodeBall unless `/usr/bin/which node`.chomp.empty?\n end", "def requirements_for_gem(gem_name)\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| r.gem_name == gem_name }\n end", "def check_version_conflict(other) # :nodoc:\n return if self.version == other.version\n\n # This gem is already loaded. If the currently loaded gem is not in the\n # list of candidate gems, then we have a version conflict.\n\n msg = \"can't activate #{full_name}, already activated #{other.full_name}\"\n\n e = Gem::LoadError.new msg\n e.name = self.name\n\n raise e\n end", "def process_project_dependencies\n BRIX11.log_warning(\"missing #process_project_dependencies implementation for #{self.to_s}\")\n end", "def excluded_deps\n missing_deps_for(upstream_gem)\n end", "def version_required(gem_def)\n return Gem::Dependency.instance_methods.map(&:to_sym).include?(:requirement) ? gem_def.requirement : gem_def.version_requirements\nend", "def gem_deps_file # :nodoc:\n File.basename @path\n end", "def excludes_dep?(gem_name)\n excluded_deps.any? { |d| d.name == gem_name }\n end", "def build_requirements_for_gem(gem_name)\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| r.gem_name == gem_name }\n end", "def validate_gemspec\n Jeweler::Commands::ValidateGemspec.build_for(self).run\n end", "def validate_ohai_version!\n unless gem_dep_matches?(\"ohai\", Gem::Version.new(Ohai::VERSION), *ohai_versions)\n raise Exceptions::CookbookOhaiVersionMismatch.new(Ohai::VERSION, name, version, *ohai_versions)\n end\n end", "def verify\n @files = []\n @manifest = nil\n\n verify_required_files\n\n rescue Errno::ENOENT => e\n raise FoobarMod::Package::FormatError.new e.message\n rescue Gem::Package::TarInvalidError => e\n raise FoobarMod::Package::FormatError.new e.message, @mod\n end", "def depended(pkg)\n abort 'No such package exists.' unless @pkg.key?(pkg)\n warn 'Warning: A option to display obsolete package is available only for finding orphan.' if @include_obsolete\n\n sputs \"Package(s) depended on #{pkg}\"\n putpkg(getdeps(pkg))\n end", "def build_gem; end", "def test_refuse_to_install_gems_with_wrong_name_prefix\n # Here, ordinal_array is the name of a simple, small gem available on rubygems.org\n # There is no significance in choosing that gem over any other.\n # Main point here is that its name does not begin with 'inspec-'.\n assert_raises(Inspec::Plugin::V2::InstallError) { @installer.install(\"ordinal_array\") }\n end", "def gem_message(requirement)\n m = \"\"\n\n # A requirement that is required by itself is actually in the Gemfile, and does\n # not \"depend on\" itself\n if requirement.required_by.first && requirement.required_by.first.name != requirement.name\n m << \" #{clean_req(requirement.required_by.first)} depends on\\n\"\n m << \" #{clean_req(requirement)}\\n\"\n else\n m << \" #{clean_req(requirement)}\\n\"\n end\n m << \"\\n\"\n end", "def gem(name, *reqs)\n @dependencies << Gem::Dependency.new(name, reqs)\n end", "def gem(name, *reqs)\n @dependencies << Gem::Dependency.new(name, reqs)\n end", "def test_no_build_deps\n c = Control.new(__method__)\n c.parse!\n assert_equal(nil, c.source.fetch('build-depends', nil),\n \"Found a build dep #{c.source.fetch('build-depends', nil)}\")\n end", "def raise_if_gem_and_node_package_versions_differ\n return if node_package_version.relative_path?\n\n node_major_minor_patch = node_package_version.major_minor_patch\n gem_major_minor_patch = gem_major_minor_patch_version\n versions_match = node_major_minor_patch[0] == gem_major_minor_patch[0] &&\n node_major_minor_patch[1] == gem_major_minor_patch[1] &&\n node_major_minor_patch[2] == gem_major_minor_patch[2]\n\n raise_differing_versions_warning unless versions_match\n\n raise_node_semver_version_warning if node_package_version.semver_wildcard?\n end", "def validate_gemspec\n build_command(Jeweler::Commands::ValidateGemspec).run\n end", "def packages_from_require(rpmdep)\n refresh\n @rpmdb.whatprovides(rpmdep)\n end", "def validate_dependencies_are_present!\n if @podfile_dependency_cache.target_definition_list.all?(&:empty?)\n add_warning 'The Podfile does not contain any dependencies.'\n end\n end", "def missing_gem_file?(gem_file)\n files.none? { |spec_file| self.class.file_satisfies?(spec_file, gem_file) }\n end", "def platform_require\n fail NotImplementedError,\n 'Abstract method must returns `Gem::Requirement`'\n end", "def find_dependencies\n\t\tunless GEMDEPS_FILE.readable?\n\t\t\tself.prompt.warn \"Deps file (%s) is missing or unreadable, assuming no dependencies.\" %\n\t\t\t\t[ GEMDEPS_FILE ]\n\t\t\treturn []\n\t\tend\n\n\t\tfinder = Rake::DevEiate::GemDepFinder.new( GEMDEPS_FILE )\n\t\tfinder.load\n\t\treturn finder.dependencies\n\tend", "def direct_dependencies; end", "def fail\n\t\t# throw up this code and feed plezi your own lines :)\n\t\traise \"Plezi raising hell!\"\n\tend", "def require_gem(gem)\n dep = fetch(:required_gems)\n dep ||= []\n if gem.respond_to?(:each)\n dep += gem\n else\n dep << gem\n end\n set(:required_gems, dep)\n end", "def validate_chef_version!\n unless gem_dep_matches?(\"chef\", Gem::Version.new(Chef::VERSION), *chef_versions)\n raise Exceptions::CookbookChefVersionMismatch.new(Chef::VERSION, name, version, *chef_versions)\n end\n end", "def ensure_gem_versions_defined_in_appraisal_are_used\n gems_defined_in_appraisal = retrieve_gems_from_gemfile(ENV['BUNDLE_GEMFILE'])\n gems_defined_in_gemfile = retrieve_gems_from_gemfile('Gemfile').collect(&:gem_name)\n\n gems_defined_in_appraisal.reject { |l| gems_defined_in_gemfile.include? l.gem_name }.each do |gem|\n add_gem gem.gem_name, gem.attributes.join(',')\n end\n end", "def required_by(dependency, dependent_name)\n dependencies_by_requirer_name[dependent_name] ||= []\n dependencies_by_requirer_name[dependent_name] << dependency\n dependencies << dependency\n\n if acceptable_versions.empty?\n message = \"Unable to satisfy the following requirements:\\n\\n\"\n dependencies_by_requirer_name.each do |name, dependencies|\n dependencies.each do |dep|\n message << \"- `#{dep}` required by `#{name}`\\n\"\n end\n end\n raise Informative, message\n end\n end", "def gem_available?(name)\n Gem::Specification.find_by_name(name)\nrescue Gem::LoadError\n puts \"[*] - esearchy requires #{name}.\"\n if RUBY_PLATFORM =~ /mingw|mswin/\n \tsystem \"gem install #{name}\"\n else\n \tsystem \"sudo gem install #{name}\"\n end\nend", "def gemspec=(_arg0); end", "def gemspec=(_arg0); end", "def gemspec=(_arg0); end", "def gemspec=(_arg0); end", "def gemspec=(_arg0); end", "def gemspec=(_arg0); end", "def gemspec=(_arg0); end", "def extra_gem_build_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_build_requirements - gem_reqs\n end", "def extra_gem_build_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_build_requirements - gem_reqs\n end", "def non_gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| !r.gem? }\n end", "def resolve\n locking_dg = Molinillo::DependencyGraph.new\n Molinillo::Resolver.new(self, self).resolve(@needed.map {|d| DependencyRequest.new d, nil }, locking_dg).tsort.map(&:payload).compact\n rescue Molinillo::VersionConflict => e\n conflict = e.conflicts.values.first\n raise Gem::DependencyResolutionError, Conflict.new(conflict.requirement_trees.first.first, conflict.existing, conflict.requirement)\n ensure\n @output.close if defined?(@output) and !debug?\n end", "def handle_composer_errors(error)\n if error.message.start_with?(\"Failed to execute git clone\")\n dependency_url =\n error.message.match(/--mirror '(?<url>.*?)'/).\n named_captures.fetch(\"url\")\n raise Dependabot::GitDependenciesNotReachable, dependency_url\n elsif error.message.start_with?(\"Failed to clone\")\n dependency_url =\n error.message.match(/Failed to clone (?<url>.*?) via/).\n named_captures.fetch(\"url\")\n raise Dependabot::GitDependenciesNotReachable, dependency_url\n elsif error.message.start_with?(\"Could not parse version\")\n raise Dependabot::DependencyFileNotResolvable, error.message\n elsif error.message == \"Requirements could not be resolved\"\n # We should raise a Dependabot::DependencyFileNotResolvable error\n # here, but can't confidently distinguish between cases where we\n # can't install and cases where we can't update. For now, we\n # therefore just ignore the dependency.\n nil\n elsif error.message.include?(\"URL required authentication\") ||\n error.message.include?(\"403 Forbidden\")\n source =\n error.message.match(%r{https?://(?<source>[^/]+)/}).\n named_captures.fetch(\"source\")\n raise Dependabot::PrivateSourceNotReachable, source\n elsif error.message.start_with?(\"Allowed memory size\")\n raise \"Composer out of memory\"\n else\n raise error\n end\n end", "def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end", "def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end", "def gemfile; end" ]
[ "0.6724499", "0.6724499", "0.66882056", "0.66457987", "0.6574887", "0.6574887", "0.6569999", "0.6400102", "0.6347521", "0.63227403", "0.6306154", "0.6276875", "0.6249284", "0.6249284", "0.61831915", "0.6126752", "0.6122544", "0.6116536", "0.6113339", "0.61018604", "0.61018604", "0.602507", "0.602507", "0.602507", "0.602507", "0.602507", "0.602507", "0.602507", "0.602507", "0.6005887", "0.5927757", "0.5899318", "0.5880773", "0.5840114", "0.5840114", "0.5804564", "0.5798002", "0.57476807", "0.57476807", "0.57476807", "0.5733691", "0.5733691", "0.573259", "0.57162565", "0.57023376", "0.56789523", "0.56654435", "0.56633174", "0.5659872", "0.5624974", "0.5623201", "0.5603217", "0.55722487", "0.55570936", "0.5555845", "0.5553207", "0.55278563", "0.54921216", "0.54912084", "0.54710674", "0.54602027", "0.54563534", "0.54489", "0.5438178", "0.54209185", "0.54189104", "0.5415702", "0.5414665", "0.5412658", "0.5412658", "0.5393235", "0.5392355", "0.53880763", "0.5378413", "0.5371801", "0.53645426", "0.5364193", "0.5363348", "0.5360804", "0.53590983", "0.5357949", "0.53570426", "0.5353658", "0.5349894", "0.5346467", "0.5337447", "0.5337447", "0.5337447", "0.5337447", "0.5337447", "0.5337447", "0.5337447", "0.5332538", "0.5332538", "0.5322924", "0.53140676", "0.5296448", "0.5296059", "0.5296059", "0.5289374" ]
0.64553404
7
Ignore a gem dependency API call.
def no_op_method( * ) # :nodoc: yield if block_given? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def excluded_deps\n missing_deps_for(upstream_gem)\n end", "def enabled_dependencies\n @dependencies.reject(&:ignore?)\n end", "def allow_missing?(dependency)\n false\n end", "def excluded_dev_deps\n missing_dev_deps_for(upstream_gem)\n end", "def excludes_dep?(gem_name)\n excluded_deps.any? { |d| d.name == gem_name }\n end", "def with_optional_dependency\n yield if block_given?\nrescue LoadError # rubocop:disable Lint/SuppressedException\nend", "def with_optional_dependency\n yield if block_given?\nrescue LoadError # rubocop:disable Lint/SuppressedException\nend", "def missing_deps_for(gem)\n # Comparison by name here assuming if it is in existing spec,\n # spec author will have ensured versions are correct for their purposes\n gem.deps.select { |dep| requirements_for_gem(dep.name).empty? }\n end", "def no_nuget_dependencies\n @nuget_dependencies = false\n end", "def skip_transitive_dependency_licensing(val = NULL)\n if null?(val)\n @skip_transitive_dependency_licensing || false\n else\n @skip_transitive_dependency_licensing = val\n end\n end", "def ignored_versions_for(dep)\n if $options[:ignore_conditions].any?\n ignore_conditions = $options[:ignore_conditions].map do |ic|\n Dependabot::Config::IgnoreCondition.new(\n dependency_name: ic[\"dependency-name\"],\n versions: ic[\"versions\"],\n update_types: ic[\"update-types\"]\n )\n end\n # Dependabot::Config::UpdateConfig.new(ignore_conditions: ignore_conditions).\n # ignored_versions_for(dep, security_updates_only: $options[:security_updates_only])\n Dependabot::Config::UpdateConfig.new(ignore_conditions: ignore_conditions).ignored_versions_for(dep)\n else\n $update_config.ignored_versions_for(dep)\n end\nend", "def ignored?(dependency)\n config.ignored?(dependency.metadata, require_version: self.class.require_matched_dependency_version)\n end", "def skipDeps(deps) \n deps = deps.select { |ding| !ding.include?(\"/commons-cli\") }\n deps = deps.select { |ding| !ding.include?(\"/commons-logging\") }\n deps = deps.select { |ding| !ding.include?(\"/commons-lang-2.1\") }\n deps = deps.select { |ding| !ding.include?(\"/commons-pool\") }\n return deps\nend", "def ignore_apdex\n record_api_supportability_metric(:ignore_apdex)\n NewRelic::Agent::Transaction.tl_current&.ignore_apdex!\n end", "def dependency_unmet?(*args, &block); end", "def non_gem_requirements\n @metadata[:requires].nil? ? [] :\n @metadata[:requires].select { |r| !r.gem? }\n end", "def gem(gem_name, *version_requirements)\n if gem_name =='i18n'\n puts \"skipping loading the i18n gem ...\"\n return\n end\n super(gem_name, *version_requirements)\nend", "def require_gems; end", "def remove_via_api!\n QA::Runtime::Logger.debug(\"#{self.class.name} - deferring removal until after suite\")\n end", "def testIgnoreDep\n lCalled = false\n setupAppDir do\n setupRegressionUI('RDI::Test::Flows::UIFlows::RegressionUI') do\n # Tune the UI's behaviour\n @Installer.access_plugin('Views', 'RegressionUI') do |ioPlugin|\n ioPlugin.Ignore = true\n end\n # Call the installer expecting the GUI to appear\n lDesc = getSimpleDesc\n lError, lCMApplied, lIgnoredDeps, lUnresolvedDeps = @Installer.ensure_dependencies( [ lDesc ], {\n :preferred_views => [ 'RegressionUI' ]\n } )\n # Check results\n assert_equal(nil, lError)\n assert_equal( {}, lCMApplied )\n assert_equal( [ lDesc ], lIgnoredDeps )\n assert_equal( [], lUnresolvedDeps )\n # Get the plugin back\n @Installer.access_plugin('Views', 'RegressionUI') do |iPlugin|\n # Check that it was called correctly\n lCalled = iPlugin.Called\n end\n # Check that the dependency is not resolved\n @Installer.access_plugin('Testers', 'Binaries') do |iPlugin|\n assert_equal(false, iPlugin.is_content_resolved?(['DummyBinary']))\n end\n end\n end\n assert_equal(true, lCalled)\n end", "def ignore_package(package)\n invalidate_ignored_package_names\n @ignored_packages << validate_package_name_argument(package, require_existing: false)\n end", "def inaccessible_git_dependencies\n in_a_temporary_bundler_context(error_handling: false) do\n ::Bundler::Definition.build(\"Gemfile\", nil, {}).dependencies.\n reject do |spec|\n next true unless spec.source.is_a?(::Bundler::Source::Git)\n\n # Piggy-back off some private Bundler methods to configure the\n # URI with auth details in the same way Bundler does.\n git_proxy = spec.source.send(:git_proxy)\n uri = spec.source.uri.gsub(\"git://\", \"https://\")\n uri = git_proxy.send(:configured_uri_for, uri)\n uri += \".git\" unless uri.end_with?(\".git\")\n uri += \"/info/refs?service=git-upload-pack\"\n\n begin\n Excon.get(\n uri,\n idempotent: true,\n **SharedHelpers.excon_defaults\n ).status == 200\n rescue Excon::Error::Socket, Excon::Error::Timeout\n false\n end\n end\n end\n end", "def ignore_conditions_for(options, dependency)\n # Find where the name matches then get an array of version requirements, e.g. [\"4.x\", \"5.x\"]\n found = options.find { |ig| dependency.name.match?(ig['name']) }\n found ? found['versions'] || [] : []\nend", "def ignore_dependency(*args)\n raise 'Cannot ignore dependencies without loading.' unless @dump\n\n args.each do |name|\n dependency = @dependencies.find { |d| d.name == name }\n dependency.ignore\n ignore_columns dependency.foreign_key, dependency.foreign_type\n end\n end", "def ignore?(pkg)\n ignores.include?(pkg)\n end", "def ignore_method_conflicts; end", "def remove_unused_dependencies\n # puts 'removing unused dependencies list.'\n dependencies = @target.dependencies\n dependencies.each do |dependency|\n dependency.remove_from_project if unused_dependencies_list.include? dependency.display_name\n end\n end", "def missing_dev_deps_for(gem)\n # Same note as in #missing_deps_for above\n gem.dev_deps.select { |dep| build_requirements_for_gem(dep.name).empty? }\n end", "def ignored?(package_name)\n raise RuntimeError, \"#{self.class} needs to overwrite ignored?\"\n end", "def no_project_dependencies\n @project_dependencies = false\n end", "def excludes_dev_dep?(gem_name)\n excluded_dev_deps.any? { |d| d.name == gem_name }\n end", "def inaccessible_git_dependencies\n in_a_temporary_bundler_context(error_handling: false) do\n ::Bundler::Definition.build(\"Gemfile\", nil, {}).dependencies.\n reject do |spec|\n next true unless spec.source.is_a?(::Bundler::Source::Git)\n\n # Piggy-back off some private Bundler methods to configure the\n # URI with auth details in the same way Bundler does.\n git_proxy = spec.source.send(:git_proxy)\n uri = spec.source.uri.gsub(\"git://\", \"https://\")\n uri = git_proxy.send(:configured_uri_for, uri)\n uri += \".git\" unless uri.end_with?(\".git\")\n uri += \"/info/refs?service=git-upload-pack\"\n\n begin\n Excon.get(\n uri,\n idempotent: true,\n omit_default_port: true,\n middlewares: SharedHelpers.excon_middleware\n ).status == 200\n rescue Excon::Error::Socket, Excon::Error::Timeout\n false\n end\n end\n end\n end", "def no_bundler\n @bundler = false\n end", "def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end", "def test_bad_rubinius_deps\n check_deps_fail \"notapackage\" => :rbx if which('rbx')\n end", "def exclude_dependencies!(exclusions)\n included, excluded = dependencies.partition { |d| !exclusions.include? d.name }\n self.dependencies = included\n excluded\n end", "def gem\n if dependency\n GemsBond::Gem.new(dependency)\n else\n unknown_dependency = Bundler::Dependency.new(@name, nil)\n GemsBond::Gem.new(unknown_dependency, unknown: true)\n end\n end", "def dependents_exclude_self\n dependents.where.not(id: id)\n end", "def warn(*args)\n # eliminate ruby/gem warnings from output\nend", "def require_matched_dependency_version\n false\n end", "def optional(*args)\n normalize_list(args).each do |dependency|\n @available.add_optional(dependency)\n end\n end", "def silence_deprecations; end", "def ignore_request(_team, _user)\n # stub\n end", "def api_only; end", "def api_only; end", "def api_only; end", "def skip_libraries_installation\n self.options = options.merge(\n skip_bundle: true,\n skip_webpack_install: true\n )\nend", "def process_project_dependencies\n BRIX11.log_warning(\"missing #process_project_dependencies implementation for #{self.to_s}\")\n end", "def exclude_package(package_name, reason)\n package = validate_package_name_argument(\n package_name, require_existing: false\n )\n if (meta = find_metapackage(package))\n meta.each_package do |pkg|\n automatic_exclusions[pkg.name] =\n \"#{meta.name} is an excluded metapackage, \"\\\n \"and it includes #{pkg.name}: #{reason}\"\n end\n else\n automatic_exclusions[package] = reason\n end\n end", "def depended(pkg)\n abort 'No such package exists.' unless @pkg.key?(pkg)\n warn 'Warning: A option to display obsolete package is available only for finding orphan.' if @include_obsolete\n\n sputs \"Package(s) depended on #{pkg}\"\n putpkg(getdeps(pkg))\n end", "def ignore_method_conflicts=(_arg0); end", "def method_missing(sym, *a, &b) # :nodoc:\n if REMOVED_METHODS.include?(sym)\n removed_method_calls << sym\n return\n end\n\n if @specification_version > CURRENT_SPECIFICATION_VERSION and\n sym.to_s.end_with?(\"=\")\n warn \"ignoring #{sym} loading #{full_name}\" if $DEBUG\n else\n super\n end\n end", "def remove_package_deps(pkg_name)\n if @index[:packages].key?(pkg_name) &&\n !@index[:packages][pkg_name].empty?\n @index[:packages][pkg_name].each do |dep|\n @index[:deps][dep].delete(pkg_name)\n end\n end\n end", "def version_required(gem_def)\n return Gem::Dependency.instance_methods.map(&:to_sym).include?(:requirement) ? gem_def.requirement : gem_def.version_requirements\nend", "def check_dependencies!(dep)\n depend_on(dep)\n depend_on_asset(dep)\n rescue Sprockets::FileNotFound\n end", "def require_dependency_with_check(dependency)\n begin\n require dependency\n rescue LoadError => e\n puts \"You need to install #{dependency} before we can proceed\"\n end\nend", "def each_excluded_package\n return enum_for(__method__) unless block_given?\n\n each_autobuild_package do |pkg|\n yield(pkg) if excluded?(pkg.name)\n end\n end", "def delete_dependencies\n raise 'Not implemented'\n end", "def non_gem_build_requirements\n @metadata[:build_requires].nil? ? [] :\n @metadata[:build_requires].select { |r| !r.gem? }\n end", "def hidden_apis; end", "def dep_check\n $gems_required.each do |current_gem|\n begin\n if current_gem.include? \",\"\n tokens = current_gem.split(\",\")\n gem tokens[0], tokens[1]\n else\n gem current_gem\n end\n rescue Gem::LoadError\n if current_gem.include? \",\"\n $gems_missing_version << current_gem\n else\n $gems_missing << current_gem\n end\n end\n end\n if $gems_missing.length == 0 && $gems_missing_version.length == 0\n return true\n else\n return false\n end\nend", "def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end", "def extra_gem_requirements(gem)\n gem_reqs = gem.deps.collect { |d| requirements_for_gem(d.name) }.flatten\n gem_requirements - gem_reqs\n end", "def dependency_met?\n true\n end", "def request_dependencies\n end", "def resolve_pull_request_dependencies(pull_requests)\n OverridesRetriever.new(client, pull_requests).resolve_dependencies\n end", "def api_used!\n update_column(:api_used, true) unless api_used?\n end", "def fetch_development_dependencies # :nodoc:\n end", "def direct_dependencies; end", "def no_download!\n\t\traise_if_error C.glyr_opt_download(to_native, false)\n\tend", "def install_dependencies\n raise 'Not implemented'\n end", "def require_without_bundler(*gems)\n unless defined?(::Bundler)\n gems.each { |g| require g }\n return\n end\n Dir.glob(\"#{Gem.path.first}/gems/*\").map { |gem_path| \n gem_name=File.basename(gem_path).gsub(/-(\\d\\.?)+$/,'')\n if gems.include?(gem_name)\n $LOAD_PATH << \"#{gem_path}/lib\"\n require gem_name\n end\n }\nend", "def request_libraries\n raise StandardError, 'Unsupported, fix this'\n end", "def ignore; end", "def from_api?; false end", "def test_bad_chicken_deps\n check_deps_fail \"notapackage\" => :chicken if which('csc')\n end", "def test_bad_chicken_deps\n check_deps_fail \"notapackage\" => :chicken if which('csc')\n end", "def dependencies\n raise \"#{self.class} needs to overwrite dependencies\"\n end", "def disable_imports_from(name)\n Autoproj.workspace.manifest.disable_imports_from(name)\nend", "def disabled?\n super || !gemfile.exist?\n end", "def gemspec( * )\n\t\traise \"Circular dependency: can't depend on the gemspec to build itself\"\n\tend", "def allow_missing?(dependency)\n # Puppet dependencies must _always_ be resolvable\n return false if dependency.is_a?(Models::PuppetDependency)\n # Explicit Puppetfile dependencies must _always_ be resolvable\n return false if dependency.is_a?(Models::PuppetfileDependency)\n @allow_missing_modules\n end", "def remote_dependencies(gem_name, _version)\n conn = Faraday.new(url: 'https://rubygems.org') do |h|\n h.headers[:content_type] = 'application/x-www-form-urlencoded'\n h.request :url_encoded\n h.adapter :excon\n end\n response = conn.get(\"/api/v1/gems/#{gem_name}.json\")\n dep_list = MultiJson.load(response.body)\n dep_list['dependencies'].values.flatten.map do |j|\n Gem::Dependency.new(\n j['name'],\n Gem::Requirement.new(j['requirements'].split(','))\n )\n end\n end", "def check_for_libraries; end", "def ignore_me\nend", "def dependencies; end", "def dependencies; end", "def dependencies; end", "def one_gradable_ex_only\n end", "def ignore(*args); end", "def private_gem(name)\n gem name, '0.3.0', git: \"https://#{ENV['GITHUB_TOKEN']}:x-oauth-basic@github.com/mharris717/#{name}.git\", branch: :master\nend", "def clear_ignored\n invalidate_ignored_package_names\n ignored_packages.clear\n end", "def google_package\n return nil\n end", "def undo_bundler_extending\n if defined?(::Bundler)\n all_global_gem_paths = Dir.glob(\"#{Gem.dir}/gems/*\")\n\n all_global_gem_paths.each do |p|\n gem_path = \"#{p}/lib\"\n $LOAD_PATH.delete(gem_path)\n end\n else\n vputs %([**:#{@name}] Bundler not defined. Skipping.)\n end\n end", "def conscientious_require; end", "def api_only=(_arg0); end", "def rubinius_skip(message = '')\n skip message if RUBY_ENGINE == 'rbx'\nend", "def rubinius_skip(message = '')\n skip message if RUBY_ENGINE == 'rbx'\nend", "def rubinius_skip(message = '')\n skip message if RUBY_ENGINE == 'rbx'\nend", "def ignore_enduser\n record_api_supportability_metric(:ignore_enduser)\n NewRelic::Agent::Transaction.tl_current&.ignore_enduser!\n end", "def patch_nokogiri\n rm_rf \"deps.rip\"\n end" ]
[ "0.67253166", "0.619571", "0.619176", "0.616641", "0.61537457", "0.6069599", "0.6069599", "0.6041873", "0.60235244", "0.5940439", "0.59284616", "0.58688396", "0.5813702", "0.57521874", "0.57307374", "0.5716537", "0.5680987", "0.56657743", "0.56621003", "0.56396055", "0.56356066", "0.563378", "0.5616816", "0.56050324", "0.55979127", "0.5593673", "0.5592698", "0.5585423", "0.5582122", "0.55799556", "0.5579717", "0.55719376", "0.55564207", "0.5555651", "0.5555651", "0.5541327", "0.55183256", "0.5464477", "0.5464468", "0.54522973", "0.5422563", "0.5410912", "0.5407114", "0.53997064", "0.53997064", "0.53997064", "0.5396601", "0.53959334", "0.53935164", "0.5390712", "0.5347437", "0.53361595", "0.5330809", "0.5323793", "0.5315532", "0.5311941", "0.5287769", "0.5269418", "0.5265278", "0.5250191", "0.5247031", "0.5228225", "0.5228225", "0.52207243", "0.52117467", "0.5193769", "0.5178896", "0.5172314", "0.5168404", "0.51600176", "0.514827", "0.5147569", "0.5126137", "0.5124429", "0.51188374", "0.5115876", "0.5115876", "0.5112174", "0.51053774", "0.5104317", "0.51039565", "0.50832415", "0.5082985", "0.5081759", "0.50807536", "0.5080515", "0.5080515", "0.5080515", "0.5073549", "0.5063976", "0.5060076", "0.5060068", "0.5057863", "0.50551784", "0.50541806", "0.5048043", "0.5039185", "0.5039185", "0.5039185", "0.50353575", "0.5032976" ]
0.0
-1
Public: Stops the Honeybadger service. Examples: Honeybadger.stop => nil Returns nothing
def stop Agent.stop end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stop\n DRb.stop_service\n end", "def service_stop; end", "def stop_service\n DRb.stop_service\n end", "def terminate!\n DRb.stop_service\nend", "def stop\r\n DRb.stop_service\r\n @log.info(\"Provider stopped on : #{@drb_server_uri}\")\r\n end", "def stop\n @builder.terminate\n @server.terminate\n end", "def stop(klass, *args)\n stop_service(hals[hardcore_alias(klass, *args)])\n end", "def stop\n\n @stopped = true\n end", "def stop (bundleId)\n execute(:stop, bundleId)\n end", "def stop\n ck_valid\n Process.kill 15, @pid if running?\n\n invalidate\n end", "def stop\n\t\treturn nil unless self.running?\n\t\tbegin\n\t\t\tProcess.kill 'TERM', @pid\n\t\t\tProcess.waitpid( @pid, 0 )\n\t\trescue SystemCallError => err\n\t\t\t$stderr.puts \"SystemCallError while stopping: #{err.message}\" if\n\t\t\t\t$DEBUG || $VERBOSE\n\t\tend\n\n\t\t@errlog = nil\n\t\t@custom_logs = {}\n\t\tObjectSpace.undefine_finalizer( self )\t\n\tend", "def cmd_stop argv\n setup argv\n uuid = @hash['uuid']\n response = @api.stop(uuid)\n msg response\n return response\n end", "def stop\n control :kill\n self\n end", "def stop\n\t\t\tSystem.logger.info \"stopping #{@controller.name}\"\n\t\t\t@sys_lock.synchronize {\n\t\t\t\tstop_nolock\n\t\t\t}\n\t\tend", "def stop\n process.stop\n end", "def stop\n system(\"pkill -f #{DAEMON}\")\n end", "def server_stop\n Process.kill 'INT', 0\n end", "def stop\n puts \"Stopping load balancer...\"\n begin\n Process.kill(\"TERM\", @pid)\n rescue\n STDERR.puts \"Error stopping load balancer: #{$!}\"\n end\n end", "def stop\n @pull.close if !@pull.nil?\n @push.close if !@push.nil?\n Communicator::get_logger.info \"Forcing app to shut down\"\n exit 0\n end", "def stop!\n @stopped = true\n end", "def stop\n @stopped = true\n end", "def shut_down\n end", "def stop!\n log \">> Stopping ...\"\n\n @backend.stop!\n end", "def stop\n @stopping = true\n supervisor.terminate\n end", "def stop_bot\n $bot.stop\n log(\"Stopped bot\")\nrescue => e\n fatal(\"Failed to stop the bot: #{e}\")\n exit\nend", "def stop\n end", "def stop\n end", "def stop\n end", "def stop\n end", "def stop\n end", "def stop\n end", "def stop\n end", "def stop\n end", "def stop\n # use pid in controlling process, webrick in server process\n @webrick.shutdown if @webrick\n Process.kill('INT', @pid) if @pid\n end", "def stop\n return if @status == :stopped\n begin\n Process::kill('-TERM', @pid)\n rescue Exception => e\n # nothing here\n ensure\n @status = :stopped\n end\n end", "def stop!\n stopper.call\n end", "def stop\n connection.write(\"stop\")\n end", "def stop\n connection.write(\"stop\")\n end", "def stop\n connection.write(\"stop\")\n end", "def stop\n info \"STOP!\"\n @worker.shutdown! if @worker\n end", "def stop\n exit\n end", "def stop\n end", "def stop\n end", "def stop\n end", "def stop\n end", "def stop\n\t\t# No-op\n\tend", "def service_stop(name)\n\t\tif session_has_services_depend?\n\t\t\tmeterpreter_service_stop(name)\n\t\telse\n\t\t\tshell_service_stop(name)\n\t\tend\n\tend", "def stop\n\t\tself.request( :stop )\n\tend", "def stop!\n @state = :stopped\n end", "def stop\n UI.info \"Shutting down Rack...\"\n ::Process.kill(\"TERM\", @pid)\n ::Process.wait(@pid)\n @pid = nil\n true\n end", "def stop\n # no-op\n end", "def stop\n action('stop')\n end", "def stop\n system(\"start-stop-daemon --stop --pidfile #{pidfile}\")\n end", "def stop!\n @monitor.kill\n @logger.info({context: :monitor, action: :stop!})\n end", "def stop\n put :stop\n end", "def stop\n # Permissions are handled by the script, use: :sudo => false\n run_script :stop, :sudo => false\n end", "def stop\n rpc(:stop).key?(:success)\n end", "def stop\n @running = false\n end", "def stop\n @running = false\n end", "def stop\n @running = false\n end", "def stop\n @running = false\n end", "def stop\n Daemons.run(file_path, options.merge(ARGV: ['stop']))\n end", "def stop!\n # Permissions are handled by the script, use: :sudo => false\n run_script! :stop, :sudo => false\n end", "def stop!; end", "def stop\n Agent.stop\n end", "def stop; self.app.stop end", "def stop\n if @pid\n kind_kill -@pid\n @pid = nil\n end\n end", "def stop()\n @state = STOPPED\n end", "def stop!\n return unless @started\n @hook_manager.delete_hook(:hook_log_message, @hook_id)\n end", "def stop\n @stopped = true\n end", "def stop\n @stopped = true\n end", "def stop\n if @subprocess\n Herald.kill(@subprocess)\n end\n @subprocess = nil\n self\n end", "def stop\n if working\n @stop = true\n else\n exit\n end\n end", "def stopKill\n self.stop_d\n return\n end", "def stop\n @running = false\n end", "def stop\n @running = false\n end", "def stop\n log('Attempting to stop')\n\n return not_enabled unless Vedeu.config.drb?\n\n if drb_running?\n log('Stopping')\n\n DRb.stop_service\n\n DRb.thread.join\n\n else\n log('Already stopped')\n\n end\n rescue NoMethodError # raised when #join is called on NilClass.\n Vedeu.log(type: :drb,\n message: 'Attempted to #join on DRb.thread.')\n end", "def stop\n @stop_loop.call\n end", "def stop\n log('Attempting to stop')\n\n return not_enabled unless Vedeu::Configuration.drb?\n\n if drb_running?\n log('Stopping')\n\n DRb.stop_service\n\n DRb.thread.join\n\n else\n log('Already stopped')\n\n end\n rescue NoMethodError # raised when #join is called on NilClass.\n Vedeu.log(type: :drb, message: 'Attempted to #join on DRb.thread.')\n end", "def stop\n Cocaine::CommandLine.new(\n @opt.fetch(:command, 'bin/delayed_job'),\n 'stop'\n ).run\n end", "def stop!\n @stop = true\n end", "def stop!\n @stop = true\n end", "def stop\n data = { :bot => Encryptor.encrypt({:id => id}.to_json, :key => $secret_key) }\n RestClient.post \"#{$service_url}/api/bot/stop\", data, { :content_type => :json, :accept => :json }\n rescue => error\n { :status => :error, :message => error.to_s }\n end", "def stop(params)\n Felixwrapper.configure(params)\n Felixwrapper.instance.stop\n return Felixwrapper.instance\n end", "def stop_handler\n end", "def terminate\n @process.stop\n end", "def drb_stop!\n Vedeu.bind(:_drb_stop_) { Vedeu::Distributed::Server.stop }\n end", "def stop\n @server.stop if @server.running?\n end", "def stop(options = {})\n # set :stopping\n info \"stopping job\"\n unsubscribe\n kill if options[:force]\n end", "def stop\n end", "def stop\n end", "def stop\n end", "def stop(flags = {})\n raise BreakControllerException.new(flags)\n end", "def stop!\n system \"pkill -f play\"\n end", "def stop\n @shutdown = true\n end", "def stop\n @thread.kill\n return nil\n end", "def stop\n system \"kill #{pid} > /dev/null 2>&1\"\n sleep(0.1)\n not rails?\n end", "def stop\n return if not running?\n @running = false\n @server.shutdown\n end", "def kill\n shutdown\n end", "def stop\n\t\tC.glyr_signal_exit(to_native)\n\tend" ]
[ "0.72559756", "0.702745", "0.6960373", "0.6931874", "0.6613953", "0.6559665", "0.65080166", "0.638478", "0.63624275", "0.6361757", "0.63569176", "0.6356461", "0.63346195", "0.6313708", "0.63101226", "0.62923825", "0.62743783", "0.6272089", "0.6258252", "0.62534255", "0.6228464", "0.6224424", "0.62125885", "0.6211048", "0.6210815", "0.6203705", "0.6203705", "0.6203705", "0.6203705", "0.6203705", "0.6203705", "0.6203705", "0.6203705", "0.6201496", "0.6195581", "0.617116", "0.6170995", "0.6170995", "0.6170995", "0.61665195", "0.6164291", "0.6157501", "0.6157501", "0.6157501", "0.6157501", "0.6153549", "0.615154", "0.61456615", "0.6134509", "0.6126366", "0.6125331", "0.61208767", "0.61191046", "0.6112717", "0.6104231", "0.6102716", "0.6100239", "0.6093737", "0.6093737", "0.6093737", "0.60871863", "0.60694", "0.6061928", "0.60599595", "0.6054464", "0.60534686", "0.60523266", "0.6046333", "0.60349226", "0.60291976", "0.60291976", "0.60187113", "0.6015923", "0.60093224", "0.6009039", "0.6009039", "0.6004521", "0.60013956", "0.600133", "0.5998276", "0.5995973", "0.5995973", "0.5986284", "0.5981552", "0.59766746", "0.5973788", "0.59716296", "0.59632057", "0.5959608", "0.59427637", "0.59427637", "0.59427637", "0.5940177", "0.59379405", "0.59325725", "0.5931989", "0.59223676", "0.591719", "0.5915556", "0.59098446" ]
0.61755747
35
Public: Callback to filter backtrace lines. One use for this is to make additional [PROJECT_ROOT] or [GEM_ROOT] substitutions, which are used by Honeybadger when grouping errors and displaying application traces. block A block which can be used to modify the Backtrace lines sent to Honeybadger. The block expects one argument (line) which is the String line from the Backtrace, and must return the String new line. Examples: Honeybadger.backtrace_filter do |line| line.gsub(/^\/my\/unknown\/bundle\/path/, "[GEM_ROOT]") end Returns nothing.
def backtrace_filter(&block) Agent.backtrace_filter(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter(backtrace); end", "def filter(backtrace); end", "def filter_backtrace(backtrace)\n ## remove backtraces that match any pattern in IGNORE_CALLERS\n trace = backtrace.reject{|b| IGNORE_CALLERS.any?{|i| i=~b}}\n ## remove `:in ...` portion of backtraces\n trace = trace.map do |bt| \n i = bt.index(':in')\n i ? bt[0...i] : bt\n end\n ## now apply MiniTest's own filter (note: doesn't work if done first, why?)\n trace = MiniTest::filter_backtrace(trace)\n ## if the backtrace is empty now then revert to the original\n trace = backtrace if trace.empty?\n ## simplify paths to be relative to current workding diectory\n trace = trace.map{ |bt| bt.sub(Dir.pwd+File::SEPARATOR,'') }\n return trace\n end", "def filter_backtrace(parsed_backtrace, raw_backtrace)\n head = backtrace.take_while { |file, _| !user_file?(file) }\n tail = backtrace[head.size..-1].find_all { |file, _| user_file?(file) }\n head + tail\n end", "def filter_backtrace(backtrace)\n target = backtrace.find_index{|line| line =~ /#{__FILE__.gsub('.', '\\.').gsub('/', '\\/')}.*eval/ }\n target ? backtrace[0..target] : backtrace\n end", "def filter(backtrace)\n result = []\n return result unless backtrace\n\n backtrace.each do |line|\n break if filters?(line)\n result << line\n end\n\n result = backtrace.reject { |line| filters?(line) } if result.empty?\n result = backtrace.dup if result.empty?\n\n result\n end", "def clean(backtrace)\n filtered = filter_backtrace(backtrace)\n\n backtrace.reverse.map do |trace_line|\n in_app = frame_in_app?(trace_line)\n [trace_line, in_app]\n end\n end", "def filter_backtrace(exception)\n prefix = Rails.root.to_s\n select_prefix = false\n exception.backtrace.select do |line|\n if line.start_with?(prefix)\n select_prefix = true\n else\n !select_prefix\n end\n end\n end", "def filter_backtrace_with_lightning_test backtrace, prefix=nil\n rv = filter_backtrace_without_lightning_test(backtrace, prefix)\n rv = filter_backtrace_without_lightning_test(rv, File.dirname(__FILE__))\n rv\n end", "def clean_backtrace(backtrace)\n trace = backtrace.reject{ |bt| bt =~ INTERNALS }\n trace = trace.map do |bt| \n if i = bt.index(':in')\n bt[0...i]\n else\n bt\n end\n end\n trace = backtrace if trace.empty?\n trace = trace.map{ |bt| bt.sub(Dir.pwd+File::SEPARATOR,'') }\n trace\n end", "def backtrace\n @backtrace ||= Protest.backtrace_filter.filter_backtrace(raw_backtrace)\n end", "def backtrace_filter(filters = nil)\n @backtrace_filters.merge!(filters) if filters\n @backtrace_filters\n end", "def clean_backtrace(&block) #:nodoc:\n # Modified from Rails' version\n begin\n yield\n rescue Object => error\n library_path = Regexp.new(\n File.expand_path(\"#{File.dirname(__FILE__)}/(assertions|unit)\") + \n '|benchmark.rb.*measure'\n )\n error.backtrace.reject! { |line| File.expand_path(line) =~ library_path }\n raise\n end\n end", "def remove_this_file_from_backtrace(backtrace)\n regexp = %r\"#{Regexp.quote(__FILE__)}\"o\n line_number = 0\n until regexp =~ backtrace[line_number] || line_number == 0\n line_number += 1\n end\n backtrace.slice!(line_number..-1)\n end", "def clean_backtrace(exception)\n if backtrace = exception.backtrace\n if Egregious.root\n backtrace.map { |line|\n line.sub Egregious.root.to_s, ''\n }\n else\n backtrace\n end\n end\n end", "def first_filtered_bt_line(backtrace)\n ((fbt = backtrace.filtered).empty? ? backtrace : fbt).first.to_s\n end", "def backtrace_remove=(_arg0); end", "def backtrace_remove; end", "def backtrace_includes=(_arg0); end", "def filtered_stacktrace(stacktrace, count: 20)\n lines = []\n\n stacktrace[0..count].inject(false) do |filtered_last_line, line|\n if filter_stacktrace_entry?(line)\n lines << \"... (lines removed) ...\" unless filtered_last_line\n true\n else\n lines << shorten_path(line)\n false\n end\n end\n\n lines\n end", "def line_filter(line)\n entry_pattern.match(line)\n end", "def clean_backtrace e\n if defined?(Rails) && ::Rails.respond_to?(:backtrace_cleaner)\n ::Rails.backtrace_cleaner.clean(e.backtrace)\n else\n e.backtrace\n end\n end", "def clean(backtrace, kind = :silent)\n filtered = filter(backtrace)\n\n case kind\n when :silent\n silence(filtered)\n when :noise\n noise(filtered)\n else\n filtered\n end\n end", "def clean_backtrace(exception)\n if backtrace = exception.backtrace\n\t\t\tbacktrace.join(\"\\n \") + \"\\n\\n\"\n\t\tend\n\tend", "def clean_backtrace(exception)\n if backtrace = exception.backtrace\n\t\t\tbacktrace.join(\"\\n \") + \"\\n\\n\"\n\t\tend\n\tend", "def clean_backtrace(backtrace)\n Lorekeeper::BacktraceCleaner.instance.clean(backtrace)\n end", "def backtrace_cleaner; end", "def backtrace_includes; end", "def stacktrace_includes=(_arg0); end", "def clean(backtrace, kind = :silent)\n filtered = filter_backtrace(backtrace)\n\n case kind\n when :silent\n silence(filtered)\n when :noise\n noise(filtered)\n else\n filtered\n end\n end", "def _extract_callstack(_callback)\n warn 'Please pass `caller_options` to the deprecation API' if $VERBOSE\n offending_line = callstack.find { |line| !ignored_callstack(line) || callstack.first }\n\n if offendihng_line\n md = offending_line.match(FILE_LINE_METHOD_REGEXP)\n\n if md.present?\n md.captures\n else\n offending_line\n end\n end\n end", "def _smart_backtrace(e)\n prefix = File.expand_path('../../..', __FILE__)\n seen_own = false\n e.backtrace.select do |line|\n matches = line.start_with?(prefix)\n seen_own = true if matches\n matches || !seen_own\n end\n end", "def stacktrace_excludes=(_arg0); end", "def clean_trace bt, script_filename\n short_trace = []\n bt.each do |line|\n break unless line.include?(script_filename)\n short_trace << line\n end\n short_trace\n end", "def pretty_backtrace backtrace = caller(1)\n trace = purge_harness_files_from( Array( backtrace ) )\n expand_symlinks( trace ).join \"\\n\"\n end", "def external_caller_for_log\n ignore = caller_logging_ignore\n c = caller.find do |line|\n !(line.start_with?(SEQUEL_LIB_PATH) ||\n line.start_with?(RbConfig::CONFIG[\"rubylibdir\"]) ||\n (ignore && line =~ ignore))\n end\n\n if c\n c = if formatter = caller_logging_formatter\n formatter.call(c)\n else\n \"(source: #{c})\"\n end\n end\n\n c\n end", "def backtrace_ignores; end", "def clean_backtrace(error)\n if $DEBUG\n error\n else\n bt = error.backtrace\n bt = bt.reject{ |e| /roll/ =~ e }\n error.set_backtrace(bt)\n error\n end\n end", "def remove_eval_internals_from_backtrace(backtrace)\n regexp = /^\\(eval\\)|^<main>/ # SketchUp 2017 | SketchUp 2014+\n line_number = backtrace.length\n until regexp =~ backtrace[line_number-1] || line_number == 0\n line_number -= 1\n end\n backtrace.slice!(line_number..-1)\n end", "def print_colorized_backtrace(e)\n e.backtrace.map! do |line|\n line.gsub!(/^#{Merb.framework_root}/, \"\\e[34mFRAMEWORK_ROOT\\e[31m\")\n end\n \n Merb.logger.fatal! \"\\e[34mFRAMEWORK_ROOT\\e[0m = #{Merb.framework_root}\"\n Merb.logger.fatal!\n Merb.logger.fatal! \"\\e[31m#{e.class}: \\e[1;31;47m#{e.message}\\e[0m\"\n e.backtrace.each do |line|\n Merb.logger.fatal! \"\\e[31m#{line}\\e[0m\"\n end \n end", "def link_backtrace_line( line )\n\t\treturn line.strip.sub( /(?<filename>[^:]*\\.rb):(?<line>\\d*)(?<rest>.*)/ ) do\n\t\t\tmatch = $~\n\t\t\tfullpath = File.expand_path( match[:filename] )\n\t\t\t%|<a href=\"txmt://open?url=file://%s&amp;line=%s\">%s:%s</a>%s| %\n\t\t\t\t[ fullpath, match[:line], match[:filename], match[:line], h(match[:rest]) ]\n\t\tend\n\tend", "def show_backtraces=(_arg0); end", "def shush_backtraces\n Kernel.module_eval do\n old_raise = Kernel.method(:raise)\n remove_method :raise\n define_method :raise do |*args|\n begin\n old_raise.call(*args)\n ensure\n if $!\n lib = File.expand_path(\"..\", __FILE__)\n $!.backtrace.reject! { |line| line.start_with?(lib) }\n end\n end\n end\n end\n end", "def backtrace_ignores=(_arg0); end", "def format_backtrace(backtrace)\n safe_join(backtrace.to_a, tag.br)\n end", "def __caller_source_line__(caller_depth=0, source_line_count=nil, source_file=nil, source_line_number=nil)\n source_line_number ||= __caller_line_number__(caller_depth+1)\n source_file ||= __caller_file__(caller_depth+1)\n source_line = ''\n if defined?(Pry) && source_file.include?('(pry)')\n @pry_instance ||= Pry.new\n source_line = Pry::Command::Hist.new(pry_instance: @pry_instance).call.instance_variable_get(:@buffer).split(\"\\n\")[source_line_number - 1] # TODO handle multi-lines in source_line_count\n elsif defined?(IRB) && TOPLEVEL_BINDING.receiver.respond_to?(:conf)\n source_line = TOPLEVEL_BINDING.receiver.conf.io.line(source_line_number) # TODO handle multi-lines in source_line_count\n else\n source_line = PutsDebuggerer::SourceFile.new(source_file).source(source_line_count, source_line_number)\n end\n source_line\n end", "def shorten_paths_in_backtrace(backtrace)\n return backtrace unless backtrace.is_a?(Array)\n return backtrace.compact.map { |trace|\n shorten_paths(trace)\n }\n end", "def render_backtrace(exception)\n return unless Rails.application.config.consider_all_requests_local\n backtrace = Rails.backtrace_cleaner.filter(exception.backtrace).first(10)\n backtrace << '...'\n backtrace.join(\"\\n\")\n end", "def filter(str)\n str = str.gsub(/^line.*trimming empty.*\\n/, '') # the messages about empty are overzealous, and not invalid\n str = str.gsub(/^line.*proprietary.*\\n/, '') if options[:ignore_proprietary] # if you use IE only attributes like wrap, or spellcheck or things not in standard\n str = str.gsub(/^line.*(?:Error|Warning):.*<\\/?(?:#{options[:ignored_tag_errors].join('|')})>.*\\n/, '') if options[:ignored_tag_errors] && options[:ignored_tag_errors].any?\n str = str.gsub(/^line.*(?:Error|Warning):.* attribute \\\"(?:#{options[:ignored_attribute_errors].join('|')})\\\".*\\n/, '') if options[:ignored_attribute_errors] && options[:ignored_attribute_errors].any?\n if options[:ignored_errors] && options[:ignored_errors].any? && str.gsub(/^line.*(?:Error|Warning):/, '') =~ ignored_errors_regex\n str = str.gsub(Regexp.new(/^line.*(?:Error|Warning):/.source + '.*' + ignored_errors_regex.source + '.*' + /\\n/.source), '')\n end\n str.gsub(/line [0-9]+ column [0-9]+ -/, '')\n # /line [0-9]+ column [0-9]+ - / + =~ \"line 1 column 1 - Warning: missing <!DOCTYPE> declaration\"\n end", "def handle_everything(user_code, in_trace)\n exe_Point_Finder(in_trace)\n @event_manager.modify_lines(user_code)\n raw_events = @event_manager.trace_list\n filtered_out_events = FilteredTraces.new([raw_events, user_code])\n filtered_out_events.return_json_string\n end", "def irrelevant_line(source_line); end", "def possibly_add_trace_info_calls(line)\n # If the current line does not start a logical line, don't bother\n if not @state[:ll_start]\n return line\n end\n\n # We will be making decisions based on the first word on the line\n line_words = line.split\n if line_words.empty?\n # The line is empty, so we disregard it\n return line\n end\n first_word = line_words[0]\n\n # Extract first word and check if it makes us want to refrain from adding a line number call\n if KEYWORDS_WITHOUT_LINE_NUMBERS.include?(first_word)\n # It's one of the statements we don't want\n return line\n\n elsif [\"'\", '\"', \"#\"].include?(first_word[0])\n # The line starts with a string or with a comment\n return line\n end\n\n # Do include a line number call\n return \"#{@state[:indent_string]}garbledwebpiratenlibraryname.debug(locals(), globals())\\n\" +\n \"#{@state[:indent_string]}garbledwebpiratenlibraryname.line(#{@state[:line_number]})\\n\" +\n \"#{line}\"\n end", "def build_trace\n if with_bt_set?\n Backtrace.to_s(@with_bt + [first_filtered_bt_line(backtrace)])\n else\n src_line\n end\n end", "def shush_backtraces\n Kernel.module_eval do\n old_raise = Kernel.method(:raise)\n remove_method :raise\n if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3.2.0')\n define_method :raise do |*args, **kwargs|\n begin\n old_raise.call(*args, **kwargs)\n ensure\n if $!\n lib = File.expand_path(\"..\", __FILE__)\n $!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?\n end\n end\n end\n else\n define_method :raise do |*args|\n begin\n old_raise.call(*args)\n ensure\n if $!\n lib = File.expand_path(\"..\", __FILE__)\n $!.backtrace.reject! { |line| line.start_with?(lib) } unless $!.backtrace.frozen?\n end\n end\n end\n end\n private :raise\n end\n end", "def backtrace_level=(_arg0); end", "def format_backtrace( notification )\n\t\tlines = notification.formatted_backtrace\n\t\treturn lines.map do |line|\n\t\t\tlink_backtrace_line( line )\n\t\tend\n\tend", "def skip_backtrace=(_arg0); end", "def __caller_file__(caller_depth=0)\n regex = RUBY_ENGINE == 'opal' ? PutsDebuggerer::STACK_TRACE_CALL_SOURCE_FILE_REGEX_OPAL : PutsDebuggerer::STACK_TRACE_CALL_SOURCE_FILE_REGEX\n caller[caller_depth] && caller[caller_depth][regex, 1]\n end", "def full_backtrace=(_arg0); end", "def merge_backtrace(sender_trace, provider_trace)\n return nil if provider_trace.nil?\n return provider_trace if sender_trace.nil?\n\n # Find the first live resource stack trace\n index = provider_trace.index do |t|\n t =~ /lib\\/live_resource\\/method_provider/\n end\n\n # Slice off everything starting at that index\n result = provider_trace[0 .. (index - 1)]\n\n # Add a trace that indicates that live resource was used\n # to link the sender to the provider.\n result << 'via LiveResource'\n\n # For the sender trace, remove the 'method_sendor'\n # part of the trace.\n index = sender_trace.index do |t| \n t =~ /lib\\/live_resource\\/method_sender/\n end\n result += sender_trace[(index + 1) .. (sender_trace.length - 1)]\n\n result\n end", "def exception_backtrace(current_exception)\n if current_exception.backtrace.respond_to?(:map)\n return current_exception.backtrace\n end\n return [] unless configuration.populate_empty_backtraces\n\n caller_backtrace = caller\n caller_backtrace.shift while caller_backtrace[0].include?(rollbar_lib_gem_dir)\n caller_backtrace\n end", "def ignore(path=nil, &block)\n if path.is_a? Regexp\n @ignored_callbacks << Proc.new {|p| p =~ path }\n elsif path.is_a? String\n path_clean = normalize_path(path)\n if path_clean.include?(\"*\") # It's a glob\n @ignored_callbacks << Proc.new {|p| File.fnmatch(path_clean, p) }\n else\n @ignored_callbacks << Proc.new {|p| p == path_clean }\n end\n elsif block_given?\n @ignored_callbacks << block\n end\n end", "def backtrace(exception)\n message = \"<br/>\" + sanitize(exception.message) + \"<br/>\"\n message += exception.backtrace.collect { |line|\n sanitize(line)\n }.join(\"<br/>\")\n return message\n end", "def uncovered_relevant_lines\n lineno = 0\n File.open(@filename, \"rb\").each_line do |line|\n if @coverage[lineno] == Bashcov::Line::IGNORED && revelant?(line)\n yield lineno\n end\n lineno += 1\n end\n end", "def notify_line(lineno, count, text)\n unless @path_notified\n Concov.error(\"path of original source code is not found\") \n end\n\n @blk.call(:line, lineno, count, text)\n end", "def normalize_message(message)\n remove_line_number(normalize_caller(normalize_callstack_path(message)))\n end", "def seperate_and_filter_trace(junit_test_file,\n files_path,\n peruser_files_path,\n student_file_name)\n code_and_trace = generate_backend_trace(junit_test_file,\n files_path,\n peruser_files_path,\n student_file_name)\n splitter = '\"' + 'trace' + '\"' + ':'\n user_code, whole_trace = code_and_trace.split(splitter)\n\n whole_trace = whole_trace[1..whole_trace.length]\n\n entire_json_file = code_analyzer(user_code, whole_trace)\n\n entire_json_file\nend", "def line\n backtrace.first.split(\":\")[1]\n end", "def backtrace(exception)\n return unless Gem.configuration.backtrace\n\n @errs.puts \"\\t#{exception.backtrace.join \"\\n\\t\"}\"\n end", "def set_backtrace(*) end", "def assert_matching_line(ex, file, options)\n line = options[:line]\n search_all = options[:deep]\n if line\n loc_re = /#{Regexp.quote(file)}:#{line}/\n else\n loc_re = Regexp.compile(Regexp.quote(file))\n end\n\n\n if search_all\n bts = ex.backtrace.join(\"\\n\")\n assert_with_block(\"expected a backtrace line to match #{loc_re}\\nBACKTRACE:\\n#{bts}\") {\n ex.backtrace.any? { |bt| loc_re =~ bt }\n }\n else\n assert_match(loc_re, ex.backtrace.first, \"BACKTRACE:\\n #{ex.backtrace.join(\"\\n \")}\")\n end\n\n ex\n end", "def backtrace\n @process_error.h['trace'].split(/\\n/)\n end", "def cleaned_call_stack(call_stack)\n defined?(::Rails) && ::Rails.respond_to?(:backtrace_cleaner) ?\n ::Rails.backtrace_cleaner.clean(call_stack, :silent) :\n call_stack\n end", "def backtrace_message\n backtrace = exception.backtrace ? clean_backtrace(exception) : nil\n\n return unless backtrace\n\n text = []\n\n text << '```'\n backtrace.first(3).each { |line| text << \"* #{line}\" }\n text << '```'\n\n text.join(\"\\n\")\n end", "def skip_backtrace; end", "def __caller_line_number__(caller_depth=0)\n return if RUBY_ENGINE == 'opal'\n caller[caller_depth] && caller[caller_depth][PutsDebuggerer::STACK_TRACE_CALL_LINE_NUMBER_REGEX, 1].to_i\n end", "def backtrace\n wrapper.application_trace\n end", "def append_backtrace(node, duration)\n if duration*1000 >= Agent.config[:'nbs.action_tracer.stack_trace_threshold']\n trace = caller.reject! { |t| t.include?('tingyun_rpm') }\n # freeze here will reduce used memory\n trace = trace.first(20).map!(&:freeze)\n node[:stacktrace] = trace\n end\n end", "def line_number\n return unless backtrace and backtrace[0]\n\n backtrace[0].split(\":\")[1].to_i\n end", "def parse_thread_stacktrace(lines, thread_id, is_crashed_thread)\n # remove the 1st line\n lines.pop\n\n stacktrace = []\n process_matching_lines(lines, BACKTRACE_LINE_REGEX) do |match|\n stacktrace << parse_crashed_thread_stacktrace_line(match, is_crashed_thread)\n end\n\n # sentry wants their stacktrace with the oldest frame first\n stacktrace = stacktrace.reverse\n\n if is_crashed_thread\n @crashed_thread_stacktrace = stacktrace\n @extra[:crashed_thread_id] = thread_id\n else\n @other_threads_stacktraces[thread_id] = stacktrace\n end\n end", "def backtrace_silencer(silencers = nil)\n if silencers\n @backtrace_silencers = silencers.map do |silencer| \n case silencer\n when Regexp\n silencer\n when String\n /#{silencer}/i\n else\n nil\n end\n end.compact\n end\n @backtrace_silencers\n end", "def full_backtrace; end", "def report_backtrace\n metadata = {\n 'sourcetype' => 'chef-handler-backtrace',\n 'source' => 'chef-handler',\n 'host' => node.hostname,\n 'index' => @index,\n 'check-index' => false\n }\n event = Array(run_status.backtrace).join(\"\\n\")\n\n splunk_post(event, metadata)\n end", "def backtrace\n if original.nil?\n super\n else\n original.backtrace\n end\n end", "def dump_caller_stack\n return unless $ITEST2_TRACE_EXECUTION\n begin\n caller.each_with_index do |position, idx|\n next unless position =~ /\\A(.*?):(\\d+)/\n file = $1\n # TODO: send multiple trace to be parse with pages.rb\n # next if file =~ /example\\/example_methods\\.rb$/ or file =~ /example\\/example_group_methods\\.rb$/ or file =~ /driver\\.rb$/ or file =~ /timeout\\.rb$/ # don't include rspec or ruby trace\n\n if file.include?(\"_spec.rb\") || file.include?(\"_test.rb\") || file.include?(\"_cmd.rb\")\n connect_to_itest(\" TRACE\", position)\n end\n\n break if idx > 4 or file =~ /\"_spec\\.rb$/\n end\n rescue => e\n puts \"failed to capture log: #{e}\"\n end\n end", "def backtrace\n end", "def stacktrace(ex)\n ex.backtrace.select do |t| \n (t =~ /gem/) == nil && (t =~ /rvm/) == nil\n end.join('\\n')\n end", "def backtrace\n Spec::deprecate(\"ExampleGroupProxy#backtrace\",\"ExampleGroupProxy#location\")\n @backtrace\n end", "def import_call_site(backtrace)\n frame = backtrace.detect {|f| f !~ /in `Rns'$/ }\n file, line = frame.split(':', 2)\n [file, line.to_i]\n end", "def backtrace_level; end", "def backtrace\n @backtrace or $DEBUG\n end", "def error_call_site(error)\n error.backtrace.first.gsub(project_root, '.')\n end", "def raw_backtrace\n error.backtrace\n end", "def extract_line_number(backtrace)\n return unless backtrace\n backtrace = backtrace.to_a\n return unless backtrace.length > 1\n m = backtrace.first.match(/^.+:(\\d+):/)\n return unless m and m.length > 1\n m[1]\n end", "def FilterExpr(path, parsed); end", "def backtrace; end", "def debugs(str)\n #Get backtrace.\n backtrace_str = caller[0]\n backtrace_match = backtrace_str.match(/^(.+):(\\d+):in /)\n self.log_puts(\"#{File.basename(backtrace_match[1])}:#{backtrace_match[2]}: #{str}\")\n end", "def initialize(\n only_project_code: true,\n shrink_bundle_path: true,\n backtrace_ignore_paths: [],\n highlighted_line_range: 3,\n highlighted_line_styles: :cyan,\n backtrace_styles: :light_red,\n error_file_path_styles: :red,\n status_code_styles: {},\n severity_styles: {},\n occurence_line: :light_blue\n )\n @only_project_code = only_project_code\n @shrink_bundle_path = shrink_bundle_path\n @ignore_paths = backtrace_ignore_paths.map do |path|\n Regexp.new \"#{Rails.root}/#{path}\"\n end << Regexp.new(bundle_path)\n @allow_path = Regexp.new bundle_install_path\n @backtrace_ignore_paths = backtrace_ignore_paths\n @highlighted_line_range = highlighted_line_range\n @highlighted_line_styles = highlighted_line_styles\n @backtrace_styles = backtrace_styles\n @error_file_path_styles = error_file_path_styles\n @status_code_styles = DEFAULT_STATUS_CODE_STYLES.merge(status_code_styles).with_indifferent_access\n @severity_styles = DEFAULT_SEVERITY_STYLES.merge(severity_styles).with_indifferent_access\n @occurence_line = occurence_line\n end", "def blame(file, line)\n #commit, author, line_no,\n output = `git blame --date=short -w -L #{line} #{file}`\n match = BLAME_REGEXP.match(output)\n if $?.success? && match && (match[3].to_i == line)\n return [ match[1].strip, match[2].strip ]\n else\n raise ProviderError, output\n end\n end", "def backtrace\n @backtrace\n end" ]
[ "0.7130077", "0.7130077", "0.7024147", "0.69362855", "0.68944085", "0.6633929", "0.65367573", "0.6326931", "0.632211", "0.6288927", "0.61718094", "0.6166607", "0.6138041", "0.6028372", "0.57720876", "0.5744469", "0.5744032", "0.5703542", "0.55516654", "0.55077255", "0.5500343", "0.5498413", "0.5455673", "0.5437679", "0.5437679", "0.5419748", "0.54128003", "0.53779244", "0.53714556", "0.535207", "0.5326428", "0.5296889", "0.5287037", "0.52701944", "0.514258", "0.5052342", "0.50406486", "0.5012597", "0.49884102", "0.49832186", "0.49614418", "0.49505728", "0.49426302", "0.49306163", "0.4928004", "0.49277624", "0.49005046", "0.4883641", "0.4875705", "0.4870303", "0.48651296", "0.48618773", "0.48538557", "0.48488736", "0.4830492", "0.48295113", "0.4828709", "0.4825079", "0.48019516", "0.4773103", "0.47700056", "0.47405875", "0.47342026", "0.47261253", "0.46730056", "0.46663827", "0.46646023", "0.4656064", "0.4653221", "0.46451434", "0.46339464", "0.46310654", "0.46038094", "0.45696992", "0.4568627", "0.45502025", "0.4546935", "0.45326775", "0.4521252", "0.45186067", "0.45060465", "0.4502346", "0.44974735", "0.44844285", "0.44815525", "0.44736043", "0.44665122", "0.44638786", "0.4462846", "0.4461887", "0.444923", "0.4447782", "0.4444123", "0.44436303", "0.44354478", "0.4411597", "0.4404969", "0.43847856", "0.43789056", "0.43788597" ]
0.7388833
0
Internal: Clears the global context
def clear! Thread.current[:__honeybadger_context] = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_context\n @current_context = nil\n end", "def clear_current\n all_contexts.delete(Thread.current.object_id)\n end", "def clear!\n contexts.clear\n end", "def clear!\n contexts.clear\n end", "def clear!\n context_manager.clear!\n end", "def reset_context\n @context = nil\n end", "def reset\n @context = nil\n end", "def clear(context = nil)\n with_scope(context) { current_base.clear }\n end", "def clear(context = nil)\n with_scope(context) { current_base.clear }\n end", "def reset\n @global = Global.new\n end", "def clear_view_context!\n @view_context = nil\n end", "def clear\n \n @hook_contexts.clear if @hook_contexts\n @execution_contexts.clear if @execution_contexts\n @cascade_contexts.clear if @cascade_contexts\n \n self\n \n end", "def clear\n context.clear if Thread.current[NAME]\n self\n end", "def clear\n context.clear if Thread.current[NAME]\n self\n end", "def reset!\n @context = [context[0]]\n end", "def clear!\n context_manager.clear!\n breadcrumbs.clear!\n end", "def reset_ctx(ctx)\n each_value {|x| x.reset_ctx(ctx) }\n end", "def remove_all_contexts\n previous_size = @contexts.size\n @contexts = []\n previous_size\n end", "def clear!\n @handlers = {}\n @environments = {}\n @requests = []\n end", "def clear!\n Thread.current[LOCAL_KEY] = nil\n end", "def reset\n @window_size = options.window_size\n contexts.reset\n end", "def clear_env\n DataCache.env_hash = {}\n end", "def reset\n @exemptions = ExemptionList.from_module(CoreExemptions)\n @global = false\n @trusted_filters = []\n end", "def clear\n namespace + '_clear'\n end", "def reset_define_context(context=nil)\n ret = @define_context\n @define_context = HashStruct.new(context || {})\n return ret\n end", "def reset\n self.configuration = ({})\n config_contexts.values.each(&:reset)\n end", "def flush_context_stack\n while (context != TopContext)\n pop_context\n end\n end", "def reset\n @instance = nil\n @local_env = nil\n end", "def reset\n @instance = nil\n @local_env = nil\n end", "def clear_current_cache\n\t\t\t\t\tself.class.clear_current_cache\n\t\t\t\tend", "def clear_all\n clear_temporary\n clear_objects\n Window.clear\n end", "def clear!\n Padrino.clear_middleware!\n Padrino.mounted_apps.clear\n @_load_paths = nil\n @_dependency_paths = nil\n @_global_configuration = nil\n Padrino.before_load.clear\n Padrino.after_load.clear\n Padrino::Reloader.clear!\n Thread.current[:padrino_loaded] = nil\n end", "def clear() end", "def clear() end", "def clear_global_appdata(*keys)\r\n @context.call_myspace_api(:appdata_global_delete, :keys => keys.join(';'))\r\n end", "def reset\n @source_buffer = nil\n\n @lexer.reset\n @static_env.reset\n @context.reset\n @current_arg_stack.reset\n @pattern_variables.reset\n @pattern_hash_keys.reset\n\n self\n end", "def clear!; end", "def clear!; end", "def clear!; end", "def clear_request_data\n Thread.current[THREAD_LOCAL_NAME] = nil\n end", "def clear\n @root = nil\n end", "def clear\n @entity_list = {}\n @context_list = {}\n @last_unique_id = 0\n @entity_names = {} # Internal cache of context names for quick key retrieval\n end", "def clear_scoping\n selector.clear\n options.clear\n end", "def clear\n system 'clear'\n \n end", "def clear_without_hooks\n\n @without_hooks = true\n\n clear\n \n @without_hooks = false\n \n return self\n \n end", "def clear\n end", "def clear\n end", "def clear_current_user\n User.current_user = nil\n end", "def reset\n @caller_context_padding = 2\n @has_at_exit_report = true\n @alert_frequency = 1\n end", "def clear; end", "def clear; end", "def clear; end", "def clear; end", "def clear; end", "def clear; end", "def clear; end", "def clear_cache\n @all = nil\n end", "def reset!\n default_tags.clear\n adapters.clear\n groups.each_key { |group| singleton_class.send(:remove_method, group) if group && respond_to?(group) }\n @groups = nil\n metrics.each_key { |metric| singleton_class.send(:remove_method, metric) if respond_to?(metric) }\n @metrics = nil\n collectors.clear\n configurators.clear\n instance_variable_set(:@configured_by, nil)\n instance_variable_set(:@debug_was_enabled_by, nil)\n end", "def clear\n\t\tif @active\n\t\t\t@active.cleanup\n\t\t\t@active = nil\n\t\tend\n\tend", "def reset\n cleanup(true)\n end", "def clear!\n end", "def reset!\n @apps = {}\n @default_params = {}\n @basic_auth = nil\n end", "def clear_current!\n @master_state.current_listener_pid = nil\n end", "def reset_all\n clear_commands\n reset_colors\n @app_info = nil\n @app_exe = nil\n @verbose_parameters = true\n @@default_method = nil\n @@class_cache = {}\n end", "def clear\n system 'clear'\n end", "def clear\n system 'clear'\n end", "def reset_ctx(ctx)\n ctx = Array(ctx || MXNet::Context.current)\n if @_data\n data = _reduce()\n Autograd.pause do\n _init_impl(data, ctx)\n end\n elsif @_deferred_init\n @_deferred_init[1] = ctx\n else\n raise ArgumentError,\n \"Cannot reset context for Parameter '#{@name}' because it \" +\n \"has not been initialized.\"\n end\n end", "def clear\r\n system('clear')\r\n end", "def clear\n ve 'rm(list=ls())'\n end", "def clear\n end", "def clear\n end", "def clear\n end", "def clear(context: Context.current)\n context.set_value(CORRELATION_CONTEXT_KEY, EMPTY_CORRELATION_CONTEXT)\n end", "def reset!\n sync do\n @global_id = 0\n @channels = {}\n end\n end", "def clear_current_user; end", "def reset_global_classes\n SheetNames.instance.clear\n SharedStrings.instance.clear\n end", "def clear\n do_clear\n end", "def clear\n end", "def unset_span_context\n OpenCensus::Context.unset SPAN_CONTEXT_KEY\n end", "def clear_screen\n CLEAR_SCREEN\n end", "def clear()\n merge(clear: 'true')\n end", "def clear!\n defined_settings.each {|setting| instance_variable_set(\"@#{setting}\", nil)}\n @storage_adapters = []\n @cached_paths = {}\n end", "def ti_clear\n\ttictl(\"clear\")\n end", "def clear_all\n clear_modules\n end", "def clear_all\n clear\n clear_stored_requests\n end", "def clear\n self.request = nil\n end", "def clear_options(contexts = nil)\n Config::Options.clear(contexts)\n end", "def clear\n return\n end", "def reset!\n Thread.current[THREAD_KEY] = {}\n end", "def clear\n LOCK.synchronize do\n @hooks = nil\n @applied = nil\n @logger = nil\n end\n end", "def reset()\n end", "def clean\n Thread.current[:__cms_original_content] = nil\n Thread.current[:__cms_active_page] = nil\n Thread.current[:__cms_stack] = nil\n Thread.current[:__content_node_stack] = nil\n Thread.current[:__content_iterator_stack] = nil\n Thread.current[:__content_iterator_stack_key] = nil\n end", "def reset()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def switch_to_default_context\n set_context nil\n end", "def switch_to_default_context\n set_context nil\n end", "def clear\n instance_variables.each do |instance_variable|\n instance_variable_set(instance_variable, nil)\n end\n end", "def reset() end", "def destroy_previous_contexts\n return unless $js\n\n runtime = $js.instance_variable_get :@runtime\n uuid = $js.instance_variable_get :@uuid\n runtime.vm.delete_context(uuid)\n end", "def clear_all!\n @commands_and_opts.clear\n self\n end", "def clear_request\n @url = nil\n @options = nil\n end" ]
[ "0.8546618", "0.81780964", "0.8075689", "0.8075689", "0.7952407", "0.78832823", "0.777144", "0.7615259", "0.7615259", "0.74167573", "0.74140745", "0.7372963", "0.7230976", "0.7230976", "0.7019988", "0.70135087", "0.69684714", "0.69677633", "0.6827737", "0.6783115", "0.6716638", "0.66924006", "0.6666552", "0.66589963", "0.6644274", "0.6590427", "0.6566706", "0.65659505", "0.65659505", "0.65405875", "0.65105593", "0.6458452", "0.6445624", "0.6445624", "0.6444942", "0.6428118", "0.64221114", "0.64221114", "0.64221114", "0.6411667", "0.63960767", "0.6383271", "0.63823986", "0.6381809", "0.6371559", "0.6370147", "0.6370147", "0.63345754", "0.6326156", "0.6325618", "0.6325618", "0.6325618", "0.6325618", "0.6325618", "0.6325618", "0.6325618", "0.63170743", "0.6316483", "0.6316096", "0.6299351", "0.6293247", "0.6281998", "0.62811226", "0.627926", "0.6263293", "0.6263293", "0.62563616", "0.62453336", "0.6244039", "0.62432045", "0.62432045", "0.62432045", "0.6242781", "0.6242324", "0.62212133", "0.62112623", "0.62072575", "0.620463", "0.61939335", "0.61892456", "0.6188326", "0.61851513", "0.61849725", "0.61792976", "0.61754674", "0.6168307", "0.6163003", "0.6160873", "0.6156174", "0.61554193", "0.6152465", "0.6136692", "0.6133072", "0.61304796", "0.61304796", "0.6127242", "0.6124504", "0.61150724", "0.6105979", "0.6086559" ]
0.70591193
14
Initialize the engine instance
def initialize(fact_class) @fact_class = fact_class end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(engine = default_engine)\n @engine = engine\n end", "def start_engine\n @engine.start_engine\n end", "def initialize_engine\n require_template_library 'eco'\n end", "def initialize(engine, interactive = true)\n @engine = engine\n @interactive = interactive\n end", "def initialize engine,tires\n\t\t@engine = engine\t#instance variables\n\t\t@tires = tires\n\tend", "def initialize\n init\n end", "def initialize_engine\n require_template_library 'opal'\n end", "def init\n end", "def init\n end", "def init\n end", "def initialize(config, engine_name)\n @config = config\n @engine_name = engine_name\n end", "def initialize_engine\n super unless self.class.superclass.engine_initialized?\n \n if Less.add_less_functions\n require 'sprockets/less/functions'\n end\n end", "def initialize_environment\n end", "def initialize_environment\n end", "def initialize(engine)\n super()\n @engine = engine\n @node_class = engine.relation_node_class\n @edge_class = engine.relation_edge_class\n @connectors = {}\n end", "def Init()\n end", "def initialize\n initialize!\n end", "def initialize\n initialize!\n end", "def init\n\n end", "def init; end", "def init; end", "def init; end", "def init; end", "def initialize()\n end", "def initialize_engine\n require_template_library 'ejs'\n end", "def initialize(options = {})\n options = default_options.merge(options)\n require_keys!(options, [:engine_path, :movetime])\n @movetime = options[:movetime]\n\n set_debug(options)\n reset_board!\n set_startpos!\n\n check_engine(options)\n set_engine_name(options)\n open_engine_connection(options[:engine_path])\n set_engine_options(options[:options]) if !options[:options].nil?\n new_game!\n end", "def initialize *engines\n raise \"Incompatible engine\" unless engines.all? do |e|\n EngineInterface === e\n end\n \n (@engines = engines) # .tap { |x| puts \"ENGINES: #{x.inspect}\" }\n end", "def initialize()\n begin\n puts \"Eis::Runner::init called\" if $DEBUG\n @loaded_modules = []\n generate_module_list()\n handle = InputHandler.new()\n set_environment()\n rescue ArgumentError =>e\n puts \"\\e[31mERROR\\e[0m: No config file given...\" + e\n puts \"--------------------------------------------\"\n raise\n end\n end", "def initialize_engine\n require_template_library 'haml_coffee_assets/compiler'\n end", "def engine; end", "def initialize(user, context)\n return unless context.respond_to?(:state_name)\n debug \"Initialize engine ...\"\n start_time = Time.now\n @user = user\n @context = context\n @conditions = parse_conditions\n @rule_set = RuleSet.new(@user, @context, @conditions)\n @rule_set.parse_dsl\n @rules = @rule_set.rules\n debug \"Done in #{ Time.now - start_time } s.\"\n @total_evaluation_time = 0\n end", "def pre_run_initialize\n @evaluator = @evaluator_class.new(self) if @evaluator.nil?\n @evolver = @evolver_class.new(self) if @evolver.nil?\n end", "def initialize\n end", "def initialize\n # Create temporary data directory\n create_data_dir\n\n # Init connection to ADS\n init_ads\n\n # Initialize Data science toolkit\n init_dstk\n\n # Init connection to SQLite\n # init_sqlite3\n end", "def initialize() end", "def initialize_engine\n require_template_library 'haml_coffee'\n end", "def init(default = :retro)\n begin\n require 'redcloth'\n self.supported_engines['textile'] = TextileEngine.new\n require 'wiki_engine/retro'\n self.supported_engines['retro'] = RetroEngine.new\n rescue LoadError; end\n \n begin\n require 'bluecloth'\n self.supported_engines['markdown'] = MarkDownEngine.new\n rescue LoadError; end\n \n begin\n require 'rdoc/markup/simple_markup'\n require 'rdoc/markup/simple_markup/to_html'\n require 'wiki_engine/rdoc'\n self.supported_engines['rdoc'] = RDocEngine.new\n rescue LoadError; end\n \n self.default_engine = default\n end", "def engine\n @engine ||= find_engine\n end", "def initialize_engine\n\t\t\t\tsuper unless self.class.superclass.engine_initialized?\n\n\t\t\t\tif Sassc.add_sass_functions != false\n\t\t\t\t\t# begin\n\t\t\t\t\t# \trequire 'sprockets/helpers'\n\t\t\t\t\t\trequire 'sprockets/sassc/functions'\n\t\t\t\t\t# rescue LoadError; end\n\t\t\t\tend\n\n\t\t\t\tself.class.sass_functions_initialized = true\n\t\t\tend", "def initialize()\n\t\tend", "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 init!\n @logger = @config = @database_config = nil\n\n load_application_config\n load_database_config\n note \"Loading #{env} environment (#{Ajaila::VERSION})\"\n load_classes\n note \"Establishing database connection\"\n establish_database_connection\n note \"Running auto-upgrade migrations\"\n run_auto_upgrade_migrations\n note \"Application has been initialized\"\n self\n end", "def after_initialize_with_engine_additions\r\n Engines.after_initialize\r\n after_initialize_without_engine_additions\r\n end", "def initialize(context = nil, engine = nil)\n @context = context\n @engine = engine || Pigeon::Engine.default_engine\n @created_at = Time.now\n @state = nil\n\n unless (@engine)\n raise EngineRequired, \"Task creation requires an active Pigeon::Engine\"\n end\n \n after_initialized\n end", "def init\n raise NotImplementedError\n end", "def initialize\r\n\r\n end", "def initialize\n self.context = Context.new\n end", "def initialize()\r\n\r\n end", "def initialize\n \n end", "def init; end", "def initialize\n\t\t\tplugins.init(self)\n\t\tend", "def set_engine\n @engine = Engine.find(params[:id])\n end", "def set_engine\n @engine = Engine.find(params[:id])\n end", "def engine\n loader_instance.engine\n end", "def set_engine\n @engine = ::EngineMaster.find(params[:id])\n end", "def initialize\n\t\t@t = 0.0\n\n\t\t# bind callback to OSX Trackpad multitouch events\n\t\tTrackpad.clear()\n\t\tTrackpad.connect()\n\t\tTrackpad.bind( lambda{ |i,f| \n\t\t\tif i == 1\n\t\t\telsif i == 2\n\t\t\tend\n\t\t})\n\n\t\tMouse.clear()\n\t\tMouse.use()\n\n\t\tparser = EisenScriptParser.apply(tree())\n\t\t@model = Model.new()\n\t\t@model.material(BasicMaterial.new())\n\t\t@model.material.color.set(0,1,0,1)\n\t\tparser.buildModel(@model)\n\n\t\tMain.setModel(@model)\n\t\t# Main.model.pose.pos.set(-50,0,0)\n\n\tend", "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 set_config\n end", "def initialize\n\n\n\n end", "def initialize(*args)\n super\n mon_initialize\n end", "def initialize\n engine_uri = URI(ENV.fetch 'ENGINE_URL')\n @conn = Rserve::Simpler.new hostname: engine_uri.host\n end", "def initialize\n\t\t\n\tend", "def initialize()\n #@ch = Concept.init_concept_hash()\n #Indexer.initialize_dict()\n #@ch = Indexer.init_concept_hash\n end", "def initialize(dir)\n @root = dir\n raise \"Cannot find an engine in either #{dir}!\" if !File.exist?(@root)\n @name = File.basename(@root)\n @info = '(none)'\n end", "def initialize\n\n\tend", "def initialize\n\n\tend", "def init\n\nend", "def initialize(label)\n\n # pass a new engine with name :knowledge_base_engine to the super class\n super KnowledgeBase::engine label\n\n # instantiate variables\n @engine_has_matched = false\n @yml_locations = nil\n\n @question_rules = Array.new\n @result_rules = Array.new\n @fact_rules = Array.new\n @triggered_rules = Array.new\n @start_rules = Array.new\n @rules = {}\n\n end", "def start\n\t\tinit\n\t end", "def initialize(options = {})\n combined_options = DEFAULT_ENGINE_OPTIONS.merge(options)\n \n @engine = Jri::JRIEngine.new(combined_options[:r_arguments].to_java(:string),\n combined_options[:callback_object],\n combined_options[:run_repl])\n\n @eval_expression_listeners = []\n \n # the R thread wont die unless we call #close on @engine, so make sure this\n # happens when this object is finalized.\n ObjectSpace.define_finalizer(self, self.class.finalize(@engine))\n end", "def at_init\n\n\t\tend", "def initialize # :notnew:\n evaluate PRELUDE, PRELUDE_PATH, 1\n global.Johnson.runtime = self\n global['Ruby'] = Object\n evaluate CORE, CORE_PATH, 1\n end", "def initialize(config)\n setup(config)\n log 'New World Instance initialized!'\n end", "def initialize (service_name, application_context)\n\n super()\n\n service_init service_name, application_context\n\n @paused_instances = {}\n\n @observers = {}\n\n @stopped = false\n\n engine_environment_id\n # makes sure it's called now\n end", "def initialize\n # kosong\n end", "def initialize(...)\n super()\n configure(...)\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 end", "def initialize\n \n end", "def initialize()\n\tend", "def initialize()\n\tend" ]
[ "0.79950374", "0.7389908", "0.7230665", "0.7178654", "0.71286577", "0.7058527", "0.70458996", "0.6987274", "0.6987274", "0.6987274", "0.69570947", "0.69389486", "0.6865608", "0.6865608", "0.6814687", "0.6790047", "0.6739879", "0.6739879", "0.673828", "0.6730506", "0.6730506", "0.6730506", "0.6730506", "0.66691315", "0.6660023", "0.6639125", "0.66355985", "0.6626333", "0.66148967", "0.6590887", "0.6587098", "0.6562242", "0.65370566", "0.6530432", "0.6525551", "0.64929986", "0.64472795", "0.64440805", "0.64434165", "0.6437312", "0.6435606", "0.6435606", "0.6435606", "0.6435606", "0.6435606", "0.6435606", "0.642627", "0.64236045", "0.64084667", "0.63868654", "0.6370488", "0.63693273", "0.6362652", "0.6345422", "0.6344752", "0.633134", "0.6315243", "0.6315243", "0.6300101", "0.6297657", "0.6293036", "0.6269598", "0.6269598", "0.6269598", "0.6269598", "0.6269598", "0.6269598", "0.6269598", "0.6269598", "0.626931", "0.6257161", "0.62559444", "0.62468916", "0.624541", "0.62444454", "0.6219294", "0.6217003", "0.6217003", "0.6216397", "0.62111425", "0.62085253", "0.6193946", "0.6189678", "0.6183388", "0.6178754", "0.6160458", "0.6154664", "0.61522275", "0.6143595", "0.6143595", "0.6143595", "0.6143595", "0.6143595", "0.6143595", "0.6143595", "0.6143595", "0.6143595", "0.6135968", "0.6135968", "0.6133354", "0.6133354" ]
0.0
-1
Populate the prejoined fact table.
def populate(options={}) populate_prejoined_fact_table(options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate_prejoined_fact_table(options={})\r\n fact_columns_string = columns.collect {|c|\r\n \"#{table_name}.\" + c.name unless excluded_foreign_key_names.include?(c.name)\r\n }.compact.join(\",\\n\") \r\n \r\n prejoined_columns = []\r\n \r\n tables_and_joins = \"#{table_name}\"\r\n \r\n prejoined_fields.each_pair do |key, value|\r\n dimension = dimension_class(key)\r\n tables_and_joins += \"\\nJOIN #{dimension.table_name} as #{key}\"\r\n tables_and_joins += \"\\n ON #{table_name}.#{dimension_relationships[key].foreign_key} = \"\r\n tables_and_joins += \"#{key}.#{dimension.primary_key}\"\r\n prejoined_columns << value.collect {|v| \"#{key}.\" + v.to_s}\r\n end\r\n\r\n if connection.support_select_into_table?\r\n drop_prejoin_fact_table\r\n sql = <<-SQL\r\n SELECT #{fact_columns_string}, \r\n #{prejoined_columns.join(\",\\n\")}\r\n FROM #{tables_and_joins}\r\n SQL\r\n sql = connection.add_select_into_table(prejoined_table_name, sql)\r\n else\r\n create_prejoined_fact_table(options)\r\n sql = <<-SQL\r\n INSERT INTO #{prejoined_table_name}\r\n SELECT #{fact_columns_string}, \r\n #{prejoined_columns.join(\",\\n\")}\r\n FROM #{tables_and_joins}\r\n SQL\r\n end\r\n connection.transaction { connection.execute(sql) } \r\n end", "def create_prejoined_fact_table(options={})\r\n connection.transaction {\r\n drop_prejoin_fact_table\r\n\r\n connection.create_table(prejoined_table_name, :id => false) do |t|\r\n # get all columns except the foreign_key columns for prejoined dimensions\r\n columns.each do |c|\r\n t.column(c.name, c.type) unless excluded_foreign_key_names.include?(c.name)\r\n end\r\n #prejoined_columns\r\n prejoined_fields.each_pair do |key, value|\r\n dclass = dimension_class(key)\r\n dclass.columns.each do |c|\r\n t.column(c.name, c.type) if value.include?(c.name.to_sym) \r\n end\r\n end\r\n end\r\n }\r\n end", "def drop_prejoin_fact_table\r\n connection.drop_table(prejoined_table_name) if connection.tables.include?(prejoined_table_name)\r\n end", "def before_load\n data_class.rebuild_table\n super\n end", "def preload_associations(associations)\n associations.reduce(dup) do |table, association|\n primary_key = association.association_primary_key\n foreign_key = association.foreign_key\n name = association.name.to_s\n\n next table if !table.names.include?(foreign_key)\n\n ids = table[foreign_key].to_a.uniq.compact_blank\n records = association.klass.where(primary_key => ids).index_by(&primary_key.to_sym)\n\n table.rename({ foreign_key => name })\n table[name] = table[name].map { |id| records[id] }\n table\n end\n end", "def seed_other_cost_rows\n OtherCost.delete_all\n OtherCostType.all.each do |t|\n t.other_costs.create if t.other_costs.empty?\n end\nend", "def rebuild(table); end", "def setup_target_table\n self.target_table = source_table if target_table.blank?\n end", "def load\n rows = fire\n columns = rows.shift\n result = []\n rows.map do |el|\n obj = table_name.camelize.singularize.constantize.new\n columns.each_with_index do |column,index|\n obj.instance_variable_set(\"@#{column}\".to_sym, el[index])\n end\n result << obj\n end\n reset\n result\n end", "def preload_conditions_columns\n ActiveRecord::Associations::Preloader.new.preload(conditions, :column)\n end", "def tables_and_joins\n sql = \"#{fact_class.table_name}\"\n cube_class.dimensions_hierarchies.each do |dimension_name, hierarchy_name|\n dimension_table_name = fact_class.dimension_class(dimension_name).table_name\n sql += \" LEFT JOIN #{dimension_table_name} as #{dimension_name}\"\n sql += \" ON #{fact_class.table_name}.\"\n sql += \"#{fact_class.dimension_relationships[dimension_name].foreign_key}\"\n sql += \" = #{dimension_name}.id\\n\"\n end\n sql\n end", "def initialize_table; end", "def populate_nonprofit_table(org_eins)\n org_eins.each do |ein|\n Nonprofit.create(charityName: charityname(ein), city: city(ein), url: url(ein), ein: ein(ein) , zipcode: zipcode(ein), cause: cause(ein))\n end\nend", "def pre_initialize_fields\n end", "def create_lookup_table\n File.open(source).each_with_index do |line|\n next if line.chomp.empty?\n\n values = unstring(line).chomp.split(';')\n\n next if values.empty?\n\n @joiners.each do |joiner|\n key = values[joiner.join[0]]\n joiner.lookup[:rows][key] = []\n\n joiner.cols.each do |i|\n joiner.lookup[:rows][key] << values[i]\n end\n end\n\n end\n end", "def initialize_columns\n @columns = []\n valid_table = table.alias('valid_taxon_names')\n\n @columns.push({ header: 'ro', projected: rank_over(table, valid_table) })\n\n @columns.push({header: 'taxon_name_id', projected: table[:id].as('taxon_name_id') } )\n @columns.push({header: 'cached_valid_taxon_name_id', projected: table[:cached_valid_taxon_name_id].as('cached_valid_taxon_name_id') } )\n @columns.push({header: 'cached', projected: table[:cached].as('cached') } )\n @columns.push({header: 'cached_author_year', projected: table[:cached_author_year].as('cached_author_year') } )\n @columns.push({header: 'cached_is_valid', projected: table[:cached_is_valid].as('cached_is_valid') } )\n\n if fieldsets.include?('observations')\n @columns.push({header: 'otu_id', projected: otu_table[:id].as('otu_id') } )\n @columns.push({header: 'otu_name', projected: otu_table[:name].as('otu_name')} )\n end\n end", "def seed\n parse\n prepare_sql\n execute_sql\n end", "def initialize_table\n @total_rows.times do |row|\n row_array = Array.new(@total_columns, \"\")\n @reconstructed_table.push(row_array)\n end\n end", "def fetch_and_import!(opts={})\n eve_table = opts[:eve_table]\n dest_table = opts[:dest_table]\n mapping = opts[:mapping]\n dbh = opts[:conn] || @dbh\n comment_label = opts[:label]\n \n # Fetch Data from crpActivities Table\n results = dbh.query(\"SELECT * FROM \"+eve_table)\n # Clear Destination Table to eliminate Redundancy\n dest_table.camelize.constantize.delete_all\n # Do some Meta programming FU magic\n results.each do |row|\n insert_map = {}\n mapping.each do |key,value|\n insert_map[key.to_sym] = row[value]\n end \n dest_table.camelize.constantize.create!(insert_map)\n # Just so you see something when running this script..\n p \"Creating Record for #{dest_table} : \" + row[comment_label].to_s\n end\nend", "def recreate_from(obj)\n keys = self.key_column_names\n args = {}\n if obj.respond_to?(:enterprise_id) and obj.respond_to?(:uid)\n args[keys.delete(:enterprise_id)] = obj.enterprise_id\n if keys.length == 1\n args[keys.first] = obj.uid\n self.get_cached(args)\n else\n puts keys.to_a.to_s\n raise NotImplementedError, 'See octocore/models.rb'\n end\n end\n end", "def populate\n\n end", "def populate\n end", "def initialize_copy(orig)\n super\n @__table__ = @__table__.dup\n end", "def preload_data\n DataStore.instance.insert_data('users', 'data/users.json')\n DataStore.instance.insert_data('tickets', 'data/tickets.json')\n end", "def prepopulate_list\n\t\tname_list = ['ben', 'bob obobb', 'mary kate', 'kim possible', 'steve-o', 'jill and jack', 'veronica mars', 'danny trejo',\n\t\t 'jon snow', 'mario anluigi', 'ed obannon', 'amy winehouse', 'juan jones', 'walter okiefe', 'fred love']\n\t\tparty_list = ['tea party', 'conservative', 'neutral', 'liberal', 'socialist']\n\t\tjimbo = Human.new \"politician\", 'jimbo jones', 'democrat'\n\t\tgene = Human.new \"politician\", 'gene wilder', 'republican'\n\t\t@people_list << jimbo\n\t\t@people_list << gene\n\n\t\tname_list.map do |name|\n\t\t\trandom_party = party_list.sample\n\t\t\tname = Human.new \"voter\", name, random_party\n\t\t\t@people_list << name\n\t\tend\n\n\tend", "def preload(records, associations, given_preload_scope = nil)\n super records, associations, chronomodel_scope(given_preload_scope)\n end", "def setup\n current_user = options[:currentuser]\n all_flag = options[:allflag]\n if current_user.percentcompleteenabled\n table = Table([:description, :goaltype_label, :datecompleted, :created_date, :last_updated_date, :percentcomplete]) do |t|\n if all_flag\n current_user.goals.find(:all).each {|g| t << g.report_record()}\n else\n current_user.goals.find(:all).each {|u| t << u.report_record unless u.datecompleted != nil}\n end\n end\n \n table.rename_columns(:description => \"Description\",\n :goaltype_label => \"Goal Type\",\n :datecompleted => \"Date Completed\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\",\n :percentcomplete => \"Percent Complete\")\n\n else\n table = Table([:description, :goaltype_label, :datecompleted, :created_date, :last_updated_date]) do |t|\n if all_flag\n current_user.goals.find(:all).each {|g| t << g.report_record()}\n else\n current_user.goals.find(:all).each {|u| t << u.report_record unless u.datecompleted != nil}\n end\n end\n\n table.rename_columns(:description => \"Description\",\n :goaltype_label => \"Goal Type\",\n :datecompleted => \"Date Completed\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\")\n\n \n end\n\n self.data = table\n end", "def setup_columns\n if inheritable?\n SimpleSet.new([primary_key, inheritance_column])\n else\n primary_key.blank? ? SimpleSet.new : SimpleSet.new([primary_key])\n end \n end", "def populate_test_data\n @alice_mrn = 123\n @alice_picudb_id = @lomi.patients.insert({:mrn => @alice_mrn, :source => \"picudb\", :first_name => \"Alice\"})\n @alice_cerner_id = @lomi.patients.insert({:mrn => @alice_mrn, :source => \"cerner_patients\", :first_name => \"Alice\"})\n\n @alice_picudb_encounter_id = @lomi.encounters.insert({:patient_id => @alice_picudb_id,\n :source => \"picudb\",\n :admission => Time.new(2000, 12, 25),\n :discharge => Time.new(2000, 12, 28)})\n @alice_cerner_encounter_id = @lomi.encounters.insert({:patient_id => @alice_cerner_id,\n :source => \"cerner_paients\"})\n\n @alice_picudb_event_id = @lomi.events.insert({:patient_id => @alice_picudb_id,\n :encounter_id => @alice_picudb_encounter_id})\n @alice_cerner_event_id = @lomi.events.insert({:patient_id => @alice_cerner_id,\n :encounter_id => @alice_cerner_encounter_id,\n :start_time => Time.new(2000, 12, 26),\n :end_time => Time.new(2000, 12, 26) })\n end", "def populate_from(partition)\n team_mapping = {}\n partition.memberships.includes(:team, :user).each do |template|\n unless team = team_mapping[template.team]\n team = Team.create name: template.team.name, partition: self,\n course: course\n teams << team\n team_mapping[template.team] = team\n end\n TeamMembership.create(team: team, user: template.user)\n end\n self\n end", "def summarize_per_relation(generator)\n @from = \"#{generator.to_subquery} AS #{visit_identifier(generator.name)} NATURAL LEFT JOIN #{@from}\"\n end", "def before_setup\n Account.connection.drop_table :accounts, if_exists: true\n Account.connection.exec_query(\"CREATE SEQUENCE accounts_id_seq\")\n Account.connection.exec_query(\"\n CREATE TABLE accounts (\n id BIGINT PRIMARY KEY DEFAULT nextval('accounts_id_seq'),\n firm_id bigint,\n firm_name character varying,\n credit_limit integer\n )\n \")\n\n Company.connection.drop_table :companies, if_exists: true\n Company.connection.exec_query(\"CREATE SEQUENCE companies_nonstd_seq\")\n Company.connection.exec_query(\"\n CREATE TABLE companies (\n id BIGINT PRIMARY KEY DEFAULT nextval('companies_nonstd_seq'),\n type character varying,\n firm_id bigint,\n firm_name character varying,\n name character varying,\n client_of bigint,\n rating bigint,\n account_id integer,\n description character varying\n )\n \")\n\n Course.connection.drop_table :courses, if_exists: true\n Course.connection.exec_query(\"CREATE SEQUENCE courses_id_seq\")\n Course.connection.exec_query(\"\n CREATE TABLE courses (\n id INT PRIMARY KEY DEFAULT nextval('courses_id_seq'),\n name character varying,\n college_id integer\n )\n \")\n\n self.class.fixtures :accounts\n self.class.fixtures :companies\n self.class.fixtures :courses\n end", "def import_data\n @data.each do |row|\n name = row.first\n family_data = row.last\n\n family = FamilyGoal.find_or_create_by(name: name)\n \n family_data[:worlds].each do |world|\n family_data[:areas].each do |area|\n family_data[:positions].each do |position|\n family_goal_attribute = family.family_goal_attributes.find_or_create_by(world: world, area: area, position: position)\n end\n end\n end\n end\n end", "def populate_target_and_source_if_required\n return if @no_preparation\n\n populate(:target) if create_target?\n populate(:source)\n end", "def create_pruned_table(conn)\n if !conn.list_tables.include?('pruned')\n query = \"CREATE TABLE `pruned` ( `table_name` VARCHAR(64) NOT NULL PRIMARY KEY, `prune_time` DATETIME NOT NULL )\"\n if @dry_run\n verbose query\n else\n conn.query query\n end\n end\n end", "def seed_data\n delete_existing_records = 'DELETE FROM campaigns'\n @connection.execute(delete_existing_records)\n \n campaigns_records.each do |record|\n sql = %{\n INSERT INTO \n campaigns(job_id, status, external_reference, ad_description)\n VALUES(#{record[0]}, '#{record[1]}', '#{record[2]}', '#{record[3]}')\n }\n\n @connection.execute(sql)\n end\n end", "def initialize_rows\n @transform_lookup = {}\n if is_time?\n initialize_time_rows\n elsif is_distance?\n initialize_distance_rows\n else\n initialize_numeric_rows\n end\n end", "def seed_app_dining_periods\n start_hash = { 'Breakfast' => 8, 'Lunch' => 11, 'Dinner' => 16, 'Brunch' => 9, 'Late Night' => 20 }\n\n DiningOpportunity.all.each { |opp|\n DiningPlace.all.each { |dp|\n (0..6).each { |dow|\n start_hour = start_hash[opp.dining_opportunity_type]\n unless start_hour.blank?\n DiningPeriod.current_or_create_new(start_time: Time.now.change(hour: start_hour, min: rand(60)), end_time: Time.now.change(hour: start_hour + 3, min: rand(60)), day_of_week: dow, dining_opportunity_id: opp.id, dining_place_id: dp.id, institution_id: 1)\n end\n }\n }\n }\nend", "def init_podunk_table(gsheet, opts={})\n opts[:connection] = self\n Table.new(gsheet.rows, opts)\n end", "def preload(connection, records, association, host_table:, schema:, as:, order_by:, limit:)\n return records if records.empty?\n\n expect! records.first => Hash\n\n as = association if as.nil?\n fq_host_table = \"#{schema}.#{host_table}\"\n\n associated_table = find_associated_table(connection, association, schema: schema)\n relation = find_matching_relation(connection, fq_host_table, associated_table)\n\n if fq_host_table == relation.belonging_table\n if order_by || limit\n raise ArgumentError, \"#{association.inspect} is a singular association, w/o support for order_by: and limit:\"\n end\n\n preload_belongs_to connection, records, relation, as: as\n else\n preload_has_one_or_many connection, records, relation, as: as, order_by: order_by, limit: limit\n end\n end", "def load_table_schema(conn, builder, table)\n builder.relvar(table){\n primary_key_columns = load_table_heading(conn, builder, table)\n load_table_constraints(conn, builder, table, primary_key_columns)\n }\n end", "def copy_polymorphic_tables\n self.polymorphic_tables.each do |t|\n polymorphic_id_col, polymorphic_type_col = \"#{t.polymorphic_as}_id\", \"#{t.polymorphic_as}_type\"\n sql_connection.select_rows(t.sql_name) do |rows, page, total_pages|\n Mongify::Status.publish('copy_polymorphic', :size => rows.count, :name => \"Polymorphicizing #{t.name}\", :action => 'add')\n rows.each do |row|\n\n #If no data is in the column, skip importing\n if (row[polymorphic_type_col])\n table_name = row[polymorphic_type_col].tableize\n new_id = no_sql_connection.get_id_using_pre_mongified_id(table_name, get_type_casted_value(t, polymorphic_id_col, row))\n end\n\n row = t.translate(row)\n row[polymorphic_id_col] = new_id if new_id\n row.merge!(fetch_reference_ids(t, row))\n row.delete('pre_mongified_id')\n\n if t.embedded? && table_name\n row.delete(polymorphic_id_col)\n row.delete(polymorphic_type_col)\n save_function_call = t.embedded_as_object? ? '$set' : '$addToSet'\n no_sql_connection.update(table_name, new_id, {save_function_call => {t.name => row}})\n else\n no_sql_connection.insert_into(t.name, row)\n end\n\n Mongify::Status.publish('copy_polymorphic')\n end\n Mongify::Status.publish('copy_polymorphic', :action => 'finish')\n end\n end\n end", "def build_tables\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS breeds(\n id serial NOT NULL PRIMARY KEY,\n breed varchar(30),\n price integer\n )])\n\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS puppies(\n id serial NOT NULL PRIMARY KEY,\n breed varchar(30),\n name varchar(30),\n age integer,\n created_at timestamp NOT NULL DEFAULT current_timestamp\n )])\n\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS requests(\n id serial NOT NULL PRIMARY KEY,\n breed text,\n status text,\n created_at timestamp NOT NULL DEFAULT current_timestamp\n )])\n end", "def install_initial_state\n db = kernel.resources.db\n db.default.submissions = []\n db.default.valid_submissions = []\n db.default.challengers = []\n db.default.people = (1..5).collect{|i| user_tuple(i, true) }\n db.default.challengers = (1..5).collect{|i| challenger_tuple(i) }\n end", "def bootstrap\n sql = 'CREATE TABLE IF NOT EXISTS states(uuid VARCHAR(128) PRIMARY KEY,'\n sql << ' id INTEGER, name VARCHAR(128), deploy_id VARCHAR(128), timestamp INTEGER,'\n sql << ' missing INTEGER, state VARCHAR(128), hyperv VARCHAR(128))'\n\n @db.execute(sql)\n\n sql = 'CREATE TABLE IF NOT EXISTS settings(key VARCHAR(128) PRIMARY KEY,'\n sql << ' value VARCHAR(128))'\n\n @db.execute(sql)\n end", "def reset_associations\n reflections.each_value do |r|\n r.instance_variable_set(:@quoted_table_name, nil)\n table_name = r.instance_variable_get(:@table_name)\n if (table_name)\n table_name = table_name.split(\".\").last\n klass = r.class_name.constantize\n schema_name = klass.tenanted? ? Roomer.current_tenant.try(:schema_name) : Roomer.shared_schema_name\n schema_name &&= schema_name.to_s\n schema_name ||= \"__no_tenant__\"\n table_name = \"#{schema_name}#{Roomer.schema_seperator}#{table_name}\"\n r.instance_variable_set(:@table_name, table_name)\n r.instance_variable_set(:@quoted_table_name, connection.quote_table_name(table_name))\n end\n end\n end", "def prefix_table\n update unless @prefix_table\n @prefix_table\n end", "def _spreadNewContentGloballyInit\n query = \"PREPARE seen (bigint, bigint) AS INSERT INTO userseen VALUES($1, $2)\"\n $conn.exec(query)\n\n query = \"PREPARE share (bigint, bigint) AS INSERT INTO usershare VALUES($1, $2)\"\n $conn.exec(query)\n\n query = \"PREPARE kill (bigint, bigint) AS INSERT INTO userkill VALUES($1, $2)\"\n $conn.exec(query)\nend", "def reset_data\n @pg_data_table = {}\n @gameview_data_table = {}\n @userlist_table = {}\n @last_parsed_pglist_data = []\n @last_parsed_userlist_data = []\n end", "def preload(records, associations, given_preload_scope = nil)\n if options[:as_of_time]\n preload_scope = given_preload_scope || NULL_RELATION.dup\n preload_scope.as_of_time!(options[:as_of_time])\n end\n\n super records, associations, preload_scope\n end", "def prepare_identities_from_data; end", "def fill_out\n @build = {}\n descend(@schema, [])\n @build\n end", "def build_fact(name, options={})\n options[:rows] ||= 100\n options[:generators] ||= {}\n options[:fk_limit] ||= {}\n rows = []\n\n fact_class = Fact.to_fact(name)\n options[:rows].times do\n row = {}\n fact_class.content_columns.each do |column|\n generator = (options[:generators][column.klass] || @generators[column.klass])\n row[column.name] = generator.generate(column, options)\n end\n fact_class.dimension_relationships.each do |name, reflection|\n # it would be better to get a count of rows from the dimension tables\n fk_limit = (options[:fk_limit][reflection.foreign_key] ||\n options[:dimensions] || 100) - 1\n row[reflection.foreign_key] = rand(fk_limit) + 1\n end\n rows << row\n end\n\n rows\n end", "def sql_load\n row = DBIntf.get_first_row(\"SELECT * FROM #{tbl_name} #{generate_where_on_pk};\")\n return row.nil? ? reset : load_from_row(row)\n end", "def post_load(all_records)\n eager_graph_build_associations(all_records) if @opts[:eager_graph]\n eager_load(all_records) if @opts[:eager] && (row_proc || @opts[:eager_graph])\n super\n end", "def preload\n entries\n collections.each &:preload\n nil\n end", "def setup_associations; end", "def prepare_for_adding_assoc_target(lecture, pre_assoc_items)\n @def_lecture_form_items = Def_Lecture_Form_Items\n @lecture_form_items = Lecture_Form_Items\n @def_lecture_time_form_items = Def_Lecture_Time_Form_Items\n @lecture_time_form_items = Lecture_Time_Form_Items\n @course = find_entity(pre_assoc_items[-2])\n flash_now @course.blank?, \"連結する科目がまだ作られていません.それを作成後,あらためて授業の作成を行ってください.\"\n arrange_environment_from_background\n set_assert_time_as_end_of_academic_season_range\n # default since through whole composite entity\n @default_since = beginning_of_academic_season(@academic_year, @academic_season)\n unless @course.blank?\n lecture.build_course(@course)\n @course.since = @root_entity_since\n @course.course_classes.reject(&:new_record?).map do |cc| \n lecture.lecture_course_classes.build(:course_class_run_id => cc.run_id)\n end\n @course_classes = @course.course_classes\n end\n @default_since = beginning_of_academic_season\n lecture.since = @root_entity_since\n lecture.lecture_member__teachers.build\n lecture.lecture_times.build\n end", "def association_symbol_for_rows\n @importing_reflection ||= self.class.import_into\n end", "def import_datas_into_master_tabel\n if params[:real_estate_property][\"remote_property_name\"] && remote_property(@property.accounting_system_type_id)\n remote_property = RealEstateProperty.find_by_sql(\"select HMY as hmy_id from #{find_table_name + '_Property'} where SCODE = '#{params[:real_estate_property][\"property_code\"].strip}' and SADDR1 = '#{params[:real_estate_property][\"remote_property_name\"].strip}'\")\n if remote_property && !remote_property.empty?\n connection = ActiveRecord::Base.connection();\n connection.execute(\"INSERT INTO `remote_properties` (`HMY` ,`real_estate_property_id` ,`accounting_system_type_id`) VALUES ('#{remote_property[0].hmy_id}',#{@property.id},#{@property.accounting_system_type_id})\")\n end\n hmy = RealEstateProperty.find_by_sql(\"select HMY as hmy_id from remote_properties where real_estate_property_id = #{@property.id} limit 1\")[0]\n Delayed::Job.enqueue DelayedPropertyDataImport.new(@property.id,current_user.id,find_table_name,hmy.hmy_id.to_i,@property.portfolio.leasing_type,@property.property_name,@property.property_code,@property.portfolio_id)\n end\n end", "def prepare_hgt_com_trsf_prkgrs_old()\n \n @conn.execute \\\n \"truncate table hgt_com_trsf_prkgrs\"\n \n puts \"hgt_com_trsf_prkgrs table truncated...\"\n \n #\n sql = \"select id,\n gene_id,\n TXSRC_ID,\n TXDST_ID,\n WEIGHT_TR_TX\n from HGT_COM_TRSF_TAXONS\"\n \n #puts \"sql: #{sql}\"\n \n \n tr_taxons = HgtComTrsfTaxon.find_by_sql(sql)\n \n tr_taxons.each {|tr|\n \n\n #debugging\n #next unless tr.gene_id == 111 and tr.txsrc_id == 768679 and tr.txdst_id == 374847\n \n #puts \"tr: #{tr.inspect}\"\n #puts \"tr.id: #{tr.id}, #{tr.gene_id}\"\n \n #for each chiteria\n (0..1).each {|crit|\n \n #for each criteria and\n #for each source and destination prok groups\n sql = \"select tg.PROK_GROUP_ID,\n tg.WEIGHT_PG\n from TAXON_GROUPS tg \n join PROK_GROUPS pg on pg.id = tg.PROK_GROUP_ID\n where tg.TAXON_ID = #{tr.txsrc_id} and\n pg.GROUP_CRITER_ID = #{crit}\"\n #puts \"sql: \\n #{sql}\"\n \n pg_src = TaxonGroup.find_by_sql(sql)\n \n \n sql = \"select tg.PROK_GROUP_ID,\n tg.WEIGHT_PG\n from TAXON_GROUPS tg \n join PROK_GROUPS pg on pg.id = tg.PROK_GROUP_ID\n where tg.TAXON_ID = #{tr.txdst_id} and\n pg.GROUP_CRITER_ID = #{crit}\"\n #puts \"sql: \\n #{sql}\"\n \n pg_dst = TaxonGroup.find_by_sql(sql)\n \n pg_src.each {|src|\n pg_dst.each {|dst|\n \n #puts \"src: #{src.inspect}\"\n #puts \"dst: #{dst.inspect}\"\n \n #insert alternative\n prkg = HgtComTrsfPrkgr.new \n prkg.gene_id = tr.gene_id\n prkg.hgt_com_trsf_taxon_id = tr.id\n prkg.pgsrc_id = src.prok_group_id\n prkg.pgdst_id = dst.prok_group_id\n prkg.weight_tr_pg = tr.weight_tr_tx * src.weight_pg * dst.weight_pg\n prkg.save\n \n #prkg.gene_id = tr.gene_id \n #prkg.save\n \n \n }\n }\n \n \n \n \n \n } \n }\n \n \n end", "def auto_assoc(opts = {})\n except = opts[:except] || []\n\n assocs = db.schema_parse_associations(table_name)\n relations = process_join_tables(assocs)\n\n relations.each do |row|\n src_tbl = row[:src_tbl]\n src_col = row[:src_col]\n if src_tbl == table_name && ! (src_col & except).empty?\n # TODO enable except for *_to_many\n next\n end\n src_uniq = row[:src_uniq]\n src_cardinality = cardinality(src_uniq)\n\n join_tbl = row[:join_tbl]\n\n dst_tbl = row[:dst_tbl]\n dst_col = row[:dst_col]\n dst_uniq = row[:dst_uniq]\n dst_cardinality = cardinality(dst_uniq)\n\n TABLE_MODELS.wait_all(src_tbl, dst_tbl) do |src_cls, dst_cls|\n self_ref = src_cls == dst_cls\n\n src = self_ref ? :child : underscore(src_cls.name).to_sym\n src = src_uniq ? singularize(src).to_sym : pluralize(src).to_sym\n\n dst = self_ref ? :parent : underscore(dst_cls.name).to_sym\n dst = dst_uniq ? singularize(dst).to_sym : pluralize(dst).to_sym\n\n if join_tbl\n left_col = row[:left_col]\n right_col = row[:right_col]\n send :many_to_many, src, :class => src_cls, :join_table => join_tbl,\n :left_key => left_col, :left_primary_key => dst_col,\n :right_key => right_col, :right_primary_key => src_col\n else\n # TODO name overrides\n\n if self == dst_cls\n # dst holds the foreign key -> one_to_*\n meth = dst_cardinality + '_to_' + src_cardinality\n send meth, src, :class => src_cls, :key => src_col, :primary_key => dst_col\n end\n\n if self == src_cls\n # src holds the foreign key -> *_to_one\n meth = src_cardinality + '_to_' + dst_cardinality\n\n # one_to_one requires to swap pk and fk\n src_col, dst_col = dst_col, src_col if src_uniq\n send meth, dst, :class => dst_cls, :key => src_col, :primary_key => dst_col\n end\n end\n\n end\n end\n end", "def preload(*args)\n fresh.tap do |criteria|\n criteria.preload_values = (preload_values || []) + args\n end\n end", "def setup\n begin\n create_campaign_table_if_not_exist\n seed_data\n rescue Exception => e\n raise \"Database setup failed with error #{e}\"\n ensure\n @connection.close\n end\n end", "def initialize\n @columns = { }\n @primary_keys = []\n @to_avoid = []\n @default_values = { }\n @associations = \n {\n :belongs_to => { },\n :has_one => { },\n :has_n => { }\n }\n end", "def preload_posts(records)\n cards = records.map(&:card)\n post_ids = records.map(&:post_id)\n card_post_ids = cards.map(&:post_id)\n\n posts = posts_scope.where(id: (post_ids + card_post_ids)).index_by(&:id)\n records.each do |rec|\n rec.post = posts[rec.post_id]\n end\n\n cards.each do |card|\n card.post = posts[card.post_id]\n end\n end", "def initialize(associations)\n @left_joins_by_alias = {}\n last_table_alias = nil\n associations.each_with_index do |association, association_path_index|\n # Important, this variable will take the last joined table to chain the join, in the first loop, will take\n # the association origin table name.\n last_table_alias ||= association.active_record.table_name\n left_join = Babik::QuerySet::Join.new_from_association(association, association_path_index, last_table_alias)\n\n @left_joins_by_alias[left_join.target_alias] = left_join\n last_table_alias = left_join.target_alias\n end\n @target_alias = last_table_alias\n end", "def initial_columns(with_excluded = false)\n # Normalize here, as from the config we can get symbols (names) instead of hashes\n columns_from_config = config[:columns] && normalize_attrs(config[:columns])\n\n\n if columns_from_config\n # automatically add a column that reflects the primary key (unless specified in the config)\n columns_from_config.insert(0, {:name => data_class.primary_key}) unless columns_from_config.any?{ |c| c[:name] == data_class.primary_key }\n\n # reverse-merge each column hash from config with each column hash from exposed_attributes\n # (columns from config have higher priority)\n for c in columns_from_config\n corresponding_default_column = default_columns.find{ |k| k[:name] == c[:name] }\n c.reverse_merge!(corresponding_default_column) if corresponding_default_column\n end\n columns_for_create = columns_from_config\n else\n # we didn't have columns configured in component's config, so, use the columns from the data class\n columns_for_create = default_columns\n end\n\n filter_out_excluded_columns(columns_for_create) unless with_excluded\n\n # Make the column config complete with the defaults\n columns_for_create.each do |c|\n detect_association(c)\n set_default_virtual(c)\n set_default_header(c)\n set_default_editor(c)\n set_default_width(c)\n set_default_hidden(c)\n set_default_editable(c)\n set_default_sortable(c)\n set_default_filterable(c)\n end\n\n columns_for_create\n end", "def prep\n\tend", "def preload\n presenter.preload(resolved_associations_map.flat_map {|k,v| v[:associations]})\n end", "def set_initial_values(accountsHash,name,row)\n\tunless accountsHash.has_key?(name)\n\t\taccountsHash[name] = AccountClass.new\n\t\taccountsHash[name].initial_values\n\tend\n\tunless accountsHash[name].getCategoryData.has_key?(row[\"Category\"].chomp)\n\t\taccountsHash[name].addCategory(row)\n\tend\n\treturn accountsHash\nend", "def initialize_copy(orig)\n super\n @table = @table.dup\n end", "def import_table( table )\n # This must come first, so we can exclude foreign key indexes later.\n import_foreign_keys( table )\n import_indexes( table )\n import_columns( table )\n end", "def post_processing_tables(nodes)\n tables = nodes\n .css('table:not(.o-ld-columns-table)')\n .add_class('c-ld-table')\n tables.wrap('<div class=\"c-ld-table__wrap\"></div>') unless @options[:material]\n end", "def create_users_products\n @db.create_join_table(:user_id => :users, :product_id => :products) do\n end\n end", "def copy_new_rows\n tables.each(&:copy_new_rows)\n end", "def populate(options={})\n populate_rollup_cube\n end", "def vendor_table\n update unless @vendor_table\n @vendor_table\n end", "def make\n if dimension?\n dimension_key_builder\n elsif fact?\n FactKeyBuilder.new(staging_db[table.table_name])\n end\n end", "def fill_bag_from(source)\n self.class.bag.columns.each do |column|\n column_name = column.name\n if source.respond_to?(column_name) && self.send(column_name).blank?\n self.send(\"#{column_name}=\", source.send(column_name)) \n end\n end\n end", "def proposal_details_rows_to_insert_sql\n sql = <<-SQL\n SELECT * FROM (\n #{all_proposal_details_rows_sql}\n ) all_rows_in_table_name\n WHERE ProposalNature IS NOT NULL\n OR ProposalOutcome IS NOT NULL\n OR ProposalRepresentation IS NOT NULL\n EXCEPT\n SELECT\n d.elib_legacy_id,\n dd.proposal_nature,\n outcomes.name,\n dd.representation,\n dd.proposal_number\n FROM (\n #{all_rows_sql}\n ) nc\n JOIN documents d ON d.elib_legacy_id = nc.DocumentID\n JOIN proposal_details dd ON d.id = dd.document_id\n JOIN document_tags outcomes ON dd.proposal_outcome_id = outcomes.id\n SQL\n end", "def populate_table_with_id_value_normalized_value(database, table_name, source_type, csv_file)\n return if database.table_exists?(table_name)\n database.create_table table_name do\n # primary_key :id\n Integer :id, primary_key: true, index: {unique: true} # non-autoincrementing\n String :value\n foreign_key :normal_form_id, index: true\n end\n data = File.readlines(csv_file).drop(1).map{|line|\n id, value, normal_form = line.chomp.split(\"\\t\", 3)\n normal_form_id = DB[:normal_forms].where(value: normal_form, source_type: source_type).get(:id)\n normal_form_id ||= DB[:normal_forms].insert(value: normal_form, source_type: source_type)\n [Integer(id), value, normal_form_id]\n }\n database[table_name].import([:id, :value, :normal_form_id], data)\nend", "def create_side_table\n RailsRedshiftReplicator.connection.exec \"CREATE TABLE #{temporary_table_name} (LIKE #{replication.target_table})\"\n end", "def insert_table(table, identifier, data)\n if existing_data = get_table(table, identifier)\n if existing_data.empty? || !existing_data.has_key?('.members')\n data.each { |key, value| existing_data[key] = value }\n return data\n else\n error_report \"Error in insert_table: Redefinition of #{identifier}\"\n raise ParseError\n end\n end\n\n table['table_data'].push([identifier, data])\n table['quick_look'][identifier] = 1\n return data\nend", "def insert_table(table, identifier, data)\n if existing_data = get_table(table, identifier)\n if existing_data.empty? || !existing_data.has_key?('.members')\n data.each { |key, value| existing_data[key] = value }\n return data\n else\n error_report \"Error in insert_table: Redefinition of #{identifier}\"\n raise ParseError\n end\n end\n\n table['table_data'].push([identifier, data])\n table['quick_look'][identifier] = 1\n return data\nend", "def preload(association, as: nil, order_by: nil, limit: nil)\n expect! association => Symbol\n expect! as => [nil, Symbol]\n\n # resolve oid into table and schema name.\n #\n # [TODO] is this still correct?\n schema, host_table = connection.reflection.lookup_pg_class @pg_source_oid\n\n AssociationLoader.preload connection,\n @hash_records, association,\n host_table: host_table, schema: schema, as: as,\n order_by: order_by, limit: limit\n\n @associations << association\n\n materialize\n end", "def setup\n current_user = options[:currentuser]\n all_flag = options[:allflag]\n if current_user.percentcompleteenabled\n table = Table([:description, :category_label, :created_date, :last_updated_date, :percentcomplete]) do |t|\n if all_flag\n current_user.tasks.find(:all).each {|u| t << u.report_record() }\n else\n completed_category = current_user.category.find(:all, :conditions => [\n \"label = 'Completed'\"\n ])\n current_user.tasks.find(:all).each {|u| t << u.report_record unless u.category_id == completed_category[0].id}\n end\n end\n table.rename_columns(:description => \"Description\",\n :category_label => \"Task Category\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\",\n :percentcomplete => \"Percent Complete\")\n else\n table = Table([:description, :category_label, :created_date, :last_updated_date]) do |t|\n if all_flag\n current_user.tasks.find(:all).each {|u| t << u.report_record() }\n else\n completed_category = current_user.category.find(:all, :conditions => [\n \"label = 'Completed'\"\n ])\n current_user.tasks.find(:all).each {|u| t << u.report_record unless u.category_id == completed_category[0].id}\n end\n end\n table.rename_columns(:description => \"Description\",\n :category_label => \"Task Category\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\")\n end\n \n self.data = table\n end", "def join_table_source\n cached_fetch(:join_table_source){split_join_table_alias[0]}\n end", "def initialize_copy(original)\n super\n @table = @table.dup\n end", "def autogrow_hashes\n wait_until_bus_section_load\n tables.last.hashes\n end", "def populate\n AgentProcess.all.each { |a| update(a.name, a) }\n end", "def preload_fields_with(params)\n params.each_key do |field|\n self.public_send(\"#{field}=\", params[field])\n end\n end", "def before_create\n self[:TableID] = 1\n self[:Type] = 0 # FIXME: guess\n super\n end", "def spawn_tables\n\t# pseudo-migration / schema\n\tif !FeedEntry.table_exists?\n\t\tprint \"Creating feed entry table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:feed_entries) do |t|\n\t\t\tt.column :name, :string\n\t\t\tt.column :content, :string\n\t\t\tt.column :url, :string\n\t\t\tt.column :guid, :string\n\t\t\tt.column :published_at, :datetime\n\t\t\tt.column :feed_id, :integer\n\t\tend\n\tend\n\tif !Feed.table_exists?\n\t\tprint \"Creating feed table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:feeds) do |t|\n\t\t\tt.column :url, :string\n\t\tend\n\tend\n\tif !Blacklist.table_exists?\n\t\tprint \"Creating blacklist table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:blacklists) do |t|\n\t\t\tt.column :word, :string\n\t\tend\n\tend\nend", "def PopulateProducts #Not used\n @@db_instant.PopulateProducts\n end", "def reload_nested_set\n reload(:select => \"#{quoted_left_column_name}, \" +\n \"#{quoted_right_column_name}, #{quoted_parent_column_name}\")\n end", "def setup_departments\n Department.delete_all \n Employee.delete_all\n dep = Department.create(:name=> 'department1', :city => 'Littleton', :state => 'CO') \n employee1 = dep.employees.create(:first_name=>\"first_1\", :last_name =>\"last_1\", :job_id => 12) \n employee2 = dep.employees.create(:first_name=>\"first_2\", :last_name =>\"last_2\", :job_id => 12) \n employee3 = dep.employees.create(:first_name=>\"first_3\", :last_name =>\"last_3\", :job_id => 12) \n employee3.manager = employee1\n \n departments = {:department1 => dep,\n :department2 => Department.create(:name=> 'department2', :city => 'Littleton', :state => 'CO') ,\n :department3 => Department.create(:name=> 'department3', :city => 'Littleton', :state => 'CO') \n }\n departments\n end", "def add_facts(data)\n record_id = assert_record_id(data)\n insert_facts_record record_id, data\n end", "def populate\n # User\n #@users = User.all.order(:name)\n #@user = User.new\n\n # Location\n @locations = Location.all.order(:name)\n @location = Location.new\n\n # Cateogry\n @categories = Category.all.order(:name)\n @category = Category.new\n\n # Course\n @courses = Course.all.order(:name)\n @course = Course.new\n end", "def prepare_orm_data_for_filters\n self.data_grid.columns.each do |col|\n next if col.filter.nil? # if no filter\n\n # Prepare auto filters\n if col.filter == :auto\n col.filter_data = self.data_grid.data_class.select(\"DISTINCT (#{col.filter_by}) as fc\").to_a.to_a.map(&:fc)\n end\n\n col.filter_data.uniq!\n col.filter_data.sort!\n end\n end" ]
[ "0.84082294", "0.74827445", "0.6295784", "0.58048487", "0.55817306", "0.5358085", "0.5300262", "0.5279212", "0.5266691", "0.5205254", "0.51967645", "0.5195885", "0.5181098", "0.5102876", "0.5089507", "0.50233686", "0.5011442", "0.50093275", "0.49745193", "0.49037144", "0.4902029", "0.48977768", "0.48869017", "0.48868543", "0.4853503", "0.4842215", "0.48242575", "0.4823016", "0.47939062", "0.47846496", "0.4777104", "0.47653717", "0.47652736", "0.47627953", "0.47481382", "0.47398347", "0.47229302", "0.47141203", "0.471361", "0.4709851", "0.47034565", "0.46977517", "0.4683772", "0.46690556", "0.46684885", "0.4666461", "0.4664414", "0.46616247", "0.46582827", "0.4648746", "0.4648686", "0.46481022", "0.46464023", "0.4641365", "0.46401206", "0.46358883", "0.46310398", "0.46187937", "0.46132958", "0.46121627", "0.46010715", "0.45852506", "0.45807582", "0.45774457", "0.45746472", "0.45736146", "0.45724732", "0.45691675", "0.45560575", "0.4551608", "0.45393816", "0.45370397", "0.45355392", "0.45319563", "0.45299786", "0.45276123", "0.45263103", "0.45069805", "0.45038784", "0.44956204", "0.4490928", "0.44903436", "0.4488783", "0.4487385", "0.4487385", "0.44851524", "0.44837114", "0.4483117", "0.44721153", "0.44616988", "0.4460338", "0.44594437", "0.44582492", "0.44575125", "0.44557428", "0.44534427", "0.4452857", "0.44500223", "0.44432428", "0.44361314" ]
0.80255306
1
Drop the storage table
def drop_prejoin_fact_table connection.drop_table(prejoined_table_name) if connection.tables.include?(prejoined_table_name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drop_table\n db.drop_table(table_name)\n end", "def drop_table\n self.connection.drop_table table_name\n end", "def drop_table(name)\n not_exist(name)\n\n ORM::DBConnection.new(model_name(name)).remove_table(name)\n File.delete(\"app/services/db/tables/#{name}.json\")\n end", "def destroy\n [METADATA_TABLE_NAME, RUN_HISTORY_TABLE_NAME,\n DISABLED_MONITOR_TABLE_NAME, MONITOR_INFO_TABLE_NAME].each do |table|\n @db.execute(\"DROP TABLE IF EXISTS #{table}\")\n end\n\n create()\n end", "def delete\n fast_storage.delete\n warehouse_storage.delete\n end", "def delete_table\n table_name = self.to_s.pluralize.underscore\n DATABASE.execute(\"DROP TABLE #{table_name}\")\n end", "def delete_table\n TinyDyno::Adapter.delete_table(table_name: self.table_name)\n end", "def drop_table_statement(repository, model)\n \"DROP TABLE #{quote_table_name(model.storage_name(repository.name))}\"\n end", "def destroy!\n drop_ddl = tables.map(&:name).map do |t|\n \"drop table if exists #{t};\\n\"\n end.join\n ActiveRecord::Base.connection.execute(drop_ddl)\n end", "def drop_versioned_table\n self.connection.drop_table versioned_table_name\n end", "def drop(db)\n\tif $table_exists\n\t\tdb.execute(\"DROP TABLE items;\")\n\t\t$table_exists = false\n\t\tputs \"\\nTable successfully deleted.\"\n\telse\n\t\tputs \"\\nTable successfully deleted.\"\n\tend\nend", "def delete_table(table_id); delete(\"tables/#{table_id}\"); nil; end", "def drop_table(tablename)\r\n raise(ArgumentError, 'Table name must be a symbol!') unless \\\r\n tablename.is_a?(Symbol)\r\n raise \"Table does not exist!\" unless table_exists?(tablename)\r\n @table_hash.delete(tablename)\r\n\r\n return @engine.delete_table(tablename)\r\n end", "def purge\n @db.execute( \"DELETE FROM #{TABLE_NAME};\" )\n end", "def delete_table(table_name)\n data.delete(table_name)\n end", "def drop\n\t\tActiveRecord::Base.connection.execute \"SET AUTOCOMMIT=0\"\n\t\tActiveRecord::Base.connection.execute \"SET FOREIGN_KEY_CHECKS=0\"\n\n self.change_schema_to 'information_schema';\n @result[:deleted] = []\n \n if request[:remove_all]\n #remove all tables\n @tables = ActiveRecord::Base.connection.select_all \"select TABLE_NAME table_name from `TABLES` where `TABLE_SCHEMA`='#{request[:db_name]}'\"\n self.change_schema_to request[:db_name];\n \n @tables.each do |table|\n ActiveRecord::Base.connection.execute \"drop table `#{table[\"table_name\"]}`\"\n @result[:deleted].push table[\"table_name\"];\n end\n else\n self.change_schema_to request[:db_name];\n ActiveRecord::Base.connection.execute \"drop table `#{request[:key]}`\";\n @result[:deleted].push request[:key];\n end\n \n self.change_schema_to 'information_schema';\n @result[:type] = 'table'\n render json: @result\n end", "def destroy(table)\n end", "def drop_table(table)\n connection.drop_collection(database,table)\n end", "def delete_kiosks\n @db.execute(\"DROP TABLE Kiosks\")\n end", "def drop_tables!\n migrate(:down)\n end", "def destroy!\n destroy_storage_snapshot(_id)\n end", "def drop_tablespace(name, options = {})\n sql = 'DROP TABLESPACE '\n sql << 'IF EXISTS ' if options[:if_exists]\n sql << quote_tablespace(name)\n\n execute(\"#{sql};\")\n end", "def drop_table(table_name, **options)\n schema_cache.clear_data_source_cache!(table_name.to_s)\n execute \"DROP#{' TEMPORARY' if options[:temporary]} TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}\"\n end", "def drop_table(table_name = temporary_table_name)\n ::RailsRedshiftReplicator.connection.exec \"drop table if exists #{table_name}\"\n end", "def delete_table instance_id, table_id\n tables.delete_table name: table_path(instance_id, table_id)\n end", "def down\n \t# Example\n \t# Easy to undo something you create, but this doesn't work\n \t# because it is hard to fix mistakes.\n \t# drop_table :pictures\n end", "def dropUserTable\n @conn.exec(\"DROPE users\")\n end", "def delete_database(table_name)\n table_details = @client.describe_table(table_name: table_name).table\n wait_until_table_available(table_name) if table_details.table_status != 'ACTIVE'\n @client.delete_table(table_name: table_name)\n rescue Aws::DynamoDB::Errors::ResourceNotFoundException\n puts 'Table did not exist. Nothing to delete.'\n end", "def clear\n table_ = [keyspace, table].compact.join '.'\n statement = \"DROP TABLE IF EXISTS #{table_} ;\"\n session.execute(statement)\n end", "def delete_table(database_name, table_name)\n @glue_client.delete_table(database_name: database_name, name: table_name)\n rescue Aws::Glue::Errors::ServiceError => e\n @logger.error(\"Glue could not delete job: \\n#{e.message}\")\n end", "def delete table\n table = table.to_sym\n @lookup = @lookup.reject { |k, v| k == table }\n @schema = @schema.reject { |k, v| k == table }\n nil\n end", "def drop_table(*names)\n options = names.last.is_a?(Hash) ? names.pop : OPTS \n names.each do |n|\n execute_ddl(drop_table_sql(n, options))\n remove_cached_schema(n)\n end\n nil\n end", "def clear_sensor_table\n open_database { |db|\n begin\n db.transaction\n\n db.query(<<~EOQ)\n delete from SENSOR_TABLE;\n EOQ\n\n db.commit\n\n rescue => e\n db.rollback\n raise(e)\n end\n }\n end", "def delete_from_disk; end", "def dropUserTable(tableName)\n @conn.exec(\"DROP TABLE #{tableName}\")\n end", "def delete_table(table)\r\n referenced_by = references(table)\r\n if !referenced_by.empty?\r\n puts \"unable to delete table \\'#{table}\\' because it is referenced by table(s):\"\r\n referenced_by.each{|table_name| puts \"#{table_name}\"}\r\n false\r\n elsif table_exists?(table)\r\n delete_table_cmd = \"DROP TABLE IF EXISTS #{table}\"\r\n @db.execute(delete_table_cmd)\r\n puts \"#{table} was deleted\"\r\n true\r\n end\r\n end", "def truncate_db\n drop_table\n create_table\n end", "def destroy_model_storage(repository, model)\n return true unless storage_exists?(model.storage_name(repository.name))\n success = without_notices { super }\n model.properties(repository.name).each do |property|\n drop_sequence(repository, property) if property.serial?\n end\n success\n end", "def clear!\n transaction do\n Schema::TABLES.each do |table|\n execute(\"DELETE FROM #{table}\")\n execute(\"DELETE FROM sqlite_sequence WHERE name = '#{table}'\") # reset the auto-increment sequence\n end\n end\n self\n end", "def delete_database(table_name)\n table_details = get_table_details(table_name)\n if table_details.nil?\n puts 'Table did not exist. Nothing to delete.'\n else\n wait_until_table_available(table_name) if table_details.table_status != 'ACTIVE'\n @client.delete_table(table_name: table_name)\n end\n end", "def remove_storage_file\n FileUtils.rm(file_path)\n end", "def delete_traps\n @db.execute(\"DROP TABLE Traps\")\n end", "def delete_table instance_id, table_id\n execute do\n tables.delete_table(\n table_path(instance_id, table_id)\n )\n end\n end", "def drop_table(table)\n current_instructions << Instructions::DropTable.new(table: table)\n end", "def remove_database\n FileUtils.rm_rf(path) if File.exist? File.join(path, \"iamflint\")\n @database = nil\n @writable_database = nil\n end", "def delete_table(table_name, options = {})\n call(:delete, table_uri(table_name, new_query(options)), nil, {}, options)\n nil\n end", "def drop_movies_table\n c = PGconn.new(:host => \"localhost\", :dbname => \"testdb\")\n c.exec \"DROP TABLE products;\"\n c.close\nend", "def remove_database\n FileUtils.rm_rf(path) if File.exist? File.join(path, \"record.DB\")\n @database = nil\n @writable_database = nil\n end", "def destroy_model_storage(repository, model)\n raise NotImplementedError\n end", "def clear_database_table\n <%= class_name %>.delete_all\n end", "def destroy_model_storage(repository, model)\n raise NotImplementedError\n end", "def delete_database\n FileUtils.rm_rf(@db_dir)\n end", "def truncate\n connection.truncate(table_name)\n end", "def delete\n storage.delete(id)\n end", "def delete_storage(storage_uuid)\n response = delete \"storage/#{storage_uuid}\"\n\n response\n end", "def delete_storage(storage_uuid)\n response = delete \"storage/#{storage_uuid}\"\n\n response\n end", "def truncate_table\n\t\t\t transaction { connection.execute(\"TRUNCATE TABLE #{quoted_table_name};\") }\n\t\t end", "def down\n \tdrop_table :solution_submissions\n\n # \texecute <<-SQL\n # \t\tDROP TYPE s_status;\n # \tSQL\n\n # \texecute <<-SQL\n # \t\tDROP TYPE lang;\n # \tSQL\n\n end", "def destroy; delete end", "def destroy\n DATABASE.destroy(self)\n end", "def destroy_model_storage(model)\n model = Persevere.enhance(model)\n return true unless storage_exists?(model.storage_name(name))\n schema_hash = model.to_json_schema_hash()\n return true unless delete_schema(schema_hash) == false\n false\n end", "def delete_table dataset_id, table_id\n execute { service.delete_table @project, dataset_id, table_id }\n end", "def drop_table_sql(name)\n \"DROP TABLE #{quote_schema_table(name)}\"\n end", "def drop_table(klass)\n # Remove leftover data from some join tabkes.\n klass.relations.each do |rel|\n if rel.class.to_s == \"Og::JoinsMany\" and rel.join_table\n target_class = rel.target_class\n exec \"DELETE FROM #{rel.join_table}\"\n end\n end\n exec \"DROP TABLE #{klass.table}\"\n end", "def drop\n ensure_service!\n service.drop_database instance_id, database_id\n true\n end", "def drop\n ensure_service!\n service.drop_database instance_id, database_id\n true\n end", "def unlink\n self.transaction do\n self.class.factory.model.connection.execute <<-SQL\n ALTER TABLE #{name} NO INHERIT #{self.class.factory.model.table_name};\n ALTER TABLE #{name} RENAME TO #{name}_unlinked;\n SQL\n self.destroy\n end\n end", "def db_deleter(database, id)\n database.execute(\"DELETE FROM wine_cellar where id=#{id}\")\nend", "def delete\n table_name = self.class.to_s.pluralize.underscore\n DATABASE.execute(\"DELETE FROM #{table_name} WHERE id = #{@id};\")\n end", "def drop_table?\n db.drop_table?(table_name)\n end", "def clear_with_new_table(table)\n @db_table = table\n init_parameters\n @filename = nil\n end", "def delete\n table_name = self.class.to_s.pluralize.underscore\n DATABASE.execute(\"DELETE FROM #{table_name} WHERE id = #{@id};\")\n end", "def drop_movies_table\n c = connect\n c.exec \"DROP TABLE IF EXISTS movies;\" \n c.close\nend", "def drop_database(name) #:nodoc:\n execute \"DROP DATABASE #{quote_table_name(name)}\"\n end", "def destroy_file\n db_file.destroy if db_file\n end", "def delete(id)\n @storage.delete(id)\n purge(id)\n end", "def delete_test_tables\n DynamoTable.delete_test_tables(CHEF_ENV)\n render_head_204\n end", "def delete\n table = self.class.to_s.pluralize.underscore\n\n DATABASE.execute(\"DELETE FROM #{table} WHERE id = #{@id};\")\n end", "def drop_db\n Mongoid.purge!\n end", "def delete_table(table_name, options={})\n query = { }\n query[\"timeout\"] = options[:timeout].to_s if options[:timeout]\n\n call(:delete, table_uri(table_name, query), nil, {}, options)\n nil\n end", "def drop_table_sql(name)\n \"DROP TABLE #{quote_schema_table(name)}\"\n end", "def destroy\n dbf.destroy\n rescue MissingSource\n ensure\n freeze\n end", "def drop_table_sql(name)\n \"DROP TABLE #{quote_identifier(name)}\"\n end", "def clear\n @table.clear\n end", "def delete_buttons\n @db.execute(\"DROP TABLE Buttons\")\n end", "def delete\n ensure_service!\n service.delete_table instance_id, name\n true\n end", "def destroy_schema\n Apartment::Tenant.drop tenant\n end", "def destroy_schema\n Apartment::Tenant.drop tenant\n end", "def destroy\n DB.execute <<SQL\nDELETE FROM #{self.class.table}\nWHERE id = #{@hash['id']}\nSQL\n end", "def drop_table(*names)\n names.each {|n| execute(drop_table_sql(n))}\n end", "def down\n drop_table TABLE_NAME\n end", "def delete_all(table)\n\t\t\t\ttable.clear\n\t\t\tend", "def down\n execute <<-SQL\n DROP TABLE event_registrations;\n SQL\n\n execute <<-SQL\n DROP TABLE members;\n SQL\n\n execute <<-SQL\n DROP TABLE events;\n SQL\n\n execute <<-SQL\n DROP TABLE treatment_logs;\n SQL\n\n execute <<-SQL\n DROP TABLE feeding_logs;\n SQL\n\n execute <<-SQL\n DROP TABLE employees;\n SQL\n\n execute <<-SQL\n DROP TABLE animals;\n SQL\n\n execute <<-SQL\n DROP TABLE tanks;\n SQL\n\n execute <<-SQL\n DROP TABLE habitats;\n SQL\n end", "def clear_table_cache!(table_name)\n @columns.delete table_name\n @columns_hash.delete table_name\n @primary_keys.delete table_name\n @tables.delete table_name\n end", "def destroy_database_directory\n FileUtils.remove_dir(database_directory)\n end", "def drop_table(table_name, options = {})\n table_name, options = extract_table_options(table_name, options)\n super(table_name, **options)\n end", "def destroy_model_storage(repository, model)\n if ENV['destroy']!=nil && ENV['destroy']=='true'\n sdb.delete_domain(@uri[:domain])\n end\n end", "def test_drop_table_if_exists\n connection.create_table(:testings)\n assert connection.table_exists?(:testings)\n connection.drop_table(:testings, if_exists: true)\n assert_not connection.table_exists?(:testings)\n end", "def drop_translated_table\n self.connection.drop_table translation_table_name\n end", "def delete_table(db)\n\tputs ('Are you sure you want to wipe the table? (y/n)')\n\tif gets.chomp == 'y'\n\t\tdb.execute(\"DELETE FROM todo\")\n\t\tdb.execute(\"DELETE FROM log\") \n\tend\nend", "def delete_all\n begin\n db.execute \"TRUNCATE TABLE #{table}\"\n\n rescue SQLite3::Exception => e\n puts \"Database Exception occured\"\n puts e\n \n ensure\n db.close if db\n end\n end" ]
[ "0.7861428", "0.75350136", "0.7481387", "0.7394846", "0.7380593", "0.7354598", "0.7313839", "0.7272783", "0.7263349", "0.7079708", "0.7041613", "0.6985817", "0.6972179", "0.6960047", "0.69326204", "0.6920041", "0.68648213", "0.68438196", "0.68410397", "0.6819557", "0.6815129", "0.6793946", "0.6774884", "0.67673814", "0.6717781", "0.670894", "0.6690482", "0.6690264", "0.6672362", "0.66712815", "0.666952", "0.6602665", "0.6586625", "0.6548773", "0.65227574", "0.6482471", "0.6469788", "0.64372176", "0.6413778", "0.6410491", "0.64087653", "0.63962954", "0.63664806", "0.6351986", "0.634711", "0.6337047", "0.631744", "0.631117", "0.62972724", "0.62852895", "0.62837446", "0.6273395", "0.6270475", "0.62606996", "0.6242531", "0.6242531", "0.62409765", "0.62402195", "0.62161535", "0.621282", "0.62079394", "0.620367", "0.62025124", "0.6201265", "0.6192181", "0.6192181", "0.61900544", "0.6181226", "0.6175794", "0.61633253", "0.6156938", "0.61549133", "0.6152797", "0.614909", "0.6143574", "0.6139166", "0.6132516", "0.61301506", "0.612993", "0.6129122", "0.6124648", "0.6123508", "0.61180556", "0.6102844", "0.61011875", "0.6100807", "0.6094065", "0.6094065", "0.6087527", "0.60784537", "0.6061935", "0.60587305", "0.60401785", "0.6015723", "0.601569", "0.60112554", "0.6001522", "0.59932816", "0.59868795", "0.598113", "0.59799796" ]
0.0
-1
Get foreign key names that are excluded.
def excluded_foreign_key_names excluded_dimension_relations = prejoined_fields.keys.collect {|k| dimension_relationships[k]} excluded_dimension_relations.collect {|r| r.foreign_key} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def foreign_key_fields\n keys = []\n database_field_names.each do |param|\n if self.send(param).is_a? ForeignKey\n keys << param\n end\n end\n keys\n end", "def non_foreign_key_fields\n self.database_field_names - self.foreign_key_fields\n end", "def foreign_keys\n vals = []\n foreign_key_fields.each do |field|\n vals << self.send(field)\n end\n vals\n end", "def flexi_fields_except_fk\n _field_names = self.associations.values.flatten.map { |_v| :\"#{_v.to_s.singularize}_id\" }\n if none_flexi_fields.present?\n none_flexi_fields.each do |field|\n ['file_name', 'content_type', 'file_size', 'updated_at'].each do |_suffix|\n _field_names << :\"#{field.name.to_s}_#{_suffix}\"\n end\n end\n end\n self.flexi_fields.select { |_f| !_field_names.include?(_f.name.to_sym) }\n end", "def foreign_keys\n @foreign_keys ||= connection.foreign_keys(table_name, \"#{name} Foreign Keys\")\n end", "def exclude\n [exceptions, self.class.exclude_always, foreign_key, polymorphic_type].flatten.uniq\n end", "def remove_table_not_exist_foreign_keys\n @foreign_keys.each do |table, foreign_keys|\n foreign_keys.delete_if do |key|\n if key.is_a?(String) && key =~ /_id$/\n class_name = Prepares.model_associations.get_association_class_name(table, key[0..-4])\n class_name ? !@table_nodes[class_name.gsub('::', '').tableize] : !@table_nodes[key[0..-4].pluralize]\n end\n end\n end\n end", "def relation_names(inclusions)\n inclusions.is_a?(Hash) ? inclusions.keys : Array.wrap(inclusions)\n end", "def foreign_keys(table_name)\n stmt = @connection.foreign_keys(native_case(table_name.to_s))\n result = stmt.fetch_all || []\n stmt.drop unless stmt.nil?\n\n result.map do |key|\n fk_from_table = key[2] # PKTABLE_NAME\n fk_to_table = key[6] # FKTABLE_NAME\n\n ActiveRecord::ConnectionAdapters::ForeignKeyDefinition.new(\n fk_from_table,\n fk_to_table,\n name: key[11], # FK_NAME\n column: key[3], # PKCOLUMN_NAME\n primary_key: key[7], # FKCOLUMN_NAME\n on_delete: key[10], # DELETE_RULE\n on_update: key[9] # UPDATE_RULE\n )\n end\n end", "def dump_table_foreign_keys(table, options=OPTS)\n if supports_foreign_key_parsing?\n fks = foreign_key_list(table, options).sort_by{|fk| fk[:columns]}\n end\n\n if fks.nil? || fks.empty?\n ''\n else\n dump_add_fk_constraints(table, fks)\n end\n end", "def scaf_foreign_keys\n scaf_belongs_tos.collect(&:primary_key_name)\n end", "def foreign_key_list(table, opts=OPTS)\n super\n rescue Sequel::DatabaseError => e\n raise unless foreign_key_error?(e)\n []\n end", "def foreign_keys_from_associations(fields = association_fields)\n fields.each_with_object([]) do |(_field_name, metadata), keys|\n keys << metadata[:foreign_key] if metadata[:foreign_key]\n keys << metadata[:polymorphic_type] if metadata[:polymorphic_type]\n keys\n end\n end", "def foreign_keys_from_associations(fields = association_fields)\n fields.each_with_object([]) do |(_field_name, metadata), keys|\n keys << metadata[:foreign_key] if metadata[:foreign_key]\n keys << metadata[:polymorphic_type] if metadata[:polymorphic_type]\n keys\n end\n end", "def to_sql_with_foreign_keys\n from_table = AirBlade::Migrations::SchemaStatements.table_name\n fks = @@foreign_keys.map{ |column, options| foreign_key_constraint from_table, column, options }\n [ to_sql_without_foreign_keys, fks ].reject{ |x| x.blank? }.join ', '\n end", "def foreigns\n []\n end", "def remove_only_type_foreign_keys\n @foreign_keys.each do |_table, foreign_keys|\n foreign_keys.delete_if { |key| key.is_a?(String) && key =~ /_type$/ }\n end\n end", "def foreign_key_choices\n choices = []\n foreign_keys.each do |foreign_key|\n choices << foreign_key.all_from_class\n end\n choices\n end", "def excluded_keys\n @excluded_keys ||= begin\n ret = self.options[:except] || []\n ret.map(&:to_sym)\n end\n end", "def remove_only_type_foreign_keys\n @foreign_keys.each { |table, foreign_keys|\n foreign_keys.delete_if { |key| key =~ /_type$/ }\n }\n end", "def non_foreign_key_values\n vals = []\n non_foreign_key_fields.each do |field|\n vals << self.send(field)\n end\n vals\n end", "def reverse_foreign_keys\n connection.reverse_foreign_keys(table_name, \"#{name} Reverse Foreign Keys\")\n end", "def association_foreign_keys(assoc_record)\n association_foreign_keys_names.map { |name| assoc_record.public_send(name) }\n end", "def associations_foreigns\n _reflections.map do |_, reflection|\n cols = [reflection.foreign_key]\n cols << reflection.foreign_type if reflection.polymorphic?\n cols\n end.flatten\n end", "def excluded_tables\n tables = []\n if group_name\n g = group(group_name)\n tables += (g['exclude_tables'] || [])\n end\n tables -= table_names\n tables\n end", "def foreign_key_list(table, opts=OPTS)\n m = output_identifier_meth\n fks = ado_schema_foreign_keys(table).inject({}) do |memo, fk|\n name = m.call(fk['FK_NAME'])\n specs = memo[name] ||= {\n :columns => [],\n :table => m.call(fk['PK_TABLE_NAME']),\n :key => [],\n :deferrable => fk['DEFERRABILITY'],\n :name => name,\n :on_delete => fk['DELETE_RULE'],\n :on_update => fk['UPDATE_RULE']\n }\n specs[:columns] << m.call(fk['FK_COLUMN_NAME'])\n specs[:key] << m.call(fk['PK_COLUMN_NAME'])\n memo\n end\n fks.values\n end", "def non_relationship_fields\n self.fields.select { |field| !field.is_relationship? }\n end", "def _foreign_key_list_ds\n @_foreign_key_list_ds ||= __foreign_key_list_ds(false)\n end", "def exceptions\n association.options[:except].to_a.collect(&:to_s)\n end", "def ignore_dependency(*args)\n raise 'Cannot ignore dependencies without loading.' unless @dump\n\n args.each do |name|\n dependency = @dependencies.find { |d| d.name == name }\n dependency.ignore\n ignore_columns dependency.foreign_key, dependency.foreign_type\n end\n end", "def required_nonpath_params\n self.associations.reject { |k,v| v[:type] != :belongs_to }.keys.reject {|x| self.resource_tuple.map { |y| y.to_s.singularize }.member?(x) }\n end", "def foreign_keys(table_name, stream)\n if (foreign_keys = @connection.foreign_keys(table_name)).any?\n add_foreign_key_statements = foreign_keys.map do |foreign_key|\n options = foreign_key.options\n table_from_key = foreign_key.to_table\n statement_parts = [ ('add_foreign_key ' + foreign_key.from_table.inspect) ]\n statement_parts << table_from_key.inspect\n statement_parts << (':name => ' + options[:name].inspect)\n\n column_from_options = options[:column]\n primary_key_from_options = options[:primary_key]\n dependent_from_options = options[:dependent]\n\n if column_from_options != \"#{table_from_key.singularize}_id\"\n statement_parts << (\":column => #{column_from_options.inspect}\")\n end\n if primary_key_from_options != 'id'\n statement_parts << (\":primary_key => #{primary_key_from_options.inspect}\")\n end\n if dependent_from_options.present?\n statement_parts << (\":dependent => #{dependent_from_options.inspect}\")\n end\n\n # Always exclude the index\n # If an index was created in a migration, it will get dumped to the schema\n # separately from the foreign key. This will raise an exception if\n # add_foreign_key is run without :exclude_index => true.\n statement_parts << (':exclude_index => true')\n\n ' ' + statement_parts.join(', ')\n end\n\n stream.puts add_foreign_key_statements.sort.join(\"\\n\")\n stream.puts\n end\n end", "def find_relations\n sql = <<-eos\n SELECT\n tc.constraint_name, tc.table_name, kcu.column_name,\n ccu.table_name AS foreign_table_name,\n ccu.column_name AS foreign_column_name\n FROM\n information_schema.table_constraints AS tc\n JOIN information_schema.key_column_usage AS kcu ON tc.constraint_name = kcu.constraint_name\n JOIN information_schema.constraint_column_usage AS ccu ON ccu.constraint_name = tc.constraint_name\n WHERE constraint_type = 'FOREIGN KEY'\n eos\n @relations = @connection.exec(sql).values\n end", "def exclude_from_model\n []\n end", "def _reverse_foreign_key_list_ds\n @_reverse_foreign_key_list_ds ||= __foreign_key_list_ds(true)\n end", "def get_all_child_collections_names()\r\n #Remember there are fields begininf with \"<\" which has to be excluded\r\n names = @db_interface.get_all_hash_fields(@certain_coll_key)\r\n names ||= []\r\n return names\r\n end", "def hash_fk_model\n foreign_keys = {}\n @model_class.reflect_on_all_associations(:belongs_to).map{ |r|\n foreign_keys[r.association_foreign_key.to_sym] = r.name\n }\n foreign_keys\n end", "def check_exclude_fields\n=begin\n [:for_index, :for_new, :for_edit, :for_show].each do |key|\n exc= exclude_fields.send(key)\n next if exc # Leave user options if given.\n \n # By default, the foreign key of the parents are assigned on nested resources,\n # so i remove the from the default columns of new\n exclude_fields.send(\"#{key}=\", parent_ids) if key == :for_new && !parent_ids.empty?\n end\n=end\n # Because a single resource can have multiple resource parents,\n # this check is going to be done on \"runtime\" (ie remove the field for the \n # current parent, not all parents' fields)\n end", "def ignored_associations\n %w().freeze\n end", "def excluded\n @excluded_projects.keys\n end", "def hidden\n context.hidden.map(&:name)\n end", "def foreign_key_name(class_name)\n Inflector.foreign_key(class_name).to_sym\n end", "def dependents_exclude_self\n dependents.where.not(id: id)\n end", "def blacklist_keys\n @blacklist_keys ||= to_adapter.column_names.map(&:to_s) - accessible_attributes.to_a.map(&:to_s)\n end", "def association_names\n self.class._associations.keys\n end", "def foreign_key_suffix\n \"_id\"\n end", "def foreign_key_list(table, opts=OPTS)\n m = output_identifier_meth\n schema, _ = opts.fetch(:schema, schema_and_table(table))\n\n h = {}\n fklod_map = FOREIGN_KEY_LIST_ON_DELETE_MAP \n reverse = opts[:reverse]\n\n (reverse ? _reverse_foreign_key_list_ds : _foreign_key_list_ds).where_each(Sequel[:cl][:oid]=>regclass_oid(table)) do |row|\n if reverse\n key = [row[:schema], row[:table], row[:name]]\n else\n key = row[:name]\n end\n\n if r = h[key]\n r[:columns] << m.call(row[:column])\n r[:key] << m.call(row[:refcolumn])\n else\n entry = h[key] = {\n :name=>m.call(row[:name]),\n :columns=>[m.call(row[:column])],\n :key=>[m.call(row[:refcolumn])],\n :on_update=>fklod_map[row[:on_update]],\n :on_delete=>fklod_map[row[:on_delete]],\n :deferrable=>row[:deferrable],\n :table=>schema ? SQL::QualifiedIdentifier.new(m.call(row[:schema]), m.call(row[:table])) : m.call(row[:table]),\n }\n\n unless schema\n # If not combining schema information into the :table entry\n # include it as a separate entry.\n entry[:schema] = m.call(row[:schema])\n end\n end\n end\n\n h.values\n end", "def table_names\n @table_names ||= ActiveRecord::Base.connection.tables - excluded_table_names\n end", "def fk_suffix\n @opts[:foreign_key][:suffix]\n end", "def datatable_exclude_fields\n # None\n []\n end", "def foreign_key_column_name\n @foreign_key_column_name ||= begin\n out = options[:foreign_key]\n\n unless out\n out = \"#{@model_class.name.underscore}_#{association_name}\"\n out = $1 if out =~ %r{/([^/]+)$}i\n out = out + \"_id\"\n end\n\n out = out.to_s if out.kind_of?(Symbol)\n\n out\n end\n end", "def model_association_names\n return unless model_associations\n\n model_associations.map do |assoc|\n assoc.name.to_sym\n end\n end", "def dependees_for(dependent)\n recursive_ancestors_for(dependent, :dependent, :keys)\n end", "def inverse_foreign_key\n if @options.key?(:inverse_foreign_key)\n @options[:inverse_foreign_key]\n elsif @options.key?(:inverse_of)\n inverse_of ? \"#{inverse_of.to_s.singularize}#{FOREIGN_KEY_SUFFIX}\" : nil\n elsif inv = inverse_association&.foreign_key\n inv\n else\n \"#{inverse_class_name.demodulize.underscore}#{FOREIGN_KEY_SUFFIX}\"\n end\n end", "def unreferenced_elements\n model\n .elements\n .select { |el| el.references.none?(&ref_is_relationship_or_diagram) }\n end", "def resource_relations_names\n resource_handler.resource_relations.collect { |_k, v| v[:name].to_sym }\n end", "def database_field_names\n attributes = instance_variables.collect{|a| a.to_s.gsub(/@/,'')}\n delete_from_array(attributes, attributes_that_should_not_be_in_database_field_names)\n attributes\n end", "def quote_constraint_name(foreign_key)\n quote_table_name(foreign_key)\n end", "def dependency_backward_names\n names = []\n each_backward_dependency do |task|\n names << task.to_s\n end\n names.sort\n end", "def reflection_to_foreign_keys!( reflection, foreign_key_list )\n reflection_to_foreign_keys( reflection ).each do |foreign_key|\n #skip if already in this list or the fk has already been uped in the db\n next if includes_foreign_key?( foreign_key, foreign_key_list ) ||\n existing_foreign_key?( foreign_key )\n foreign_key_list << foreign_key\n end\n end", "def columns_without_id\n singular_table_name.classify.constantize.columns.select{ |c| c.name != 'id' }\n end", "def foreign_key_name(table_name, columns)\n keys = foreign_key_list(table_name).select{|key| key[:columns] == columns}\n raise(Error, \"#{keys.empty? ? 'Missing' : 'Ambiguous'} foreign key for #{columns.inspect}\") unless keys.size == 1\n keys.first[:name]\n end", "def retrieve_models_exclude(env)\n env['MODELS_EXCLUDE'].to_s\n .split(',')\n .collect { |x| x.strip.underscore.singularize.camelize.constantize }\n end", "def foreign_key_present?\n false\n end", "def foreign_key_present?\n false\n end", "def foreign_properties\n to_h.slice(*foreign_keys + foreign_objects)\n end", "def dump_add_fk_constraints(table, fks)\n sfks = String.new\n sfks << \"alter_table(#{table.inspect}) do\\n\"\n sfks << create_table_generator do\n fks.sort_by{|fk| fk[:columns]}.each do |fk|\n foreign_key fk[:columns], fk\n end\n end.dump_constraints.gsub(/^foreign_key /, ' add_foreign_key ')\n sfks << \"\\nend\"\n end", "def record_foreign_keys(parent_record)\n association_foreign_keys(parent_record)\n end", "def foreign_key\n @foreign_key ||= (@options[:foreign_key] || \"#{@name}_id\").to_s\n end", "def excluded_models; %w[Tenant] end", "def required_attribute_names\n removed_attributes.each_with_object([]) do |attribute, names|\n names << attribute.name if attribute.required?\n end\n end", "def column_names_to_skip\n @column_names_to_skip ||= begin\n primary_keys = [ ]\n primary_keys += Array(@low_card_model.primary_keys || [ ]) if @low_card_model.respond_to?(:primary_keys)\n primary_keys += Array(@low_card_model.primary_key || [ ]) if @low_card_model.respond_to?(:primary_key)\n\n out = (primary_keys +\n COLUMN_NAMES_TO_ALWAYS_SKIP +\n Array(@low_card_model.low_card_options[:exclude_column_names] || [ ]))\n\n out.map { |n| n.to_s.strip.downcase }.compact.uniq\n end\n end", "def hiddens\n @hiddens ||= fields.select { |f| f.class == Hidden }\n end", "def serializable_attribute_names\n attribute_names = @record.attribute_names\n\n if options[:only]\n options.delete(:except)\n attribute_names = attribute_names & Array(options[:only]).collect { |n| n.to_s }\n else\n options[:except] = Array(options[:except]) | Array(@record.class.inheritance_column)\n attribute_names = attribute_names - options[:except].collect { |n| n.to_s }\n end\n\n attribute_names\n end", "def serializable_attribute_names\n attribute_names = @record.attribute_names\n\n if options[:only]\n options.delete(:except)\n attribute_names = attribute_names & Array(options[:only]).collect { |n| n.to_s }\n else\n options[:except] = Array(options[:except]) | Array(@record.class.inheritance_column)\n attribute_names = attribute_names - options[:except].collect { |n| n.to_s }\n end\n\n attribute_names\n end", "def tables\n connection.list_tables.select { |table| !exclude?(table) }\n end", "def dump_foreign_key_migration(options=OPTS)\n ts = _dump_tables(options)\n <<END_MIG\nSequel.migration do\n change do\n#{ts.map{|t| dump_table_foreign_keys(t)}.reject{|x| x == ''}.join(\"\\n\\n\").gsub(/^/, ' ')}\n end\nend\nEND_MIG\n end", "def field_names(include_hidden = false)\n # collect field names\n names = []\n hidden = no_eval_param(:hide)\n @field_names.each do |name|\n if include_hidden or not hidden.include?(name)\n names << name\n end\n end\n names\n end", "def denormalized_attribute_names\n @denormalized_attribute_names ||= (self.column_names.select { |attribute_name| self.denormalized_attribute?(attribute_name) } rescue [])\n end", "def excluded_tag_names\n parsed_excluded_tags[:missing]\n end", "def supports_foreign_keys?\n false\n end", "def supports_foreign_keys?\n false\n end", "def attachment_reference_ids_removed\n attachment_reference_ids = []\n self.class.attachable_columns.each do |column|\n attachment_reference_ids += send(\"#{column}#{ATTACHMENT_REMOVED_SUFFIX}\")\n end\n\n attachment_reference_ids\n end", "def ignore_associations(*associations)\n ignored_associations.concat associations.flatten.compact.collect(&:to_sym)\n ignored_associations.uniq!\n end", "def attributes_that_should_not_be_in_database_field_names\n [\"id\", \"errors\"]\n end", "def foreign_key_constraints_enabled?\n @disable_foreign_key_constraints != true\n end", "def keys\n fields.map { |f| f.name }\n end", "def field_names\n @_field_path.map{ |field_| field_.name }\n end", "def excluded_trackers\n Tracker.select(:id)\n .where(\n \"#{Tracker.table_name}.id IN (?) OR #{Tracker.table_name}.fields_bits & ?\",\n RedmineWbs.excluded_tracker_ids,\n RedmineWbs.required_core_field_bits\n )\n end", "def import_foreign_keys( table )\n for opts in db.foreign_key_list( table.name )\n opts = opts.dup\n name = opts.delete( :name )\n columns = opts.delete( :columns )\n table_name = opts.delete( :table )\n opts.delete( :deferrable ) unless opts[ :deferrable ]\n table.add_foreign_key( columns, table_name, opts )\n end\n end", "def except(attributes_to_exclude)\n attributes_to_exclude = [attributes_to_exclude] unless attributes_to_exclude.kind_of? Array\n attributes_to_exclude.map! { |a| a.to_s.singularize }\n attributes.select { |a| !attributes_to_exclude.include?(a.id) }\n end", "def excluded\n @ancestors - @picked\n end", "def foreign_key(class_name, key = \"id\")\n underscore(demodulize(class_name.to_s)) << \"_\" << key.to_s\n end", "def constraint_name(table, field)\n \"fk_#{table}_#{field_list_name(field)}\"\n end", "def active_dependents_exclude_self\n active_dependents.where.not(id: id)\n end", "def inherited_fields\n return [] unless has_parent?\n\n names = parent.fields.keys - fields.keys\n names.concat(parent.aliases.reject { |k,v| !parent.has_field?(v) }.keys)\n names.sort!\n\n names\n end", "def foreign_key\n association ? association.foreign_key : name\n end", "def scaffold_foreign_key(reflection)\n get_key_array_safe(reflection.child_key).name\n end", "def foreign_key(class_name, separate_class_name_and_id_with_underscore = true)\n Geode::FastInflector.foreign_key(class_name, separate_class_name_and_id_with_underscore)\n end", "def related_names_in_use\n @in_use.map { |n| /\\A#{normalised_name}_(\\d+)\\z/.match(n) }.compact\n end" ]
[ "0.6926847", "0.6741855", "0.67373955", "0.65991753", "0.64413625", "0.63550436", "0.62120456", "0.61069524", "0.60865986", "0.60457295", "0.6005258", "0.5979622", "0.59685093", "0.59685093", "0.5932059", "0.59176356", "0.59096026", "0.59076685", "0.58819073", "0.5847478", "0.5847115", "0.5838848", "0.58335435", "0.5808344", "0.5805046", "0.57438314", "0.57393694", "0.56982285", "0.5686852", "0.5672967", "0.5662574", "0.55250305", "0.5474742", "0.54687464", "0.5463527", "0.54552805", "0.5450272", "0.5442695", "0.5424795", "0.53992385", "0.53635764", "0.53599215", "0.5350175", "0.5344658", "0.5342038", "0.53360826", "0.533018", "0.5324794", "0.5299179", "0.52989787", "0.52970016", "0.5295921", "0.5289576", "0.5275825", "0.52755105", "0.5273805", "0.52614975", "0.52354187", "0.5234376", "0.5201567", "0.5197002", "0.51869464", "0.5179617", "0.51757747", "0.51757747", "0.51736796", "0.5151573", "0.51286966", "0.51109743", "0.51028067", "0.5095004", "0.50928044", "0.5089251", "0.5081283", "0.5081283", "0.50774777", "0.5075383", "0.50652796", "0.50630474", "0.50611305", "0.5037885", "0.5037885", "0.5034075", "0.5004844", "0.50034624", "0.49967358", "0.49945712", "0.49906164", "0.4989275", "0.49747178", "0.4967604", "0.495452", "0.49473992", "0.49457452", "0.49328285", "0.49218735", "0.4919398", "0.49184024", "0.4899294", "0.489416" ]
0.863032
0
Construct the prejoined fact table.
def create_prejoined_fact_table(options={}) connection.transaction { drop_prejoin_fact_table connection.create_table(prejoined_table_name, :id => false) do |t| # get all columns except the foreign_key columns for prejoined dimensions columns.each do |c| t.column(c.name, c.type) unless excluded_foreign_key_names.include?(c.name) end #prejoined_columns prejoined_fields.each_pair do |key, value| dclass = dimension_class(key) dclass.columns.each do |c| t.column(c.name, c.type) if value.include?(c.name.to_sym) end end end } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate_prejoined_fact_table(options={})\r\n fact_columns_string = columns.collect {|c|\r\n \"#{table_name}.\" + c.name unless excluded_foreign_key_names.include?(c.name)\r\n }.compact.join(\",\\n\") \r\n \r\n prejoined_columns = []\r\n \r\n tables_and_joins = \"#{table_name}\"\r\n \r\n prejoined_fields.each_pair do |key, value|\r\n dimension = dimension_class(key)\r\n tables_and_joins += \"\\nJOIN #{dimension.table_name} as #{key}\"\r\n tables_and_joins += \"\\n ON #{table_name}.#{dimension_relationships[key].foreign_key} = \"\r\n tables_and_joins += \"#{key}.#{dimension.primary_key}\"\r\n prejoined_columns << value.collect {|v| \"#{key}.\" + v.to_s}\r\n end\r\n\r\n if connection.support_select_into_table?\r\n drop_prejoin_fact_table\r\n sql = <<-SQL\r\n SELECT #{fact_columns_string}, \r\n #{prejoined_columns.join(\",\\n\")}\r\n FROM #{tables_and_joins}\r\n SQL\r\n sql = connection.add_select_into_table(prejoined_table_name, sql)\r\n else\r\n create_prejoined_fact_table(options)\r\n sql = <<-SQL\r\n INSERT INTO #{prejoined_table_name}\r\n SELECT #{fact_columns_string}, \r\n #{prejoined_columns.join(\",\\n\")}\r\n FROM #{tables_and_joins}\r\n SQL\r\n end\r\n connection.transaction { connection.execute(sql) } \r\n end", "def populate(options={})\r\n populate_prejoined_fact_table(options)\r\n end", "def drop_prejoin_fact_table\r\n connection.drop_table(prejoined_table_name) if connection.tables.include?(prejoined_table_name)\r\n end", "def tables_and_joins\n sql = \"#{fact_class.table_name}\"\n cube_class.dimensions_hierarchies.each do |dimension_name, hierarchy_name|\n dimension_table_name = fact_class.dimension_class(dimension_name).table_name\n sql += \" LEFT JOIN #{dimension_table_name} as #{dimension_name}\"\n sql += \" ON #{fact_class.table_name}.\"\n sql += \"#{fact_class.dimension_relationships[dimension_name].foreign_key}\"\n sql += \" = #{dimension_name}.id\\n\"\n end\n sql\n end", "def make\n if dimension?\n dimension_key_builder\n elsif fact?\n FactKeyBuilder.new(staging_db[table.table_name])\n end\n end", "def create_pruned_table(conn)\n if !conn.list_tables.include?('pruned')\n query = \"CREATE TABLE `pruned` ( `table_name` VARCHAR(64) NOT NULL PRIMARY KEY, `prune_time` DATETIME NOT NULL )\"\n if @dry_run\n verbose query\n else\n conn.query query\n end\n end\n end", "def create_lookup_table\n File.open(source).each_with_index do |line|\n next if line.chomp.empty?\n\n values = unstring(line).chomp.split(';')\n\n next if values.empty?\n\n @joiners.each do |joiner|\n key = values[joiner.join[0]]\n joiner.lookup[:rows][key] = []\n\n joiner.cols.each do |i|\n joiner.lookup[:rows][key] << values[i]\n end\n end\n\n end\n end", "def initialize_table; end", "def initialize_table\n @total_rows.times do |row|\n row_array = Array.new(@total_columns, \"\")\n @reconstructed_table.push(row_array)\n end\n end", "def rebuild(table); end", "def initialize(associations)\n @left_joins_by_alias = {}\n last_table_alias = nil\n associations.each_with_index do |association, association_path_index|\n # Important, this variable will take the last joined table to chain the join, in the first loop, will take\n # the association origin table name.\n last_table_alias ||= association.active_record.table_name\n left_join = Babik::QuerySet::Join.new_from_association(association, association_path_index, last_table_alias)\n\n @left_joins_by_alias[left_join.target_alias] = left_join\n last_table_alias = left_join.target_alias\n end\n @target_alias = last_table_alias\n end", "def build_fact(name, options={})\n options[:rows] ||= 100\n options[:generators] ||= {}\n options[:fk_limit] ||= {}\n rows = []\n\n fact_class = Fact.to_fact(name)\n options[:rows].times do\n row = {}\n fact_class.content_columns.each do |column|\n generator = (options[:generators][column.klass] || @generators[column.klass])\n row[column.name] = generator.generate(column, options)\n end\n fact_class.dimension_relationships.each do |name, reflection|\n # it would be better to get a count of rows from the dimension tables\n fk_limit = (options[:fk_limit][reflection.foreign_key] ||\n options[:dimensions] || 100) - 1\n row[reflection.foreign_key] = rand(fk_limit) + 1\n end\n rows << row\n end\n\n rows\n end", "def summarize_per_relation(generator)\n @from = \"#{generator.to_subquery} AS #{visit_identifier(generator.name)} NATURAL LEFT JOIN #{@from}\"\n end", "def create_table_joins(klass)\n if join_tables = klass.ann(:self, :join_tables)\n for info in join_tables\n begin\n # UGGLY hack!\n key_type = klass.ann(:oid, :sql).split(\" \").first\n create_join_table_sql(info, key_type).each do |sql|\n exec(sql, false)\n end\n debug \"Created join table '#{info[:table]}'.\" if $DBG\n rescue Object => ex\n if table_already_exists_exception? ex\n debug \"Join table already exists\" if $DBG\n else\n raise\n end\n end\n end\n end\n end", "def do_table\n @table = Hash.new { |h,k| h[k] = Hash.new }\n\n @grammar.productions.each do |lhs, prods|\n prods.each do |prod|\n if prod.rhs.size > 0\n i = 0\n sub_first = @grammar.first_set(prod.rhs[0])\n while sub_first.include?(Grammar::EPSILON)\n sub_first -= [Grammar::EPSILON]\n i += 1\n sub_first += @grammar.first_set(prod.rhs[i])\n end\n\n sub_first.each { |sym| table[lhs][sym] = prod }\n\n else\n @grammar.follow_set(lhs).each { |sym| table[lhs][sym] = prod }\n end\n end\n end\n end", "def build_query_parts\n # Always include the following columns:\n select_clause = ['DISTINCT(Person.' + _(:id, :person) + ') as person_id'] # person id\n select_clause += ['Person.' + _(:first_name, :person) + ' as First_Name'] # first name\n select_clause += ['Person.' + _(:last_name, :person) + ' as Last_Name'] # last name\n \n # Always include the person table\n tables = ['Person']\n tables_clause = Person.table_name + ' as Person'\n # Always include the campus involvements table\n tables << 'CampusInvolvement'\n tables_clause += \" LEFT JOIN #{CampusInvolvement.table_name} as CampusInvolvement on Person.#{_(:id, :person)} = CampusInvolvement.#{_(:person_id, :campus_involvement)} AND CampusInvolvement.end_date IS NULL\"\n # Always include the ministry involvements table\n tables << 'MinistryInvolvement'\n tables_clause += \" LEFT JOIN #{MinistryInvolvement.table_name} as MinistryInvolvement on Person.#{_(:id, :person)} = MinistryInvolvement.#{_(:person_id, :ministry_involvement)} AND MinistryInvolvement.end_date IS NULL\"\n # Always include the current address\n tables << 'CurrentAddress'\n tables_clause += \" LEFT JOIN #{CurrentAddress.table_name} as CurrentAddress on Person.#{_(:id, :person)} = CurrentAddress.#{_(:person_id, :address)} AND #{_(:address_type, :address)} = 'current'\"\n # Hooks to support different schemas\n tables += build_query_parts_custom_tables if self.respond_to?(:build_query_parts_custom_tables)\n tables_clause += build_query_parts_custom_tables_clause if self.respond_to?(:build_query_parts_custom_tables_clause)\n\n columns.each do |column|\n raise inspect if column.nil? # If something goes wrong, we want good information\n # Add table to table clause\n table_name = column.from_clause.constantize.table_name if column.from_clause.present?\n unless !column.from_clause.present? || tables.include?(column.from_clause)\n tables << column.from_clause\n source_model = (column.source_model.to_s.empty? ? 'Person' : column.source_model).constantize\n source_column = column.source_column.to_s.empty? ? 'id' : column.source_column\n foreign_key = column.foreign_key.to_s.empty? ? 'person_id' : column.foreign_key\n source_table_name = source_model.table_name\n join_on_left = \"#{source_model}.#{_(source_column.to_sym, source_model.name.downcase.to_sym)}\"\n join_on_right = \"#{column.from_clause}.#{_(foreign_key.to_sym, column.from_clause.underscore.to_sym)}\"\n tables_clause += \" LEFT JOIN #{table_name} as #{column.from_clause} on #{join_on_left} = #{join_on_right}\"\n tables_clause += \" AND \" + column.join_clause unless column.join_clause.blank?\n end\n \n # Don't add id, first name or last name here because we added them earlier\n unless ['id','first_name','last_name'].include?(column.select_clause)\n # Add column to select clause\n unless column.select_clause.first == '('\n select_clause << \"#{column.from_clause}.#{_(column.select_clause, column.from_clause.underscore)} as #{column.safe_name}\"\n else\n select_clause << \"#{column.select_clause} as #{column.safe_name}\"\n end\n end\n end\n self.select_clause = select_clause.join(', ')\n self.tables_clause = tables_clause\n return tables\n end", "def preload_associations(associations)\n associations.reduce(dup) do |table, association|\n primary_key = association.association_primary_key\n foreign_key = association.foreign_key\n name = association.name.to_s\n\n next table if !table.names.include?(foreign_key)\n\n ids = table[foreign_key].to_a.uniq.compact_blank\n records = association.klass.where(primary_key => ids).index_by(&primary_key.to_sym)\n\n table.rename({ foreign_key => name })\n table[name] = table[name].map { |id| records[id] }\n table\n end\n end", "def create_join_excluded_tbl(preserve_null_pk = true)\n if @excluded_join_tbl.nil?\n join_list =join_list()\n cross_join_from = ''\n full_join_from = ''\n satisfied_tbl = create_satisfied_tbl()\n 0.upto(join_list.count-1) do |i|\n join = join_list.find{|j| j['id'] ==i }\n l_rel_list = join['l_rel_list']\n quals = join['quals']\n q = ReverseParseTree.whereClauseConst(quals)\n has_quals = (not join['quals'].nil?)\n join_type = ReverseParseTree.joinTypeConvert(join['jointype'].to_s, has_quals)\n\n r_rel = join['r_rel_list'][0]\n l_arg = (i==0 ? \"#{l_rel_list[0].relname} #{l_rel_list[0].relalias}\" : \"\")\n # for efficiency only change the last join to cross join\n if i == join_list.count-1\n cross_join_from = cross_join_from + \"#{l_arg} CROSS JOIN #{r_rel.relname} #{r_rel.relalias} \"\n else\n cross_join_from = cross_join_from + \"#{l_arg} #{join_type} #{r_rel.relname} #{r_rel.relalias} on #{q} \"\n end\n # full_join_from = full_join_from + \"#{l_arg} CROSS JOIN #{r_rel.relname} #{r_rel.relalias} on #{q}\"\n end\n @excluded_join_tbl = \"#{@table}_join_excluded\"\n # renamed_pk_col = @pk_full_list.map { |pk| \"#{pk['col']} as #{pk['alias']}_pk\" }.join(', ')\n \n if preserve_null_pk\n renamed_pk_col = @pk_full_list.map { |pk| \"#{pk['col']} as #{pk['alias']}_pk\" }.join(', ')\n else\n renamed_pk_col = @pk_full_list.map do |pk|\n pkcol = @all_cols.find{|col| col.colname == pk['colname'] and col.relname==pk['relname']}\n \"COALESCE(#{pkcol.select_name},#{pkcol.null_replacement}) as #{pkcol.colalias}_pk\"\n end.join(',')\n end\n targetListReplacement = \"#{renamed_pk_col},#{@all_cols_select}\"\n query = ReverseParseTree.reverseAndreplace(@parseTree, targetListReplacement, '')\n old_from = from_query()\n # cross join\n all_cols_renamed()\n cross_join_query = query.gsub(/#{old_from}/i,cross_join_from)\n # pk_join_satisfied_tbl = @pk_full_list.map { |pk| \"t.#{pk['alias']}_pk = s.#{pk['alias']}_pk\" }.join(' AND ')\n # pk_not_in_satisfied_tbl = @pk_full_list.map { |pk| \"s.#{pk['alias']}_pk is null\" }.join(' OR ')\n\n create_tbl_query = \"select * from #{satisfied_tbl} where 1=2\"\n create_tbl_query = QueryBuilder.create_tbl(@excluded_join_tbl, '', create_tbl_query)\n DBConn.exec(create_tbl_query)\n # limit to 1000 rows due to resource limitation\n cross_join_query = \"with cross_join as (#{cross_join_query} limit 1000) INSERT INTO #{@excluded_join_tbl} select * from (select t.* from cross_join as t except select * from #{satisfied_tbl}) as tmp\"\n puts cross_join_query\n DBConn.exec(cross_join_query)\n\n # unless preserve_null_pk\n # pk = @pk_full_list.map { |pk| \"#{pk['alias']}_pk\" }.join(',')\n # DBConn.update_null_columns(@excluded_join_tbl,pk)\n # end\n # # full join\n # full_join_query = query.gsub(old_from,full_join_from)\n # full_join_query = \"(#{full_join_query} except select #{@all_cols_renamed} from #{satisfied_tbl})\"\n # full_join_query = \"INSERT INTO #{@excluded_tbl} #{full_join_query}\"\n # DBConn.exec(query)\n end\n return @excluded_join_tbl\n end", "def initialize_columns\n @columns = []\n valid_table = table.alias('valid_taxon_names')\n\n @columns.push({ header: 'ro', projected: rank_over(table, valid_table) })\n\n @columns.push({header: 'taxon_name_id', projected: table[:id].as('taxon_name_id') } )\n @columns.push({header: 'cached_valid_taxon_name_id', projected: table[:cached_valid_taxon_name_id].as('cached_valid_taxon_name_id') } )\n @columns.push({header: 'cached', projected: table[:cached].as('cached') } )\n @columns.push({header: 'cached_author_year', projected: table[:cached_author_year].as('cached_author_year') } )\n @columns.push({header: 'cached_is_valid', projected: table[:cached_is_valid].as('cached_is_valid') } )\n\n if fieldsets.include?('observations')\n @columns.push({header: 'otu_id', projected: otu_table[:id].as('otu_id') } )\n @columns.push({header: 'otu_name', projected: otu_table[:name].as('otu_name')} )\n end\n end", "def build_tables\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS breeds(\n id serial NOT NULL PRIMARY KEY,\n breed varchar(30),\n price integer\n )])\n\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS puppies(\n id serial NOT NULL PRIMARY KEY,\n breed varchar(30),\n name varchar(30),\n age integer,\n created_at timestamp NOT NULL DEFAULT current_timestamp\n )])\n\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS requests(\n id serial NOT NULL PRIMARY KEY,\n breed text,\n status text,\n created_at timestamp NOT NULL DEFAULT current_timestamp\n )])\n end", "def create_side_table\n RailsRedshiftReplicator.connection.exec \"CREATE TABLE #{temporary_table_name} (LIKE #{replication.target_table})\"\n end", "def build_table_header\n names = column_names(data)\n build_md_row(output, names)\n build_md_row(output, alignment_strings(names))\n end", "def fat_record_joins\n joins = \" LEFT JOIN active_sources AS obj_sources ON semantic_relations.object_id = obj_sources.id AND semantic_relations.object_type = 'TaliaCore::ActiveSource'\"\n joins << \" LEFT JOIN semantic_properties AS obj_props ON semantic_relations.object_id = obj_props.id AND semantic_relations.object_type = 'TaliaCore::SemanticProperty'\"\n joins << \" LEFT JOIN active_sources AS subject_sources ON semantic_relations.subject_id = subject_sources.id\"\n joins\n end", "def join_table_source\n cached_fetch(:join_table_source){split_join_table_alias[0]}\n end", "def initialize(table:, source_connection:)\n @table = table\n @table_name = table.target_table_name.downcase\n @optimised_for_table_name = ENV['POSTGRES_TO_REDSHIFT_OPTIMISED_FOR_TABLE']&.downcase&.strip || table_name\n @keys = Keys.new(source_connection: source_connection, tables: [table_name, optimised_for_table_name].uniq).all\n end", "def init_podunk_table(gsheet, opts={})\n opts[:connection] = self\n Table.new(gsheet.rows, opts)\n end", "def build_predecessors\n result = Hash.new { |h,k| h[k] = [] }\n @specs.each do |spec|\n\t@specs.each do |other|\n\t next if spec.full_name == other.full_name\n\t other.dependencies.each do |dep|\n\t if spec.satisfies_requirement?(dep)\n\t result[spec.full_name] << other\n\t end\n\t end\n\tend\n end\n result\n end", "def build_primer_table\n operations.map do |op|\n primer = op.output(\"Primer\").sample\n [primer.id.to_s + \" \" + primer.name, primer.properties[\"Overhang Sequence\"] + primer.properties[\"Anneal Sequence\"]]\n end\n end", "def initialize_copy(orig)\n super\n @__table__ = @__table__.dup\n end", "def start_table\r\n n = @char_set.length\r\n t_size = @size\r\n create_table(@char_set, '', n, t_size)\r\n end", "def before_load\n data_class.rebuild_table\n super\n end", "def setup_target_table\n self.target_table = source_table if target_table.blank?\n end", "def load_table_schema(conn, builder, table)\n builder.relvar(table){\n primary_key_columns = load_table_heading(conn, builder, table)\n load_table_constraints(conn, builder, table, primary_key_columns)\n }\n end", "def create_full_rst_tbl(preserve_null_pk = true)\n unless defined? @full_rst_tbl\n self.all_cols_select\n self.pk_full_list\n if preserve_null_pk\n renamed_pk_col = @pk_full_list.map { |pk| \"#{pk['col']} as #{pk['alias']}_pk\" }.join(', ')\n else\n renamed_pk_col = @pk_full_list.map do |pk|\n pkcol = @all_cols.find{|col| col.colname == pk['colname'] and col.relname==pk['relname']}\n \"COALESCE(#{pk['col']},#{pkcol.null_replacement}) as #{pk['alias']}_pk\"\n end.join(',')\n end\n targetListReplacement = \"#{renamed_pk_col},#{@all_cols_select}\"\n query = ReverseParseTree.reverseAndreplace(@parseTree, targetListReplacement, '')\n @full_rst_tbl = \"#{@table}_full_rst\"\n pk = @pk_full_list.map { |pk| \"#{pk['alias']}_pk\" }.join(', ')\n # binding.pry\n DBConn.tblCreation(@full_rst_tbl, pk, query)\n\n # unless preserve_null_pk\n # DBConn.update_null_columns(@full_rst_tbl,pk)\n # end\n # if is_plain_query()\n # query = QueryBuilder.create_tbl(@full_rst_tbl, pk, query)\n # DBConn.exec(query)\n # else\n # query = QueryBuilder.create_tbl(@full_rst_tbl, '', query)\n # DBConn.exec(query)\n\n # # not_null_query = pk_list.flat.map{|pk| \"#{pk} is not null\"}.join(' AND ')\n # # add index on not null columns\n # pk_not_null = @pk_full_list.map { |pk| \"#{pk['alias']}_pk is not null\"}.join(' OR ')\n # create_indx = \"CREATE UNIQUE INDEX idx_#{@full_rst_tbl} on #{@full_rst_tbl} (#{pk}) where #{pk_not_null}\"\n # pp create_indx\n # DBConn.exec(create_indx)\n\n # end\n end\n return @full_rst_tbl\n end", "def preload_conditions_columns\n ActiveRecord::Associations::Preloader.new.preload(conditions, :column)\n end", "def build_inheritances_joins(arel, types)\n columns = Hash.new{ |h, k| h[k] = [] }\n base_on_key = model.arel_table[primary_key]\n base_attributes = model.attribute_names\n\n # Iterate over each casted dependent calculating the columns\n types.each.with_index do |model, idx|\n join_table = model.arel_table.alias(\"\\\"i_#{idx}\\\"\")\n arel.outer_join(join_table).on(base_on_key.eq(join_table[primary_key]))\n (model.attribute_names - base_attributes).each do |column|\n columns[column] << join_table\n end\n end\n\n # Return the list of needed columns\n columns.default_proc = nil\n columns\n end", "def createSymbolTable(name,predecessor)\n\t\t\n\t\t# Create new table with corresponding ID\n\t\tlastID = $tableID.pop\n\t\t\n\t\tif(predecessor.name.eql? \"ROOT TABLE\") then\n\t\t\tnewSymbolTable = SymbolTable.new lastID.to_s, name\n\t\telse\n\t\t\tnewSymbolTable = SymbolTable.new predecessor.id + \".\" + lastID.to_s, name\n\t\tend\n\n\t\t$tableID.push(lastID+1)\n\t\t$tableID.push(1)\n\n\t\t# Link to predecessor\n\t\tnewSymbolTable.set_predecessor(predecessor)\n\t\tpredecessor.add_child(newSymbolTable)\n\t\t\n\t\treturn newSymbolTable\n\tend", "def add_piggy_back_sql_data!(reflection_name, prefix, table_alias, attributes, select, joins, conditions, join_type)\n ktn = table_name\n kpkey = primary_key\n reflection = reflections[reflection_name]\n atn = reflection.table_name\n attributes.each do |attr|\n if table_alias\n select << \", #{table_alias}.#{attr} AS #{prefix}_#{attr}\"\n else\n select << \", #{atn}.#{attr} AS #{prefix}_#{attr}\"\n end\n end\n fkey = reflection.primary_key_name\n fpkey = reflection.klass.primary_key\n\n case reflection.macro\n when :belongs_to\n if table_alias\n joins << \" #{join_type} JOIN #{atn} #{table_alias} ON #{table_alias}.#{fpkey}=#{ktn}.#{fkey} \"\n else\n joins << \" #{join_type} JOIN #{atn} ON #{atn}.#{fpkey}=#{ktn}.#{fkey} \"\n end\n when :has_one\n if table_alias\n joins << \" #{join_type} JOIN #{atn} #{table_alias} ON #{table_alias}.#{fkey}=#{ktn}.#{kpkey} \"\n else\n joins << \" #{join_type} JOIN #{atn} ON #{atn}.#{fkey}=#{ktn}.#{kpkey} \"\n end\n when :has_many\n raise \"piggy_back: aliasing not implemented for has_many\" if table_alias\n if reflection.options[:through]\n ttn = reflection.through_reflection.klass.table_name\n tkfkey = reflection.through_reflection.primary_key_name\n tafkey = reflection.source_reflection.primary_key_name\n\n through_conditions = reflection.options[:conditions] ?\n \" AND \" + reflection.options[:conditions] : \"\"\n source_conditions = reflection.through_reflection.options[:conditions] ?\n \" AND \" + reflection.through_reflection.options[:conditions] : \"\"\n\n joins << \" LEFT JOIN #{ttn} ON (#{ttn}.#{tkfkey}=#{ktn}.#{kpkey}#{through_conditions})\"\n joins << \" LEFT JOIN #{atn} ON (#{ttn}.#{tafkey}=#{atn}.#{fpkey}#{source_conditions}) \"\n else\n reflection_conditions = reflection.options[:conditions] ?\n \" AND \" + reflection.options[:conditions] : \"\"\n\n joins << \" LEFT JOIN #{atn} ON (#{atn}.#{fkey}=#{ktn}.#{kpkey}#{reflection_conditions}) \"\n end\n else\n raise \"can't piggy back #{reflection.macro} on class #{klass}\"\n end\n end", "def initialize\n @columns = { }\n @primary_keys = []\n @to_avoid = []\n @default_values = { }\n @associations = \n {\n :belongs_to => { },\n :has_one => { },\n :has_n => { }\n }\n end", "def prepend_join(join)\n @clause[:join] = join.string << @clause[:join]\n @clause[:join] << join.implicit_joins\n end", "def initialize(base, table, associations, alias_tracker, eager_loading: true)\n @alias_tracker = alias_tracker\n @eager_loading = eager_loading\n tree = self.class.make_tree associations\n @join_root = JoinBase.new(base, table, build(tree, base))\n @join_root.children.each { |child| construct_tables! @join_root, child }\n end", "def create_table_def\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 5 )\n return_value = CreateTableDefReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n column20 = nil\n pk_definition21 = nil\n\n\n begin\n # at line 31:3: ( column | pk_definition )\n alt_5 = 2\n look_5_0 = @input.peek( 1 )\n\n if ( look_5_0 == ID )\n alt_5 = 1\n elsif ( look_5_0 == PRIMARY_KEY )\n alt_5 = 2\n else\n raise NoViableAlternative( \"\", 5, 0 )\n end\n case alt_5\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 31:5: column\n @state.following.push( TOKENS_FOLLOWING_column_IN_create_table_def_180 )\n column20 = column\n @state.following.pop\n @adaptor.add_child( root_0, column20.tree )\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 32:5: pk_definition\n @state.following.push( TOKENS_FOLLOWING_pk_definition_IN_create_table_def_186 )\n pk_definition21 = pk_definition\n @state.following.pop\n @adaptor.add_child( root_0, pk_definition21.tree )\n\n end# - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 5 )\n\n end\n \n return return_value\n end", "def tnTableCreation(tableName)\n pk_list = @pkList.join(',')\n pk_list = \"#{pk_list},branch_name,node_name\"\n q = QueryBuilder.create_tbl(tableName, pk_list, \"select #{@pkSelect}, 0 as test_id,''::varchar(30) as node_name, ''::varchar(30) as branch_name, ''::varchar(5) as type from #{@fTable} f where 1 = 0\")\n # pp q\n DBConn.exec(q)\n\n # q=\"ALTER TABLE #{tableName} add column test_id int, add column node_name varchar(30), add column branch_name varchar(30), add column type varchar(5);\"\n # DBConn.exec(q)\n # pk=@pkList.join(',')\n # # add index\n # q=\"create index ix_#{tableName}t on #{tableName} (#{pk},branch_name);\"\n # pp q\n # DBConn.exec(q)\n end", "def test_join1\n\t\tr = prep(\"program foo;\\nfoo(A,B) :- bar(A,B);\\n\")\n\t\t\n\t\t# set up schema table's predicate\n\t\t## require 'ruby-debug'; debugger\n\t\tterm_schema = @terms.schema_of\n\t\tterm_pred = Predicate.new(false,@terms.name,@terms,term_schema.variables)\n\t\tterm_pred.set(r, \"global\", \"r3\", 1)\n\t\t\n\t\tsj = ScanJoin.new(r, term_pred, @preds.schema_of)\t\n\t\tts = TupleSet.new(\"pred\", *@preds.tuples)\n\t\tres = sj.evaluate(ts)\n\n\t\tassert_equal(2, res.tups.length)\n\tend", "def generate_table\n letters.reverse.each_with_index do |letter, index|\n row = build_row(letter, index)\n table << row\n table.unshift(row) unless index == 0\n end\n end", "def table; end", "def table; end", "def table; end", "def table; end", "def create_rollup_cube_table(options={})\n # TODO: perhaps this should all be executed in a single transaction?\n connection.drop_table(rollup_table_name) if connection.tables.include?(rollup_table_name)\n\n ActiveRecord::Base.transaction do\n connection.create_table(rollup_table_name, :id => false) do |t|\n dimensions_to_columns.each do |c|\n t.column(c.label, c.column_type)\n end\n aggregate_fields.each do |c|\n t.column(c.label_for_table, c.column_type)\n end\n end\n end\n end", "def drop_left\n tbl = self.class.new(\n 'Columns' => Array.new(self.rows.count+1,' '),\n 'Header' => self.header,\n 'Indent' => self.indent)\n (self.columns.count+1).times do |ti|\n row = self.rows.map {|r| r[ti]}.unshift(self.columns[ti]).flatten\n # insert our col|row break. kind of hackish\n row[1] = \"| #{row[1]}\" unless row.all? {|e| e.nil? || e.empty?}\n tbl << row\n end\n return tbl\n end", "def table\n @table ||= FACT_COLUMN_PREFIX + Model::to_id(name)\n end", "def create_table\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 4 )\n return_value = CreateTableReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal13 = nil\n __ID14__ = nil\n char_literal15 = nil\n char_literal17 = nil\n string_literal19 = nil\n create_table_def16 = nil\n create_table_def18 = nil\n\n tree_for_string_literal13 = nil\n tree_for_ID14 = nil\n tree_for_char_literal15 = nil\n tree_for_char_literal17 = nil\n tree_for_string_literal19 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 28:5: 'create table' ID '(' create_table_def ( ',' create_table_def )* ');'\n string_literal13 = match( CREATE_TABLE, TOKENS_FOLLOWING_CREATE_TABLE_IN_create_table_151 )\n\n tree_for_string_literal13 = @adaptor.create_with_payload( string_literal13 )\n root_0 = @adaptor.become_root( tree_for_string_literal13, root_0 )\n\n __ID14__ = match( ID, TOKENS_FOLLOWING_ID_IN_create_table_154 )\n\n tree_for_ID14 = @adaptor.create_with_payload( __ID14__ )\n @adaptor.add_child( root_0, tree_for_ID14 )\n\n char_literal15 = match( T__17, TOKENS_FOLLOWING_T__17_IN_create_table_156 )\n @state.following.push( TOKENS_FOLLOWING_create_table_def_IN_create_table_159 )\n create_table_def16 = create_table_def\n @state.following.pop\n @adaptor.add_child( root_0, create_table_def16.tree )\n # at line 28:46: ( ',' create_table_def )*\n while true # decision 4\n alt_4 = 2\n look_4_0 = @input.peek( 1 )\n\n if ( look_4_0 == T__18 )\n alt_4 = 1\n\n end\n case alt_4\n when 1\n # at line 28:47: ',' create_table_def\n char_literal17 = match( T__18, TOKENS_FOLLOWING_T__18_IN_create_table_162 )\n @state.following.push( TOKENS_FOLLOWING_create_table_def_IN_create_table_165 )\n create_table_def18 = create_table_def\n @state.following.pop\n @adaptor.add_child( root_0, create_table_def18.tree )\n\n else\n break # out of loop for decision 4\n end\n end # loop for decision 4\n string_literal19 = match( T__19, TOKENS_FOLLOWING_T__19_IN_create_table_169 )\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 4 )\n\n end\n \n return return_value\n end", "def load\n rows = fire\n columns = rows.shift\n result = []\n rows.map do |el|\n obj = table_name.camelize.singularize.constantize.new\n columns.each_with_index do |column,index|\n obj.instance_variable_set(\"@#{column}\".to_sym, el[index])\n end\n result << obj\n end\n reset\n result\n end", "def feedable_wells_table(plate)\n tab = plate.matrix.map do |row|\n row.map do |id|\n next \"(empty)\" if id == -1\n well = Item.find(id)\n {content: \"#{well.id}\", check: is_feedable(well) ? true : false}\n end\n end\n tab.unshift((1..6).to_a)\n ['', 'A', 'B', 'C', 'D'].each.with_index{ |str, i| tab[i].unshift(str) }\n return tab\n end", "def post_processing_tables(nodes)\n tables = nodes\n .css('table:not(.o-ld-columns-table)')\n .add_class('c-ld-table')\n tables.wrap('<div class=\"c-ld-table__wrap\"></div>') unless @options[:material]\n end", "def build_preloader\n ActiveRecord::Associations::Preloader.new(as_of_time: as_of_time)\n end", "def build_table_body\n body =\n if data.column_names && !data.column_names.empty?\n data\n else\n data[1..-1]\n end\n body.each { |row| build_md_row(output, row) }\n end", "def ft\n\tFancifyTable.new([[1,2],[3,4]])\nend", "def base_table\n {\n \"Partner\" => ->(distribution) {\n distribution.partner.name\n },\n \"Date of Distribution\" => ->(distribution) {\n distribution.issued_at.strftime(\"%m/%d/%Y\")\n },\n \"Source Inventory\" => ->(distribution) {\n distribution.storage_location.name\n },\n \"Total Items\" => ->(distribution) {\n distribution.line_items.total\n },\n \"Total Value\" => ->(distribution) {\n distribution.cents_to_dollar(distribution.line_items.total_value)\n },\n \"Delivery Method\" => ->(distribution) {\n distribution.delivery_method\n },\n \"State\" => ->(distribution) {\n distribution.state\n },\n \"Agency Representative\" => ->(distribution) {\n distribution.agency_rep\n },\n \"Comments\" => ->(distribution) {\n distribution.comment\n }\n }\n end", "def construct_simple_join_sql(num)\n connection = klass.connection\n key_value_table = klass.table_name\n\n main_table = definition.klass.table_name\n main_table_pk, value_table_fk_main = reflection_keys(definition.reflection_by_name(definition.klass, relation))\n\n join_sql = \"\\n INNER JOIN #{connection.quote_table_name(key_value_table)} #{key_value_table}_#{num} ON (#{connection.quote_table_name(main_table)}.#{connection.quote_column_name(main_table_pk)} = #{key_value_table}_#{num}.#{connection.quote_column_name(value_table_fk_main)})\"\n return join_sql\n end", "def make_table(table, *args, others)\n unless others.is_a? Hash\n args << others\n others = {}\n end\n table = table.to_s # probably already was\n table_sym = table.to_sym\n @fields[table_sym] = args + others.keys\n @xform[table_sym] = {:inspect => [], :yaml => []}\n xform, fields = @xform, @fields # because of change in 'self'\n @db.create_table table_sym do\n primary_key table+\"_id\"\n args.each do |field| \n if field.to_s =~ /_id$/\n Integer field \n else\n String field\n end\n end\n others.each_pair do |field, klass|\n case klass.to_s.to_sym\n when :Integer; Integer field\n when :String; String field\n when :Float; Float field\n when :DateTime; DateTime field\n when :Array, :Hash, :Symbol\n String field\n xform[table_sym][:inspect] << field\n when :Yaml\n String field\n xform[table_sym][:yaml] << field\n end\n end\n end\n # Now save metadata...\n args_hash = {}\n args.each {|arg| args_hash.update(arg => :String) }\n args_hash.update(others)\n args_hash.each_pair {|k, v| args_hash[k] = v.to_s.to_sym }\n @db[:metadata].insert(:table => table, :transform => xform[table_sym].to_yaml, \n :fields => fields[table_sym].to_yaml)\n end", "def initialize(session, left_table, right_table = nil)\n super\n end", "def create_fund_table\n Bsf::Scraper.db.create_fund_table\n end", "def initialize(session, left_table, right_table = nil)\n if session.left.primary_key_names(left_table).empty?\n raise \"Table '#{left_table}' doesn't have a primary key. Cannot scan.\"\n end\n \n self.session, self.left_table, self.right_table = session, left_table, right_table\n self.right_table ||= self.left_table\n self.primary_key_names = session.left.primary_key_names left_table\n end", "def prefix_table\n update unless @prefix_table\n @prefix_table\n end", "def initialize_copy(orig)\n super\n @table = @table.dup\n end", "def new_table(name, field_defs, encrypt, record_class)\r\n # Header rec consists of last record no. used, delete count, and\r\n # all field names/types. Here, I am inserting the 'recno' field\r\n # at the beginning of the fields.\r\n header_rec = ['000000', '000000', record_class, 'recno:Integer',\r\n field_defs].join('|')\r\n\r\n header_rec = 'Z' + encrypt_str(header_rec) if encrypt\r\n\r\n begin\r\n fptr = open(File.join(@db.path, name.to_s + @db.ext), 'w')\r\n fptr.write(header_rec + \"\\n\")\r\n ensure\r\n fptr.close\r\n end\r\n end", "def create_table_sql(name, generator, options)\n a, b = super(name, generator, options), table_options_sql(options)\n \"#{a}\\n#{b}\"\n\t end", "def create_partition_of_table_sql(name, generator, options)\n sql = create_table_prefix_sql(name, options).dup\n\n sql << \" PARTITION OF #{quote_schema_table(options[:partition_of])}\"\n\n case generator.partition_type\n when :range\n from, to = generator.range\n sql << \" FOR VALUES FROM #{literal(from)} TO #{literal(to)}\"\n when :list\n sql << \" FOR VALUES IN #{literal(generator.list)}\"\n when :hash\n mod, remainder = generator.hash_values\n sql << \" FOR VALUES WITH (MODULUS #{literal(mod)}, REMAINDER #{literal(remainder)})\"\n else # when :default\n sql << \" DEFAULT\"\n end\n\n sql << create_table_suffix_sql(name, options)\n\n sql\n end", "def association_symbol_for_rows\n @importing_reflection ||= self.class.import_into\n end", "def table_csv_string(options = {})\n opt = {\n :klass => nil,\n :header_row => true\n }.merge!(options)\n str = ''\n \n return false if !opt[:klass]\n\n klass_name = opt[:klass].name\n tbl = ActiveSupport::Inflector.tableize(opt[:klass].name.to_s)\n\n cols = []\n sql = ''\n\n if klass_name == \"Person\" \n cols = %w(id last_name first_name middle_name login)\n else\n cols = opt[:klass].columns.map(&:name) \n end\n\n cols_str = cols.join(\", \")\n\n case opt[:klass].name\n when \"Person\"\n sql = \"SELECT #{cols_str} FROM people p INNER JOIN people_projs pp on p.id = pp.person_id WHERE pp.proj_id = #{self.id};\"\n when \"Ref\"\n cols_str = cols.collect{|c| \"r.#{c}\"}.join(\", \") # refs shared across projects, be more explicit for the join table\n sql = \"SELECT #{cols_str} FROM refs r INNER JOIN projs_refs pr on r.id = pr.ref_id WHERE pr.proj_id = #{self.id};\"\n when \"TaxonName\"\n sql = \"SELECT #{cols_str} FROM taxon_names WHERE #{self.sql_for_taxon_names}\"\n when \"Author\"\n sql = \"SELECT #{cols_str} FROM authors a WHERE a.ref_id IN (SELECT r.id FROM refs r INNER JOIN projs_refs pr on r.id = pr.ref_id WHERE pr.proj_id = #{self.id})\"\n when \"ChrState\"\n sql = \"SELECT #{cols_str} FROM chr_states cs WHERE cs.chr_id IN (SELECT chrs.id from chrs WHERE chrs.proj_id = #{self.id})\" \n # when \"Identifier\"\n # sql = \"SELECT #{cols_str} FROM identifiers si WHERE si.specimen_id IN (SELECT specimens.id from specimens WHERE specimens.proj_id = #{self.id})\"\n when \"SpecimenDetermination\"\n sql = \"SELECT #{cols_str} FROM specimen_determinations sd WHERE sd.specimen_id IN (SELECT specimens.id from specimens WHERE specimens.proj_id = #{self.id})\"\n\n else\n sql = \"SELECT #{cols_str} FROM #{tbl}\" \n end\n\n # add the project level restrictions if they exist\n sql << \" WHERE proj_id = #{self.id}\" if opt[:klass].columns.collect{|c| c.name}.include?(\"proj_id\")\n\n # build the str\n str << cols.join(\"\\t\") if opt[:header_row]# the header row\n str << \"\\n\"\n\n ActiveRecord::Base.connection.select_rows(sql).each do |row| \n # not filtering for tab characters here, likely should\n str << row.collect{|c| c == nil ? nil : c.gsub(/\\n|\\r\\n|\\r/, '\\n')}.join(\"\\t\") + \"\\n\"\n end\n str\n end", "def spawn_tables\n\t# pseudo-migration / schema\n\tif !FeedEntry.table_exists?\n\t\tprint \"Creating feed entry table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:feed_entries) do |t|\n\t\t\tt.column :name, :string\n\t\t\tt.column :content, :string\n\t\t\tt.column :url, :string\n\t\t\tt.column :guid, :string\n\t\t\tt.column :published_at, :datetime\n\t\t\tt.column :feed_id, :integer\n\t\tend\n\tend\n\tif !Feed.table_exists?\n\t\tprint \"Creating feed table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:feeds) do |t|\n\t\t\tt.column :url, :string\n\t\tend\n\tend\n\tif !Blacklist.table_exists?\n\t\tprint \"Creating blacklist table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:blacklists) do |t|\n\t\t\tt.column :word, :string\n\t\tend\n\tend\nend", "def build_table_aliases(from)\n # for the targets\n returning({}) do |aliases|\n from.map(&:to_s).sort.map(&:to_sym).each_with_index do |plural, t_index|\n table = plural._as_class.table_name\n plural._as_class.columns.map(&:name).each_with_index do |field, f_index|\n aliases[\"#{table}.#{field}\"] = \"t#{t_index}_r#{f_index}\"\n end\n end\n end\n end", "def generate_query\n unless databases.nil?\n databases.each do |db|\n create_query[db] = [\"create table #{tablename} (\"]\n end\n csv_column_datatypes.each do |header, datatype|\n append_to_query = build_query_for_datatype(header, datatype)\n append_to_query.each do |key, value|\n create_query[key].push(value)\n end\n end\n prepare_sql_statements\n prepare_import_csv\n # Pass the prepared statements to options varaible.\n # Which gets passed on to print_metadata_analysis\n options[:create_query] = create_query\n options[:import_query] = import_query\n end\n print_metadata_analysis\n end", "def initialize_copy(original)\n super\n @table = @table.dup\n end", "def create_header_table(frequent_items)\n headers = []\n frequent_items.each do | item_node |\n headers << SubTreeNode.new(ItemNode.new(item_node, 0))\n end\n self.header_table = headers\n end", "def create_table!\n return true unless Fathom.config.uses_sqlite_optimizer\n value = Fathom.config.db.execute(table_creation_sql)\n end", "def compute_table_name\n \"#{full_table_name_prefix}#{undecorated_table_name(name)}#{table_name_suffix}\"\n end", "def table\n association.table_name\n end", "def create_main_npc_tbl\n\t\t\ts_rows = @player_data_db.execute <<-SQL\n\t\t\t\tCREATE TABLE IF NOT EXISTS npcs (\n\t\t\t\t\tid INTEGER PRIMARY KEY,\n\t\t\t\t\tdb_name varchar(30),\n\t\t\t\t\tname varchar(30),\n\t\t\t\t\trepeat int\n\t\t\t\t\t\n\t\t\t\t);\n\t\t\tSQL\n\t\tend", "def bootstrap\n sql = 'CREATE TABLE IF NOT EXISTS states(uuid VARCHAR(128) PRIMARY KEY,'\n sql << ' id INTEGER, name VARCHAR(128), deploy_id VARCHAR(128), timestamp INTEGER,'\n sql << ' missing INTEGER, state VARCHAR(128), hyperv VARCHAR(128))'\n\n @db.execute(sql)\n\n sql = 'CREATE TABLE IF NOT EXISTS settings(key VARCHAR(128) PRIMARY KEY,'\n sql << ' value VARCHAR(128))'\n\n @db.execute(sql)\n end", "def prepare_table(element)\n name=element.attributes[\"name\"]\n oid=SNMPPass.oid2num(element.attributes[\"oid\"])\n\n # Read index and columns\n indexes=element.elements[\"row/linkage\"].elements.collect(\"index\") {|index| index.attributes[\"name\"]}\n columns=element.elements[\"row\"].elements.collect(\"column\") do\n |column|\n column_name=column.attributes[\"name\"]\n column_oid=column.attributes[\"oid\"]\n column_id=SNMPPass.oid2num(column_oid).last\n\n $DEBUG.puts \"TABLE: #{name} NAME: #{column_name} ID #{column_id}, OID: #{column_oid}\"\n\n #column_desc=column.elements[\"description\"].text.gsub(/^[[:blank:]\\n]*/,\"\").gsub(/[[:blank:]\\n]*$/,\"\")\n type=prepare_type(column.elements[\"syntax\"], column_name)\n [column_name,column_id,type]\n end\n\n @indexes[name]=indexes\n @columns[name]=columns\n\n table=DynamicTree.new(oid){|op, *roid| dynamic_tree_callback(name, op, *roid) }\n add_node(table)\n end", "def rollup_table_name\n \"#{cube_class.name.tableize.singularize}_rollup\"\n end", "def create_users_products\n @db.create_join_table(:user_id => :users, :product_id => :products) do\n end\n end", "def create_table_prefix_sql(name, options)\n \"CREATE #{temporary_table_sql if options[:temp]}TABLE#{' IF NOT EXISTS' if options[:if_not_exists]} #{options[:temp] ? quote_identifier(name) : quote_schema_table(name)}\"\n end", "def tables\n @tables ||= {:left => left_table, :right => right_table}\n end", "def create_global_tbl\n # full table contains all columns without where predicate\n # so for where predicate it also contains excluded rows\n\n # create full rst_tbl and update null pk\n @t_full_tbl = @tQueryObj.create_full_rst_tbl(false)\n @f_full_tbl = @fQueryObj.create_full_rst_tbl(false)\n\n tbl = Table.new(@t_full_tbl)\n global_name = 'tf_global'\n pkList = tbl.pk_column_list.map{|c| c.colname}.join(', ')\n insert_query = \"select #{pkList}, case count(1) when 1 then 'f' else 'p' end as type \"\\\n \"from (select #{pkList} from #{@t_full_tbl} UNION ALL \"\\\n \"select #{pkList} from #{@f_full_tbl}) as tmp \"\\\n \"group by #{pkList}\"\n # puts insert_query\n # QueryBuilder.exec_create_tbl(global_name, pkList, insert_query)\n DBConn.tblCreation(global_name, pkList, insert_query)\n # update null columns to resolve null value comparasion issue\n # binding.pry\n # DBConn.update_null_columns(global_name,pkList)\n\n return global_name\n end", "def _table; @table end", "def make_table(options={})\n get_table(options).rows\n end", "def initialize(pivot_table)\n @pivot_table = pivot_table\n end", "def initialize #:nodoc:\n super\n @generated_conditions = []\n @by_table_names = HashWithIndifferentAccess.new\n end", "def schema_ds_join(table_name, opts)\n [:information_schema__columns, {:table_catalog=>:table_catalog,\n :table_schema => :table_schema, :table_name => :table_name} , :c]\n end", "def create_table(set, prefix, n, t_size)\r\n \t# base case\r\n if t_size.zero?\r\n @table_array[@table_i] = prefix.chars\r\n @table_i += 1\r\n return\r\n end\r\n \r\n # recursive case\r\n set.each do |x|\r\n new_prefix = prefix + x\r\n create_table(set, new_prefix, n, t_size - 1)\r\n end\r\n end", "def create_table\n dimension_length = (@numbers_to_multiply.length - 1)\n @multiplication_table = []\n new_table_row = [\" \"]\n\n for i in 0..dimension_length\n new_table_row << @numbers_to_multiply[i]\n end\n\n new_table_row\n @multiplication_table << new_table_row\n\n for x in 0..dimension_length \n new_table_row = []\n new_table_row << @numbers_to_multiply[x]\n # rowValues = \"#{@numbers_to_multiply[x]} |\"\n for y in 0..dimension_length\n nextEntry = @numbers_to_multiply[x] * @numbers_to_multiply[y]\n new_table_row << nextEntry\n end\n @multiplication_table << new_table_row\n end\n end", "def initialize (num_legs) #You can put specific table material in initialize\n\t\t@tabletop = []\n\t\t@num_legs = num_legs\n\tend", "def get_lines(cls, cfg)\n sqlCDef = Array.new\n indent = \"\"\n\n codeLine = indent + \"CREATE TABLE `\" + cls.name + \"List` (\"\n sqlCDef << codeLine\n sqlCDef << indent << \"`id` INT\"\n\n varArray = Array.new\n cls.getAllVarsFor(varArray);\n\n for var in varArray\n if var.elementId == CodeElem::ELEM_VARIABLE\n codeLine = \", \"\n\n codeLine << XCTESql::Utils::getVarDec(var)\n\n if var.defaultValue != nil\n codeLine << \" default '\" << var.defaultValue << \"'\"\n end\n\n sqlCDef << codeLine\n end\n end\n\n sqlCDef << indent << \", PRIMARY KEY (`id`)\"\n\n sqlCDef << indent << \" ) ENGINE=MyISAM DEFAULT CHARSET=utf8;\"\n\n return(sqlCDef); \n end", "def table_name_prefix; end", "def init_table(layer, stat) # returns self\n tbl = Table.new(layer, stat)\n if stat[:data_ver].to_i > 0\n ___create_tbl(tbl)\n ___real_mode(stat, tbl)\n else\n ___dummy_mode(stat, tbl)\n end\n self\n end", "def exportable_from(options = {})\n if options[:parent]\n raise ArgumentError, \"Expected - :association must be specified with parent\" unless options[:association]\n p_association = options[:parent].exportable_reflections[p_association]\n p_table_name = options[:parent].table_name\n t_foreign_key = p_association.foreign_key\n \n QueryPiece.new :join => \"LEFT JOIN #{exportable_table_name} ON (#{exportable_table_name}.project_id = #{p_table_name}.id)\"\n else\n QueryPiece.new :from => \"FROM #{exportable_table_name}\"\n end\n end" ]
[ "0.81337154", "0.6465175", "0.6194726", "0.60960203", "0.53838074", "0.53418994", "0.53412735", "0.52600896", "0.52530104", "0.52224874", "0.5216368", "0.51703537", "0.5150687", "0.5143182", "0.51354873", "0.51294726", "0.5122486", "0.5099326", "0.5083423", "0.50702107", "0.5038216", "0.50379777", "0.5000423", "0.49667645", "0.49640006", "0.49373797", "0.49315685", "0.4927901", "0.4904572", "0.48963016", "0.48721886", "0.4853283", "0.4845132", "0.48347068", "0.483162", "0.48309195", "0.4822304", "0.48077872", "0.48002425", "0.47929305", "0.478315", "0.47805429", "0.47773543", "0.4772387", "0.47369224", "0.47216493", "0.47216493", "0.47216493", "0.47216493", "0.47123188", "0.47093487", "0.46617943", "0.4659161", "0.46463522", "0.4645067", "0.4637551", "0.46251854", "0.46158296", "0.46125892", "0.46086267", "0.46068564", "0.45897466", "0.45867872", "0.4581056", "0.45765975", "0.45738226", "0.45722967", "0.45612907", "0.45447192", "0.45443785", "0.45390984", "0.4531386", "0.45231378", "0.45198467", "0.4519817", "0.45168358", "0.45160925", "0.4513887", "0.4512922", "0.4512777", "0.4510283", "0.45051727", "0.45011038", "0.45000523", "0.44942117", "0.44922027", "0.44883677", "0.44856635", "0.44842333", "0.44822624", "0.44775808", "0.4477026", "0.44729546", "0.44652545", "0.44624865", "0.4462178", "0.44608334", "0.44579682", "0.4457624", "0.44536558" ]
0.80051035
1
Populate the prejoined fact table.
def populate_prejoined_fact_table(options={}) fact_columns_string = columns.collect {|c| "#{table_name}." + c.name unless excluded_foreign_key_names.include?(c.name) }.compact.join(",\n") prejoined_columns = [] tables_and_joins = "#{table_name}" prejoined_fields.each_pair do |key, value| dimension = dimension_class(key) tables_and_joins += "\nJOIN #{dimension.table_name} as #{key}" tables_and_joins += "\n ON #{table_name}.#{dimension_relationships[key].foreign_key} = " tables_and_joins += "#{key}.#{dimension.primary_key}" prejoined_columns << value.collect {|v| "#{key}." + v.to_s} end if connection.support_select_into_table? drop_prejoin_fact_table sql = <<-SQL SELECT #{fact_columns_string}, #{prejoined_columns.join(",\n")} FROM #{tables_and_joins} SQL sql = connection.add_select_into_table(prejoined_table_name, sql) else create_prejoined_fact_table(options) sql = <<-SQL INSERT INTO #{prejoined_table_name} SELECT #{fact_columns_string}, #{prejoined_columns.join(",\n")} FROM #{tables_and_joins} SQL end connection.transaction { connection.execute(sql) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate(options={})\r\n populate_prejoined_fact_table(options)\r\n end", "def create_prejoined_fact_table(options={})\r\n connection.transaction {\r\n drop_prejoin_fact_table\r\n\r\n connection.create_table(prejoined_table_name, :id => false) do |t|\r\n # get all columns except the foreign_key columns for prejoined dimensions\r\n columns.each do |c|\r\n t.column(c.name, c.type) unless excluded_foreign_key_names.include?(c.name)\r\n end\r\n #prejoined_columns\r\n prejoined_fields.each_pair do |key, value|\r\n dclass = dimension_class(key)\r\n dclass.columns.each do |c|\r\n t.column(c.name, c.type) if value.include?(c.name.to_sym) \r\n end\r\n end\r\n end\r\n }\r\n end", "def drop_prejoin_fact_table\r\n connection.drop_table(prejoined_table_name) if connection.tables.include?(prejoined_table_name)\r\n end", "def before_load\n data_class.rebuild_table\n super\n end", "def preload_associations(associations)\n associations.reduce(dup) do |table, association|\n primary_key = association.association_primary_key\n foreign_key = association.foreign_key\n name = association.name.to_s\n\n next table if !table.names.include?(foreign_key)\n\n ids = table[foreign_key].to_a.uniq.compact_blank\n records = association.klass.where(primary_key => ids).index_by(&primary_key.to_sym)\n\n table.rename({ foreign_key => name })\n table[name] = table[name].map { |id| records[id] }\n table\n end\n end", "def seed_other_cost_rows\n OtherCost.delete_all\n OtherCostType.all.each do |t|\n t.other_costs.create if t.other_costs.empty?\n end\nend", "def rebuild(table); end", "def setup_target_table\n self.target_table = source_table if target_table.blank?\n end", "def load\n rows = fire\n columns = rows.shift\n result = []\n rows.map do |el|\n obj = table_name.camelize.singularize.constantize.new\n columns.each_with_index do |column,index|\n obj.instance_variable_set(\"@#{column}\".to_sym, el[index])\n end\n result << obj\n end\n reset\n result\n end", "def preload_conditions_columns\n ActiveRecord::Associations::Preloader.new.preload(conditions, :column)\n end", "def tables_and_joins\n sql = \"#{fact_class.table_name}\"\n cube_class.dimensions_hierarchies.each do |dimension_name, hierarchy_name|\n dimension_table_name = fact_class.dimension_class(dimension_name).table_name\n sql += \" LEFT JOIN #{dimension_table_name} as #{dimension_name}\"\n sql += \" ON #{fact_class.table_name}.\"\n sql += \"#{fact_class.dimension_relationships[dimension_name].foreign_key}\"\n sql += \" = #{dimension_name}.id\\n\"\n end\n sql\n end", "def initialize_table; end", "def populate_nonprofit_table(org_eins)\n org_eins.each do |ein|\n Nonprofit.create(charityName: charityname(ein), city: city(ein), url: url(ein), ein: ein(ein) , zipcode: zipcode(ein), cause: cause(ein))\n end\nend", "def pre_initialize_fields\n end", "def create_lookup_table\n File.open(source).each_with_index do |line|\n next if line.chomp.empty?\n\n values = unstring(line).chomp.split(';')\n\n next if values.empty?\n\n @joiners.each do |joiner|\n key = values[joiner.join[0]]\n joiner.lookup[:rows][key] = []\n\n joiner.cols.each do |i|\n joiner.lookup[:rows][key] << values[i]\n end\n end\n\n end\n end", "def initialize_columns\n @columns = []\n valid_table = table.alias('valid_taxon_names')\n\n @columns.push({ header: 'ro', projected: rank_over(table, valid_table) })\n\n @columns.push({header: 'taxon_name_id', projected: table[:id].as('taxon_name_id') } )\n @columns.push({header: 'cached_valid_taxon_name_id', projected: table[:cached_valid_taxon_name_id].as('cached_valid_taxon_name_id') } )\n @columns.push({header: 'cached', projected: table[:cached].as('cached') } )\n @columns.push({header: 'cached_author_year', projected: table[:cached_author_year].as('cached_author_year') } )\n @columns.push({header: 'cached_is_valid', projected: table[:cached_is_valid].as('cached_is_valid') } )\n\n if fieldsets.include?('observations')\n @columns.push({header: 'otu_id', projected: otu_table[:id].as('otu_id') } )\n @columns.push({header: 'otu_name', projected: otu_table[:name].as('otu_name')} )\n end\n end", "def seed\n parse\n prepare_sql\n execute_sql\n end", "def initialize_table\n @total_rows.times do |row|\n row_array = Array.new(@total_columns, \"\")\n @reconstructed_table.push(row_array)\n end\n end", "def fetch_and_import!(opts={})\n eve_table = opts[:eve_table]\n dest_table = opts[:dest_table]\n mapping = opts[:mapping]\n dbh = opts[:conn] || @dbh\n comment_label = opts[:label]\n \n # Fetch Data from crpActivities Table\n results = dbh.query(\"SELECT * FROM \"+eve_table)\n # Clear Destination Table to eliminate Redundancy\n dest_table.camelize.constantize.delete_all\n # Do some Meta programming FU magic\n results.each do |row|\n insert_map = {}\n mapping.each do |key,value|\n insert_map[key.to_sym] = row[value]\n end \n dest_table.camelize.constantize.create!(insert_map)\n # Just so you see something when running this script..\n p \"Creating Record for #{dest_table} : \" + row[comment_label].to_s\n end\nend", "def recreate_from(obj)\n keys = self.key_column_names\n args = {}\n if obj.respond_to?(:enterprise_id) and obj.respond_to?(:uid)\n args[keys.delete(:enterprise_id)] = obj.enterprise_id\n if keys.length == 1\n args[keys.first] = obj.uid\n self.get_cached(args)\n else\n puts keys.to_a.to_s\n raise NotImplementedError, 'See octocore/models.rb'\n end\n end\n end", "def populate\n\n end", "def populate\n end", "def initialize_copy(orig)\n super\n @__table__ = @__table__.dup\n end", "def preload_data\n DataStore.instance.insert_data('users', 'data/users.json')\n DataStore.instance.insert_data('tickets', 'data/tickets.json')\n end", "def prepopulate_list\n\t\tname_list = ['ben', 'bob obobb', 'mary kate', 'kim possible', 'steve-o', 'jill and jack', 'veronica mars', 'danny trejo',\n\t\t 'jon snow', 'mario anluigi', 'ed obannon', 'amy winehouse', 'juan jones', 'walter okiefe', 'fred love']\n\t\tparty_list = ['tea party', 'conservative', 'neutral', 'liberal', 'socialist']\n\t\tjimbo = Human.new \"politician\", 'jimbo jones', 'democrat'\n\t\tgene = Human.new \"politician\", 'gene wilder', 'republican'\n\t\t@people_list << jimbo\n\t\t@people_list << gene\n\n\t\tname_list.map do |name|\n\t\t\trandom_party = party_list.sample\n\t\t\tname = Human.new \"voter\", name, random_party\n\t\t\t@people_list << name\n\t\tend\n\n\tend", "def preload(records, associations, given_preload_scope = nil)\n super records, associations, chronomodel_scope(given_preload_scope)\n end", "def setup\n current_user = options[:currentuser]\n all_flag = options[:allflag]\n if current_user.percentcompleteenabled\n table = Table([:description, :goaltype_label, :datecompleted, :created_date, :last_updated_date, :percentcomplete]) do |t|\n if all_flag\n current_user.goals.find(:all).each {|g| t << g.report_record()}\n else\n current_user.goals.find(:all).each {|u| t << u.report_record unless u.datecompleted != nil}\n end\n end\n \n table.rename_columns(:description => \"Description\",\n :goaltype_label => \"Goal Type\",\n :datecompleted => \"Date Completed\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\",\n :percentcomplete => \"Percent Complete\")\n\n else\n table = Table([:description, :goaltype_label, :datecompleted, :created_date, :last_updated_date]) do |t|\n if all_flag\n current_user.goals.find(:all).each {|g| t << g.report_record()}\n else\n current_user.goals.find(:all).each {|u| t << u.report_record unless u.datecompleted != nil}\n end\n end\n\n table.rename_columns(:description => \"Description\",\n :goaltype_label => \"Goal Type\",\n :datecompleted => \"Date Completed\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\")\n\n \n end\n\n self.data = table\n end", "def setup_columns\n if inheritable?\n SimpleSet.new([primary_key, inheritance_column])\n else\n primary_key.blank? ? SimpleSet.new : SimpleSet.new([primary_key])\n end \n end", "def populate_test_data\n @alice_mrn = 123\n @alice_picudb_id = @lomi.patients.insert({:mrn => @alice_mrn, :source => \"picudb\", :first_name => \"Alice\"})\n @alice_cerner_id = @lomi.patients.insert({:mrn => @alice_mrn, :source => \"cerner_patients\", :first_name => \"Alice\"})\n\n @alice_picudb_encounter_id = @lomi.encounters.insert({:patient_id => @alice_picudb_id,\n :source => \"picudb\",\n :admission => Time.new(2000, 12, 25),\n :discharge => Time.new(2000, 12, 28)})\n @alice_cerner_encounter_id = @lomi.encounters.insert({:patient_id => @alice_cerner_id,\n :source => \"cerner_paients\"})\n\n @alice_picudb_event_id = @lomi.events.insert({:patient_id => @alice_picudb_id,\n :encounter_id => @alice_picudb_encounter_id})\n @alice_cerner_event_id = @lomi.events.insert({:patient_id => @alice_cerner_id,\n :encounter_id => @alice_cerner_encounter_id,\n :start_time => Time.new(2000, 12, 26),\n :end_time => Time.new(2000, 12, 26) })\n end", "def populate_from(partition)\n team_mapping = {}\n partition.memberships.includes(:team, :user).each do |template|\n unless team = team_mapping[template.team]\n team = Team.create name: template.team.name, partition: self,\n course: course\n teams << team\n team_mapping[template.team] = team\n end\n TeamMembership.create(team: team, user: template.user)\n end\n self\n end", "def summarize_per_relation(generator)\n @from = \"#{generator.to_subquery} AS #{visit_identifier(generator.name)} NATURAL LEFT JOIN #{@from}\"\n end", "def before_setup\n Account.connection.drop_table :accounts, if_exists: true\n Account.connection.exec_query(\"CREATE SEQUENCE accounts_id_seq\")\n Account.connection.exec_query(\"\n CREATE TABLE accounts (\n id BIGINT PRIMARY KEY DEFAULT nextval('accounts_id_seq'),\n firm_id bigint,\n firm_name character varying,\n credit_limit integer\n )\n \")\n\n Company.connection.drop_table :companies, if_exists: true\n Company.connection.exec_query(\"CREATE SEQUENCE companies_nonstd_seq\")\n Company.connection.exec_query(\"\n CREATE TABLE companies (\n id BIGINT PRIMARY KEY DEFAULT nextval('companies_nonstd_seq'),\n type character varying,\n firm_id bigint,\n firm_name character varying,\n name character varying,\n client_of bigint,\n rating bigint,\n account_id integer,\n description character varying\n )\n \")\n\n Course.connection.drop_table :courses, if_exists: true\n Course.connection.exec_query(\"CREATE SEQUENCE courses_id_seq\")\n Course.connection.exec_query(\"\n CREATE TABLE courses (\n id INT PRIMARY KEY DEFAULT nextval('courses_id_seq'),\n name character varying,\n college_id integer\n )\n \")\n\n self.class.fixtures :accounts\n self.class.fixtures :companies\n self.class.fixtures :courses\n end", "def import_data\n @data.each do |row|\n name = row.first\n family_data = row.last\n\n family = FamilyGoal.find_or_create_by(name: name)\n \n family_data[:worlds].each do |world|\n family_data[:areas].each do |area|\n family_data[:positions].each do |position|\n family_goal_attribute = family.family_goal_attributes.find_or_create_by(world: world, area: area, position: position)\n end\n end\n end\n end\n end", "def populate_target_and_source_if_required\n return if @no_preparation\n\n populate(:target) if create_target?\n populate(:source)\n end", "def create_pruned_table(conn)\n if !conn.list_tables.include?('pruned')\n query = \"CREATE TABLE `pruned` ( `table_name` VARCHAR(64) NOT NULL PRIMARY KEY, `prune_time` DATETIME NOT NULL )\"\n if @dry_run\n verbose query\n else\n conn.query query\n end\n end\n end", "def seed_data\n delete_existing_records = 'DELETE FROM campaigns'\n @connection.execute(delete_existing_records)\n \n campaigns_records.each do |record|\n sql = %{\n INSERT INTO \n campaigns(job_id, status, external_reference, ad_description)\n VALUES(#{record[0]}, '#{record[1]}', '#{record[2]}', '#{record[3]}')\n }\n\n @connection.execute(sql)\n end\n end", "def initialize_rows\n @transform_lookup = {}\n if is_time?\n initialize_time_rows\n elsif is_distance?\n initialize_distance_rows\n else\n initialize_numeric_rows\n end\n end", "def seed_app_dining_periods\n start_hash = { 'Breakfast' => 8, 'Lunch' => 11, 'Dinner' => 16, 'Brunch' => 9, 'Late Night' => 20 }\n\n DiningOpportunity.all.each { |opp|\n DiningPlace.all.each { |dp|\n (0..6).each { |dow|\n start_hour = start_hash[opp.dining_opportunity_type]\n unless start_hour.blank?\n DiningPeriod.current_or_create_new(start_time: Time.now.change(hour: start_hour, min: rand(60)), end_time: Time.now.change(hour: start_hour + 3, min: rand(60)), day_of_week: dow, dining_opportunity_id: opp.id, dining_place_id: dp.id, institution_id: 1)\n end\n }\n }\n }\nend", "def init_podunk_table(gsheet, opts={})\n opts[:connection] = self\n Table.new(gsheet.rows, opts)\n end", "def preload(connection, records, association, host_table:, schema:, as:, order_by:, limit:)\n return records if records.empty?\n\n expect! records.first => Hash\n\n as = association if as.nil?\n fq_host_table = \"#{schema}.#{host_table}\"\n\n associated_table = find_associated_table(connection, association, schema: schema)\n relation = find_matching_relation(connection, fq_host_table, associated_table)\n\n if fq_host_table == relation.belonging_table\n if order_by || limit\n raise ArgumentError, \"#{association.inspect} is a singular association, w/o support for order_by: and limit:\"\n end\n\n preload_belongs_to connection, records, relation, as: as\n else\n preload_has_one_or_many connection, records, relation, as: as, order_by: order_by, limit: limit\n end\n end", "def load_table_schema(conn, builder, table)\n builder.relvar(table){\n primary_key_columns = load_table_heading(conn, builder, table)\n load_table_constraints(conn, builder, table, primary_key_columns)\n }\n end", "def copy_polymorphic_tables\n self.polymorphic_tables.each do |t|\n polymorphic_id_col, polymorphic_type_col = \"#{t.polymorphic_as}_id\", \"#{t.polymorphic_as}_type\"\n sql_connection.select_rows(t.sql_name) do |rows, page, total_pages|\n Mongify::Status.publish('copy_polymorphic', :size => rows.count, :name => \"Polymorphicizing #{t.name}\", :action => 'add')\n rows.each do |row|\n\n #If no data is in the column, skip importing\n if (row[polymorphic_type_col])\n table_name = row[polymorphic_type_col].tableize\n new_id = no_sql_connection.get_id_using_pre_mongified_id(table_name, get_type_casted_value(t, polymorphic_id_col, row))\n end\n\n row = t.translate(row)\n row[polymorphic_id_col] = new_id if new_id\n row.merge!(fetch_reference_ids(t, row))\n row.delete('pre_mongified_id')\n\n if t.embedded? && table_name\n row.delete(polymorphic_id_col)\n row.delete(polymorphic_type_col)\n save_function_call = t.embedded_as_object? ? '$set' : '$addToSet'\n no_sql_connection.update(table_name, new_id, {save_function_call => {t.name => row}})\n else\n no_sql_connection.insert_into(t.name, row)\n end\n\n Mongify::Status.publish('copy_polymorphic')\n end\n Mongify::Status.publish('copy_polymorphic', :action => 'finish')\n end\n end\n end", "def build_tables\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS breeds(\n id serial NOT NULL PRIMARY KEY,\n breed varchar(30),\n price integer\n )])\n\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS puppies(\n id serial NOT NULL PRIMARY KEY,\n breed varchar(30),\n name varchar(30),\n age integer,\n created_at timestamp NOT NULL DEFAULT current_timestamp\n )])\n\n @db.exec(%q[\n CREATE TABLE IF NOT EXISTS requests(\n id serial NOT NULL PRIMARY KEY,\n breed text,\n status text,\n created_at timestamp NOT NULL DEFAULT current_timestamp\n )])\n end", "def install_initial_state\n db = kernel.resources.db\n db.default.submissions = []\n db.default.valid_submissions = []\n db.default.challengers = []\n db.default.people = (1..5).collect{|i| user_tuple(i, true) }\n db.default.challengers = (1..5).collect{|i| challenger_tuple(i) }\n end", "def bootstrap\n sql = 'CREATE TABLE IF NOT EXISTS states(uuid VARCHAR(128) PRIMARY KEY,'\n sql << ' id INTEGER, name VARCHAR(128), deploy_id VARCHAR(128), timestamp INTEGER,'\n sql << ' missing INTEGER, state VARCHAR(128), hyperv VARCHAR(128))'\n\n @db.execute(sql)\n\n sql = 'CREATE TABLE IF NOT EXISTS settings(key VARCHAR(128) PRIMARY KEY,'\n sql << ' value VARCHAR(128))'\n\n @db.execute(sql)\n end", "def reset_associations\n reflections.each_value do |r|\n r.instance_variable_set(:@quoted_table_name, nil)\n table_name = r.instance_variable_get(:@table_name)\n if (table_name)\n table_name = table_name.split(\".\").last\n klass = r.class_name.constantize\n schema_name = klass.tenanted? ? Roomer.current_tenant.try(:schema_name) : Roomer.shared_schema_name\n schema_name &&= schema_name.to_s\n schema_name ||= \"__no_tenant__\"\n table_name = \"#{schema_name}#{Roomer.schema_seperator}#{table_name}\"\n r.instance_variable_set(:@table_name, table_name)\n r.instance_variable_set(:@quoted_table_name, connection.quote_table_name(table_name))\n end\n end\n end", "def prefix_table\n update unless @prefix_table\n @prefix_table\n end", "def _spreadNewContentGloballyInit\n query = \"PREPARE seen (bigint, bigint) AS INSERT INTO userseen VALUES($1, $2)\"\n $conn.exec(query)\n\n query = \"PREPARE share (bigint, bigint) AS INSERT INTO usershare VALUES($1, $2)\"\n $conn.exec(query)\n\n query = \"PREPARE kill (bigint, bigint) AS INSERT INTO userkill VALUES($1, $2)\"\n $conn.exec(query)\nend", "def reset_data\n @pg_data_table = {}\n @gameview_data_table = {}\n @userlist_table = {}\n @last_parsed_pglist_data = []\n @last_parsed_userlist_data = []\n end", "def preload(records, associations, given_preload_scope = nil)\n if options[:as_of_time]\n preload_scope = given_preload_scope || NULL_RELATION.dup\n preload_scope.as_of_time!(options[:as_of_time])\n end\n\n super records, associations, preload_scope\n end", "def prepare_identities_from_data; end", "def fill_out\n @build = {}\n descend(@schema, [])\n @build\n end", "def build_fact(name, options={})\n options[:rows] ||= 100\n options[:generators] ||= {}\n options[:fk_limit] ||= {}\n rows = []\n\n fact_class = Fact.to_fact(name)\n options[:rows].times do\n row = {}\n fact_class.content_columns.each do |column|\n generator = (options[:generators][column.klass] || @generators[column.klass])\n row[column.name] = generator.generate(column, options)\n end\n fact_class.dimension_relationships.each do |name, reflection|\n # it would be better to get a count of rows from the dimension tables\n fk_limit = (options[:fk_limit][reflection.foreign_key] ||\n options[:dimensions] || 100) - 1\n row[reflection.foreign_key] = rand(fk_limit) + 1\n end\n rows << row\n end\n\n rows\n end", "def sql_load\n row = DBIntf.get_first_row(\"SELECT * FROM #{tbl_name} #{generate_where_on_pk};\")\n return row.nil? ? reset : load_from_row(row)\n end", "def post_load(all_records)\n eager_graph_build_associations(all_records) if @opts[:eager_graph]\n eager_load(all_records) if @opts[:eager] && (row_proc || @opts[:eager_graph])\n super\n end", "def preload\n entries\n collections.each &:preload\n nil\n end", "def setup_associations; end", "def prepare_for_adding_assoc_target(lecture, pre_assoc_items)\n @def_lecture_form_items = Def_Lecture_Form_Items\n @lecture_form_items = Lecture_Form_Items\n @def_lecture_time_form_items = Def_Lecture_Time_Form_Items\n @lecture_time_form_items = Lecture_Time_Form_Items\n @course = find_entity(pre_assoc_items[-2])\n flash_now @course.blank?, \"連結する科目がまだ作られていません.それを作成後,あらためて授業の作成を行ってください.\"\n arrange_environment_from_background\n set_assert_time_as_end_of_academic_season_range\n # default since through whole composite entity\n @default_since = beginning_of_academic_season(@academic_year, @academic_season)\n unless @course.blank?\n lecture.build_course(@course)\n @course.since = @root_entity_since\n @course.course_classes.reject(&:new_record?).map do |cc| \n lecture.lecture_course_classes.build(:course_class_run_id => cc.run_id)\n end\n @course_classes = @course.course_classes\n end\n @default_since = beginning_of_academic_season\n lecture.since = @root_entity_since\n lecture.lecture_member__teachers.build\n lecture.lecture_times.build\n end", "def association_symbol_for_rows\n @importing_reflection ||= self.class.import_into\n end", "def import_datas_into_master_tabel\n if params[:real_estate_property][\"remote_property_name\"] && remote_property(@property.accounting_system_type_id)\n remote_property = RealEstateProperty.find_by_sql(\"select HMY as hmy_id from #{find_table_name + '_Property'} where SCODE = '#{params[:real_estate_property][\"property_code\"].strip}' and SADDR1 = '#{params[:real_estate_property][\"remote_property_name\"].strip}'\")\n if remote_property && !remote_property.empty?\n connection = ActiveRecord::Base.connection();\n connection.execute(\"INSERT INTO `remote_properties` (`HMY` ,`real_estate_property_id` ,`accounting_system_type_id`) VALUES ('#{remote_property[0].hmy_id}',#{@property.id},#{@property.accounting_system_type_id})\")\n end\n hmy = RealEstateProperty.find_by_sql(\"select HMY as hmy_id from remote_properties where real_estate_property_id = #{@property.id} limit 1\")[0]\n Delayed::Job.enqueue DelayedPropertyDataImport.new(@property.id,current_user.id,find_table_name,hmy.hmy_id.to_i,@property.portfolio.leasing_type,@property.property_name,@property.property_code,@property.portfolio_id)\n end\n end", "def prepare_hgt_com_trsf_prkgrs_old()\n \n @conn.execute \\\n \"truncate table hgt_com_trsf_prkgrs\"\n \n puts \"hgt_com_trsf_prkgrs table truncated...\"\n \n #\n sql = \"select id,\n gene_id,\n TXSRC_ID,\n TXDST_ID,\n WEIGHT_TR_TX\n from HGT_COM_TRSF_TAXONS\"\n \n #puts \"sql: #{sql}\"\n \n \n tr_taxons = HgtComTrsfTaxon.find_by_sql(sql)\n \n tr_taxons.each {|tr|\n \n\n #debugging\n #next unless tr.gene_id == 111 and tr.txsrc_id == 768679 and tr.txdst_id == 374847\n \n #puts \"tr: #{tr.inspect}\"\n #puts \"tr.id: #{tr.id}, #{tr.gene_id}\"\n \n #for each chiteria\n (0..1).each {|crit|\n \n #for each criteria and\n #for each source and destination prok groups\n sql = \"select tg.PROK_GROUP_ID,\n tg.WEIGHT_PG\n from TAXON_GROUPS tg \n join PROK_GROUPS pg on pg.id = tg.PROK_GROUP_ID\n where tg.TAXON_ID = #{tr.txsrc_id} and\n pg.GROUP_CRITER_ID = #{crit}\"\n #puts \"sql: \\n #{sql}\"\n \n pg_src = TaxonGroup.find_by_sql(sql)\n \n \n sql = \"select tg.PROK_GROUP_ID,\n tg.WEIGHT_PG\n from TAXON_GROUPS tg \n join PROK_GROUPS pg on pg.id = tg.PROK_GROUP_ID\n where tg.TAXON_ID = #{tr.txdst_id} and\n pg.GROUP_CRITER_ID = #{crit}\"\n #puts \"sql: \\n #{sql}\"\n \n pg_dst = TaxonGroup.find_by_sql(sql)\n \n pg_src.each {|src|\n pg_dst.each {|dst|\n \n #puts \"src: #{src.inspect}\"\n #puts \"dst: #{dst.inspect}\"\n \n #insert alternative\n prkg = HgtComTrsfPrkgr.new \n prkg.gene_id = tr.gene_id\n prkg.hgt_com_trsf_taxon_id = tr.id\n prkg.pgsrc_id = src.prok_group_id\n prkg.pgdst_id = dst.prok_group_id\n prkg.weight_tr_pg = tr.weight_tr_tx * src.weight_pg * dst.weight_pg\n prkg.save\n \n #prkg.gene_id = tr.gene_id \n #prkg.save\n \n \n }\n }\n \n \n \n \n \n } \n }\n \n \n end", "def auto_assoc(opts = {})\n except = opts[:except] || []\n\n assocs = db.schema_parse_associations(table_name)\n relations = process_join_tables(assocs)\n\n relations.each do |row|\n src_tbl = row[:src_tbl]\n src_col = row[:src_col]\n if src_tbl == table_name && ! (src_col & except).empty?\n # TODO enable except for *_to_many\n next\n end\n src_uniq = row[:src_uniq]\n src_cardinality = cardinality(src_uniq)\n\n join_tbl = row[:join_tbl]\n\n dst_tbl = row[:dst_tbl]\n dst_col = row[:dst_col]\n dst_uniq = row[:dst_uniq]\n dst_cardinality = cardinality(dst_uniq)\n\n TABLE_MODELS.wait_all(src_tbl, dst_tbl) do |src_cls, dst_cls|\n self_ref = src_cls == dst_cls\n\n src = self_ref ? :child : underscore(src_cls.name).to_sym\n src = src_uniq ? singularize(src).to_sym : pluralize(src).to_sym\n\n dst = self_ref ? :parent : underscore(dst_cls.name).to_sym\n dst = dst_uniq ? singularize(dst).to_sym : pluralize(dst).to_sym\n\n if join_tbl\n left_col = row[:left_col]\n right_col = row[:right_col]\n send :many_to_many, src, :class => src_cls, :join_table => join_tbl,\n :left_key => left_col, :left_primary_key => dst_col,\n :right_key => right_col, :right_primary_key => src_col\n else\n # TODO name overrides\n\n if self == dst_cls\n # dst holds the foreign key -> one_to_*\n meth = dst_cardinality + '_to_' + src_cardinality\n send meth, src, :class => src_cls, :key => src_col, :primary_key => dst_col\n end\n\n if self == src_cls\n # src holds the foreign key -> *_to_one\n meth = src_cardinality + '_to_' + dst_cardinality\n\n # one_to_one requires to swap pk and fk\n src_col, dst_col = dst_col, src_col if src_uniq\n send meth, dst, :class => dst_cls, :key => src_col, :primary_key => dst_col\n end\n end\n\n end\n end\n end", "def preload(*args)\n fresh.tap do |criteria|\n criteria.preload_values = (preload_values || []) + args\n end\n end", "def setup\n begin\n create_campaign_table_if_not_exist\n seed_data\n rescue Exception => e\n raise \"Database setup failed with error #{e}\"\n ensure\n @connection.close\n end\n end", "def initialize\n @columns = { }\n @primary_keys = []\n @to_avoid = []\n @default_values = { }\n @associations = \n {\n :belongs_to => { },\n :has_one => { },\n :has_n => { }\n }\n end", "def preload_posts(records)\n cards = records.map(&:card)\n post_ids = records.map(&:post_id)\n card_post_ids = cards.map(&:post_id)\n\n posts = posts_scope.where(id: (post_ids + card_post_ids)).index_by(&:id)\n records.each do |rec|\n rec.post = posts[rec.post_id]\n end\n\n cards.each do |card|\n card.post = posts[card.post_id]\n end\n end", "def initialize(associations)\n @left_joins_by_alias = {}\n last_table_alias = nil\n associations.each_with_index do |association, association_path_index|\n # Important, this variable will take the last joined table to chain the join, in the first loop, will take\n # the association origin table name.\n last_table_alias ||= association.active_record.table_name\n left_join = Babik::QuerySet::Join.new_from_association(association, association_path_index, last_table_alias)\n\n @left_joins_by_alias[left_join.target_alias] = left_join\n last_table_alias = left_join.target_alias\n end\n @target_alias = last_table_alias\n end", "def initial_columns(with_excluded = false)\n # Normalize here, as from the config we can get symbols (names) instead of hashes\n columns_from_config = config[:columns] && normalize_attrs(config[:columns])\n\n\n if columns_from_config\n # automatically add a column that reflects the primary key (unless specified in the config)\n columns_from_config.insert(0, {:name => data_class.primary_key}) unless columns_from_config.any?{ |c| c[:name] == data_class.primary_key }\n\n # reverse-merge each column hash from config with each column hash from exposed_attributes\n # (columns from config have higher priority)\n for c in columns_from_config\n corresponding_default_column = default_columns.find{ |k| k[:name] == c[:name] }\n c.reverse_merge!(corresponding_default_column) if corresponding_default_column\n end\n columns_for_create = columns_from_config\n else\n # we didn't have columns configured in component's config, so, use the columns from the data class\n columns_for_create = default_columns\n end\n\n filter_out_excluded_columns(columns_for_create) unless with_excluded\n\n # Make the column config complete with the defaults\n columns_for_create.each do |c|\n detect_association(c)\n set_default_virtual(c)\n set_default_header(c)\n set_default_editor(c)\n set_default_width(c)\n set_default_hidden(c)\n set_default_editable(c)\n set_default_sortable(c)\n set_default_filterable(c)\n end\n\n columns_for_create\n end", "def prep\n\tend", "def preload\n presenter.preload(resolved_associations_map.flat_map {|k,v| v[:associations]})\n end", "def set_initial_values(accountsHash,name,row)\n\tunless accountsHash.has_key?(name)\n\t\taccountsHash[name] = AccountClass.new\n\t\taccountsHash[name].initial_values\n\tend\n\tunless accountsHash[name].getCategoryData.has_key?(row[\"Category\"].chomp)\n\t\taccountsHash[name].addCategory(row)\n\tend\n\treturn accountsHash\nend", "def initialize_copy(orig)\n super\n @table = @table.dup\n end", "def import_table( table )\n # This must come first, so we can exclude foreign key indexes later.\n import_foreign_keys( table )\n import_indexes( table )\n import_columns( table )\n end", "def post_processing_tables(nodes)\n tables = nodes\n .css('table:not(.o-ld-columns-table)')\n .add_class('c-ld-table')\n tables.wrap('<div class=\"c-ld-table__wrap\"></div>') unless @options[:material]\n end", "def create_users_products\n @db.create_join_table(:user_id => :users, :product_id => :products) do\n end\n end", "def copy_new_rows\n tables.each(&:copy_new_rows)\n end", "def populate(options={})\n populate_rollup_cube\n end", "def vendor_table\n update unless @vendor_table\n @vendor_table\n end", "def make\n if dimension?\n dimension_key_builder\n elsif fact?\n FactKeyBuilder.new(staging_db[table.table_name])\n end\n end", "def fill_bag_from(source)\n self.class.bag.columns.each do |column|\n column_name = column.name\n if source.respond_to?(column_name) && self.send(column_name).blank?\n self.send(\"#{column_name}=\", source.send(column_name)) \n end\n end\n end", "def proposal_details_rows_to_insert_sql\n sql = <<-SQL\n SELECT * FROM (\n #{all_proposal_details_rows_sql}\n ) all_rows_in_table_name\n WHERE ProposalNature IS NOT NULL\n OR ProposalOutcome IS NOT NULL\n OR ProposalRepresentation IS NOT NULL\n EXCEPT\n SELECT\n d.elib_legacy_id,\n dd.proposal_nature,\n outcomes.name,\n dd.representation,\n dd.proposal_number\n FROM (\n #{all_rows_sql}\n ) nc\n JOIN documents d ON d.elib_legacy_id = nc.DocumentID\n JOIN proposal_details dd ON d.id = dd.document_id\n JOIN document_tags outcomes ON dd.proposal_outcome_id = outcomes.id\n SQL\n end", "def populate_table_with_id_value_normalized_value(database, table_name, source_type, csv_file)\n return if database.table_exists?(table_name)\n database.create_table table_name do\n # primary_key :id\n Integer :id, primary_key: true, index: {unique: true} # non-autoincrementing\n String :value\n foreign_key :normal_form_id, index: true\n end\n data = File.readlines(csv_file).drop(1).map{|line|\n id, value, normal_form = line.chomp.split(\"\\t\", 3)\n normal_form_id = DB[:normal_forms].where(value: normal_form, source_type: source_type).get(:id)\n normal_form_id ||= DB[:normal_forms].insert(value: normal_form, source_type: source_type)\n [Integer(id), value, normal_form_id]\n }\n database[table_name].import([:id, :value, :normal_form_id], data)\nend", "def create_side_table\n RailsRedshiftReplicator.connection.exec \"CREATE TABLE #{temporary_table_name} (LIKE #{replication.target_table})\"\n end", "def insert_table(table, identifier, data)\n if existing_data = get_table(table, identifier)\n if existing_data.empty? || !existing_data.has_key?('.members')\n data.each { |key, value| existing_data[key] = value }\n return data\n else\n error_report \"Error in insert_table: Redefinition of #{identifier}\"\n raise ParseError\n end\n end\n\n table['table_data'].push([identifier, data])\n table['quick_look'][identifier] = 1\n return data\nend", "def insert_table(table, identifier, data)\n if existing_data = get_table(table, identifier)\n if existing_data.empty? || !existing_data.has_key?('.members')\n data.each { |key, value| existing_data[key] = value }\n return data\n else\n error_report \"Error in insert_table: Redefinition of #{identifier}\"\n raise ParseError\n end\n end\n\n table['table_data'].push([identifier, data])\n table['quick_look'][identifier] = 1\n return data\nend", "def preload(association, as: nil, order_by: nil, limit: nil)\n expect! association => Symbol\n expect! as => [nil, Symbol]\n\n # resolve oid into table and schema name.\n #\n # [TODO] is this still correct?\n schema, host_table = connection.reflection.lookup_pg_class @pg_source_oid\n\n AssociationLoader.preload connection,\n @hash_records, association,\n host_table: host_table, schema: schema, as: as,\n order_by: order_by, limit: limit\n\n @associations << association\n\n materialize\n end", "def setup\n current_user = options[:currentuser]\n all_flag = options[:allflag]\n if current_user.percentcompleteenabled\n table = Table([:description, :category_label, :created_date, :last_updated_date, :percentcomplete]) do |t|\n if all_flag\n current_user.tasks.find(:all).each {|u| t << u.report_record() }\n else\n completed_category = current_user.category.find(:all, :conditions => [\n \"label = 'Completed'\"\n ])\n current_user.tasks.find(:all).each {|u| t << u.report_record unless u.category_id == completed_category[0].id}\n end\n end\n table.rename_columns(:description => \"Description\",\n :category_label => \"Task Category\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\",\n :percentcomplete => \"Percent Complete\")\n else\n table = Table([:description, :category_label, :created_date, :last_updated_date]) do |t|\n if all_flag\n current_user.tasks.find(:all).each {|u| t << u.report_record() }\n else\n completed_category = current_user.category.find(:all, :conditions => [\n \"label = 'Completed'\"\n ])\n current_user.tasks.find(:all).each {|u| t << u.report_record unless u.category_id == completed_category[0].id}\n end\n end\n table.rename_columns(:description => \"Description\",\n :category_label => \"Task Category\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\")\n end\n \n self.data = table\n end", "def join_table_source\n cached_fetch(:join_table_source){split_join_table_alias[0]}\n end", "def initialize_copy(original)\n super\n @table = @table.dup\n end", "def autogrow_hashes\n wait_until_bus_section_load\n tables.last.hashes\n end", "def populate\n AgentProcess.all.each { |a| update(a.name, a) }\n end", "def preload_fields_with(params)\n params.each_key do |field|\n self.public_send(\"#{field}=\", params[field])\n end\n end", "def before_create\n self[:TableID] = 1\n self[:Type] = 0 # FIXME: guess\n super\n end", "def spawn_tables\n\t# pseudo-migration / schema\n\tif !FeedEntry.table_exists?\n\t\tprint \"Creating feed entry table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:feed_entries) do |t|\n\t\t\tt.column :name, :string\n\t\t\tt.column :content, :string\n\t\t\tt.column :url, :string\n\t\t\tt.column :guid, :string\n\t\t\tt.column :published_at, :datetime\n\t\t\tt.column :feed_id, :integer\n\t\tend\n\tend\n\tif !Feed.table_exists?\n\t\tprint \"Creating feed table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:feeds) do |t|\n\t\t\tt.column :url, :string\n\t\tend\n\tend\n\tif !Blacklist.table_exists?\n\t\tprint \"Creating blacklist table...\\n\"\n\t\tActiveRecord::Base.connection.create_table(:blacklists) do |t|\n\t\t\tt.column :word, :string\n\t\tend\n\tend\nend", "def PopulateProducts #Not used\n @@db_instant.PopulateProducts\n end", "def reload_nested_set\n reload(:select => \"#{quoted_left_column_name}, \" +\n \"#{quoted_right_column_name}, #{quoted_parent_column_name}\")\n end", "def setup_departments\n Department.delete_all \n Employee.delete_all\n dep = Department.create(:name=> 'department1', :city => 'Littleton', :state => 'CO') \n employee1 = dep.employees.create(:first_name=>\"first_1\", :last_name =>\"last_1\", :job_id => 12) \n employee2 = dep.employees.create(:first_name=>\"first_2\", :last_name =>\"last_2\", :job_id => 12) \n employee3 = dep.employees.create(:first_name=>\"first_3\", :last_name =>\"last_3\", :job_id => 12) \n employee3.manager = employee1\n \n departments = {:department1 => dep,\n :department2 => Department.create(:name=> 'department2', :city => 'Littleton', :state => 'CO') ,\n :department3 => Department.create(:name=> 'department3', :city => 'Littleton', :state => 'CO') \n }\n departments\n end", "def add_facts(data)\n record_id = assert_record_id(data)\n insert_facts_record record_id, data\n end", "def populate\n # User\n #@users = User.all.order(:name)\n #@user = User.new\n\n # Location\n @locations = Location.all.order(:name)\n @location = Location.new\n\n # Cateogry\n @categories = Category.all.order(:name)\n @category = Category.new\n\n # Course\n @courses = Course.all.order(:name)\n @course = Course.new\n end", "def prepare_orm_data_for_filters\n self.data_grid.columns.each do |col|\n next if col.filter.nil? # if no filter\n\n # Prepare auto filters\n if col.filter == :auto\n col.filter_data = self.data_grid.data_class.select(\"DISTINCT (#{col.filter_by}) as fc\").to_a.to_a.map(&:fc)\n end\n\n col.filter_data.uniq!\n col.filter_data.sort!\n end\n end" ]
[ "0.80255306", "0.74827445", "0.6295784", "0.58048487", "0.55817306", "0.5358085", "0.5300262", "0.5279212", "0.5266691", "0.5205254", "0.51967645", "0.5195885", "0.5181098", "0.5102876", "0.5089507", "0.50233686", "0.5011442", "0.50093275", "0.49745193", "0.49037144", "0.4902029", "0.48977768", "0.48869017", "0.48868543", "0.4853503", "0.4842215", "0.48242575", "0.4823016", "0.47939062", "0.47846496", "0.4777104", "0.47653717", "0.47652736", "0.47627953", "0.47481382", "0.47398347", "0.47229302", "0.47141203", "0.471361", "0.4709851", "0.47034565", "0.46977517", "0.4683772", "0.46690556", "0.46684885", "0.4666461", "0.4664414", "0.46616247", "0.46582827", "0.4648746", "0.4648686", "0.46481022", "0.46464023", "0.4641365", "0.46401206", "0.46358883", "0.46310398", "0.46187937", "0.46132958", "0.46121627", "0.46010715", "0.45852506", "0.45807582", "0.45774457", "0.45746472", "0.45736146", "0.45724732", "0.45691675", "0.45560575", "0.4551608", "0.45393816", "0.45370397", "0.45355392", "0.45319563", "0.45299786", "0.45276123", "0.45263103", "0.45069805", "0.45038784", "0.44956204", "0.4490928", "0.44903436", "0.4488783", "0.4487385", "0.4487385", "0.44851524", "0.44837114", "0.4483117", "0.44721153", "0.44616988", "0.4460338", "0.44594437", "0.44582492", "0.44575125", "0.44557428", "0.44534427", "0.4452857", "0.44500223", "0.44432428", "0.44361314" ]
0.84082294
0
this page allows you to add food items to a participant
def edit @food_item = @participant.food_items.new end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_food(food)\n food_meals.create(food_id: food.id)\n end", "def update\n @food_item = @restaurant.food_items.find_by(name: params[:new_food_item])\n if @food_item.nil?\n # here we are taking user input and inserting it into the flash, thus the flash needs to be sanitized before displayed\n # this happens automatically with rails and should not be disabled\n flash[:danger] = \"Sorry we were not able to find the food item #{params[:new_food_item]} at the restaurant.\"\n else\n @participant.food_items << @food_item\n @participant.processed = true\n @participant.save\n end\n respond_to do |format|\n format.js {\n render partial: 'add_food_item', food_item: @food_item\n }\n format.json {\n render json: food_item\n }\n format.html {\n redirect_to edit_meal_participant_path(@meal, @participant)\n }\n end\n end", "def create\n @food_item_add_on = FoodItemAddOn.new(food_item_add_on_params)\n\n\n\n#Todo: can select multiple items for a sinfle addons\n respond_to do |format|\n if @food_item_add_on.save\n format.html { redirect_to :controller => 'home', :action => 'dashboard' }\n format.json { render :show, status: :created, location: @food_item_add_on }\n else\n format.html { render :new }\n format.json { render json: @food_item_add_on.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\t food_params = params.require(:food).permit(:name, :exercise, :calories, :time)\n\t\t food = Food.create(food_params)\n\t\t current_user.foods << food\n\t\t if food.save\n\t\t \tredirect_to \"/users/#{current_user.id}\"\n\t\t end\n\tend", "def add_item\n\t puts \"What is the name of the item you'd like to add?\"\n\t\t@item_name = gets.chomp\n\t\tputs \"And how many?\"\n\t\t@quantity = gets.chomp.to_i\n\t\tif @quantity <= 0\n\t\t puts \"Please enter a number higher than 0.\"\n\t\t puts \"(Also, must be '1' not 'one'.)\"\n\t\telse\n\t\t @grocery_list[@item_name] = @quantity\n\t\tend\n\t\tget_item\n\tend", "def add\n\t\tputs \"\\nEnter the name of the item you would like to add:\"\n\t\tnew_item = gets.chomp\n\t\tputs \"\\nHow many #{new_item} would you like?\"\n\t\tnew_qty = gets.chomp\n\t\t@grocery_list.add(new_item, new_qty)\n\t\tputs \"\\nAdding #{new_item} to list...\"\n\t\tputs \"#{new_qty} #{new_item} were added to your Grocery List!\"\n\tend", "def add_item (grocery, item_name, quantity)\n grocery[item_name] = quantity\n display_list(grocery)\n end", "def add_item\n\t\tcurrent_user.saved.items.push(Item.find(params[:item]))\n\t\tredirect_to :back\n\tend", "def add_to\n begin\n study = Study.find(params[:study_id])\n unless study.user_id != session[:user_id] || study.active == true\n i = Item.new\n i.study_id = params[:study_id]\n i.name = params[:item_name]\n i.description = params[:item_description]\n unless i.save\n flash[:error] = \"Please enter a valid item name and description.\"\n end\n end\n rescue\n\n ensure\n redirect_to(edit_study_path(params[:study_id]))\n end\n end", "def add_ingredient_to_recipe quantity, measure, food_item_name, recipe \n food_item = FoodItem.new(:name => food_item_name, :price => nil)\n ingredient = Ingredient.new(:food_item => food_item, :quantity => quantity, :measure => measure, :recipe_id => recipe.id)\n recipe.ingredients << ingredient\n end", "def add_item(item)\n @chores << item\n end", "def add_item\n puts \"What food item would you like to add to the grocery store?\"\n new_item_rec = gets.chomp!\n if new_item_rec.empty?\n puts \"You must provide a name for the item\"\n add_item\n else\n end\n puts \"How many of that item would you like to add?\"\n new_item_inv = gets.chomp!\n if new_item_inv.empty?\n puts \"You must provide an inventory amount for the item\"\n puts \"How many of that item would you like to add?\"\n new_item_inv = gets.chomp!\n else\n end\n puts \"How much would it cost?\"\n new_item_cost = gets.chomp!\n if new_item_cost.empty?\n puts \"You must provide a cost for the item\"\n puts \"How much would it cost?\"\n new_item_cost = gets.chomp!\n else\n end\n new_item = {name: new_item_rec, inventory: new_item_inv.to_i, price: new_item_cost.to_f}\n @food_items.push(new_item)\n food_list\n puts 'Add another item? y/n -->' \n choice = gets.strip.downcase\n if choice == 'y'\n add_item\n else \n menu\n end\nend", "def add\n # 1. Ask the user for the meal name and store in var\n name = @meal_view.ask_name\n # 2. Ask the user for the meal price and store in var\n price = @meal_view.ask_price\n # 3. Create a new meal instance with those values\n meal = Meal.new(name: name, price: price)\n # 4. Add to repository using #create\n @meal_repo.create(meal)\n end", "def add(food)\n foodList << food\nend", "def add\n # ask user for name and price\n attributes = {\n name: @view.ask_for_string(:name),\n price: @view.ask_for_number(:price)\n }\n # make new meal object\n # pass that to the repo\n @meals_repo.add(Meal.new(attributes))\n end", "def add\n # ask user for name and price\n attributes = {\n name: @view.ask_for_string(:name),\n price: @view.ask_for_number(:price)\n }\n # make new meal object\n # pass that to the repository\n @meals_repository.add(Meal.new(attributes))\n end", "def add\n meal_name = @view.ask_name\n meal_price = @view.ask_price.to_i\n new_meal = Meal.new({name: meal_name, price: meal_price})\n @meals_repository.add(new_meal)\n end", "def addItem\n begin\n ProgrammeItem.transaction do\n @assignment = nil\n if !params[:cancel]\n item = ProgrammeItem.find(params[:itemid])\n room = Room.find(params[:roomid])\n day = params[:day]\n time = params[:time].to_time # The start time\n\n @assignment = addItemToRoomAndTime(item, room, day, time)\n end\n\n render :layout => 'content'\n end\n rescue => ex\n render status: :bad_request, text: ex.message\n end\n end", "def create\n @todo_item = @todo_list.todo_items.create(todo_item_params) \n redirect_to @todo_list, notice: \"Todo item added\"\n end", "def create\n @part_types = Constants::PART_TYPES\n @item = Item.new(item_params.merge(user_id: current_user.id))\n \n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: \"Item was successfully created.\" }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :created)\n end", "def create\n @fulfillment = Fulfillment.new(params.require(:fulfillment).permit(:buyer_name, :buyer_email, :quantity, :message, :item_id))\n item = Item.find(@fulfillment.item_id)\n item.fulfilled += @fulfillment.quantity\n item.save\n gift = pluralize_gift(@fulfillment, item)\n if @fulfillment.save\n flash[:notice] = \"Thank you! #{item.user.couple_full_names} were informed that you will be buying them #{@fulfillment.quantity} #{gift}\"\n else\n flash[:error] = \"There was an error processing your request. Please try again.\"\n end\n redirect_to :back\n end", "def create\n @ingredient = Ingredient.find(params[:id])\n \n @supplier.ingredients << @ingredient\n redirect_to supplier_path(@supplier)\n end", "def add_item\n #params[item_id]\n end", "def add_item(item, quant=0)\n\t$grocery_list.store(item, quant)\n\tp \"You added #{item} to your list.\"\nend", "def add_to_user\n @user = current_user;\n @user.diet_type = DietType.find_by_name(diet_type_params[:name])\n \n respond_to do |format|\n flash[:success] = 'diet type was successfully add.'\n format.html { redirect_to action:\"index\" }\n end\n end", "def add_an_item\n item = Item.new\n item.description = \"Task number #{to_do_list.size+1}\"\n to_do_list << item\n end", "def brief_vendor_add_item\n brief = Brief.find(params[:brief_id])\n brief_vendor = brief.brief_vendors.find_by_org_id(params[:vendor_id])\n brief_vendor.items << Item.new{|r| r.parent_id = params[:item_id]}\n\n redirect_to(cheil_brief_vendor_items_path(params[:brief_id],params[:vendor_id])) \n end", "def create\n @fooditem = Fooditem.new(params[:fooditem])\n\n respond_to do |format|\n if @fooditem.save\n format.html { redirect_to @fooditem, :notice => 'Fooditem was successfully created.' }\n format.json { render :json => @fooditem, :status => :created, :location => @fooditem }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @fooditem.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_food_item\n @food_item = current_restaurant.restaurant_food_items.find_by(uuid: params[:id])\n end", "def create\n my_facility = MyFacility.find(params[:my_facility_id])\n current_user.add_favorite(my_facility)\n flash[:success] = \"お気に入りに追加しました\"\n redirect_back(fallback_location: root_path)\n end", "def add_item\n puts \"What's the item you want to add to your giftlist?\"\n item_to_add = gets.chomp.downcase\n $list << { gift_name: item_to_add, gift_status: \"[ ]\" }\nend", "def add_multiple_food_items(items)\n items.each do |item|\n item['_id'] = FoodItem.create_id item[:api_key], item[:item_id]\n FoodItem.new_item item\n end\n items\n end", "def set_food_item\n @food_item = @current_user.food_items.find(params[:id])\n end", "def set_food_item\n @food_item = FoodItem.find(params[:id])\n end", "def create_item(list_id, content, responsible_party=nil, notify=true)\n record \"/todos/create_item/#{list_id}\",\n :content => content, :responsible_party => responsible_party,\n :notify => notify\n end", "def add_item(electives, item)\n puts electives.push(\"debate club\")\nend", "def add\n\n item = params[:item]\n type = params[:type]\n\n added = nil\n\n if type=='song'\n\n if Favorite.exist_song(item, user_signed_in?, current_user)\n added = Song.quit_favorite(item, user_signed_in?, current_user)\n else\n added = Song.add_favorite(item, user_signed_in?, current_user)\n end\n \n end\n\n if type=='movie'\n\n year = item['year']\n name = item['name']\n\n if Favorite.exist_movie(year, name, user_signed_in?, current_user)\n added = Movie.quit_favorite(item, user_signed_in?, current_user)\n else\n added = Movie.add_favorite(item, user_signed_in?, current_user)\n end\n\n end\n\n response = {\n :added => added,\n }\n \n render :json =>response\n \n end", "def add_item_to_list(grocery_list, grocery_item, quantity = 1)\n grocery_list.store(grocery_item,quantity)\n puts \"I've added #{grocery_item} to the list. Please pick up #{quantity} of these.\"\nend", "def save_to_inventory\n @user = User.find(params[:id])\n @item = Item.find(1)\n @user.items.push(@item)\n end", "def add_item\r\n session[:items] << params[:id]\r\n redirect_to root_url\r\n end", "def create\n @item = @client.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully added.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_favourites\n \n #pull out whichever recipe you are clicking on\n yummly_id = params[:yummly_id]\n recipe = Yummly.find(yummly_id)\n\n # make new instance of that recipe\n r = Recipe.find_or_create_by(name: recipe.name, thumbnail: recipe.thumbnail)\n\n UserFavouriteRecipe.create(recipe_id: r.id, user_id: current_user.id, yummly_id: yummly_id)\n\n redirect_to recipes_url, notice: \"Added recipe from your list of favourite recipes\"\n\n end", "def add_to_total(food)\n Farm.add_food(food)\n end", "def add_to_collection\n\n if request.post?\n # Actually add the item to the collection\n ids = request.params[:id].split(',')\n ids.each do |id|\n add_to_collection_action(request.params[:collection], id)\n end\n\n # Don't render the default \"Add to Collection\" dialog - render the \"Success!\" dialog contents\n flash[:success] ||= \"The item has been added to the collection\"\n render 'catalog/add_to_collection_success'\n end\n\n end", "def create\n @ingredient = Ingredient.new(params[:ingredient])\n @food = Food.find_by_name(params[:food][:name])\n @ingredient.food_id = @food.id if @food\n respond_to do |format|\n if @recipe.ingredients << @ingredient\n flash[:notice] = 'Ingredient was successfully added.'\n format.html { redirect_to recipe_url(@recipe) }\n format.js\n format.xml { head :created, :location => ingredient_url(@ingredient) }\n else\n format.html { render :action => \"new\" }\n format.js\n format.xml { render :xml => @ingredient.errors.to_xml }\n end\n end\n end", "def add_item_to_the_room\n @item = Item.find(params[:id])\n @room = Room.find(params[:room_id])\n \n @item.rooms << @room\n \n render json: @item, include: :rooms\n\n end", "def add_item(item_name, grocery_list, quantity=1)\n grocery_list[item_name] = quantity\n grocery_list\n end", "def add_item(list, item, quantity = 1)\r\n# input: list, item name, and optional quantity\r\n# steps: \r\n # check for optional quantity. if not present, set to default (1)\r\n list[item] = quantity\r\n # update list with input\r\n puts \"#{item.upcase} has been added to your grocery list!\"\r\n p list\r\n# output: complete list, updated\r\nend", "def create\n @intowel = Intowel.find(params[:intowel_id])\n \n #verifica se o produto foi selecionado\n if item_params[:product_id].blank?\n flash[:warning] = 'Selecione o item desejado!'\n redirect_to intowel_path(@intowel) and return\n end\n \n #verifica se já existe o mesmo item adicionado na venda\n check_item = Item.where(intowel_id: @intowel.id, product_id: item_params[:product_id])\n if check_item.present?\n flash[:warning] = 'Este item já foi adicionado!'\n redirect_to intowel_path(@intowel) and return\n end\n \n if item_params[:qnt].blank?\n flash[:warning] = 'Informe uma quantidade para o item selecionado!'\n redirect_to intowel_path(@intowel) and return\n end\n \n @item = @intowel.items.create(item_params)\n redirect_to intowel_path(@intowel)\n end", "def eat(food)\n @foods_eaten << food\n end", "def add_item\n\t\tputs \"Welcome to the Jones market\"\n\t\tputs \" \"\n\t\tputs \"please input product name\"\n\t\tproduct_name = gets.chomp\n\t\tputs \"please input the price\"\n\t\tprice = gets.chomp.to_i\n\n\t\tproduct_type(product_name, price)\n\tend", "def add\n cur_user = current_user.role_id\n pid = params[:id]\n if Member.find(cur_user).favoriteds.create(\n :member_id=>cur_user, :employer_id=>pid\n )\n flash[:notice] = 'Employer added to Faved list!'\n else\n flash[:alert] = 'There was a problem adding Employer to Faved list.'\n end\n redirect_to :action => 'display', :id =>(pid)\n end", "def add_new(type, new_item)\n #Add exercise to exercise_list\n if type == \"exercise\"\n @exercise_list.push(new_item)\n return 0\n #Add a workout to workout_routines\n elsif type == \"workout\"\n @workout_routines.push(new_item)\n return 0\n #Error handling\n else\n return -1\n end\n\n end", "def add1\n bp = bpn\n bp.add_list_item('Apollo13',actors,hanks)\nend", "def add(args)\n return @client.api_helper.add(args, \"item_add\")\n end", "def add_favorite_food(food_id)\n post(\"/user/#{@user_id}/foods/log/favorite/#{food_id}.json\")\n end", "def add_item(order_id, item_sku, price, quantity, name = nil, category = nil, utmhid = random_id)\n check_account_params\n hey(item_params(order_id, item_sku, name, category, price, quantity, utmhid))\n end", "def add_to_database\n Partner.add({\"assignment_id\" => \"#{self.assignment_id}\", \"name_worked\" => \"#{self.name_worked}\"})\n end", "def add_item(list, food_item, quantity_of_food = 1)\n list[food_item] = quantity_of_food\n list\nend", "def item_create\n @brief = Brief.find(params[:brief_id])\n @brief_vendor = @brief.brief_vendors.find_by_org_id(@cur_user.org_id)\n invalid_op unless @brief_vendor\n @brief_vendor.items << Item.new(params[:item]){|r|r.kind = params[:kind]}\n redirect_to vendor_show_brief_path(@brief)\n end", "def add(pizza)\n @contents << pizza\n end", "def add\n\t\tputs \"\\n\\n\\nAdd a restaurant\\n\\n\".upcase\n\t\trestaurant = Restaurant.build_using_questions\n\t\tif restaurant.save\n\t\t\tputs \"\\nRestaurant Added\\n\\n\"\n\t\telse\n\t\t\tputs \"\\nSave Error: restaurant not added\\n\\n\"\t\n\t\tend\n\tend", "def create\n\n \t\t@item = current_user.items.build(item_params)\n \t\tif @item.save\n \t\t\tflash[:success] = \"Item created!\"\n \t\t\tredirect_to items_path\n \t\telse\n \t\t\t@feed_items = []\n \t\t\trender 'static_pages/home'\n \t\tend\n \tend", "def add_ingredients\n rid = params['id']\n name = params['name']\n quant = params['quantity']\n meas = params['measurement']\n\n ingredients = {\n 'name' => name,\n 'quantity' => quant,\n 'measurement' => meas,\n }\n\n if Aws.save_ingredient_to_db(rid, ingredients)\n msg = {:notice => \"Ingredient created!\"}\n render :json => msg\n else\n msg = {:notice => \"Error while creating ingredient!\"}\n render :json => msg\n end\n end", "def add_recipe\n recipe = Recipe.find_by_id(params[:id])\n\n recipe.ingredients.each do |ingredient|\n listItem = ingredient_to_list_item(ingredient)\n listItem.quantity = listItem.quantity.to_f * params[:scale].to_f #if something has been scaled\n\n if logged_in?\n listItem.user = current_user\n listItem.save\n else\n session[:list_items] ||= {id: 0}\n listItem.id = session[:list_items][:id]\n session[:list_items][listItem.id] = listItem\n session[:list_items][:id] += 1\n end\n end\n\n respond_to do |format|\n format.html do\n redirect_to :shopping_list\n end\n format.json do\n render json: true\n end\n end\n end", "def eat(food)\n @foods_eaten.push(food)\n end", "def create\n if mass_recipe.valid?\n flash[:notice] = \"#{mass_recipe.item_id_collection.size} items were added\"\n mass_recipe.create_recipes!\n end\n respond_with(mass_recipe, :location => profession_path(mass_recipe.recipe_group.profession))\n end", "def create\n @action_item = ActionItem.new(params[:action_item])\n @action_item.person = current_person\n\n respond_to do |format|\n if @action_item.save\n format.html { redirect_to(@action_item, :notice => 'Action item was successfully created.') }\n format.xml { render :xml => @action_item, :status => :created, :location => @action_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @action_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_participant\n user = self.load_user(params)\n meeting = self.load_meeting(params)\n participant_ids = params[\"participant_ids\"]\n comment = params[\"comment\"].nil? ? \"\" : params[\"comment\"]\n\n if user != nil and meeting != nil and participant_ids.length > 0\n participant_ids.each do |participant_id|\n unless meeting.participants.exists?(participant_id)\n new_participant = User.find(participant_id)\n meeting.participants << new_participant\n # add default vote for the new added participant to each suggestion\n meeting.suggestions.each do |suggestion|\n suggestion.votes << Vote.new(:voter => new_participant, :decision => \"?\")\n end\n\n NotificationService.send_meeting_invitation(user, new_participant, meeting, comment)\n end\n end\n self.send_ok\n else\n self.send_error 401\n end\n end", "def create_starting_items\n items.create name: \"Starter item\", attack: 5, defense: 5, life: 10, experience_bonus: 0\n end", "def add(grocery_list, food, quantity)\n\tgrocery_list[food] = quantity\nend", "def add_item(grocery,item_name,quantity)\n # input: list, item name, and optional quantity\n # steps: insert item_name as a key and quantity as a value to the hash \n grocery[item_name] = quantity\n # output:display the latest list\n display_list(grocery)\nend", "def create\n item = current_user.find_item(params[:id])\n item.assign_attributes(params[:item])\n response = current_user.follow_item(item)\n unless response.is_a? StandardError\n redirect_to items_path, notice: \"Item suivi\"\n else\n redirect_to new_item_path(item.id), alert: response.message\n end\n end", "def add_participant_to_deal(id:, **args)\n params = parameters(args) do\n required_params :person_id\n optional_params :person_id\n end\n request(:post, \"deals/#{id}/participants\", params)\n end", "def add list\n list_action list, \"add\"\n end", "def create\n @item = current_owner.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to items_path, notice: 'Item was created successfully' }\n format.json { render :show, status: :created, location: items_path }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @wanted_item = WantedItem.new(wanted_item_params)\n\n respond_to do |format|\n if @wanted_item.save\n format.html { redirect_to @wanted_item, notice: 'Wanted item was successfully created.' }\n format.json { render :show, status: :created, location: @wanted_item }\n else\n format.html { render :new }\n format.json { render json: @wanted_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_item(item, quantity, groceries_list)\n groceries_list[item] = quantity\nend", "def add\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:recipe_id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] #hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n recipe_data = JSON.parse response.read_body\r\n recipe = Recipe.create :title => recipe_data[\"title\"], :image => recipe_data[\"image\"]\r\n @current_user.recipes << recipe # add recipe to My Recipes\r\n\r\n redirect_to my_recipes_path\r\n end", "def create\n @choice_item = ChoiceItem.new(choice_item_params)\n\n respond_to do |format|\n if @choice_item.save\n format.html { redirect_to @choice_item, notice: 'Choice item was successfully created.' }\n format.json { render :show, status: :created, location: @choice_item }\n else\n format.html { render :new }\n format.json { render json: @choice_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add\n if ! @collection.write?(@user, @client)\n render_json :status => :forbidden, :messages => \"This collection belongs to another client.\" and return\n end\n render_json :status => :bad_request and return unless @collection.create_item(params[:item], @user, @client)\n @item = @collection.items[-1]\n entry = ( @item.class == Collection ? @item.to_hash(@user, @client) : @item )\n render_json :status => :created, :entry => entry and return\n end", "def create\n respond_to do |format|\n @lineitem = Lineitem.create!(lineitem_params)\n @participants = Participant.all\n\t @users = User.all\n if @lineitem.save\n format.html { redirect_to @lineitem, notice: 'Lineitem was successfully created.' }\n format.json { render action: 'show', status: :created, location: @lineitem }\n else\n format.html { render action: 'new' }\n format.json { render json: @lineitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @list.append_items!(params.dig(:list, :items), current_user)\n redirect_to [@project, @randomization_scheme], notice: \"Items successfully added.\"\n end", "def create\n @item_delivery = ItemDelivery.new(item_delivery_params)\n @item_name = item_delivery_params[:item_name]\n \n puts \"Item name [#{@item_delivery.item_name}], Item: #{@item_delivery.item}\"\n\n respond_to do |format|\n if @item_delivery.save\n @item_delivery.record_activity(:create, current_user, \"Add PO Delivery\")\n format.html { redirect_to @item_delivery.purchase_order, notice: 'Item delivery was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item_delivery }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @item_delivery.errors, status: :unprocessable_entity }\n format.js { render 'error' }\n end\n end\n end", "def create\n @facility_item = FacilityItem.new(facility_item_params)\n\n respond_to do |format|\n if @facility_item.save\n format.html { redirect_to '/facilities/'+@facility_item.facility_id.to_s+'/facility_items', notice: 'Facility item was successfully created.' }\n format.json { render :show, status: :created, location: @facility_item }\n else\n format.html { render :new }\n format.json { render json: @facility_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_item(name)\n\t\ttodo_items.push(TodoItem.new(name))\n\tend", "def create\n @todo_item = @todo_list.todo_items.new(todo_item_params)\n\n if @todo_item.save\n redirect_to @todo_list, notice: 'Todo item was successfully created.'\n else\n redirect_to @todo_list, alert: 'Todo item failed to be created.'\n end\n end", "def giveItem\n toLocation = Company.where(name: params[:recepCompany]).first.locations.where(address: params[:recepLocation]).first\n location = current_company.locations.where(id: params[:locationId]).first\n if(location.is_supplier === true)\n updatedItem = location.items.where(name: params[:name]).first\n toUpdatedItem = toLocation.items.where(name: params[:name]).first\n if(toUpdatedItem.present? && updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n toUpdatedItem.increment!(:amount, params[:amount].to_i)\n elsif(updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n item = Item.create(name: params[:name], amount:params[:amount].to_i, price: updatedItem.price, autoRestock: false, lastSupplier:location.id)\n toLocation.items << item\n end\n if(updatedItem.amount <= updatedItem.restockPoint)\n changeItemSupplier(updatedItem.id)\n end\n end\n end", "def add_item(itemToAdd)\r\n itemToAdd.set_owner(self)\r\n itemToAdd.deactivate\r\n self.items.push(itemToAdd)\r\n end", "def create\n @user = User.find(current_user.id)\n @item = @user.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to '/items', notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_item(name, annotation, content, avaliability, units, userId)\r\n @newInstance = Ingredience.new\r\n @newInstance.name = name;\r\n @newInstance.annotation = annotation\r\n @newInstance.content = content\r\n @newInstance.avaliability = avaliability\r\n @newInstance.units = units;\r\n @newInstance.user_id = userId;\r\n @newInstance.activation_state = 1;\r\n\r\n @newInstance.save\r\n end", "def addItem(item)\n @items << item\n end", "def add\n @event = Event.find(params[:id])\n @user = current_user\n @content = \"is_interested\"\n @object = @event.id\n if current_user \n \t\t@event.users << current_user\n \tredirect_to @event, :notice => I18n.t(:reminders_add)\n else\n redirect_to sign_up_url, :notice => I18n.t(:remindes_add_else)\n \tend\n end", "def add_item(grocery_list, new_item_to_add, quanity)\n\tgrocery_list[new_item_to_add] = quanity\n\tp grocery_list\n\nend", "def generate_shopping_list\n\n #pull out whichever recipe you are clicking on\n recipe = Yummly.find(params[:yummly_id])\n\n # create a recipe for the database for future use\n r = Recipe.find_or_create_by(name: recipe.name, thumbnail: recipe.thumbnail)\n\n #create new shopping list for each recipe\n s = ShoppingList.create(\n name: recipe.name, \n yummly_id: params[:yummly_id],\n user_id: current_user.id,\n recipe_id: r.id)\n\n #find recipe and ingredient name from yummly\n recipe.ingredients.each do |ingredient|\n ShoppingListItem.create(done: nil, shopping_list_id: s.id, ingredient_name: ingredient, ingredient_quantity: nil, ingredient_quantity_unit: nil)\n end\n\n redirect_to recipes_url, notice: \"Added recipe to your shopping lists\"\n\n end", "def add(todo)\n @items << Item.new(todo)\n save\n @items.last\n end", "def pick_workitem (workitem_id)\n\n user = session[:user]\n\n workitem = OpenWFE::Extras::Workitem.find workitem_id\n\n workitem.store_name = \"users\"\n workitem.participant_name = user.name\n workitem.save!\n end", "def add\n\t\t# se o usuário não entiver infectado e já existir o inventário salvo, insere a qauantidade no inventário\n\t\tunless User.healthy? inventory_params[:user_id]\n \t \trender json: { error: \"Denied access. User is contaminated!\" }, status: 403 and return\n\t\tend\n\n\t\tif @inventory.add(inventory_params[:amount].to_i)\n\t\t\trender json: @inventory, status: 200\n\t\telse\n\t\t\trender json: @inventory.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def addy \n\t\trestaurant = Restaurant.build_using_questions\n\t\tif restaurant.save \n\t\t\tputs \"\\nRestaurant Added\\n\\n\"\n\t\telse\n\t\t\tputs \"\\nError: restaurant not added\\n\\n\"\n\t\tend\n\tend" ]
[ "0.6631024", "0.6522788", "0.6497612", "0.64098877", "0.6310791", "0.6310409", "0.6297878", "0.6289299", "0.6271286", "0.6214466", "0.61955434", "0.61719424", "0.6122305", "0.6105413", "0.60910183", "0.6056701", "0.6052904", "0.6041875", "0.6040316", "0.6033282", "0.6021365", "0.60095036", "0.59873796", "0.5981824", "0.59708554", "0.59657025", "0.59656984", "0.5962705", "0.59600013", "0.5937842", "0.5933358", "0.5930311", "0.59298843", "0.5926482", "0.59260654", "0.5923954", "0.59176564", "0.58971196", "0.5888148", "0.588021", "0.5870848", "0.58504814", "0.58455265", "0.5844421", "0.58413494", "0.5840683", "0.5836431", "0.5836324", "0.58324015", "0.5816053", "0.5814669", "0.58025104", "0.57966167", "0.57920027", "0.57780385", "0.5774634", "0.5769135", "0.57626146", "0.57495475", "0.57472056", "0.5743905", "0.5736483", "0.57331884", "0.5727785", "0.57238775", "0.57222015", "0.5722102", "0.5718023", "0.571331", "0.5710335", "0.5710195", "0.57077426", "0.5702865", "0.57002306", "0.56993836", "0.5684752", "0.5683997", "0.5682319", "0.5681983", "0.5678841", "0.56766975", "0.56622285", "0.5657894", "0.5657076", "0.56529367", "0.5643877", "0.5642151", "0.5640536", "0.56400627", "0.563887", "0.5638418", "0.5636007", "0.5634511", "0.56317085", "0.56274456", "0.5619596", "0.5618119", "0.56172204", "0.5615652", "0.56155384" ]
0.6902602
0
posts to here should add a food item to a participant
def update @food_item = @restaurant.food_items.find_by(name: params[:new_food_item]) if @food_item.nil? # here we are taking user input and inserting it into the flash, thus the flash needs to be sanitized before displayed # this happens automatically with rails and should not be disabled flash[:danger] = "Sorry we were not able to find the food item #{params[:new_food_item]} at the restaurant." else @participant.food_items << @food_item @participant.processed = true @participant.save end respond_to do |format| format.js { render partial: 'add_food_item', food_item: @food_item } format.json { render json: food_item } format.html { redirect_to edit_meal_participant_path(@meal, @participant) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_food(food)\n food_meals.create(food_id: food.id)\n end", "def create\n\t\t food_params = params.require(:food).permit(:name, :exercise, :calories, :time)\n\t\t food = Food.create(food_params)\n\t\t current_user.foods << food\n\t\t if food.save\n\t\t \tredirect_to \"/users/#{current_user.id}\"\n\t\t end\n\tend", "def create\n json_response(current_restaurant.restaurant_food_items.create!(food_item_params), :created)\n end", "def create\n @todo_item = @todo_list.todo_items.create(todo_item_params) \n redirect_to @todo_list, notice: \"Todo item added\"\n end", "def add_item\n\t\tcurrent_user.saved.items.push(Item.find(params[:item]))\n\t\tredirect_to :back\n\tend", "def add_favorite_food(food_id)\n post(\"/user/#{@user_id}/foods/log/favorite/#{food_id}.json\")\n end", "def add_item\n #params[item_id]\n end", "def create\n item = current_user.find_item(params[:id])\n item.assign_attributes(params[:item])\n response = current_user.follow_item(item)\n unless response.is_a? StandardError\n redirect_to items_path, notice: \"Item suivi\"\n else\n redirect_to new_item_path(item.id), alert: response.message\n end\n end", "def create\n @fulfillment = Fulfillment.new(params.require(:fulfillment).permit(:buyer_name, :buyer_email, :quantity, :message, :item_id))\n item = Item.find(@fulfillment.item_id)\n item.fulfilled += @fulfillment.quantity\n item.save\n gift = pluralize_gift(@fulfillment, item)\n if @fulfillment.save\n flash[:notice] = \"Thank you! #{item.user.couple_full_names} were informed that you will be buying them #{@fulfillment.quantity} #{gift}\"\n else\n flash[:error] = \"There was an error processing your request. Please try again.\"\n end\n redirect_to :back\n end", "def edit\n @food_item = @participant.food_items.new\n end", "def create\n @food_item_add_on = FoodItemAddOn.new(food_item_add_on_params)\n\n\n\n#Todo: can select multiple items for a sinfle addons\n respond_to do |format|\n if @food_item_add_on.save\n format.html { redirect_to :controller => 'home', :action => 'dashboard' }\n format.json { render :show, status: :created, location: @food_item_add_on }\n else\n format.html { render :new }\n format.json { render json: @food_item_add_on.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_item(list_id, content, responsible_party=nil, notify=true)\n record \"/todos/create_item/#{list_id}\",\n :content => content, :responsible_party => responsible_party,\n :notify => notify\n end", "def add_to_favourites\n \n #pull out whichever recipe you are clicking on\n yummly_id = params[:yummly_id]\n recipe = Yummly.find(yummly_id)\n\n # make new instance of that recipe\n r = Recipe.find_or_create_by(name: recipe.name, thumbnail: recipe.thumbnail)\n\n UserFavouriteRecipe.create(recipe_id: r.id, user_id: current_user.id, yummly_id: yummly_id)\n\n redirect_to recipes_url, notice: \"Added recipe from your list of favourite recipes\"\n\n end", "def add_ingredient_to_recipe quantity, measure, food_item_name, recipe \n food_item = FoodItem.new(:name => food_item_name, :price => nil)\n ingredient = Ingredient.new(:food_item => food_item, :quantity => quantity, :measure => measure, :recipe_id => recipe.id)\n recipe.ingredients << ingredient\n end", "def create\n @fooditem = Fooditem.new(params[:fooditem])\n\n respond_to do |format|\n if @fooditem.save\n format.html { redirect_to @fooditem, :notice => 'Fooditem was successfully created.' }\n format.json { render :json => @fooditem, :status => :created, :location => @fooditem }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @fooditem.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add\n if ! @collection.write?(@user, @client)\n render_json :status => :forbidden, :messages => \"This collection belongs to another client.\" and return\n end\n render_json :status => :bad_request and return unless @collection.create_item(params[:item], @user, @client)\n @item = @collection.items[-1]\n entry = ( @item.class == Collection ? @item.to_hash(@user, @client) : @item )\n render_json :status => :created, :entry => entry and return\n end", "def add\n\n item = params[:item]\n type = params[:type]\n\n added = nil\n\n if type=='song'\n\n if Favorite.exist_song(item, user_signed_in?, current_user)\n added = Song.quit_favorite(item, user_signed_in?, current_user)\n else\n added = Song.add_favorite(item, user_signed_in?, current_user)\n end\n \n end\n\n if type=='movie'\n\n year = item['year']\n name = item['name']\n\n if Favorite.exist_movie(year, name, user_signed_in?, current_user)\n added = Movie.quit_favorite(item, user_signed_in?, current_user)\n else\n added = Movie.add_favorite(item, user_signed_in?, current_user)\n end\n\n end\n\n response = {\n :added => added,\n }\n \n render :json =>response\n \n end", "def add\n meal_name = @view.ask_name\n meal_price = @view.ask_price.to_i\n new_meal = Meal.new({name: meal_name, price: meal_price})\n @meals_repository.add(new_meal)\n end", "def add\n params.require(:task).permit(:title, :body)\n #raise params.inspect\n current_user.tasks.create({title: params[:task][:title], body: params[:task][:body]})\n ActionCable.server.broadcast 'roster_notifications_channel', update: true\n redirect_to roster_url\n end", "def add\n # 1. Ask the user for the meal name and store in var\n name = @meal_view.ask_name\n # 2. Ask the user for the meal price and store in var\n price = @meal_view.ask_price\n # 3. Create a new meal instance with those values\n meal = Meal.new(name: name, price: price)\n # 4. Add to repository using #create\n @meal_repo.create(meal)\n end", "def create\n my_facility = MyFacility.find(params[:my_facility_id])\n current_user.add_favorite(my_facility)\n flash[:success] = \"お気に入りに追加しました\"\n redirect_back(fallback_location: root_path)\n end", "def add(food)\n foodList << food\nend", "def create\n @item_group = ItemGroup.new(params[:item_group])\n @item_group.user = request.user\n\n respond_to do |format|\n if @item_group.save\n format.html { redirect_to new_item_path(group_key:@item_group.key), notice: 'Question was successfully created. Want to add something for people to vote on?' }\n format.json { render json: @item_group, status: :created, location: @item_group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item_group.errors, status: :unprocessable_entity }\n end\n end\n end", "def add(args)\n return @client.api_helper.add(args, \"item_add\")\n end", "def add_an_item\n item = Item.new\n item.description = \"Task number #{to_do_list.size+1}\"\n to_do_list << item\n end", "def save_to_inventory\n @user = User.find(params[:id])\n @item = Item.find(1)\n @user.items.push(@item)\n end", "def set_food_item\n @food_item = current_restaurant.restaurant_food_items.find_by(uuid: params[:id])\n end", "def addItem\n begin\n ProgrammeItem.transaction do\n @assignment = nil\n if !params[:cancel]\n item = ProgrammeItem.find(params[:itemid])\n room = Room.find(params[:roomid])\n day = params[:day]\n time = params[:time].to_time # The start time\n\n @assignment = addItemToRoomAndTime(item, room, day, time)\n end\n\n render :layout => 'content'\n end\n rescue => ex\n render status: :bad_request, text: ex.message\n end\n end", "def add\n cur_user = current_user.role_id\n pid = params[:id]\n if Member.find(cur_user).favoriteds.create(\n :member_id=>cur_user, :employer_id=>pid\n )\n flash[:notice] = 'Employer added to Faved list!'\n else\n flash[:alert] = 'There was a problem adding Employer to Faved list.'\n end\n redirect_to :action => 'display', :id =>(pid)\n end", "def add\n # ask user for name and price\n attributes = {\n name: @view.ask_for_string(:name),\n price: @view.ask_for_number(:price)\n }\n # make new meal object\n # pass that to the repo\n @meals_repo.add(Meal.new(attributes))\n end", "def create\n @wanted_item = WantedItem.new(wanted_item_params)\n\n respond_to do |format|\n if @wanted_item.save\n format.html { redirect_to @wanted_item, notice: 'Wanted item was successfully created.' }\n format.json { render :show, status: :created, location: @wanted_item }\n else\n format.html { render :new }\n format.json { render json: @wanted_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @part_types = Constants::PART_TYPES\n @item = Item.new(item_params.merge(user_id: current_user.id))\n \n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: \"Item was successfully created.\" }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_multiple_food_items(items)\n items.each do |item|\n item['_id'] = FoodItem.create_id item[:api_key], item[:item_id]\n FoodItem.new_item item\n end\n items\n end", "def create\n\n @item = Item.new(params[:item])\n\n if(!@item.borrower.nil? && @item.borrower != \"\")\n UserMailer.loaned_notification_email(current_user, @item).deliver\n end\n\n current_user.items.push @item\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to(root_path, :notice => 'Item was successfully created.') }\n format.xml { render :xml => @item, :status => :created, :location => @item }\n else\n\n format.html { render :action => \"new\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @action_item = ActionItem.new(params[:action_item])\n @action_item.person = current_person\n\n respond_to do |format|\n if @action_item.save\n format.html { redirect_to(@action_item, :notice => 'Action item was successfully created.') }\n format.xml { render :xml => @action_item, :status => :created, :location => @action_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @action_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_work_item(data)\n name = @table_name.to_s\n sql = @model.from(name.to_sym).insert_sql(\n description: data[:description],\n guide: data[:guide],\n status: data[:status],\n username: data[:name],\n archived: 0\n )\n sql = _format_sql(sql)\n @logger.info(\"Prepared POST query: #{sql}\")\n response = run_statement(sql, \"post\")\n id = response[0][:long_value]\n @logger.info(\"Successfully created work_item_id: #{id}\")\n id\n end", "def add\r\n url = URI(\"https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/#{params[:recipe_id]}/information\")\r\n\r\n http = Net::HTTP.new(url.host, url.port)\r\n http.use_ssl = true\r\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n\r\n request = Net::HTTP::Get.new(url)\r\n request[\"x-rapidapi-key\"] = ENV[\"SPOONACULAR_API_KEY\"] #hidden API key\r\n request[\"x-rapidapi-host\"] = 'spoonacular-recipe-food-nutrition-v1.p.rapidapi.com'\r\n\r\n response = http.request(request)\r\n recipe_data = JSON.parse response.read_body\r\n recipe = Recipe.create :title => recipe_data[\"title\"], :image => recipe_data[\"image\"]\r\n @current_user.recipes << recipe # add recipe to My Recipes\r\n\r\n redirect_to my_recipes_path\r\n end", "def create_todo_item(name, list_id)\n data = {\n item: {\n name: name\n }\n }\n rest(\"post\", \"lists/#{list_id}/items\", data)\n end", "def add_participant_to_deal(id:, **args)\n params = parameters(args) do\n required_params :person_id\n optional_params :person_id\n end\n request(:post, \"deals/#{id}/participants\", params)\n end", "def add_item(electives, item)\n puts electives.push(\"debate club\")\nend", "def create\n @todo_item = @todo_list.todo_items.new(todo_item_params)\n\n if @todo_item.save\n redirect_to @todo_list, notice: 'Todo item was successfully created.'\n else\n redirect_to @todo_list, alert: 'Todo item failed to be created.'\n end\n end", "def create\n # This is to make amon ignore its own sayings\n return if params[:user_id].eql?(\"USLACKBOT\")\n\n # Try to create a new item\n item = Item.create_from_webhook params\n if item.nil?\n message = I18n.t(:no_such_team, :url=>\"#{request.env['HTTP_HOST']}/auth/slack\")\n else\n message = I18n.t('item_create_response').sample\n end\n render_slack message\n end", "def add\n # ask user for name and price\n attributes = {\n name: @view.ask_for_string(:name),\n price: @view.ask_for_number(:price)\n }\n # make new meal object\n # pass that to the repository\n @meals_repository.add(Meal.new(attributes))\n end", "def add\n @event = Event.find(params[:id])\n @user = current_user\n @content = \"is_interested\"\n @object = @event.id\n if current_user \n \t\t@event.users << current_user\n \tredirect_to @event, :notice => I18n.t(:reminders_add)\n else\n redirect_to sign_up_url, :notice => I18n.t(:remindes_add_else)\n \tend\n end", "def create\n\n \t\t@item = current_user.items.build(item_params)\n \t\tif @item.save\n \t\t\tflash[:success] = \"Item created!\"\n \t\t\tredirect_to items_path\n \t\telse\n \t\t\t@feed_items = []\n \t\t\trender 'static_pages/home'\n \t\tend\n \tend", "def add_to\n begin\n study = Study.find(params[:study_id])\n unless study.user_id != session[:user_id] || study.active == true\n i = Item.new\n i.study_id = params[:study_id]\n i.name = params[:item_name]\n i.description = params[:item_description]\n unless i.save\n flash[:error] = \"Please enter a valid item name and description.\"\n end\n end\n rescue\n\n ensure\n redirect_to(edit_study_path(params[:study_id]))\n end\n end", "def brief_vendor_add_item\n brief = Brief.find(params[:brief_id])\n brief_vendor = brief.brief_vendors.find_by_org_id(params[:vendor_id])\n brief_vendor.items << Item.new{|r| r.parent_id = params[:item_id]}\n\n redirect_to(cheil_brief_vendor_items_path(params[:brief_id],params[:vendor_id])) \n end", "def add_to_total(food)\n Farm.add_food(food)\n end", "def add_item_to_the_room\n @item = Item.find(params[:id])\n @room = Room.find(params[:room_id])\n \n @item.rooms << @room\n \n render json: @item, include: :rooms\n\n end", "def create\n @item = @client.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully added.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n puts params\n item_data = {\n :title => params[:title],\n :description => params[:description]\n }\n @item = current_user.items.build(item_data)\n if params[:attachments]\n params[:attachments].each do |att_id|\n @att = Attachment.find(att_id)\n @item.attachments.push(@att)\n if @att.att_type == 'photo'\n @item.photos.build(\n photo_url: @att.url\n )\n end\n end\n end\n if @item.save\n respond_to do |format|\n format.json { render :json => @item.to_json, :status => 200 }\n format.xml { head :ok }\n format.html { redirect_to :action => :index }\n end\n else\n respond_to do |format|\n format.json { render :text => \"Could not create item\", :status => :unprocessable_entity } # placeholder\n format.xml { head :ok }\n format.html { render :action => :new, :status => :unprocessable_entity }\n end\n end\n end", "def add_to_collection\n\n if request.post?\n # Actually add the item to the collection\n ids = request.params[:id].split(',')\n ids.each do |id|\n add_to_collection_action(request.params[:collection], id)\n end\n\n # Don't render the default \"Add to Collection\" dialog - render the \"Success!\" dialog contents\n flash[:success] ||= \"The item has been added to the collection\"\n render 'catalog/add_to_collection_success'\n end\n\n end", "def create\n list_item = @list.list_items.build(dish_id: params[:dish_id])\n if list_item.save\n increase_dish_popularity(list_item.dish)\n redirect_to user_dishes_path(current_user), alert: \"Dish successfully added to your list\"\n else\n redirect_to user_dishes_path(current_user), alert: \"Unable to add dish to list\"\n end\n end", "def eat(food)\n @foods_eaten.push(food)\n end", "def create\n item = Item.new(item_params)\n item.done = \"0\"\n item.trash = \"0\"\n\n if item.save\n render json: {data:item}, status: :created\n else\n render json: {data:item}, status: :unprocessable_entity\n end\n end", "def giveItem\n toLocation = Company.where(name: params[:recepCompany]).first.locations.where(address: params[:recepLocation]).first\n location = current_company.locations.where(id: params[:locationId]).first\n if(location.is_supplier === true)\n updatedItem = location.items.where(name: params[:name]).first\n toUpdatedItem = toLocation.items.where(name: params[:name]).first\n if(toUpdatedItem.present? && updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n toUpdatedItem.increment!(:amount, params[:amount].to_i)\n elsif(updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n item = Item.create(name: params[:name], amount:params[:amount].to_i, price: updatedItem.price, autoRestock: false, lastSupplier:location.id)\n toLocation.items << item\n end\n if(updatedItem.amount <= updatedItem.restockPoint)\n changeItemSupplier(updatedItem.id)\n end\n end\n end", "def addRestaurant(restaurant)\n @restaurants << restaurant\n end", "def create\n item = list.items.create!(item_params)\n render json: item, status: 201\n end", "def pickup_item\n if status == :confirmed \n transaction do\n update(:status => :in_progress)\n # Create newsfeed\n ::Yito::Model::Newsfeed::Newsfeed.create(category: 'booking',\n action: 'pickup_item',\n identifier: self.id.to_s,\n description: BookingDataSystem.r18n.t.picked_up_item)\n end \n end\n self\n end", "def create\n @ingredient = Ingredient.new(params[:ingredient])\n @food = Food.find_by_name(params[:food][:name])\n @ingredient.food_id = @food.id if @food\n respond_to do |format|\n if @recipe.ingredients << @ingredient\n flash[:notice] = 'Ingredient was successfully added.'\n format.html { redirect_to recipe_url(@recipe) }\n format.js\n format.xml { head :created, :location => ingredient_url(@ingredient) }\n else\n format.html { render :action => \"new\" }\n format.js\n format.xml { render :xml => @ingredient.errors.to_xml }\n end\n end\n end", "def add_to_feeds( feed_item, achievement )\n feed_item.user = achievement.creator\n feed_item.referenced_model = achievement\n feed_item.save!\n\n achievement.group.feed.add_feed_item( feed_item )\n # achievement.creator.feed.add_feed_item( feed_item )\n achievement.group.users.each { |user| user.feed.add_feed_item( feed_item ) } # add to each feed item for members of the group\n end", "def create\n @item = current_owner.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to items_path, notice: 'Item was created successfully' }\n format.json { render :show, status: :created, location: items_path }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_new(type, new_item)\n #Add exercise to exercise_list\n if type == \"exercise\"\n @exercise_list.push(new_item)\n return 0\n #Add a workout to workout_routines\n elsif type == \"workout\"\n @workout_routines.push(new_item)\n return 0\n #Error handling\n else\n return -1\n end\n\n end", "def create\n @order = Order.find(request[:order_id])\n @order_item = OrderItem.new(params[:order_item])\n @order_item.order_id = @order.id\n @order_item.owner = current_user\n\n respond_to do |format|\n #if @order.order_items.push(@order_item)\n result = @order_item.save()\n if result\n format.html { redirect_to [@order, @order_item], notice: \"This item was successfully added to '#{@order.name}'.\" }\n format.json { render json: @order_item, status: :created, location: @order_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.order_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @potluck_item = PotluckItem.new(params[:potluck_item])\n\n respond_to do |format|\n if @potluck_item.save\n format.html { redirect_to [@event, @potluck_item], notice: 'Potluck item was successfully created.' }\n format.json { render json: @potluck_item, status: :created, location: @potluck_item }\n else\n format.html { render action: \"new\", status: :unprocessable_entity }\n format.json { render json: @potluck_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @ingredient = Ingredient.find(params[:id])\n \n @supplier.ingredients << @ingredient\n redirect_to supplier_path(@supplier)\n end", "def create\n @item = @list.items.create(item_params)\n redirect_to @list\n end", "def create\n\n @item = Item.new(params[:item])\n @item.user_id = current_user.id\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to '/main', :notice => 'Item was successfully created.' }\n format.json { render :json => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def add_item\n\t puts \"What is the name of the item you'd like to add?\"\n\t\t@item_name = gets.chomp\n\t\tputs \"And how many?\"\n\t\t@quantity = gets.chomp.to_i\n\t\tif @quantity <= 0\n\t\t puts \"Please enter a number higher than 0.\"\n\t\t puts \"(Also, must be '1' not 'one'.)\"\n\t\telse\n\t\t @grocery_list[@item_name] = @quantity\n\t\tend\n\t\tget_item\n\tend", "def add(todo)\n @items << Item.new(todo)\n save\n @items.last\n end", "def eat(food)\n @foods_eaten << food\n end", "def create\n dish = Dish.where(name: params[:name]).first\n dish ||= Dish.create(name: params[:name], party: current_party, price: params[:price])\n\n OrderItem.create(user: current_user, dish: dish)\n\n render json: { :name => dish.name, :price => dish.price, :participants => [current_user.login] }\n end", "def create\n @item_delivery = ItemDelivery.new(item_delivery_params)\n @item_name = item_delivery_params[:item_name]\n \n puts \"Item name [#{@item_delivery.item_name}], Item: #{@item_delivery.item}\"\n\n respond_to do |format|\n if @item_delivery.save\n @item_delivery.record_activity(:create, current_user, \"Add PO Delivery\")\n format.html { redirect_to @item_delivery.purchase_order, notice: 'Item delivery was successfully created.' }\n format.json { render action: 'show', status: :created, location: @item_delivery }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @item_delivery.errors, status: :unprocessable_entity }\n format.js { render 'error' }\n end\n end\n end", "def add_item\n puts \"What food item would you like to add to the grocery store?\"\n new_item_rec = gets.chomp!\n if new_item_rec.empty?\n puts \"You must provide a name for the item\"\n add_item\n else\n end\n puts \"How many of that item would you like to add?\"\n new_item_inv = gets.chomp!\n if new_item_inv.empty?\n puts \"You must provide an inventory amount for the item\"\n puts \"How many of that item would you like to add?\"\n new_item_inv = gets.chomp!\n else\n end\n puts \"How much would it cost?\"\n new_item_cost = gets.chomp!\n if new_item_cost.empty?\n puts \"You must provide a cost for the item\"\n puts \"How much would it cost?\"\n new_item_cost = gets.chomp!\n else\n end\n new_item = {name: new_item_rec, inventory: new_item_inv.to_i, price: new_item_cost.to_f}\n @food_items.push(new_item)\n food_list\n puts 'Add another item? y/n -->' \n choice = gets.strip.downcase\n if choice == 'y'\n add_item\n else \n menu\n end\nend", "def set_food_item\n @food_item = FoodItem.find(params[:id])\n end", "def create\n @doing_item = DoingItem.new(doing_item_params)\n\n respond_to do |format|\n if @doing_item.save\n format.html { redirect_to @doing_item, notice: 'Doing item was successfully created.' }\n format.json { render :show, status: :created, location: @doing_item }\n else\n format.html { render :new }\n format.json { render json: @doing_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add\n\t\t# se o usuário não entiver infectado e já existir o inventário salvo, insere a qauantidade no inventário\n\t\tunless User.healthy? inventory_params[:user_id]\n \t \trender json: { error: \"Denied access. User is contaminated!\" }, status: 403 and return\n\t\tend\n\n\t\tif @inventory.add(inventory_params[:amount].to_i)\n\t\t\trender json: @inventory, status: 200\n\t\telse\n\t\t\trender json: @inventory.errors, status: :unprocessable_entity\n\t\tend\n\tend", "def add_bonus_item(message)\n match = /(bonus item|hidden treasure)! <(?<id>.*)> \\| <(?<name>.*)>/.match(message)\n return nil unless match\n \n add_item(nil, match[:id], match[:name])\n publish Events::ADD_ITEM, match[:id], match[:name]\n end", "def addItem(item)\n @toDoListArray.push(item)\n end", "def created(item)\n end", "def create\n @intowel = Intowel.find(params[:intowel_id])\n \n #verifica se o produto foi selecionado\n if item_params[:product_id].blank?\n flash[:warning] = 'Selecione o item desejado!'\n redirect_to intowel_path(@intowel) and return\n end\n \n #verifica se já existe o mesmo item adicionado na venda\n check_item = Item.where(intowel_id: @intowel.id, product_id: item_params[:product_id])\n if check_item.present?\n flash[:warning] = 'Este item já foi adicionado!'\n redirect_to intowel_path(@intowel) and return\n end\n \n if item_params[:qnt].blank?\n flash[:warning] = 'Informe uma quantidade para o item selecionado!'\n redirect_to intowel_path(@intowel) and return\n end\n \n @item = @intowel.items.create(item_params)\n redirect_to intowel_path(@intowel)\n end", "def create\n @user = User.find(current_user.id)\n @item = @user.items.new(item_params)\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to '/items', notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_item_to_list(item)\n @to_do_item.push(item)\n end", "def add_to_user\n @user = current_user;\n @user.diet_type = DietType.find_by_name(diet_type_params[:name])\n \n respond_to do |format|\n flash[:success] = 'diet type was successfully add.'\n format.html { redirect_to action:\"index\" }\n end\n end", "def set_food_item\n @food_item = @current_user.food_items.find(params[:id])\n end", "def create\n @meal = Meal.find(params[:meal_id]) if params[:meal_id]\n @recipe = @meal ? @meal.recipes.create(params[:recipe]) : Recipe.new(params[:recipe])\n\n #@recipe.ingredients = params[:ingredients].map {|i| \n #Ingredient.new(:item => Food.find(i.delete(:item_id)), :quantity => i[:quantity]) unless i[:item_id].blank? \n #}.compact if params[:ingredients]\n\n @recipe.tags = params[:tags].split(/,/).map { |t|\n Tag.find_or_create_by_name(t.strip.downcase)\n }.compact if params[:tags]\n\n respond_to do |format|\n if @recipe.save\n format.html { redirect_to @recipe}\n format.json { render json: @recipe, status: :created, location: @recipe }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe.errors, status: :unprocessable_entity }\n end\n end\n end", "def add(grocery_list, food, quantity)\n\tgrocery_list[food] = quantity\nend", "def add_to_feeds( feed_item, user_achievement )\n feed_item.user = user_achievement.user\n feed_item.referenced_model = user_achievement\n feed_item.save!\n\n user_achievement.achievement.group.feed.add_feed_item( feed_item )\n user_achievement.achievement.group.users.each { |user| user.feed.add_feed_item( feed_item ) } # add to each feed item for members of the group\n end", "def dispatch_create_item!(msg)\n if msg.has_attachments?\n draft = msg.draft\n msg.draft = true\n resp = validate_created_item(ews.create_item(msg.to_ews))\n msg.file_attachments.each do |f|\n next unless f.kind_of?(File)\n resp.add_file_attachment(f)\n end\n if draft\n resp.submit_attachments!\n resp\n else\n resp.submit!\n end\n else\n resp = ews.create_item(msg.to_ews)\n validate_created_item resp\n end\n end", "def create\n @food = Food.create(params[:food])\n redirect_to foods_url\n end", "def create\n params[:item][:user_id] = current_user.id\n # @user = User.find(params[:id])\n\n @item = Item.create(item_params)\n\n redirect_to \"/items/#{@item.id}\"\n end", "def create\n @pizza = Pizza.new(pizza_params)\n\n @pizza.user_id = current_user.id\n\n params[:topping_ids].each do |tid|\n topping = Topping.find_by_id(tid)\n @pizza.toppings << topping\n end\n\n respond_to do |format|\n if @pizza.save\n format.html { redirect_to @pizza, notice: 'Pizza was successfully created.' }\n format.json { render action: 'show', status: :created, location: @pizza }\n else\n format.html { render action: 'new' }\n format.json { render json: @pizza.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @food_item = FoodItem.new(food_item_params)\n @food_item.category = Category.find(params[:food_item][:category_id])\n respond_to do |format|\n if @food_item.save\n format.html { redirect_to @food_item, notice: \"Food item was successfully created.\" }\n format.json { render :show, status: :created, location: @food_item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @food_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @quest_item = QuestItem.new(quest_item_params)\n\n respond_to do |format|\n if @quest_item.save\n format.html { redirect_to admin_quest_items_url, notice: 'Всё норм' }\n format.json { head :no_content }\n else\n format.html { render :new }\n format.json { render json: @quest_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_item\r\n session[:items] << params[:id]\r\n redirect_to root_url\r\n end", "def add_item(list, food_item, quantity_of_food = 1)\n list[food_item] = quantity_of_food\n list\nend", "def create\n if params[:item].present?\n # TODO - see impact\n @item = Item.new(params[:item])\n @item.user_id = current_user.id if current_user.present?\n\n # TODO Commented shipping information because of REQUIREMENT CHANGE (https://www.pivotaltracker.com/story/show/62299176)\n \n # @item.bring_it_to_you = params[:item][:bring_it_to_you] if params[:item][:bring_it_to_you].present?\n # @item.come_and_get_it = params[:item][:come_and_get_it] if params[:item][:come_and_get_it].present?\n # @item.lets_meet_up = params[:item][:lets_meet_up] if params[:item][:lets_meet_up].present?\n # @item.come_to_you = params[:item][:come_to_you] if params[:item][:come_to_you].present?\n # @item.come_to_me = params[:item][:come_to_me] if params[:item][:come_to_me].present?\n # @item.done_remotely = params[:item][:done_remotely] if params[:item][:done_remotely].present?\n # @item.ship_it = params[:item][:ship_it] if params[:item][:ship_it].present?\n # @item.lets_meet_service = params[:item][:lets_meet_service] if params[:item][:lets_meet_service]\n\n if @item.user.nil? and params[:user_id] and params[:user_id] != ''\n @item.user_id = params[:user_id]\n end\n if not @item.user_id.present? and session[:guest_user_id].to_i > 0\n @item.user_id = session[:guest_user_id].to_i\n end\n # if params[:multi_trade] and params[:multi_trade] == \"on\"\n # @item.is_single_tradeya = false\n # end\n if params[:item][:tod_id].blank?\n @item.exp_date = Item.get_expiry_date_for_tod\n @item.status = \"LIVE\"\n else\n @item.tod = false\n @item.status = \"ACTIVE\"\n end\n respond_to do |format|\n if ((params[:captcha] and params[:item][:tod_id]) or params[:item][:tod_id].nil?) and not @item.user_id.blank?\n if @item.desc == \"Add more details about your good or service here...\" then @item.desc = \"\" end\n if @item.save\n\n # sbx tracking pixel fire\n if current_user.tracking_infos.where(affiliate:'sbx').present?\n Resque.enqueue(FireTrackingPixelJob, current_user.id, 'post')\n end\n\n chk = false\n # Case 1 - Old Offer - edit\n\n # Case 2 - New Tradeya/Offer but item selected from dropdown\n if params[:item][:selected_item_id].to_i > 0 or params[:item][:have].to_i > 0\n create_new = true\n # Create new record for item photos\n end\n # Case 3 - New Tradeya/Offer\n if params[:item_photos].present?\n photos = JSON.parse(params[:item_photos])\n if photos and photos.count > 0\n photos.each_with_index do |photo,index|\n existing_ph = ItemPhoto.find(photo[\"id\"])\n if create_new and existing_ph.item_id.present?\n ph = ItemPhoto.new\n ph.photo = existing_ph.photo\n ph.width = existing_ph.width; ph.height = existing_ph.height;\n ph.crop_x = existing_ph.crop_x; ph.crop_y = existing_ph.crop_y;\n ph.crop_w = existing_ph.crop_w; ph.crop_h = existing_ph.crop_h;\n else\n ph = existing_ph\n end\n if ph.present?\n ph.item_id = @item.id\n if index == 0\n ph.main_photo = true\n end\n ph.save\n chk = true\n end\n end\n end\n end\n if params[:item_videos].present?\n videos = JSON.parse(params[:item_videos])\n if videos and videos.count > 0\n videos.each do |video|\n existing_vi = ItemVideo.find(video[\"id\"])\n if create_new and existing_vi.item_id.present?\n vi = ItemVideo.new\n vi.video = existing_vi.vi\n else\n vi = existing_vi\n end\n if vi.present?\n vi.item_id = @item.id\n vi.save\n chk = true\n end\n end\n end\n end\n # TODO - read below and make it like below\n\n # if params[:file_type] == \"photo\"\n # if params[:item][:item_photo] and params[:item][:item_photo][:id] and params[:item][:item_photo][:id].to_i > 0\n # ip = ItemPhoto.find(params[:item][:item_photo][:id])\n # ip.item_id = @item.id\n # ip.save\n # chk = true\n # elsif params[:item][:item_photo]\n # if params[:item][:item_photo][:photo]\n # o = ItemPhoto.new(params[:item][:item_photo])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # end\n # end\n # elsif params[:file_type] == \"video\"\n # if params[:item][:item_video] and params[:item][:item_video][:id] and params[:item][:item_video][:id].to_i > 0\n # o = ItemVideo.find(params[:item][:item_video][:id])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # elsif params[:item][:item_video]\n # if params[:item][:item_video][:video]\n # o = ItemVideo.new(params[:item][:item_video])\n # o.item_id = @item.id\n # o.save\n # chk = true\n # end\n # end\n # end\n\n if not chk and params[:item][:selected_item_id].to_i > 0\n itm = Item.find(params[:item][:selected_item_id])\n if itm.item_videos and itm.item_videos.count > 0\n o = ItemVideo.new\n if File.exist?(itm.item_videos[0].video.path)\n o.video = File.open(itm.item_videos[0].video.path)\n else\n o.video_from_url(itm.item_videos[0].video.url)\n end\n o.item_id = @item.id\n o.save\n elsif itm.item_photos and itm.item_photos.count > 0\n o = ItemPhoto.new\n if File.exist?(itm.item_photos[0].photo.path)\n o.photo = File.open(itm.item_photos[0].photo.path)\n else\n o.photo_from_url(itm.item_photos[0].photo.url)\n end\n o.item_id = @item.id\n o.save\n end\n end\n\n # if params[:item_wants] and params[:item_wants].present?\n # os = JSON.parse(params[:item_wants])\n # os.each do |iwa|\n # o = ItemWant.new\n # o.title = iwa[0]\n # o.category_id = iwa[1]\n # o.desc = iwa[2]\n # o.item = @item\n # o.user = current_user\n # o.save\n # end\n # end\n if params[:item][:have].present?\n Have.create(:item_id => params[:item][:have].to_i,:user_id => current_user.id )\n end\n\n flash[:notice] = \"item created\"\n # Send mail when item created\n if (InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins)\n if (@item.user.items.count == 1)\n ItemMailer.item_added_first(@item.id,@item.user.id).deliver\n elsif (@item.user.items.count < 6)\n ItemMailer.item_added(@item.id,@item.user.id).deliver\n end\n # Activity Feed\n @item.create_activity key: @item.id, owner: @item.user, recipient: @item.user\n end\n\n\n if params[:item][:tod_id] # check if the request is coming from an offer or just item\n trade = Trade.new(:item_id => params[:item][:tod_id].to_i, :offer_id => @item.id, :status => 'ACTIVE')\n trade.save!\n if params[:item][:tod] and params[:item][:tod] == \"1\"\n offer_as_tod = Item.new\n offer_as_tod.title = @item.title\n offer_as_tod.desc = @item.desc\n offer_as_tod.tod = true\n offer_as_tod.exp_date = Item.get_expiry_date_for_tod\n offer_as_tod.category_id = @item.category_id\n offer_as_tod.user_id = @item.user_id\n offer_as_tod.status = 'INCOMPLETE'\n offer_as_tod.is_single_tradeya = @item.is_single_tradeya\n if offer_as_tod.save\n session[:offer_as_tod] = offer_as_tod.id\n chk = false\n if params[:file_type] == \"photo\"\n if params[:item][:item_photo]\n if params[:item][:item_photo] and params[:item][:item_photo][:id] and params[:item][:item_photo][:id].to_i > 0\n ip = ItemPhoto.find(params[:item][:item_photo][:id])\n o = ItemPhoto.new\n if File.exist?(ip.photo.path)\n o.photo = File.open(ip.photo.path)\n else\n o.photo_from_url(ip.photo.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n elsif params[:item][:item_photo]\n if params[:item][:item_photo][:photo]\n o = ItemPhoto.new(params[:item][:item_photo])\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n end\n end\n elsif params[:file_type] == \"video\"\n if params[:item][:item_video] and params[:item][:item_video][:id] and params[:item][:item_video][:id].to_i > 0\n iv = ItemVideo.find(params[:item][:item_video][:id])\n o = ItemVideo.new\n if File.exist?(iv.video.path)\n o.video = File.open(iv.video.path)\n else\n o.video_from_url(iv.video.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n elsif params[:item][:item_video]\n if params[:item][:item_video][:video]\n o = ItemVideo.new(params[:item][:item_video])\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n end\n end\n\n if not chk and params[:archive_id].present?\n o = ItemVideo.new\n o.video_from_url(@url)\n o.item_id = offer_as_tod.id\n o.save\n chk = true\n end\n\n if not chk and params[:item][:selected_item_id].to_i > 0\n itm = Item.find(params[:item][:selected_item_id])\n if itm.item_videos and itm.item_videos.count > 0\n o = ItemVideo.new\n if File.exist?(itm.item_videos[0].video.path)\n o.video = File.open(itm.item_videos[0].video.path)\n else\n o.video_from_url(itm.item_videos[0].video.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n else\n o = ItemPhoto.new\n if File.exist?(itm.item_photos[0].photo.path)\n o.photo = File.open(itm.item_photos[0].photo.path)\n else\n o.photo_from_url(itm.item_photos[0].photo.url)\n end\n o.item_id = offer_as_tod.id\n o.save\n end\n end\n if session[:guest_user_id].to_i > 0\n session[:guest_offer_as_tod] = true\n end\n end\n else\n session[:guest_user_id] = nil\n session[:is_guest_user] = nil\n end\n\n # Alert.add_2_alert_q(ALERT_TYPE_TRADEYA, NEW_OFFER_ON_TRADEYA, trade.item.user.id, nil, trade.id)\n\n # if InfoAndSetting.sm_on_o_made then EventNotificationMailer.offer_is_made(trade).deliver end\n if InfoAndSetting.sm_on_o_made and trade.item.user.notify_received_offer then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_OFFER_MADE, trade.item.user.id, {:trade_id => trade.id}) end\n # if InfoAndSetting.sm_on_trd_live and params[:item][:tod] == '1' then EventNotificationMailer.tradeya_is_live(@item).deliver end\n # if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins?(MAIL) and params[:item][:tod] == '1' then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n #if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins and params[:item][:tod] == '1' then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n\n # if offer is submitted from new offer flow, id and title of offer is needed\n if params[:new_offer_flow].present? and params[:item][:is_tod].present? and (params[:item][:is_tod] == 'false') and current_user\n session[:new_offer_title] = @item.title\n session[:new_offer_id] = @item.id\n else\n session[:item_saved_offer] = true\n end\n finished(\"make_offer_form\")\n # if current_user and !current_user.showed_onboarding\n # format.html { redirect_to profile_url }\n # else\n format.html { redirect_to item_path(Item.find(params[:item][:tod_id])) }\n # end\n else\n session[:guest_user_id] = nil\n session[:is_guest_user] = nil\n # Alert.add_2_alert_q(ALERT_TYPE_TRADEYA, TRADEYA_LIVE, @item.user.id, @item.id)\n\n # if InfoAndSetting.sm_on_trd_live then EventNotificationMailer.tradeya_is_live(@item).deliver end\n # if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins?(MAIL) then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n #if InfoAndSetting.sm_on_trd_live and @item.user.notify_tradeya_begins then EventNotification.add_2_notification_q(NOTIFICATION_TYPE_USER_SETTING, NOTIFICATION_TRADEYA_IS_LIVE, @item.user.id, {:item_id => @item.id}) end\n\n # if not session[:ipad_mini_contest].nil? and session[:ipad_mini_contest] = 5\n # format.html{ redirect_to contest_url}\n # else\n\n if params[:item][:offer_for]\n if params[:item][:offer_for].include? \"?\"\n format.html { redirect_to my_offers_item_path(Item.find(params[:item][:offer_for]))+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html { redirect_to my_offers_item_path(Item.find(params[:item][:offer_for]))+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:referer_page]\n session[:have_saved] = params[:item][:referer_page]\n if params[:item][:referer_page].include? \"?\"\n format.html {redirect_to params[:item][:referer_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:referer_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:have_add_page]\n if params[:item][:have_add_page].include? \"?\"\n format.html {redirect_to params[:item][:have_add_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:have_add_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n elsif params[:item][:referer_browse_page]\n if params[:item][:referer_browse_page].include? \"?\"\n format.html {redirect_to params[:item][:referer_browse_page]+ \"&item_saved=\" + @item.id.to_s}\n else\n format.html {redirect_to params[:item][:referer_browse_page]+ \"?item_saved=\" + @item.id.to_s}\n end\n else\n # session[:item_saved] = {:title => @item.title, :url => item_path(@item)}\n format.html { redirect_to new_item_path + \"?item_saved=\" + @item.id.to_s }\n end\n # format.html { redirect_to @item.item_url }\n # end\n end\n else\n format.html { redirect_to new_item_path }\n end\n else\n if params[:item][:tod_id]\n format.html { redirect_to item_path(Item.find(params[:item][:tod_id])) }\n else\n format.html { redirect_to new_item_path }\n end\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to new_item_path }\n end\n end\n end", "def create\n \n if params[:file] == nil\n item_details = item_params\n item_details[:image] = 'http://fillmurray.com/200/200'\n\n else\n response = Cloudinary::Uploader.upload params[:file]\n item_details = item_params\n item_details[:image] = response[\"url\"]\n end\n\n\n @item = Item.create item_details\n \n\n allWishes = Wish.all.each do |eachWish|\n \n if(eachWish.category_id == Item.last.category_id && eachWish.subcategory_id == Item.last.subcategory_id && eachWish.name == Item.last.name)\n Wish.update eachWish.id, item_id: Item.last.id\n end\n end\n\n if @item.category_id == 1\n #if the category is community\n @item.price = 0\n \n elsif @item.category_id == 4\n #if the category is personals\n @item.price = 0\n \n elsif @item.category_id == 6\n #if the category is housing\n @item.price = 0 \n\n else\n @item.price\n \n end\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @item }\n \n else\n format.html { render :new }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n\n\n @current_user.items << @item\n\n end", "def add_guts(user, item)\n return\n end", "def meet\n # Envia pedido de que quer conhecer o animal. \n # Isto mandaria uma proposta para o dono do shelter.\n\n # TODO: É preciso criar uma tabela associativa para saber quem já mandou proposta para o animal.\n # Assim evitaria mandar proposta múltiplas vezes.\n if params[:user_id]\n # friendly_user = User.find(params[:user_id])\n friendly_user = current_user\n AnimalMailer.meet_up_proposal(@animal, friendly_user).deliver\n end\n end" ]
[ "0.6984389", "0.65566176", "0.650754", "0.63522476", "0.6317013", "0.62996984", "0.62992465", "0.62980515", "0.6276073", "0.62479335", "0.61999863", "0.61997306", "0.61840165", "0.61717063", "0.6166774", "0.6131458", "0.61282486", "0.60976136", "0.60473317", "0.6045609", "0.60339355", "0.602708", "0.6026583", "0.60147035", "0.6005101", "0.5998148", "0.5964456", "0.596231", "0.5955613", "0.59506565", "0.5945732", "0.59353435", "0.5929226", "0.59276414", "0.5921195", "0.59201527", "0.59193015", "0.5918038", "0.5916548", "0.59084415", "0.5904507", "0.59022015", "0.58996266", "0.589768", "0.5881507", "0.58807343", "0.586529", "0.58625305", "0.586204", "0.58612216", "0.58484256", "0.58392787", "0.58368677", "0.58325875", "0.5829755", "0.58227557", "0.5820993", "0.581664", "0.58152056", "0.58121234", "0.5809945", "0.5809614", "0.5805485", "0.58034277", "0.57989407", "0.5796021", "0.5791425", "0.57901466", "0.5783425", "0.57831395", "0.5782238", "0.5781864", "0.5776693", "0.57693356", "0.5766633", "0.57627815", "0.57601625", "0.57569456", "0.57519144", "0.5749919", "0.57497066", "0.57483196", "0.5747916", "0.5747824", "0.57470536", "0.5745527", "0.5735528", "0.57342046", "0.5732619", "0.5729788", "0.5729018", "0.5726675", "0.57264185", "0.572558", "0.57232034", "0.5721609", "0.5720384", "0.5719825", "0.5714324", "0.57140326" ]
0.6390024
3
Exports data to a CSV formatted file, using columns directly from a table table_name: name of the table exporting. Column names are pulled from it. data_array: an array of hashes (link from a find)
def csv_export_rawtable(table_name, data_array, options = {}) column_definitions = [] eval("#{table_name}.content_columns").each do |column| column_definitions << [column.name, column.name] end csv_export(column_definitions, data_array, options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def export_data(array, name = \"data\")\n CSV.open(\"public/data/\" + name + \"_\" + Time.now.strftime(\"%m_%d_%Y_%H:%M:%S\") + \".csv\", \"w\") do |csv|\n csv << array\n end\n end", "def export_data(array, name = \"data\")\n CSV.open(\"public/data/\" + name + \"_\" + Time.now.strftime(\"%m_%d_%Y_%H:%M:%S\") + \".csv\", \"w\") do |csv|\n csv << array\n end\n end", "def export\n headers = JSON[params[:column_array]]\n rows = JSON[params[:row_array]]\n column_names = Array.new\n headers.each do |col|\n column_names << col\n end\n csv_string = CSV.generate do |csv|\n csv << column_names\n rows.each do |row|\n csv << row\n end\n end\n\n filename = params[:file_name] + \".csv\"\n send_data(csv_string,\n :type => 'text/csv; charset=utf-8; header=present',\n :filename => filename)\n end", "def to_csv(filename, label_array, data_array)\n CSV.open(filename, \"wb\") do |csv|\n csv << label_array\n data_array.each { |d| csv << d }\n end\n end", "def writeCSVFile(dataArray, fileName)\n\t# Create file handle\n\toutFile = File.new(fileName, 'w');\n\t\n\t# Loop through and output each piece of data\n\tdataArray.each_index do |i|\n\t\toutFile.print(\"#{dataArray[i]}\")\n\t\t\n\t\t# This check is so that we do not have an extra comma at the end\n\t\tif (i < dataArray.length() - 1)\n\t\t\toutFile.print(\", \");\n\t\tend\n\tend\n\toutFile.puts();\n\t\n\toutFile.close();\nend", "def write_csv filename, fields = nil\n\n # By default all fields present in every row of output_data will be incorporated.\n if fields.nil?\n # Transform each output struct into a list of its keys, then take the intersection of each Array of keys.\n # This ensures that only fields present for all rows will be incorporated.\n fields = output_data.map{|o| o.to_h.keys}.inject do |last_keys, this_keys|\n last_keys & this_keys\n end\n end\n\n CSV.open filename, \"wb\", row_sep: \"\\r\\n\" do |csv|\n # Header line\n csv << fields\n\n output_data.each do |out|\n output_row = []\n fields.each do |field|\n output_row << out[field]\n end\n csv << output_row\n end\n end\n end", "def direct_export(file_name, sql = nil, col_sep = \"\\t\")\n sql = self.select(column_names).to_sql if sql.blank?\n data = streaming_query(sql)\n return 0 if data.nil?\n\n write_to_csv(file_name, data, col_sep) {|rec| rec.values }\n end", "def to_csv(array)\n @io.rewind\n @io.truncate(0)\n @csv << array\n @io.rewind\n @io.string\n end", "def output\n CSV.open(\"test.csv\", \"wb\") do |csv|\n csv << [\"name\",\"type\",\"value\",\"date\"]\n @array_csv.each do |element|\n csv << element\n puts element.inspect\n end\n end\n end", "def write_to_simple_csv(filename, data)\n\tfile = filename\n\tdata_for_csv = prep_hash_for_csv(data)\n\tCSV.open(HOME + file, \"wb\") do |csv|\n\t\tdata_for_csv.each do |line|\n\t\t\tcsv << line\n\t\tend\n\tend\nend", "def writeData(filename = \"out.csv\")\n\t\tfile = File.new(filename, \"w\")\n\t\t\n\t\t@dataArray.each do |singleEntry|\n\t\t\tfile.puts \"#{singleEntry[0]},#{singleEntry[1]},#{singleEntry[2]}\"\n\t\tend\n\t\n\t\tfile.close\n\t\t\n\tend", "def write_to_csv(file, table, headers)\n hours_worked = 0\n current_tutor = ''\n CSV.open(file, \"w\", write_headers: true, headers: headers) do |writer|\n table_iterate(table, writer, hours_worked, current_tutor)\n end\n end", "def save_as_csv(array)\n final_array = array\n CSV.open(\"emails94.csv\", \"w\") do |csv|\n csv << [\"Nom des Mairies\", \"Emails des Mairies\"]\n final_array.each do |x|\n\n csv << [x.keys.join, x.values.join]\n end\n end\n end", "def write(data)\n begin\n File.open(@filename, \"wb\") { |file| file.puts data.to_csv }\n rescue \n puts \"Error: \" + $!.to_s\n end \n end", "def store_concert_details_data(concert_details_array, output_file)\n CSV.open(output_file, 'a') do |csv|\n concert_details_array.each{|x| csv << x.toArray()} \n end\n end", "def export_csv\n export_string = \"#{@id},#{type_string},#{@name.gsub(/[\\,,\\s]/,\"\")},\"\n @details.each{|k,v| export_string << \"#{k}=#{v};\".gsub(/[\\,,\\s]/,\"\") }\n export_string\n end", "def export_csv\n export_string = \"#{@id},#{type_string},#{@name.gsub(/[\\,,\\s]/,\"\")},\"\n @details.each{|k,v| export_string << \"#{k}=#{v};\".gsub(/[\\,,\\s]/,\"\") }\n export_string\n end", "def export_to_csv(file_name, arr)\n puts \"Exporting list...\"\n csv_headers = [\"CLS URN:\", \"Lead2Lease Count:\"]\n CSV.open(file_name, \"wb\") do |csv|\n csv << csv_headers\n end\n i = 0\n while i < arr.length\n CSV.open(file_name, \"a+\") do |csv|\n formatted = []\n if arr[i].get_count > 0\n formatted.push(arr[i].name, arr[i].get_count)\n csv << formatted\n end\n end\n i = i+1\n end\n puts \"Lead2Lease list exported!\"\nend", "def save_as_csv\n CSV.open(\"db/emails.csv\", \"wb\") do |csv|\n for i in 0...@ville_name_array.length\n csv << [@ville_name_array[i], @ville_email_array[i]]\n end\n end\n end", "def generateCSV data\n CSV.open(\"schools.csv\", \"wb\") do |csv|\n csv << [ \"school_name\", \"school_address\", \"school_type\", \"school_url\", \"school_area\"]\n data.each do |cell|\n csv << [ cell[\"school_name\"], cell[\"school_address\"], cell[\"school_type\"], cell[\"school_url\"], cell[\"school_area\"]]\n end\n end\nend", "def open_csv(table)\n command = \"mdb-export -bstrip -D '%F %T' -d #{Shellwords.escape(delimiter)} #{file_name} #{table}\"\n Open3.popen3(command) do |stdin, stdout, stderr|\n yield CSV.new(stdout, col_sep: delimiter)\n end\n end", "def write_champ_data(filename, data)\n CSV.open(filename, \"wb\") do |csv|\n csv << [\"ID\", \"Name\", \"Title\"]\n data.each do |data|\n csv << data\n end\n end\nend", "def export_csv\n # Find all Setup with the stored restrictions\n sorting :default => @@default_sort\n collection = @@model.find :all, :order => @sort, :conditions => session[:conditions]\n # Creation of the file\n file_name = \"#{@@param_name}_export_\" + current_user.id.to_s + \".csv\"\n \n csv_string = CSV.generate({:col_sep => ';', :encoding => \"ISO-8859-15\" }) do |csv|\n csv << @@name_print.map{|n| n.trn}\n collection.each do |element|\n csv << @@field_print.map{|f| element[f]}\n end\n end\n send_data Iconv.conv('iso-8859-1//IGNORE', 'utf-8', csv_string), :filename => file_name, :disposition => 'attachment', :type => 'text/csv; charset=iso-8859-1; header=present'\n end", "def format_csv(demographics_data)\n keys = ['geographyName', 'population', 'households', 'incomeBelowPoverty', 'medianIncome']\n csv = demographics_data\n .map { |row| row.fetch_values(*keys) }\n .map { |row| row.join(',')}\n\n keys.join(',') + \"\\n\" + csv.join(\"\\n\")\n end", "def savedata(array)\n CSV.open('scraper.csv', 'a') do |csv|\n csv << array\n end\nend", "def writeCSV(file_name)\n generated_array = transaction(file_name)\n array_from_csv = read_file(file_name)\n final_hash = merge_arrays(array_from_csv, generated_array)\n binding.pry\n\n CSV.open(\"results.csv\", \"w\") do |row|\n final_hash.each do |nested_hash|\n row << [nested_hash[\"SKU\"], nested_hash[\"quantity\"]]\n end #end each nested_hash loop\n end #end csv loop\nend", "def convert_to_csv(obj_array)\n CSV.generate(headers: true) do |csv|\n csv << obj_array.first.keys\n\n obj_array.each do |object|\n csv << object.values\n end\n end\n end", "def export_csv(csv_data)\n\t\tFile.write(\"kfit_partners.csv\", csv_data.map(&:to_csv).join)\n\tend", "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 file_write\n File.open(@@filename,\"r\") do |file|\n file.each_line do |line|\n rg = /<td.*>([\\w\\s\\.*]*)<\\/td>/i\n str = line.scan(rg)\n\n arr = str.to_a\n if arr.any?\n @temp_arr ||= []\n arr.each{|i| @temp_arr.push(arr) }\n @temp_arr\n end\n\n end\n @temp_arr = @temp_arr.flatten\n p @temp_arr\n CSV.open(\"profiles.csv\", \"w\") do |row|\n @temp_arr.each_slice(4).to_a.each do |temp|\n row << temp\n end\n end\n\n end\n end", "def export_data(table_or_report_name, format, criteria, config={})\n body = {'ZOHO_CRITERIA' => criteria}\n body = body.merge!(config) if config.present?\n\n options = {\n :query => {\n 'ZOHO_ACTION' => 'EXPORT',\n 'ZOHO_OUTPUT_FORMAT' => format,\n },\n :body => body\n }\n\n result = send_request get_uri(table_or_report_name), 'post', options\n result\n # TODO: Figure out to what to do with File objects response\n end", "def output_csv(datastore)\n CSV.open(OUTPUT_CSV, \"wb\") do |csv|\n csv << \t[\"Period\", \"First Use In\", \"Engaged Users\"]\n\n datastore.keys.sort.each do |date_key|\n pretty_date = Date.parse(date_key.split(\"_\")[0]).strftime(\"%Y-%m-%d\")\n datastore[date_key].keys.sort.each do |cohort_key|\n pretty_cohort= Date.parse(cohort_key.split(\"_\")[0]).strftime(\"%Y-%m-%d\")\n csv << [ pretty_date, pretty_cohort,\tdatastore[date_key][cohort_key]['total_users']]\n end\n end\n end\nend", "def convert_to_csv(records_array)\n CSV.generate(headers: true) do |csv|\n csv << ATTRIBUTES_TO_SELECT\n\n records_array.each do |info|\n csv << info.attributes\n .slice(*ATTRIBUTES_TO_SELECT)\n .values\n end\n end\n end", "def write_rows file_name, names, values\n header = names.join(',') + \"\\n\"\n body = values.map {|row| row.join(',') }.join($/)\n File.open(file_name + \".csv\", 'w') { |f| f.write(header + body) }\nend", "def export_data\n # This is the basic functionality for exporting the data from the database. By default the data\n # table (what is created when you save_data) is called ocdata, but it can be called anything else,\n # and the query can be more complex, returning, for example, only the most recent results.\n sql_query = \"ocdata.* from ocdata\"\n select(sql_query).collect do |raw_datum|\n # raw_datum will be a Hash of field names (as symbols) for the keys and the values for each field.\n # It should be converted to the format necessary for importing into OpenCorporates by using a\n # prepare_for_export method.\n prepare_for_export(raw_datum)\n end\n end", "def export\n #@contacts = Contact.all\n send_data Contact.to_csv(@contacts),\n :filename => 'addressbook.csv',\n :type => 'text/csv; charset=utf-8',\n :disposition => 'attachment'\n end", "def to_csv\n self.data.to_csv\n end", "def create_column_data_array\n\ttable_id = create_table_id('../data/census_column_metadata.csv')\n\tcolumn_id = create_column_id('../data/census_column_metadata.csv')\n\t\n\t[title_processor,table_id,column_id].transpose\n\nend", "def csv_write(filename,a)\n csv_str = \"\";\n for i in 0..a.size-1 do\n for j in 0..a[i].size-2 do\n csv_str = csv_str + \"\\\"\" + a[i][j].to_s + \"\\\",\"\n end;\n csv_str = csv_str + \"\\\"\" + a[i][j+1].to_s + \"\\\"\\n\";\n end;\n File.write(filename,csv_str);\nend", "def data(table)\n CSV.parse(%x[mdb-export CRBE.mdb #{table}])[1..-1]\nend", "def export_table_to_file(table)\n export_table.export_one_table(get_case_name(), table)\n end", "def download_table\n params = download_table_params\n table_name = params[:table_name].parameterize.underscore\n action_name = table_name + \"_table\"\n table_url = self.send(\"#{table_name}_table_admin_reports_path\") + \".csv\"\n filters = params.except(:table_name).to_h\n \n redirect_to({\n controller: 'reports', \n action: action_name, \n format: :csv\n }.merge(filters))\n end", "def save_to_csv(data)\n h = %w[name github_account picture_url about]\n CSV.open('data.csv', 'w', write_headers: true, headers: h) do |csv|\n csv << [data[:name], data[:github_account], data[:picture_url], data[:about]]\n csv << [\"number of last year's conterbutions #{data[:conterbutions]}\"]\n csv << ['pinned repositories']\n csv << [\"1) #{data[:pinned_repos_urls][0]}\"]\n csv << [\"2) #{data[:pinned_repos_urls][1]}\"]\n csv << [\"3) #{data[:pinned_repos_urls][2]}\"]\n csv << [\"4) #{data[:pinned_repos_urls][3]}\"]\n csv << [\"5) #{data[:pinned_repos_urls][4]}\"]\n csv << [\"6) #{data[:pinned_repos_urls][5]}\"]\n end\nend", "def write(data_row)\n @csv << data_row.values_at(*@output_fields)\n end", "def to_csv_data( options={} )\n inject( [] ) do |arr,model_instance|\n arr.push( *model_instance.to_csv_data( options ) )\n end\n end", "def export(file_name, export_records, options = {})\n\n @file_name = file_name\n\n records = [*export_records]\n\n unless records && !records.empty?\n logger.warn('No objects supplied for export')\n return\n end\n\n first = records[0]\n\n raise ArgumentError, 'Please supply set of ActiveRecord objects to export' unless first.is_a?(ActiveRecord::Base)\n\n @csv_delimiter = options[:csv_delim] if options[:csv_delim]\n\n headers = Headers.klass_to_headers(first.class)\n\n logger.debug \"Writing out CSV Export. Columns delimited by [#{csv_delimiter}]\"\n\n remove_list = DataShift::Transformation::Remove.new.remove_list\n\n CSV.open(file_name, 'w', col_sep: csv_delimiter ) do |csv|\n csv << headers.sources\n\n records.each do |r|\n next unless r.is_a?(ActiveRecord::Base)\n csv.ar_to_row(r, remove_list)\n end\n end\n\n logger.info \"CSV export completed for #{records.size} records\"\n end", "def generate_csv_file(file_path, row_data)\n CSV.open(file_path, \"wb\") do |csv|\n csv << [\"first_name\", \"last_name\", \"dob\", \"member_id\", \"effective_date\", \"expiry_date\", \"phone_number\"]\n row_data.each { |row| csv << row }\n end\nend", "def rewrite(data)\n CSV.open(@@data_path, \"wb\") do |csv|\n csv << [\"id\", \"brand\", \"product\", \"price\"]\n data.each do |item|\n csv << item\n end\n end\n end", "def csvexport_all_tables\n @wires = Wire.all.sort_by {|obj| obj.kabeltyp}\n @switchgears_einbau = Switchgear.all.sort_by {|obj| obj.kennung}\n @switchgears = Switchgear.where(:typ => 1).sort_by {|obj| obj.kennung}\n @assemblies = Assembly.all.sort_by {|obj| obj.kennung}\n @electrical_installations = ElectricalInstallation.all.sort_by {|obj| obj.kennung}\n @drives = Drive.all.sort_by {|obj| obj.kennung}\n @devices = Device.all.sort_by {|obj| obj.definition}\n @iogroups = Iogroup.all.sort_by {|obj| obj.name}\n @switchgearcombinations = Switchgearcombination.all.sort_by {|obj| obj.name}\n @offertpositions = Offertposition.where(:subsubproject_id => params[:subsubproject_id]).sort_by {|obj| obj.name}\n @subsubproject = Subsubproject.find(params[:subsubproject_id])\n @subsubprojects = @subsubproject.subproject.subsubprojects.sort_by {|obj| obj.name}\n @subsystems = @subsubproject.subproject.project.subsystems.all.sort_by {|obj| obj.name}\n @units = Unit.where(:subsystem_id => @subsystems.pluck(:id)).sort_by {|obj| obj.name}\n\n CSV.open(\"export_all_tables#{Time.now.strftime(\"%Y-%m-%d-%H-%M\")}.csv\", \"wb\", {:headers => true, :encoding => \"iso-8859-1\", :col_sep => \";\"}) do |csv|\n csv << ['Geraetetypen', '']\n @devices.each do |entry| csv << [entry.id, entry.definition] end\n csv << ['SPS-Modultypen', '']\n @assemblies.each do |entry| csv << [entry.id, entry.kennung] end\n csv << ['Frequenzumrichtertypen', '']\n @drives.each do |entry| csv << [entry.id, entry.kennung] end\n csv << ['Kabeltypen', '']\n @wires.each do |entry| csv << [entry.id, entry.kabeltyp] end\n csv << ['Elektroinstallationstypen', '']\n @electrical_installations.each do |entry| csv << [entry.id, entry.kennung] end\n csv << ['Schaltschranktypen', '']\n @switchgears.each do |entry| csv << [entry.id, entry.kennung] end\n csv << ['Schaltschrankeinbautypen', '']\n @switchgears_einbau.each do |entry| csv << [entry.id, entry.kennung] end\n csv << ['Schaltgeraetekombinationen', '']\n @switchgearcombinations.each do |entry| csv << [entry.id, entry.name] end\n csv << ['IO-Gruppen', '']\n @iogroups.each do |entry| csv << [entry.id, entry.name] end\n csv << ['Offertpositionen', '']\n @offertpositions.each do |entry| csv << [entry.id, entry.name] end\n csv << ['Teilanlagen', '']\n @subsystems.each do |entry| csv << [entry.id, entry.name] end\n csv << ['TeilanlagenUnits', '']\n @units.each do |entry| csv << [entry.id, entry.name] end\n csv << ['Projektversionen', '']\n @subsubprojects.each do |entry| csv << [entry.id, entry.name] end\n end\n\n redirect_to settings_path, :notice => \"Export wurde unter \" + Rails.root.to_s + \"/ abgelegt!\"\n end", "def to_csv(path = nil)\n path = File.basename(@data.path, '.adt') + '.csv' if path.nil?\n FCSV.open(path, 'w', :force_quotes => true) do |csv|\n each do |record|\n csv << record.to_a\n end\n end\n end", "def to_csv\n str = ''\n str << ( columns.join(\",\") + \"\\n\" )\n rows.each { |row|\n next if is_hr(row) || !row_visible(row)\n str << ( row.map{|x|\n x = x.to_s\n x.gsub(/[\\r\\n]/, ' ').gsub(/\\s+/, ' ').gsub('\"', '\"\"')\n }.map{|x| \"\\\"#{x}\\\"\" }.join(\",\") + \"\\n\" )\n }\n str\n end", "def export_csv\n # Find all Setup with the stored restrictions\n sorting :default => 'es_setups.path, es_setups.name'\n setups = EsSetup.find :all, :order => @sort, :conditions => session[:conditions_setup]\n # Creation of the file\n file_name = \"setups_export_\" + current_user.id.to_s + \".csv\"\n \n csv_string = CSV.generate({:col_sep => ';', :encoding => \"ISO-8859-15\" }) do |csv|\n csv << [\"Chemin\".trn,\"Nom\".trn,\"Valeur\".trn,\"Type\".trn, \"Lecture seule\".trn]\n setups.each do |t|\n csv << [t.path,t.name,t.value,t.type_data,(t.read_only=='Y' ? 'V' : '')]\n end\n end\n send_data Iconv.conv('iso-8859-1//IGNORE', 'utf-8', csv_string), :filename => file_name, :disposition => 'attachment', :type => 'text/csv; charset=iso-8859-1; header=present'\n end", "def render_csv(data,headers,filename)\n csv_writer = ::CSV::Writer.generate(output = '')\n csv_writer << headers.split(',')\n data.each {|row| csv_writer << row}\n\t\tsend_data(output, :type => \"text/plain\", :filename => \"#{filename}\")\n end", "def render_csv(data,headers,filename)\n csv_writer = ::CSV::Writer.generate(output = '')\n csv_writer << headers.split(',')\n data.each {|row| csv_writer << row}\n\t\tsend_data(output, :type => \"text/plain\", :filename => \"#{filename}\")\n end", "def export(params={})\n columns = delimited_string_to_array(Settings.export.travel_fields)\n send_data Travel.export(columns), :filename => \"travel.csv\"\n end", "def csv_writer(rows)\n headers = [\"name\", \"capacity\", \"storage\"]\n CSV.open(\"reservoir_data.csv\", 'w') do |csv|\n csv << headers\n rows.each do |row|\n csv << row\n end\n end\nend", "def write(data)\n raise CSVStream::InsufficientDataError unless data.is_a?(Array)\n\t \twrapper = data[0].is_a?(Array) ? data : [data]\n \t\twrapper.each {|r| write_row(r) }\n \tend", "def write_csv(type, final_arr)\n csv_data = CSV.generate do |csv|\n val = []\n final_arr[0][0].each do |title|\n val << title\n end\n csv << val\n final_arr[1].each do |elem|\n elem.each do |doc|\n data = []\n json_doc = JSON.generate(doc)\n json_doc = JSON.parse(json_doc)\n final_arr[0][0].each do |key|\n key_array = key.split('.')\n data << get_nested_val(key_array,json_doc)\n end\n csv << data\n end\n end\n end\n File.write(\"#{type}_details.csv\",csv_data)\n end", "def save_as_csv\n temp = get_email_list.map{|hash| hash.map{|k, v| [k, v]}}\n temp = temp.map { |data| data.join(\",\") }.join(\"\\n\")\n File.open(\"db/emails.csv\", \"w\") do |csv|\n csv.write(temp)\n end\n end", "def print_as_csv\n file_data = []\n file_data << headers\n @case_data_by_date_map.each do |_, elements|\n file_data += elements.shuffle\n end\n\n file_data.each do |element|\n puts element.join(',')\n end\n end", "def write_csv(path, headers, data)\n return if data.empty?\n CSV.open(path, 'wb') do |csv|\n csv << headers\n data.uniq.each do |row|\n csv << CSV::Row.new(row.keys, row.values).values_at(*headers) unless row.values.all? { |v| v.nil? || v.strip == '' }\n end\n end\n end", "def export_to_csv(file)\n Keybox::Convert::CSV.to_file(@db.records, file)\n hsay \"Exported #{@db.records.size} records to #{file}.\", :information\n end", "def export_data\r\n folder = \"\\data\"\r\n FileUtils.mkdir_p folder\r\n CSV.open(File.join(folder, @output_stats_name), 'wb') do |csv|\r\n csv << @global_bests\r\n csv << @average_global_bests\r\n @neighbourhoods_list[0].report_particles.each do |x|\r\n csv << x\r\n end\r\n end\r\n end", "def save_wizards\n #open the file for writing\n file = File.open(\"wizards.csv\", \"w\")\n # iterate over the array of save_wizards\n @wizards.each do |wizard|\n wizard_data = [wizard[:name], wizard[:house]]\n csv_line = wizard_data.join(\",\")\n file.puts csv_line\n end\n file.close\nend", "def create_csv_for_GH(csv_data)\n\n csv_string = CSV.open(\"#{$basefile}GH.csv\", \"wb\") do |csv|\n\n csv_data.each do |hash|\n csv << hash\n\n end\n end\n end", "def to_csv(array2d,filename=nil)\n fp = File.open(filename,'w') if filename\n array2d.each { |x| \n (fp || STDOUT).puts Array(x)*','\n }\n fp.close if fp\n end", "def export_badge_data(user_data)\n header = []\n rows = []\n\n # grab the first badge in order to get all the info need to create the header row\n user_data[\"badges\"][0].each_key do |key|\n header << key\n end\n\n # loop through all the badges and push the values into their own array\n user_data[\"badges\"].each do |badge|\n row = []\n badge.each_value do |val|\n if val.to_s[val.to_s.length-1] == \"Z\"\n row << val.slice(0, 10).split(\"-\").join(\"/\")\n elsif val.class == Array\n row << val.length\n else\n row << val\n end\n end\n\n # push the new row array (row in CSV file) into the main rows array;\n rows << row\n end\n\n # create the CSV file\n CSV.open(\"badges_#{user_data[\"name\"].downcase.split.join(\"_\")}.csv\", \"wb\") do |csv|\n\n # add the header\n csv << header\n\n # loop through the rows array and push inot the CSV file\n rows.each do |row|\n csv << row \n end\n end\n\n # unless something went wrong, \n if File.exist?(\"badges_#{user_data[\"name\"].downcase.split.join(\"_\")}.csv\")\n puts \"\\nFile successfully save!\"\n else\n puts \"\\nThe files did not save, try again.\"\n end\nend", "def write_to_csv(result_arr)\n\tprint \"Please enter the file you would like to write the gene data to: \"\n\t#example: 'BRCA1_DATA'\n\tfile_name = gets.strip.to_s \n\tCSV.open(\"#{file_name}.csv\", 'wb') do |csv|\n\t\tcsv << ['CAID', 'Protein Changes', 'Clinical Significance', 'Review Status', 'Allele freq', 'Last Evaluated']\n\t\tfor elem in result_arr\n\t\t\tif elem[2] == nil \n\t\t\t\tcsv << [elem[0], elem[1], \"N/A\", elem[3], elem[4], elem[5]]\n\t\t\telse\n\t\t\t\tcsv << [elem[0], elem[1], elem[2], elem[3], elem[4], elem[5]]\n\t\t\tend\n\t\tend\n\tend\nend", "def to_csv\n initialize_generator\n csv_report_generator.records = pull_join\n csv_report_generator.generate_report\n end", "def create_new_csv(file, movie_array)\n CSV.open(file, \"wb\", :write_headers=> true, :headers => [\"movie_title\", \"imdb_link\", \"imdb_id\", \"watched_date\", \"tagline\", \"plot\", \"runtime\", \"rating\", \"votes\", \"poster_url\", \"genres\", \"release_date\"]) do |csv|\n movie_array.each do |movie|\n csv << [movie.title, movie.imdb_link, movie.imdb_id, movie.date, movie.tagline, movie.plot, movie.runtime, movie.rating, movie.votes, movie.poster_url, movie.genres, movie.release_date]\n end\n end\nend", "def write_batch_data\n data = []\n # Loop through each row of data\n @document.xpath('//Row').each do |xml_row|\n row = []\n # Loop through each column value\n @column_names.keys.each do |column|\n row.append(xml_row.xpath(column).text)\n end\n data.append(row)\n end\n\n # Write the data to a csv file\n CSV.open(csv_file_path, 'a') do |csv|\n # Add each row by row\n data.each do |row|\n csv << row\n end\n end\n end", "def csv\n send_data(Map.to_csv, {:filename => \"maps.csv\" })\n end", "def save_csv(file_path, options = {})\n require 'csv'\n default_opts = {\n headers: @field_name, write_headers: true\n }\n CSV.open(file_path, 'wb', default_opts.merge(options)) do |csv|\n @data.each{ |rec| csv << rec }\n end\n end", "def convert_hash_array_to_csv(hash_array)\r\n\t\t\tcsv_string = CSV.generate do |csv|\r\n\t\t\t\tcsv << hash_array.first.keys # adds the attributes name on the first line\r\n\t\t \thash_array.each do |hash|\r\n\t\t \t\tcsv << hash.values\r\n\t\t \tend\r\n\t\t\tend\r\n\t\t\treturn CSV.parse(csv_string, :encoding => 'bom|utf-8')\r\n\t\tend", "def export\n @fans = Fan.active.find(:all)\n\n csv_string = FasterCSV.generate do |csv|\n csv << [\"Name\", \"E-mail\", \"Notes\", \"Section 1 - Description\", \"Section 1 - Email\", \"Section 1 - IM\", \"Section 1 - Phone\", \"Section 1 - Mobile\", \"Section 1 - Pager\", \"Section 1 - Fax\", \"Section 1 - Company\", \"Section 1 - Title\", \"Section 1 - Other\", \"Section 1 - Address\"]\n\n for fan in @fans\n csv << [fan.name,\n fan.email,\n \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\", \"\",\n fan.address \n ]\n end\n end\n\n # filename = @list.name.downcase.gsub(/[^0-9a-z]/, \"_\") + \".csv\"\n filename = \"fans.csv\"\n send_data(csv_string,\n :type => 'text/csv; charset=utf-8; header=present',\n :filename => filename)\n end", "def export_csv\n # Find all Setup with the stored restrictions\n sorting :default => \"name\"\n collection = PostitTask.find :all, :order => @sort, :conditions => session[:conditions]\n # Creation of the file\n file_name = \"postit_task_export_\" + current_user.id.to_s + \".csv\"\n \n csv_string = CSV.generate({:col_sep => ';', :encoding => \"ISO-8859-15\" }) do |csv|\n csv << [\"Nom\".trn,\"Description\".trn,\"Séquence\".trn]\n collection.each do |element|\n csv << [element.name,element.description,element.sequence]\n end\n end\n send_data Iconv.conv('iso-8859-1//IGNORE', 'utf-8', csv_string), :filename => file_name, :disposition => 'attachment', :type => 'text/csv; charset=iso-8859-1; header=present'\n end", "def create_output_csv(output)\n CSV.open(\"./output.csv\", \"wb\") do |csv|\n output.each do |row|\n csv << row\n end\n end\n end", "def save_students\n #open the file for writing\n filename = get_filename\n #save each entry of the array @students into the file\n CSV.open(filename, \"wb\") do |csv|\n @students.each do |student|\n student_data = [student[:name], student[:cohort]]\n csv << student_data\n end\n end\n\nend", "def csv_write (filename = \"students.csv\")\n CSV.open(filename, \"w\") do |row|\n @students.each do |student|\n row << [student[:name], student[:cohort], student[:food]]\n end\n end\nend", "def output_data(filename)\n output = CSV.open(filename, \"w\")\n @file.each do |line|\n if @file.lineno == 2\n output << line.headers\n else\n line[:homephone] = clean_numbers(line[:homephone])\n line[:zipcode] = clean_zipcodes(line[:zipcode])\n output << line\n end\n\n end\n end", "def update_csv\n CSV.open(@csv_file, \"w\") do |csv|\n csv << [\"id\", \"name\", \"password\", \"title\"]\n @data.each do |record|\n csv << [record.id, record.name, record.password, record.title]\n end\n end\n end", "def write_to_csv(type)\n fields = return_fields(type)\n records = get_records(type)\n file_name = generate_name(type)\n\n CSV.open(file_name, \"wb:UTF-8\") do |file|\n @logger.info \"Opened #{file_name} for export\"\n file << fields\n records.each do |record|\n arr = []\n fields.each do |field|\n arr << record.send(field)\n arr.map!(&method(:remove_quotes))\n end\n file << arr\n end\n end\n end", "def fee_reciepts_export_csv\n parameters={:search => params[:search] ,:filename => filename}\n csv_export('finance_transaction', 'fee_reciepts_export', parameters) \n end", "def csv_report\n tire_cols = params[:tire] || {}\n ar_cols = params[:activerecord] || {}\n assocs_to_include = params[:assoc][:include] || {}\n params[:assoc][:max] ||= {}\n klass = model_class.constantize\n @filename = \"#{model_class.humanize}.csv\"\n\n response.headers['Content-Type'] ||= 'text/plain'\n response.headers['Content-Disposition'] = \"attachment; filename=#{@filename}\"\n response.headers['Content-Transfer-Encoding'] = 'binary'\n response.headers['Last-Modified'] = Time.now.to_s\n\n # Right, try to define a header:\n header = []\n tire_cols.keys.each { |x| header.push(x.humanize) }\n ar_cols.keys.each { |x| header.push(x.humanize) }\n assocs_to_include.keys.each do |assoc|\n if params[:assoc][:max][assoc] == 'join' # Is a has_many with only one real column\n header.push params[:assoc][assoc.to_sym].keys.first\n elsif params[:assoc][:max][assoc] # has_many\n (1 .. (params[:assoc][:max][assoc].to_i)).each do |i|\n params[:assoc][assoc.to_sym].keys.each do |k|\n header.push(\"#{assoc.singularize.humanize} #{i} #{k.humanize}\")\n end\n end\n else # has_a\n params[:assoc][assoc.to_sym].keys.each do |k| # Each key requested from the associated record\n header.push \"#{assoc.humanize} #{k.humanize}\"\n end\n end\n end\n\n results = klass.search({ per: TireSearch::INFINITY }, 1, '')\n self.response_body = Enumerator.new do |y|\n results.each_with_index do |result, i|\n y << header.to_csv if i == 0\n\n line = []\n tire_cols.keys.each { |x| line.push(result[x]) }\n\n result = result.load if ar_cols.count > 0 || assocs_to_include.keys.count > 0\n\n ar_cols.keys.each { |x| line.push(result.send(x)) } if ar_cols.count > 0\n\n assocs_to_include.keys.each do |assoc|\n related = result.send(assoc)\n if params[:assoc][:max][assoc] == 'join' # Is a has_many with only one real column\n col = params[:assoc][assoc.to_sym].keys.first\n line.push related.map { |x| x.send(col) }.join(' // ')\n elsif params[:assoc][:max][assoc]\n (0 .. (params[:assoc][:max][assoc].to_i - 1)).each do |j|\n params[:assoc][assoc.to_sym].keys.each do |k|\n line.push(related[j] ? related[j].send(k) : nil)\n end\n end\n else\n params[:assoc][assoc.to_sym].keys.each do |k| # Each key requested from the associated record\n line.push related ? related.send(k) : nil\n end\n end\n end\n y << line.to_csv\n GC.start if i % 500 == 0\n end\n end\n end", "def to_csv(csv_file_name = 'ponderated_season_' + @season.id.to_s)\n # Check if data already collected and collect if needed\n scan_for_gender_category_and_event if @single_events.count == 0\n\n rows = []\n\n File.open(csv_file_name + '.csv', 'w') do |f|\n titles = ['gender', 'category', 'event', 'pool', 'total_results', 'ponderated best', 'best results']\n rows << titles.join(';')\n\n @single_events.each do |event|\n event_row = ''\n event_row += event.gender_type.code + ';'\n event_row += event.category_type.code + ';'\n event_row += event.event_type.code + ';'\n event_row += event.pool_type.code + ';'\n event_row += event.total_results.to_s + ';'\n event_row += event.get_ponderated_best.to_s + ';'\n event_row += event.best_results.map { |mir| mir.get_timing.to_s }.join(';')\n rows << event_row\n end\n f.puts rows.map { |row| row }\n end\n end", "def save_students\n# open the file to save\n file = File.open(\"students.csv\", \"w\")\n# iterate over the array of students\n @students.each do |student|\n student_data = [student[:name], student[:cohort]]\n csv_line = student_data.join(\",\")\n file.puts csv_line\n end\n file.close\nend", "def write_to_csv(data_hash)\n\tprint(\"Please enter the name of the csv file to be written: \")\n\t#example: BRCA1_Data\n\tfile = gets.strip.to_s\n\tCSV.open(\"#{file}.csv\", 'wb') do |csv|\n\t\tfor key in data_hash\n\t\tcsv << [key[0], key[1]]\n\t\tend\n\tend\n\tputs \"done!\"\nend", "def export_data(data, exporter)\n if data.respond_to?(:find_in_batches) && data.respond_to?(:orders) && data.orders.blank? && data.respond_to?(:taken) && data.taken.blank?\n data.find_in_batches(find_in_batches_options) do |group|\n group.each{|f| exporter << generate_value(f) }\n end\n else\n data.each{|f| exporter << generate_value(f) }\n end\n end", "def to_csv( options={} )\n FasterCSV.generate do |csv|\n headers = self.class.to_csv_headers( options )\n csv << headers if headers\n to_csv_data( options ).each{ |data| csv << data }\n end\n end", "def export\n @transactions = Transaction.find_all_by_user_id(current_user.id)\n csv = \"\"\n i = 0\n @transactions.each do |trans|\n if (i==0)\n csv += trans.to_csv(true)\n else\n csv += trans.to_csv(false)\n end\n i += 1\n end\n\n respond_to do |format|\n format.csv { send_data csv }\n end\n end", "def export_data_using_sql(table_or_report_uri, format, sql, config={})\n body = {'ZOHO_SQLQUERY' => sql}\n body = body.merge!(config) if config.present?\n\n options = {\n :query => {\n 'ZOHO_ACTION' => 'EXPORT',\n 'ZOHO_OUTPUT_FORMAT' => format,\n },\n :body => body\n }\n\n result = send_request get_uri(table_or_report_name), 'post', options\n result\n # TODO: Figure out to what to do with File objectsw response\n end", "def updateCSVFile\n\t\tFile.open('accounts.csv', 'w') do |file|\n\t\t\tfile << \"Account,Date,Payee,Category,Outflow,Inflow\\n\"\n\t\t\t@arrayOfRows.each do |line|\n\t\t\t\tfile << line\n\t\t\tend\n\t\tend\n\tend", "def csv_download\n filename = sprintf(\"%s-%s.csv\",\n model_name,\n Time.now.strftime(\"%Y%m%d-%H%M%S\"))\n file = Tempfile.new(filename, Settings.edgarj.csv_dir)\n csv_visitor = EdgarjHelper::CsvVisitor.new(view_context)\n file.write CSV.generate_line(model.columns.map{|c| c.name})\n for rec in user_scoped.where(page_info.record.conditions).\n order(\n page_info.order_by.blank? ?\n nil :\n page_info.order_by + ' ' + page_info.dir) do\n array = []\n for col in model.columns do\n array << csv_visitor.visit_column(rec, col)\n end\n file.write CSV.generate_line(array)\n end\n file.close \n File.chmod(Settings.edgarj.csv_permission, file.path)\n send_file(file.path, {\n type: 'text/csv',\n filename: filename})\n #file.close(true)\n end", "def to_csv_dash_data\n @grant_data = dash_data_create\n respond_to do |format|\n format.html\n format.csv do\n send_data @grant_data, filename: \"all_dashboard_data#{Time.now.to_s(:db)}.csv\"\n end\n # format.CSV {render csv: @grant_data.to_csv}\n # format.xls {render text: @grant_data.to_csv(col_sep: \"\\t\")}\n end\n end", "def generateCSV()\n findCommits\n findLinesOfCode\n\n CSV.open(\"data.csv\", \"wb\") {|csv| @students.to_a.each {|elem| csv << elem} }\nend", "def export_users(file)\n users = User.all\n\n csv_string = FasterCSV.generate do |csv|\n users.each do |user|\n csv << [user.email, user.first_name, user.last_name]\n end\n end\n\n send_data csv_string,\n :type => 'text/csv; charset=iso-8859-1; header=present',\n :disposition => \"attachment; filename=users.csv\"\n File.open(file,\"w\").write\n end", "def build_csv(file_name)\n\t\t\t\t\t\tarr = [\"Location URN\", \"Email List\"]\n\t\t\t\t\t\t\t\tCSV.open(file_name, \"wb\") do |csv|\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tcsv << arr\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\nend", "def add_to_csv(arr)\n\t\t\t\t\t\tCSV.open(\"location-emails.csv\", \"a+\") do |csv|\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tcsv << arr\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tend\nend", "def export_to_csv\n puts 'Please enter a csv file name:'\n\n filename = get_filename\n filename = add_csv_suffix_if_needed filename\n \n write_to_csv_file filename\n \n end", "def escribir_promedios(array)\n #por cada alumno\n array.each do |alumno|\n #split en cada ,\n al = alumno.split(', ').map(&:chomp)\n #generar el nombre del archivo del alumno\n filename = \"#{al[0]}.csv\"\n #generar el archivo\n alumno_file = File.open(filename, \"w\")\n #obtener el promedio final del alumno\n final = promedio_alumno(al)\n #escribir el promedio final en el archivo\n alumno_file.puts final\n #cerrar\n alumno_file.close\n end \nend" ]
[ "0.73341936", "0.73341936", "0.69036597", "0.65343547", "0.65272987", "0.6493118", "0.6469194", "0.632637", "0.62658876", "0.623132", "0.62234145", "0.62212783", "0.62028", "0.6189768", "0.618202", "0.60957974", "0.60957974", "0.6062983", "0.6034636", "0.6026678", "0.6009424", "0.5984309", "0.5977921", "0.5972698", "0.59623903", "0.59475076", "0.5919111", "0.591542", "0.59099007", "0.59012896", "0.5882847", "0.5879842", "0.5876141", "0.5863321", "0.58620214", "0.58520997", "0.583045", "0.5825259", "0.5784948", "0.57831794", "0.57655567", "0.57632875", "0.57570744", "0.57441807", "0.5737671", "0.5723406", "0.570979", "0.57019794", "0.5699631", "0.5686898", "0.56860405", "0.56745815", "0.5662688", "0.5662688", "0.56413203", "0.56402206", "0.5640136", "0.561998", "0.56029844", "0.5597403", "0.5594994", "0.5580393", "0.55773866", "0.55768317", "0.5570742", "0.5565001", "0.55556726", "0.555567", "0.555322", "0.5548034", "0.55470407", "0.5540257", "0.5531852", "0.55127096", "0.5508412", "0.55060804", "0.5505183", "0.5503991", "0.54943895", "0.5490899", "0.5490008", "0.54845595", "0.5483201", "0.548261", "0.54814935", "0.547646", "0.5469306", "0.5461355", "0.54577094", "0.54533595", "0.5437493", "0.54349256", "0.54183865", "0.5414706", "0.54135627", "0.54061145", "0.54011744", "0.5400509", "0.5393418", "0.53837246" ]
0.8191336
0
Use the column_options to change data to a specific type
def convert_value(value, column_options) if column_options case column_options[:type] when 'Number' return value.to_i end end value end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def change_column(table_name, column_name, type, options = {})\n begin\n execute \"ALTER TABLE #{table_name} ALTER COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\"\n rescue ActiveRecord::StatementInvalid\n # This is PostgreSQL 7.x, so we have to use a more arcane way of doing it.\n begin_db_transaction\n tmp_column_name = \"#{column_name}_ar_tmp\"\n add_column(table_name, tmp_column_name, type, options)\n execute \"UPDATE #{table_name} SET #{quote_column_name(tmp_column_name)} = CAST(#{quote_column_name(column_name)} AS #{type_to_sql(type, options[:limit], options[:precision], options[:scale])})\"\n remove_column(table_name, column_name)\n rename_column(table_name, tmp_column_name, column_name)\n commit_db_transaction\n end\n \n change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)\n change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)\n end", "def change_column(table_name, column_name, type, options = {})\n execute(\n \"ALTER TABLE #{quote_table_name(table_name)} \"+\n \"ALTER COLUMN #{quote_column_name(column_name)} \"+\n \"SET DATA TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\",\n SCHEMA_LOG_NAME\n )\n change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)\n change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)\n end", "def change_column(table_name, column_name, type, options = {})\n quoted_table_name = quote_table_name(table_name)\n\n begin\n execute \"ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\"\n rescue ActiveRecord::StatementInvalid => e\n begin\n begin_db_transaction\n tmp_column_name = \"#{column_name}_ar_tmp\"\n add_column(table_name, tmp_column_name, type, options)\n execute \"UPDATE #{quoted_table_name} SET #{quote_column_name(tmp_column_name)} = CAST(#{quote_column_name(column_name)} AS #{type_to_sql(type, options[:limit], options[:precision], options[:scale])})\"\n remove_column(table_name, column_name)\n rename_column(table_name, tmp_column_name, column_name)\n commit_db_transaction\n rescue\n rollback_db_transaction\n end\n end\n\n change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)\n change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)\n end", "def change_column(table_name, column_name, type, options = {})\n sql = \"ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\"\n add_column_options!(sql, options)\n execute(sql)\n end", "def prepare_column_options(column)\n super.tap do |spec|\n spec[:encoding] = \"'#{column.sql_type_metadata.encoding}'\" if column.sql_type_metadata.encoding.present?\n end\n end", "def change_column(table_name, column_name, type, options = {})\n quoted_table_name = quote_table_name(table_name)\n\n begin\n execute \"ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\"\n rescue ActiveRecord::StatementInvalid => e\n raise e if postgresql_version > 80000\n # This is PostgreSQL 7.x, so we have to use a more arcane way of doing it.\n begin\n begin_db_transaction\n tmp_column_name = \"#{column_name}_ar_tmp\"\n add_column(table_name, tmp_column_name, type, options)\n execute \"UPDATE #{quoted_table_name} SET #{quote_column_name(tmp_column_name)} = CAST(#{quote_column_name(column_name)} AS #{type_to_sql(type, options[:limit], options[:precision], options[:scale])})\"\n remove_column(table_name, column_name)\n rename_column(table_name, tmp_column_name, column_name)\n commit_db_transaction\n rescue\n rollback_db_transaction\n end\n end\n\n change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)\n change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)\n end", "def change_column(table_name, column_name, type, options = {})\n quoted_table_name = quote_table_name(table_name)\n quoted_column_name = quote_table_name(column_name)\n\n sql_type = type_to_sql(type, options[:limit], options[:precision], options[:scale])\n sql_type << \"[]\" if options[:array]\n\n sql = \"ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quoted_column_name} TYPE #{sql_type}\"\n sql << \" USING #{options[:using]}\" if options[:using]\n if options[:cast_as]\n sql << \" USING CAST(#{quoted_column_name} AS #{type_to_sql(options[:cast_as], options[:limit], options[:precision], options[:scale])})\"\n end\n begin\n execute sql\n rescue ActiveRecord::StatementInvalid => e\n raise e if postgresql_version > 80000\n change_column_pg7(table_name, column_name, type, options)\n end\n\n change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)\n change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)\n end", "def datatype\n @options[:datatype] || (@column ? @column.type : nil)\n end", "def change_column(table_name, column_name, type, options = {})\n clear_cache!\n quoted_table_name = quote_table_name(table_name)\n sql_type = type_to_sql(type, options[:limit], options[:precision], options[:scale])\n sql = \"ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{sql_type}\"\n sql << \" USING #{options[:using]}\" if options[:using]\n if options[:cast_as]\n sql << \" USING CAST(#{quote_column_name(column_name)} AS #{type_to_sql(options[:cast_as], options[:limit], options[:precision], options[:scale])})\"\n end\n execute sql\n\n change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)\n change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)\n end", "def column(name, type)\n @fields.merge!(name => type.to_s)\n end", "def finalize_datatypes_for_csv\n csv_column_datatypes.map { |column_name, possible_datatypes|\n #If there is string type even atleast 1 there is no other option but to set the datatype to string => varchar\n if possible_datatypes.has_key?(:string)\n csv_column_datatypes[column_name] = :string\n else\n #set the max occurance datatype as the datatype of column\n csv_column_datatypes[column_name] = possible_datatypes.key(possible_datatypes.values.max)\n end\n }\n end", "def column_type\r\n @type\r\n end", "def cast(data_type)\n case data_type\n when String\n new_jcolumn = jcolumn.cast(data_type)\n when DataType\n jdata_type = JDataType.fromJson(data_type.json)\n new_jcolumn = jcolumn.cast(jdata_type)\n else\n raise ArgumentError, \"Unsupported type: #{data_type.class}\"\n end\n\n Column.new(new_jcolumn)\n end", "def set_type_for_columns(table_name, column_type, *args)\n @table_column_type ||= {}\n @table_column_type[table_name] ||= {}\n args.each do |col|\n @table_column_type[table_name][col.to_s.downcase] = column_type\n end\n end", "def set_column_type(table, *args)\n alter_table(table) {set_column_type(*args)}\n end", "def set_column_type(table, *args)\n alter_table(table) {set_column_type(*args)}\n end", "def augment_column_config(c)\n super\n set_default_data_index(c)\n set_default_xtype c\n end", "def change\n change_column(:table_name, :column_name, :new_type)\nend", "def schema_column_type(db_type)\n case db_type\n when /\\Ainterval\\z/io\n :interval\n when /\\Acitext\\z/io\n :string\n else\n super\n end\n end", "def type_cast(value)\r\n @column_definition.type_cast(value)\r\n end", "def apply_reporter_schema(name, type, options={})\n column name, type.to_s.downcase.to_sym, options\n end", "def dbms_type_cast(columns, values)\n int_column = {}\n columns.each_with_index do |c, i|\n int_column[i] = c.type == 3 && c.scale == 0\n end\n\n float_column = {}\n columns.each_with_index do |c, i|\n float_column[i] = c.type == 3 && c.scale != 0\n end\n\n values.each do |row|\n row.each_index do |idx|\n val = row[idx]\n if val\n if int_column[idx]\n row[idx] = val.to_i\n elsif float_column[idx]\n row[idx] = val.to_f\n elsif val.is_a?(String)\n row[idx] = val.force_encoding('UTF-8')\n end\n end\n end\n end\n end", "def type(column); self[column]['type']; end", "def import_column_type_and_options( opts )\n opts = opts.dup\n\n # Discard anything we don't need.\n\n opts.delete_if{ |key, value| IGNORED_OPTS.include? key }\n\n # Import type.\n\n type = opts.delete( :type )\n db_type = opts.delete( :db_type )\n\n type, type_opts = revert_type_literal( db_type, type )\n opts.merge!( type_opts ) if type_opts\n\n # Import NULL option.\n\n opts[ :null ] = opts.delete( :allow_null )\n\n # Import default value.\n\n default = opts.delete( :default )\n ruby_default = opts.delete( :ruby_default )\n\n default = revert_default( type, default, ruby_default )\n\n opts[ :default ] = default unless default.nil?\n\n [ type, opts ]\n end", "def scaffold_column_type_options(type)\n @scaffold_column_type_options ||= {}\n @scaffold_column_type_options[type] ||= SCAFFOLD_OPTIONS[:column_type_options][type] || {}\n end", "def cast_data_for_column(data, col)\n if !@columns\n raise \"need to fetch columns but in a query\"\n end\n\n case @columns[col][:type]\n when /boolean/i\n return data == true ? 1 : 0\n when /datetime/i\n return (data == nil ? nil : data.to_i)\n when /integer/i\n return (data == nil ? nil : data.to_i)\n else\n return data\n end\n end", "def convert_to_type(val)\n case type\n when 'NilClass'\n if val != false && val.blank?\n # Leave the type of the Column open. Unfortunately, false counts as\n # blank and we don't want it to. It should be classified as a boolean.\n new_val = nil\n else\n # Only non-blank values are allowed to set the type of the Column\n bool_val = convert_to_boolean(val)\n new_val =\n if bool_val.nil?\n convert_to_date_time(val) ||\n convert_to_numeric(val) ||\n convert_to_string(val)\n else\n bool_val\n end\n @type =\n if [true, false].include?(new_val)\n 'Boolean'\n elsif new_val.is_a?(Date) || new_val.is_a?(DateTime)\n 'DateTime'\n elsif new_val.is_a?(Numeric)\n 'Numeric'\n elsif new_val.is_a?(String)\n 'String'\n else\n msg = \"can't add #{val} of type #{new_val.class.name} to a column\"\n raise UserError, msg\n end\n end\n new_val\n when 'Boolean'\n if val.is_a?(String) && val.blank? || val.nil?\n nil\n else\n new_val = convert_to_boolean(val)\n if new_val.nil?\n msg = \"attempt to add '#{val}' to a column already typed as #{type}\"\n raise UserError, msg\n end\n new_val\n end\n when 'DateTime'\n if val.blank?\n nil\n else\n new_val = convert_to_date_time(val)\n if new_val.nil?\n msg = \"attempt to add '#{val}' to a column already typed as #{type}\"\n raise UserError, msg\n end\n new_val\n end\n when 'Numeric'\n if val.blank?\n nil\n else\n new_val = convert_to_numeric(val)\n if new_val.nil?\n msg = \"attempt to add '#{val}' to a column already typed as #{type}\"\n raise UserError, msg\n end\n new_val\n end\n when 'String'\n if val.nil?\n nil\n else\n new_val = convert_to_string(val)\n if new_val.nil?\n msg = \"attempt to add '#{val}' to a column already typed as #{type}\"\n raise UserError, msg\n end\n new_val\n end\n else\n raise UserError, \"Mysteriously, column has unknown type '#{type}'\"\n end\n end", "def set_data_type_and_array\n column_schema = SearchFacet.get_table_schema(column_name: self.big_query_id_column)\n detected_type = column_schema[:data_type]\n self.is_array_based = detected_type.include?('ARRAY')\n item_type = BQ_DATA_TYPES.detect {|d| detected_type.match(d).present?}\n self.data_type = BQ_TO_FACET_TYPES[item_type]\n end", "def map_types!(column_mapping)\n\t\tself.column_mapping = column_mapping\n\t\tself\n\tend", "def add_column(table_name, column_name, type, options = {})\n clear_cached_table(table_name)\n add_column_sql = \"ALTER TABLE #{table_name} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\"\n add_column_options!(add_column_sql, options)\n # TODO: Add support to mimic date columns, using constraints to mark them as such in the database\n # add_column_sql << \" CONSTRAINT ck__#{table_name}__#{column_name}__date_only CHECK ( CONVERT(CHAR(12), #{quote_column_name(column_name)}, 14)='00:00:00:000' )\" if type == :date\n execute(add_column_sql)\n end", "def add_column(table_name, column_name, type, options = {})\n clear_cached_table(table_name)\n add_column_sql = \"ALTER TABLE #{table_name} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\"\n add_column_options!(add_column_sql, options)\n # TODO: Add support to mimic date columns, using constraints to mark them as such in the database\n # add_column_sql << \" CONSTRAINT ck__#{table_name}__#{column_name}__date_only CHECK ( CONVERT(CHAR(12), #{quote_column_name(column_name)}, 14)='00:00:00:000' )\" if type == :date\n execute(add_column_sql)\n end", "def set_data_type_and_array\n column_schema = SearchFacet.get_table_schema(column_name: big_query_id_column)\n detected_type = column_schema[:data_type]\n self.is_array_based = detected_type.include?('ARRAY')\n item_type = BQ_DATA_TYPES.detect { |d| detected_type.match(d).present? }\n self.data_type = BQ_TO_FACET_TYPES[item_type]\n end", "def convert_cell(value, coltype)\n case coltype\n when \"boolean\"\n value ? 'true' : 'false'\n when \"number\"\n value.to_i\n when \"string\"\n value\n when \"date\"\n DataDate.new(Date.parse(value))\n when \"datetime\"\n DataDateTime.new(DateTime.parse(value))\n when \"timeofday\"\n [ value.hour, value.min, value.sec, value.usec / 1000 ]\n end\n end", "def set_types(column_types)\n raise NotImplementedError.new\n end", "def up\n change_column(:my_table, :my_columnn, :new_type)\nend", "def add_column(table_name, column_name, type, options = {})\n clear_cached_table(table_name)\n add_column_sql = \"ALTER TABLE #{quote_table_name(table_name)} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\"\n add_column_options!(add_column_sql, options)\n # TODO: Add support to mimic date columns, using constraints to mark them as such in the database\n # add_column_sql << \" CONSTRAINT ck__#{table_name}__#{column_name}__date_only CHECK ( CONVERT(CHAR(12), #{quote_column_name(column_name)}, 14)='00:00:00:000' )\" if type == :date\n execute(add_column_sql)\n end", "def column_type(type_indicator)\n case type_indicator\n when :eval; :text\n when :text; :text\n when :string; :string\n when :sec; :double\n when :msec; :double\n when :duration; :double\n when :float; :double\n when :double; :double\n when :integer; :integer\n when :int; :int\n when :timestamp; :datetime\n when :datetime; :datetime\n when :date; :date\n else :string\n end\n end", "def column_options\n { limit: column.limit, default: column.default, null: column.null }\n end", "def map_value(column_type)\n case column_type\n when :datetime then :timestamp\n when :json then :string\n else column_type\n end\n end", "def convert_text_column_storage_type(table_name, column_name, to_type, temp_column_name)\n quoted_table_name = quote_table_name(table_name)\n orig_col = quote_column_name(column_name)\n temp_col = quote_column_name(temp_column_name || 'oee_temp_col')\n cmds = <<-SQL\n alter table #{quoted_table_name} add #{temp_col} #{to_type}\n update #{quoted_table_name} set #{temp_col} = #{orig_col}\n alter table #{quoted_table_name} drop column #{orig_col}\n alter table #{quoted_table_name} rename column #{temp_col} to #{orig_col}\n SQL\n cmds.split(\"\\n\").map(&:strip).each{|cmd| execute cmd}\n end", "def default_input_type(attribute_name, column, options); end", "def datatype_analysis\n SmarterCSV.process(filename, {:col_sep => delimiter, :chunk_size => chunk_size, \n :remove_empty_values => false, :remove_zero_values => false}) do |chunk|\n chunk.each do |row|\n row.each do |key, value|\n unless null_like?(value)\n datatype = determine_dataype(value)\n add_to_datatype(key, datatype.to_sym)\n else \n nullable.push(key) unless nullable.include?(key)\n end\n end\n end\n break\n end\n options[:csv_datatype_analysis] = csv_column_datatypes.clone # To retain the current state of csv_column_datatypes since it's altered further\n finalize_datatypes_for_csv\n options[:csv_column_datatypes] = csv_column_datatypes\n options[:nullable] = nullable\n take_further_actions\n end", "def column_type(type)\n case type\n when :integer then Integer\n when :float, :decimal then Float\n when :string, :text, :uuid then String\n when :datetime, :timestamp, :time then DateTime\n when :date then Date\n when :boolean then Virtus::Attribute::Boolean # Boolean is not a standard Ruby class\n else\n raise \"Could not match column type '#{type}' for #{model_name}\"\n end\n end", "def schema_column_type(db_type)\n case db_type\n when 'json'\n :json\n when 'jsonb'\n :jsonb\n else\n super\n end\n end", "def value_column\n case value_type\n when 'integer' then 'value_integer'\n when 'float' then 'value_float'\n when 'string' then 'value_string'\n else raise_invalid_type\n end\n end", "def set_columns_changeable(value)\n self.write_attribute :columns_changeable, value.to_json\n end", "def column(name, type = nil, options = {})\n super\n column = self[name]\n # NOTE: <= 3.1 no #new_column_definition hard-coded ColumnDef.new :\n # column = self[name] || ColumnDefinition.new(@base, name, type)\n # thus we simply do not support array column definitions on <= 3.1\n column.array = options[:array] if column.is_a?(ColumnDefinition)\n self\n end", "def convert(t, dtype)\n dtype.each do |col, type|\n if type == Integer \n t[col] = t[col].map{|v| v.to_i unless v.nil?}\n elsif type == Float\n t[col] = t[col].map{|v| v.to_f unless v.nil?}\n elsif type == String\n t[col] = t[col].map{|v| v.to_s unless v.nil?}\n elsif type == DateTime\n t[col] = t[col].map do |dt|\n begin\n DateTime.parse dt.to_s\n rescue => exception\n end\n end\n elsif type == Date\n t[col] = t[col].map do |dt|\n begin\n Date.parse dt.to_s\n rescue => exception\n end\n end\n else\n throw \"Unsupported dtype '#{type}'\"\n end\n end\n end", "def to_table_column\n col_type = type ? type.to_sym : :string\n [column_name, col_type, { index: index_options, default: default }]\n end", "def schema_column_type(db_type)\n if convert_smallint_to_bool && db_type =~ /smallint/i \n :boolean\n else\n super\n end\n end", "def set_columns_changeable(value)\n write_attribute :columns_changeable, value.to_json\n end", "def column_type\n class_name.columns_hash[@column.to_s].type\n end", "def column_options_for(type, request, obj, column)\n opts = model.column_options_for(type, request, column)\n if opts[:class] == 'autoforme_autocomplete'\n if type == :show\n opts[:value] = model.column_value(type, request, obj, column)\n elsif key = obj.send(model.association_key(column))\n opts[:value] = \"#{key} - #{model.column_value(type, request, obj, column)}\"\n end\n end\n opts\n end", "def data_type=(value)\n @data_type = value\n end", "def options_to_columns(options)\n columns = []\n options[:columns].each do |column|\n if column.kind_of? Symbol # a column from the database, we don't need to do anything\n columns << {:name => column, :attribute => column}\n elsif column.kind_of? Hash\n columns << {:name => column[:name], :special => column}\n end\n end\n columns\n end", "def column_types\n @column_types ||= @columns.values\n end", "def add_column(table_name, column_name, type, options = {})\n add_column_sql = \"ALTER TABLE #{quote_table_name(table_name)} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\"\n add_column_options!(add_column_sql, options)\n begin\n execute(add_column_sql)\n rescue\n raise unless non_existent_domain_error?\n create_boolean_domain\n execute(add_column_sql)\n end\n if options[:position]\n # position is 1-based but add 1 to skip id column\n alter_position_sql = \"ALTER TABLE #{quote_table_name(table_name)} ALTER COLUMN #{quote_column_name(column_name)} POSITION #{options[:position] + 1}\"\n execute(alter_position_sql)\n end\n end", "def column_type\n return @column_type if defined?(@column_type)\n ind = index\n table[1..500].each do |row|\n if row[ind]&.cell_type\n cel_column_type = row[ind].cell_type\n if !defined?(@column_type) || @column_type.nil?\n @column_type = cel_column_type\n elsif (cel_column_type == @column_type) || (cel_column_type == :nil)\n else\n @column_type = :string\n break\n end\n end\n end\n @column_type\n end", "def add_column(name, type, options = {})\n\t printf \"Column name is: %s\\n\", name\n\t printf \"Type is: %s\\n\", type\n\t options.each {|key, value| puts \"The #{key} is #{value}\" }\n\tend", "def add_column_types obj\n FbArray.new(obj)\n end", "def uncast_data_from_column(data, col)\n if !@columns\n raise \"need to fetch columns but in a query\"\n end\n\n case @columns[col][:type]\n when /boolean/i\n return (data >= 1)\n when /datetime/i\n return (data == nil ? nil : Time.at(data.to_i))\n when /integer/i\n return (data == nil ? nil : data.to_i)\n else\n return data\n end\n end", "def dbms_type_cast(columns, rows)\n # Cast the values to the correct type\n columns.each_with_index do |column, col_index|\n #puts \" #{column.name} type #{column.type} length #{column.length} nullable #{column.nullable} scale #{column.scale} precision #{column.precision} searchable #{column.searchable} unsigned #{column.unsigned}\"\n rows.each do |row|\n value = row[col_index]\n\n new_value = case\n when value.nil?\n nil\n when [ODBC::SQL_CHAR, ODBC::SQL_VARCHAR, ODBC::SQL_LONGVARCHAR].include?(column.type)\n # Do nothing, because the data defaults to strings\n # This also covers null values, as they are VARCHARs of length 0\n value.is_a?(String) ? value.force_encoding(\"UTF-8\") : value\n when [ODBC::SQL_DECIMAL, ODBC::SQL_NUMERIC].include?(column.type)\n column.scale == 0 ? value.to_i : value.to_f\n when [ODBC::SQL_REAL, ODBC::SQL_FLOAT, ODBC::SQL_DOUBLE].include?(column.type)\n value.to_f\n when [ODBC::SQL_INTEGER, ODBC::SQL_SMALLINT, ODBC::SQL_TINYINT, ODBC::SQL_BIGINT].include?(column.type)\n value.to_i\n when [ODBC::SQL_BIT].include?(column.type)\n value == 1\n when [ODBC::SQL_DATE, ODBC::SQL_TYPE_DATE].include?(column.type)\n value.to_date\n when [ODBC::SQL_TIME, ODBC::SQL_TYPE_TIME].include?(column.type)\n value.to_time\n when [ODBC::SQL_DATETIME, ODBC::SQL_TIMESTAMP, ODBC::SQL_TYPE_TIMESTAMP].include?(column.type)\n value.to_datetime\n # when [\"ARRAY\"?, \"OBJECT\"?, \"VARIANT\"?].include?(column.type)\n # TODO: \"ARRAY\", \"OBJECT\", \"VARIANT\" all return as VARCHAR\n # so we'd need to parse them to make them the correct type\n\n # As of now, we are just going to return the value as a string\n # and let the consumer handle it. In the future, we could handle\n # if here, but there's not a good way to tell what the type is\n # without trying to parse the value as JSON as see if it works\n # JSON.parse(value)\n when [ODBC::SQL_BINARY].include?(column.type)\n # These don't actually ever seem to return, even though they are\n # defined in the ODBC driver, but I left them in here just in case\n # so that future us can see what they should be\n value\n else\n # the use of @connection.types() results in a \"was not dropped before garbage collection\" warning.\n raise \"Unknown column type: #{column.type} #{@connection.types(column.type).first[0]}\"\n end\n\n row[col_index] = new_value\n end\n end\n rows\n end", "def infer_types!\n types = Array.new(ncols)\n each do |row| merge_types(types, row[:*].infer_string_types) end\n types.each.with_index do |type, i|\n colname = @colnames[i]\n if type <= Integer then\n @rownames.each do |_, rowid| @rows[rowid][colname] = Integer(@rows[rowid][colname]) end\n elsif type <= Float then\n @rownames.each do |_, rowid| @rows[rowid][colname] = Float(@rows[rowid][colname]) end\n end\n end\n self\n end", "def add_typecast_on_load_columns(*columns)\n @typecast_on_load_columns.concat(columns)\n end", "def add_field(field, data_type = nil, options = {})\n data_type = DataType::String if data_type.nil?\n puts [\":#{field}\", \"#{data_type.class.to_s}\", \"#{options.inspect}\"].collect { |s| s.ljust(25) }.join if ENV['DEBUG']\n \n # Fields that do special things go here.\n if field == :timestamps\n add_field(:updated_at, :datetime)\n add_field(:created_at, :datetime)\n return true\n end\n\n # Add index if explicitly asked\n @indexes << field if options.delete(:index) || data_type.class.to_s == 'Hash' && data_type.delete(:index)\n @validations[field] = options.delete(:validates) if options[:validates]\n options.merge!(:field => field) \n \n # Matches: description DataType::Paragraph, :index => true\n if data_type.is_a?(Class) && data_type.respond_to?(:migrant_data_type?)\n @columns[field] = data_type.new(options)\n # Matches: description :index => true, :unique => true\n else\n begin\n # Eg. \"My field\" -> String -> DataType::String\n @columns[field] = \"DataType::#{data_type.class.to_s}\".constantize.new(options.merge(:value => data_type))\n rescue NameError\n # We don't have a matching type, throw a warning and default to string\n puts \"MIGRATION WARNING: No migration implementation for class #{data_type.class.to_s} on field '#{field}', defaulting to string...\"\n @columns[field] = DataType::Base.new(options)\n end\n end\n end", "def change(column_name, type, **options)\n raise_on_if_exist_options(options)\n @base.change_column(name, column_name, type, **options)\n end", "def add_data_column(name, type, options = {})\n options = {:index => options} unless options.is_a?(Hash)\n index_name = options[:index]\n index_name = :\"#{@name}_#{name}_idx\" if index_name == true\n DataColumn.new(name, type(type), index_name).\n tap { |column| @data_columns << add_column(column) }\n end", "def column_for_attribute(method)\n if method.to_s == \"value\" && [VTYPE_BOOLEAN,\n VTYPE_NUMBER,\n VTYPE_DATETIME].include?(self.vtype)\n dressed_like_column = OpenStruct.new(\n name: \"value\", type: nil, sql_type: nil, klass: nil,\n coder: nil, default: false, null: true, primary: false,\n limit: nil, precision: nil, scale: nil\n )\n case self.vtype\n when VTYPE_BOOLEAN\n dressed_like_column.type = :boolean\n dressed_like_column.sql_type = \"boolean\"\n dressed_like_column.klass = Object\n when VTYPE_NUMBER\n dressed_like_column.type = :decimal\n dressed_like_column.sql_type = \"numeric\"\n dressed_like_column.klass = BigDecimal\n when VTYPE_DATETIME\n dressed_like_column.type = :datetime\n dressed_like_column.sql_type = \"timestamp without time zone\"\n dressed_like_column.klass = Time\n end\n dressed_like_column\n else\n super(method)\n end\n end", "def schema_data_type\n case type\n when \"N\", \"F\"\n decimal > 0 ? \":float\" : \":integer\"\n when \"I\"\n \":integer\"\n when \"D\"\n \":date\"\n when \"T\"\n \":datetime\"\n when \"L\"\n \":boolean\"\n when \"M\"\n \":text\"\n else\n \":string, :limit => #{length}\"\n end\n end", "def add_column(table_name, column_name, type, options = {})\n default = options[:default]\n notnull = options[:null] == false\n \n # Add the column.\n execute(\"ALTER TABLE #{quote_table_name(table_name)} ADD COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\")\n\n change_column_default(table_name, column_name, default) if options_include_default?(options)\n change_column_null(table_name, column_name, false, default) if notnull\n end", "def from_formotion!(data)\n self.returnable_columns.each{|column|\n if data[column] && column_type(column) == :date || column_type(column) == :time\n data[column] = Time.at(data[column]) unless data[column].nil?\n end\n value = self.send(\"#{column}=\", data[column])\n }\n end", "def change_column_type(col_name, col_type)\r\n raise \"Do not execute this method in client/server mode!\" if \\\r\n @db.client?\r\n\r\n raise \"Cannot change type for recno column!\" if col_name == :recno\r\n raise 'Invalid column name: ' % col_name unless \\\r\n @field_names.include?(col_name)\r\n \r\n raise 'Invalid field type: %s' % col_type unless \\\r\n KBTable.valid_field_type?(col_type)\r\n\r\n @db.engine.change_column_type(self, col_name, col_type)\r\n\r\n # Need to reinitialize the table instance and associated indexes.\r\n @db.engine.remove_recno_index(@name)\r\n @db.engine.remove_indexes(@name)\r\n\r\n update_header_vars\r\n create_indexes\r\n create_table_class unless @db.server?\r\n end", "def database_column_type\n :string\n end", "def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:\r\n if native = native_database_types[type]\r\n if type == :integer\r\n column_type_sql = 'integer'\r\n elsif type == :string and !limit.nil?\r\n \"varchar (#{limit})\"\r\n else\r\n super(type, limit, precision, scale)\r\n end\r\n else\r\n super(type, limit, precision, scale)\r\n end\r\n end", "def typecast_value(column_type, value)\n return nil if value.nil?\n case column_type\n when :integer\n Integer(value)\n when :string\n value.to_s\n when :float\n Float(value)\n when :decimal\n case value\n when BigDecimal\n value\n when String, Float\n value.to_d\n when Integer\n value.to_s.to_d\n else\n raise ArgumentError, \"invalid value for BigDecimal: #{value.inspect}\"\n end\n when :boolean\n case value\n when false, 0, \"0\", /\\Af(alse)?\\z/i\n false\n else\n value.blank? ? nil : true\n end\n when :date\n case value\n when Date\n value\n when DateTime, Time\n Date.new(value.year, value.month, value.day)\n when String\n value.to_date\n else\n raise ArgumentError, \"invalid value for Date: #{value.inspect}\"\n end\n when :time\n case value\n when Time\n value\n when String\n value.to_time\n else\n raise ArgumentError, \"invalid value for Time: #{value.inspect}\"\n end\n when :datetime\n raise(ArgumentError, \"invalid value for #{tc}: #{value.inspect}\") unless value.is_one_of?(DateTime, Date, Time, String)\n if Sequel.datetime_class === value\n # Already the correct class, no need to convert\n value\n else\n # First convert it to standard ISO 8601 time, then\n # parse that string using the time class.\n (Time === value ? value.iso8601 : value.to_s).to_sequel_time\n end\n else\n value\n end\n end", "def add_type_validation(column_name, options)\n return unless options[:validate_type]\n\n type = options[:type]\n class_eval { validates column_name, :\"#{type.to_s.underscore}_format\" => true, allow_blank: true }\n end", "def add_column(table_name, column_name, type, options = {})\n default = options[:default]\n notnull = options[:null] == false\n\n # Add the column.\n execute(\"ALTER TABLE #{quote_table_name(table_name)} ADD COLUMN #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\")\n\n change_column_default(table_name, column_name, default) if options_include_default?(options)\n change_column_null(table_name, column_name, false, default) if notnull\n end", "def serialize_column(data)\n activerecord_json_column? ? data : super\n end", "def column(name, type, options = {})\n def_accessors(name)\n set_attribute_default(name, options[:default])\n end", "def sql_type=(val)\n self['sql_type'] = val\n end", "def type_to_sql(type, limit: nil, precision: nil, scale: nil, **) # :nodoc:\n # MSSQL's NVARCHAR(n | max) column supports either a number between 1 and\n # 4000, or the word \"MAX\", which corresponds to 2**30-1 UCS-2 characters.\n #\n # It does not accept NVARCHAR(1073741823) here, so we have to change it\n # to NVARCHAR(MAX), even though they are logically equivalent.\n #\n # See: http://msdn.microsoft.com/en-us/library/ms186939.aspx\n #\n type = type.to_sym if type\n native = native_database_types[type]\n\n if type == :string && limit == 1_073_741_823\n 'nvarchar(max)'\n elsif NO_LIMIT_TYPES.include?(type)\n super(type)\n elsif %i[int integer].include?(type)\n if limit.nil? || limit == 4\n 'int'\n elsif limit == 2\n 'smallint'\n elsif limit == 1\n 'tinyint'\n else\n 'bigint'\n end\n elsif type == :uniqueidentifier\n 'uniqueidentifier'\n elsif %i[datetime time].include?(type)\n precision ||= 7\n column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup\n if (0..7).include?(precision)\n column_type_sql << \"(#{precision})\"\n else\n raise(\n ArgumentError,\n \"No #{native[:name]} type has precision of #{precision}. The \" \\\n 'allowed range of precision is from 0 to 7, even though the ' \\\n 'sql type precision is 7 this adapter will persist up to 6 ' \\\n 'precision only.'\n )\n end\n else\n super\n end\n end", "def data_type\n @options[:data_type].presence\n end", "def schema_type(column)\n column.type == :enum_set ? :enum : super\n end", "def typecast(obj)\n case obj \n when Array\n _typecast(convert_format(obj))\n when Hash\n unless @columns\n raise Error, 'PGRow::Parser without columns cannot typecast from a hash'\n end\n _typecast(obj)\n else\n raise Error, 'PGRow::Parser can only typecast arrays and hashes'\n end\n end", "def column_class(type)\n if @numeric_types.include?(type) then NumericColumn\n elsif @enumerated_types.include?(type) then EnumeratedColumn\n elsif @textual_types.include?(type) then TextualColumn\n else\n Column\n end\n end", "def update!(**args)\n @column_type = args[:column_type] if args.key?(:column_type)\n @data_type = args[:data_type] if args.key?(:data_type)\n @name = args[:name] if args.key?(:name)\n end", "def update!(**args)\n @column_type = args[:column_type] if args.key?(:column_type)\n @data_type = args[:data_type] if args.key?(:data_type)\n @name = args[:name] if args.key?(:name)\n end", "def update!(**args)\n @column_type = args[:column_type] if args.key?(:column_type)\n @data_type = args[:data_type] if args.key?(:data_type)\n @name = args[:name] if args.key?(:name)\n end", "def update!(**args)\n @column_type = args[:column_type] if args.key?(:column_type)\n @data_type = args[:data_type] if args.key?(:data_type)\n @name = args[:name] if args.key?(:name)\n end", "def with_options(options)\n self.class.new(@table, @options.merge(options), @col_types).freeze\n end", "def column_type(col)\n column(col).type || nil\n end", "def scaffold_table_column_type(c)\n column = self.properties[c]\n if column then\n if column.type == DataMapper::Property::Text\n :text\n else\n column.class.to_s.split(\"::\").last.downcase.intern\n end\n else\n nil\n end\n end", "def real_column; end", "def data_type\n\tend", "def column_type_of(attribute)\n column = @ar_class.columns_hash[attribute.to_s]\n return :string unless column\n return :numeric if column.number? or [:datetime,:time,:date,:timestamp].include?(column.type)\n return :string\n end", "def type\n @ar_column_info.type\n end", "def attributes\n [type, column_options]\n end", "def admin_data_get_value_for_column(column, source, options = {})\n options.reverse_merge!(:limit => 400)\n if column.type == :datetime\n d = source.send(column.name)\n d.strftime('%m/%d/%Y %H:%M:%S %p') unless d.blank?\n else\n value = source.send(column.name)\n return value if options[:limit].blank?\n if column.type == :string || column.type == :text\n # truncate method fails in handling serialized array stored in string column\n begin\n truncate(value,:length => options[:limit])\n rescue\n '<actual data is not being shown because truncate method failed.>'\n end\n end\n end\n end", "def column(column_name, options={})\n columns_object.merge(column_name.to_sym => options)\n end", "def data_type\n\t\tend" ]
[ "0.71148425", "0.701191", "0.68691784", "0.68393767", "0.6827363", "0.6787256", "0.66701823", "0.66531485", "0.66143113", "0.66076595", "0.65629375", "0.65298116", "0.64940614", "0.6430979", "0.64124805", "0.64124805", "0.6408913", "0.640504", "0.6404931", "0.6399527", "0.63810265", "0.63682854", "0.635613", "0.63456166", "0.6324432", "0.63216054", "0.6309668", "0.62999266", "0.6288137", "0.6281014", "0.6281014", "0.6280345", "0.6277489", "0.626518", "0.62630934", "0.62605256", "0.62409323", "0.6240039", "0.6235483", "0.623012", "0.6182326", "0.61575973", "0.6136894", "0.6132764", "0.60769534", "0.6064387", "0.60585916", "0.60575193", "0.60404366", "0.60255176", "0.60210586", "0.60127336", "0.600902", "0.6001971", "0.597974", "0.59398097", "0.5922437", "0.5920735", "0.5911165", "0.5903525", "0.59030914", "0.58898675", "0.5888136", "0.5880219", "0.58769095", "0.58760613", "0.5871992", "0.58566284", "0.58561826", "0.5835484", "0.5825214", "0.58213836", "0.581737", "0.5813882", "0.5812923", "0.58111733", "0.5803622", "0.57951075", "0.57757026", "0.57707757", "0.57691836", "0.57637787", "0.5753101", "0.57343817", "0.57078445", "0.56905437", "0.56905437", "0.56905437", "0.56905437", "0.56901056", "0.5689299", "0.5686889", "0.5678333", "0.56774175", "0.56751347", "0.56748974", "0.56707287", "0.56653357", "0.5664049", "0.5656473" ]
0.6140565
42
Older Excel limited to 32 char filenames removed filename length limit put back if problems occur
def to_excel_filename(title) the_time = Time.now file_prefix = "#{the_time.year}_#{the_time.mon}_#{the_time.day}_" filename = (file_prefix + title.gsub(/[^\w.\-]/, '_')).squeeze('_') # --- removed filename length limit - put back if problems occur : (filename.length > 27 ? filename[0...27] : filename) + '.xls' filename + '.xls' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trim_filename(filename)\n filename_length = filename.length\n \n #trim 'n' splice if necessary\n if filename_length > MAX_FILENAME_LENGTH\n filename = filename.to_s[0..MAX_FILENAME_LENGTH] + '...' + filename.to_s[(filename_length - FILENAME_TAIL_LENGTH)..filename_length]\n end\n \n return filename\nend", "def safe_file_name(filename)\n basename = File.basename(filename)\n all_ascii = true\n basename.each_byte do |c|\n if c>=128\n all_ascii = false\n break\n end\n end\n\n\n if(all_ascii)\n yield(filename)\n else\n new_file_name = File.dirname(filename) + '/' + (0...8).map{ ('a'..'z').to_a[rand(26)] }.join + File.extname(filename)\n FileUtils.cp(filename,new_file_name)\n yield(new_file_name)\n FileUtils.rm(new_file_name)\n end\n end", "def clean_filename(filename)\n\t\tUtf8Converter.convert_ka_to_en(filename.gsub(' ', '_').gsub('»', '_').gsub(/[\\\\ \\/ \\: \\* \\? \\\" \\< \\> \\| \\, \\. ]/,''))\n\tend", "def to_filename(filename, size)\n filename.gsub! /^.*(\\\\|\\/)/, ''\n filename.gsub!(/[^0-9A-Za-z.\\-]/, '') \n filename.downcase.slice! 0..size\nend", "def clean_filename(filename)\n\t\tUtf8Converter.convert_ka_to_en(filename.gsub(' ', '_').gsub(/[\\\\ \\/ \\: \\* \\? \\\" \\< \\> \\| \\, \\. ]/,''))\n\tend", "def sanitize_filename(s)\n return '' if s.nil?\n s.chars.map{ |c| c.ord < 32 || c.ord > 126 ? '' : ([34, 42, 47, 58, 60, 62, 63, 92, 124].include?(c.ord) ? '_' : c) }.join\nend", "def sanitizeFilename(fn)\n fn.gsub(/[^-A-Za-z0-9_.]/, \"_\")[0,80]\nend", "def awful_file_name\n (((0x00..0x7f).to_a - [0x00, 0x0a, 0x2b, 0x2f]).map { |n| n.chr }).join + '.txt'\n end", "def assert_filename_length!(filename)\n name = relative_name = filename.to_s.sub(File.expand_path(@options[:spec_directory]), \"\")\n assert false, \"Filename #{name} must no more than #{256 - GEMFILE_PREFIX_LENGTH} characters long\" if name.size > (256 - GEMFILE_PREFIX_LENGTH)\n\n if name.size <= 100 then\n prefix = \"\"\n else\n parts = name.split(/\\//)\n newname = parts.pop\n nxt = \"\"\n\n loop do\n nxt = parts.pop\n break if newname.size + 1 + nxt.size > 100\n newname = nxt + \"/\" + newname\n end\n\n prefix = (parts + [nxt]).join \"/\"\n name = newname\n\n assert false, \"base name (#{name}) of #{relative_name} must no more than 100 characters long\" if name.size > 100\n assert false, \"prefix (#{prefix}) of #{relative_name} must no more than #{155 - GEMFILE_PREFIX_LENGTH} characters long\" if prefix.size > (155 - GEMFILE_PREFIX_LENGTH)\n end\n return nil\n end", "def filename_cleaner\n @options[:filename_cleaner] || FilenameCleaner.new(@options[:restricted_characters])\n end", "def valid_filename?(name)\n name.length.positive?\nend", "def cropped_type_name\n over_limit = (Zaru.sanitize! \"#{type_description}-#{filename_date}-#{filename_doc_id}.#{preferred_extension}\").size - MAXIMUM_FILENAME_LENGTH\n end_index = over_limit <= 0 ? -1 : -1 - over_limit\n type_description[0..end_index]\n end", "def sanitized\n @filename.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: \"�\").strip.tr(\"\\u{202E}%$|:;/\\t\\r\\n\\\\\", \"-\")\n end", "def get_valid_file_name(iFileName)\n if (defined?(prohibited_file_names_chars) != nil)\n return iFileName.gsub(/[#{Regexp.escape(prohibited_file_names_chars)}]/, '_')\n else\n return iFileName\n end\n end", "def safe_backup_name( filename )\n file = filename\n orig_file = filename\n index = 1\n while File.exists?(file)\n index = index + 1\n file = \"#{File.basename(orig_file, '.*')}-#{index}#{File.extname(orig_file)}\"\n end\n file\n end", "def file_name(title)\n name = title.gsub(/[\\r\\n]/, \" \")\n .gsub(/[^a-zA-Z\\d\\s]/, \"\")\n .gsub(/ /, \"_\")\n\n name.length > 31 ? name[0..30] : name\n end", "def confirm_filename(filename)\n filename.gsub!(/[<>:\"\\/\\\\|?*]/) { \"\" }\n end", "def filename\n case File.extname original_filename\n when /.zip/\n \"oag_airlines.xls.zip\"\n when /.xls/\n \"oag_airlines.xls\"\n end\n end", "def filesystem_safe_name\n name.\n gsub(ReservedCharacters) {|sub| '%%%02X' % sub.ord }.\n gsub(ReservedFilenameRegexp) {|sub| sub.gsub(/[^.]/) {|c| '%%%02X' % c.ord } }\n end", "def trailer_arquivo_posicao_394_a_400(sequencial)\n\t\t\t\t\t\t\"#{sequencial}\".adjust_size_to(6, '0', :right)\n\t\t\t\t\tend", "def original_filename; end", "def filename\n original_filename.try(:gsub, '+', '-')\n end", "def index_file_size_limit\n return MAX_TEXT_EXTRACT_FILESIZE\n end", "def file_name(title)\n name = title.gsub(/[\\r\\n]/, ' ')\n .gsub(/[^a-zA-Z\\d\\s]/, '')\n .tr(' ', '_')\n\n name.length > 31 ? name[0..30] : name\n end", "def sanitize_filename(filename)\n filename.split(/\\\\|\\//)[-1]\n end", "def clean_filename\n doc_file_name.gsub!(' ', '_')\n end", "def fix_filename\n unless self.filename.blank?\n self.filename.sub!(/^.*\\/([^\\/]*)$/, '\\1')\n self.filename += '.torrent' unless self.filename =~ /\\.torrent$/\n end\n end", "def original_file_name\r\n file_name_parts = initial_image_name.split('_')\r\n if file_name_parts.length > 0\r\n last_occurrence = nil\r\n first_element = file_name_parts[0]\r\n if Output835.element_duplicates?(first_element, file_name_parts)\r\n last_occurrence = file_name_parts.rindex(first_element)\r\n end\r\n last_occurrence ||= file_name_parts.length\r\n # Fetch the first n ( where n = last_occurrence ) elements of the array, until the first element duplicates.\r\n normalized_file_name_parts = file_name_parts.first(last_occurrence)\r\n normalized_file_name = normalized_file_name_parts.join('_')\r\n if Output835.element_duplicates?(first_element, file_name_parts)\r\n # Only for the duplicating file names, the extension of the file is appended to the normalized_file_name.\r\n # For others, the normalized_file_name itself has the extension.\r\n image_format_extension = batch.facility.image_file_format\r\n normalized_file_name << '.' << image_format_extension.downcase\r\n end\r\n normalized_file_name\r\n else\r\n initial_image_name\r\n end\r\n end", "def sanitize_filename(filename)\n @original_filename = filename\n # TODO: replace with GenericFile?\n StashEngine::DataFile.sanitize_file_name(filename)\n end", "def validate_image_name\n name = upload_original_name.to_s\n name = name.sub(/^[a-zA-Z]:/, \"\")\n name = name.sub(%r{^.*[/\\\\]}, \"\")\n # name = '(uploaded at %s)' % Time.now.web_time if name.empty?\n name = name.truncate(120)\n return unless name.present? && User.current &&\n User.current.keep_filenames != \"toss\"\n\n self.original_name = name\n end", "def sanitize_filename(filename)\n filename.strip.gsub(/[^0-9A-Za-z.\\-]|\\s/, '_')\n end", "def untitled_file_name()\n return \"ללא שם\"\n end", "def find_free_name(filename); end", "def max_files; end", "def filename\n \"#{secure_token(10)+File.extname(original_filename)}\" if original_filename.present?\n end", "def min_file_size\n (1024 * 200)\n end", "def fix_drive_letter(path); end", "def filename\n @data[10..-1]\n end", "def sanitize_filename(file_name)\r\n\t\tjust_filename = File.basename(file_name)\r\n\t\tjust_filename.sub(/[^\\w\\.\\-]/, '_')\r\n\tend", "def unique_file_name file_name\n count = 0\n name = file_name\n current_user = User.find(self.user_id)\n while Userfile.find_all_accessible_by_user(current_user).exists?(:name => name)\n count += 1\n extname = File.extname(name)\n name = \"#{File.basename(name,extname)}-#{count}#{extname}\"\n end\n return name\n end", "def extension_white_list\n %w(xls zip)\n end", "def error_for_new_doc_name(filename, extension)\n full_file_name = filename + \".\" + extension\n if !(1..20).cover?(filename.size)\n return \"File name must be between 1 and 20 characters\"\n elsif find_by_name(full_file_name)\n return \"File name must be unique\"\n elsif (filename =~ /(^[A-Za-z][A-Za-z0-9_]+)$/).nil?\n return \"Invalid file name. File must begin with an alpha character. The rest of the file name can only contain alphanumeric characters and underscores\"\n end\n nil\nend", "def img_name_size(file, size)\n return file.sub(\"_300\", \"_#{size}\")\n end", "def clean_filename\n if filename.present?\n cleaned_filename = cleaned_basename = basename.gsub(/[^a-z0-9\\-_]/i, '-')\n cleaned_filename = \"#{cleaned_basename}.#{extension.downcase}\" if extension\n self.filename = cleaned_filename\n end\n end", "def xls_filename\n timestamp = Time.now.strftime('%Y-%m-%d')\n \"#{resource_collection_name.to_s.tr('_', '-')}-#{timestamp}.xls\"\n end", "def max_file_size\n (1024 * 1024 * 20)\n end", "def process_xls_file\n return unless file.instance.file_content_type.eql?(\"application/x-ole-storage\") &&\n CONTENT_TYPES.include?(\"application/vnd.ms-excel\")\n file.instance.file_content_type = \"application/vnd.ms-excel\"\n end", "def trim_length\n \t400\n end", "def sanitize_filename(filename)\n fn = filename.split(/(?<=.)\\.(?=[^.])(?!.*\\.[^.])/m)\n fn.map! { |s| s.gsub /[^a-z0-9\\-]+/i, '_' }\n return fn.join '.'\nend", "def max_file_buffer; end", "def max_file_buffer; end", "def test_huge_document_to_csv\n skip_long_test\n\n original_csv_path = File.join(TESTDIR, \"Bibelbund.csv\")\n with_each_spreadsheet(name: \"Bibelbund\", format: [:openoffice, :excelx]) do |workbook|\n Dir.mktmpdir do |tempdir|\n new_csv_path = File.join(tempdir, \"Bibelbund.csv\")\n assert_equal \"Tagebuch des Sekret\\303\\244rs. Letzte Tagung 15./16.11.75 Schweiz\", workbook.cell(45, \"A\")\n assert_equal \"Tagebuch des Sekret\\303\\244rs. Nachrichten aus Chile\", workbook.cell(46, \"A\")\n assert_equal \"Tagebuch aus Chile Juli 1977\", workbook.cell(55, \"A\")\n assert workbook.to_csv(new_csv_path)\n assert File.exist?(new_csv_path)\n assert FileUtils.identical?(original_csv_path, new_csv_path), \"error in class #{workbook.class}\"\n end\n end\n end", "def clean_book_id(filename)\n File.read(filename).gsub(/#book /, '')\n end", "def safe_filename( filename )\n ret = filename\n\n # remove commas\n ret = ret.gsub( /,/, '' )\n\n # remove colons\n ret = ret.gsub( /:/, '' )\n\n # change spaces to underscores\n ret = ret.gsub( / /, '_' )\n\n return ret\n end", "def make_fat32_compliant(filepath)\n extname = File.extname(filepath)\n basename = File.basename(filepath, extname)\n dirname = File.dirname(filepath)\n path_without_ext = File.join(dirname, basename)\n\n split = path_without_ext.split(\"/\")\n new_split = []\n split.map do |part|\n new_split << part.gsub(/([\\?\\*\\|:;\"“”<>])/, \"\").strip.gsub(/ {2,}/,\" \").gsub('’', \"'\")\n end\n return new_split.join(\"/\")+extname\n end", "def sanitize_filename(filename)\n filename.gsub(/.*[\\/\\\\]/, '')\n end", "def sanitize_filename(filename)\n filename.gsub(/.*[\\/\\\\]/, '')\n end", "def sanitize_filename(filename)\n filename.gsub(/.*[\\/\\\\]/, '')\n end", "def sanitize_filename(filename)\n filename.gsub(/.*[\\/\\\\]/, '')\n end", "def filename\n \"#{secure_token(10)}.#{file.extension}\" if original_filename.present?\n end", "def filename\n sanitize(original_filename) if original_filename\n end", "def collisionless_filename source, extension\n base_name = \"#{source}_scrape_#{Date.today.strftime('%Y-%m-%d')}.#{extension}\"\n unused_filename = base_name\n n = 1\n while File.file?(unused_filename) do\n unused_filename = \"#{base_name}_v#{n}.#{extension}\"\n n += 1\n end\n unused_filename\n end", "def fix_name(title)\n result = String.new( title )\n # Replace all invalid characters\n for substitution in $INVALID_CHARS_FOR_FILENAME\n result.gsub!(substitution[0], substitution[1])\n end\n result\nend", "def proper_filename(file)\n file.gsub(/[^\\w]/,'_')\n end", "def clean_filename(filename)\n valid_filename_regexp = /[\\s+\\\\\\/*?:\\\"<>|]/\n filename.gsub(valid_filename_regexp, '')\n end", "def tempfile_extension\n # complexity here is due to supporting mangling non-UTF8 strings (e.g. latin-1 filenames with characters that are illegal in UTF-8)\n b = File.basename(@new_resource.path)\n i = b.index(\".\")\n i.nil? ? \"\" : b[i..].scrub\n end", "def processed_original_filename_without_extension\n processed_filename original_filename_without_extension\n end", "def truncate_formatted_filename f, unformatted_len, wid\n excess = unformatted_len - wid\n\n f = case @truncate_from\n\n when :right\n # FIXME: 2019-04-23 - do we need the control code at end ??\n f[0..wid - 3] + '$ '\n\n when :center\n\n # from central point calculate how much to remove in both directions\n center = unformatted_len / 2\n excess_half = excess / 2\n point = center + excess_half\n point1 = point - excess\n\n # remove text between point1 and point\n f[0..(point1 - 1)] + '$' + f[point + 2..-1] + ' '\n\n when :left\n\n # NOTE: we cannot remove the hint\n # for single hints we need to add extra space\n # there could be escape codes of varying length\n sindex = f.index(' ') || f.index('+')\n # 4 = 2 for literals, 2 to get ahead of sindex+1\n # FIXME crashing here, maybe there was a plus sign in place of space\n f[0..sindex + 0] + '<' + f[sindex + 3 + excess..-1] + ' '\n end\n return f\nend", "def sanitize_as_filename\n self.gsub(/^.*(\\\\|\\/)/, '').transliterate.downcase.gsub(/[^a-z0-9\\. ]/, ' ').strip.gsub(/[ ]+/, '-')\n end", "def max_file_size\n 35.megabytes\n end", "def sanitized_filename(filename)\n filename.strip.tap do |name|\n # NOTE: File.basename doesn't work right with Windows paths on Unix\n # get only the filename, not the whole path\n name.sub! /\\A.*(\\\\|\\/)/, ''\n # Finally, replace all non alphanumeric, underscore\n # or periods with underscore\n name.gsub! /[^\\w\\.\\-]/, '_'\n end\n end", "def valid_new_filename(file)\n new_file = file\n counter = 0\n while File.exist?(new_file) do\n counter += 1\n ext = File.extname(file)\n basename = file.split(ext).first\n new_file = \"#{basename}_#{counter}#{ext}\"\n end\n new_file\n end", "def sanitize_filename\n name = self.strip\n #--- get only the filename, not the whole path\n name.gsub! /^.*(\\\\|\\/)/, ''\n\n #--- Finally, replace all non alphanumeric, underscore or periods with underscore\n name.gsub! /[^\\w\\.\\-]/, '_'\n return name\n end", "def get_formatted_filename ix, wid\n f = @viewport[ix]\n\n ind = get_shortcut(ix)\n mark = get_mark(f)\n # make visited files bold\n bcolor = BOLD if mark == VMARK\n # Handle separator before enhanced file list.\n # We do lose a shortcut\n ind = cur = mark = '-' if f == SEPARATOR\n prefix = \"#{ind}#{mark}#{cur}\"\n\n color = color_for(f)\n color = \"#{bcolor}#{color}\"\n\n f = format_long_listing(f) if @long_listing\n\n # replace unprintable chars with ?\n f = f.gsub(/[^[:print:]]/, '?')\n\n f = \"#{prefix}#{f}\"\n\n unformatted_len = f.length\n if unformatted_len > wid\n # take the excess out from the center on both sides\n\n f = truncate_formatted_filename(f, unformatted_len, wid)\n f = \"#{color}#{f}#{CLEAR}\" if color # NOTE clear not added if not color\n\n elsif unformatted_len < wid\n\n # f << ' ' * (wid - unformatted_len)\n f = \"#{color}#{f}#{CLEAR}\" + ' ' * (wid - unformatted_len)\n end\n\n return f\nend", "def header_posicao_047_a_076\n\t\t\t\t\t''.adjust_size_to(30)\n\t\t\t\tend", "def sanitize_filename(value)\n # get only the filename, not the whole path\n just_filename = value.gsub(/^.*(\\\\|\\/)/, '')\n # Finally, replace all non alphanumeric, underscore or periods with underscore\n just_filename.gsub(/[^\\w\\.\\-]/,'_') \n end", "def file_ext\n File.extname(@file_name).downcase\n end", "def extension_white_list\n known=%w(xls xlsx)\n known << /\\w+/\n end", "def split?\n file.bytesize > MAXIMUM_NAME_LENGTH\n end", "def has_pathname_length_limitations?\n # Goddamn, does Windows ever suck. Man.\n os_type =~ /^\\s*windows\\s*$/i\n end", "def longest_sheet\n sheet(worksheets.inject {|m, o|\n o.row_count > m.row_count ? o : m\n }.name)\n end", "def fileable\n tr(' ', '_').downcase\n end", "def remove_file_extension(filename)\r\n extensions = [\"TIF\", \"TIFF\", \"JPEG\", \"JPG\", \"PDF\"]\r\n original_file_extension = filename.split('.').last\r\n if extensions.include?(original_file_extension.upcase)\r\n unwanted_string = \".\"+original_file_extension\r\n filename = filename.chomp(unwanted_string)\r\n end\r\n filename\r\n end", "def file_suffix\n file_name.split('.').last \n end", "def filename\n Time.now.to_i.to_s + [*('A'..'Z')].sample(8).join + \".\" + file.extension if original_filename\n end", "def filename() @fn.dup end", "def filter_filename(filename)\n filename.gsub(/(\\.\\.\\/)/, '')\n end", "def old_display_filename\n filename = self._internal_display_filename\n\n # Convert weird spaces (e.g. \\n) to normal ones\n filename = filename.gsub(/\\s/, \" \")\n # Remove slashes, they mess with URLs\n filename = filename.gsub(/\\//, \"-\")\n\n return filename\n end", "def fix_wikimedia_characters(res)\n res.media.where(w: nil).find_each do |img|\n next if img.source_url =~ /(svg|ogg|ogv)$/\n string = img.source_page_url.sub(/^.*File:/, '').sub(/\\..{3,4}$/, '')\n good_name = URI.decode(string)\n bad_name = img.source_url.sub(/^.*\\//, '').sub(/\\..{3,4}$/, '')\n %i[source_url name_verbatim name description description_verbatim].each do |f|\n img[f].sub!(bad_name, good_name) unless img[f].nil?\n end\n img.save\n img.download_and_resize\n end\n end", "def keep_file_regex; end", "def short_file_name_with_span(model)\n\t file_name = File.basename(url_for_file_column(model, 'filedata'))\n\t short_part = truncate(file_name, 16)\n\t long_part_with_span = content_tag :span, file_name\n\t \n\t return short_part + long_part_with_span\n end", "def file_type file_name \n\t\tFile.extname( file_name ).gsub /^\\./, '' \n\tend", "def sanitize_filename(filename)\n perform_ipad_renaming(filename\n .gsub('Grey', 'Gray') # some Apple devices have \"Grey\" instead of \"Gray\" color -> unify\n .gsub(' - Portrait', '') # iPads Pro include Portrait and Landscape - we just need Portrait; Landscape filtered via DEVICES_TO_SKIP\n .gsub(' - ', ' ') # Google Pixel device names are separated from their colors by a dash -> remove\n .gsub('Note10', 'Note 10') # Samsung Galaxy Note 10 is missing a space in \"Note10\"\n .gsub('Mi Mix Alpha Front', 'Mi Mix Alpha')) # Xiaomi Mi Mix Alpha contains the words \"Front\", \"Back\" and \"Side\" => back and side are filtered via DEVICES_TO_SKIP, \"Front\" removed from the name here\nend", "def extension_allowlist\n [\"xlsx\", \"csv\"]\n end", "def sanitize(filename)\r\n # Bad as defined by wikipedia: https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words\r\n # Also have to escape the backslash\r\n bad_chars = [ '/', '\\\\', '?', '%', '*', ':', '|', '\"', '<', '>', '.', ' ' ]\r\n bad_chars.each do |bad_char|\r\n filename.gsub!(bad_char, '_')\r\n end\r\n filename.gsub!(/[éèë]/i, 'e')\r\n filename.gsub!(/[âà]/i, 'a')\r\n filename.gsub!(/[ïìî]/i, 'i')\r\n filename.gsub!(/[ùû]/i, 'u')\r\n filename\r\nend", "def full_filename(filename)\n if filename.include? '.pdf'\n filename.gsub! '.pdf' '.jpg' \n end\n \"thumb_#{filename}\"\n end", "def max_file_buffer=(_arg0); end", "def sanitize_name\n if ['Gene List', 'Cluster'].include?(self.file_type)\n self.name.strip!\n end\n end", "def extname; end", "def extname; end" ]
[ "0.6036188", "0.5801818", "0.5786523", "0.5732437", "0.57285184", "0.5618781", "0.55944943", "0.55806315", "0.55549175", "0.5546898", "0.5445526", "0.5429091", "0.54183054", "0.53831494", "0.53813446", "0.5372781", "0.5344138", "0.5341651", "0.5328573", "0.5327912", "0.53225285", "0.5298741", "0.5292324", "0.52916574", "0.52905726", "0.5288028", "0.5256941", "0.52248466", "0.52138066", "0.519409", "0.51731366", "0.51574445", "0.515492", "0.5149086", "0.5144808", "0.51439786", "0.51269126", "0.51096797", "0.5109557", "0.51067513", "0.51051545", "0.510123", "0.5074989", "0.5070892", "0.50476944", "0.5045406", "0.5044305", "0.50374365", "0.50330555", "0.50324905", "0.50324905", "0.5031743", "0.50286466", "0.502253", "0.5020355", "0.5007686", "0.5007686", "0.5007686", "0.5007686", "0.50060403", "0.49985704", "0.49873167", "0.49839795", "0.4978167", "0.4977318", "0.4972876", "0.49638516", "0.49579594", "0.49548775", "0.4952982", "0.49341255", "0.49323127", "0.49275354", "0.49258772", "0.49234313", "0.4921889", "0.49111563", "0.49040037", "0.48936376", "0.48856285", "0.4873315", "0.48713633", "0.4860997", "0.48547664", "0.48412585", "0.48376623", "0.4836752", "0.4835917", "0.48265836", "0.48207313", "0.48099247", "0.48084524", "0.47870132", "0.47814542", "0.47801188", "0.47798362", "0.47755703", "0.4770314", "0.47675616", "0.47675616" ]
0.50657207
44
Completes the transfer by creating inventory entries corresponding to the changes made to the source and destination inventories by the transfer items.
def complete! now = Time.current transaction do transfer_items.each do |item| source.present? && source.destock!(item, now, self) destination.present? && destination.restock!(item, now, self) end update completed_at: now end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def complete_transactions!\n pending_transactions.each do |transaction|\n ActiveRecord::Base.transaction do\n transaction.entries.create!(amount: transaction.amount, entry_type: 'D', transaction: transaction, account: Account.mimo_assets)\n transaction.entries.create!(amount: transaction.amount, entry_type: 'C', transaction: transaction, account: wallet)\n transaction.destination_user = self\n transaction.complete! unless transaction.completed?\n end\n transaction.source_user.send_pending_sent_transfer_completed(transaction)\n self.send_pending_received_transfer_completed(transaction)\n end\n end", "def move_inventory!(transfer)\n updated_quantities = {}\n item_validator = Errors::InsufficientAllotment.new(\"Transfer items exceeds the available inventory\")\n transfer.line_items.each do |line_item|\n inventory_item = self.inventory_items.find_by(item: line_item.item)\n new_inventory_item = transfer.to.inventory_items.find_or_create_by(item: line_item.item)\n next if inventory_item.nil? || inventory_item.quantity == 0\n if inventory_item.quantity >= line_item.quantity\n updated_quantities[inventory_item.id] = (updated_quantities[inventory_item.id] || inventory_item.quantity) - line_item.quantity\n updated_quantities[new_inventory_item.id] = (updated_quantities[new_inventory_item.id] ||\n new_inventory_item.quantity) + line_item.quantity\n else\n item_validator.add_insufficiency(line_item.item, inventory_item.quantity, line_item.quantity)\n end\n end\n \n raise item_validator unless item_validator.satisfied?\n\n update_inventory_inventory_items(updated_quantities)\n end", "def transfer_inventory(reason)\n packaging.product.transfers.create!(\n :detail => self,\n :happened_at => Time.zone.now,\n :quantity => (-1 * quantity * packaging.size),\n :reason => reason\n )\n end", "def transfer(qty,prod,from,to)\n #Ensure from location has product in Stock\n if (get_product_qauntity(from.id) >= qty)\n #remove product from from Store\n rmv = from.remove_product(prod,qty)\n if rmv == 99\n puts \"REMOVED #{qty} ITEMS - (ID:#{prod.id}) from #{from.name}\"\n end\n to.add_product(prod,qty)\n puts \"SENT #{qty} ITEMS - (ID:#{prod.id}) to #{to.name}\"\n #Report action\n #puts \"Moved #{qty} items from #{from.name} to #{to.name}\"\n else\n puts \"ERROR: Tried to transfer more items than you have!\"\n end\n end", "def inventory_transfer2\n flash[:success] = \"Successfully Transfered\"\n redirect_to inventories_path\n end", "def update\n @breadcrumb = 'update'\n @inventory_transfer = InventoryTransfer.find(params[:id])\n\n items_changed = false\n if params[:inventory_transfer][:inventory_transfer_items_attributes]\n params[:inventory_transfer][:inventory_transfer_items_attributes].values.each do |new_item|\n current_item = InventoryTransferItem.find(new_item[:id]) rescue nil\n if ((current_item.nil?) || (new_item[:_destroy] != \"false\") ||\n ((current_item.product_id.to_i != new_item[:product_id].to_i) ||\n (current_item.quantity.to_f != new_item[:quantity].to_f)))\n items_changed = true\n break\n end\n end\n end\n master_changed = false\n if ((params[:inventory_transfer][:transfer_date].to_date != @inventory_transfer.transfer_date) ||\n (params[:inventory_transfer][:transfer_no].to_s != @inventory_transfer.transfer_no) ||\n (params[:inventory_transfer][:remarks].to_s != @inventory_transfer.remarks) ||\n (params[:inventory_transfer][:store_id].to_i != @inventory_transfer.store_id.to_i) ||\n (params[:inventory_transfer][:company_id].to_i != @inventory_transfer.company_id.to_i) ||\n (params[:inventory_transfer][:organization_id].to_i != @inventory_transfer.organization_id.to_i))\n master_changed = true\n end\n\n respond_to do |format|\n if master_changed || items_changed\n @inventory_transfer.updated_by = current_user.id if !current_user.nil?\n if @inventory_transfer.update_attributes(params[:inventory_transfer])\n format.html { redirect_to @inventory_transfer,\n notice: (crud_notice('updated', @inventory_transfer) + \"#{undo_link(@inventory_transfer)}\").html_safe }\n format.json { head :no_content }\n else\n @stores = stores_dropdown\n format.html { render action: \"edit\" }\n format.json { render json: @inventory_transfer.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to @inventory_transfer }\n format.json { head :no_content }\n end\n end\n end", "def transfer_product(qty,id,from_loc,to_loc)\n from_stock = from_loc.get_qauntity(id)\n to_stock = to_loc.get_qauntity(id)\n puts \"Action: Transfer #{qty} Product Id: #{id}\"\n puts \"From Location: #{from_loc}, #{from_stock} IN Stock.\"\n puts \" To Location: #{to_loc}, #{to_stock} IN Stock.\"\n #Check if transfer possible\n if (from_stock >= qty)\n rmv = from_loc.remove_product(id,qty)\n if rmv == 99\n puts \"REMOVED #{qty} ITEMS - (ID:#{id}) from #{from_loc.name}\"\n end\n to_loc.add_product(id,qty)\n puts \"SENT #{qty} ITEMS - (ID:#{id}) to #{to_loc.name}\"\n else\n puts \"ERROR: Tried to transfer more items than you have!\"\n end\n end", "def return!\n self.return_transfer = create_return_transfer(\n store: transfer.store,\n destination: transfer.source\n )\n return_transfer.duplicate_items_from(transfer.transfer_items)\n return_transfer.complete!\n end", "def transfer\n @inventory_type = InventoryType.find_by_id(params[:id])\n @inventory =Inventory.find_by_id(params[:format])\n end", "def completed_transfer_items\n transfer_items.joins(transfer: :shipment).merge(Shipment.complete)\n end", "def trans(inventory, transfer_id, inventory_type)\n @inventory_log = InventoryLog.create!(inventory_type_id: params[:transfer][:id] )\n @inventory_update = Inventory.find(params[:inventory])\n @inventory_update.transfer.inventory_type.inventories.each do |i|\n if @inventory_update.part_no == i.part_no\n value = i.warehouse_stock_qty\n final = value.to_i - params[:transfer_item].to_i\n # stock = final + i.engineer_stock_qty.to_i\n i.update(warehouse_stock_qty: final) \n tot = final + i.engineer_stock_qty.to_i\n i.update(total_stock_qty: tot)\n end\n end\n @inventory.inventories.each do |f|\n if @inventory_update.part_no == f.part_no\n value = f.warehouse_stock_qty\n final = value.to_i + params[:transfer_item].to_i\n f.update(warehouse_stock_qty: final) \n tot = final + f.engineer_stock_qty.to_i\n f.update(total_stock_qty: tot)\n end\n end\n @inv = Inventory.create!(branch: @inventory_update.branch, part_no: @inventory_update.part_no, description: @inventory_update.description, warehouse_stock_qty: params[:transfer_item].to_i, transfered_stock_qty: params[:transfer_item].to_i, engineer_stock_qty: @inventory_update.engineer_stock_qty,location1: @inventory_update.location1,location2:@inventory_update.location2, location3: @inventory_update.location3,map: @inventory_update.map,total_stock_value: @inventory_update.total_stock_value,status: @inventory_update.status, latest_modify_date: @inventory_update.latest_modify_date,remark: @inventory_update.remark, inventory_type_id: @inventory.id, transfer_id: @transfer.id)\n total_stock_qty1 = @inv.warehouse_stock_qty.to_i + @inv.engineer_stock_qty.to_i\n @inv.update(total_stock_qty: total_stock_qty1 )\n\n end", "def update_inventory\n self.order_items.each { |item| item.variant.add_pending_to_customer }\n end", "def transfer cart\n \t\tself.order_items.destroy_all\n \t\tcart.cart_items.each do |item|\n \t\t\t@order_item = order_items.build(price: item.price, quantity: item.quantity, sku_id: item.sku_id, weight: item.weight, order_id: id)\n \t\t\t@order_item.build_order_item_accessory(accessory_id: item.cart_item_accessory.accessory_id, price: item.cart_item_accessory.price, quantity: item.cart_item_accessory.quantity) unless item.cart_item_accessory.nil?\n \t\t\t@order_item.save!\n \t\tend\n \tend", "def exchange\n\t\t# se os usuários não entiverem infectados e os pontos dos items serem iguais, executa o escambo entre os usuários\n\t\tdata_origin, data_destiny = origin_params, destiny_params\n\n\t\tunless (User.healthy?(data_origin[:user_id]) && User.healthy?(data_destiny[:user_id]))\n \t\trender json: { error: \"Denied access. User is contaminated!\" }, status: 403 and return\n\t\tend\n\n\t\tunless Inventory.equality(data_origin, data_destiny)\n\t\t\trender json: { error: \"The items points aren't equal!\" }, status: 400 and return\n\t\tend\n\n\t\tif Inventory.exchange(data_origin, data_destiny)\n\t\t\trender json: :success, status: 200\n\t\telse\n\t\t\trender json: :error, status: 400\n\t\tend\n\tend", "def end_transaction\n case @transaction_stack.length\n when 0\n PEROBS.log.fatal 'No ongoing transaction to end'\n when 1\n # All transactions completed successfully. Write all modified objects\n # into the backend storage.\n @transaction_stack.pop.each { |id| @transaction_objects[id]._sync }\n @transaction_objects = ::Hash.new\n @transaction_thread = nil\n else\n # A nested transaction completed successfully. We add the list of\n # modified objects to the list of the enclosing transaction.\n transactions = @transaction_stack.pop\n # Merge the two lists\n @transaction_stack.push(@transaction_stack.pop + transactions)\n # Ensure that each object ID is only included once in the list.\n @transaction_stack.last.uniq!\n end\n end", "def duplicate_items_from(items)\n transaction do\n items.each do |item|\n transfer_items << item.dup\n end\n end\n end", "def inventory_transfer\n puts \"#{params}\".inspect\n @transfer = Transfer.create!(remark: params[:remark], transfer_item: params[:transfer_item], inventory_type_id: params[:transfer][:inventory_type_id]) \n @inventory_trans = Inventory.find(params[:inventory])\n @inventory_trans.update(:transfer_id => @transfer.id)\n @inventory = InventoryType.shod(params[:transfer][:id])\n trans(params[:inventory], params[:transfer][:id], @inventory)\n inventory_transfer2\nend", "def execute_trade!\n offer_inventory = @offer[:records].map{ |e| [e.item_name.to_sym, e]}.to_h\n for_inventory = @for[:records].map{ |e| [e.item_name.to_sym, e]}.to_h\n\n @offer[:items].each do |name, quantity|\n offer_inventory[name.to_sym].quantity -= quantity\n for_inventory[name.to_sym].quantity += quantity\n end\n\n @for[:items].each do |name, quantity|\n for_inventory[name.to_sym].quantity -= quantity\n offer_inventory[name.to_sym].quantity += quantity\n end\n\n ActiveRecord::Base.transaction do\n @offer[:records].each(&:save)\n @for[:records].each(&:save)\n end\n end", "def complete\n @stock_transfer = StockTransfer.find(params[:id])\n @product = @stock_transfer.product\n # Event-b: product ∈ activeProducts\n @locationto = @stock_transfer.stock_location\n @locationfrom = @locationto.previous_location\n\n\n #Mark as complete\n @stock_transfer.update_attribute(:complete,true)\n @stock_transfer.save\n\n #Event-b : act1: productlevels(product) ≔ productlevels(product) <+ {Floor ↦ (productlevels(product)(Floor) + amount),Backroom ↦ (productlevels(product)(Backroom) − amount)}\n @stock_level_to = StockLevel.find_by_product_id_and_stock_location_id(@product,@locationto)\n @stock_level_to.update_attribute(:quantity, (@stock_level_to.quantity + @stock_transfer.quantity))\n @stock_level_to.save\n\n @stock_level_from = StockLevel.find_by_product_id_and_stock_location_id(@product,@locationfrom)\n @stock_level_from.update_attribute(:quantity, (@stock_level_from.quantity - @stock_transfer.quantity))\n @stock_level_from.save\n\n\n\n\n respond_to do |format|\n format.html { redirect_to stock_transfers_url }\n format.json { head :no_content }\n end\n end", "def qbd_stock_transfer_to_transfer_inventory_xml(xml, stock_transfer_hash, match = nil, step)\n if match\n xml.TxnID match.fetch(:sync_id)\n xml.EditSequence match.fetch(:sync_alt_id)\n end\n\n xml.TxnDate stock_transfer_hash.fetch(:created_at).to_date.to_s\n if stock_transfer_hash.fetch(:number)\n xml.RefNumber stock_transfer_hash.fetch(:number)\n end\n xml.FromInventorySiteRef do\n source_location_hash = self.integration_item.integration_sync_matches.find_or_create_by(integration_syncable_id: stock_transfer_hash.fetch(:source_location_id), integration_syncable_type: 'Spree::StockLocation')\n xml.ListID source_location_hash.try(:sync_id)\n end\n xml.ToInventorySiteRef do\n destination_location_hash = self.integration_item.integration_sync_matches.find_or_create_by(integration_syncable_id: stock_transfer_hash.fetch(:destination_location_id), integration_syncable_type: 'Spree::StockLocation')\n xml.ListID destination_location_hash.try(:sync_id)\n end\n unless qbd_stock_memo(stock_transfer_hash).blank?\n xml.Memo qbd_stock_memo(stock_transfer_hash)\n end\n\n stock_transfer_hash.fetch(:destination_items, []).each do |line_item|\n variant_match = self.integration_item.integration_sync_matches.find_or_create_by(integration_syncable_id: line_item.fetch(:variant_id), integration_syncable_type: 'Spree::Variant')\n xml.TransferInventoryLineAdd do\n xml.ItemRef do\n xml.ListID variant_match.try(:sync_id)\n end\n # As of March 4, 2017 we cannot support sending row/bin locations\n xml.FromInventorySiteLocationRef do\n xml.ListID\n end\n xml.ToInventorySiteLocationRef do\n xml.ListID\n end\n xml.QuantityToTransfer line_item.fetch(:quantity)\n end\n end\n end", "def create\n @transfer = Transfer.new(transfer_params)\n respond_to do |format|\n if !params[:transfer][:items].nil?\n total = 0\n params[:transfer][:items].each do |f| \n item = Item.where([\"id = #{f}\"]).first\n total += item.amount\n end\n account = Account.where([\"id = #{@transfer.account_id}\"]).first\n new_total = account.amount - total\n if new_total > 0 \n if @transfer.save\n account.update(amount: new_total)\n params[:transfer][:items].each do |f| \n Item.where([\"id = #{f}\"]).first.update(transfer_id: @transfer.id)\n end\n \n format.html { redirect_to accounts_path, notice: \"Transfer was successfully created.\" }\n format.json { render :show, status: :created, location: @transfer }\n end\n else\n format.html { redirect_to budgets_url, notice: \"The account hasn't got enough money\"}\n format.json { render json: @transfer.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def finalize!\n update_attribute(:completed_at, Time.now)\n InventoryUnit.assign_opening_inventory(self)\n # lock any optional adjustments (coupon promotions, etc.)\n adjustments.optional.each { |adjustment| adjustment.update_attribute(\"locked\", true) }\n\t\n envia_correos_notific # Envío de correos...\n\n self.state_events.create({\n :previous_state => \"cart\",\n :next_state => \"complete\",\n :name => \"order\" ,\n :user_id => (User.respond_to?(:current) && User.current.try(:id)) || self.user_id\n })\n end", "def finish(transfer, force=false)\n\n # print changes, return if none\n Modder.status transfer\n return if transfer.empty?\n\n if force || Modder.confirm?\n Modder.execute transfer, force\n puts \"Modifications complete.\"\n else\n puts \"No modifications done.\"\n end\n end", "def transaction(file_name)\n\n prices_array = read_file(file_name)\n #puts prices_array\n array_subtotals_per_item = user_select_name_quantity_array(prices_array)\n #puts \"Array with item quantity and subtotal: #{array_subtotals_per_item}\"\n\n puts \"Welcome to Jacinda's coffee emporium!\"\n puts nil\n\n #display menu of items\n displayTransactionOptions(prices_array)\n puts nil\n\n done = false\n while not done\n #user selects item\n user_selection_str = save_input_string(\"Make a selection: \")\n\n #break if user selects done\n if user_selection_str == \"4\"\n done = true\n break\n end\n\n #user types quantity of item\n quantity = user_quantity\n\n item_name = user_selection_name(user_selection_str)\n item_hash = return_item_hash(item_name, prices_array)\n item_price = return_item_price(item_name, item_hash).to_f\n #puts \"Item name: #{item_name}, Item hash: #{item_hash}, Item price: #{item_price}\"\n\n\n #calculate and display the subtotal\n subtotal = item_subtotal(item_price, quantity)\n quant_sub_item_hash = array_subtotals_per_item[user_selection_str.to_f - 1]\n new_item_hash = update_subtotal(quant_sub_item_hash, subtotal)\n array_subtotals_per_item[user_selection_str.to_f - 1] = new_item_hash\n #puts \"quant_sub_item_hash: #{quant_sub_item_hash}\"\n #puts \"Array: #{array_subtotals_per_item}\"\n\n #update the quantity in quantity/subtotal array\n updated_quant_hash = update_quantity(new_item_hash, quantity)\n array_subtotals_per_item[user_selection_str.to_f - 1] = new_item_hash\n\n #binding.pry\n\n total = total(array_subtotals_per_item)\n formatted_subtotal = formatted_currency(total)\n puts \"Subtotal: #{formatted_subtotal}\"\n puts nil\n\n end #end while loop\n\n puts \"===Sale Complete===\"\n puts nil\n\n #displays items purchased\n display_final_transaction(array_subtotals_per_item)\n puts nil\n puts \"Total: #{formatted_subtotal}\"\n puts nil\n\n #amount tendered and change calculation\n amount_tendered = save_input_float(\"What is the amount tendered?\" )\n\n change = (amount_tendered - total)\n\n if change < 0\n puts \"========================\"\n puts \"WARNING: Customer still owes #{formatted_currency(change.abs)}\"\n puts \"========================\"\n else\n change = sprintf('%.2f', change)\n puts nil\n puts \"=======Thank You!=======\"\n puts \"The total change due is $#{change}\"\n puts nil\n puts Time.now.strftime(\"%m/%d/%Y %l:%M %p\")\n puts \"========================\"\n end #end if statement\n\n binding.pry\n\n return array_subtotals_per_item\nend", "def withdraw exit_date, estimated_return_date, pickup_company, pickup_company_contact, additional_comments, quantity, folio\n \n return self.status if cannot_withdraw?\n\n if quantity != '' and quantity < self.quantity.to_i\n self.quantity = self.quantity.to_i - quantity\n quantity_withdrawn = quantity\n else\n self.status = InventoryItem::OUT_OF_STOCK\n quantity_withdrawn = self.quantity\n self.quantity = 0\n end\n \n if self.save\n inventory_item = InventoryItem.where( 'actable_id = ? AND actable_type = ?', self.id, 'BulkItem' ).first\n if self.warehouse_locations?\n quantity_left = quantity\n if quantity != '' and quantity < ( self.quantity.to_i + quantity_withdrawn.to_i )\n item_location = self.item_locations.where( 'quantity >= ?', quantity ).first\n location = item_location.warehouse_location\n location.remove_quantity( inventory_item.id, quantity )\n elsif quantity != ''\n while quantity_left > 0\n item_location = self.item_locations.first\n location = item_location.warehouse_location\n if quantity_left >= item_location.quantity \n current_location_quantity = item_location.quantity \n location.remove_item( inventory_item.id )\n self.item_locations.delete( item_location )\n location.update_status\n else\n location.remove_quantity( inventory_item.id, quantity_left )\n end\n quantity_left = quantity_left - current_location_quantity\n end\n else\n item_location = self.item_locations.first\n location = item_location.warehouse_location\n location.remove_item( inventory_item.id )\n self.item_locations.delete( item_location )\n location.update_status\n end\n end\n CheckOutTransaction.create( :inventory_item_id => inventory_item.id, :concept => 'Salida granel', :additional_comments => additional_comments, :exit_date => exit_date, :estimated_return_date => estimated_return_date, :pickup_company => pickup_company, :pickup_company_contact => pickup_company_contact, :quantity => quantity_withdrawn, :folio => folio )\n return true\n end\n\n return false\n end", "def update\n #replace the parts first\n\n Service.transaction do\n @service.expended_part_ids.uniq.each do |part_id|\n p = ExpendedPart.find(part_id)\n p.part.update(inventory: p.part.inventory + @service.expended_part_ids.count(part_id) )\n p.destroy\n end\n\n updated_parts = service_params[:part_ids]\n updated_parts.delete('')\n updated_parts.uniq.each do |part_id|\n p = Part.find(part_id)\n p.update(inventory: p.inventory - updated_parts.count(part_id))\n end\n end\n\n if @service.update(service_params)\n redirect_to tool_path(service_params[:tool_id]); gflash :success => 'Service was successfully updated.'\n else\n render action: 'edit'\n end\n\n end", "def transfer_sold_to_child\n return unless self.inventory_units.sold.count > 0\n sold_units = self.inventory_units.sold.all\n sold_units.each { |u| self.inventory_units.delete(u) }\n self.create_child(sold_units)\n end", "def execute\n\n copiedCounter = 0\n failedCounter = 0\n skippedCounter = 0\n \n # traverse all srcfiles\n FiRe::filesys.find(@source) { |srcItem|\n \n # give some feedback\n FiRe::log.info \"searching #{srcItem}...\" if FiRe::filesys.directory?(srcItem)\n \n # skip this subtree if it matches ignored-items\n FiRe::filesys.prune if ignore?(srcItem) \n \n # transform srcpath to destpath\n destItem = srcItem.gsub(@source, @destination)\n\n # do not copy if item already exists and looks OK\n if needCopy(destItem,srcItem)\n copyWentWell = copyItem(srcItem, destItem)\n copiedCounter += 1 if copyWentWell\n failedCounter += 1 if !copyWentWell\n else\n skippedCounter += 1 \n end\n \n }\n \n # give some feedback\n FiRe::log.info \"copied #{copiedCounter} items, while #{failedCounter} items failed. #{skippedCounter} items did not need to be copied today.\"\n\n end", "def complete\n required_actions = Array.new\n\n #work out the build status for each pallet\n\n begin\n\n progress_stats = ReworksProgressManager.new(self)\n busy?(\"complete\")\n\n self.transaction do\n\n progress_stats.event_generic_action(\"determining potential qc resets from buildup actions...\")\n set_inspection_status_for_built_up_pallets\n progress_stats.event_generic_action(\"determining potential qc resets from grade reclassifications...\")\n set_inspection_status_for_grade_changes\n progress_stats.event_generic_action(nil)\n\n num_qc_resets = progress_stats.calc_pallets_qc_resets\n progress_stats.run_completion_stats.pallets_qc_resets_req = num_qc_resets\n\n self.reload #force reload of active cartons, since they were updated from underneath us by previous 2 methods\n\n\n self.rw_active_bins.each do |bin|\n if bin.reworks_action.upcase == \"RECLASSIFIED\"\n progress_stats.event_bin_reclassified\n\n original_bin = Bin.find(bin.bin_id)\n from_pack_material_product_id =original_bin.pack_material_product_id\n\n if bin.pack_material_product_id !=from_pack_material_product_id\n add_quantity_to_location(bin, original_bin, \"add_asset_quantity\")\n add_quantity_to_location(bin, original_bin, \"remove_asset_quantity\")\n end\n\n\n elsif bin.reworks_action.upcase == \"TIPPED\"\n stock_item =StockItem.find_by_inventory_reference(bin.bin_number)\n if stock_item\n Inventory.move_stock(\"REWORKS\", self.id.to_s, \"REWORKS\", [bin.bin_number])\n Inventory.remove_stock(nil, \"BIN\", \"REWORKS\", self.id.to_s, \"REWORKS\", [bin.bin_number], \"KROMCO\")\n end\n\n\n elsif bin.reworks_action.upcase == \"BULK_TIPPED\"\n stock_item =StockItem.find_by_inventory_reference(bin.bin_number)\n if stock_item\n Inventory.move_stock(\"REWORKS\", self.id.to_s, \"REWORKS\", [bin.bin_number])\n Inventory.remove_stock(nil, \"BIN\", \"REWORKS\", self.id.to_s, \"REWORKS\", [bin.bin_number], \"KROMCO\")\n end\n\n progress_stats.event_bin_tipped\n\n end\n\n\n if bin.weight_changed\n progress_stats.event_bin_reclassified\n stock_type =StockItem.find_by_inventory_reference(bin.bin_number).stock_type_code\n if stock_type == \"PRESORT\" && bin.bin.mix_ps_bin == 'MIX_PS_BIN'\n bin.set_child_weights\n end\n\n end\n\n reclassed_bin = RwReclassedBin.new\n bin.export_attributes(reclassed_bin, true)\n reclassed_bin.create\n\n bin.export_attributes(bin.bin, true)\n bin.bin.update\n\n #create integration record\n #outbox_record = NewOutboxRecord.new(\"bin_reclassified\",bin.bin)\n\n end\n\n\n self.rw_active_pallets.each do |pallet|\n set_build_status(pallet)\n if pallet.build_up_balance\n new_account = Pallet.set_account(pallet.pallet_number, true, true)\n pallet.account_code = new_account\n pallet.set_oldest_pack_date_time\n\n if pallet.carton_quantity_actual == 0 && pallet.build_up_balance < 0\n pallet.exit_ref = 'SCRAPPED_FROM_RW_BUILDUP'\n\n\n end\n\n\n end\n\n pallet.process_status = \"PALLETIZED\"\n if pallet.reworks_action.upcase == \"NEW_PALLET\" && pallet.get_carton_count > 0\n progress_stats.event_pallet_created\n new_pallet = RwPallet.new\n pallet.export_attributes(new_pallet, true, ['is_depot_pallet', 'consignment_note_number'])\n new_pallet.date_time_created = Time.now\n new_pallet.create\n #new mes pallet\n new_mes_pallet = Pallet.new\n pallet.export_attributes(new_mes_pallet, true, ['is_depot_pallet', 'consignment_note_number'])\n new_mes_pallet.rw_create_datetime = Time.now\n new_mes_pallet.create\n pallet.pallet = new_mes_pallet\n\n pallet.update\n #------------------------------------------------------------------------------------------------\n #update cartons of this pallet to have correct pallet_id- the one just created\n #cartons already have correct pallet_number (it can be created at add time), but\n #pallet_id can only be created at run_complete time, because the new pallet is only created now\n #------------------------------------------------------------------------------------------------\n pallet.rw_active_cartons.each do |ctn|\n\n ctn.pallet_id = new_mes_pallet.id\n ctn.update\n\n end\n\n #outbox_record = NewOutboxRecord.new(\"pallet_new\",new_mes_pallet)\n Inventory.create_stock(nil, \"PALLET\", nil, nil, \"REWORKS\", self.id.to_s, \"REWORKS\", [new_mes_pallet.pallet_number])\n elsif (pallet.reworks_action == \"ALT_PACKED\"||pallet.build_up_balance) && pallet.reworks_action != \"reclassified\"\n progress_stats.event_pallet_reclassified if pallet.reworks_action == \"ALT_PACKED\"\n if pallet.build_up_balance && pallet.build_up_balance != 0\n progress_stats.event_pallet_built_up\n end\n pallet.pallet.qc_status_code = pallet.qc_status_code\n pallet.pallet.qc_result_status = pallet.qc_result_status\n pallet.pallet.carton_quantity_actual = pallet.carton_quantity_actual\n pallet.pallet.cpp = pallet.cpp\n pallet.pallet.account_code = pallet.account_code\n pallet.pallet.build_status = pallet.build_status\n pallet.pallet.update\n\n #outbox_record = NewOutboxRecord.new(\"pallet_carton_count_update\",pallet.pallet)\n if pallet.reworks_action == \"ALT_PACKED\"\n progress_stats.event_pallet_reclassified\n pallet.export_attributes(pallet.pallet, true)\n pallet.pallet.update\n #outbox_record = NewOutboxRecord.new(\"pallet_update\",pallet.pallet)\n end\n elsif pallet.reworks_action == \"reclassified\"\n progress_stats.event_pallet_reclassified\n pallet.export_attributes(pallet.pallet, true, ['is_depot_pallet', 'consignment_note_number','load_detail_id','exit_ref'])\n reclassed_pallet = RwReclassedPallet.new\n pallet.export_attributes(reclassed_pallet, true, ['is_depot_pallet', 'consignment_note_number','load_detail_id','exit_ref'])\n reclassed_pallet.create\n pallet.pallet.update\n if pallet.build_up_balance && pallet.build_up_balance != 0\n progress_stats.event_pallet_built_up\n end\n #outbox_record = NewOutboxRecord.new(\"pallet_update\",pallet.pallet)\n\n end\n\n end\n\n #----------------------------------------------------------------------------------------------------------\n #pallets to delete: alt-packed and scrapped pallets- pallets that must be deleted in legacy db\n #----------------------------------------------------------------------------------------------------------\n get_all_deleted_pallets().each do |pallet|\n #create integration record TODO: UNCOMMENT THIS LINE\n progress_stats.event_pallet_scrapped\n pallet.pallet.exit_ref = \"scrapped\" #TODO: UNCOMMENT THIS LINE\n pallet.pallet.carton_quantity_actual = 0\n pallet.pallet.update\n #outbox_record = NewOutboxRecord.new(\"pallet_deleted\",pallet.pallet)\n stock_item =StockItem.find_by_inventory_reference(pallet.pallet_number)\n if stock_item\n\n\n Inventory.remove_stock(nil, \"PALLET\", \"REWORKS\", self.id.to_s, \"REWORKS\", [pallet.pallet_number])\n\n\n end\n end\n #---------------------------------------------------------------------------------------------------------------\n #Go through active cartons table: create reworks table records for alt_packed and reclassified\n #records. Records in active cartons table, that have not been reclassed, scrapped (in which case\n # they would not be in active table) or alt-packed, must be checked for pallet reference changes\n # (resulting from 'add_to_pallet' and 'remove_from_pallet' build-up actions). If pallet ref changes took\n # place, integration record must be created for it. Pallet ref changed could also have taken place on cartons\n # involved in reclassification or alt pack, but in this case the pallet ref will be updated anyway\n # as part of the normal integration transaction for such types\n #--------------------------------------------------------------------------------------------------------------\n self.rw_active_cartons.each do |carton|\n\n raise \"CARTON: #{carton.carton_number} HAS NO VALUE FOR TRACK_INDICATOR. <BR> IF YOU CHANGED THE PRODUCTION RUN, MAKE SURE THE RMT_SETUP HAS A A VALUE FOR OUT_TRACK_INDICATOR_CODE\" if !carton.track_indicator_code || carton.track_indicator_code.strip() == \"\"\n\n if carton.reworks_action.upcase == \"RECLASSIFIED\"\n\n if !carton.rw_active_pallet_id\n\n required_actions.push(carton.carton_number.to_s)\n else\n reclassed_carton = RwReclassedCarton.new\n progress_stats.event_carton_reclassified\n carton.export_attributes(reclassed_carton, true, ['is_depot_carton', 'intake_header_number'])\n reclassed_carton.date_time_created = Time.now\n reclassed_carton.production_run_id = carton.production_run_id\n reclassed_carton.create\n #update our carton\n #puts \"orig carton id: \" + carton.carton.id.to_s\n if carton.rw_pallet_action\n carton.export_attributes(carton.carton, true, ['is_depot_carton', 'intake_header_number'])\n progress_stats.event_carton_pallet_ref_changed\n else\n carton.export_attributes(carton.carton, true, ['pallet_id', 'pallet_number', 'is_depot_carton', 'intake_header_number'])\n end\n\n #puts \"RECLASSIFY: CTN NUMBER = \" + carton.carton.carton_number.to_s + \"; ID = \" + carton.carton.id.to_s + \" (this num: \" + carton.carton_number.to_s + \")\"\n carton.carton.update\n puts reclassed_carton.carton_number.to_s\n #create integration record\n #outbox_record = NewOutboxRecord.new(\"carton_reclassified\",reclassed_carton)\n end\n elsif carton.reworks_action.upcase == \"ALT_PACKED\"||carton.reworks_action.upcase == \"ALT_PACKED_FROM_CARTON\"\n if !(carton.rw_pallet_action && (carton.rw_pallet_action.upcase == \"REMOVED\"||carton.rw_pallet_action.upcase == \"PALLET_SCRAPPED\"))\n new_carton = RwCarton.new\n progress_stats.event_carton_created\n new_carton.date_time_created = Time.now\n carton.export_attributes(new_carton, true)\n new_carton.create\n\n #create new carton in our system\n new_mes_carton = Carton.new\n new_mes_carton.rw_create_datetime = Time.now\n carton.export_attributes(new_mes_carton, true)\n new_mes_carton.create\n\n #create integration record\n #outbox_record = NewOutboxRecord.new(\"rw_carton_new\",new_mes_carton)\n end\n elsif carton.rw_pallet_action && (carton.rw_pallet_action.upcase == \"ADDED\")\n #update mes record\n progress_stats.event_carton_pallet_ref_changed\n carton.carton.pallet = carton.rw_active_pallet.pallet\n carton.carton.pallet_number = carton.rw_active_pallet.pallet_number\n puts \"CARTON PALLET ACTION: CTN NUMBER = \" + carton.carton.carton_number.to_s + \"; ID = \" + carton.carton.id.to_s + \" (this num: \" + carton.carton_number.to_s + \")\"\n\n carton.carton.update\n\n #create integration record\n #outbox_record = NewOutboxRecord.new(\"carton_pallet_ref_change\",carton.carton)\n elsif carton.rw_pallet_action && (carton.rw_pallet_action.upcase == \"REMOVED\"||carton.rw_pallet_action.upcase == \"PALLET_SCRAPPED\")\n #update mes record\n integrate_scrapped_carton(carton)\n end\n end\n\n #----------------------------------------------------------------------------------------------------------\n #cartons to delete: alt-packed and scrapped cartons- cartons that must be deleted in legacy db\n #----------------------------------------------------------------------------------------------------------\n get_all_deleted_cartons().each do |carton|\n progress_stats.event_carton_scrapped\n integrate_scrapped_carton(carton)\n end\n\n get_all_deleted_rebins().each do |rebin|\n progress_stats.event_bin_scrapped\n rebin.bin.exit_ref = \"scrapped\"\n rebin.bin.exit_reference_date_time= Time.now\n rebin.bin.update\n stock_item =StockItem.find_by_inventory_reference(rebin.bin_number)\n if stock_item\n\n Inventory.move_stock(\"REWORKS\", self.id.to_s, \"REWORKS\", [rebin.bin_number])\n Inventory.remove_stock(nil, \"BIN\", \"REWORKS\", self.id.to_s, \"REWORKS\", [rebin.bin_number], \"KROMCO\")\n\n end\n end\n\n #---------------------------------------------------------------------------\n #Get a list of all pallets where qc_status_code = 'UNINSPECTED'\n #If it's not a new pallet, create a ppecb_inspection_reset integration flow +\n #Create a new ppecb_inspection record, copy of most recent for pallet and\n #set it's cancelled field value to true + date_time_cancelled\n #----------------------------------------------------------------------------\n reset_pallets = RwActivePallet.find_by_sql(\"select * from rw_active_pallets where rw_run_id = #{self.id.to_s} and UPPER(qc_status_code) = 'UNINSPECTED' AND upper(reworks_action) <> 'NEW_PALLET' AND upper(reworks_action) <> 'ALT_PACKED'\")\n reset_pallets.each do |reset_pallet|\n progress_stats.event_pallet_qc_reset\n #NewOutboxRecord.new(\"pallet_qc_reset\",reset_pallet)\n if reset_pallet.carton_quantity_actual > 0\n last_inspection = PpecbInspection.most_recent_inspection?(reset_pallet.rw_active_cartons[0].carton_number)\n if last_inspection\n new_inspection = PpecbInspection.new\n last_inspection.export_attributes(new_inspection, true)\n new_inspection.cancelled_inspection_id = last_inspection.id\n new_inspection.cancelled = true\n new_inspection.create\n end\n end\n end\n\n update_cartons_pallets #that is: of pallets that were not recieved explicitly\n update_scrapped_cartons_pallets\n\n\n self.rw_active_pallets.reload\n\n if self.rw_active_pallets && self.rw_active_pallets.length > 0\n pallet_numbers_order_upgrade=self.rw_active_pallets.map{|p|p.pallet_number}\n end\n\n #update the pallets of cartons that were received as cartons (i.e without pallets) and reclassed\n\n\n self.rw_active_cartons.delete_all\n self.rw_active_pallets.delete_all\n self.rw_run_end_datetime = Time.now\n self.rw_run_status_code = \"complete\"\n self.rw_active_bins.delete_all\n\n\n archive_receipt_objects\n\n self.update\n\n if required_actions.length > 0\n raise \"Some cartons do not have a pallet id. You must scrap these cartons or add them to a pallet to complete the run. They are: <br>\" + required_actions.join(\"<BR>\")\n end\n\n if pallet_numbers_order_upgrade\n Order.get_and_upgrade_prelim_orders(pallet_numbers_order_upgrade)\n end\n end\n rescue\n puts $!.backtrace.join(\"\\n\").to_s\n #RAILS_DEFAULT_LOGGER.info (\"REWORKS COMPLETION ERROR: \" + $!.backtrace.join(\"\\n\").to_s)\n err = $!.message\n err = \"exception occurred.See error log for details\" if !err\n progress_stats.run_completion_stats.error = err\n progress_stats.reset_stats\n raise \"Complete run failed: <BR>\" + $!\n\n ensure\n progress_stats.run_completion_stats.done = true\n progress_stats.run_completion_stats.persist\n progress_stats = nil\n done\n end\n\n end", "def destroy\n raise \"Permission denied\" if (RemoveItemOrderTask.roles & @permissions).empty?\n OrderItem.transaction do\n item = @order.items.find(params[:id])\n item.destroy\n task_complete({ :data => { :product_id => item.product.id, :item_id => item.id } },\n RemoveItemOrderTask, [RemoveItemOrderTask])\n end\n redirect_to :back\n end", "def finalize!\n update_attribute(:completed_at, Time.now)\n update_attribute(:payment_method_name, self.payment_method.name) unless self.payment_method_name\n self.out_of_stock_items = InventoryUnit.assign_opening_inventory(self)\n # lock any optional adjustments (coupon promotions, etc.)\n adjustments.optional.each { |adjustment| adjustment.update_attribute(\"locked\", true) }\n\n self.state_events.create({\n :previous_state => \"cart\",\n :next_state => \"complete\",\n :name => \"order\" ,\n :user_id => (User.respond_to?(:current) && User.current.try(:id)) || self.user_id\n })\n end", "def finish\n\t\t\tputs \"finish transfers #{write_fds} and #{read_fds}\"\n\t\t\twrite transfer_until: :eof\n\t\t\tread transfer_until: :eof\n\t\tend", "def item_inventory_update\n \n item = Item.find(params[:item_id])\n order= Order.find(params[:id])\n item_order = ItemOrder.where(item_id: item.id, order_id: order.id).first\n new_inventory = item.inventory - item_order.quantity\n item_order.update(status: \"fulfilled\")\n item.update(inventory: new_inventory)\n end", "def update\n # puts \"params: #{params.to_hash}\"\n return_order_items = JSON.parse(params[:order][:items]) \n\n # puts \"Params: #{return_order_items}\"\n\n @order = Order.find(params[:id])\n\n\n ActiveRecord::Base.transaction do\n return_order_items.each do |item|\n if params[:order].has_key?(:supplier) \n @ordered_item = Item.find_by_id(item[\"id\"].to_i)\n @ordered_item.decrement!(:remaining_quantity, item[\"quantity\"].to_i)\n else\n @ordered_item = Item.find_by_id(item[\"id\"].to_i)\n @ordered_item.increment!(:remaining_quantity, item[\"quantity\"].to_i)\n end\n end\n\n @order.return = true\n if @order.save\n @current_user = current_user\n redirect_to :root, notice: 'Return Order was successfully created.'\n else\n render :new\n end\n end\n\n end", "def return\n @num_in += 1\n @num_out -= 1\n\n puts \"Inventory ERROR!!!\" if @num_in > @num_copies\n end", "def purchase\n @order = current_order\n @order_items = @order.order_items\n @order_items.each do |item|\n new_inventory = Product.find(item.product_id).inventory_count - item.quantity\n Product.update(item.product_id, inventory_count: new_inventory)\n end\n @order_items.destroy_all\n end", "def 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 checkout(attributes)\n completed = false\n transaction do\n update!(attributes.merge(status: \"Completed\"))\n orderitems.each do |item|\n raise ActiveRecord::Rollback unless item.reduce_stock\n end\n completed = true\n end\n\n completed\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 transfer( amount:, to:, from: )\n\t\tself.log.info \"%s --{%0.6f𝓩}--> %s\" % [ from, amount, to ]\n\t\tamount = normalize_amount( amount )\n\n\t\traise \"No such wallet #{to}\" unless self.wallets.include?( to )\n\t\traise \"No such wallet #{from}\" unless self.wallets.include?( from )\n\t\traise \"Can't transfer to same wallet #{to}\" if to == from\n\t\traise \"Wallet #{from} doesn't contain enough to cover #{amount}\" unless\n\t\t\tself.wallet_has_at_least?( from, amount )\n\n\t\tself.add_transaction( amount: amount, to: to, from: from )\n\t\tself.log.info \"transfer complete.\"\n\tend", "def change_inventory_items_for_vendor vendor_id, inventory_item_ids\n\n # Remove all menu items where we are dealing with this vendor, but leave the fee, if any\n line_items.destroy(line_items.select{|li| (!li.inventory_item.nil? && li.inventory_item.vendor_id == vendor_id)})\n\n inventory_item_ids.each do |id|\n line_items.push(create_line_item_from_inventory_item(InventoryItem.find(id), 0, Vendor.find(vendor_id), account, false, false, \"\"))\n end\n\n trigger_event_rollup\n\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 update_inventory_and_status\n self.update_inventory\n self.update_status \n end", "def purchase\n @cart_items = CartItem.where(cart: Cart.last)\n \n @cart_items.each do |cart_item|\n @product = cart_item.product\n if (@product.inventory_count > 0)\n cart_item.product.update(title: @product.title, \n description: @product.description,\n price: @product.price,\n inventory_count: @product.inventory_count - cart_item.quantity)\n cart_item.destroy\n else\n flash[:notice] = \"Item in cart had no inventory left\"\n next\n end\n end\n if @cart = Cart.last\n @cart.destroy\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Cart was successfully purchased.'}\n format.json { head :no_content }\n end\n else\n respond_to do |format|\n format.html { redirect_to products_url, notice: \"A cart must exist for products to be added to\" }\n format.json { head :no_content }\n end\n end\n Cart.create()\n end", "def destroy\n @inventory_transfer = InventoryTransfer.find(params[:id])\n\n respond_to do |format|\n if @inventory_transfer.destroy\n format.html { redirect_to inventory_transfers_url,\n notice: (crud_notice('destroyed', @inventory_transfer) + \"#{undo_link(@inventory_transfer)}\").html_safe }\n format.json { head :no_content }\n else\n format.html { redirect_to inventory_transfers_url, alert: \"#{@inventory_transfer.errors[:base].to_s}\".gsub('[\"', '').gsub('\"]', '') }\n format.json { render json: @inventory_transfer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n ordered_item_from_table = OrderedItem.new(passed_parameters_from_items_index)\n order = Order.where(id: ordered_item_from_table.order_id, confirmed: false, user_id: current_user.id).last\n ordered_item_from_db = OrderedItem.where(order_id: order.id, item_id: ordered_item_from_table.item_id).last\n \n if ordered_item_from_db.present?\n item = Item.where(id: ordered_item_from_db.item_id).last\n if item.quantity > 0\n if ordered_item_from_db.update(quantity: ordered_item_from_db.quantity + 1) && item.update(quantity: item.quantity - 1)\n redirect_to items_path\n flash[:notice] = \"Item has been added to your order.\"\n else\n redirect_to items_path\n flash[:alert] = \"Item can not be added to your order.\"\n end\n else \n redirect_to items_path\n flash[:alert] = \"Item can not be added to your order.\"\n end\n \n\n else\n @ordered_item = OrderedItem.new(passed_parameters_from_items_index)\n @item = Item.find(@ordered_item.item_id)\n\n if @item.quantity > 0\n @item.quantity -= @ordered_item.quantity\n @item.update(quantity: @item.quantity )\n if @ordered_item.save\n redirect_to items_path\n flash[:notice] = \"Item has been added to your order.\"\n else\n redirect_to items_path\n flash[:alert] = \"Item can not be added to your order.\"\n end\n \n\n else\n flash[:alert] = \"Something went wrong! Item was not added to the cart\"\n redirect_to items_path\n end\n\n end\n end", "def transfer_funds()\n vendor = Portfolio.find(self.seller_id)\n customer = Portfolio.find(self.buyer_id)\n amount = self.transaction_cost\n customer.balance -= amount\n vendor.balance += amount\n \n Transactor.transaction do \n raise \"Transaction of funds failed!\" unless customer.save && vendor.save\n end\n end", "def handle_transfer(resp_body)\n params = {\n id: resp_body[:id],\n from: resp_body[:from],\n to: resp_body[:to],\n by: resp_body[:by],\n from_amount: Amount.new(\n currency: resp_body[:fromAmount][:currency],\n value: resp_body[:fromAmount][:value]\n ),\n to_amount: Amount.new(\n currency: resp_body[:fromAmount][:currency],\n value: resp_body[:fromAmount][:value]\n ),\n banking_id: resp_body[:banking_id],\n memo: resp_body[:memo],\n type: Utils.parse_enum(resp_body[:type]),\n status: Utils.parse_enum(resp_body[:status]),\n refund: Refund.new(resp_body[:refund]),\n created_at: Utils.parse_epoch(resp_body[:created])\n }\n TransferItem.new(@member_account, params)\n end", "def run!\n # Validations here are intended to catch all necessary prerequisites.\n # We return early so all checks have happened already.\n return false if invalid?\n desired_shipment.save! if desired_shipment.new_record?\n\n # Retrieve how many on hand items we can take from desired stock location\n available_quantity = [desired_shipment.stock_location.count_on_hand(variant), 0].max\n\n new_on_hand_quantity = [available_quantity, quantity].min\n unstock_quantity = desired_shipment.stock_location.backorderable?(variant) ? quantity : new_on_hand_quantity\n\n ActiveRecord::Base.transaction do\n if handle_stock_counts?\n # We only run this query if we need it.\n current_on_hand_quantity = [current_shipment.inventory_units.pre_shipment.size, quantity].min\n\n # Restock things we will not fulfil from the current shipment anymore\n current_stock_location.restock(variant, current_on_hand_quantity, current_shipment)\n # Unstock what we will fulfil with the new shipment\n desired_stock_location.unstock(variant, unstock_quantity, desired_shipment)\n end\n\n # These two statements are the heart of this class. We change the number\n # of inventory units requested from one shipment to the other.\n # We order by state, because `'backordered' < 'on_hand'`.\n current_shipment.\n inventory_units.\n where(variant: variant).\n order(state: :asc).\n limit(new_on_hand_quantity).\n update_all(shipment_id: desired_shipment.id, state: :on_hand)\n\n current_shipment.\n inventory_units.\n where(variant: variant).\n order(state: :asc).\n limit(quantity - new_on_hand_quantity).\n update_all(shipment_id: desired_shipment.id, state: :backordered)\n end\n\n # We modified the inventory units at the database level for speed reasons.\n # The downside of that is that we need to reload the associations.\n current_shipment.inventory_units.reload\n desired_shipment.inventory_units.reload\n\n # If the current shipment now has no inventory units left, we won't need it any longer.\n if current_shipment.inventory_units.length.zero?\n current_shipment.destroy!\n else\n # The current shipment has changed, so we need to make sure that shipping rates\n # have the correct amount.\n current_shipment.refresh_rates\n end\n\n # The desired shipment has also change, so we need to make sure shipping rates\n # are up-to-date, too.\n desired_shipment.refresh_rates\n\n true\n end", "def return_item\n items = self.see_purchases.map do |merchandise|\n {name: merchandise.name, merch_id: merchandise.id}\n end\n merch = TTY::Prompt.new.select(\"Here is a list of your purchases. What would you like to return?\",items)\n purchase = self.specific_purchase(merch)\n purchase.destroy \n puts \"your item has been refunded!\"\n restock = self.select_merchandise(merch)\n restock.update(inventory: restock.inventory + 1)\n end", "def revert_complete\n QcInspection.transaction do\n self.set_status STATUS_IN_PROGRESS\n end\n end", "def inventory\n items = @purchase.inventory!\n flash.notice = [t(:inventorized) ,items ,t(:items)].join(\" \")\n redirect_to purchase_path(@purchase)\n end", "def transfer!\n backup = connection.backups.create\n Logger.info \"Created backup [#{backup.id}]\"\n\n package.filenames.each do |filename|\n src = File.join(Config.tmp_path, filename)\n metadata = {}\n\n [:sha512sum, :sha1sum, :cksum].each do |cmd|\n if !`which #{cmd}`.empty?\n metadata[cmd] = %x|#{cmd} #{src}|.split.first\n break\n end\n end\n\n metadata[:size] = %x|ls -sh #{src}|.split.first\n\n backup_file = backup.files.create(filename: src, metadata: metadata)\n Logger.info \"Created backup file [#{backup_file.id}]\"\n\n Logger.info \"EngineYard performing upload of '#{File.join(src)}' to '#{backup_file.upload_url}' with metadata '#{metadata.inspect}'.\"\n\n backup_file.upload(file: src)\n end\n Logger.info \"Finished uploading files for backup [#{backup.id}]\"\n\n backup.finish!\n\n Logger.info \"Finished backup [#{backup.id}]\"\n end", "def done_migrating(action)\n @free_tems[[@rindex_tems[action[:with]], action[:with]]] = true\n @with[action[:secpack]] << action[:to]\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 complete\n\t\t\t@from.short_of_cash(@amount) if @from.balance < @amount\n\t\t\tamount_to_pay = ( @from.balance >= @amount ? @amount : @from.balance )\n\n\t\t\t@to.receive(amount_to_pay)\n\t\t\t@from.deduct(amount_to_pay)\n\t\t\tpaying_to = @to.owner.name\n\n\t\t\tif amount_to_pay < amount\n\t\t\t\t@from.owner.game.log '[%s] Unable to pay £%d to %s%s! Paid £%d instead' % [ @from.owner.name, amount, paying_to, ( @reason ? ' for %s' % @reason : '' ), amount_to_pay ]\n\t\t\t\t@from.owner.bankrupt!(@to.owner) if @from.owner.respond_to? :bankrupt!\n\t\t\t\tfalse\n\t\t\telse\n\t\t\t\t@from.owner.game.log '[%s] Paid £%d to %s%s (balance: £%d)' % [ @from.owner.name, amount, paying_to, ( @reason ? ' for %s' % @reason : '' ), @from.balance ]\n\t\t\t\ttrue\n\t\t\tend\n\n\t\t\t@completed = true\n\t\tend", "def consume_items(item_quantities)\n item_quantities.each do |ingredient_name, quantity|\n @ingredients[ingredient_name] = @ingredients[ingredient_name] - quantity\n end\n end", "def complete!\n return false unless pending? && transfer.feasible?\n transfer.complete!\n update shipped_at: Time.current\n order.update_shipped!\n email.shipment(to: order.billing_recipient)&.deliver_later if order.billing_address.present?\n email.shipment(to: order.shipping_recipient, bcc: false)&.deliver_later if order.has_contact_email?\n true\n end", "def destroy\n\n InventoryOwn.transaction do\n @inventory_own.deleted = true\n @inventory_own.save\n\n user_id = @inventory_own.user_id\n\n #If the book being removed is involved in a trade, email other users involved in trade that the trade\n #has been cancelled\n @trades = @inventory_own.trades\n debugger\n @trades.each do |trade|\n\n if not trade.declined?\n trade.user_decline(user_id, \"Sorry, I removed this item from my have list.\")\n\n @trade_lines = trade.get_tradelines_except(user_id)\n @trade_lines.each do |line|\n UserMailer.trade_destroyed(line.inventory_own.user, trade).deliver\n end\n end\n end\n\n end\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def commit_transaction\n\t real_object = __getobj__\n\t partition_new_old_relations(:parent_objects) do |trsc_objects, rel, new, del, existing|\n\t\tfor other in new\n\t\t other.add_child_object(real_object, rel, trsc_objects[other][self, rel])\n\t\tend\n\t\tfor other in del\n\t\t other.remove_child_object(real_object, rel)\n\t\tend\n for other in existing\n other[real_object, rel] = trsc_objects[other][self, rel]\n end\n\t end\n\n\t partition_new_old_relations(:child_objects) do |trsc_objects, rel, new, del, existing|\n\t\tfor other in new\n\t\t real_object.add_child_object(other, rel, self[trsc_objects[other], rel])\n\t\tend\n\t\tfor other in del\n\t\t real_object.remove_child_object(other, rel)\n\t\tend\n for other in existing\n real_object[other, rel] = self[trsc_objects[other], rel]\n end\n\t end\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 transfer\n\t\t\t\t@loop.transfer\n\t\t\tend", "def clean_up\n reset_items_unit1\n reset_items_unit2\n end", "def create\n @transfer = Transfer.new(transfer_params)\n respond_to do |format|\n if @transfer.save\n @transfer.transferable.update( branch_id: transfer_params[:to_location_id] )\n if @transfer.transferable_type == \"Employee\"\n @transfer.transferable.devices.update_all( status: \"instock\", status_date: Date.today )\n @transfer.transferable.device_assignments.update_all(unassign_date: @transfer.transfer_date)\n end \n format.html { redirect_to @transfer, notice: 'Transfer was successfully created.' }\n format.json { render :show, status: :created, location: @transfer }\n else\n set_resources\n format.html { render :new }\n format.json { render json: @transfer.errors, status: :unprocessable_entity }\n end\n end\n end", "def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end", "def transfer!\n package.filenames.each do |filename|\n src = File.join(Config.tmp_path, filename)\n dest = File.join('/', remote_path, filename)\n Logger.info \"Storing '#{ dest }'...\"\n\n File.open(src, 'r') do |file|\n @uploader = ChunkedUploader.new(client, file)\n with_retries do\n @uploader.upload(1024**2 * chunk_size)\n end\n end\n\n with_retries do\n @uploader.finish(dest)\n end\n end\n rescue => err\n raise Error.wrap(err, \"Upload Failed!\")\n end", "def update_order_of_items_bulk\n @catalog = Catalog.find(params[:id])\n result = @catalog.do_update_order_of_items_bulk(params[:item_change][:moved_items], params[:item_change][:before_item]);\n \n # return a success message, wouldn't make sense to call this API method as html, but for debugging\n # just return json anyway\n respond_to do |format|\n format.html { render json: result}\n format.json { render json: result}\n end\n end", "def finalize!\n logger.info 'FINALIZE ORDER'\n \n update_attribute(:completed_at, Time.now)\n # self.out_of_stock_items = InventoryUnit.assign_opening_inventory(self)\n # lock any optional adjustments (coupon promotions, etc.)\n # adjustments.optional.each { |adjustment| adjustment.update_attribute(\"locked\", true) }\n # OrderMailer.confirm_email(self).deliver\n \n # Mail products\n OrderMailer.order_email(self).deliver\n logger.info 'MAILING PRODUCTS'\n \n # User.current.update_cap(self.customer_total)\n self.user.update_cap(self.customer_total)\n logger.info 'UPDATE BUYER CAP'\n \n # Mail via sms\n if self.mobile_number.empty? == false then\n sms = SMS.new()\n sms.create(self.mobile_number, self)\n end\n \n self.state_events.create({\n :stateful_id => self.id,\n :previous_state => \"cart\",\n :next_state => \"complete\",\n :stateful_type => \"order\" ,\n :user_id => (User.respond_to?(:current) && User.current.try(:id)) || self.user_id\n })\n end", "def update\n respond_to do |format|\n @tia_item.transaction do\n tia_original = @tia_item.dup\n @tia_item.assign_attributes( tia_item_params ) unless tia_item_params.empty?\n if @tia_item.valid? then\n tia_item_delta = TiaItemDelta.new\n tia_item_delta.collect_delta_information( tia_original, @tia_item )\n if tia_item_delta.valid? then\n tia_item_delta.save!\n @tia_item.save!\n format.html { redirect_to our_tia_item_path( @tia_item ), notice: t( 'tia_items.msg.edit_ok' )}\n elsif tia_item_delta.delta_count == 0 then\n format.html { redirect_to our_tia_item_path( @tia_item ), notice: t( 'tia_items.msg.no_change' )}\n else\n @tia_item.errors.add( :base, 'Internal Error: TiaItemDelta record failed validation' )\n set_member_list\n format.html{ render :edit }\n end\n else\n set_member_list\n format.html { render :edit }\n end\n end\n end\n end", "def mark_complete\n ActiveRecord::Base.transaction do\n find_order\n separate_shipment_costs\n assert_refund_adjustments params['refund_items'], true\n @order.update!\n end\n settle_payments_if_desired\n render text: @settlement_results.to_json\n end", "def perform_transfer\n if $game_map.map_id != @new_map_id\n refresh_falcao_int_system \n @clear_lights = true\n @working_at = {} ; @grabevents = []\n if @showing_barrel and not @gamebarrel.picked\n @showing_barrel = false\n @gamebarrel.moveto(-1, -1)\n @gamebarrel.fire_duration = 0; @gamebarrel.pushable_busy = nil\n @gamebarrel.character_name = BarrelGraphicOff\n end\n if @showing_bomb and not @gamebomb.picked\n @gamebomb.action_time = 0\n @showing_bomb = false\n @gamebomb.moveto(-1, -1)\n end\n @gamearrow.char_steps = 0 if @showing_arrow \n @showing_arrow = false if @showing_arrow \n @gamegun.char_steps = 0 if @showing_gun \n @showing_gun = false if @showing_gun \n \n end\n falcao_intsystem_perform_transfer\n end", "def transfer!\n remote_path = remote_path_for(@package)\n\n files_to_transfer_for(@package) do |local_file, remote_file|\n Logger.info \"#{storage_name} started transferring '#{ local_file }'.\"\n\n File.open(File.join(local_path, local_file), 'r') do |file|\n connection.put_object(\n container, File.join(remote_path, remote_file), file\n )\n end\n end\n end", "def cleanup_successful\n\t\tself.order_status_code_id = 5\n self.new_notes=\"Order completed.\"\n self.product_cost = self.line_items_total\n self.account.clear_personal_information\n self.save\n\tend", "def rollback(order_id, item_ids, old_state, new_state)\n @orders.update({\"_id\" => order_id}, {\"$pullAll\" => {:item_ids => item_ids}})\n\n item_ids.each do |id|\n @inventory.find_and_modify(:query => {\"_id\" => id, :state => new_state},\n :update => {\"$set\" => {:state => old_state, :add_time => nil}})\n end\n end", "def complete_xaction\n if valid?\n # For new records, certain types of transactions will be automatically set as completed.\n self.completed = true if new_record? && (to.is_account? && (from_id.nil? || from.is_account?))\n\n # If amount changes, we have to update the envelope amount if it's still pending; otherwise update just the account amount.\n if !new_record? && dirty_attributes.keys.include?(Xaction.properties[:amount])\n if completed\n # update the debited account\n diff = amount - Xaction.get(id).amount\n from.update_attributes(:actual_amount => from.actual_amount.to_f + diff)\n else\n # update the envelope amount\n diff = amount - Xaction.get(id).amount\n to.update_attributes(:actual_amount => to.actual_amount.to_f + diff)\n end\n end\n \n # Complete/Pending\n if dirty_attributes.keys.include?(Xaction.properties[:completed])\n # Envelope side\n if to && !to.is_account?\n if new_record? && !completed\n # credit the envelope\n to.update_attributes(:actual_amount => to.actual_amount.to_f + amount.to_f)\n end\n if !new_record?\n if completed\n # debit the envelope\n to.update_attributes(:actual_amount => to.actual_amount.to_f - amount.to_f)\n to.budget.update_attributes(:amount => amount.to_f < from.budget.amount.to_f ? to.budget.amount.to_f - amount.to_f : 0) # If spending, take it out of the current budget too.\n else\n # undo the debit\n to.update_attributes(:actual_amount => to.actual_amount.to_f + amount.to_f)\n to.budget.update_attributes(:amount => amount.to_f < to.budget.amount.to_f ? to.budget.amount.to_f + amount.to_f : 0) # If spending, take it out of the current budget too.\n end\n end\n end\n\n # Debiting from Account\n if from && from.is_account?\n if completed\n # debit the account\n from.update_attributes(:actual_amount => from.actual_amount.to_f - amount.to_f)\n elsif !new_record? && !completed\n # undo the debit\n from.update_attributes(:actual_amount => from.actual_amount.to_f + amount.to_f)\n end\n end\n\n # Crediting to Account\n if to && to.is_account?\n if completed\n # debit the account\n to.update_attributes(:actual_amount => to.actual_amount.to_f + amount.to_f)\n elsif !new_record? && !completed\n # undo the debit\n to.update_attributes(:actual_amount => to.actual_amount.to_f - amount.to_f)\n end\n end\n end\n end\n end", "def commit\n offer = Offer.find(params[:id])\n if offer\n if offer.product.user_id == @current_user.id\n if offer.offer_status != Offer.OFFER_COMPLETED\n conversation = offer.conversation\n conversation_id = conversation.id\n conversation.destroy\n\n product = offer.product\n product.sold_status = Product.SOLD_SOLD\n product.save\n\n SearchEntry.destroy_index product\n \n offer.offer_status = Offer.OFFER_COMPLETED\n offer.save\n\n notify(\"NOTIF_TRANSACTION_FINISHED\", {\n conversation: conversation_id,\n user: {\n id: @current_user.id,\n username: @current_user.username,\n first_name: @current_user.first_name,\n last_name: @current_user.last_name\n },\n product: {\n id: product.id,\n product_name: product.product_name\n },\n offer: {\n price: offer.price\n }\n }, offer.user_id)\n\n render status: 200, json: {error: false, id: offer.id}\n else\n render status: 471, json: {error: true}\n end\n else\n render status: 472, json: {error: true}\n end\n else\n render status: 404, json: {error: true}\n end\n end", "def destroy\n ActiveRecord::Base.transaction do\n begin\n deposito_suministro = Deposito.where(\"nombre LIKE ?\", \"%SUMINISTRO%\").first\n\n @consumo_directo.recepciones_de_bien_de_consumo[0] ? @recepcion = @consumo_directo.recepciones_de_bien_de_consumo[0] : @recepcion = nil\n @consumo_directo.bienes_de_consumo_para_consumir.each do |bien|\n @item_stock = ItemStock.where(\"bien_de_consumo_id = ? AND deposito_id = ?\", bien.bien_de_consumo.id, bien.deposito_id)\n if !@item_stock.first.nil?\n suma = @item_stock.first.cantidad + bien.cantidad\n raise ActiveRecord::Rollback unless @item_stock.first.update(cantidad: suma)\n else\n raise ActiveRecord::Rollback\n end\n volver_costo_de_bien_al_anterior(bien) unless @recepcion.nil?\n end\n\n\n respond_to do |format|\n if @consumo_directo.update(estado: 2)\n if !@recepcion.nil?\n @recepcion.bienes_de_consumo_de_recepcion.each do |bien_de_recepcion|\n @item_stock = ItemStock.where(\"bien_de_consumo_id = ? AND deposito_id = ?\", bien_de_recepcion.bien_de_consumo.id, deposito_suministro.id)\n if !@item_stock.first.nil?\n resta = @item_stock.first.cantidad - bien_de_recepcion.cantidad\n raise ActiveRecord::Rollback unless @item_stock.first.update(cantidad: resta)\n else\n raise ActiveRecord::Rollback\n end\n #volver_costo_de_bien_al_anterior(bien) unless recepcion.nil?\n end\n raise ActiveRecord::Rollback unless @recepcion.update(estado: 7)\n end\n format.html { redirect_to consumos_directo_url, notice: 'El consumo fué dado de baja exitosamante' }\n format.json { head :no_content }\n else\n raise ActiveRecord::Rollback\n end\n end\n rescue ActiveRecord::Rollback\n respond_to do |format|\n format.html { redirect_to consumos_directo_url, notice: 'El consumo no pudo ser dado de baja. Consulte con el administrador del sistema' }\n format.json { head :no_content }\n end\n end #begin\n end #transaction\n end", "def send_transaction_finished_event\n agent.events.notify(:transaction_finished, payload)\n end", "def change_inventory_items_for_event_vendor vendor_id, inventory_item_ids, include_expense_price, include_revenue_price, inventory_item_quantities={}, item_notes={}, menu_template=nil\n # Remove all menu items where we are dealing with this vendor, but leave the fee, if any\n destroy_line_items(line_items.select{|li| (!li.inventory_item.nil? && li.inventory_item.vendor_id == vendor_id )}) unless menu_template\n inventory_item_ids.each do |id|\n if inventory_item_quantities.is_a? Hash\n # This is how catering does quantity \n quantity = inventory_item_quantities[id].try(:to_i) || 0\n else\n # This is how snappea's data looks. fuck... -djb\n quantity = inventory_item_quantities[id.to_i].try(:to_i) || 0\n end\n line_items.push(create_line_item_from_inventory_item(InventoryItem.find(id), quantity, Vendor.find(vendor_id), account, include_expense_price.include?(id.to_s), include_revenue_price.include?(id.to_s), item_notes[id]))\n end\n\n create_per_person_charge_addons_for_payable_party(Vendor.find(vendor_id))\n trigger_event_rollup\n end", "def upload_done(ids)\n # Forces a check that the supplied info is correct\n self.previous_uploads = ids.map { |id| NfsStore::Upload.find(id) }\n self.previous_upload_stored_file_ids = previous_uploads.map(&:nfs_store_stored_file_id)\n\n # Get any uploads that already have an upload_set, since it is invalid to reset it\n raise FsException::Action, \"Upload set files don't match\" if previous_uploads.map(&:upload_set).uniq.length != 1\n\n return unless parent_item&.can_edit?\n\n extra_options_config.calc_save_trigger_if self, alt_on: :upload\n end", "def create\n @transaction = Transaction.new(params[:transaction])\n #@item = Item.find(@transaction.item_id)\n #@item.buyer_id = current_user.id\n @transaction.user_id = current_user.id\n @shopping_cart = ShoppingCart.find_by_user_id(current_user.id)\n error_flag = 0\n error_message = \"\"\n available_item = Array.new\n eval(@shopping_cart.item_list).each do |item_id, quantity|\n item = Item.find(Integer(item_id))\n if item.quantity < quantity\n error_message = \"Sorry! Only #{item.quantity} of #{item.title} is available at the moment\"\n error_flag = 1\n else\n available_item += [item]\n item.quantity -= quantity\n end\n end\n\n if error_flag == 1\n redirect_to @shopping_cart, notice: error_message\n else\n item_list = Hash.new\n eval(@shopping_cart.item_list).each do |item_id, item_quantity|\n index = Item.find(Integer(item_id)).attributes.except(\"created_at\", \"updated_at\", \"product_file_name\",\n \"product_content_type\", \"product_file_size\", \"product_updated_at\")\n item_list[index] = item_quantity\n end\n @transaction.item_list = item_list.to_s\n\n respond_to do |format|\n if @transaction.save\n available_item.each do |item|\n item.save\n end\n @shopping_cart.delete\n format.html { redirect_to @transaction, notice: 'Transaction successful.' }\n format.json { render json: @transaction, status: :created, location: @transaction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def place_order\n @order = Order.new(order_params)\n @basket.line_items.map do |line_item|\n @order.line_items << line_item\n item.basket_id = nil\n\n dish = Dish.find(line_item.dish_id)\n dish.inventory -= line_item.quantity\n dish.save\n end\n @order.save\n @basket.destroy\n render Dish.all, status: :ok\n end", "def transfer!\n create_local_directories!\n\n files_to_transfer do |local_file, remote_file|\n Logger.message \"#{storage_name} started transferring '#{ local_file }'.\"\n FileUtils.cp(\n File.join(local_path, local_file),\n File.join(remote_path, remote_file)\n )\n end\n end", "def finish\n self.class.debug_log(\"SAVE #{flavor} \" \\\n \"from=#{begin\n user.login\n rescue StandardError\n \"nil\"\n end} \" \\\n \"to=#{begin\n to_user.login\n rescue StandardError\n \"nil\"\n end} \" +\n queued_email_integers.map { |x| \"#{x.key}=#{x.value}\" }.join(\" \") +\n queued_email_strings.map { |x| \"#{x.key}=\\\"#{x.value}\\\"\" }.join(\" \"))\n current_locale = I18n.locale\n unless MO.queue_email || QueuedEmail.queue\n deliver_email if RunLevel.is_normal?\n destroy\n end\n I18n.locale = current_locale\n end", "def update_items\n @existing_items = []\n @order.items.each { |i| @existing_items << i.id }\n\n # detail and reproduction_pages will come in as attributes of items, but they actually belong to the item_order\n # so look for those, then add them to the correct record in @item_orders\n\n @item_orders.each do |item_order|\n # add item to order\n if !@existing_items.include?(item_order['item_id'].to_i)\n item_order_record = @order.item_orders.create!(item_id: item_order['item_id'], archivesspace_uri: item_order['archivesspace_uri'], user_id: current_user.id, active: true)\n else\n item_order_record = @order.item_orders.where(item_id: item_order['item_id']).first\n item_order_record.update_attributes(archivesspace_uri: item_order['archivesspace_uri'])\n @order.reload\n # delete id from @existing_items array to track associations to be deleted\n @existing_items.delete(item_order['item_id'])\n end\n\n if item_order['reproduction_spec']\n create_or_update_reproduction_spec(item_order_record.id, item_order['reproduction_spec'])\n end\n\n # handle fees\n if @order_sub_type_name == 'reproduction_fee'\n if item_order['order_fee']\n create_or_update_order_fee(item_order_record.id, 'ItemOrder', item_order['order_fee'])\n end\n else\n # delete any existing fee for this item_order if it exists\n OrderFee.where(record_id: item_order_record.id,\n record_type: 'ItemOrder').each { |f| f.destroy! }\n end\n end\n\n @existing_items.each do |item_id|\n @order.item_orders.where(item_id: item_id).each { |io| io.destroy! }\n end\n end", "def transfer_to_otu(otu, delete_from_incoming = true)\n return false if otu.id == self.otu_id\n c = Content.find(:first, :conditions => {:otu_id => otu.id, :content_type_id => self.content_type_id})\n # does the incoming otu have this content_type already\n \n begin\n Content.transaction do\n if c # content already exists for the clone-to OTU \n c.text = c.text + \" [Transfered from OTU #{self.otu_id}: #{self.text}]\" # append content\n c.save! \n # deal with figures\n for f in self.figures\n if found = Figure.find(:first, :conditions => {:addressable_type => 'Content', :addressable_id => c.id , :image_id => f.image_id})\n # append the caption\n found.caption += \" [Transfered from OTU #{self.otu_id}: #{f.caption}]\"\n f.destroy if delete_from_incoming\n else\n if delete_from_incoming\n # transfer the figure\n f.addressable_id = c.id\n f.save!\n else\n # clone the figure\n n = f.clone\n n.addressable_id = c.id\n end\n end\n end\n\n # deal with tags\n for t in self.tags\n if found = Tag.find(:first, :conditions => {:addressable_type => 'Content' , :addressable_id => c.id , :keyword_id => t.keyword_id })\n # append the notes\n \n found.notes += \" [Transfered from OTU #{self.otu_id}: #{t.notes}]\"\n found.save!\n t.destroy if delete_from_incoming\n else\n if delete_from_incoming\n # transfer the tag\n t.addressable_id = c.id\n t.save!\n else\n #clone the tag\n n = t.clone\n n.addressable_id = c.id\n n.save!\n end\n end\n end\n\n self.destroy if delete_from_incoming\n \n else # content in transfer-to OTU doesn't exist\n if delete_from_incoming # just update the otu_id and everything gets transferred\n self.otu_id = otu.id\n self.save!\n else # need to clone everything\n # clone the content\n nc = self.clone\n nc.otu_id = otu.id\n nc.save!\n\n # clone figures\n for f in self.figures\n fn = f.clone\n fn.addressable_id = nc.id\n fn.save!\n end\n\n # clone tags\n for t in self.tags\n tn = t.clone\n tn.addressable_id = nc.id\n tn.save!\n end\n end\n end\n end\n\n rescue\n returns false\n end\n true\n end", "def finish_downlink_transaction\n\n conditionCode = create_file\n\n writeLog(\"Cleaning buffer from transaction #{@ID}\")\n CFDP::CFDPEngine.instance.clean_buffer(@ID)\n\n # transaction is complete, send FINISHED Pdu\n finishedPdu = CFDP.generatePDU(\"FINISHED\", {sourceID:DESTINATIONID, destinationID:MYID, conditionCode:conditionCode, endSystemStatus:1,\n deliveryCode:(conditionCode == 0 ? 0 : 1), fileStatus:(conditionCode == 4 ? 1 : 2), direction:1, transmissionMode:0, sequenceNumber:@ID[DESTINATIONID]})\n writeLog(\"Generated FINISHED PDU: #{finishedPdu.pack.to_s}\")\n update(finishedPdu)\n\n CFDP::CFDPEngine.instance.insertIntoBuffer(finishedPdu)\n\n CFDP::CFDP_Indication(\"Transaction #{@ID} finished with <#{CFDP.conditionCodeToStr(conditionCode)}> condition.\")\n writeLog(\"Transaction #{@ID} finished with <#{CFDP.conditionCodeToStr(conditionCode)}> condition.\")\n end", "def update\n respond_to do |format|\n if @transfer.update(transfer_params)\n latest_transfer = Transfer.latest_transfer(@transfer.transferable_id, @transfer.transferable_type)\n if @transfer.transferable_type == \"Employee\" && @transfer.from_location != @transfer.transferable.branch\n @transfer.transferable.devices.update_all( status: \"instock\", status_date: Date.today )\n @transfer.transferable.device_assignments.where.not(unassign_date: nil).update_all(unassign_date: @transfer.transfer_date)\n end \n @transfer.transferable.update(branch_id: @transfer.to_location_id) if latest_transfer == @transfer\n format.html { redirect_to @transfer, notice: 'Transfer was successfully updated.' }\n format.json { render :show, status: :ok, location: @transfer }\n else\n set_resources\n format.html { render :edit }\n format.json { render json: @transfer.errors, status: :unprocessable_entity }\n end\n end\n end", "def move_detail\n params[:q].split(',').map(&:to_i).each do |productId|\n p \"producto: #{productId}\"\n inventory = Inventory.find(productId)\n @move_detail = MoveDetail.new(site_to_id: params[:site_to_id], site_from_id: inventory.deposit_id, inventory_id: productId, move_id: params[:move_id])\n @move_detail.save!\n inventory.update_attributes(deposit_id: params[:site_to_id], status: :en_movimiento)\n end\n redirect_back fallback_location: inventories_path\n end", "def apply_tranfer_items_to_asset(user_id = nil)\n # return if the allocations of the assets are NOT the same as the transfering items \n return false if transfering_assets.any?{|tr| !(tr.asset.allocations.collect(&:id) ^ tr.asset_transfer_item_froms.collect(&:id)).empty? }\n default_attrs = {:created_by_id => user_id, :updated_by_id => user_id}\n # 1st: disable the former allocations\n # 2nd: new allocations by trans_tos\n ActiveRecord::Base.transaction do\n transfering_assets.collect do |tr|\n tr.asset.allocations.each{|alloc| alloc.disabled!(user_id)}\n tr.asset.reload\n tr.asset.allocations << tr.asset_transfer_item_tos.collect do |trans_to|\n AssetAllocation.new_by_transfer_item_to(trans_to, default_attrs)\n end\n tr.save\n end.all?\n end\n end", "def destroy_along_with_units\n self.quantity = 0\n OrderInventoryAssembly.new(self).verify\n self.destroy\n end", "def destroy_along_with_units\n self.quantity = 0\n OrderInventoryAssembly.new(self).verify\n self.destroy\n end", "def transfer!\n remote_path = remote_path_for(@package)\n\n files_to_transfer_for(@package) do |local_file, remote_file|\n Logger.info \"#{ storage_name } started transferring '#{ local_file }'.\"\n\n uploader, retries = nil, 0\n File.open(File.join(local_path, local_file), 'r') do |file|\n uploader = connection.get_chunked_uploader(file, file.stat.size)\n while uploader.offset < uploader.total_size\n begin\n uploader.upload(1024**2 * chunk_size)\n retries = 0\n # Timeout::Error is not a StandardError under ruby-1.8.7\n rescue StandardError, Timeout::Error => err\n retries += 1\n if retries <= chunk_retries\n Logger.info \"Chunk retry #{ retries } of #{ chunk_retries }.\"\n sleep(retry_waitsec)\n retry\n end\n raise Errors::Storage::Dropbox::TransferError.\n wrap(err, 'Dropbox upload failed!')\n end\n end\n end\n\n uploader.finish(File.join(remote_path, remote_file))\n end\n end", "def done(index)\n save do\n items[index-1].context = '@done'\n items[index-1]\n end\n end", "def perform\n ActiveRecord::Base.transaction do\n copy_account_combatant\n create_combatant_status\n copy_moves\n end\n end", "def create\n @breadcrumb = 'create'\n @inventory_transfer = InventoryTransfer.new(params[:inventory_transfer])\n @inventory_transfer.created_by = current_user.id if !current_user.nil?\n\n respond_to do |format|\n if @inventory_transfer.save\n format.html { redirect_to @inventory_transfer, notice: crud_notice('created', @inventory_transfer) }\n format.json { render json: @inventory_transfer, status: :created, location: @inventory_transfer }\n else\n @stores = stores_dropdown\n format.html { render action: \"new\" }\n format.json { render json: @inventory_transfer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \tflash[:notice] =\"\"\n \t@transport = Transport.find(params[:id])\n \n\t\t\t\n \tTransport.transaction do\n \t\tfor i in 1..(params[:pieces].to_i) do\n\t\t\t\t\tbegin\n\t\t\t\t\t\t@item = Item.create( :weight => params[:nettoWeight],:length => params[:length],\n\t\t\t\t\t\t\t\t\t\t:diameter => params[:diameter], :width => params[:width],:place_id => @transport.loadPlace_id, :itemid => params[:itemid])\n\t\t\t\t\t\t@itemtransports = @transport.items << @item\n\t\t\t\t\t @wagon = @itemtransports.find(@item).wagons.find_by_transport_id(@transport)\n\t\t\t\t\t @wagon.vrn = params[:wagon_vrn]\n\t\t\t\t\t @wagon.wag_type = \"train\"\n\t\t\t\t\t @wagon.save\n\t\t\t\t\trescue Exception => e \n\t\t\t\t\t\tflash[:notice] = e.message \n\t\t\t\t\t\traise ActiveRecord::Rollback\n\t\t\t\t\tend\t\n\t\t\tend\n\t\t\t\t\n\t\tend\t\n\t\t\trespond_to do |format|\n if @transport.update_attributes(params[:transport])\n flash[:notice] += '<br/>Transport was successfully updated.'\n format.html { redirect_to(@transport) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @transport.errors, :status => :unprocessable_entity }\n end\n end\n end", "def recipe_done(recipe_index)\n @recipes[recipe_index].done!\n save_recipes_in_csv\n end", "def transfer(*args)\n commit 'MassPay', build_mass_pay_request(*args)\n end", "def update_quantity(quantity)\n\n if quantity != self.quantity\n\n old_quantity = self.quantity || 0\n old_item_cost = self.item_cost || 0\n old_item_deposit = self.product_deposit_cost || 0\n old_category_supplement_1_cost = self.category_supplement_1_cost || 0\n old_category_supplement_2_cost = self.category_supplement_2_cost || 0\n old_category_supplement_3_cost = self.category_supplement_3_cost || 0\n\n transaction do\n\n # Update the item\n self.quantity = quantity\n self.item_cost = (self.item_unit_cost || 0) * quantity\n self.product_deposit_cost = (self.product_deposit_unit_cost || 0) * quantity\n self.category_supplement_1_cost = (self.category_supplement_1_unit_cost || 0) * quantity\n self.category_supplement_2_cost = (self.category_supplement_2_unit_cost || 0) * quantity\n self.category_supplement_3_cost = (self.category_supplement_3_unit_cost || 0) * quantity\n self.save\n\n # Update the shopping cart cost\n self.shopping_cart_item_cost_variation(old_item_cost, \n old_item_deposit, \n old_category_supplement_1_cost,\n old_category_supplement_2_cost,\n old_category_supplement_3_cost)\n self.shopping_cart.calculate_cost(false, true)\n\n begin\n self.shopping_cart.save\n rescue DataMapper::SaveFailureError => error\n p \"Error saving shopping cart: #{self.shopping_cart.errors.full_messages.inspect}\"\n raise error\n end\n\n # Add or shopping cart item resources\n if quantity < old_quantity\n (quantity..(old_quantity-1)).each do |resource_number|\n self.item_resources[quantity].destroy unless self.item_resources[quantity].nil?\n self.item_resources.reload\n end\n elsif quantity > old_quantity\n product = ::Yito::Model::Booking::BookingCategory.get(item_id)\n (old_quantity..(quantity-1)).each do |resource_number|\n shopping_cart_item_resource = ShoppingCartItemResourceRenting.new\n shopping_cart_item_resource.item = self\n shopping_cart_item_resource.pax = product.capacity unless product.nil?\n shopping_cart_item_resource.save\n end\n end\n\n end\n end\n end", "def destroy\n\n InventoryNeed.transaction do\n @inventory_need.deleted = true\n @inventory_need.save\n\n user_id = @inventory_need.user_id\n\n #If the book being removed is involved in a trade, email other users involved in trade that the trade\n #has been cancelled\n @trades = @inventory_need.trades\n\n @trades.each do |trade|\n\n if not trade.declined?\n trade.user_decline(user_id, \"Sorry, I removed this item from my want list.\")\n\n @trade_lines = trade.get_tradelines_except(user_id)\n @trade_lines.each do |line|\n UserMailer.trade_destroyed(line.inventory_own.user, trade).deliver\n end\n end\n end\n\n end\n\n respond_to do |format|\n format.json { head :no_content }\n format.js { render :layout=>false }\n end\n end" ]
[ "0.6582895", "0.63096386", "0.5977841", "0.5905514", "0.58127666", "0.5804521", "0.5718544", "0.56545705", "0.55839056", "0.55536807", "0.5511493", "0.5504977", "0.5487107", "0.5475895", "0.5421679", "0.5414727", "0.5402404", "0.5346618", "0.52448153", "0.52358997", "0.52107435", "0.516845", "0.51309675", "0.5122602", "0.5075812", "0.50527287", "0.5047676", "0.5030065", "0.50270116", "0.5024843", "0.50210583", "0.50114316", "0.5003334", "0.49784616", "0.49701625", "0.49603015", "0.49529868", "0.49383375", "0.49370337", "0.4934102", "0.4896971", "0.4895627", "0.48934194", "0.4882823", "0.48736274", "0.48656288", "0.48545474", "0.48499882", "0.48434085", "0.48265386", "0.48194355", "0.4814797", "0.48125166", "0.48076937", "0.48035908", "0.48028994", "0.4802816", "0.4795146", "0.47927397", "0.477831", "0.47719324", "0.4769743", "0.47680405", "0.47548738", "0.47535402", "0.4750402", "0.47466585", "0.47452295", "0.47330135", "0.47321102", "0.47293285", "0.4721035", "0.47185197", "0.4716453", "0.47157776", "0.47127074", "0.47117886", "0.47104663", "0.4706796", "0.47041488", "0.4702534", "0.4702396", "0.46939224", "0.4691816", "0.46867618", "0.46718878", "0.4670106", "0.46697184", "0.46691704", "0.46684602", "0.46684602", "0.46672848", "0.4663491", "0.46607316", "0.46549246", "0.46524093", "0.46499893", "0.4648251", "0.46480286", "0.4647583" ]
0.70786023
0
Transfer is considered feasible only if all its items can be transferred, given current stock levels. Immediately returns true if the source is nil denoting an external source or if the source uses a stock gateway, which will not be queried.
def feasible? return true if source.nil? || source.enable_gateway? transfer_items.each do |item| return false unless item.feasible? end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def feasible?\n return true if amount < 0 || source.nil? || !product.tracked_stock? || source.enable_gateway?\n inventory_item = source_item\n inventory_item.present? && inventory_item.available >= amount\n end", "def can_buy_ship?(other)\n return false unless @credits >= (other.price - @start_ship.tradein)\n return @start_ship.can_transfer_to?(other)\n end", "def available?\n Spree::Config[:track_inventory_levels] ? (Spree::Config[:allow_backorders] || self.in_stock?) : true\n end", "def can_transfer?\n return if sender.balance >= amount\n errors.add(:amount, INSUFFICIENT_FUNDS_MESSAGE)\n end", "def in_stock?\n\t\tif self.downloadable?\n\t\t\ttrue\n\t\telsif self.inventory.xsmall > 0 || self.inventory.xxlarge > 0 || \n\t\t\tself.inventory.small > 0 || self.inventory.medium > 0 ||\n\t\t\tself.inventory.xlarge > 0 || self.inventory.large > 0\n\t\t \ttrue\n\t\telse \n\t\t\tfalse\n\t\tend\n\tend", "def shares_available_for_purchase?\n if Stock.all.find_by(id: trade.stock_id).shares_available < trade.num_shares\n return false\n else\n return true\n end\n end", "def available?\n self.in_stock? || self.backorderable?\n end", "def can_supply?\n if has_variants?\n variants.any?(&:in_stock?)\n else\n master.in_stock?\n end\n end", "def can_supply?(required)\n total_on_hand >= required || backorderable?\n end", "def funds_available?\n if self.num_shares * Stock.find(self.stock_id).quote > Account.find_by(investor_id: self.investor_id).balance\n self.status = \"canceled\"\n self.bought_sold = \"Funds to execute trade were unavailable.\"\n puts \"Your account does not have the funds available to execute this trade.\"\n return false\n else\n true\n end\n end", "def available?\n in_stock? || backorderable?\n end", "def enough_stock?\n\t\tif self.product.stock == 0\n\t\t\treturn false\n\t\telse\n\t\t\treturn self.product_quantity <= available_stock\n\t\tend\n\t\t#self.product_quantity <= self.product.stock\n\tend", "def source_account_has_enough_balance?\n return true if @source_account.blank?\n\n transfer_amount = transaction_params[:amount]\n final_balance = @source_account.current_balance - transfer_amount\n final_balance >= 0\n end", "def in_stock?\n Spree::Config[:track_inventory_levels] ? on_hand > 0 : true\n end", "def is_available?\n stock > 0\n end", "def transfer_success?(source)\n return source.successful? if source.respond_to?(:successful?)\n source.valid? && source.persisted?\n end", "def applicable?\n adjustment_source && adjustment_source.eligible?(order) && super\n end", "def in_stock?\n if @stock <= 0\n false\n else\n true\n end\n end", "def tranch_available?\n current_tranch_open? and previous_tranch_all_sold_out_or_operated?\n end", "def can_deliver?(cur, amount)\n amount > 0.01 && amount <= available_balance(cur)\n end", "def transferable?\n !bundle? && !part_of_bundle? && unreserved? or\n bundle? && bundled_vouchers.all?(&:unreserved?)\n end", "def transfer\n return false if @source_account_id == @destination_account_id\n return false unless @amount > 0\n return false unless Account.exists?(@source_account_id) &&\n Account.exists?(@destination_account_id)\n return false if AccountService.new(@source_account_id).balance < @amount\n\n create_traders\n end", "def can_sell?\n inventory.any? { |inv| inv.price > 0 }\n end", "def installed?\n source_api.number_of_units.positive? && positive_availability?\n end", "def can_cash?\n if self.tier && self.tier.piggy_bank\n if rate = find_bonus_rate\n # transfer cents\n if rate.cents.to_i > 0 && rate.funding_source.piggy_bank &&\n cashed_events_limit_not_reached?(rate.max_events_per_month)\n result = rate.funding_source.piggy_bank.transfer(self.receiver.piggy_bank, \n Money.new(rate.cents, rate.default_currency))\n if result.success?\n self.description = result.message \n return true\n end\n end\n end\n end\n false\n end", "def deliverable?\n (!current_stage.nil? &&\n current_stage.stage.eql?('acceptance') &&\n current_stage.status.eql?('passed') &&\n !AutomateSoup.url.nil? &&\n !AutomateSoup.credentials.nil? &&\n !links.nil? &&\n !links['deliver'].nil? &&\n !links['deliver']['href'].nil?)\n end", "def transfer_given?\n params.has_key?(:is_transfer) || params.has_key?(:transfer_buddy)\n end", "def qualifiable?\n !source.nil?\n end", "def newly_craftable?(item)\n !item.nil? && item.synthesis_level == @level\n end", "def has_editorial_or_stock_for_sale\n return false if self.requests.length == 0\n self.requests.each do |r|\n return false if r.state == \"denied\"\n end\n true\n end", "def in_stock?(quantity = 1)\n if !self.manage_stock?\n return true\n elsif self.is_in_stock && ((quantity.to_f <= self.quantity.to_f || quantity.to_f == 0) || self.backorders > 0)\n return true\n else\n return false\n end\n end", "def any_copies_available?\n @copies.each do |copy|\n return true if copy.status == 'Available'\n end\n false\n end", "def in_stock?\n self.default_variant ? self.default_variant.in_stock? : (stock_control? ? stock > 0 : true)\n end", "def in_stock?()\n if self.stock >0\n return true\n else\n return false\n end\n end", "def can_add_stock?(ticker_symbol)\n under_stock_limit? && !stock_already_added?(ticker_symbol)\n end", "def is_applicable?\n if self.source.nil?\n # check the source of the item\n self.source.downcase != \"hsb\"\n end \n end", "def can_add_stock?(ticker_symbol)\n under_stock_limit? && !stock_already_added?(ticker_symbol)\n end", "def enabled?\n return false if !@remote_url.nil? &&\n Fizzy::Sync.others(self).any? { |e|\n @remote_url.to_s.start_with?(\"#{e.name}:\")\n }\n return true if default? && Fizzy::Sync.others(self).\n map { |e| e.new(@local_dir_path, @remote_url) }.\n all? { |e| !e.enabled? }\n end", "def in_stock?\n default_variant ? default_variant.in_stock? : (stock_control? ? stock > 0 : true)\n end", "def can_add_stock?(ticker_symbol)\n\t\tunder_stock_limit? && !stock_already_added?(ticker_symbol)\n\tend", "def in_stock?\n stock\n end", "def has_available_payment_source?\n stripe_customer.sources.count > 0\n end", "def isLegal?(source,destination)\n if source == 1\n if @@tower_1==nil \n return false \n end\n if destination == 2 \n if @@tower_2.empty? || @@tower_1.last < @@tower_2.last\n return true\n end\n end\n if destination == 3 \n if @@tower_3.empty? || @@tower_1.last < @@tower_3.last\n return true\n end\n end\n \n elsif source == 2\n if @@tower_2.empty?\n return false\n end\n if destination == 1 \n if @@tower_1.empty? || @@tower_2.last < @@tower_1.last\n return true\n end\n end\n if destination == 3 \n if @@tower_3.empty? || @@tower_2.last < @@tower_3.last\n return true\n end\n end\n \n \n elsif source == 3\n if @@tower_3.empty?\n return false\n end\n if destination == 1 \n if @@tower_1.empty? || @@tower_3.last < @@tower_1.last\n return true\n end\n end\n if destination == 2 \n if @@tower_2.empty? || @@tower_3.last < @@tower_2.last\n return true\n end\n end\n \n else \n return false\n end\n \n end", "def positive_availability?\n target_api.availability.positive?\n end", "def is_available\n\t\tself.stock_qty > 0\n\tend", "def can_buy?(item)\n item.buyable_by?(self)\n end", "def can_buy?(item)\r\n item.buyable_by?(self)\r\n end", "def valid_fc_target?\n dell_server? &&\n !brownfield? &&\n has_related_storage? &&\n related_storage_volumes.map(&:fc?).all?\n end", "def eligible?()\n @networks.include? @remote_network\n end", "def ready_to_exchange?\n self.balance >= self.promotion.points_to_exchange\n end", "def locally_available?(request)\n UmlautBorrowDirect.locally_available? request\n end", "def track_shipments?\n !store.disable_shipment_transfers?\n end", "def in_stock?\n \treturn @stock > 0 ? true : false\n end", "def shippable?\n can_supply? && !(on_hold? || collection?)\n end", "def can_buy_depot_train?(entity)\n entity.cash >= @depot.upcoming.first.price\n end", "def stock_values\n if self.stock && self.stock_warning_level && self.stock <= self.stock_warning_level\n errors.add(:sku, \"stock warning level value must not be below your stock count.\")\n return false\n end\n end", "def redeemable?\n [AVAILABLE, EXPIRED].include?(status) and started? and delay_passed?\n end", "def must_buy_train?(entity)\n must_buy_power?(entity)\n end", "def wants_to_subscribe?\n source_is_ffcrm? && has_list?\n end", "def available?\n self.active == true and self.quantity_available > 0\n end", "def gta_travel_support_single_rate_multiplier?\n if is_channel_gta_travel? and self.gta_travel_rate_basis <= 1 and self.gta_travel_max_occupancy >= 1\n return true\n else\n false\n end\n end", "def check_sources\n if Source.count == 0\n redirect_to :controller=>\"admin/sources\" # unless current controller == sources\n end\n end", "def available\n # inventory_management.blank? ||\n # inventory_policy == INVENTORY_POLICY_ALLOW ||\n # inventory_quantity(??? check VariantDrop) > 0\n # call Variant.available, because ProductDrop calls Variant.available\n # both should always call the same method\n # (either in Variant or in VariantDrop)\n @object.available\n end", "def can_be_synced_to_remote?\n if is_drupal?\n !(lapsed? or applied?) and club.billing_enable\n elsif is_spree?\n !(applied?) and club.billing_enable\n end\n end", "def integrity_check\n start_values = condition.start_values\n generations.each do |g|\n # FIXME -- use the registered fitness function\n if IterativeLearning::FunctionLearning.sum_of_error(g.start_values, start_values) != 0\n return false\n end\n start_values = g.best_task_response\n end\n return true\n end", "def check_by_supplier\n _r = false\n c = self.supplier.max_orders_count.blank? ? 0 : self.supplier.max_orders_count\n s = self.supplier.max_orders_sum.blank? ? 0 : self.supplier.max_orders_sum\n _r = (c > 0 && (self.quantity > c)) || (s > 0 && (self.taxable > s))\n end", "def stock_of?(commodity)\n stock_of(commodity).positive?\n end", "def in_stock?\n \t\tif stock > 0 \n \t\t\tTRUE\n \t\telse \n \t\t\tFALSE \n \t\tend\n \tend", "def handle_stock_counts?\n current_shipment.order.completed? && current_stock_location != desired_stock_location\n end", "def isValidMoveAvailable()\n isValidMoveAvailableForDisc(@disc)\n end", "def checkout_allowed?\n line_items.count > 0\n end", "def permited_source?(ip)\n # get permitted subnet \n config = BeEF::Core::Configuration.instance\n permitted_ui_subnet = config.get('beef.restrictions.permitted_ui_subnet')\n target_network = IPAddr.new(permitted_ui_subnet)\n \n # test if ip within subnet\n return target_network.include?(ip)\n end", "def applySupport(x)\n if ((x.minus_state_set.length > 0 || x.plus_state_set.length > 0) && \n x.base_damage == 0 && \n x.hp_recovery == 0 && x.hp_recovery_rate == 0 &&\n x.mp_recovery == 0 && x.mp_recovery_rate == 0) == @value\n return true\n else\n return false\n end\n end", "def recipient_required?\n transfer_type?\n end", "def pending_financials?\n shop && shop.pending_products.any?\n end", "def valid_to_process?\n #TODO\n # available money to transfer\n persisted? ? true : false\n end", "def is_available?\n return self.available_inventory > 0\n end", "def checkout_allowed?\n order_items.count > 0\n end", "def check_buyable\n raise PermissionDeniedError, \"出品したアイテムはサポートできません\" if @item.owner?(current_user)\n end", "def can_exchange_any?(entity)\n return false unless entity.player?\n\n entity.companies.each do |company|\n return true if %w[MC VR SB].include?(company.id)\n\n next unless company.id == 'IB'\n\n # Only true if there are shares available from an ipo'd company\n # that isn't PEIR, Mainline or Shortline\n corps = @game.corporations.select(&:ipoed).reject do |c|\n @game.mainline == c or @game.shortline == c or @game.peir == c\n end\n\n corps.each do |c|\n return true if @game.share_pool.shares_by_corporation[c].size.positive?\n end\n end\n\n false\n end", "def products_in_stock?(products)\n in_stock = false\n products.each_value {|p| in_stock = true if product_in_stock?(p) }\n return in_stock\n end", "def safe?(lbd, condition)\n # if it's a draining operation\n # check for safety\n if condition == :draining\n # this inverts the result of the boolean statement\n # if these conditions are met, we are *NOT* safe\n # if there is onle one mode enabled: NOT SAFE\n # if any node is disabled/draining: NOT SAFE\n return !(lbd[:nodes_enabled] == 1 || lbd[:nodes_enabled] != lbd[:nodes].size)\n end\n\n # otherwise, it's safe\n true\n end", "def require_self_enabled_cross_selling\n if @entity.try(:self_enabled_cross_sell) != true\n redirect_to [:admin, @entity, :cross_selling_lists]\n end\n end", "def shippable?\n status != \"shipped\" && products.count >= 1\n end", "def have_enough_items_to_trade?\n fetch_inventory\n\n is_valid = true\n\n max_avaliable_quantity = @offer[:records].map {|x|\n [x.item_name.to_sym ,x.quantity]}.to_h\n\n @offer[:items].each do |item, quantity|\n if quantity > max_avaliable_quantity[item.to_sym]\n is_valid = false\n add_error(:offer, :items, {item.to_sym =>\n \"Not enough items, only #{max_avaliable_quantity[item.to_sym]} available\"})\n end\n end\n\n max_avaliable_quantity = @for[:records].map {|x|\n [x.item_name.to_sym ,x.quantity]}.to_h\n\n @for[:items].each do |item, quantity|\n if quantity > max_avaliable_quantity[item.to_sym]\n is_valid = false\n add_error(:for, :items, {item.to_sym =>\n \"Not enough items, only #{max_avaliable_quantity[item.to_sym]} available\"})\n end\n end\n is_valid\n end", "def eligible?\n return false if Flipflop.enabled?(:disable_ills) \n # If it has a disqualifying status, you can't ILL it. If it doesn't, you're\n # good to go.\n [\n available_here_now?,\n @status == 'Received',\n ineligible_statuses.include?(@z30status)\n ].none?\n end", "def tour_available?\n self.tour_credits > 0 || self.tours_unlimited\n end", "def has_no_source?\n sources.count == 0\n end", "def can_submit?\n # First check the state machine to see if it is Ok to submit based on the\n # current state\n b = super()\n if b\n # Now check that the CP has funding\n b = false unless total_cost > 0\n #b = false unless funding_difference <= 0\n end\n b\n end", "def requestable?\n # Sometimes a PUBFI002 error code isn't really an error,\n # but just means not available. \n if response_hash && response_hash[\"Error\"] && (response_hash[\"Error\"][\"ErrorNumber\"] == \"PUBFI002\")\n return false\n end\n\n # Items that are available locally, and thus not requestable via BD, can\n # only be found by looking at the RequestMessage, bah \n if locally_available?\n return false\n end\n\n return response_hash[\"Available\"].to_s == \"true\"\n end", "def can_buy_any_from_market?(entity)\n @game.share_pool.shares.group_by(&:corporation).each do |corporation, shares|\n next unless corporation.ipoed\n return true if can_buy_shares?(entity, shares)\n end\n\n false\n end", "def available?\n restrictions.all? {|restriction| restriction.permitted?}\n end", "def allowed?(required_level, actual_levels)\n requested_array = Access::Validate.levels([required_level])\n actual_array = Access::Validate.levels([actual_levels])\n\n # short circuit checking nils\n return false if requested_array.blank? || requested_array.compact.blank? ||\n actual_array.blank? || actual_array.compact.blank?\n\n actual_highest = Access::Core.highest(actual_array)\n actual_equal_or_lower = Access::Core.equal_or_lower(actual_highest)\n requested_highest = Access::Core.highest(requested_array)\n\n actual_equal_or_lower.include?(requested_highest)\n end", "def is_package_shippable? package\n return true\n\n # check for weight limits on service\n # country_weight_error? package\n end", "def is_transfer?\n case params[:is_transfer]\n when '1', 't', 'true', 'on'\n return true\n when '0', 'f', 'false', 'off'\n return false\n else\n return (not transfer_buddy.nil?)\n end\n end", "def canIBuyLevels(nLevels)\n @level + nLevels < 10\n end", "def is_valid_data_source?\n is_valid = false\n if self.current_data_source != DataSourceNone\n if self.inherited_data_source == DataSourceNone # top level data source\n section_contexts = self.current_contexts\n if section_contexts.length == 1\n available_data_sources = ContextDataSourceMap[section_contexts.first]\n if available_data_sources.present?\n is_valid = ( available_data_sources.include? self.current_data_source )\n end\n else\n #TODO validate data source for more than on section contexts\n is_valid = true\n end\n else #sub level data source\n #Rails.logger.debug \"self.inherited_data_source=#{self.inherited_data_source}\"\n is_valid = ( DataSourceChainMap[self.inherited_data_source].include? self.current_data_source)\n end\n else\n is_valid = true\n end\n#Rails.logger.debug \"is_valid = #{is_valid}\"\n is_valid\n end", "def any_sold?\r\n self.is_a?(Listing) && invoices.exists?(status: 'paid')\r\n end", "def allows?\n !(coupable_countries - restricted_countries).empty?\n end", "def backorderable?\n stock_items.any?(&:backorderable)\n end" ]
[ "0.69510263", "0.60551435", "0.5973509", "0.59410405", "0.58941346", "0.5849367", "0.5816457", "0.5791938", "0.56999266", "0.5693581", "0.56742793", "0.56690663", "0.56568885", "0.5652399", "0.56424236", "0.5602203", "0.55789673", "0.5552804", "0.5547144", "0.55413353", "0.5537608", "0.55205506", "0.5423071", "0.5352068", "0.53511876", "0.5349688", "0.53366816", "0.53062594", "0.5305855", "0.53003436", "0.5292014", "0.529195", "0.5282095", "0.5280387", "0.5272108", "0.52575177", "0.52516246", "0.5240546", "0.52362317", "0.52239656", "0.52057976", "0.5200627", "0.5200213", "0.5198791", "0.51923835", "0.5190903", "0.5186534", "0.5178151", "0.5161855", "0.5150859", "0.5123432", "0.5085988", "0.50846195", "0.5084519", "0.50566417", "0.504437", "0.50399685", "0.5015299", "0.5012592", "0.5006422", "0.5005019", "0.4996944", "0.49939078", "0.49937114", "0.49887028", "0.49863628", "0.49845868", "0.49794582", "0.49790096", "0.49745688", "0.49714398", "0.49645743", "0.49644524", "0.49532312", "0.4950761", "0.49489138", "0.49431378", "0.49410108", "0.49402738", "0.49390295", "0.4933398", "0.492949", "0.49251625", "0.49248827", "0.49147815", "0.49082267", "0.49043047", "0.48986948", "0.48932403", "0.4891042", "0.4890382", "0.48794624", "0.4863332", "0.48608357", "0.48600957", "0.48595783", "0.4858145", "0.48559055", "0.48479852", "0.48469657" ]
0.73438925
0
Loads the given order items into the transfer. To keep track of inventory during the load, matching inventory items are preloaded and updated by each load_item! call.
def load!(order_items) transaction do products = order_items.map(&:product) stock = source.inventory_items.for(products) order_items.each do |order_item| load_item!(order_item, stock) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load!\n transfer = find_or_create_transfer\n transfer.load!(order.items_waiting)\n end", "def load_item_from_stock(order_item, stock_items)\n amount = order_item.waiting\n stock_items.each do |item|\n all = item.available\n next if all <= 0\n\n if amount <= all\n # This inventory item satisfies the amount, we're done.\n item.reserved += amount\n return create_item_from(order_item, item.code, item.expires_at, amount)\n else\n # Load all of this item and continue with the remaining amount.\n item.reserved += all\n create_item_from(order_item, item.code, item.expires_at, all)\n amount -= all\n end\n end\n end", "def set_order_items\n @order_items = @order.order_items\n end", "def load_items\n items.map { |serialized_item| item_from_attributes(serialized_item) }.compact\n end", "def load_item_list\n @item_quantity = []\n get_list_item\n get_definitive_list_price\n check_if_shop_empty\n @index = 0\n @last_index = @list_item.size - 1\n end", "def load_item_from_infinite_stock(order_item)\n create_item_from(order_item, order_item.order.number)\n true\n end", "def order_items(order, main, sides, extras, wallet, spent)\n\t# set looping value until order complete\n\tcontinue = true\n\n\t# get one item from main menu\n\titem = get_item(\"main\", main, wallet, spent)\n\tif item\n\t\torder.push item\n\t\tspent = spent + order.last.price\n\t\tprint_item(item, spent)\n\tend\n\n\t# get one item from side menu\n\titem = get_item(\"side\", sides, wallet, spent)\n\tif item\n\t\torder.push item\n\t\tspent = spent + order.last.price\n\t\tprint_item(item, spent)\n\tend\n\n\t# get another item from side menu\n\titem = get_item(\"side\", sides, wallet, spent)\n\tif item\n\t\torder.push item\n\t\tspent = spent + order.last.price\n\t\tprint_item(item, spent)\n\tend\n\n\t# get extras until user says they're done\n\twhile continue\n\t\tputs \"Do you want to order extra items? Y or N\"\n\t\tresponse = gets.strip\n\t\tcase response.downcase\n\t\twhen 'y', 'yes'\n\t\t\titem = get_item(\"extra\", extras, wallet, spent)\n\t\t\tif item\n\t\t\t\torder.push item\n\t\t\t\tspent = spent + order.last.price\n\t\t\t\tprint_item(item, spent)\n\t\t\telse\n\t\t\t\tcontinue = false\n\t\t\tend\n\t\twhen 'n', 'no'\n\t\t\tcontinue = false\n\t\telse\n\t\t\tputs \"INVALID INPUT.\\n\\n\"\n\t\tend\n\tend\n\n\t# return array with order which is an array of instantiations of class lunch item\n\t# and amount spent\n\t[order, spent]\nend", "def load_item!(order_item, stock)\n if !order_item.product.tracked_stock? || source.enable_gateway?\n load_item_from_infinite_stock(order_item) && return\n end\n stock_items = stock.select { |item| item.product == order_item.product }\n return false if stock_items.none?\n\n if order_item.lot_code.present?\n load_item_by_lot_code(order_item, stock_items)\n else\n load_item_from_stock(order_item, stock_items)\n end\n end", "def items\n @items ||= data[\"items\"].map { |item| OrderItem.new(item) }\n end", "def update_items\n @existing_items = []\n @order.items.each { |i| @existing_items << i.id }\n\n # detail and reproduction_pages will come in as attributes of items, but they actually belong to the item_order\n # so look for those, then add them to the correct record in @item_orders\n\n @item_orders.each do |item_order|\n # add item to order\n if !@existing_items.include?(item_order['item_id'].to_i)\n item_order_record = @order.item_orders.create!(item_id: item_order['item_id'], archivesspace_uri: item_order['archivesspace_uri'], user_id: current_user.id, active: true)\n else\n item_order_record = @order.item_orders.where(item_id: item_order['item_id']).first\n item_order_record.update_attributes(archivesspace_uri: item_order['archivesspace_uri'])\n @order.reload\n # delete id from @existing_items array to track associations to be deleted\n @existing_items.delete(item_order['item_id'])\n end\n\n if item_order['reproduction_spec']\n create_or_update_reproduction_spec(item_order_record.id, item_order['reproduction_spec'])\n end\n\n # handle fees\n if @order_sub_type_name == 'reproduction_fee'\n if item_order['order_fee']\n create_or_update_order_fee(item_order_record.id, 'ItemOrder', item_order['order_fee'])\n end\n else\n # delete any existing fee for this item_order if it exists\n OrderFee.where(record_id: item_order_record.id,\n record_type: 'ItemOrder').each { |f| f.destroy! }\n end\n end\n\n @existing_items.each do |item_id|\n @order.item_orders.where(item_id: item_id).each { |io| io.destroy! }\n end\n end", "def load_items\n @items = []\n data_sources.each do |ds|\n items_in_ds = ds.items\n items_in_ds.each { |i| i.identifier = File.join(ds.items_root, i.identifier) }\n @items += items_in_ds\n end\n\n @items_loaded = true\n end", "def create_order_items(order)\n raise NoOrderItemsGiven unless valid_order_items?\n\n Array(param(:order_items)).each do |order_item_params|\n order_item = build_order_item(order_item_params)\n order_item.save!\n end\n end", "def populate\n @order = current_order(create_order_if_necessary: true)\n variant = Spree::Variant.find(params[:variant_id])\n content = params[:content]\n content_file = params[:content_file]\n cover = params[:cover]\n deliver_on = params[:deliver_on]\n address_ids = get_address_ids\n quantity = address_ids.count\n\n @order.errors.add(:base, \"Select an address\") if address_ids.empty?\n if variant.product.property('cover') && !cover\n @order.errors.add(:base, \"Attach a cover image\")\n end\n\n # 2,147,483,647 is crazy. See issue https://github.com/spree/spree/issues/2695.\n if quantity > 2_147_483_646\n @order.errors.add(:base, \"Too many addresses\")\n end\n\n unless @order.errors.any?\n begin\n @line_item = @order.contents.add(variant, quantity, content, content_file, cover, deliver_on, address_ids)\n lob_error = lob_test(@line_item)\n if lob_error\n @order.errors.add(:base, lob_error)\n @order.remove_item(@line_item)\n end\n rescue ActiveRecord::RecordInvalid => e\n @order.errors.add(:base, e.record.errors.full_messages.join(\", \"))\n end\n end\n\n respond_with(@order) do |format|\n format.html do\n if @order.errors.any?\n flash[:error] = @order.errors.full_messages.join(\", \")\n redirect_to product_path(variant.product)\n return\n else\n redirect_to cart_path\n end\n end\n end\n end", "def set_orders\n @load = Load.find(params[:load_id])\n end", "def load_item_by_lot_code(order_item, stock_items)\n item = stock_items.find { |item| order_item.lot_code == item.code }\n\n # If the order item has a serial number, try lot code part only.\n if item.nil? && order_item.lot_code['-']\n lot_code_part = order_item.lot_code.split('-').first\n item = stock_items.find { |item| lot_code_part == item.code }\n end\n\n # If a match was found, load the item and return. If a partial\n # match set a lot code part above, use that, or provide nil\n # to use the code on the order item.\n if item.present?\n item.reserved += order_item.amount\n return create_item_from(order_item, lot_code_part, item.expires_at)\n end\n\n false # Failed to load the item.\n end", "def _line_items(order)\n params.require(:orders).each do |variant_id, info|\n count = info.require(:count)\n price = info.require(:price)\n variant = Variant.find variant_id\n LineItem.create(variant_id: variant_id, order: order, quantity: count,\n price: price).ready_to_pay!\n end\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 load_inventory(first)\n first ? setup_inventory : restore_inventory\n log(RuneRb::GLOBAL[:COLOR].green(\"Loaded Inventory for #{RuneRb::GLOBAL[:COLOR].yellow(@profile.name)}\")) if RuneRb::GLOBAL[:DEBUG]\n end", "def show\n @order = Order.includes(:items).find(params[:id])\n end", "def load_inv(object, game_objects)\n\n if not object.respond_to? :inventory\n #log \"#{object} has no inventory\"\n return\n elsif object.inventory.nil? #I can't think of when this might happen\n object.inventory = Inventory.new\n #log \"#{object} had a nil inventory\"\n return\n elsif object.inventory.empty?\n object.inventory = Inventory.new(object.inventory.capacity)\n #log \"#{object} has nothing in its inventory\"\n return\n end\n\n inv = Inventory.new(object.inventory.capacity)\n\n object.inventory.each do |inv_obj|\n if game_objects.include? inv_obj[0]\n obj = game_objects[inv_obj[0]]\n pos = inv_obj[1]\n unless obj.is_a? Player\n inv.add(obj, pos)\n obj.container = object.goid\n end\n #log \"Added #{obj} to #{object}\"\n else\n log \"Don't have #{inv_obj} loaded...what does that mean? (Probably a Player)\", Logger::Medium\n end\n end\n\n object.inventory = inv\n end", "def order \n @items = Item.all\n @item = Item.find(params[:id])\n end", "def set_order_item\n @order_item = @order.order_items.find(params[:id])\n end", "def order_items_read(id, opts = {})\n data, _status_code, _headers = order_items_read_with_http_info(id, opts)\n data\n end", "def set_menu_items_order\n @menu_items_order = MenuItemsOrder.find(params[:id])\n end", "def add_items_from_cart(cart)\n cart.order_items.all.each do |item|\n #self refers to the individual order\n self.order_items.new(product: item.product, quantity: item.quantity)\n end\n end", "def load_order!\n @order = current_user.orders.find params[:id]\n # @order = @cookbook.get_active_reorder(params[:id]) if @cookbook.is_owner? current_user\n end", "def set_ordered_item\n @ordered_item = OrderedItem.find(params[:id])\n end", "def set_ordered_item\n @ordered_item = OrderedItem.find(params[:id])\n end", "def update_inventory\n self.order_items.each { |item| item.variant.add_pending_to_customer }\n end", "def populate\n @order = current_order(session)\n variant_id = params[:variant_id]\n \n new_line_item = Breeze::Commerce::LineItem.new(:variant_id => variant_id, :quantity => params[:quantity] || 1)\n existing_line_item = @order.line_items.unarchived.where(:variant_id => variant_id).first \n if existing_line_item\n existing_line_item.quantity += new_line_item.quantity\n existing_line_item.save\n else\n @order.line_items << new_line_item\n end\n\n @order.save\n end", "def load_items\n return @items unless YAML.load_file(file)\n\n YAML.load_file(file).each do |key, texts|\n texts.each do |text|\n @items << Item.new(\"#{text} #{key}\") if key.to_s != '@done'\n end\n end\n @items\n end", "def load_items\n YAML.load_file(file).each do |key, texts|\n texts.each do |text|\n if key.to_s == @options[:filter] || @options[:filter].nil?\n @items << Item.new(\"#{text} #{key}\") if key.to_s != '@done'\n end\n end\n end\n @items\n end", "def set_ordereditem\n @ordereditem = Ordereditem.find(params[:id])\n end", "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 set_order\n @item = Order.find(params[:id])\n end", "def update\n @order_item.update_attributes(order_item_params)\n @order_items = @order.order_items\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def save_local_data_to_order_and_items\n self.price = subtotal - self.used_credit.to_f\n self.discount = discount_subtotal + self.used_credit.to_f\n self.size = quantity\n\n line_items.each do |i|\n i.price = i.sell_price\n i.discount_rate = i.discount\n end\n end", "def update\n # puts \"params: #{params.to_hash}\"\n return_order_items = JSON.parse(params[:order][:items]) \n\n # puts \"Params: #{return_order_items}\"\n\n @order = Order.find(params[:id])\n\n\n ActiveRecord::Base.transaction do\n return_order_items.each do |item|\n if params[:order].has_key?(:supplier) \n @ordered_item = Item.find_by_id(item[\"id\"].to_i)\n @ordered_item.decrement!(:remaining_quantity, item[\"quantity\"].to_i)\n else\n @ordered_item = Item.find_by_id(item[\"id\"].to_i)\n @ordered_item.increment!(:remaining_quantity, item[\"quantity\"].to_i)\n end\n end\n\n @order.return = true\n if @order.save\n @current_user = current_user\n redirect_to :root, notice: 'Return Order was successfully created.'\n else\n render :new\n end\n end\n\n end", "def add_items_to_order\n params[:order][:menu_item_ids]\n \n end", "def place_order!()\n if has_order_items?\n order_template = order_object\n order_template = yield order_object if block_given?\n\n @virtual_server.softlayer_client[:Product_Order].placeOrder(order_template)\n end\n end", "def load_order\n\t\tparams[:order_param] ||= session[:order_param]\n\t\tsession[:order_param] = params[:order_param]\n\tend", "def order\n return nil if return_items.blank?\n return_items.first.inventory_unit.order\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def add_basket_items(items)\n items.each do |i|\n order_lines.build(\n product_id: i.product.id,\n product_sku: i.product.sku,\n product_name: i.product.name,\n product_rrp: i.product.rrp,\n product_price: i.product.price_ex_vat(i.quantity),\n product_weight: i.product.weight,\n vat_amount: i.product.vat_amount(i.quantity) * i.quantity,\n quantity: i.quantity,\n feature_descriptions: i.feature_descriptions\n )\n end\n end", "def load(units)\n raise GameLogicError.new(\n \"You did not give any units to load!\"\n ) if units.blank?\n\n transporter_location = location\n units.each do |unit|\n raise GameLogicError.new(\n \"Unit #{unit} must be in same location as #{self}!\"\n ) unless unit.location == transporter_location\n\n raise GameLogicError.new(\n \"Cannot load unit #{unit} that is still upgrading!\"\n ) if unit.upgrading?\n end\n \n taken_volume = self.class.calculate_volume(units)\n\n raise GameLogicError.new(\n \"Not enough storage (#{stored}/#{storage\n }) to load all requested units into #{self} (volume #{taken_volume})!\"\n ) if taken_volume > (storage - stored)\n\n self.stored += taken_volume\n save!\n\n update_transporter_units(units, location_point)\n end", "def import_catalog_items 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_import_catalog_items_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def add_order(order_item, qty, order)\r\n if order_item == \"latte\"\r\n item = Item.new(\"latte\", $latte_cost, $latte_price)\r\n elsif order_item == \"tea\"\r\n item = Item.new(\"tea\", $tea_cost, $tea_price)\r\n elsif order_item == \"scones\"\r\n item = Item.new(\"scones\", $scones_cost, $scones_price)\r\n end\r\n order.add_item(item, qty)\r\nend", "def place_order\n @order = Order.new(order_params)\n @basket.line_items.map do |line_item|\n @order.line_items << line_item\n item.basket_id = nil\n\n dish = Dish.find(line_item.dish_id)\n dish.inventory -= line_item.quantity\n dish.save\n end\n @order.save\n @basket.destroy\n render Dish.all, status: :ok\n end", "def save_items_data\n @parsed[\"order_items\"].each do |i| \n external_code = i['item']['id']\n item = Item.find_or_create_by(external_code: external_code)\n item.order_id = @order.id\n item.external_code = i['item']['id']\n item.name = i['item']['title']\n item.price = i['unit_price']\n item.quantity = i['quantity']\n item.total = i['full_unit_price']\n @subItems = []\n item.save\n end\n end", "def test_build_line_items_from_hash\n # Create a new order and put just one line item.\n setup_new_order()\n @o.order_line_items << @li\n \n # Now try to feed it with others.\n @o.line_items = {\n items(:red_lightsaber).id => {'quantity' => 2},\n items(:towel).id => {'quantity' => 1},\n items(:blue_lightsaber).id => {'quantity' => \"\"}\n }\n \n assert_equal @o.items.size, 2\n end", "def reload(*_)\n super.tap do\n @cart_items = nil\n @incomplete_order = nil\n end\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\n # 2,147,483,647 is crazy. See issue #2695.\n if quantity.between?(1, 2_147_483_647)\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\n if error\n flash[:error] = error\n redirect_back_or_default(spree.root_path)\n else\n respond_with(order) do |format|\n format.html { redirect_to cart_path }\n end\n end\n end", "def import_inventory_file()\n @worksheet_products.each { |row|\n if(@inventory_row = build_inventory_hash(row))\n import_inventory()\n end\n }\n end", "def fetch_from_inventory(an_order)\n order = extract_code_qty(an_order)\n return Inventory.fetch_an_item(order[:code])\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 original_price = params[:price].to_i\n sku = params[:sku]\n direccion = params[:direccion]\n code = params[:code]\n price = getPrice(code, original_price)\n\n # 2,147,483,647 is crazy. See issue #2695.\n if quantity.between?(1, 2_147_483_647)\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\n if direccion.empty?\n url = \"http://integra6.ing.puc.cl/tienda/noAddress\"\n redirect_to url\n else\n if (quantity>Bodega.getProductStock(sku))\n url = \"http://integra6.ing.puc.cl/tienda/stock\"\n redirect_to url\n else\n @id_boleta = Banco.crearBoleta(quantity*price, direccion)\n Bodega.despacharPedido(@id_boleta, sku, quantity, price, direccion)\n urlOk='http://integra6.ing.puc.cl/tienda/success/'<<@id_boleta\n url = $heroku_url+ \"web/pagoenlinea?callbackUrl=\"+urlOk+\"&cancelUrl=http://integra6.ing.puc.cl/tienda/error&boletaId=\"+@id_boleta\n redirect_to url\n end\n end\n end", "def items\n load\n @data\n end", "def add_item_to_order(id)\n return if @items[id] <= 0\n\n socket = GameData::Item[id].socket\n get_order(socket) << id unless get_order(socket).include?(id)\n end", "def update\n @order = current_order\n if @order.may_add?\n @order_item = @order.order_items.find(params[:id])\n @order_item.update_attributes(order_item_params)\n @order_items = @order.order_items\n end\n end", "def load_by_ids(ids, context)\n ids.map { |id| load_by_id(id, context) }\n end", "def populate\n @order = current_order(true)\n\n if params[:options].present? && params[:variants]\n\n params[:variants].each do |variant_id, quantity|\n if variant = Spree::Variant.find(variant_id)\n quantity = quantity.to_i\n\n option_values = Spree::OptionValue.find(params[:options].values.map(&:to_i))\n\n line_item = @order.add_variant(variant, quantity, option_values)\n\n line_item.customizations = params[:customizations] if params[:customizations]\n end\n end\n\n params.delete(:variants) # prevent populate_orig from adding again\n end\n\n populate_without_spree_myriad_options\n end", "def processItemsOrder\n @id = params[:itemID]\n @description = params[:description]\n @price = params[:price]\n @award = params[:award]\n @item = Item.find_by(id: @id)\n \n if @item.save\n head 204\n else\n # test\n render json: @item.to_json, status: 400\n # originally\n #head 400\n end\n end", "def load_by_ids ids\n items = @api.fetch_multiple_items ids\n create_by_api_items(items)\n end", "def organize_items\n # just hash actor ids -> item containers -> item ids and store it\n # in the tactical battle manager. When bringing up this scene, display\n # previously organized items to the player by consulting the hash.\n # Then when a tactical unit is loaded all it just looks at the hash\n # in the TBM module and loads its items from there. \n # Make a note of this, in addition to the equipment problem when detailing \n # why no more than one Game_Actor should be able to be produced as a \n # produceable unite\n \n @unit_list_swap_items.show\n @unit_list_swap_items.select(0)\n deactivate_all_but(@unit_list_swap_items)\n @unit_list_swap_items.activate\n @unit_list_swap_items.refresh\n @basic_text_win.show\n @place_coms.hide\n end", "def checkout \n \t@order_items = current_order.order_items\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 # 2,147,483,647 is crazy. See issue #2695.\n if quantity.between?(1, 2_147_483_647)\n begin\n order.contents.add(variant, quantity, options, ad_hoc_option_value_ids, product_customizations)\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\n if error\n flash[:error] = error\n redirect_back_or_default(spree.root_path)\n else\n respond_with(order) do |format|\n format.html { redirect_to cart_path }\n end\n end\n end", "def order_params\n params.require(:order).permit(:amount, :user_id, :item_ids => [])\n end", "def menu_items_order_params\n params.require(:menu_items_order).permit(:menu_item_id, :order_id)\n end", "def assign_order_item_values\n # Copies prices from purchasable into order items\n present_order_items.each { |oi| oi.assign_purchasable_attributes }\n end", "def reload # :nodoc:\n @ordered_objects = nil\n ordered_objects\n super\n end", "def serve_order(t_order)\n temp_inventory = deep_copy(@inventory)\n beverages[t_order].each do |key, value|\n err_msg = \"#{t_order} cannot be prepared because #{key}\"\n raise \"#{err_msg} is not available\" if temp_inventory[key].nil?\n raise \"#{err_msg} is not sufficient\" if temp_inventory[key] < value\n\n temp_inventory[key] -= value\n end\n @inventory = temp_inventory\n \"#{t_order} is prepared\"\n end", "def duplicate_items_from(items)\n transaction do\n items.each do |item|\n transfer_items << item.dup\n end\n end\n end", "def items\n if params[:update] == \"true\"\n ## Invariant: we are about to update all of the items in the library.\n logger.debug(\"Updating Items.\")\n Product.find(:all).each do |product|\n @name_call = product.id.to_s + \".name\"\n product.update_name(params[@name_call])\n @price_call = product.id.to_s + \".price\"\n product.update_price(params[@price_call])\n @inventory_call = product.id.to_s + \".inventory\"\n product.update_inventory(params[@inventory_call])\n @description_call = product.id.to_s + \".description\"\n product.update_description(params[@description_call])\n end\n ## Now we have to add any new items that were written in.\n if params[:added] != 0\n for i in 1..params[:added].to_i\n @n = \"name.new.\" + i.to_s\n @p = \"price.new.\" + i.to_s\n @inv = \"inventory.new.\" + i.to_s\n @des = \"description.new.\" + i.to_s\n if params[@n] && params[@p] && params[@inv] && params[@des]\n Product.create(:name => params[@n].to_s, :price => params[@p].to_f, :inventory => params[@inv].to_i, :description => params[@des].to_s)\n end\n end\n end\n end\n end", "def consume_items(item_quantities)\n item_quantities.each do |ingredient_name, quantity|\n @ingredients[ingredient_name] = @ingredients[ingredient_name] - quantity\n end\n end", "def ordered_item_params\n params.require(:ordered_item).permit(:order_id, :item_id, :ordered_item[\"quantity_new\"])\n end", "def edit\n\t\t@porder = Order.find_by(id: params[:id]) # old order\n\t\t@user = User.find_by(id: @porder.user_id)\n\t\t@orderdate = @porder.created_at\n\n\t\t# if this is showing an existing inventory order, just go right to showing the inventory\n\t\tif is_inventory(@porder)\n\t\t\t@order = @porder # /inventory/view expects instance variable @order\n\t\t\trender '/inventory/view' and return\n\t\tend\n\t\n\t\t@cuisine_inventory = get_inventory(@porder.cuisine)\n\t\tif @cuisine_inventory.nil?\n\t\t\t\tflash[:danger] = \"Order failed: No inventory template. Contact City Produce.\"\n\t\t\t\tredirect_to contact_path and return\n\t\tend\n\n\t\t@order = @user.orders.build(note: @porder.note, name: @porder.name, cuisine: @porder.cuisine)\n\n# build new order with all existing products\n\t\t@porder.lineitems.sort.each do |l|\n\t\t\t@order.lineitems.build(quantity: l.quantity,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tselum: l.selum,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\tproduct_id: l.product_id)\n\t\tend\n\n\t\tif (@porder.cuisine != @order.cuisine)\n\t\t# user just switched restaurant types.... so allow products from new cuisine\n\t\t\t@cuisine_inventory = get_inventory(@order.cuisine)\n\t\t\tif @cuisine_inventory.nil?\n\t\t\t\tflash[:danger] = \"No inventory for #{@order.cuisine}\"\n\t\t\t\tredirect_to @user and return\n\t\t\tend\n\t\tend\n\t\t\n# add all the remaining products from allowable inventory\n\t\tif @cuisine_inventory.lineitems.any?\n\t\t\t@cuisine_inventory.lineitems.sort.each do |l|\n\t\t\t\tfound = false\n\t\t\t\t@porder.lineitems.each do |x|\n\t\t\t\t\tif (found == false)\n\t\t\t\t\t\tif (x.product_id == l.product_id)\n\t\t\t\t\t\t\tfound = true\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tif (found == false)\n\t\t\t\t\t@order.lineitems.build(quantity: 0,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tselum: l.selum,\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tproduct_id: l.product_id)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n#\t\t@full_inventory = get_inventory(\"Inventory\")\n#\t\tdebugger\n\tend", "def populate\n\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\n # 2,147,483,647 is crazy. See issue #2695.\n if quantity.between?(1, 2_147_483_647)\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\n if error\n respond_to do |format|\n format.html {\n flash[:error] = error\n redirect_back_or_default(spree.root_path)\n }\n format.js {render :json => t(\"messages.add_to_cart_fail\"), :status => 422}\n end\n else\n respond_with(order) do |format|\n format.html { redirect_to cart_path }\n format.js {}\n end\n end\n\n end", "def load_item_data\n item = Item.find_by_id(params[:id]).present? ? Item.find(params[:id]) : Item.unscoped.find_by_id(params[:id])\n render :plain => [item.item_description || \"\", item.unit_cost.to_f || 1, item.quantity.to_f || 1, item.tax_1 || 0, item.tax_2 || 0, item.item_name || \"\", item.tax1_name || \"\", item.tax2_name || \"\", item.tax1_percentage || 0, item.tax2_percentage || 0 ]\n end", "def items(params = {})\n if instance_variable_defined?(:@items)\n # TODO raise error if params are passed here, since they're meaningless\n @items\n else\n @items = load_page(params)\n end\n end", "def load_order\n @cache_load_order = read_load_order unless defined?(@cache_load_order)\n @cache_load_order\n end", "def set_item\n @item = @order.order_items\n .where(product_id: params[:product_id])\n .first_or_initialize(order_id: @order.id)\n end", "def update_order_item\n \n end", "def setup_items(selected_items, for_action)\n # Retrieve each file's details. The container_id will be passed if this is a\n # multi container download, otherwise it will be ignored\n selected_items.each do |s|\n container = self.container || Browse.open_container(id: s[:container_id], user: current_user)\n activity_log = self.activity_log || ActivityLog.open_activity_log(s[:activity_log_type], s[:activity_log_id],\n current_user)\n retrieve_file_from(s[:id], s[:retrieval_type], container: container, activity_log: activity_log,\n for_action: for_action)\n end\n end", "def import\n if gateway.valid?\n gateway.items.map do |item|\n import_item(item)\n end\n else\n @errors = gateway.errors\n false\n end\n end", "def fetch\n items_distributed = fetch_items_distributed\n\n # Inject the \"onhand\" data\n items_distributed.map! do |item|\n item_name = item[:name]\n\n below_onhand_minimum = if current_onhand_quantities[item_name] && current_onhand_minimums[item_name]\n current_onhand_quantities[item_name] < current_onhand_minimums[item_name]\n end\n\n item.merge({\n current_onhand: current_onhand_quantities[item_name],\n onhand_minimum: current_onhand_minimums[item_name],\n below_onhand_minimum: below_onhand_minimum\n })\n end\n\n items_distributed.sort_by { |item| -item[:distributed] }\n end", "def rollback(order_id, item_ids, old_state, new_state)\n @orders.update({\"_id\" => order_id}, {\"$pullAll\" => {:item_ids => item_ids}})\n\n item_ids.each do |id|\n @inventory.find_and_modify(:query => {\"_id\" => id, :state => new_state},\n :update => {\"$set\" => {:state => old_state, :add_time => nil}})\n end\n end", "def order_item_params\n params.require(:order_item).permit(:order_id, :item_id, :quantity)\n end", "def items\n @items ||= fetch_items(contents)\n end", "def load_materials(materials)\n mt = 1\n materials.each do |material|\n case mt\n when 1\n self.mat_item1 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_1 = material.quantity\n when 2\n self.mat_item2 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_2 = material.quantity\n when 3\n self.mat_item3 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_3 = material.quantity\n when 4\n self.mat_item4 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_4 = material.quantity\n when 5\n self.mat_item5 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_5 = material.quantity\n when 6\n self.mat_item6 = material.item_key.to_s + \" - \" + material.item\n self.mat_qty_6 = material.quantity\n else\n #nothing\n end\n mt += 1\n end\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\n # 2,147,483,647 is crazy. See issue #2695.\n if quantity.between?(1, 2_147_483_647)\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\n json_rtn = {}\n\n if request.xhr?\n if error\n flash[:error] = error\n #redirect_back_or_default(spree.root_path)\n json_rtn.merge!(status: 'error')\n json_rtn.merge!(mess: error)\n render :json => json_rtn.to_json\n else\n json_rtn.merge!(status: 'success')\n json_rtn.merge!(mess: %Q{Item #{variant.sku} Added to cart})\n render :json => json_rtn.to_json\n end\n else\n if error\n flash[:error] = error\n redirect_back_or_default(spree.root_path)\n else\n respond_with(order) do |format|\n flash[:notice] = \"Item added to cart\"\n format.html { redirect_to %Q{#{request.referer}?variant_id=#{variant.id}} }\n end\n end\n end\n\n end", "def constructOrderItems(email_order_items)\n\t\temail_items = \"\"\n\t\temail_order_items.each do |item|\n\t\t\temail_item_hash = Hash.new\n\t\t\temail_item_hash = {\n\t\t\t\t:item_name\t=> item[\"project\"][\"title\"].to_s,\n\t\t\t\t:item_amount\t=> item[\"quantity\"].to_s,\n\t\t\t\t:item_total => \"%.2f\" % (item[\"price\"].to_f/100)\n\t\t\t}\n\t\t\t\n\t\t\temail_item = $CONFIG[:email_receipt_item].gsub('[item_name]', email_item_hash[:item_name]).gsub('[item_amount]', email_item_hash[:item_amount]).gsub('[item_total]', email_item_hash[:item_total])\n\t\t\t\n\t\t\temail_items += email_item\n\t\tend\n\t\temail_items\n\tend", "def load(_ids, **_options)\n raise NotImplementedError\n end", "def import(products, user_auth, options)\n post_with_auth 'item/import',\n ImportResponse,\n products: products,\n user_auth: user_auth,\n options: options\n end", "def process_cart_items()\n \torder = self.customer.orders.create\n \tself.cart_items.each do |item|\n \t\torder.order_items.create :product_id => item.product_id\n \tend\n \tself.cart_items = [] #clear the cart\n \treturn order\n end", "def populate\n populator = Spree::OrderPopulator.new(current_order(true), current_currency)\n from_hash = params.slice(:products, :variants, :quantity, :prescription_options)\n\n if populator.populate(from_hash)\n current_order.ensure_updated_shipments\n\n fire_event('spree.cart.add')\n fire_event('spree.order.contents_changed')\n\n variant_id = nil\n variant_id = from_hash[:products].values.first if from_hash[:products] and from_hash[:products].values.any?\n variant_id = from_hash[:variants].keys.first if from_hash[:variants] and from_hash[:variants].keys.any?\n\n if variant_id.present?\n if frame_line_item = @current_order.line_items.find_by(type: 'FrameLineItem', variant_id: variant_id)\n if not frame_line_item.lens_required? and params.key?('checkout-without-lenses')\n respond_with(@order) do |format|\n format.html {redirect_to cart_path}\n end\n else\n redirect_to select_lens_orders_path(frame_line_item.id)\n end\n elsif contact_lens_line_item = @current_order.line_items.find_by(type: 'ContactLensLineItem', variant_id: variant_id)\n if contact_lens_line_item.has_products_to_recommend?\n redirect_to recommendations_orders_path(contact_lens_line_item.id)\n else\n redirect_to select_prescription_orders_path(contact_lens_line_item.id)\n end\n else\n respond_with(@order) do |format|\n format.html {redirect_to cart_path}\n end\n end\n else\n respond_with(@order) do |format|\n format.html do\n flash[:error] = \"You need to select a Product\"\n redirect_to :back\n end\n end\n end\n else\n flash[:error] = populator.errors.full_messages.join('<br/>')\n redirect_to :back\n end\n end", "def create_order_for_lazada(order, smp)\n @order_items = []\n @order = nil\n @order_status = nil\n message = \"\"\n cm_user = smp.seller.is_cm_user\n begin\n # List item fetch from order API\n @order = Spree::Order.where(\"market_place_order_no=? AND seller_id=?\", order[:OrderId], smp.seller_id).try(:first)\n if !@order.present?\n p '----------'\n Time.zone = \"Singapore\"\n current_time = Time.zone.now\n list_item_params = {\"Action\"=>\"GetOrderItems\", \"OrderId\"=>order[:OrderId], \"Timestamp\"=>current_time.to_time.iso8601, \"UserID\"=>smp.contact_email, \"Version\"=>\"1.0\"}\n signature_lt = generate_lazada_signature(list_item_params, smp)\n market_place = smp.market_place\n if signature_lt\n formed_list_item = []\n sorted_params_lt = Hash[list_item_params.sort]\n sorted_params_lt.merge!(\"Signature\"=>signature_lt)\n sorted_params_lt.each do |key,value|formed_list_item << CGI::escape(\"#{key}\")+\"=\"+CGI::escape(\"#{value}\")end\n param_string_lt = \"?\"+formed_list_item.join('&')\n uri_lt = URI.parse(market_place.domain_url+param_string_lt)\n http_lt = Net::HTTP.new(uri_lt.host, uri_lt.port)\n http_lt.use_ssl = true\n http_lt.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request_lt = Net::HTTP::Get.new(uri_lt.request_uri)\n res_lt = http_lt.request(request_lt)\n if res_lt.code == \"200\"\n res_lt_body = Hash.from_xml(res_lt.body).to_json\n res_lt_body = JSON.parse(res_lt_body, :symbolize_names=>true)\n @order_items << res_lt_body[:SuccessResponse][:Body][:OrderItems][:OrderItem]\n @order_items = @order_items.flatten\n @order_status = @order_items[0][:Status]\n gift = (order[:GiftOption] == \"0\" ? false : true)\n shipping_country = Spree::Country.find_by_name(order[:AddressShipping][:Country])\n billing_country = Spree::Country.find_by_name(order[:AddressBilling][:Country])\n shipping_last_name = (order[:AddressShipping][:LastName] ? order[:AddressShipping][:LastName] : order[:AddressShipping][:FirstName])\n billing_last_name = (order[:AddressBilling][:LastName] ? order[:AddressBilling][:LastName] : order[:AddressBilling][:FirstName])\n shipping_phone_no = (order[:AddressShipping][:Phone].present? ? order[:AddressShipping][:Phone] : order[:AddressShipping][:Phone2])\n billing_phone_no = (order[:AddressBilling][:Phone].present? ? order[:AddressBilling][:Phone] : order[:AddressBilling][:Phone2])\n @shpping_address = Spree::Address.create!(:firstname=>order[:AddressShipping][:FirstName], :lastname=>shipping_last_name, :address1=>order[:AddressShipping][:Address1], :address2=>order[:AddressShipping][:Address2], :city=>shipping_country.name, :zipcode=>order[:AddressShipping][:PostCode], :phone=>shipping_phone_no, :alternative_phone=>order[:AddressShipping][:Phone2], :country_id=>shipping_country.id, :state_name=>shipping_country.name)\n if !order[:AddressBilling][:FirstName].present? && !order[:AddressBilling][:Address1].present? && !order[:AddressBilling][:Country].present? && !order[:AddressBilling][:PostCode].present? && !order[:AddressBilling][:Phone].present? && !billing_country.nil?\n @billing_address = Spree::Address.create!(:firstname=>order[:AddressBilling][:FirstName], :lastname=>billing_last_name, :address1=>order[:AddressBilling][:Address1], :address2=>order[:AddressBilling][:Address2], :city=>billing_country.name,:zipcode=>order[:AddressBilling][:PostCode], :phone=>billing_phone_no, :alternative_phone=>order[:AddressBilling][:Phone2], :country_id=>billing_country.id, :state_name=>billing_country.name)\n end\n billing_address = (!@billing_address.nil? && !@billing_address.blank?) ? @billing_address.id : nil\n order_item_list = []\n item_total = 0.0\n payment_total = 0.0\n quantity_hash = {}\n price_hash = {}\n @order_items.each do |item|\n # item[:Sku] = 'NEWRKIT'#'TPUSBC'#'NEWRKIT'\n item_total = item_total + item[:ItemPrice].to_f\n payment_total = payment_total + item[:PaidPrice].to_f\n if price_hash[item[:Sku]].present?\n price_hash[item[:Sku]] = price_hash[item[:Sku]].to_f + item[:PaidPrice].to_f\n else \n price_hash = price_hash.merge(item[:Sku]=>item[:PaidPrice].to_f) \n end\n if quantity_hash[item[:Sku]].present?\n quantity_hash[item[:Sku]] = quantity_hash[item[:Sku]].to_i + 1\n else\n quantity_hash = quantity_hash.merge(item[:Sku]=>1)\n order_item_list << item\n end\n end\n currency = (order_item_list.present? ? order_item_list.first[:Currency] : \"SGD\")\n @order = Spree::Order.create!(:number=>order[:OrderNumber], :order_date=>order[:CreatedAt], :market_place_details=>order, :item_total=>item_total, :total=>payment_total, :payment_total=>payment_total, :email=>smp.seller.contact_person_email, :currency=>currency, :send_as_gift=>gift, :market_place_id=>smp.market_place_id, :market_place_order_no=>order[:OrderId], :market_place_order_status=>@order_status, :bill_address_id=>billing_address, :ship_address_id=> @shpping_address.id, :cart_no=>order[:OrderNumber], :seller_id=>smp.seller_id, :is_bypass=>!cm_user)\n p @order\n order_item_list.each do |item|\n if cm_user\n # item[:Sku] ='NEWRKIT'# 'TPUSBC'#\n @variant = nil\n @mp_product = nil\n @line_item = nil\n @stock = nil\n @variant = Spree::Variant.includes(:product).where(\"spree_products.seller_id=? AND sku=?\", smp.seller_id, item[:Sku]).try(:first)\n if @variant.present?\n @mp_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", @variant.product.seller_id, smp.market_place_id, @variant.product_id).first\n if @variant.product.kit.present?\n kit = @variant.product.kit\n l_items = kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*quantity_hash[item[:Sku]]\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>item[:Currency], :kit_id=>kit.id, :rcp=>price_hash[item[:Sku]])\n stock = lt_variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n msg = 'Application Helper Create Order Lazada'\n lt_variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n stock.update_attributes!(:count_on_hand=>(stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 ) if stock.present? && lt_variant.quantity_inflations.present?\n end\n else\n if @variant.parent_id.present?\n @parent = Spree::Variant.find(@variant.parent_id)\n if @parent.product.kit.present?\n kit = @parent.product.kit\n l_items = kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*quantity_hash[item[:Sku]]\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>item[:Currency], :kit_id=>kit.id, :rcp=>price_hash[item[:Sku]])\n stock = lt_variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n stock.update_attributes!(:count_on_hand=>(stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 ) if @stock.present? && lt_variant.quantity_inflations.present?\n msg = 'Application Helper Create Order Lazada Family Kit If'\n lt_variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@parent.id, :order_id=>@order.id, :quantity=>quantity_hash[item[:Sku]], :price=>item[:PaidPrice], :currency=>item[:Currency], :rcp=>price_hash[item[:Sku]])\n type = (STOCKCONFIG[@parent.product.stock_config_type] == \"default\" ? STOCKCONFIG[@parent.product.seller.stock_config_type] : STOCKCONFIG[@parent.product.stock_config_type])\n @parent.update_attributes(:fba_quantity=>(@parent.fba_quantity - quantity_hash[item[:Sku]])) if !@parent.quantity_inflations.present?\n msg = 'Application Helper Create Order Lazada Parent Family Kit Else'\n @parent.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n @variant.update_attributes(:fba_quantity=>(@parent.fba_quantity - quantity_hash[item[:Sku]])) if (!@variant.quantity_inflations.present? && @parent.quantity_inflations.present?)\n msg = 'Application Helper Create Order Lazada Family Kit Else'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@parent.product.kit.present?)\n @stock = @parent.stock_products.where(\"sellers_market_places_product_id IN (?)\", @parent.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - quantity_hash[item[:Sku]]) >= 0 ? (@stock.count_on_hand - quantity_hash[item[:Sku]]) : 0 ) if @stock.present? && @parent.quantity_inflations.present?\n end\n child_type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n if (child_type != \"flat_quantity\") || (child_type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - quantity_hash[item[:Sku]]) >= 0 ? (@stock.count_on_hand - quantity_hash[item[:Sku]]) : 0 ) if @stock.present? && @variant.quantity_inflations.present?\n end\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@variant.id, :order_id=>@order.id, :quantity=>quantity_hash[item[:Sku]], :price=>item[:PaidPrice], :currency=>item[:Currency], :rcp=>price_hash[item[:Sku]]) \n type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - quantity_hash[item[:Sku]])) if !@variant.quantity_inflations.present?\n msg = 'Application Helper Create Order Lazada Without Family'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - quantity_hash[item[:Sku]]) >= 0 ? (@stock.count_on_hand - quantity_hash[item[:Sku]]) : 0 ) if @stock.present? && @variant.quantity_inflations.present?\n end\n end\n end\n end\n else\n Spree::MpOrderLineItem.create!(:order_id=>@order.id, :market_place_details=>item)\n end\n end # end of order_item_list\n @order.update_column(:total, payment_total)\n @order.reload\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => @order})\n @cart_numbers << order[:OrderNumber]\n else # else for order check condition\n if @order.market_place_order_status != @order_status\n @order.update_attributes(:market_place_order_status=>@order_status)\n end\n end\n end # End for item list response check\n\n end # End of item list signature check\n rescue Exception => e\n message << e.message\n end\n return message.length > 0 ? message : true\n end", "def edit_order(items, quantities, camp_id)\r\n\r\n #Deletes each order item from the table\r\n order_items.each do |order_item|\r\n order_item.destroy\r\n end\r\n\r\n #Saves the campaign ID of the order\r\n self.campaign_id = camp_id\r\n self.save\r\n\r\n #Saves the order_items for the current order\r\n items.each_with_index do |item,i|\r\n order_item = OrderItem.new do |u|\r\n u.order_id = id\r\n u.item_id = Item.find_by(name: item).id\r\n u.quantity = quantities[i].to_i\r\n end\r\n order_item.save\r\n end\r\n end" ]
[ "0.7143785", "0.65659773", "0.6305985", "0.60799503", "0.60450166", "0.59311044", "0.5776516", "0.57490283", "0.5734592", "0.56506526", "0.55872136", "0.55603206", "0.5530761", "0.5525726", "0.55232835", "0.5515011", "0.5450952", "0.5434968", "0.5424652", "0.54147923", "0.539697", "0.539578", "0.5379966", "0.5360248", "0.53509057", "0.5337468", "0.5321723", "0.5321723", "0.5306905", "0.5303594", "0.5296189", "0.52797663", "0.5275425", "0.52616334", "0.52602375", "0.52598786", "0.52474076", "0.52474076", "0.52474076", "0.52474076", "0.5228268", "0.5226375", "0.52107227", "0.5200706", "0.51879305", "0.517866", "0.5169017", "0.5166441", "0.51586", "0.51553875", "0.51454616", "0.513994", "0.51365304", "0.5129646", "0.51253265", "0.5122147", "0.5119944", "0.51088905", "0.50869554", "0.5064587", "0.50487345", "0.50478566", "0.5030343", "0.5018628", "0.50058174", "0.4995925", "0.49924043", "0.49820232", "0.49778178", "0.49682122", "0.4964185", "0.49562418", "0.4954345", "0.49526566", "0.4948791", "0.49439746", "0.49414274", "0.4936267", "0.4930665", "0.49235904", "0.49135867", "0.4911928", "0.4911438", "0.4905618", "0.49012583", "0.49002287", "0.4892227", "0.4885643", "0.48683205", "0.48669136", "0.4866231", "0.48649958", "0.4843758", "0.4843151", "0.48425183", "0.48421687", "0.48402047", "0.48356196", "0.48347574", "0.4815789" ]
0.85636306
0
Creates a new transfer item based on given order item, specifying the product, lot code, and amount, if not overridden by arguments.
def create_item_from(order_item, lot_code = nil, expires_at = nil, amount = nil) transfer_items.create!( order_item: order_item, product: order_item.product, lot_code: lot_code || order_item.lot_code, expires_at: expires_at, amount: amount || order_item.waiting ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_order(order_item, qty, order)\r\n if order_item == \"latte\"\r\n item = Item.new(\"latte\", $latte_cost, $latte_price)\r\n elsif order_item == \"tea\"\r\n item = Item.new(\"tea\", $tea_cost, $tea_price)\r\n elsif order_item == \"scones\"\r\n item = Item.new(\"scones\", $scones_cost, $scones_price)\r\n end\r\n order.add_item(item, qty)\r\nend", "def transfer_inventory(reason)\n packaging.product.transfers.create!(\n :detail => self,\n :happened_at => Time.zone.now,\n :quantity => (-1 * quantity * packaging.size),\n :reason => reason\n )\n end", "def add_item(order_id, item_sku, price, quantity, name = nil, category = nil, utmhid = random_id)\n check_account_params\n hey(item_params(order_id, item_sku, name, category, price, quantity, utmhid))\n end", "def generate_new_item_object\n @new_item = Flight.new\n insert_required_params_into_new_item_object\n insert_default_params_into_new_item_object\n insert_optional_params_into_new_item_object(self)\n return @new_item\n end", "def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n\n order_item = order.items.find_or_create_by(\n product_id: product_id\n )\n\n order_item.price = product.price\n order_item.quantity = 1\n order_item.save\n end", "def create_item(name, price, quantity, description=\"No description available\", image=\"\")\n new_item = Item.created( name, price, self.working_for, quantity, description, image)\n if !(identical = self.working_for.list_items_inactive.detect{|i| i == new_item }).nil?\n identical.quantity += new_item.quantity\n else\n self.working_for.offers.push(new_item)\n new_item.save\n end\n Activity.log(self, \"add_item\", new_item, self.working_for)\n return new_item\n end", "def buy_now(item_params)\n new_item = cart_items.new(item_id: item_params[:item][:item_id], quantity: item_params[:quantity], buy_now: item_params[:buy_now], cart_id: self.id)\n end", "def create_item(name, price)\r\n new_item = Trading::Item.created( name, price, self )\r\n self.item_list.push(new_item) # AK You can also do `item_list << new_item`\r\n return new_item\r\n end", "def add_item(item_name, price, quantity = 1)\n @transactions << Transaction.new(item_name, price, quantity)\n quantity.times{self.items << item_name}\n self.total += price*quantity\n end", "def initialize(quantity, item_code)\n\t\t@requested_quantity = quantity\n\t\t@menu_item = Menu.instance.get_item_instance_from_code(item_code)\n\t\t@menu_item_index = Menu.instance.get_index_from_code(item_code)\n\t\t@packs = Array.new\n\t\t@item_total = 0.00\n\t\t@remaining_units = @requested_quantity\n\n\t\tTracer.debug \"\\nOrderItem.new: { remaining_units: \" + @remaining_units.to_s + \\\n\t\t\t\" menu_item: \" + @menu_item_index.to_s + \\\n\t\t\t\" }\\n\"\n\t\tif @menu_item_index < 0\n\t\t\tTracer.flash \"Item with code: \" + item_code.to_s + \" was not found.\"\n\t\telse\t\t\t\n\t\t\tadd_packs()\n\t\tend\n\tend", "def add_item(item, price, quantity=1)\n @total += (price * quantity)\n @items.fill(item, @items.size, quantity)\n @last_transaction = {item => (price * quantity)}\n @last_qty = quantity\n end", "def item_create\n @brief = Brief.find(params[:brief_id])\n @brief_vendor = @brief.brief_vendors.find_by_org_id(@cur_user.org_id)\n invalid_op unless @brief_vendor\n @brief_vendor.items << Item.new(params[:item]){|r|r.kind = params[:kind]}\n redirect_to vendor_show_brief_path(@brief)\n end", "def add_details item, qty, val\n if item && val\n item_detail = @txn.transaction_details.build rescue nil\n item_detail.item_name, item_detail.quantity, item_detail.price = item, qty, val if item_detail\n end\n item_detail\n end", "def create\n @purchasable = find_purchasable\n @order_item = @purchasable.order_items.new(order_item_params)\n @order_item.user_id = current_user.id\n @order_item.channel_id = current_user.profile.selected_channel_id\n @order_item.product = @purchasable.product\n# @order_item.cost = @purchasable.product.price\n \n respond_to do |format|\n if @order_item.save\n format.html { redirect_to [@purchasable, :order_items], notice: 'Item was successfully created.' }\n format.json { render :show, status: :created, location: @order_item }\n else\n format.html { render :new }\n format.json { render json: @purchasable.errors, status: :unprocessable_entity }\n end\n end\n end", "def order_items_create(data, opts = {})\n data, _status_code, _headers = order_items_create_with_http_info(data, opts)\n data\n end", "def create_pay_item(xero_tenant_id, pay_item, opts = {})\n data, _status_code, _headers = create_pay_item_with_http_info(xero_tenant_id, pay_item, opts)\n data\n end", "def new_order(args)\n # Args: amount:, keychain_id: nil, currency: nil, btc_denomination: :satoshi\n #\n # The reason these arguments are supplied as a hash and not as named arguments\n # is because we don't know in advance which arguments are required for a particular\n # AddressAdapter. So we accept all, check manually for required ones like :amount,\n # set default values where needed and then hand them all to address_adapter.\n if args[:amount].nil? || !args[:amount].kind_of?(Numeric) || args[:amount] < 0\n raise OrderAmountInvalid, \"amount cannot be nil or less than 0\"\n end\n\n # Build order with default values\n order = Kernel.const_get(order_class).new\n order.gateway = self\n order.keychain_id = args[:keychain_id]\n order.block_height_created_at = fetch_latest_block_height rescue nil\n\n args[:currency] ||= default_currency\n\n # Generates address and calculates amount in satoshi\n if address_provider.takes_fees?\n order.address, order.amount =\n address_provider.new_address_and_amount(**args)\n else\n order.address = address_provider.new_address(**args)\n order.amount =\n amount_from_exchange_rate(\n args[:amount],\n currency: args[:currency],\n btc_denomination: args[:btc_denomination] || :satoshi,\n )\n end\n\n unless args[:currency] == \"BTC\"\n order.amount_with_currency =\n format(\"%.2f %s\", args[:amount], args[:currency])\n end\n\n order\n end", "def create_line_item_from_inventory_item inventory_item, qty, payable_party, billable_party, include_price_in_expense, include_price_in_revenue, notes\n\n [\n # Vendor\n LineItem.create(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_vendor, :quantity => qty,\n :unit_price_expense => inventory_item.cogs,\n :tax_rate_expense => 0,\n :payable_party => payable_party,\n :include_price_in_expense => include_price_in_expense,\n :inventory_item => inventory_item, :notes => notes),\n\n # Account\n LineItem.create(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_public, :quantity => qty,\n :unit_price_revenue => calculate_sell_price_from_inventory_item(inventory_item),\n :billable_party => billable_party,\n :include_price_in_revenue => include_price_in_revenue,\n :inventory_item => inventory_item, :notes => notes)\n ]\n end", "def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n order_item = order.items.find_or_initialize_by(\n product_id: product_id,\n price: product.price,\n quantity: quantity\n )\n\n order_item.save!\n end", "def create_item(index)\n item = @data[index]\n rect = item_rect(index, true)\n \n shopItem = UCShopItem.new(self, item, rect,\n SHOP_CONFIG::ITEM_NUMBER_PATTERN)\n \n shopItem.cItemPrice.align = 2\n shopItem.cItemPossess.align = 2 \n shopItem.cItemPossess.font = Font.shop_possess_font\n shopItem.ucItemNumber.cLabelNumber.align = 2\n shopItem.ucItemNumber.min = 0\n shopItem.ucItemNumber.max = shopItem.inventory_quantity\n return shopItem\n end", "def create\n @toodoo_item = ToodooItem.new(toodoo_item_params)\n\n respond_to do |format|\n if @toodoo_item.save\n format.html { redirect_to @toodoo_item, notice: 'Toodoo item was successfully created.' }\n format.json { render :show, status: :created, location: @toodoo_item }\n else\n format.html { render :new }\n format.json { render json: @toodoo_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_item\n @item = Fox_Item.new(self, @content.join(\"\\t\"), @icon, @icon)\n end", "def buy(params)\n params[:side] = 'buy'\n params[:product_id] = id\n\n Order.create(params)\n end", "def create_item(item_request_body, opts = {})\n data, _status_code, _headers = create_item_with_http_info(item_request_body, opts)\n data\n end", "def make_item(object_type_name)\n\n ot = ObjectType.find_by(name: object_type_name)\n raise \"Could not find object type #{name}\" unless ot\n\n Item.make({ quantity: 1, inuse: 0 }, sample: self, object_type: ot)\n\n end", "def create\n @order_item = OrderItem.new(order_items_params)\n\n respond_to do |format|\n if @order_item.save\n format.html { redirect_to @order_item, notice: \"Order item was successfully created.\" }\n format.json { render json: @order_item, status: :created, location: @order_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order_item.errors, status: :unprocessable_entry }\n end\n end\n end", "def initialize(order_item)\n @order_item = order_item\n end", "def buy(item, quantity)\r\n if quantity < item.quantity\r\n item_to_buy = item.split(quantity)\r\n else\r\n item_to_buy = item\r\n end\r\n seller = item_to_buy.owner\r\n seller.sell(item_to_buy)\r\n item_to_buy.owner = self\r\n self.remove_credits(item_to_buy.price * quantity)\r\n item_to_buy.deactivate\r\n Marketplace::Activity.create(Activity.ITEM_BOUGHT, item, \"#{item.name} has been bought by #{self.name}\")\r\n Marketplace::Activity.create(Activity.USER_BOUGHT_ITEM, self, \"#{self.name} bought #{item.name}\")\r\n #delete the history in the description log, except the newest entry\r\n item_to_buy.clean_description_log\r\n item_to_buy.clean_comments\r\n item_to_buy\r\n end", "def 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 create\n @order_item_extra = OrderItemExtra.new(order_item_extra_params)\n\n if @order_item_extra.save\n render json: @order_item_extra, status: :created, location: @order_item_extra\n else\n render json: @order_item_extra.errors, status: :unprocessable_entity\n end\n end", "def new_item(which = 0,opts={})\n defaults = {:number => @holdings[which].items.count}\n @holdings[which].new_item(defaults.merge(opts))\n end", "def create_item(item_code)\n \t\txero = XeroConnection.new.connect\n\n \t\tif xero.Item.all(where: 'code == \"%s\"' % item_code).empty?\n \t\t\tnew_item = xero.Item.build(code: item_code)\n \t\t\tnew_item.save\n \t\tend\n \tend", "def add_item(item, price, quantity = 1)\n @total += price * quantity\n @transactions << price * quantity\n i = quantity\n until i == 0 do\n @items << item\n i -= 1\n end\n end", "def prorate_create_item(t, tariff, invoice_id, subcode, price, quantity, measure, tax_type_id, discount_pct, user_id, d)\n if t == 'P'\n create_pre_invoice_item(tariff, invoice_id, subcode, price, quantity, measure, tax_type_id, discount_pct, user_id, d)\n else\n create_invoice_item(tariff, invoice_id, subcode, price, quantity, measure, tax_type_id, discount_pct, user_id, d)\n end\n end", "def new_invoice_item(invoice, i)\n invoice_item = SupplierInvoiceItem.new\n if i.class.name == 'ReceiptNoteItem'\n invoice_item.receipt_note_id = i.receipt_note_id\n invoice_item.receipt_note_item_id = i.id\n else\n invoice_item.purchase_order_id = i.purchase_order_id\n invoice_item.purchase_order_item_id = i.id\n end\n invoice_item.supplier_invoice_id = invoice.id\n invoice_item.product_id = i.product_id\n invoice_item.code = i.code\n invoice_item.description = i.description\n invoice_item.quantity = i.balance\n invoice_item.price = i.price\n invoice_item.discount_pct = i.discount_pct\n invoice_item.discount = i.discount\n invoice_item.tax_type_id = i.tax_type_id\n invoice_item.work_order_id = i.work_order_id\n invoice_item.project_id = i.project_id\n if !i.charge_account_id.blank?\n invoice_item.charge_account_id = i.charge_account_id\n else\n invoice_item.charge_account_id = ChargeAccount.expenditures(i.project_id).first.id\n end\n invoice_item.created_by = current_user.id if !current_user.nil?\n return invoice_item\n end", "def create_line_item_from_inventory_item inventory_item, qty, payable_party, billable_party, include_price_in_expense, include_price_in_revenue, notes\n # Vendor\n l1 = LineItem.create!(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_vendor, :quantity => qty,\n :unit_price_expense => inventory_item.cogs,\n :tax_rate_expense => 0,\n :payable_party => payable_party,\n :include_price_in_expense => include_price_in_expense,\n :inventory_item => inventory_item, :notes => notes, :event => self)\n\n # Account\n l2 = LineItem.create!(\n :line_item_type => \"Goods\", :line_item_sub_type => \"Menu-Item\",\n :sku => inventory_item.sku, :name => inventory_item.name_public, :quantity => qty,\n :unit_price_revenue => calculate_sell_price_from_inventory_item(inventory_item),\n :billable_party => billable_party,\n :include_price_in_revenue => include_price_in_revenue,\n :inventory_item => inventory_item, :notes => notes, :event => self)\n\n l1.opposing_line_item = l2\n l2.opposing_line_item = l1\n l1.save\n l2.save\n\n [l1, l2]\n end", "def create\n @order = Order.new(order_params)\n @order.user_id = current_user.id\n @order_item = OrderItem.create\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Замовлення створено.' }\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 create_item(name, price)\r\n new_item = Models::Item.created( name, price, self )\r\n self.item_list.push(new_item)\r\n new_item.save\r\n return new_item\r\n end", "def create_item_with_http_info(item_request_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ItemsApi.create_item ...'\n end\n # verify the required parameter 'item_request_body' is set\n if @api_client.config.client_side_validation && item_request_body.nil?\n fail ArgumentError, \"Missing the required parameter 'item_request_body' when calling ItemsApi.create_item\"\n end\n # resource path\n local_var_path = '/items'\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'])\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[:debug_body] || @api_client.object_to_http_body(item_request_body)\n\n # return_type\n return_type = opts[:debug_return_type] || 'SingleItem'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['basicAuth', 'oAuth2ClientCredentials']\n\n new_options = opts.merge(\n :operation => :\"ItemsApi.create_item\",\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(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ItemsApi#create_item\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def add_item\n item = params[:item]\n image = Image.find(item[:image_id])\n\n order = current_user.init_cart.order\n line_item = order.line_items.where(\n image_id: image.id,\n product_id: item[:product_id],\n product_option_id: item[:product_option_id]\n ).first\n\n if line_item.present?\n line_item.quantity += item[:quantity].to_i\n else\n line_item = order.line_items.build(item)\n end\n\n line_item.price = Product.find(line_item.product_id).price_for_tier(image.tier_id, image.owner?(current_user))\n line_item.tax = line_item.price * PER_TAX\n\n if line_item.save\n render json: line_item, status: :created\n else\n render json: { msg: line_item.errors.full_messages.to_sentence }, status: :bad_request\n end\n end", "def new\n @order = Order.find(request[:order_id])\n @order_item = @order.order_items.new\n @order_item.owner = current_user\n item_id = request[:item_id]\n unless item_id.nil?\n @order_item.item_id = item_id\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order_item }\n end\n end", "def new_item(content)\n Item.new(:project_id => @project_id, :content => content)\n end", "def create_item( *args )\n raise NotImplementedError.new(\"Subclasses must implement #create_item\")\n end", "def order_items_create_with_http_info(data, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: OrderItemsApi.order_items_create ...'\n end\n # verify the required parameter 'data' is set\n if @api_client.config.client_side_validation && data.nil?\n fail ArgumentError, \"Missing the required parameter 'data' when calling OrderItemsApi.order_items_create\"\n end\n # resource path\n local_var_path = '/order-items/'\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'])\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(data) \n\n # return_type\n return_type = opts[:return_type] || 'OrderItem' \n\n # auth_names\n auth_names = opts[:auth_names] || ['Basic', 'Token']\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(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OrderItemsApi#order_items_create\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @part_types = Constants::PART_TYPES\n @item = Item.new(item_params.merge(user_id: current_user.id))\n \n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: \"Item was successfully created.\" }\n format.json { render :show, status: :created, location: @item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def initialize(item, quantity)\n @item = item\n @quantity = quantity\n end", "def buy!(qty, price)\n order = Fyb::Order.new qty, price, :buy\n order.perform\n end", "def buy_new_item(item_to_buy, quantity, account)\n return false if item_to_buy.auction\n preowner = item_to_buy.owner\n\n if (Integer(item_to_buy.price*quantity) > self.credits and item_to_buy.currency == \"credits\") or Integer(item_to_buy.quantity)<quantity\n Activity.log(account, \"item_bought_failure\", item_to_buy, self)\n Activity.log(account, \"item_sold_failure\", item_to_buy, preowner)\n return false\n end\n\n\n if !item_to_buy.wishlist_users.empty? and item_to_buy.quantity == quantity and !item_to_buy.permanent\n item_to_buy.wishlist_users.each {|trader| trader.remove_from_wishlist(item_to_buy); item_to_buy.wishlist_users.delete(trader)}\n end\n\n Holding.ship_item(item_to_buy, item_to_buy.owner, self, quantity)\n Activity.log(account, \"item_bought_success\", item_to_buy, self)\n Activity.log(account, \"item_sold_success\", item_to_buy, preowner)\n Mailer.item_sold(preowner.e_mail, \"Hi #{preowner.name}, \\n #{self.name} bought your Item #{item_to_buy.name}.\n Please Contact him for completing the trade. His E-Mail is: #{self.e_mail}\")\n\n return true\n end", "def new_from_item(item, options = {})\n cart_item = item.send(self.to_s.tableize).build(options)\n cart_item.attributes.map {|attribute| attribute if item.respond_to?(attribute[0].to_s) && !attribute[0].to_s.include?(\"_at\") }.compact.each {|attribute| cart_item.send(\"#{attribute[0]}=\", item.send(attribute[0].to_s))}\n # TODO Add a callback\n cart_item\n # TODO Add a callback\n end", "def add_item(item, quantity = 1)\n order_item = self.order_items.find_by item: item, price: item.price\n if order_item.is_a? OrderItem\n order_item.add quantity\n else\n self.order_items.create item: item, price: item.price, quantity: quantity\n end\n recalculate!\n end", "def new_item(opts={})\n defaults = {:number => @items.count + 1}\n @items << ItemRecord.new(defaults.merge(opts))\n end", "def create\n @order_pack_item = OrderPackItem.new(order_pack_item_params)\n\n respond_to do |format|\n if @order_pack_item.save\n format.html { redirect_to @order_pack_item, notice: 'Order pack item was successfully created.' }\n format.json { render :show, status: :created, location: @order_pack_item }\n else\n format.html { render :new }\n format.json { render json: @order_pack_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @purchase_order_item = PurchaseOrderItem.new(params[:purchase_order_item])\n\n respond_to do |format|\n if @purchase_order_item.save\n format.html { redirect_to @purchase_order_item, notice: 'Purchase order item was successfully created.' }\n format.json { render json: @purchase_order_item, status: :created, location: @purchase_order_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @purchase_order_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def duplicate(qty_ordered, qty_received = nil, qty_issued = nil)\n new_item = OrderedLineItem.create!(self.attributes.merge({\n :quantity_ordered => qty_ordered, \n :quantity_received => qty_received, \n :issued_quantity => qty_issued,\n :date_received => nil\n }))\n new_item.line_item_no = self.line_item_no\n new_item.save!\n end", "def create\n @cart = current_cart\n @product = Product.find(params[:id])\n @order_item = @cart.order_items.build\n @order_item.product_id = @product.id\n #@order_item = OrderItem.create!(:cart => current_cart, :product => @product, :qty_ordered => params[:qty_ordered], :qty_ordered_price => @product.price)\n #@order_item = OrderItem.find_or_initialize_by_cart_id(:cart_id => current_cart.id, :cart => current_cart, :product => @product, :qty_ordered => params[:qty_ordered], :qty_ordered_price => @product.price)\n # @order_item = OrderItem.new\n # @order_item.cart_id = current_cart.id\n # @order_item.product_id = @product.id\n @order_item.qty_ordered = params[:qty]\n @order_item.qty_ordered_price = @product.price\n @order_item.save\n flash[:notice] = \"Added #{@product.name} to cart.\"\n redirect_to current_cart_url\n\n # @order = current_order\n # product = Product.find(params[:product_id])\n # # @order_item = OrderItem.new(params[:order_item]) Ian's line\n # @order_item = @order.add_product(product.id)\n \n # if Order.last == nil\n # @order_item.order_id = 1\n # else @order_item.order_id = Order.last.id + 1\n # end\n # @order_item.qty_ordered_price = @order_item.product.price\n\n # respond_to do |format|\n # if @order_item.save\n # format.html { redirect_to @order_item.order, notice: 'Order item was successfully created.' }\n # format.json { render json: @order_item, status: :created, location: @order_item }\n # else\n # format.html { render action: \"new\" }\n # format.json { render json: @order_item.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def create\n # defined object to receive strict item_params including :description, :price, :stockQty ; else return 400\n @item = Item.new(item_params)\n \n if @item.save\n render json: @item.to_json, status: 201\n else\n head 400\n end\n end", "def order_item_params\n params.require(:order_item).permit(:order_id, :product_id, :amount)\n end", "def new\n @item = Item.new\n \n @order = Order.new\n @order.order_number = 'NEW ORDER'\n \n @customer = Customer.new\n @address = Address.new\n @address.state = 'IL'\n \n # Ledgers\n @deposit_ledger = Ledger.new\n @payment_ledger = Ledger.new\n \n # Remaining balance\n @remaining_balance = 'NEW ORDER'\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end", "def create\n @order = Order.find(request[:order_id])\n @order_item = OrderItem.new(params[:order_item])\n @order_item.order_id = @order.id\n @order_item.owner = current_user\n\n respond_to do |format|\n #if @order.order_items.push(@order_item)\n result = @order_item.save()\n if result\n format.html { redirect_to [@order, @order_item], notice: \"This item was successfully added to '#{@order.name}'.\" }\n format.json { render json: @order_item, status: :created, location: @order_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.order_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_product(product, quantity=1, payment_method='deposit')\n item = @items.find { |i| i.product_id == product.id && i.payment_method == payment_method }\n if item\n item.quantity += quantity\n if item.quantity > 20\n item.quantity = 20\n @quantity_error=\"Only 20 Items may be added at one time. If you need to purchase additional items please contact customer service.\"\n end\n else\n @items << OrderLineItem.new(\n :product_id => product.id,\n :quantity => quantity,\n :unit_deposit => product.deposit,\n :unit_price => product.price,\n :payment_method => payment_method\n )\n end\n end", "def item_new\n @brief = Brief.find(params[:brief_id])\n @item = Item.new\n @item.kind = params[:kind]\n @action_to = vendor_item_create_path(@brief,@item.kind)\n end", "def create_line_item_from_inventory_item_id inventory_item_id, qty, include_price_in_expense, include_price_in_revenue, notes\n # Inventory item\n inventory_item = InventoryItem.find(inventory_item_id)\n line_items.push(create_line_item_from_inventory_item(\n inventory_item, qty,\n inventory_item.vendor, account,\n include_price_in_expense, include_price_in_revenue, notes))\n end", "def create\n @order = Order.new(\n quantity:params[:order][:quantity],\n item_id:params[:order][:item_id],\n requester: current_member,\n requested_at:Time.now,\n approver:Member.find(1),\n approved_at: nil,\n deadline: nil,\n returned:false)\n\n respond_to do |format|\n if @order.save\n #it may become negative to simulate real life scenarios\n @item = @order.item\n @item.update(units:@item.units-@order.quantity)\n format.html { redirect_to orders_path, notice: \"Order was successfully created.\" }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def pay_item\n Payjp.api_key = ENV[\"PAYJP_SECRET_KEY\"] # 自身のPAY.JPテスト秘密鍵を記述しましょう\n Payjp::Charge.create(\n amount: @item.price, # 商品の値段\n card: addresse_params[:token], # カードトークン\n currency: 'jpy' # 通貨の種類(日本円)\n )\n end", "def create\n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to \"/new/\" + Base58.encode(@item.id) }\n format.xml { render :xml => @item, :status => :created, :location => @item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_order_items(order)\n raise NoOrderItemsGiven unless valid_order_items?\n\n Array(param(:order_items)).each do |order_item_params|\n order_item = build_order_item(order_item_params)\n order_item.save!\n end\n end", "def order_item_params\n params.require(:order_item).permit(:name, :product_id, :custom, :cost, :ordered, :requested, :delivered)\n end", "def giveItem\n toLocation = Company.where(name: params[:recepCompany]).first.locations.where(address: params[:recepLocation]).first\n location = current_company.locations.where(id: params[:locationId]).first\n if(location.is_supplier === true)\n updatedItem = location.items.where(name: params[:name]).first\n toUpdatedItem = toLocation.items.where(name: params[:name]).first\n if(toUpdatedItem.present? && updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n toUpdatedItem.increment!(:amount, params[:amount].to_i)\n elsif(updatedItem.amount > params[:amount].to_i)\n updatedItem.increment!(:amount, -params[:amount].to_i)\n item = Item.create(name: params[:name], amount:params[:amount].to_i, price: updatedItem.price, autoRestock: false, lastSupplier:location.id)\n toLocation.items << item\n end\n if(updatedItem.amount <= updatedItem.restockPoint)\n changeItemSupplier(updatedItem.id)\n end\n end\n end", "def create\n @custom_item = CustomItem.new(custom_item_params)\n\n respond_to do |format|\n if @custom_item.save\n format.html { redirect_to order_bill_path(@custom_item.bill.order, @custom_item.bill), notice: 'Custom item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @custom_item }\n else\n format.html { redirect_to order_bill_path(@custom_item.bill.order, @custom_item.bill) }\n format.json { render json: @custom_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def buy(item)\n raise_no_money! if item.price > pending_amount\n change = calc_change(pending_amount - item.price)\n transfer_pending_to_money\n remove_from_money change\n change\n end", "def create\n @customer_order_item = CustomerOrderItem.new(customer_order_item_params)\n\n respond_to do |format|\n if @customer_order_item.save\n format.html { redirect_to @customer_order_item, notice: 'Customer order item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @customer_order_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @customer_order_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(attributes)\n response = JSON.parse(@client.post('items', attributes).body)\n Promisepay::Item.new(@client, response['items'])\n end", "def create_with_item(params_item, params_fuman)\n ActiveRecord::Base.transaction do\n\n #TODO 条件にservice_codeもいれる\n #TODO 二重で登録されているところあり\n item = Item.find_by_product_id(params_item[:product_id])\n\n # create\n if item.nil?\n\n name = ApiBucket::Service.name(params_item[:service_code].to_i)\n\n if Rails.env.test?\n item = @service.lookup(params_item[:product_id])\n else\n service = ApiBucket::Service.instance(:\"#{name}\")\n res = service.lookup(params_item[:product_id])\n item = res.items.first\n end\n\n params_item.merge!({\n url: item.detail_url,\n preview_url: item.preview_url,\n title: item.title,\n description: item.description,\n release_date: item.release_date,\n image_s: item.image[:l][:url],\n image_m: item.image[:l][:url],\n image_l: item.image[:l][:url],\n price: item.price\n })\n\n item = Item.new(params_item)\n raise ActiveRecord::Rollback unless item.save\n end\n\n @fuman = Fuman.where(user_id: @user.id).where(item_id: item.id).first\n return true if @fuman.present?\n\n # create\n params_fuman.merge!({\n user_id: @user.id,\n item_id: item.id\n })\n\n @fuman = Fuman.new(params_fuman)\n raise ActiveRecord::Rollback unless @fuman.save\n end\n\n true\n end", "def create\n @order = current_order(create_order_if_necessary: true)\n authorize! :update, @order, cookies.signed[:guest_token]\n product = ::Spree::Product.find(params[:product_id])\n option_values_ids = params[:options].present? ? params[:options].values : []\n option_values = ::Spree::OptionValue.where(id: option_values_ids)\n variant = product.try_variant option_values\n quantity = params[:quantity].present? ? params[:quantity].to_i : 1\n\n # 2,147,483,647 is crazy. See issue https://github.com/spree/spree/issues/2695.\n if !quantity.between?(1, 2_147_483_647)\n @order.errors.add(:base, t('spree.please_enter_reasonable_quantity'))\n else\n begin\n @line_item = @order.contents.add(variant, quantity)\n rescue ActiveRecord::RecordInvalid => error\n @order.errors.add(:base, error.record.errors.full_messages.join(\", \"))\n end\n end\n\n respond_with(@order) do |format|\n format.html do\n if @order.errors.any?\n flash[:error] = @order.errors.full_messages.join(\", \")\n redirect_back_or_default(root_path)\n return\n else\n redirect_to edit_cart_path\n end\n end\n end\n end", "def trade_item_params\n params.require(:trade_item).permit(:number, :item_id)\n end", "def sell_shipping_profile_item_create (payload, item_id, params={})\r\n url = api_url \"/sell/shipping_profiles/items​/#{item_id}\"\r\n load = MultiJson.dump payload\r\n req = request_params(params)\r\n\r\n feed_or_retry do\r\n RestClient.post url, load, req \r\n end \r\n end", "def create_transfer(options = {})\n required_params = %i( amount currency)\n required_params_present = required_params.all? { |e| options.keys.include?(e) }\n raise \"Required Argument Error. Must include #{required_params.join(', ')}\" unless required_params_present\n mutually_exclusive_params = %i( merchant pbntag)\n mutually_exclusive_params_present = mutually_exclusive_params.any? { |e| options.keys.include?(e) }\n raise \"Required Argument Error. Must include one of #{mutually_exclusive_params.join(', ')}\" unless required_params_present\n body = {\n cmd: \"create_transfer\",\n amount: options[:amount],\n currency: options[:currency],\n }\n body[:merchant] = options[:merchant] if options[:merchant]\n body[:pbntag] = options[:pbntag] if options[:pbntag]\n body[:auto_confirm] = 1 if options[:auto_confirm]\n post body\n\n end", "def generate_item(item)\n item\n end", "def create\n \n #debug\n write_log(\n Const::SL::LOG_PATH_SL,\n \"items_controller#create(params[:item] => #{params[:item]})\",\n # __FILE__,\n __FILE__.split(\"/\")[-1],\n __LINE__.to_s)\n\n \n @item = Item.new(params[:item])\n\n respond_to do |format|\n if @item.save\n format.html { redirect_to @item, notice: 'Item was successfully created.' }\n format.json { render json: @item, status: :created, location: @item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item.errors, status: :unprocessable_entity }\n end\n end\n end", "def ordered_item_params\n params.require(:ordered_item).permit(:order_id, :item_id, :ordered_item[\"quantity_new\"])\n end", "def create\n @ordered_item = OrderedItem.new(params[:ordered_item])\n\n respond_to do |format|\n if @ordered_item.save\n format.html { redirect_to(@ordered_item, :notice => 'Ordered item was successfully created.') }\n format.xml { render :xml => @ordered_item, :status => :created, :location => @ordered_item }\n format.json { render :json => @ordered_item, :status => :created, :location => @ordered_item }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ordered_item.errors, :status => :unprocessable_entity }\n format.json { render :json => @ordered_item.errors, :status => :unprocessable_entity }\n end\n end\n end", "def import_item(item)\n Art.create({\n name: gateway.art_name(item),\n creator: gateway.art_creator(item),\n image: gateway.art_image(item),\n description: gateway.art_description(item),\n source: gateway.art_source,\n source_link: gateway.art_source_link(item),\n additional_images: gateway.art_additional_images(item),\n category: Category.find_or_create_by(name: gateway.art_category(item)),\n creation_date: gateway.art_release_date(item)\n })\n end", "def addIngredient(params)\n parent_item = self.item\n ingredient_item = Item.find(params[:ingredient][:item_id])\n create_params = {\n base_item_id: params[:ingredient][:item_id],\n quantity: params[:ingredient][:quantity],\n basis_of_cost: parent_item.price_basis.to_i,\n formula_id: self.id,\n ndc_number: ingredient_item.ndc_number,\n base_cost: Ingredient.getPrice(\n {basis: parent_item.price_basis.to_i,\n quantity: params[:ingredient][:quantity],\n item_id: params[:ingredient][:item_id]\n })\n }\n Ingredient.create(create_params)\n set_unit_cost\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 buy_requested_item(request, item)\r\n self.overlay.delete_item_request(request.id)\r\n item.price = request.price #The prize given in the request is relevant.\r\n buy(item, true)\r\n end", "def order_item_params\n params.require(:order_item).permit(:description, :item_number, :unit_price, :quantity, :order_id, :user_id)\n end", "def create_line_item_from_inventory_item_id inventory_item_id, qty, include_price_in_expense, include_price_in_revenue, notes\n # Inventory item\n inventory_item = InventoryItem.find(inventory_item_id)\n new_line_items = create_line_item_from_inventory_item(\n inventory_item, qty,\n inventory_item.vendor, account,\n include_price_in_expense, include_price_in_revenue, notes)\n line_items.push(new_line_items)\n new_line_items\n end", "def create\n @ordereditem = Ordereditem.new(ordereditem_params) \n respond_to do |format|\n if @ordereditem.save\n format.html { redirect_to @ordereditem, notice: 'Ordereditem was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ordereditem }\n else\n format.html { render action: 'new' }\n format.json { render json: @ordereditem.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_merchant_with_items\n merchant = Merchant.create(name: \"merchant name\")\n merchant.items << [ Item.create(name: \"item name\", description: \"item description\", unit_price: \"23.22\"),\n Item.create(name: \"item name\", description: \"item description\", unit_price: \"21.22\") ]\n merchant\n end", "def return_item(product)\n Transaction.new(self,product,refund: product.title)\n end", "def create\n @order = Order.new(:customer_id => order_params[:customer_id])\n\n order_params[:line_items].each do |item|\n if !item.empty?\n @order.line_items.new(:product_id => item, :order_id => @order.id)\n @order.update(cost: @order.cost + @order.line_items[0].product.price)\n end\n end\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 create\n @orden_item = OrdenItem.new(orden_item_params)\n @orden_item.orden_id = @orden_item.id_orden\n @orden_item.item_id = @orden_item.id_item\n @orden_item.item_name = @orden_item.item.item_name\n @orden_item.item_image = @orden_item.item.item_image\n @orden_item.item_type = @orden_item.item.item_type\n\n respond_to do |format|\n if @orden_item.save\n format.html { redirect_to @orden_item, notice: 'Orden item was successfully created.' }\n format.json { render :show, status: :created, location: @orden_item }\n else\n format.html { render :new }\n format.json { render json: @orden_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def add(product_object, amount=nil, unit=nil)\n product_object = (product_object)\n product_object.amount = amount if amount\n product_object.unit = unit if unit\n\n cart_item_params = product_object.to_cart_item_params\n existing_item = find_item(cart_item_params)\n\n if existing_item\n existing_item.inc(amount: cart_item_params[:amount])\n else\n cart_items.create!(cart_item_params)\n end\n end", "def buy!(amount, price)\n add_order!(:buy, amount, price)\n end", "def create_inventory_item(to_be_created_inventory_item_params, state)\n return_params = Hash.new(0)\n begin\n if in_it = InventoryItem.create!(\n location: Location.find(to_be_created_inventory_item_params[:location_id]),\n item: Item.find(to_be_created_inventory_item_params[:item_id]),\n inventory_item_state: InventoryItemState.find_by(name: state),\n inventory_item_condition: InventoryItemCondition.find(to_be_created_inventory_item_params[:inventory_item_condition_id]),\n quantity: to_be_created_inventory_item_params[:count])\n else\n return_params[:errors] = inventory_item.errors.full_messages\n in_it = nil\n end\n rescue\n puts \"there is a problem in creating inventory item in Committed state for Item: #{item.name} \"\n end\n return_params[:inventory_item] = in_it\n return return_params\n end", "def create_item(data_bag, item_name, data = {}, metadata = {})\n item = ::SecureDataBag::Item.new(metadata)\n item.raw_data = { 'id' => item_name }.merge(data)\n item.data_bag data_bag\n item\n end", "def create\n @order_item = OrderItem.new(order_item_params)\n @order_item.requested_by = current_user\n\n respond_to do |format|\n if @order_item.save\n format.html { redirect_to @order_item, notice: 'Order item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @order_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @order_item.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @order = current_order\n @order_item = @order.order_items.new(order_item_params)\n if @order.save\n session[:order_id] = @order.id\n end\n head :ok\n\n # @order_item = OrderItems.new(order_item_params)\n # respond_to do |format|\n # if @order_item.save\n # format.html { redirect_to @order_item, notice: 'Order item was successfully created.' }\n # format.json { render :show, status: :created, location: @order_item }\n # else\n # format.html { render :new }\n # format.json { render json: @order_item.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def add(*items, quantity: 1)\n raise 'unable to alter a purchased order' if purchased?\n raise 'unable to alter a declined order' if declined?\n\n cart_items = items.flatten.flat_map do |item|\n if item.kind_of?(Effective::Cart)\n item.cart_items.to_a\n elsif item.kind_of?(ActsAsPurchasable)\n Effective::CartItem.new(quantity: quantity, purchasable: item)\n elsif item.kind_of?(Effective::Order)\n # Duplicate an existing order\n self.note_to_buyer ||= item.note_to_buyer\n self.note_internal ||= item.note_internal\n self.cc ||= item.cc\n\n item.order_items.select { |oi| oi.purchasable.kind_of?(Effective::Product) }.map do |oi|\n purchasable = oi.purchasable\n\n product = Effective::Product.new(name: purchasable.purchasable_name, price: purchasable.price, tax_exempt: purchasable.tax_exempt)\n\n # Copy over any extended attributes that may have been created\n atts = purchasable.dup.attributes.except('name', 'price', 'tax_exempt', 'purchased_order_id').compact\n\n atts.each do |k, v|\n next unless product.respond_to?(\"#{k}=\") && product.respond_to?(k)\n product.send(\"#{k}=\", v) if product.send(k).blank?\n end\n\n Effective::CartItem.new(quantity: oi.quantity, purchasable: product)\n end\n else\n raise 'add() expects one or more acts_as_purchasable objects, or an Effective::Cart'\n end\n end.compact\n\n # Make sure to reset stored aggregates\n assign_attributes(subtotal: nil, tax_rate: nil, tax: nil, amount_owing: nil, surcharge_percent: nil, surcharge: nil, total: nil)\n\n retval = cart_items.map do |item|\n order_items.build(\n name: item.name,\n quantity: item.quantity,\n price: item.price,\n tax_exempt: (item.tax_exempt || false),\n ).tap { |order_item| order_item.purchasable = item.purchasable }\n end\n\n retval.size == 1 ? retval.first : retval\n end", "def create_item_with_location\n inventory_item = FactoryBot.create :inventory_item\n warehouse_location = FactoryBot.create :warehouse_location\n ItemLocation.create(inventory_item_id: inventory_item.id, warehouse_location_id: warehouse_location.id, quantity: inventory_item.quantity)\n\n inventory_item\n end" ]
[ "0.6691924", "0.6266502", "0.62314475", "0.6195867", "0.61193067", "0.6056103", "0.6008871", "0.5976084", "0.5946891", "0.5939792", "0.59351736", "0.59328204", "0.59294873", "0.58686465", "0.5860523", "0.58581656", "0.5846601", "0.5842059", "0.5814926", "0.5803405", "0.5782196", "0.5781015", "0.57735705", "0.5772296", "0.5766469", "0.57553166", "0.574936", "0.5749104", "0.57433563", "0.5730293", "0.5727371", "0.57270163", "0.5723048", "0.5714507", "0.5713417", "0.5710637", "0.5710493", "0.56989956", "0.56756747", "0.56661755", "0.5662238", "0.56609195", "0.5645315", "0.5637697", "0.5634261", "0.5632209", "0.5629215", "0.5619502", "0.56181175", "0.5611014", "0.5608832", "0.55978584", "0.55853015", "0.55711395", "0.55693614", "0.5554974", "0.554408", "0.5542683", "0.5539607", "0.55238265", "0.5523267", "0.5520943", "0.55167264", "0.5516243", "0.55119765", "0.55083716", "0.5505279", "0.550483", "0.55013615", "0.54934686", "0.54870003", "0.5484972", "0.548267", "0.5477252", "0.5472254", "0.547222", "0.54709125", "0.5470406", "0.54701895", "0.54646003", "0.5464361", "0.5461665", "0.546101", "0.5457355", "0.5455283", "0.5448877", "0.5448188", "0.54474896", "0.5446746", "0.544563", "0.54344416", "0.5433765", "0.54252094", "0.54250735", "0.5423806", "0.5423749", "0.5421468", "0.54155296", "0.54140437", "0.54099977" ]
0.8461544
0
Duplicates given existing transfer items into this transfer, useful for creating return transfers.
def duplicate_items_from(items) transaction do items.each do |item| transfer_items << item.dup end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_duplicate(attrs)\n # Note that the duplication is *ONLY* the cart items and no attributes from\n # the originating cart are retained\n cloned = Cart.new(attrs)\n\n # Nor are the cart items fully cloned. Only the fabric variant is\n # retained (and associated denormalized columns)\n cart_items.each do |ci|\n cloned.cart_items.build({\n fabric_variant_id: ci.fabric_variant_id,\n mill_id: ci.mill_id,\n fabrium_id: ci.fabrium_id\n })\n end\n\n # overrides\n cloned.duplicating!\n cloned\n end", "def return!\n self.return_transfer = create_return_transfer(\n store: transfer.store,\n destination: transfer.source\n )\n return_transfer.duplicate_items_from(transfer.transfer_items)\n return_transfer.complete!\n end", "def duplicate\n dup = Order.new\n dup.parent = self\n self.children << dup\n\n [:email,\n :ship_address,\n :bill_address,\n :shipping_method,\n :special_instructions,\n :split_shipment_type,\n :dc_code,\n :order_type].each do |attr|\n value = self.send(attr)\n dup.send(\"#{attr.to_s}=\", value)\n end\n\n # assign line_items\n self.line_items.each { |li| dup.add_variant li.variant, li.quantity }\n\n # set name\n dup.order_name = \"Duplicate of #{self.number}: #{self.order_name}\"\n dup.save!\n dup\n end", "def duplicate_transactions()\n duplicates = Hash.new()\n\n self.duplicate_transactions_by_actor().each do |a, txns|\n txns.each do |txn, val|\n duplicates[txn] = val\n end\n end\n\n duplicates\n end", "def duplicate_objects(objects)\n # TODO: Inform the user when the duplication is complete.\n duplicator.duplicate(objects).tap(&:save!)\n end", "def duplicate\n @copy = self.deep_clone :no_duplicates => true, :never_clone => [:uuid, :updated_at,:created_at]\n @copy.static_page = self.static_page.duplicate\n self.sub_pages.each do |page| \n copy_of_page = page.duplicate\n @copy.sub_pages << copy_of_page\n copy_of_page.save\n end\n @copy.save\n @copy\n end", "def dup_copy\n @num_copies += 1\n @num_in += 1\n\n puts \"Great now we have #{@num_copies}!\"\n end", "def duplicate(i)\n\t\tself.push @storage[i].resource.clone\n\tend", "def merge_duplicates!\n Rails.logger.info \"Merging duplicates of #{url}\"\n duplicates.each do |dupe|\n dupe.merge_with!(self)\n end\n end", "def deepcopy(items)\n case items\n when Hash\n result = {}\n items.each do |k, v|\n result[k] = deepcopy(v)\n end\n result\n when Array\n items.map { |i| deepcopy(i) }\n when Numeric\n items\n when NilClass\n items\n when TrueClass\n items\n when FalseClass\n items\n when String\n items.dup\n else\n STDERR.puts \"Unrecognized item type #{items.class.inspect} in copyfreeze!\"\n items.dup\n end\n end", "def full_dup(progress={})\r\n progress[object_id] = result = dup\r\n exclude = full_dup_exclude\r\n\r\n if exclude.empty?\r\n result.full_dup_no_exclusions(progress)\r\n else\r\n result.full_dup_with_exclusions(progress, exclude)\r\n end\r\n\r\n result\r\n end", "def copied(src_item, item)\n end", "def duplicate\n original_trip = Trip.find(params[:id])\n @trip = original_trip.clone\n @trip.name = \"Copy of #{@trip.name}\"\n @trip.photo_1 = original_trip.photo_1 unless original_trip.photo_1.blank?\n @trip.photo_2 = original_trip.photo_2 unless original_trip.photo_2.blank?\n @trip.photo_3 = original_trip.photo_3 unless original_trip.photo_3.blank?\n @trip.photo_4 = original_trip.photo_4 unless original_trip.photo_4.blank?\n original_trip.products.each{|x| @trip.products << x}\n original_trip.destinations.each{|x| @trip.destinations << x}\n original_trip.accommodations.each{|x| @trip.accommodations << x}\n original_trip.activities.each{|x| @trip.activities << x}\n original_trip.pickup_dropoff_times.each{|x| @trip.pickup_dropoff_times << x.clone}\n @trip.pickup_dropoff_times.each do |pickup_time|\n if pickup_time.limit == nil\n pickup_time.update_attribute(:limit, 0)\n end\n pickup_time.update_attribute(:places_cache, 0)\n end\n #original_trip.pickups.each{|x| @trip.pickups << x}\n @trip.display = false\n if @trip.save\n #for trip_flag in trip_flags\n # TripFlag.create(:country_code => trip_flag.country_code, :trip_id => @trip.id)\n #end\n for room in original_trip.rooms\n Room.create(:places => room.places, :trip_id => @trip.id)\n end\n flash[:notice] = \"Trip duplicated\"\n redirect_to :action => \"list\"\n else\n flash[:notice] = \"Could not duplicate trip\"\n end\n end", "def transfer cart\n \t\tself.order_items.destroy_all\n \t\tcart.cart_items.each do |item|\n \t\t\t@order_item = order_items.build(price: item.price, quantity: item.quantity, sku_id: item.sku_id, weight: item.weight, order_id: id)\n \t\t\t@order_item.build_order_item_accessory(accessory_id: item.cart_item_accessory.accessory_id, price: item.cart_item_accessory.price, quantity: item.cart_item_accessory.quantity) unless item.cart_item_accessory.nil?\n \t\t\t@order_item.save!\n \t\tend\n \tend", "def items; @items.clone end", "def uniq(*args)\n clone(:distinct => args)\n end", "def duplicate(stuff)\n duplicated_stuff = []\n stuff = [*stuff] unless stuff.is_a?(Enumerable)\n stuff.each do |obj|\n duplicated_stuff << duplicate_object(obj)\n end\n duplicated_stuff.length == 1 ? duplicated_stuff[0] : duplicated_stuff\n end", "def consolidate_cart(cart:[])\n add_item_counts(cart:cart)\n remove_duplicates(cart:cart)\n cart.inject({}) { |hash, cart_item| hash.merge(cart_item) }\nend", "def duplicate(qty_ordered, qty_received = nil, qty_issued = nil)\n new_item = OrderedLineItem.create!(self.attributes.merge({\n :quantity_ordered => qty_ordered, \n :quantity_received => qty_received, \n :issued_quantity => qty_issued,\n :date_received => nil\n }))\n new_item.line_item_no = self.line_item_no\n new_item.save!\n end", "def remove_duplicates(cart:[])\n cart.uniq\nend", "def duplicate(array)\n array.uniq!\nend", "def completed_transfer_items\n transfer_items.joins(transfer: :shipment).merge(Shipment.complete)\n end", "def dup\n self.class.new(\n items.dup,\n first: first,\n after: after,\n max_page_size: max_page_size,\n last: last,\n before: before\n )\n end", "def uniq(*arguments, &block)\n dup.uniq!\n end", "def dedup(match_section: true)\n unique = Items.new\n each do |item|\n unique.push(item) unless unique.include?(item, match_section: match_section)\n end\n\n unique\n end", "def dup\n\n # duplicate self\n rta = super\n\n # iterate through array and dup each hash\n rta.each_with_index do |w_hash, index|\n\n # dup the hash at this index\n rta[index] = w_hash.dup\n\n # to be complete, also dup the key/values in the hash, in case another hash/array is nested\n w_hash.each_pair do |k, v|\n rta[index][k] = v.dup if v.is_a? Hash\n end\n end\n\n # now everything should have new object_id's\n rta\n end", "def deep_clone\n b = dup\n b.generate_token\n b.save\n basket_items.each {|i| b.basket_items << i.dup}\n b\n end", "def go_single_transfer_in\r\n wait_for_transfer_file_come_up\r\n size = wait_for_the_data_to_all_get_here\r\n @copied_files += copy_files_from_dropbox_to_local_permanent_storage size\r\n create_done_copying_files_to_local_file\r\n wait_till_current_transfer_is_over\r\n\treturn recombinate_files_for_multiple_transfers_possibly\r\n end", "def dup\n\n Workitem.new(Rufus::Json.dup(@h))\n end", "def copy\n dup\n end", "def move_inventory!(transfer)\n updated_quantities = {}\n item_validator = Errors::InsufficientAllotment.new(\"Transfer items exceeds the available inventory\")\n transfer.line_items.each do |line_item|\n inventory_item = self.inventory_items.find_by(item: line_item.item)\n new_inventory_item = transfer.to.inventory_items.find_or_create_by(item: line_item.item)\n next if inventory_item.nil? || inventory_item.quantity == 0\n if inventory_item.quantity >= line_item.quantity\n updated_quantities[inventory_item.id] = (updated_quantities[inventory_item.id] || inventory_item.quantity) - line_item.quantity\n updated_quantities[new_inventory_item.id] = (updated_quantities[new_inventory_item.id] ||\n new_inventory_item.quantity) + line_item.quantity\n else\n item_validator.add_insufficiency(line_item.item, inventory_item.quantity, line_item.quantity)\n end\n end\n \n raise item_validator unless item_validator.satisfied?\n\n update_inventory_inventory_items(updated_quantities)\n end", "def dup\n copy = Queue.new\n copy.size = @size\n copy.elements = @elements\n copy\n end", "def unique_push!(*elements)\n elements.each do |element|\n self << element unless self.include?(element)\n end\n self\n end", "def merge_drops_items(items)\n drop_items = []\n for item in items\n if item != nil\n \n victory_item = nil\n drop_items.each() { |vi| victory_item = vi if vi.item.id == item.id }\n \n if victory_item.nil?\n drop_items.push(VictoryItem.new(item, 1))\n else\n victory_item.quantity += 1\n end\n end\n end\n return drop_items\n end", "def duplicate\n @account = Account.find(params[:id]).dup\n @account.name += ' - NEW'\n @account.username = ''\n @account.password = ''\n end", "def dup\n copy(false)\n end", "def assure_unique_ingredients\n self.ingredients.uniq!\n end", "def pbt_dup_build(item_to_duplicate, &block)\n self.class.pbt_dup_build(self, item_to_duplicate, &block)\n end", "def duplicate\n dup.tap do |c|\n c.page = nil\n columns.each do |column|\n c.columns << column.duplicate\n end\n pictures.each do |picture|\n c.pictures << picture.duplicate\n end\n end\n end", "def duplicate\n begin\n study = Study.find(params[:study_id])\n if study.user_id != session[:user_id]\n redirect_to(manage_study_path)\n return\n end\n \n unless params[:study_name] && params[:study_name] != \"\"\n flash[:error] = \"Please enter a valid name for the duplicate study.\"\n redirect_to(manage_study_path)\n return\n end\n \n s = Study.new\n s.name = params[:study_name]\n s.originator = session[:user_email]\n s.user_id = session[:user_id]\n s.active = false\n s.public = false\n s.n_way = 2\n s.save\n \n items = Item.where(study_id: params[:study_id])\n items.each do |item|\n i = Item.new\n i.study_id = s.id\n i.name = item.name\n i.description = item.description\n i.link = item.link\n i.image = item.image\n i.save\n end\n \n redirect_to(manage_study_path)\n rescue\n redirect_to(manage_study_path)\n end\n end", "def push_dup; end", "def duplicate(duplicate, original)\n @duplicate = duplicate\n @original = original\n @account = @duplicate.account\n @user = @account.user\n\n mail :to => @user.email\n end", "def duplicate\n enhance_settings\n\n p = self.dup\n p.category = 'COPY OF ' + category\n p.created_at = p.updated_at = nil\n p.url = url\n p.attachment = attachment\n\n # allow site to do some customization\n p.send( :duplicate_extra, self ) if p.respond_to?( :duplicate_extra )\n p.save!\n \n p\n end", "def must_have_no_duplicate_products\n seen = []\n items.each do |item|\n if seen.include?(item.product.uuid) then\n errors.add(:items, \"cannot have duplicate products\")\n else\n seen << item.product.uuid\n end\n end\n end", "def dup\n duped_rows = rows.map(&:dup)\n self.class.new(duped_rows)\n end", "def add_hardcoded_duplicates(task)\n task.add_duplicate('t1 duplicate 1')\n task.add_duplicate('t1 duplicate 2')\n end", "def duplicate_transactions_by_actor()\n actor_txns = Hash.new()\n\n my_transactions = self.unique_transactions(self.actor).keys\n\n self.counts.keys.each do |a|\n next if a == self.actor\n uniques = self.unique_transactions(a).keys\n actor_txns[a] = (my_transactions & uniques)\n end\n\n actor_txns\n end", "def rem_dup(list)\n list.uniq!\n return list\nend", "def duplicate\n p = self.dup\n p.name = 'COPY OF ' + name\n p.deleted_at = nil\n p.created_at = p.updated_at = nil\n p.taxons = taxons\n\n p.product_properties = product_properties.map { |q| r = q.dup; r.created_at = r.updated_at = nil; r }\n\n image_dup = lambda { |i| j = i.dup; j.attachment = i.attachment.clone; j }\n\n variant = master.dup\n variant.sku = 'COPY OF ' + master.sku\n variant.deleted_at = nil\n variant.images = master.images.map { |i| image_dup.call i }\n p.master = variant\n\n # don't dup the actual variants, just the characterising types\n p.option_types = option_types if has_variants?\n\n # allow site to do some customization\n p.send(:duplicate_extra, self) if p.respond_to?(:duplicate_extra)\n p.save!\n p\n end", "def push *items\n @items.concat items\n end", "def dup\n clone\n end", "def hash_dup\n save\n end", "def merge!(other)\n update_attributes items: items + other.items\n other.destroy! and self\n end", "def clone_sku!(order_item)\n SkuCloner.new(order_item, sku, :singular).process\n order_item.reload # thanks mongo\n end", "def duplicates(collection); end", "def deep_dup\n dup\n end", "def copy_list \n\n\tend", "def copy\n copy = self.clone\n copy.delete_all\n @collection.each do |obj|\n copy.add_param(obj.key,obj.value,obj.type)\n end\n return copy\n end", "def deep_dup\n # noinspection RubyMismatchedReturnType\n dup\n end", "def active_transfer_items\n transfer_items.joins(transfer: :shipment).merge(Shipment.active)\n end", "def duplicate\n super do |cloned_resource|\n cloned_resource.title = \"Copy #{@resource.title[0...Integral.title_length_maximum - 5]}\"\n cloned_resource.view_count = 0\n cloned_resource.build_active_block_list(content: @resource.active_block_list.content, listable: cloned_resource)\n cloned_resource.tag_list = @resource.tag_list_on(@resource.tag_context)\n cloned_resource.slug = @resource.slug\n cloned_resource.status = :draft\n cloned_resource.published_at = nil\n end\n end", "def dup\n copy = super\n copy.clear_puzzle\n @puzzle.each_with_index do |entry, index|\n copy[index] = entry\n end\n copy\n end", "def dup\n Transaction.new(version: @version,\n inputs: (@inputs || []).map{|txin|txin.dup},\n outputs: (@outputs || []).map{|txout|txout.dup},\n lock_time: @lock_time,\n block_hash: @block_hash,\n block_height: @block_height,\n block_time: @block_time,\n confirmations: @confirmations,\n fee: @fee,\n inputs_amount: @inputs_amount)\n end", "def duplicate(user)\n copy = self.dup\n copy.user = user\n copy.genre_ids = self.genre_ids\n copy.save\n end", "def copy_files\n require 'ftools'\n @files.inject({}) do |result, file|\n seed = (rand * 1000).to_i\n new_path = \"temp_uploads/#{seed}\" + file[1].path.split('/').last\n File.move(file[1].path, new_path, true)\n result[file[0].to_sym] = new_path\n result\n end\n end", "def initialize_transfer\r\n @temp = Array.new\r\n\r\n @lines.each {|line, stations|\r\n stations.each_with_index {|item, index|\r\n @temp.push(item)\r\n }\r\n }\r\n\r\n return @temp.select {|e| @temp.count(e) > 1}.uniq\r\n end", "def to_a\n items.deep_dup\n end", "def copy(cleanse = true)\n a = dup\n a.cleanse if cleanse\n fta_service_types.each do |x|\n a.fta_service_types << x\n end\n fta_mode_types.each do |x|\n a.fta_mode_types << x\n end\n a\n end", "def dup_and_save\n new_q = self.amoeba_dup\n new_q.sort_order = self.sort_order.to_i + 1\n new_q.save\n new_q\n end", "def remove_duplicates\n return @remove_duplicates if @set_remove_duplicates\n @remove_duplicates ||= true\n end", "def pbt_deep_dup_build(item_to_duplicate, &block)\n self.class.pbt_deep_dup_build(self, item_to_duplicate, &block)\n end", "def copy_object_set\n @objects.clone\n end", "def duplicate(from)\n @bits.each_index {|i| @bits[i] = from.getWord(i)}\n end", "def deep_dup; end", "def remove_duplicates()\n self.duplicate_transactions_by_actor().each do |a, txns|\n # Spaceship operator, if my actor is of greater value than theirs, skip because they should remove the dupe\n next if (self.actor <=> a) == 1\n txns.each do |txn|\n self.counts[self.actor][\"txns\"].delete(txn)\n end\n end\n end", "def copy\n\t\tplayitems = PlaylistMedia.find(params[:items])\n\t\t@playlist = Playlist.find(params[:playlist])\n\t\t\n\t\tPlaylistMedia.transaction do\n\t\t\tplayitems.each do |item|\n\t\t\t\tPlaylistMedia.create(item.attributes.merge({:playlist_id => @playlist.id, :id => nil, :published => false}))\n\t\t\tend\n\t\tend\n\t\t\n\t\trespond_with(@playlist) do |format|\n\t\t\tformat.js { render :action => 'update_playlist', :layout => false }\n\t\tend\n\tend", "def __deep_copy__\n self.class.new(aliases) do |copy|\n each do |entry|\n copy.push(entry.__deep_copy__)\n end\n end\n end", "def full_dup_with_exclusions(progress, exclude)\r\n each_index do |name|\r\n unless exclude.include?(name)\r\n value = self[name]\r\n value = progress[value.object_id] || value.full_dup(progress)\r\n self[name] = value\r\n end\r\n end\r\n end", "def dup\n duplicate = ManyValues.new(@details, @attribute)\n duplicate.values = self.values.map { |v| v.dup }\n duplicate\n end", "def deep_dup\n map(&:deep_dup)\n end", "def create\n @transfer = Transfer.new(transfer_params)\n respond_to do |format|\n if !params[:transfer][:items].nil?\n total = 0\n params[:transfer][:items].each do |f| \n item = Item.where([\"id = #{f}\"]).first\n total += item.amount\n end\n account = Account.where([\"id = #{@transfer.account_id}\"]).first\n new_total = account.amount - total\n if new_total > 0 \n if @transfer.save\n account.update(amount: new_total)\n params[:transfer][:items].each do |f| \n Item.where([\"id = #{f}\"]).first.update(transfer_id: @transfer.id)\n end\n \n format.html { redirect_to accounts_path, notice: \"Transfer was successfully created.\" }\n format.json { render :show, status: :created, location: @transfer }\n end\n else\n format.html { redirect_to budgets_url, notice: \"The account hasn't got enough money\"}\n format.json { render json: @transfer.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def clean_up_dupes(dupes, output)\n unless dupes.empty?\n dupes.uniq.each do |sequence|\n output.delete sequence\n end\n end\n\n output\n end", "def duplicate!\n ff = amoeba_dup\n ff.save\n ff\n end", "def recombinate_files_for_multiple_transfers_possibly\r\n got_end_big_transfer = false\r\n \tif @current_transfer_file =~ /recombinate_ok/\r\n\t recombinate_files_split_piece_wise @copied_files\r\n\t @copied_files = []\r\n\t got_end_big_transfer = true\r\n\tend\r\n\t@current_transfer_file = nil\r\n\tgot_end_big_transfer\r\n end", "def dedup(sources)\n merged = sources.map do |source|\n all = sources.select { |el| el[:url] == source[:url] }\n all.inject(&:merge)\n end\n merged.uniq\n end", "def transfer(item)\n base = File.basename(item.to_s.chomp)\n cmd = \"#{@rsync_cmd} #{@origin}/#{base} #{@dst}\"\n SingleLogger.instance.info cmd\n `#{cmd}`\n end", "def duplicate\n super do |cloned_resource|\n cloned_resource.title = \"Copy #{@resource.title}\"\n end\n end", "def transfers\n self.ListTransfers.first.map { |t| map_transfer(t) }\n end", "def clone\n copy = super\n transaction do\n copy.save!\n\n %w[\n registration_information support information_source advance_directive\n ].each do |assoc|\n copy.send(\"#{assoc}\\=\", send(assoc).clone) if send(assoc)\n end\n\n %w[\n patient_identifiers languages providers medications allergies conditions\n all_results immunizations encounters procedures medical_equipments social_history insurance_providers\n ].each do |assoc|\n send(assoc).each do |item|\n copy.send(assoc) << item.clone\n end\n end\n\n end\n copy\n end", "def shuffle\n dup.shuffle!\n end", "def diff(items)\n a = clone\n b = items.clone\n\n a.delete_if do |item|\n if b.include?(item)\n b.delete(item)\n true\n else\n false\n end\n end\n { added: b, deleted: a }\n end", "def duplicates\n # isolate time period from request params\n start_time = params[:from]\n end_time = params[:to]\n\n exchanges = []\n # target specific payouts in time period\n payouts = Payout.where(\"timestamp > ? AND timestamp <= ?\", start_time, end_time).order('timestamp')\n\n # iterate through targeted payouts and create transaction array\n payouts.each do |p|\n exchanges.push(p.exchange_id)\n end\n\n # check for duplicates\n duplicates = exchanges.group_by { |v| v }.select { |k, v| v.count > 1 }.keys\n puts duplicates\n render json: {status: 'SUCCESS', data: [transactions: duplicates]}, status: :ok\n end", "def consolidate_cart(cart)\n # code here\n new_hash = {}\n cart.each do |items|\n items.each do |name, attributes|\n if new_hash[name]\n new_hash[name][:count] += 1 #adds a count of one to each item when there are no duplicates\n else\n new_hash[name] = attributes\n new_hash[name][:count] = 1\n end\n end\n end\n new_hash\nend", "def dup\n clone = super\n clone.name = \"Clone of #{self.name}\"\n clone.institution_default = false\n # The instance requires an ID for MetadataProfileElement validations.\n clone.save!\n self.elements.each { |e| clone.elements << e.dup }\n clone\n end", "def dedupe\n deduped_direct = []\n deduped_query_links = []\n\n @raw_multi_query_links.each do |_key, value|\n deduped_direct.push(value['direct']).compact\n deduped_query_links.push(value['query_links']).compact\n end\n deduped = {\n 'direct' => deduped_direct,\n 'query_links' => deduped_query_links\n }\n deduped\n end", "def copy(cleanse = true)\n a = dup\n a.cleanse if cleanse\n vehicle_features.each do |x|\n a.vehicle_features << x\n end\n fta_service_types.each do |x|\n a.fta_service_types << x\n end\n fta_mode_types.each do |x|\n a.fta_mode_types << x\n end\n a\n end", "def copy(cleanse = true)\n a = dup\n a.cleanse if cleanse\n vehicle_features.each do |x|\n a.vehicle_features << x\n end\n fta_service_types.each do |x|\n a.fta_service_types << x\n end\n fta_mode_types.each do |x|\n a.fta_mode_types << x\n end\n a\n end", "def copy\n workflows = Workflow.accessible_by(@context).where(id: params[:item_ids])\n\n new_workflows = workflows.map { |wf| copy_service.copy(wf, params[:scope]).first }\n\n # TODO: change old UI to handle json-response!\n respond_to do |format|\n format.html do\n redirect_to pathify(workflows.first),\n success: \"The workflow has been published successfully!\"\n end\n\n format.json { render json: new_workflows, root: \"workflows\", adapter: :json }\n end\n end", "def reverse_dup_copy(new_stack)\n new_stack.objects = self.objects.dup\n end", "def clone\n dup\n end" ]
[ "0.605014", "0.60479575", "0.5778689", "0.57436013", "0.55729043", "0.5521336", "0.55010784", "0.5485309", "0.54599166", "0.5440926", "0.54229176", "0.5409679", "0.538437", "0.5382901", "0.53795326", "0.53790027", "0.53771126", "0.5372685", "0.5371709", "0.5361232", "0.53530306", "0.5339482", "0.53378034", "0.5271253", "0.52497387", "0.52478427", "0.52408695", "0.5227007", "0.521678", "0.52144176", "0.5199219", "0.51582587", "0.51509225", "0.51196253", "0.51028913", "0.51022446", "0.5095781", "0.50955045", "0.5085686", "0.50718564", "0.50670207", "0.50543815", "0.504778", "0.504428", "0.50318277", "0.5019959", "0.50146556", "0.50134444", "0.49962902", "0.49931476", "0.49919596", "0.49842438", "0.4970489", "0.49617097", "0.49507254", "0.49471286", "0.49432006", "0.49431202", "0.49418506", "0.4923547", "0.49233606", "0.4922134", "0.49075493", "0.4904129", "0.49031568", "0.48986012", "0.48939872", "0.48929933", "0.48920006", "0.4888749", "0.488137", "0.4880947", "0.4880409", "0.4876246", "0.4871348", "0.48673233", "0.4864666", "0.48645708", "0.48590732", "0.48572248", "0.48493358", "0.4848196", "0.484136", "0.48367855", "0.48364025", "0.48353663", "0.4834891", "0.48337844", "0.4833312", "0.48268634", "0.48204562", "0.48184317", "0.4809514", "0.48062167", "0.48032713", "0.4800597", "0.4800597", "0.47996658", "0.4799293", "0.47814143" ]
0.82348144
0
Loads a single order item from given stock into the transfer as one or more transfer items. Updates the stock accordingly. Attempts several strategies until one returns true to denote the item has been loaded or the item is left (partially) unloaded.
def load_item!(order_item, stock) if !order_item.product.tracked_stock? || source.enable_gateway? load_item_from_infinite_stock(order_item) && return end stock_items = stock.select { |item| item.product == order_item.product } return false if stock_items.none? if order_item.lot_code.present? load_item_by_lot_code(order_item, stock_items) else load_item_from_stock(order_item, stock_items) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_item_from_stock(order_item, stock_items)\n amount = order_item.waiting\n stock_items.each do |item|\n all = item.available\n next if all <= 0\n\n if amount <= all\n # This inventory item satisfies the amount, we're done.\n item.reserved += amount\n return create_item_from(order_item, item.code, item.expires_at, amount)\n else\n # Load all of this item and continue with the remaining amount.\n item.reserved += all\n create_item_from(order_item, item.code, item.expires_at, all)\n amount -= all\n end\n end\n end", "def load_item_from_infinite_stock(order_item)\n create_item_from(order_item, order_item.order.number)\n true\n end", "def load!\n transfer = find_or_create_transfer\n transfer.load!(order.items_waiting)\n end", "def load!(order_items)\n transaction do\n products = order_items.map(&:product)\n stock = source.inventory_items.for(products)\n order_items.each do |order_item|\n load_item!(order_item, stock)\n end\n end\n end", "def load_item_by_lot_code(order_item, stock_items)\n item = stock_items.find { |item| order_item.lot_code == item.code }\n\n # If the order item has a serial number, try lot code part only.\n if item.nil? && order_item.lot_code['-']\n lot_code_part = order_item.lot_code.split('-').first\n item = stock_items.find { |item| lot_code_part == item.code }\n end\n\n # If a match was found, load the item and return. If a partial\n # match set a lot code part above, use that, or provide nil\n # to use the code on the order item.\n if item.present?\n item.reserved += order_item.amount\n return create_item_from(order_item, lot_code_part, item.expires_at)\n end\n\n false # Failed to load the item.\n end", "def load_shopping_item_or_not\n @shopping_item_id = nil\n\n if si = params[:shopping_item]\n if si[:offer_id]\n # this is a shopping item that references an offer and cart\n @shopping_item_id = si[:offer_id]\n @admin_customer_offer = Admin::Customer::Offer.find(si[:offer_id])\n @cart = Shopping::Cart.find_by_id(si[:cart_id])\n session[:admin_customer_offer_id] = @admin_customer_offer.id\n raise \"cart offer email mismatch\" if (@cart.email.id != @admin_customer_offer.email.id)\n elsif si[:piece_id]\n @shopping_item_id = si[:piece_id]\n end\n end\n\n unless @shopping_item_id\n @admin_customer_offer = Admin::Customer::Offer.find(session[:admin_customer_offer_id]) if session[:admin_customer_offer_id]\n @shopping_item_id = @admin_customer_offer.id if @admin_customer_offer\n end\n\n end", "def trade_item_with_party(new_item, old_item)\n return false if new_item && !$game_party.has_item?(new_item)\n temp = UI_MSG::ITEM\n UI_MSG.const_set(:ITEM, false)\n $game_party.gain_item(old_item, 1)\n $game_party.lose_item(new_item, 1)\n UI_MSG.const_set(:ITEM, temp)\n return true\n end", "def reload!\n transfer = find_or_create_transfer\n transfer.transfer_items.destroy_all\n load!\n end", "def trade_item_with_party(new_item, old_item)\n return false if new_item && !$game_party.has_item?(new_item)\n $game_party.force_gain_item(old_item, 1)\n $game_party.force_gain_item(new_item, -1)\n return true\n end", "def use_item(item, entity)\n index = has_item(item)\n if index\n actual_item = inventory[index].first\n actual_item.use(self, entity)\n remove_item(actual_item) if actual_item.consumable\n else\n print NO_SUCH_ITEM_ERROR\n end\n end", "def load_item_list\n @item_quantity = []\n get_list_item\n get_definitive_list_price\n check_if_shop_empty\n @index = 0\n @last_index = @list_item.size - 1\n end", "def update_item\n # continue input if item should be used\n return false if !self.check_item_condition?\n # if item not usable or item use process not executed and no selection\n if $game_player.battler.item == 0 ||\n !$game_player.use_item($data_items[$game_player.battler.item]) &&\n $game_temp.select_data == nil\n # play buzzer, can't use\n $game_system.se_play($data_system.buzzer_se)\n end\n # stop input update\n return true\n end", "def populate\n @order = current_order(session)\n variant_id = params[:variant_id]\n \n new_line_item = Breeze::Commerce::LineItem.new(:variant_id => variant_id, :quantity => params[:quantity] || 1)\n existing_line_item = @order.line_items.unarchived.where(:variant_id => variant_id).first \n if existing_line_item\n existing_line_item.quantity += new_line_item.quantity\n existing_line_item.save\n else\n @order.line_items << new_line_item\n end\n\n @order.save\n end", "def sync_local_to_magento\n response = API::SOAP::CatalogInventory::StockItem.update(self)\n\n if response.success?\n self.sync_needed = false\n return true\n else\n errors.add(:base, response.body[:faultstring])\n return false\n end\n end", "def stock_item(variant_id, user_id = nil, original_stock_location_id = nil)\n return super(variant_id) unless reserved_items?\n raise(\n UserRequiredArgumentError,\n Spree.t(:user_id_required_for_reserved_stock_location)\n ) unless user_id.present?\n items = stock_items.where(variant_id: variant_id, user_id: user_id)\n items = items.where(\n original_stock_location_id: original_stock_location_id\n ) unless original_stock_location_id.blank?\n items.order(:id).first\n end", "def set_item\n @item = @order.order_items\n .where(product_id: params[:product_id])\n .first_or_initialize(order_id: @order.id)\n end", "def import\n if gateway.valid?\n gateway.items.map do |item|\n import_item(item)\n end\n else\n @errors = gateway.errors\n false\n end\n end", "def import_produit_assoc(elt, produit_assoc, index)\n import_ok = true\n produit_assoc.facture_id = elt.id if elt.kind_of?(Facture)\n produit_assoc.pulve_id = elt.id if elt.kind_of?(Pulve)\n if produit_assoc.save\n # update stock produit according to putoproduit quantity \n # amount of stock increase when produit is baught\n produit_assoc.produit.update_protofacture_stock\n import_ok = true\n else\n import_ok = false\n produit = produit_assoc.try(:produit).try(:name) || ''\n self.add_error(\"produit '#{produit}' non valide\", index)\n self.add_error(produit_assoc.errors, index)\n end\n return import_ok\n end", "def load_item(data_bag, item_name, metadata = {})\n item = ::SecureDataBag::Item.load(data_bag, item_name, metadata)\n item\n end", "def update_order_item\n \n end", "def set_stock_item\n @stock_item = StockItem.find(params[:id])\n end", "def set_stock_item\n @stock_item = StockItem.find(params[:id])\n end", "def update\n # puts \"params: #{params.to_hash}\"\n return_order_items = JSON.parse(params[:order][:items]) \n\n # puts \"Params: #{return_order_items}\"\n\n @order = Order.find(params[:id])\n\n\n ActiveRecord::Base.transaction do\n return_order_items.each do |item|\n if params[:order].has_key?(:supplier) \n @ordered_item = Item.find_by_id(item[\"id\"].to_i)\n @ordered_item.decrement!(:remaining_quantity, item[\"quantity\"].to_i)\n else\n @ordered_item = Item.find_by_id(item[\"id\"].to_i)\n @ordered_item.increment!(:remaining_quantity, item[\"quantity\"].to_i)\n end\n end\n\n @order.return = true\n if @order.save\n @current_user = current_user\n redirect_to :root, notice: 'Return Order was successfully created.'\n else\n render :new\n end\n end\n\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 load_inventory(first)\n first ? setup_inventory : restore_inventory\n log(RuneRb::GLOBAL[:COLOR].green(\"Loaded Inventory for #{RuneRb::GLOBAL[:COLOR].yellow(@profile.name)}\")) if RuneRb::GLOBAL[:DEBUG]\n end", "def gather_item\n local_item = FoodItem.fetch_local_item @item_id\n return local_item unless local_item.nil?\n\n item_id = @item_id.split('-')\n remote_item = fetch_remote_item item_id[0], item_id[1]\n remote_item = FoodItem.new_item remote_item\n\n return remote_item unless remote_item.nil?\n\n nil # fallback\n end", "def set_ordered_item\n @ordered_item = OrderedItem.find(params[:id])\n end", "def set_ordered_item\n @ordered_item = OrderedItem.find(params[:id])\n end", "def set_order_pack_item\n @order_pack_item = OrderPackItem.find(params[:id])\n end", "def load_item\n @item = Item.find(params[:id]) rescue nil\n \n render_404 unless @item\n end", "def load_inv(object, game_objects)\n\n if not object.respond_to? :inventory\n #log \"#{object} has no inventory\"\n return\n elsif object.inventory.nil? #I can't think of when this might happen\n object.inventory = Inventory.new\n #log \"#{object} had a nil inventory\"\n return\n elsif object.inventory.empty?\n object.inventory = Inventory.new(object.inventory.capacity)\n #log \"#{object} has nothing in its inventory\"\n return\n end\n\n inv = Inventory.new(object.inventory.capacity)\n\n object.inventory.each do |inv_obj|\n if game_objects.include? inv_obj[0]\n obj = game_objects[inv_obj[0]]\n pos = inv_obj[1]\n unless obj.is_a? Player\n inv.add(obj, pos)\n obj.container = object.goid\n end\n #log \"Added #{obj} to #{object}\"\n else\n log \"Don't have #{inv_obj} loaded...what does that mean? (Probably a Player)\", Logger::Medium\n end\n end\n\n object.inventory = inv\n end", "def update_product\n if inbound_order? || quantity_adjustment?\n product.update(stock: product.stock + quantity)\n else outbound_order?\n product.update(stock: product.stock - quantity)\n end\n end", "def refresh!(quantity)\n raise_error?(quantity)\n update_quantity!(quantity)\n save_order!\n order_maker.handle_coupon!\n recalibrate_order!\n lock!\n return_with(:success, order_item: order_item)\n rescue OrderMaker::Error => exception\n # remove! if package_sku # risky logic should be put somewhere else\n return_with(:error, error: exception.message)\n end", "def item_stocking?(item)\n item_stocking_items.include?(item)\n end", "def unit_item_ok\n return refresh_items if @unit_item_list.tb_unit.nil?\n @unit_item_list.activate\n return if (item = @unit_item_list.item).nil?\n @unit_item_list.tb_unit.lose_item(item, 1) \n TactBattleManager.rm_unit_item(@actor.id, item)\n $game_party.gain_item(item, 1)\n refresh_items\n end", "def set_order_item\n @order_item = @order.order_items.find(params[:id])\n end", "def pick_up(item_name)\n if current_room.has_item(item_name)\n item = current_room.items.find { |thing| thing.name == item_name }\n @player.add_to_inventory(item)\n current_room.remove_one(item)\n else\n puts \"Sorry, that item is not in this room. Try again.\"\n end\n end", "def buy_item(user, item)\r\n if(self.has_enough_money(item) and user.has_item(item))\r\n self.get_item(user, item)\r\n self.pay_amount(user, item.get_price)\r\n else\r\n #transaction not possible\r\n end\r\n end", "def use_item_by_object(item, e)\n index = has_item_by_object(item)\n if (index != -1)\n actual_item = inventory[index].first\n actual_item.use(e)\n if actual_item.consumable then remove_item(actual_item) end\n else\n print \"What?! You don't have THAT!\\n\\n\"\n end\n end", "def take(item_name)\n if current_room.npc && current_room.npc.has_item(item_name)\n npc_item = item_to_take(item_name)\n @player.add_to_inventory(npc_item)\n # this just doesn't seem to remove the item from NPC inventory no matter what I do :(\n current_room.npc.remove_from_inventory(npc_item)\n else\n puts \"Sorry, that item isn't here.\"\n end\n end", "def set_ordereditem\n @ordereditem = Ordereditem.find(params[:id])\n end", "def pick_up(item)\n\n puts \"in pick_up item = #{item}\"\n puts \"equipped_weapon #{equipped_weapon}\"\n\n # binding.pry\n\n if (CAPACITY - items_weight) >= item.weight\n @items << item\n\n # binding.pry\n if item.class == PlasmaCannon || item.class == Laser\n # binding.pry\n self.equipped_weapon = item\n end\n\n true\n\n else\n false\n end\n\n end", "def move_inventory!(transfer)\n updated_quantities = {}\n item_validator = Errors::InsufficientAllotment.new(\"Transfer items exceeds the available inventory\")\n transfer.line_items.each do |line_item|\n inventory_item = self.inventory_items.find_by(item: line_item.item)\n new_inventory_item = transfer.to.inventory_items.find_or_create_by(item: line_item.item)\n next if inventory_item.nil? || inventory_item.quantity == 0\n if inventory_item.quantity >= line_item.quantity\n updated_quantities[inventory_item.id] = (updated_quantities[inventory_item.id] || inventory_item.quantity) - line_item.quantity\n updated_quantities[new_inventory_item.id] = (updated_quantities[new_inventory_item.id] ||\n new_inventory_item.quantity) + line_item.quantity\n else\n item_validator.add_insufficiency(line_item.item, inventory_item.quantity, line_item.quantity)\n end\n end\n \n raise item_validator unless item_validator.satisfied?\n\n update_inventory_inventory_items(updated_quantities)\n end", "def update\n @order.earliest_pickup_date = calculate_earliest_pickup_date(:update)\n # Save off original quantity for order_products\n original_quantities = {}\n @order.order_products.each { |order_product| original_quantities[order_product.id] = order_product.quantity }\n respond_to do |format|\n if @order.update(order_params)\n okay = true\n @order.order_products.each do |order_product|\n new_quantity = order_product.quantity\n original_quantity = original_quantities[order_product.id]\n unless (new_quantity == original_quantity)\n product = order_product.product\n new_quantity_in_stock = (product.quantity_in_stock + original_quantity - new_quantity)\n if new_quantity_in_stock < 0 # Desired quantity no longer available\n okay = false if okay\n # Update the order the best we can and notify user of discrepancy\n new_quantity_in_stock = 0\n # The original quantity was already subtracted from the stock; quantity should never have to decrease below what was previously ordered\n new_quantity = original_quantity + product.quantity_in_stock\n order_product.update_attributes(quantity: new_quantity)\n end\n product.update_attributes(quantity_in_stock: new_quantity_in_stock)\n end\n end\n redirect_to(edit_order_path(@order), notice: t('orders.not_available')) and return if (!okay) # \"One or more of the products you selected is not available in the desired quantity. Please review the updated order.\"\n if session[:showing_user]\n format.html { redirect_to @order.user, notice: t('orders.create') } # \"Order was successfully updated.\"\n format.json { head :no_content }\n else\n format.html { redirect_to orders_path, notice: t('orders.create') } # \"Order was successfully updated.\"\n format.json { head :no_content }\n end\n else\n format.html { render action: 'edit' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_items\n @existing_items = []\n @order.items.each { |i| @existing_items << i.id }\n\n # detail and reproduction_pages will come in as attributes of items, but they actually belong to the item_order\n # so look for those, then add them to the correct record in @item_orders\n\n @item_orders.each do |item_order|\n # add item to order\n if !@existing_items.include?(item_order['item_id'].to_i)\n item_order_record = @order.item_orders.create!(item_id: item_order['item_id'], archivesspace_uri: item_order['archivesspace_uri'], user_id: current_user.id, active: true)\n else\n item_order_record = @order.item_orders.where(item_id: item_order['item_id']).first\n item_order_record.update_attributes(archivesspace_uri: item_order['archivesspace_uri'])\n @order.reload\n # delete id from @existing_items array to track associations to be deleted\n @existing_items.delete(item_order['item_id'])\n end\n\n if item_order['reproduction_spec']\n create_or_update_reproduction_spec(item_order_record.id, item_order['reproduction_spec'])\n end\n\n # handle fees\n if @order_sub_type_name == 'reproduction_fee'\n if item_order['order_fee']\n create_or_update_order_fee(item_order_record.id, 'ItemOrder', item_order['order_fee'])\n end\n else\n # delete any existing fee for this item_order if it exists\n OrderFee.where(record_id: item_order_record.id,\n record_type: 'ItemOrder').each { |f| f.destroy! }\n end\n end\n\n @existing_items.each do |item_id|\n @order.item_orders.where(item_id: item_id).each { |io| io.destroy! }\n end\n end", "def item_stock(item)\n item_stocks.create(item_id: item.id)\n end", "def checkout(attributes)\n completed = false\n transaction do\n update!(attributes.merge(status: \"Completed\"))\n orderitems.each do |item|\n raise ActiveRecord::Rollback unless item.reduce_stock\n end\n completed = true\n end\n\n completed\n end", "def complete!\n now = Time.current\n transaction do\n transfer_items.each do |item|\n source.present? && source.destock!(item, now, self)\n destination.present? && destination.restock!(item, now, self)\n end\n update completed_at: now\n end\n end", "def pick_up(item)\n return false if items_weight + item.weight > MAX_WEIGHT\n\n @equipped_weapon = item if item.is_a?(Weapon)\n @items << item\n end", "def update\n @order = current_order\n if @order.may_add?\n @order_item = @order.order_items.find(params[:id])\n @order_item.update_attributes(order_item_params)\n @order_items = @order.order_items\n end\n end", "def load_order!\n @order = current_user.orders.find params[:id]\n # @order = @cookbook.get_active_reorder(params[:id]) if @cookbook.is_owner? current_user\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def transfer_stocks()\n customer = Portfolio.find(self.buyer_id)\n #Here, we take a string from the transactor object and convert it to an array\n stocks_array = self.stocks_to_move.split(',')\n stocks_array = stocks_array.take(self.moveable)\n \n for i in 0..stocks_array.length - 1 do\n stock = Stock.find(stocks_array[i].tr('[]','').to_i)\n #Stock is transfered to new owner\n stock.portfolio_id = customer.id\n stock.active = true\n if stock.ipo?\n stock.ipo = false\n end\n stock.save!\n end\n end", "def import_supply_items(filename = self.import_filename)\n # before calling this in a descended class, you must set up these variables:\n # @supplier = The supplier to import for (an AR object)\n SupplyItem.expire_category_tree_cache(@supplier)\n\n ThinkingSphinx::Deltas.suspend :supply_item do\n File.open(filename, \"r:utf-8\").each_with_index do |line, i|\n next if i == 0 # We skip the first line, it only contains header information\n data = parse_line(line)\n next if data == false\n next if data[:supplier_product_code].blank? # The line is incomplete, skip it\n # check if we have the supply item\n local_supply_item = SupplyItem.where(:supplier_id => @supplier.id,\n :supplier_product_code => data[:supplier_product_code]).first\n # We do not have that supply item yet\n if local_supply_item.nil?\n si = new_supply_item(data)\n if si.save\n supplier_logger.info(\"[#{DateTime.now.to_s}] SupplyItem create: #{si.inspect}\")\n else\n supplier_logger.error(\"Failed adding supply item during sync: #{si.inspect.to_s}, #{si.errors.to_s}\")\n end\n # We already have that supply item and need to update that and related product information\n else\n update_supply_item(local_supply_item, data)\n end\n end\n end\n Product.update_price_and_stock # Sync available products to the now changed supply items\n CategoryDispatcher.create_unique_combinations_for(@supplier)\n end", "def take_item(command)\n if @current_room.has_item?(command) # item isn't in current room\n self.new_current_item(command)\n # Remove from room and add to backpack\n @current_room.remove_item(command)\n @player.pick_up(command)\n puts \"\\nYou have picked up a #{@current_item.name}\"\n puts @current_item.collect_description + \"\\n\\n\"\n else\n puts \"This item isn't here\\n\"\n end\n end", "def return_item_to_stock(product_id)\n\t\tproduct = Product.find(product_id)\n\t\tproduct.stock += 1\n\t\tproduct.save\n\tend", "def set_trade\n\t\t\tbegin \n\t\t\t\t@trade = Trade.find(params[:id])\n\t\t\t\tif params[:item_id] \n\t\t\t\t\t@item = Item.find_by_id(params[:item_id])\n\t\t\t\tend\n\t\t\trescue ActiveRecord::RecordNotFound\n\t\t\t\tredirect_to mines_swapper_url, :notice => \"That Trade could not be found\"\n\t\t\tend\n end", "def util_item_open_party_sequence(item, extend_data, result_process)\n call_scene(GamePlay::Party_Menu, @team || $actors, :item, extend_data, no_leave: false) do |scene|\n if $game_temp.in_battle && scene.return_data != -1\n @return_data = [item.id, extend_data, scene.return_data]\n @running = false\n next\n end\n $bag.remove_item(item.id, 1) if item.limited && scene.return_data != -1\n result_process&.call\n end\n return false unless @running\n\n return extend_data\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def activate\n if player.location.has_items?\n # set inventory index being considered for get\n @index = 0\n @item = player.location.inventory[@index]\n if player.inventory.can_fit?(@item)\n if player.location.inventory.size == 1 && @item.quantity == 1\n # a single item at the location so just get it\n player.get(@item)\n game.change_state(Map.new)\n else\n game.messages << \"Do you want to pick up #{@item}? Y/N\"\n end\n else\n game.messages << 'Your inventory is full.'\n game.change_state(Map.new)\n end\n else\n # no items at location\n game.change_state(Map.new)\n end\n end", "def update_stock\n \tproduct = FileOperations.search_by_name(self)\n \tproduct = product[0].split(';')\n \tself.id = product[0]\n \tself.name = product[1]\n \tself.price = product[2]\n \tself.company = product[3]\n \tself.stock = product[4].to_i - 1\n \tFileOperations.update(self)\n end", "def pbWithdrawItemScreen\n if !$PokemonGlobal.pcItemStorage\n $PokemonGlobal.pcItemStorage = PCItemStorage.new\n end\n storage = $PokemonGlobal.pcItemStorage\n @scene.pbStartScene(storage)\n loop do\n item = @scene.pbChooseItem\n break if item==0\n commands = [_INTL(\"Withdraw\"),_INTL(\"Give\"),_INTL(\"Cancel\")]\n itemname = PBItems.getName(item)\n command = @scene.pbShowCommands(_INTL(\"{1} is selected.\",itemname),commands)\n if command==0 # Withdraw\n qty = storage.pbQuantity(item)\n if qty>1 && !pbIsImportantItem?(item)\n qty = @scene.pbChooseNumber(_INTL(\"How many do you want to withdraw?\"),qty)\n end\n if qty>0\n if !@bag.pbCanStore?(item,qty)\n pbDisplay(_INTL(\"There's no more room in the Bag.\"))\n else\n dispqty = (pbIsImportantItem?(item)) ? 1 : qty\n itemname = PBItems.getNamePlural(item) if dispqty>1\n pbDisplay(_INTL(\"Withdrew {1} {2}.\",dispqty,itemname))\n if !storage.pbDeleteItem(item,qty)\n raise \"Can't delete items from storage\"\n end\n if !@bag.pbStoreItem(item,qty)\n raise \"Can't withdraw items from storage\"\n end\n end\n end\n elsif command==1 # Give\n if $Trainer.pokemonCount==0\n @scene.pbDisplay(_INTL(\"There is no Jermon.\"))\n return 0\n elsif pbIsImportantItem?(item)\n @scene.pbDisplay(_INTL(\"The {1} can't be held.\",itemname))\n else\n pbFadeOutIn(99999){\n sscene = PokemonParty_Scene.new\n sscreen = PokemonPartyScreen.new(sscene,$Trainer.party)\n if sscreen.pbPokemonGiveScreen(item)\n # If the item was held, delete the item from storage\n if !storage.pbDeleteItem(item,1)\n raise \"Can't delete item from storage\"\n end\n end\n @scene.pbRefresh\n }\n end\n end\n end\n @scene.pbEndScene\n end", "def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end", "def check_line_item_in_inventory(line_item)\n # feature flipper\n if Features.inactive?(:refulfill)\n return true\n end\n found = false\n\n if rii = find_match_and_decrement_available(line_item)\n if line_item.order.shipping_address.country.name == 'United States' && rii.vendor == 'bergen'\n line_item.return_inventory_item = rii\n line_item.refulfill_status = 'new'\n found = true\n line_item.save\n elsif line_item.order.shipping_address.country.name == 'Australia' && rii.vendor == 'next'\n line_item.return_inventory_item = rii\n line_item.refulfill_status = 'new'\n found = true\n line_item.save\n end\n end\n found\n end", "def get_item\n \n if active_character\n item = Item.find(params[:item][:id])\n position = params[:item][:container_position]\n \n # swap any existing item in same position\n prev_item = active_character.inventory.find(:first, :conditions => {:container_position => position})\n \n if item.owner == active_character\n if prev_item\n prev_item.container_position = item.container_position\n prev_item.save\n end\n \n item.container_position = position\n item.save\n elsif item.owner == active_character.area\n area = active_character.area\n \n if prev_item\n prev_item.owner = area\n prev_item.save\n \n render_to_area area do |page|\n page.call :addEvent, \"#{h current_user} has dropped #{h prev_item.name}!\"\n page.call 'game.updateDisplayable', prev_item.css_id, prev_item.left, prev_item.top\n end\n end\n \n item.owner = active_character\n item.container_position = position\n item.save\n # Update all clients in area\n render_to_area area do |page|\n page.call :addEvent, \"#{h active_character.name} has picked up #{h item.name}!\"\n page.call :got_item, item.css_id, active_character.id\n end\n end\n end\n \n render :nothing => true\n end", "def pick_up(item)\n @items.push(item) unless items_weight + item.weight > CAPACITY\n @equipped_weapon = item if item.is_a?(Weapon) \n if item.is_a?(BoxOfBolts) \n item.feed(self) if self.health <= 80\n end\n end", "def add_item_to_order(id)\n return if @items[id] <= 0\n\n socket = GameData::Item[id].socket\n get_order(socket) << id unless get_order(socket).include?(id)\n end", "def load_unit(good, x=0, y=0, amt=-1)\n return if @city.warehouse[good] == 0\n\n $ui.top_message _('Where do you want to move these goods to?')\n @scr.print 1, @scr.h-1, '<key>#<default>: ' + _('Move a specific amount of goods')\n @scr.refresh\n\n # get new char\n @scr.x, @scr.y = x, y\n nch = @scr.getch\n \n # ask amount to the user\n if nch == '#'\n amt = $ui.ask_s _('How much of this good do you want to move?')\n amt = amt.to_i\n if amt < 1 or amt > 100\n $ui.messages << 'Invalid amount.'\n @scr.show_cursor = false\n return\n else\n load_unit(good, x, y, amt)\n end\n end\n\n # ask destination\n @scr.show_cursor = false\n nchoice = @units_store[nch]\n if nchoice\n # move goods\n begin\n unit = nchoice[0]\n amt = [100, @city.warehouse[good]].min if amt == -1\n unit.load(good, amt)\n rescue CocivMessage => e\n $ui.messages << e.message\n getch\n end\n else\n invalid_key\n end\n end", "def load!\n update(get_json(url))\n rescue\n @exists = false\n else\n @exists = true\n ensure\n @loaded = true\n end", "def load(units)\n raise GameLogicError.new(\n \"You did not give any units to load!\"\n ) if units.blank?\n\n transporter_location = location\n units.each do |unit|\n raise GameLogicError.new(\n \"Unit #{unit} must be in same location as #{self}!\"\n ) unless unit.location == transporter_location\n\n raise GameLogicError.new(\n \"Cannot load unit #{unit} that is still upgrading!\"\n ) if unit.upgrading?\n end\n \n taken_volume = self.class.calculate_volume(units)\n\n raise GameLogicError.new(\n \"Not enough storage (#{stored}/#{storage\n }) to load all requested units into #{self} (volume #{taken_volume})!\"\n ) if taken_volume > (storage - stored)\n\n self.stored += taken_volume\n save!\n\n update_transporter_units(units, location_point)\n end", "def reorder_stock?\n stock < 100 && !current_reorder ? true : false\n end", "def buy(item)\n raise_no_money! if item.price > pending_amount\n change = calc_change(pending_amount - item.price)\n transfer_pending_to_money\n remove_from_money change\n change\n end", "def buy_item(item)\r\n if !item.active || item.price > self.credits\r\n false\r\n else\r\n seller = item.owner\r\n price = item.price\r\n\r\n seller.give_credits(price)\r\n self.take_credits(price)\r\n seller.remove_item(item)\r\n self.add_item(item)\r\n item.active = false\r\n true\r\n end\r\n end", "def attach_item(item)\r\n equal_item = self.check_for_equal_item(item.name,item.price,item.description)\r\n if equal_item == nil\r\n self.items << item\r\n item.owner = self\r\n item.deactivate\r\n else\r\n equal_item.quantity += item.quantity\r\n equal_item.deactivate\r\n item.delete\r\n end\r\n end", "def activate_item(position)\r\n self.items.fetch(position).activate\r\n end", "def load_object(game_object_id, game_objects)\n object = nil\n file = nil\n\n open_store \"goids\" do |gd|\n file = gd[game_object_id]\n end\n\n if file.nil?\n log \"No file found for that goid (#{game_object_id})\"\n raise MUDError::NoSuchGOID\n end\n\n open_store file do |gd|\n object = Marshal.load(gd[game_object_id])\n end\n\n if object.nil?\n log \"Tried to load object (#{game_object_id}), but got nil\"\n raise MUDError::ObjectLoadError\n end\n\n if object.respond_to? :inventory\n log \"Loading inventory for #{object}\", Logger::Ultimate\n load_too = object.inventory.map{ |e| e[0]}\n object.inventory = Inventory.new(object.inventory.capacity)\n load_too.each do |goid|\n if game_objects.find_by_id(goid)\n obj = game_objects.find_by_id(goid)\n else\n obj = load_object(goid, game_objects)\n end\n\n #Don't want to load players until they are playing.\n #We can add the player to a room once they login, not before.\n object.inventory << obj unless obj.is_a? Player\n obj.container = object.goid\n end\n end\n\n if object.respond_to? :equipment\n log \"Loading equipment for #{object}\", Logger::Ultimate\n load_too = object.equipment.inventory.map{ |e| e[0]}\n object.equipment.inventory = Inventory.new\n load_too.each do |goid|\n if game_objects.find_by_id(goid)\n obj = game_objects.find_by_id(goid)\n else\n obj = load_object(goid, game_objects)\n end\n\n #Don't want to load players until they are playing.\n #We can add the player to a room once they login, not before.\n unless obj.is_a? Player or obj.nil?\n object.equipment.inventory << obj\n obj.info.equipment_of = object.goid\n end\n\n #Remove object if it does not seem to exist any longer\n if obj.nil?\n object.equipment.delete(goid)\n end\n end\n\n object.load_defaults\n end\n\n\n object.rehydrate(nil)\n game_objects << object\n\n unless object.container.nil? or game_objects.loaded? object.container\n begin\n load_object(object.container, game_objects)\n rescue MUDError::NoSuchGOID, MUDError::ObjectLoadError\n object.container = ServerConfig.start_room\n end\n end\n\n return object\n end", "def increase!(amount = 1)\n transaction do\n self.quantity += amount\n unless in_stock?\n # fail Shoppe::Errors::NotEnoughStock, ordered_item: ordered_item, requested_stock: self.quantity\n end\n save!\n # order.remove_delivery_service_if_invalid\n end\n end", "def update_inventory\n self.order_items.each { |item| item.variant.add_pending_to_customer }\n end", "def update_product_cache_stock\n\t\t\tself.product.update_cache_stock if self.product.present?\n\t\tend", "def use_item_by_string(name, e)\n index = has_item_by_string(name)\n if (index != -1)\n actual_item = inventory[index].first\n actual_item.use(e)\n remove_item(actual_item) if actual_item.consumable\n else\n print \"What?! You don't have THAT!\\n\\n\"\n end\n end", "def set_order\n @item = Order.find(params[:id])\n end", "def sweetist_synchronize_line_item(line_item_hash, sweetist_order_id)\n line_item_match = self.integration_item.integration_sync_matches.find_or_create_by(integration_syncable_id: line_item_hash.fetch(:id,nil), integration_syncable_type: 'Spree::LineItem')\n # TODO sync variant first\n\n if line_item_match.sync_id\n payload = sweetist_map_to_sweetist_line_item(line_item_hash)\n push_request = send_request(\"#{ENV['SWEETIST_INTEGRATION_URL']}/api/orders/#{sweetist_order_id}/line_items/#{line_item_match.sync_id}?token=#{ENV['SWEETIST_API_KEY']}\", :patch, payload)\n elsif false\n # TODO find line item by variant\n\n else\n payload = sweetist_map_to_sweetist_line_item(line_item_hash)\n payload[:line_item][:order_id] = sweetist_order_id\n push_request = send_request(\"#{ENV['SWEETIST_INTEGRATION_URL']}/api/orders/#{sweetist_order_id}/line_items?token=#{ENV['SWEETIST_API_KEY']}\", :post, payload)\n end\n\n if push_request.code.to_s.starts_with?('20')\n sweetist_line_item = JSON.parse(push_request.body)\n line_item_match.update_columns(sync_id: sweetist_line_item.fetch('id',nil))\n { status: 10, log: \"#{line_item_hash.fetch(:item_name,'')} saved to order\"}\n else\n { status: -1, log: \"#{line_item_hash.fetch(:item_name,'')} => Error(#{push_request.code}) - #{push_request.message}\"}\n end\n\n rescue Exception => e\n { status: -1, log: \"#{e.class.to_s} - #{e.message}\" }\n end", "def include?(item_id_type, item_id)\n active?( item_id_type, item_id ) ||\n saved_for_later?( item_id_type, item_id )\n end", "def fetch_item(item_id)\n fail \"Missing id\" if item_id.nil?\n fail \"No such item id: #{item_id}\" unless @items.member?(item_id.to_i)\n @items.fetch(item_id.to_i)\n end", "def push\n API::SOAP::CatalogInventory::StockItem.update(self.product);\n end", "def _order_upgrade_item!(upgrade_item_price)\n # put together an order\n upgrade_order = {\n 'complexType' => 'SoftLayer_Container_Product_Order_Virtual_Guest_Upgrade',\n 'virtualGuests' => [{'id' => self.id }],\n 'properties' => [{'name' => 'MAINTENANCE_WINDOW', 'value' => Time.now.iso8601}],\n 'prices' => [ upgrade_item_price ]\n }\n\n self.softlayer_client[\"Product_Order\"].placeOrder(upgrade_order)\n end", "def has_ordered?(item_to_check)\n if item_to_check.class == Item\n @order.any? {|item| item.name == item_to_check.name}\n else \n false\n end \nend", "def load_existing_variant_sku\n @order = Spree::Order.find_by_id(params[:order_id])\n @line_item = Spree::LineItem.find_by_id(params[:line_item_id])\n respond_to do |format|\n format.html { render :partial=>\"edit_lineitems\"}\n end\n end", "def set_needed_item\n @needed_item = NeededItem.find(params[:id])\n end", "def update_item\n self.item.update_complete\n end", "def changeItem\n locationItem = current_company.locations.where(id: params[:locationId]).first.items.where(id: params[:id]).first\n locationItem.increment!(:amount, params[:amount].to_i)\n if(locationItem.amount <= locationItem.restockPoint && locationItem.lastSupplier != locationItem.location.id)\n previousSupplierItem = Location.where(id:locationItem.lastSupplier).first.items.where(name:locationItem.name).first\n if(previousSupplierItem.amount > (locationItem.restockTo - locationItem.amount))\n previousSupplierItem.increment!(:amount, -(locationItem.restockTo - locationItem.amount))\n # PRETEND CASH ISN\"T A THING YET\n # locationItem.location.company.increment!(:cash, -previousSupplierItem.price * (locationItem.restockTo - locationItem.amount))\n locationItem.update(amount: locationItem.restockTo)\n else\n locationItem.increment!(:amount, previousSupplierItem.amount)\n # PRETEND CASH ISN\"T A THING YET\n # locationItem.location.company.increment!(:cash, -previousSupplierItem.price * previousSupplierItem.amount)\n previousSupplierItem.amount = 0\n end\n if(previousSupplierItem.amount <= previousSupplierItem.restockPoint)\n changeItemSupplier(previousSupplierItem.id)\n end\n end\n end", "def equip_item(item)\n\n index = has_item(item)\n if index\n actual_item = inventory[index].first\n\n # Checks for Equippable without importing the file.\n if (defined? actual_item.equip)\n actual_item.equip(self)\n\n # Equipping the item will always remove it from the entity's inventory.\n remove_item(actual_item)\n else\n print \"#{actual_item.name} cannot be equipped!\\n\\n\"\n end\n else\n print NO_SUCH_ITEM_ERROR\n end\n end", "def assign_parts(hash={})\n return if hash.nil? or hash == {}\n self.parts = []\n hash ||= {}\n hash.each do |h|\n i = self.vendor.items.visible.find_by_sku(h[:sku])\n if i then\n i.is_part = true\n i.part_quantity = self.string_to_float(h[:part_quantity])\n result = i.save\n if result == false\n raise \"Could not save Item because #{ i.errors.messages }\"\n end\n self.parts << i\n end\n end\n result = self.save\n if result == false\n raise \"Could not save Item because #{ self.errors.messages }\"\n end\n end", "def load_inventory(library, book, stock)\n inventory = Inventory.add_book_to_library(library, book, stock)\n puts \"#{library.name} has a stock of #{stock} of #{book.title}\"\nend", "def update_item\r\n # If B button was pressed\r\n if Input.trigger?(Input::B)\r\n # Play cancel SE\r\n $game_system.se_play($data_system.cancel_se)\r\n # Switch to menu screen\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n # If C button was pressed\r\n if Input.trigger?(Input::C)\r\n # Get currently selected data on the item window\r\n @item = @item_window.item\r\n # If not a use item\r\n unless @item.is_a?(RPG::Item)\r\n # Play buzzer SE\r\n $game_system.se_play($data_system.buzzer_se)\r\n return\r\n end\r\n # Play decision SE\r\n $game_system.se_play($data_system.decision_se)\r\n # If effect scope is an ally\r\n\r\n puts \"User chose item #{ItemService.item_sym_of(id)}\"\r\n @pedestal.pedestal_item_id = id\r\n\t\t\t$game_party.gain_item(rmxp_item_id, -1)\r\n\r\n SetupEventService.new.setup!\r\n $scene = Scene_Map.new\r\n return\r\n end\r\n end", "def buy_new_item(item_to_buy, quantity, account)\n return false if item_to_buy.auction\n preowner = item_to_buy.owner\n\n if (Integer(item_to_buy.price*quantity) > self.credits and item_to_buy.currency == \"credits\") or Integer(item_to_buy.quantity)<quantity\n Activity.log(account, \"item_bought_failure\", item_to_buy, self)\n Activity.log(account, \"item_sold_failure\", item_to_buy, preowner)\n return false\n end\n\n\n if !item_to_buy.wishlist_users.empty? and item_to_buy.quantity == quantity and !item_to_buy.permanent\n item_to_buy.wishlist_users.each {|trader| trader.remove_from_wishlist(item_to_buy); item_to_buy.wishlist_users.delete(trader)}\n end\n\n Holding.ship_item(item_to_buy, item_to_buy.owner, self, quantity)\n Activity.log(account, \"item_bought_success\", item_to_buy, self)\n Activity.log(account, \"item_sold_success\", item_to_buy, preowner)\n Mailer.item_sold(preowner.e_mail, \"Hi #{preowner.name}, \\n #{self.name} bought your Item #{item_to_buy.name}.\n Please Contact him for completing the trade. His E-Mail is: #{self.e_mail}\")\n\n return true\n end", "def reload_items\n @item_data = nil\n end" ]
[ "0.74615616", "0.70915425", "0.69880384", "0.6798755", "0.59630257", "0.5661048", "0.5522546", "0.544738", "0.5381362", "0.5239705", "0.5188291", "0.5172124", "0.51267564", "0.5115782", "0.5044405", "0.4995173", "0.4985708", "0.4950463", "0.4935117", "0.48869804", "0.4881234", "0.4881234", "0.48715538", "0.48696822", "0.48612317", "0.48492602", "0.4835266", "0.4835266", "0.482796", "0.48275664", "0.4825533", "0.48209786", "0.47902057", "0.4776651", "0.47685736", "0.47647846", "0.47601607", "0.47580788", "0.47459742", "0.47456706", "0.47353888", "0.47298318", "0.4728979", "0.47283083", "0.47281572", "0.47258502", "0.4719427", "0.4718428", "0.47118238", "0.47115314", "0.46980247", "0.4693301", "0.4693301", "0.4693301", "0.4693301", "0.4692557", "0.46899235", "0.46752703", "0.4670067", "0.4663302", "0.46575084", "0.46574143", "0.46546417", "0.46502334", "0.46457255", "0.46412182", "0.46335623", "0.46091527", "0.460208", "0.4599645", "0.45924863", "0.45763662", "0.4574429", "0.45671278", "0.45617497", "0.455819", "0.4555943", "0.45554107", "0.45508218", "0.4544253", "0.45397294", "0.45387995", "0.45381337", "0.45377064", "0.45341054", "0.45326132", "0.4532098", "0.4529358", "0.45233274", "0.4519651", "0.4515344", "0.45144764", "0.45124093", "0.45038316", "0.45028812", "0.44953763", "0.44953096", "0.44943425", "0.4484891", "0.44844842" ]
0.78892595
0
Loading from infinite stock always succeeds. Order number is used as lot code for the transfer item.
def load_item_from_infinite_stock(order_item) create_item_from(order_item, order_item.order.number) true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_item!(order_item, stock)\n if !order_item.product.tracked_stock? || source.enable_gateway?\n load_item_from_infinite_stock(order_item) && return\n end\n stock_items = stock.select { |item| item.product == order_item.product }\n return false if stock_items.none?\n\n if order_item.lot_code.present?\n load_item_by_lot_code(order_item, stock_items)\n else\n load_item_from_stock(order_item, stock_items)\n end\n end", "def load_item_from_stock(order_item, stock_items)\n amount = order_item.waiting\n stock_items.each do |item|\n all = item.available\n next if all <= 0\n\n if amount <= all\n # This inventory item satisfies the amount, we're done.\n item.reserved += amount\n return create_item_from(order_item, item.code, item.expires_at, amount)\n else\n # Load all of this item and continue with the remaining amount.\n item.reserved += all\n create_item_from(order_item, item.code, item.expires_at, all)\n amount -= all\n end\n end\n end", "def load!(order_items)\n transaction do\n products = order_items.map(&:product)\n stock = source.inventory_items.for(products)\n order_items.each do |order_item|\n load_item!(order_item, stock)\n end\n end\n end", "def load!\n transfer = find_or_create_transfer\n transfer.load!(order.items_waiting)\n end", "def load_item_by_lot_code(order_item, stock_items)\n item = stock_items.find { |item| order_item.lot_code == item.code }\n\n # If the order item has a serial number, try lot code part only.\n if item.nil? && order_item.lot_code['-']\n lot_code_part = order_item.lot_code.split('-').first\n item = stock_items.find { |item| lot_code_part == item.code }\n end\n\n # If a match was found, load the item and return. If a partial\n # match set a lot code part above, use that, or provide nil\n # to use the code on the order item.\n if item.present?\n item.reserved += order_item.amount\n return create_item_from(order_item, lot_code_part, item.expires_at)\n end\n\n false # Failed to load the item.\n end", "def load_item_list\n @item_quantity = []\n get_list_item\n get_definitive_list_price\n check_if_shop_empty\n @index = 0\n @last_index = @list_item.size - 1\n end", "def alipay_load_order\n Rails.logger.debug \"#{__LINE__} alipay_load_order called \"\n raise \"'out_trade_no' requird to load the order\" unless params.key?('out_trade_no')\n #order_number = parse_alipay_out_trade_no(params['out_trade_no'])[:payment_order_number]\n order_number, payment_identifier = parse_alipay_out_trade_no(params['out_trade_no'])\n @order = Order.find_by_number(order_number) #if request.referer=~/alipay.com/\n @payment = Payment.find_by(identifier: payment_identifier)\n #@current_order = @order\n unless @order.present?\n raise RuntimeError, \"Could not find order #{order_number}\"\n end\n Rails.logger.debug \"#{__LINE__} alipay_load_order called and order is found #{@order.inspect}\"\n end", "def import_stock_daily\n JdeItemAvailability.checking_stock_daily\n end", "def fetch_invoice_from_lazada(smp)\n @messages = []\n @orders = smp.seller.orders.where(\"invoice_details IS NULL AND market_place_id=? AND is_cancel=false AND fulflmnt_state not in(?)\", smp.market_place_id, ['rfp','partial'])\n market_place = smp.market_place\n if @orders.present?\n @orders.each do |order|\n begin\n # List item fetch from order API\n order_item_code = []\n Time.zone = \"Singapore\"\n current_time = Time.zone.now\n list_item_params = {\"Action\"=>\"GetOrderItems\", \"OrderId\"=>order.market_place_order_no, \"Timestamp\"=>current_time.to_time.iso8601, \"UserID\"=>smp.contact_email, \"Version\"=>\"1.0\"}\n signature_lt = generate_lazada_signature(list_item_params, smp)\n if signature_lt\n formed_list_item = []\n sorted_params_lt = Hash[list_item_params.sort]\n sorted_params_lt.merge!(\"Signature\"=>signature_lt)\n sorted_params_lt.each do |key,value|formed_list_item << CGI::escape(\"#{key}\")+\"=\"+CGI::escape(\"#{value}\")end\n param_string_lt = \"?\"+formed_list_item.join('&')\n uri_lt = URI.parse(market_place.domain_url+param_string_lt)\n http_lt = Net::HTTP.new(uri_lt.host, uri_lt.port)\n http_lt.use_ssl = true\n http_lt.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request_lt = Net::HTTP::Get.new(uri_lt.request_uri)\n res_lt = http_lt.request(request_lt)\n if res_lt.code == \"200\"\n res_lt_body = Hash.from_xml(res_lt.body).to_json\n res_lt_body = JSON.parse(res_lt_body, :symbolize_names=>true)\n if res_lt_body[:SuccessResponse]\n order_items = res_lt_body[:SuccessResponse][:Body][:OrderItems][:OrderItem]\n if order_items.class == Array\n order_items.each do |order_item|\n order_item_code = order_item[:OrderItemId]\n end\n elsif order_items.class != Array\n order_item_code = order_items[:OrderItemId]\n end\n #Invoice generation call\n order_item_code = (order_item_code.present? ? order_item_code : '')\n invoice_no = order.fulflmnt_tracking_no ? order.fulflmnt_tracking_no : \"12345\"\n invoice_params = {\"Action\"=>\"GetDocument\", \"DocumentType\"=>\"invoice\", \"InvoiceNumber\"=>invoice_no, \"OrderItemId\"=>order_item_code, \"Timestamp\"=>current_time.to_time.iso8601, \"UserID\"=>smp.contact_email, \"Version\"=>\"1.0\"}\n signature = generate_lazada_signature(invoice_params, smp)\n if signature.present?\n string_to_be_formed = []\n sorted_params = Hash[invoice_params.sort]\n sorted_params.merge!(\"Signature\"=>signature)\n sorted_params.each do |key,value|string_to_be_formed << CGI::escape(\"#{key}\")+\"=\"+CGI::escape(\"#{value}\")end\n param_string = \"?\"+string_to_be_formed.join('&')\n uri = URI.parse(market_place.domain_url+param_string)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n res = http.request(request)\n if res.code == \"200\"\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=>true)\n if res_body[:SuccessResponse]\n #FBA invoice push API call\n fba_res = order.send_invoice(smp, order, res_body[:SuccessResponse][:Body][:Documents][:Document][:File])\n order.update_column(:invoice_details,res_body[:SuccessResponse][:Body][:Documents][:Document][:File]) if fba_res\n else\n @messages << \"#{market_place.name}: [\"+\"#{order.market_place_order_no.to_s}\"+\"]\"+res_body[:ErrorResponse][:Head][:ErrorMessage]\n end\n end\n else\n @messsges << \"#{market_place.name}: Signature can not be generated.\"\n end # End for invoice signature check\n else\n @messages << \"#{market_place.name}: [\"+\"#{order.market_place_order_no.to_s}\"+\"] \"+res_lt_body[:ErrorResponse][:Head][:ErrorMessage]\n end # End for line items error check\n end\n else\n @messsges << \"#{market_place.name}: Signature can not be generated.\"\n end # End for the line items signature check\n rescue Exception => e\n @messsges << \"#{market_place.name}: [\"+\"#{order.market_place_order_no.to_s}\"+\"] \"+e.message\n end\n end # End for order loop\n end # End for order present check\n return @messages.join(\"; \")\n end", "def load_inventory(library, book, stock)\n inventory = Inventory.add_book_to_library(library, book, stock)\n puts \"#{library.name} has a stock of #{stock} of #{book.title}\"\nend", "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 load_all_raw_data_into_redis\n\t$all_stock_list.each do |symbol,name|\n\t\tputs \"#{symbol} start\"\n\t\tyahoo_get_raw_data_from_file(symbol)\n\tend\n\nend", "def getStock(symbol)\n\n return StockQuote::Stock.batch([\"quote\",\"logo\"],symbol)\n\n end", "def fetch_from_inventory(an_order)\n order = extract_code_qty(an_order)\n return Inventory.fetch_an_item(order[:code])\n end", "def check_luxire_inventory\n order = Spree::Order.find(params[:order_id])\n line_items = order.line_items\n line_items.each do |line_item|\n variant = Spree::Variant.find(line_item.variant_id)\n product = variant.product\n unless Spree::Product.non_depletable_product.include? product.name.downcase\n length_required_per_product = product.luxire_product.length_required\n quantity = line_item.quantity\n stock = product.luxire_stock\n unless stock.backorderable\n total_length_required = length_required_per_product * quantity\n if(stock.virtual_count_on_hands - total_length_required < 0)\n response = {msg: \"#{product.name} is out of stock\"}\n render json: response.to_json, status: 422 and return\n end\n end\n end\n end\n end", "def import_beginning_of_week\n JdeItemAvailability.import_buffer_daily\n JdeItemAvailability.import_beginning_week_of_stock\n end", "def get_stock(stock_ticker)\n stock = StockQuote::Stock.quote(stock_ticker)\n return stock\nend", "def create_order_for_lazada(order, smp)\n @order_items = []\n @order = nil\n @order_status = nil\n message = \"\"\n cm_user = smp.seller.is_cm_user\n begin\n # List item fetch from order API\n @order = Spree::Order.where(\"market_place_order_no=? AND seller_id=?\", order[:OrderId], smp.seller_id).try(:first)\n if !@order.present?\n p '----------'\n Time.zone = \"Singapore\"\n current_time = Time.zone.now\n list_item_params = {\"Action\"=>\"GetOrderItems\", \"OrderId\"=>order[:OrderId], \"Timestamp\"=>current_time.to_time.iso8601, \"UserID\"=>smp.contact_email, \"Version\"=>\"1.0\"}\n signature_lt = generate_lazada_signature(list_item_params, smp)\n market_place = smp.market_place\n if signature_lt\n formed_list_item = []\n sorted_params_lt = Hash[list_item_params.sort]\n sorted_params_lt.merge!(\"Signature\"=>signature_lt)\n sorted_params_lt.each do |key,value|formed_list_item << CGI::escape(\"#{key}\")+\"=\"+CGI::escape(\"#{value}\")end\n param_string_lt = \"?\"+formed_list_item.join('&')\n uri_lt = URI.parse(market_place.domain_url+param_string_lt)\n http_lt = Net::HTTP.new(uri_lt.host, uri_lt.port)\n http_lt.use_ssl = true\n http_lt.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request_lt = Net::HTTP::Get.new(uri_lt.request_uri)\n res_lt = http_lt.request(request_lt)\n if res_lt.code == \"200\"\n res_lt_body = Hash.from_xml(res_lt.body).to_json\n res_lt_body = JSON.parse(res_lt_body, :symbolize_names=>true)\n @order_items << res_lt_body[:SuccessResponse][:Body][:OrderItems][:OrderItem]\n @order_items = @order_items.flatten\n @order_status = @order_items[0][:Status]\n gift = (order[:GiftOption] == \"0\" ? false : true)\n shipping_country = Spree::Country.find_by_name(order[:AddressShipping][:Country])\n billing_country = Spree::Country.find_by_name(order[:AddressBilling][:Country])\n shipping_last_name = (order[:AddressShipping][:LastName] ? order[:AddressShipping][:LastName] : order[:AddressShipping][:FirstName])\n billing_last_name = (order[:AddressBilling][:LastName] ? order[:AddressBilling][:LastName] : order[:AddressBilling][:FirstName])\n shipping_phone_no = (order[:AddressShipping][:Phone].present? ? order[:AddressShipping][:Phone] : order[:AddressShipping][:Phone2])\n billing_phone_no = (order[:AddressBilling][:Phone].present? ? order[:AddressBilling][:Phone] : order[:AddressBilling][:Phone2])\n @shpping_address = Spree::Address.create!(:firstname=>order[:AddressShipping][:FirstName], :lastname=>shipping_last_name, :address1=>order[:AddressShipping][:Address1], :address2=>order[:AddressShipping][:Address2], :city=>shipping_country.name, :zipcode=>order[:AddressShipping][:PostCode], :phone=>shipping_phone_no, :alternative_phone=>order[:AddressShipping][:Phone2], :country_id=>shipping_country.id, :state_name=>shipping_country.name)\n if !order[:AddressBilling][:FirstName].present? && !order[:AddressBilling][:Address1].present? && !order[:AddressBilling][:Country].present? && !order[:AddressBilling][:PostCode].present? && !order[:AddressBilling][:Phone].present? && !billing_country.nil?\n @billing_address = Spree::Address.create!(:firstname=>order[:AddressBilling][:FirstName], :lastname=>billing_last_name, :address1=>order[:AddressBilling][:Address1], :address2=>order[:AddressBilling][:Address2], :city=>billing_country.name,:zipcode=>order[:AddressBilling][:PostCode], :phone=>billing_phone_no, :alternative_phone=>order[:AddressBilling][:Phone2], :country_id=>billing_country.id, :state_name=>billing_country.name)\n end\n billing_address = (!@billing_address.nil? && !@billing_address.blank?) ? @billing_address.id : nil\n order_item_list = []\n item_total = 0.0\n payment_total = 0.0\n quantity_hash = {}\n price_hash = {}\n @order_items.each do |item|\n # item[:Sku] = 'NEWRKIT'#'TPUSBC'#'NEWRKIT'\n item_total = item_total + item[:ItemPrice].to_f\n payment_total = payment_total + item[:PaidPrice].to_f\n if price_hash[item[:Sku]].present?\n price_hash[item[:Sku]] = price_hash[item[:Sku]].to_f + item[:PaidPrice].to_f\n else \n price_hash = price_hash.merge(item[:Sku]=>item[:PaidPrice].to_f) \n end\n if quantity_hash[item[:Sku]].present?\n quantity_hash[item[:Sku]] = quantity_hash[item[:Sku]].to_i + 1\n else\n quantity_hash = quantity_hash.merge(item[:Sku]=>1)\n order_item_list << item\n end\n end\n currency = (order_item_list.present? ? order_item_list.first[:Currency] : \"SGD\")\n @order = Spree::Order.create!(:number=>order[:OrderNumber], :order_date=>order[:CreatedAt], :market_place_details=>order, :item_total=>item_total, :total=>payment_total, :payment_total=>payment_total, :email=>smp.seller.contact_person_email, :currency=>currency, :send_as_gift=>gift, :market_place_id=>smp.market_place_id, :market_place_order_no=>order[:OrderId], :market_place_order_status=>@order_status, :bill_address_id=>billing_address, :ship_address_id=> @shpping_address.id, :cart_no=>order[:OrderNumber], :seller_id=>smp.seller_id, :is_bypass=>!cm_user)\n p @order\n order_item_list.each do |item|\n if cm_user\n # item[:Sku] ='NEWRKIT'# 'TPUSBC'#\n @variant = nil\n @mp_product = nil\n @line_item = nil\n @stock = nil\n @variant = Spree::Variant.includes(:product).where(\"spree_products.seller_id=? AND sku=?\", smp.seller_id, item[:Sku]).try(:first)\n if @variant.present?\n @mp_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", @variant.product.seller_id, smp.market_place_id, @variant.product_id).first\n if @variant.product.kit.present?\n kit = @variant.product.kit\n l_items = kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*quantity_hash[item[:Sku]]\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>item[:Currency], :kit_id=>kit.id, :rcp=>price_hash[item[:Sku]])\n stock = lt_variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n msg = 'Application Helper Create Order Lazada'\n lt_variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n stock.update_attributes!(:count_on_hand=>(stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 ) if stock.present? && lt_variant.quantity_inflations.present?\n end\n else\n if @variant.parent_id.present?\n @parent = Spree::Variant.find(@variant.parent_id)\n if @parent.product.kit.present?\n kit = @parent.product.kit\n l_items = kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*quantity_hash[item[:Sku]]\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>item[:Currency], :kit_id=>kit.id, :rcp=>price_hash[item[:Sku]])\n stock = lt_variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n stock.update_attributes!(:count_on_hand=>(stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 ) if @stock.present? && lt_variant.quantity_inflations.present?\n msg = 'Application Helper Create Order Lazada Family Kit If'\n lt_variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@parent.id, :order_id=>@order.id, :quantity=>quantity_hash[item[:Sku]], :price=>item[:PaidPrice], :currency=>item[:Currency], :rcp=>price_hash[item[:Sku]])\n type = (STOCKCONFIG[@parent.product.stock_config_type] == \"default\" ? STOCKCONFIG[@parent.product.seller.stock_config_type] : STOCKCONFIG[@parent.product.stock_config_type])\n @parent.update_attributes(:fba_quantity=>(@parent.fba_quantity - quantity_hash[item[:Sku]])) if !@parent.quantity_inflations.present?\n msg = 'Application Helper Create Order Lazada Parent Family Kit Else'\n @parent.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n @variant.update_attributes(:fba_quantity=>(@parent.fba_quantity - quantity_hash[item[:Sku]])) if (!@variant.quantity_inflations.present? && @parent.quantity_inflations.present?)\n msg = 'Application Helper Create Order Lazada Family Kit Else'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@parent.product.kit.present?)\n @stock = @parent.stock_products.where(\"sellers_market_places_product_id IN (?)\", @parent.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - quantity_hash[item[:Sku]]) >= 0 ? (@stock.count_on_hand - quantity_hash[item[:Sku]]) : 0 ) if @stock.present? && @parent.quantity_inflations.present?\n end\n child_type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n if (child_type != \"flat_quantity\") || (child_type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - quantity_hash[item[:Sku]]) >= 0 ? (@stock.count_on_hand - quantity_hash[item[:Sku]]) : 0 ) if @stock.present? && @variant.quantity_inflations.present?\n end\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@variant.id, :order_id=>@order.id, :quantity=>quantity_hash[item[:Sku]], :price=>item[:PaidPrice], :currency=>item[:Currency], :rcp=>price_hash[item[:Sku]]) \n type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - quantity_hash[item[:Sku]])) if !@variant.quantity_inflations.present?\n msg = 'Application Helper Create Order Lazada Without Family'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - quantity_hash[item[:Sku]]) >= 0 ? (@stock.count_on_hand - quantity_hash[item[:Sku]]) : 0 ) if @stock.present? && @variant.quantity_inflations.present?\n end\n end\n end\n end\n else\n Spree::MpOrderLineItem.create!(:order_id=>@order.id, :market_place_details=>item)\n end\n end # end of order_item_list\n @order.update_column(:total, payment_total)\n @order.reload\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => @order})\n @cart_numbers << order[:OrderNumber]\n else # else for order check condition\n if @order.market_place_order_status != @order_status\n @order.update_attributes(:market_place_order_status=>@order_status)\n end\n end\n end # End for item list response check\n\n end # End of item list signature check\n rescue Exception => e\n message << e.message\n end\n return message.length > 0 ? message : true\n end", "def load_shopping_item_or_not\n @shopping_item_id = nil\n\n if si = params[:shopping_item]\n if si[:offer_id]\n # this is a shopping item that references an offer and cart\n @shopping_item_id = si[:offer_id]\n @admin_customer_offer = Admin::Customer::Offer.find(si[:offer_id])\n @cart = Shopping::Cart.find_by_id(si[:cart_id])\n session[:admin_customer_offer_id] = @admin_customer_offer.id\n raise \"cart offer email mismatch\" if (@cart.email.id != @admin_customer_offer.email.id)\n elsif si[:piece_id]\n @shopping_item_id = si[:piece_id]\n end\n end\n\n unless @shopping_item_id\n @admin_customer_offer = Admin::Customer::Offer.find(session[:admin_customer_offer_id]) if session[:admin_customer_offer_id]\n @shopping_item_id = @admin_customer_offer.id if @admin_customer_offer\n end\n\n end", "def getStock(symbol)\n\n return StockQuote::Stock.batch([\"quote\",\"logo\"],symbol)\n\n end", "def order_fetch_qoo10(smp)\n @message = []\n @cart_numbers = []\n cm_user = smp.seller.is_cm_user\n #qoo10_statuses = {\"1\"=>\"Waiting for Shipping\", \"2\"=>\"Request Shipping\", \"3\"=>\"Check Order\"}\n qoo10_statuses = {\"2\"=>\"Request Shipping\", \"3\"=>\"Check Order\"}\n market_place = Spree::MarketPlace.find(smp.market_place_id)\n qoo10_statuses.keys.each do |k|\n uri = URI(market_place.domain_url+'/ShippingBasicService.api/GetShippingInfo')\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data({'key'=>smp.api_secret_key,'ShippingStat'=>k,'search_Sdate'=>'','search_Edate'=>''})\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|http.request(req) end\n if res.code == \"200\"\n begin\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=>true)\n if res_body[:ShippingAPIService][:ResultMsg] == \"Success\"\n for i in 1..res_body[:ShippingAPIService][:TotalOrder].to_i\n begin\n @order = nil\n order = res_body[:ShippingAPIService][(\"Order\"+i.to_s).to_sym]\n @order = Spree::Order.where(\"market_place_order_no=? AND seller_id=?\", order[:orderNo], smp.seller_id).try(:first)\n @shpping_address = nil\n @billing_address = nil\n @is_customer_pickup = nil\n if !@order.present?\n gift = order[:Gift].present? ? false : true\n shipping_country = Spree::Country.find_by_iso(order[:shippingCountry])\n billing_country = Spree::Country.find_by_iso(order[:senderNation])\n name = order[:receiver].present? ? order[:receiver] : (order[:buyer].present? ? order[:buyer] : \"NA\")\n telno = order[:receiverTel].present? ? order[:receiverTel] : (order[:buyerTel].present? ? order[:buyerTel] : \"NA\")\n mobileno = order[:receiverMobile].present? ? order[:receiverMobile] : (order[:buyerMobile].present? ? order[:buyerMobile] : \"NA\")\n if order[:OrderType] == \"Pickup\"\n @is_customer_pickup = true\n # Our Singapore warehouse address\n address1 = \"151 Pasir Panjang Road\"\n address2 = \"#02-02 Pasir Panjang Distripark\"\n zipcode = \"118480\"\n phone = \"+65 6271 0524\"\n @shpping_address = Spree::Address.create!(:firstname=>name, :lastname=>name, :address1=>address1, :address2=>address2, :city=>shipping_country.name, :zipcode=>zipcode, :phone=>phone, :alternative_phone=>\"\", :country_id=>shipping_country.id, :state_name=>shipping_country.name)\n if order[:Addr1].present?\n @billing_address = Spree::Address.create!(:firstname=>name, :lastname=>name, :address1=>order[:Addr1], :address2=>order[:Addr2], :city=>shipping_country.name, :zipcode=>order[:zipCode], :phone=>telno, :alternative_phone=>mobileno, :country_id=>shipping_country.id, :state_name=>shipping_country.name)\n end\n else\n @is_customer_pickup = false\n @shpping_address = Spree::Address.create!(:firstname=>name, :lastname=>name, :address1=>order[:Addr1], :address2=>order[:Addr2], :city=>shipping_country.name, :zipcode=>order[:zipCode], :phone=>telno, :alternative_phone=>mobileno, :country_id=>shipping_country.id, :state_name=>shipping_country.name)\n end\n if !order[:senderName].present? && !order[:senderAddr].present? && !order[:senderNation].present? && !order[:senderZipCode].present? && !order[:senderTel].present? && !billing_country.nil?\n @billing_address = Spree::Address.create!(:firstname=>order[:senderName], :lastname=>order[:senderName], :address1=>order[:senderAddr], :address2=>\"\", :city=>billing_country.name,\n :zipcode=>order[:senderZipCode], :phone=>order[:senderTel], :alternative_phone=>\"\", :country_id=>billing_country.id, :state_name=>billing_country.name)\n end\n billing_address = (!@billing_address.nil? && !@billing_address.blank?) ? @billing_address.id : nil\n if @shpping_address.present?\n @order = Spree::Order.create!(:number=>order[:orderNo], :order_date=> order[:PaymentDate], :market_place_details=>order, :item_total=>order[:orderPrice], :total=>order[:total].to_f, :payment_total=>order[:total], :email=>order[:buyerEmail], :currency=>order[:Currency], :send_as_gift=>gift, :market_place_id=>smp.market_place_id, :market_place_order_no=>order[:orderNo], :market_place_order_status=>qoo10_statuses[k], :bill_address_id=>billing_address, :ship_address_id=> @shpping_address.id, :cart_no=> order[:packNo], :seller_id=>smp.seller_id, :is_bypass=>!cm_user)\n else\n @message << order[:orderNo]+\": \"+ \"Ooops..Shipping address is missing\"\n end\n if cm_user\n @mp_product = nil\n @mp_product = Spree::SellersMarketPlacesProduct.find_by_market_place_product_code(order[:itemCode])\n if @order.present?\n if order[:option] == \"\"\n @variant = Spree::Variant.includes(:product).where(\"spree_products.seller_id=? AND sku=?\", smp.seller_id, order[:sellerItemCode]).try(:first) if order[:sellerItemCode].present?\n @variant = Spree::Variant.find_by_sku(@mp_product.product.sku) if !@variant.present? && @mp_product.present? \n if @variant.present? && @variant.product.kit.present?\n kit = @variant.product.kit\n l_items = kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*order[:orderQty].to_i\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :kit_id=>kit.id, :rcp=>order[:total])\n stock = lt_variant.product.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Variant Kit 003'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n stock.update_attributes!(:count_on_hand=>((stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 )) if stock.present? && lt_variant.quantity_inflations.present?\n end\n elsif @variant.present?\n if @variant.parent_id.present?\n @parent = Spree::Variant.find(@variant.parent_id)\n if @parent.product.kit.present?\n kit = @parent.product.kit\n l_items = kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*order[:orderQty].to_i\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :kit_id=>kit.id, :rcp=>order[:total])\n stock = lt_variant.product.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Variant Family 002'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n stock.update_attributes!(:count_on_hand=>((stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 )) if stock.present? && lt_variant.quantity_inflations.present?\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@parent.id, :order_id=>@order.id, :quantity=>order[:orderQty].to_i, :price=>order[:orderPrice], :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :rcp=>order[:total])\n type = (STOCKCONFIG[@parent.product.stock_config_type] == \"default\" ? STOCKCONFIG[@parent.product.seller.stock_config_type] : STOCKCONFIG[@parent.product.stock_config_type])\n @parent.update_attributes(:fba_quantity=>(@parent.fba_quantity - order[:orderQty].to_i)) if !@parent.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 parent Family kit 001'\n @parent.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - order[:orderQty].to_i)) if !@variant.quantity_inflations.present? && @parent.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Family Kit 001'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@parent.product.kit.present?)\n @stock = @parent.stock_products.where(\"sellers_market_places_product_id IN (?)\", @parent.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && @parent.quantity_inflations.present?\n end\n child_type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n if (child_type != \"flat_quantity\") || (child_type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).try(:first)\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && (@parent.quantity_inflations.present? || @variant.quantity_inflations.present?)\n end\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@variant.id, :order_id=>@order.id, :quantity=>order[:orderQty].to_i, :price=>order[:orderPrice], :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :rcp=>order[:total])\n type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - order[:orderQty].to_i)) if !@variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Family Only Variant Else'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && @variant.quantity_inflations.present?\n end\n end\n end\n else\n option_code_count = 1\n option_codes = []\n if order[:optionCode] == \"\" || !order[:optionCode].present?\n option_arr = order[:option].split(\":\")\n if option_arr[1].split(\"(+\").count > 1\n option_arr[1] = option_arr[1].split(\"(+\")[0]\n elsif option_arr[1].split(\"(-\").count > 1\n option_arr[1] = option_arr[1].split(\"(-\")[0]\n end\n @variant = nil\n @mp_product.product.variants.each do |v|\n @variant = v if !v.option_values.blank? && (v.option_values.map(&:presentation).include?option_arr[1].strip)\n option_codes = [@variant.sku] if @variant.present?\n end if @mp_product.present? && @mp_product.product && @mp_product.product.option_types && @mp_product.product.option_types.present? && (@mp_product.product.option_types.map(&:presentation).include?option_arr[0])\n else\n option_codes = order[:optionCode].to_s.split(\",\")\n option_code_count = option_codes.length\n end\n for j in 0..(option_code_count - 1)\n @line_item = nil\n @stock = nil\n @variant = nil\n @variant = Spree::Variant.includes(:product).where(\"spree_products.seller_id=? AND sku=?\", smp.seller_id, option_codes[j]).try(:first) if order[:sellerItemCode].present?\n @variant = @mp_product.product.variants_including_master.find_by_sku(option_codes[j]) if !@variant.present? && @mp_product.present?\n if @variant.present?\n if @variant.product.kit.present?\n kit = @variant.product.kit\n l_items = kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*order[:orderQty].to_i\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :kit_id=>kit.id, :rcp=>(order[:total].to_f/option_code_count))\n stock = lt_variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).try(:first)\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Only Kit If'\n lt_variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n stock.update_attributes!(:count_on_hand=>(stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 ) if stock.present? && lt_variant.quantity_inflations.present?\n end\n else\n if @variant.parent_id.present?\n @parent = Spree::Variant.find(@variant.parent_id)\n # @line_item = Spree::LineItem.create!(:variant_id=>@parent.id, :order_id=>@order.id, :quantity=>order[:orderQty].to_i, :price=>order[:orderPrice], :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup)\n if @parent.product.kit.present?\n l_items = @parent.product.kit.kit_products\n l_items.each do |lt|\n lt_variant = lt.variant\n quantity = lt.quantity*order[:orderQty].to_i\n line_item = Spree::LineItem.create!(:variant_id=>lt_variant.id, :order_id=>@order.id, :quantity=>quantity, :price=>(lt_variant.price*quantity), :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :kit_id=>kit.id, :rcp=>(order[:total].to_f/option_code_count))\n stock = lt_variant.product.stock_products.where(\"sellers_market_places_product_id IN (?)\", lt_variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n lt_variant.update_attributes(:fba_quantity=>(lt_variant.fba_quantity - quantity)) if !lt_variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Family Kit If'\n lt_variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n stock.update_attributes!(:count_on_hand=>((stock.count_on_hand - quantity) >= 0 ? (stock.count_on_hand - quantity) : 0 )) if stock.present? && lt_variant.quantity_inflations.present?\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@parent.id, :order_id=>@order.id, :quantity=>order[:orderQty].to_i, :price=>order[:orderPrice], :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :rcp=>(order[:total].to_f/option_code_count))\n type = (STOCKCONFIG[@parent.product.stock_config_type] == \"default\" ? STOCKCONFIG[@parent.product.seller.stock_config_type] : STOCKCONFIG[@parent.product.stock_config_type])\n @parent.update_attributes(:fba_quantity=>(@parent.fba_quantity - order[:orderQty].to_i)) if !@parent.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Parent Family Kit Else'\n @parent.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - order[:orderQty].to_i)) if !@variant.quantity_inflations.present? && @parent.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 Family Kit Else'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@parent.product.kit.present?)\n @stock = @parent.stock_products.where(\"sellers_market_places_product_id IN (?)\", @parent.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && @parent.quantity_inflations.present?\n end\n child_type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n if (child_type != \"flat_quantity\") || (child_type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && (@parent.quantity_inflations.present? && @variant.quantity_inflations.present?)\n end\n end\n else\n @line_item = Spree::LineItem.create!(:variant_id=>@variant.id, :order_id=>@order.id, :quantity=>order[:orderQty].to_i, :price=>order[:orderPrice], :currency=>order[:Currency], :is_pick_at_store => @is_customer_pickup, :rcp=>(order[:total].to_f/option_code_count))\n type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - order[:orderQty].to_i)) if !@variant.quantity_inflations.present?\n msg = 'Application Helper fetch Qoo10 without Family Else'\n @variant.add_log_on_update(msg) rescue QTY_LOG.error \"#{Time.zone.now} Error -- #{msg}\"\n\n if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@variant.product.kit.present?)\n @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock.present? && @variant.quantity_inflations.present?\n end\n end\n\n end\n end\n # if @variant.parent_id.present?\n # @parent = Spree::Variant.find(@variant.parent_id)\n # type = (STOCKCONFIG[@parent.product.stock_config_type] == \"default\" ? STOCKCONFIG[@parent.product.seller.stock_config_type] : STOCKCONFIG[@parent.product.stock_config_type])\n # @parent.update_attributes(:fba_quantity=>(@parent.fba_quantity - order[:orderQty].to_i)) if !@parent.quantity_inflations.present?\n # if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@parent.product.kit.present?)\n # @stock = @parent.stock_products.where(\"sellers_market_places_product_id IN (?)\", @parent.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n # @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock && @parent.quantity_inflations.present?\n # end\n # else\n # type = (STOCKCONFIG[@variant.product.stock_config_type] == \"default\" ? STOCKCONFIG[@variant.product.seller.stock_config_type] : STOCKCONFIG[@variant.product.stock_config_type])\n # @variant.update_attributes(:fba_quantity=>(@variant.fba_quantity - order[:orderQty].to_i)) if !@variant.quantity_inflations.present?\n # if (type != \"flat_quantity\") || (type == \"flat_quantity\" && !@variant.product.kit.present?)\n # @stock = @variant.stock_products.where(\"sellers_market_places_product_id IN (?)\", @variant.product.sellers_market_places_products.where(\"market_place_id=?\",smp.market_place_id).map(&:id)).first\n # @stock.update_attributes(:count_on_hand=>(@stock.count_on_hand - order[:orderQty].to_i) >= 0 ? (@stock.count_on_hand - order[:orderQty].to_i) : 0 ) if @stock\n # end\n # end\n\n end # end of option codes loop\n end\n end\n else # is CM user else\n Spree::MpOrderLineItem.create!(:order_id=>@order.id, :market_place_details=>@order.market_place_details)\n end\n @order.update_column(:total, order[:total])\n @order.reload\n ActiveSupport::Notifications.instrument('spree.order.contents_changed', {:user => nil, :order => @order})\n @cart_numbers << order[:packNo]\n else # else for the order check condition\n if @order.market_place_order_status != qoo10_statuses[k]\n @order.update_attributes(:market_place_order_status=>qoo10_statuses[k])\n end\n end\n @message << (@order && @order.present? ? (@order.market_place_order_no.to_s+\": \"+ \"Success\") : nil)\n rescue Exception => e\n @message << e.message\n end\n end # End of for loop\n end\n rescue Exception => e\n @message << e.message\n end\n else\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=>true)\n @message << res_body[:ShippingAPIService][:ResultMsg]\n end\n end\n @cart_numbers = @cart_numbers.uniq\n @message << \"FBA: \"+ Spree::Order.push_to_fba(@cart_numbers) if @cart_numbers.present?\n return @message.join(\"; \")\n end", "def fetch_fba_quantity\n sellers = Spree::Seller.all\n sellers.each do |seller|\n begin\n @res = view_context.update_stock_for_seller(seller, true)\n rescue Exception => e\n \n end \n end \n redirect_to :back, :notice => \"FBA quantity fetch successfully\" \n end", "def refresh!(quantity)\n raise_error?(quantity)\n update_quantity!(quantity)\n save_order!\n order_maker.handle_coupon!\n recalibrate_order!\n lock!\n return_with(:success, order_item: order_item)\n rescue OrderMaker::Error => exception\n # remove! if package_sku # risky logic should be put somewhere else\n return_with(:error, error: exception.message)\n end", "def populate\n @order = current_order(session)\n variant_id = params[:variant_id]\n \n new_line_item = Breeze::Commerce::LineItem.new(:variant_id => variant_id, :quantity => params[:quantity] || 1)\n existing_line_item = @order.line_items.unarchived.where(:variant_id => variant_id).first \n if existing_line_item\n existing_line_item.quantity += new_line_item.quantity\n existing_line_item.save\n else\n @order.line_items << new_line_item\n end\n\n @order.save\n end", "def update_stock\n \tproduct = FileOperations.search_by_name(self)\n \tproduct = product[0].split(';')\n \tself.id = product[0]\n \tself.name = product[1]\n \tself.price = product[2]\n \tself.company = product[3]\n \tself.stock = product[4].to_i - 1\n \tFileOperations.update(self)\n end", "def fetch_qoo10_delivered_orders(smp)\n @message = []\n @all_cart_numbers = []\n fba_complete_states = ['complete', 'customer_complete', 'self_collect_complete', 'collect_complete', 'return_complete']\n market_place = smp.market_place\n #qoo10_statuses = {\"5\"=>\"Delivered\", \"4\"=>\"On delivery\"}\n qoo10_statuses = {\"5\"=>\"Delivered\"}\n for j in 1..10\n begin\n s_date = j.day.ago.strftime(\"%Y%m%d\")\n e_date = (j-1).day.ago.strftime(\"%Y%m%d\")\n qoo10_statuses.keys.each do |k|\n uri = URI(market_place.domain_url+'/ShippingBasicService.api/GetShippingInfo')\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data({'key'=>smp.api_secret_key,'ShippingStat'=>k,'search_Sdate'=>s_date,'search_Edate'=>e_date})\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|http.request(req)end\n if res.code == \"200\"\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=>true)\n begin\n if res_body[:ShippingAPIService][:ResultMsg] == \"Success\"\n for i in 1..res_body[:ShippingAPIService][:TotalOrder].to_i\n order = res_body[:ShippingAPIService][(\"Order\"+i.to_s).to_sym]\n # find out the order\n @order = nil\n @order = Spree::Order.where(\"market_place_order_no=? AND seller_id=?\", order[:orderNo], smp.seller_id).try(:first)\n # check order present or not and order should not be cancelled already\n if @order.present? && !@order.is_cancel?\n # code to delivered the order\n if @order.update_attributes!(:market_place_order_status => \"Delivered\")\n @all_cart_numbers << @order.cart_no if @order.market_place_order_status == \"Delivered\" && (!fba_complete_states.include?@order.fulflmnt_state)\n else\n @message << \"Order not found!\"\n end # End of success status change in SF if\n end # End if order nil\n end # End of for loop\n end # End of success if\n @all_cart_numbers = @all_cart_numbers.uniq\n #Call to FBA to change status\n Spree::Order.update_fba_state(@all_cart_numbers.uniq, smp, \"Completed\") if @all_cart_numbers.present?\n rescue Exception => e\n @message << e.message\n end\n else\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=> true)\n @message << res_body[:ShippingAPIService][:ResultMsg]\n end\n end # End of status do\n rescue Exception => e\n @message << e.message\n end\n end # End for loop for day\n return @message.join(\"; \")\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 original_price = params[:price].to_i\n sku = params[:sku]\n direccion = params[:direccion]\n code = params[:code]\n price = getPrice(code, original_price)\n\n # 2,147,483,647 is crazy. See issue #2695.\n if quantity.between?(1, 2_147_483_647)\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\n if direccion.empty?\n url = \"http://integra6.ing.puc.cl/tienda/noAddress\"\n redirect_to url\n else\n if (quantity>Bodega.getProductStock(sku))\n url = \"http://integra6.ing.puc.cl/tienda/stock\"\n redirect_to url\n else\n @id_boleta = Banco.crearBoleta(quantity*price, direccion)\n Bodega.despacharPedido(@id_boleta, sku, quantity, price, direccion)\n urlOk='http://integra6.ing.puc.cl/tienda/success/'<<@id_boleta\n url = $heroku_url+ \"web/pagoenlinea?callbackUrl=\"+urlOk+\"&cancelUrl=http://integra6.ing.puc.cl/tienda/error&boletaId=\"+@id_boleta\n redirect_to url\n end\n end\n end", "def load_next_track\n self.already_read = 0\n self.current_track = Track.next_track(self.current_track._id) \n end", "def despacharFtp(sku,cant,to,oc)\n price = Product.where(sku: sku).first.price\n transfered = 0\n #do while products have to be dispatched\n while transfered < cant do\n resp = Fetcher.Bodegas(\"GET\"+DESPACHO+sku.to_s,\"stock?almacenId=\"+DESPACHO+\"&sku=\"+sku.to_s)\n puts resp\n count = 0\n for prod in resp do\n if count == 89 && transfered < cant then\n sleep(60)\n count = 0\n end\n if transfered < cant then\n id_aux = prod['_id']\n dispatchStockFTP(id_aux,oc,to,price)\n count+=1\n transfered+=1\n else\n return 0\n end\n end\n end\n #restar stock\n a = Product.where(sku:sku.to_i).first\n a.stock -= cant\n a.save\n end", "def quote_missing_symbol(missing_symbol)\n endpoint = 'https://www.alphavantage.co/'\n query = \"query?function=GLOBAL_QUOTE&symbol=#{missing_symbol}&apikey=#{@api}\"\n\n #### TODO: Break this out into a new function, since #quote uses it, too. Not doing it now for the sake of time.\n resp = JSON.parse(URI.open(\"#{endpoint}#{query}\").read)['Global Quote']\n\n if resp.nil?\n @value = Stock::NO_VALUE\n @movement = Stock::NO_CHANGE\n else\n @value = resp['05. price'].to_i\n change = resp['09. change'].to_i\n\n @movement = if change.positive?\n Stock::POS_CHANGE\n elsif change.negative?\n Stock::NEG_CHANGE\n elsif change.zero?\n Stock::NO_CHANGE\n else\n Stock::NO_CHANGE\n end\n end\n\n old_value = @cache[missing_symbol]\n @cache[missing_symbol] = \"#{missing_symbol} $#{@value} #{@movement}\"\n\n return unless @cache[missing_symbol] != old_value\n\n # TODO: DRY this up, make sure it isn't being called too much (see init_cache)\n # TODO: simple file operations like this are a good candidate for optimization/moving\n File.open(Stock::CACHE_FILENAME, 'w') do |file|\n file.write(@cache.to_json)\n end\n\n @cache[missing_symbol]\n end", "def lowest_stock # A refactoriser via méthode SQL, on peut faire beaucoup plus court\n # Pour chaque produit récupérer la remaining quantity\n # Vérifier si cette valeur est inférieure à un critère donné\n # Renvoyer la liste de tous les produits concernés\n @products = Product.all\n @products = @products.sort_by do |product|\n product.total_remaining_quantity\n end\n low_stock_trigger = 3 # Plancher de quantité qui trigger l'alimentation de la liste des low_stocks\n low_stock_list = Array.new\n @products.each do |product|\n if product.total_remaining_quantity < low_stock_trigger\n low_stock_list << product\n end\n end\n return low_stock_list.first # Pour l'instant on ne renvoit qu'un item pour qu'on ait une seule notif pour stock bas\n end", "def refill\n check = Ticket.where(table: session[:table_id]).last\n\t unless check.nil?\n\t\t@items = OrderItem.where(:ticket_id => check.id)\n\t end\n end", "def load_order!\n @order = current_user.orders.find params[:id]\n # @order = @cookbook.get_active_reorder(params[:id]) if @cookbook.is_owner? current_user\n end", "def enter_stock(params, user)\n # PaperTrail.whodunnit = user.id\n\n # validate fifo\n puts '----------------------ss'\n fifo = validate_fifo_time(params[:fifo])\n # validate whId existing\n wh = Warehouse.find_by(id: params[:warehouse_id])\n raise '仓库未找到' unless wh\n # validate uniq_nr\n raise 'uniq nr 已存在!' if params[:uniq_nr].present? and Storage.find_by(params[:uniq_nr])\n\n if !params[:package_nr].blank? and Storage.find_by(package_nr: params[:package_nr], part_id: params[:part_id])\n raise \"该唯一码#{params[:package_nr]}已入库!\"\n else\n data = {part_id: params[:part_id], quantity: params[:quantity], fifo: fifo, warehouse_id: wh.id, position_id: params[:position_id]}\n data[:uniq_nr] = params[:uniq_nr] if params[:uniq_nr].present?\n data[:package_nr] = params[:package_nr] if params[:package_nr].present?\n data[:user_id] = user.id\n # data[:locked]=true if params[:locked].present?\n if params[:package_nr].present?\n Storage.create!(data)\n else\n storage = Storage.where(part_id: params[:part_id], warehouse_id: wh.id, position_id: params[:position_id], package_nr: nil).order(\"storages.quantity asc\").first\n\n if storage\n storage.update!(quantity: storage.quantity + params[:quantity].to_f)\n else\n Storage.create!(data)\n end\n end\n end\n\n #:part_id, :fifo, :quantity, :package_nr, :uniq, :from_position_id, :from_warehouse_id, :to_position_id, :to_warehouse_id, :move_type_id, :user_id, :remarks\n type = MoveType.find_by_nr('ENTRY')\n data = {fifo: fifo, part_id: params[:part_id], quantity: params[:quantity], to_warehouse_id: wh.id, to_position_id: params[:position_id],\n move_type_id: type.id}\n data[:uniq_nr] = params[:uniq_nr] if params[:uniq_nr].present?\n data[:package_nr] = params[:package_nr] if params[:package_nr].present?\n data[:user_id] = user.id\n data[:remarks] = params[:remarks] if params[:remarks].present?\n Movement.create!(data)\n end", "def reorder_stock?\n stock < 100 && !current_reorder ? true : false\n end", "def set_stock\n if params[:id]\n @stock = Stock.find(params[:id])\n elsif params[:ticker_symbol]\n @stock = Stock.find_by_ticker_symbol(params[:ticker_symbol])\n end\n @stock.update_price if @stock and Time.now - @stock.updated_at > 1.minute \n end", "def load_existing_variant_sku\n @order = Spree::Order.find_by_id(params[:order_id])\n @line_item = Spree::LineItem.find_by_id(params[:line_item_id])\n respond_to do |format|\n format.html { render :partial=>\"edit_lineitems\"}\n end\n end", "def fetch_data\n xml = AxOrder.httpagent(:body => AxOrder.request_xml(ax_order_number)).body\n doc = Hpricot.XML(xml)\n\n order = {\n :ax_account_id => find_ax_account_id((doc/:CustAccount).inner_text),\n :ax_account_number => (doc/:CustAccount).inner_text,\n :delivery_city => (doc/:DeliveryCity).inner_text,\n :delivery_country_region_id => (doc/:DeliveryCountryRegionId).inner_text,\n :delivery_county => (doc/:DeliveryCounty).inner_text,\n :delivery_date => (doc/:DeliveryDate).inner_text,\n :delivery_state => (doc/:DeliveryState).inner_text,\n :delivery_street => (doc/:DeliveryStreet).inner_text,\n :delivery_zip_code => (doc/:DeliveryZipCode).inner_text,\n :purch_order_form_num => (doc/:PurchOrderFormNum).inner_text,\n :sales_tax => (doc/:SalesTax).inner_text,\n :shipping_charges => (doc/:ShippingCharges).inner_text,\n :discounts => (doc/:Discounts).inner_text,\n :created_date => (doc/:CreatedDate).inner_text,\n :modified_date => (doc/:ModifiedDate).inner_text,\n :sales_status => (doc/:SalesStatus).inner_text,\n :status => \"UPDATE\"\n }\n\n items = []\n (doc/:SalesLine).each do |sales_line|\n items << {\n :ax_order_number => ax_order_number,\n :confirmed_lv => (sales_line/:ConfirmedDlv).inner_text,\n :delivered_in_total => (sales_line/:DeliveredInTotal).inner_text,\n :invoiced_in_total => (sales_line/:InvoicedInTotal).inner_text,\n :item_id => (sales_line/:ItemId).inner_text,\n :remain_sales_physical => (sales_line/:RemainSalesPhysical).inner_text,\n :sales_item_reservation_number => (sales_line/:SalesItemReservationNumber).inner_text,\n :sales_qty => (sales_line/:SalesQty).inner_text,\n :sales_unit => (sales_line/:SalesUnit).inner_text\n }\n end\n\n return order, items\n end", "def import_supply_items(filename = self.import_filename)\n # before calling this in a descended class, you must set up these variables:\n # @supplier = The supplier to import for (an AR object)\n SupplyItem.expire_category_tree_cache(@supplier)\n\n ThinkingSphinx::Deltas.suspend :supply_item do\n File.open(filename, \"r:utf-8\").each_with_index do |line, i|\n next if i == 0 # We skip the first line, it only contains header information\n data = parse_line(line)\n next if data == false\n next if data[:supplier_product_code].blank? # The line is incomplete, skip it\n # check if we have the supply item\n local_supply_item = SupplyItem.where(:supplier_id => @supplier.id,\n :supplier_product_code => data[:supplier_product_code]).first\n # We do not have that supply item yet\n if local_supply_item.nil?\n si = new_supply_item(data)\n if si.save\n supplier_logger.info(\"[#{DateTime.now.to_s}] SupplyItem create: #{si.inspect}\")\n else\n supplier_logger.error(\"Failed adding supply item during sync: #{si.inspect.to_s}, #{si.errors.to_s}\")\n end\n # We already have that supply item and need to update that and related product information\n else\n update_supply_item(local_supply_item, data)\n end\n end\n end\n Product.update_price_and_stock # Sync available products to the now changed supply items\n CategoryDispatcher.create_unique_combinations_for(@supplier)\n end", "def load!\n money = redis.get('money')\n money && @use_redis ? money_from_json(money) : default_hash\n end", "def order_fetch_lazada(smp)\n @message = []\n @cart_numbers = []\n Time.zone = \"Singapore\"\n current_time = Time.zone.now\n orders_params = {\"Action\"=>\"GetOrders\", \"CreatedAfter\"=>(current_time.to_time-1.year).iso8601, \"Timestamp\"=>current_time.to_time.iso8601, \"UserID\"=>smp.contact_email, \"Version\"=>\"1.0\"}\n signature = ApiJob.generate_lazada_signature(orders_params, smp)\n market_place = smp.market_place\n if signature\n string_to_be_formed = []\n sorted_params = Hash[orders_params.sort]\n sorted_params.merge!(\"Signature\"=>signature)\n sorted_params.each do |key,value|string_to_be_formed << CGI::escape(\"#{key}\")+\"=\"+CGI::escape(\"#{value}\")end\n param_string = \"?\"+string_to_be_formed.join('&')\n uri = URI.parse(market_place.domain_url+param_string)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n res = http.request(request)\n if res.code == \"200\"\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=>true)\n if res_body[:SuccessResponse] && res_body[:SuccessResponse][:Body][:Orders]\n @orders = []\n @orders << res_body[:SuccessResponse][:Body][:Orders][:Order]\n @orders = @orders.flatten\n begin\n @orders.each do |order|\n # {:OrderId=>\"127250\", :CustomerFirstName=>\"JUNtest\", :CustomerLastName=>\"Lee\", :OrderNumber=>\"205373278\", :PaymentMethod=>\"CashOnDelivery\", :Remarks=>nil, :DeliveryInfo=>nil, :Price=>\"1497.00\", :GiftOption=>\"0\", :GiftMessage=>nil, :VoucherCode=>nil, :CreatedAt=>\"2015-12-08 15:20:03\", :UpdatedAt=>\"2015-12-14 17:20:13\",\n # :AddressBilling=>{:FirstName=>\"JUNtest\", :LastName=>\"Lee\", :Phone=>\"94331273\", :Phone2=>\"94331273\", :Address1=>\"Blk 602 B Punggol Central\", :Address2=>\"#04-666\", :Address3=>nil, :Address4=>nil, :Address5=>nil, :City=>\"Singapore\", :Ward=>nil, :Region=>nil, :PostCode=>\"822602\", :Country=>\"Singapore\"},\n # :AddressShipping=>{:FirstName=>\"JUNtest\", :LastName=>\"Lee\", :Phone=>\"94331273\", :Phone2=>\"94331273\", :Address1=>\"Blk 602 B Punggol Central\", :Address2=>\"#04-666\", :Address3=>nil, :Address4=>nil, :Address5=>nil, :City=>\"Singapore\", :Ward=>nil, :Region=>nil, :PostCode=>\"822602\", :Country=>\"Singapore\"},\n # :NationalRegistrationNumber=>nil, :ItemsCount=>\"3\", :PromisedShippingTime=>nil, :Statuses=>{:Status=>\"ready_to_ship\"}}\n # order = @orders.first\n message = create_order_for_lazada(order, smp)\n @message << order[:OrderNumber].to_s+\"-\"+message.to_s if message != true\n end if @orders.present? # End for Order loop\n rescue Exception => e\n @message << e.message\n end\n else\n @message << \"API call failed\"\n end\n end # End for the order fetch response check\n end # End for order fetch signature check\n @cart_numbers = @cart_numbers.uniq\n @message << \"FBA: \"+ Spree::Order.push_to_fba(@cart_numbers) if @cart_numbers.present?\n @message << fetch_invoice_from_lazada(smp)\n return @message.join(\"; \")\n end", "def in_stock?\n stock\n end", "def in_stock?\n true\n end", "def import\n if gateway.valid?\n gateway.items.map do |item|\n import_item(item)\n end\n else\n @errors = gateway.errors\n false\n end\n end", "def set_uniform_stock_received\n @uniform_stock_received = UniformStockReceived.find(params[:id])\n end", "def in_stock?\n \t\tif stock > 0 \n \t\t\tTRUE\n \t\telse \n \t\t\tFALSE \n \t\tend\n \tend", "def validate_product_quantity_in_stock\n init_order_and_order_item\n session[:cart].values.each do |item|\n product = Product.find_by id: item[\"product_id\"].to_i\n next if conditional_checking(product, item)\n @order.errors.add(:unit_in_stock, add_flash_danger(product))\n end\n return if @order.errors.blank?\n render :new\n end", "def consultar_stock(sku = nil)\n begin\n logger.debug(Rails.application.config.oc_api_url)\n sku_code = sku || params.require(:sku)\n stock = 0\n hydra = Typhoeus::Hydra.new\n Store.where('pulmon = ? AND despacho = ? AND recepcion = ?',false,false,false).each do |fabrica|\n request = StoresController.new.request_sku_with_stock(fabrica['_id'])\n request.on_complete do |response|\n value = JSON.parse(response.body).select { |item| item['_id'] == sku_code }.first()\n if !value.nil?\n stock = stock + value['total'];\n end\n end\n hydra.queue(request)\n end\n response = hydra.run\n if sku.nil?\n respond_to do |format|\n format.json { render json: {:stock => stock, :sku => sku_code} }\n format.html { render json: {:stock => stock, :sku => sku_code} }\n end\n else\n return stock\n end\n rescue => ex\n Applog.debug(ex.message,'consultar_stock')\n respond_to do |format|\n format.json { render json: {:status => false} }\n format.html { render json: {:status => false} }\n end\n end\nend", "def stock_item(variant_id, user_id = nil, original_stock_location_id = nil)\n return super(variant_id) unless reserved_items?\n raise(\n UserRequiredArgumentError,\n Spree.t(:user_id_required_for_reserved_stock_location)\n ) unless user_id.present?\n items = stock_items.where(variant_id: variant_id, user_id: user_id)\n items = items.where(\n original_stock_location_id: original_stock_location_id\n ) unless original_stock_location_id.blank?\n items.order(:id).first\n end", "def import_produit_assoc(elt, produit_assoc, index)\n import_ok = true\n produit_assoc.facture_id = elt.id if elt.kind_of?(Facture)\n produit_assoc.pulve_id = elt.id if elt.kind_of?(Pulve)\n if produit_assoc.save\n # update stock produit according to putoproduit quantity \n # amount of stock increase when produit is baught\n produit_assoc.produit.update_protofacture_stock\n import_ok = true\n else\n import_ok = false\n produit = produit_assoc.try(:produit).try(:name) || ''\n self.add_error(\"produit '#{produit}' non valide\", index)\n self.add_error(produit_assoc.errors, index)\n end\n return import_ok\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def lookup_stock(name)\n return StockQuote::Stock.quote(name)\nend", "def set_stock_item\n @stock_item = StockItem.find(params[:id])\n end", "def set_stock_item\n @stock_item = StockItem.find(params[:id])\n end", "def handle_bestbuy\n sku_number = find_bestbuy_id(self.url)\n\n if sku_number\n # gets rid of .p\n sku_number = sku_number[0..-3]\n begin\n bestbuy_json = JSON.parse(open(\"http://api.remix.bestbuy.com/v1/products(sku=#{sku_number})?apiKey=#{BEST_BUY_API_KEY}&format=json\").read)\n if bestbuy_json[\"total\"] == 0\n errors.add(:base, \"Best Buy URL Invalid. Please try again.\")\n else\n self.thumbnail = bestbuy_json[\"products\"][0][\"largeImage\"] || bestbuy_json[\"products\"][0][\"image\"] \n self.name = self.name || bestbuy_json[\"products\"][0][\"name\"]\n # TODO should get rid of this in favor of decimal column\n self.current_price = Integer(bestbuy_json[\"products\"][0][\"salePrice\"].to_s.sub(\".\", \"\")) || Integer(bestbuy_json[\"products\"][0][\"regularPrice\"].to_s.sub(\".\", \"\"))\n end\n rescue => e\n # for debugging\n logger.error e.message\n e.backtrace.each { |line| logger.error line }\n errors.add(:base, \"Best Buy URL Invalid. Please try again.\")\n end\n else\n errors.add(:base, \"Best Buy URL Invalid. Please try again.\")\n end\n end", "def purchase_stock!\n nil\n end", "def innotrac_response\n InnotracOrder.where(order_number: self.number).first\n end", "def receive_quietly backordered_units\n \n return if backordered_units.count < 1\n \n # TODO backordered units are not in stock\n \n self.variant.update_column(:count_on_hand, self.variant.on_hand + backordered_units.count)\n self.variant.save\n backordered_units.each(&:fill_backorder)\n \n end", "def initialize(symbol)\n @stock = StockQuote::Stock.quote(symbol)\n @name = @stock.name\n @bid = @stock.bid\n @change = @stock.change\n @change_percent = @stock.change_percent_change\n @day_range = @stock.days_range\n end", "def bs_order(o)\n tkr = o[:tkr]\n half_at_2R = o[:half_at_2R]\n return if not active_ticker?(tkr)\n #orders[tkr] |= {}\n size = (o[:pos_risk].to_f / (o[:stop_px].to_f-o[:stop_ex].to_f)).to_i\n return if invalid_size?(size)\n debug \"stage order to buy #{size} #{o[:tkr]} @#{o[:stop_px]}, risking #{o[:pos_risk]}\"\n unless o[:stop_px].to_f > 0\n warn \"must input valid entry stop price!\"\n return\n end\n stop_price = (o[:stop_px].to_f).round(2)\n stop_loss = (o[:stop_ex].to_f).round(2)\n limit_price = ((stop_price > 10) ? stop_price+0.38 : stop_price+0.12).round(2)\n #limit_price = 0\n profit_price = o[:tgt_price].to_f.round(2) || (o[:pos_risk].to_f * 4 / size + stop_price).round(2)\n\n debug \"stop_price = #{stop_price}\"\n debug \"stop_loss = #{stop_loss}\"\n debug \"limit_price = #{limit_price}\"\n debug \"profit_price = #{profit_price}\"\n\n #-- Parent Order --\n #buy_limit(tkr,size,limit_price)\n debug \"send parent order\"\n debug \"IB::Order.new :total_quantity => #{size},\"\n debug \" :limit_price => #{limit_price},\"\n debug \" :aux_price => #{stop_price},\"\n debug \" :action => 'BUY',\"\n debug \" :order_type => 'STP',\"\n debug \" :algo_strategy => '',\"\n debug \" #:account => account_code,\"\n debug \" :transmit => true\"\n buy_order = IB::Order.new :total_quantity => size,\n :limit_price => limit_price,\n :aux_price => stop_price,\n :action => 'BUY',\n :tif => 'GTC',\n :order_type => 'STPLMT',\n :algo_strategy => '',\n #:account => account_code,\n :transmit => true\n #ib.wait_for :NextValidId\n place_order buy_order, @contracts[tkr]\n \n #-- Child STOP --\n puts \"send stop order\"\n debug \"IB::Order.new :total_quantity => #{size},\"\n debug \" :limit_price => 0,\"\n debug \" :aux_price => #{stop_loss},\"\n debug \" :action => 'SELL',\"\n debug \" :order_type => 'STP',\"\n #puts \" :account => account_code,\"\n debug \" :parent_id => #{buy_order.local_id},\"\n debug \" :transmit => true\"\n stop_order = IB::Order.new :total_quantity => size,\n :limit_price => 0,\n :aux_price => stop_loss,\n :action => 'SELL',\n :tif => 'GTC',\n :order_type => 'STP',\n #:account => account_code,\n :parent_id => buy_order.local_id,\n :transmit => true\n ib.wait_for :NextValidId\n place_order stop_order, @contracts[tkr]\n \n #-- BreakEven LMT\n tgt_1 = (stop_price + 2*(stop_price - stop_loss)).round(2)\n size_1 = (size/2).round(0)\n size_2 = size - size_1\n if half_at_2R && profit_price > tgt_1\n size = size_2\n debug \"breakeven_order = IB::Order.new :total_quantity => #{size_1},\"\n debug \" :limit_price => #{tgt_1},\"\n debug \" :action => 'SELL',\"\n debug \" :tif => 'GTC',\"\n debug \" :order_type => 'LMT',\"\n #debug \" :parent_id => #{buy_order.local_id},\"\n debug \" :transmit => true\"\n \n breakeven_order = IB::Order.new :total_quantity => size_1,\n :limit_price => tgt_1,\n :action => 'SELL',\n :tif => 'GTC',\n :order_type => 'LMT',\n #:parent_id => buy_order.local_id,\n :transmit => true\n place_order breakeven_order, @contracts[tkr]\n end \n #-- Profit LMT\n #puts \"profit_order = IB::Order.new :total_quantity => #{size},\"\n #puts \" :limit_price => #{profit_price},\"\n #puts \" :action => 'SELL',\"\n #puts \" :tif => 'GTC',\"\n #puts \" :order_type => 'LMT',\"\n #puts \" :parent_id => #{buy_order.local_id},\"\n #puts \" :transmit => true\"\n \n #profit_order = IB::Order.new :total_quantity => size,\n # :limit_price => profit_price,\n # :action => 'SELL',\n # :tif => 'GTC',\n # :order_type => 'LMT',\n # #:account => account_code,\n # :parent_id => buy_order.local_id,\n # :transmit => true\n #place_order profit_order, @contracts[tkr]\n end", "def return_stock!(from_status, new_status)\n update_from_to_status!(from_status, new_status, noop: true) do\n order_items.each(&:return_items!)\n end\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def cancel_order_fetch_qoo10(smp)\n @message = []\n market_place = Spree::MarketPlace.find(smp.market_place_id)\n #qoo10_claim_statuses = {\"1\"=>\"Cancel Request\", \"2\"=>\"Cancelling\", \"3\"=>\"Cancel Completed\", \"4\"=>\"Return Request\", \"5\"=>\"Returning\", \"6\"=>\"Return completed\"}\n #qoo10_claim_statuses.keys.each do |k|\n uri = URI(market_place.domain_url+'/ShippingBasicService.api/GetClaimInfo')\n req = Net::HTTP::Post.new(uri.path)\n req.set_form_data({'key'=> smp.api_secret_key, 'ClaimStat'=> '3', 'search_Sdate'=> '', 'search_Edate'=>''})\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|http.request(req)end\n if res.code == \"200\"\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=> true)\n begin\n if res_body[:ShippingAPIService][:ResultMsg] == \"Success\"\n for i in 1..res_body[:ShippingAPIService][:TotalOrder].to_i\n order = res_body[:ShippingAPIService][(\"Order\"+i.to_s).to_sym]\n # find out the order\n @order = nil\n @order = Spree::Order.where(\"market_place_order_no=? AND seller_id=?\", order[:orderNo], smp.seller_id).try(:first)\n # check order present or not and order should not be cancelled already\n if @order.present? && !@order.is_cancel?\n # code to cancel the order\n if @order.update_attributes(:is_cancel=> true)\n cm_user = !@order.is_bypass rescue true\n if cm_user\n seller_id = @order.seller_id\n market_place_id = @order.market_place_id.present? ? @order.market_place_id : nil\n product_id = @order.products.present? ? @order.products.first.id : nil\n seller_market_place_product = Spree::SellersMarketPlacesProduct.where(\"seller_id=? AND market_place_id=? AND product_id=?\", seller_id, market_place_id, product_id)\n if seller_market_place_product.present?\n # code to add the stock after cancelling the order\n # if @order.line_items.present?\n # @order.line_items.each do |line_item|\n # stock = seller_market_place_product.first.product.stock_products.where(\"variant_id=? AND sellers_market_places_product_id=?\", line_item.variant.id, seller_market_place_product.first.id).first\n # stock.variant.update_attributes(:fba_quantity=>stock.variant.fba_quantity + line_item.quantity) if stock && !stock.variant.quantity_inflations.present?\n # stock.update_attributes(:count_on_hand=>stock.count_on_hand + line_item.quantity) if stock\n # end\n # end\n @order.update_attributes!(:market_place_order_status => \"cancel\", :order_canceled_date=>order[:cancelRefundDate])\n # call api in FBA to cancel the order\n #@order.cancel_order_on_fba(smp)\n @message << @order.market_place_order_no.to_s+\": \"+ \"Success\"\n end # End if seller_product\n else\n @order.update_attributes!(:market_place_order_status => \"cancel\", :order_canceled_date=>order[:cancelRefundDate])\n @order.mp_order_line_items.update_all(:is_cancel=>true)\n end\n else\n @order.update_attributes(:is_cancel=> false, :order_canceled_date=>nil)\n @message << @order.market_place_order_no.to_s+\": \"+ \"Failure\"\n end # End if update order\n else\n @message << \"Order not found!\"\n end # End if order nil\n end # End of for loop\n end # End of if\n # Order cancelation on FBA\n order_cancelation_on_fba(smp)\n rescue Exception => e\n @message << e.message\n end\n else\n res_body = Hash.from_xml(res.body).to_json\n res_body = JSON.parse(res_body, :symbolize_names=> true)\n @message << res_body[:ShippingAPIService][:ResultMsg]\n end\n #end # End of do\n return @message.join(\"; \")\n end", "def initialize\n\t\t\t@header = Array.new\n\t\t\t@data = Array.new\n\n\t\t\tclient = JpnStock::Client.new\n\n\t\t\tJpnStock.configure do |config|\n\t\t\t\tclient.code = config.code\n\t\t\t\tclient.year = config.year\n\t\t\tend\n\n\t\t\turl = client.get\n\t\t\t# => \"https://kabuoji3.com/stock/1321/2018/\"\n\n\t\t\tcharset = nil\n\t\t\thtml = open(url) do |f|\n\t\t\t\tcharset = f.charset\n\t\t\t\tf.read\n\t\t\tend\n\n\t\t\thtml_doc = Nokogiri::HTML.parse(html, nil, charset)\n\n=begin\n\t\t\tbegin\n\t\t\t\thtml_doc = Nokogiri::HTML.parse(html, nil, charset)\n\t\t\trescue\n\t\t\t\tSTDOUT.puts 'Warning: Wait 1 mitunes...'\n\t\t\t\tsleep(30)\n\t\t\t\tSTDOUT.puts 'Retry'\n\t\t\t\tretry\n\t\t\tend\n=end\n\n\t\t\tmode = Configuration::DEFAULT_MODE\n\n\t\t\tJpnStock.configure do |config|\n\t\t\t\tmode = config.mode\n\t\t\tend\n\n\t\t\tif Configuration::MODE.index(mode).nil?\n\t\t\t\tif mode.nil?\n\t\t\t\t\tSTDERR.puts \"#{__FILE__}:#{__LINE__}:Error: wrong mode of configuration - Nil\"\n\t\t\t\telse\n\t\t\t\t\tSTDERR.puts \"#{__FILE__}:#{__LINE__}:Error: wrong mode of configuration - #{mode}\"\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t@header = client.stock_data_table_header\n\t\t\t\t# => {\n\t\t\t\t # \t:japanese => ['日付', '始値', '高値', '安値', '終値', '出来高', '終値調整'], \n\t\t\t\t # \t:english => ['date', 'open', 'high', 'low', 'close', 'volume', 'adj_close']\n\t\t\t\t # }\n\n\t\t\t\t# pick up 'stock data table'\n\t\t\t\t@data = parse(html_doc)\n\t\t\t\t# => [\n\t\t\t\t # \t['2018-01-04', '23770', '24150', '23770', '24150', '611004', '24150'], \n\t\t\t\t # \t['2018-01-05', '24280', '24390', '24170', '24370', '495513', '24370']\n\t\t\t\t # ]\n\n\t\t\t\tcase mode\n\t\t\t\t# 'year'\n\t\t\t\t#when Configuration::MODE[0]\n\t\t\t\t# 'month'\n\t\t\t\t#when Configuration::MODE[1]\n\t\t\t\t# 'day'\n\t\t\t\twhen Configuration::MODE[2]\n\t\t\t\t\tdate = ''\n\t\t\t\t\tJpnStock.configure do |config|\n\t\t\t\t\t\tif config.year.nil?\n\t\t\t\t\t\t\tSTDERR.puts \"#{__FILE__}:#{__LINE__}:Error: year is Nil\"\n\t\t\t\t\t\t\t# data is initialized due to error\n\t\t\t\t\t\t\t@data.clear\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tif config.month.nil?\n\t\t\t\t\t\t\tSTDERR.puts \"#{__FILE__}:#{__LINE__}:Error: month is Nil\"\n\t\t\t\t\t\t\t# data is initialized due to error\n\t\t\t\t\t\t\t@data.clear\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tif config.day.nil?\n\t\t\t\t\t\t\tSTDERR.puts \"#{__FILE__}:#{__LINE__}:Error: day is Nil\"\n\t\t\t\t\t\t\t# data is initialized due to error\n\t\t\t\t\t\t\t@data.clear\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tdate = config.year + '-' + config.month + '-' + config.day\n\t\t\t\t\t\t# => '2018-01-05'\n\n\t\t\t\t\t\tbegin\n\t\t\t\t\t\t\tt = Time.parse(date)\n\t\t\t\t\t\trescue => error\n\t\t\t\t\t\t\tSTDERR.puts \"#{__FILE__}:#{__LINE__}:Error: #{error.message} (#{error.class})\"\n\n\t\t\t\t\t\t\t# data is initialized due to error\n\t\t\t\t\t\t\t@data = []\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\ttmp = Array.new\n\t\t\t\t\t\t\tindex = @header[:english].index('date')\n\n\t\t\t\t\t\t\t# search and extract target data corresponding to date\n\t\t\t\t\t\t\t@data.each{ |e|\n\t\t\t\t\t\t\t\tif t == Time.parse(e[index])\n\t\t\t\t\t\t\t\t\ttmp = e\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t@data.clear\n\n\t\t\t\t\t\t\t# if could not search target data, then @data is stil empty\n\t\t\t\t\t\t\t# if could search target one, @data is updated\n\t\t\t\t\t\t\t@data.push tmp unless tmp.empty?\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def initialize(submitted_stock)\n @stock_ticker = submitted_stock\n \tend", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def set_stock\n @stock = Stock.find(params[:id])\n end", "def calculate_stocks\n stocks = stocks_owned\n .map { |stock| {ticker: stock[0], shares: stock[1]} }\n .sort_by { |stock| stock[:ticker] }\n\n # url = \"https://cloud.iexapis.com/stable/stock/market/batch?types=quote,chart&range=1d&token=#pk_2d262b4b89114ceda9b7ada2d9e99bb9&symbols=\"\n # stocks.each { |stock| url += \"#{stock[:ticker]},\"}\n # response = JSON.parse(open(url).read)\n\n stocks.each_with_index do |stock, idx| \n response = JSON.parse(open(\"https://cloud.iexapis.com/stable/stock/market/batch?types=quote,chart&range=1d&token=pk_2d262b4b89114ceda9b7ada2d9e99bb9&symbols=#{stock[:ticker]}\").read)\n\n \n stock[:price] = response[stock[:ticker]]['quote']['latestPrice']\n stock[:intraday] = response[stock[:ticker]]['chart']\n end\n\n stocks\n end", "def stockquote(stock)\n url = URI(\"https://apidojo-yahoo-finance-v1.p.rapidapi.com/market/v2/get-quotes?region=US&symbols=#{@stock}\")\n\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n \n request = Net::HTTP::Get.new(url)\n request[\"x-rapidapi-key\"] = ENV['X_RAPIDAPI_KEY']\n request[\"x-rapidapi-host\"] = 'apidojo-yahoo-finance-v1.p.rapidapi.com'\n \n response = http.request(request)\n quoteResponse = JSON.parse(response.read_body)['quoteResponse']\n result = quoteResponse['result']\n @zero = result[0]\n puts \"Symbol = #{@zero['symbol']}, Exchange = #{@zero['fullExchangeName']}, Bid = #{@zero['bid']}, Ask = #{@zero['ask']}\"\n\n return \"<div class =col>\n <h2>Symbol=<a>#{@zero['symbol']}</a></h2>\n <h4>Exchange=<a>#{@zero['fullExchangeName']}</a></h4>\n <h4>Bid=<a>#{@zero['bid']}</a></h4>\n <h4>Ask=<a>#{@zero['ask']}</a></h4>\n </div>\"\n end", "def force_load(idx)\n return @index[idx] if @index[idx]\n @index_handle.seek(idx * BLOCK_SIZE)\n @index[idx] = read_entry(@index_handle, idx)\n end", "def before_delivery\r\n return if params[:order].present?\r\n \r\n if @order.bill_address.address1 == 'dummy_address1' or @order.bill_address.city == 'dummy_city' or @order.bill_address.address2.include? \"CityBox\"\r\n @disable_all_except_citybox = true\r\n end\r\n\r\n packages = @order.shipments.map { |s| s.to_package }\r\n @differentiator = Spree::Stock::Differentiator.new(@order, packages)\r\n end", "def fetch\n result = WebApi.json!('ITFItems_440', 'GetPlayerItems', 1, { :SteamID => @steam_id64 })\n\n @items = []\n result[:items][:item].each do |item_data|\n unless item_data.nil?\n item = TF2Item.new(item_data)\n @items[item.backpack_position - 1] = item\n end\n end\n end", "def import_bien b\n\t\tref \t\t\t\t= b['refClient']\n\t\tnb \t\t\t\t\t= Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n\t\tif(nb.nil?)\n\t\t\tif((b['flag'] == \"A\") || (b['flag'] == \"U\"))\n\t\t\t\tnb = Bien.new\n\t\t\telse\n\t\t\t\treturn\n\t\t\tend\n\t\telse\n\t\t\tif(b['flag'] == \"D\")\n\t\t\t\tmark_for_destruction nb\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\t\n\t\tcat_s \t\t\t\t= CAT_CODE_MATCHING[b['typeBien']]\n\t\tnb.bien_type \t\t= BienType.find_or_create cat_s.up_first\n\t\t\n\t\ttransaction\t\t\t= TRANSACTION_MATCHING[b['typeVente']]\n\t\tnb.bien_transaction = BienTransaction.where(:nom => transaction.up_first).first\n\t\tif nb.bien_transaction.nil?\n\t\t\tLogger.send(\"warn\",\"[Ubiflow] Type de transaction nul pour le bien ref : #{ref}\")\n\t\t\t@result[:description] << \"[Ubiflow] Type de transaction nul pour le bien ref : #{ref}\"\n\t\t\treturn\n\t\tend\n\t\t\n\t\t# Good location\n\t\tgood_address \t\t= {}\n\t\tloc \t\t\t\t= BienEmplacement.new\n\t\tloc.pays \t\t\t= \"France\"\n\t\tloc.ville \t\t\t= b['ville']\n\t\tloc.code_postal \t= b['code_postal']\n\n\t\t# find if good already exist, unless create it\n\t\t#nb \t\t\t\t\t= Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n\t\t#nb \t\t\t\t\t= Bien.new if nb.nil?\n\n\t\tnb.is_accueil \t\t= false\n\t\n\t\t# bien common attributes\n\t\tnb.passerelle \t\t= @passerelle\n\t\tnb.reference \t\t= ref\n\t\tnb.bien_emplacement = loc\n\n\t\tnb.nb_piece \t\t= b.xpath('./NbrePiece').text.to_i\n\t\tnb.nb_chambre \t\t= b.xpath('./NbreChambres').text.to_i\n\t\tnb.surface\t\t\t= b.xpath('./SurfaceHabitable').text.to_i\n\t\tnb.surface_terrain\t= b.xpath('./SurfaceTerrain').text.to_i\n\t\t\n\t\tnb.titre \t\t\t= b.xpath('./Designation').text\n\n\t\tif (transaction == \"Location\")\n\t\t\tif NEGOCIATION_MATCHING[b['modeNego']]\n\t\t\t\tnb.prix_charges_comprises \t= b.xpath('./PVB').text.to_i\n\t\t\telse\n\t\t\t\tnb.prix_hors_charges \t\t= b.xpath('./PNV').text.to_i\n\t\t\t\tnb.prix_charges_comprises \t= b.xpath('./PNB').text.to_i\n\t\t\tend\n\n\t\t\tnb.prix \t\t\t= nb.prix_charges_comprises\n\t\telse\n\t\t\tif NEGOCIATION_MATCHING[b['modeNego']]\n\t\t\t\tnb.prix \t\t= b.xpath('./PVB').text.to_i\n\t\t\telse\n\t\t\t\tnb.prix \t\t= b.xpath('./PNV').text.to_i + b.xpath('./fraisNego').text.to_i\n\t\t\tend\n\t\tend\n\t\tnb.prix \t\t\t= b.xpath('./PVB').text.to_i\n\t\tnb.description \t\t= b.xpath('./Annonce').text\n\t\t\n\t\tnb.valeur_dpe \t\t= b.xpath('./dpeNrj').text.to_i\n\t\tnb.classe_dpe\t\t= nb.classe_energie\n\t\tnb.valeur_ges \t\t= b.xpath('./dpeGes').text.to_i\n\t\tnb.class_ges\t\t= nb.classe_ges\n\t\tnb.statut \t\t\t= 'new'\n\t\tnb.save!\n\t\t\n\t\t# If new images : Drop old images, add current images\t\t\n\t\tphotos = b.xpath('./Photo')\n\t\tif photos && !photos.empty?\n\t\t\t# Logger.send(\"warn\", \"[Transim] re import bien photo\")\n\t\t\t\n\t\t\t# un-attach old\n\t\t\tnb.bien_photos.each{ |photo|\n\t\t\t\tphoto.bien = nil\n\t\t\t\tphoto.save!\n\t\t\t}\n\t\t\t\n\t\t\tnumber \t= 0\n\t\t\tphotos.each { |entry| \n\t\t\t\tp = import_local_media(entry.text, entry[\"id\"].to_i, nb, entry.text)\n\t\t\t}\n\t\t\tnb.save!\n\t\tend\n\n\treturn\n\tend", "def in_stock?\n\t\tif self.downloadable?\n\t\t\ttrue\n\t\telsif self.inventory.xsmall > 0 || self.inventory.xxlarge > 0 || \n\t\t\tself.inventory.small > 0 || self.inventory.medium > 0 ||\n\t\t\tself.inventory.xlarge > 0 || self.inventory.large > 0\n\t\t \ttrue\n\t\telse \n\t\t\tfalse\n\t\tend\n\tend", "def in_stock?\n if @stock <= 0\n false\n else\n true\n end\n end", "def populate\n @order = current_order(create_order_if_necessary: true)\n variant = Spree::Variant.find(params[:variant_id])\n content = params[:content]\n content_file = params[:content_file]\n cover = params[:cover]\n deliver_on = params[:deliver_on]\n address_ids = get_address_ids\n quantity = address_ids.count\n\n @order.errors.add(:base, \"Select an address\") if address_ids.empty?\n if variant.product.property('cover') && !cover\n @order.errors.add(:base, \"Attach a cover image\")\n end\n\n # 2,147,483,647 is crazy. See issue https://github.com/spree/spree/issues/2695.\n if quantity > 2_147_483_646\n @order.errors.add(:base, \"Too many addresses\")\n end\n\n unless @order.errors.any?\n begin\n @line_item = @order.contents.add(variant, quantity, content, content_file, cover, deliver_on, address_ids)\n lob_error = lob_test(@line_item)\n if lob_error\n @order.errors.add(:base, lob_error)\n @order.remove_item(@line_item)\n end\n rescue ActiveRecord::RecordInvalid => e\n @order.errors.add(:base, e.record.errors.full_messages.join(\", \"))\n end\n end\n\n respond_with(@order) do |format|\n format.html do\n if @order.errors.any?\n flash[:error] = @order.errors.full_messages.join(\", \")\n redirect_to product_path(variant.product)\n return\n else\n redirect_to cart_path\n end\n end\n end\n end", "def load_order\n\t\tparams[:order_param] ||= session[:order_param]\n\t\tsession[:order_param] = params[:order_param]\n\tend", "def import_bien b\n \n # Good location\n good_address = {}\n\tif b['LOCALISATION']['VISIBLE'].to_s == \"true\"\n\t\tloc = BienEmplacement.new\n\t\tloc.pays = \"France\"\n\t\tloc.code_postal = b['LOCALISATION']['CODE_POSTAL']\n\t\tloc.ville = b['LOCALISATION']['VILLE']\n\telse\n\t\tloc = nil\n\tend\n\n\t# Category & Transaction type\n\tcat_text = find_cat(b)\n if(cat_text.nil? or b[cat_text].nil?)\n\t Logger.send(\"warn\",\"[AC3] Categorie non connue pour le bien ref : #{b[\"INFO_GENERALES\"][\"AFF_NUM\"]}\")\n\t @result[:description] << \"[AC3] Categorie non connue pour le bien ref : #{b[\"INFO_GENERALES\"][\"AFF_NUM\"]}\"\n return\n end\n\tcat_root = b[cat_text]\n\tcat = BienType.find_or_create cat_text.up_first\n\t\n\tLogger.send(\"warn\",\"Categorie : #{cat_text}\")\n\t\n\tif !(b[\"VENTE\"].nil?)\n\t transaction_type = BienTransaction.where(:nom => 'Vente').first\n transactionTypeIndex = \"VENTE\"\n price = b[\"VENTE\"][\"PRIX\"]\n elsif !(b[\"LOCATION\"].nil?)\n transaction_type = BienTransaction.where(:nom => 'Location').first\n transactionTypeIndex = \"LOCATION\"\n b[\"LOCATION\"][\"PROVISION_SUR_CHARGES\"] ||= 0\n price = b[\"LOCATION\"][\"LOYER\"].to_i + b[\"LOCATION\"][\"PROVISION_SUR_CHARGES\"].to_i\n # elsif !(b[\"SAISONNIER\"].nil?)\n # transaction_type = Immo::TransactionType.get 'Saisonnier'\n # transactionTypeIndex = \"SAISONNIER\"\n # price = 0\n else\n\t Logger.send(\"warn\",\"[AC3] Type de transaction nul pour le bien ref : #{b[\"INFO_GENERALES\"][\"AFF_NUM\"]}\")\n\t @result[:description] << \"[AC3] Type de transaction nul pour le bien ref : #{b[\"INFO_GENERALES\"][\"AFF_NUM\"]}\"\n return\n end\n\n\t# find if good already exist, unless create it\n\tref = b[\"INFO_GENERALES\"][\"AFF_NUM\"] \n\tnb = Bien.where(:reference => ref).select{ |b| b.passerelle.installation == @passerelle.installation }.first\n nb = Bien.new if nb.nil?\n\n\tnb.is_accueil = false\n\t#nb.is_accueil = true if b[\"TEXTE_MAILING\"] && (b[\"TEXTE_MAILING\"].to_s.downcase =~ /.*virtual.*touch.*/)\n\t\n\t# update attributes\n\tnb.passerelle = @passerelle\n\tnb.reference = ref\n nb.bien_type = cat\n nb.bien_transaction = transaction_type\n nb.bien_emplacement = loc\n\t\n\tnb.nb_piece = cat_root['NBRE_PIECES'].to_i\n nb.nb_chambre = cat_root['NBRE_CHAMBRES'].to_i\n nb.surface = cat_root['SURFACE_HABITABLE'].to_i\n nb.surface_terrain = cat_root['SURFACE_TERRAIN'].to_i\n nb.titre = b['INTITULE']['FR']\n\t\n nb.prix = price\n nb.description = b['COMMENTAIRES']['FR']\n nb.valeur_dpe = cat_root['CONSO_ANNUEL_ENERGIE']\n\tnb.classe_dpe = cat_root['CONSOMMATIONENERGETIQUE']\n\tnb.valeur_ges = cat_root['VALEUR_GES']\n\tnb.class_ges = cat_root['GAZEFFETDESERRE']\n nb.statut = 'new'\n nb.save!\n\t\n\t# If new images : Drop old images, add current images\n if b['IMAGES'] && b['IMAGES']['IMG']\n # un-attach old\n\t nb.bien_photos.each{ |photo|\n\t\t photo.bien = nil\n\t\t photo.save!\n\t }\n pl = b['IMAGES']['IMG']\n \n # When there only exists a single image, +pl+ will directly be the hash\n pl = [pl] unless pl.kind_of? Array\n # Map photo-hashes to medias, filter out failures, and add medias to good\n\t number = 0\n pl.map { |p| import_remote_media(p,(number += 1),nb) }\n end\n nb.save!\n\n return true\n\n return\n end", "def price_bulk_load\n logger.info 'PRICE BULK LOAD REQUESTED.'\n FeedWorker.perform_async('price_bulk_load')\n head :accepted\n end", "def handle_list( m, params )\n if @stock.length == 0\n m.reply( \"Nothing available.\" ); return\n end\n\n m.reply \"Finite goods: #{@stock.keys.sort.join(', ')}\"\n end", "def create_stock_item\n\n added_new_stock_item = false\n # Get stock location for appropriate location\n @product_row[:location].split(',').each do |sub_location|\n sub_location.chomp!\n stock_location = case sub_location.to_s.downcase\n when /george/\n @@loc_attic\n # NFS no matter what - JC10 OR buffalo display case OR back shop\n when /jc\\d{1,2}|buffalo|back\\sshop|attic/\n @@loc_home_nfs\n # NFS if listed as not for sale (don't count in quantity)\n when /w\\d{1,2}/\n (@product_row[:available] && @product_row[:available].downcase == \"n\") ? @@loc_home_nfs : @@loc_home\n when /[[:alpha:]]\\d{2,3}|D\\d{3}\\.\\d|h\\d|file\\scabinet|suite\\s2/\n (@product_row[:available] && @product_row[:available].downcase == \"n\") ? @@loc_suite2_nfs : @@loc_suite2\n # NWC08\n when /nw[[:alpha:]]\\d{1,2}|ste3/\n @@loc_suite3\n # Warehouse\n when /warehouse/\n @@loc_warehouse\n # West trailer OR east racks\n when /east\\sracks|west\\strailer/\n @@loc_east_racks\n else # if unidentifiable location\n @errors << { :part_number => @product_row[:name], :condition => @product_row[:condition], :message => \"Cannot identify location \" + sub_location }\n next # skip to next location\n end\n\n # if no exisiting sub location, add one\n if(@new_product_condition.add_sub_location(sub_location, stock_location))\n added_new_stock_item = true\n end\n\n end # end location loop\n\n added_new_stock_item # return true if at least one new stock item added\n\n end" ]
[ "0.7569398", "0.7144613", "0.67937493", "0.67354023", "0.65367925", "0.6056922", "0.5861945", "0.5587089", "0.54921794", "0.54418737", "0.5432402", "0.5432042", "0.53774035", "0.5306669", "0.52873474", "0.5270145", "0.5215932", "0.52012783", "0.51901776", "0.51871717", "0.5186042", "0.5172415", "0.5159364", "0.51525795", "0.5152156", "0.5149346", "0.51424843", "0.5115545", "0.5108284", "0.5107658", "0.5099551", "0.50939", "0.50871795", "0.50674903", "0.5057454", "0.50542676", "0.50383276", "0.5036583", "0.5025287", "0.5012748", "0.5012226", "0.49967965", "0.49853453", "0.4985024", "0.4975176", "0.4966747", "0.49602267", "0.4953873", "0.49506164", "0.4945592", "0.49451447", "0.49393767", "0.4936951", "0.4936951", "0.4922752", "0.49178058", "0.4916104", "0.4915072", "0.4913396", "0.4911971", "0.49098083", "0.4908341", "0.49018568", "0.4901019", "0.49010122", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48977357", "0.48945507", "0.48840395", "0.48763108", "0.48732132", "0.48678452", "0.48637047", "0.4858783", "0.48581797", "0.4856323", "0.48511165", "0.48504972", "0.48447883", "0.48414394", "0.48267516" ]
0.7764891
0
Loading an item by lot code selects an inventory item by code, and only loads the item if a match is found.
def load_item_by_lot_code(order_item, stock_items) item = stock_items.find { |item| order_item.lot_code == item.code } # If the order item has a serial number, try lot code part only. if item.nil? && order_item.lot_code['-'] lot_code_part = order_item.lot_code.split('-').first item = stock_items.find { |item| lot_code_part == item.code } end # If a match was found, load the item and return. If a partial # match set a lot code part above, use that, or provide nil # to use the code on the order item. if item.present? item.reserved += order_item.amount return create_item_from(order_item, lot_code_part, item.expires_at) end false # Failed to load the item. end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def source_item\n source.item_by_product_and_code(product, lot_code)\n end", "def find_by_code(code)\n record = fetch(code)\n return unless record\n\n Models::InventoryItem.new(**record.merge(code: code,\n discount: @discounts_rep.find_by_code(code)))\n end", "def assign_inventory_item\n self.inventory_item ||= inventory.item_by_product_and_code(product, lot_code)\n self\n end", "def load_item!(order_item, stock)\n if !order_item.product.tracked_stock? || source.enable_gateway?\n load_item_from_infinite_stock(order_item) && return\n end\n stock_items = stock.select { |item| item.product == order_item.product }\n return false if stock_items.none?\n\n if order_item.lot_code.present?\n load_item_by_lot_code(order_item, stock_items)\n else\n load_item_from_stock(order_item, stock_items)\n end\n end", "def fetch_from_inventory(an_order)\n order = extract_code_qty(an_order)\n return Inventory.fetch_an_item(order[:code])\n end", "def load_item\n @item = Item.find(params[:id]) rescue nil\n \n render_404 unless @item\n end", "def find(item_name)\n @inventory.find(item_name)\n end", "def load_inventory(library, book, stock)\n inventory = Inventory.add_book_to_library(library, book, stock)\n puts \"#{library.name} has a stock of #{stock} of #{book.title}\"\nend", "def determine_item(item_type, item_id)\n case item_type\n \n when \"weapon_id\"\n Weapon.find(item_id) \n when \"armor_id\"\n Armor.find(item_id)\n when \"potion_id\"\n Potion.find(item_id)\n end\n end", "def item_with_identifier(identifier)\n @items.find { |i| i.identifier == identifier }\n end", "def load_from_server(bag_name, item_name = nil)\n begin\n if (item_name)\n item = Chef::DataBagItem.load(bag_name, item_name)\n item = Chef::EncryptedDataBagItem.new(item.raw_data, read_secret) if use_encryption\n else\n item = Chef::DataBag.load(bag_name)\n end\n rescue Net::HTTPServerException => e\n raise unless e.to_s =~ /^404/\n end\n item\n end", "def load_shopping_item_or_not\n @shopping_item_id = nil\n\n if si = params[:shopping_item]\n if si[:offer_id]\n # this is a shopping item that references an offer and cart\n @shopping_item_id = si[:offer_id]\n @admin_customer_offer = Admin::Customer::Offer.find(si[:offer_id])\n @cart = Shopping::Cart.find_by_id(si[:cart_id])\n session[:admin_customer_offer_id] = @admin_customer_offer.id\n raise \"cart offer email mismatch\" if (@cart.email.id != @admin_customer_offer.email.id)\n elsif si[:piece_id]\n @shopping_item_id = si[:piece_id]\n end\n end\n\n unless @shopping_item_id\n @admin_customer_offer = Admin::Customer::Offer.find(session[:admin_customer_offer_id]) if session[:admin_customer_offer_id]\n @shopping_item_id = @admin_customer_offer.id if @admin_customer_offer\n end\n\n end", "def fetch_item(item_id)\n fail \"Missing id\" if item_id.nil?\n fail \"No such item id: #{item_id}\" unless @items.member?(item_id.to_i)\n @items.fetch(item_id.to_i)\n end", "def item\n return $data_items[@item_id] if @item_type == 0\n return $data_weapons[@item_id] if @item_type == 1\n return $data_armors[@item_id] if @item_type == 2\n end", "def load_inventory(first)\n first ? setup_inventory : restore_inventory\n log(RuneRb::GLOBAL[:COLOR].green(\"Loaded Inventory for #{RuneRb::GLOBAL[:COLOR].yellow(@profile.name)}\")) if RuneRb::GLOBAL[:DEBUG]\n end", "def load_item(data_bag, item_name, metadata = {})\n item = ::SecureDataBag::Item.load(data_bag, item_name, metadata)\n item\n end", "def load_item_from_stock(order_item, stock_items)\n amount = order_item.waiting\n stock_items.each do |item|\n all = item.available\n next if all <= 0\n\n if amount <= all\n # This inventory item satisfies the amount, we're done.\n item.reserved += amount\n return create_item_from(order_item, item.code, item.expires_at, amount)\n else\n # Load all of this item and continue with the remaining amount.\n item.reserved += all\n create_item_from(order_item, item.code, item.expires_at, all)\n amount -= all\n end\n end\n end", "def lot_code_from_serial\n if lot_code.blank? && serial.present?\n self[:lot_code] = serial\n end\n self\n end", "def test_selectItem\n\t\t#vm = VendingMachine.new\n\t\tvm = VendingMachine.new(@db)\n\t\tvm.output = StringIO.new\n\t\t# vm.items[\"A1\"].quantity = 1\n\t\tvm.inputMoney(0.50)\n\t\titem = vm.selectItem(\"A1\")\n\t\tassert_not_nil(item)\n\t\tassert_equal(\"A1\", item.code)\n\t\tassert_equal(\"Almond Joy\", item.description)\n\tend", "def item_from_uuid(id)\n @items.find { |i| i[:id].to_s == id } || raise(\"Unable to resolve item for uuid '#{id}'\")\n end", "def available\n @available ||= product.available(inventory, lot_code)\n end", "def item_by_persistent_id\n IITSource.new(@ole.ItemByPersistentID)\n end", "def lot_code_from_serial\n if lot_code.blank? && serial.present?\n self[:lot_code] = serial\n end\n end", "def item\n item_type.name.classify.constantize.find(item_id)\n end", "def retrieve(barcode)\n\n if barcode =~ /#{configuration.mme_code}\\.IN/\n get_inventory(f_global_id: barcode)\n return response['data'].first if response && response['total'] && response['total'] > 0\n end\n\n if barcode =~ /#{configuration.mme_code}\\.BA/\n get_inventory(f_batch_id: barcode)\n return response['data'].first if response && response['total'] && response['total'] > 0\n end\n\n get_inventory page: 999\n\n page = response['last_page']\n data = false\n while !data && page > 0\n get_inventory(page: page)\n if response['data'].respond_to? :values\n data = response['data'].values.find{ |el| el['global_original_id'] == barcode }\n else\n data = response['data'].find{ |el| el['global_original_id'] == barcode }\n end\n page -= 1\n end\n\n if data\n self.response['data'] = [data].compact\n data\n end\n end", "def use_item_by_string(name, e)\n index = has_item_by_string(name)\n if (index != -1)\n inventory[index].first.use(e)\n else\n print \"What?! You don't have THAT!\\n\\n\"\n end\n end", "def item\n fetch('sword_art_online.item')\n end", "def select_product code\n @selected_product = @products.find_by_code(code)\n end", "def use_item\n\n if @inventory.empty?\n slow_type(\"\\nYou don't have anything in your inventory\")\n\n else\n print_inventory_items\n\n use_item = TTY::Prompt.new\n\n choices = []\n @options = []\n @inventory.each do |item_id|\n inventory_item = find_item_by_id(item_id)\n choices << { name: inventory_item.name, value: inventory_item.item_id }\n end\n\n item_id = use_item.select(slow_type(\"\\nWhat would you like to use?\"), choices)\n \n selected_item = find_item_by_id(item_id)\n \n use_on = TTY::Prompt.new\n\n choices = []\n @options = []\n current_cell_items.each do |item_id|\n item = find_item_by_id(item_id)\n choices << { name: item.name, value: item.item_id } unless @inventory.include?(item.item_id) || item.show_item == false\n end\n\n target_item = use_on.select(slow_type(\"\\nWhat would you like to use the #{selected_item.name} on?\"), choices)\n\n combo = @use_combos.find { |combo| combo[:item_id] == item_id && combo[:usage_location] == @current_room_id && combo[:target_id] == target_item}\n \n if combo.nil?\n slow_type(\"\\nYou cannot use these two items together\") \n \n else \n use_item_dependency(item_id)\n slow_type(combo[:message])\n\n if combo[:cell_to_unlock]\n find_room_by_id(combo[:cell_to_unlock]).isLocked = false\n game_complete if combo[:game_complete]\n\n elsif\n combo[:knocked_out]\n @guard_is_knocked_out = true\n end\n\n end\n end\n end", "def get_item name\n if (@listOfItem)\n @listOfItem.select do |item|\n item.product.name == name\n end.first\n else\n puts \"@listOfItem is null, so can't get an item from this\"\n end\n end", "def consume_item(type, id)\n action = eval(type + '_Need_Items.dup')\n equipment = eval(type + '_Need_Equiped.dup')\n if action.include?(id)\n for need in action[id]\n $game_party.lose_item(need[1], need[2]) if need[0] == 'i' \n $game_party.lose_armor(need[1], need[2]) if need[0] == 'a' \n $game_party.lose_weapon(need[1], need[2]) if need[0] == 'w' \n end\n end\n if equipment.include?(id)\n if $atoa_script['Atoa Multi Slot']\n for need in equipment[id]\n equipments = armors.dup if need[0] == 'a'\n equipments = weapons.dup if need[0] == 'w'\n for i in 0...equips.size\n if action_id(equip[i]) == need[1]\n equip(i, 0)\n $game_party.lose_armor(need[1], need[2]) if need[0] == 'a'\n $game_party.lose_weapon(need[1], need[2]) if need[0] == 'w'\n equip(i, equip[i].id)\n end\n end\n end\n else\n for need in equipment[id]\n equipments = armors.dup if need[0] == 'a'\n equipments = weapons.dup if need[0] == 'w'\n for equip in equipments\n if equip.type_name == 'Weapon'\n type = 0\n else\n type = 1 if equip.id == @armor1_id\n type = 2 if equip.id == @armor2_id\n type = 3 if equip.id == @armor3_id\n type = 4 if equip.id == @armor4_id\n end\n if action_id(equip) == need[1]\n equip(type, 0)\n $game_party.lose_armor(need[1], need[2]) if need[0] == 'a'\n $game_party.lose_weapon(need[1], need[2]) if need[0] == 'w'\n equip(type, equip.id)\n end\n end\n end\n end\n end\n end", "def get_item_info(pid)\n @item_info[pid] ||= query_library(pid)\n end", "def find( embed_code )\n query( :embed_code => embed_code ).items.first || raise( ItemNotFound )\n end", "def item_by_name\n IITSource.new(@ole.ItemByName)\n end", "def find_item(purchase_or_id)\n raise NotImplementedError\n end", "def get(item_type, item_id)\n all(item_type).detect { |item| item[:id].to_i == item_id.to_i }\n end", "def item(id)\n Item.find(id)\n end", "def load_item_page\n visit(ITEM_PAGE_URL)\n end", "def use_item(item)\n battler.use_item(item)\n end", "def load_item_list\n @item_quantity = []\n get_list_item\n get_definitive_list_price\n check_if_shop_empty\n @index = 0\n @last_index = @list_item.size - 1\n end", "def find_item_by_product(product, items)\n\t\tsku = product.sap_sku.to_s.upcase\n\t\tsku_options = sku.match(/\\-?[MV]$/) ? [sku, sku.gsub(/\\-?[MV]$/, '')] : sku_options = [\"#{sku}-V\", \"#{sku}-M\", \"#{sku}V\", \"#{sku}M\", sku]\n\n\t\titem = nil\n\t\tsku_options.each do |s|\n\t\t\tif item = items[s]\n\t\t\t\treturn item\n\t\t\tend\n\t\tend\n\t\titem\n\tend", "def pbUseKeyItem\n # TODO: Remember move order\n moves = [:CUT,:DEFOG,:DIG,:DIVE,:FLASH,:FLY,:HEADBUTT,:ROCKCLIMB,:ROCKSMASH,\n :SECRETPOWER,:STRENGTH,:SURF,:SWEETSCENT,:TELEPORT,:WATERFALL,\n :WHIRLPOOL]\n realmoves = []\n for i in moves\n move = getID(PBMoves,i)\n next if move==0\n for j in 0...$Trainer.party.length\n next if $Trainer.party[j].egg?\n if $Trainer.party[j].hasMove?(move)\n realmoves.push([move,j]) if Kernel.pbCanUseHiddenMove?($Trainer.party[j],move,false)\n break\n end\n end\n end\n realitems = []\n for i in $PokemonBag.registeredItems\n realitems.push(i) if $PokemonBag.pbHasItem?(i)\n end\n if realitems.length==0 && realmoves.length==0\n Kernel.pbMessage(_INTL(\"An item in the Bag can be registered to this key for instant use.\"))\n else\n $game_temp.in_menu = true\n $game_map.update\n sscene = PokemonReadyMenu_Scene.new\n sscreen = PokemonReadyMenu.new(sscene) \n sscreen.pbStartReadyMenu(realmoves,realitems)\n $game_temp.in_menu = false\n end\nend", "def create_item(item_code)\n \t\txero = XeroConnection.new.connect\n\n \t\tif xero.Item.all(where: 'code == \"%s\"' % item_code).empty?\n \t\t\tnew_item = xero.Item.build(code: item_code)\n \t\t\tnew_item.save\n \t\tend\n \tend", "def lookup_item_type\n @item_type = ItemType.find(params[:item_type_id])\n end", "def item_by_id(id)\n @items[id]\n end", "def get_mods_item(mods_uuid)\n url = \"#{@server_url}/items/mods/#{mods_uuid}.json\"\n json = self.get_json(url)\n \n item = nil\n if json[\"nyplAPI\"][\"response\"][\"mods\"]\n item = json[\"nyplAPI\"][\"response\"][\"mods\"]\n end\n \n return item\n end", "def find_item_type\n @item_type = catalog.item_types\n .where(:slug => params[:item_type_slug])\n .first!\n end", "def use_item_by_string(name, e)\n index = has_item_by_string(name)\n if (index != -1)\n actual_item = inventory[index].first\n actual_item.use(e)\n remove_item(actual_item) if actual_item.consumable\n else\n print \"What?! You don't have THAT!\\n\\n\"\n end\n end", "def item\n @item ||= item_class.where(id: item_id).first if item_class\n end", "def fetch\n result = WebApi.json!(\"IEconItems_#{app_id}\", 'GetPlayerItems', 1, { :SteamID => @steam_id64 })\n item_class = self.class.send :class_variable_get, :@@item_class\n\n @items = []\n result[:items].each do |item_data|\n unless item_data.nil?\n item = item_class.new(self, item_data)\n @items[item.backpack_position - 1] = item\n end\n end\n end", "def find(code)\n @stock[code.to_sym]\n end", "def find_item\n @item = Item.new(query_service.find_by(id: params[:id]).symbolize_keys)\n end", "def locate(id)\n return self if are_you(id)\n\n # Try Inventory\n i = @inv.fetch(id)\n return i if !i.nil?\n\n return nil\n end", "def load_item_data\n item = Item.find_by_id(params[:id]).present? ? Item.find(params[:id]) : Item.unscoped.find_by_id(params[:id])\n render :plain => [item.item_description || \"\", item.unit_cost.to_f || 1, item.quantity.to_f || 1, item.tax_1 || 0, item.tax_2 || 0, item.item_name || \"\", item.tax1_name || \"\", item.tax2_name || \"\", item.tax1_percentage || 0, item.tax2_percentage || 0 ]\n end", "def find_item_by_id(id)\n\n @items.each do |item|\n return item if item.item_id == id\n end\n return nil\n end", "def fetch\n result = WebApi.json!('ITFItems_440', 'GetPlayerItems', 1, { :SteamID => @steam_id64 })\n\n @items = []\n result[:items][:item].each do |item_data|\n unless item_data.nil?\n item = TF2Item.new(item_data)\n @items[item.backpack_position - 1] = item\n end\n end\n end", "def loot\r\n\t@@item_number += 1\r\n\t$items = @@item_number\r\n\treturn\r\n\tend", "def get_item_availability(holding, item)\n # is_offsite = LOCATIONS['offsite_locations'].include? holding[:location_code]\n # if is_offsite\n if is_offsite_location_code?(holding[:location_code])\n self.fetch_scsb_availabilty unless @scsb_availability\n return @scsb_availability[ item[:barcode] ] if @scsb_availability.has_key?(item[:barcode])\n else\n # If we didn't find an offsite availability for this item, check Voyager availability\n self.fetch_voyager_availability unless @voyager_availability\n return @voyager_availability[ item[:item_id] ]\n end \n end", "def load_chef_bootstrap_vault_item(vault, item)\n ChefVault::Item.load(vault, item)\n end", "def item_by_name\n IITPlaylist.new(@ole.ItemByName)\n end", "def valid_item_code?(item_code)\n @product = Product::PRODUCTS[item_code]\n (!@product.nil? && !@product.empty?)\n end", "def load_item_from_infinite_stock(order_item)\n create_item_from(order_item, order_item.order.number)\n true\n end", "def fetch(id)\n # Pass in a proc that will return true if item with id is looked up\n # (pass in invItem as a param to lambda)\n return lookup(id, Proc.new { |invItem| return invItem } )\n end", "def find(id, type = :full)\n case type\n when :full\n response = JSON.parse(@client.get(\"items/#{id}\").body)\n Promisepay::Item.new(@client, response['items'])\n when :status\n response = JSON.parse(@client.get(\"items/#{id}/status\").body)\n Promisepay::Item.new(@client, response['items'])\n end\n end", "def put_item_in_inventory(input)\n\n if find_item_by_id(input).canBePickedUp\n unless @inventory.include?(input)\n @inventory << input\n slow_type(\"\\nYou have picked up the #{find_item_by_id(input).name}.\")\n end\n\n else\n slow_type(\"You cannot pick up this item\")\n end\n end", "def get_item_in_this_state(inventory_item_params, state = nil)\n return nil if (state.nil? || InventoryItemState.find_by(name: state).nil?) #No need to check if the state is nil.\n item_state_id = InventoryItemState.find_by(name: state).id\n\n in_it = InventoryItem.find_by(item_id: inventory_item_params[:item_id],\n location_id: inventory_item_params[:location_id],\n inventory_item_state_id: item_state_id,\n inventory_item_condition_id: inventory_item_params[:inventory_item_condition_id])\n\n return nil if in_it.nil?\n return in_it\n end", "def gms_find_code_value_item(items, code_value)\n items.each_item do |item|\n return item if item[CNCS] && item[CNCS].items[0][CV].value == code_value\n end\n\n nil\nend", "def live_lookup_item_id\n id || folio_item&.id || barcode\n end", "def load!(order_items)\n transaction do\n products = order_items.map(&:product)\n stock = source.inventory_items.for(products)\n order_items.each do |order_item|\n load_item!(order_item, stock)\n end\n end\n end", "def use_item_by_object(item, e)\n index = has_item_by_object(item)\n if (index != -1)\n actual_item = inventory[index].first\n actual_item.use(e)\n if actual_item.consumable then remove_item(actual_item) end\n else\n print \"What?! You don't have THAT!\\n\\n\"\n end\n end", "def get_item_from_body(body)\n get_item_from_result(body.fetch('Item', {}))\n end", "def item_lookup_id=(item_lookup_id)\n self.item = Item.find_or_load(item_lookup_id.to_i)\n end", "def item_lookup_id=(item_lookup_id)\n self.item = Item.find_or_load(item_lookup_id.to_i)\n end", "def item_lookup_id=(item_lookup_id)\n self.item = Item.find_or_load(item_lookup_id.to_i)\n end", "def get_item_from_sellable_state(inventory_item_params)\n initial_condition = inventory_item_params[:inventory_item_condition_id]\n inventory_item_in_sellable_state = get_item_in_this_state(inventory_item_params, \"Available\")\n if inventory_item_in_sellable_state.nil?\n inventory_item_in_sellable_state = get_item_in_this_state(inventory_item_params, \"Critical_Level\")\n end\n if inventory_item_in_sellable_state.nil?\n inventory_item_params[:inventory_item_condition_id] = InventoryItemCondition.find_by(name: \"Not_Sellable\" ).id\n inventory_item_in_sellable_state = get_item_in_this_state(inventory_item_params, \"Out_of_Stock\")\n inventory_item_params[:inventory_item_condition_id] = initial_condition\n end\n return inventory_item_in_sellable_state\n end", "def item_by_persistent_id\n IITPlaylist.new(@ole.ItemByPersistentID)\n end", "def load_for(key)\n input_efficiency, output_efficiency =\n Merit::Flex::OptimizingStorage.normalized_efficiencies(\n battery(key).optimizing_storage_params.output_efficiency\n )\n\n self.class.reserve_to_load(\n reserve_for(key),\n input_efficiency: input_efficiency,\n output_efficiency: output_efficiency\n )\n end", "def getItem\n Product.select(:product).find(params[:id])\n end", "def line_item_items_exist_in_inventory\n self.line_items.each do |line_item|\n next unless line_item.item\n inventory_item = self.from.inventory_items.find_by(item: line_item.item)\n if inventory_item.nil?\n errors.add(:inventory,\n \"#{line_item.item.name} is not available \" \\\n \"at this storage location\")\n end\n end\n end", "def load_item_from_local(name)\n local_data_bag_item = Dir[\"#{@context.repo_path}/data_bags/**/#{name}.json\"].first\n return nil if local_data_bag_item.nil?\n\n FFI_Yajl::Parser.parse(File.read(local_data_bag_item))\n rescue FFI_Yajl::ParseError\n nil\n end", "def item_by_name\n IITTrack.new(@ole.ItemByName)\n end", "def pbChooseItemScreen(proc=nil)\n oldlastpocket = @bag.lastpocket\n oldchoices = @bag.getAllChoices\n @scene.pbStartScene(@bag,true,proc)\n item = @scene.pbChooseItem\n @scene.pbEndScene\n @bag.lastpocket = oldlastpocket\n @bag.setAllChoices(oldchoices)\n return item\n end", "def load_equipment(object, game_objects)\n\n if not object.respond_to? :equipment\n #log \"#{object} has no equipment\"\n return\n end\n\n load_inv(object.equipment, game_objects)\n object.equipment.each do |o|\n o.info.equipment_of = object.goid\n end\n end", "def include_item(identifier)\n if item = lookup_item(identifier)\n item.compiled_content\n end\nend", "def load_inv(object, game_objects)\n\n if not object.respond_to? :inventory\n #log \"#{object} has no inventory\"\n return\n elsif object.inventory.nil? #I can't think of when this might happen\n object.inventory = Inventory.new\n #log \"#{object} had a nil inventory\"\n return\n elsif object.inventory.empty?\n object.inventory = Inventory.new(object.inventory.capacity)\n #log \"#{object} has nothing in its inventory\"\n return\n end\n\n inv = Inventory.new(object.inventory.capacity)\n\n object.inventory.each do |inv_obj|\n if game_objects.include? inv_obj[0]\n obj = game_objects[inv_obj[0]]\n pos = inv_obj[1]\n unless obj.is_a? Player\n inv.add(obj, pos)\n obj.container = object.goid\n end\n #log \"Added #{obj} to #{object}\"\n else\n log \"Don't have #{inv_obj} loaded...what does that mean? (Probably a Player)\", Logger::Medium\n end\n end\n\n object.inventory = inv\n end", "def pick_up(item_name)\n if current_room.has_item(item_name)\n item = current_room.items.find { |thing| thing.name == item_name }\n @player.add_to_inventory(item)\n current_room.remove_one(item)\n else\n puts \"Sorry, that item is not in this room. Try again.\"\n end\n end", "def cartridgeLoad(cartridge_type)\n \n case cartridge_type\n when 'RNA'\n cartridge = find(:item, object_type: { name: \"QX RNA Screening Cartridge Container\" }).first#.first {|c| c.location == 'Fragment analyzer'} # .find { |c| c.location == \"Fragment analyzer\" }\n when 'DNA'\n cartridge = find(:item, object_type: { name: \"QX DNA Screening Cartridge\" }).first#.find { |c| c.location == \"Fragment analyzer\" }\n end\n \n if(cartridge) # already in\n take [cartridge]\n else # prep new cartridge\n # prep cartridge\n show do\n title \"Prepare to insert QX #{cartridge_type} Screening Cartridge into the machine\"\n warning \"Please keep the cartridge vertical at all times!\".upcase\n check \"Take the cartridge labeled #{cartridge} from #{cartridge.location} and bring to fragment analyzer.\"\n check \"Remove the cartridge from its packaging and CAREFULLY wipe off any soft tissue debris from the capillary tips using a soft tissue.\"\n check \"Remove the purge cap seal from the back of the cartridge.\"\n #image \"frag_an_cartridge_seal_off\"\n warning \"Do not set down the cartridge when you proceed to the next step.\"\n end\n # place in machine\n show do\n title \"Insert QX #{cartridge_type} Screening Cartridge into the machine\"\n check \"Use a soft tissue to wipe off any gel that may have leaked from the purge port.\"\n check \"Open the cartridge compartment by gently pressing on the door.\"\n check \"Carefully place the cartridge into the fragment analyzer; cartridge description label should face the front and the purge port should face the back of the fragment analyzer.\"\n check \"Insert the smart key into the smart key socket; key can be inserted in either direction.\"\n #image \"frag_an_cartridge_and_key\"\n check \"Close the cartridge compartment door.\"\n check \"Open the ScreenGel software and latch the cartridge by clicking on the <b>Latch</b> icon.\"\n check \"Grab the purge port seal bag from the bottom drawer beneath the machine, put the seal back on its backing, and return it in the bag to the drawer.\"\n end\n # enter runs if not already associated\n unless(cartridge.get(:runs))\n runs = show do \n title \"Enter number of runs\"\n get \"number\", var: \"runs\", label: \"Please enter the number of <b>Remaining Runs</b> left in this cartridge.\", default: 0\n end\n cartridge.associate :runs, runs[:runs]\n end\n \n # wait for equilibration \n if cartridge_type == 'DNA' # wait for equilibration \n show do\n title \"Wait for the cartridge to equilibrate\"\n check \"Start a <b>30 min</b> timer, and do not run the fragment analyzer until it finishes.\"\n end\n end\n \n # set location\n take [cartridge]\n cartridge.location = \"Fragment analyzer\"\n cartridge.save\n \n end # if(cartridge)\n \n # return\n cartridge\n end", "def set_inventory_item\n @inventory_item = InventoryItem.find(params[:id])\n end", "def get_item( item )\n @session.base_url = \"http://cl.ly\"\n resp = @session.get( \"/\" + item )\n \n raise ItemNotFound if resp.status == 404\n Crack::JSON.parse(resp.body)\n end", "def change_equip(slot_id, item)\n return unless trade_item_with_party(item, equips[slot_id])\n return if item && !etype_can_equip?(slot_id, item)\n @equips[slot_id].object = item\n refresh\n end", "def set_item_inventory\n @item_inventory = ItemInventory.find(params[:id])\n end", "def item_from_filename(filename)\n identifier = Nanoc::Identifier.from(expand_volume_path(filename))\n @items[identifier] || raise(\"Unable to resolve item for file '#{filename}'\")\n end", "def find_item(name)\n items.find do |item|\n item.name == name ||\n item.short_name.gsub('…','') == name.gsub('…','')\n end\n end", "def pbItemMenu(idxBattler,_firstAction)\r\n # Fade out and hide all sprites\r\n visibleSprites = pbFadeOutAndHide(@sprites)\r\n # Set Bag starting positions\r\n oldLastPocket = $PokemonBag.lastpocket\r\n oldChoices = $PokemonBag.getAllChoices\r\n $PokemonBag.lastpocket = @bagLastPocket if @bagLastPocket!=nil\r\n $PokemonBag.setAllChoices(@bagChoices) if @bagChoices!=nil\r\n # Start Bag screen\r\n itemScene = PokemonBag_Scene.new\r\n itemScene.pbStartScene($PokemonBag,true,Proc.new { |item|\r\n useType = GameData::Item.get(item).battle_use\r\n next useType && useType>0\r\n },false)\r\n # Loop while in Bag screen\r\n wasTargeting = false\r\n loop do\r\n # Select an item\r\n item = itemScene.pbChooseItem\r\n break if !item\r\n # Choose a command for the selected item\r\n item = GameData::Item.get(item)\r\n itemName = item.name\r\n useType = item.battle_use\r\n cmdUse = -1\r\n commands = []\r\n commands[cmdUse = commands.length] = _INTL(\"Use\") if useType && useType!=0\r\n commands[commands.length] = _INTL(\"Cancel\")\r\n command = itemScene.pbShowCommands(_INTL(\"{1} is selected.\",itemName),commands)\r\n next unless cmdUse>=0 && command==cmdUse # Use\r\n # Use types:\r\n # 0 = not usable in battle\r\n # 1 = use on Pokémon (lots of items), consumed\r\n # 2 = use on Pokémon's move (Ethers), consumed\r\n # 3 = use on battler (X items, Persim Berry), consumed\r\n # 4 = use on opposing battler (Poké Balls), consumed\r\n # 5 = use no target (Poké Doll, Guard Spec., Launcher items), consumed\r\n # 6 = use on Pokémon (Blue Flute), not consumed\r\n # 7 = use on Pokémon's move, not consumed\r\n # 8 = use on battler (Red/Yellow Flutes), not consumed\r\n # 9 = use on opposing battler, not consumed\r\n # 10 = use no target (Poké Flute), not consumed\r\n case useType\r\n when 1, 2, 3, 6, 7, 8 # Use on Pokémon/Pokémon's move/battler\r\n # Auto-choose the Pokémon/battler whose action is being decided if they\r\n # are the only available Pokémon/battler to use the item on\r\n case useType\r\n when 1, 6 # Use on Pokémon\r\n if @battle.pbTeamLengthFromBattlerIndex(idxBattler)==1\r\n break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene\r\n end\r\n when 3, 8 # Use on battler\r\n if @battle.pbPlayerBattlerCount==1\r\n break if yield item.id, useType, @battle.battlers[idxBattler].pokemonIndex, -1, itemScene\r\n end\r\n end\r\n # Fade out and hide Bag screen\r\n itemScene.pbFadeOutScene\r\n # Get player's party\r\n party = @battle.pbParty(idxBattler)\r\n partyPos = @battle.pbPartyOrder(idxBattler)\r\n partyStart, _partyEnd = @battle.pbTeamIndexRangeFromBattlerIndex(idxBattler)\r\n modParty = @battle.pbPlayerDisplayParty(idxBattler)\r\n # Start party screen\r\n pkmnScene = PokemonParty_Scene.new\r\n pkmnScreen = PokemonPartyScreen.new(pkmnScene,modParty)\r\n pkmnScreen.pbStartScene(_INTL(\"Use on which Pokémon?\"),@battle.pbNumPositions(0,0))\r\n idxParty = -1\r\n # Loop while in party screen\r\n loop do\r\n # Select a Pokémon\r\n pkmnScene.pbSetHelpText(_INTL(\"Use on which Pokémon?\"))\r\n idxParty = pkmnScreen.pbChoosePokemon\r\n break if idxParty<0\r\n idxPartyRet = -1\r\n partyPos.each_with_index do |pos,i|\r\n next if pos!=idxParty+partyStart\r\n idxPartyRet = i\r\n break\r\n end\r\n next if idxPartyRet<0\r\n pkmn = party[idxPartyRet]\r\n next if !pkmn || pkmn.egg?\r\n idxMove = -1\r\n if useType==2 || useType==7 # Use on Pokémon's move\r\n idxMove = pkmnScreen.pbChooseMove(pkmn,_INTL(\"Restore which move?\"))\r\n next if idxMove<0\r\n end\r\n break if yield item.id, useType, idxPartyRet, idxMove, pkmnScene\r\n end\r\n pkmnScene.pbEndScene\r\n break if idxParty>=0\r\n # Cancelled choosing a Pokémon; show the Bag screen again\r\n itemScene.pbFadeInScene\r\n when 4, 9 # Use on opposing battler (Poké Balls)\r\n idxTarget = -1\r\n if @battle.pbOpposingBattlerCount(idxBattler)==1\r\n @battle.eachOtherSideBattler(idxBattler) { |b| idxTarget = b.index }\r\n break if yield item.id, useType, idxTarget, -1, itemScene\r\n else\r\n wasTargeting = true\r\n # Fade out and hide Bag screen\r\n itemScene.pbFadeOutScene\r\n # Fade in and show the battle screen, choosing a target\r\n tempVisibleSprites = visibleSprites.clone\r\n tempVisibleSprites[\"commandWindow\"] = false\r\n tempVisibleSprites[\"targetWindow\"] = true\r\n idxTarget = pbChooseTarget(idxBattler,GameData::Target.get(:Foe),tempVisibleSprites)\r\n if idxTarget>=0\r\n break if yield item.id, useType, idxTarget, -1, self\r\n end\r\n # Target invalid/cancelled choosing a target; show the Bag screen again\r\n wasTargeting = false\r\n pbFadeOutAndHide(@sprites)\r\n itemScene.pbFadeInScene\r\n end\r\n when 5, 10 # Use with no target\r\n break if yield item.id, useType, idxBattler, -1, itemScene\r\n end\r\n end\r\n @bagLastPocket = $PokemonBag.lastpocket\r\n @bagChoices = $PokemonBag.getAllChoices\r\n $PokemonBag.lastpocket = oldLastPocket\r\n $PokemonBag.setAllChoices(oldChoices)\r\n # Close Bag screen\r\n itemScene.pbEndScene\r\n # Fade back into battle screen (if not already showing it)\r\n pbFadeInAndShow(@sprites,visibleSprites) if !wasTargeting\r\n end", "def load_item_data\n\n \n @product = CurrentInventory.find_by(product_id: params[:product_id])\n \n \n render :json => [@product.product.price, @product.current_quantity,@product.product.unit]\n end", "def equip_item(item)\n\n index = has_item(item)\n if index\n actual_item = inventory[index].first\n\n # Checks for Equippable without importing the file.\n if (defined? actual_item.equip)\n actual_item.equip(self)\n\n # Equipping the item will always remove it from the entity's inventory.\n remove_item(actual_item)\n else\n print \"#{actual_item.name} cannot be equipped!\\n\\n\"\n end\n else\n print NO_SUCH_ITEM_ERROR\n end\n end", "def use_item(item, entity)\n index = has_item(item)\n if index\n actual_item = inventory[index].first\n actual_item.use(self, entity)\n remove_item(actual_item) if actual_item.consumable\n else\n print NO_SUCH_ITEM_ERROR\n end\n end", "def item_for _ph\n @items.select {|i| i.placeholder == _ph }.first\n rescue\n nil\n end", "def find_item(item)\n md5 = ItemBuilder.md5(item)\n items.find { |e| e[0] == md5 } if items\n end", "def set_inventory_item\n @inventory_item = InventoryItem.find(params[:id])\n end" ]
[ "0.65136737", "0.6332236", "0.6300958", "0.61952794", "0.6193434", "0.5958836", "0.5933638", "0.5852383", "0.5797833", "0.5743802", "0.5683368", "0.56575394", "0.565443", "0.56279033", "0.5621907", "0.5619759", "0.5562339", "0.5548164", "0.55050683", "0.54750896", "0.545956", "0.54573524", "0.5438952", "0.5437057", "0.5436936", "0.5429499", "0.54255533", "0.5419439", "0.5418264", "0.5407074", "0.5400334", "0.535877", "0.5358175", "0.5353947", "0.5349936", "0.5346858", "0.5340101", "0.53181505", "0.5310696", "0.529459", "0.529341", "0.52916884", "0.5284293", "0.5269532", "0.5247478", "0.5237395", "0.5231502", "0.5231088", "0.52271235", "0.5223005", "0.5218364", "0.5213057", "0.52070034", "0.5202784", "0.5202772", "0.51997614", "0.5192639", "0.51919585", "0.51882184", "0.51721", "0.5165999", "0.51619965", "0.51598865", "0.51587397", "0.5157641", "0.51526266", "0.5150425", "0.5132405", "0.513236", "0.5126641", "0.5122696", "0.5116609", "0.5116609", "0.5116609", "0.510729", "0.51027554", "0.50834215", "0.50562346", "0.5056192", "0.5051086", "0.5043873", "0.50396985", "0.50371593", "0.50351286", "0.5033447", "0.50319916", "0.50234646", "0.50220156", "0.5019075", "0.50170964", "0.50138754", "0.5004463", "0.50030774", "0.50013274", "0.4998951", "0.499855", "0.49959713", "0.4992754", "0.49921197", "0.49917904" ]
0.80378413
0
Default strategy: loads the order item from given stock items.
def load_item_from_stock(order_item, stock_items) amount = order_item.waiting stock_items.each do |item| all = item.available next if all <= 0 if amount <= all # This inventory item satisfies the amount, we're done. item.reserved += amount return create_item_from(order_item, item.code, item.expires_at, amount) else # Load all of this item and continue with the remaining amount. item.reserved += all create_item_from(order_item, item.code, item.expires_at, all) amount -= all end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load!(order_items)\n transaction do\n products = order_items.map(&:product)\n stock = source.inventory_items.for(products)\n order_items.each do |order_item|\n load_item!(order_item, stock)\n end\n end\n end", "def load_item!(order_item, stock)\n if !order_item.product.tracked_stock? || source.enable_gateway?\n load_item_from_infinite_stock(order_item) && return\n end\n stock_items = stock.select { |item| item.product == order_item.product }\n return false if stock_items.none?\n\n if order_item.lot_code.present?\n load_item_by_lot_code(order_item, stock_items)\n else\n load_item_from_stock(order_item, stock_items)\n end\n end", "def load_item_from_infinite_stock(order_item)\n create_item_from(order_item, order_item.order.number)\n true\n end", "def load_item_by_lot_code(order_item, stock_items)\n item = stock_items.find { |item| order_item.lot_code == item.code }\n\n # If the order item has a serial number, try lot code part only.\n if item.nil? && order_item.lot_code['-']\n lot_code_part = order_item.lot_code.split('-').first\n item = stock_items.find { |item| lot_code_part == item.code }\n end\n\n # If a match was found, load the item and return. If a partial\n # match set a lot code part above, use that, or provide nil\n # to use the code on the order item.\n if item.present?\n item.reserved += order_item.amount\n return create_item_from(order_item, lot_code_part, item.expires_at)\n end\n\n false # Failed to load the item.\n end", "def load!\n transfer = find_or_create_transfer\n transfer.load!(order.items_waiting)\n end", "def set_ordered_item\n @ordered_item = OrderedItem.find(params[:id])\n end", "def set_ordered_item\n @ordered_item = OrderedItem.find(params[:id])\n end", "def stock_item(variant_id, user_id = nil, original_stock_location_id = nil)\n return super(variant_id) unless reserved_items?\n raise(\n UserRequiredArgumentError,\n Spree.t(:user_id_required_for_reserved_stock_location)\n ) unless user_id.present?\n items = stock_items.where(variant_id: variant_id, user_id: user_id)\n items = items.where(\n original_stock_location_id: original_stock_location_id\n ) unless original_stock_location_id.blank?\n items.order(:id).first\n end", "def set_ordereditem\n @ordereditem = Ordereditem.find(params[:id])\n end", "def items\n @items ||= data[\"items\"].map { |item| OrderItem.new(item) }\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def item\n super || item_order.item\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def set_order_item\n @order_item = OrderItem.find(params[:id])\n end", "def order \n @items = Item.all\n @item = Item.find(params[:id])\n end", "def add_order(order_item, qty, order)\r\n if order_item == \"latte\"\r\n item = Item.new(\"latte\", $latte_cost, $latte_price)\r\n elsif order_item == \"tea\"\r\n item = Item.new(\"tea\", $tea_cost, $tea_price)\r\n elsif order_item == \"scones\"\r\n item = Item.new(\"scones\", $scones_cost, $scones_price)\r\n end\r\n order.add_item(item, qty)\r\nend", "def load_order!\n @order = current_user.orders.find params[:id]\n # @order = @cookbook.get_active_reorder(params[:id]) if @cookbook.is_owner? current_user\n end", "def set_item\n @item = @order.order_items\n .where(product_id: params[:product_id])\n .first_or_initialize(order_id: @order.id)\n end", "def set_order_item\n @order_item = @order.order_items.find(params[:id])\n end", "def get_order_item(id, options = nil)\r\n @client.raw('get', \"/ecommerce/order-items/#{id}\", options, nil, @contact_v1_url)\r\n end", "def set_order\n @item = Order.find(params[:id])\n end", "def load_item_list\n @item_quantity = []\n get_list_item\n get_definitive_list_price\n check_if_shop_empty\n @index = 0\n @last_index = @list_item.size - 1\n end", "def item_stock(item)\n item_stocks.create(item_id: item.id)\n end", "def load_shopping_item_or_not\n @shopping_item_id = nil\n\n if si = params[:shopping_item]\n if si[:offer_id]\n # this is a shopping item that references an offer and cart\n @shopping_item_id = si[:offer_id]\n @admin_customer_offer = Admin::Customer::Offer.find(si[:offer_id])\n @cart = Shopping::Cart.find_by_id(si[:cart_id])\n session[:admin_customer_offer_id] = @admin_customer_offer.id\n raise \"cart offer email mismatch\" if (@cart.email.id != @admin_customer_offer.email.id)\n elsif si[:piece_id]\n @shopping_item_id = si[:piece_id]\n end\n end\n\n unless @shopping_item_id\n @admin_customer_offer = Admin::Customer::Offer.find(session[:admin_customer_offer_id]) if session[:admin_customer_offer_id]\n @shopping_item_id = @admin_customer_offer.id if @admin_customer_offer\n end\n\n end", "def set_stock_item\n @stock_item = StockItem.find(params[:id])\n end", "def set_stock_item\n @stock_item = StockItem.find(params[:id])\n end", "def initialize(order_item)\n @order_item = order_item\n end", "def load_items\n items.map { |serialized_item| item_from_attributes(serialized_item) }.compact\n end", "def set_store_order_item\n @store_order_item = StoreOrderItem.find(params[:id])\n end", "def set_order_pack_item\n @order_pack_item = OrderPackItem.find(params[:id])\n end", "def initialize(*args)\n @stock = args.map{ |item| [item.code.to_sym, item] }.to_h\n end", "def stock(item_id)\n stocks.find {|st| st.item_id === item_id }\n end", "def show\n @order = Order.includes(:items).find(params[:id])\n end", "def set_order_items\n @order_items = @order.order_items\n end", "def order\n return nil if return_items.blank?\n return_items.first.inventory_unit.order\n end", "def set_order_item\n @order_item = current_user.order_items.find(params[:id])\n end", "def place_order!()\n if has_order_items?\n order_template = order_object\n order_template = yield order_object if block_given?\n\n @virtual_server.softlayer_client[:Product_Order].placeOrder(order_template)\n end\n end", "def fetch\n items_distributed = fetch_items_distributed\n\n # Inject the \"onhand\" data\n items_distributed.map! do |item|\n item_name = item[:name]\n\n below_onhand_minimum = if current_onhand_quantities[item_name] && current_onhand_minimums[item_name]\n current_onhand_quantities[item_name] < current_onhand_minimums[item_name]\n end\n\n item.merge({\n current_onhand: current_onhand_quantities[item_name],\n onhand_minimum: current_onhand_minimums[item_name],\n below_onhand_minimum: below_onhand_minimum\n })\n end\n\n items_distributed.sort_by { |item| -item[:distributed] }\n end", "def load_order\n\t\tparams[:order_param] ||= session[:order_param]\n\t\tsession[:order_param] = params[:order_param]\n\tend", "def populate_from_enquiry_items\n if enquiry_items.present? # not present\n self.food_partner = enquiry_items.first.packageable_item.food_partner # cleanlol\n enquiry_price.populate_price_from_cart\n end\n end", "def lookup_stock(name)\n return StockQuote::Stock.quote(name)\nend", "def update_order_item\n \n end", "def order_item\n @items.sample\n end", "def item_by_play_order\n IITTrack.new(@ole.ItemByPlayOrder)\n end", "def load_item(data_bag, item_name, metadata = {})\n item = ::SecureDataBag::Item.load(data_bag, item_name, metadata)\n item\n end", "def set_menu_items_order\n @menu_items_order = MenuItemsOrder.find(params[:id])\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 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 item\n\t\tself.bmet_work_order.bmet_item\n\tend", "def use_cart(cart)\n cart.cart_items.each do |cart_item|\n order_items.build(item_id: cart_item.item.id, price: cart_item.item.send(item_price_method_name), quantity: cart_item.quantity) if cart_item.quantity.to_i > 0\n end\n end", "def order_items(order, main, sides, extras, wallet, spent)\n\t# set looping value until order complete\n\tcontinue = true\n\n\t# get one item from main menu\n\titem = get_item(\"main\", main, wallet, spent)\n\tif item\n\t\torder.push item\n\t\tspent = spent + order.last.price\n\t\tprint_item(item, spent)\n\tend\n\n\t# get one item from side menu\n\titem = get_item(\"side\", sides, wallet, spent)\n\tif item\n\t\torder.push item\n\t\tspent = spent + order.last.price\n\t\tprint_item(item, spent)\n\tend\n\n\t# get another item from side menu\n\titem = get_item(\"side\", sides, wallet, spent)\n\tif item\n\t\torder.push item\n\t\tspent = spent + order.last.price\n\t\tprint_item(item, spent)\n\tend\n\n\t# get extras until user says they're done\n\twhile continue\n\t\tputs \"Do you want to order extra items? Y or N\"\n\t\tresponse = gets.strip\n\t\tcase response.downcase\n\t\twhen 'y', 'yes'\n\t\t\titem = get_item(\"extra\", extras, wallet, spent)\n\t\t\tif item\n\t\t\t\torder.push item\n\t\t\t\tspent = spent + order.last.price\n\t\t\t\tprint_item(item, spent)\n\t\t\telse\n\t\t\t\tcontinue = false\n\t\t\tend\n\t\twhen 'n', 'no'\n\t\t\tcontinue = false\n\t\telse\n\t\t\tputs \"INVALID INPUT.\\n\\n\"\n\t\tend\n\tend\n\n\t# return array with order which is an array of instantiations of class lunch item\n\t# and amount spent\n\t[order, spent]\nend", "def import_supply_items(filename = self.import_filename)\n # before calling this in a descended class, you must set up these variables:\n # @supplier = The supplier to import for (an AR object)\n SupplyItem.expire_category_tree_cache(@supplier)\n\n ThinkingSphinx::Deltas.suspend :supply_item do\n File.open(filename, \"r:utf-8\").each_with_index do |line, i|\n next if i == 0 # We skip the first line, it only contains header information\n data = parse_line(line)\n next if data == false\n next if data[:supplier_product_code].blank? # The line is incomplete, skip it\n # check if we have the supply item\n local_supply_item = SupplyItem.where(:supplier_id => @supplier.id,\n :supplier_product_code => data[:supplier_product_code]).first\n # We do not have that supply item yet\n if local_supply_item.nil?\n si = new_supply_item(data)\n if si.save\n supplier_logger.info(\"[#{DateTime.now.to_s}] SupplyItem create: #{si.inspect}\")\n else\n supplier_logger.error(\"Failed adding supply item during sync: #{si.inspect.to_s}, #{si.errors.to_s}\")\n end\n # We already have that supply item and need to update that and related product information\n else\n update_supply_item(local_supply_item, data)\n end\n end\n end\n Product.update_price_and_stock # Sync available products to the now changed supply items\n CategoryDispatcher.create_unique_combinations_for(@supplier)\n end", "def order_items_read(id, opts = {})\n data, _status_code, _headers = order_items_read_with_http_info(id, opts)\n data\n end", "def get_stock(stock_ticker)\n stock = StockQuote::Stock.quote(stock_ticker)\n return stock\nend", "def load_item\n @item = Item.find(params[:id]) rescue nil\n \n render_404 unless @item\n end", "def set_event_order_line_item\n @event_order_line_item = EventOrderLineItem.preloaded_data.find(params[:id])\n end", "def fetch_from_inventory(an_order)\n order = extract_code_qty(an_order)\n return Inventory.fetch_an_item(order[:code])\n end", "def _line_items(order)\n params.require(:orders).each do |variant_id, info|\n count = info.require(:count)\n price = info.require(:price)\n variant = Variant.find variant_id\n LineItem.create(variant_id: variant_id, order: order, quantity: count,\n price: price).ready_to_pay!\n end\n end", "def set_lottery_order_item\n @lottery_order_item = LotteryOrderItem.find(params[:id])\n end", "def load_work_order\n @work_order = WorkOrder.accessible_by(current_ability).find(params[:id])\n end", "def set_ordered\n @ordered = Ordered.find(params[:id])\n end", "def buying_item item_name\n @buying_results_parser.read @querier.buying_item(item_name)\n end", "def import_supply_items(filename = self.import_filename)\n super\n end", "def import_supply_items(filename = self.import_filename)\n super\n end", "def index\n @catalog_items = CatalogItem.all\n\n order_items = []\n @catalog_items.each do |catalog_item|\n order_items << OrderItem.new(\n catalog_item: catalog_item,\n quantity: 0,\n unit_price: catalog_item.price\n )\n\n end\n\n\n @order = Order.new(\n order_items: order_items\n )\n end", "def add_item(product_id:, quantity: 1)\n product = Product.find(product_id)\n order_item = order.items.find_or_initialize_by(\n product_id: product_id,\n price: product.price,\n quantity: quantity\n )\n\n order_item.save!\n end", "def item_by_persistent_id\n IITSource.new(@ole.ItemByPersistentID)\n end", "def get_stocks\n @stocks = Stock.where(user_id: session[:current_user_id]).order(\"ticker_symbol ASC\")\n end", "def get_item(**opt)\n cache_read(**opt) || default\n end", "def assign_order_item_values\n # Copies prices from purchasable into order items\n present_order_items.each { |oi| oi.assign_purchasable_attributes }\n end", "def set_lab_order_item\n @lab_order_item = LabOrderItem.find(params[:id])\n end", "def find_item\n @item = Item.new(query_service.find_by(id: params[:id]).symbolize_keys)\n end", "def get(pAuthToken, p_item_id, p_args)\r\n service_uri = \"#{@@m_service_url.path}#{@@m_service_get}#{p_item_id}.#{@@m_content_format}?authToken=#{pAuthToken}\"\r\n\r\n # verify user intention about related items, if :related_items flag is set\r\n # load all related items\r\n if p_args.nil? == false and p_args[:related_items] == true\r\n service_uri += \"&#{PARAM_LOAD_RELATED_ITEMS}=true\"\r\n\r\n # verify whether user has set any offset\r\n offset = p_args[:offset]\r\n unless offset.nil?\r\n service_uri += \"&offset=#{offset.to_s}\"\r\n end\r\n\r\n # verify whether user has set any maximum number of related items\r\n max = p_args[:max]\r\n unless max.nil?\r\n service_uri += \"&max=#{max}\"\r\n end\r\n\r\n # verify whether user has set the accepted relation types\r\n relation_types_array = p_args[:relation_types]\r\n unless relation_types_array.nil? and relation_types_array.empty?\r\n relation_types = \"\"\r\n relation_types_array.each do |relation_type|\r\n if relation_types.size > 0\r\n relation_types += \",\" + relation_type\r\n else\r\n relation_types += relation_type\r\n end\r\n end\r\n service_uri += \"&relation_types=#{relation_types}\"\r\n end\r\n end\r\n debug service_uri\r\n response = Net::HTTP.start(@@m_service_url.host,\r\n @@m_service_url.port) {|http|\r\n http.get(service_uri, {HEADER_COOKIE => @@m_cookies})\r\n }\r\n xml_content = response.body\r\n built_item = build_item(xml_content)\r\n debug(\"built item - #{built_item}\")\r\n return built_item\r\n end", "def find_item(purchase_or_id)\n raise NotImplementedError\n end", "def populate\n @order = current_order(session)\n variant_id = params[:variant_id]\n \n new_line_item = Breeze::Commerce::LineItem.new(:variant_id => variant_id, :quantity => params[:quantity] || 1)\n existing_line_item = @order.line_items.unarchived.where(:variant_id => variant_id).first \n if existing_line_item\n existing_line_item.quantity += new_line_item.quantity\n existing_line_item.save\n else\n @order.line_items << new_line_item\n end\n\n @order.save\n end", "def order\n @order ||= if session['order']\n OrderBasket.load(session['order']).tap(&:apply_promotions!)\n else\n OrderBasket.new\n end\n end", "def index\n @items = Item.all\n\n set_order\n end", "def show \n @order_items = OrderItem.where(order_id: params[:id])\n end", "def set_order_slip_item\n @order_slip_item = OrderSlipItem.find(params[:id])\n end", "def load_item_data\n item = Item.find_by_id(params[:id]).present? ? Item.find(params[:id]) : Item.unscoped.find_by_id(params[:id])\n render :plain => [item.item_description || \"\", item.unit_cost.to_f || 1, item.quantity.to_f || 1, item.tax_1 || 0, item.tax_2 || 0, item.item_name || \"\", item.tax1_name || \"\", item.tax2_name || \"\", item.tax1_percentage || 0, item.tax2_percentage || 0 ]\n end", "def update_items\n @existing_items = []\n @order.items.each { |i| @existing_items << i.id }\n\n # detail and reproduction_pages will come in as attributes of items, but they actually belong to the item_order\n # so look for those, then add them to the correct record in @item_orders\n\n @item_orders.each do |item_order|\n # add item to order\n if !@existing_items.include?(item_order['item_id'].to_i)\n item_order_record = @order.item_orders.create!(item_id: item_order['item_id'], archivesspace_uri: item_order['archivesspace_uri'], user_id: current_user.id, active: true)\n else\n item_order_record = @order.item_orders.where(item_id: item_order['item_id']).first\n item_order_record.update_attributes(archivesspace_uri: item_order['archivesspace_uri'])\n @order.reload\n # delete id from @existing_items array to track associations to be deleted\n @existing_items.delete(item_order['item_id'])\n end\n\n if item_order['reproduction_spec']\n create_or_update_reproduction_spec(item_order_record.id, item_order['reproduction_spec'])\n end\n\n # handle fees\n if @order_sub_type_name == 'reproduction_fee'\n if item_order['order_fee']\n create_or_update_order_fee(item_order_record.id, 'ItemOrder', item_order['order_fee'])\n end\n else\n # delete any existing fee for this item_order if it exists\n OrderFee.where(record_id: item_order_record.id,\n record_type: 'ItemOrder').each { |f| f.destroy! }\n end\n end\n\n @existing_items.each do |item_id|\n @order.item_orders.where(item_id: item_id).each { |io| io.destroy! }\n end\n end", "def alipay_load_order\n Rails.logger.debug \"#{__LINE__} alipay_load_order called \"\n raise \"'out_trade_no' requird to load the order\" unless params.key?('out_trade_no')\n #order_number = parse_alipay_out_trade_no(params['out_trade_no'])[:payment_order_number]\n order_number, payment_identifier = parse_alipay_out_trade_no(params['out_trade_no'])\n @order = Order.find_by_number(order_number) #if request.referer=~/alipay.com/\n @payment = Payment.find_by(identifier: payment_identifier)\n #@current_order = @order\n unless @order.present?\n raise RuntimeError, \"Could not find order #{order_number}\"\n end\n Rails.logger.debug \"#{__LINE__} alipay_load_order called and order is found #{@order.inspect}\"\n end", "def index\n @order = Order.all\n @order_item = current_order.order_items.new\n end", "def load_aliquots(flowcell_id)\n dataset.join(@session.aliquot.dataset, :id => :aliquot_id).filter(:flowcell_id => flowcell_id).each do |att|\n position = att.delete(:position)\n att.delete(:id)\n aliquot = @session.aliquot.get_or_create_single_model(att[:aliquot_id], att )\n yield(position, aliquot)\n end\n end", "def index\n @store_order_items = StoreOrderItem.all\n end", "def load_from_server(bag_name, item_name = nil)\n begin\n if (item_name)\n item = Chef::DataBagItem.load(bag_name, item_name)\n item = Chef::EncryptedDataBagItem.new(item.raw_data, read_secret) if use_encryption\n else\n item = Chef::DataBag.load(bag_name)\n end\n rescue Net::HTTPServerException => e\n raise unless e.to_s =~ /^404/\n end\n item\n end", "def load_by_ids ids\n items = @api.fetch_multiple_items ids\n create_by_api_items(items)\n end", "def new_order_from_cookies\n order = Order.new\n order.order_items = read_from_cookies\n order\n end", "def set_order_line_item\n @order_line_item = OrderLineItem.find(params[:id])\n end", "def get_item_at(position)\n # TODO Stubbed - Required definition and implementation\n end", "def load(_ids, **_options)\n raise NotImplementedError\n end", "def checkout \n \t@order_items = current_order.order_items\n end", "def get_item_at(position)\n # TODO Stubbed - Required definition and implementation\n end", "def index\n @order_items = OrderItem.all\n end", "def set_line_item\n @line_item = order.line_items.find(params[:id])\n end", "def load_all_raw_data_into_redis\n\t$all_stock_list.each do |symbol,name|\n\t\tputs \"#{symbol} start\"\n\t\tyahoo_get_raw_data_from_file(symbol)\n\tend\n\nend", "def load_inventory(library, book, stock)\n inventory = Inventory.add_book_to_library(library, book, stock)\n puts \"#{library.name} has a stock of #{stock} of #{book.title}\"\nend", "def fetch\n result = WebApi.json!(\"IEconItems_#{app_id}\", 'GetPlayerItems', 1, { :SteamID => @steam_id64 })\n item_class = self.class.send :class_variable_get, :@@item_class\n\n @items = []\n result[:items].each do |item_data|\n unless item_data.nil?\n item = item_class.new(self, item_data)\n @items[item.backpack_position - 1] = item\n end\n end\n end" ]
[ "0.75004685", "0.73562926", "0.68975836", "0.6496159", "0.58743876", "0.5844464", "0.5844464", "0.57095766", "0.56721216", "0.5621166", "0.559142", "0.5583651", "0.5574895", "0.5574895", "0.5574895", "0.5574895", "0.5548346", "0.5531116", "0.5512123", "0.54989743", "0.54847074", "0.54751", "0.5474459", "0.5462562", "0.536978", "0.53403616", "0.5310431", "0.5310431", "0.5288792", "0.52749294", "0.5273665", "0.526376", "0.52607614", "0.52490115", "0.52482474", "0.52217615", "0.50960463", "0.50891876", "0.5079701", "0.50731546", "0.5031364", "0.5029992", "0.50260526", "0.502475", "0.5008628", "0.49875805", "0.49807847", "0.4956951", "0.4952951", "0.49521652", "0.49213934", "0.4907508", "0.49018165", "0.49016383", "0.4900441", "0.48995999", "0.48950687", "0.48822728", "0.4865574", "0.48637196", "0.4861822", "0.48481506", "0.4847744", "0.48440844", "0.48402348", "0.48402348", "0.48367223", "0.48238525", "0.48117352", "0.48089418", "0.4808454", "0.48080593", "0.48020712", "0.47979432", "0.47843447", "0.47825295", "0.4780577", "0.47724846", "0.47635362", "0.4760344", "0.47570586", "0.47536615", "0.47532594", "0.4752775", "0.47506598", "0.4741557", "0.47312325", "0.47302884", "0.4728732", "0.4721281", "0.47197083", "0.47197032", "0.47114167", "0.47076645", "0.47070527", "0.47061357", "0.47045857", "0.4701298", "0.46957076", "0.46881264" ]
0.7040457
2
Define a custom model with a UUID key
def heffalump_model @model ||= Class.new { include DataMapper::Resource property :id, DataMapper::Property::SimpleUUID property :color, DataMapper::Property::String property :num_spots, DataMapper::Property::Integer property :striped, DataMapper::Property::Boolean # This is needed for DataMapper.finalize def self.name() 'Heffalump' end }.tap { DataMapper.finalize } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate_uuid\n self.uuid = SecureRandom.uuid()\n end", "def set_uuid\n self.id = SecureRandom.uuid\n end", "def set_uuid\n self.uuid = SecureRandom.uuid\n end", "def set_uuid\n self.uuid = SecureRandom.uuid\n end", "def create_uuid\n self.uuid = SecureRandom.hex(12)\n end", "def before_create\n super\n @uuid = Concept.find_by_sql(\"SELECT UUID() uuid\").first.uuid\n \n self.uuid = @uuid if !self.uuid?\n end", "def set_uuid\n self.id ||= SecureRandom.uuid\n end", "def uuid\n abort_if_unsaved!\n\n model_name = self.class.to_s\n model_id = self.id\n\n uuid = Uuidify::Uuid.where(:model_name => model_name, :model_id => model_id).first\n\n if uuid.nil?\n new_uuid = UUIDTools::UUID.timestamp_create\n new_uuid = Uuidify::Uuid.uuid_to_sql_string(new_uuid)\n\n uuid = Uuidify::Uuid.create(:model_name => model_name, :model_id => self.id, :model_uuid => new_uuid)\n uuid.save!\n end\n\n Uuidify::Uuid.uuid_from_sql_string(uuid.model_uuid)\n end", "def add_uuid\n self.uuid ||= UUIDTools::UUID.timestamp_create().to_s\n end", "def uuid= new_uuid\n abort_if_unsaved!\n\n uuid_value = Uuidify::Uuid.uuid_to_sql_string(new_uuid)\n \n Uuidify::Uuid.where(:model_name => self.class.to_s, :model_id => self.id).first_or_create!.update_column(:model_uuid, uuid_value)\n end", "def set_uuid\n self.uuid ||= SecureRandom.uuid\n end", "def initialize(params={})\n super params\n\n # self._id = self.properties[:uuid]\n\n end", "def uuid; end", "def uuid; end", "def assign_uuid\n self.id = UUIDTools::UUID.timestamp_create().to_s\n end", "def initialize\n @uuid = \"_\" + UUID.new.generate\n end", "def assign_uuid\n self.uuid ||= SecureRandom.urlsafe_base64(8)\n end", "def generate_uuid\n# self[:uuid] = UUID.sha1_create(UUID_OID_NAMESPACE, Time.now.utc.to_f.to_s).to_s\n end", "def default_key\n :\"#{self[:model].name.to_s.demodulize.underscore}_id\"\n end", "def default_key\n :\"#{underscore(demodulize(self[:model].name))}_id\"\n end", "def set_random_uuid\n self.uuid = SecureRandom.uuid\n end", "def create_uuid_for_id\n if self.id.nil?\n self.id = SecureRandom.uuid\n #self.id = SecureRandom.uuid.gsub('-','').upcase\n end\n end", "def before_create\n self[:GUID] = SecureRandom.uuid\n super\n end", "def create_guid\n self.guid = SecureRandom.uuid\n end", "def assign_uuid\n self.uuid ||= \"_#{SecureRandom.uuid.tr('-', '_')}\"\n end", "def primary_key(name, type = :primary_key, options = {})\n return super unless type == :uuid\n options[:default] = options.fetch(:default, 'uuid_generate_v4()')\n options[:primary_key] = true\n column name, type, options\n end", "def primary_key(name, type = :primary_key, options = {})\n return super unless type == :uuid\n options[:default] = options.fetch(:default, 'uuid_generate_v4()')\n options[:primary_key] = true\n column name, type, options\n end", "def set_uuid(uuid=create_uuid)\n field = model.uuid_field\n meth = :\"#{field}=\"\n if respond_to?(field) && respond_to?(meth) && (model.uuid_overwrite? || get_column_value(field).nil?)\n set_column_value(meth, uuid)\n end\n end", "def set_identifier\n self.identifier ||= SecureRandom.uuid\n end", "def to_param\n uuid\n end", "def to_param\n uuid\n end", "def to_param\n uuid\n end", "def set_uuid\n self.uuid = UUIDTools::UUID::timestamp_create.to_s if self.uuid.blank?\n end", "def assign_identifier\n self.id ||= SecureRandom.uuid\n end", "def set_uuid\n @uuid = Uuid.find(params[:id])\n end", "def namespaced_uuid()\n UUID.sha1_create(self.class.uuid_namespace, self.send(self.class.uuid_generating_method)).hexdigest\n end", "def uuid\n SecureRandom.uuid\nend", "def assign_uuid\n self.uuid = UUIDTools::UUID.random_create.to_s\n self.document_number ||= Numerator.get_number\n end", "def uuid() = @uuid ||= SecureRandom.uuid", "def gen_api_key\n u = UUID.new\n self.api_key = u.generate\n end", "def create_guid\n self.id ||= UUIDTools::UUID.random_create.to_s\n end", "def to_param\n uuid\n end", "def make_code\n self.code = UUID.new\n end", "def to_param\n uuid\n end", "def default_key\n :\"#{self[:name]}_id\"\n end", "def lookup_uuid\n get(KABUIDProperty)\n end", "def id\n @model.guid\n end", "def _before_validation\n set_uuid if new?\n super\n end", "def key\n raise MissingID if not defined?(@id)\n model.key[id]\n end", "def id\n key\n end", "def key\n \"User:#{@id}\"\n end", "def set_identifier\n time_tag = \"#{Time.now.to_s}\".gsub(/[^0-9]/,'')[0,14]\n fingerprint_tag = \"#{fingerprint}\".gsub(/[^0-9a-zA-Z]/,'')[-6,6]\n self.identifier ||=\n begin\n case key_type\n when KEY_TYPE_USER\n user.gitolite_identifier\n #\"#{user.gitolite_identifier}_#{fingerprint_tag}_#{time_tag}\"\n when KEY_TYPE_DEPLOY\n \"#{user.gitolite_identifier}_#{fingerprint_tag}_#{time_tag}_#{DEPLOY_PSEUDO_USER}\"\n end\n end\n end", "def generate_ids\n uuid = UUID.new\n self.id = uuid.generate\n end", "def create_uuid\n if self.uuid.nil?\n valid_uid = false\n until valid_uid\n self.uuid = format_uuid(SecureRandom.hex(5))\n valid_uid = Voucher.find_by_uuid(self.uuid).nil?\n self.slug = self.uuid\n end\n end\n end", "def payload_key\n self.class.payload_key(@uuid)\n end", "def default_key\n :\"#{self[:name]}_id\"\n end", "def by_uuid(id)\n DB_UUID[id]\n end", "def create_uuid\n SecureRandom.uuid\n end", "def generate_api_key\n generate_uuid\nend", "def before_save\n self.resource_type ||= self.class.to_s.split('::')[-1].downcase\n self.uuid ||= UUIDTools::UUID.random_create\n self.name ||= self.uuid\n self.urn ||= GURN.create(self.name, :type => self.class.to_s.split('::')[-1].downcase).to_s\n super\n end", "def uwt_id\n GraphQL::Schema::UniqueWithinType.encode(self.class.name, id)\n end", "def hash #:nodoc:\n uuid.hash\n end", "def uuid\n @__uuid__ ||= Util::UUID.generate\n end", "def generate_uuid\n if [nil, \"\"].include?(uuid)\n self.uuid = Vidibus::Uuid.generate\n end\n end", "def uuid!\n @uuid ||= ::UUID.timestamp_create.to_s\n end", "def key\n id\n end", "def hash\n \tcustom_unique_id.hash\n end", "def uuid\n idme_uuid\n end", "def uuid\n\t\t\t@uuid ||= SecureRandom.uuid\n\t\tend", "def model_identifier\n raise 'Invalid' unless id\n \"#{self.class.name}##{id}\"\n end", "def identify!\n self.id ||= SecureRandom.uuid\n end", "def add(model)\n self[model.primary_key] = model\n end", "def key_id; end", "def uuid_params\n params.require(:uuid).permit(:uuid, :location)\n end", "def initialize(id, key='')\n @_id = id\n @_key = key\n end", "def initialize(attrs = {})\n @attributes = {}.with_indifferent_access\n process(defaults.merge(attrs))\n @new_record = true if id.nil?\n generate_key\n end", "def get_model(redis_id)\n model = JSON.parse($redis.get(redis_id))\n model[\"id\"] = redis_id\n model\n end", "def mint_uuid\n self.url_uuid ||= Time.now.to_i\n end", "def uuid\n @keystore[:id]\n end", "def set_id\n self.id = SecureRandom.random_number(9223372036854775807)\n end", "def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id(name)}\"\n end", "def urn_id; :id end", "def urn_id; :id end", "def generate_key; end", "def register_model(model)\n model_dao_name, primary_key = keys_from_model(model, action: :register)\n return self unless model_dao_name.present? && primary_key.present?\n\n log \"register model #{model_dao_name}:#{primary_key}\"\n\n @identity_map[model_dao_name] ||= {}\n @identity_map[model_dao_name][primary_key] = model\n\n self\n end", "def instantiate_record(record, prefix_options = {})\n super(record, prefix_options).tap do |r|\n prefix_options.each do |k, v|\n if r.respond_to?(\"#{k}=\")\n r.send(\"#{k}=\", v)\n end\n end\n # set the id field from [element_name]Id (e.g. userId)\n r.id = r.send(\"#{element_name}Id\") if r.respond_to?(\"#{element_name}Id\")\n end\n end", "def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id @schema.title}.#{Model::to_id name}\"\n end", "def id\n @json['uuid']\n end", "def prepare_value(value)\n {uuid => value}\n end", "def hash_fk_model\n raise NotImplementedError\n end", "def hash_fk_model\n raise NotImplementedError\n end", "def initialize(model, options = {})\n @model = model\n @name = options[:name] || model.storage_name\n @connection = options[:connection] || Oedipus::DataMapper.connection\n @mappings = {}\n @key = model.key.first.name\n\n map(:id, with: @key)\n\n yield self if block_given?\n end", "def raw\n command = \"create_uuid\"\n end", "def set_unique_id\n self.update_column(:unique_id, Digest::MD5.hexdigest(self.id.to_s+Time.now.to_s))\n end", "def globally_unique_identifier\n super\n end", "def generate_api_key\n begin\n api_key = SecureRandom.uuid\n end while ApiKey.exists?(:api_key => api_key)\n\n api = ApiKey.new\n api.api_key = api_key\n api.save\n\n self.api_key = api\n end", "def reassign_uuid!(uuid, virtual_model, owner, new_id)\n raise \"Cannot edit uuid for virtual_model (#{virtual_model.name}) with no fixed baze_class.\" if virtual_model.baze_class.nil?\n sd_uuid = find_uuid_record_for_virtual_model_owner_and_uuid(virtual_model, owner, uuid)\n sd_uuid.update_attributes!({:bb_model_id => new_id})\n end", "def key\n self.id\n end", "def key\n self.id\n end", "def key\n self.id\n end", "def initialize(options = {}) \n options.each_pair do |k,v|\n # TODO: don't allow setting of others?\n instance_variable_set(\"@#{k.to_s}\",v)\n end\n @uuid = UUID.new.generate.gsub('-','').upcase\n end" ]
[ "0.68468714", "0.67764723", "0.6723268", "0.6723268", "0.6704489", "0.6674335", "0.665937", "0.66423947", "0.65382326", "0.6537561", "0.6532744", "0.6523552", "0.6489476", "0.6489476", "0.6474152", "0.6464125", "0.6411354", "0.6405148", "0.6402602", "0.6376676", "0.63421744", "0.63164014", "0.63098145", "0.6289271", "0.62757677", "0.6221813", "0.6221813", "0.61677945", "0.61547524", "0.61477876", "0.61477876", "0.61477876", "0.61471933", "0.6094221", "0.60857123", "0.6070264", "0.60623", "0.605125", "0.60448545", "0.60420024", "0.6023204", "0.6021248", "0.5998074", "0.5972934", "0.5966822", "0.59626204", "0.59569395", "0.5956163", "0.5951958", "0.5947249", "0.5927821", "0.591724", "0.5893734", "0.5892369", "0.5884546", "0.58673507", "0.58536446", "0.58424836", "0.58373916", "0.5827227", "0.58210206", "0.581849", "0.5813058", "0.58037", "0.57909507", "0.57687587", "0.5765776", "0.5760504", "0.5747693", "0.57396495", "0.5737169", "0.57310104", "0.57226145", "0.5719889", "0.57127464", "0.57044154", "0.57042116", "0.5700285", "0.56944054", "0.56738794", "0.5658797", "0.5657414", "0.5657414", "0.56508726", "0.5649122", "0.56269956", "0.56261945", "0.5624311", "0.56223214", "0.5617276", "0.5617276", "0.56136733", "0.55926836", "0.55893916", "0.5584901", "0.5577661", "0.5577233", "0.5575009", "0.5575009", "0.5575009", "0.5528535" ]
0.0
-1
Define a custom model with an Integer key
def heffalump_model @model ||= Class.new { include DataMapper::Resource property :id, DataMapper::Property::Serial property :color, DataMapper::Property::String property :num_spots, DataMapper::Property::Integer property :striped, DataMapper::Property::Boolean # This is needed for DataMapper.finalize def self.name() 'Heffalump' end }.tap { DataMapper.finalize } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key\n raise MissingID if not defined?(@id)\n model.key[id]\n end", "def integer(key, opts={})\n @attrs[key.to_sym] = Attributes::IntegerAttr.new(key, opts)\n end", "def default_key\n :\"#{underscore(demodulize(self[:model].name))}_id\"\n end", "def id\n key\n end", "def default_key\n :\"#{self[:model].name.to_s.demodulize.underscore}_id\"\n end", "def id_key_for(model_class)\n get_key('ID_KEY', model_class) + '_id'\n end", "def key\n id\n end", "def default_key\n :\"#{self[:name]}_id\"\n end", "def default_key\n :\"#{self[:name]}_id\"\n end", "def add(model)\n self[model.primary_key] = model\n end", "def [](*args)\n if args.length == 1 && (i = args[0]) && i.is_a?(Integer)\n with_pk(i)\n else\n super\n end\n end", "def [](*args)\n if args.length == 1 && (i = args[0]) && i.is_a?(Integer)\n with_pk(i)\n else\n super\n end\n end", "def primary_key\n 'id'\n end", "def key(*fields)\n @primary_key = fields\n before_save :generate_key\n end", "def key_id; end", "def primary_key\n self[:primary_key] ||= self[:model].primary_key\n end", "def default_left_key\n :\"#{underscore(demodulize(self[:model].name))}_id\"\n end", "def key\n self.id\n end", "def key\n self.id\n end", "def key\n self.id\n end", "def primary_key_attribute\n :id\n end", "def to_key # :nodoc:\n id\n end", "def add_integer(key, value)\n int = QueuedEmailInteger.find_by(queued_email_id: id, key: key.to_s)\n unless int\n int = QueuedEmailInteger.new\n int.queued_email_id = id\n int.key = key.to_s\n end\n int.value = value.to_i\n int.save\n int\n end", "def default_right_key\n :\"#{self[:name].to_s.singularize}_id\"\n end", "def primary_key(name, type = :primary_key, options = {})\n return super\n end", "def key=(value)\n raise TypeError, 'key must respond to #to_i' unless value.respond_to?(:to_i)\n \n @key = value.to_i\n end", "def initialize(id, key='')\n @_id = id\n @_key = key\n end", "def default_left_key\n :\"#{self[:model].name.to_s.demodulize.underscore}_id\"\n end", "def key(*fields)\n self.primary_key = fields\n identity(:type => String)\n set_callback :save, :before, :identify\n end", "def default_right_key\n :\"#{singularize(self[:name])}_id\"\n end", "def primary_key\n fail NotImplementedError\n end", "def generate_primary_key\n self[self.class.primary_key] ||= self.class.new_primary_key(10_000)\n end", "def primary_key_type\n \"integer PRIMARY KEY\"\n end", "def set_key\n last_key = Issue.find_by_sql('select max(issueId) as maxid from issue')[0].maxid\n self.issueId = last_key.to_i + 1\n end", "def id_number; end", "def model_type_key\n model.model_type_key\n end", "def model_id\n model.id\n end", "def flexible_key; end", "def set_key\n @key = Key.find(params[:id])\n end", "def initialize(model, key, patch={})\n @model = model\n @key = key\n @patch = patch\n end", "def primary_key\n '_id'\n end", "def key_id=(value)\n @key_id = value\n end", "def key_id=(value)\n @key_id = value\n end", "def key_id=(value)\n @key_id = value\n end", "def hash_fk_model\n raise NotImplementedError\n end", "def hash_fk_model\n raise NotImplementedError\n end", "def primary_key\n \"#{quoted_table_name}.#{model_class.send :primary_key}\"\n end", "def primary_key\n \"#{quoted_table_name}.#{model_class.send :primary_key}\"\n end", "def integer_attr name, options = {}\n add_attribute(IntegerAttribute.new(name, options))\n end", "def model_id(model)\n \"#{model.class.name}_#{model.id}\"\n end", "def model_id(model)\n \"#{model.class.name}_#{model.id}\"\n end", "def id; 1; end", "def to_param\n plural? ? id : model_name.param_key\n end", "def initialize_field(key)\n class_name = model_class.properties[key.to_s].try(:class_name)\n return super unless class_name\n\n self[key] += [class_name.new]\n end", "def key\n @entity.key\n end", "def key(*fields)\n self.primary_key = fields\n self.key_formatter = block_given? ? Proc.new : nil\n identity(:type => String)\n set_callback(:save, :around, :set_composite_key)\n end", "def default_right_key\n :\"#{self[:name]}_id\"\n end", "def self_key # :nodoc:\n klass = self.class\n if klass.superclass != ActiveRecord::Base\n if klass.superclass.eav_class == klass.eav_class\n klass = klass.superclass\n end\n end\n\n \"#{klass.name.underscore}_id\".to_sym\n end", "def id; 1; end", "def id\n @id_number = 12345\n end", "def custom_key\n object.title\n end", "def id\n @model.guid\n end", "def set_primary_key(key)\n clear_setter_methods_cache\n if key.is_a?(Array)\n if key.length < 2\n key = key.first\n else\n key = key.dup.freeze\n end\n end\n self.simple_pk = if key && !key.is_a?(Array)\n (@dataset || db).literal(key).freeze\n end\n @primary_key = key\n end", "def set_primary_key(key)\n clear_setter_methods_cache\n if key.is_a?(Array)\n if key.length < 2\n key = key.first\n else\n key = key.dup.freeze\n end\n end\n self.simple_pk = if key && !key.is_a?(Array)\n (@dataset || db).literal(key).freeze\n end\n @primary_key = key\n end", "def attr_set_integer(attr_type, number)\n #This is a stub, used for indexing\n end", "def key_field\n 'key'\n end", "def primary_key\n send( self.class.primary_key )\n end", "def key_prefix\n \"number\"\n end", "def get_object(key, model)\n @objects ||= {}\n @objects[key] = model.safe_find(get_integer(key)) unless @objects.key?(key)\n @objects[key]\n end", "def get_model_id\n @mid\n end", "def pk\n raise(Error, \"No primary key is associated with this model\") unless key = primary_key\n case key\n when Array\n key.collect{|k| @values[k]}\n else\n @values[key]\n end\n end", "def model_identifier\n raise 'Invalid' unless id\n \"#{self.class.name}##{id}\"\n end", "def [](primary_key_value)\n entity = odata_entity_set[primary_key_value]\n return entity if entity.nil?\n model = self.new\n model.instance_variable_set(:@odata_entity, entity)\n model\n end", "def initialize(model, options = {})\n @model = model\n @name = options[:name] || model.storage_name\n @connection = options[:connection] || Oedipus::DataMapper.connection\n @mappings = {}\n @key = model.key.first.name\n\n map(:id, with: @key)\n\n yield self if block_given?\n end", "def get_int(attr); end", "def primary_key(name, type = :primary_key, options = {})\n return super unless type == :uuid\n options[:default] = options.fetch(:default, 'uuid_generate_v4()')\n options[:primary_key] = true\n column name, type, options\n end", "def primary_key(name, type = :primary_key, options = {})\n return super unless type == :uuid\n options[:default] = options.fetch(:default, 'uuid_generate_v4()')\n options[:primary_key] = true\n column name, type, options\n end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def id; end", "def key\n @attributes[:key]\n end", "def key\n @attributes[:key]\n end", "def id\n '1234567890'\n end", "def id\n model.id.to_s\n end", "def integer name, description: nil, mode: :nullable, policy_tags: nil\n record_check!\n\n add_field name, :integer, description: description, mode: mode, policy_tags: policy_tags\n end", "def primary_key\n @primary_key || 'id'\n end", "def numid; end", "def primary_key=(name, options = {})\n field name, options\n @config.primary_key = name.to_sym\n end", "def force_primary_key(klass)\n # Automatically add an :oid serializable field if none is\n # defined and no other primary key is defined.\n if klass.primary_key == :oid and !klass.instance_attributes.include?(:oid)\n klass.attr_accessor :oid, Fixnum, :sql => primary_key_type\n end\n end", "def identifier(model)\n models[model]\n end", "def get_id(model, name)\n\t\tid = 0\n\t\tmodel.each do |hash|\n\t\t\thash.each do |k, v|\n\t\t\t\tif v == name\n\t\t\t\t\tid = k.to_i\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tid\n\tend", "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" ]
[ "0.6720784", "0.666855", "0.6541495", "0.64091", "0.6388466", "0.6317858", "0.62648356", "0.61169046", "0.6099205", "0.6097988", "0.6094806", "0.6094806", "0.6052079", "0.5998992", "0.5998329", "0.5993525", "0.5992326", "0.596866", "0.596866", "0.596866", "0.5931119", "0.59217685", "0.59151244", "0.5885983", "0.5885684", "0.5871023", "0.58657235", "0.5846154", "0.584572", "0.58321995", "0.5831076", "0.5826198", "0.57947475", "0.5781393", "0.5761842", "0.57589704", "0.57512844", "0.57274324", "0.5702392", "0.56951064", "0.5681971", "0.5677139", "0.5677139", "0.5677139", "0.56460214", "0.56460214", "0.564494", "0.564494", "0.563394", "0.5621256", "0.5621256", "0.5587977", "0.558758", "0.55803585", "0.55765104", "0.55653554", "0.5556243", "0.5549923", "0.55495256", "0.5537739", "0.5527188", "0.551896", "0.5517049", "0.5517049", "0.5512798", "0.5512258", "0.55084354", "0.55070114", "0.55060756", "0.54923344", "0.5487366", "0.5468744", "0.546626", "0.54640514", "0.5461503", "0.54569733", "0.54569733", "0.5452855", "0.5452855", "0.5452855", "0.5452855", "0.5452855", "0.5452855", "0.5452855", "0.5452855", "0.5452855", "0.5452855", "0.5452855", "0.5452855", "0.5451165", "0.5451165", "0.5450575", "0.54438823", "0.5443805", "0.54412717", "0.54234123", "0.54216117", "0.54202324", "0.541785", "0.541415", "0.54141223" ]
0.0
-1
encoding: muleutf8 Define a navi for contecting to sakamoto san's website
def navi(rel_pos="/~kunolab/") puts "<ul class='menuBar'>" puts "<li><a href=\"/~sakamoto/kunolab/MiniWorkshop/2nd/index.html\">Mini-Workshop</a>" puts "<li><a href=\"https://calendar.google.com/calendar/embed?src=kunogroup%40gmail.com&ctz=Asia%2FTokyo\">久野研カレンダー(KunoLabCalendar)</a>" puts "<li><a href=\"/~kunolab/seminar/ronbun/2018/index.html\">論文紹介(Paper Presentation)</a>" puts "<li><a href=\"/~kunolab/seminar/kenkyu/2018/index.html\">研究紹介(Research Presentation)</a>" puts "<li><a href='#'>ゼミ(Seminar) <image src=\"image/sita3.png\" class=\"headImg\"></a>" puts "<ul>" puts "<li><a href=\"/~kunolab/seminar/Lepton_2017/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Leptonゼミ(2017)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Modern_2016/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Thomsonゼミ(2016)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Modern_2015/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Thomsonゼミ(2015)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Perkins_2015/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Perkinsゼミ(2015)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Mann_2014/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Mannゼミ(2014)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Mann/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Mannゼミ(2013)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Elementary_2013/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> 素粒子物理学ゼミ(2013)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Leo_2012/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Leoゼミ(2012)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Perkins_2012/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Perkinsゼミ(2012)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Elementary/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> 素粒子物理学ゼミ(2012)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Knoll/index.html\"> <image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Knollゼミ(2011)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Knoll_en/index.html\"> <image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Knoll(en)ゼミ(2011)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Roe/index.html\"> <image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Roeゼミ(2011)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Leo/index.html\"> <image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Leoゼミ(2010)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Perkins_en/index.html\"><image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Perkins(en)ゼミ(2010)</a></li>" puts "<li><a href=\"/~sakamoto/kunolab/Leo_en/index.html\"> <image src=\"#{rel_pos}img/yoko3.png\" class=\"headImg\"> Leo(en)ゼミ(2010)</a></li>" puts "</ul>" puts "</ul>" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def utf_page(url)\t\n Hpricot(Iconv.new('utf-8', 'windows-1257').iconv(open(@@WWW+url).read))\n end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def encoding; end", "def meta_encoding; end", "def meta_encoding; end", "def encoding(encoding); end", "def inicio\n cadena = 'Content-Type: text/html; charset=utf-8\\n\\n'\n cadena << '<!DOCTYPE html>'\n cadena << \"<html lang='es'>\"\n end", "def encoding_line; end", "def utf8_enforcer_tag; end", "def encodings; end", "def mozart_italian; end", "def meta_encoding=(encoding); end", "def meta_encoding=(encoding); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def encoding=(_arg0); end", "def header_nav\n return [[\"/scuola\", \"La Scuola &#x25BE;\", 1],\n [\"#\", \"Personale\", 0],\n [\"#\", \"Servizi di Supporto\", 2],\n [\"#\", \"Offerta Formativa &#x25BE;\", 1],\n [\"#\", \"Modulistica\", 0],\n [\"#\", \"Calendario\", 2],\n [\"/classe/tutte_le_classi\", \"Classi\", 0],\n [\"/docente/tutti_i_docenti\", \"Docenti\", 0],\n [\"#\", \"Circolari\", 0],\n [\"/attivita_extra\", \"Attivit&agrave; Extra\", 0],\n [\"#\", \"Strutture\", 0],\n [\"#\", \"News\", 0]]\n end", "def encoding=(enc); end", "def meta_charset(body); end", "def ethnologue_url\n \"http://www.ethnologue.com/show_language.asp?code=#{iso_639_3}\"\n end", "def anstatauKodo(teksto)\n\n trovoj = teksto.scan(/&(.*?);/)\n if trovoj == nil or trovoj.size <= 0 then return teksto end\n\n for i in 0..trovoj.size do\n \n\ttrov = trovoj[i].to_s[2..-3]\n if @literoj[trov] != nil\n\t teksto.sub!(\"&#{trov};\", @literoj[trov])\n\telse\n\t #puts \"Eraro! Ne trovis [#{trov}]\"\n\tend\n end\n\n teksto = CGI::unescapeHTML(teksto)\n return teksto\nend", "def lien_bureau\n 'Votre bureau'.in_a(href:\"unanunscript/bureau/pages\") \n end", "def iconv() end", "def convert_encoding(content); end", "def translate\n translate_matches\n add_meta_charset\n set_encoding\n end", "def tuc(arg)\n h = Hash.[](\".\"=>\"&#x0F0B;\", \"/\"=>\"&#x0F0D;\", \";\"=>\"&#x0F14;\", \"\"=>\"\",\n \"ka\"=>\"&#x0F40;\", \"kha\"=>\"&#x0F41;\", \"ga\"=>\"&#x0F42;\", \"nga\"=>\"&#x0F44;\",\n \"ca\"=>\"&#x0F45;\", \"cha\"=>\"&#x0F46;\", \"ja\"=>\"&#x0F47;\", \"nya\"=>\"&#x0F49;\",\n \"ta\"=>\"&#x0F4F;\", \"tha\"=>\"&#x0F50;\", \"da\"=>\"&#x0F51;\", \"na\"=>\"&#x0F53;\",\n \"pa\"=>\"&#x0F54;\", \"pha\"=>\"&#x0F55;\", \"ba\"=>\"&#x0F56;\", \"ma\"=>\"&#x0F58;\",\n \"tsa\"=>\"&#x0F59;\", \"tsha\"=>\"&#x0F5A;\", \"dza\"=>\"&#x0F5B;\", \"wa\"=>\"&#x0F5D;\",\n \"zha\"=>\"&#x0F5E;\", \"za\"=>\"&#x0F5F;\", \"'a\"=>\"&#x0F60;\", \"ya\"=>\"&#x0F61;\",\n \"ra\"=>\"&#x0F62;\", \"la\"=>\"&#x0F63;\", \"sha\"=>\"&#x0F64;\", \"sa\"=>\"&#x0F66;\",\n \"ha\"=>\"&#x0F67;\", \"a\"=>\"&#x0F68;\",\n # numbers !!! better include number_generator\n \"0\"=>\"&#x0F20;\", \"1\"=>\"&#x0F21;\", \"2\"=>\"&#x0F22;\", \"3\"=>\"&#x0F23;\",\n \"4\"=>\"&#x0F24;\", \"5\"=>\"&#x0F25;\", \"6\"=>\"&#x0F26;\", \"7\"=>\"&#x0F27;\",\n \"8\"=>\"&#x0F28;\", \"9\"=>\"&#x0F29;\",\n # vowel signs\n \".e\"=>\"&#x0F7A;\", \".i\"=>\"&#x0F72;\", \".o\"=>\"&#x0F7C;\", \".u\"=>\"&#x0F74;\",\n # double vowel signs\n \"E\" => \"&#x0F7B;\", \"O\" => \"&#x0F7D;\",\n # subscribed characters\n \"x_ka\"=>\"&#x0F90;\", \"x_kha\"=>\"&#x0F91;\", \"x_ga\"=>\"&#x0F92;\", \"x_nga\"=>\"&#x0F94;\",\n \"x_ca\"=>\"&#x0F95;\", \"x_cha\"=>\"&#x0F96;\", \"x_ja\"=>\"&#x0F97;\", \"x_nya\"=>\"&#x0F99;\",\n \"x_ta\"=>\"&#x0F9F;\", \"x_tha\"=>\"&#x0F90;\", \"x_da\"=>\"&#x0FA1;\", \"x_na\"=>\"&#x0FA3;\",\n \"x_pa\"=>\"&#x0FA4;\", \"x_pha\"=>\"&#x0FA5;\", \"x_ba\"=>\"&#x0FA6;\", \"x_ma\"=>\"&#x0FA8;\",\n \"x_tsa\"=>\"&#x0FA9;\", \"x_tsha\"=>\"&#x0FAA;\", \"x_dza\"=>\"&#x0FAB;\", \"x_wa\"=>\"&#x0FAD;\",\n \"x_zha\"=>\"&#x0FAE;\", \"x_za\"=>\"&#x0FAF;\", \"x_'a\"=>\"&#x0F71;\", \"x_ya\"=>\"&#x0FB1;\",\n \"x_ra\"=>\"&#x0FB2;\", \"x_la\"=>\"&#x0FB3;\", \"x_sha\"=>\"&#x0FB4;\", \"x_sa\"=>\"&#x0FB6;\",\n \"x_ha\"=>\"&#x0FB7;\", \"x_a\"=>\"&#x0FB8;\",\n # superscribed character\n \"ra_x\"=>\"&#x0F62;\",\n # revered letters\n \"Ta\"=>\"&#x0F4A;\", \"Tha\" => \"&#x0F4B;\", \"Da\" => \"&#x0F4C;\", \"Na\" => \"&#x0F4E;\",\n \"Sha\" => \"&#x0F65;\")\n\n result = h[arg]\n if result != nil\n erg = result\n else\n erg = \"\"\n end\n return erg\n end", "def html_convert(str)\r\n\t\t#リンク処理\r\n\t\tstr = str.to_s.gsub(/(http[s]?\\:\\/\\/[\\w\\.\\~\\-\\/\\?\\&\\+\\=\\:\\@\\%\\;\\#\\%]+)/) do\r\n\t\t\t\"<a href=\\\"#{$1}\\\" target=\\\"_blank\\\">#{$1}</a>\"\r\n\t\tend\r\n\t\t#@ハンドル名リンク\r\n\t\tstr = str.to_s.gsub(/(\\@)([a-zA-Z0-9_]+)/) do\r\n\t\t\t\"<a href=\\\"http://twitter.com/#{$2}\\\" target=\\\"_blank\\\">#{$1}#{$2}</a>\"\r\n\t\tend\r\n\t\t# #タグリンク\r\n\t\tstr = str.to_s.gsub(/(#)([a-zA-Z0-9]+)/) do\r\n\t\t\t\"<a href=\\\"http://twitter.com/#search?q=%23#{$2}\\\" target=\\\"_blank\\\">#{$1}#{$2}</a>\"\r\n\t\tend\r\n\t\treturn str\r\n\tend", "def encoding\n\t'ISO-8859-1'\nend", "def external_encoding()\n #This is a stub, used for indexing\n end", "def scrape(uri)\n site = open(uri)\n data = \"\"\n site.each_line { |x| data += x }\n Hpricot(Iconv.conv('utf-8', 'iso-8859-1', data))\nend", "def encoding_line=(_arg0); end", "def hello\n \"Hello, Hello, はろ!\"\nend", "def gerund\n b = gerundive.sub( /.*\\s+(.*)um.*$/, \"\\\\1\" )\n b += \"ī, ō, etc.\"\n return b\n end", "def default_encoding; end", "def default_encoding; end", "def latin\n @input = I18n.transliterate(@input)\n end", "def hecho_en\n 'china'\n end", "def charset; end", "def charset; end", "def charset; end", "def found_encoding; end", "def found_encoding; end", "def mobile_encoding\n\t'ISO-8859-1'\nend", "def encoding\n @content[pn(:Encoding)]\n end", "def html5_noti\n \n end", "def content_encoding_hooks; end", "def content_encoding_hooks; end", "def writeencoding; end", "def index\n @natulangs = Natulang.all\n\n @text = History.last.content\n\n @msg = Moji.type(\"漢\")\n \n nlp = NLP.new()\n \n #@msg = nlp.cut_morph(@text)\n \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @natulangs }\n end\n end", "def encoding()\n #This is a stub, used for indexing\n end", "def test_encoded_in_change_out\n doc = Document.new( @encoded )\n doc.xml_decl.encoding = \"UTF-8\"\n assert_equal(\"UTF-8\", doc.encoding)\n REXML::Formatters::Default.new.write( doc.root, out=\"\" )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @not_encoded.b, out )\n char = XPath.first( doc, \"/a/b/text()\" ).to_s\n char.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( \"ĉ\".b, char )\n end", "def scramble_unencode(param)\n param && SimpleScramble.unscramble(CGI.unescape(param))\n end", "def encoding\n Encoding::UTF_8\n end", "def encoding\n Encoding::UTF_8\n end", "def encoding_found; end", "def encoding_found; end", "def load_and_parse_navigation(nav_url=\"https://www.unibet.com/betting\")\n\t\t# download home page\n\t\tload(nav_url)\n f = IO.read(File.join(@dir, nav_url.split(\"/\").last))\n doc = Hpricot.XML(f)\n \n \t\t(doc/\"ul.uHide/li\").each do |sport|\n\t\t\tsportname = (sport/\"/dl/dd/a\").inner_text.strip\n\t\t\t@link_hash[sportname] = {} unless @link_hash.include? sportname\n\t\t\t(sport/\"//ul/li\").each do |region|\n\t\t\t\tregionname = (region/\"/dl/dd/a\").inner_text.strip\n\t\t\t\t@link_hash[sportname][regionname] = {} unless @link_hash[sportname].include? regionname\n\t\t\t\t(region/\"//ul/li\").each do |league|\n\t\t\t\t\tleaguename = (league/\"/dl/dd/a\").inner_text.strip\n\t\t\t\t\tlink = (league/\"/dl/dd/a\").first[\"href\"]\n\t\t\t\t\t@link_hash[sportname][regionname][leaguename] = link\n\t\t\t\tend\n\t\t\tend\n\t\tend\n end", "def parse_autolink; end", "def internal_encoding()\n #This is a stub, used for indexing\n end", "def fix_encoding(url)\n convert_to_latin_1(url)\n rescue Encoding::InvalidByteSequenceError\n # It was Latin-1 already.\n url\n end", "def content_encoding\n v = @meta['content-encoding']\n if v && %r{\\A#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?(?:,#{RE_LWS}?#{RE_TOKEN}#{RE_LWS}?)*}o =~ v\n v.scan(RE_TOKEN).map {|content_coding| content_coding.downcase}\n else\n []\n end\n end", "def default_encoding\n Encoding::UTF_8\n end", "def i18n_nav(thing)\n pages = @context.registers[:site].pages_by_language\n lang = @context.registers[:page]['language']\n return thing if @context.registers[:page]['is_default_language']\n # puts \"#{lang}: before '#{thing}'\"\n filtered = thing.find_all do |t|\n t['url'] == '/' || # always pass through \"Start\"\n exists_in_language(t['url'], lang)\n #pages[lang][t['url']].name.end_with?(\"#{lang}.md\")\n end\n # puts \"#{lang}: after '#{filtered}'\"\n filtered\n end", "def fix_encoding\n self.title = EncodingManager.fix_encoding self.title\n self.url = EncodingManager.fix_encoding self.url\n self.author = EncodingManager.fix_encoding self.author\n self.content = EncodingManager.fix_encoding self.content\n self.summary = EncodingManager.fix_encoding self.summary\n self.guid = EncodingManager.fix_encoding self.guid\n end", "def find_encoding(encoding); end", "def to_wiki_code\n \tself.gsub!(/<b>(.*)?(<\\/b>)/,'**\\1**')\n \tself.gsub!(/<i>(.*)?(<\\/i>)/,'\\\\\\\\\\\\\\\\\\1\\\\\\\\\\\\\\\\')\n \tself.gsub!(/<a href=\"\\/(.*)?\">(.*)?(<\\/a>)/,'((\\1 \\2))')\n end", "def slogan\n search_by_text 'слоган'\n end", "def force_utf32; end", "def force_utf32; end", "def force_utf32; end", "def ruta_externa\n @base = \"http://www.gis3.com\"\n\n if I18n.locale == :es\n return @base + '/espanol'\n\n elsif I18n.locale == :en\n return @base + '/english'\n\n end\n\n end", "def default_encoding=(_arg0); end", "def html_lang\n\t'en-US'\nend", "def encoding_for(character)\n encoding_for_bars(ENCODINGS[character])\n end", "def set_win_lang_codes(lcode)\n lcode[0x0436] = 'af;Afrikaans'\n lcode[0x041C] = 'sq;Albanian'\n lcode[0x0001] = 'ar;Arabic'\n lcode[0x0401] = 'ar-sa;Arabic (Saudi Arabia)'\n lcode[0x0801] = 'ar-iq;Arabic (Iraq)'\n lcode[0x0C01] = 'ar-eg;Arabic (Egypt)'\n lcode[0x1001] = 'ar-ly;Arabic (Libya)'\n lcode[0x1401] = 'ar-dz;Arabic (Algeria)'\n lcode[0x1801] = 'ar-ma;Arabic (Morocco)'\n lcode[0x1C01] = 'ar-tn;Arabic (Tunisia)'\n lcode[0x2001] = 'ar-om;Arabic (Oman)'\n lcode[0x2401] = 'ar-ye;Arabic (Yemen)'\n lcode[0x2801] = 'ar-sy;Arabic (Syria)'\n lcode[0x2C01] = 'ar-jo;Arabic (Jordan)'\n lcode[0x3001] = 'ar-lb;Arabic (Lebanon)'\n lcode[0x3401] = 'ar-kw;Arabic (Kuwait)'\n lcode[0x3801] = 'ar-ae;Arabic (you.A.E.)'\n lcode[0x3C01] = 'ar-bh;Arabic (Bahrain)'\n lcode[0x4001] = 'ar-qa;Arabic (Qatar)'\n lcode[0x042D] = 'eu;Basque'\n lcode[0x0402] = 'bg;Bulgarian'\n lcode[0x0423] = 'be;Belarusian'\n lcode[0x0403] = 'ca;Catalan'\n lcode[0x0004] = 'zh;Chinese'\n lcode[0x0404] = 'zh-tw;Chinese (Taiwan)'\n lcode[0x0804] = 'zh-cn;Chinese (China)'\n lcode[0x0C04] = 'zh-hk;Chinese (Hong Kong SAR)'\n lcode[0x1004] = 'zh-sg;Chinese (Singapore)'\n lcode[0x041A] = 'hr;Croatian'\n lcode[0x0405] = 'cs;Czech'\n lcode[0x0406] = 'da;Danish' #changed from \"the\"\n lcode[0x0413] = 'nl;Dutch (Netherlands)'\n lcode[0x0813] = 'nl-be;Dutch (Belgium)'\n lcode[0x0009] = 'en;English'\n lcode[0x0409] = 'en-us;English (United States)'\n lcode[0x0809] = 'en-gb;English (United Kingdom)'\n lcode[0x0C09] = 'en-au;English (Australia)'\n lcode[0x1009] = 'en-ca;English (Canada)'\n lcode[0x1409] = 'en-nz;English (New Zealand)'\n lcode[0x1809] = 'en-ie;English (Ireland)'\n lcode[0x1C09] = 'en-za;English (South Africa)'\n lcode[0x2009] = 'en-jm;English (Jamaica)'\n lcode[0x2809] = 'en-bz;English (Belize)'\n lcode[0x2C09] = 'en-tt;English (Trinidad)'\n lcode[0x0425] = 'et;Estonian'\n lcode[0x0438] = 'fo;Faeroese'\n lcode[0x0429] = 'fa;Farsi'\n lcode[0x040B] = 'fi;Finnish'\n lcode[0x040C] = 'fr;French (France)'\n lcode[0x080C] = 'fr-be;French (Belgium)'\n lcode[0x0C0C] = 'fr-ca;French (Canada)'\n lcode[0x100C] = 'fr-ch;French (Switzerland)'\n lcode[0x140C] = 'fr-lu;French (Luxembourg)'\n lcode[0x043C] = 'gd;Gaelic'\n lcode[0x0407] = 'de;German (Germany)'\n lcode[0x0807] = 'de-ch;German (Switzerland)'\n lcode[0x0C07] = 'de-at;German (Austria)'\n lcode[0x1007] = 'de-lu;German (Luxembourg)'\n lcode[0x1407] = 'de-li;German (Liechtenstein)'\n lcode[0x0408] = 'el;Greek'\n lcode[0x040D] = 'he;Hebrew'\n lcode[0x0439] = 'hi;Hindi'\n lcode[0x040E] = 'hu;Hungarian'\n lcode[0x040F] = 'is;Icelandic'\n lcode[0x0421] = 'in;Indonesian'\n lcode[0x0410] = 'it;Italian (Italy)'\n lcode[0x0810] = 'it-ch;Italian (Switzerland)'\n lcode[0x0411] = 'ja;Japanese'\n lcode[0x0412] = 'ko;Korean'\n lcode[0x0426] = 'lv;Latvian'\n lcode[0x0427] = 'lt;Lithuanian'\n lcode[0x042F] = 'mk;FYRO Macedonian'\n lcode[0x043E] = 'ms;Malay (Malaysia)'\n lcode[0x043A] = 'mt;Maltese'\n lcode[0x0414] = 'no;Norwegian (Bokmal)'\n lcode[0x0814] = 'no;Norwegian (Nynorsk)'\n lcode[0x0415] = 'pl;Polish'\n lcode[0x0416] = 'pt-br;Portuguese (Brazil)'\n lcode[0x0816] = 'pt;Portuguese (Portugal)'\n lcode[0x0417] = 'rm;Rhaeto-Romanic'\n lcode[0x0418] = 'ro;Romanian'\n lcode[0x0818] = 'ro-mo;Romanian (Moldova)'\n lcode[0x0419] = 'ru;Russian'\n lcode[0x0819] = 'ru-mo;Russian (Moldova)'\n lcode[0x0C1A] = 'sr;Serbian (Cyrillic)'\n lcode[0x081A] = 'sr;Serbian (Latin)'\n lcode[0x041B] = 'sk;Slovak'\n lcode[0x0424] = 'sl;Slovenian'\n lcode[0x042E] = 'sb;Sorbian'\n lcode[0x040A] = 'es;Spanish (Traditional Sort)'\n lcode[0x080A] = 'es-mx;Spanish (Mexico)'\n lcode[0x0C0A] = 'es;Spanish (International Sort)'\n lcode[0x100A] = 'es-gt;Spanish (Guatemala)'\n lcode[0x140A] = 'es-cr;Spanish (Costa Rica)'\n lcode[0x180A] = 'es-pa;Spanish (Panama)'\n lcode[0x1C0A] = 'es-do;Spanish (Dominican Republic)'\n lcode[0x200A] = 'es-ve;Spanish (Venezuela)'\n lcode[0x240A] = 'es-co;Spanish (Colombia)'\n lcode[0x280A] = 'es-pe;Spanish (Peru)'\n lcode[0x2C0A] = 'es-ar;Spanish (Argentina)'\n lcode[0x300A] = 'es-ec;Spanish (Ecuador)'\n lcode[0x340A] = 'es-cl;Spanish (Chile)'\n lcode[0x380A] = 'es-uy;Spanish (Uruguay)'\n lcode[0x3C0A] = 'es-py;Spanish (Paraguay)'\n lcode[0x400A] = 'es-bo;Spanish (Bolivia)'\n lcode[0x440A] = 'es-sv;Spanish (El Salvador)'\n lcode[0x480A] = 'es-hn;Spanish (Honduras)'\n lcode[0x4C0A] = 'es-ni;Spanish (Nicaragua)'\n lcode[0x500A] = 'es-pr;Spanish (Puerto Rico)'\n lcode[0x0430] = 'sx;Sutu'\n lcode[0x041D] = 'sv;Swedish'\n lcode[0x081D] = 'sv-fi;Swedish (Finland)'\n lcode[0x041E] = 'th;Thai'\n lcode[0x0431] = 'ts;Tsonga'\n lcode[0x0432] = 'tn;Tswana'\n lcode[0x041F] = 'tr;Turkish'\n lcode[0x0422] = 'uk;Ukrainian'\n lcode[0x0420] = 'ur;Urdu' #changed from \"your\"\n lcode[0x042A] = 'vi;Vietnamese'\n lcode[0x0434] = 'xh;Xhosa'\n lcode[0x043D] = 'ji;Yiddish'\n lcode[0x0435] = 'zu;Zulu'\nend", "def return_in_latin(input)\n input.tr('αβεηικμνορτχυζ'.upcase, 'abehikmnoptxyz'.upcase) \n end", "def charset=(charset); end", "def transcode(str)\n str.force_encoding('UTF-8')\nend", "def translate_utf8 text, index\n @dict.each { |word| \n key, eng = word[0], word[1][TABLE[index]] \n text.gsub!(key, eng)\n }\n text\n end", "def art_directors_hash\n search_by_text_hash 'художник'\n end", "def convert text\n label = convert_flow @am.flow text\n\n CGI.escape(label).gsub('%', '-').sub(/^-/, '')\n end", "def llmap_url\n \"http://llmap.org/languages/#{iso_639_3}.html\"\n end", "def toUrl (title)\n chars = {\n \"-\" => /[ ':_]/,\n \"a\" => /[áàâä]/,\n \"c\" => /[ç]/,\n \"e\" => /[éèêë]/,\n \"i\" => /[iï]/,\n \"o\" => /[ô]/,\n \"u\" => /[ùûü]/\n }\n title = title.downcase\n chars.each { |char, pattern|\n title.gsub! pattern, char\n }\n title\nend" ]
[ "0.66995645", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.58150536", "0.5733221", "0.5733221", "0.56812507", "0.5677913", "0.5602107", "0.5579253", "0.55567896", "0.5510838", "0.5502299", "0.5502299", "0.54577684", "0.54577684", "0.5456753", "0.5456753", "0.5456753", "0.5456753", "0.5456753", "0.54403764", "0.5374769", "0.53390956", "0.5336075", "0.53085977", "0.52934325", "0.5286768", "0.5276036", "0.52485484", "0.5245455", "0.5233652", "0.52130896", "0.5206483", "0.5181957", "0.51783276", "0.51622146", "0.5160058", "0.51426643", "0.51426643", "0.5123551", "0.50765777", "0.506402", "0.506402", "0.506402", "0.50438815", "0.50438815", "0.5043416", "0.50404835", "0.5039595", "0.50375944", "0.50375944", "0.502074", "0.50203776", "0.5012072", "0.5011239", "0.5008281", "0.5007954", "0.5007954", "0.5003956", "0.5003956", "0.49927026", "0.4989574", "0.4983587", "0.49829364", "0.49779654", "0.49763173", "0.49555248", "0.4952203", "0.4941553", "0.4938749", "0.49361327", "0.49355438", "0.49355438", "0.49355438", "0.4928612", "0.4918975", "0.49122557", "0.49117753", "0.4899407", "0.48819867", "0.4880082", "0.48725766", "0.48695526", "0.48672742", "0.48672223", "0.48579347", "0.4856011" ]
0.5490137
26
A function to read slide path
def read_slide(fname) hash={} File.open(fname,'r') do |f| f.each_line do |line| line.chomp! a1,a2 = line.split(/\s*==\s*/) hash[a1] = a2 # a1:id, a2:path end end hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path() end", "def path() end", "def path() end", "def path\n @reader.path\n end", "def read_path_with_own_path\n File.join(read_path, path)\n end", "def path_section\n $1 if @basename.to_s =~ /\\.(\\d\\w*)\\./\n end", "def read_path(path)\n File.read(path)\n end", "def process_path\n unless params[:name].nil?\n #get path from params\n @path = params[:name]\n\n #get last section which is page name\n @name = @path.split(\"/\").last\n end\n end", "def path\n @absolute_path.sub(%r{^#{Slimdown.config.location}/(.*)\\.md}, '\\1')\n end", "def pathDocuments\n \"./documents/\"\nend", "def path\n read_attribute(:path).sub(/^[^:]+:/,'').gsub(/^\\/+/,'')\n end", "def path\n return @path\n end", "def get_path_pins(path); end", "def get_path_pins(path); end", "def path(*) end", "def defined_path(path)\n return root_defined_path_part[path]\n end", "def path\n file.url\n end", "def path\n end", "def path\n end", "def path\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @file.path\n end", "def path\n @path ||= position.sub(/\\.\\d+\\z/, \"\")\n end", "def full_path\n container.root.join(path)\n end", "def full_path\n container.root.join(path)\n end", "def read_path\n @read_path ||= self.class.image_read_path.dup\n end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path; end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @data[\"path\"].to_s\n end", "def path\n @filename\n end", "def path\n File.join(doc.path, \"#excerpt\")\n end", "def read(path); end", "def path(params={})\n rep_name = params.fetch(:rep, :default)\n\n # Get rep\n rep = self.reps.find { |r| r.name == rep_name }\n if rep.nil?\n raise Nanoc::Errors::Generic,\n \"No rep named #{rep_name.inspect} was found.\"\n end\n\n # Get rep's path\n rep.path\n end", "def image_read_path\n @image_read_path\n end", "def path\n end", "def slides\n @file_manager.slide_files\n end", "def path_expanded path\n end", "def get_path(filename)\n\n Pathname(__FILE__).ascend{ |directory|\n path = directory + \"ansiblealexa.yml\"; break path if path.file?\n }\n\nend", "def paths; end", "def paths; end", "def paths; end", "def paths; end", "def paths; end", "def path\n Pathname(@path.respond_to?(:to_path) ? @path.to_path : @path.to_s).expand_path\n end", "def path\n @file.path\n end", "def get_Path(initial)\n\tinitial.split(' ',3)[1]\nend", "def path # getter method \n # - this method will get the path passed through the MusicImporter object\n @path\n end", "def get_path(fullpath = \"\")\n (fullpath || \"\").scan(/^[\\w+|\\/]+/)[0]\n end", "def file_path\n end", "def path\n data.path\n end", "def path\n data.path\n end", "def full_path\n path\n end", "def get_presentation_id(slide_url)\n starting_index = slide_url.index(\"/d/\")\n # Following string matching seems to be lengthy, But is faster the Regular Exp.\n ending_index = slide_url.index(\"/present#slide\") || slide_url.index(\"/present?slide\") || slide_url.index(\"/edit#slide\") || slide_url.index(\"/edit?slide\")\n return nil unless ending_index and starting_index\n presentation_id = slide_url[starting_index + 3..ending_index-1]\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @path\n end", "def path\n @path\n end", "def step3g_fluctuation_source(path)\n return \"#{path.pathmap('%d')}/nreads.RData\"\nend", "def path\n return @path\n end", "def path\n return @path\n end", "def path\n return @path\n end", "def fetch_path(start_path)\n ['', 'config'].each do |directory|\n ['', '.'].each do |prefix|\n path = File.join(start_path, directory, \"#{prefix}#{@file_name}\")\n return path if File.exist?(path)\n end\n end\n nil\n end", "def path\n File.expand_path File.join(songs.first.path, '..').gsub(' ','\\ ')\n end", "def path\n @game_info['path']\n end" ]
[ "0.61731964", "0.61731964", "0.61731964", "0.61456704", "0.6084605", "0.60776776", "0.60620546", "0.601105", "0.59851295", "0.5976377", "0.59317535", "0.5889492", "0.58782643", "0.58782643", "0.5853616", "0.5844539", "0.5841976", "0.5812183", "0.5812183", "0.5812183", "0.5811919", "0.5811919", "0.5811477", "0.5795958", "0.5783662", "0.5783662", "0.57767725", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57570094", "0.57549536", "0.57549536", "0.57549536", "0.57549536", "0.57481605", "0.57399946", "0.57279843", "0.5727975", "0.5726784", "0.5726063", "0.5706262", "0.56827", "0.56789327", "0.5673687", "0.56701785", "0.56701785", "0.56701785", "0.56701785", "0.56701785", "0.5669006", "0.5654321", "0.5651221", "0.56507194", "0.56464833", "0.56422234", "0.56376094", "0.56376094", "0.5631431", "0.5629136", "0.56275934", "0.56275934", "0.56275934", "0.56275934", "0.5624014", "0.5620073", "0.5620073", "0.5620073", "0.56137246", "0.5602075", "0.55969054" ]
0.0
-1
Read Data A function to read summary path
def read_summary(fname) hash={} # Read file File.open(fname,'r') do |f| # Loop over line f.each_line do |line| line.chomp! index,content = line.split(/\s*==\s*/) hash[index] = content # index:id, content:path end end return hash end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_data_file(path); end", "def data name\n File.read data_path(name)\nend", "def read_metadata; end", "def summarize_file(path); end", "def read(path); end", "def read\n IO.read(full_path)\n end", "def parse_from_summary(data)\n # \n end", "def read\n self.read_layout\n self.read_directories\n end", "def data_d\n Pathname.new \"#{exp_crit_d}/data\"\n \n end", "def data\n File.read(path)\n end", "def esri_opendata_metadata\n File.read(File.join(File.dirname(__FILE__), './docs/esri_open_data.json'))\n end", "def esri_opendata_metadata\n File.read(File.join(File.dirname(__FILE__), './docs/esri_open_data.json'))\n end", "def read_file(absolute_path); end", "def step3g_fluctuation_source(path)\n return \"#{path.pathmap('%d')}/nreads.RData\"\nend", "def get_data(arg)\n dir_to_data = Dir.pwd + '/features/support'\n data = YAML.load_file(\"#{dir_to_data}/data_list.yml\")\n data['DataSet'][\"#{arg}\"]\nend", "def read_feature_by_path(feature_file_name)\n file = File.open(feature_file_name)\n file_data = file.read\n file_data\nend", "def get_file_summary(file_path)\n response = HTTParty.get(\"https://#{accountName}.azuredatalakestore.net\" +\n \"/webhdfs/v1/#{file_path}?op=GETCONTENTSUMMARY\", {\n body: \"grant_type=client_credentials&client_id=#{clientId}\"+\n \"&client_secret=#{clientSecret}\"+\n \"&resource=https%3A%2F%2Fmanagement.azure.com%2F\",\n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Accept\" => \"*/*\",\n \"Cache-Control\" => 'no-cache',\n \"Host\" => \"#{accountName}.azuredatalakestore.net\",\n \"Connection\" => 'keep-alive',\n \"cache-control\" => 'no-cache'\n },\n verify: true,\n })\n \n return JSON.parse response.read_body\n end", "def readDataset\n entries = Array.new\n Dir.entries(DATASET_DIR).sort.each do |x|\n if x != \".\" and x != \"..\"\n entries << DatasetEntry.new(File.join(DATASET_DIR, x))\n end\n end\n entries\nend", "def pathBaseSummary()\n return \"#{@resultBaseDir}/#{getConf(:basenameSummary)}\" ;\n end", "def test_each_file_returns_data\n files = NutrientDataSet::META_DATA.keys\n files.each do |name|\n parser = data[\"nutr_def\"]\n row = parser.take(1)\n \n assert !row.empty?, \"Expected data for #{name} to exist.\"\n end\n end", "def read_data_to(dir, data); end", "def find_data_path(path)\n each_data_path(path).first\n end", "def read_metadata\n raise NotImplementedError.new 'This is only a function body for documentation'\n end", "def extract_datas_from_json(path)\n file = File.read(path)\n data_details = JSON.parse(file)\n return data_details\nend", "def path\n data.path\n end", "def path\n data.path\n end", "def fetch_path(path=\"\")\n read_data(@uri + path)\n end", "def read_path(path)\n File.read(path)\n end", "def data_file_full_path\n File.join(@data_lib.dir_name,\"#{@data_set_name}\")\n end", "def get_data(lvl1_label)\n\n pattern_data_file = File.read(\"../#{ROOT_DIR}/lib/assets/data/data.json\")\n pattern_data = JSON.parse(pattern_data_file)\n\n data_files = Dir.glob(\"../#{ROOT_DIR}/lib/assets/data/**/**/*.json\")\n\n data_files.each do |data|\n\n data_name = data.split(\"/\")[-1]\n data_file = File.read(data)\n data_hash = JSON.parse(data_file)\n\n pattern_data = pattern_data.merge(data_hash) unless data_name == \"data.json\"\n end\n\n\n\n # For merging all data in this or previous levels\n lvl1NavData = levelOne = Dir.entries(SOURCE_ROOT).select { |item| item[0,1] != '.' && !item.end_with?(\".md\") && !item.end_with?(\".json\") }\n reached_current_lvl = false\n\n lvl1NavData.each do |nav_category|\n\n if (reached_current_lvl == false)\n\n category_data = Dir.glob(\"../#{ROOT_DIR}/lib/views/source/#{nav_category}/**/**/*.json\")\n\n category_data.each do |data|\n data_name = data.split(\"/\")[-1]\n data_file = File.read(data)\n data_hash = JSON.parse(data_file)\n\n pattern_data = pattern_data.merge(data_hash)\n end\n\n reached_current_lvl = true if nav_category == lvl1_label\n end\n end\n\n return pattern_data\n end", "def readFile()\n\t#This is assuming the file name will be used\n\tfilename = 'names-data.txt'\n\topen(filename, 'r') {|f| f.read}\nend", "def data\n return @data unless @data.nil?\n\n if File.exists?(@path)\n @data = File.read(@path)\n else\n raise FileNotFound.new(@path)\n end\n end", "def metadata_full_path\n @metadata_full_path ||= \"#{File.dirname(@full_path)}/#{name}\"\n end", "def path\n @reader.path\n end", "def data; file_log.read(file_node); end", "def read(_ = nil)\n as_hash(read_lines)[base_name]\n end", "def read_path_with_own_path\n File.join(read_path, path)\n end", "def metadata_full_path\n @metadata_full_path ||= File.join(File.dirname(@full_path), name)\n end", "def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end", "def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end", "def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end", "def latest_data\n path = Dir[\"#{storage_path}/[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\"].\n sort{|a,b| b.split(\"/\")[-1].to_i <=> a.split(\"/\")[-1].to_i}.\n first\n\n if not path\n raise RuntimeError, \"No dataset available for #{self.name}\"\n end\n\n path\n end", "def spec_description(path)\n File.read(path).scan(/describe.+?['\"]([^'\"]+)/).flatten.first\n end", "def read id, &block\n fn = _data_path(id)\n if block_given?\n File.open(fn, 'r', &block)\n else\n File.read(fn)\n end\n end", "def load_info\n info = File.readlines @dir+\"info\"\n @last_learnq = info[0].to_i\n @last_repq = info[1].to_i\n @last_exerq = info[2].to_i\n @last_category = info[3].to_i\n @exercises = info[4].split(\",\").collect! {|v| v.to_i}\n @rep_ex = info[4].to_i\n end", "def read_metadata\n @client.get(metadata_path)\n end", "def read_data\n\t\t@testers_data = CSV.read(\"data/testers.csv\")\n\n\t\t@testers_device_data = CSV.read(\"data/tester_device.csv\")\n\n\t\t@devices_data = CSV.read(\"data/devices.csv\")\n\n\t\t@bugs_data = CSV.read(\"data/bugs.csv\")\n\tend", "def load_info\n info = File.readlines @dir+\"info\"\n @last_quantity = info[0].chop\n @last_category = info[1].chop.to_i\n @exercises = info[2].chop.split(\",\")\n @last_repq = info[3].chop\n @rep_ex = info[4].chop\n end", "def read_info(uid)\n grid_info = files_collection.find(filename: uid).first or raise Tus::NotFound\n grid_info[:metadata]\n end", "def get_summary( medal_code )\r\n @summary.get_medals( medal_code )\r\n end", "def fetch_data(user)\n array = read_from_file(\"userdata/#{user}.txt\")\n array[0]\nend", "def read_data(uri)\n begin\n \topen_uri_or_path(uri) do |input|\n \t input.read\n \tend\n rescue\n \told_uri = uri\n \turi = uri.downcase\n \tretry if old_uri != uri\n \traise\n end\n end", "def parse_from_summary(data)\n {} # nothing for college\n end", "def read_etl_data\n\n ### CHANGE CUSTOM PATHS\n\toetl_script = OPT[:oetl]\n\tetl_dir = Pathname.new File.expand_path(\"./spec/etl/\")\n #etl_dir.children.each{|f| puts \"#{oetl_script} #{f} \" if f.extname == '.json' } # debugging\n etl_dir.children.each{ |f| `#{oetl_script} #{f} ` if f.extname == '.json' }\n\nend", "def read\n @read ||= File.read(path)\n end", "def read_details\r\n read_detail while peek == 'LX'\r\n self\r\n end", "def summary\n @data['summary']\n end", "def read(*path)\n read!(*path)\n rescue Chef::Exceptions::NoSuchAttribute\n nil\n end", "def get_data filename=nil\n unless filename\n filename = $filename\n else\n $filename = filename\n end\n raise \"File name not found #{filename} in get_data \" if !File.exists?(filename)\n #lines = File.open(filename, \"r\").read.split(\"\\n\")\n #if lines.nil? or lines.empty?\n #perror \"Failed trying to read #{filename}. Please delete if empty \"\n #lines = [\"no data\", \"no data, please refresh\"]\n #end\n obj = YAML::load( File.open( filename ) )\n $yaml_obj = obj\n age = compute_file_age filename\n articles = obj[:articles]\n if articles.empty?\n # this happens when doing More with a stale url\n perror \"No articles in this file. Please delete file.\"\n return\n end\n colh = articles.first.keys\n colh = [:title\t,:age_text\t,:comment_count\t,:points\t,:article_url\t,:comments_url\t,:age\t,:submitter\t,:submitter_url\t,:byline]\n $forum_bgcolor = BOLD\n $forum_bgcolor = ON_RED if age > 8\n # this should only happen if columns are in row 0\n # # FIXME\n $column_headings = colh\n $full_data = Array.new\n # there will be a path also at some time\n #$subforum = filename.sub(File.extname(filename),\"\").sub(\"__\",\"/\")\n $subforum = file_to_forum(filename)\n $host = forum_to_host $subforum\n titles = Array.new\n articles.each do |a|\n titles << a[:title]\n _cols = []\n $column_headings.each do |c|\n _cols << a[c] \n end\n $full_data << _cols\n end\n perror \"No data for #{filename} \" if $full_data.empty?\n raise \"No data for #{filename} \" if $full_data.empty?\n #lines.each_with_index do |l, ix|\n #_cols = l.split(\"\\t\")\n #titles << _cols.first\n #$full_data << _cols\n #end\n calc_column_widths\n size_column_headings\n $files = titles\nend", "def read_save_data(file)\r\n read_characters(file)\r\n read_frame(file)\r\n read_data(file)\r\n read_edit\r\n read_refresh\r\n end", "def read(src_path)\n if File.exist?(src_path) && !File.directory?(src_path)\n File.read(src_path)\n else\n \"\"\n end \n end", "def read\n\t\t@file_content = File.open(\"/home/calin/football/football.dat\",\"r\")\n\tend", "def sample1\n Anomalous.load('spec/sample_data/sample.mat', data_format: :matlab)\nend", "def find_data_file(path)\n each_data_path(path).find { |full_path| File.file?(full_path) }\n end", "def path_to_data_file( path_to_ai_file )\n source_folder = File.dirname( path_to_ai_file )\n base_name = File.basename( path_to_ai_file, '.ai' )\n data_file = source_folder + '/' + base_name + '_data.jsn'\n data_file\n end", "def csvFilenameSummary()\n return pathBaseSummary() + \".csv\" ;\n end", "def read(*args)\n IO.read(@path, *args)\n end", "def read_file(path)\n api.read_file container_name, path\n end", "def data_path name\n File.join File.dirname(__FILE__), 'data', \"#{ name }.yml\"\nend", "def read\n $t1 = Time.now # Init procedure timestamp\n person = []\n IO.foreach(\"data_500.txt\") do |line| # Get all patients from file iterate each line\n line.chomp! # Remove trailing whitespace.\n person.push(line.split(\":\")) # Saving data split :\n end\n group(person) # Get blood type\n end", "def read\nend", "def assembly_summaries &block\n # can't use Enum because the file stream will be closed\n open(URL_ASSEMBLY_SUMMARY) do |handle|\n handle.gets # skip first line\n header = handle.gets.strip.split(\"\\t\")\n header[0] = header[0].gsub(/# /, '') # remove comment from header\n handle.each do |line|\n if line =~ /^#/\n next\n else\n row = line.strip.split(\"\\t\")\n block.yield(Hash[header.zip(row)])\n end\n end\n end\n end", "def data_file!(path)\n path = Pathname.new(path)\n if relative_data_files.include?(path)\n data_dir/path\n else\n raise FileNotFoundError, \"No such file #{path} in bag\"\n end\n end", "def read(*args)\n #This is a stub, used for indexing\n end", "def read(*args) IO.read(path, *args) end", "def read_metadata(path)\n unless path\n abort \"Must exist a markdown filename which have Yaml Front Matter.\"\n end\n yml, _ = Maliq::FileUtils.retrieveYFM(File.read path)\n return nil if yml.empty?\n YAML.load(yml).to_symkey\n end", "def data_path(filetype)\n \"#{@datapath}.#{filetype}.txt\"\n end", "def read\n file\n end", "def read(path)\n @path = path\n unless File.exist?(info_file)\n debug(\"file #{info_file} missing\")\n write(path, {})\n return\n end\n # data = @info_cacher[info_file]\n info_hash[base_name]\n end", "def readDataSingleSource(nameout)\n\t\t\tif nameout.include?(\".source\") == false\n\t\t\t\tnameout = nameout + \".source\"\n\t\t\tend\n\t\t\tdatautils = DataUtils.new\n\t\t\t#puts \"nameout: \" + nameout;\n\t\t\t@l = -1;\n\t\t\t@b = -1;\n\t\t\t@r = -1;\n\t\t\t@ell_a = -1;\n\t\t\t@ell_b = -1;\n\t\t\t@ell_phi = -1;\n\t\t\t\n\t\t\t@sicalc = 0\n\t\t\t@sicalc_error = 0\n\n\t\t\t#read upper limit\n\t\t\tindex2 = 0;\n\t\t\t@r = -1;\n\t\t\t@galcoeff = \"-1\"\n\t\t\t@galcoeff_err = \"-1\"\n\t\t\t@galcoeffzero = \"-1\"\n\t\t\t@galcoeffzero_err = \"-1\"\t\n\t\t\t@isocoeff = \"-1\"\n\t\t\t@isocoeff_err = \"-1\"\n\t\t\t@isocoeffzero = \"-1\"\n\t\t\t@isocoeffzero_err = \"-1\"\t\n\t\t\t@fitdata = \"-1, -1, -1, -1, -1, -1, -1\"\n\t\t\tFile.open(nameout).each_line do | line |\n\t\t\t\tindex2 = index2 + 1;\n\t\t\t\tlll = line.split(\" \")\n\t\t\t\tif index2.to_i == 15\n\t\t\t\t\t@label =lll[0];\n\t\t\t\t\t@fix =lll[1];\n\t\t\t\t\t@si_start = lll[2];\n\t\t\t\t\t@ulconflevel = lll[3];\n\t\t\t\t\t@srcconflevel = lll[4];\n\t\t\t\t\t@startL = lll[5];\n\t\t\t\t\t@startB = lll[6];\n\t\t\t\t\t@startFlux = lll[7];\n\t\t\t\t\t@lmin = lll[9];\n\t\t\t\t\t@lmax = lll[11];\n\t\t\t\t\t@bmin = lll[14];\n\t\t\t\t\t@bmax = lll[16];\n\t\t\t\tend\n\t\t\t\tif index2.to_i == 16\n\t\t\t\t\t@sqrtTS =lll[0];\n\t\t\t\tend\n\t\t\t\tif index2.to_i == 17\n\t\t\t\t\t@l_peak = lll[0];\n\t\t\t\t\t@b_peak = lll[1];\n\t\t\t\t\t@dist = lll[2];\n\t\t\t\tend\n\t\t\t\tif index2.to_i == 18\n\t\t\t\t\t@l = lll[0]\n\t\t\t\t\t@b = lll[1]\n\t\t\t\t\t@distellipse = lll[2];\n\t\t\t\t\t@r = lll[3];\n\t\t\t\t\t@ell_a = lll[4];\n\t\t\t\t\t@ell_b = lll[5];\n\t\t\t\t\t@ell_phi = lll[6];\n\t\t\t\t\t@fullellipseline = format(\"%.2f %.2f %.2f %.2f %.2f %.2f %.2f\", @l, @b, @distellipse, @r, @ell_a, @ell_b, @ell_phi)\n\t\t\t\tend\n\t\t\t\tif index2.to_i == 19\n\t\t\t\t\t@counts = lll[0]\n\t\t\t\t\t@counts_error = lll[1]\n\t\t\t\t\t@counts_error_p = lll[2]\n\t\t\t\t\t@counts_error_m = lll[3]\n\t\t\t\t\t@counts_ul = lll[4];\n\t\t\t\tend\n\t\t\t\tif index2.to_i == 20\n\t\t\t\t\t@flux = lll[0]\n\t\t\t\t\t@flux_error = lll[1]\n\t\t\t\t\t@flux_error_p = lll[2]\n\t\t\t\t\t@flux_error_m = lll[3]\n\t\t\t\t\t@flux_ul = lll[4];\n\t\t\t\t\t@exposure = lll[5]\n\t\t\t\tend\n\t\t\t\tif index2.to_i == 21\n\t\t\t\t\t@sicalc = lll[0]\n\t\t\t\t\t@sicalc_error = lll[1]\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif index2.to_i == 22\n\t\t\t\t\t@fit_cts = lll[0]\n\t\t\t\t\t@fit_fcn0 = lll[1]\n\t\t\t\t\t@fit_fcn1 = lll[2]\n\t\t\t\t\t@fit_edm0 = lll[3]\n\t\t\t\t\t@fit_edm1 = lll[4]\n\t\t\t\t\t@fit_iter0 = lll[5]\n\t\t\t\t\t@fit_iter1 = lll[6]\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif index2.to_i == 23\n\t\t\t\t\t@galcoeff = lll[0]\n\t\t\t\t\t@galcoeff_err = lll[1]\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif index2.to_i == 24\n\t\t\t\t\t@galcoeffzero = lll[0]\n\t\t\t\t\t@galcoeffzero_err = lll[1]\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif index2.to_i == 25\n\t\t\t\t\t@isocoeff = lll[0]\n\t\t\t\t\t@isocoeff_err = lll[1]\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif index2.to_i == 26\n\t\t\t\t\t@isocoeffzero = lll[0]\n\t\t\t\t\t@isocoeffzero_err = lll[1]\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif index2.to_i == 27\n\t\t\t\t\t@tstart = lll[0]\n\t\t\t\t\t@tstop = lll[1]\n\t\t\t\t\t\n\t\t\t\t\t@timestart_utc = @tstart\n\t\t\t\t\t@timestop_utc = @tstop\n\t\t\t\t\t@timestart_tt = datautils.time_utc_to_tt(@tstart);\n\t\t\t\t\t@timestop_tt = datautils.time_utc_to_tt(@tstop);\n\t\t\t\t\t@timestart_mjd = datautils.time_tt_to_mjd(@timestart_tt);\n\t\t\t\t\t@timestop_mjd = datautils.time_tt_to_mjd(@timestop_tt);\n\t\t\t\t\t\n\t\t\t\t\t#calcolo fase orbitale\n\t\t\t\t\t@orbitalphase = -1;\n\t\t\t\t\tif(@calcorbitalphase_period.to_f != 0)\n\t\t\t\t\t\ttimemjd = @timestart_mjd.to_f + (@timestop_mjd.to_f-@timestart_mjd.to_f)\n\t\t\t\t\t\t@orbitalphase = (timemjd.to_f - @calcorbitalphase_t0.to_f) / @calcorbitalphase_period.to_f;\n\t\t\t\t\t\t@orbitalphase = @orbitalphase.to_f - @orbitalphase.to_i;\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tif index2.to_i == 28\n\t\t\t\t\t@energyrange = lll[0]\n\t\t\t\t\t@fovrange = lll[1]\n\t\t\t\t\t@albedo = lll[2]\n\t\t\t\t\t@binsize = lll[3] \n\t\t\t\t\t@expstep = lll[4] \n\t\t\t\t\t@phasecode = lll[5] \n\t\t\t\tend\n\t\t\tend\n\n\tend", "def read(path)\n entries[self.class.path(path)]\n end", "def path\n @data[\"path\"].to_s\n end", "def payload_example(sample_name)\n payload_examples_path.join(sample_name).read\n end", "def read_src name\n IO.readlines('../src/' + name).collect{|c| \"\\t\" + c}\nend", "def analyzeDemandLog()\n demandLogFile = @basePath + \".demandLog.json\" ;\n com = \"../Savs/analyzeDemandLog #{demandLogFile}\" ;\n p [:com, com] ;\n jsonStr = `#{com}` ;\n @demandStat = JSON.load(jsonStr) ;\n return @demandStat ;\n end", "def path\n 'soccerdata'\n end", "def mock_data\n\t\tputs \"Failsafe. Using mock data as no data is provided or the file path is not a complete file path or file does not exist\"\n\t\tdata = File.open(\"./conference/data/problem_data.txt\",\"r+\") do |f|\n\t\t\tf.read\n\t\tend \n\t\treturn data\n\tend", "def sample_data(file_name)\n file = File.expand_path(File.dirname(\"spec/assets/*\")) + \"/#{file_name}\"\n File.read(file)\nend", "def read\n \n end", "def data_path(path)\n return File.expand_path(File.join(@@config['dataPath'], path))\n end", "def read_machine_folder\n end", "def generate_summary_page(path, p)\n b = File.basename(path, '.tsv')\n table = '<table class=\"table table-hover table-responsive\">'\n File.open(path, 'r') do |fh|\n fh.each do |ln|\n r = ln.chomp.split(\"\\t\")\n if $. == 1\n table += '<thead><tr>' +\n r.map { |i| \"<th scope=col>#{format_name(i)}</th>\" }.join(' ') +\n '</tr></thead><tbody>'\n else\n table += \"<tr><th scope=row>#{r.shift}</th>\" +\n r.map { |i| \"<td>#{i}</td>\" }.join(' ') + \"</tr>\"\n end\n end\n end\n table += '</tbody></table>'\n write_file(p, \"s-#{b}.html\") do\n build_from_template(\n 'summary.html', file: \"#{b}.tsv\", name: format_name(b), table: table\n )\n end\n end", "def find_data(path, type: nil)\n if @data_dir\n full_path = ::File.join(@data_dir, path)\n case type\n when :file\n return full_path if ::File.file?(full_path)\n when :directory\n return full_path if ::File.directory?(full_path)\n else\n return full_path if ::File.readable?(full_path)\n end\n end\n parent&.find_data(path, type: type)\n end", "def summary\n description_section.first\n end", "def read(files); end", "def read(files); end", "def file_contents(full_path)\n\t\t::File.read(full_path)\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, full_path\n\tend", "def file_contents(full_path)\n\t\t::File.read(full_path)\n\trescue Errno::ENOENT\n\t\traise Rush::DoesNotExist, full_path\n\tend", "def read_contents\n\n #puts \"pofr file #{@file_blob.filename}\"\n\n file_lines=[]\n @file_blob.open do |file|\n File.open(file){|x| file_lines = x.readlines}\n puts file_lines[0]\n puts file_lines.last\n end\n\n if @file_blob.filename.extension == \"out\" # GNOM\n getDataLinesFromGnom(file_lines)\n elsif @file_blob.filename.extension == \"dat\" # scatter\n puts \"reading file @file #{@file_blob.filename}\"\n getDataLinesFromScatter(file_lines)\n end\n\n @dmax = @r_values.last\n @pr_values.each do |y|\n @pr_max = (y[1] > @pr_max) ? y[1] : @pr_max\n @pr_min = (y[1] < @pr_min) ? y[1] : @pr_min\n end\n\n end", "def read_file(path)\n File.read(path)\n end" ]
[ "0.6683467", "0.6334066", "0.6097599", "0.60357463", "0.5965562", "0.5940172", "0.5874988", "0.5801263", "0.57817864", "0.57148975", "0.56931293", "0.56931293", "0.56892806", "0.56694525", "0.5619701", "0.56122977", "0.55611265", "0.5526575", "0.54714274", "0.5470373", "0.5445007", "0.5386634", "0.5380586", "0.53393245", "0.5338387", "0.5338387", "0.5328031", "0.5302912", "0.52476907", "0.5232541", "0.5227083", "0.5208377", "0.5197187", "0.51817775", "0.5179047", "0.51757866", "0.5147225", "0.51465315", "0.5134125", "0.5134125", "0.5134125", "0.5134125", "0.5132387", "0.512814", "0.5127126", "0.5122977", "0.51095736", "0.51090735", "0.50977254", "0.50899595", "0.50818866", "0.5080993", "0.50583774", "0.50545824", "0.5054064", "0.50471205", "0.50448793", "0.5035797", "0.5035244", "0.50311047", "0.50272304", "0.50217324", "0.5020261", "0.5013699", "0.50080264", "0.500679", "0.49985301", "0.4989999", "0.49887854", "0.49759948", "0.49758595", "0.4974886", "0.49684817", "0.49651015", "0.4963354", "0.49592906", "0.49565703", "0.49443394", "0.49368474", "0.4934398", "0.4933275", "0.49303177", "0.49287447", "0.4927967", "0.49254164", "0.49118617", "0.4909409", "0.4905981", "0.4903598", "0.49028292", "0.49015224", "0.48956454", "0.48869172", "0.48865286", "0.48814148", "0.48814148", "0.48749128", "0.48749128", "0.48692104", "0.48655173" ]
0.5781134
9
A function to read data Arg: fname: file name (text file) The format is like this id | name | title | reference | slide Define Read data
def read_data(fname) ents=[] if ( File.exist?(fname) ) File.open(fname,'r') do |f| f.each_line do |line| line.chomp! a1,a2,a3,a4,a5,a6 = line.split(/\s*==\s*/) hash={} hash["1"] = a1 hash["2"] = a2 hash["3"] = a3 hash["4"] = a4 hash["5"] = a5 hash["6"] = a6 ents.push(hash) end end end ents end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_file(filename); end", "def read_data_file(path); end", "def readFile()\n\t#This is assuming the file name will be used\n\tfilename = 'names-data.txt'\n\topen(filename, 'r') {|f| f.read}\nend", "def my_file_reader(fname)\n fstream = File.open(fname, 'r')\n data = fstream.read\n fstream.close\n \n return data\nend", "def data name\n File.read data_path(name)\nend", "def read_text(filename); end", "def read_file(file, context); end", "def read(*args, **kwd); end", "def read_feature_by_path(feature_file_name)\n file = File.open(feature_file_name)\n file_data = file.read\n file_data\nend", "def read(files); end", "def read(files); end", "def readFile(fname)\n\tinf = File.new(fname, \"r\")\n\tret = inf.read()\n\tinf.close\n\treturn ret\nend", "def readfile\n features=[]\n feature=''\n data_range=''\n price=''\n \n File.open(\"./public/test.txt\", \"r\").each_line do |line|\n feature = line.scan(/([a-zA-z ]+ \\– [0-9]+)/).to_s.strip()\n date_range= line.scan(/([0-9\\/]+ \\– [0-9]+\\/[0-9]+)/).to_s\n price = line.scan(/( [0-9]+\\.[0-9]+)/).to_s.strip()\n this_feature={\n \"feature\" => feature,\n \"date_range\" => date_range,\n \"price\" => price\n \n }\n features << this_feature\n \n \n end\n\n return features\n end", "def read_file(filename)\n file = File.open(filename, 'r')\n data = file.read\n file.close\n data\nend", "def read_file(file_name)\n file = File.open(file_name, \"r\")\n data = file.read\n file.close\n return data\nend", "def get_data filename=nil\n unless filename\n filename = $filename\n else\n $filename = filename\n end\n raise \"File name not found #{filename} in get_data \" if !File.exists?(filename)\n #lines = File.open(filename, \"r\").read.split(\"\\n\")\n #if lines.nil? or lines.empty?\n #perror \"Failed trying to read #{filename}. Please delete if empty \"\n #lines = [\"no data\", \"no data, please refresh\"]\n #end\n obj = YAML::load( File.open( filename ) )\n $yaml_obj = obj\n age = compute_file_age filename\n articles = obj[:articles]\n if articles.empty?\n # this happens when doing More with a stale url\n perror \"No articles in this file. Please delete file.\"\n return\n end\n colh = articles.first.keys\n colh = [:title\t,:age_text\t,:comment_count\t,:points\t,:article_url\t,:comments_url\t,:age\t,:submitter\t,:submitter_url\t,:byline]\n $forum_bgcolor = BOLD\n $forum_bgcolor = ON_RED if age > 8\n # this should only happen if columns are in row 0\n # # FIXME\n $column_headings = colh\n $full_data = Array.new\n # there will be a path also at some time\n #$subforum = filename.sub(File.extname(filename),\"\").sub(\"__\",\"/\")\n $subforum = file_to_forum(filename)\n $host = forum_to_host $subforum\n titles = Array.new\n articles.each do |a|\n titles << a[:title]\n _cols = []\n $column_headings.each do |c|\n _cols << a[c] \n end\n $full_data << _cols\n end\n perror \"No data for #{filename} \" if $full_data.empty?\n raise \"No data for #{filename} \" if $full_data.empty?\n #lines.each_with_index do |l, ix|\n #_cols = l.split(\"\\t\")\n #titles << _cols.first\n #$full_data << _cols\n #end\n calc_column_widths\n size_column_headings\n $files = titles\nend", "def read_cmd(tablename, fname)\n #puts \"reading \" + fname\n @datafiles[tablename] = DataFile.new fname\n end", "def read file\n File.open file\n end", "def read_data(file_name)\n file = File.open(file_name,\"r\")\n object = eval(file.gets)\n file.close()\n return object\nend", "def read\n\t\t@file_content = File.open(\"/home/calin/football/football.dat\",\"r\")\n\tend", "def read_feeds(fname)\r\n File.foreach(fname) {|line| process_feed(line.split(',')[0], line.split(',')[1], line.split(',')[2], line.split(',')[3])}\r\n end", "def read\n return nil if FileTest.exist?(@fname)==false\n\n open(@fname,\"rb\") do |file| #Read & Binary mode\n @data = Marshal.load(file)\n end\n @data\n end", "def read_save_data(file)\r\n read_characters(file)\r\n read_frame(file)\r\n read_data(file)\r\n read_edit\r\n read_refresh\r\n end", "def get_data(arg)\n dir_to_data = Dir.pwd + '/features/support'\n data = YAML.load_file(\"#{dir_to_data}/data_list.yml\")\n data['DataSet'][\"#{arg}\"]\nend", "def read\n @fileobj = File.open(@fname,\"r\")\n parse_header_line(@fileobj.readline) unless @fileobj.eof?\n\n while (!@fileobj.eof?)\n yield(parse_data_line(@fileobj.readline))\n end\n end", "def read id, &block\n fn = _data_path(id)\n if block_given?\n File.open(fn, 'r', &block)\n else\n File.read(fn)\n end\n end", "def read_contents\n\n #puts \"pofr file #{@file_blob.filename}\"\n\n file_lines=[]\n @file_blob.open do |file|\n File.open(file){|x| file_lines = x.readlines}\n puts file_lines[0]\n puts file_lines.last\n end\n\n if @file_blob.filename.extension == \"out\" # GNOM\n getDataLinesFromGnom(file_lines)\n elsif @file_blob.filename.extension == \"dat\" # scatter\n puts \"reading file @file #{@file_blob.filename}\"\n getDataLinesFromScatter(file_lines)\n end\n\n @dmax = @r_values.last\n @pr_values.each do |y|\n @pr_max = (y[1] > @pr_max) ? y[1] : @pr_max\n @pr_min = (y[1] < @pr_min) ? y[1] : @pr_min\n end\n\n end", "def read filename\n # Open file, Read in and process data.\n file = File.open(filename)\n file.each do |line|\n # Comma seperated data.\n # E.g. 1,2,1 => x=1, y=2, output=1\n line = line.chomp\n if line.size > 0\n # If the line is not empty, then it has data\n line = line.split \",\"\n @x << line[0].to_i\n @y << line[1].to_i\n @output << line[2].to_i\n end\n end\n end", "def read_todos(filename)\n File.readlines(filename)\nend", "def read\n x = nil\n File.open(@filename, 'r') {|f| x = f.readlines }\n x.each do |line|\n\n line = self.class.remove_comments(line)\n\n if line.present?\n @data << self.class.extract_data_from_line(line)\n # puts self.class.extract_data_from_line(line).to_yaml\n end\n end\n end", "def read_data(filename)\n data = File.readlines(filename).map{|line| line.chomp.split(\"\\t\"). map{|field| field == \"\" ? nil : field}}\n data.map do |line|\n {:district => line[0], :name => line[1], :sponsorship => line[2], :phone1 => line[3], :phone2 => line[4], :email => line[5]}\n end\nend", "def read(*args)\n #This is a stub, used for indexing\n end", "def read_slide(fname)\n hash={}\n File.open(fname,'r') do |f|\n f.each_line do |line|\n line.chomp!\n a1,a2 = line.split(/\\s*==\\s*/)\n hash[a1] = a2 # a1:id, a2:path\n end\n end\n hash\nend", "def load(fldDefs, filename)\r\n input = File.new(filename)\r\n doc = Document.new(input)\r\n root = doc.root\r\n input.close\r\n\r\n transCase = self.new(fldDefs)\r\n transCase.name = root.attribute('name').value if root.attributes.has_key? 'name'\r\n transCase.desc = root.attribute('desc').value if root.attributes.has_key? 'desc'\r\n if root.attributes.has_key? 'card_index'\r\n transCase.cardIndex = root.attribute('card_index').value.to_i\r\n end\r\n if root.attributes.has_key? 'acquirer_index'\r\n transCase.acquirerIndex = root.attribute('acquirer_index').value.to_i\r\n end\r\n\r\n root.elements.each(\"action\") do |elm|\r\n transCase.actions << loadAction(transCase, elm)\r\n end\r\n\r\n transCase\r\n end", "def read_file(file)\n File.read(file)\nend", "def fetch_data(user)\n array = read_from_file(\"userdata/#{user}.txt\")\n array[0]\nend", "def read_data(file_name)\n file = File.open(file_name,\"r\")\n object = eval(file.gets.untaint.encode('UTF-8', :invalid => :replace, :replace => '').gsub('\\n', \"\"))\n file.close()\n return object\nend", "def readData(filename)\n\t\t@dataArray = Array.new\n\t\tfile = File.open(filename)\n\t\t\n\t\tfile.each_line do |line|\n\t\t\tarray = line.split(/,/)\n\t\t\tentry = Struct::ContactEntry.new(array[0], array[1], array[2])\n\t\t\t@dataArray.push(entry)\n\t\tend\n\t\n\t\tfile.close\n\t\t\n\tend", "def load(filename)\n # Note: Must get a first name and last name\n # Note: Phone should be formatted (###) ###-####\n # Note: Assume you'll always have a valid id\n # Return true \n raise \"Not implemented\"\n end", "def read_file(seq_fn = \"seq.txt\", prob_fn = \"hmm.txt\")\n\t\n\t# Reads Sequence of Observations from File\n\tif !File.exists?(seq_fn)\n\t\tseq_fn = \"seq.txt\"\n\t\tif !File.exists?(seq_fn)\n\t\t\tprint \"File does not exist.\"\n\t\t\treturn\t\t\t\n\t\tend\n\tend\n\n\tprint \"\\n\\nReading file \"\n\tprint seq_fn\n\tprint \"\\n\"\n\n\tifile = File.new(seq_fn, \"r\")\n\twhile (line = ifile.gets)\n\t\tif (line.to_i.to_s == line)\n\t\t\t# Converting the line into an array.\n\t\t\tprint \"Observations: \"\n\t\t\tprint line\n\t\t\t@observations = line.chars.map(&:to_i)\n\t\t\tbreak\n\t\tend\n\tend\n\tifile.close\n\n\t# Reads Transition and Sensory Probabilites from a file\n\tif !File.exists?(prob_fn)\n\t\tprob_fn = \"hmm.txt\"\n\t\tif !File.exists?(prob_fn)\n\t\t\tprint \"File does not exist.\"\n\t\t\treturn\t\t\t\n\t\tend\n\tend\n\n\tprint \"\\n\\nReading file \"\n\tprint prob_fn\n\tprint \"\\n\"\n\n\t# Open the file. Read only.\n\tifile = File.new(prob_fn, \"r\")\n\t@b_b = ifile.gets.to_f\n\t@l_b = ifile.gets.to_f\n\t@b_l = ifile.gets.to_f\n\t@l_l = ifile.gets.to_f\n\t@h_b = ifile.gets.to_f\n\t@t_b = ifile.gets.to_f\n\t@h_l = ifile.gets.to_f\n\t@t_l = ifile.gets.to_f\n\tifile.close\nend", "def read_file filename\n\t\tbegin\t \n\t\t\tfile = File.new(filename, \"r\")\n\t\t\tline_number = 1\n\t\t file.each do |line|\t\t \t\n\t\t \tself.read_input_line line, line_number\n\t\t \tline_number += 1\n\t\t end\t \n\t\trescue => err\n\t\t puts \"File not loaded: #{err}\"\n\t\t err\n\t\tensure file.close if file end\n\tend", "def read(path); end", "def read\n file\n end", "def readfile filename\n if filename.index(\".json\")\n require 'json'\n str = File.read(filename)\n hash = JSON.parse(str)\n elsif filename.index \".yml\"\n require 'yaml'\n hash = YAML::load( File.open( filename ) )\n else\n $stderr.puts color(\"#{$0}: Don't know how to handle #{filename}, pass either .json or .yml\", \"red\")\n exit 1\n end\n puts \"==> readfile: imdbid=\" + hash[\"imdbID\"] if $opt_verbose\n return hash\nend", "def parse_input (input_file)\nend", "def get_file()\n puts(\"Please enter a file path: \")\n for arg in ARGV\n \tname = arg\n end\n print meta_data(name)\n name\nend", "def load_data(filename=nil)\n filename=data_file(filename)\n return unless File.exist?(filename)\n case File.extname(filename).downcase\n when \".yaml\",\".yml\"\n YAML.load(File.open(filename))\n when \".json\"\n JSON.parse(File.read(filename))\n else\n File.read(filename)\n end\n end", "def parse_file(filename); end", "def readParams(fname)\n begin\n f = File.open(fname)\n rescue Exception => e\n puts e\n $stdout.flush\n exit(1)\n end\n\n section = nil\n f.each_line{|line|\n\n line.chomp!\n line.strip!\n if line == \"\" || line =~ /^%/\n # skip blank lines & lines beginning with %\n\n elsif line == $headerPorts || line == $headerShips ||\n line == $headerTraveler || line == $headerOutput\n section = line\n\n elsif section == $headerPorts\n parts = line.split(' ')\n name = parts[0]\n size = parts[1].to_i\n $starport.push(Starport.new(name,size))\n \n elsif section == $headerShips\n parts = line.split(' ')\n name = parts[0]\n size = parts[1].to_i\n $starship.push(Starship.new(name,size))\n\n elsif section == $headerTraveler\n parts = line.split(' ')\n name = parts.shift\n itinerary = []\n parts.each { |p| itinerary.push(find_name($starport,p)) }\n person = Traveler.new(name,itinerary)\n $traveler.push(person)\n find_name($starport,parts.first).arrive(person)\n\n elsif section == $headerOutput\n $simOut.push(line)\n\n else\n puts \"ERROR: simFile format error at #{line}\"\n $stdout.flush\n exit(1)\n end\n }\nend", "def read_generic_file(file)\n TagLib::FileRef.open(file) do |fileref|\n tag = fileref.tag\n \n # Read basic attributes\n puts 'title: ' + tag.title.to_s #=> \"Wake Up\"\n puts 'artist: ' + tag.artist.to_s #=> \"Arcade Fire\"\n puts 'albulm: ' + tag.album.to_s #=> \"Funeral\"\n puts 'year: ' + tag.year.to_s #=> 2004\n puts 'track ' + tag.track.to_s #=> 7\n puts 'genre ' + tag.genre.to_s #=> \"Indie Rock\"\n puts 'comment ' +tag.comment.to_s #=> nil\n \n properties = fileref.audio_properties\n puts 'prop.length ' + properties.length.to_s #=> 335 (song length in seconds)\n end\n end", "def show\r\n @feature = Feature.find(params[:id])\r\n # @content = File.readlines(@feature.name).each {|line| line.rstrip!<<'<br/>'}\r\n @content= File.read(@feature.name)\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @feature }\r\n end\r\n end", "def LoadFile ()\n\t\n\tinput = \"\"\n\tFile.foreach(\"../Data Files/042-Words.txt\") {|x| input = x }\n\tnames = input.split(\",\")\n\t\n\treturn names;\nend", "def read_multi(*names); end", "def read_file(fname=nil)\n return if fname.nil?\n # Array we use to store entries\n lines = Array.new\n ah_data = Array.new\n # Deal with DOS line endings by reading in file, then manually splitting on DOS line ending\n File.open(fname).each_line do |line|\n lines = line.split(/\\r\\n?/).map(&:chomp)\n end\n return lines\nend", "def read\n @input_files.each do |file|\n if File.exist? file\n input_data[file] = File.read(file)\n end\n end\n nil\n end", "def read_file(absolute_path); end", "def load_file(f)\n\t\tdata = []\n f.each do |line| \n user_id, movie_id, rating, timestamp = line.split(\"\\t\")\n data.push({\"user_id\"=> user_id.to_i, \"movie_id\"=>movie_id.to_i,\"rating\"=> rating.to_i,\"timestamp\"=>timestamp.to_i})\n\t\tend\n\t\treturn data\n\tend", "def read_file\n if @file_lines.empty?\n @file = File.open(@population_file)\n @file_lines = @file.readlines()\n end\n end", "def require_data(*file); end", "def require_data(*file); end", "def load_file(filename); end", "def load_file(filename); end", "def read_file\n \t@readin = []\n file = File.open(@filename[@file_count], 'r')\n\t @readin = file.each.to_a\n\t # chop off the escaped characters (in this case: \\r\\n)\n @readin.map! {|s| s.chomp}\n # increment the file count\n @file_count += 1\n file.close\n # determine which file was read in\n # the files either have a \"W\" (for power) or \"Wh\" as the first line\n \tif @readin[0] =~ /Wh/\n \t\tparse_energy\n \telse @readin[0] =~ /W/\n \t\tparse_power\n \tend\n end", "def read_by_filename(filename)\n result = find_by_filename(filename)\n \n if result.count > 1\n result.map! { |r| read(r['_id']) }\n else\n result.blank? ? [] : [read(result.first['_id'])]\n end\n end", "def load_data(file_name)\n\t\tindata = []\n\t\t#csv reader as shown in class; typecasted because I ran into some weird bugs\n\t\tCSV.foreach(\"#{file_name}\", col_sep: \"\\t\") do |row| \n\t\t\tindata.push({\"user_id\"=>row[0].to_i, \"movie_id\"=>row[1].to_i, \"rating\" => row[2].to_i, \"timestamp\" => row[3].to_i})\n\t\tend\n\t\treturn indata\n\tend", "def reader; end", "def parse_file\n @file ||= File.open(@file_name) unless @file_name.nil?\n @text = @file.readlines\n @file.close unless @file.nil?\n parse_text\n end", "def readlines(*args, **kwd); end", "def openFile(folder, arquive)\n file = File.open(folder+\"/\"+arquive+\".txt\",\"r\")\n @dataLines=file.read\n file.close\n @vectorLines = split_input(@dataLines, \"\\n\")\n end", "def read(*rest) end", "def read(*rest) end", "def read\n $t1 = Time.now # Init procedure timestamp\n person = []\n IO.foreach(\"data_500.txt\") do |line| # Get all patients from file iterate each line\n line.chomp! # Remove trailing whitespace.\n person.push(line.split(\":\")) # Saving data split :\n end\n group(person) # Get blood type\n end", "def read_input_file\n\t\tbegin \n\t\t\tfile = File.read('data.json')\n\t\t\tjson_info = JSON.parse(file)\n\t\t\t\n\t\t\t#getting cars and rentals information\n\t\t\t@cars = json_info[\"cars\"]\n\t\t\t@rentals = json_info[\"rentals\"]\n\t\trescue Exception => e \n\t\t\tputs \"Error trying to read the input file!\" \n\t\t\tputs e.message\n\t\tend\n\tend", "def loadStructure(file)\n csv_text = File.read(file)\n return CSV.parse(csv_text, :headers => true)\n \nend", "def read\n \n end", "def load_info\n info = File.readlines @dir+\"info\"\n @last_quantity = info[0].chop\n @last_category = info[1].chop.to_i\n @exercises = info[2].chop.split(\",\")\n @last_repq = info[3].chop\n @rep_ex = info[4].chop\n end", "def read_input_file\n gridfile_name = ARGV[0]\n # puts gridfile_name\n grid_data = File.read(gridfile_name).split\nend", "def read\n status = 200\n\n # File path\n fpath = filepathById params[:id]\n\n if nil == fpath\n # File description does not exists\n result = {status: 'error', message: 'Bad request'}\n status = 400\n elsif File.exists? fpath\n result = {content: File.read(fpath)}\n else\n result = {content: ''}\n end\n render json: result.to_json, status: status\n end", "def read_track a_file\n track_title = a_file.gets()\n track_location = a_file.gets()\n track = Track.new(track_title, track_location)\n track\nend", "def read_instance(filename)\n File.open(filename) do | f |\n read_ukp_instance(f)\n end\nend", "def load_info\n info = File.readlines @dir+\"info\"\n @last_learnq = info[0].to_i\n @last_repq = info[1].to_i\n @last_exerq = info[2].to_i\n @last_category = info[3].to_i\n @exercises = info[4].split(\",\").collect! {|v| v.to_i}\n @rep_ex = info[4].to_i\n end", "def read(*args)\n file.try(:read, *args)\n end", "def open_data(file)\n @data = JSON.parse(IO.readlines(file).join)\n end", "def get_file_data(options={})\n options={ file_type: :testflow \n }.merge(options)\n fp = FileParser.new\n fp.open(filename: @filename)\n if options[:file_type] == :testflow\n @testflow_lines = fp.readlines\n elsif options[:file_type] == :limits\n @limits_lines = fp.readlines\n else\n fail \"Invalid type '#{options[:type]}' passed to 'get_file_data'!\"\n end\n fp.close()\nend", "def read(*args) IO.read(path, *args) end", "def read\n file.read\n end", "def read_input_file\n gridfile_name = ARGV[0]\n puts gridfile_name\n grid_data = File.read(gridfile_name).split\nend", "def read\nend", "def read ( file, trace_dir )\n extension = File.extname(file)\n case extension\n when '.csv' then read_csv(file)\n when '.bag' then read_bag(file,trace_dir)\n else abort(\"file extension #{extension} not supported\")\n end\nend", "def parse_input(input_file); end", "def parse_input(input_file); end", "def read_data_from_file(filename=nil)\n filename = default_data_filename if filename.nil?\n @raw_data = File.read(filename)\n end", "def read_summary(fname)\n hash={}\n # Read file\n File.open(fname,'r') do |f|\n # Loop over line\n f.each_line do |line|\n line.chomp!\n index,content = line.split(/\\s*==\\s*/)\n hash[index] = content # index:id, content:path\n end\n end\n return hash\nend", "def initialize(filename)\n @name = ''\n @desc = ''\n @diagram = ''\n \n file = File.open(filename)\n \n while(line = file.gets)\n line.chomp!\n if(line == 'NAME')\n @name = file.gets.chomp!\n elsif(line == 'DESC')\n while((line = file.gets) && line != \"END\\n\")\n @desc += line\n end\n elsif(line == 'DIAGRAM')\n while((line = file.gets) && line != \"END\\n\")\n @diagram += line\n end \n end\n end\n file.close()\n end", "def read_data(file_name)\r\n file = File.open(file_name,\"r\")\r\n object = eval(file.gets.untaint.encode('UTF-8', :invalid => :replace))\r\n file.close()\r\n return object\r\nend", "def read_data(filename)\n count = 0\n fd = File.open(filename)\n while not fd.eof?\n line = fd.readline\n line.chomp!\n count += 1\n fields = []\n line.split('^').each do |f|\n datum = f.gsub('~~','').gsub(/^~/,'').gsub(/~$/,'')\n fields.push(datum.empty? ? nil : datum)\n end\n yield fields\n end\nrescue => e\n STDERR.puts \"error '#{e}' file '#{filename}' line #{count}\"\n exit\nensure\n fd.close\nend", "def read(id)\n File.read(find(id))\n end", "def load_sample_data\n\tbegin # try to load the file\n\t\t# open the file and create an array to hold it\n\t\tsample_data_file = File.open($sample_data_filename)\n\t\tsample_contents = Array.new{Array.new}\n\t\ti = 0\n\t\t# add the contents of the file to the two-dimensional array\n\t\tsample_data_file.each do |line|\n\t\t\tsample_contents[i] = line.split(\",\").map(&:strip)\n\t\t\ti += 1\n\t\tend\n\t\treturn sample_contents\n\trescue # catch exceptions\n\t\tabort \"Unable to continue - sample data file #{$sample_data_filename} not found.\"\n\tend\nend", "def working_read(filename)\n data = @file_opener.open(filename, \"r\") {|f| f.read }\n data = @filters[\"encode\"].call(filename, data) if @filters[\"encode\"]\n data\n end", "def read_album\n\n # You could use get_integer_range below to get a genre.\n # You only the need validation if reading from the terminal\n # (i.e when using a file later, you can assume the data in\n # the file is correct)\n\n # insert lines here - use read_integer_in_range to get a genre\n album_title = read_string(\"Album Title: \")\n album_artist = read_string(\"Album Artist: \")\n album_genre = read_integer_in_range(\"Album ID: \",1,4)\n album = Album.new(album_title, album_artist, album_genre)\nend" ]
[ "0.6743158", "0.66980904", "0.6688931", "0.6547904", "0.6420694", "0.623779", "0.6237525", "0.6228019", "0.61477125", "0.6127539", "0.6127539", "0.6085452", "0.60843104", "0.6037993", "0.60239553", "0.5988194", "0.5975208", "0.5961383", "0.59195316", "0.5913285", "0.59058404", "0.5893301", "0.5854525", "0.5853428", "0.58503085", "0.58259594", "0.580133", "0.5783412", "0.5760138", "0.57471955", "0.5743057", "0.57419896", "0.57281965", "0.57228565", "0.5718333", "0.57120955", "0.5708212", "0.57076013", "0.5705192", "0.56789976", "0.5677081", "0.5672721", "0.5666398", "0.5661564", "0.565547", "0.5654234", "0.5652009", "0.56411386", "0.56251496", "0.56250066", "0.56156516", "0.56142193", "0.5611301", "0.56037974", "0.5586198", "0.55699116", "0.55671453", "0.5558304", "0.5548316", "0.5548316", "0.5547027", "0.5547027", "0.5546514", "0.55360645", "0.5534879", "0.5534267", "0.55331", "0.55269706", "0.55236024", "0.5522688", "0.5522688", "0.5515721", "0.55071265", "0.5503613", "0.5501965", "0.54976094", "0.548556", "0.54825", "0.5478556", "0.5461052", "0.5460618", "0.54541963", "0.5445396", "0.5443023", "0.54369164", "0.543479", "0.5423728", "0.5417118", "0.54149836", "0.5412868", "0.5412868", "0.54124624", "0.5406076", "0.54025054", "0.5402029", "0.5399211", "0.5396171", "0.53956985", "0.5391693", "0.5383497" ]
0.5424846
86
A function to read schedule .txt
def read_schedule2(fname) ents=[] File.open(fname,'r') do |f| f.each_line do |line| line.chomp! a1,a2,a3,a4 = line.split(/\s*==\s*/) hash={} hash["1"] = a1 hash["2"] = a2 hash["3"] = a3 hash["4"] = a4 ents.push(hash) end end ents end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_schedule\n schedule = {}\n File.open(SCHEDULE_FILE, 'r') do |f|\n f.each_line do |line|\n m = /^(\\d+)\\s+(\\S+)/.match(line)\n next if m.nil?\n week = m[1]\n server = m[2]\n schedule[server] = week.to_i\n end\n end\n\n schedule\n end", "def load_schedule_file(schedule)\n raw_data = CSV.table(schedule.externalFile.filePath.to_s)\n # Indexing starts at 1\n column = schedule.columnNumber - 1\n rows_to_skip = schedule.rowstoSkipatTop\n\n num_values = \\\n schedule.numberofHoursofData.get * 60 / schedule.minutesperItem.get.to_i\n occupancy = OpenStudio::Vector.new(num_values)\n\n raw_data.each_with_index do |row, i|\n next if i < rows_to_skip\n occupancy[i] = row[column]\n end\n return occupancy\n end", "def read_taskwarrior_file(file)\n tasks = []\n open(file).each_line do |l|\n l = l.encode('UTF-8', :invalid => :replace, :undef => :replace, :replace => 'X')\n t = l.scan( /\\w+:\".+?\"/ ).collect{|i| \n k, v = i.split(':', 2)\n [k.to_sym, v.gsub(/\\A\"|\"\\Z/,'')] \n } \n t = Hash[t]\n t[:tags] = t[:tags].strip.split(\",\") if t[:tags]\n t[:entry] = t[:entry].to_i\n t[:end] = t[:end].to_i if t[:end]\n tasks << t\n end if File.file? file\n tasks\n end", "def load_period\n open('input.txt') do |file|\n dates = file.gets.split(/-/)\n Period.new(Date.parse(dates.first), Date.parse(dates.last))\n end\n end", "def read_from_file(filename) # Input existing file\n IO.readlines(filename).each do |line|\n status, *description = line.split(':')\n status = status.upcase.include?('X')\n add(Task.new(description.join(':').strip, status))\n puts line\n end # End of input, output\n end", "def processFile(file)\n lines = IO.readlines(file)\n lines.sort!\n\n shifts = Array.new\n newshift = false\n lines.each{ |line|\n nums = line.scan(/\\d+/)\n nums.map! {|n| n.to_i}\n year, month, day, hour, minute, guard = nums\n if guard \n shifts.push(Shift.new(guard))\n else\n if line =~ /wakes up/\n shifts.last.addWake(minute)\n elsif line =~ /asleep/\n shifts.last.addSleep(minute)\n end\n end \n }\n return shifts\nend", "def read_from_file(filename)\n\t\tIO.readlines(filename).each{ |line|\n\t\t\t*description, status = line.split(':')\n\t\t\tstatus = status.include?('X')\n\t\t\tadd(Task.new(description.join(':').strip, status))\n\t\t}\n\tend", "def init\n @by_day = {}\n if File.exist?('result.txt')\n File.readlines('result.txt').each do |line|\n a = line.chomp.split(\"\\t\")\n @by_day[a.first] = a\n end\n end \nend", "def read_tsp_file( file_name )\n file_path = File.join( TSP_DIR, \"#{file_name}.tsp\" )\n File.open( file_path ).read\nend", "def read_time_table(fname)\n ents=[]\n File.open(fname,'r') do |f|\n f.each_line do |line|\n line.chomp!\n a1,a2,a3,a4,a5 = line.split(/\\s*==\\s*/)\n hash={}\n hash[\"1\"] = a1 # id\n hash[\"2\"] = a2 # start time\n hash[\"3\"] = a3 # end time\n hash[\"4\"] = a4 # person\n hash[\"5\"] = a5 # title\n ents.push(hash)\n end\n end\n ents\nend", "def read_tasks\n JSON.parse(File.read(\"tasks.json\"))\nend", "def read_task_file\n File.read(file_path)\n end", "def read_from_file(filename = \"listsave\")\n\t\tIO.readlines(filename).each do |line|\n\t\t\tadd_task(Task.new(line.chomp))\n\t\tend\n\tend", "def parsef!(file: \"\")\n types = @type ? [@type] : VALID_TASKS\n\n File.open(file, \"r\") do |f|\n line_number = 1\n while line = f.gets\n types.each do |type|\n result = line.match(/#{Regexp.escape(type)}[\\s,:-]+(\\S.*)\\Z/) rescue nil\n\n unless result.nil?\n task = {\n file: file,\n line_number: line_number,\n task: result.to_a.last\n }\n\n @tasks[type.to_sym] << task\n end\n end\n\n line_number += 1\n end\n end\n end", "def read_file(uptime_file)\n raise('File doest not exist') unless File.exist? uptime_file\n\n File.read(uptime_file)\nend", "def read_input(path, options)\n config = YAML.load(File.read(File.expand_path(\"../employees.yml\", File.dirname(__FILE__))))\n\n parse_opts = {}\n parse_opts[:log] = $stderr if options[:verbose]\n parse_opts[:names] = NameCompleter.new(:full_names => config[\"employees\"], :aliases => config[\"aliases\"])\n\n File.open(path) do |f|\n Timesheets.parse_raw(f, parse_opts)\n end\nend", "def load_workouts(file)\n workout_num = 0\n exercise_num = 0\n workout_list = []\n \n File.foreach(file) { |line| \n if line =~ /^Start Time: (\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}).[0-9]* +|-\\d*$/ then\n workout_num += 1\n exercise_num = -1\n workout_list << Workout.new.start_time=($1)\n elsif line =~ /^\\s*Exercise name: (\\w*\\D+\\s*\\w*) Exercise Type: (\\w+)$/ then\n exercise_num += 1\n exercise = Exercise.new()\n exercise.exercise_name = $1\n exercise.exercise_type = $2\n workout_list[workout_num] << exercise\n end\n }\n \n workout_list #return created workoutlist \n end", "def read(owners)\n lines = []\n File.open(@file_name, \"a+\").read.each_line do |line|\n if TodoParser.is_task?(line)\n task = TodoParser.parse_one(line, owners)\n lines << { \"local\" => task }\n else\n lines << line\n end\n end\n lines\n end", "def load_timestamp(fname)\n stamps = []\n File.open(fname).read().each_line do |line|\n parsed = line.strip().split() \n stamps << [parsed[2].to_f, parsed[3].to_f, parsed[4].to_f, parsed[5].to_f, parsed[6].to_f]\n end\n return stamps\nend", "def index(file) \n\n file = File.open(file, \"r\")\n tasks = file.readlines\n file.close\n\n return tasks\n\nend", "def read_tasks(file)\n @session_tasks = []\n io.read_file(file).each_line do |line|\n @session_tasks << line.gsub(/\\n/,'') unless line.blank?\n end\n end", "def read_shift(single_line)\r\n#\treturn \"Wrong line\" unless single_line =~/^(\\d{2})\\/(\\d{2})\\/(\\d{4})/\r\n shift_date=single_line.split(',')[0].split[0]\r\n shift=single_line.split(',')[1]\r\n cg=shift.split(':')[0]\r\n shift_start=shift.split('-')[0].split(':')\r\n if shift =~ /(\\d{2})\\/(\\d{2})\\/(\\d{4})/ \r\n startTime=Time.strptime(shift_start[1]+\":\"+shift_start[2], ' %m/%d/%Y %I:%M %p')\r\n endTime=Time.strptime(shift.split('-')[1], ' %m/%d/%Y %I:%M %p')\r\n else\r\n startTime=Time.strptime(shift_date+shift_start[1]+\":\"+shift_start[2], ' %m/%d/%Y %I:%M %p')\r\n endTime=Time.strptime(shift_date+shift.split('-')[1], ' %m/%d/%Y %I:%M %p')\r\n end\r\n [shift_date, cg, startTime, endTime]\r\nend", "def parse_schedule(url)\n # Turn class schedule into an array of arrays.\n page = Nokogiri::HTML(open(url))\n schedule = page.search('table')[5]\n rows = schedule.search('tr')\n rows.map { |row| parse_row(row) }\nend", "def process_feed(fname, channel, offset, etype)\r\n p \"Channel: #{channel} | URL: #{fname}\"\r\n schedule = ICS::Event.file(open(fname)) rescue nil\r\n schedule.map {|cal| process_event(cal, channel, offset, etype) } if schedule\r\n end", "def read_arrival(upload)\n active_date = self.active_date.to_date\n ArrivalFlight.arrival_codeshare(active_date)\n ArrivalFlight.arrival_codeshare(active_date.tomorrow)\n path = File.join(\"public/system/dailyrosters/#{active_date.to_formatted_s(:number)}\", upload)\n File.open(path, 'r') {|f|\n lines = f.readlines(\"\\n\")\n lines.each do |line|\n a = line.split(%r{[|\\s]+})\n if (a.length > 5 && a[3].match(/VN.*/))\n route = Routing.find_or_create_by_routing(a[4], {:is_arrival => true, :destination => \"Sai Gon\"})\n if (route.destination == \"Sai Gon\")\n aircraft = get_aircraft(a[2])\n time_raw = a[5].split(':')\n if (!a[6].nil? && a[6] == 'ARRNEXTDAY')\n flight_date = active_date.advance(:days => 1)\n sta_time = Time.local(flight_date.year, flight_date.month, flight_date.day, time_raw[0], time_raw[1])\n else\n sta_time = Time.local(active_date.year, active_date.month, active_date.day, time_raw[0], time_raw[1])\n flight_date = active_date\n end\n flight = ArrivalFlight.find_or_initialize_by_flight_no_and_flight_date(a[3], flight_date)\n # flight.flight_no = flight_no(a[3], route, flight_date)\n if a[3] == \"VN\"\n flight.flight_no = 'YY' + (ArrivalFlight.max_flight_number(flight_date) + 1).to_s\n flight.remarks = \"Pls check flight no.\"\n else\n flight.flight_no = a[3]\n flight.remarks = a[6] if !a[6].blank?\n end\n flight.routing_id = route.id\n flight.reg_no = aircraft.reg_no\n flight.flight_date = flight_date\n flight.is_domestic = flight.update_is_domestic\n flight.sta = sta_time\n flight.is_active = true\n flight.is_approval = false\n begin\n flight.save!\n rescue ActiveRecord::StatementInvalid => e\n if flight.flight_no == \"VN\"\n flight.flight_no = 'YY' + (ArrivalFlight.max_flight_number(flight_date) + 1)\n flight.remarks += \"Pls check flight no.\"\n flight.save!\n end\n rescue ActiveRecord::RecordNotSaved => e\n flight.errors.full_messages\n end\n end\n end\n end\n }\n path\n end", "def parse_sifttter_file(filepath, date)\n title = File.basename(filepath).gsub(/^.*?\\/([^\\/]+)$/, \"\\\\1\") + \"\\n\"\n\n date_regex = /(?:#{ date.strftime(\"%B\") } 0?#{ date.strftime(\"%-d\") }, #{ date.strftime(\"%Y\") })/\n time_regex = /(?:\\d{1,2}:\\d{1,2}\\s?[AaPpMm]{2})/\n entry_regex = /@begin\\n@date\\s#{ date_regex }(?: at (#{ time_regex }?)\\n)?(.*?)\\n@end/m\n\n contents = File.read(filepath)\n cur_entries = contents.scan(entry_regex)\n unless cur_entries.empty?\n @entries.merge!(title => []) unless @entries.key?(title)\n cur_entries.each { |e| @entries[title] << [e[0], e[1].strip] }\n end\n end", "def read_txt\n # Open TXT file\n # f = File.open(self.fichero, \"r\")\n # Use TXT file content\n f = self.fichero\n # Loop thru open file lines\n f.each_line do |line|\n cod_reg = line[0,2]\n if cod_reg == '80'\n # Totals line\n amount = line[36,12]\n self.total_bills = line[22,6].to_i\n self.total_amount = (amount[0,10] + '.' + amount[10,2]).to_d\n elsif cod_reg == '02'\n # Header line\n pdate = line[36,6]\n self.nif = line[10,8]\n self.sufijo = line[18,3]\n self.process_date_time = Date.parse(pdate[4,2] + pdate[2,2] + pdate[0,2]) rescue Date.today\n elsif cod_reg == '01' || cod_reg == '90'\n # First or Last line\n else\n # Invoice charged line: Save in array\n amount = line[36,12]\n self.lista_cobros.push(bill_id: line[76,11].to_i,\n amount: (amount[0,10] + '.' + amount[10,2]).to_d,\n date: line[30,6],\n issuer: line[10,8],\n suffix: line[18,3],\n charge_code: line[21,1],\n charge_bank: line[22,4],\n charge_office: line[26,4],\n charge_id: line[48,6],\n iban_head: line[4,4],\n ccc_bank: line[54,4],\n ccc_office: line[58,4],\n ccc_dc: line[62,2],\n ccc_account_no: line[64,10],\n debit_code: line[74,1],\n cancel_code: line[75,1],\n reference: line[76,13])\n end\n end # f.each_line\n # f.close\n end", "def readerlistedplaces(thefilename)\n\tmoregoods = File.open(thefilename, \"r\")\n\twholeline = Array.new\n\n\tmoregoods.readlines.each do |line|\n\t\tline.chomp\n\t\twholeline << line.split(\",\") # Similar to readerevents, wholeline\n\t\t\t\t# is array of lines from txtfile.\n\tend\n\n\tj=0\n\twhile j < wholeline.size\n\t\twholeline[j].delete_at(0) # Deletes Events from array\n\t\tj+=1\n\tend\n\n\t# At this point the Times and IDs are isolated in two dimentional\n\t# wholeline array as [[Time1, ID1, Time2, ID2], [Time1, ID1, ...],...]\n\tarrayoftimes = Array.new\n\tarrayofids = Array.new\n\n\tfillarrayids = []\n\tfillarraytimes = []\n\n\twholeline.each do |stuff1| # wholeline is 2D array, stuff1 is \n\t\t\t\t\t\t# the way to get array within array\n\n\t\tstuff1.each_with_index do |stuffinarr, index| \n\n\t\t\tif index%2 == 0\n\t\t\t\tarrayofids << stuffinarr\n\t\t\tend\n\t\t\tif index%2 == 1\n\t\t\t\tarrayoftimes << stuffinarr\n\t\t\tend\n\n\t\tend\n\n\t\t# This loops through arrays within wholeline and every other spot\n\t\t# from wholeline is sent to two different arrays. \n\t\t# arrayofids will collect ids (cuz they are in every 2nd spot)\n\t\t# arrayoftimes collects times at every other spot\n\n\t\tfillarrayids.push arrayofids\n\t\tfillarraytimes.push arrayoftimes\n\n\t\t# fillarray's will take those arrayofids and times and push\n\t\t# those arrays as one spot inside fillarray, creating another \n\t\t# 2D array. ex: fillarrayids = [[arrayofids(first do loop)],\n\t\t# [arrayofids(second do loop)],...]\n\n\t\tarrayofids = []\n\t\tarrayoftimes = []\n\n\t\t# arrayofids is set to blank to be ready for next do loop\n\t\t# without this reset, fillarrays would include duplicates.\n\tend\n\n\t## Now that we got times seperated from IDS, we can NOW arrange times\n\t# from largest to smallest for the times.\n\t#\n\t# The below codage will arrange those times as such and also\n\t# rearranges the IDS in the same way so indexs still match.\n\tnewarrayoftimes = []\n\tnewarrayofids = []\n\ttoparrayoftimes = []\n\ttoparrayofids = []\n\n\tn = 0\n\n\tfillarraytimes.each do |stuff|\n\n\t\twhile n < stuff.size\n\n\t\t\tidindexspot = fillarraytimes.index(stuff) \n\n\t\t\tstuff.each_with_index do |morestuff, index|\n\t\t\t\tstuff[index] = morestuff.chomp.to_f\n\t\t\tend\n\n\t\t\ttopspot = stuff.index(stuff.max) # Finds the highest time's index\n\n\t\t\tstuff.each_with_index do |morestuff, index|\n\t\t\t\tstuff[index] = morestuff.to_s\n\t\t\tend\n\n\t\t\tnewarrayoftimes << stuff[topspot] # pushes highest time to newarray\n\t\t\tnewarrayofids << fillarrayids[idindexspot][topspot] # pushes ID corresponding to highest time\n\t\t\tstuff[topspot] = \"\"\n\t\t\tfillarrayids[idindexspot][topspot] = \"\"\n\t\t\tn += 1\n\t\t\t# Had to change the loops highest time to blank spot to avoid it being used again\n\t\tend\n\n\t\ttoparrayoftimes.push newarrayoftimes\n\t\ttoparrayofids.push newarrayofids\n\t\tnewarrayoftimes = []\n\t\tnewarrayofids = []\n\t\tn = 0\n\t\t# toparray's are another 2D array set similary to fillarrays, but\n\t\t# they are arranged! Newarrays are reset for same purposes from above\n\tend\n\n\t# The results page shows three things, Name, Time, and college for each event\n\t# ABOVE we have assembled nice 2D arrays for IDs and Times, BELOW we \n\t# do the same thing for colleges, names, and addresses.\n\ttoparrayofcolleges = []\n\ttoparrayofaddress = []\n\tpushingarray = []\n\tanotherpushing = []\n\n\n\ttoparrayofids.each do |replacenames|\n\t\treplacenames.each_with_index do |names, index|\n\t\t\tpushingarray[index] = collegelookbyID(\"./entrants.txt\", replacenames[index])\n\t\t\tanotherpushing[index] = addresslookbyID(\"./entrants.txt\", replacenames[index])\n\t\t\treplacenames[index] = namelookbyID(\"./entrants.txt\", replacenames[index])\n\n\n\t\tend\n\t\ttoparrayofcolleges.push pushingarray\n\t\ttoparrayofaddress.push anotherpushing\n\t\tpushingarray = []\n\t\tanotherpushing = []\n\tend\n\n\ncomboarray = []\n\ncomboarray.push toparrayofids\ncomboarray.push toparrayoftimes\ncomboarray.push toparrayofcolleges\n\nreturn comboarray\n\nend", "def parse_time_data input\n while line = input.gets\n line.chomp!\n @line_no += 1\n\n if line =~ /^[\\#;]/\n # ignore comment lines\n elsif line =~ /^(\\d{1,2})\\/(\\d{1,2})\\/(\\d{2}|\\d{4})$/\n # mm/dd/yy or mm/dd/yyyy\n handle_new_day($1, $2, $3)\n elsif line =~ /^([0-9.:]+)\\s*[-]\\s*([0-9.]+)\\s+(\\S+.*)/\n # t1 - t2 description for example:\n # 7.1-13.6 Mantis issues OR (for Jordan :)\n # 7:30-10 Mantis issues\n handle_new_entry($1, $2, $3)\n elsif line.strip.empty?\n # ignore blank lines\n else\n raise \"parse error - invalid line\"\n end\n end\n rescue Exception => e\n puts \"line #{@line_no}: #{e.message}\"\n end", "def read_text(filename); end", "def read\n $t1 = Time.now # Init procedure timestamp\n person = []\n IO.foreach(\"data_500.txt\") do |line| # Get all patients from file iterate each line\n line.chomp! # Remove trailing whitespace.\n person.push(line.split(\":\")) # Saving data split :\n end\n group(person) # Get blood type\n end", "def schedule_line\n [ level_to_config, pool_to_config, month, day, \"at #{time}\"].join(\" \")\n end", "def obtainTrips(contents)\n\n # variable to hold the list of trips\n trips = []\n\n # for every line...\n contents.each do |line|\n\n # use regex to ensure the line matches\n captures = /^Trip ([A-Za-z]{1,64}) ([0-2]\\d):(\\d\\d) ([0-2]\\d):(\\d\\d) (\\d{1,3}\\.?\\d?)$/.match(line)\n\n # safety check, ensure the capture isn't nil\n if captures.nil?\n next\n end\n\n # if the regex capture has a length of at least 6:\n #\n # * driver\n # * start time - HH\n # * start time - MM\n # * end time - HH\n # * end time - MM\n # * average speed \n #\n if captures.length < 6\n next\n end\n\n # safety check, ensure this actually resembles a 24 hour clock\n if captures[2].to_i > 23 || captures[4].to_i > 23 ||\n captures[3].to_i > 59 || captures[5].to_i > 59\n next\n end\n\n # Obtain the current time\n t = Time.now\n\n # Assemble a start time\n start_time = Time.local(t.year, t.day, t.month, captures[2], captures[3])\n\n # Assemble an end time\n end_time = Time.local(t.year, t.day, t.month, captures[4], captures[5])\n\n # Throw a warning if the start time is *after* the end time,\n # but skip on to the next element...\n if start_time > end_time\n puts \"\\nWarning: Improper start / end time detected!\"\n puts \"--------------------------------------------\"\n puts line\n puts \"--------------------------------------------\\n\"\n next\n end\n\n # assemble the trip array\n trip = {:driver => captures[1],\n :start_time => start_time,\n :end_time => end_time,\n :average_speed => 0,\n :miles_driven => captures[6].to_f}\n\n # attempt to calculate the average speed\n start_minutes = (captures[2].to_i * 60) + captures[3].to_i\n end_minutes = (captures[4].to_i * 60) + captures[5].to_i\n total_time_in_minutes = end_minutes - start_minutes\n if total_time_in_minutes <= 0\n next\n end\n trip[:average_speed] = trip[:miles_driven] * 60 / total_time_in_minutes\n\n # discard trips with speed < 5mph or speed > 100mph\n if trip[:average_speed] < 5 || trip[:average_speed] > 100\n next\n end\n\n # add the trip to the list of trips\n trips.push(trip)\n end\n\n # send back the list of trips\n return trips\nend", "def read_todos(filename)\n File.readlines(filename)\nend", "def createBoard file\n\n\tbegin\n\t\tlines = IO.readlines(template)\n\t\n\trescue Exception => e\n\t\tputs e.message\n\t\tputs e.backtrace.inspect\n\tend\t\n\nend", "def GetUserStoriesAndTasksFromFile(taskFile)\n\n\tFile.open(taskFile, \"r\") do |infile|\n\n\t defect_tasks = Hash.new(Array.new)\n\t us_tasks = Hash.new(Array.new)\n\t work_product = \"\"\n\n\t while (line = infile.gets)\n\t\t\n\t\tline = line.strip\n\n\t\tif (!work_product.match('\\AUS').nil? && line.match('(\\AUS|\\ADE)').nil?) then us_tasks[work_product] += [line] end\n\t\tif (!work_product.match('\\ADE').nil? && line.match('(\\AUS|\\ADE)').nil?) then defect_tasks[work_product] += [line] end\n\t\tif (!line.match('\\AUS').nil? || !line.match('\\ADE').nil?) then work_product = line end\n\n\t end\n\n\t us_tasks.each_pair { |us,values| CreateTasksForUserStory(us,values) }\n\t defect_tasks.each_pair { |de,values| CreateTasksForDefect(de,values) }\n\t\n\tend\nend", "def scan_logfile(file, backlog_minutes, pattern)\n offset_found = false\n from_time = Time.now - backlog_minutes*60\n offset = from_time.to_s.split[1..3].join(\" \")\n File.open(file) do |f|\n while line = f.gets do\n tokens = line.split[0..3]\n hour, min, sec = tokens[2].split(\":\")\n t = Time.local(Time.now.year, tokens[0], tokens[1].to_i, hour.to_i, min.to_i, sec.to_i)\n if t > from_time\n offset_found = true\n end\n if offset_found and line =~ pattern\n return line\n end\n end\n end\nend", "def load1\nf = File.read(@filename)\nf.each_line do |line|\nif line.match('#undone')\n@pending << line\nelse\n@completed << line\nend\nend\nreturn @pending\nend", "def process_externals_lines\n File.open(file_name, \"r\") do |f|\n #File.open(\"./lib/externals/externals_table_data_input_lines.txt\", \"r\") do |f|\n f.each_line do |line|\n puts line.to_textual\n sleep(0.01)\n end\n end\n end", "def get_total_time_list(filename)\n to_return = []\n lines = File.open(filename, \"rb\") {|f| f.read.split(/\\n+/)}\n lines.each do |line|\n kernel_start = 0.0\n kernel_end = 0.0\n # The lines we're interested in shouldn't contain any letters, just numbers\n next if line =~ /[a-zA-Z]/\n values = line.split.map {|v| v.to_f}\n to_return << [values[0], values[3]]\n end\n to_return\nend", "def readFile\r\n\t\tfile = File.open(fileName, \"r\")\r\n\r\n\t\t#Array for partial matches\t\t\r\n\t\t@dictionary = Array.new\r\n\t\tfile.each do |line|\r\n\t\t\tif line != \"\\n\"\r\n\t\t\t\t@dictionary << line.split(/[:;\\n]/)\r\n\t\t\tend\r\n\t\tend\r\n\t\tstartStrategies\r\n\tend", "def input\n lines = File.new('day12_input.txt').readlines()\n initial_state = lines[0].match('initial state:\\s*([^\\n]*)')[1]\n .chars\n .each_with_index\n .map { |x, i| [i, x] }\n rules = lines[2...lines.length].map { |item|\n item.strip.split(\" => \")\n }\n return initial_state, rules\nend", "def read_from_jobinfo\n data = YAML.load(jobinfo.read)\n @desc = data[:desc]\n @ctime = Timestamp.parse(data[:ctime])\n @mtime = Timestamp.parse(data[:mtime])\n @ppg_filename = data[:ppg_filename]\n end", "def read\n x = nil\n File.open(@filename, 'r') {|f| x = f.readlines }\n x.each do |line|\n\n line = self.class.remove_comments(line)\n\n if line.present?\n @data << self.class.extract_data_from_line(line)\n # puts self.class.extract_data_from_line(line).to_yaml\n end\n end\n end", "def parse_file\n @file ||= File.open(@file_name) unless @file_name.nil?\n @text = @file.readlines\n @file.close unless @file.nil?\n parse_text\n end", "def cron_open\n # jo = File.open #still need to write crontab protocol\n end", "def readFile()\n\t#This is assuming the file name will be used\n\tfilename = 'names-data.txt'\n\topen(filename, 'r') {|f| f.read}\nend", "def generateSchedule(roomsArray, inputNumOfAttendees, inputStartTime, inputDate, scheduleTable, inputDuration, percentOfAttendeesWhoNeedComputers, percentOfAttendeesWhoEat)\n \n\n puts \"What would you like to name the file?: \"\n fn = gets.strip\n f = File.open(fn, \"w\") \n\n \n x = 0\n reservedRooms = []\n\n #Creates sperates arrays for each specialty \n fullCapacityRoomsArray = seperateFullCapacityRooms(roomsArray, inputNumOfAttendees)\n foodRoomsArray = seperateFoodRooms(roomsArray)\n computerRoomsArray = seperateComputerRooms(roomsArray)\n genericRoomsArray = seperateGenericRooms(roomsArray)\n\n #Gets decimal in hours which is used to iterate\n timeDec = initialTimeDecimal(inputStartTime)\n timeString = timeDecToString(timeDec)\n\n openingSessionRoom = fullCapacityGetter(fullCapacityRoomsArray, inputDate, inputStartTime, scheduleTable, inputNumOfAttendees)\n reservedRooms[x] = openingSessionRoom\n x+=1\n f.puts \"Time: \" + timeString\n f.puts \"Opening event is occuring: \"\n f.puts openingSessionRoom.displayInfo()\n\n i = 1\n while i <= inputDuration.to_i - 1 #while the hour is before 1 hour before the end of the event and 1 hour after the start continue to loop\n\n emptyAllRooms(roomsArray)\n timeDec = timeIteratorDecimal(timeDec)\n timeString = timeDecToString(timeDec)\n f.puts \"\"\n f.puts \"\"\n f.puts \"Time: \" + timeString\n\n currNumOfAttendees = inputNumOfAttendees.to_i\n computerNeedingAttendees = currNumOfAttendees * percentOfAttendeesWhoNeedComputers\n currNumOfAttendees -= computerNeedingAttendees\n #Used for hours where attendees eat\n if i == 4 || i == 10 || i == 16 || i == 22 #Times when attendees eat\n eatingAttendees = (currNumOfAttendees * percentOfAttendeesWhoEat) #Calculates how many attendees are eating\n currNumOfAttendees -= eatingAttendees #Seperates eating attendees from total # of attendees to deal with seperately\n f.puts \"There will be a total of \" + eatingAttendees.to_s + \" attendees eating in the following rooms:\" #Tells user how many attendees are eating\n j = 0\n foodRoomsAvailible = foodRoomsCheck(foodRoomsArray, inputDate, timeString, scheduleTable) #Returns food rooms availible at the given time and date\n while j <= foodRoomsAvailible.length() - 1 && eatingAttendees > 0 #loops through all availible food rooms\n eatingAttendees = foodRoomsAvailible[j].addToCapacity(eatingAttendees) #Adds attendees to rooms then returns amount of remaining attendees not added to eatingAttendees\n reservedRooms[x] = foodRoomsAvailible[j]\n x+=1\n f.puts foodRoomsAvailible[j].displayInfo()\n if eatingAttendees == 0\n break\n end\n j+=1\n end\n if(eatingAttendees > 0)\n f.puts \"IMPORTANT: Not enough rooms for attendees to eat in during meal time!!!!\"\n break\n end\n end\n \n computerRoomsAvailible = computerRoomsCheck(computerRoomsArray, inputDate, timeString, scheduleTable)\n f.puts \"There will be a total of \" + computerNeedingAttendees.to_s + \" attendees using computers in the following rooms:\" \n j = 0\n while j <= computerRoomsAvailible.length() - 1 && computerNeedingAttendees > 0 #loops through all availible food rooms\n computerNeedingAttendees = computerRoomsAvailible[j].addToCapacity(computerNeedingAttendees) #Adds attendees to rooms then returns amount of remaining attendees not added to eatingAttendees\n reservedRooms[x] = computerRoomsAvailible[j]\n x+=1\n f.puts computerRoomsAvailible[j].displayInfo()\n if computerNeedingAttendees == 0\n break\n end\n j+=1\n end\n if(computerNeedingAttendees > 0)\n f.puts \"IMPORTANT: Not enough rooms for attendees to use computers in!!!!\"\n break\n end\n\n genericRoomsAvailible = genericRoomsCheck(genericRoomsArray, inputDate, timeString, scheduleTable)\n f.puts \"There will be a total of \" + currNumOfAttendees.to_s + \" attendees working in the following rooms:\" \n j = 0\n while j <= genericRoomsAvailible.length() - 1 && currNumOfAttendees > 0 #loops through all availible food rooms\n currNumOfAttendees = genericRoomsAvailible[j].addToCapacity(currNumOfAttendees) #Adds attendees to rooms then returns amount of remaining attendees not added to eatingAttendees\n reservedRooms[x] = genericRoomsAvailible[j]\n x+=1\n f.puts genericRoomsAvailible[j].displayInfo()\n if currNumOfAttendees == 0\n break\n end\n j+=1\n end\n if(currNumOfAttendees > 0)\n f.puts \"IMPORTANT: Not enough rooms for attendees to use work in!!!!\"\n break\n end\n \n\n i+=1\n end\n emptyAllRooms(roomsArray)\n timeDec = timeIteratorDecimal(timeDec)\n timeString = timeDecToString(timeDec)\n \n\n f.puts \"\"\n #f.put \"\"\n closingSessionRoom = fullCapacityGetter(fullCapacityRoomsArray, inputDate, timeString, scheduleTable, inputNumOfAttendees)\n reservedRooms[x] = closingSessionRoom\n f.puts \"Time: \" + timeString\n f.puts \"Closing event will occur: \"\n #closingSessionRoom.reserveRoom(inputDate, timeString, scheduleTable)\n f.puts closingSessionRoom.displayInfo()\n\n f.close\n\n\n return reservedRooms\nend", "def read(path)\n File.open(path) do |f|\n until f.eof?\n line = f.gets.chomp\n next if line.empty? || line =~ /^%%/\n yield line.split(/\\t/).map! { |s| s.empty? ? nil : s }\n end\n end\n end", "def readParams(fname)\n begin\n f = File.open(fname)\n rescue Exception => e\n puts e\n $stdout.flush\n exit(1)\n end\n\n section = nil\n f.each_line{|line|\n\n line.chomp!\n line.strip!\n if line == \"\" || line =~ /^%/\n # skip blank lines & lines beginning with %\n\n elsif line == $headerPorts || line == $headerShips ||\n line == $headerTraveler || line == $headerOutput\n section = line\n\n elsif section == $headerPorts\n parts = line.split(' ')\n name = parts[0]\n size = parts[1].to_i\n $starport.push(Starport.new(name,size))\n \n elsif section == $headerShips\n parts = line.split(' ')\n name = parts[0]\n size = parts[1].to_i\n $starship.push(Starship.new(name,size))\n\n elsif section == $headerTraveler\n parts = line.split(' ')\n name = parts.shift\n itinerary = []\n parts.each { |p| itinerary.push(find_name($starport,p)) }\n person = Traveler.new(name,itinerary)\n $traveler.push(person)\n find_name($starport,parts.first).arrive(person)\n\n elsif section == $headerOutput\n $simOut.push(line)\n\n else\n puts \"ERROR: simFile format error at #{line}\"\n $stdout.flush\n exit(1)\n end\n }\nend", "def recover_data\n subjects = []\n dt = nil\n begin\n File.open('data', 'r') do |file|\n file.each_line do |line|\n next if line.nil?\n if /^[0-9]+\\.[0-9]+/.match(line)\n code, name = line.strip.split('|')\n subj = Subject.new(code, name)\n subjects << subj\n dt = DataExtractor.new(subj)\n elsif /^[A-Z]+$/.match(line)\n dt.handle_event(:comision, line.strip)\n elsif /(Lunes|Martes|Miércoles|Jueves|Viernes|Sábado|Domingo)/.match(line)\n dt.handle_event(:dia, line.strip)\n elsif /^[0-9]+:[0-9]+$/.match(line)\n dt.handle_event(:hora, line.strip)\n end\n end\n end\n File.open('data.json', 'w') do |file|\n file.write(create_subjects_json(subjects))\n end\n rescue StandardError\n puts 'Archivo corrupto.'\n end\n subjects\nend", "def read_file(path)\n struct=Struct.new(:u_id, :m_id,:rating,:time)\n puts path\n return [] if !File.exists? path\n File.open(path, \"r\") do |f|\n #splits each line by ws and convert to integer and build structures from values\n return f.each_line.map { |line| struct.new(*line.split.map {|x| x.to_i}) }\n end\n end", "def fetch_schedule(name)\n schedule[name]\n end", "def schedule\n unless (@schedule)\n schedule = []\n emails = @emails\n emails << 'n/a' if @emails.size.odd?\n\n top_row = emails[0...(emails.size/2)]\n (0...top_row.size).each do |shifts|\n weekly_pairs = []\n second_row = emails[(emails.size/2)...emails.size]\n\n shifts.times {second_row << second_row.shift}\n top_row.each_with_index do |top_row_email, index|\n weekly_pairs << [top_row_email, second_row[index]]\n end\n\n schedule << weekly_pairs\n end\n\n @schedule = schedule\n\n end\n\n @schedule\n end", "def parse_file(filename)\n start = Time.now\n open filename do |file|\n data = {}\n i = 0\n file.each do |line|\n date, query = line.chomp.split(\"\\t\")\n\n insert(date, query)\n i += 1\n end\n puts \"Successfully read #{i} lines.\"\n end\n puts \"Done in #{Time.now - start} seconds.\"\n end", "def stdin_parser(lines) #{{{\n lines = lines.split(/\\n/) unless lines.class == Array\n lines.map {|line|\n line.chomp.gsub(/\\e\\[\\d+m/,\"\").split('|').map(&:strip)\n }.keep_if{|i| i != []}\n .map {|l| \n task = {}\n task[:date] = Time.parse(l[0])\n task[:title] = l[1]\n task[:tag] = YAML.load(l[2])\n task\n }\n rescue\n raise RuntimeError, 'Stdin lines are invalid.'\n end", "def schedules\n @doc.at_xpath('/a:akomaNtoso/a:components/a:component/a:doc[@name=\"schedules\"]/a:mainBody', a: NS)\n end", "def read_schematics(file)\n File.open(file, 'r') do |f|\n @schematics = f.readlines.reject { |line| line =~ /^\\s*$/ }\n end\n end", "def task_2(str)\n r = []\n str.each_line do |x|\n ip = x[/^.* - -/]\n d = x[/[\\[].*[\\]]/]\n a = x[/T .* H/]\n if ip && d && a\n r << d[1..-2] + ' FROM: ' + ip[0..-4] + 'TO:' + a[1..-3].upcase\n end\n end\n r\nend", "def read_to(pattern); end", "def read_runtime\n if File.exists?(run_file)\n Time.parse(File.open(run_file, &:readline).strip).utc.strftime(\"%FT%T\")\n else\n Time.parse('1970-01-01').utc.strftime(\"%FT%T\")\n end\n end", "def read_events(lines)\n # Each line has 4 fields:\n # - The word \"change\"\n # - A timestamp, as seconds from epoch\n # - The state of a pod (e.g. \"Pending\", \"Init:0/1\", \"Run:1/2\", ...)\n # - The name of the pod.\n # For example: \"change 1596841778 Ready uaa-0\"\n\n entries = lines.map do |line|\n (marker, stamp, state, pod) = line.split\n Event.new(stamp: stamp.to_i, state: state, pod: pod) if marker == 'change'\n end\n base = entries.map(&:stamp).min\n entries.each { |entry| entry.offset = entry.stamp - base }\nend", "def load_midi_assignments\n File.open(File.join(WORKING_DIR,'MIDIAssignments.xml')) do |file|\n slot_re = Regexp.new('^\\s*<slot num=\"(?<num>\\d+)\" name=\"(?<name>.+)\">{DOCUMENTS}/KemperAmp/Rigs/(?<rig_file>\\k<name> - (?<year>\\d+)-(?<month>\\d+)-(?<day>\\d+) (?<hour>\\d+)-(?<min>\\d+)-(?<sec>\\d+)\\.kipr)</slot>\\s*$')\n while line = file.gets\n # <slot num=\"5\" name=\"Alright\">{DOCUMENTS}/KemperAmp/Rigs/Alright - 2014-07-03 15-21-10.kipr</slot>\n match = slot_re.match(line)\n if match\n @midi[:nums][match['num']] = {\n rig_file: match['rig_file'],\n ts: get_rig_ts(match),\n rig_name: match['name']\n }\n if midi_has_rig?(match['name'])\n @midi[:rigs][match['name']][:midi_num] << match['num']\n else\n @midi[:rigs][match['name']] = {\n rig_file: match['rig_file'],\n ts: get_rig_ts(match),\n midi_num: [match['num']]\n }\n end\n end\n end\n end\n end", "def trigger\n @trigger ||= begin\n trg = schedule.split(\":\")\n raise \"ll-007: illegal schedule format '#{schedule}'\" unless trg.size == 2\n trg.map(&:strip).map(&:chomp)\n end\n end", "def read_inv x\n File.readlines('inventory.txt')[x]\nend", "def load_file(f)\n\t\tdata = []\n f.each do |line| \n user_id, movie_id, rating, timestamp = line.split(\"\\t\")\n data.push({\"user_id\"=> user_id.to_i, \"movie_id\"=>movie_id.to_i,\"rating\"=> rating.to_i,\"timestamp\"=>timestamp.to_i})\n\t\tend\n\t\treturn data\n\tend", "def read\n\t\t@file_content = File.open(\"/home/calin/football/football.dat\",\"r\")\n\tend", "def import\n Schedule.import(params[:file])\n redirect_to schedules_path, notice: \"Schedules imported successfully\"\n end", "def parse_lines(lines)\n result = {}\n for l in lines\n fname, desc, time = l.split(/\\t/)\n result[desc] = time.to_f\n end\n return result\n end", "def testParseLine\n ep = EiBiScheduleParser.new\n\n line = \"7490;2300-0455;;;WBCQ;E;NA;;;;\"\n bc = ep.parseEiBiTextLine(line)\n assert_equal 7490, bc[:frequency]\n assert_equal \"WBCQ\", bc[:broadcaster]\n assert_equal 23, bc[:startHour]\n assert_equal 0, bc[:startMinute]\n assert_equal 4, bc[:endHour]\n assert_equal 55, bc[:endMinute]\n assert_equal \"NA\", bc[:targetRegion]\n end", "def get_report()\n # Get yesterday unless today is Monday then get Friday\n today = Date.today.strftime('%m/%d/%Y')\n yesterday = (Date.today-(Date.today.monday? ? 3 : 1)).strftime('%m/%d/%Y')\n date_pattern = /\\d\\d\\/\\d\\d\\/\\d\\d\\d\\d/\n report = \"\"\n last_date = \"\"\n File.foreach(\"$HOME/standup_report.txt\") do |line|\n data = line.chomp\n last_date = data if date_pattern.match(data)\n next if last_date == today || (last_date == yesterday && date_pattern.match(data))\n\n # End of 'yesterdays' report\n break if last_date != yesterday && date_pattern.match(data)\n\n report += data + \"\\n\"\n end\n report\nend", "def process_externals\n File.open(\"./lib/externals/externals_table_data_input_hash.txt\", \"r\") do |f|\n #File.open(\"./lib/externals/externals_table_data_input_lines.txt\", \"r\") do |f|\n f.each_line do |line|\n external_searched, searched = line.chomp.split(\"\\t\")\n # created_sequence_id = external_searched(/continue code/)\n # creation_sequence_id = \n # complete_sequence_id = \n # lexigram_sequence_id = \n # singular_sequence_id = complete_sequence_id.squeeze\n puts \"#{external_searched.to_textual}\\t#{searched}\" \n sleep(0.01)\n end\n end\n end", "def parse_schedule(html)\n table = html.scan(/<table.*?<\\/table>/m).first\n \n slots = table.scan(/<td.*?><font.*?>(.*?)<\\/td>/).inject([[]]) do |m, n| \n m << [] if m[-1].length >= 20\n if n[0] =~ /(\\d+)/ \n m[-1] << $1.to_i\n else\n m[-1] << nil\n end\n m\n end\n \n slots\nend", "def read_file\n\t\t\treturn 'wordlists/reverse_ip.txt'\n\t\tend", "def parse_txt_file(filename)\n file_lines = []\n File.open(filename).each do |line|\n file_lines << line.chomp\n end\n file_lines\nend", "def ReadStuData(id,scores)\n #read file Chp9gm2i.txt and get the student id and scores read into an array\n @line = 0\n File.open('Chp9Pgm2i.txt','r') do |f1|\n while line = f1.gets\n @temp_line = line.split(' ')\n id [@line] = @temp_line[0] #Student's ID\n scores[@line] = @temp_line[1].to_i #Exam Score\n @line = @line +1\n end #ends while\n end #ends file.open\n return id, scores\nend", "def get_week(file, week)\n file.seek((week - 1) * 63)\n\n week = {\n date: file.read(10).strip,\n temps: {}\n }\n\n [:nino12, :nino3, :nino34, :nino4].each do |region|\n week[:temps][region] = {\n temp: file.read(9).to_f,\n change: file.read(4).to_f\n }\n end\n\n week\nend", "def parse_logfile\n File.open(\"DietLog.txt\", \"r\") do |f|\n f.each_line do |line|\n line.chomp!\n command = line.split(\",\")\n date = command[0]\n food = command[1]\n addLog(food, date)\n end\n end\n end", "def load(contents)\n\n\t\t# save the NAME of the current schedule item, to restore later\n\t\tbackup_position = current.name if current\n\t\t\n\t\t# delete al items\n\t\tschedule_spans.delete_all\n\t\t\n\t\t# create all items\n\t\tcontents.each do |name, items|\n\t\t\tspan = schedule_spans.where(name: name).first_or_initialize\n\t\t\tspan.content = items.to_yaml\n\t\t\tspan.save\n\t\tend\n\t\t\n\t\t# restore 'current' item\n\t\tupdate_attribute(:current, backup_position && self.schedule_spans.find_by_name(backup_position))\n\t\t\n\tend", "def read_files(year, month, path)\n array = [0, '', 100, '', 0, '', 100, 100, 100]\n month_name = Date::MONTHNAMES[month]\n link = \"#{path}_#{year}_#{month_name[0..2]}.txt\"\n file = CSV.read(link)\n loop_var, line_count = case_read_file(path, link)\n until loop_var > line_count\n high_temp_file_loop(loop_var, array, file)\n low_temp_file_loop(loop_var, array, file)\n humid_file_loop(loop_var, array, file)\n loop_var += 1\n end\n array\n end", "def rank_times\n hours = Array.new(24){0}\n @file.each do |line|\n hour = line[:regdate].split(\" \")\n hour = hour[1].split(\":\")\n hours[hour[0].to_i] += 1\n\n end\n hours.each_with_index{ |counter,hours| puts \"#{hours}: #{counter}\"}\n end", "def write_scheduling_to_file(servers)\n filename = \"outputs/results.txt\"\n File.open(filename, \"w\") do |file|\n # header of the file\n file.write(\"#jobid serverid start end\\n\")\n file_content = Array.new\n # we read the queue of each server\n servers.each do |server|\n server.queue.each do |job|\n file_content << \"#{job.id} #{server.id} #{job.start} #{job.end}\"\n end\n end\n # sort by ascending job id\n file_content.sort_by! { |line| line.split(' ').first }\n file_content.each do |line|\n if line.split(' ')[3].to_f < 20\n file.write(line + \"\\n\")\n else\n # to keep the graph compact\n # if the periodicity is too high, we comment it for python\n file.write(\"#arrival > 20, exclude from graph plot\\n#\" + line + \"\\n\")\n end\n end\n end\nend", "def load_game(file) \n raise \"I suspect you of cheating.\" if File.mtime(file) != Time.at(File.readlines(file).last.to_i)\nend", "def print_day date\n @list ||= Array.read TODO\n @done ||= Array.read DONE\n @deleted ||= Array.read DELETED\n\n=begin\n YAML.load_file(RECURRENT).each do |taskstr,dates|\n if dates.include? date.wday #and !@deleted.select{|t| t[:scheduled] == date and t[:description] == taskstr}.empty?\n task = Task.new(taskstr.split(\" \"))\n task[:scheduled] = date.to_datetime\n @list << task if (@done+@list).select{|t| t.scheduled_at?(date) and t[:description] == task[:description]}.empty?\n end\n end\n @list.save TODO\n=end\n\n not_scheduled = (@list+@done).select{|t| t.day_dur(date) > 0.0 and !t.scheduled_at? date}\n all_stat = Stat.new not_scheduled, date, date#[@list,@done]\n done_stat = Stat.new @done, date, date\n todo_stat = Stat.new @list, date, date\n\n puts yellow(\"#{(date).strftime('%a %d %b %Y')} w#{todo_stat[:work][:planned].to_f.to_datetime}/f#{todo_stat[:not_work][:planned].to_f.to_datetime}/t#{todo_stat[:total][:planned].to_f.to_datetime}\")\n @list.each{|t| @list.print t if t[:scheduled] and t[:scheduled].to_date == date}\n\n if date == Date.today\n puts blue(\" Done: w#{done_stat[:work][:measured].to_f.to_datetime}/f#{done_stat[:not_work][:measured].to_f.to_datetime}/t#{done_stat[:total][:measured].to_f.to_datetime}\")\n @done.each do |t|\n if t[:finished] == date\n print \" \"\n @done.print t\n end\n end\n #puts cyan(\" Not scheduled: w#{all_stat[:work][:measured].to_f.to_datetime}/f#{all_stat[:not_work][:measured].to_f.to_datetime}/t#{all_stat[:total][:measured].to_f.to_datetime}\")\n @list.each do |t|\n unless t.day_dur(date) == 0.0 or t.scheduled_at? date\n print \" \"\n @list.print t\n end\n end\n @done.each do |t|\n unless t.day_dur(date) == 0.0 or t.scheduled_at? date\n print \" \"\n @done.print t\n end\n end\n end\nend", "def schedule\n # obtain list of required courses\n course_titles = RequiredCourse.all\n\n # obtains Courses associated with each of these titles\n courses = []\n course_titles.each do |ct|\n courses.push(Course.where(subject: Subject.where(department: ct.department), courseId: ct.courseId).first)\n end\n\n return schedule_courses(courses, [[]])\n\n\n end", "def read_feeds(fname)\r\n File.foreach(fname) {|line| process_feed(line.split(',')[0], line.split(',')[1], line.split(',')[2], line.split(',')[3])}\r\n end", "def read_file(seq_fn = \"seq.txt\", prob_fn = \"hmm.txt\")\n\t\n\t# Reads Sequence of Observations from File\n\tif !File.exists?(seq_fn)\n\t\tseq_fn = \"seq.txt\"\n\t\tif !File.exists?(seq_fn)\n\t\t\tprint \"File does not exist.\"\n\t\t\treturn\t\t\t\n\t\tend\n\tend\n\n\tprint \"\\n\\nReading file \"\n\tprint seq_fn\n\tprint \"\\n\"\n\n\tifile = File.new(seq_fn, \"r\")\n\twhile (line = ifile.gets)\n\t\tif (line.to_i.to_s == line)\n\t\t\t# Converting the line into an array.\n\t\t\tprint \"Observations: \"\n\t\t\tprint line\n\t\t\t@observations = line.chars.map(&:to_i)\n\t\t\tbreak\n\t\tend\n\tend\n\tifile.close\n\n\t# Reads Transition and Sensory Probabilites from a file\n\tif !File.exists?(prob_fn)\n\t\tprob_fn = \"hmm.txt\"\n\t\tif !File.exists?(prob_fn)\n\t\t\tprint \"File does not exist.\"\n\t\t\treturn\t\t\t\n\t\tend\n\tend\n\n\tprint \"\\n\\nReading file \"\n\tprint prob_fn\n\tprint \"\\n\"\n\n\t# Open the file. Read only.\n\tifile = File.new(prob_fn, \"r\")\n\t@b_b = ifile.gets.to_f\n\t@l_b = ifile.gets.to_f\n\t@b_l = ifile.gets.to_f\n\t@l_l = ifile.gets.to_f\n\t@h_b = ifile.gets.to_f\n\t@t_b = ifile.gets.to_f\n\t@h_l = ifile.gets.to_f\n\t@t_l = ifile.gets.to_f\n\tifile.close\nend", "def read_file pn\n pn.readlines.map(&:chomp)\n .each do |line|\n @entries.add line, pn\n end\n end", "def weekplan_parse(lines)\n lines = lines.drop_while{|line| not line =~ TITLE_REGEX}\n exit if lines.empty? # TODO error message\n entry = Entry.new(lines.shift)\n entries = EntryArray.new\n lines.each do |line|\n if line =~ TITLE_REGEX\n entries.add(entry)\n entry = Entry.new(line)\n elsif line =~ /[[:print:]]/\n entry.add(line)\n end\n end\n entries.add(entry)\n return entries\nend", "def load_evfixed_places(config)\n @log.info(\"reading input file \\\"#{config[:input]}\\\" ...\")\n\n # Create schedule records and formatted displays for early voting schedules.\n valid_schedule_code = {}\n schedule_id_by_code = {}\n schedule_formatted_by_code = config[:schedule_formatted_by_code] || {}\n config[:hours_by_code].each do |code, hours|\n valid_schedule_code[code] = true\n schedule_id_by_code[code] = make_schedule(hours)\n schedule_formatted_by_code[code] ||= format_schedule(hours)\n end\n\n CSV.foreach(config[:input], :headers => true) do |row|\n\n cleanup_row(row)\n\n schedule_code = row[\"Hours\"]\n unless valid_schedule_code[schedule_code]\n raise \"unknown schedule code \\\"#{schedule_code}\\\": #{row}\"\n end\n\n location = make_location(row)\n\n info = VotingPlaceInfo.new(\"Early Voting Location\", location, schedule_formatted_by_code[schedule_code])\n\n @log.debug(\"places_early_fixed: creating: location_id=#{location[:id]}\")\n @db[:voting_places] << {\n :place_type => \"EARLY_FIXED\",\n :location_id => location[:id],\n :schedule_id => schedule_id_by_code[schedule_code],\n :info => info.to_s,\n }\n\n end\nend", "def scheduler_rules(rule_name, info)\n\n # Get to the advanced page.\n self.goto_advanced(rule_name, info)\n \n # Get to the \"Scheduler Rules\" page.\n begin\n @ff.link(:text, 'Scheduler Rules').click\n self.msg(rule_name, :info, 'Scheduler Rules', 'Reached page \\'Scheduler Rules\\'.')\n rescue\n self.msg(rule_name, :error, 'Scheduler Rules', 'Did not reach \\'Scheduler Rules\\' page')\n return\n end\n \n # Check the key.\n if ( info.has_key?('section') ) then\n # Right,go on.\n else\n self.msg(rule_name,:error,'scheduler_rules','Some key NOT found.')\n return\n end \n \n # Parse the json file\n \n # Add a scheduler rule here.\n \n # Click the \"Add\" button under scheduler rule main page.\n @ff.link(:text,'Add').click\n self.msg(rule_name,:info,'Add a scheduler rule','Begin')\n \n # Confirm it\n if not @ff.text.include? 'Set Rule Schedule'\n self.msg(rule_name,:error,'scheduler_rules','Did not reach the \\'Set Rule Schedule\\' page')\n return\n end\n \n # Set the rule name\n @ff.text_field(:name,'schdlr_rule_name').set(info['Rule Name'])\n self.msg(rule_name,:info,'Rule Name',info['Rule Name'])\n \n # Active?\n case info['Rule will be Active at the Scheduled Time']\n \n when \"on\"\n # Active\n @ff.radio(:id,'is_enabling_0').set\n when \"off\"\n # Inactive\n @ff.radio(:id,'is_enabling_0').clear\n else\n # Wong here\n self.msg(rule_name,:error,'scheduler_rules','Ambigurous on active or inactive.')\n return\n end # end of case\n self.msg(rule_name,:info,'Rule will be Active at the Scheduled Time',info['Rule will be Active at the Scheduled Time'])\n \n # Active?\n case info['Rule will be inactive at the Scheduled Time']\n \n when \"on\"\n # Active\n @ff.radio(:id,'is_enabling_1').set\n when \"off\"\n # Inactive\n @ff.radio(:id,'is_enabling_1').clear\n else\n # Wong here\n self.msg(rule_name,:error,'scheduler_rules','Ambigurous on active or inactive.')\n return\n end # end of case\n self.msg(rule_name,:info,'Rule will be inactive at the Scheduled Time',info['Rule will be inactive at the Scheduled Time'])\n \n # Click the \"Add Rule Schedule\" button.\n @ff.link(:text,'Add Rule Schedule').click\n \n # Setup the days.\n \n self.msg(rule_name, :debug, 'scheduler_rules', 'doing rule days begin')\n \n if info.has_key?('Monday')\n if info['Monday'] == 'on'\n @ff.label(:for,'day_mon_').click\n end\n end\n \n if info.has_key?('Tuesday')\n if info['Tuesday'] == 'on'\n @ff.label(:for,'day_tue_').click\n end\n end \n \n if info.has_key?('Wednesday')\n if info['Wednesday'] == 'on'\n @ff.label(:for,'day_wed_').click\n end\n end \n\n if info.has_key?('Thursday')\n if info['Thursday'] == 'on'\n @ff.label(:for,'day_thu_').click\n end\n end \n \n if info.has_key?('Friday')\n if info['Friday'] == 'on'\n @ff.label(:for,'day_fri_').click\n end\n end \n \n if info.has_key?('Saturday')\n if info['Saturday'] == 'on'\n @ff.label(:for,'day_sat_').click\n end\n end \n \n if info.has_key?('Sunday')\n if info['Sunday'] == 'on'\n @ff.label(:for,'day_sun_').click\n end\n end \n \n self.msg(rule_name, :debug, 'scheduler_rules', 'doing rule days end')\n self.msg(rule_name,:info,'Add days','OK')\n \n # Setup the hours\n if info.has_key?('Start Time') and info.has_key?('End Time')\n \n self.msg(rule_name, :debug, 'scheduler_rules', 'doing rule hours: begin' ) \n \n # Click \"New Hours Range Entry\".\n @ff.link(:text, 'New Hours Range Entry').click\n \n start_time = info['Start Time'].split(':')\n end_time = info['End Time'].split(':')\n \n @ff.text_field(:name, 'start_hour').set(start_time[0].strip)\n @ff.text_field(:name, 'start_min').set(start_time[1].strip)\n @ff.text_field(:name, 'end_hour').set(end_time[0].strip)\n @ff.text_field(:name, 'end_min').set(end_time[1].strip)\n \n # Apply for the \"hours\"\n @ff.link(:text, 'Apply').click\n \n \n self.msg(rule_name, :debug, 'scheduler_rules', 'doing rule hours: end' )\n self.msg(rule_name,:info,'Add hours','OK')\n \n end #end if hours\n \n # Apply for the days and hours\n @ff.link(:text, 'Apply').click\n \n # Apply for the rules\n @ff.link(:text,'Apply').click\n \n # Close the \"Scheduler Rules\" page\n @ff.link(:text,'Close').click\n \n self.msg(rule_name,:info,'Add a scheduler rule','End')\n self.msg(rule_name,:info,'Scheduler Rules','SUCCESS')\n \n end", "def run\n file = \"english.srt\"\n times = parse_times file\n build_ffmpeg times, file\nend", "def parse_spec_file(task_spec)\n task_spec_metadata = {}\n\n begin\n text = task_spec.read\n text.split(\"\\n\").each do |line|\n line = line.downcase\n\n if line =~ /^\\s*#\\s*(?:yamls|hiera):\\s*(.*)/\n task_spec_metadata[:hiera] = [] unless task_spec_metadata[:hiera].is_a? Array\n task_spec_metadata[:hiera] += get_list_of_yamls $1\n end\n\n if line =~ /^\\s*#\\s*facts:\\s*(.*)/\n task_spec_metadata[:facts] = [] unless task_spec_metadata[:facts].is_a? Array\n task_spec_metadata[:facts] += get_list_of_yamls $1\n end\n\n if line =~ /^\\s*#\\s*(?:skip_yamls|skip_hiera):\\s(.*)/\n task_spec_metadata[:skip_hiera] = [] unless task_spec_metadata[:skip_hiera].is_a? Array\n task_spec_metadata[:skip_hiera] += get_list_of_yamls $1\n end\n\n if line =~ /^\\s*#\\s*skip_facts:\\s(.*)/\n task_spec_metadata[:skip_facts] = [] unless task_spec_metadata[:skip_facts].is_a? Array\n task_spec_metadata[:skip_facts] += get_list_of_yamls $1\n end\n\n if line =~ /^\\s*#\\s*disable_spec/\n task_spec_metadata[:disable] = true\n end\n\n if line =~ /^\\s*#\\s*role:\\s*(.*)/\n task_spec_metadata[:roles] = [] unless task_spec_metadata[:roles].is_a? Array\n roles = line.split /\\s*,\\s*|\\s+/\n task_spec_metadata[:roles] += roles\n end\n\n if line =~ /^\\s*#\\s*run:\\s*(.*)/\n run_record = get_list_of_yamls $1\n if run_record.length >= 2\n run_record = {\n :hiera => run_record[0],\n :facts => run_record[1],\n }\n task_spec_metadata[:runs] = [] unless task_spec_metadata[:runs].is_a? Array\n task_spec_metadata[:runs] << run_record\n end\n end\n end\n rescue\n return task_spec_metadata\n end\n task_spec_metadata\n end", "def parse_init_file(path)\n return [] unless ::File.exist?(path)\n\n in_info = false\n ::File.readlines(path).each_with_object([]) do |line, acc|\n if /^### BEGIN INIT INFO/.match?(line)\n in_info = true\n elsif /^### END INIT INFO/.match?(line)\n break acc\n elsif in_info\n if line =~ /Default-(Start|Stop):\\s+(\\d.*)/\n acc << $2.split(\" \")\n end\n end\n end.flatten\n end", "def read file\n File.open file\n end", "def get_next_rr(file)\n while (!file.eof?)\n line = file.gets\n next if (!line || (line.length == 0))\n next if (line.index(';') == 0)\n next if (line.strip.length == 0)\n rr_text = \"\\n\"\n begin\n # Strip off prepended name up to \"\\v\" character before creating RR\n rr_text = line[line.index(Preparser::SORT_SEPARATOR) +\n Preparser::SORT_SEPARATOR.length, line.length]\n rescue Exception => e\n log(LOG_INFO, \"File contains unrecognisable line : #{rr_text}, ERROR : #{e} - skipping this line\")\n next\n end\n begin\n rr = RR.create(rr_text)\n return rr\n # rescue DecodeError => e\n rescue Exception => e\n split = rr_text.split\n if (split[3].index(\"NSEC3\"))\n @unknown_nsecs[split[0]] = split[8] # Store the next name\n elsif (split[3].index(\"NSEC\"))\n @unknown_nsecs[split[0]] = split[4] # Store the next name\n end\n # Assume this is a valid, but unsupported, type - we then need simply to ignore it.\n # But we also need to ignore the NSEC/NSEC3 and the RRSIG(s) (including for the hashed owner name)\n # So - if we're loading an NSEC3 record, then make sure we grab the owner name\n # We can then check it in the NSEC3 chain, and not try to validate the RRSIG for that NSEC3.\n #\n # log(LOG_ERR, \"File contains invalid RR : #{rr_text.chomp}, ERROR : #{e}\")\n log(LOG_INFO, \"File contains invalid RR : #{rr_text.chomp}, ERROR : #{e} - skipping this record\")\n end\n\n end\n return nil\n end", "def run()\n list = []\n result = \"\"\n while result != \"END OF MESSAGE\"\n result = @client.gets.chomp\n list.push(result)\n end\n if list[0] == 'VIEW TIMES'\n schedule = Schedule.new\n result = schedule.get_free_times(list[1],list[2])\n return result\n else\n schedule = Schedule.new\n result = schedule.set_appointment(list[1],list[2],list[3])\n [result]\n end\n end", "def read_in\n File.foreach(file_name).map(&:chomp)\n end", "def load(file)\n reset\n data = YAML::load(file.respond_to?(:read) ? file : File.open(file))\n config = (data[\"business_time\"] || {})\n\n # load each config variable from the file, if it's present and valid\n config_vars = %w(beginning_of_workday end_of_workday work_week work_hours)\n config_vars.each do |var|\n send(\"#{var}=\", config[var]) if config[var] && respond_to?(\"#{var}=\")\n end\n\n (config[\"holidays\"] || []).each do |holiday|\n holidays << Date.parse(holiday)\n end\n end", "def schedule_info\n\n @cron_line.original\n end" ]
[ "0.7165557", "0.6616428", "0.6464286", "0.6092501", "0.60570586", "0.60412633", "0.6032724", "0.6025103", "0.60056823", "0.59381217", "0.58323586", "0.58003163", "0.57709646", "0.5670735", "0.5614807", "0.56066287", "0.56003714", "0.5568436", "0.55491984", "0.55422306", "0.5499158", "0.5471346", "0.5468", "0.5428078", "0.5404293", "0.5401996", "0.53964293", "0.538865", "0.53756696", "0.537245", "0.5357794", "0.5351397", "0.5314138", "0.52742755", "0.52498144", "0.52468175", "0.52338016", "0.52291244", "0.52177495", "0.5198176", "0.5191572", "0.5178705", "0.51524794", "0.51514465", "0.5135073", "0.5135065", "0.5125107", "0.51120895", "0.50987196", "0.50853235", "0.5083285", "0.5051442", "0.50507647", "0.5049445", "0.5046959", "0.50449353", "0.50399846", "0.50323546", "0.5030817", "0.50260323", "0.501518", "0.5006499", "0.5005964", "0.5002653", "0.499324", "0.49874082", "0.4981333", "0.49720278", "0.49651715", "0.49644548", "0.49613118", "0.4957973", "0.4954585", "0.49446395", "0.4943342", "0.4937449", "0.4936495", "0.49334785", "0.4928931", "0.49246985", "0.49200764", "0.49192998", "0.49144626", "0.49123487", "0.4908811", "0.4899854", "0.48973954", "0.48932374", "0.48850396", "0.48841962", "0.4883955", "0.48820186", "0.4879859", "0.48774695", "0.48698032", "0.48574263", "0.48487002", "0.48469183", "0.48458105", "0.48445034" ]
0.672207
1
A function to read time table
def read_time_table(fname) ents=[] File.open(fname,'r') do |f| f.each_line do |line| line.chomp! a1,a2,a3,a4,a5 = line.split(/\s*==\s*/) hash={} hash["1"] = a1 # id hash["2"] = a2 # start time hash["3"] = a3 # end time hash["4"] = a4 # person hash["5"] = a5 # title ents.push(hash) end end ents end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_time fn=nil\n time = read_single_line(fn)\n if time.size == 2 # vector of two integers\n time.map { |t| t.to_i }\n else # single number\n single = time.first\n single =~ float_re ? single.to_f : single.to_i\n [single, nil]\n end\n end", "def loadTime()\n\t\treturn @rankedTimeDB.execute(\"SELECT idMap,name,time FROM rankedTime WHERE idMap = '#{@idMap}' ORDER BY time ASC\")\n\tend", "def table\n self.class.read_and_parse_file(@table_path)\n end", "def r_time cell, horaire\n if cell.empty?\n return nil\n end\n DateTime.new(cell.split(\"/\").third.to_i, cell.split(\"/\").second.to_i, cell.split(\"/\").first.to_i, horaire.split(\":\").first.to_i, horaire.split(\":\").second.to_i)\n end", "def get_time row \n\ttimes = JSON.parse \"{ #{row[\"opening_times\"]} }\"\n\tdefault = times[\"opening_times\"][\"default\"] rescue nil\n\tif default \n\t\ttime_string = \"\"\n\t\tdefault.each do |tt|\n\t\t\ttime_string += \"#{tt[\"days\"]} #{tt[\"open_in\"]} #{tt[\"open_out\"]} #{tt[\"close_in\"]} #{tt[\"close_out\"]}|\"\t\n\t\tend\n\t\treturn time_string.chop!\n\tend\n\treturn nil\nend", "def get_time()\n return @noko.css(\"li.g:first-of-type table table\")[0].text\n end", "def readTable(path)\n return JSON.parse(File.read(path).rstrip)\nend", "def table_time\n @table_time * 1000\n end", "def get_vtk_time(file)\n # read the first 256 chars and split into lines\n a = IO.read(file, 256)\n a.split\n\n # parse out time= using a regex\n a = a.map{|l| l.sub!(/.*time= ([0-9e+\\-\\.]+).*/, '\\1')}\n\n # return first non-empty line\n a = a.delete_if{|l| l==nil}\n a.first.to_f\nend", "def transform_time fields,row\n @time_fields.each do |f|\n v = fields[f]\n next unless v\n ## change time field so it looks like standard\n # Y Mon Day H Mn Sec\n n = 4 + 2 + 2 + 2 + 2 + 2 - 1 # arr start at 0 =)\n row[v] = row[v].gsub(\"+01\",\"\")[0..n]\n transform_time_values row,v\n end\n return row\n end", "def time_series(template_series)\n ts = []\n header = true\n File.foreach(template_series) do |line|\n line = line.split(' ',6)\n ts << line[0..4] unless header || line.size < 4\n header = false if line.first==\"*\"\n end\n t0 = parse_time_stamp(ts[0].first)\n t1 = parse_time_stamp(ts[1].first)\n [ts, (t1 - t0).to_f]\n end", "def get_time(row, col)\n ensure_not_empty(row, col)\n m = row[col].match(%r[^(\\d{1,2}):(\\d\\d)$])\n raise \"bad #{col} value \\\"#{row[col]}\\\": #{row}\" unless m && m.length-1 == 2\n m.captures.map {|s| s.to_i}\nend", "def get_times(hash)\n\ttimes = hash.map { |name, time| time }\nend", "def parse_timesheet\n @page.body.scan(/TCMS.oTD.push\\((\\[.*\\])\\)/).map do |match|\n row = match[0].gsub(/\"/, '').split(',')\n row.map { |x|\n CGI.unescape(x.strip).delete('[]')\n }.values_at(0, 7, 8, 9, 11, 12, 14, 15, 32, 1)\n end\n end", "def parse_table; end", "def get_total_time_list(filename)\n to_return = []\n lines = File.open(filename, \"rb\") {|f| f.read.split(/\\n+/)}\n lines.each do |line|\n kernel_start = 0.0\n kernel_end = 0.0\n # The lines we're interested in shouldn't contain any letters, just numbers\n next if line =~ /[a-zA-Z]/\n values = line.split.map {|v| v.to_f}\n to_return << [values[0], values[3]]\n end\n to_return\nend", "def time(text)\n scan(text, TIME, :time)\n end", "def parse_srt_times(times)\n times =~ /^([0-9:,]+) --> ([0-9:,]+)/ # May have trailing data.\n [$1, $2].map {|t| parse_srt_time(t) }\n end", "def parse_time_data input\n while line = input.gets\n line.chomp!\n @line_no += 1\n\n if line =~ /^[\\#;]/\n # ignore comment lines\n elsif line =~ /^(\\d{1,2})\\/(\\d{1,2})\\/(\\d{2}|\\d{4})$/\n # mm/dd/yy or mm/dd/yyyy\n handle_new_day($1, $2, $3)\n elsif line =~ /^([0-9.:]+)\\s*[-]\\s*([0-9.]+)\\s+(\\S+.*)/\n # t1 - t2 description for example:\n # 7.1-13.6 Mantis issues OR (for Jordan :)\n # 7:30-10 Mantis issues\n handle_new_entry($1, $2, $3)\n elsif line.strip.empty?\n # ignore blank lines\n else\n raise \"parse error - invalid line\"\n end\n end\n rescue Exception => e\n puts \"line #{@line_no}: #{e.message}\"\n end", "def get_block_time_list(filename)\n to_return = []\n lines = File.open(filename, \"rb\") {|f| f.read.split(/\\n+/)}\n lines.each do |line|\n next if line !~ /^Block times/\n values = []\n # Block times are given as a space-separated list of start,end pairs. They\n # are in units of seconds * 1e5, so convert them to seconds here for\n # consistency.\n if line =~ /^[^:]+: (.*?)\\s*$/\n values = $1.split(\" \").map{|r| r.split(\",\").map{|v| v.to_f / 1e5}}\n end\n to_return << values\n end\n to_return\nend", "def parse_time(row)\n raw_time = row[1]\n if raw_time\n time = \"#{raw_time[0..4]}#{raw_time[-2..-1].downcase!}\"\n\n # remove leading 0\n time = time[1..-1] if time[0] === '0'\n time\n else\n nil\n end\nend", "def time_rows\n rows = []\n (0..NUM_HALF_HOURS-1).each do |half_hour|\n cols = []\n row = content_tag :tr do\n cols << hour_cell(half_hour)\n cols << minute_cell(half_hour)\n (0..(num_days-1)).each do |day|\n cols << event_cells(half_hour,day)\n end\n cols.join.html_safe\n end\n rows << row\n end\n rows.join.html_safe\n end", "def timeRecordsForDate(brick, date)\n end", "def rows(table, id, start_time, end_time)\n res = connection.query(\"SELECT UNIX_TIMESTAMP(dtime), counter, rate FROM #{table} WHERE id = #{id} AND dtime >= FROM_UNIXTIME(#{start_time}) AND dtime <= FROM_UNIXTIME(#{end_time})\")\n rows = []\n res.each { |row| rows << [ row[0].to_i, row[1].to_i, row[2].to_i ] }\n return rows\n end", "def index\n @timetables = Timetable.all\n end", "def parse_lines(lines)\n result = {}\n for l in lines\n fname, desc, time = l.split(/\\t/)\n result[desc] = time.to_f\n end\n return result\n end", "def read_table table\n table_offset = @archive_header.send \"#{table}_table_offset\"\n @io.seek @user_header.archive_header_offset + table_offset\n table_entries = @archive_header.send \"#{table}_table_entries\"\n data = @io.read table_entries * 16\n key = Hashing::hash_for :table, \"(#{table} table)\"\n data = Hashing::decrypt data, key\n klass = table == :hash ? HashTableEntry : BlockTableEntry\n (0...table_entries).map do |i|\n klass.read(data[i * 16, 16])\n end\n end", "def core_timetable(course_code)\n Tableau::TimetableParser.new(course_code).parse\n end", "def load_timestamp(fname)\n stamps = []\n File.open(fname).read().each_line do |line|\n parsed = line.strip().split() \n stamps << [parsed[2].to_f, parsed[3].to_f, parsed[4].to_f, parsed[5].to_f, parsed[6].to_f]\n end\n return stamps\nend", "def get_flow_table_matrix\n flow_table_matrix = browser.div(:class, 'sData').when_present(@time_out)\n data_flow_table = flow_table_matrix.table(:id, 'DataFlowTable') \n end", "def set_time_table\n @time_table = TimeTable.find(params[:id])\n end", "def parse_time(file_time_struct)\n wtime_to_time(make_uint64(file_time_struct[:dw_low_date_time],\n file_time_struct[:dw_high_date_time]))\n end", "def get_kernel_time_list(filename)\n to_return = []\n lines = File.open(filename, \"rb\") {|f| f.read.split(/\\n+/)}\n lines.each do |line|\n kernel_start = 0.0\n kernel_end = 0.0\n # The lines we're interested in shouldn't contain any letters, just numbers\n next if line =~ /[a-zA-Z]/\n values = line.split.map {|v| v.to_f}\n to_return << [values[1], values[2]]\n end\n to_return\nend", "def init\n @by_day = {}\n if File.exist?('result.txt')\n File.readlines('result.txt').each do |line|\n a = line.chomp.split(\"\\t\")\n @by_day[a.first] = a\n end\n end \nend", "def time_entries\n get_ticket_property_list(\"time_entries\" , Unfuddled::TimeEntry)\n end", "def get_timetable\n @timetable_parser.get_timetable_for_course(@courseCode, @year)\n end", "def read_records(table)\n hashes = []\n each(table) {|hash| hashes << hash}\n hashes\n end", "def rank_times\n hours = Array.new(24){0}\n @file.each do |line|\n hour = line[:regdate].split(\" \")\n hour = hour[1].split(\":\")\n hours[hour[0].to_i] += 1\n\n end\n hours.each_with_index{ |counter,hours| puts \"#{hours}: #{counter}\"}\n end", "def get_space_tables(space, language, time_now, subspace)\n keys = redis.keys(\"table_#{space}_*\" )\n\n live_tables = []\n redis.mget(*keys).each do |one_table|\n one_table = JSON.parse(one_table.force_encoding('UTF-8'))\n\n if (is_table_live(one_table, time_now) and\n (language.nil? or language == one_table['language']) and\n (subspace.nil? or subspace.empty? or subspace == one_table['subspace']))\n is_focus_group = one_table['is_focus_group']\n is_focus_group = false if is_focus_group.nil?\n one_table['hangouts_url'] = get_hangouts_url(\n one_table['id'],\n one_table['space'],\n one_table['language'],\n one_table['onair'],\n one_table['subspace'],\n is_focus_group: is_focus_group\n )\n live_tables << one_table\n end\n end if not keys.empty?\n\n live_tables\n end", "def timetable_for_class( school_class )\n Timetable.select{|t| t.school_class == school_class }.to_a\n end", "def readTSVline(l, sep=nil)\n\n sep = detectSeperator if sep.nil?\n\n #row = CSV.parse_line(l, :col_sep => seperator).collect{|x|\n row = l.split(sep).collect{|x|\n if ! x.nil?\n x.strip;\n end\n }\n\n ### Pick specify elements of that table\n #name, id, lastVisitDate, lastAttendedDate, meetupsAttended, profileURL, lastDonationAmount, lastDonationDate = readTSVline(seperator)\n [0, 3, 6, 7, 12, 18, 19, 21].map {|i| row[i]}\nend", "def timings\n\t\treturn [] unless self.timing_line?\n\t\ta,b = @value.split(' --> ')\n\t\treturn [SubtitleTiming.new(a), SubtitleTiming.new(b)]\n\tend", "def time_entries(start_date, end_date)\n opts = {\n params: {\n start_date: start_date.to_datetime.iso8601,\n end_date: end_date.to_datetime.iso8601\n }\n }\n\n begin\n response = toggl_resource['time_entries'].get(opts)\n rescue => e\n raise 'Error getting Toggl data: ' + e.response\n end\n data = JSON.parse response\n\n data.map do |entry|\n duration = entry['duration'].to_f\n\n # Negative duration means the task is currently running.\n # In this case, we'll set duration to how long it's been running\n if duration < 0\n duration = Time.now - Time.at(duration.abs)\n end\n\n {\n description: entry['description'],\n start: Date.parse(entry['start']),\n duration: duration\n }\n end\n end", "def get_in_table upto = Time.now.to_i\n request = {\n where: \"time < #{upto}\"\n }\n select(request)\n end", "def parse\n input_data.each do |filename, data|\n rowdata_template = OpenStruct.new\n @preprocess_block.call(filename, rowdata_template) if @preprocess_block\n\n arrived_at_table_data = false\n\n data.split(\"\\r\\n\").each do |line|\n next if line.strip.empty? # Skip blank and whitespace lines\n\n if !arrived_at_table_data\n next if line =~ /\\ACreated by SunData/ # Skip created by line\n if date_match = line.match(/\\A(\\d\\d\\d\\d-\\d\\d-\\d\\d)\\t\\tLocal time is (GMT.\\d+ Hrs)/)\n rowdata_template.date = date_match[1]\n rowdata_template.timezone = date_match[2]\n end\n\n if sunscan_match = line.match(/\\ASunScan probe (v.*)/)\n rowdata_template.sunscan_version = sunscan_match[1]\n end\n\n if matches = line.scan(/\\s*([^\\t:]+)\\s*:\\s*([^\\t:]+)/)\n matches.flatten.map(&:strip).each_slice(2) do |key, value|\n next if value.nil? || value.empty?\n rowdata_template[key.downcase.gsub(\" \", \"_\")] = value\n end\n end\n\n # Once we hit the table hearder we can start processing tabular data.\n # The header is two lines long because of the formatting.\n next if line =~ /\\ATime\\tPlot\\t/\n arrived_at_table_data = true and next if line =~ /\\s+mitted\\s+ent/\n\n\n else\n rowdata = rowdata_template.dup\n table_line = line.split(\"\\t\")\n rowdata.time = table_line[0]\n rowdata.plot = table_line[1]\n rowdata.sample = table_line[2]\n rowdata.transmitted = table_line[3]\n rowdata.spread = table_line[4]\n rowdata.incident = table_line[5]\n rowdata.beam = table_line[6]\n rowdata.zenith_angle = table_line[7]\n rowdata.lai = table_line[8]\n rowdata.notes = table_line[9]\n # Only record output data once the full line data has been captured.\n output_data << rowdata\n end\n end\n end\n end", "def get_data_for_time_span()\n set_schedule_query_params\n\n @t1 = Time.at(@t1.to_i)\n @t2 = Time.at(@t2.to_i)\n\n @rsrcs = @config.resource_list # ScheduledResource.resource_list\n\n @blockss = ScheduledResource.get_all_blocks(@config, @t1, @t2, @inc)\n\n json_adjustments\n end", "def obtainTrips(contents)\n\n # variable to hold the list of trips\n trips = []\n\n # for every line...\n contents.each do |line|\n\n # use regex to ensure the line matches\n captures = /^Trip ([A-Za-z]{1,64}) ([0-2]\\d):(\\d\\d) ([0-2]\\d):(\\d\\d) (\\d{1,3}\\.?\\d?)$/.match(line)\n\n # safety check, ensure the capture isn't nil\n if captures.nil?\n next\n end\n\n # if the regex capture has a length of at least 6:\n #\n # * driver\n # * start time - HH\n # * start time - MM\n # * end time - HH\n # * end time - MM\n # * average speed \n #\n if captures.length < 6\n next\n end\n\n # safety check, ensure this actually resembles a 24 hour clock\n if captures[2].to_i > 23 || captures[4].to_i > 23 ||\n captures[3].to_i > 59 || captures[5].to_i > 59\n next\n end\n\n # Obtain the current time\n t = Time.now\n\n # Assemble a start time\n start_time = Time.local(t.year, t.day, t.month, captures[2], captures[3])\n\n # Assemble an end time\n end_time = Time.local(t.year, t.day, t.month, captures[4], captures[5])\n\n # Throw a warning if the start time is *after* the end time,\n # but skip on to the next element...\n if start_time > end_time\n puts \"\\nWarning: Improper start / end time detected!\"\n puts \"--------------------------------------------\"\n puts line\n puts \"--------------------------------------------\\n\"\n next\n end\n\n # assemble the trip array\n trip = {:driver => captures[1],\n :start_time => start_time,\n :end_time => end_time,\n :average_speed => 0,\n :miles_driven => captures[6].to_f}\n\n # attempt to calculate the average speed\n start_minutes = (captures[2].to_i * 60) + captures[3].to_i\n end_minutes = (captures[4].to_i * 60) + captures[5].to_i\n total_time_in_minutes = end_minutes - start_minutes\n if total_time_in_minutes <= 0\n next\n end\n trip[:average_speed] = trip[:miles_driven] * 60 / total_time_in_minutes\n\n # discard trips with speed < 5mph or speed > 100mph\n if trip[:average_speed] < 5 || trip[:average_speed] > 100\n next\n end\n\n # add the trip to the list of trips\n trips.push(trip)\n end\n\n # send back the list of trips\n return trips\nend", "def read_shift(single_line)\r\n#\treturn \"Wrong line\" unless single_line =~/^(\\d{2})\\/(\\d{2})\\/(\\d{4})/\r\n shift_date=single_line.split(',')[0].split[0]\r\n shift=single_line.split(',')[1]\r\n cg=shift.split(':')[0]\r\n shift_start=shift.split('-')[0].split(':')\r\n if shift =~ /(\\d{2})\\/(\\d{2})\\/(\\d{4})/ \r\n startTime=Time.strptime(shift_start[1]+\":\"+shift_start[2], ' %m/%d/%Y %I:%M %p')\r\n endTime=Time.strptime(shift.split('-')[1], ' %m/%d/%Y %I:%M %p')\r\n else\r\n startTime=Time.strptime(shift_date+shift_start[1]+\":\"+shift_start[2], ' %m/%d/%Y %I:%M %p')\r\n endTime=Time.strptime(shift_date+shift.split('-')[1], ' %m/%d/%Y %I:%M %p')\r\n end\r\n [shift_date, cg, startTime, endTime]\r\nend", "def printByTimeRecords(timeBegin,timeEnd)\n t0 = timeBegin\n t1 = t0+24*60*60\n while t0 < timeEnd\n puts t0.strftime(\"[%m.%d.%y]\")\n self.traverse_preorder() {|brick, depth|\n brick['timeWorked'].each{ |tr|\n #if(tr.inRange(timeBegin,timeEnd)) \n if(tr.inRange(t0,t1)) \n print \"\\t\", tr, \" [#{brick['brick']}]\\n\"\n end\n }\n }\n t0 = t1\n t1 = t1+24*60*60\n end\n end", "def initialize(texttable, runtime = 0)\r\n\r\n @runtime = runtime\r\n @table = texttable\r\n\r\n @table.map!{|r|\r\n r.map!{|c|\r\n c.delete!(\"映画館問合休\")\r\n c[/[^\\(]+/]\r\n }\r\n }\r\n\r\n @table.delete_at(1)\r\n\r\n @table = @table.transpose\r\n\r\n @table.delete_if{|day|\r\n day.include?(nil)\r\n }\r\n\r\n @table.each{|d|\r\n d[1] = d[1].split(\" \")\r\n }\r\n\r\n year_crossing = false\r\n cur_mon = Date.today.month\r\n unless @table.empty?\r\n @table.first[0] =~ /^\\d+/\r\n year_crossing ||= (cur_mon < $&.to_i)\r\n @table.last[0] =~ /^\\d+/\r\n year_crossing ||= ($&.to_i < cur_mon)\r\n end\r\n\r\n cur_year = Date.today.year\r\n @table.map!{|d|\r\n month, day = d[0].split(\"/\").map{|i| i.to_i}\r\n year = cur_year\r\n if year_crossing\r\n year += (cur_mon <=> month)\r\n end\r\n d[1].map{|t|\r\n DateTime.parse(Chronic.parse(\"%d-%02d-%02d %s\"%[year, month, day, t]).to_s)\t# for \"2016/02/14 26:25\"\r\n }\r\n }\r\n @table.flatten!\r\n end", "def hour_table\n content_tag :div, :class => \"day_div\" do\n content_tag :table, :class => \"day_table\" do\n header + time_body\n end\n end\n end", "def read_time\n (number_of_words.to_f / WORDS_PER_MINUTE).ceil\n end", "def calc_time_diff(src_path)\n i=0\n timediff =[]\n pictimes = read_all_dates(src_path).values.sort\n timediff << 0\n \n until i == pictimes.length-1 \n i +=1\n timediff << pictimes[i] - pictimes[i-1]\n end\n \n return timediff # returns an array of time differences\nend", "def ot_parser\n # check for params\n puts \">>> PARAMS:\"\n ap params\n \n # Init times array\n response = {}\n # puts '>>> has params check here'\n if params.has_key?(:uid) && params.has_key?(:s) && params.has_key?(:d) && params.has_key?(:t)\n place = Place.find_by_uid(params[:uid])\n end\n \n puts '>>> place:'\n ap place\n \n # See if exists in OT / get Restuarant ID\n if place && place.ot_rid.nil?\n puts '>>> See if exists in OT'\n place.ot_rid = ot_rid(place)\n place.save!\n end\n \n if place && place.ot_rid && place.ot_rid != \"f\"\n # >>> Step 2 - get Times\n # http://m.opentable.com/search/results?Date=2012-12-19T00%3A00%3A00&TimeInvariantCulture=0001-01-01T19%3A30%3A00&PartySize=2&RestaurantID=47\n base_url = 'http://m.opentable.com'\n base_search_url = base_url + '/search/results'\n party_size = params[:s]\n date = params[:d]\n time = params[:t]\n query = '?' + 'Date=' + (CGI::escape date) + '&TimeInvariantCulture=' + (CGI::escape time) + '&PartySize=' + (CGI::escape party_size) + '&RestaurantID=' + place.ot_rid\n url = base_search_url + query\n \n puts '>>> open table url:'\n ap url\n \n # Get a Nokogiri::HTML::Document for the page we’re interested in...\n doc = Nokogiri::HTML(open(url))\n \n # times results array\n times = []\n \n # Search for nodes by css\n doc.css('ul#ulSlots li.ti a').each do |link|\n # doc.css('#ulSlots li a').each do |link|\n time = {}\n time[\"url\"] = base_url + link['href']\n time[\"time\"] = link.content.strip\n \n times << time\n end\n \n if times.empty?\n response[:error] = { :exists => \"true\", :error => \"true\", :url => url }\n else\n response[:error] = { :exists => \"true\", :error => \"false\", :url => url }\n response[:times] = times\n end\n else\n response[:error] = { :exists => \"false\" }\n end\n \n puts '>>> response:'\n ap response\n \n render json: response\n end", "def parse_timestamps\n self.keys.each do |key|\n self[key].map! do |timestamp| \n timestamp.is_a?(Time) ? timestamp : Time.parse(timestamp)\n end\n end\n end", "def printTimeRecords(dateBegin, dateEnd)\n tasks = []\n self.traverse_preorder() {|brick, depth|\n #print \" \" * depth, \"#{brick['brick']}:\\n\"\n brick['timeWorked'].each{ |tr|\n if(tr.inRange(dateBegin,dateEnd)) \n #print \" \" * (depth+1), tr, \"\\n\"\n #print \" \" * (depth+1), tr, \"\\n\"\n print \"\\t\", tr, \"--\", brick['brick'],\"\\n\"\n end\n tasks.push(tr)\n }\n }\n tasks\n end", "def get_kernel_time(filename)\n to_return = 0.0\n data = JSON.parse(File.open(filename, \"rb\") {|f| f.read})\n data[\"times\"].each do |t|\n next if !t.include?(\"kernel_times\")\n values = t[\"kernel_times\"]\n to_return += values[1] - values[0]\n end\n to_return\nend", "def read_date; end", "def read_time # :nodoc:\n\t rt_sec, rt_usec = rio.read(TIME_SIZE).unpack('VV')\n\t Time.at(rt_sec, rt_usec)\n\tend", "def parse_time\n s0 = @scanner.pos\n if match_str('(') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s3 = parse_ms\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str('/') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s5 = parse_hms\n s5 = parse_ms(with_hour: true) if s5 == :failed\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str(')') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'now' => s3, 'total' => s5 }\n end\n end\n end\n end\n end\n s0\n end", "def read_table(table_name)\r\n ODBC.connect('', '', '') do |db|\r\n rows = db.run(\"select * from #{table_name}\").each_hash\r\n\r\n rows.map do |row|\r\n row.transform_values!(&:strip)\r\n id = row['FFJITMN']\r\n desc = row['FFIIDE1'].sub(/^PRODX?/, '').strip\r\n cat = row['FFJPBHN']\r\n\r\n Item.new(id, desc, cat, nil)\r\n end\r\n end\r\nend", "def get_time_entries(start_date=nil, end_date=nil)\n options = Hash.new\n options[\"start_date\"] = iso8601_date(start_date) if start_date\n options[\"end_date\"] = iso8601_date(end_date) if end_date\n get \"/time_entries\", options\n end", "def parse_hash\n \thash = {}\n \t# Remove the first five lines of the file\n \ttemp_array = @readin[5, @readin.length]\n \t# Split the input at the semicolon: the left hand side is a timestamp and the right hand side\n \t# is the value (either power in W, or energy in Wh depending on the file type).\n \t# This is committed to a hash with time as the key and the W/Wh as the value.\n \ttemp_array.each do |s|\n \t\tk,v = s.split(/;/)\n \t\t# the Aurora reports time as seconds since 1/1/0000 and Ruby reports time utilizing an epoch\n \t\t# that began on 1/1/1970. The time stamp is adjusted for the time in seconds between these\n \t\t# two dates.\n \t\thash[Time.at(k.to_i - 62167104000)] = v.to_f\n \tend\n \treturn hash\n end", "def test_format\n\n\t data = analyse_log(@filename,@keywords, @start, Time.parse(\"31.12.3000\"), @output_file)\n \tdata_hist = prepare_data(data, @keywords, @start, 3600)\n\n \tassert_equal(true, data_hist.keys[0].class == String)\n \tassert_equal(true, data_hist[@keywords[0]].keys[0].class == Time)\n \tassert_equal(true, data_hist[@keywords[0]][0].class == Fixnum)\n\tend", "def parse_schedule(html)\n table = html.scan(/<table.*?<\\/table>/m).first\n \n slots = table.scan(/<td.*?><font.*?>(.*?)<\\/td>/).inject([[]]) do |m, n| \n m << [] if m[-1].length >= 20\n if n[0] =~ /(\\d+)/ \n m[-1] << $1.to_i\n else\n m[-1] << nil\n end\n m\n end\n \n slots\nend", "def parse\n line = @io.gets until md = /\\ATime before run:\\s+(?<time>.*)\\Z/.match(line)\n return unless md\n @db.date_time ||= DateTime.parse(md[:time])\n super\n @db[\"lparstat_out\"] = @db[\"lparstat_sum\"]\n end", "def get_data_flow_table\n data_flow_table = browser.table(:id, 'DataFlowTable').when_present(@time_out)\n end", "def read_tsv(path, header = true, nil_values = [''])\n output = Array.new\n content = File.read(path).rstrip.split(/\\n/).map{|r| r.split(/\\t/)}\n if header\n head = content[0]\n content.shift\n else\n head = dummy_header(content[0].length)\n end\n content.each do |c|\n d = head.map.with_index{|h, i| [h, (nil_values.any?(c[i])) ? nil : c[i]]}\n output << d.to_h\n end\n return output\nend", "def read_tsv(path, header = true, nil_values = [''])\n output = Array.new\n content = File.read(path).rstrip.split(/\\n/).map{|r| r.split(/\\t/)}\n if header\n head = content[0]\n content.shift\n else\n head = dummy_header(content[0].length)\n end\n content.each do |c|\n d = head.map.with_index{|h, i| [h, (nil_values.any?(c[i])) ? nil : c[i]]}\n output << d.to_h\n end\n return output\nend", "def parse(filename, resolution)\n # first, parse everything into data\n data = [[0, 0, 0, 0, 0]]\n t_start = nil\n File.read(filename).each_line do |l|\n begin\n t = DateTime.parse(l[0...20])\n if t_start.nil?\n t_start = t \n end\n\n t_sec_now = ((t - t_start)*24*60*60).to_i\n\n t_sec_now = (t_sec_now / resolution) * resolution\n\n while data.last[0] + resolution < t_sec_now\n data.push data.last.clone\n data.last[0] += resolution\n end\n\n m = /UpdateTip:.*height=(\\d+) .* tx=(\\d+) .* cache=(.*)MiB\\((\\d+)txo/.match(l)\n if m\n height = m[1]\n tx = m[2]\n cache_MiB = m[3]\n cache_tx = m[4]\n\n # overwrite when second has not changed\n if (data.last[0] == t_sec_now)\n data.pop\n end\n data.push [t_sec_now, height, tx, cache_MiB, cache_tx]\n else\n if (data.last[0] != t_sec_now)\n data.push(data.last.clone)\n end\n data.last[0] = t_sec_now\n end\n rescue => e\n STDERR.puts \"'#{l.strip}': #{e}\"\n end\n end\n\n\n t_next = 0\n data.each do |d|\n if d[0] != t_next\n raise \"t_next does not match!\"\n end\n t_next += resolution\n yield d\n end\nend", "def extract_timesheet\n @page.parser.css(\".ErrorText\").each do |n|\n puts \"ERROR: #{n.text}\"\n end\n\n timesheet = parse_timesheet\n\n department = timesheet.first[6]\n employee_id = timesheet.first[7]\n error = timesheet.first[9]\n\n puts \"ERROR: #{error}\" if error\n\n puts \"Employee #{@username} id #{employee_id}, department #{department}\"\n\n puts \"-\" * 80\n\n date = nil\n last_date = nil\n\n timesheet.each do |row|\n date = row[2]\n\n if row[0] == '0' and date == last_date then\n # do nothing\n elsif row[0] == '0' then\n puts \"#{row[2]} no time entered\"\n elsif date == last_date then\n puts \" %s to %s for %3s hours %s\" % row.values_at(3, 4, 5, 8)\n else\n puts \"%s %s to %s for %3s hours %s\" % row.values_at(2, 3, 4, 5, 8)\n end\n\n last_date = date\n end\n end", "def read_cell_date_or_time(row, idx)\n cell = read_cell_content(row, idx)\n cell = cell.to_s.to_f\n if cell < 1.0\n value_type = :time\n f = cell * 24.0 * 60.0 * 60.0\n secs = f.round\n h = (secs / 3600.0).floor\n secs = secs - 3600 * h\n m = (secs / 60.0).floor\n secs = secs - 60 * m\n s = secs\n value = h * 3600 + m * 60 + s\n else\n datetime = row.send(:_datetime, cell)\n\n if datetime.hour != 0 ||\n datetime.min != 0 ||\n datetime.sec != 0\n value_type = :datetime\n value = datetime\n else\n value_type = :date\n value = row.send(:_date, cell)\n end\n end\n\n [value_type, value]\n end", "def load_schedule_file(schedule)\n raw_data = CSV.table(schedule.externalFile.filePath.to_s)\n # Indexing starts at 1\n column = schedule.columnNumber - 1\n rows_to_skip = schedule.rowstoSkipatTop\n\n num_values = \\\n schedule.numberofHoursofData.get * 60 / schedule.minutesperItem.get.to_i\n occupancy = OpenStudio::Vector.new(num_values)\n\n raw_data.each_with_index do |row, i|\n next if i < rows_to_skip\n occupancy[i] = row[column]\n end\n return occupancy\n end", "def load_frequencies\n frequencies = {}\n\n frequencies_table = conn.exec <<-SQL\n SELECT * FROM gtf_frequencies\n SQL\n\n frequencies_table.each do |trip_id, start_time, end_time, headway_secs|\n st = GoogleTransitFeed::parse_time( start_time )\n et = GoogleTransitFeed::parse_time( end_time )\n hs = headway_secs.to_i\n # If there is not a key in the hash then creates the key\n frequencies[trip_id] ||=[]\n # Fills all the starting times for the trip\n while st <= et\n frequencies[trip_id] << st\n st += hs\n end\n end\n\n # Traverse the frequencies hash and subtract the first start time from all values\n frequencies.each do |key, row|\n first = row[0]\n frequencies[key] = []\n row.each do |f|\n frequencies[key] << f - first\n end\n end\n return frequencies\n end", "def load_showtimes\n available_times = {\n 10.45 => \"10:45am\", 11.00 => \"11:00am\", 11.15 => \"11:15am\", 11.30 => \"11:30am\",11.45 => \"11:45am\", 12.00 => \"12:00pm\", 12.15 => \"12:15pm\", 12.30 => \"12:30pm\", 12.45 => \"12:45pm\", \n 13.00 => \"1:00pm\", 13.15 => \"1:15pm\", 13.30 => \"1:30pm\",13.45 => \"1:45pm\",14.00 => \"2:00pm\",14.15 => \"2:15pm\",14.30 => \"2:30pm\", 14.45 => \"2:45pm\", 15.00 => \"3:00pm\",15.15 => \"3:15pm\",16.00 => \"4:00pm\", 16.15 => \"4:15pm\", 16.30 => \"4:30pm\", 16.45 => \"4:45pm\", 17.00 => \"5:00pm\",17.15 => \"5:15pm\", 17.30 => \"5:30pm\",17.45 => \"5:45pm\",18.00 => \"6:00pm\", 18.15 => \"6:15pm\", 18.30 => \"6:30pm\", 18.45 => \"6:45pm\", 19.00 => \"7:00pm\", 19.15 => \"7:15pm\", 19.30 => \"7:30pm\", 19.45 => \"7:45pm\", 20.00 => \"8:00pm\", 20.15 => \"8:15pm\", 20.30 => \"8:30pm\", 20.45 => \"8:45pm\", 21.00 => \"9:00pm\", 21.15 => \"9:15pm\", 21.30 => \"9:30pm\", \n 22.00 => \"10:00pm\", 22.15 => \"10:15pm\", 22.30 => \"10:30pm\", 22.45 => \"10:45pm\", 23.00=> \"11:00pm\", 23.15 => \"11:15pm\", \n 23.30 => \"11:30pm\", 23.45 => \"11:45pm\",24.00 => \"12:00am\"}\n\n\n\n showtimes = [10.45]\n\n if self.runtime >= 1.33 && self.runtime <= 1.5\n showtimes << 12.30 << 14.00 << 15.30 << 17.00 << 18.30 << 20.00 << 21.30 << 23.00\n\n elsif self.runtime >= 1.5 && self.runtime <= 2 \n showtimes << 13.00 << 15.00 << 17.00 << 19.00 << 21.00 << 23.00 << 24.00\n\n elsif self.runtime >= 2 && self.runtime <= 3\n showtimes << 14.15 << 17.15 << 21.15 << 24.00\n end \n\n\n\n showtimes.map! do |time|\n time = Showing.create!(military_time: time.to_f, time_string: available_times[time], movie: self)\n end\n\n self.showings = showtimes\n end", "def speeches\n self.time_slots\n end", "def load_time_ranges\n @time_ranges = ActiveSupport::HashWithIndifferentAccess.new\n time_ranges = @config['time']\n time_ranges.each do |t,r|\n time_range = ActiveSupport::HashWithIndifferentAccess.new\n src_ranges ||= r\n src_ranges.map { |k,v| time_range[k.to_sym] = rangify_time_boundaries(v) }\n @time_ranges[t.to_sym] = time_range\n end\n\n end", "def timecodes\n return [] if start_time.nil?\n start_hour = start_time.strftime(\"%H\")\n start_min = start_time.strftime(\"%M\").to_i < 30 ? \"00\" : \"30\"\n curr_time = Time.parse(\"#{start_hour}:#{start_min}\")\n timecode_array = []\n while curr_time < Time.parse(\"#{end_time.strftime(\"%H\")}:#{end_time.strftime(\"%M\")}\") - 1.second\n timecode_array << \"#{curr_time.strftime(\"%H\").to_i}:#{curr_time.strftime(\"%M\")}\"\n curr_time = curr_time + 30.minutes\n end\n timecode_array_with_days = []\n %w(monday tuesday wednesday thursday friday saturday sunday).each do |day|\n timecode_array_with_days << timecode_array.collect{|t| \"#{t}_#{day}\"}.flatten if read_attribute(day)\n end\n timecode_array_with_days.flatten\n end", "def get_table(table, env=nil)\n require 'net/http'\n http_config = get_remote_credentials(env)\n ret = false\n Net::HTTP.start(http_config['server_name'], http_config['server_port']) {|http|\n req = Net::HTTP::Get.new(\"/dumps/#{table}.txt\")\n req.basic_auth http_config['http_user'], http_config['http_pass']\n resp = http.request(req)\n ret = tab_to_array_of_hashes(resp.body) if resp.code == '200'\n }\n ret\n end", "def parse_time(tt)\n tt = tt.force_encoding('utf-8')\n MONTHS.map{|k,v|\n tt.gsub!(/ #{k}/i, \" #{v.downcase}\")\n }\n case tt\n when /Demain.*/\n t = Time.parse(tt)+60*60*24\n else\n t = Time.parse(tt)\n end\n return t\nend", "def entries\n settings.time_entries.present? ? settings.time_entries : []\n end", "def read_table\n\t$table.each_index do |i|\n\t\t$table[i] = gets.split(\" \")\n\tend\nend", "def read_runtime\n if File.exists?(run_file)\n Time.parse(File.open(run_file, &:readline).strip).utc.strftime(\"%FT%T\")\n else\n Time.parse('1970-01-01').utc.strftime(\"%FT%T\")\n end\n end", "def rows\n if @rows.empty?\n start_time = Time.now.to_f\n if should_cache? and cached?\n load_table_from_cache\n else\n create_table \n cache if should_cache?\n end\n end_time = Time.now.to_f\n @table_time = end_time - start_time \n end\n \n @rows\n end", "def tt(time, format=:short); '13:37'; end", "def compute_timestamps(begin_time, end_time)\n @timevec = value_hash[:bartime]\n if model == DailyBar\n begin\n @time_map = TimeMap.new(begin_time, end_time, timevec, :missing_bar_error => options[:missing_bar_error])\n rescue TimeseriesException => e\n raise TimeseriesException, \"#{e.message} for #{symbol}\"\n end\n else\n timevec.each_with_index { |time, idx| @time_map[time.to_i] = idx }\n end\n end", "def process_line_of_tsv_in_this_pipe line\n parts = line.strip.split(\"\\t\")\n case parts.size\n when 2\n timestamp = Time.now\n key, value = parts\n when 3\n key, value = parts[0..1]\n timestamp = Time.parse(parts.last)\n else\n error(\"Each line of input must be a tab separated row consisting of 2 columns (key, value) or 3 columns (timestamp, key, value)\")\n return\n end\n send_data(key, value, timestamp)\n end", "def read\n rows = to_a\n if @use_headers\n Table.new(rows)\n else\n rows\n end\n end", "def parse_table\n advance\n table = Element.new(:table)\n table = parse_attributes(table)\n table = parse_caption(table)\n while match?(:table_row, :table_header, :table_data)\n table = parse_row(table)\n end\n if match? :table_end\n advance\n else\n warning 'Could not find end of table, missing \"|}\"'\n end\n table\n end", "def toc_to_vtt\n path = toc_path\n File.open(path, 'w+:UTF-8') do |f|\n f.write vtt_start\n proper_items_by_time.reject(&:hidden).each do |i|\n f.write i.vtt_time_span\n f.write i.vtt_reference\n end\n end\n path\n end", "def parse_times_and_items\n @item_counts.sort.each do |item_count|\n items = item_count[1] # returns hash\n time = item_count[0].strftime(\"%I:%M\")\n @times.push(time)\n\n str = \"\"\n items.sort.each do |sub_arr|\n item = sub_arr[0]\n quantity = sub_arr[1]\n item = item.pluralize if quantity > 1\n str.concat(\"#{quantity} #{item}, \")\n end\n @items.push(str.slice(0...-2))\n\n end\n end", "def read_schedule2(fname)\n ents=[]\n File.open(fname,'r') do |f|\n f.each_line do |line|\n line.chomp!\n a1,a2,a3,a4 = line.split(/\\s*==\\s*/)\n hash={}\n hash[\"1\"] = a1\n hash[\"2\"] = a2\n hash[\"3\"] = a3\n hash[\"4\"] = a4\n ents.push(hash)\n end\n end\n ents\nend", "def index\n @time_lines = TimeLine.all\n end", "def read_date=(_); end", "def time_fragments\n []\n end", "def collect_time_information\n ### Time information\n mark_data_time_information = Array.new\n time_information = @case_details[:case][:system][:time]\n\n mark_data_time_information << 'Answer the following about each time period present in the evidence on the system'\n time_information.each do | key, value | mark_data_time_information << \"-#{key.capitalize}::#{value}\"\n end\n mark_data_time_information << ''\n\n return mark_data_time_information\n end", "def gettiming\n\tworker = params[:compname]\n\t\n\trealdata = '{\"dataArray\":[{\"label\":\"first\",\"oldtime\":\"1245\"}]}'\n\t\n\ttime = MongoDBConnector.instance.getRunTime(worker)\n\t\n\ttimeList = []\n\ttime.each do |x|\n\t\tx.each do |key, value|\n\t\t\ttimeList.push(:label => key, :oldtime => value )\n\t\tend\n\tend\n\ttime = {:dataArray => timeList}\n\ttime = time.to_json\n\trender :text => time\n end", "def table\n @max_cols = []\n @col_width = []\n @col_event = []\n (0..(num_days-1)).each do |day|\n @max_cols[day] = calc_max_cols(0, NUM_HALF_HOURS,day)\n if @max_cols[day] == 0\n @max_cols[day] = 1\n end\n @col_width[day] = (100.0/(num_days*@max_cols[day]) + 0.5).to_i\n @col_event << {}\n end\n @all_day_max = calc_all_day_max\n calc_event_rows\n content_tag :div do\n all_day_table + hour_table\n end\n end", "def count_time(relevant_line)\n t0 = 0\n time_between = []\n relevant_line.each do |n|\n t1 = Time.parse(n)\n d = t1 - t0\n t0 = t1\n time_between << d\n end\n time_between\nend", "def get_datetimes(row)\n mm, dd, yyyy = get_date(row, \"Date\")\n start_hh, start_mm = get_time(row, \"Start Time\")\n end_hh, end_mm = get_time(row, \"End Time\")\n [Time.local(yyyy, mm, dd, start_hh, start_mm), Time.local(yyyy, mm, dd, end_hh, end_mm)]\nend" ]
[ "0.62877005", "0.59484184", "0.588952", "0.5858403", "0.5856105", "0.5802663", "0.5800128", "0.5799782", "0.5752518", "0.5727681", "0.5693217", "0.5658559", "0.5654533", "0.5636147", "0.56288266", "0.5618865", "0.55988264", "0.55954945", "0.5577572", "0.55742943", "0.5570156", "0.55352175", "0.5506488", "0.54963267", "0.5487733", "0.54656", "0.54618907", "0.54584444", "0.5441746", "0.54158384", "0.54041684", "0.53791666", "0.5363408", "0.5357561", "0.5354285", "0.53529155", "0.5352226", "0.53412765", "0.5327319", "0.53126377", "0.53060424", "0.52995074", "0.5297395", "0.5265297", "0.5246716", "0.524345", "0.523995", "0.52313304", "0.5224475", "0.5190587", "0.51723087", "0.51627374", "0.51602393", "0.5158223", "0.5147546", "0.5147179", "0.5147128", "0.5135748", "0.51302373", "0.51270765", "0.51233554", "0.51003194", "0.51002204", "0.5093825", "0.5093285", "0.5091316", "0.50909466", "0.5084774", "0.5084774", "0.5083385", "0.50824547", "0.50814533", "0.5080589", "0.50648224", "0.50627327", "0.50606334", "0.50420874", "0.50376457", "0.5029135", "0.50263053", "0.50241303", "0.5005162", "0.50041586", "0.49904314", "0.49785212", "0.49766904", "0.49716446", "0.49676806", "0.49489045", "0.4946424", "0.49447292", "0.494385", "0.494269", "0.49378914", "0.49362653", "0.49330372", "0.4931994", "0.49301487", "0.4914169", "0.49064404" ]
0.70969385
0
This checks if the schools need to log in to sign up competitors, or if it's open sign up
def school_password_required Setting.find_by(key: "require_school_password").value == "yes" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def canSignUp(u)\n ret = {}\n ts = Time.now.utc\n shop_info = u.workshops.collect {|w| [w.session, w.name]}\n if u.workshop_ids.count >= 3\n # Can't have more than 3 workshops\n ret[:status] = \"You can't more than three workshops.\"\n ret[:result] = false\n elsif shop_info.map(&:first).include? session\n # Can't have more than one workshop in a session OR two workshops with the same name\n ret[:status] = \"You can't have more than one workshop in a session, and you can't sign up for a workshop twice.\"\n ret[:result] = false\n elsif shop_info.map(&:last).include? name\n # Can't sign up for a workshop twice\n ret[:result] = false\n elsif u.role == \"teacher\" and (ttaken.to_f < tlimit.to_f)\n ret[:status] = \"The workshop is full.\"\n ret[:result] = false\n elsif self.twofer_ref != 0 and not ( u.sessions_needed.include?(Workshop.find(self.twofer_ref).session) )\n # You can't sign up for a workshop if it has a nonzero twofer_ref and the workshop it points to is in a session you already are signed up for\n ret[:status] = \"You can't register for a double-length workshop that overlaps one of your other workshops.\"\n ret[:result] = false\n elsif u.role == \"student\" and (staken.to_f < slimit.to_f) and u.division == \"BD\" and ((boys.count + 1)/slimit.to_f <= percentage.to_f/100.to_f)\n #if adding a boy doesn't push us over the percentage limit\n ret[:status] = \"Available.\"\n ret[:result] = true\n elsif u.role == \"student\" and (staken.to_f < slimit.to_f) and u.division == \"GD\" and ((girls.count + 1)/slimit.to_f <= percentage.to_f/100.to_f)\n #same with girls\n ret[:status] = \"Available.\"\n ret[:result] = true\n else\n # If none of these conditions: slot is unavailable\n ret[:status] = \"The workshop is full\"\n ret[:result] = false\n end\n# puts \"One round of checks - #{Time.now.utc - ts}\"\n ret\n end", "def allow_sign_up?\n @allow_sign_up\n end", "def logged_in?\n !current_school.nil?\n end", "def signup_allowed?(dd)\n dd.deadline_type_id == DeadlineHelper::DEADLINE_TYPE_SIGN_UP\n end", "def check_developer_orcid!\n return false unless params[:name].blank? && params[:email].blank? && params[:test_domain].blank? && !params[:orcid].blank?\n @orcid = params[:orcid]\n orcid_choose_tenant_or_login!\n true\n end", "def not_account_owner_in_signup\n enterprise.blank? || !enterprise.id.nil?\n end", "def login_required?\n !using_open_id?\n end", "def check_org\n unless current_user.organisation == @division.organisation\n redirect_to current_user, :alert => \"Sorry, you are not authorised for that\"\n end\n end", "def signed_up?(person)\n shifts.collect{|shift| shift.signed_up?(person)}.include?(true)\n end", "def check_auth\n if current_user.company_id != @company.id && !current_user.manager? && !current_user.admin?\n redirect_to projects_path, :alert => \"Access denied.\" and return\n end\n end", "def logged_in?\n !current_company.nil?\n end", "def require_signed_up\n return true if session[:cas_user].present? and User.exists?(:login => session[:cas_user])\n\n redirect_to :controller => :users, :action => :new\n return false\n end", "def require_signed_up\n return true if session[:cas_user].present? and User.exists?(:login => session[:cas_user])\n\n redirect_to :controller => :users, :action => :new\n return false\n end", "def registration_open?\n today = Date.current\n if registration_dates_given?\n (registration_start_date..registration_end_date).cover?(today)\n else\n false\n end\n end", "def is_logged_in?\n !session[:school_id].nil?\n end", "def registration_open?\n today = Date.current\n if self.registration_start_date.blank? || self.registration_end_date.blank?\n false\n end\n\n (registration_start_date..registration_end_date).cover?(today)\n end", "def current_user_signed_up?\n logged_in? && !current_user_is_host? && @game.players.include?(current_user)\n end", "def check_registration\n registrations = Registration.where(\"user_id = ? and course_id = ?\", self.user_id, self.course_id)\n if (registrations.nil? || registrations.length == 0)\n errors[:name] = \"only users who are registered for the course can review the course.\"\n return false\n end\n end", "def check_if_login_required\n false\n end", "def prevent_appirio_cs_signups\n if params[:signup_form]\n redirect_to \"http://content.cloudspokes.com/appirio-cloudspokes-users\" if params[:signup_form][:email].include?('@appirio.com')\n end\n end", "def check_user_before_membership\n if current_user\n ncm_membership = current_user.get_membership(@mother)\n epicenter = Epicenter.find_by_slug(params['epicenter_id'])\n\n if epicenter != @mother and not ncm_membership\n session[:new_ncm_membership] = { \n :epicenter_id => params['epicenter_id'], \n :membership_id => params['membership_id'],\n :t => Time.now\n }\n #\n redirect_to new_epicenter_subscription_path(@mother)\n end\n else\n # it's possible that we can put the logic from \"authenticate\" method below here\n redirect_to epicenters_path\n end\n end", "def registration_is_open!\n unless ::Metadata.first.registration_open\n redirect_to root_path\n end\n end", "def first_login?\n \n m = ['projects', 'clients', 'tasks'].map { |n| n.to_sym }\n \n coll = m.map do |k|\n self.send(k).count\n end.unshift(self.sign_in_count)\n \n return coll.reject{ |x| x.nil? }.inject(:+) == 1\n end", "def first_login?\n \n m = ['projects', 'clients', 'tasks'].map { |n| n.to_sym }\n \n coll = m.map do |k|\n self.send(k).count\n end.unshift(self.sign_in_count)\n \n return coll.reject{ |x| x.nil? }.inject(:+) == 1\n end", "def logged_in?\n \t!current_staff.nil? || !current_student.nil? || !current_admin.nil?\n\tend", "def rollcall_student_required\n if current_user.is_rollcall_epi? || current_user.is_rollcall_health_officer? || current_user.is_rollcall_nurse? ||\n current_user.is_rollcall_admin?\n return true\n else\n redirect_to :action => \"unauthorized\", :controller => 'rollcall/rollcall_app'\n return false\n end\n end", "def check_company_signed_in\n redirect_to root_path, notice: 'Invalid permissions.' and return unless company_signed_in?\n end", "def needs_login?() false end", "def can_close_signup?\n @signup_closecross.visible?\n end", "def create?\n\t\tuser.course_grants > 0\n\tend", "def check_for_admin_or_org_account\n unless (user_signed_in? && current_user.admin?) || current_organization_account.present?\n redirect_to root_path\n end\n end", "def ensure_is_authorized_to_view\n @is_member_of_company = (@relation == :company_admin_own_site || @relation == :company_employee || @relation == :rentog_admin_own_site)\n\n # ALLOWED\n return if @relation == :rentog_admin ||\n @relation == :rentog_admin_own_site ||\n @relation == :domain_supervisor ||\n @relation == :company_admin_own_site\n\n\n # NOT ALLOWED\n # with error message\n flash[:error] = t(\"listing_events.you_have_to_be_company_member\")\n redirect_to root\n return false\n end", "def active?\n self.employee_authenticate && self.employee_profile\n end", "def logged_in?\n !current_personnel.nil?\n end", "def volunteer_logged_in?\n session[:id] && session[:volunteer]\n end", "def accepts_registrations?\n in_reg_period? and !invite_only?\n end", "def can_signup?(loc_group)\n permission_list.include?(loc_group.signup_permission) && self.is_active?(loc_group.department)\n end", "def create\n @bypass_sso = params[:sso_bypass] == 'true'\n if sign_in_params[:email].blank?\n # If the email was left blank display an error\n redirect_to root_path, alert: _('Invalid email address!')\n\n elsif sign_in_params[:org_id].present? && !@bypass_sso\n # If there is an Org in the params then this is step 2 of the email+password workflow\n # so just let Devise sign them in normally\n super\n\n else\n # If there is no Org then the user provided their email in step 1 so we need\n # to send them to the Sign in OR Sign up page\n clean_up_passwords(resource)\n\n # If this is a user with an invitation, then clean up the stub data\n active_invite = resource.active_invitation?\n\n if active_invite\n resource.firstname = nil\n resource.surname = nil\n resource.org = org_from_email_domain(email_domain: resource.email&.split('@')&.last)\n end\n\n is_new_user = resource.new_record? || active_invite\n\n # If this is the first time someone has tried to create an account for an Org, save it\n resource.org.save if is_new_user && resource.org.present? && resource.org.new_record?\n\n # If this is part of an API V2 Oauth workflow\n if session['oauth-referer'].present?\n oauth_hash = ApplicationService.decrypt(payload: session['oauth-referer'])\n\n @client = ApiClient.where(uid: oauth_hash['client_id'])\n\n render 'doorkeeper/authorizations/new', layout: 'doorkeeper/application'\n else\n render is_new_user ? 'users/registrations/new' : :new\n end\n end\n end", "def check_accounts\n\t\t( @participant.facebook_account != nil && @participant.facebook_account != \"\" ) ||\n\t\t( @participant.twitter_account != nil && @participant.twitter_account != \"\" ) ||\n\t\t( @participant.github_account != nil && @participant.github_account != \"\" ) ||\n\t\t( @participant.google_plus_account != nil && @participant.google_plus_account != \"\" )\n\tend", "def check_account_filling\n return unless depricated_page?\n\n redirect_to edit_account_path(current_account) unless\n request.get? &&\n current_user&.valid? &&\n current_account&.valid?\n end", "def can_enter?(user)\n self.is_active &&\n self.teams.include?(user.team) &&\n (self.start_date < Time.now) && (!self.finish_date || self.finish_date > Time.now)\n end", "def operational?\n @user1_confirmed && @user2_confirmed\n end", "def employee_logged_in?\n !current_employee.nil?\n end", "def employee_logged_in?\n !current_employee.nil?\n end", "def sign_up\n if @worksession.free == false\n respond_to do |format|\n format.html {\n flash[:notice] = 'Worksession is unavailable. Please choose another'\n redirect_to available_path\n }\n end\n else\n if !params[:notes].nil?\n @worksession.notes = params[:notes]\n end\n booking = Booking.create(user_id: @user.id, worksession_id: @worksession.id, notes: params[:notes])\n\n if Rails.env.production?\n url = URI.parse('http://worksessions-notifier.pierobotics.org/api/v0/signup/')\n else\n url = URI.parse('http://worksessions-notifier-staging.pierobotics.org/api/v0/signup/')\n end\n Net::HTTP.post_form(url, {\n 'notes' => booking.notes,\n 'date' => @worksession.date.strftime(\"%m/%d/%Y\"),\n 'start_time' => @worksession.begin_at.strftime(\"%I:%M %P\"),\n 'end_time' => @worksession.end_at.strftime(\"%I:%M %P\"),\n 'school' => @user.team_name,\n })\n\n # @worksession.users << @user\n if (@worksession.date.wday.between?(0, 1) and @worksession.users.size >= 8) or (@worksession.date.wday.between?(5, 6) and @worksession.users.size >= 4)\n @worksession.free = false\n @worksession.save\n end\n redirect_to available_path\n end\n\n end", "def check_firecloud_registration\n if user_signed_in?\n if current_user.registered_for_firecloud?\n # make sure user is part of user group\n if !current_user.added_to_unity_group?\n current_user.add_to_unity_user_group\n end\n else\n if user_fire_cloud_client(current_user).registered?\n current_user.add_to_unity_user_group\n current_user.update(registered_for_firecloud: true)\n true\n else\n redirect_to profile_path, notice: 'You must register before using Unity - please fill out the profile form and submit.' and return\n end\n end\n end\n end", "def check_user_github_organizations\n if Figaro.env.respond_to?(:github_organization)\n github_orgs_url = auth_hash.extra.raw_info.organizations_url + '?access_token=' + auth_hash.credentials.token\n user_organizations = get_user_github_organizations(github_orgs_url)\n unless user_organizations.include?(Figaro.env.github_organization)\n flash[:error] = \"You are not a member of the github organization '#{Figaro.env.github_organization}'\"\n logger.error \"User email '#{get_user_email}' is not in github organization '#{Figaro.env.github_organization}'\"\n return false\n end\n end\n\n true\n end", "def is_usable_for_sign_in\n return @is_usable_for_sign_in\n end", "def check_if_user_has_company\n if @user_company.nil?\n else\n redirect_to root_path\n flash[:danger] = I18n.t 'flash.access_deny_text'\n end\n end", "def open?\n registration_open_time < DateTime.now rescue false\n end", "def not_account_owner\n not_account_owner_in_signup && !is_account_owner? \n end", "def check_user_registration\n if not user_signed_in?\n return\n end\n\n redirect_path = current_user.administrator? ? user_signup_info_edit_path(current_user) : edit_user_path(current_user)\n\n if not current_user.done_registering?\n redirect_to redirect_path\n return\n end\n\n if current_user.administrator?\n admin = current_user.becomes(current_user.type.constantize)\n if admin.account.nil? or admin.account.apps.blank?\n redirect_to redirect_path\n return\n end\n end\n\n if session['omniauth.redirect']\n redirect_to session['omniauth.redirect']\n session['omniauth.redirect'] = nil\n return\n end\n end", "def share_cases?(account)\n if [AppConstants::PRIVILEGE[:super_user],AppConstants::PRIVILEGE[:admin],AppConstants::PRIVILEGE[:user_manager]].include?(portal_privilege) and account == company\n true\n else\n false\n end\n end", "def signed_in?\n return false if ! current_account.present?\n adie = Adie.find_by(github_username: current_account.username)\n domain = \"@adadevelopersacademy.org\"\n staff = Employee.where(\"email like ?\", \"%#{domain}\")\n\n if adie.nil? || staff.nil?\n flash[:notice] = \"You are not in the database and cannot log in. Please contact an administrator at info@adadevelopersacademy.org!\"\n end\n\n if adie.present? || staff.present?\n return true\n end\n\n end", "def logged_in?\n !current_person.nil?\n end", "def logged_in?\n !current_person.nil?\n end", "def valid_principals; end", "def require_login?\n !(Jiralicious.username.empty? && Jiralicious.password.empty?) && !alive?\n end", "def should_register_google_analytic_hits(the_login)\n result = true\n if !the_login.blank?\n if the_login.is_superuser?\n result = false\n else\n member_type_names = the_login.memberships.map{|m|m.member_type}.map{|t|t.member_type_desc}\n for name in member_type_names\n if name.downcase.include?(\"administrator\")\n result = false\n break\n end\n end\n end\n end\n result\n end", "def can_create_personal_login?\n teacher_managed_account? # once parent e-mail is added, we should check for it here\n end", "def logged_in?\n !current_employee.nil?\n end", "def logged_in?\n !current_employee.nil?\n end", "def logged_in?\n !current_doctor.nil?\n end", "def logged_in?\n !current_doctor.nil?\n end", "def ensure_auth # rubocop:disable Metrics/AbcSize, Metrics/MethodLength\n if session[:prospect_params]\n # we have an application going so we've probably just refreshed the\n # screen\n redirect_to action: 'new', controller: 'prospects'\n elsif session[:cas].nil? || session[:cas][:user].nil?\n render status: :unauthorized, plain: 'Redirecting to SSO...'\n else\n user = User.find_by cas_directory_id: session[:cas][:user]\n if user.nil?\n render status: :forbidden, plain: 'Unrecognized user'\n else\n update_current_user(user)\n end\n end\n nil\n end", "def sex_offender_check_pending?\n !background_check_authorized_at.nil? && (!passed_sex_offender_check? && sex_offender_check_run_at.nil?)\n end", "def employee_logged_in?\n !current_employee.nil?\n end", "def team_registration_open?\n d = @data_object\n today = Date.today\n d.aff_team_reg_start.to_date <= today && d.aff_team_reg_end.to_date >= today\n end", "def meetup_auto_create_account?\n self.meetup_auto_create_account\n end", "def username_and_password_check\n company = get_company\n if company == nil\n exit\n end\n if get_username_and_test_validity(company)\n if get_password_and_test_validity(company)\n else\n puts \"That is not the correct password, please try again.\"\n entry_menu\n end\n else \n puts \"That is not the correct username, please try again.\"\n entry_menu\n end\n end", "def verify_register_conclusion\n if !@user.face_confirmed?\n flash[:notice] = \"Insira um e-mail pessoal para receber nossos avisos.\"\n redirect_to email_completar_path\n return false\n end\n if !@user.is_completed?\n flash[:notice] = \"Conclua sua inscrição para acessar todas as funções do sistema\"\n #flash[:notice] = \"Não é possível finalizar seu cadastro. Aguarde até o dia 20 para se inscrever novamente!\"\n redirect_to cadastro_completar_path\n return false\n end\n end", "def allow_verification?\n logged_in? && correct_identifier? && pape_requirements_met?(auth_time)\n end", "def join_or_create_project_banner?\n return false unless logged_in_and_registered?\n return false if logged_in_and_member?\n return false if current_page?(create_or_join_project_home_path) ||\n current_page?(guided_create_projects_path) ||\n current_page?(guided_join_projects_path)\n\n #current_page? doesn't work with POST\n return false if ['request_join','request_create'].include?(action_name)\n\n return Seek::Config.programmes_enabled && Programme.site_managed_programme\n end", "def check_change_principle\n user_has_packages? || user_first_order? ? true : false\n end", "def signed_up_registrants(event)\n filter_registrants_for_signed_up_event(Registrant.active.competitor, event)\n end", "def check_permission\n if ((session[:register].nil? || session[:register]==false) &&\n (session[:student_current_user].nil? || session[:student_current_user]==false) &&\n (session[:admin_current_user].nil? || session[:admin_current_user]==false))\n redirect_to \"/registration_home/index\"\n end\n end", "def has_auth?\n !current_person.nil?\n end", "def registration_open?\n d = @data_object\n today = Date.today\n d.aff_reg_start.to_date <= today && d.aff_reg_end.to_date >= today\n end", "def person_logged_in?\n !session[:person_id].nil?\n end", "def registration_approval_required?; false; end", "def password_signup?\n if password_digest\n return false\n else\n bool1=(@non_signup_provider_bool == true)\n bool2=(@signup_provider_bool == true)\n bool1||bool2\n end\n end", "def organisation?\n session[:organisation] and session[:organisation].size > 0\n end", "def check_eligibility\n if params[:user_id].to_i == current_user.id\n redirect_to root_path, alert: \"Error: Owner can't collaborate\"\n end\n end", "def check_work_user\n owner = Work.friendly.find(params[:id]).user\n unless owner == current_user || current_user.is_admin?\n store_location\n flash[:error] = 'You are not authorized to perform this action.'\n redirect_to login_path\n end\n end", "def logged_in?\n !!current_donor\n end", "def users_joined?\n true\n end", "def logged_doctor_in?\n !current_doctor.nil?\n end", "def verify_existing_login\n return if cookies[GlobalConstant::Cookie.user_cookie_name.to_sym].blank?\n\n @response = CompanyApi::Request::Client.new(\n CompanyApi::Response::Formatter::Client,\n request.cookies,\n {\"User-Agent\" => http_user_agent}\n ).fetch_verify_cookie_details\n\n # success means user is already logged in, we would redirect to dashboard / planner\n # Error means user ain't logged in yet.\n return unless @response.success?\n\n @presenter_obj = ::WebPresenter::UserPresenter.new(@response, params)\n\n if @presenter_obj.client_token.step_three_done?\n redirect_to :dashboard, status: GlobalConstant::ErrorCode.temporary_redirect and return\n else\n redirect_to :planner, status: GlobalConstant::ErrorCode.temporary_redirect and return\n end\n\n end", "def student_logged_in?\n !current_student.nil?\n end", "def ensure_signup_complete\n # Ensure we don't go into an infinite loop\n return if action_name == 'finish_signup'\n\n # Redirect to the 'finish_signup' page if the user\n # email hasn't been verified yet\n if user_signed_in? && current_user && ( !current_user.email_verified?() || !current_user.username_verified?())\n redirect_to finish_signup_path(current_user)\n end\n end", "def any_oauth_register_enabled?\n facebook_register_enabled? ||\n github_register_enabled? ||\n linkedin_register_enabled? ||\n twitter_register_enabled? ||\n att_register_enabled?\n end", "def active_school_admin?\n school_admin_or_user? && school.active?\n end", "def check_correct_owners\n if current_admin.nil?\n if @referral.referral_email != current_user.email && @referral.user != current_user\n redirect_to(new_user_session_path, notice: \"You cannot view this referral. Please login to the correct account.\")\n end\n else\n if @referral.job.admin != current_admin && @referral.admin_id != current_admin.id\n redirect_to(new_user_session_path, notice: \"You cannot view this referral. Please login to the correct account.\")\n end\n end\n end", "def logged_in?\n\t\t!current_golfer.nil?\n\tend", "def registration_owned?\n if current_user\n current_user == Registration.find_by(id: params[:id]).user\n end\n end", "def open_to_public?\n allow_external_students? || allow_external_volunteers?\n end", "def attemp_signup\n\n end", "def check_instructor_info_initialized\n exists = InstructorInfo.exists?(current_user.id)\n create = controller_name == 'instructor_infos' && %w(new create).include?(action_name)\n if exists && create\n redirect_to(edit_instructor_info_path)\n elsif !exists && !create\n flash[:notice] = \"Page will be available after filling in your information.\"\n redirect_to(new_instructor_info_path)\n end\n end", "def logged_in?\n !!current_employee\n end", "def check_pending_registration!\n redirect_to dashboard_finish_registration_path if current_user.is_newbie?\n end", "def company_valid?\n return true if AccountType.individual?(account_type) || company.nil?\n\n company.valid?(account_type.registration_type.to_sym)\n end" ]
[ "0.6519415", "0.64361525", "0.63620067", "0.630236", "0.62322503", "0.62223345", "0.6175254", "0.6172759", "0.6172146", "0.6137977", "0.61055636", "0.6084167", "0.6084167", "0.6077931", "0.6064437", "0.6037957", "0.60218525", "0.59957254", "0.5983902", "0.59413975", "0.5935785", "0.5934714", "0.5910923", "0.5910923", "0.5900899", "0.58930993", "0.589052", "0.58840585", "0.58544934", "0.58420366", "0.58355093", "0.5821221", "0.5797079", "0.5793271", "0.5792648", "0.5786554", "0.57784134", "0.5777051", "0.5776594", "0.57666975", "0.57639647", "0.57555294", "0.57445216", "0.57445216", "0.57380533", "0.5733789", "0.5731389", "0.5727852", "0.57253534", "0.5717445", "0.57157737", "0.5714933", "0.5713374", "0.56993407", "0.5690208", "0.5690208", "0.568984", "0.5689289", "0.56890786", "0.56862193", "0.56815267", "0.56815267", "0.5674781", "0.5674781", "0.5668889", "0.5668888", "0.5666337", "0.5660599", "0.5658725", "0.56586313", "0.56577706", "0.56515807", "0.5650618", "0.56351215", "0.5632389", "0.5628919", "0.5628289", "0.5626299", "0.56257045", "0.56247777", "0.56229055", "0.5618411", "0.56182146", "0.56145066", "0.56127816", "0.56061727", "0.5603785", "0.560338", "0.5601116", "0.55995715", "0.5599456", "0.55989677", "0.558523", "0.5582819", "0.55822337", "0.5581325", "0.55806595", "0.5576847", "0.5569266", "0.5564952", "0.556099" ]
0.0
-1
GET /my_exams GET /my_exams.json
def index @my_exams = MyExam.all respond_to do |format| format.html # index.html.erb format.json { render json: @my_exams } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @exams = Exam.all\n end", "def index\n @course = Course.find(params[:course_id])\n @exams = @course.exams \n end", "def index\n\n\t\t@resource =\tUser.find_by_authentication_token(params[:auth_token])\n\t\t# byebug\n\t\treturn invalid_user unless @resource\n\t\t@exams = Exam.all\n\t\t# @user = current_user\n\tend", "def show\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam }\n end\n end", "def show\n @my_exam = MyExam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_exam }\n end\n end", "def get_existing_exams(user_id, course_id)\r\n get(Path::USERS_COURSES_EXAMS % [user_id, course_id])\r\n end", "def index\n @introexams = Introexam.all\n end", "def index\n @random_exams = RandomExam.all\n end", "def index\n redirect_to exams_path\n end", "def index\n @rand_exams = Xmt::Test::RandExam.all\n end", "def index\n @jams = Jam.all\n end", "def show\n @sentence = Sentence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sentence }\n end\n end", "def show\n @exam_user = ExamUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_user }\n end\n end", "def index\n @exams = Exam.all\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.csv { send_data @exams.to_csv }\n\t\tend\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @examinations }\n end\n end", "def index\n @exams = Exam.order(created_at: :desc).all\n end", "def index\n @ideas = Idea.current_ideas_for(current_user).entries\n respond_with(@ideas) do |format|\n format.json { render json: @ideas }\n end\n end", "def index\n @first_exams = FirstExam.all\n end", "def show\n Exam.find(params[:exam_id])\n\n user_exam = current_user.user_exams.find_or_initialize_by(exam_id: params[:exam_id])\n user_exam.save! unless user_exam.persisted?\n render json: UserExamRepresenter.new(user_exam).to_h\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @examples }\n end\n end", "def index\n if current_employee.user_role == 'employee'\n @exams = Exam.eager_load(team: :team_members).where(\"team_members.employee_id = ?\", current_employee.id)\n else\n @exams = Exam.all\n end\n end", "def index\n @response = JSON.parse(current_user.access_token.token.get('/api/v0/aspects'))\n @activities = @response\n respond_to do |format|\n format.html\n format.json {render :json=> @response, :callback=>params[:callback]}\n end\n end", "def searchByExperience\n\t\turl = request.original_url\n\t\t\n\t\tbegin\n\n\t\t\tprms = CGI.parse(URI.parse(url).query)\n\n\n\t\t\tresults = Doctor.where(\"experience LIKE ?\", \"%#{prms['experience'][0]}%\")\n\t\t\trender json: results\n\t\trescue Exception => e\n\t\t\trender json: { errors: \"Some errors\" }, status: 422\n\t\tend\n\tend", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end", "def show\n @examination = Examination.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @examination }\n end\n end", "def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def show\n @exam_option = ExamOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_option }\n end\n end", "def new\n @exam = Exam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam }\n end\n end", "def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @exercises }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @examination }\n end\n end", "def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end", "def new\n @my_exam = MyExam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @my_exam }\n end\n end", "def index\n @advances = user_capabilities(Advance).current_advances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @advances }\n end\n end", "def index\n @lesson_learneds = LessonLearned.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_learneds }\n end\n end", "def new\n @result_word = ResultWord.new\n @exam = Exam.find(params[:exam_id])\n @paper_words = PaperWord.find_all_by_paper_id(@exam.paper_id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result_word }\n end\n end", "def show\n @exam_code = ExamCode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_code }\n end\n end", "def index\n @absences = Absence.where(\"member_id = ?\",params[:member_id]).order(\"start_date DESC\").page(params[:page]).per(7)\n @member = Member.find(params[:member_id])\n \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @absences }\n end\n end", "def api\n url = \"https://wagon-dictionary.herokuapp.com/#{@answer}\"\n response = URI.open(url).read\n json = JSON.parse(response)\n return json['found']\n end", "def index\n @foams = Foam.order(\"lower(name) ASC\").all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @foams }\n end\n end", "def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end", "def show\n @exprience = Exprience.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exprience }\n end\n end", "def index\n if get_event\n @v1_answers = @event.alternatives\n render json: @v1_answers\n else\n @v1_answers = V1::Answer.all\n render json: @v1_answers\n end\n end", "def index\n if params[:meeting_id] && params[:team_id]\n @passages = Passage.includes(:team, :meeting).where(\n 'meetings.id' => params[:meeting_id],\n 'teams.id' => params[:team_id]\n ).to_a\n else\n @passages = []\n end\n render status: 200, json: @passages\n end", "def index\n @verbs = Verb.active.to_a \n @lines = @lines.where(:verb_id => params[:verb_id]) unless params[:verb_id].nil? \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lines }\n end\n end", "def show\n @lesson_learned = LessonLearned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson_learned }\n end\n end", "def index\n respond_to do |format|\n format.json { render :json => Phrase.all }\n end\n end", "def show\n @exercises = @programme.exercises\n if params[:search]\n @search = Exercise.search do\n fulltext params[:search]\n end\n @exSearch = @search.results\n else\n @exSearch = Exercise.all\n end\n end", "def index\n if params[:story_id].present?\n @invitations = Story.find(params[:story_id]).invitations\n else\n @invitations = Invitation.find_by_email(@current_user.email)\n end\n render json: @invitations\n end", "def index\n @enemies = Enemy.find_by(name: params[:name])\n render json: @enemies\n end", "def show\n render json: @answer\n end", "def biography artist\n url = \"http://developer.echonest.com/api/v4/artist/biographies?api_key=#{ECHONEST_API_KEY}&name=#{artist}&format=json\"\nend", "def index\n @ideas = current_user.ideas.page(params[\"page\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end", "def show\n @textanswer = Textanswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @textanswer }\n end\n end", "def show\n @excercise = Excercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @excercise }\n end\n end", "def index\n @exams = Exam.all.order(\"created_at desc\")\n end", "def index\n @team_challenges = TeamChallenge.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @team_challenges }\n end\n end", "def exams_statistics\n end", "def people\n Birdman::Requester.get(\"movies/#{id}/people\")\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def popular_jams\n PopularJams.popular_jams(@api_key, @https)\n end", "def index\n @verbs = Verb.all\n\n render json: @verbs\n end", "def show\n @faq = Faq.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @faq, include: 'subject' }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mood }\n end\n end", "def answers\n request('answers')\n end", "def index\n @audiences = Audience.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @audiences }\n end\n end", "def resumes_matching\n\t\tresp = @resp\n\t\t# Prcessing keyword values for matching resume list\n\t\tresp = Resume.resumes_matching(resp, params)\n\t\trender :json => resp\n end", "def answers\n @celebrity = Celebrity.find(params[:id])\n @answers = @celebrity.answers\n render json: @answers\n end", "def show\n @title = \"Key Word\"\n @key_word = KeyWord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: KeyWordArticle.map_json_data(@key_word) }\n end\n end", "def index\n @lectures = Lecture.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @lectures }\n end\n end", "def show\n @idiom = Idiom.find(params[:id])\n @essays = Essay.where(idiom_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @idiom }\n end\n end", "def index\n @ideas = Idea.all\n\n render json: @ideas\n end", "def index\n if params[:aspect_id]\n @questions = Aspect.find(params[:aspect_id]).questions.all\n else\n @questions = Question.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def show\n @mood = Mood.find(params[:id])\n respond_to do |format|\n format.any { render :json => @mood }\n end\n end", "def index\n @my_questions = MyQuestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_questions }\n end\n end", "def index\n @ideas = Idea.all\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @exercise }\n end\n end", "def index\n @episodes = Episode.accessible_by(current_ability).search(params[:search]).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @episodes }\n end\n end", "def index\n @ideas = Idea.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end", "def index\n @expertises = Expertise.all\n\n render json: @expertises\n end", "def index\n @exhibits = Exhibit.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exhibits }\n end\n end", "def index\n @experiences = Experience.paginate(page: params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @experiences }\n end\n end", "def index\n @instructor_texts = InstructorText.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @instructor_texts }\n end\n end", "def index\n @talks = Talk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @talks }\n end\n end", "def show\n @exercise = Exercise.find_by_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def index\n @question_answers = Question::Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @question_answers }\n end\n end", "def show\n @exam_category = ExamCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_category }\n end\n end", "def show \n @dilemma = Dilemma.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dilemma }\n end \n end", "def index\n @lessons = Lesson.all\n\n render 'index.json'\n end", "def index\n @solutions = @idea.solutions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @solutions }\n end\n end", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def index\n @essays = Essay.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @essays }\n end\n end", "def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end", "def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end", "def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end" ]
[ "0.69597405", "0.6736313", "0.643277", "0.63711256", "0.6279522", "0.62561756", "0.62325245", "0.60618776", "0.6056022", "0.60445017", "0.5982109", "0.59747404", "0.5951909", "0.59491444", "0.5907248", "0.5858777", "0.5805613", "0.57967013", "0.5796345", "0.5753043", "0.5752903", "0.57383347", "0.57223195", "0.5707469", "0.5707469", "0.5705198", "0.5703989", "0.5696959", "0.56880844", "0.56798744", "0.56798744", "0.56798744", "0.56798744", "0.56690943", "0.56582814", "0.5654508", "0.5646559", "0.5644275", "0.56253016", "0.56177205", "0.5613755", "0.561031", "0.56038314", "0.5602797", "0.5597378", "0.55824536", "0.557898", "0.55781746", "0.55756783", "0.55756545", "0.55676275", "0.5565396", "0.55594164", "0.5555869", "0.55556995", "0.5544413", "0.55382645", "0.5528691", "0.55060744", "0.55037254", "0.5501152", "0.5495563", "0.5491651", "0.5490515", "0.5490515", "0.5483356", "0.5480804", "0.54787475", "0.5473906", "0.5473522", "0.54719704", "0.54691476", "0.54673743", "0.54671973", "0.5463625", "0.54631966", "0.54630315", "0.5454797", "0.54510945", "0.54493386", "0.54482275", "0.54442143", "0.5439147", "0.54390925", "0.5438484", "0.5436964", "0.5434715", "0.54331", "0.54284376", "0.54282457", "0.5425984", "0.5418914", "0.5412517", "0.5411996", "0.54103553", "0.5409613", "0.5409501", "0.5406161", "0.5406161", "0.5406161" ]
0.74871546
0
GET /my_exams/1 GET /my_exams/1.json
def show @my_exam = MyExam.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @my_exam } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @my_exams = MyExam.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_exams }\n end\n end", "def index\n @exams = Exam.all\n end", "def show\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam }\n end\n end", "def index\n @course = Course.find(params[:course_id])\n @exams = @course.exams \n end", "def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end", "def show\n @exam_user = ExamUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_user }\n end\n end", "def index\n @introexams = Introexam.all\n end", "def show\n @exam_option = ExamOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_option }\n end\n end", "def show\n @sentence = Sentence.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sentence }\n end\n end", "def index\n\n\t\t@resource =\tUser.find_by_authentication_token(params[:auth_token])\n\t\t# byebug\n\t\treturn invalid_user unless @resource\n\t\t@exams = Exam.all\n\t\t# @user = current_user\n\tend", "def show\n @examination = Examination.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @examination }\n end\n end", "def get_existing_exams(user_id, course_id)\r\n get(Path::USERS_COURSES_EXAMS % [user_id, course_id])\r\n end", "def show\n begin\n @example = Example.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n # last URL parameter is not example ID, but the example's number\n @example = @language.examples.where(number: params[:id].to_i).first\n end\n @examples = [@example]\n respond_to do |format|\n format.html { render 'examples/index' } # also show index.html.erb\n format.json { render json: @example }\n end\n end", "def show\n Exam.find(params[:exam_id])\n\n user_exam = current_user.user_exams.find_or_initialize_by(exam_id: params[:exam_id])\n user_exam.save! unless user_exam.persisted?\n render json: UserExamRepresenter.new(user_exam).to_h\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @examinations }\n end\n end", "def new\n @exam = Exam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam }\n end\n end", "def show\n @exam_code = ExamCode.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_code }\n end\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @examples }\n end\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @exercises }\n end\n end", "def show\n @exprience = Exprience.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exprience }\n end\n end", "def index\n redirect_to exams_path\n end", "def show\n @exercise = Exercise.find_by_id(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exercise }\n end\n end", "def index\n @exercises = Exercise.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @exercises }\n end\n end", "def index\n @first_exams = FirstExam.all\n end", "def show\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @exercise }\n end\n end", "def fetch_experiment(id)\n url = @base + \"experiments/#{id}.json?token=#{@token}\"\n puts url\n response = JSON.parse(RestClient.get(url))\nend", "def index\n @jams = Jam.all\n end", "def index\n @random_exams = RandomExam.all\n end", "def show\n @idiom = Idiom.find(params[:id])\n @essays = Essay.where(idiom_id: params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @idiom }\n end\n end", "def new\n @my_exam = MyExam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @my_exam }\n end\n end", "def index\n @exams = Exam.order(created_at: :desc).all\n end", "def show\n @explaination = Explaination.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @explaination }\n end\n end", "def show\n @exam_category = ExamCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_category }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @examination }\n end\n end", "def index\n @rand_exams = Xmt::Test::RandExam.all\n end", "def show\n @lesson_learned = LessonLearned.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson_learned }\n end\n end", "def index\n\n @answers = Answer.current\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def show\n @exalt = Exalt.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exalt }\n end\n end", "def show\n @experiment = Experiment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiment }\n end\n end", "def show\n @experiment = Experiment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiment }\n end\n end", "def show\n @excercise = Excercise.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @excercise }\n end\n end", "def index\n @absences = Absence.where(\"member_id = ?\",params[:member_id]).order(\"start_date DESC\").page(params[:page]).per(7)\n @member = Member.find(params[:member_id])\n \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @absences }\n end\n end", "def index\n @ideas = Idea.current_ideas_for(current_user).entries\n respond_with(@ideas) do |format|\n format.json { render json: @ideas }\n end\n end", "def index\n @exams = Exam.all\n\t\trespond_to do |format|\n\t\t\tformat.html\n\t\t\tformat.csv { send_data @exams.to_csv }\n\t\tend\n end", "def index\n if get_event\n @v1_answers = @event.alternatives\n render json: @v1_answers\n else\n @v1_answers = V1::Answer.all\n render json: @v1_answers\n end\n end", "def show\n @mood = Mood.find(params[:id])\n respond_to do |format|\n format.any { render :json => @mood }\n end\n end", "def index\n @response = JSON.parse(current_user.access_token.token.get('/api/v0/aspects'))\n @activities = @response\n respond_to do |format|\n format.html\n format.json {render :json=> @response, :callback=>params[:callback]}\n end\n end", "def show\n @faq = Faq.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @faq, include: 'subject' }\n end\n end", "def new\n @result_word = ResultWord.new\n @exam = Exam.find(params[:exam_id])\n @paper_words = PaperWord.find_all_by_paper_id(@exam.paper_id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result_word }\n end\n end", "def getex\n url = prefix + \"getex\" + id_param\n return response(url)\n end", "def index\n @teaches = Teach.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @teaches }\n end\n end", "def index\n if params[:aspect_id]\n @questions = Aspect.find(params[:aspect_id]).questions.all\n else\n @questions = Question.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def index\n @advances = user_capabilities(Advance).current_advances\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @advances }\n end\n end", "def index\n @lesson_learneds = LessonLearned.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lesson_learneds }\n end\n end", "def show\n @quest = Quest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quest }\n end\n end", "def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def index\n @answers = Answer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answers }\n end\n end", "def show\n @absence = Absence.where(id: params[:id], user_id: params[:user_id])\n @title = \"User #{@absence.user_id} Absence\" \n respond_to do |format|\n format.html { render :file => \"absences/show\"}\n format.json { render json: @absence }\n end\n end", "def show\n @exercises = Exercise.where(\"chapter_id = ?\", params[:id]).order(:number)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chapter }\n end\n end", "def index\n @experiments = Experiment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @experiments }\n end\n end", "def biography artist\n url = \"http://developer.echonest.com/api/v4/artist/biographies?api_key=#{ECHONEST_API_KEY}&name=#{artist}&format=json\"\nend", "def show\n @experiencedetail = Experiencedetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @experiencedetail }\n end\n end", "def index\n @api_v1_exercises = Api::V1::Exercise.all\n end", "def show\n @advance = Advance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @advance }\n end\n end", "def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end", "def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end", "def show\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer }\n end\n end", "def show\n @essay = Essay.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @essay }\n end\n end", "def show\n @exhibition = Exhibition.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exhibition }\n end\n end", "def show\n @completed_quest = CompletedQuest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @completed_quest }\n end\n end", "def index\n @verbs = Verb.active.to_a \n @lines = @lines.where(:verb_id => params[:verb_id]) unless params[:verb_id].nil? \n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lines }\n end\n end", "def show\n @reminder_phrase = ReminderPhrase.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @reminder_phrase }\n end\n end", "def index\n @ideas = current_user.ideas.page(params[\"page\"])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ideas }\n end\n end", "def show\n @learn = Learn.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @learn }\n end\n end", "def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @questionnaire }\n end\n end", "def searchByExperience\n\t\turl = request.original_url\n\t\t\n\t\tbegin\n\n\t\t\tprms = CGI.parse(URI.parse(url).query)\n\n\n\t\t\tresults = Doctor.where(\"experience LIKE ?\", \"%#{prms['experience'][0]}%\")\n\t\t\trender json: results\n\t\trescue Exception => e\n\t\t\trender json: { errors: \"Some errors\" }, status: 422\n\t\tend\n\tend", "def show\n @textanswer = Textanswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @textanswer }\n end\n end", "def show\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @practice }\n end\n end", "def show\n @practice = Practice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @practice }\n end\n end", "def show\n @story = Story.find(params[:id])\n @epics = Epic.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @story }\n end\n end", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def index\n @enemies = Enemy.find_by(name: params[:name])\n render json: @enemies\n end", "def index\n @audiences = Audience.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @audiences }\n end\n end", "def show \n @dilemma = Dilemma.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dilemma }\n end \n end", "def show\n @irregular_verb = IrregularVerb.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @irregular_verb }\n end\n end", "def index\n @my_questions = MyQuestion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_questions }\n end\n end", "def new\n @exam_user = ExamUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam_user }\n end\n end", "def index\n @lessons = Lesson.all\n\n render 'index.json'\n end", "def show\n @title = \"View Team Challenge Score\"\n @challenge_grade = ChallengeGrade.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @challenge_grade }\n end\n end", "def index\n respond_to do |format|\n format.json { render :json => Phrase.all }\n end\n end", "def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end", "def show\n @lesson = Lesson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lesson }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end", "def show\n @participant = Participant.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @participant }\n end\n end" ]
[ "0.74351555", "0.6804366", "0.67775935", "0.66019934", "0.6292801", "0.6272089", "0.6157554", "0.61472136", "0.613771", "0.6120837", "0.60940826", "0.6082671", "0.60677797", "0.6046901", "0.6037483", "0.6015028", "0.5993006", "0.5988773", "0.5975579", "0.5975579", "0.59754854", "0.59754854", "0.59753823", "0.5963451", "0.59631926", "0.59336096", "0.59266657", "0.59251815", "0.5915709", "0.5907278", "0.5900111", "0.5896839", "0.5869818", "0.58633006", "0.5860725", "0.58572614", "0.58423275", "0.58153343", "0.5811451", "0.58004874", "0.5797474", "0.57865626", "0.57865626", "0.57857", "0.57829756", "0.5779547", "0.5778435", "0.5771159", "0.57546705", "0.5734795", "0.573257", "0.57276356", "0.5711645", "0.5710731", "0.56968427", "0.56918705", "0.568911", "0.568737", "0.56855893", "0.56855893", "0.56855893", "0.56855893", "0.56839347", "0.56753135", "0.5671941", "0.56648993", "0.5660485", "0.5657849", "0.564739", "0.5647362", "0.5647362", "0.5647362", "0.5646511", "0.5643826", "0.56283367", "0.5628193", "0.56246537", "0.5623381", "0.56230646", "0.5621748", "0.56172276", "0.5614448", "0.5613417", "0.5613417", "0.5609545", "0.56043017", "0.5602367", "0.56005335", "0.5599505", "0.559904", "0.5598203", "0.5597399", "0.55960554", "0.5594144", "0.55938625", "0.5591715", "0.55901337", "0.5588693", "0.5588693", "0.5588693" ]
0.6599216
4
GET /my_exams/new GET /my_exams/new.json
def new @my_exam = MyExam.new respond_to do |format| format.html # new.html.erb format.json { render json: @my_exam } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @exam = Exam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam }\n end\n end", "def new\n @sentence = Sentence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sentence }\n end\n end", "def new\n @exam_user = ExamUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam_user }\n end\n end", "def new\n @examination = Examination.new\n\t\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @examination }\n end\n end", "def new\n @exam_option = ExamOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam_option }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise }\n end\n end", "def new\n @exprience = Exprience.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exprience }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @exercise }\n end\n end", "def new\n @exam_code = ExamCode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam_code }\n end\n end", "def new\n @tutorial_quest = Tutorial::Quest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tutorial_quest }\n end\n end", "def new\n @quest = Quest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest }\n end\n end", "def new\n @exercice = Exercice.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercice }\n end\n end", "def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end", "def new\n @answer = Answer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end", "def new\n @experience = Experience.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @experience }\n end\n end", "def new\n @exercise = Exercise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @exercise }\n end\n\n end", "def new\n @essay = Essay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @essay }\n end\n end", "def new\n @exam_category = ExamCategory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam_category }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant }\n end\n end", "def new\n @participant = Participant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant }\n end\n end", "def new\n @explaination = Explaination.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @explaination }\n end\n end", "def new\n @patent = Patent.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patent }\n end\n end", "def new\n @irregular_verb = IrregularVerb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @irregular_verb }\n end\n end", "def new\n @expectation = Expectation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @expectation }\n end\n end", "def new\n @dilemma = Dilemma.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dilemma }\n end\n end", "def new\n @qa = Qa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @qa }\n end\n end", "def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talk }\n end\n end", "def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talk }\n end\n end", "def new\n @exp = Exp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exp }\n end\n end", "def new\n @advance = Advance.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @advance }\n end\n end", "def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @talk }\n end\n end", "def new\n @what = What.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @what }\n end\n end", "def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.haml\n format.json { render json: @talk }\n end\n end", "def new\n @experiment = Experiment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @experiment }\n end\n end", "def new\n @experiment = Experiment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @experiment }\n end\n end", "def new\n @experiment = Experiment.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @experiment }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @question }\n end\n end", "def new\n @quick_answer = QuickAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quick_answer }\n end\n end", "def new\n @assist = Assist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assist }\n end\n end", "def new\n @interested = Interested.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interested }\n end\n end", "def new\n @moose = Moose.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @moose }\n end\n end", "def new\n @experiment = Experiment.new\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @experiment }\n end\n end", "def new\n @my_question = MyQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @my_question }\n end\n end", "def new\n @lesson = Lesson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lesson }\n end\n end", "def new\n @absence = Absence.new\n @title = \"New Absence\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @absence }\n end\n end", "def new\n @exposition = Exposition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exposition }\n end\n end", "def new\n @passage = Passage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @passage }\n end\n end", "def new\n #@question = Question.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @foam = Foam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @foam }\n end\n end", "def new\n @immigrant = Immigrant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @immigrant }\n end\n end", "def new\n @learn = Learn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @learn }\n end\n end", "def new\n @mistake = Mistake.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mistake }\n end\n end", "def new\n @survey = Survey.new\n\n respond_to do |format|\n format.html # new.slim\n format.json { render json: @survey }\n end\n end", "def new\n @interesting = Interesting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @interesting }\n end\n end", "def new\n @saying = Saying.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @saying }\n end\n end", "def new\n @patentcase = Patentcase.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @patentcase }\n end\n end", "def new\n @title = \"New Subject\"\n @subject = Subject.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subject }\n end\n end", "def new\n @submitted_answer = SubmittedAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submitted_answer }\n end\n end", "def new\n @special_word = SpecialWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @special_word }\n end\n end", "def new\n @lesson_learned = LessonLearned.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lesson_learned }\n end\n end", "def new\n @title = t('view.surveys.new_title')\n @survey = Survey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @survey }\n end\n end", "def new\n @completed_quest = CompletedQuest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @completed_quest }\n end\n end", "def create\n @exam = Exam.new(params[:exam])\n\n respond_to do |format|\n if @exam.save\n format.html { redirect_to @exam, notice: 'Exam was successfully created.' }\n format.json { render json: @exam, status: :created, location: @exam }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @teach = Teach.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @teach }\n end\n end", "def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end", "def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end", "def new\n @verse = Verse.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @verse }\n end\n end", "def new\n @questionnaire = Questionnaire.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @questionnaire }\n end\n end", "def new\n @question = Question.new\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @question }\n end\n end", "def new\n @match = Match.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @match }\n end\n end", "def new\n @match = Match.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @match }\n end\n end", "def new\n @match = Match.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @match }\n end\n end", "def new\n @match = Match.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @match }\n end\n end", "def new\n @match = Match.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @match }\n end\n end", "def new\n @gotcha = Gotcha.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gotcha }\n end\n end", "def new\n @knowledge_points = KnowledgePoint.all\n @question = Question.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @question }\n end\n end", "def new\n @intake_question = IntakeQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @intake_question }\n end\n end", "def new\n @yourstory = Yourstory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @yourstory }\n end\n end", "def new\n @exam = Exam.new\n @dictionaries = Dictionary.all\n @difficulties = Difficulty.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @exam }\n end\n end", "def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end", "def new\n @challenge = Challenge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @challenge }\n end\n end", "def new\n @knowledge = Knowledge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @knowledge }\n end\n end", "def new\n @title = t 'view.teaches.new_title'\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @teach }\n end\n end", "def create\n @exam = current_user.exams.new(exam_params)\n respond_to do |format|\n if @exam.save\n format.html { redirect_to course_exams_url(@exam.course_id), notice: 'Exam was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exam }\n else\n format.html { render action: 'new' }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @exercise_plan = ExercisePlan.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exercise_plan }\n end\n end", "def new \n @faq = Faq.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @faq }\n end\n end", "def new\n @result_word = ResultWord.new\n @exam = Exam.find(params[:exam_id])\n @paper_words = PaperWord.find_all_by_paper_id(@exam.paper_id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result_word }\n end\n end", "def new\n @tutorial = Tutorial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tutorial }\n end\n end", "def new\n @tutorial = Tutorial.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tutorial }\n end\n end", "def new\n @activity = Activity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @activity }\n end\n end", "def new\n @activity = Activity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @activity }\n end\n end" ]
[ "0.7593478", "0.71986675", "0.7113014", "0.70557946", "0.70039195", "0.69941354", "0.69941354", "0.69941354", "0.69941354", "0.6951249", "0.6947157", "0.69334483", "0.69263786", "0.691952", "0.6895242", "0.68790585", "0.68790585", "0.6874897", "0.6874568", "0.6839693", "0.6839677", "0.6839182", "0.6839182", "0.6839182", "0.68113285", "0.6807729", "0.6803098", "0.6798634", "0.67977595", "0.6793498", "0.6790841", "0.6790841", "0.67877454", "0.67842877", "0.6783995", "0.67836565", "0.67830634", "0.67828083", "0.67828083", "0.6778249", "0.67764425", "0.67764425", "0.67764425", "0.67764425", "0.67764425", "0.67506367", "0.6741307", "0.67396945", "0.6732214", "0.6729225", "0.6728867", "0.6725464", "0.6722758", "0.6722027", "0.6717541", "0.6714752", "0.6714432", "0.6712343", "0.6709994", "0.67093784", "0.6706854", "0.6702719", "0.6700575", "0.66957545", "0.6693148", "0.669016", "0.6680792", "0.66771936", "0.667662", "0.66693646", "0.6668737", "0.6668524", "0.6665879", "0.66622275", "0.66622275", "0.66622275", "0.6661517", "0.6660907", "0.66609013", "0.66609013", "0.66609013", "0.66609013", "0.665717", "0.665642", "0.66525394", "0.66482455", "0.66478837", "0.6644026", "0.6637907", "0.6637907", "0.66357225", "0.66328895", "0.66268617", "0.6625597", "0.66245556", "0.6623647", "0.6613009", "0.6613009", "0.6612527", "0.6612527" ]
0.7325477
1
POST /my_exams POST /my_exams.json
def create @my_exam = MyExam.new(params[:my_exam]) respond_to do |format| if @my_exam.save format.html { redirect_to @my_exam, notice: 'My exam was successfully created.' } format.json { render json: @my_exam, status: :created, location: @my_exam } else format.html { render action: "new" } format.json { render json: @my_exam.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @my_exams = MyExam.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @my_exams }\n end\n end", "def create\n @exam = current_user.exams.new(exam_params)\n respond_to do |format|\n if @exam.save\n format.html { redirect_to course_exams_url(@exam.course_id), notice: 'Exam was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exam }\n else\n format.html { render action: 'new' }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exam = Exam.new(params[:exam])\n\n respond_to do |format|\n if @exam.save\n format.html { redirect_to @exam, notice: 'Exam was successfully created.' }\n format.json { render json: @exam, status: :created, location: @exam }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exam = Exam.new(exam_params)\n\n respond_to do |format|\n if @exam.save\n format.html { redirect_to @exam, notice: 'Exam was successfully created.' }\n format.json { render :show, status: :created, location: @exam }\n else\n format.html { render :new }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exam = Exam.new(exam_params)\n\n respond_to do |format|\n if @exam.save\n format.html { redirect_to @exam, notice: 'Exam was successfully created.' }\n format.json { render :show, status: :created, location: @exam }\n else\n format.html { render :new }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exam = Exam.new(exam_params)\n\n respond_to do |format|\n if @exam.save\n format.html { redirect_to @exam, notice: 'Exam was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exam }\n else\n format.html { render action: 'new' }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exam = Exam.new(exam_params)\n @exam.patient = @patient\n\n if @exam.save\n render json: @exam, include: [:point_po, :point_or, :point_n, :point_a], methods: :maxillary_depth_angle, status: :created\n else\n render json: @exam.errors, status: :unprocessable_entity\n end\n end", "def create\n @random_exam = RandomExam.new(random_exam_params)\n\n respond_to do |format|\n if @random_exam.save\n format.html { redirect_to @random_exam, notice: 'Random exam was successfully created.' }\n format.json { render :show, status: :created, location: @random_exam }\n else\n format.html { render :new }\n format.json { render json: @random_exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exam = Exam.new(exam_params)\n @exam.user = current_user\n\n respond_to do |format|\n if @exam.save\n format.html { redirect_to @exam, notice: 'Exam was successfully created.' }\n format.json { render :show, status: :created, location: @exam }\n else\n format.html { render :new }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @exam = Exam.new(exam_params)\n result=@exam.save\n @exam.add_questions_to_exam(@validated_question)\n respond_to do |format|\n if result\n format.html { redirect_to @exam, notice: \"已成功建立考试“#{@exam.name}.”\" }\n format.json { render :show, status: :created, location: @exam }\n else\n format.html { render :new }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @introexam = Introexam.new(introexam_params)\n\n respond_to do |format|\n if @introexam.save\n format.html { redirect_to @introexam, notice: 'Introexam was successfully created.' }\n format.json { render :show, status: :created, location: @introexam }\n else\n format.html { render :new }\n format.json { render json: @introexam.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @exams = Exam.all\n end", "def new\n @exam = Exam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam }\n end\n end", "def exam_params\n\t\t\tparams.require(:exam).permit(:title, :date, :unit_id, \n\t\t\t\tquestions_attributes:[ :id, :question, :exam_id,\t:_destroy,\n\t\t\t\tresponse_attributes:[:id, :answer, :question_id, :video,:_destroy]]\n\t\t\t\t)\n\t\tend", "def new\n @result_word = ResultWord.new\n @exam = Exam.find(params[:exam_id])\n @paper_words = PaperWord.find_all_by_paper_id(@exam.paper_id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @result_word }\n end\n end", "def new\n @my_exam = MyExam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @my_exam }\n end\n end", "def create\n @exam = Exam.new(params[:exam])\n\n respond_to do |format|\n if @exam.save\n format.html { redirect_to exams_path, notice: 'Exam was successfully created.' }\n format.json { render json: exams_path, status: :created, location: @exam }\n else\n format.html { \n flash[:error] = 'Exam name can not be left blank.'\n render action: \"new\"\n }\n format.json { render json: exams_path.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n @survey = Survey.new(json)\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Survey was successfully created.' }\n format.json { render json: @survey, status: :created, location: @survey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:exam][:state] ||= nil\n @exam = Exam.new(exam_params)\n\n respond_to do |format|\n if @exam.save\n format.html { redirect_to @exam, notice: 'Exam was successfully created.' }\n format.json { render :show, status: :created, location: @exam }\n else\n format.html { render :new }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @exam = Exam.new(exam_params)\r\n\r\n if @exam.save\r\n redirect_to @exam, notice: \"Exam was successfully created.\"\r\n else\r\n render :new, status: :unprocessable_entity\r\n end\r\n end", "def create\n @exam_user = ExamUser.new(params[:exam_user])\n\n respond_to do |format|\n if @exam_user.save\n format.html { redirect_to @exam_user, notice: 'Exam user was successfully created.' }\n format.json { render json: @exam_user, status: :created, location: @exam_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exam_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def exam_params\n params.require(:exam).permit(:name, :level, :description, :experience,\n questions_attributes: [:id, :exam_id, :content, '_destroy',\n answers_attributes: [:id, :question_id, :content, :correct, '_destroy' ] ])\n end", "def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend", "def create\n respond_to do |format|\n if ExamSubject.create(exam_subject_params[:exam_subject])\n format.html { redirect_to exams_path, notice: 'Exam marks saved.' }\n else\n format.html { render :new }\n end\n end\n end", "def new\n @sentence = Sentence.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sentence }\n end\n end", "def create\n @examquestion = Examquestion.new(examquestion_params)\n\n respond_to do |format|\n if @examquestion.save\n format.html { redirect_to @examquestion, notice: 'Examquestion was successfully created.' }\n format.json { render action: 'show', status: :created, location: @examquestion }\n else\n format.html { render action: 'new' }\n format.json { render json: @examquestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_should_create_invite_via_API_JSON\r\n get \"/logout\"\r\n post \"/invites.json\", :api_key => 'testapikey',\r\n :invite => {:message => 'API Invite 1',\r\n :accepted => false,\r\n :email => 'test@email.com',\r\n :user_id => 1 }\r\n assert_response :created\r\n invite = JSON.parse(response.body)\r\n check_new_invite(invite) \r\n end", "def create\n @emily = Emily.new(emily_params)\n\n respond_to do |format|\n if @emily.save\n format.html { redirect_to @emily, notice: 'Emily was successfully created.' }\n format.json { render :show, status: :created, location: @emily }\n else\n format.html { render :new }\n format.json { render json: @emily.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @course = Course.find(params[:course_id])\n @exams = @course.exams \n end", "def create\n @sentence = Sentence.new(sentence_params)\n\n respond_to do |format|\n if @sentence.save\n format.html { redirect_to @sentence, notice: 'Sentence was successfully created.' }\n format.json { render json: @sentence, status: :created, location: @sentence }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sentence.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exosuit = Exosuit.new(exosuit_params)\n\n respond_to do |format|\n if @exosuit.save\n format.html { redirect_to @exosuit, notice: 'Exosuit was successfully created.' }\n format.json { render :show, status: :created, location: @exosuit }\n else\n format.html { render :new }\n format.json { render json: @exosuit.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\t\n\tquestion_param = question_params.merge(:words => in_words(question_params[\"answer\"].to_i))\n @question = Question.new(question_param)\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n\t#=end\n end", "def exam_params\n params[:exam]\n params.permit(:file, :posttype, :year, :user_id, :course_id, :examtype, :accepted, :acceptedby)\n end", "def submit_form\n answers_params = params.permit!\n\n render json: Answer.insert_answers(answers_params, current_user[\"id\"])\n end", "def create\n @sentence = Sentence.new(sentence_params)\n\n respond_to do |format|\n if @sentence.save\n format.html { redirect_to @sentence, notice: 'Sentence was successfully created.' }\n format.json { render :show, status: :created, location: @sentence }\n else\n format.html { render :new }\n format.json { render json: @sentence.errors, status: :unprocessable_entity }\n end\n end\n end", "def handle_post(body)\n make_response(200, validate_questions(body))\nend", "def survey\n expose Survey.create(@oauth_token, params[:challenge_id].strip, \n params[:data])\n end", "def create\n @answer = AttemptAnswer.new(answer_params) \n \n if @answer.save\n render json: @answer, status: :created \n else\n head(:unprocessable_entity)\n end\n end", "def answers\n request('answers')\n end", "def create\n @exam_set = ExamSet.new(exam_set_params)\n\n respond_to do |format|\n if @exam_set.save\n format.html { redirect_to @exam_set, notice: 'Exam set was successfully created.' }\n format.json { render :show, status: :created, location: @exam_set }\n else\n format.html { render :new }\n format.json { render json: @exam_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exam = Exam.new(exam_params)\n authorize @exam\n respond_to do |format|\n if @exam.save\n format.html { redirect_to @exam, notice: 'Exam was successfully created.' }\n format.json { render action: 'show', status: :created, location: @exam }\n else\n format.html { render action: 'new' }\n end\n end\n end", "def POST; end", "def create\n @user_say = current_user.user_says.create(user_say_params)\n\n respond_to do |format|\n if @user_say.save\n if @user_say.extract_data == true\n Lesson.where(intent: @user_say.intent, bot_id: @user_say.bot_id).take.update(extract_data: true)\n #создаем регулярку с capture groups и сохраняем их в отдельное поле\n @user_say.update(regexp: @user_say.make_regexp(Regexp.new(Regexp.escape(@user_say.input), \"i\").to_s)) \n # создаем ключ-переменную для привязки примеров переменной\n if @user_say.input.match(/@[\\wа-я]+/i)\n @user_say.input.to_enum(:scan, /(@[\\wа-я]+)/i).map { Regexp.last_match }.each do |a|\n i = 0\n unless Key.where(bot_id: @user_say.bot_id, name: a[i]).take\n Key.create(name: a[i], bot_id: @user_say.bot_id, user_say_id: @user_say.id, lesson_id: @user_say.lesson_id)\n end\n i = i + 1 \n end\n end \n end\n format.html { redirect_to @user_say.bot, notice: 'User say was successfully created.' }\n format.json { render :show, status: :created, location: @user_say }\n else\n format.html { redirect_to @user_say.bot }\n format.json { render json: @user_say.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @survey = Survey.find(params[:survey_id])\n emoji = params[:emoji]\n mood = params[:mood]\n @feeling = Feeling.new(mood: mood, emoji: emoji)\n @survey.feelings << @feeling\n\n if @feeling.save\n render :ok, json: @feeling\n else\n @errors = @feelings.error.full_messages\n render json: {message: @errors}, status: :unprocessable_entity\n end\n\n if !@survey\n render json: {message: [\"Survey is Required!\"] }, status: :unprocessable_entity\n end\n end", "def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end", "def sync_user_answers\n return head :ok if params[:user_answers].blank?\n\n user_exam = current_user.user_exams.find(params[:id])\n user_exam.user_answers.create! user_answers_params\n\n head :ok\n end", "def create\n @v1_answer = current_user.answers.new(v1_answer_params)\n if @v1_answer.save\n render json: @v1_answer, status: :created\n else\n render json: @v1_answer.errors, status: :unprocessable_entity\n end\n end", "def new\n @exam_user = ExamUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @exam_user }\n end\n end", "def exam_params\n params.require(:exam).permit(:user_id, :title, :description, :exam_date, :place, files: [], :tag_ids=>[])\n end", "def answer_params\n params.require(:answer).permit(:content)\n end", "def answer_params\n params.require(:answer).permit(:content)\n end", "def new\n @textanswer = Textanswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @textanswer }\n end\n end", "def create\n @frase = Frase.new(frase_params)\n\n respond_to do |format|\n if @frase.save\n format.html { redirect_to @frase, notice: 'Frase was successfully created.' }\n format.json { render :show, status: :created, location: @frase }\n else\n format.html { render :new }\n format.json { render json: @frase.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exam_result = ExamResult.new(exam_result_params)\n\n respond_to do |format|\n if @exam_result.save\n format.html { redirect_to @exam_result, notice: 'Exam result was successfully created.' }\n format.json { render :show, status: :created, location: @exam_result }\n else\n format.html { render :new }\n format.json { render json: @exam_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n question_response = QuestionResponse.build_response_essay(current_user, params)\n\n if question_response.try :save\n render json: { message: \"answer saved\" }\n else\n render json: { message: \"error\" }, status: :unprocessable_entity\n end\n end", "def create\n @answer_respondent = AnswerRespondent.new(answer_respondent_params)\n\n respond_to do |format|\n if @answer_respondent.save\n format.html { redirect_to @answer_respondent, notice: 'Answer respondent was successfully created.' }\n format.json { render :show, status: :created, location: @answer_respondent }\n else\n format.html { render :new }\n format.json { render json: @answer_respondent.errors, status: :unprocessable_entity }\n end\n end\n end", "def answer\n survey = Survey.find(find_params)\n sa = SurveyAnswerer.new(survey)\n\n if sa.answer(answer_params)\n head :ok\n else\n render json: sa.errors, status: :unprocessable_entity\n end\n end", "def create\n @program = Program.new(params[:program])\n @program.user_id = current_user.id\n token = current_user.access_token\n\n respond_to do |format|\n if @program.save\n payload = JSON.generate(\n {\n :activity => {\n :actor => {\n :name => current_user.full_name,\n :email => current_user.email\n },\n :action => 'create',\n :object => {\n :url => 'http://localhost:3000/programs/' + @program.id.to_s,\n :type => 'page',\n :title => @program.name + \" signup form\"\n }\n }\n })\n\n connection = Net::HTTP.new(\"www.yammer.com\", 443) # Create the connection to Yammer API\n connection.use_ssl = true # Enable SSL\n\n raw_response = connection.post(\"https://www.yammer.com/api/v1/activity.json?access_token=#{token}\", payload, {\n \"Content-Type\" => \"application/json\",\n \"Content-Length\" => payload.length.to_s\n })\n\n format.html { redirect_to \"/programs\", notice: 'Program was successfully created.' }\n format.json { render json: \"/programs\", status: :created, location: @programs }\n else\n format.html { render action: \"new\" }\n format.json { render json: @program.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n category = params[:text].scan(/#(\\w+)/).flatten\n\n idea = Idea.create!(\n content: params[:text],\n category: category,\n user: User.find_by(uid: params[:user_id]),\n channel: params[:channel_name],\n stage: \"seed\"\n )\n json = {\n \"text\": \"#{idea.content}\",\n \"attachments\": [\n {\n \"text\": \"#{idea.user.firstname} just logged a new idea!\",\n \"fallback\": \"You are unable to choose a game\",\n \"callback_id\": \"wopr_game\",\n \"color\": \"#3AA3E3\",\n \"attachment_type\": \"default\",\n \"actions\": [\n {\n \"name\": \"game\",\n \"text\": \"endorse\",\n \"type\": \"button\",\n \"value\": \"chess\"\n },\n {\n \"name\": \"game\",\n \"text\": \"Suggest\",\n \"type\": \"button\",\n \"value\": \"maze\"\n },\n ]\n }\n ]\n }\n\n render json: json\n end", "def exam_params\n params.require(:exam).permit(:name, :exam_type, :difficulty_level, :course_id, :full_mark, :no_of_questions)\n end", "def create\n #p params\n if params[:results].present? && params[:results][:answers].present?\n answers = params[:results][:answers] \n params[:results].delete :answers\n #params[:aspects]=params[:aspects]+1\n end\n\n #p \"Array?: \" + params[:results][:aspects].is_a?(Array).to_s\n #p \"String?: \" + params[:results][:aspects].is_a?(String).to_s\n \n @results = Result.create(params[:results])\n if answers\n answers.each do |answer|\n @results.answers.build(answer)\n end\n end\n\n if @results.save\n\n # @results.send_email\n @results.delay.send_email\n end\n\n respond_with(@results)\n end", "def introexam_params\n params.require(:introexam).permit(:title, :message, :picture1, :testimonial1, :picture2, :testimonial2, :picture3, :testimonial3)\n end", "def mockexam_params\n params.require(:mockexam).permit(:name, :level_id, :subject_id, {:mock_questions => [{:mock_answers => [:mock_question_id, :content], :mock_correct_answers => [:content,:mock_answer_id] } ]})\n end", "def create\n @answers = params[:user_answers]\n @answers.each do |key, value|\n UserAnswer.create(:user_id => current_user.id, :survey_question_id => key.to_i, :text => value)\n end\n redirect_to :root\n end", "def answer_params\n params.require(:answer).permit(:content)\n end", "def answer_params\n params.require(:answer).permit(:content)\n end", "def answer_params\n params.require(:answer).permit(:content)\n end", "def answer_params\n params.require(:answer).permit(:content)\n end", "def answer_params\n params.require(:answer).permit(:content)\n end", "def index\n redirect_to exams_path\n end", "def create\n answer = Answer.new(content: params[:content], upvotes: 0, downvotes:0, user_id: params[:user_id], question_id: params[:question_id])\n \n if answer.save\n render json: {answer: answer, create_time: (answer.created_at.to_f * 1000).to_i, success: true}\n else\n render json: @answer.errors, success: false\n end\n end", "def create_exams\n Course.all.each do |course|\n next if is_attending?(course) or succeeded_in?(course)\n\n exam_options = {\n :student_id => self.id,\n :course_id => course.id,\n :number => course.number,\n :attempt => attempts_for(course) + 1,\n :registered_at => Time.now\n }\n\n exams << Exam.create(exam_options)\n end\n end", "def exam_params\n params.require(:exam).permit(:name)\n end", "def exam_params\n params.require(:exam).permit(:title)\n end", "def create\n @first_exam = FirstExam.new(first_exam_params)\n\n respond_to do |format|\n if @first_exam.save\n format.html { redirect_to @first_exam, notice: 'First exam was successfully created.' }\n format.json { render :show, status: :created, location: @first_exam }\n else\n format.html { render :new }\n format.json { render json: @first_exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @exam = Exam.new(params[:exam])\n @exam.user_id = current_user.id\n\n respond_to do |format|\n if @exam.save\n flash[:notice] = 'Exam was successfully created.'\n format.html { redirect_to(@exam) }\n format.xml { render :xml => @exam, :status => :created, :location => @exam }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @exam.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n # @answer = Answer.new\n # @answer.user_id = current_user.もid\n # @answer.question_id = params[:question_id]\n # @answer.content = params[:content]\n # @answer.save\n # 一個保存できれば、何個でも保存できる\n if !params[:answer][:content]\n render json: {errors: \"未入力の項目があります。\"}, status: 422\n\n end\n @answer = current_user.answers.build(answer_params)\n @answer.save\n end", "def answer_params\n params.require(:answer).permit(:body)\n end", "def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @answer = Answer.new(params[:answer])\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @hero_phrase = HeroPhrase.new(hero_phrase_params)\n\n respond_to do |format|\n if @hero_phrase.save\n format.html { redirect_to @hero_phrase, notice: 'Hero phrase was successfully created.' }\n format.json { render :show, status: :created, location: @hero_phrase }\n else\n format.html { render :new }\n format.json { render json: @hero_phrase.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_answer\n request('answers/add')\n end", "def create\n # puts params\n questions = JSON.parse(params[:questions])\n q_hash = questions[\"questions\"]\n @assignment = Assignment.new\n @assignment.course_id = params[:course_id]\n @assignment.type = \"Homework\"\n @assignment.start_date = params[:start_date]\n @assignment.end_date = params[:end_date]\n @assignment.name = params[:name]\n # Following is the question hash\n q_hash.each do |key, value|\n a_hash = key[\"answers\"]\n question = key[\"question\"]\n puts question\n new_question = Question.new\n new_question.description = question\n new_question.type = \"MultipleChoice\"\n # Answer hash\n a_hash.each do |k,v|\n puts k[\"is_correct\"]\n puts k[\"description\"]\n new_answer = Answer.new\n new_answer.description = k[\"description\"]\n new_answer.is_correct = k[\"is_correct\"]\n new_question.association(:answers).add_to_target(new_answer)\n end\n @assignment.association(:questions).add_to_target(new_question)\n end\n \n if @assignment.save\n render :show, status: :created, location: @assignment\n else\n render json: @assignment.errors, status: :unprocessable_entity\n end\n end", "def api_request(name) \n\tresponse = HTTParty.post('https://api.talentiq.co/v2/person', \n :body => {:name => name }.to_json,\n :headers => { 'Content-Type' => 'application/json', \n \t\t\t'x-api-key:' => 'e058cdd334c69c31d45d87e44b405d128a9e8937939e7d0ab2496334',\n 'Accept' => 'application/json' })\n puts response.body\nend", "def create\n @emotional_word = EmotionalWord.new(params[:emotional_word])\n\n respond_to do |format|\n if @emotional_word.save\n format.html { redirect_to(@emotional_word, :notice => 'Emotional word was successfully created.') }\n format.xml { render :xml => @emotional_word, :status => :created, :location => @emotional_word }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @emotional_word.errors, :status => :unprocessable_entity }\n end\n end\n end", "def exam_params\n params.require(:exam).permit(:exam_type, :name,:brief)\n end", "def create_mod\n if params[:title] != nil && params[:content] != nil && params[:subId] != nil && params[:userId] != nil && params[:groupId] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n @question.subId = params[:subId].to_i\n @question.userId = params[:userId].to_i\n @question.groupId = params[:groupId].to_i\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/createQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully created\"\n redirect_to questions_path\n\n end\n end", "def perform(id, texts, is_tokenized: false)\n params = { id: id, texts: texts, is_tokenized: is_tokenized }\n response = HTTP.post(\"#{@host}/encode\", json: params)\n embeddings = JSON.parse(response.to_s)['result']\n embeddings\n end", "def create\n return\n teacher = Teacher.find_by_name(params[:teacher])\n user = User.new(:username => params[:username])\n\n teacher.users << user\n \n user.record_exam(params)\n\n respond_to do |format|\n format.html { render :status => 200, :text => 'done' }\n end\n end", "def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @answer, notice: 'Answer was successfully created.' }\n format.json { render action: 'show', status: :created, location: @answer }\n else\n format.html { render action: 'new' }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def exam_params\n params.require(:event)\n .permit(:lecture_title, :description, :email, :duration)\n .merge(num_times: 0)\n .merge(event_type: 'exam')\n end", "def response_params\n params.require(:response).permit(:user, :questionnaire_id, answers_attributes: [:id, :content, :question_id])\n end", "def create\n @exam_option = ExamOption.new(params[:exam_option])\n\n respond_to do |format|\n if @exam_option.save\n format.html { redirect_to @exam_option, notice: 'Exam option was successfully created.' }\n format.json { render json: @exam_option, status: :created, location: @exam_option }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exam_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n idea_hash = params[:idea]\n idea_hash[:idea_actions] = idea_hash[:idea_actions].blank? ? [] : idea_hash[:idea_actions].map { | action_attrs | IdeaAction.new(action_attrs.merge(member: current_member)) }\n idea_hash[:talks] = idea_hash[:talks].blank? ? [] : idea_hash[:talks].map { | talk_attrs | Talk.find(talk_attrs[:id]) }\n\n @idea = Idea.new(idea_hash)\n @idea.member = member\n\n respond_to do |format|\n if @idea.save\n format.json { render json: @idea, status: :created, location: @idea }\n else\n format.json { render json: @idea.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @submitted_answer = SubmittedAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submitted_answer }\n end\n end", "def index\n @introexams = Introexam.all\n end", "def create \n\t\tquestionId = params[:questionId]\n\t\tanswerId = params[:answerId]\n\t\tanswer = params[:answer]\n\t\tnumAnswers = params[:numAnswers].to_i\n\n\t\tbegin\n\t\t\tsuccess = ParseManager.createUserAnswer(answer, answerId, questionId)\n\t\t\tnumAnswers -= 1\n\t\tend until numAnswers == 0\n\n\t\trender json:success\n\tend", "def create\n @examination = Examination.new(params[:examination])\n respond_to do |format|\n if @examination.save\n format.html { redirect_to @examination, notice: 'Examination was successfully created.' }\n format.json { render json: @examination, status: :created, location: @examination }\n else\n format.html { render action: \"new\" }\n format.json { render json: @examination.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.61441857", "0.6086509", "0.59997255", "0.59955865", "0.59955865", "0.59372014", "0.58337593", "0.5766544", "0.57370776", "0.56390977", "0.5620361", "0.55895036", "0.55798846", "0.5563627", "0.55165786", "0.5514264", "0.55109465", "0.5504571", "0.5500483", "0.5494432", "0.54786426", "0.54713887", "0.54663056", "0.5463348", "0.54601383", "0.54538274", "0.54531074", "0.54440993", "0.543784", "0.5432159", "0.54234225", "0.54233235", "0.5421921", "0.5417982", "0.5417778", "0.5407786", "0.5395168", "0.5393217", "0.5383926", "0.5369347", "0.5369106", "0.53688985", "0.5364688", "0.53532654", "0.5319879", "0.53133726", "0.5301296", "0.52958864", "0.5295827", "0.52944463", "0.52944463", "0.52932674", "0.52887267", "0.5276374", "0.5267788", "0.5265366", "0.5265211", "0.5264958", "0.5262502", "0.52619886", "0.52592915", "0.52586913", "0.52584976", "0.5255983", "0.5253625", "0.5253625", "0.5253625", "0.5253625", "0.5253625", "0.5242236", "0.5228355", "0.52263224", "0.5214607", "0.52106863", "0.5200589", "0.5198718", "0.5195269", "0.5188141", "0.5186938", "0.5186938", "0.51809245", "0.51809245", "0.5178174", "0.51777214", "0.517251", "0.5159167", "0.5154279", "0.5152112", "0.51427513", "0.5142714", "0.5142161", "0.5138439", "0.5136352", "0.5132669", "0.5132012", "0.5128889", "0.5125804", "0.51231396", "0.5120094", "0.51159114" ]
0.5986983
5
PUT /my_exams/1 PUT /my_exams/1.json
def update @my_exam = MyExam.find(params[:id]) respond_to do |format| if @my_exam.update_attributes(params[:my_exam]) format.html { redirect_to @my_exam, notice: 'My exam was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @my_exam.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n if @exam.update_attributes(params[:exam])\n format.html { redirect_to exams_path, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n if @exam.update_attributes(params[:exam])\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def put!\n request! :put\n end", "def update\n respond_to do |format|\n if @exam.update(exam_params)\n format.html { redirect_to course_exams_url(@exam.course_id), notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exam.update(exam_params)\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exam.update(exam_params)\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { render :show, status: :ok, location: @exam }\n else\n format.html { render :edit }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exam.update(exam_params)\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { render :show, status: :ok, location: @exam }\n else\n format.html { render :edit }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exam.update(exam_params)\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { render :show, status: :ok, location: @exam }\n else\n format.html { render :edit }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exam.update(exam_params)\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { render :show, status: :ok, location: @exam }\n else\n format.html { render :edit }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n if @exam.update_attributes(params[:exam])\n flash[:notice] = 'Exam was successfully updated.'\n format.html { redirect_to(@exam) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @exam.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @random_exam.update(random_exam_params)\n format.html { redirect_to @random_exam, notice: 'Random exam was successfully updated.' }\n format.json { render :show, status: :ok, location: @random_exam }\n else\n format.html { render :edit }\n format.json { render json: @random_exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exam_user = ExamUser.find(params[:id])\n\n respond_to do |format|\n if @exam_user.update_attributes(params[:exam_user])\n format.html { redirect_to @exam_user, notice: 'Exam user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n @exam_option = ExamOption.find(params[:id])\n\n respond_to do |format|\n if @exam_option.update_attributes(params[:exam_option])\n format.html { redirect_to @exam_option, notice: 'Exam option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @introexam.update(introexam_params)\n format.html { redirect_to @introexam, notice: 'Introexam was successfully updated.' }\n format.json { render :show, status: :ok, location: @introexam }\n else\n format.html { render :edit }\n format.json { render json: @introexam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize @exam\n respond_to do |format|\n if @exam.update(exam_params)\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n end\n end\n end", "def update!(**args)\n @exam_id = args[:exam_id] if args.key?(:exam_id)\n @exam_type = args[:exam_type] if args.key?(:exam_type)\n @token = args[:token] if args.key?(:token)\n end", "def update\n respond_to do |format|\n if @api_v1_exercise.update(api_v1_exercise_params)\n format.html { redirect_to @api_v1_exercise, notice: 'Exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_exercise }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exam_subject.update(exam_subject_params)\n format.html { redirect_to @exam_subject, notice: 'Exam subject was successfully updated.' }\n format.json { render :show, status: :ok, location: @exam_subject }\n else\n format.html { render :edit }\n format.json { render json: @exam_subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @examquestion.update(examquestion_params)\n format.html { redirect_to @examquestion, notice: 'Examquestion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @examquestion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @first_exam.update(first_exam_params)\n format.html { redirect_to @first_exam, notice: 'First exam was successfully updated.' }\n format.json { render :show, status: :ok, location: @first_exam }\n else\n format.html { render :edit }\n format.json { render json: @first_exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @verb = Verb.find(params[:id])\n\n if @verb.update(verb_params)\n head :no_content\n else\n render json: @verb.errors, status: :unprocessable_entity\n end\n end", "def update_mod\n if params[:title] != nil && params[:content] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully updated\"\n redirect_to questions_path\n end\n end", "def update\n respond_to do |format|\n if @exosuit.update(exosuit_params)\n format.html { redirect_to @exosuit, notice: 'Exosuit was successfully updated.' }\n format.json { render :show, status: :ok, location: @exosuit }\n else\n format.html { render :edit }\n format.json { render json: @exosuit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exam_set.update(exam_set_params)\n format.html { redirect_to @exam_set, notice: 'Exam set was successfully updated.' }\n format.json { render :show, status: :ok, location: @exam_set }\n else\n format.html { render :edit }\n format.json { render json: @exam_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @emily.update(emily_params)\n format.html { redirect_to @emily, notice: 'Emily was successfully updated.' }\n format.json { render :show, status: :ok, location: @emily }\n else\n format.html { render :edit }\n format.json { render json: @emily.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @faq.update(faqs_params)\n json_response(@faq)\n end", "def update\n @sentence = Sentence.find(params[:id])\n\n respond_to do |format|\n if @sentence.update_attributes(sentence_params)\n format.html { redirect_to @sentence, notice: 'Sentence was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sentence.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @answer = Answer.find(params[:id])\n\n if @answer.update(answer_params)\n head :no_content\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end", "def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def update\n respond_to do |format|\n if @visit.update(visit_params)\n format.html { redirect_to location_after_save, notice: 'Visit was successfully updated.' }\n format.json { head :no_content }\n else\n if visit_params[:exams_attributes].present?\n flash[:error] = 'Attachment is invalid.'\n format.html { redirect_to location_after_save }\n else\n format.html { render action: 'edit' }\n end\n format.json { render json: @visit.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @answer = current_user.answers.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.json { head :no_content }\n else\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n unless @edit_or_delete_right\n redirect_to exams_url,notice:\"您无权修改别人编写的考试\"\n end\n parsed_param=exam_params\n @exam.questions.delete_all\n @exam.add_questions_to_exam(@validated_question)\n respond_to do |format|\n if @exam.update(parsed_param)\n format.html { redirect_to @exam, notice: \"已成功更新考试“#{@exam.name}.”\" }\n format.json { render :show, status: :ok, location: @exam }\n else\n format.html { render :edit }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n question = Question.find_by!(id: params[:id])\n if question\n question.name = params[:name]\n question.description = params[:description]\n question.user_id = params[:user_id]\n question.category_id = params[:category_id]\n question.zavrseno = params[:zavrseno]\n question.uposlenik_id = params[:uposlenik_id]\n question.save\n render json: question, status: 200 \n else\n render json: { errors: \"This link is invalid.\"}, status: 404\n end\n end", "def update\n respond_to do |format|\n if @exapmle.update(exapmle_params)\n format.html { redirect_to @exapmle, notice: 'Exapmle was successfully updated.' }\n format.json { render :show, status: :ok, location: @exapmle }\n else\n format.html { render :edit }\n format.json { render json: @exapmle.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, @theorem\n if @theorem.update(theorem_params)\n render json: @theorem, status: :ok, location: @theorem\n else\n render json: @theorem.errors, status: :unprocessable_entity\n end\n end", "def update\n @idea = Idea.find(params[:id])\n respond_with(@idea) do |format|\n if @idea.update_attributes(params[:idea])\n format.json { render json: @idea, status: :created, location: @idea }\n else\n format.json { render json: @idea.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @exam = Exam.shod(params[:id])\n @exam_group = @exam.exam_group\n @batch = @exam.exam_group.batch\n @subjects = @batch.subjects.where(no_exams: false)\n authorize! :update, @exam\n end", "def set_exam\n @exam = @student.exams.find(params[:id])\n end", "def update\n @exprience = Exprience.find(params[:id])\n\n respond_to do |format|\n if @exprience.update_attributes(params[:exprience])\n format.html { redirect_to @exprience, notice: 'Exprience was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exprience.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(*args)\n request :put, *args\n end", "def update\n update_init(@written_exam)\n respond_to do |format|\n if @written_exam.update(written_exam_params)\n format.html { redirect_to @written_exam, notice: 'Written exam was successfully updated.' }\n format.json { render :show, status: :ok, location: @written_exam }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, :notice => 'exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @exercise.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(path, options={})\n request :put, path, options\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @experience = Experience.find(params[:id])\n respond_to do |format|\n if @experience.update_attributes(params[:experience])\n format.html { redirect_to @experience, notice: 'Experience was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exercise = Exercise.find(params[:id])\n\n respond_to do |format|\n if @exercise.update_attributes(params[:exercise])\n format.html { redirect_to @exercise, notice: 'Exercise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @oferta_academica = OfertaAcademica.find(params[:id])\n\n if @oferta_academica.update(params[:oferta_academica])\n head :no_content\n else\n render json: @oferta_academica.errors, status: :unprocessable_entity\n end\n end", "def update\n @expectation_stem = RiGse::ExpectationStem.find(params[:id])\n\n respond_to do |format|\n if @expectation_stem.update_attributes(params[:expectation_stem])\n flash[:notice] = 'RiGse::ExpectationStem.was successfully updated.'\n format.html { redirect_to(@expectation_stem) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @expectation_stem.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\tquestion_param = question_params.merge(:words => in_words(question_params[\"answer\"].to_i))\n\trespond_to do |format|\n if @question.update(question_param)\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\t\n end", "def update\r\n if @exam.update(exam_params)\r\n redirect_to @exam, notice: \"Exam was successfully updated.\"\r\n else\r\n render :edit, status: :unprocessable_entity\r\n end\r\n end", "def edit_question\n\t\t\tquizzes = current_instructor.quizzes\n\t\t\t@found = 0\n\t\t\tquizzes.each do |quiz|\n\t\t\t\tif(quiz.questions.exists?(:id => params[:question_id]))\n\t\t\t\t\t@found = @found + 1\n\t\t\t\tend \n\t\t\tend\n\t\t\tif (@found > 0)\n\t\t\t\tquestion = Question.find(params[:question_id])\n\t\t\t\tif (question.update(question_params))\n\t\t\t\t\trender json: { success: true, data: { :question => question }, info:{} }, status: 200\n\t\t\t\telse\n\t\t\t\t\trender json: { error: question.errors }, status: 422 \n\t\t\t\tend\t\n\t\t\telse\n\t\t\t\trender json: { error:\"Question is not found\" }, status: 422\n\t\t\tend\n\t\tend", "def update\n params[:examination][:usesOfDrug_ids] ||= []\n params[:examination][:resistancesToDrug_ids] ||= []\n params[:examination][:mutation_ids] ||= []\n @examination = Examination.find(params[:id])\n\n respond_to do |format|\n if @examination.update_attributes(params[:examination])\n format.html { redirect_to @examination, notice: 'Examination was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @examination.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n fn = params[:id].gsub('DOTDOT','.').gsub('SLASHSLASH','/')\n File.open(fn,'w+') { |f| \n f.puts params[:content]\n }\n respond_to do |format|\n format.json { render json: { success: true} }\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def update\n @explaination = Explaination.find(params[:id])\n\n respond_to do |format|\n if @explaination.update_attributes(params[:explaination])\n format.html { redirect_to @explaination, notice: 'Explaination was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @explaination.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_exams\n @course = Course.find(params[:course_id])\n end", "def update\n @faq = Faq.find(params[:id])\n\n respond_to do |format|\n if @faq.update_attributes(params[:faq])\n format.html { redirect_to @faq, notice: 'FAQ atualizada com sucesso.' }\n format.json { head :no_content }\n else\n @subjects = Subject.all\n format.html { render action: \"edit\" }\n format.json { render json: @faq.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exam_code = ExamCode.find(params[:id])\n\n respond_to do |format|\n if @exam_code.update_attributes(params[:exam_code])\n format.html { redirect_to @exam_code, notice: 'Exam code was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam_code.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def put(path, options={})\n send_request 'put', path, options\n end", "def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end", "def update\n if @exam.update(exam_params)\n render json: @exam, include: [:point_po, :point_or, :point_n, :point_a], methods: :maxillary_depth_angle\n else\n render json: @exam.errors, status: :unprocessable_entity\n end\n end", "def update\n @question = Question.update(params[:id], { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n respond_to do |format|\n format.json { render :json => @question.as_json({:include => :answers}) }\n\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render :action => \"edit\" }\n # format.json { render :json => @question.errors, :status => :unprocessable_entity }\n # end\n end\n end", "def update\n word = Word.find(params[:id])\n word.gender = params[:gender]\n if word.save\n head :ok\n end\n end", "def update\n respond_to do |format|\n if @sentence.update(sentence_params)\n format.html { redirect_to @sentence, notice: 'Sentence was successfully updated.' }\n format.json { render :show, status: :ok, location: @sentence }\n else\n format.html { render :edit }\n format.json { render json: @sentence.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_answer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def update\n Symptom.find(params[:id]).update(symptom_params)\n render response: { :message => \"Symptom successfully edited.\"}\n end", "def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def update\n authorize! :edit, @questionnaire\n\n @questionnaire.load_JSON(params[:questionnaire], current_user)\n\n respond_to do |format|\n# if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Kysymyslomakkeen muokkaaminen onnistui.' }\n format.json { head :no_content }\n# else\n# format.html { render action: \"edit\" }\n# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n# end\n\n end\n end", "def update\n respond_to do |format|\n if @subject_of_speech.update(subject_of_speech_params)\n format.html { redirect_to @subject_of_speech, notice: 'Subject of speech was successfully updated.' }\n format.json { render :show, status: :ok, location: @subject_of_speech }\n else\n format.html { render :edit }\n format.json { render json: @subject_of_speech.errors, status: :unprocessable_entity }\n end\n end\n end", "def answered\n @the_question = Question.find(params[:id])\n @the_question.answered = true\n @the_question.save\n render json: [{question: @the_question}]\n end", "def update\n @symptom = Symptom.find(params[:id])\n\n if @symptom.update(symptom_params)\n render json: @symptom, status: :updated\n else\n render json: @symptom.errors, status: :unprocessable_entity\n end\n end", "def update\n @moose = Moose.find(params[:id])\n\n respond_to do |format|\n if @moose.update_attributes(params[:moose])\n format.html { redirect_to @moose, notice: 'Moose was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @moose.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n @question.update_attributes(params[:question])\n render :json => @question.id if @question.save\n # respond_to do |format|\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to(@question, :notice => 'Question was successfully updated.') }\n # format.xml { head :ok }\n # else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n # end\n # end\n end", "def perform_put(path, options = {})\n perform_request(:put, path, options)\n end", "def update\n @word = Word.find(params[:id])\n\n respond_to do |format|\n\n if @word.update_attributes(params[:word])\n format.json { head :no_content }\n else\n format.json { render :json => @word.errors,\n :status => :unprocessable_entity }\n end\n\n end\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def put(path, options = {})\n request(:put, path, options)\n end", "def update\n @my_question = MyQuestion.find(params[:id])\n\n respond_to do |format|\n if @my_question.update_attributes(params[:my_question])\n format.html { redirect_to @my_question, notice: 'My question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @team = Team.find(params[:id])\n\n if @team.update_attributes(params[:team])\n head :no_content\n else\n render json: @team.errors, status: :unprocessable_entity\n end\n end", "def update\n @emotional_word = EmotionalWord.find(params[:id])\n\n respond_to do |format|\n if @emotional_word.update_attributes(params[:emotional_word])\n format.html { redirect_to(@emotional_word, :notice => 'Emotional word was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @emotional_word.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @answer = Answer.find(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to @answer, notice: 'Answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n question = Question.find(params[:id_question])\n if question.update(params_question)\n render json: question, status: 200\n else\n render json: question.errors, status: 422\n end\n\n end", "def put_update(options = {})\n options[:id] ||= @phone.id\n options[:phone] ||= @attributes\n\n # options[:email][@email.id.to_s] = @attributes\n put :update,options\n end", "def set_api_v1_exercise\n @api_v1_exercise = Api::V1::Exercise.find(params[:id])\n end", "def set_api_v1_exercise\n @api_v1_exercise = Api::V1::Exercise.find(params[:id])\n end", "def update\n respond_to do |format|\n if @rand_exam.update(rand_exam_params)\n @rand_exam.cache_paper_reset\n format.html { redirect_to xmt_test_exams_path, notice: '编辑成功.' }\n format.json { render :show, status: :ok, location: @rand_exam }\n else\n format.html { render :edit }\n format.json { render json: @rand_exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @exam_student.update(exam_student_params)\n format.html { redirect_to @exam_student, notice: 'Exam student was successfully updated.' }\n format.json { render :show, status: :ok, location: @exam_student }\n else\n format.html { render :edit }\n format.json { render json: @exam_student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.json { render :json => 'Question updated OK' }\n format.xml { head :ok }\n else\n format.json { render :json => @question.errors }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @sentence = Sentence.find(params[:id])\n\n success = @sentence.add_sentence(params[:sentence])\n @story.save if success\n\n respond_to do |format|\n if success && @story.update_attributes(params[:story])\n if @story.finished\n format.html { redirect_to story_path(@story) }\n else\n format.html { redirect_to stories_path, notice: 'Story was successfully updated.' }\n format.json { head :ok }\n end\n else\n format.html { render \"edit\" }\n format.json { render json: @story.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @skill = Skill.find(params[:id])\n\n if @skill.update(skill_params)\n head :no_content\n else\n render json: @skill.errors, status: :unprocessable_entity\n end\n end", "def update\n if @v1_question.update(v1_question_params)\n render json: @v1_question, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def update\n @dilemma = Dilemma.find(params[:id])\n\n respond_to do |format|\n if @dilemma.update_attributes(params[:dilemma])\n format.html { redirect_to @dilemma, notice: \"Ok your dilemma has been updated, let's hope you have it right this time.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dilemma.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.64303535", "0.63440514", "0.6166141", "0.61212033", "0.6035428", "0.60242563", "0.60242563", "0.60242563", "0.60242563", "0.5959499", "0.5910932", "0.5886689", "0.5871076", "0.5867297", "0.5799167", "0.57983476", "0.57724565", "0.5735059", "0.57146245", "0.5683933", "0.56825733", "0.56670314", "0.5663717", "0.56628656", "0.5650737", "0.5619684", "0.5600946", "0.5600273", "0.559908", "0.5590668", "0.558823", "0.5587267", "0.55859834", "0.558256", "0.55473936", "0.5540105", "0.55395275", "0.5536166", "0.55328214", "0.55325025", "0.5528751", "0.5526614", "0.5522083", "0.5521589", "0.5513886", "0.55137366", "0.55077285", "0.5501246", "0.5501246", "0.5501246", "0.5497687", "0.5496399", "0.54867893", "0.5486322", "0.5484333", "0.5482045", "0.5470493", "0.54654056", "0.546171", "0.5453352", "0.5439696", "0.5437011", "0.5435901", "0.5433741", "0.5433174", "0.54311836", "0.5425243", "0.542402", "0.54223526", "0.54217374", "0.5414619", "0.5414619", "0.54108226", "0.5410357", "0.5399671", "0.539795", "0.539087", "0.53817695", "0.5379183", "0.53730404", "0.53653413", "0.5365295", "0.5364141", "0.5364141", "0.53637683", "0.5357467", "0.5357415", "0.53573865", "0.53573865", "0.5353354", "0.53457606", "0.5345085", "0.5345085", "0.5343402", "0.5337016", "0.53364396", "0.5331524", "0.5331281", "0.5329466", "0.5326306" ]
0.6154803
3
DELETE /my_exams/1 DELETE /my_exams/1.json
def destroy @my_exam = MyExam.find(params[:id]) @my_exam.destroy respond_to do |format| format.html { redirect_to my_exams_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @exam = Exam.find(params[:id])\n @exam.destroy\n\n respond_to do |format|\n format.html { redirect_to exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam = Exam.find(params[:id])\n @exam.destroy\n\n respond_to do |format|\n format.html { redirect_to(exams_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exam.destroy\n respond_to do |format|\n format.html { redirect_to course_exams_url(@exam.course_id) }\n format.json { head :no_content }\n end\n end", "def destroy\n # @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url, notice: 'Exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @random_exam.destroy\n respond_to do |format|\n format.html { redirect_to random_exams_url, notice: 'Random exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @file = current_user.past_exams.find(params[:id])\n\t\t@file.destroy\n respond_to do |format|\n format.html { redirect_to file_infos_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url, notice: 'Exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url, notice: 'Exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url, notice: 'Exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @explaination = Explaination.find(params[:id])\n @explaination.destroy\n\n respond_to do |format|\n format.html { redirect_to explainations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @first_exam.destroy\n respond_to do |format|\n format.html { redirect_to first_exams_url, notice: 'First exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @examan.destroy\n respond_to do |format|\n format.html { redirect_to examen_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @introexam.destroy\n respond_to do |format|\n format.html { redirect_to introexams_url, notice: 'Introexam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def destroy\n @exam_user = ExamUser.find(params[:id])\n @exam_user.destroy\n\n respond_to do |format|\n format.html { redirect_to exam_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @examination = Examination.find(params[:id])\n @examination.destroy\n\n respond_to do |format|\n format.html { redirect_to examinations_url }\n format.json { head :ok }\n end\n end", "def destroy\n @exam_option = ExamOption.find(params[:id])\n @exam_option.destroy\n\n respond_to do |format|\n format.html { redirect_to exam_options_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sentence = Sentence.find(params[:id])\n @sentence.destroy\n\n respond_to do |format|\n format.html { redirect_to sentences_url }\n format.json { head :ok }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @example.update_attributes(:deleted => 1)\n respond_to do |format|\n format.html { redirect_to examples_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exprience = Exprience.find(params[:id])\n @exprience.destroy\n\n respond_to do |format|\n format.html { redirect_to expriences_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam.destroy\n authorize @exam\n respond_to do |format|\n format.html { redirect_to exams_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @examquestion.destroy\n respond_to do |format|\n format.html { redirect_to examquestions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_exercise.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_exercises_url, notice: 'Exercise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expectation = Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to expectations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise = Exercise.find(params[:id])\n @exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise.destroy\n respond_to do |format|\n format.html { redirect_to exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exalt = Exalt.find(params[:id])\n @exalt.destroy\n\n respond_to do |format|\n format.html { redirect_to exalts_url }\n format.json { head :ok }\n end\n end", "def destroy\n @exosuit.destroy\n respond_to do |format|\n format.html { redirect_to exosuits_url, notice: 'Exosuit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @file_example.destroy\n respond_to do |format|\n format.html { redirect_to file_examples_url, notice: 'File example was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @verb.destroy\n\n head :no_content\n end", "def destroy\n @normal_example = NormalExample.find(params[:id])\n @normal_example.destroy\n\n respond_to do |format|\n format.html { redirect_to(normal_examples_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @answer = Answer.find_by_key(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam.destroy\n respond_to do |format|\n format.html { redirect_to patient_url(@patient), notice: 'Exam was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete!\n request! :delete\n end", "def destroy\n @annex = Annex.find(params[:id])\n @annex.destroy\n\n respond_to do |format|\n format.html { redirect_to annexes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam_category = ExamCategory.find(params[:id])\n @exam_category.destroy\n\n respond_to do |format|\n format.html { redirect_to exam_categories_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @exam_student.destroy\n respond_to do |format|\n format.html { redirect_to exams_url, notice: 'Odjavili ste ispit.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evangelism.destroy\n respond_to do |format|\n format.html { redirect_to evangelisms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @thesis_examination.destroy\n respond_to do |format|\n format.html { redirect_to thesis_examinations_url }\n format.json { head :no_content }\n end\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @exam_subject.destroy\n respond_to do |format|\n format.html { redirect_to exam_subjects_url, notice: 'Exam subject was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @my_exercise = MyExercise.find(params[:id])\n @my_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to(my_exercises_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @verb.destroy\n respond_to do |format|\n format.html { redirect_to verbs_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @exam = Exam.find(params[:id])\n authorize! :delete, @exam\n @exam.destroy\n redirect_to exams_exam_group_path(@exam.exam_group)\n end", "def destroy\n @exam_set.destroy\n respond_to do |format|\n format.html { redirect_to exam_sets_url, notice: 'Exam set was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @anything.destroy\n respond_to do |format|\n format.html { redirect_to anythings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qa = Qa.find(params[:id])\n @qa.destroy\n\n respond_to do |format|\n format.html { redirect_to qas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exapmle.destroy\n respond_to do |format|\n format.html { redirect_to exapmles_url, notice: 'Exapmle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(options={})\n connection.delete(\"/\", @name)\n end", "def destroy\n @survey_answer_item = SurveyAnswerItem.find(params[:id])\n @survey_answer_item.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_answer_items_url }\n format.json { head :no_content }\n end\n end", "def delete\n \n end", "def destroy\n @tutorial_quest = Tutorial::Quest.find(params[:id])\n @tutorial_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorial_quests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @examination.destroy\n\n respond_to do |format|\n format.html { redirect_to @examination.project }\n format.json { head :no_content }\n end\n end", "def delete_questions\n response = Request.delete_request(URL_QUESTION)\n if response.success?\n redirect '/upload-csv'\n end\nend", "def destroy\n @ai_contest = AiContest.find(params[:id])\n @ai_contest.destroy\n\n respond_to do |format|\n format.html { redirect_to ai_contests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @written_exam.destroy\n respond_to do |format|\n format.html { redirect_to written_exams_url, notice: 'Written exam was successfully destroyed.' }\n end\n end", "def destroy\n @essay = Essay.find(params[:id])\n @essay.destroy\n\n respond_to do |format|\n format.html { redirect_to essays_url }\n format.json { head :ok }\n end\n end", "def destroy\n @irregular_verb = IrregularVerb.find(params[:id])\n @irregular_verb.destroy\n\n respond_to do |format|\n format.html { redirect_to irregular_verbs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @jam = Jam.find(params[:id])\n @jam.destroy\n\n respond_to do |format|\n format.html { redirect_to jams_url }\n format.json { head :no_content }\n end\n end", "def delete(name)\n @ctx.delete(@path + name)\n end", "def destroy\n @sentence.destroy\n respond_to do |format|\n format.html { redirect_to sentences_url, notice: 'Sentence was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @advocacy = Advocacy.find(params[:id])\n @advocacy.destroy\n\n respond_to do |format|\n format.html { redirect_to advocacies_url }\n format.json { head :ok }\n end\n end", "def delete(path)\n request(:delete, path)\n end", "def destroy\n @oncourse_exercise.destroy\n respond_to do |format|\n format.html { redirect_to oncourse_exercises_url }\n format.json { head :no_content }\n end\n end", "def delete\n api_client.delete(url)\n end", "def destroy\n @expectation = RiGse::Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exercise_plan = ExercisePlan.find(params[:id])\n @exercise_plan.destroy\n\n respond_to do |format|\n format.html { redirect_to exercise_plans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aspect = Aspect.find(params[:id])\n @aspect.destroy\n\n respond_to do |format|\n format.html { redirect_to(aspects_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n answer = Answer.find(params[:answer_id])\n answer.destroy\n \n render json: {success: true}\n end", "def destroy\n @example.destroy\n respond_to do |format|\n format.html { redirect_to examples_url, notice: 'Operação realizada com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionnaire.destroy\n respond_to do |format|\n format.html { redirect_to questionnaires_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aliexpress = Aliexpress.find(params[:id])\n @aliexpress.destroy\n\n respond_to do |format|\n format.html { redirect_to aliexpresses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @intention = Intention.find(params[:id])\n @intention.destroy\n\n respond_to do |format|\n format.html { redirect_to intentions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exp = Exp.find(params[:id])\n @exp.destroy\n\n respond_to do |format|\n format.html { redirect_to exps_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @examination = Examination.find(params[:id])\r\n @examination.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(list_examinations_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @exhibition = Exhibition.find(params[:id])\n @exhibition.destroy\n\n respond_to do |format|\n format.html { redirect_to exhibitions_url }\n format.json { head :no_content }\n end\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def delete(*rest) end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @patient_exercise = PatientExercise.find(params[:id])\n @patient_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to patient_exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy_rest\n @entry_answer = EntryAnswer.find(params[:id])\n @entry_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(entry_answers_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @do_exercise = DoExercise.find(params[:id])\n @do_exercise.destroy\n\n respond_to do |format|\n format.html { redirect_to do_exercises_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.73418057", "0.71732163", "0.70905197", "0.692606", "0.691144", "0.6909299", "0.6881308", "0.6849361", "0.6839646", "0.6839646", "0.6839646", "0.68239444", "0.67956245", "0.67746824", "0.675569", "0.6749452", "0.67456764", "0.67290425", "0.66978794", "0.66743493", "0.6655176", "0.6622941", "0.66134816", "0.6599395", "0.6578735", "0.6571425", "0.656406", "0.65610135", "0.6553783", "0.6553783", "0.6553783", "0.6553783", "0.6553641", "0.65509087", "0.65509087", "0.6546229", "0.6542253", "0.6540357", "0.6528997", "0.6525015", "0.651878", "0.65157706", "0.65009815", "0.6495499", "0.64941955", "0.6493627", "0.6487839", "0.64770395", "0.64770395", "0.64770395", "0.64770395", "0.6473394", "0.64705974", "0.6460151", "0.64551353", "0.64539033", "0.6440588", "0.6435252", "0.6428523", "0.6411066", "0.63997394", "0.63943166", "0.63916475", "0.63865435", "0.63863474", "0.6383354", "0.6381533", "0.6380225", "0.6376992", "0.6374442", "0.6372255", "0.6371792", "0.6368929", "0.63650125", "0.63649833", "0.63648593", "0.6364793", "0.636271", "0.63583434", "0.6357114", "0.6356284", "0.6351509", "0.6349435", "0.6348458", "0.6348005", "0.63463676", "0.63446856", "0.63380456", "0.6334462", "0.6334338", "0.63339305", "0.6333609", "0.63303345", "0.632852", "0.63272023", "0.63267803", "0.6324728", "0.63236505", "0.6323233", "0.63213545" ]
0.7298862
1
GET /checklocations/1 GET /checklocations/1.json
def show @checklocation = Checklocation.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @checklocation } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def locations\n get('locations')\n end", "def get_location\n as_json(get_results('/locations.json'))\n end", "def index\n locations = Location.all\n render json: locations\n end", "def index\n @api_v1_locations = Api::V1::Location.all\n respond_to do |format|\n format.html { @api_v1_locations }\n format.json { render json: {results: @api_v1_locations, message: 'Locations have loaded successfully.'} }\n end\n end", "def show\n respond_to do |format|\n format.html { @api_v1_location }\n format.json { render json: {results: @api_v1_location, message: 'Locations have loaded successfully.'} }\n end\n end", "def index\n @locs = Loc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locs }\n end\n end", "def new\n @checklocation = Checklocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @checklocation }\n end\n end", "def index\n locations = @project.locations.all\n render json: { locations: locations }\n end", "def index\n @user_locations = ::Users::UserLocation.where(user_id: auth_user.id).order('is_primary desc')\n @page_title = 'Your Addresses'\n\n respond_to do|format|\n format.html\n format.json { render json: @user_locations }\n end\n end", "def locations(place)\n get :loc => place\n end", "def show\n render json: Location.find(params[\"id\"])\n end", "def index\r\n @locations = Location.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end", "def index\r\n @locations = Location.all\r\n @mv = MapsVersion.first\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @locations }\r\n end\r\n end", "def index\n @locations = Location.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @locations }\n end\n end", "def show\n @location_have_location = LocationHaveLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location_have_location }\n end\n end", "def index\n @service_locations = ServiceLocation.all\n render json: @service_locations\n end", "def show\n @campus_food = CampusFood.find(params[:id])\n\t@loc = params[:loc]\n\t\n\t@locations = Location.all(:conditions =>[ \"loc like ? \", \"%#{params[:loc]}%\"])\n\tif !@locations.empty?\n @lat = @locations[0].lat\n @lng = @locations[0].lng\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @locations }\n end\n end", "def locations\n @client.get('/BikePoint')\n end", "def show\n render :json => Location.find(params[:id])\n end", "def get_json\n response = @api.request(:get, @location)\n response.body if response.status == 200\n end", "def lookup\n respond_to do |format|\n @grid = Grid.find_by_location(params[:location])\n format.json {render json: @grid.colors, status: :ok, location: @grid }\n end\n end", "def index\n @items_locations = ItemsLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items_locations }\n end\n end", "def index\n # @checkpoints = Checkpoint.all\n @route = Route.find(params[:route_id])\n @checkpoints = @route.checkpoints\n # render json: {\n # checkpoints: @checkpoints.to_a\n # }\n end", "def location_primer\n render(json: location_list)\n end", "def get_json\n response = conn.get(@current_location)\n parsed = JSON.parse(response.body, symbolize_names: true)\n\n end", "def locations\n farm = Farm.find(params[:id])\n\n @locations = []\n # Find which locations this user is authorized to access\n if (current_user.is_hog_owner? || current_user.is_farm_owner? || current_user.is_admin?)\n @locations = farm.locations\n elsif current_user.is_barn_manager?\n @locations << current_user.owner.barn.location\n elsif current_user.is_site_manager?\n @locations << current_user.owner.location\n end\n\n @page_title = \"Sites\"\n @header_icon_class = \"icon-road\"\n @page_subtitle = \"\"\n \n respond_to do |format|\n format.html { render '/locations/index' }\n format.json { render json: @locations }\n end\n end", "def hotel_location\n service_data = hotel_service.get_location(params[:hotelId].to_i)\n result = false\n status = 'nok'\n\n if service_data[:hotel]\n #convert the JSON data to hash\n success_response = process_response(service_data[:list_hotel_response], \"LocationInfoResponse\")\n \n result = {\n :hotel => service_data[:hotel],\n :places => JSON.parse(success_response['response'])['LocationInfoResponse']['LocationInfos']['LocationInfo']\n }\n status = success_response['status']\n end\n respond_to do |format|\n format.json {render :json => {:data => result, :status => status}}\n end\n end", "def list_locations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: V1LocationsApi.list_locations ...\"\n end\n # resource path\n local_var_path = \"/v1/me/locations\".sub('{format}','json')\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\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<V1Merchant>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: V1LocationsApi#list_locations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end", "def show\n\t\t@all_locations = Location.where(:faculty => params[:id])\n\t\trender :json => @all_locations\n\tend", "def show\n @corp_location = CorpLocation.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @corp_location }\n end\n end", "def get_locations\n response = execute_get(\"/reference/location\")\n Location.from_array(decode(response))\n end", "def index\n @processed_locations = ProcessedLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @processed_locations }\n end\n end", "def index\n @locations = current_user.locations\n respond_with @locations\n end", "def index\n @locations = Location.roots.order(:location_name) \n render :json => @locations #Using Location serializer by default\n end", "def index\n @locations = Location.all\n\n respond_with(@locations)\n end", "def show\n @location = Location.find(params[:id])\n render json: @locationProut\n end", "def show\n @locations=@work.locations\n map\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @work }\n end\n end", "def show\n @location = Location.find(params[:id])\n @jobs = @location.jobs\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @items_location = ItemsLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @items_location }\n end\n end", "def index\n\t\tsurgery_locations = SurgeryLocation.all\n\t\tif surgery_locations.present?\n\t # response to the JSON\n\t render json: { success: true, response: surgery_locations.map{ |f| SurgeryLocationSerializer.new(f).as_json( root: false ) } }\n\t else\n\t render :json=> { success: false, message: \"Surgery Location is not present.\" },:status=> 203\n\t end \n\tend", "def index\n @specific_locations = SpecificLocation.all\n end", "def location\n @client.get(\"#{path}/location\")\n end", "def show\n render json: @service_location\n end", "def show\n if can?(:>=, \"5\")\n @location = Kitting::Location.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n else\n redirect_to main_app.unauthorized_url\n end\n end", "def event_get_location_details\n @loc = Apis::HereApi.new(\"\").get_location_details(params[:locationid])\n render json: @loc\n end", "def locations id, date = Date.today.to_s\n uri = \"#{BASE_URL}/gauges/#{id}/locations?date=#{date}\"\n fetch uri\n end", "def show\n objid = params[:id]\n obj = PickupLocation.find_by_id(objid)\n if obj\n render json: {pickup_location: obj}, status: 200\n else\n render json: {}, status: 404\n end\n rescue => error\n render json: {}, status: 500\n end", "def show\n @processed_location = ProcessedLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @processed_location }\n end\n end", "def index\n @map = Map.find(params[:map_id])\n if @map.kind == \"activity\"\n @locations = @map.locations.activity\n elsif @map.kind == \"news\"\n @locations = @map.locations.news\n else\n @locations = @map.locations\n end\n respond_to do |format|\n format.json { render :json => @locations.as_json(:include => :location_pin)}\n end\n end", "def show\n @loc = Loc.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @loc }\n end\n end", "def getlocation\n \tlocafid = Windmill.where(no: params[:no])\nif locafid.present?\n \t\tlocafid = Windmill.find_by(no: params[:no])\n \t\trender json: [locafid.as_json(only: [:no, :latitude, :londitude,:location])]\nelse\n \t\trender json: {massage: 'windmill not found'}\n end\nend", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @locations = Location.all\n end", "def index\n @clinic_locations = ClinicLocation.all\n\n # respond_to do |f|\n # f.json { render :index, location: @clinic_locations }\n # end\n end", "def index\n @drop_locations = DropLocation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @drop_locations }\n end\n end", "def index\n @locations = Location.order(\"id desc\").page(params[:page]).per(50)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def create\n @checklocation = Checklocation.new(params[:checklocation])\n\n respond_to do |format|\n if @checklocation.save\n format.html { redirect_to @checklocation, notice: 'Checklocation was successfully created.' }\n format.json { render json: @checklocation, status: :created, location: @checklocation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @checklocation.errors, status: :unprocessable_entity }\n end\n end\n end", "def get(params = {})\n client.get(\"/v1/reference-data/locations/#{@location_id}\", params)\n end", "def show\n @location_url_map = LocationUrlMap.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location_url_map }\n end\n end", "def index \t\t\n respond_to do |format|\n format.html # index.html.erb\n format.json { \n locations = JqxConverter.jqxGrid(current_user.entity.locations.where(record_status: 0))\n render json: locations \n }\n end\n end", "def show\n @curpg = :admintools\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @location }\n end\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username1,\n :password => $password1,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def get_locations\n splits = SplitLocationFinder.splits(params).where.not(course_id: @event.course_id)\n render json: splits, each_serializer: SplitLocationSerializer\n end", "def get_locations\n splits = SplitLocationFinder.splits(params).where.not(course_id: @event.course_id)\n render json: splits, each_serializer: SplitLocationSerializer\n end", "def query\n { :locations => [] }\n end", "def show\n @location = Location.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @location }\n end\n end", "def get_json(location)\n response = RestClient::Request.new(\n :method => :get,\n :url => location,\n :user => $username2,\n :password => $password2,\n :headers => { :accept => :json,\n :content_type => :json,\n :params => { \"page\" => 1, \"per_page\" => 1000 }\n }\n ).execute\n results = JSON.parse(response.to_str)\n end", "def index\n @locations = Spree::Location.all\n end", "def show\n @records_location = RecordsLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @records_location }\n end\n end", "def show\r\n @location = Location.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @location }\r\n end\r\n end", "def show\n @itemname = Itemname.find(params[:id])\n @locations = Location.all\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @itemname }\n end\n end", "def get_all_hotel_location\n service_data = hotel_service.get_all_hotel_location(params[:hotelIds])\n result = false\n if service_data[:hotel]\n result = {\n :places => service_data[:list_hotel_response]\n }\n end\n respond_to do |format|\n format.json {render :json => {:data => result}}\n end\n end", "def index\n @location_points = LocationPoint.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @location_points }\n end\n end", "def index\n @locations = salor_user.get_locations(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @locations }\n end\n end", "def index\n if can?(:>=, \"5\")\n @locations = Kitting::Location.where(\"customer_number = ? OR customer_number IS NULL\",session[:customer_number])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @locations }\n end\n else\n redirect_to main_app.unauthorized_url\n end\n end", "def show\n @lookup = Lookup.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lookup }\n end\n end", "def location(location,types=nil)\n handle_response(get(\"/content/location.json\", :query => {:location => location,:types=>types}))\n end", "def show\n @meeting_location = MeetingLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @meeting_location }\n end\n end", "def show\n @subcellular_location = SubcellularLocation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @subcellular_location }\n end\n end", "def locations\n locations_params = Hashie::Mash.new( {f: params.f} )\n response = make_request(LOCATIONS_BASE, locations_params)\n return not_available (response) unless response.status == 200\n response_body = Hashie::Mash.new(JSON.parse(response.body))\n response_body.data\n end", "def index\n @recipe_locations = RecipeLocation.all\n end" ]
[ "0.67741096", "0.6695241", "0.65326035", "0.6521637", "0.63815725", "0.6380121", "0.6329414", "0.6285283", "0.62847316", "0.62704057", "0.6257463", "0.6232984", "0.6215145", "0.61881995", "0.6181893", "0.6178184", "0.61647683", "0.6142148", "0.6132089", "0.6120561", "0.6096163", "0.6044172", "0.60438275", "0.60285836", "0.6023331", "0.60200274", "0.59995264", "0.5997681", "0.5993098", "0.5989012", "0.5960044", "0.5959108", "0.5949813", "0.5933418", "0.5931503", "0.59279776", "0.59255415", "0.59246784", "0.5914766", "0.5909727", "0.5903465", "0.58989185", "0.589751", "0.58878344", "0.58838165", "0.58775514", "0.58746696", "0.58743495", "0.58726794", "0.58642155", "0.5863372", "0.5854837", "0.5842032", "0.5842032", "0.5842032", "0.5842032", "0.5842032", "0.5842032", "0.5842032", "0.5842032", "0.5842032", "0.5842032", "0.5842032", "0.5841543", "0.582208", "0.5821863", "0.5806848", "0.5806848", "0.5806848", "0.5806848", "0.5806848", "0.5806848", "0.5806848", "0.5806848", "0.5806848", "0.580669", "0.58022624", "0.5800028", "0.57939225", "0.57866377", "0.5776922", "0.57709754", "0.57709754", "0.5767876", "0.57621", "0.5744434", "0.5743303", "0.57337743", "0.57321924", "0.57269025", "0.572634", "0.5720508", "0.5713374", "0.5707896", "0.5702972", "0.57017267", "0.5695804", "0.56949186", "0.5690673", "0.56834203" ]
0.70227426
0
GET /checklocations/new GET /checklocations/new.json
def new @checklocation = Checklocation.new respond_to do |format| format.html # new.html.erb format.json { render json: @checklocation } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @loc = current_user.locs.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loc }\n end\n end", "def new\n @location_have_location = LocationHaveLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_have_location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @curpg = :admintools\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @lookup = Lookup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lookup }\n end\n end", "def new\r\n @location = Location.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @location }\r\n end\r\n end", "def new\r\n @location = Location.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @location }\r\n end\r\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @location }\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @location = Location.new \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @location }\n end\n end", "def new\n @processed_location = ProcessedLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @processed_location }\n end\n end", "def new\n @locationmap = Locationmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @locationmap }\n end\n end", "def new\n @corp_location = CorpLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @corp_location }\n end\n end", "def create\n @checklocation = Checklocation.new(params[:checklocation])\n\n respond_to do |format|\n if @checklocation.save\n format.html { redirect_to @checklocation, notice: 'Checklocation was successfully created.' }\n format.json { render json: @checklocation, status: :created, location: @checklocation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @checklocation.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @location_url_map = LocationUrlMap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_url_map }\n end\n end", "def new\n @items_location = ItemsLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @items_location }\n end\n end", "def new\n @records_location = RecordsLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @records_location }\n end\n end", "def new\n\t @location = Location.new\n\t @months = Month.all\n\t @countries = Location.all.map(&:country).uniq\n\n\t respond_to do |format|\n\t format.html # new.html.erb\n\t format.json { render json: @location }\n\t end\n\t end", "def new\n @locations = Location.all\n @itemname = Itemname.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @itemname }\n end\n end", "def new\n @location = Location.new(:status=>1)\n init_new_form\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n if can?(:>=, \"5\")\n @location = Kitting::Location.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n else\n redirect_to main_app.unauthorized_url\n end\n end", "def new\n if (current_user.role == \"customer\" || current_user.role == \"supervisor\")\n add_breadcrumb \"Location\", 'locations_path'\n add_breadcrumb \"Add new\", '#'\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n else\n redirect_to error_users_path and return\n end \n end", "def new\n @where_to_stay = WhereToStay.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @where_to_stay }\n end\n end", "def new\r\n @discounts_on_location = DiscountsOnLocation.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @discounts_on_location }\r\n end\r\n end", "def new\n @location = Location.new\n respond_to do |format|\n format.html\n format.xml { render :xml => @location }\n format.json { render :text => @location.to_json }\n end\n end", "def new\n @event_location = EventLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event_location }\n end\n end", "def new\n @meeting_location = MeetingLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meeting_location }\n end\n end", "def create\n @curpg = :admintools\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to :controller => \"locations\", :action => \"index\" }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\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", "def new\n\n return unless representsCompany?\n\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @location = @organization.locations.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @record = Location.new\n @networks = current_user.entity.networks\n @location_types = Location.location_types\n\n respond_to do |format|\n format.html {render :layout => 'popup'} \n format.json { \n response = {}\n render json: response \n }\n end\n end", "def new\n @location_point = LocationPoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_point }\n end\n end", "def new\n @location_property = LocationProperty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_property }\n end\n end", "def new\n @origin = OriginAddr.new\n \n drop_breadcrumb('新增')\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @origin }\n end\n end", "def new\n @check = Check.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @check }\n end\n end", "def new\n do_new_resource\n get_project_if_exists\n do_set_attributes\n do_authorize_instance\n\n # initialize lat/lng to Brisbane-ish\n @site.longitude = 152\n @site.latitude = -27\n respond_to do |format|\n format.html\n format.json { respond_new }\n end\n end", "def new\n @location = Location.new\n @json = @location.to_gmaps4rails\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n if current_user.is_not_member?\n flash[:error] = \"You do not have permissions to access that feature.\"\n redirect_to root_path and return\n end\n \n @location_history = LocationHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location_history }\n end\n end", "def new\n @person = Person.new\n @locations = Location.all.map{|l| [l.name, l.id]}\n end", "def new\n @checklist = Checklist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @checklist }\n end\n end", "def new\n @user_location = ::Users::UserLocation.new\n\n respond_to do |format|\n format.html { render 'index.html.haml' } # new.html.erb\n format.json { render json: @user_location }\n end\n end", "def create\n @loc = current_user.locs.new(params[:loc])\n\n respond_to do |format|\n if @loc.save\n format.html { redirect_to @loc, notice: 'Loc was successfully created.' }\n format.json { render json: @loc, status: :created, location: @loc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @loc.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @spawner = Spawner.new\n @fieldtrips = Fieldtrip.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spawner }\n end\n end", "def new\n @location = Location.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n #@updateavail = Updateavail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @updateavail }\n end\n end", "def new\n @factors_location = FactorsLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @factors_location }\n end\n end", "def new\n @accession_location_entry = AccessionLocationEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @accession_location_entry }\n end\n end", "def new\n @deal_location = DealLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @deal_location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n format.js\n end\n end", "def new\n @location = Location.new\n respond_with(@location) \n end", "def new\n\t\t@location = Location.new \n\tend", "def new\n @locacao = Locacao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @locacao }\n end\n end", "def new\n @campus_food = CampusFood.new\n\t@locations = Location.all\n\t@temp = []\n\tfor each in @locations\n\t\t@temp.push(each.loc.to_s)\n\tend\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @campus_food }\n end\n end", "def new\n @backup_check = BackupCheck.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @backup_check }\n end\n end", "def new\n @provider = Provider.new\n @provider.locations.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @provider }\n end\n end", "def new\n @subcellular_location = SubcellularLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @subcellular_location }\n end\n end", "def new\n @location = Location.new\n @pages = {}\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def new\n @sys_check = SysCheck.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sys_check }\n end\n end", "def new\n @map = Map.new\n\n puts @saved_locations\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @map }\n end\n end", "def new\n @user_follow_location = UserFollowLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_follow_location }\n end\n end", "def new\n @zone_updater = ZoneUpdater.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zone_updater }\n end\n end", "def new\n @balance = scope.new\n @routes = current_user.locations.collect(&:routes).flatten\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @balance }\n end\n end", "def new\n respond_to do |format|\n format.html { render_template } # new.html.erb\n format.xml { render xml: @location_region }\n end\n end", "def new\n\n @location = Location.new\n\n end", "def new\n @loud_check = LoudCheck.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @loud_check }\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.json { render :show, status: :created }\n else\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @location = Location.new\n\t\tif signed_in? && Project.find(params[:pid]).user_id == User.find_by_remember_token(cookies[:remember_token]).id\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n else\n redirect_to \"/\"\n\t \tend\n end", "def new\n @location = Location.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @location }\n end\n end", "def new\n @check_register = CheckRegister.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @check_register }\n end\n end", "def new\n @location = Location.new\n end", "def new\n @location = Location.new\n @location.contacts = [{:phone => [{}]}]\n @types = Type.find(:all)\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @location }\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n\tlogger.info \"location saved successfully\"\n\tlogger.info @location.to_json\n format.html { redirect_to @location, :notice => 'Location was successfully created.' }\n format.json { render :json => @location }\n else\n\tlogger.info \"error saving location\"\n format.html { render :action => \"new\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @work_entry = WorkEntry.new\n @locations = Location.order(:name)\n @initial_codes = Code.where(location_id: @locations.first.id).all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @work_entry }\n end\n end", "def create\n @location_have_location = LocationHaveLocation.new(params[:location_have_location])\n\n respond_to do |format|\n if @location_have_location.save\n format.html { redirect_to @location_have_location, notice: 'Location have location was successfully created.' }\n format.json { render json: @location_have_location, status: :created, location: @location_have_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location_have_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @tutor_location = TutorLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tutor_location }\n end\n end", "def new\n @chef_mapping = ChefMapping.new\n @source = []\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @chef_mapping }\n end\n end", "def create\n @resource = Catalogs::Location.new(catalogs_location_params)\n\n respond_to do |format|\n if @resource.save\n index\n\n flash[:success] = t('notices.saved_successfully')\n format.html { redirect_to @resource, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end", "def create\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @shiftmap = Shiftmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shiftmap }\n end\n end", "def new\n #reset_session\n @location = Location.new\n build\n \n if params[:client_id]\n @location.client = params[:client_id]\n end\n\n if params[:contact_id]\n @location.contact = params[:contact_id]\n @location.client = Contact.where(:id=>@location.contact).first.client_id\n end\n\n if params[:country_id]\n @location.country_id = params[:country_id]\n else\n @location.country_id = 38\n end\n\n if params[:project_id]\n @project = params[:project_id]\n #session[:project] = @project\n end\n \n filter_type\n\n respond_to do |format|\n format.html\n format.json { render json: @location }\n end\n end", "def new\n @map = current_user.maps.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @map }\n end\n end", "def new\n @reloud_check = ReloudCheck.new\n @reloud_entries = ReloudEntry.all\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @reloud_check }\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n @locations = Location.index_locations\n format.html { redirect_to(@location, :notice => 'Location was successfully created.') }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n format.js\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def new\n @select_markers = return_markers\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @place }\n end\n end" ]
[ "0.7326898", "0.7140238", "0.71116495", "0.71116495", "0.71116495", "0.71116495", "0.71116495", "0.7072644", "0.7057065", "0.70568", "0.70568", "0.70374763", "0.69907475", "0.69710684", "0.696086", "0.6918263", "0.6904993", "0.6895286", "0.68744946", "0.6860864", "0.6849603", "0.67710286", "0.6706144", "0.66641444", "0.6660017", "0.66184896", "0.6604005", "0.66033226", "0.6598652", "0.6580768", "0.6577478", "0.65711695", "0.655421", "0.65432835", "0.65303147", "0.65248144", "0.652019", "0.649613", "0.6492899", "0.6482291", "0.64721274", "0.6467238", "0.6459136", "0.6448472", "0.644391", "0.64333993", "0.64276797", "0.64064056", "0.6395738", "0.6393733", "0.6380777", "0.6376302", "0.6369077", "0.63689995", "0.63672376", "0.63672376", "0.63672376", "0.63672376", "0.63672376", "0.63672376", "0.6362965", "0.63558966", "0.63540953", "0.6342511", "0.6337774", "0.63199663", "0.63088727", "0.63065207", "0.6304104", "0.6283016", "0.6280867", "0.6280313", "0.62670964", "0.6265277", "0.6261561", "0.625669", "0.62492627", "0.6246995", "0.62398505", "0.6236069", "0.6231201", "0.6231099", "0.62272155", "0.6222867", "0.6222502", "0.6216584", "0.62160134", "0.620215", "0.6194447", "0.6191614", "0.6179753", "0.6176698", "0.6159447", "0.6155987", "0.61552715", "0.61552715", "0.61552715", "0.61552715", "0.61465764", "0.61464787" ]
0.7804917
0
POST /checklocations POST /checklocations.json
def create @checklocation = Checklocation.new(params[:checklocation]) respond_to do |format| if @checklocation.save format.html { redirect_to @checklocation, notice: 'Checklocation was successfully created.' } format.json { render json: @checklocation, status: :created, location: @checklocation } else format.html { render action: "new" } format.json { render json: @checklocation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @location = Location.new(location_params)\n authorize @location\n if @location.save\n check_active_locations\n ok_status\n else\n error_status\n end\n end", "def create\n @location_have_location = LocationHaveLocation.new(params[:location_have_location])\n\n respond_to do |format|\n if @location_have_location.save\n format.html { redirect_to @location_have_location, notice: 'Location have location was successfully created.' }\n format.json { render json: @location_have_location, status: :created, location: @location_have_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location_have_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n if @location.save \n render :json => { status: :created, location: @location }\n else\n render :json => { errors: @location.errors, status: :unprocessable_entity }\n end\n end", "def verify_locations(test_data)\n locations = test_data[UseOfCollections::LOCATION_LIST.name] || [{ UseOfCollections::LOCATION.name => ''}]\n locations.each_with_index { |location, index| verify_values_match(location[UseOfCollections::LOCATION.name], element_value(location_input index)) }\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.json { render :show, status: :created }\n else\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def verify_locations(test_data)\n locations = test_data[CoreUseOfCollectionsData::LOCATION_LIST.name] || [{CoreUseOfCollectionsData::LOCATION.name => ''}]\n locations.each_with_index { |location, index| verify_values_match(location[CoreUseOfCollectionsData::LOCATION.name], element_value(location_input index)) }\n end", "def create\n @user_location = auth_user.primary_user_location || auth_user.user_locations.last || ::Users::UserLocation.new\n loc_params = params[resource_param_name]\n if loc_params.present?\n @user_location.attributes = loc_params.select{|k,v| ![:id].include?(k) }\n @user_location.user_id = auth_user.id\n end\n\n if (user_locations = params[:user_locations] || params['user_locations']).present?\n new_user_locations = user_locations.collect do|p|\n loc = ::Users::UserLocation.new(p)\n loc.user_id = auth_user.id\n loc\n end\n if new_user_locations.present?\n ::Users::UserLocation.where(user_id: auth_user.id).delete_all\n auth_user.user_locations = new_user_locations\n auth_user.save\n @user_location = new_user_locations.first\n end\n end\n logger.info \"| valid location? #{@user_location.valid?} : #{@user_location.errors.full_messages}\"\n respond_to do |format|\n if @user_location.save\n\n save_phone_number\n\n format.html { redirect_to next_after_save, notice: 'Address was successfully created.' }\n format.json { render json: {success: true, user_location: @user_location.as_json }, status: :created }\n else\n format.html { render action: \"new\" }\n format.json { render json: {success: false, errors: @user_location.errors.messages}, status: :unprocessable_entity }\n end\n end\n end", "def create\n @regions = Region.all\n @location = Location.new(location_params)\n\n if params[:regions]\n @location_regions = Region.find(params[:regions])\n else\n @location_regions = []\n end\n\n @location.regions = @location_regions\n\n respond_to do |format|\n if @location.save\n @location.create_stat\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @location = Location.new(params[:location])\r\n\r\n respond_to do |format|\r\n if @location.save\r\n format.json { render json: @location, status: :created, location: @location }\r\n else\r\n format.json { render json: @location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def send_to_JSON\n evaluate_checks = [check_times, check_dates, check_day_of_week]\n evaluate_checks.all?\n end", "def create\n @service_location = ServiceLocation.new(service_location_params)\n if @service_location.save\n render json: @service_location, status: :created, location: @service_location\n else\n render json: @service_location.errors, status: :unprocessable_entity\n end \n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created }\n else\n format.html { redirect_to root_path, notice: 'Please fill in all fields!' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def coordinates\n location = Location.new(location_params)\n if location.save\n render json: location\n else\n render json: \"ERROR\"\n end\n end", "def test_construct_location_empty_form\n login('mary')\n post(:create_location,\n :where => '',\n :approved_where => '',\n :location => {\n :display_name => ''\n }\n )\n end", "def test_list_locations()\n\n # Perform the API call through the SDK function\n result = @controller.list_locations()\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n end", "def create\n @place = Place.find(params[:places_id])\n if user_signed_in?\n location = current_user.locations.last\n location_for_json = location\n if current_user.admin?\n location = Location.last\n end\n end\n\n if user_signed_in?\n @tmp = Checkin.where([\"place_id = ? and user_id = ?\", @place.id, current_user.id]).first\n if @tmp\n @checkin = @tmp\n respond_to do |format|\n if @checkin.touch\n format.html { redirect_to @place, notice: '再チェックインしました。' }\n format.json { render json: @place, status: :checkin, location: @place }\n else\n format.html { redirect_to @place, notice: 'チェックインできませんでした。' }\n format.json { render json: @place.errors, status: :unprocessable_entity }\n end\n end\n else\n @checkin = Checkin.new({\"lat\" => location.latitude, \"lng\" => location.longitude, \"accuracy\" => location.accuracy})\n @checkin.place_id = @place.id\n @checkin.user_id = current_user.id\n respond_to do |format|\n if @checkin.save\n format.html { redirect_to @place, notice: 'チェックインしました。' }\n format.json { render json: @place, status: :checkin, location: @place }\n else\n format.html { redirect_to @place, notice: 'チェックインできませんでした。' }\n format.json { render json: @place.errors, status: :unprocessable_entity }\n end\n end\n end\n end\n end", "def create\n @api_v1_location = Api::V1::Location.new(api_v1_location_params)\n\n respond_to do |format|\n if @api_v1_location.save\n format.html { redirect_to @api_v1_location, notice: 'Location was successfully created.' }\n format.json { render json: { results: @api_v1_location, message: 'Location was successfully created.' } }\n else\n format.html { render :new }\n format.json { render json: { results: @api_v1_location.errors, message: 'Location was NOT successfully created.' } }\n end\n end\n end", "def create\n @location = Location.new(\n name: location_params[:name],\n address_line_1: location_params[:lineOne],\n address_line_2: location_params[:lineTwo],\n lat: location_params[:lat],\n lng: location_params[:lng]\n )\n if @location.save\n render json: @location\n else\n render json: {message: 'creation failed'}\n end\n end", "def create\n @curpg = :admintools\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to :controller => \"locations\", :action => \"index\" }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def ok_status\n respond_to do |format|\n format.html { redirect_to locations_path }\n format.json { render :show, status: :created, location: @location }\n end\n end", "def postLocation( location_id, type, country, language, name, formal_name, resolution, population, description, timezone, latitude, longitude, parent_town, parent_county, parent_province, parent_region, parent_neighbourhood, parent_district, postalcode, searchable_id, searchable_ids)\n params = Hash.new\n params['location_id'] = location_id\n params['type'] = type\n params['country'] = country\n params['language'] = language\n params['name'] = name\n params['formal_name'] = formal_name\n params['resolution'] = resolution\n params['population'] = population\n params['description'] = description\n params['timezone'] = timezone\n params['latitude'] = latitude\n params['longitude'] = longitude\n params['parent_town'] = parent_town\n params['parent_county'] = parent_county\n params['parent_province'] = parent_province\n params['parent_region'] = parent_region\n params['parent_neighbourhood'] = parent_neighbourhood\n params['parent_district'] = parent_district\n params['postalcode'] = postalcode\n params['searchable_id'] = searchable_id\n params['searchable_ids'] = searchable_ids\n return doCurl(\"post\",\"/location\",params)\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n\tlogger.info \"location saved successfully\"\n\tlogger.info @location.to_json\n format.html { redirect_to @location, :notice => 'Location was successfully created.' }\n format.json { render :json => @location }\n else\n\tlogger.info \"error saving location\"\n format.html { render :action => \"new\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @job_location = JobLocation.new(job_location_params)\n\n \n if @job_location.save\n render json: {job_location: @job_location, status: 'Job location was successfully created.'}, status: :created\n else\n render json: { errors: @job_location.errors.full_messages }, status: :bad_request \n end\n \n end", "def create\n @loc = current_user.locs.new(params[:loc])\n\n respond_to do |format|\n if @loc.save\n format.html { redirect_to @loc, notice: 'Loc was successfully created.' }\n format.json { render json: @loc, status: :created, location: @loc }\n else\n format.html { render action: \"new\" }\n format.json { render json: @loc.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n current_user.update(location_params)\n\n if current_user.save\n render action: 'show', status: :ok, location: current_user\n else\n render json: current_user.errors, status: :unprocessable_entity\n end\n end", "def create\n @recipe_location = RecipeLocation.new(recipe_location_params)\n\n respond_to do |format|\n if @recipe_location.save\n format.html { redirect_to @recipe_location, notice: 'Recipe location was successfully created.' }\n format.json { render :show, status: :created, location: @recipe_location }\n else\n format.html { render :new }\n format.json { render json: @recipe_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n\t\tsurgery_locations = SurgeryLocation.all\n\t\tif surgery_locations.present?\n\t # response to the JSON\n\t render json: { success: true, response: surgery_locations.map{ |f| SurgeryLocationSerializer.new(f).as_json( root: false ) } }\n\t else\n\t render :json=> { success: false, message: \"Surgery Location is not present.\" },:status=> 203\n\t end \n\tend", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_list_locations\n\n # Perform the API call through the SDK function\n result = @controller.list_locations()\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n end", "def create\n @processed_location = ProcessedLocation.new(params[:processed_location])\n\n respond_to do |format|\n if @processed_location.save\n format.html { redirect_to @processed_location, notice: 'Processed location was successfully created.' }\n format.json { render json: @processed_location, status: :created, location: @processed_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @processed_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to locations_path, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n#binding.pry\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, flash: {success: \"Successfully created #{@location.name} location!\" }}\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @checklocation = Checklocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @checklocation }\n end\n end", "def create\n if can?(:>=, \"5\")\n @location = Kitting::Location.new(params[:location])\n @location.customer_number = session[:customer_number]\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location is created successfully.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to main_app.unauthorized_url\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render action: 'show', status: :created, location: @location }\n else\n format.html { render action: 'new' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.'}\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @locations = Location.paginate(:page => params[:page], :per_page => 30).order('updated_at DESC')\n @location = Location.create(params[:location])\n end", "def locations\n get('locations')\n end", "def create\n @location = Location.new(location_params)\n @location.save\n respond_with(@location)\n end", "def create\n @location = Location.new(params[:location])\n \n @location.location = current_location\n @location.location_type = \"shelf\"\n \n respond_to do |format|\n if @location.save\n format.html { redirect_to current_location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\n respond_to do |format|\n if @location.save\n @locations = Location.index_locations\n format.html { redirect_to(@location, :notice => 'Location was successfully created.') }\n format.xml { render :xml => @location, :status => :created, :location => @location }\n format.js\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @location = Location.new(params[:location].merge!(:user => current_user))\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'La habitación se ha guardado exitosamente.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_locations(locations)\n File.open('location_data.json', 'w') do |file|\n file.puts locations\n end\n end", "def locations\n locations_params = Hashie::Mash.new( {f: params.f} )\n response = make_request(LOCATIONS_BASE, locations_params)\n return not_available (response) unless response.status == 200\n response_body = Hashie::Mash.new(JSON.parse(response.body))\n response_body.data\n end", "def create\n if signed_in?\n @user = current_user\n end\n @location = Location.friendly.find_or_create_by(location_params)\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location}\n format.json { render action: 'show', status: :created, location: @location }\n UserMailer.location_email(@location, @user).deliver_now\n else\n format.html { render action: 'new' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @specific_location = SpecificLocation.new(specific_location_params)\n\n respond_to do |format|\n if @specific_location.save\n format.html { redirect_to @specific_location, notice: 'Specific location was successfully created.' }\n format.json { render :show, status: :created, location: @specific_location }\n else\n format.html { render :new }\n format.json { render json: @specific_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n\t\n\t\n\t\n respond_to do |format|\n if @location.save\n format.html { redirect_to admin_locations_url(:site => current_site.id), notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: admin_locations_url(:site => current_site.id) }\n else\n \n \tset_site_entities @location\n \t\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @records_location = RecordsLocation.new(params[:records_location])\n\n respond_to do |format|\n if @records_location.save\n format.html { redirect_to @records_location, notice: 'Records location was successfully created.' }\n format.json { render json: @records_location, status: :created, location: @records_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @records_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @totem_location = TotemLocation.new(totem_location_params)\n\n respond_to do |format|\n if @totem_location.save\n format.html { redirect_to @totem_location, notice: 'Totem location was successfully created.' }\n format.json { render action: 'show', status: :created, location: @totem_location }\n else\n format.html { render action: 'new' }\n format.json { render json: @totem_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_location_opt_out_on_create_update\n # Step 1\n count = 0\n 2.times do\n assign_http(Config['turtle']['host'])\n\n headers = { 'Accept' => 'application/json' }\n\n user = TurtleUser.new\n\n params = {\n 'user' => {\n 'first_name' => user.first_name,\n 'last_name' => user.last_name,\n 'email' => user.email,\n 'new_password' => user.password,\n 'new_password_confirmation' => user.password,\n 'vrid' => user.vrid,\n 'terms' => '1',\n 'zip_code' => '91201',\n 'location_opt_out' => 0,\n },\n 'app_id' => 'WEB',\n }\n params['user']['location_opt_out'] = 1 if count >= 1\n\n post '/usr', params, headers\n assert_response(@response, :success)\n turtle_response = @parsed_response\n user.id = turtle_response['id']\n user.cookie_id = turtle_response['cookie_id']\n\n # Check Dragon if @parsed_response['location_opt_out'] returns nil\n if @parsed_response['location_opt_out'].nil?\n get_dragon_user(user.id)\n assert_response(@response, :success)\n dragon_response = @parsed_response\n assert(dragon_response['locationOptOut'], \"dragon response for user id: #{user.id}, missing the parameter: locationOptOut\")\n if count >= 1\n assert_equal(1, @parsed_response['location_opt_out'], \"dragon Response: #{dragon_response}\")\n else\n assert_equal(0, @parsed_response['location_opt_out'], \"dragon Response: #{dragon_response}\")\n end\n else\n if count >= 1\n assert_equal(1, @parsed_response['location_opt_out'], \"Turtle Response: #{turtle_response}\")\n else\n assert_equal(0, @parsed_response['location_opt_out'], \"Turtle Response: #{turtle_response}\")\n end\n end\n assert_equal(false, @parsed_response['email_opt_in'], @parsed_response)\n\n # Login Oauth\n params = {\n 'client_id' => user.turtle_client_id,\n 'client_secret' => user.turtle_secret_key,\n 'grant_type' => user.grant_type,\n 'email' => user.email,\n 'password' => user.password\n }\n\n post '/oauth/access_token', params\n assert_response(@response, :success)\n user.oauth_token = @parsed_response['access_token']\n\n # Step 2\n headers = {\n 'Authorization' => \"Bearer #{user.oauth_token}\",\n 'Accept' => 'application/json'\n }\n\n params = {\n 'user' => {\n 'location_opt_out' => 1\n },\n 'email_opt_in' => 'true'\n }\n params['user']['location_opt_out'] = 0 if count >= 1\n\n put '/usr', params, headers\n assert_response(@response, :success)\n if count >= 1\n assert_equal(0, @parsed_response['location_opt_out'], @parsed_response)\n else\n assert_equal(1, @parsed_response['location_opt_out'], @parsed_response)\n end\n assert_equal(true, @parsed_response['email_opt_in'], @parsed_response)\n\n # Step 3\n assign_http(Config['panda']['host'])\n\n params = {\n 'oauth_token' => user.oauth_token,\n 'user' => {\n 'location_opt_out' => 0\n },\n 'email_opt_in' => 'false'\n }\n params['user']['location_opt_out'] = 1 if count >= 1\n\n post \"/usr/update_by_id/#{user.id}\", params\n assert_response(@response, :success)\n if count >= 1\n assert_equal(1, @parsed_response['location_opt_out'], @parsed_response)\n else\n assert_equal(0, @parsed_response['location_opt_out'], @parsed_response)\n end\n assert_equal(false, @parsed_response['email_opt_in'], @parsed_response)\n\n count += 1\n end\n end", "def travel_nodes_confirmation\n @event.set_current_ip(params[:current_ip])\n @event.create_previous_travel_node(params[:previous_travel_node]) if params[:previous_travel_node] && params[:previous_travel_node][:address].present?\n @event.create_current_travel_node(params[:current_travel_node]) if params[:current_travel_node] && params[:current_travel_node][:address].present?\n @event.save\n @event.wait\n # @event.check_for_favorite_locations\n render :json => @event, :status => :ok\n end", "def create\n @resource = Catalogs::Location.new(catalogs_location_params)\n\n respond_to do |format|\n if @resource.save\n index\n\n flash[:success] = t('notices.saved_successfully')\n format.html { redirect_to @resource, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @resource }\n else\n format.html { render :new }\n format.json { render json: @resource.errors, status: :unprocessable_entity }\n end\n format.js\n end\n end", "def create\n @location = Location.new(params[:location]) \n # transale address into lat/long\n lat, long = Geocoder.coordinates(@location.full_address) \n \n response = get_place_report(params[:location], long, lat)\n @location.reference = response[\"reference\"]\n @location.general_type = get_general_type(params[:location][:types])\n respond_to do |format|\n if @location.save \n format.html { redirect_to(@location, :notice => 'Location was successfully created.') }\n format.xml { render :xml => @location, :status => :created, :location => @location } \n else\n @pages = {}\n format.html { render :action => \"new\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def location_primer\n render(json: location_list)\n end", "def hotel_location\n service_data = hotel_service.get_location(params[:hotelId].to_i)\n result = false\n status = 'nok'\n\n if service_data[:hotel]\n #convert the JSON data to hash\n success_response = process_response(service_data[:list_hotel_response], \"LocationInfoResponse\")\n \n result = {\n :hotel => service_data[:hotel],\n :places => JSON.parse(success_response['response'])['LocationInfoResponse']['LocationInfos']['LocationInfo']\n }\n status = success_response['status']\n end\n respond_to do |format|\n format.json {render :json => {:data => result, :status => status}}\n end\n end", "def create\r\n @discounts_on_location = DiscountsOnLocation.new(params[:discounts_on_location])\r\n\r\n respond_to do |format|\r\n if @discounts_on_location.save\r\n format.html { redirect_to @discounts_on_location, notice: 'Discounts on location was successfully created.' }\r\n format.json { render json: @discounts_on_location, status: :created, location: @discounts_on_location }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @discounts_on_location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def fill_locations\n location_id = Location.where(:id => params[:id], :sti_type => params[:sti_type].camelize).first\n location_code = params[:code].present? ? Location.where(:code => params[:code], :sti_type => params[:sti_type].camelize).first : nil\n @location = location_id.nil? ? location_code : location_id\n if @location\n @ok = true\n @locations = @location.select_with_selected(false)\n else\n @ok = false\n end\n end", "def create\n @user=User.find_by_id(params[:user_id])\n @location = Location.new(params[:location])\n @location.user_id = @user.uid\n @location.name = @user.name\n \n respond_to do |format|\n \n if @location.save\n format.html { redirect_to user_locations_path(@user), notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n delete_keys = params.keys.select{|k| k =~ /^delete-/}\n direction = 'created'\n if delete_keys.empty?\n locations = Location.find_near(params[:x], params[:y])\n @location = locations.empty? ?\n Location.create(:x => params[:x], :y => params[:y]) :\n locations.first\n @ministry.locations << @location\n else\n logger.info delete_keys.first\n delete, x, y = delete_keys.first.split('-')\n logger.info \"X: #{x}, Y: #{y}\"\n locations = Location.find_near(x, y)\n locations.each{|l| @ministry.locations.delete(l)}\n direction = 'deleted'\n end\n\n respond_to do |format|\n if @ministry.save\n flash[:notice] = \"Ministry location was successfully #{direction}.\"\n format.html { redirect_to(edit_ministry_path(@ministry)) }\n format.xml { render :xml => @ministry, :status => :created, :location => @ministry }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ministry.errors, :status => :unprocessable_entity }\n end\n end\n end", "def valid_build_locations\n \n team = Integer(params[:team])\n building = Integer(params[:building])\n early = params[:early] == '1'\n \n case building\n when BuildingEnums::SETTLEMENT\n valid = Vertex.all.select {|vertex| settlement_build_is_valid?(vertex, team, early)}.map {|v| v.vertex_id}\n when BuildingEnums::CITY\n valid = Vertex.all.select {|vertex| city_build_is_valid?(vertex, team)}.map {|v| v.vertex_id}\n when BuildingEnums::ROAD\n valid = Edge.all.select {|edge| road_build_is_valid?(edge, team)}.map {|e| e.edge_id}\n else\n valid = []\n end\n render :json => valid\n end", "def create\n @location = Location.new(params[:location])\n if @location.save\n flash[:notice] = 'Location was successfully created.'\n end\n respond_with(@location, location: locations_url) \n end", "def create\n @location = Location.new\n @location.address = gym_params[:location]\n location = Location.limit(1).find_by_address(gym_params[:location])\n @location.save! if location.eql? nil\n location = Location.limit(1).find_by_address(gym_params[:location])\n @gym = Gym.new(gym_params.reject!{ |k| k == \"location\"})\n# raise @user.inspect\n @gym.location_id = location.id\n # @gym = Gym.new(gym_params)\n\n respond_to do |format|\n if @gym.save\n format.html { redirect_to @gym, notice: 'Gym was successfully created.' }\n format.json { render :show, status: :created, location: @gym }\n `echo \"Nome:#{@gym.name}\\n Gerente: #{@gym.manager.name}\\n Address:#{@gym.location.address}\" | mutt -s \"Gym was successfully created.\" #{@gym.manager.email}`\n else\n format.html { render :new }\n format.json { render json: @gym.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Spree::Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to '/admin/locations', notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n @location.user_id = current_user.id\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to locations_path, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t\tLocation.create(params[:location])\n\t\tredirect_to locations_path\n\tend", "def check_in_params\n params.require(:check_in).permit(:location, :longitude, :latitude, :destination_id)\n end", "def create\n @location = Location.new(location_params)\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n format.js\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def create\r\n @backend_location = Backend::Location.new(backend_location_params)\r\n\r\n respond_to do |format|\r\n if @backend_location.save\r\n format.html { redirect_to @backend_location, notice: 'Location was successfully created.' }\r\n format.json { render :show, status: :created, location: @backend_location }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @backend_location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n\t\t@location = Location.new(params[:location])\n\n\t\trespond_to do |format|\n\t\t\tif @location.save\n\t\t\t\tformat.html { redirect_to @location, notice: 'Location was successfully created.' }\n\t\t\t\tformat.json { render json: @location, status: :created, location: @location }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @location.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n end", "def create\n @slocation = Slocation.new(slocation_params)\n\n respond_to do |format|\n if @slocation.save\n format.html { redirect_to @slocation, notice: 'Story location was successfully created.' }\n format.json { render :show, status: :created, slocation: @slocation }\n else\n format.html { render :new }\n format.json { render json: @slocation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @item_location = ItemLocation.new(item_location_params)\n\n respond_to do |format|\n if @item_location.save\n format.html do\n redirect_to api_v1_item_location_url(@item_location),\n notice: 'Item location was successfully created.'\n end\n format.json { render :show, status: :created, location: @item_location }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @item_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @check_request = CheckRequest.new(check_request_params)\n\n respond_to do |format|\n if @check_request.save\n format.html { redirect_to check_requests_path, notice: 'Check request was successfully created.' }\n format.json { render :show, status: :created, location: @check_request }\n else\n format.html { render :new }\n format.json { render json: @check_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n end", "def get_locations\n response = execute_get(\"/reference/location\")\n Location.from_array(decode(response))\n end", "def create\n @ms_location = MsLocation.new(ms_location_params)\n\n respond_to do |format|\n if @ms_location.save\n format.html { redirect_to @ms_location, notice: 'Ms location was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ms_location }\n else\n format.html { render action: 'new' }\n format.json { render json: @ms_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @step = @trip.steps.new(step_params)\n\n @locations = JSON params['locations']\n\n respond_to do |format|\n if @step.valid?\n if @step.save\n if @step.have_updated_forecast? # return true or false\n format.html { redirect_to @trip, notice: 'Step was successfully created. Updated forecast available.' }\n format.json { render action: 'show', status: :created, location: @step }\n else\n if @step.should_make_forecast?\n if @step.make_forecast == true # return true , false or nil\n format.html { redirect_to @trip, notice: 'Step was successfully created. New forecast requested.' }\n format.json { render action: 'show', status: :created, location: @step }\n else @step.make_forecast == false\n format.html { \n flash.now[:notice] = \"Cannot make forecast for #{@step.location}. City not found!\" \n render action: 'new' }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to @trip, notice: 'Step was successfully created. No forecast available for the arrival.' }\n format.json { render action: 'show', status: :created, location: @step } \n end \n end\n else\n format.html { render action: 'new' }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n else\n format.html { \n flash.now[:notice] = \"Cannot make forecast for #{@step.location}. Arrive on should be in the past!\" \n render action: 'new' }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n \n end\n\n end", "def create\n @admin_location = Admin::Location.new(admin_location_params)\n\n respond_to do |format|\n if @admin_location.save\n format.html { redirect_to @admin_location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @admin_location }\n else\n format.html { render :new }\n format.json { render json: @admin_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meeting_location = MeetingLocation.new(params[:meeting_location])\n\n respond_to do |format|\n if @meeting_location.save\n format.html { redirect_to @meeting_location, notice: 'Meeting location was successfully created.' }\n format.json { render json: @meeting_location, status: :created, location: @meeting_location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @meeting_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location_perk = LocationPerk.new(location_perk_params)\n\n respond_to do |format|\n if @location_perk.save\n format.html { redirect_to @location_perk, notice: 'Location perk was successfully created.' }\n format.json { render :show, status: :created, location: @location_perk }\n else\n format.html { render :new }\n format.json { render json: @location_perk.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\t @location = Location.new(location_params)\n\n\t respond_to do |format|\n\t if @location.save\n\t format.html { redirect_to @location, notice: 'location was successfully created.' }\n\t format.json { render json: @location, status: :created, location: @location }\n\t format.js\n\t else\n\t format.html { render action: \"new\" }\n\t format.json { render json: @location.errors, status: :unprocessable_entity }\n\t end\n\t end\n\t end", "def create\n\t\t@location = Location.new(location_params)\n\n\t\trespond_to do |format|\n\t\t\tif @location.save\n\t\t\t\tformat.html { redirect_to @location, notice: 'Location was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :created, location: @location }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @location.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n authorize @location\n if @location.update(location_params)\n check_active_locations\n ok_status\n else\n error_status\n end\n end", "def create\n @location = @organization.locations.build(params[:location])\n\n respond_to do |format|\n if @location.save\n format.html { redirect_to [@organization, @location], notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_locations\n LOGGER.add 0, 'INFO: Beginning location generation'\n overpass = OverpassAPI.new(timeout: TIMEOUT, json: true)\n\n row = 0\n total = 0\n\n # rubocop:disable Metrics/BlockLength\n (GLOBAL_BOUNDARIES[:s]...GLOBAL_BOUNDARIES[:n]).step(STEP) do |ns|\n row += 1\n column = 0\n\n (GLOBAL_BOUNDARIES[:w]...GLOBAL_BOUNDARIES[:e]).step(STEP) do |ew|\n column += 1\n total += 1\n attempts = 0\n boundaries = { s: ns, n: ns + STEP, w: ew, e: ew + STEP }\n LOGGER.add 0, \"INFO: Beginning row #{row}, column #{column} (#{boundaries})\"\n\n begin\n attempts += 1\n overpass.query(query(boundaries)).slice_before { |result| result[:type] == 'node' }.each do |node_set|\n node_group = node_set.group_by { |item| item[:type] }\n\n streets = node_group['way']\n next if streets.blank?\n\n # We're only concerned with certain streets\n streets = streets.select { |way| way[:tags][:highway].present? }\n streets = streets.select { |way| way[:tags][:name].present? }\n streets = streets.select { |way| %w[footway cycleway path service track].exclude? way[:tags][:highway] }\n\n # Deduplicate names on four fields if they are present\n streets = streets.uniq { |way| strip_direction(way[:tags][:name]) }\n streets = streets.uniq { |way| strip_direction(way[:tags][:name_1]) || rand }\n streets = streets.uniq { |way| way[:tags][:'tiger:name_base'] || rand }\n streets = streets.uniq { |way| way[:tags][:'tiger:name_base_1'] || rand }\n\n streets = streets.map { |way| way[:tags][:name] }\n streets = streets.sort_by { |way| way.scan(/(?=\\d)/).length }.reverse\n\n node = node_group['node'].first\n next if node.blank?\n\n lat_lon_duplicate = Location.where(latitude: node[:lat], longitude: node[:lon]).first\n\n street_duplicate = Location.where(\n '(street1 = ? AND street2 = ?) OR (street2 = ? AND street1 = ?)',\n streets.first,\n streets.second,\n streets.first,\n streets.second,\n ).first\n\n if lat_lon_duplicate.present?\n LOGGER.add(\n 0,\n 'WARN: Found multiple street pairs at same lat/lon. '\\\n \"Found #{streets.first} & #{streets.last}, had #{street_duplicate}\",\n )\n elsif streets.try(:length) != 2\n LOGGER.add 0, \"WARN: Node didn't have 2 ways #{streets} (#{node[:lat]}, #{node[:lon]})\"\n elsif street_duplicate.present?\n LOGGER.add(\n 0,\n \"INFO: Adding #{humanize_street(streets.first)} & #{humanize_street(streets.second)} \"\\\n 'at midpoint & removed previous location',\n )\n Location.create!(\n latitude: (street_duplicate.latitude + node[:lat]) / 2,\n longitude: (street_duplicate.longitude + node[:lon]) / 2,\n active: false,\n street1: streets.first,\n street2: streets.second,\n name: \"#{humanize_street(streets.first)} & #{humanize_street(streets.second)}\",\n )\n street_duplicate.destroy!\n else\n LOGGER.add 0, \"INFO: Adding #{humanize_street(streets.first)} & #{humanize_street(streets.second)}\"\n Location.create!(\n latitude: node[:lat],\n longitude: node[:lon],\n active: false,\n street1: streets.first,\n street2: streets.second,\n name: \"#{humanize_street(streets.first)} & #{humanize_street(streets.second)}\",\n )\n end\n end\n rescue StandardError => e\n if attempts <= RETRIES\n LOGGER.add 0, \"WARN: Encountered error, retry #{attempts} of #{RETRIES}\"\n sleep(attempts < RETRIES ? PAUSE : TIMEOUT)\n retry\n else\n LOGGER.add 0, \"ERROR: #{e.message}\"\n end\n ensure\n sleep(PAUSE)\n end\n end\n # rubocop:enable Metrics/BlockLength\n end\n LOGGER.add 0, \"INFO: Total requests: #{total}\"\n end", "def create\n @location = Location.new location_params\n @location.target = current_user\n respond_to do |format| \n if @location.save\n format.html { redirect_to @location, notice: 'Location was successfully created.' }\n format.json { render :show, status: :created, location: @location }\n else\n format.html { render :new }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def enter_locations(test_data)\n locations = test_data[CoreUseOfCollectionsData::LOCATION_LIST.name] || [{CoreUseOfCollectionsData::LOCATION.name => ''}]\n hide_notifications_bar\n prep_fieldsets_for_test_data([fieldset(CoreUseOfCollectionsData::LOCATION_LIST.name)], locations)\n locations.each_with_index do |location, index|\n logger.info \"Entering location data set at index #{index}: #{location}\"\n enter_auto_complete(location_input(index), location_options(index), location[CoreUseOfCollectionsData::LOCATION.name], 'Local Places')\n end\n end", "def create\n @itinerary = Itinerary.new(itinerary_params)\n @start_loc = Location.create(address: params[:start_loc], is_origin: true, itinerary_id: @itinerary.id)\n @end_loc = Location.create(address: params[:end_loc], is_origin: false, itinerary_id: @itinerary.id)\n @itinerary.locations.push(@start_loc)\n @itinerary.locations.push(@end_loc)\n\n respond_to do |format|\n if @itinerary.save\n format.html { redirect_to @itinerary, notice: 'Itinerary was successfully created.' }\n format.json { render :show, status: :created, location: @itinerary }\n\n # origin = @itinerary.locations.new( address: params[:origin], is_origin: true )\n # origin.get_coords\n\n # destination = @itinerary.locations.new( address: params[:destination], is_origin: false )\n # destination.get_coords\n\n else\n format.html { render :new }\n format.json { render json: @itinerary.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @located_at = LocatedAt.new(located_at_params)\n\n respond_to do |format|\n if @located_at.save\n format.html { redirect_to @located_at, notice: 'Located at was successfully created.' }\n format.json { render :show, status: :created, location: @located_at }\n else\n format.html { render :new }\n format.json { render json: @located_at.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.61141616", "0.58627456", "0.5854386", "0.58495474", "0.5847235", "0.5788752", "0.57777876", "0.5777498", "0.57715297", "0.57215303", "0.56990874", "0.5698953", "0.56949586", "0.5674815", "0.565803", "0.56263936", "0.56254256", "0.56242496", "0.5610269", "0.5572539", "0.5571878", "0.5569237", "0.5560795", "0.55590403", "0.5557775", "0.5546433", "0.5522535", "0.5511946", "0.5493463", "0.5493463", "0.5493463", "0.5493463", "0.5491269", "0.54861975", "0.5481598", "0.5478278", "0.5476013", "0.5453044", "0.54496044", "0.54448456", "0.5443781", "0.5443564", "0.5443564", "0.5443564", "0.5443564", "0.5443564", "0.5443564", "0.5443564", "0.54290015", "0.5428078", "0.5415519", "0.5415324", "0.53937614", "0.53820455", "0.53499407", "0.53427815", "0.5341031", "0.53352976", "0.53350705", "0.5332387", "0.52999896", "0.52879107", "0.5287499", "0.5282024", "0.5277305", "0.5276335", "0.5265805", "0.52577335", "0.52463543", "0.5245042", "0.5236952", "0.52368116", "0.5233428", "0.5228978", "0.522766", "0.5224878", "0.5220129", "0.52151704", "0.52059734", "0.5204801", "0.52040404", "0.5201831", "0.52004164", "0.5195615", "0.5189969", "0.5183532", "0.5182731", "0.5182281", "0.5180348", "0.51738316", "0.5167487", "0.51618296", "0.5158666", "0.5158651", "0.5155663", "0.5154884", "0.5149324", "0.5141928", "0.51366025", "0.51361966" ]
0.6602425
0
PUT /checklocations/1 PUT /checklocations/1.json
def update @checklocation = Checklocation.find(params[:id]) respond_to do |format| if @checklocation.update_attributes(params[:checklocation]) format.html { redirect_to @checklocation, notice: 'Checklocation was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @checklocation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_location(params)\n @client.put(\"#{path}/location\", nil, params, \"Content-Type\" => \"application/json\")\n end", "def update\n render json: Location.update(params[\"id\"], params[\"location\"])\n end", "def create\n @checklocation = Checklocation.new(params[:checklocation])\n\n respond_to do |format|\n if @checklocation.save\n format.html { redirect_to @checklocation, notice: 'Checklocation was successfully created.' }\n format.json { render json: @checklocation, status: :created, location: @checklocation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @checklocation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n format.html { redirect_to controller: \"sites\", action: \"checklists_manager\" }\n format.json { head :no_content }\n end\n end", "def update\r\n @location = Location.find(params[:id])\r\n \r\n respond_to do |format|\r\n if @location.update_attributes(params[:location])\r\n format.json { head :no_content }\r\n else\r\n format.json { render json: @location.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n authorize @location\n if @location.update(location_params)\n check_active_locations\n ok_status\n else\n error_status\n end\n end", "def update\n @location = Location.new\n @location.address = gym_params[:location]\n location = Location.limit(1).find_by_address(gym_params[:location])\n @location.save! if location.eql? nil\n location = Location.limit(1).find_by_address(gym_params[:location])\n\n respond_to do |format|\n if @gym.update(gym_params.reject!{ |k| k == \"location\"})\n @gym.location_id = location.id\n @gym.save!\n format.html { redirect_to @gym, notice: 'Gym was successfully updated.' }\n format.json { render :show, status: :ok, location: @gym }\n `echo \"Nome:#{@gym.name}\\n Gerente: #{@gym.manager.name}\\n Address:#{@gym.location.address}\" | mutt -s \"Gym was successfully updated.\" #{@gym.manager.email}`\n else\n format.html { render :edit }\n format.json { render json: @gym.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @service_location.update(service_location_params)\n render json: @service_location, status: :ok, location: @service_location\n else\n render json: @service_location.errors, status: :unprocessable_entity\n end \n end", "def update\n @location_have_location = LocationHaveLocation.find(params[:id])\n\n respond_to do |format|\n if @location_have_location.update_attributes(params[:location_have_location])\n format.html { redirect_to @location_have_location, notice: 'Location have location was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location_have_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @check_request.update(check_request_params)\n format.html { redirect_to check_requests_path, notice: 'Check request was successfully updated.' }\n format.json { render :show, status: :ok, location: @check_request }\n else\n format.html { render :edit }\n format.json { render json: @check_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_location.update(api_v1_location_params)\n format.html { redirect_to @api_v1_location, notice: 'Location was successfully updated.' }\n format.json { render json: { location: @api_v1_location, message: 'Location was successfully updated.' } }\n else\n format.html { render :edit }\n format.json { render json: { results: @api_v1_location.errors, message: 'Location was NOT successfully update.' } }\n end\n end\n end", "def update\n @poopstation = Poopstation.find(params[:id])\n\n respond_to do |format|\n if @poopstation.locations.create(:name => params[:location], :city => params[:city], :state => params[:state])\n format.html { redirect_to @poopstation, notice: 'Spanks!' }\n format.json { head :no_content }\n format.mobile { redirect_to @poopstation, notice: 'Spanks!' }\n else\n format.html { render action: \"edit\" }\n format.mobile { render action: \"edit\" }\n format.json { render json: @poopstation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n logger.info params[:location].to_json\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, :notice => 'Location was successfully updated.' }\n format.json { render :json => @location, :status => :updated, :location => @location }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @location.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @trip = Trip.find(params[:trip_id])\n @location = Location.find(params[:location_id])\n @team.trip = @location\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to trip_location_path(@trip, @location), notice: 'Location was successfully updated.' }\n format.html { redirect_to trip_locations_path(@trip), notice: 'Location was successfully updated.2' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @slocation.update(slocation_params)\n format.html { redirect_to @slocation, notice: 'Story location was successfully updated.' }\n format.json { render :show, status: :ok, slocation: @slocation }\n else\n format.html { render :edit }\n format.json { render json: @slocation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @locations = []\n @errors = []\n @hide_map = true\n if params.has_key? :id\n location = Location.find(params[:id])\n @locations = [ location ]\n location_params = params.clone\n [:created_at, :id, :updated_at, :category, :subcategories, :markerVisible, :action, :controller, :location].each do |param|\n location_params.delete param\n end\n location.update_attributes location_params\n @errors = location.errors\n elsif params.has_key? :locations\n params[:locations][:location].each do |data|\n l = Location.find data[0]\n if not l.update_attributes data[1]\n pp l.errors\n @errors.push l.errors\n end\n @locations.push l\n end\n end\n\n respond_to do |format|\n if @errors.empty?\n format.html { redirect_to :locations, :notice => 'Locations successfully updated.'}\n format.json { head :no_content }\n else\n format.html { render :action =>\"edit\" }\n format.json { render :json => @errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @latstraps1.update(latstraps1_params)\n format.html { redirect_to \"/latstraps1s\"}\n format.json { render :show, status: :ok, location: @latstraps1 }\n else\n format.html { render :edit }\n format.json { render json: @latstraps1.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @check_point.update(check_point_params)\n format.html { redirect_to @check_point, notice: 'Check point was successfully updated.' }\n format.json { render :show, status: :ok, location: @check_point }\n else\n format.html { render :edit }\n format.json { render json: @check_point.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end", "def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end", "def update!(**args)\n @locations = args[:locations] if args.key?(:locations)\n end", "def test_update_location_errors\n params = update_params_from_loc(locations(:albion))\n params[:location][:north] = 100\n update_location_error(params)\n end", "def update\n \n @job_location.update(job_location_params)\n \n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n puts \"\\nUPDATE: #{@location.inspect}\"\n format.html { redirect_to @location, notice: \"Location was successfully updated.\" }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n puts \"Location::update (params): \" + location_params.inspect\n \n if @location.update(location_params)\n render :json => {status: :ok, location: @location }\n else\n render :json => {errors: @location.errors, status: :unprocessable_entity }\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Ubicacion actualizada correctamente!' }\n format.json { head :no_content }\n else\n format.html { redirect_to '/locations/'+@location.id.to_s+'/edit',notice: 'Ingrese una direccion y un numero de casa!' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @curpg = :admintools\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to :controller => \"locations\", :action => \"index\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @check_route.update(check_route_params)\n format.html { redirect_to @check_route, notice: 'Check Route was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @check_route.errors, status: :internal_server_error }\n end\n end\n end", "def update\n respond_to do |format|\n if @check_list.update(check_list_params)\n format.html { redirect_to @check_list, notice: \"Check list was successfully updated.\" }\n format.json { render :show, status: :ok, location: @check_list }\n else\n format.html { render :edit }\n format.json { render json: @check_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n \n @previousMap = Location.WhereAmI(@location.region_id)\n\n #binding.pry\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @previousMap, notice: 'Location was successfully updated.' }\n format.json { respond_with_bip(@location) }\n else\n format.html { render action: \"edit\" }\n format.json { respond_with_bip(@location) }\n end\n end\n end", "def update\n @locations = Location.where(\"status <> 'NORMAL'\").order(\"state, township desc\")\n respond_to do |format|\n if @aid_offer.update(aid_offer_params)\n format.html { redirect_to @aid_offer, notice: 'Aid offer was successfully updated.' }\n format.json { render :show, status: :ok, location: @aid_offer }\n else\n format.html { render :edit }\n format.json { render json: @aid_offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n set_location\n\n respond_to do |format|\n if @location.update_attributes(location_params)\n format.html { redirect_to @location, flash: {success: \"Successfully updated #{@location.name} location!\" }}\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @location = Location.new(params[:location])\n \n @location.location = current_location\n @location.location_type = \"shelf\"\n \n respond_to do |format|\n if @location.save\n format.html { redirect_to current_location, notice: 'Location was successfully created.' }\n format.json { render json: @location, status: :created, location: @location }\n else\n format.html { render action: \"new\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @record = Location.find(params[:id])\n @record.update_attributes(params[:location]) \n respond_to do |format|\n# format.html\n format.json {\n render json: {}\n }\n end\n end", "def update\n @location = Location.friendly.find(params[:id])\n respond_to do |format|\n if @location.update_attributes!(location_params)\n format.html { redirect_to @location, notice: 'location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_location(location={})\n\t\tclient.update(location)\n\tend", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @loc = current_user.locs.find(params[:id])\n\n respond_to do |format|\n if @loc.update_attributes(params[:loc])\n format.html { redirect_to @loc, notice: 'Loc was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @loc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @recipe_location.update(recipe_location_params)\n format.html { redirect_to @recipe_location, notice: 'Recipe location was successfully updated.' }\n format.json { render :show, status: :ok, location: @recipe_location }\n else\n format.html { render :edit }\n format.json { render json: @recipe_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @check_in.update(check_in_params)\n format.html { redirect_to @check_in, notice: 'Check in was successfully updated.' }\n format.json { render :show, status: :ok, location: @check_in }\n else\n format.html { render :edit }\n format.json { render json: @check_in.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def update\n @location = Location.find(params[:id])\n @location.update_attributes(params[:location])\n end", "def update\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @check = Check.find(params[:id])\n\n respond_to do |format|\n if @check.update_attributes(params[:check])\n format.html { redirect_to @check, notice: 'Check was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @check.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@items_location = ItemsLocation.find(params[:id])\n\n respond_to do |format|\n #if @items_location.update_attributes(params[:items_location])\n # format.html { redirect_to @items_location, notice: 'Items location was successfully updated.' }\n # format.json { head :no_content }\n #else\n # format.html { render action: \"edit\" }\n # format.json { render json: @items_location.errors, status: :unprocessable_entity }\n #end\n end\n end", "def update\n if params[:new_check_list_item][:id].present?\n @check_list.check_list_items.create(check_id: params[:new_check_list_item][:id])\n end\n if params[:cli]\n params[:cli].each do |cli_array|\n cli = CheckListItem.find(cli_array[0].to_i)\n cli.position = cli_array[1].to_i\n cli.save\n end\n end\n\n respond_to do |format|\n if @check_list.update(check_list_params)\n format.html { redirect_to :back, notice: 'Check list was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @check_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @regions = Region.all\n if params[:regions]\n @location_regions = Region.find(params[:regions])\n else\n @location_regions = []\n end\n @location.regions = @location_regions\n\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: \"Location was successfully updated.\" }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\t\t# updating the surgery location attribute\n\t\tif @surgery_location.update(surgery_location_params)\n\t\t# response to the JSON\n\t\t\trender json: { success: true,message: \"Surgery Location Successfully Updated.\", response: SurgeryLocationSerializer.new(@surgery_location).as_json(root: false) },:status=>200\n\t else\n\t render :json=> { success: false, message: \"Surgery Location is not available\" },:status=> 404\n\t end\n\tend", "def update!(**args)\n @allowed_locations = args[:allowed_locations] if args.key?(:allowed_locations)\n end", "def update_check\r\n job = Job.find(params[:id])\r\n check = job.check_information\r\n batch = job.batch\r\n respond_to do |format|\r\n if check.update_attributes(params[:check_information])\r\n Batch.where(:id => batch.id).update_all(:associated_entity_updated_at => Time.now)\r\n format.json { render json: :back }\r\n else\r\n format.json { render :json => check.errors.full_messages, :status => :unprocessable_entity}\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @item_location.update(item_location_params)\n format.html { redirect_to @item_location, notice: 'Item location was successfully updated.' }\n format.json { render :show, status: :ok, location: @item_location }\n else\n format.html { render :edit }\n format.json { render json: @item_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @check.update(check_params)\n format.html { redirect_to company_checks_path(company_id: params[:company_id]), notice: \"志望度チェックの更新に成功しました。\" }\n format.json { render redirect_to company_checks_path(company_id: params[:company_id]), status: :ok, location: @check }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @check.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to user_locations_path, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @muster_location.update(muster_location_params)\n format.html { redirect_to @muster_location, notice: 'Muster location was successfully updated.' }\n format.json { render :show, status: :ok, location: @muster_location }\n else\n format.html { render :edit }\n format.json { render json: @muster_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n flash[:notice] = t('scaffold.notice.updated', :item => SicossLocation.model_name.human) if @sicoss_location.update_attributes(params[:sicoss_location])\n respond_with(@sicoss_location, :location => sicoss_locations_path)\n end", "def update\n @operations_check = OperationsCheck.find(params[:id])\n\n respond_to do |format|\n if @operations_check.update_attributes(operations_check_params)\n format.html { redirect_to @operations_check, \n notice: 'Operations check was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @operations_check.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @check_in.update(check_in_params)\n flash[:success] = 'Check in was successfully updated.' \n format.html { redirect_to @check_in}\n format.json { render :show, status: :ok, location: @check_in }\n else\n flash[:danger] = \"Did not successfully update.\"\n format.html { render :edit }\n format.json { render json: @check_in.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sign = Sign.find(params[:id])\n @location = Location.find(@sign.location_id)\n\n respond_to do |format|\n if @sign.update_attributes(params[:sign])\n format.html { redirect_to location_index_path(@location.name.downcase), notice: 'Sign was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sign.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @equipment_things_to_check.update(equipment_things_to_check_params)\n format.html { redirect_to @equipment_things_to_check, notice: 'Equipment things to check was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @equipment_things_to_check.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sys_check = SysCheck.find(params[:id])\n\n respond_to do |format|\n if @sys_check.update_attributes(params[:sys_check])\n format.html { redirect_to @sys_check, notice: 'Sys check was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sys_check.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to [@organization, @location], notice: 'Location was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n \n #abort\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to :back, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n set_site_entities @location\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n \n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sneaker.update(sneaker_params)\n Sneaker.reindex\n format.html { redirect_to @sneaker, notice: 'Sneaker was successfully updated.' }\n format.json { render :show, status: :ok, location: @sneaker }\n else\n format.html { render :edit }\n format.json { render json: @sneaker.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n format.html { redirect_to @location, notice: 'La habitación se ha guardado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inventory_check.update(inventory_check_params)\n format.html { redirect_to @inventory_check, notice: 'Inventory check was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @inventory_check.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @check_register = CheckRegister.find(params[:id])\n\n respond_to do |format|\n if @check_register.update_attributes(check_register_params)\n format.html { redirect_to @check_register, notice: 'Check register was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @check_register.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @location.update(location_params)\n format.html { redirect_to @location, notice: 'Location was successfully updated.' }\n format.json { render :show, status: :ok, location: @location }\n else\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n\n respond_to do |format|\n if @location.update_attributes(params[:location])\n @locations = Location.index_locations\n format.html { redirect_to(@location, :notice => 'Location was successfully updated.') }\n format.xml { head :ok }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @location.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @place = Place.find(params[:places_id])\n if user_signed_in?\n location = current_user.locations.last\n location_for_json = location\n if current_user.admin?\n location = Location.last\n end\n end\n\n if user_signed_in?\n @tmp = Checkin.where([\"place_id = ? and user_id = ?\", @place.id, current_user.id]).first\n if @tmp\n @checkin = @tmp\n respond_to do |format|\n if @checkin.touch\n format.html { redirect_to @place, notice: '再チェックインしました。' }\n format.json { render json: @place, status: :checkin, location: @place }\n else\n format.html { redirect_to @place, notice: 'チェックインできませんでした。' }\n format.json { render json: @place.errors, status: :unprocessable_entity }\n end\n end\n else\n @checkin = Checkin.new({\"lat\" => location.latitude, \"lng\" => location.longitude, \"accuracy\" => location.accuracy})\n @checkin.place_id = @place.id\n @checkin.user_id = current_user.id\n respond_to do |format|\n if @checkin.save\n format.html { redirect_to @place, notice: 'チェックインしました。' }\n format.json { render json: @place, status: :checkin, location: @place }\n else\n format.html { redirect_to @place, notice: 'チェックインできませんでした。' }\n format.json { render json: @place.errors, status: :unprocessable_entity }\n end\n end\n end\n end\n end", "def update\n @check = Check.find(params[:id])\n updated = @check.update_attributes(params[:check])\n if updated\n @check.contacts.delete_all\n @check.servers.delete_all\n params.keys.each do |k|\n if k.starts_with? 'server_'\n s = Server.find(k.gsub('server_',''))\n @check.servers << s unless @check.servers.include?(s)\n end\n if k.starts_with? 'contact_'\n c = Contact.find(k.gsub('contact_',''))\n @check.contacts << c unless @check.contacts.include?(c)\n end\n end\n updated = @check.save\n end\n respond_to do |format|\n if updated\n flash[:notice] = 'Check was successfully updated.'\n format.html { redirect_to(@check) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @check.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @processed_location = ProcessedLocation.find(params[:id])\n\n respond_to do |format|\n if @processed_location.update_attributes(params[:processed_location])\n format.html { redirect_to @processed_location, notice: 'Processed location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @processed_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @locationtype.update(locationtype_params)\n format.html { redirect_to @locationtype, notice: 'Locationtype was successfully updated.' }\n format.json { render :show, status: :ok, location: @locationtype }\n else\n format.html { render :edit }\n format.json { render json: @locationtype.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @location = Location.find(params[:id])\n if @location.update_attributes(params[:location])\n flash[:notice] = 'Location was successfully updated.'\n end\n respond_with(@location, location: locations_url) \n end", "def test_update_location_name_errors\n params = update_params_from_loc(locations(:albion))\n params[:location][:display_name] = \"Somewhere Dubious\"\n update_location_error(params)\n end", "def update\n respond_to do |format|\n if @totem_location.update(totem_location_params)\n format.html { redirect_to @totem_location, notice: 'Totem location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @totem_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ms_location.update(ms_location_params)\n format.html { redirect_to @ms_location, notice: 'Ms location was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ms_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @lookup.update(lookup_params)\n format.html { redirect_to lookups_url, notice: 'Lookups was successfully updated.' }\n format.json { render :show, status: :ok, location: @lookup }\n else\n format.html { render :edit }\n format.json { render json: @lookup.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @service_location.update(service_location_params)\n format.html { redirect_to @service_location, notice: \"Updated Information for location: '#{@service_location.location.name}'\" }\n format.json { render :show, status: :ok, location: @service_location }\n else\n format.html { render :edit }\n format.json { render json: @service_location.errors, status: :unprocessable_entity }\n end\n end\n end", "def test_putpoi_update_valid\n nd = create(:node)\n cs_id = nd.changeset.id\n user = nd.changeset.user\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", cs_id, nd.version, nd.id, nd.lon, nd.lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 1, result[4]\n\n # Now try to update again, with a different lat/lon, using the updated version number\n lat = nd.lat + 0.1\n lon = nd.lon - 0.1\n amf_content \"putpoi\", \"/2\", [\"#{user.email}:test\", cs_id, nd.version + 1, nd.id, lon, lat, nd.tags, nd.visible]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/2\")\n\n assert_equal 5, result.size\n assert_equal 0, result[0]\n assert_equal \"\", result[1]\n assert_equal nd.id, result[2]\n assert_equal nd.id, result[3]\n assert_equal nd.version + 2, result[4]\n end" ]
[ "0.648955", "0.6414245", "0.6151873", "0.6077711", "0.6064187", "0.5968042", "0.5915312", "0.5865967", "0.58075815", "0.57981247", "0.57776487", "0.57734776", "0.5769888", "0.5757061", "0.5748443", "0.5743139", "0.5731062", "0.57206774", "0.5700789", "0.5700789", "0.5700243", "0.5695744", "0.56944656", "0.56891024", "0.56850415", "0.568081", "0.5680365", "0.5675104", "0.5667672", "0.5652923", "0.5645787", "0.56363565", "0.56277186", "0.5614785", "0.56005144", "0.5600351", "0.5592521", "0.55922556", "0.55890375", "0.55867547", "0.5575885", "0.5563725", "0.5561235", "0.5559477", "0.5559271", "0.55562323", "0.5548271", "0.5545717", "0.55252683", "0.55252683", "0.5523044", "0.5522681", "0.55189955", "0.5518755", "0.5518564", "0.55171317", "0.551172", "0.5501331", "0.5495959", "0.54923534", "0.54905677", "0.54813224", "0.54812217", "0.547943", "0.5479402", "0.5479402", "0.5479402", "0.5479402", "0.54793435", "0.54784626", "0.5474826", "0.54696596", "0.546675", "0.54643124", "0.54598176", "0.545869", "0.545869", "0.545869", "0.545869", "0.545869", "0.545869", "0.545869", "0.545869", "0.545869", "0.545869", "0.545869", "0.545869", "0.545777", "0.54510653", "0.5448068", "0.5445538", "0.54384506", "0.54244787", "0.5421189", "0.5419574", "0.54194236", "0.5415092", "0.54131097", "0.5412907", "0.5410013" ]
0.67213523
0
DELETE /checklocations/1 DELETE /checklocations/1.json
def destroy @checklocation = Checklocation.find(params[:id]) @checklocation.destroy respond_to do |format| format.html { redirect_to checklocations_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete\n render json: Location.delete(params[\"id\"])\n end", "def destroy\n @record = Location.find(params[:id])\n @record.trash\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n #@items_location = ItemsLocation.find(params[:id])\n #@items_location.destroy\n\n respond_to do |format|\n format.html { redirect_to items_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n #@client = Client.find(@location.client_ids)\n #@contact = Contact.find(@location.contact_ids)\n \n @location.destroy\n\n respond_to do |format|\n \n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end", "def destroy\n @check_route.destroy\n respond_to do |format|\n format.html { redirect_to check_routes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_location.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_locations_url, notice: 'Location was successfully destroyed.' }\n format.json { render json: { results: @api_v1_location, message: 'Location was successfully destroyed.' } }\n end\n end", "def destroy\n @location_have_location = LocationHaveLocation.find(params[:id])\n @location_have_location.destroy\n\n respond_to do |format|\n format.html { redirect_to location_have_locations_url }\n format.json { head :ok }\n end\n end", "def destroy\r\n @location = Location.find(params[:id])\r\n @location.destroy\r\n\r\n respond_to do |format|\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @totem_location.destroy\n respond_to do |format|\n format.html { redirect_to totem_locations_url }\n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @inventory_check.destroy\n respond_to do |format|\n format.html { redirect_to inventory_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @discounts_on_location = DiscountsOnLocation.find(params[:id])\r\n @discounts_on_location.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to discounts_on_locations_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @check_request.destroy\n respond_to do |format|\n format.html { redirect_to check_requests_url, notice: 'Check request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @check_list.destroy\n respond_to do |format|\n format.html { redirect_to check_lists_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ms_location.destroy\n respond_to do |format|\n format.html { redirect_to ms_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bg_check.destroy\n respond_to do |format|\n format.html { redirect_to bg_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :ok }\n end\n end", "def destroy\n @corp_location = CorpLocation.get(params[:id])\n @corp_location.destroy\n\n respond_to do |format|\n format.html { redirect_to corp_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @check.destroy\n respond_to do |format|\n format.html { redirect_to checks_url, notice: \"志望度チェックの削除に成功しました。\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @loc = current_user.locs.find(params[:id])\n @loc.destroy\n\n respond_to do |format|\n format.html { redirect_to locs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @operations_check = OperationsCheck.find(params[:id])\n @operations_check.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @records_location = RecordsLocation.find(params[:id])\n @records_location.destroy\n\n respond_to do |format|\n format.html { redirect_to records_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @check = Check.find(params[:id])\n @check.destroy\n\n respond_to do |format|\n format.html { redirect_to checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @processed_location = ProcessedLocation.find(params[:id])\n @processed_location.destroy\n\n respond_to do |format|\n format.html { redirect_to processed_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @storage_location = StorageLocation.find(params[:id])\n @storage_location.destroy\n\n respond_to do |format|\n format.html { redirect_to storage_locations_url }\n format.json { head :ok }\n end\n end", "def destroy\n @backup_check = BackupCheck.find(params[:id])\n internal_check = InternalCheck.find(params[:internal_check_id])\n @backup_check.destroy\n\n respond_to do |format|\n format.html { redirect_to internal_check }\n format.json { head :no_content }\n end\n end", "def destroy\n @sign = Sign.find(params[:id])\n @location = Location.find(@sign.location_id)\n @sign.destroy\n\n respond_to do |format|\n format.html { redirect_to location_index_path(@location.name.downcase) }\n format.json { head :no_content }\n end\n end", "def destroy\n @storeloc = Storeloc.find(params[:id])\n @storeloc.itemlocs.each do |loc|\n loc.destroy\n end\n\n @storeloc.destroy\n\n respond_to do |format|\n format.html { redirect_to(storelocs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location_time.destroy\n respond_to do |format|\n format.html { redirect_to location_times_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @equipment_things_to_check.destroy\n respond_to do |format|\n format.html { redirect_to equipment_things_to_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to trip_locations_path, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @reloud_check = ReloudCheck.find(params[:id])\n @reloud_check.destroy\n\n respond_to do |format|\n format.html { redirect_to reloud_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @location = Location.find(params[:id])\r\n RemovedLocation.create(server_id: Integer(params[:id]))\r\n directory = Rails.root.join('app','assets','locations');\r\n\r\n path = File.join(directory, @location.image)\r\n File.delete(path)\r\n @location.destroy\r\n mv = MapsVersion.first\r\n mv.version = mv.version+1\r\n mv.save\r\n respond_to do |format|\r\n format.html { redirect_to locations_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n set_location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, flash: {success: \"Successfully deleted #{@location.name} location!\" }}\n format.json { head :no_content }\n end\n end", "def destroy\n @location = $User.get_location(params[:id])\n @location.kill\n GlobalData.reload(:locations)\n respond_to do |format|\n format.html { redirect_to('/locations') }\n format.xml { head :ok }\n end\n end", "def destroy\n @slocation.destroy\n respond_to do |format|\n format.html { redirect_to slocations_url, notice: 'Story Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @specific_location.destroy\n respond_to do |format|\n format.html { redirect_to specific_locations_url, notice: 'Specific location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_locations!(start, stop)\n params = { from: start, end: stop }\n\n @client.delete(\"#{path}/location/waypoints\", nil, params, \"Content-Type\" => \"application/json\")\n end", "def destroy\n operations_check = OperationsCheck.find(params[:operations_check_id])\n @load_balancer_check = LoadBalancerCheck.find(params[:id])\n @load_balancer_check.destroy\n\n respond_to do |format|\n format.html { redirect_to operations_check_path(operations_check, tab: \"load_balancers\") }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to geolocation_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #@netracks = @location.net_racks.all\n #binding.pry\n #@netracks.destroy.all\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n @location = Location.find(params[:location_id])\n end", "def destroy\n @locations = nil\n\n if params.has_key? :id\n location = Location.find params[:id]\n @locations = [ location ]\n elsif params.has_key? :ids\n @locations = Location.find params[:ids].split(\",\")\n end\n\n if not @locations.empty?\n @locations.each do |l|\n l.destroy\n end\n end\n\n respond_to do |format|\n format.html { redirect_to locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @location_detail.destroy\n respond_to do |format|\n format.html { redirect_to location_details_url, notice: 'Location detail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(splat)\n bad_request if splat.empty?\n _delete resolve_uri(splat[0])\n end", "def destroy\n @location.destroy\n render :json => { status: :deleted, head: :no_content }\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/locations', notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @check_list.destroy\n respond_to do |format|\n format.html { redirect_to check_lists_url, notice: \"Check list was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @accession_location_entry = AccessionLocationEntry.find(params[:id])\n @accession_location_entry.destroy\n\n respond_to do |format|\n format.html { redirect_to accession_location_entries_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sys_check = SysCheck.find(params[:id])\n @sys_check.destroy\n\n respond_to do |format|\n format.html { redirect_to sys_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @item_location.destroy\n respond_to do |format|\n format.html { redirect_to item_locations_url, notice: 'Item location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipe_location.destroy\n respond_to do |format|\n format.html { redirect_to recipe_locations_url, notice: 'Recipe location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n @dropoff_location.destroy\n respond_to do |format|\n format.html { redirect_to dropoff_locations_url, notice: 'Dropoff location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @checklist = Checklist.find(params[:id])\n @checklist.destroy\n\n respond_to do |format|\n format.html { redirect_to checklists_url }\n format.json { head :no_content }\n end\n end", "def delete\n CONNECTION.execute(\"DELETE FROM locations WHERE id = #{self.id};\")\n end", "def destroy\n @locationmap = Locationmap.find(params[:id])\n @locationmap.destroy\n\n respond_to do |format|\n format.html { redirect_to locationmaps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @check_point.destroy\n respond_to do |format|\n format.html { redirect_to check_points_url, notice: 'Check point was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @raft_check.destroy\n respond_to do |format|\n format.html { redirect_to raft_checks_url, notice: 'Raft check was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @subcellular_location = SubcellularLocation.find(params[:id])\n @subcellular_location.destroy\n\n respond_to do |format|\n format.html { redirect_to subcellular_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_meeting_location = UserMeetingLocation.find(params[:id])\n @user_meeting_location.destroy\n\n respond_to do |format|\n format.html { redirect_to user_meeting_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meeting_location = MeetingLocation.find(params[:id])\n @meeting_location.destroy\n\n respond_to do |format|\n format.html { redirect_to meeting_locations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_location.destroy\n respond_to do |format|\n format.html { redirect_to admin_locations_url, notice: 'Location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location.destroy\n respond_to do |format|\n format.html { redirect_to locations_url, notice: 'location was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @locationtype.destroy\n respond_to do |format|\n format.html { redirect_to locationtypes_url, notice: 'Locationtype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @loud_check = LoudCheck.find(params[:id])\n @loud_check.destroy\n\n respond_to do |format|\n format.html { redirect_to loud_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #controllare che le location che lascia non siano vuote\n Work.check_n_destroy_locations(@work)\n @work.destroy\n\n respond_to do |format|\n format.html { redirect_to url_for current_dataset }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @check_list.destroy\n respond_to do |format|\n format.html { redirect_to check_lists_url, notice: 'Чек-лист успешно удален.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @location = Location.find(params[:id])\n @location.destroy\n\n respond_to do |format|\n format.html { redirect_to(locations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @backend_location.destroy\r\n respond_to do |format|\r\n format.html { redirect_to backend_locations_url, notice: 'Location was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @maplocation.destroy\n respond_to do |format|\n format.html { redirect_to maplocations_url, notice: 'Maplocation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.69042605", "0.67305315", "0.6674951", "0.66638136", "0.6660653", "0.66491914", "0.66388047", "0.6622575", "0.6600498", "0.65997493", "0.65913284", "0.6581632", "0.6563891", "0.6561262", "0.6554776", "0.6554426", "0.6549019", "0.6548426", "0.6548426", "0.65432316", "0.65348965", "0.65316564", "0.6522645", "0.6522645", "0.6522645", "0.6522645", "0.6521093", "0.651779", "0.65135926", "0.6511097", "0.6508419", "0.65024954", "0.649832", "0.64913785", "0.6491317", "0.6487356", "0.6485979", "0.6485979", "0.6485979", "0.6485979", "0.6485979", "0.6485979", "0.6485979", "0.6485979", "0.6478833", "0.64701635", "0.64680326", "0.6454604", "0.6449921", "0.6446862", "0.64423674", "0.64386594", "0.64374024", "0.64368916", "0.64276", "0.6423183", "0.6421828", "0.64207584", "0.64175403", "0.6413722", "0.641188", "0.6410881", "0.6404955", "0.63969815", "0.63913214", "0.6388125", "0.63879246", "0.6387643", "0.63845533", "0.6378144", "0.63750577", "0.6374709", "0.6371946", "0.63704085", "0.63675225", "0.6356278", "0.63548565", "0.6352551", "0.6346466", "0.6344985", "0.6343344", "0.6339831", "0.6338788", "0.63326854", "0.63299096", "0.6329145", "0.6329145", "0.6329145", "0.6329145", "0.6329145", "0.6329145", "0.6329145", "0.6329145", "0.6329145", "0.6329145", "0.6329145", "0.6329145", "0.6329145", "0.63256717", "0.6317527" ]
0.75030154
0
Concatenate strings using an operator
def string_concat_infix(operator, *args) if args.blank? || args.size < 2 fail ArgumentError, "string concatenation requires operator and two or more arguments, given '#{args.size}'" end result = Arel::Nodes::InfixOperation.new(operator, args[0], args[1]) if args.size > 2 args.drop(2).each do |a| result = Arel::Nodes::InfixOperation.new(operator, result, a) end end result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cmd_concat_operator\n\t\t\" & \"\n\tend", "def operator_c_string\n operator_string + \" \"\n end", "def operator_ruby_string\n operator_string + \" \"\n end", "def join_terms(op, *terms)\n [terms.map { |t| t.first.presence }.compact.join(\" #{op} \"),\n terms.map(&:second).reduce(:+) || []]\n end", "def to_s\n \"(#{@op.to_s} #{@first.to_s} #{@second.to_s})\"\n end", "def concat(string); end", "def to_s\n operator_string + \" \" + @expression.to_s\n end", "def opcode(op,cond,args) \"#{op}#{cond} #{args.join ','}\" end", "def operator_to_string\n {\n \"+\" => 'plus', \n \"-\" => 'minus'\n }\n end", "def expr_to_s\n buf = ''\n each_term do |term|\n if term[:operator]\n buf << term[:operator]\n end\n buf << term[:token]\n end\n buf\n end", "def concat(other_expression)\n @expression = send(:+, other_expression)\n end", "def concatenator(string1, string2)\n \"#{string1} #{string2}\"\nend", "def join_conditions op, *conditions\n conditions = conditions.compact\n if conditions.empty?\n conditions\n elsif conditions.count == 1\n conditions.first\n else\n strings = conditions.map(&:first)\n args = conditions.flat_map{|c| c[1..-1]}\n [\n strings.map{|s| \"(#{s})\"}.join(\" #{op} \"),\n *args\n ]\n end\n end", "def to_s\n rule.embed + operator\n end", "def to_s\n # Wrap the expression on the left/right in parentheses if the operation of\n # the expression on the left/right has a lower precedence than this\n # Expression's, e.g. 2 * (3 + 5) because without parentheses it becomes 6 +\n # 5\n [@left, @right].each do |operand|\n if operand.class == Expression\n operand.do_parens = (has_lower_precedence?(operand) or ! operand.is_associative?)\n end\n end\n string = \"#{@left} #{@operator} #{@right}\"\n # Wrap in parentheses if necessary\n string = \"(#{string})\" if @do_parens\n return string\n end", "def convert_operator_to_text(op)\n case op\n when '1'\n 'add'\n when '2'\n 'subtract'\n when '3'\n 'multiply'\n when '4'\n 'divide'\n end\nend", "def complete_operator(node)\n definition.operator_by_field_name(node.value).map { |o| o.end_with?(' ') ? o : \"#{o} \" }\n end", "def concatenate(strings)\n\nend", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def opcode(op,args) \"#{op} #{args.join ','}\" end", "def to_s(operator: 'exact')\n \"#{category},#{operator},#{URI.encode(value.gsub(';', ''))}\"\n end", "def concatenate(strings)\n return strings.inject(:+)\n end", "def command_join_string!\n (@mode == :pipe) ? \" | \" : \" && \"\n end", "def calculate(op1, operator, op2)\n\tstring = op1.to_s + operator + op2.to_s\n\n\t# operator is assumed to be a string; \n\t# make one big string of it and the two operands \n\teval(string) # evaluate and return a value - never use eval ! eval is EVIL lol \nend", "def to_s\n b = @b\n b = \"c\" if b == \"\"\n \"#{@a}#{@op}#{maybe_quote(b)}\"\n end", "def to_s\n identifier = \"#{fieldx}_#{value}\".downcase.gsub(/\\W/,'_')\n \"#{operator}#{identifier}\"\n end", "def to_s\n @operator\n end", "def to_s\n [left, right].uniq.join(\" #{messages[:or]} \")\n end", "def concatenate(strings)\n\n strings.inject(\"\") do |result, str|\n result += str\n end\n\nend", "def concat(str1, str2)\n str1 + str2\nend", "def complex_expression_sql_append(sql, op, args)\n case op\n when :^\n j = ' # '\n c = false\n args.each do |a|\n sql << j if c\n literal_append(sql, a)\n c ||= true\n end\n when :ILIKE, :'NOT ILIKE'\n sql << '('\n literal_append(sql, args[0])\n sql << ' ' << op.to_s << ' '\n literal_append(sql, args[1])\n sql << ')'\n else\n super\n end\n end", "def arithmeticUnary(op)\n str = getTopOfStack + \"M=\"+op+\"M\"+\"\\n\"\n return str+\"\\n\"\nend", "def string_concat(name_1, name_2)\n puts \"I went to the concert with \" +name_1 + \" and \" + name_2 + \".\"\nend", "def concat(word, another)\n word << another\nend", "def to_s\n s = for_string(@iterator, @first, @last, @step, @operator)\n return s\n end", "def operator\n @operator ||= case [min, max]\n when [0, 0] then ''\n when [0, 1] then '?'\n when [1, Infinity] then '+'\n else\n [min, max].map {|n| n == 0 || n == Infinity ? '' : n.to_s }.join('*')\n end\n end", "def operator\n @operator ||= case [min, max]\n when [0, 0] then ''\n when [0, 1] then '?'\n when [1, Infinity] then '+'\n else\n [min, max].map {|n| n == 0 || n == Infinity ? '' : n.to_s }.join('*')\n end\n end", "def expression(operator, val)\n val = (val.is_a?(String) || val.is_a?(Symbol)) ? \"'#{val}'\" : val\n \"#{@attr} #{operator} #{val}\"\n end", "def join_strings(word_1, word_2)\n join_strings=\"#{word_1} #{word_2}\"\nend", "def string_conc(dog, cat)\n p \"#{dog} #{cat} around the house.\"\nend", "def concat_str(str1, str2)\n p str1 + str2\nend", "def join_strings(a, b)\n a + \" \" + b\nend", "def make_predicate_string predicate\n if predicate.is_a? String\n predicate_string_term predicate\n else\n predicate.map { |pred| predicate_string_term pred }.join(\"/\")\n end\nend", "def concatenation(word1, word2)\n puts \"Artist #{word1} just released their newest album, titled #{word2}.\"\nend", "def applyOperator(num1, num2, operator)\n #eval((num1.to_s + operator + num2.to_s).gsub(\"^\", \"**\"))\n @operators[operator][:action].call(num1.to_i, num2.to_i)\n end", "def concat(txt, b)\n @engine.concat(txt, b)\n end", "def to_citrus # :nodoc:\n rule.to_embedded_s + operator\n end", "def concat(ga1, ga2)\n p \"#{ga1} makes a better ginger ale than #{ga2}\"\nend", "def combine_squeel_expressions(left_expression, left_expression_joins, operator,\n right_expression, right_expression_joins)\n case operator\n when :& then conjunction_expressions(left_expression, left_expression_joins,\n right_expression, right_expression_joins)\n when :| then disjunction_expressions(left_expression, left_expression_joins,\n right_expression, right_expression_joins)\n else\n raise ArgumentError, \"#{operator} must either be :& or :|\"\n end\n end", "def adjacent *a; CssString.new a.flatten.unshift(self).join ' + ' end", "def concat(school, person, program)\n return person + \" wants to go to \" + school + \" for \" + program + \".\"\nend", "def merge_final_ops(seq1, seq2, res = [])\n ops1, ops2 = [], []\n ops1 << seq1.pop while seq1.last.is_a?(String)\n ops2 << seq2.pop while seq2.last.is_a?(String)\n\n # Not worth the headache of trying to preserve newlines here. The most\n # important use of newlines is at the beginning of the selector to wrap\n # across lines anyway.\n ops1.reject! {|o| o == \"\\n\"}\n ops2.reject! {|o| o == \"\\n\"}\n\n return res if ops1.empty? && ops2.empty?\n if ops1.size > 1 || ops2.size > 1\n # If there are multiple operators, something hacky's going on. If one\n # is a supersequence of the other, use that, otherwise give up.\n lcs = Sass::Util.lcs(ops1, ops2)\n return unless lcs == ops1 || lcs == ops2\n res.unshift(*(ops1.size > ops2.size ? ops1 : ops2).reverse)\n return res\n end\n\n # This code looks complicated, but it's actually just a bunch of special\n # cases for interactions between different combinators.\n op1, op2 = ops1.first, ops2.first\n if op1 && op2\n sel1 = seq1.pop\n sel2 = seq2.pop\n if op1 == '~' && op2 == '~'\n if sel1.superselector?(sel2)\n res.unshift sel2, '~'\n elsif sel2.superselector?(sel1)\n res.unshift sel1, '~'\n else\n merged = sel1.unify(sel2)\n res.unshift [\n [sel1, '~', sel2, '~'],\n [sel2, '~', sel1, '~'],\n ([merged, '~'] if merged)\n ].compact\n end\n elsif (op1 == '~' && op2 == '+') || (op1 == '+' && op2 == '~')\n if op1 == '~'\n tilde_sel, plus_sel = sel1, sel2\n else\n tilde_sel, plus_sel = sel2, sel1\n end\n\n if tilde_sel.superselector?(plus_sel)\n res.unshift plus_sel, '+'\n else\n merged = plus_sel.unify(tilde_sel)\n res.unshift [\n [tilde_sel, '~', plus_sel, '+'],\n ([merged, '+'] if merged)\n ].compact\n end\n elsif op1 == '>' && %w(~ +).include?(op2)\n res.unshift sel2, op2\n seq1.push sel1, op1\n elsif op2 == '>' && %w(~ +).include?(op1)\n res.unshift sel1, op1\n seq2.push sel2, op2\n elsif op1 == op2\n merged = sel1.unify(sel2)\n return unless merged\n res.unshift merged, op1\n else\n # Unknown selector combinators can't be unified\n return\n end\n return merge_final_ops(seq1, seq2, res)\n elsif op1\n seq2.pop if op1 == '>' && seq2.last && seq2.last.superselector?(seq1.last)\n res.unshift seq1.pop, op1\n return merge_final_ops(seq1, seq2, res)\n else # op2\n seq1.pop if op2 == '>' && seq1.last && seq1.last.superselector?(seq2.last)\n res.unshift seq2.pop, op2\n return merge_final_ops(seq1, seq2, res)\n end\n end", "def joinor(ary, punc=', ', conj='or')\n if ary.size <= 1\n ary.first.to_s\n elsif ary.size == 2\n ary.join(\" #{conj} \")\n else\n \"#{ary[0..-2].join(punc)}#{punc + conj} #{ary.last}\"\n end\nend", "def concat(str)\n @string.concat str\n end", "def operation_as_string\n @operation == :all && 'all_' || ''\n end", "def _eval_join(*args)\n args = args.compact\n args.delete_if &:empty?\n args.slice(1, args.size).to_a.inject(args.first) do |memo, item|\n if item.start_with?(\"[\")\n memo += item\n else\n memo += \".#{item}\"\n end\n end\n end", "def to_s\n values = compact.map do |scope|\n value = scope.to_s\n value = if scope.is_a?(NestedScope)\n scope.compact.count > 1 ? \"(#{value})\" : value\n else value\n end\n [scope.operator, value]\n end\n\n values = values.flatten.compact\n values.shift\n values.join(\" \")\n end", "def basic_op(operator, value1, value2)\nvalue1.send operator, value2\nend", "def merica(str)\n # concatenating the strings\n str + \"only in America!\"\nend", "def can_join_two_strings(string_1, string_2)\n return \"#{string_1}#{string_2}\"\nend", "def operators= new_ops\n @operators = new_ops.gsub(/[^+*-]/, '').split(//)\n reset\n end", "def to_s\n if Prefix===prefix\n s = symbol ? \"#{prefix.symbol}#{symbol}\" : \"#{prefix.name}#{term})\"\n else\n s = symbol ? \"#{symbol}\" : \"#{term}\"\n end\n if power != 1\n s = s + (power > 0 ? \"^#{power}\" : \"#{power}\")\n end\n s\n end", "def to_s\n \"#{property_name} #{operator} #{url_value}\"\n end", "def to_s\n inject(\"\") { |a, b| a + b.to_s }\n end", "def to_s\n inject(\"\") { |a, b| a + b.to_s }\n end", "def to_s\n inject(\"\") { |a, b| a + b.to_s }\n end", "def concat_head(other)\n if other.to_s.empty?\n self\n elsif other.to_s.match(/[\\W&&[:ascii:]]\\Z/)\n DecorationWrapper.new(other.to_s + to_s)\n else\n DecorationWrapper.new(\"#{other} #{to_s}\")\n end\n end", "def to_s; \"<Operand: #{to_source}>\"; end", "def to_s\n inject(\"\") { |a, b| a + b.to_s }\n end", "def to_s\n inject(\"\") { |a, b| a + b.to_s }\n end", "def join_strings(text_1, text_2)\n text_1 + \" \" + text_2\nend", "def add ( a, b)\n return a + b #{}\"#{a+b}\"\nend", "def string_add(string1, string2)\n puts \"#{string1} #{string2}\"\nend", "def combinator(a, b)\n a.product(b).map{ |c| c.join('') }\nend", "def pack_doper(operator, token) #:nodoc:\n doper = ''\n string = ''\n\n # Return default doper for non-defined filters.\n if operator.nil?\n return pack_unused_doper, string\n end\n\n if token.to_s =~ /^blanks|nonblanks$/i\n doper = pack_blanks_doper(operator, token)\n elsif operator == 2 or\n !(token.to_s =~ /^([+-]?)(?=\\d|\\.\\d)\\d*(\\.\\d*)?([Ee]([+-]?\\d+))?$/)\n # Excel treats all tokens as strings if the operator is equality, =.\n string = token.to_s\n\n encoding = 0\n length = string.length\n\n # Handle utf8 strings\n if string =~ NonAscii\n string = NKF.nkf('-w16B0 -m0 -W', string)\n encodign = 1\n end\n\n string = [encoding].pack('C') + string\n doper = pack_string_doper(operator, length)\n else\n string = ''\n doper = pack_number_doper(operator, token)\n end\n\n return [doper, string]\n end", "def operator_method(string)\n known_operations[string]\n end", "def combine(str, arr)\n out = ''\n arr.each do |el|\n out += el\n end\n out + str\nend", "def join_strings(string_1, string_2)\n \"#{string_1} #{string_2}\"\nend", "def together(string, string2, string3)\n return \"#{string} #{string2} #{string3}\" \nend", "def add_binary(a,b)\n string = (a + b).to_s(2)\nend", "def to_s\n \"(#{@x.map(&:to_s).join(\" + \")})\"\n end", "def operator\n case @matches[2]\n when \"plus\" then :+\n when \"minus\" then :-\n when \"divided by\" then :/\n when \"multiplied by\" then :*\n end\n end", "def operator_label(op)\n op.to_s.gsub(\"_\", \" \")\n end", "def join_strings(parameter1, parameter2)\r\n\treturn parameter1 + \" \" + parameter2\r\nend", "def to_s\n template = indirect? ? \"[%s]\" : \"%s\"\n return template % expr_to_s\n end", "def to_s\n \"(#{@x})^(#{@y})\"\n end", "def string_append\n <<-CODE\n t1 = stack_pop();\n t2 = stack_pop();\n string_append(state, t1, t2);\n stack_push(t1);\n CODE\n end", "def to_s\n lft = self.left.to_s if self.left.is_a? Pow or !(self.left.is_a? BinaryOp)\n lft = \"(#{self.left.to_s})\" unless self.left.is_a? Pow or !(self.left.is_a? BinaryOp)\n rht = self.right.to_s if self.right.is_a? Pow or !(self.right.is_a? BinaryOp)\n rht = \"(#{self.right.to_s})\" unless self.right.is_a? Pow or !(self.right.is_a? BinaryOp)\n return \"#{lft}*#{rht}\"\n end", "def concat_strings(short, long)\n short + long + short\nend", "def complex_expression_sql(op, args)\n case op\n when :'||'\n super(:+, args)\n else\n super(op, args)\n end\n end", "def create_equation\n equation =''\n for i in 0..(@operands.size-1)\n if i==0\n equation << @operands[i].to_s\n else\n #binding.pry\n equation << @operators[@operator_value[i-1]].to_s\n equation << @operands[i].to_s\n end\n end\n equation\n end", "def operator_to_message(op)\n msg = case op\n when '1'\n 'Adding'\n when '2'\n 'Subtracting'\n when '3'\n 'Multiplying'\n when '4'\n 'Dividing'\n end\n msg\nend", "def concat(other, sep = \" \")\n Function.new(type).concat(self, sep, other)\n end", "def operation_as_join\n @operation == :all && ' && ' || ' || '\n end", "def joinor(arr, delimiter = ', ', conjunction = 'or')\n return '' if arr.empty?\n arr.map!(&:to_s)\n return arr[0] if arr.size == 1\n str = arr.size > 2 ? arr[0..-2].join(delimiter) + delimiter : arr[0] + ' '\n # str = arr[0..-2].join(delimiter)\n # str << (arr.size > 2 ? delimiter : ' ')\n str << conjunction + ' ' + arr[-1]\nend", "def arithmeticBinary(op)\n str = getTopTwoFromStack + \"M=M\"+op+\"D\"+\"\\n\"\n return str+\"\\n\"\nend", "def process_or(exp)\n lhs = process exp.shift\n rhs = process exp.shift\n\n return \"#{lhs} || #{rhs}\"\n end", "def evaluate_expression_inner(expression)\n expression_string = evaluate_expression(expression.left)\n expression_string << ' ' + expression.operator.to_s + ' '\n expression_string << evaluate_expression(expression.right)\n expression_string\n end" ]
[ "0.73667884", "0.73354244", "0.7304202", "0.6864403", "0.68610144", "0.6741919", "0.6715501", "0.6635938", "0.6606676", "0.65955436", "0.65381765", "0.6432006", "0.6428878", "0.63948524", "0.6383927", "0.6324063", "0.63008976", "0.6263552", "0.62539715", "0.62539715", "0.62539715", "0.62539715", "0.62311953", "0.62093484", "0.6158814", "0.6129315", "0.61077756", "0.59784025", "0.597138", "0.5965013", "0.59521115", "0.5948", "0.5939844", "0.59355897", "0.5915182", "0.5905159", "0.58649534", "0.58552146", "0.58552146", "0.5848788", "0.5831623", "0.58228636", "0.5822432", "0.5817395", "0.580262", "0.578731", "0.57852936", "0.5761616", "0.5758959", "0.5757125", "0.5749795", "0.5733355", "0.5723553", "0.57151294", "0.5712508", "0.5707344", "0.57030743", "0.56992525", "0.56991327", "0.569529", "0.56950974", "0.56945586", "0.56942385", "0.5686415", "0.56824374", "0.56807864", "0.56807864", "0.56807864", "0.56805503", "0.5677846", "0.5673368", "0.5673368", "0.5672826", "0.5669989", "0.5658005", "0.56567234", "0.56534237", "0.56497926", "0.5647359", "0.56351674", "0.56343174", "0.563159", "0.562579", "0.5625663", "0.5624672", "0.56219596", "0.56184256", "0.5601998", "0.55977196", "0.55947936", "0.55924135", "0.5591001", "0.5586115", "0.55823314", "0.556644", "0.5566171", "0.55629736", "0.5553521", "0.5551316", "0.5550741" ]
0.7225854
3
Construct a SQL literal. This is useful for sql that is too complex for Arel.
def sql_literal(value) Arel::Nodes::SqlLiteral.new(value) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sql(string)\n ::Arel::Nodes::SqlLiteral.new(string)\n end", "def sql_literal(ds)\n ds.literal(sql_expr)\n end", "def sql_literal(object)\n object.literal(to_s)\n end", "def sql_literal(*)\n @dataset.sql\n end", "def literal_string_append(sql, v)\n sql << \"'\" << ::Mysql.quote(v) << \"'\"\n end", "def sql_of( expr, dataset)\n dataset.send :literal_expression_append, rv=String.new, expr\n rv\n end", "def literal(v)\n case v\n when LiteralString\n v\n when String\n \"'#{v.gsub(/\\\\/, \"\\\\\\\\\\\\\\\\\").gsub(/'/, \"''\")}'\"\n when Integer, Float\n v.to_s\n when BigDecimal\n v.to_s(\"F\")\n when NilClass\n NULL\n when TrueClass\n BOOL_TRUE\n when FalseClass\n BOOL_FALSE\n when Symbol\n symbol_to_column_ref(v)\n when ::Sequel::SQL::Expression\n v.to_s(self)\n when Array\n v.all_two_pairs? ? literal(v.sql_expr) : (v.empty? ? '(NULL)' : \"(#{v.collect{|i| literal(i)}.join(COMMA_SEPARATOR)})\")\n when Hash\n literal(v.sql_expr)\n when Time, DateTime\n v.strftime(TIMESTAMP_FORMAT)\n when Date\n v.strftime(DATE_FORMAT)\n when Dataset\n \"(#{v.sql})\"\n else\n raise Error, \"can't express #{v.inspect} as a SQL literal\"\n end\n end", "def literal_string_append(sql, s)\n sql << APOS << s.to_s.gsub(STRING_ESCAPE_RE){|m| STRING_ESCAPES[m]} << APOS\n end", "def literal_string_append(sql, v)\n sql << \"'\" << v.gsub(\"'\", \"''\") << \"'\"\n end", "def visit_Squeel_Nodes_Literal(o, parent)\n Arel.sql(o.expr)\n end", "def as_sql(expression, aliaz)\n \"#{expression} #{quote_identifier(aliaz)}\"\n end", "def lit(*args)\n args.empty? ? self : SQL::PlaceholderLiteralString.new(self, args)\n end", "def lit(*args)\n args.empty? ? LiteralString.new(self) : SQL::PlaceholderLiteralString.new(self, args)\n end", "def sql_string\n StringExpression.new(self.op, *self.args)\n end", "def complex_expression_sql(op, args)\n case op\n when *TWO_ARITY_OPERATORS\n \"(#{literal(args.at(0))} #{op} #{literal(args.at(1))})\"\n when *N_ARITY_OPERATORS\n \"(#{args.collect{|a| literal(a)}.join(\" #{op} \")})\"\n when :NOT\n \"NOT #{literal(args.at(0))}\"\n when :NOOP\n literal(args.at(0))\n else\n raise(Sequel::Error, \"invalid operator #{op}\")\n end\n end", "def query_literal(args)\n case (s = args[0])\n when LiteralString, SQL::Blob\n nil\n when String\n if args.length == 1\n LiteralString.new(s)\n else\n SQL::PlaceholderLiteralString.new(s, args[1..-1])\n end\n end\n end", "def to_sql(arel, binds = [])\n if arel.respond_to?(:ast)\n binds = binds.dup\n visitor.accept(arel.ast) do\n quote(*binds.shift.reverse)\n end\n else\n arel\n end\n end", "def sql_literal_append(ds, sql)\n sql << 'ROW'\n ds.literal_append(sql, to_a)\n if db_type\n sql << '::'\n ds.quote_schema_table_append(sql, db_type)\n end\n end", "def literal_string_append(sql, s)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape(s)} << \"'\"\n end", "def literal_string_append(sql, v)\n db.synchronize(@opts[:server]){|c| sql << c.quote(v)}\n end", "def to_sql(rel_exp=nil)\n rel_exp ||= @rel_exp\n sql = ''\n if rel_exp[0].is_a?(Array) then\n sql << \"(#{to_sql(rel_exp[0])})\"\n else\n sql << rel_exp[0].to_s\n end\n sql << \" #{rel_exp[2]} \"\n if rel_exp[3].is_a?(Array) then\n sql << \"(#{to_sql(rel_exp[3])})\"\n else\n sql << \"'#{rel_exp[3]}'\"\n end\n end", "def literal_string_append(sql, v)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape(v)} << \"'\"\n end", "def literal_string_append(sql, v)\n sql << APOS << db.synchronize{|c| c.escape_string(v)} << APOS\n end", "def function_sql(f)\n args = f.args\n \"#{f.f}#{args.empty? ? '()' : literal(args)}\"\n end", "def string\n @sql_string = \"SELECT #{@select} FROM #{@from}#{@join} WHERE #{@where};\"\n end", "def literal_string_append(sql, v)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape_string(v)} << \"'\"\n end", "def sql_string\n StringExpression.new(:NOOP, self)\n end", "def sql_string\n StringExpression.new(:NOOP, self)\n end", "def sql_literal_append(ds, sql)\n check_columns!\n sql << 'ROW'\n ds.literal_append(sql, values_at(*columns))\n if db_type\n sql << '::'\n ds.quote_schema_table_append(sql, db_type)\n end\n end", "def to_arel_sql(value)\n case value\n when Arel::Nodes::Node, Arel::Nodes::SqlLiteral, nil\n value\n when ActiveRecord::Relation\n Arel.sql(value.spawn.to_sql)\n else\n Arel.sql(value.respond_to?(:to_sql) ? value.to_sql : value.to_s)\n end\n end", "def prepare_for_sql_in_clause\n \"(#{self.to_string_no_brackets})\"\n end", "def `(s)\n Sequel::Deprecation.deprecate(\"Using Sequel#VirtualRow#` to create a literal SQL fragment\", \"Use Sequel.lit instead\")\n Sequel::LiteralString.new(s)\n end", "def literal_blob_append(sql, v)\n sql << \"'\" << v.gsub(/[\\000-\\037\\047\\134\\177-\\377]/n){|b| \"\\\\#{(\"%o\" % b[0..1].unpack(\"C\")[0]).rjust(3, '0')}\"} << \"'\"\n end", "def quoted_identifier_append(sql, c)\n sql << '`%s`' % c\n end", "def to_sparql(**options)\n \"isLiteral(\" + operands.first.to_sparql(**options) + \")\"\n end", "def sql_quoted(value)\n Arel::Nodes.build_quoted(value)\n end", "def sql(options = {})\n options = normalize_options(options)\n if value\t\n\t\"#{column(options)} #{operator} #{quoted_value(options)}\"\n else\n\t\"#{column(options)} #{operator}\"\n end\n end", "def to_sql(prefix = \"\")\n prefix += \"_\" unless prefix.blank?\n Array.wrap(sql).join(\" \").gsub(/__/, prefix)\n end", "def sql_expr\n @sql_expr ||= (meta[:sql_expr] || to_sql_name)\n end", "def to_sql\n @sql ||= case @kind\n when :target, :comp_op, :bin_bool_op, :term\n child(0).to_sql\n when :target_set\n # array of fragments, one per target\n [child(0).to_sql] + (child(1) ? child(2).to_sql : [])\n when :qual_term\n # child(2) will be an array (target_set)\n \"(\" + child(2).to_sql.collect{|sql| comparison(child(0), child(1).child(0), sql)}.join(\" OR \") + \")\"\n when :unqual_term\n \"(\" + default_quals.collect{|q| comparison(q, EQUAL_TOKEN, child(0).to_sql)}.join(\" OR \") + \")\"\n when :query\n # first form\n if child(0).is?(:lparen)\n @children.collect{|c| c.to_sql}.join\n # second form\n elsif child(1) && child(1).is?(:bin_bool_op)\n @children.collect{|c| c.to_sql}.join(\" \")\n # third form\n elsif child(1) && child(1).is?(:query)\n child(0).to_sql + \" AND \" + child(1).to_sql\n # fourth form\n else\n child(0).to_sql\n end\n end\n end", "def build_sql(structure)\n structure = structure.is_a?(Constructor) ? structure.structure : structure\n sql = ''\n [:with, :union, :select, :insert, :update, :delete, :set, :from,\n :join, :where, :returning, :group, :order, :limit, :offset].each do |i|\n next unless structure[i]\n sql += send(\"build_#{i}\", structure[i], structure)\n end\n sql\n end", "def escaped_sql\n sql % binds.reduce({}) { |a, (col, val)|\n a[col.to_sym] = if val.is_a? Array\n val.map { |x| @conn.quote x }.join(', ')\n else\n @conn.quote val\n end\n a\n }\n end", "def with_sql(sql, *args)\n if sql.is_a?(Symbol)\n sql = public_send(sql, *args)\n else\n sql = SQL::PlaceholderLiteralString.new(sql, args) unless args.empty?\n end\n clone(:sql=>sql)\n end", "def build_statement(constructor, field, options = T.unsafe(nil)); end", "def to_cql_literal(value)\n return 'NULL' if value.nil?\n return \"'#{escape_special_chars(value)}'\" if value.is_a?(String)\n return \"'#{value}'\" if value.is_a?(Symbol)\n return \"#{value}\" if value.is_a?(Numeric)\n return \"'#{value.strftime(CQL_TIMESTAMP_FORMAT)}'\" if value.is_a?(Time) || value.is_a?(DateTime)\n #return \"#{value.to_i * 1000}\" if value.is_a?(Time) || value.is_a?(DateTime)\n\n # Set\n if value.is_a?(Set)\n return \"{#{value.map {|v| to_cql_literal(v)}.join(',')}}\"\n end\n\n # Map\n if value.is_a?(Hash)\n keys = value.keys\n return \"{#{keys.map {|k| \"#{to_cql_literal(k)} : #{to_cql_literal(value[k])}\" }.join(',')} }\"\n end\n\n # List\n return \"[#{value.map {|v| to_cql_literal(v)}.join(',')}]\" if value.is_a?(Array)\n\n return nil\n end", "def literal_blob_append(sql, v)\n if v.empty?\n sql << \"''\"\n else\n sql << \"x'#{v.unpack('H*').first}'\"\n end\n end", "def generate_sql\n sql = 'guid, obj_id'\n @fields.each do |field|\n sql << ',v'\n sql << field.num.to_s\n sql << ' as '\n sql << field.name\n end\n return sql\n end", "def sql_valuify\n nil? ? 'NULL' : \"'#{to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\").gsub(/\\t/, \"\\\\t\").gsub(/\\r/, \"\\\\r\").gsub(/\\n/, \"\\\\n\")}'\"\n end", "def sql_string\n self\n end", "def to_ruby_literal\n \"Alf::Relation([\" + tuples.map{|t| Support.to_ruby_literal(t) }.join(', ') + \"])\"\n end", "def to_ruby_literal\n \"Alf::Relation[\" +\n tuples.collect{|t| Tools.to_ruby_literal(t)}.join(', ') + \"]\"\n end", "def literal_string(v)\n \"'#{v.gsub(\"'\", \"''\")}'\"\n end", "def literal(v)\n schema_utility_dataset.literal(v)\n end", "def irregular_function_sql(f)\n \"#{f.f}(#{literal(f.arg1)} #{f.joiner} #{literal(f.arg2)})\"\n end", "def generate_sql_escape(token)\n escaped_token = token.gsub(/\\\\|'/, '\\0\\0\\0\\0').gsub(\"?\", \"\\\\\\\\77\")\n \"'\" + escaped_token + \"'\"\n end", "def emit_literal\n text = literal.join\n self.literal = nil\n emit(:literal, :literal, text)\n end", "def literal(v)\n schema_utility_dataset.literal(v)\n end", "def literal(v)\n schema_utility_dataset.literal(v)\n end", "def interpolate_sql(sql, record = nil)\n instance_eval(\"%(#{sql})\")\n end", "def complex_expression_sql_append(sql, op, args)\n case op\n when :^\n j = ' # '\n c = false\n args.each do |a|\n sql << j if c\n literal_append(sql, a)\n c ||= true\n end\n when :ILIKE, :'NOT ILIKE'\n sql << '('\n literal_append(sql, args[0])\n sql << ' ' << op.to_s << ' '\n literal_append(sql, args[1])\n sql << ')'\n else\n super\n end\n end", "def sql\n @sql ||= begin\n bind_params = []\n 1.upto(selector_keys.length + setter_keys.length) { |i| bind_params << \"$#{i}\" }\n %{SELECT #{name}(#{bind_params.join(', ')})}\n end\n end", "def compound_dataset_sql_append(sql, ds)\n sql << '('\n super\n sql << ')'\n end", "def sql_string(value)\n \"'#{value.gsub(\"'\", \"''\")}'\" \nend", "def to_sql(code)\n raise ArgumentError, 'code required' if code.nil? || code.strip.empty?\n expr = VinesQL.parse(code.strip)\n\n keys, values = expr.params.partition.each_with_index {|p, ix| ix % 2 == 0 }\n joins = keys.each_with_index.map do |k, ix|\n \"inner join attributes a%s on id=a%s.system_id and a%s.key=?\" % [ix, ix, ix]\n end\n\n where = expr.sql.tap do |sql|\n values.size.times do |ix|\n sql.sub!(/(^|[^\\.])value/, \"\\\\1a#{ix}.value\")\n end\n end\n\n sql = %Q{\n select name, os from systems\n #{joins.join(\"\\n\")}\n where #{where}\n order by name\n }\n\n [sql, [keys, values].flatten]\n end", "def sql_raw(*args)\n sql, bind = parse_args(*args)\n return SQL::QueryMaker.new(nil, Proc.new { sql }, bind)\n end", "def to_sparql(**options)\n \"STRLANG(\" + operands.to_sparql(delimiter: ', ', **options) + \")\"\n end", "def aliased_expression_sql(ae)\n \"#{literal(ae.expression)} AS #{quote_identifier(ae.aliaz)}\"\n end", "def subscript_sql(s)\n \"#{s.f}[#{s.sub.join(COMMA_SEPARATOR)}]\"\n end", "def to_nosql(arel, binds = [])\n arel = arel.ast if arel.respond_to?(:ast)\n if arel.is_a? ::Arel::Nodes::Node\n binds = binds.dup\n visitor.accept(arel) do\n quote(*binds.shift.reverse)\n end\n else # assume it is already serialized\n arel\n end\n end", "def to_sql\n [@sql_insert, @sql_on_conflict, @sql_returning].reject(&:nil?).join(' ')\n end", "def emit_literal\n text = literal_run.join\n self.literal_run = nil\n emit(:literal, :literal, text)\n end", "def sql\n selected_field_path = \"#{@selection.target_alias}.#{@selection.selected_field}\"\n operation = self.sql_operation.sub('?field', selected_field_path)\n \"#{operation} AS #{@field_name}\"\n end", "def literal_symbol_append(sql, v)\n if @opts[:bind_vars] and match = /\\A\\$(.*)\\z/.match(v.to_s)\n s = match[1].to_sym\n if prepared_arg?(s)\n literal_append(sql, prepared_arg(s))\n else\n sql << v.to_s\n end\n else\n super\n end\n end", "def to_sql(options = {})\n \"#{field.to_sql(options)} = #{expression.to_sql(options)}\"\n end", "def literal_string(v)\n db.synchronize{|c| \"'#{c.escape(v)}'\"}\n end", "def raw_sql(record)\n record.class.arel_table.create_insert.tap do |insert_manager|\n insert_manager.insert(insert_values(record))\n end.to_sql\n end", "def `(value)\n ::Sequel.lit(value)\n end", "def to_sql\n [@attribute.to_sql,@value.to_sql].compact.join(' ')\n end", "def get_sql(structure, options)\n # get_partial_sql structure, key: 'sql'\n wrap_result send(\"build_#{options[:key] || 'sql'}\", structure)\n end", "def creating_jql_string arr, str, type\n if !arr.empty? && str.empty?\n array_to_string arr, type\n elsif !arr.empty? && !str.empty?\n \" AND #{array_to_string(arr, type)}\"\n end\n end", "def sql\n @sql ||= begin\n bind_params = []\n i = 1\n (selector_keys.length + setter_keys.length).times do\n bind_params << \"$#{i}\"\n i += 1\n end\n hstore_delete_handlers.length.times do\n bind_params << \"$#{i}::text[]\"\n i += 1\n end\n %{SELECT #{name}(#{bind_params.join(', ')})}\n end\n end", "def sql\n @sql ||= begin\n bind_params = []\n i = 1\n (selector_keys.length + setter_keys.length).times do\n bind_params << \"$#{i}\"\n i += 1\n end\n hstore_delete_handlers.length.times do\n bind_params << \"$#{i}::text[]\"\n i += 1\n end\n %{SELECT #{name}(#{bind_params.join(', ')})}\n end\n end", "def literal; end", "def literal_blob_append(sql, v)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape_bytea(v)} << \"'\"\n end", "def sql\n s = \"\"\n options = @options.dup\n\n if update = options.delete(:update)\n s = \"UPDATE \"\n s << Mao.quote_ident(@table)\n s << \" SET \"\n\n if update.length == 0\n raise ArgumentError, \"invalid update: nothing to set\"\n end\n\n s << update.map do |column, value|\n check_column(column, @table, @col_types)\n\n \"#{Mao.quote_ident(column)} = #{Mao.escape_literal(value)}\"\n end.join(\", \")\n\n if where = options.delete(:where)\n s << \" WHERE \"\n s << Mao::Filter.sql(where)\n end\n elsif insert = options.delete(:insert)\n s = \"INSERT INTO \"\n s << Mao.quote_ident(@table)\n s << \" (\"\n\n keys = insert.map(&:keys).flatten.uniq.sort\n s << keys.map do |column|\n check_column(column, @table, @col_types)\n Mao.quote_ident(column)\n end.join(\", \")\n s << \") VALUES \"\n\n first = true\n insert.each do |row|\n if first\n first = false\n else\n s << \", \"\n end\n\n s << \"(\"\n s << keys.map {|k|\n if row.include?(k)\n Mao.escape_literal(row[k])\n else\n \"DEFAULT\"\n end\n }.join(\", \")\n s << \")\"\n end\n\n if returning = options.delete(:returning)\n s << \" RETURNING \"\n s << returning.map {|c| Mao.quote_ident(c)}.join(\", \")\n end\n else\n s = \"SELECT \"\n\n join = options.delete(:join)\n only = options.delete(:only)\n\n if join\n n = 0\n s << (@col_types.keys.sort.map {|c|\n n += 1\n if !only or (only[@table] and only[@table].include?(c))\n \"#{Mao.quote_ident(@table)}.#{Mao.quote_ident(c)} \" +\n \"#{Mao.quote_ident(\"c#{n}\")}\"\n end\n } + Mao.query(join[0]).col_types.keys.sort.map {|c|\n n += 1\n if !only or (only[join[0]] and only[join[0]].include?(c))\n \"#{Mao.quote_ident(join[0])}.#{Mao.quote_ident(c)} \" +\n \"#{Mao.quote_ident(\"c#{n}\")}\"\n end\n }).reject(&:nil?).join(\", \")\n elsif only\n s << only.map {|c| Mao.quote_ident(c)}.join(\", \")\n else\n s << \"*\"\n end\n\n s << \" FROM #{Mao.quote_ident(@table)}\"\n\n if join\n s << \" INNER JOIN #{Mao.quote_ident(join[0])} ON \"\n s << Mao::Filter.sql(join[1])\n end\n\n if where = options.delete(:where)\n s << \" WHERE \"\n s << Mao::Filter.sql(where)\n end\n\n if order = options.delete(:order)\n s << \" ORDER BY \"\n s << Mao.quote_ident(order[0])\n s << \" \"\n s << order[1]\n end\n\n if limit = options.delete(:limit)\n s << \" LIMIT #{limit}\"\n end\n end\n\n if options.length > 0\n raise ArgumentError,\n \"invalid options in #sql: #{options.inspect}. \" \\\n \"SQL constructed: #{s}\"\n end\n\n s\n end", "def to_sql\n @applied.reverse.map{ |e| \"#{e.type}(#{e.args.join(\", \")})\" }.join('.')\n end", "def sql_op(*args)\n column, expr, bind = (args.size >= 3 ? args : [nil] + args)\n (num_bind, builder) = _compile_builder(expr)\n croak(\"the operator expects num_bind but got #{bind.size}\") if num_bind != bind.size\n return _sql_op(\"sql_op\", builder, column, bind)\n end", "def next_condition_as_sql\n case @next_condition\n when CONDITION::NONE\n return \"\"\n when CONDITION::AND\n return \"AND\"\n when CONDITION::OR\n return \"OR\"\n end\n end", "def to_sparql(**options)\n \"(!\" + operands.first.to_sparql(**options) + \")\"\n end", "def build_insert_stmt(dynamo_field_value)\n values = []\n insert_stmt_fields = DynamoFieldValue.column_names.reject{ |field| field == 'id'}\n insert_stmt_fields.each do |field_name|\n # We need to tinker with fields based on their type for sql syntax purposes\n temp_val = dynamo_field_value.send(field_name)\n temp_val = \"'#{temp_val}'\" if temp_val.class.to_s == \"String\" || temp_val.class.to_s == \"ActiveSupport::TimeWithZone\"\n temp_val = \"NULL\" if temp_val.nil?\n values << temp_val\n end\n \"(#{values.join(',')})\"\n end", "def create_table_as_sql(name, sql, options)\n \"#{create_table_prefix_sql(name, options)} AS (#{sql}) WITH DATA\"\n end", "def create_language_sql(name, opts=OPTS)\n \"CREATE#{' OR REPLACE' if opts[:replace] && server_version >= 90000}#{' TRUSTED' if opts[:trusted]} LANGUAGE #{name}#{\" HANDLER #{opts[:handler]}\" if opts[:handler]}#{\" VALIDATOR #{opts[:validator]}\" if opts[:validator]}\"\n end", "def escape_sql(args)\n return @text if args.empty?\n sql = @text.dup\n vars = args.dup\n\n replacements = 0\n mismatch = false\n\n sql.gsub!(/'[^']*'|\"[^\"]*\"|`[^`]*`|\\?/) do |x|\n next x unless x == '?'\n replacements += 1\n if vars.empty?\n mismatch = true\n else\n var = vars.shift\n connection.quote_value(var)\n end\n end\n\n if !vars.empty? || mismatch\n raise ArgumentError, \"Binding mismatch: #{args.size} for #{replacements}\"\n else\n sql\n end\n end", "def to_sql\n\n # Hide Amex numbers\n# if (!@titolo_name.nil?) \n# if (@categoria_name == \"AMERICAN EXPRESS\" || @categoria_name == \"BANK OF AMERICA\") \n# @titolo_name.gsub!(/\\*.*\\*/, \"\");\n# end\n# end\n\n \n\n return \"INSERT INTO expenses (`created`, `anno`, `missione_title`, `missione_id`, `categoria_title`, `categoria_code`, `titolo_name`, `amministrazione_id`, `amministrazione_title`, `programma_id`, `programma_title`, `pagamenti_residui`,`pagamenti_totali`) VALUES (NOW(), '#{@anno}','#{@missione_title.to_s.gsub(/\\\\/,'\\&\\&').gsub(/'/,\"''\")}', '#{@missione_id}', '#{@categoria_title.to_s.gsub(/'/, \"''\")}', '#{@categoria_code}', '#{@titolo_name.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")}', '#{@amministrazione_id}', '#{@amministrazione_title.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")}', '#{@programma_id}', '#{@programma_title.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")}', #{@pagamenti_residui.gsub(/,/, \"\")}), #{@pagamenti_totali.gsub(/,/, \"\")});\"\n end", "def make_sql_friendly( name )\n return name.strip.gsub( \"'\", \"''\" )\n end", "def build_equal_condition(v) \n if v.nil?\n # Nulls (nil)\n return \"IS NULL\"\n elsif v.kind_of? Integer or v.kind_of? Float\n # Integers / Floats\n return \"= \"+v.to_s\n else\n # Everything Else\n return \"= '#{@mysql.escape(v.to_s)}'\" \n end\n end", "def get_target_string_literal_from_antlrstring_literal(codegen, literal)\n buf = Grammar.get_unescaped_string_from_grammar_string_literal(literal)\n prefix = \"\\\"\"\n if (codegen.attr_grammar.get_max_char_value > 255)\n prefix = \"L\\\"\"\n end\n return prefix + RJava.cast_to_string(escape_string(buf.to_s)) + \"\\\"\"\n end", "def <<(sql); execute((Array === sql) ? sql.to_sql : sql); end", "def sql! sql=nil\n require 'niceql'\n puts Niceql::Prettifier.prettify_sql sql || $last_sql_command\n end", "def to_select_sql\n return nil unless include_as_association?\n \n separator = all_ints? || all_datetimes? || @crc ? ',' : ' '\n \n clause = @columns.collect { |column|\n part = column_with_prefix(column)\n case type\n when :string\n adapter.convert_nulls(part)\n when :datetime\n adapter.cast_to_datetime(part)\n when :multi\n part = adapter.cast_to_datetime(part) if is_many_datetimes?\n part = adapter.convert_nulls(part, '0') if is_many_ints?\n part\n else\n part\n end\n }.join(', ')\n \n clause = adapter.crc(clause) if @crc\n clause = adapter.concatenate(clause, separator) if concat_ws?\n clause = adapter.group_concatenate(clause, separator) if is_many?\n \n \"#{clause} AS #{quote_column(unique_name)}\"\n end" ]
[ "0.7736763", "0.76860034", "0.7586923", "0.73519284", "0.72554016", "0.7220023", "0.72013044", "0.7135038", "0.708184", "0.6977372", "0.6962823", "0.68229246", "0.67857265", "0.67269695", "0.6726387", "0.67204005", "0.6716745", "0.6714795", "0.67112356", "0.66904217", "0.66794395", "0.6675131", "0.66618145", "0.66564035", "0.6631944", "0.660022", "0.65975004", "0.65975004", "0.65786946", "0.65605", "0.6512949", "0.6499905", "0.64883065", "0.6459054", "0.6450768", "0.64317465", "0.64226854", "0.63858", "0.6376434", "0.6348396", "0.6344253", "0.63123316", "0.6253075", "0.62500435", "0.6246797", "0.6214841", "0.62063336", "0.61596644", "0.6138671", "0.61335695", "0.6093732", "0.60866034", "0.6080864", "0.6076841", "0.6074828", "0.60214096", "0.60142195", "0.60142195", "0.5987906", "0.59870964", "0.59870416", "0.59831554", "0.5966844", "0.59634084", "0.5955762", "0.5954706", "0.59366983", "0.59064525", "0.58775747", "0.5874777", "0.58632547", "0.5860132", "0.58599687", "0.58474576", "0.58420616", "0.5833468", "0.58266777", "0.5824142", "0.5821609", "0.5800854", "0.5776179", "0.5776179", "0.5766039", "0.5762799", "0.5752719", "0.5749163", "0.5747773", "0.5742318", "0.5728546", "0.5698584", "0.5684125", "0.5667482", "0.5666096", "0.5663772", "0.56448615", "0.5639529", "0.5639003", "0.56368333", "0.56357974", "0.56124634" ]
0.8052894
0
Construct a SQL quoted string. This is used for fragments of SQL.
def sql_quoted(value) Arel::Nodes.build_quoted(value) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def string\n @sql_string = \"SELECT #{@select} FROM #{@from}#{@join} WHERE #{@where};\"\n end", "def quoted_identifier_append(sql, c)\n sql << '`%s`' % c\n end", "def escaped_sql\n sql % binds.reduce({}) { |a, (col, val)|\n a[col.to_sym] = if val.is_a? Array\n val.map { |x| @conn.quote x }.join(', ')\n else\n @conn.quote val\n end\n a\n }\n end", "def format_quote(q)\n if q == \"'\"\n '\"\\'\"'\n else\n \"'#{q}'\"\n end\n end", "def literal_string_append(sql, v)\n sql << \"'\" << ::Mysql.quote(v) << \"'\"\n end", "def quoted(value)\n sql _scope.connection.quote(value)\n end", "def quoted(value)\n sql _scope.connection.quote(value)\n end", "def literal_string_append(sql, v)\n sql << \"'\" << v.gsub(\"'\", \"''\") << \"'\"\n end", "def to_sql(prefix = \"\")\n prefix += \"_\" unless prefix.blank?\n Array.wrap(sql).join(\" \").gsub(/__/, prefix)\n end", "def generate_sql_escape(token)\n escaped_token = token.gsub(/\\\\|'/, '\\0\\0\\0\\0').gsub(\"?\", \"\\\\\\\\77\")\n \"'\" + escaped_token + \"'\"\n end", "def to_sql(rel_exp=nil)\n rel_exp ||= @rel_exp\n sql = ''\n if rel_exp[0].is_a?(Array) then\n sql << \"(#{to_sql(rel_exp[0])})\"\n else\n sql << rel_exp[0].to_s\n end\n sql << \" #{rel_exp[2]} \"\n if rel_exp[3].is_a?(Array) then\n sql << \"(#{to_sql(rel_exp[3])})\"\n else\n sql << \"'#{rel_exp[3]}'\"\n end\n end", "def custom_sql(q)\n query = q + ';' unless q =~ /;$/\n query = @db_connection.query(\"#{query}\")\n query.each { |x| print_line(\"#{x.join(',')}\") } unless query.empty?\n end", "def sql_string(value)\n \"'#{value.gsub(\"'\", \"''\")}'\" \nend", "def literal_string_append(sql, s)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape(s)} << \"'\"\n end", "def quoted_string; end", "def literal_string_append(sql, v)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape(v)} << \"'\"\n end", "def escape_sql(args)\n return @text if args.empty?\n sql = @text.dup\n vars = args.dup\n\n replacements = 0\n mismatch = false\n\n sql.gsub!(/'[^']*'|\"[^\"]*\"|`[^`]*`|\\?/) do |x|\n next x unless x == '?'\n replacements += 1\n if vars.empty?\n mismatch = true\n else\n var = vars.shift\n connection.quote_value(var)\n end\n end\n\n if !vars.empty? || mismatch\n raise ArgumentError, \"Binding mismatch: #{args.size} for #{replacements}\"\n else\n sql\n end\n end", "def quote(s)\n \"\\\"#{s}\\\"\"\n end", "def literal_string_append(sql, v)\n db.synchronize(@opts[:server]){|c| sql << c.quote(v)}\n end", "def literal_string_append(sql, v)\n sql << \"'\" << db.synchronize(@opts[:server]){|c| c.escape_string(v)} << \"'\"\n end", "def qq esc = nil\n %[\"#{esc ? self.gsub('\"') { esc } : self}\"]\n end", "def sql! sql=nil\n require 'niceql'\n puts Niceql::Prettifier.prettify_sql sql || $last_sql_command\n end", "def to_s()\n @sql ||= print_to(Printer.new()).to_s()\n end", "def to_sql\n [@sql_insert, @sql_on_conflict, @sql_returning].reject(&:nil?).join(' ')\n end", "def quote_string(s) #:nodoc:\n s.gsub(/'/, \"''\") # ' (for ruby-mode)\n end", "def literal_string_append(sql, s)\n sql << APOS << s.to_s.gsub(STRING_ESCAPE_RE){|m| STRING_ESCAPES[m]} << APOS\n end", "def dquote( str ) #:nodoc:\n unless str =~ /^\".*?\"$/\n '\"' + str.gsub(/[\"\\\\]/n) {|s| '\\\\' + s } + '\"'\n else\n str\n end\n end", "def quote( val )\n\t\treturn %q{\"%s\"} % [ val.to_s.gsub(/\"/, '\\\\\"') ]\n\tend", "def make_sql_friendly( name )\n return name.strip.gsub( \"'\", \"''\" )\n end", "def format_sql_comment(comment)\n \" -- #{comment.to_s.gsub(/\\s+/, ' ')}\\n\"\n end", "def sql_string\n self\n end", "def sql_quote(value)\n value = value.to_s.downcase if %i[nil null NULL].include?(value)\n # noinspection RubyMismatchedReturnType\n case value\n when nil, 'nil', 'null', 'NULL' then nil\n when /^-?\\d+$/ then value.to_i\n when SQL_NUMBER then value.to_f\n when String, Symbol then \"'#{value}'\"\n else value\n end\n end", "def _format_sql(sql)\n sql = sql.delete '\"'\n sql.downcase\n end", "def quote(s, column = nil)\n dummy_conn.quote(s)\n end", "def as_sql(expression, aliaz)\n \"#{expression} #{quote_identifier(aliaz)}\"\n end", "def odb_format_str(*args)\n \"format('#{to_s}', #{args.map{|x| quote(x)}.join(', ')})\"\n end", "def sql_valuify\n nil? ? 'NULL' : \"'#{to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\").gsub(/\\t/, \"\\\\t\").gsub(/\\r/, \"\\\\r\").gsub(/\\n/, \"\\\\n\")}'\"\n end", "def quote\n %q[(?:\"|')?]\n end", "def quoted_definition\n \"'%s'\" % \\\n definition.\n gsub(\"\\\\'\") { |m| '\\\\' + m }.\n gsub(\"'\") { |m| %q['\\''] }\n end", "def quoted(string)\n if string.to_s.match(/[\\t\\n\\r]/)\n string = string.gsub('\\\\', '\\\\\\\\\\\\\\\\').gsub('\"\"\"', '\\\\\"\\\\\"\\\\\"')\n %(\"\"\"#{string}\"\"\")\n else\n \"\\\"#{escaped(string)}\\\"\"\n end\n end", "def to_Qdl\n gsub /\\\"/,\"'\"\n end", "def qualified_identifier_sql(qcr)\n \"#{quote_identifier(qcr.table)}.#{quote_identifier(qcr.column)}\"\n end", "def subscript_sql(s)\n \"#{s.f}[#{s.sub.join(COMMA_SEPARATOR)}]\"\n end", "def literal_string_append(sql, v)\n sql << APOS << db.synchronize{|c| c.escape_string(v)} << APOS\n end", "def sql_string\n StringExpression.new(self.op, *self.args)\n end", "def quote(sep = nil)\n sep ||= \"'\"\n sep + self + sep\n end", "def quote_column_name(name) #:nodoc:\r\n %Q(\"#{name}\")\r\n end", "def sql sql\n @master.puts \"#{sql};\"\n end", "def sql(options = {})\n options = normalize_options(options)\n if value\t\n\t\"#{column(options)} #{operator} #{quoted_value(options)}\"\n else\n\t\"#{column(options)} #{operator}\"\n end\n end", "def quoted\n with_opts(:quoted=>true)\n end", "def quote(value)\n return value.inspect unless value.is_a? String\n\n if value.include?(\"'\")\n value.inspect\n else\n \"'#{value}'\"\n end\n end", "def to_sql(arel, binds = [])\n if arel.respond_to?(:ast)\n binds = binds.dup\n visitor.accept(arel.ast) do\n quote(*binds.shift.reverse)\n end\n else\n arel\n end\n end", "def quote(string)\n\t\t\tstring.nil? ? \"NULL\" : \"'#{super}'\"\n\t\tend", "def esc\r\n \"\\\"#{self}\\\"\"\r\n end", "def escape_for_cql_double_quotes(str)\n str = str.gsub('\"', \" \")\n str = str.gsub(\"'\", \"''\")\n\n return str\n end", "def to_sql\n @sql ||= case @kind\n when :target, :comp_op, :bin_bool_op, :term\n child(0).to_sql\n when :target_set\n # array of fragments, one per target\n [child(0).to_sql] + (child(1) ? child(2).to_sql : [])\n when :qual_term\n # child(2) will be an array (target_set)\n \"(\" + child(2).to_sql.collect{|sql| comparison(child(0), child(1).child(0), sql)}.join(\" OR \") + \")\"\n when :unqual_term\n \"(\" + default_quals.collect{|q| comparison(q, EQUAL_TOKEN, child(0).to_sql)}.join(\" OR \") + \")\"\n when :query\n # first form\n if child(0).is?(:lparen)\n @children.collect{|c| c.to_sql}.join\n # second form\n elsif child(1) && child(1).is?(:bin_bool_op)\n @children.collect{|c| c.to_sql}.join(\" \")\n # third form\n elsif child(1) && child(1).is?(:query)\n child(0).to_sql + \" AND \" + child(1).to_sql\n # fourth form\n else\n child(0).to_sql\n end\n end\n end", "def get_filter_sql\n filter_sql = \"( \"\n self.foreach_filter do |filter|\n filter_sql += \"#{filter.get_filter_sql} #{filter.next_condition_as_sql} \"\n end\n filter_sql += \")\"\n return filter_sql\n end", "def quote\n %Q{\"#{self}\"}\n end", "def compound_dataset_sql_append(sql, ds)\n sql << '('\n super\n sql << ')'\n end", "def generate_sql(columns)\n [\"SELECT #{columns} FROM #{@from}\", @where, @group, @having, @order, @limit, @offset].join\n end", "def quote_string(value)\n \"'#{value.gsub(\"'\", \"''\")}'\"\n end", "def esc_sql(data )\n # global $wpdb;\n $wpdb._escape(data)\n end", "def to_escaped_for_sql_like\n gsub(/[\\\\%_]/) { |x| '\\\\' + x }.gsub(\"*\", \"%\")\n end", "def sql_strings(value)\n case value\n when String\n \"'#{value}'\"\n when Numeric\n value.to_s\n else\n \"null\"\n end\n end", "def quote_column_name(name)\n %[\"#{name.to_s.gsub('\"', '\"\"')}\"]\n end", "def quote(value)\n string = value.to_s\n unquoted = unquote(string)\n escaped = unquoted.gsub(QuoteNotEscapedMatcher, \"\\\\\\\"\")\n %Q{\"#{escaped}\"}\n end", "def quote(*args)\n arr = args.map {|x| '\"' + x + '\"'}\n return arr.join(\" \")\nend", "def escape(string)\n # This code is taken directly from the documentation so we dont have to rely on the SQLite3::Database class. This way it can also be used with JRuby and IronRuby...\n # http://sqlite-ruby.rubyforge.org/classes/SQLite/Database.html\n string.to_s.gsub(\"'\", \"''\")\n end", "def to_sql\n @applied.reverse.map{ |e| \"#{e.type}(#{e.args.join(\", \")})\" }.join('.')\n end", "def sql(string)\n ::Arel::Nodes::SqlLiteral.new(string)\n end", "def wrap_in_quotes(str)\n unless str\n return str\n end\n\n %Q(\"#{str}\")\n end", "def q(str)\n str.class == String ? ActiveRecord::Base.connection.quote_string(str) : str\n end", "def quoted(node)\n @model_class.connection.quote(node, self.last_column)\n end", "def quote(value)\n return \"'#{value}'\" if value.is_a?(String)\n\n value.to_s\n end", "def creating_jql_string arr, str, type\n if !arr.empty? && str.empty?\n array_to_string arr, type\n elsif !arr.empty? && !str.empty?\n \" AND #{array_to_string(arr, type)}\"\n end\n end", "def to_s\n statements.collect { |s| s.to_s }.join(\";\\n\")\n end", "def quote(fld)\n case fld\n when DateTime, Time\n %Q|'#{fld.to_s[0..-7]}'|\n when String, Symbol\n %Q|'#{escape fld.to_s}'|\n else\n super\n end\n\n end", "def sql\n s = \"\"\n options = @options.dup\n\n if update = options.delete(:update)\n s = \"UPDATE \"\n s << Mao.quote_ident(@table)\n s << \" SET \"\n\n if update.length == 0\n raise ArgumentError, \"invalid update: nothing to set\"\n end\n\n s << update.map do |column, value|\n check_column(column, @table, @col_types)\n\n \"#{Mao.quote_ident(column)} = #{Mao.escape_literal(value)}\"\n end.join(\", \")\n\n if where = options.delete(:where)\n s << \" WHERE \"\n s << Mao::Filter.sql(where)\n end\n elsif insert = options.delete(:insert)\n s = \"INSERT INTO \"\n s << Mao.quote_ident(@table)\n s << \" (\"\n\n keys = insert.map(&:keys).flatten.uniq.sort\n s << keys.map do |column|\n check_column(column, @table, @col_types)\n Mao.quote_ident(column)\n end.join(\", \")\n s << \") VALUES \"\n\n first = true\n insert.each do |row|\n if first\n first = false\n else\n s << \", \"\n end\n\n s << \"(\"\n s << keys.map {|k|\n if row.include?(k)\n Mao.escape_literal(row[k])\n else\n \"DEFAULT\"\n end\n }.join(\", \")\n s << \")\"\n end\n\n if returning = options.delete(:returning)\n s << \" RETURNING \"\n s << returning.map {|c| Mao.quote_ident(c)}.join(\", \")\n end\n else\n s = \"SELECT \"\n\n join = options.delete(:join)\n only = options.delete(:only)\n\n if join\n n = 0\n s << (@col_types.keys.sort.map {|c|\n n += 1\n if !only or (only[@table] and only[@table].include?(c))\n \"#{Mao.quote_ident(@table)}.#{Mao.quote_ident(c)} \" +\n \"#{Mao.quote_ident(\"c#{n}\")}\"\n end\n } + Mao.query(join[0]).col_types.keys.sort.map {|c|\n n += 1\n if !only or (only[join[0]] and only[join[0]].include?(c))\n \"#{Mao.quote_ident(join[0])}.#{Mao.quote_ident(c)} \" +\n \"#{Mao.quote_ident(\"c#{n}\")}\"\n end\n }).reject(&:nil?).join(\", \")\n elsif only\n s << only.map {|c| Mao.quote_ident(c)}.join(\", \")\n else\n s << \"*\"\n end\n\n s << \" FROM #{Mao.quote_ident(@table)}\"\n\n if join\n s << \" INNER JOIN #{Mao.quote_ident(join[0])} ON \"\n s << Mao::Filter.sql(join[1])\n end\n\n if where = options.delete(:where)\n s << \" WHERE \"\n s << Mao::Filter.sql(where)\n end\n\n if order = options.delete(:order)\n s << \" ORDER BY \"\n s << Mao.quote_ident(order[0])\n s << \" \"\n s << order[1]\n end\n\n if limit = options.delete(:limit)\n s << \" LIMIT #{limit}\"\n end\n end\n\n if options.length > 0\n raise ArgumentError,\n \"invalid options in #sql: #{options.inspect}. \" \\\n \"SQL constructed: #{s}\"\n end\n\n s\n end", "def quote_string(string)\n @logger.unknown(\"ODBCAdapter#quote_string>\") if @trace\n\n # MySQL requires backslashes to be escaped\t\t\t\t\n string.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")\n end", "def function_sql(f)\n args = f.args\n \"#{f.f}#{args.empty? ? '()' : literal(args)}\"\n end", "def quote(val, column=nil)\n return val unless val.is_a?(String)\n \"'#{val.gsub(/\\'/, \"\\\\\\\\'\")}'\" # \" <= for Emacs font-lock\n end", "def build_query(table_name, where_expression)\n query = %Q{SELECT *\\n FROM \"#{table_name}\"}\n unless where_expression.nil?\n query << \"\\n WHERE #{where_expression}\"\n end\n unless (pk = find_primary_key(table_name)).empty?\n query << \"\\n ORDER BY \" << pk.join(', ')\n end\n return query\nend", "def to_sql\n [@attribute.to_sql,@value.to_sql].compact.join(' ')\n end", "def to_gql\n result = ' ' * __depth + __name\n result += __params_to_s(__params, true) unless __params.empty?\n unless __nodes.empty?\n result += \" {\\n\"\n result += __nodes.map(&:to_gql).join(\"\\n\")\n result += \"\\n#{' ' * __depth}}\"\n end\n\n result\n end", "def quote_table_name(name)\n '[' + name.to_s + ']'\n end", "def add_quotes_to_string(string)\n string = \"'#{string}'\"\n end", "def generate_sql\n sql = 'guid, obj_id'\n @fields.each do |field|\n sql << ',v'\n sql << field.num.to_s\n sql << ' as '\n sql << field.name\n end\n return sql\n end", "def to_s\n require \"shellwords\"\n\n escaped_args = @args.map do |arg|\n escaped = Shellwords.escape(arg)\n next escaped if escaped == arg\n next escaped if arg.include?(\"'\")\n \"'#{arg}'\"\n end\n escaped_args.join(\" \")\n end", "def quote(value, column = nil)\n connection.quote(value, column)\n end", "def quoted_table_name\n @quoted_table_name ||= \"`#{table_name}`\"\n end", "def quote_column_name(str)\n str.to_s\n end", "def quote(text)\n \"#{quotes[0]}#{text}#{quotes[1]}\"\n end", "def prepare_for_sql_in_clause\n \"(#{self.to_string_no_brackets})\"\n end", "def sql\n @sql ||= begin\n bind_params = []\n 1.upto(selector_keys.length + setter_keys.length) { |i| bind_params << \"$#{i}\" }\n %{SELECT #{name}(#{bind_params.join(', ')})}\n end\n end", "def quote(value) # :doc:\n if value.respond_to? :each_pair\n return value.map do |k, v|\n \"#{k}: #{quote(v)}\"\n end.join(\", \")\n end\n return value.inspect unless value.is_a? String\n\n if value.include?(\"'\")\n value.inspect\n else\n \"'#{value}'\"\n end\n end", "def qesc(s)\n s.gsub(\"'\", \"''\")\nend", "def to_sql\n return nil unless filters.present? and valid?\n filters.map { |n, f| sql_for(n) }.reject(&:blank?).join(' AND ')\n end", "def quote_column_name(name) #:nodoc:\n \"\\\"#{name}\\\"\"\n #query(\"SELECT QUOTE_IDENT('#{name}')\")[0][0]\n end", "def shq(s) # sh(1)-style quoting\n sprintf(\"'%s'\", s.gsub(/'/, \"'\\\\\\\\''\"))\nend", "def sql\n @sql ||= begin\n bind_params = []\n i = 1\n (selector_keys.length + setter_keys.length).times do\n bind_params << \"$#{i}\"\n i += 1\n end\n hstore_delete_handlers.length.times do\n bind_params << \"$#{i}::text[]\"\n i += 1\n end\n %{SELECT #{name}(#{bind_params.join(', ')})}\n end\n end" ]
[ "0.7503615", "0.7257309", "0.71583223", "0.70563316", "0.7047856", "0.7003093", "0.7003093", "0.69992816", "0.6699972", "0.6696728", "0.6689568", "0.6659244", "0.6655971", "0.662139", "0.65766203", "0.6499731", "0.6451111", "0.6422716", "0.6410513", "0.6401725", "0.6389198", "0.6351363", "0.63388526", "0.6323545", "0.63112205", "0.6284272", "0.6275704", "0.6272412", "0.6256789", "0.6251071", "0.6249669", "0.6241885", "0.62294996", "0.62245363", "0.6192176", "0.61842567", "0.61811936", "0.6163187", "0.61402375", "0.6123048", "0.61141443", "0.61033857", "0.6094644", "0.60882133", "0.6064427", "0.6058659", "0.6041432", "0.6030713", "0.6025979", "0.59985477", "0.59850127", "0.5976523", "0.5975075", "0.5969916", "0.59657395", "0.5962415", "0.596077", "0.5959552", "0.59578073", "0.59233844", "0.5920882", "0.59090906", "0.59080976", "0.5905574", "0.5902642", "0.58995485", "0.5897434", "0.5876452", "0.5872814", "0.5871132", "0.5871104", "0.5867849", "0.58675975", "0.58653575", "0.5863259", "0.5852921", "0.58497787", "0.5848042", "0.5844986", "0.58380896", "0.583505", "0.5819981", "0.581946", "0.5818914", "0.5815764", "0.5814304", "0.5811838", "0.58065546", "0.58043325", "0.5774941", "0.5765194", "0.5761236", "0.5757519", "0.57558894", "0.5752122", "0.57442033", "0.5737208", "0.57289207", "0.572842", "0.5724834" ]
0.73625314
1
Construct a SQL EXISTS clause.
def exists(node) Arel::Nodes::Exists.new(node) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exists(opts = nil)\n \"EXISTS (#{select_sql(opts)})\"\n end", "def exists(table, where = {})\n count(table, where) > 0\n end", "def exists(*args); end", "def exist? \n !DB.execute(\"SELECT name FROM students WHERE Id = ? \", @id).empty?\n end", "def prepare_for_sql_in_clause\n \"(#{self.to_string_no_brackets})\"\n end", "def exists?\n criteria.exists?\n end", "def exists?(*args); end", "def to_sql_contains\n \"%#{to_sql_escaped_for_like}%\"\n end", "def row_exists?(dbh, table=nil, column=nil, where_value=nil)\n stmt = %Q(SELECT #{column} FROM #{table} WHERE #{column} = #{where_value})\n res = dbh.query(stmt)\n ary = []\n res.each do |array|\n array.each do |value|\n ary << value\n end\n end\n ary.empty? ? false : true\nend", "def exists?\n rec = run_sql(\"SELECT * FROM #{table} WHERE id = #{@id};\")\n if rec.empty?\n @errors << \"That id does not exist in the table.\"\n false\n else\n true\n end\n end", "def contains(val, path=nil)\n fn = function(:contains, self, Sequel.object_to_json(val), path)\n Sequel::SQL::BooleanExpression.new(:NOOP, fn)\n end", "def exists_with(hash)\n\t\tcolumn = hash.keys.first\n\t\tcheck_column(column.to_s)\n\t\tvalue = hash[column]\n\t\tresult = @db.execute(\n\t\t\t\"SELECT * FROM #{@table} WHERE #{column.to_s} IS ?\", \n\t\t\tvalue\n\t\t)\n\n\t\tif(result.size == 0)\n\t\t\tfalse\n\t\telse\n\t\t\ttrue\n\t\tend\n\tend", "def exists?(query)\n @coll.find(query).count > 0\n end", "def is_barber_exists? db, name\n db.execute(\"select * from Barbers where name=?\", [name]).length > 0\nend", "def does_one_exist?(sql)\n result = ActiveRecord::Base.connection.execute(sql)\n case ActiveRecord::Base.connection.class.to_s\n when \"ActiveRecord::ConnectionAdapters::PostgreSQLAdapter\"\n return result.num_tuples == 1\n when \"ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter\"\n row_count= 0\n while f = result.fetch\n row_count += 1\n end\n return row_count == 1\n else\n return result.length == 1\n end\n end", "def vend_present?\n \n sql = \"SELECT COUNT(*)\n FROM vendors_lists\n WHERE business_type = '#{@type}' AND\n city_name = '#{@city}' AND\n branch_name = '#{@area}' AND\n vendor_name = '#{@name}'\"\n\n db.execute(sql).map{|i| i[0] == 0 ? nil : 1 }[0]\n \n end", "def exist?(name, options = T.unsafe(nil)); end", "def exists?\n new? ? false : !this.get(SQL::AliasedExpression.new(1, :one)).nil?\n end", "def exists?\n new? ? false : !this.get(SQL::AliasedExpression.new(1, :one)).nil?\n end", "def test_exists_with_order\n assert_equal true, Topic.order(Arel.sql(\"invalid sql here\")).exists?\n end", "def exists?; end", "def exist?(*args)\n alloc(*args).exist?\n end", "def exists?()\n end", "def exists(*keys); end", "def exists?(cache_key)\n @pg.exec_prepared(@exists_statement_name, [object_to_cache_key(cache_key)]).ntuples.eql?(1)\n end", "def exist?\n with_script_compiler do |compiler|\n return !!compiler.plan_signature(@plan)\n end\n end", "def where_sql\n named.or(taxon_name_named).to_sql\n end", "def exists?\n !count.zero?\n end", "def user_exist?(id)\n DB[:users].select.where(:id=>id).all\nend", "def contains(name)\n database.has_key? name\n end", "def exists?(id)\n rec = CONNECTION.execute(\"SELECT * FROM #{table_name} WHERE id = #{id};\").first\n if rec.nil?\n false\n else\n self.new(rec)\n end\n end", "def exists?\n Table.exists?(db, auditor.audit_db, name)\n end", "def exists?(identifier, configuration = {}); true; end", "def conversation_exist?(receiver_uid)\n !DatabaseConnection.query(\"SELECT * \n FROM \n (SELECT * FROM conversations \n WHERE\n u1_id = #{receiver_uid}\n OR u2_id = #{receiver_uid}) AS z\n WHERE\n u1_id = #{@uid}\n OR u2_id = #{@uid}\" \n ).num_tuples.zero?\n end", "def has(*conditions)\n if conditions.size == 1\n self.class.new( where( conditions[0], :!=, nil ) )\n elsif conditions.size == 2\n self.class.new( where( { conditions[0] => conditions[1] } ) )\n elsif conditions.size == 3\n self.class.new( where( *conditions ) )\n end\n end", "def exist?\n @exists\n end", "def exists(value)\n 1 == @client.execute_udf(@key, @PACKAGE_NAME, 'exists', [@bin_name, value], @policy)\n end", "def table_exists?(table='test_ruby') \n begin\n res = @db.query(\"select * from #{table} where 1=0\")\n return true\n rescue\n return false\n end\n end", "def exist?\n !count.zero?\n end", "def construct_sql\n if @reflection.options[:finder_sql]\n @finder_sql = interpolate_sql(@reflection.options[:finder_sql])\n else\n @finder_sql = conditions\n end\n \n if @reflection.options[:counter_sql]\n @counter_sql = interpolate_sql(@reflection.options[:counter_sql])\n elsif @reflection.options[:finder_sql]\n # replace the SELECT clause with COUNT(*), preserving any hints within /* ... */\n @reflection.options[:counter_sql] = @reflection.options[:finder_sql].sub(/SELECT (\\/\\*.*?\\*\\/ )?(.*)\\bFROM\\b/im) { \"SELECT #{$1}COUNT(*) FROM\" }\n @counter_sql = interpolate_sql(@reflection.options[:counter_sql])\n else\n @counter_sql = @finder_sql\n end\n end", "def exists?(*keys); end", "def exists?(name, table)\n Existence.new(name, table).matches?\n end", "def exists?()\n #This is a stub, used for indexing\n end", "def file_name_exist(file_name, owner_id)\n if $db.execute(\"SELECT file_name FROM files WHERE file_name = ? AND owner_id = ?\", file_name, owner_id) == []\n return false\n else\n return true\n end\nend", "def sequence_exists?(repository, property)\n statement = <<-EOS.compress_lines\n SELECT COUNT(*)\n FROM \"information_schema\".\"sequences\"\n WHERE \"sequence_name\" = ?\n AND \"sequence_schema\" = current_schema()\n EOS\n\n query(statement, sequence_name(repository, property)).first > 0\n end", "def exists? args = {}\n RedisModelExtension::Database.redis {|r| r.exists(self.name.constantize.generate_key(args)) }\n end", "def fexistd(fname, sname, dname)\n if fexists fname, sname\n if eval \"$#{fname}['#{sname},facets'].include? dname\"\n return true\n else\n return false\n end\n else\n return false\n end\nend", "def table_exist?(table_name)\n res = run_single_result(\"SELECT COUNT(*) FROM X$File\n WHERE Xf$Name = '#{table_name}'\")\n res == 1\n end", "def exists?\n true\n end", "def exist?\n true\n end", "def exists?(user_id)\n connect_cassandra\n rows = @client.execute(\"SELECT user_id FROM users WHERE user_id = '#{user_id}'\")\n !rows.empty?\nend", "def sql_in_values_or_false_if_empty(in_values, prefix='', parenthesis=nil)\n if in_values.empty?\n sql_in_values = '1=0'\n sql_in_values = \"(#{sql_in_values})\" if parenthesis\n return sql_in_values\n end\n\n sql_in_values = \"#{prefix} IN (#{in_values})\"\n sql_in_values = \"(#{sql_in_values})\" if parenthesis\n sql_in_values\n end", "def exists!\n @exists = true\n end", "def checkifexists\n que = \" CREATE TABLE IF NOT EXISTS rubicante_logs ( \"\n que += \" id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT, \"\n que += \" timestamp DATETIME, \"\n que += \" nickname VARCHAR(31), \"\n que += \" clienthost VARCHAR(255), \"\n que += \" action VARCHAR(20), \"\n que += \" channel VARCHAR(100), \"\n que += \" msg TEXT \"\n que += \" );\"\n\n # Perform the query! \n @mResource.query(que) \n end", "def index_exists?(table_name, column_name, options = {})\n column_names = Array.wrap(column_name)\n index_name = options.key?(:name) ? options[:name].to_s : index_name(table_name, column: column_names)\n\n # Always compare the index name\n default_comparator = lambda { |index| index.name == index_name }\n comparators = [default_comparator]\n\n # Add a comparator for each index option that is part of the query\n index_options = [:unique, :where]\n index_options.each do |index_option|\n comparators << if options.key?(index_option)\n lambda do |index|\n pg_where_clause = index.send(index_option)\n # pg does nothing to boolean clauses, e.g. 'where active' => 'where active'\n if pg_where_clause.is_a?(TrueClass) or pg_where_clause.is_a?(FalseClass)\n pg_where_clause == options[index_option]\n else\n # pg adds parentheses around non-boolean clauses, e.g. 'where color IS NULL' => 'where (color is NULL)'\n pg_where_clause.gsub!(/[()]/,'')\n # pg casts string comparison ::text. e.g. \"where color = 'black'\" => \"where ((color)::text = 'black'::text)\"\n pg_where_clause.gsub!(/::text/,'')\n # prevent case from impacting the comparison\n pg_where_clause.downcase == options[index_option].downcase\n end\n end\n else\n # If the given index_option is not an argument to the index_exists? query,\n # select only those pg indexes that do not have the component\n lambda { |index| index.send(index_option).blank? }\n end\n end\n\n # Search all indexes for any that match all comparators\n indexes(table_name).any? do |index|\n comparators.inject(true) { |ret, comparator| ret && comparator.call(index) }\n end\n end", "def needs_db_query?(search)\n search[:author_id].present? || search[:include_closed] == true\n end", "def exists?(ids)\r\n if ids.is_a?(Array) && ids.first.is_a?(String)\r\n count(:conditions => ids) > 0\r\n else\r\n obj = find(ids) rescue false\r\n !obj.nil? and obj.is_a?(self) \r\n end\r\n end", "def sql_clause(k, v = nil)\n k, v = *k.first if k.is_a?(Hash)\n v = Array.wrap(v) if v.is_a?(Range)\n v = v.strip if v.is_a?(String)\n v = v.split(/\\s*,\\s*/) if v.is_a?(String) && v.include?(',')\n return sql_test(k, v) unless v.is_a?(Array)\n v = v.uniq\n if v.many? && (v.map(&:class).uniq.size == 1)\n ranges = v.sort.chunk_while { |prev, this| prev.succ == this }.to_a\n ranges.map! { |r| (r.size >= 5) ? Range.new(r.first, r.last) : r }\n ranges, singles = ranges.partition { |r| r.is_a?(Range) }\n ranges.map! { |range| sql_test(k, range) }\n singles.flatten!\n else\n ranges = []\n singles = v\n end\n if singles.present?\n singles.map! { |s| sql_quote(s) }\n ranges << \"#{k} IS NULL\" if singles.reject!(&:nil?)\n ranges << \"#{k} IN (%s)\" % singles.join(',') if singles.present?\n end\n if ranges.many?\n ranges.map! { |s| \"(#{s})\" }.join(' OR ')\n else\n ranges.first\n end\n end", "def sql_where_clauses opts = { }\n opts = options.merge(opts)\n\n sql = ''\n\n clauses = [ ]\n\n # Construct find :conditions.\n (Content.query_column_names + [ :content_id, :size ]).\n each do | column |\n if params.key?(column)\n value = params[column]\n field_is_int = false\n field = \n case column \n when :content_id\n field_is_int = true\n \"contents.id\"\n when :id, :version\n field_is_int = true\n \"contents.#{column}\"\n when :uuid, :md5sum, :filename, :tasks\n \"contents.#{column}\"\n when :data\n \"(CASE WHEN (content_types.mime_type_id NOT IN (SELECT id FROM mime_types WHERE code LIKE 'text/%')) THEN '' ELSE convert_from(contents.data, 'UTF8') END)\" \n when :size\n field_is_int = true\n 'length(contents.data)'\n when :content_key_uuid\n 'content_keys.uuid'\n when :creator\n 'creator_users.login'\n when :updater\n 'updater_users.login'\n else \n case column.to_s\n when /\\A(.+)_id\\Z/\n field_is_int = true\n \"#{$1.pluralize}.id\"\n else\n \"#{column.to_s.pluralize}.code\"\n end\n end\n \n # Coerce value.\n case value\n when Symbol\n value = value.to_s\n when Regexp\n value = value.inspect\n when String\n value = value\n when ActiveRecord::Base\n value = value.id\n field = \"#{column.to_s.pluralize}.id\"\n end\n\n # $stderr.puts \"#{column} = #{value.inspect}\"\n clauses << _match(column, field, value, field_is_int, opts)\n end\n end\n\n unless clauses.empty?\n sql << \"(\\n #{clauses * (opts[:or] ? \"\\nOR \" : \"\\nAND \")}\\n )\"\n end\n\n # Subquery clauses:\n if @subquery && ! (where = @subquery.sql_where_clauses).empty?\n sql << \"\\nAND \" unless sql.empty?\n sql << where\n end\n\n sql\n end", "def chris_is_missed\n MovieDatabase.execute(<<-SQL)\n\n select movie.title, actor.name\n from movie\n join casting on movie.id = casting.movieid\n join actor on casting.actorid = actor.id\n where ord = 1 and movie.title in\n (\n select movie.title\n from movie\n join casting on movie.id = casting.movieid\n join actor on casting.actorid = actor.id\n where actor.name = 'Chris Farley'\n )\n SQL\nend", "def exists_by_primary_key?(primary_key)\n qry = \"SELECT COUNT(*) AS `c` FROM `#{@table_name}` WHERE \"+build_where({@primary_key => primary_key})\n res = cached_query(qry,[@table_name])\n res[0]['c'] != 0\n end", "def exists?(id_or_conditions = {})\n case id_or_conditions\n when Hash then where(id_or_conditions).count >= 1\n else\n begin\n find(id_or_conditions)\n true\n rescue Dynamoid::Errors::RecordNotFound\n false\n end\n end\n end", "def exists?\n this.count > 0\n end", "def dbselect(find, table, condition, condition_name)\n if find.kind_of?(Array) == false\n variables = find\n else\n variables = \"\"\n i = 0\n while i < find.length\n variables += find[i].to_s\n i += 1\n if i < find.length\n variables += \", \"\n end\n end\n end\n\n if condition.kind_of?(Array) == false\n cond = condition.to_s + \"=?\"\n else\n cond = \"\"\n i = 0\n while i < condition.length\n cond += condition[i].to_s + \"=?\"\n i += 1\n if i < condition.length\n cond += \" AND \"\n end\n end\n end\n return db.execute(\"SELECT #{variables} FROM #{table} WHERE #{cond}\", condition_name)\nend", "def build_where_ns(query,ns)\n where = \"\"\n query.each_pair do |k, v| \n if (k!='include' and k!='exclude')\n where += \"(`#{ns}`.`#{escape_str_field(k)}` #{build_equal_condition(v)}) AND \"\n end\n end\n where.chomp(' AND ')\n end", "def room_exists?(room_hash)\n begin\n statement = @db.prepare \"SELECT EXISTS(SELECT * FROM chat_rooms WHERE room_hash = ?)\"\n statement.execute room_hash\n result = statement.fetch.first\n statement.close\n ensure\n #@db.close\n end\n return true if result == 1\n false\n end", "def check_duplicate_item(db, tbl,field_name,value)\r\n check_command = \"Select * from ? where ? = ?\",[tbl, field_name,value]\r\n if db.execute(check_command).length > 0\r\n return true\r\n else \r\n return false \r\n end \r\nend", "def ∃table?(table_name); self.sql(\"SELECT does_table_exist('#{table_name}');\").rows[0][0]; end", "def exists?(domain_expr)\n domain_name = domain_expr.domain_name\n domain_attr = domain_expr.domain_attr\n\n entry = find(domain_name, domain_attr)\n db_expr, values = convert_expr(domain_expr, [], entry)\n db = storage_class_from_entry(entry, :db)\n\n db.exists?([db_expr, *values])\n end", "def exist?\n\t\t!self.class.first(:conditions => {:identification_document => identification_document}).nil?\n\tend", "def exists?\n context.count > 0\n end", "def row_exists?(unique_identifier)\n wait_for_results\n exists? result_row(unique_identifier)\n end", "def row_exists?(unique_identifier)\n wait_for_results\n exists? result_row(unique_identifier)\n end", "def exists?(path)\n eval(EXISTS_CHECK, binding, __FILE__, EXISTS_CHECK_LINE)\n nil\nend", "def exists?(column_family, key, column = nil, sub_column = nil, consistency = Consistency::WEAK)\n column_family = column_family.to_s\n assert_column_name_classes(column_family, column, sub_column) \n _get(column_family, key, column, sub_column, 1, ''..'', false, consistency)\n true\n rescue CassandraThrift::NotFoundException\n end", "def email_exist(email)\n if $db.execute(\"SELECT email from users WHERE email = ?\", email) != []\n return true\n else\n return false\n end\nend", "def table_exists?(name)\n schema, table = extract_schema_and_table(name.to_s)\n return false unless table\n\n binds = [[nil, table]]\n binds << [nil, schema] if schema\n\n sql = \"#{TABLE_EXISTS_SQL_PREFIX} AND n.nspname = #{schema ? \"?\" : 'ANY (current_schemas(false))'}\"\n\n log(sql, 'SCHEMA', binds) do\n @connection.execute_query_raw(sql, binds).first['table_count'] > 0\n end\n end", "def exist? (name)\n @by_id[name.to_s]\n end", "def exists?\n begin\n res=@db.fetch %Q/ SELECT tablename FROM pg_tables WHERE tablename='%s' AND schemaname='%s'/ % [table_name,schema_name]\n if res.count == 0\n res=@db.fetch %Q/ SELECT viewname FROM pg_views WHERE viewname='%s'AND schemaname='%s'/ % [table_name,schema_name]\n end\n rescue PG::Error => err\n return false\n end\n\n # also say false if the table is empty\n if res.count > 0\n return ds.select(1).limit(1).count > 0\n else\n return true\n end\n return false\n end", "def exist?\n !find_exists.nil?\n end", "def exists?(key, _locale = T.unsafe(nil), locale: T.unsafe(nil), **options); end", "def exists(*keys)\n send_command([:exists, *keys])\n end", "def exists?\n @exists\n end", "def diarySubjectExists _obj, _args\n \"_obj diarySubjectExists _args;\" \n end", "def select_with_sql_base\n opts[:with].any?{|w| w[:recursive]} ? \"WITH RECURSIVE \" : super\n end", "def exist?\n nil\n end", "def photo_exists?(db, filename)\n\n query = db.exec(\"select photo from imageuploader where photo = '#{filename}'\")\n query == nil ? true : false\n\n end", "def exists?\n !@exists.nil? && @exists\n end", "def exists?\n !@exists.nil? && @exists\n end", "def exists?\n false\n end", "def exists?\n false\n end", "def exist\n\treturn true\n end", "def is_existing_exercise(db, name)\n exercises_arr = db.execute(\"SELECT name FROM exercises\")\n exercises_arr.each do |exercise|\n if exercise[0] == name\n return true\n end\n end\n return false\nend", "def exists?\n @exists == true\n end", "def exists(key)\n call(key, [:exists, key], transform: Redis::Boolify, read: true)\n end", "def exists(key)\n mon_synchronize do\n perform [\"exists\", key], :proc => T_BOOL\n end\n end", "def exist?(*args)\n find(*args) && true\n rescue NotFoundError\n false\n end", "def table_exists?\n true\n end", "def exist?\n raise NotImplementedError\n end", "def select_by_class_exists(class_name)\n return select_by_class(class_name).exist?\nend" ]
[ "0.7812344", "0.6293995", "0.59380126", "0.5665825", "0.56566733", "0.56529945", "0.5576356", "0.5492517", "0.5490903", "0.54658306", "0.5446944", "0.5446695", "0.53890246", "0.53038657", "0.5272023", "0.52305394", "0.5213588", "0.5200785", "0.5200785", "0.5168884", "0.5167953", "0.516592", "0.5151614", "0.51363724", "0.5060756", "0.50572574", "0.504819", "0.50418985", "0.5037227", "0.5017479", "0.50107706", "0.50050634", "0.50048524", "0.49921653", "0.49918786", "0.49788442", "0.49736252", "0.49651667", "0.4965046", "0.4937728", "0.4934918", "0.49183667", "0.49152058", "0.48990914", "0.48866248", "0.48774385", "0.48725", "0.48662317", "0.48625576", "0.4856209", "0.48483035", "0.4832072", "0.48258224", "0.48127383", "0.48121777", "0.4809586", "0.4801836", "0.47984436", "0.47979525", "0.4797315", "0.47964194", "0.47841483", "0.4778749", "0.47773957", "0.4767929", "0.4762125", "0.47597197", "0.4759719", "0.47569808", "0.4754172", "0.4733239", "0.47284096", "0.47284096", "0.4726792", "0.47251305", "0.47206706", "0.471714", "0.47127327", "0.4708424", "0.47018453", "0.4700552", "0.47001195", "0.46997178", "0.46956667", "0.46921822", "0.4689107", "0.46875522", "0.46875212", "0.46875212", "0.46866682", "0.46866682", "0.46843693", "0.4682244", "0.4680264", "0.46756008", "0.46685946", "0.46683508", "0.46544868", "0.4653904", "0.46459484" ]
0.4955571
39
Construct an Arel representation of a SQL function.
def named_function(name, expression, function_alias = nil) Arel::Nodes::NamedFunction.new(name, expression, function_alias) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def function_sql(f)\n args = f.args\n \"#{f.f}#{args.empty? ? '()' : literal(args)}\"\n end", "def irregular_function_sql(f)\n \"#{f.f}(#{literal(f.arg1)} #{f.joiner} #{literal(f.arg2)})\"\n end", "def create_function_sql(name, definition, opts=OPTS)\n args = opts[:args]\n if !opts[:args].is_a?(Array) || !opts[:args].any?{|a| Array(a).length == 3 and %w'OUT INOUT'.include?(a[2].to_s)}\n returns = opts[:returns] || 'void'\n end\n language = opts[:language] || 'SQL'\n <<-END\n CREATE#{' OR REPLACE' if opts[:replace]} FUNCTION #{name}#{sql_function_args(args)}\n #{\"RETURNS #{returns}\" if returns}\n LANGUAGE #{language}\n #{opts[:behavior].to_s.upcase if opts[:behavior]}\n #{'STRICT' if opts[:strict]}\n #{'SECURITY DEFINER' if opts[:security_definer]}\n #{\"PARALLEL #{opts[:parallel].to_s.upcase}\" if opts[:parallel]}\n #{\"COST #{opts[:cost]}\" if opts[:cost]}\n #{\"ROWS #{opts[:rows]}\" if opts[:rows]}\n #{opts[:set].map{|k,v| \" SET #{k} = #{v}\"}.join(\"\\n\") if opts[:set]}\n AS #{literal(definition.to_s)}#{\", #{literal(opts[:link_symbol].to_s)}\" if opts[:link_symbol]}\n END\n end", "def function(name, *args)\n SQL::Function.new(name, *args)\n end", "def function(name, *args)\n SQL::Function.new(function_name(name), *args)\n end", "def create_function(name, definition, opts=OPTS)\n self << create_function_sql(name, definition, opts)\n end", "def calculate_function(function)\n raise \"invalid function '#{function}'\" unless [:sum, :avg, :min, :max, :count].include?(function.to_sym)\n Sequel::SQL::Function.new(function.to_sym, :value)\n end", "def to_s(ds)\n ds.function_sql(self)\n end", "def arel_fn(name, *args)\n Arel::Nodes::NamedFunction.new(name, args)\n end", "def to_sql(arel, binds = [])\n if arel.respond_to?(:ast)\n binds = binds.dup\n visitor.accept(arel.ast) do\n quote(*binds.shift.reverse)\n end\n else\n arel\n end\n end", "def create_function(function_name, returning, definition, options = {})\n\n function_name = full_function_name(function_name, options)\n language = options[:language] || 'plpgsql'\n replace = if options[:replace] == false\n ''\n else\n 'OR REPLACE '\n end\n volatility = case options[:volatility]\n when :volatile, :stable, :immutable\n \"\\n #{options[:volatility].to_s.upcase}\"\n else\n \"\"\n end\n\n sql = <<-SQL.gsub(/^[ ]{6}/, \"\")\n CREATE #{replace}FUNCTION #{function_name}\n RETURNS #{returning}\n LANGUAGE #{language}#{volatility}\n AS $function$\n #{definition.strip}\n $function$\n SQL\n\n execute(sql)\n end", "def arel_field\n case param.field.options[:transmogrification]\n when :timestamp_to_hours\n Arel::Nodes::NamedFunction.new('TIMESTAMPDIFF', [Arel::Nodes::SqlLiteral.new('HOUR'), arel_table[field], Arel::Nodes::SqlLiteral.new('UTC_TIMESTAMP()')])\n when :timestamp_to_days\n Arel::Nodes::NamedFunction.new('TIMESTAMPDIFF', [Arel::Nodes::SqlLiteral.new('DAY'), arel_table[field], Arel::Nodes::SqlLiteral.new('UTC_TIMESTAMP()')])\n when :sum\n Arel::Nodes::NamedFunction.new('SUM', [arel_table[field]])\n when :upper\n Arel::Nodes::NamedFunction.new('UPPER', [arel_table[field]])\n when :lower\n Arel::Nodes::NamedFunction.new('LOWER', [arel_table[field]])\n else\n arel_table[field]\n end\n end", "def to_s(ds)\n ds.irregular_function_sql(self)\n end", "def to_arel_sql(value)\n case value\n when Arel::Nodes::Node, Arel::Nodes::SqlLiteral, nil\n value\n when ActiveRecord::Relation\n Arel.sql(value.spawn.to_sql)\n else\n Arel.sql(value.respond_to?(:to_sql) ? value.to_sql : value.to_s)\n end\n end", "def create_custom_function\n # puts \"Creating a custom function to make queries with timestamp as a string...\".cyan\n @session.execute('CREATE OR REPLACE FUNCTION timefstring(somearg text)\n RETURNS NULL ON NULL INPUT\n RETURNS timestamp\n LANGUAGE java\n AS $$\n java.text.SimpleDateFormat formatter = new java.text.SimpleDateFormat(\"yyyy-MM-dd HH:mm:ss.SSS\");\n try {\n Date date = formatter.parse(somearg);\n return date;\n } catch(java.text.ParseException e) {\n return new Date();\n }\n $$')\n end", "def functions\n pg_major = ::PgSaurus::Engine.pg_server_version[0]\n res = select_all <<-SQL\n SELECT n.nspname AS \"Schema\",\n p.proname AS \"Name\",\n pg_catalog.pg_get_function_result(p.oid) AS \"Returning\",\n CASE\n WHEN #{pg_major >= 11 ? \"p.prokind = 'w'\" : \"p.proiswindow\"} THEN 'window'\n WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN 'trigger'\n ELSE 'normal'\n END AS \"Type\",\n p.oid AS \"Oid\"\n FROM pg_catalog.pg_proc p\n LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace\n WHERE pg_catalog.pg_function_is_visible(p.oid)\n AND n.nspname <> 'pg_catalog'\n AND n.nspname <> 'information_schema'\n AND #{pg_major >= 11 ? \"p.prokind <> 'a'\" : \"p.proisagg <> TRUE\"}\n ORDER BY 1, 2, 3, 4;\n SQL\n res.inject([]) do |buffer, row|\n returning = row['Returning']\n function_type = row['Type']\n oid = row['Oid']\n\n function_str = select_value(\"SELECT pg_get_functiondef(#{oid});\")\n\n name = parse_function_name(function_str)\n language = parse_function_language(function_str)\n definition = parse_function_definition(function_str)\n volatility = parse_function_volatility(function_str)\n\n if definition\n buffer << ::PgSaurus::ConnectionAdapters::FunctionDefinition.new(name,\n returning,\n definition.strip,\n function_type,\n language,\n oid,\n volatility)\n end\n buffer\n end\n end", "def to_php\n \"#{function}(#{arguments.join(', ')})\"\n end", "def f; @function.to_s; end", "def create_trigger_sql(table, name, function, opts=OPTS)\n events = opts[:events] ? Array(opts[:events]) : [:insert, :update, :delete]\n whence = opts[:after] ? 'AFTER' : 'BEFORE'\n if filter = opts[:when]\n raise Error, \"Trigger conditions are not supported for this database\" unless supports_trigger_conditions?\n filter = \" WHEN #{filter_expr(filter)}\"\n end\n \"CREATE #{'OR REPLACE ' if opts[:replace]}TRIGGER #{name} #{whence} #{events.map{|e| e.to_s.upcase}.join(' OR ')} ON #{quote_schema_table(table)}#{' FOR EACH ROW' if opts[:each_row]}#{filter} EXECUTE PROCEDURE #{function}(#{Array(opts[:args]).map{|a| literal(a)}.join(', ')})\"\n end", "def as_sql(expression, aliaz)\n \"#{expression} #{quote_identifier(aliaz)}\"\n end", "def createFunction(code:, name:, isDeterministic: nil) # TESTED\n body = {\n \"code\" => code,\n \"name\" => name,\n \"isDeterministic\" => isDeterministic\n }.delete_if{|k,v| v.nil?}\n request = @@request.merge({ :body => body.to_json })\n result = self.class.post(\"/_db/#{@database}/_api/aqlfunction\", request)\n self.class.return_result result: result\n end", "def reformat_math_functions\n funcs = %w(min max sum avg count round rounddown roundup sin cos tan)\n regex = /\\b(?<func>#{funcs}.join('|'))\\((?<expr>[^()]+)\\)/\n match = @expression.match(regex)\n\n if match\n func = match.named_captures[\"func\"]\n expr = match.named_captures[\"expr\"]\n @expression = \"#{func.upcase}(#{expr})\"\n end\n end", "def info_sql\n \"#{INFO_SQL} AND pg_catalog.pg_get_function_arguments(p.oid) = '#{to_s}'\"\n end", "def visit_RGeo_ActiveRecord_SpatialNamedFunction(node_)\n name_ = st_func(node_.name)\n exprs_ = []\n node_.expressions.each_with_index do |expr_, index_|\n exprs_ << (node_.spatial_argument?(index_) ? visit_in_spatial_context(expr_) : visit(expr_))\n end\n \"#{name_}(#{node_.distinct ? 'DISTINCT ' : ''}#{exprs_.join(', ')})#{node_.alias ? \" AS #{visit node_.alias}\" : ''}\"\n end", "def to_sql(rel_exp=nil)\n rel_exp ||= @rel_exp\n sql = ''\n if rel_exp[0].is_a?(Array) then\n sql << \"(#{to_sql(rel_exp[0])})\"\n else\n sql << rel_exp[0].to_s\n end\n sql << \" #{rel_exp[2]} \"\n if rel_exp[3].is_a?(Array) then\n sql << \"(#{to_sql(rel_exp[3])})\"\n else\n sql << \"'#{rel_exp[3]}'\"\n end\n end", "def sql(string)\n ::Arel::Nodes::SqlLiteral.new(string)\n end", "def update_function(name, options = {})\n version = options[:version]\n sql_definition = options[:sql_definition]\n\n if version.nil? && sql_definition.nil?\n raise(\n ArgumentError,\n \"version or sql_definition must be specified\"\n )\n end\n\n sql_definition = sql_definition.strip_heredoc if sql_definition\n sql_definition ||= Fx::Definition.function(name: name, version: version).to_sql\n\n Fx.database.update_function(name, sql_definition)\n end", "def sql_literal(*)\n @dataset.sql\n end", "def name\n\t\t\"db_fun\"\n\tend", "def create_function( name, arity, type=nil, &block ) # :yields: func, *args\n case type\n when :numeric\n type = SQLite::API::NUMERIC\n when :text\n type = SQLite::API::TEXT\n when :args\n type = SQLite::API::ARGS\n end\n\n callback = proc do |func,*args|\n block.call( FunctionProxy.new( func ), *args )\n end\n\n SQLite::API.create_function( @handle, name, arity, callback )\n SQLite::API.function_type( @handle, name, type ) if type\n\n self\n end", "def aliased_expression_sql(ae)\n \"#{literal(ae.expression)} AS #{quote_identifier(ae.aliaz)}\"\n end", "def function(id)\n case id\n when :base64\n Function::Base64\n when :join\n Function::Join\n when :if\n Function::If\n when :equals\n Function::Equals\n when :get_azs\n Function::GetAZs\n else\n raise ReferenceMissing.new(\"Invalid function #{id.inspect}\")\n end\n end", "def sql_of( expr, dataset)\n dataset.send :literal_expression_append, rv=String.new, expr\n rv\n end", "def visit_RGeo_ActiveRecord_SpatialNamedFunction(node, collector)\n name = st_func(node.name)\n exprs = []\n node.expressions.each_with_index do |expr, index|\n exprs << (node.spatial_argument?(index) ? visit_in_spatial_context(expr, collector) : visit(expr, collector))\n end\n collector << name\n collector << \"(\"\n collector << \"DISTINCT \" if node.distinct\n collector << exprs.join(\", \")\n collector << \")\"\n collector << \" AS #{visit(node.alias, collector)}\" if node.alias\n collector\n end", "def generate_sql_query(stored_procedure_call, *attributes)\n sql_query = 'select * from '\n sql_query << stored_procedure_call << '('\n\n sql_query << attributes.map { |attribute|\n if attribute.kind_of?(Fixnum) || attribute.kind_of?(Float) || attribute.kind_of?(TrueClass) || \n attribute.kind_of?(FalseClass)\n attribute\n elsif attribute.nil?\n \"null\"\n else\n \"'\" + escape_quotes(attribute) + \"'\"\n end\n }.join(', ')\n\n sql_query << ');'\n end", "def build_sql(structure)\n structure = structure.is_a?(Constructor) ? structure.structure : structure\n sql = ''\n [:with, :union, :select, :insert, :update, :delete, :set, :from,\n :join, :where, :returning, :group, :order, :limit, :offset].each do |i|\n next unless structure[i]\n sql += send(\"build_#{i}\", structure[i], structure)\n end\n sql\n end", "def to_sql(code)\n raise ArgumentError, 'code required' if code.nil? || code.strip.empty?\n expr = VinesQL.parse(code.strip)\n\n keys, values = expr.params.partition.each_with_index {|p, ix| ix % 2 == 0 }\n joins = keys.each_with_index.map do |k, ix|\n \"inner join attributes a%s on id=a%s.system_id and a%s.key=?\" % [ix, ix, ix]\n end\n\n where = expr.sql.tap do |sql|\n values.size.times do |ix|\n sql.sub!(/(^|[^\\.])value/, \"\\\\1a#{ix}.value\")\n end\n end\n\n sql = %Q{\n select name, os from systems\n #{joins.join(\"\\n\")}\n where #{where}\n order by name\n }\n\n [sql, [keys, values].flatten]\n end", "def [](*args)\n Sequel::SQL::Function.new(self, *args)\n end", "def aqlFunctions(namespace: nil)\r\n request(\"GET\", \"_api/aqlfunction\", query: {\"namespace\": namespace}, key: :result)\r\n end", "def full_function_name(function_name, options)\n schema = options[:schema]\n function_name = %Q{\"#{schema}\".#{function_name}} if schema\n function_name\n end", "def to_ast\n identifier = fn.is_a?(::Proc) ? fn : fn.name\n [identifier, args]\n end", "def to_ast\n identifier = Proc === fn ? fn : fn.name\n [identifier, args]\n end", "def to_php\n body = children? ? ('{ ' << children.map(&:to_php).join('; ') << ' }') : '{}'\n if anonymous?\n \"function(#{parameters.join(', ')}) \" << body # FIXME\n else\n \"function #{name}(#{parameters.join(', ')}) \" << body # FIXME\n end\n end", "def to_sql\n @applied.reverse.map{ |e| \"#{e.type}(#{e.args.join(\", \")})\" }.join('.')\n end", "def apply_functions(fun, series)\n expr = CGI::unescape(fun)\n\n # pass values needed for hitting Cassandra in\n control = { :cass_client => cass_client }\n control[:start_ts], control[:end_ts] = get_start_end :one_day\n\n Hastur::Aggregation.evaluate(expr, series, control)\n end", "def visit_Arel_Nodes_NamedFunction o, collector\n case o.name\n when 'ST_Within'\n { visit(o.expressions.first, collector) => { within: o.expressions.last.expressions.map(&:expr)[0...4].reverse } }\n else\n raise 'xxx'\n end\n # collector << o.name\n # collector << \"(\"\n # collector << \"DISTINCT \" if o.distinct\n # collector = inject_join(o.expressions, collector, \", \") << \")\"\n # if o.alias\n # collector << \" AS \"\n # visit o.alias, collector\n # else\n # collector\n # end\n end", "def to_nfa\n exec(:expression)\n end", "def apply_function_concat(scope, ast)\n args = ast.children.map { |arg|\n scope, sql = apply_ast(scope, arg)\n \"(#{sql}::text)\"\n }\n\n return scope, \"(concat(#{args.join(',')}))\"\n end", "def sql_literal(value)\n Arel::Nodes::SqlLiteral.new(value)\n end", "def function_literal\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 70 )\n return_value = FunctionLiteralReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n string_literal333 = nil\n string_literal337 = nil\n variable_name334 = nil\n function_parameters335 = nil\n statement_block336 = nil\n variable_name338 = nil\n function_parameters339 = nil\n statement_block340 = nil\n\n tree_for_string_literal333 = nil\n tree_for_string_literal337 = nil\n\n begin\n # at line 715:3: ( 'function' ( variable_name )? function_parameters statement_block | '->' ( variable_name )? ( function_parameters )? statement_block )\n alt_86 = 2\n look_86_0 = @input.peek( 1 )\n\n if ( look_86_0 == FUNCTION )\n alt_86 = 1\n elsif ( look_86_0 == ARROW )\n alt_86 = 2\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n raise NoViableAlternative( \"\", 86, 0 )\n end\n case alt_86\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 715:5: 'function' ( variable_name )? function_parameters statement_block\n string_literal333 = match( FUNCTION, TOKENS_FOLLOWING_FUNCTION_IN_function_literal_5064 )\n if @state.backtracking == 0\n\n tree_for_string_literal333 = @adaptor.create_with_payload( string_literal333 )\n root_0 = @adaptor.become_root( tree_for_string_literal333, root_0 )\n\n end\n # at line 715:17: ( variable_name )?\n alt_83 = 2\n look_83_0 = @input.peek( 1 )\n\n if ( look_83_0 == GET || look_83_0 == SET || look_83_0 == MACRO || look_83_0 == EACH || look_83_0.between?( DEF, OBJECT_DEF ) || look_83_0 == ID || look_83_0.between?( T__148, T__150 ) )\n alt_83 = 1\n end\n case alt_83\n when 1\n # at line 715:17: variable_name\n @state.following.push( TOKENS_FOLLOWING_variable_name_IN_function_literal_5067 )\n variable_name334 = variable_name\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, variable_name334.tree )\n end\n\n end\n @state.following.push( TOKENS_FOLLOWING_function_parameters_IN_function_literal_5070 )\n function_parameters335 = function_parameters\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, function_parameters335.tree )\n end\n @state.following.push( TOKENS_FOLLOWING_statement_block_IN_function_literal_5072 )\n statement_block336 = statement_block\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, statement_block336.tree )\n end\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 716:5: '->' ( variable_name )? ( function_parameters )? statement_block\n string_literal337 = match( ARROW, TOKENS_FOLLOWING_ARROW_IN_function_literal_5078 )\n if @state.backtracking == 0\n\n tree_for_string_literal337 = @adaptor.create_with_payload( string_literal337 )\n root_0 = @adaptor.become_root( tree_for_string_literal337, root_0 )\n\n end\n # at line 716:11: ( variable_name )?\n alt_84 = 2\n look_84_0 = @input.peek( 1 )\n\n if ( look_84_0 == GET || look_84_0 == SET || look_84_0 == MACRO || look_84_0 == EACH || look_84_0.between?( DEF, OBJECT_DEF ) || look_84_0 == ID || look_84_0.between?( T__148, T__150 ) )\n alt_84 = 1\n end\n case alt_84\n when 1\n # at line 716:11: variable_name\n @state.following.push( TOKENS_FOLLOWING_variable_name_IN_function_literal_5081 )\n variable_name338 = variable_name\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, variable_name338.tree )\n end\n\n end\n # at line 716:26: ( function_parameters )?\n alt_85 = 2\n look_85_0 = @input.peek( 1 )\n\n if ( look_85_0 == LPAREN )\n alt_85 = 1\n end\n case alt_85\n when 1\n # at line 716:26: function_parameters\n @state.following.push( TOKENS_FOLLOWING_function_parameters_IN_function_literal_5084 )\n function_parameters339 = function_parameters\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, function_parameters339.tree )\n end\n\n end\n @state.following.push( TOKENS_FOLLOWING_statement_block_IN_function_literal_5087 )\n statement_block340 = statement_block\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, statement_block340.tree )\n end\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__, 70 )\n\n end\n \n return return_value\n end", "def update_function(name, args)\n version = args[:version]\n sql_definition = args[:sql_definition]\n revert_to_version = args[:revert_to_version]\n\n if version.nil? && sql_definition.nil?\n raise(\n ArgumentError,\n \"version or sql_definition must be specified\",\n )\n end\n\n sql_definition = sql_definition.strip_heredoc if sql_definition\n sql_definition ||= Fx::Definition.new(\n name: name,\n version: version,\n ).to_sql\n\n Fx.database.update_function(name, sql_definition)\n end", "def drop_function_sql(name, opts=OPTS)\n \"DROP FUNCTION#{' IF EXISTS' if opts[:if_exists]} #{name}#{sql_function_args(opts[:args])}#{' CASCADE' if opts[:cascade]}\"\n end", "def create_functions\n @ddl[:aggregate].each_with_index do |agg, _i|\n output = agg[:args][0]\n\n if contains_output?(output)\n arguments = agg[:args][1]\n format = (arguments.delete(:format) if arguments) || nil\n begin\n @functions << load_function(agg[:function]).new(output, arguments, format, @action)\n rescue Exception => e # rubocop:disable Lint/RescueException\n Log.error(\"Cannot create aggregate function '%s': %s\" % [output, e])\n @failed << {:name => output, :type => :startup}\n end\n else\n Log.error(\"Cannot create aggregate function '%s'. '%s' has not been specified as a valid ddl output.\" % [output, output])\n @failed << {:name => output, :type => :create}\n end\n end\n end", "def to_ruby_literal\n \"Alf::Relation([\" + tuples.map{|t| Support.to_ruby_literal(t) }.join(', ') + \"])\"\n end", "def add_function(key, aString, op, table)\n counts = aString.downcase.to_counts\n src = 'lambda { |targ| '\n counts.each_with_index do |n,i|\n src += \"targ[#{i}] #{op}= #{n}; \" if (n > 0)\n end\n src += '}'\n table[key] = eval(src)\n end", "def sql_function_args(args)\n \"(#{Array(args).map{|a| Array(a).reverse.join(' ')}.join(', ')})\"\n end", "def sql_cast_as(new_type, castable)\n casting = Arel::Nodes::As.new castable, Arel::Nodes::SqlLiteral.new(new_type.to_s.upcase)\n Arel::Nodes::NamedFunction.new 'CAST', [casting]\n end", "def type\n \"Function\"\n end", "def construct_geometric_sql(type,geoms,options)\n not_db, on_db = geoms.partition { |g| g.is_a?(Geometry) || g.new_record? }\n not_db.map! {|o| o.respond_to?(:new_record?) ? o.geom : o }\n\n tables = on_db.map do |t| {\n :name => t.class.table_name,\n :column => t.postgis_geoms.keys[0],\n :uid => unique_identifier,\n :primary_key => t.class.primary_key,\n :id => t[:id] }\n end\n\n # Implement a better way for options?\n if options.instance_of? Hash\n transform = options.delete(:transform)\n stcollect = options.delete(:stcollect)\n options = nil\n end\n\n fields = tables.map { |f| \"#{f[:uid]}.#{f[:column]}\" } # W1.geom\n fields << not_db.map { |g| \"'#{g.as_hex_ewkb}'::geometry\"} unless not_db.empty?\n fields.map! { |f| \"ST_Transform(#{f}, #{transform})\" } if transform # ST_Transform(W1.geom,x)\n fields.map! { |f| \"ST_Union(#{f})\" } if stcollect # ST_Transform(W1.geom,x)\n conditions = tables.map {|f| \"#{f[:uid]}.#{f[:primary_key]} = #{f[:id]}\" } # W1.id = 5\n\n tables.map! { |f| \"#{f[:name]} #{f[:uid]}\" } # streets W1\n\n #\n # Data => SELECT Func(A,B)\n # BBox => SELECT (A <=> B)\n # Func => SELECT Func(Func(A))\n #\n if type != :bbox\n opcode = type.to_s\n opcode = \"ST_#{opcode}\" unless opcode =~ /th3d|pesinter/\n fields << options if options\n fields = fields.join(\",\")\n else\n fields = fields.join(\" #{options} \")\n end\n\n\n sql = \"SELECT #{opcode}(#{fields}) \"\n sql << \"FROM #{tables.join(\",\")} \" unless tables.empty?\n sql << \"WHERE #{conditions.join(\" AND \")}\" unless conditions.empty?\n sql\n end", "def create_function( db, name, args, text, cookie, func, step, final )\n if func || ( step && final )\n cb = CallbackData.new\n cb.proc = cb.proc2 = nil\n cb.data = cookie\n end\n\n if func\n cb.proc = func\n step = final = nil\n elsif step && final\n cb.proc = step\n cb.proc2 = final\n\n func = nil\n end\n\n result = CSSQLite.sqlite3_create_function( db, name, args, text, cb, func, step, final )\n\n # see comments in busy_handler\n if cb\n @callback_data[ name ] = cb\n else\n @callback_data.delete( name )\n end\n\n return result\n end", "def signature\n @signature ||= ::Amalgalite::SQLite3::Database::Function.signature( self.name, self.arity )\n end", "def compose_expression(expression_object, model:, column_name:, column_node:, column_type:)\n expression_object => {expressions:, value: raw_value}\n\n raise \"column_type not supplied (it was #{column_type})\" unless column_type.is_a?(Symbol)\n unless column_node.is_a?(::Arel::Nodes::Node) || column_node.is_a?(::Arel::Attributes::Attribute)\n raise \"column was not an Arel::Nodes::Node, it was a #{column_node.class}\"\n end\n\n last_type = column_type\n query_transforms = []\n\n field = column_node\n\n validate_basic_class(field, raw_value)\n case raw_value\n when String\n ::Arel::Nodes::Quoted.new(raw_value)\n else\n raw_value\n end => value\n\n raise CustomErrors::FilterArgumentError, 'Expressions must contain at least one function' if expressions.blank?\n\n # apply each expression in sequence, building up the query\n expressions.each_with_index do |name, index|\n expression = KNOWN_EXPRESSIONS.fetch(name.to_sym, nil)\n\n raise CustomErrors::FilterArgumentError, \"Expression function `#{name}` does not exist\" if expression.nil?\n\n context = {\n last: index == (expressions.length - 1),\n raw_value:\n }\n\n expression.validate_type(last_type, model, column_name)\n\n field = expression.transform_field(field, model, column_name)\n value = expression.transform_value(value, model, column_name, context)\n\n query_transform = expression.transform_query(model, column_name)\n validate_closure(query_transform, [:query])\n query_transforms << query_transform\n\n last_type = expression.new_type\n end\n\n [query_transforms, field, value]\n end", "def function_for(path)\n\t\t\t\tparent = @attributes\n\n\t\t\t\tfunction = path.inject(parent) do |current, key|\n\t\t\t\t\tparent = current\n\n\t\t\t\t\tthrow ArgumentError.new(\"Invalid function name #{path.join(\".\")}\") unless current\n\n\t\t\t\t\tcurrent[key]\n\t\t\t\tend\n\n\t\t\t\t# Compile the function if required:\n\t\t\t\tif String === function\n\t\t\t\t\tparent[path.last] = @context.parse_function(function, binding, 'design-document')\n\t\t\t\telse\n\t\t\t\t\tfunction\n\t\t\t\tend\n\t\t\tend", "def to_ruby_literal\n \"Alf::Relation[\" +\n tuples.collect{|t| Tools.to_ruby_literal(t)}.join(', ') + \"]\"\n end", "def create_method_from_expressions; end", "def v(o)\n case o\n when Symbol, Numeric, String, Class, TrueClass, FalseClass, NilClass\n o\n when Array\n o.map{|x| v(x)}\n when Hash\n h = {}\n o.each{|k, val| h[v(k)] = v(val)}\n h\n when SQL::NumericExpression\n if o.op == :extract\n o.class.new(o.op, o.args[0], v(o.args[1]))\n else\n o.class.new(o.op, *v(o.args))\n end\n when SQL::ComplexExpression\n o.class.new(o.op, *v(o.args))\n when SQL::Identifier\n SQL::Identifier.new(v(o.value))\n when SQL::QualifiedIdentifier\n SQL::QualifiedIdentifier.new(v(o.table), v(o.column))\n when SQL::OrderedExpression\n SQL::OrderedExpression.new(v(o.expression), o.descending, :nulls=>o.nulls)\n when SQL::AliasedExpression\n SQL::AliasedExpression.new(v(o.expression), o.alias, o.columns)\n when SQL::CaseExpression\n args = [v(o.conditions), v(o.default)]\n args << v(o.expression) if o.expression?\n SQL::CaseExpression.new(*args)\n when SQL::Cast\n SQL::Cast.new(v(o.expr), o.type)\n when SQL::Function\n h = {}\n o.opts.each do |k, val|\n h[k] = v(val)\n end\n SQL::Function.new!(o.name, v(o.args), h)\n when SQL::Subscript\n SQL::Subscript.new(v(o.f), v(o.sub))\n when SQL::Window\n opts = o.opts.dup\n opts[:partition] = v(opts[:partition]) if opts[:partition]\n opts[:order] = v(opts[:order]) if opts[:order]\n SQL::Window.new(opts)\n when SQL::PlaceholderLiteralString\n args = if o.args.is_a?(Hash)\n h = {}\n o.args.each{|k,val| h[k] = v(val)}\n h\n else\n v(o.args)\n end\n SQL::PlaceholderLiteralString.new(o.str, args, o.parens)\n when SQL::JoinOnClause\n SQL::JoinOnClause.new(v(o.on), o.join_type, v(o.table_expr))\n when SQL::JoinUsingClause\n SQL::JoinUsingClause.new(v(o.using), o.join_type, v(o.table_expr))\n when SQL::JoinClause\n SQL::JoinClause.new(o.join_type, v(o.table_expr))\n when SQL::DelayedEvaluation\n SQL::DelayedEvaluation.new(lambda{|ds| v(o.call(ds))})\n when SQL::Wrapper\n SQL::Wrapper.new(v(o.value))\n else\n o\n end\n end", "def v(o)\n case o\n when Symbol, Numeric, String, Class, TrueClass, FalseClass, NilClass\n o\n when Array\n o.map{|x| v(x)}\n when Hash\n h = {}\n o.each{|k, val| h[v(k)] = v(val)}\n h\n when SQL::NumericExpression\n if o.op == :extract\n o.class.new(o.op, o.args[0], v(o.args[1]))\n else\n o.class.new(o.op, *v(o.args))\n end\n when SQL::ComplexExpression\n o.class.new(o.op, *v(o.args))\n when SQL::Identifier\n SQL::Identifier.new(v(o.value))\n when SQL::QualifiedIdentifier\n SQL::QualifiedIdentifier.new(v(o.table), v(o.column))\n when SQL::OrderedExpression\n SQL::OrderedExpression.new(v(o.expression), o.descending, :nulls=>o.nulls)\n when SQL::AliasedExpression\n SQL::AliasedExpression.new(v(o.expression), o.alias, o.columns)\n when SQL::CaseExpression\n args = [v(o.conditions), v(o.default)]\n args << v(o.expression) if o.expression?\n SQL::CaseExpression.new(*args)\n when SQL::Cast\n SQL::Cast.new(v(o.expr), o.type)\n when SQL::Function\n h = {}\n o.opts.each do |k, val|\n h[k] = v(val)\n end\n SQL::Function.new!(o.name, v(o.args), h)\n when SQL::Subscript\n SQL::Subscript.new(v(o.expression), v(o.sub))\n when SQL::Window\n opts = o.opts.dup\n opts[:partition] = v(opts[:partition]) if opts[:partition]\n opts[:order] = v(opts[:order]) if opts[:order]\n SQL::Window.new(opts)\n when SQL::PlaceholderLiteralString\n args = if o.args.is_a?(Hash)\n h = {}\n o.args.each{|k,val| h[k] = v(val)}\n h\n else\n v(o.args)\n end\n SQL::PlaceholderLiteralString.new(o.str, args, o.parens)\n when SQL::JoinOnClause\n SQL::JoinOnClause.new(v(o.on), o.join_type, v(o.table_expr))\n when SQL::JoinUsingClause\n SQL::JoinUsingClause.new(v(o.using), o.join_type, v(o.table_expr))\n when SQL::JoinClause\n SQL::JoinClause.new(o.join_type, v(o.table_expr))\n when SQL::DelayedEvaluation\n SQL::DelayedEvaluation.new(lambda{|ds| v(o.call(ds))})\n when SQL::Wrapper\n SQL::Wrapper.new(v(o.value))\n else\n o\n end\n end", "def expression(expression)\n if expression.function_sql == \"DISTINCT\"\n \"#{expression.function_sql} #{expression.attribute.to_sql(self)}\" +\n (expression.alias ? \" AS #{quote_column_name(expression.alias)}\" : '')\n else\n \"#{expression.function_sql}(#{expression.attribute.to_sql(self)})\" +\n (expression.alias ? \" AS #{quote_column_name(expression.alias)}\" : \"\")\n end\n end", "def to_nosql(arel, binds = [])\n arel = arel.ast if arel.respond_to?(:ast)\n if arel.is_a? ::Arel::Nodes::Node\n binds = binds.dup\n visitor.accept(arel) do\n quote(*binds.shift.reverse)\n end\n else # assume it is already serialized\n arel\n end\n end", "def create_function(function_name, returning, definition, options = {})\n\n end", "def generate_sql\n sql = 'guid, obj_id'\n @fields.each do |field|\n sql << ',v'\n sql << field.num.to_s\n sql << ' as '\n sql << field.name\n end\n return sql\n end", "def transpile\n code = String.new(\" \")\n code << \"$#{body['name']} = \" if body['name']\n code << function_call(function, format_args(body))\n code << \"\\n\"\n end", "def get_sql(structure, options)\n # get_partial_sql structure, key: 'sql'\n wrap_result send(\"build_#{options[:key] || 'sql'}\", structure)\n end", "def function(*code)\n Function.new(*code)\nend", "def sql_for_remove\n \"DROP FUNCTION IF EXISTS #{proname}(#{get_function_args})\"\n end", "def sql_string\n StringExpression.new(self.op, *self.args)\n end", "def to_sql(prefix = \"\")\n prefix += \"_\" unless prefix.blank?\n Array.wrap(sql).join(\" \").gsub(/__/, prefix)\n end", "def complex_expression_sql(op, args)\n case op\n when *TWO_ARITY_OPERATORS\n \"(#{literal(args.at(0))} #{op} #{literal(args.at(1))})\"\n when *N_ARITY_OPERATORS\n \"(#{args.collect{|a| literal(a)}.join(\" #{op} \")})\"\n when :NOT\n \"NOT #{literal(args.at(0))}\"\n when :NOOP\n literal(args.at(0))\n else\n raise(Sequel::Error, \"invalid operator #{op}\")\n end\n end", "def function(*args)\n Function.new(self, *args)\n end", "def function(*args)\n Function.new(self, *args)\n end", "def calc_query(query, table, aggregate = {}, as=nil)\n\tquery = \"select #{query}\"\n\n\tif !aggregate.empty?\n\t\taggregate.each do |operation, column|\n\t\t\tquery += \"#{operation}(#{column}) \"\n\t\t\tquery += as \" #{as}\"\n\t\tend\n\tend\n\n\tquery += \" from #{table}\"\n\n\treturn query\nend", "def process_defn(exp)\n make_function exp\n end", "def aql\n aql = Visitor.run(relation).aql\n adapter.logger.debug { \"AQL: #{aql}\" }\n aql\n end", "def build_sql(field)\n statement_sql = ''\n keys = primary_keys(field)\n puts \" Altering #{keys.length} records for: #{field.name} => #{field.output_type}\".blue\n keys.each do |primary_key|\n record_sql = \"UPDATE #{field.table} \"\n record_sql += \"SET #{field.column} = '#{out_val(field)}' \"\n record_sql += \"#{where_and(record_sql)} #{field.primary_key_col} = #{primary_key};\\n\"\n statement_sql += record_sql\n end \n statement_sql\nend", "def generate(name, glsl, typeInfo)\n # Merge type information for all argument lists a function might\n # have.\n minParam, paramTypes = mergeParameterLists(typeInfo.parameterLists)\n\n # Assemble type annotations for the closure compile.\n paramtypestr = []\n paramstr = []\n (0...minParam).each do |i|\n paramtypestr << \" * @param {!(#{paramTypes[i].toClosure})} arg#{i}\\n * Function argument #{i}.\"\n paramstr << \"arg#{i}\"\n end\n (minParam...paramTypes.size).each do |i|\n paramtypestr << \" * @param {!(#{paramTypes[i].toClosure})=} arg#{i}\\n * Function argument #{i}.\"\n paramstr << \"arg#{i}\"\n end\n annotations = paramtypestr.join(\"\\n\")\n\n return <<EOF\n\n/**\n * Create expression for GLSL function '#{glsl}'.\n *\n#{annotations}\n * @return {!embedsl.Expression} Created expression.\n */\nembedsl.lang.#{name} = (function() {\n var cached = #{typeInfo.toEsl};\n return function(#{paramstr.join(\",\\n \")}) {\n var args = Array.prototype.slice.call(arguments);\n return new embedsl.Expression(\n embedsl.Kind.BUILTIN, cached, '#{name}', '#{glsl}', args);\n };\n})();\nEOF\nend", "def to_sql\n @sql ||= case @kind\n when :target, :comp_op, :bin_bool_op, :term\n child(0).to_sql\n when :target_set\n # array of fragments, one per target\n [child(0).to_sql] + (child(1) ? child(2).to_sql : [])\n when :qual_term\n # child(2) will be an array (target_set)\n \"(\" + child(2).to_sql.collect{|sql| comparison(child(0), child(1).child(0), sql)}.join(\" OR \") + \")\"\n when :unqual_term\n \"(\" + default_quals.collect{|q| comparison(q, EQUAL_TOKEN, child(0).to_sql)}.join(\" OR \") + \")\"\n when :query\n # first form\n if child(0).is?(:lparen)\n @children.collect{|c| c.to_sql}.join\n # second form\n elsif child(1) && child(1).is?(:bin_bool_op)\n @children.collect{|c| c.to_sql}.join(\" \")\n # third form\n elsif child(1) && child(1).is?(:query)\n child(0).to_sql + \" AND \" + child(1).to_sql\n # fourth form\n else\n child(0).to_sql\n end\n end\n end", "def get_function(type, value, dst = '%')\n query = \"SELECT * FROM builder WHERE description = '%s' \" +\n \"AND value = %d AND dst LIKE '%s' ORDER BY num\" %\n [quote(type), value.to_i, quote(dst)]\n res = sql(query).inject(Payload.new) {|a, e| a << gadget_build(e['address'])}\n raise \"no function %s, %s found for %s\" % [type, value, dst] if res.size == 0\n res\n end", "def to_sql\n \"\n SELECT row_to_json(fc)\n FROM ( SELECT 'FeatureCollection' AS type, array_to_json(array_agg(f)) AS features\n FROM ( SELECT 'Feature' AS type\n , ST_AsGeoJSON(subquery.geom)::json AS geometry\n , row_to_json(\n (SELECT l FROM (SELECT id, geoid) AS l)\n ) AS properties\n\n FROM (\n SELECT\n ct.id,\n ct.geom,\n ct.geoid,\n ST_Area(ST_SetSRID(geom,4326)) as d,\n ST_Area(\n ST_Intersection(\n ST_SetSRID( ST_GeomFromGeoJSON('#{ @geojson }'), 4326),\n ST_SetSRID(geom,4326)\n )\n ) as n\n FROM census_tracts_2010 AS ct\n WHERE\n ST_Intersects(\n ST_SetSRID(geom,4326),\n ST_SetSRID( ST_GeomFromGeoJSON('#{ @geojson }'), 4326)\n )\n ) subquery\n WHERE (n/d*100) >= 15\n\n\n ) AS f\n ) AS fc;\n \"\n end", "def to_sparql(**options)\n \"UCASE(\" + operands.last.to_sparql(**options) + \")\"\n end", "def visitFunction func,args=nil\n type=func.type.accept(self)\n name=func.name.accept(self)\n args=func.args.collect{|arg| arg.accept(self)}\n body=func.body.accept(self)\n Function.new(name,type,args,body)\n end", "def calc_from_clause(our_join = join, our_tables = tables)\n implicits = [model.table_name] + our_tables\n result = implicits.uniq.map { |x| \"`#{x}`\" }.join(\", \")\n if our_join\n result += \" \"\n result += calc_join_conditions(model.table_name, our_join).join(\" \")\n end\n result\n end", "def to_s\n Semantic.check_class(self) do\n str = \"function #{name}(#{@parameters.join(', ')}) {\\n\"\n Indentation.indent do\n str << \"#{@attributes.map(&:to_s).join(\"\\n\")}\\n\" unless\n @attributes.empty?\n str << \"#{Indentation.get}var self = this;\\n\\n\"\n str << \"#{function2method(@constructor)}\"\n unless @private_methods.empty?\n str << \"\\n#{@private_methods.map(&:to_s).join(\"\\n\")}\"\n end\n unless @public_methods.empty?\n str << \"\\n\"\n str << @public_methods.map { |m| function2method(m) }.join(\"\\n\")\n end\n str << \"\\n#{Indentation.get}this.init(#{@parameters.join(', ')});\\n\"\n end\n \"#{str}#{Indentation.get}}\\n\"\n end\n end", "def to_sql\n\n # Hide Amex numbers\n# if (!@titolo_name.nil?) \n# if (@categoria_name == \"AMERICAN EXPRESS\" || @categoria_name == \"BANK OF AMERICA\") \n# @titolo_name.gsub!(/\\*.*\\*/, \"\");\n# end\n# end\n\n \n\n return \"INSERT INTO expenses (`created`, `anno`, `missione_title`, `missione_id`, `categoria_title`, `categoria_code`, `titolo_name`, `amministrazione_id`, `amministrazione_title`, `programma_id`, `programma_title`, `pagamenti_residui`,`pagamenti_totali`) VALUES (NOW(), '#{@anno}','#{@missione_title.to_s.gsub(/\\\\/,'\\&\\&').gsub(/'/,\"''\")}', '#{@missione_id}', '#{@categoria_title.to_s.gsub(/'/, \"''\")}', '#{@categoria_code}', '#{@titolo_name.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")}', '#{@amministrazione_id}', '#{@amministrazione_title.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")}', '#{@programma_id}', '#{@programma_title.to_s.gsub(/\\\\/, '\\&\\&').gsub(/'/, \"''\")}', #{@pagamenti_residui.gsub(/,/, \"\")}), #{@pagamenti_totali.gsub(/,/, \"\")});\"\n end", "def sql_literal(object)\n object.literal(to_s)\n end", "def visitFunction func,args=nil\n code=Code.new\n tname=func.type.accept(self)\n fname=func.name.accept(self)\n args=func.args.collect{|arg| arg.accept(self)}\n args=args.join(\",\")\n code << \"\\n#{tname} #{fname}(#{args})\"\n code.indent=2\n code << func.body.accept(self)\n code.indent=0\n return code\n end", "def sql_quoted(value)\n Arel::Nodes.build_quoted(value)\n end", "def to_s\n return @to_s if @to_s\n parsed = parse_operation\n if parsed\n @to_s = \"#{model}/#{parsed}\"\n else\n @to_s = regex_name(sql)\n end\n end", "def sql_for_columns; @sql_for_columns end", "def to_sql(options = {})\n \"#{field.to_sql(options)} = #{expression.to_sql(options)}\"\n end", "def as(aliaz)\n ::Sequel::SQL::AliasedExpression.new(self, aliaz)\n end" ]
[ "0.72114253", "0.72029746", "0.7162768", "0.70845366", "0.69390935", "0.67026633", "0.64334005", "0.6325903", "0.62504846", "0.6182804", "0.6076468", "0.6029248", "0.60250694", "0.5994138", "0.59470236", "0.59458596", "0.59052366", "0.58389825", "0.56853765", "0.56518453", "0.56294554", "0.5612346", "0.5603333", "0.5601133", "0.557791", "0.55702716", "0.5564155", "0.5551071", "0.5537636", "0.5536734", "0.5518968", "0.5514303", "0.5504719", "0.5503567", "0.54978776", "0.54437006", "0.5440141", "0.54378885", "0.5427529", "0.5416605", "0.5407193", "0.5402434", "0.5398335", "0.5395285", "0.53942716", "0.5389961", "0.53893054", "0.5386126", "0.53725314", "0.53578883", "0.5353017", "0.5347406", "0.53458637", "0.53376836", "0.5333949", "0.53212154", "0.53027016", "0.5295954", "0.5283351", "0.5281066", "0.52676845", "0.526512", "0.52614975", "0.5261235", "0.5219792", "0.5215946", "0.5212986", "0.5208588", "0.52051413", "0.51737726", "0.5171883", "0.5171008", "0.5161455", "0.51571995", "0.51557976", "0.51410323", "0.51388234", "0.5109959", "0.5101329", "0.5101329", "0.50946176", "0.5080127", "0.507984", "0.50669765", "0.50638616", "0.5063474", "0.50532395", "0.504325", "0.5042852", "0.50405467", "0.5033472", "0.5023427", "0.50229836", "0.5020808", "0.50132626", "0.50100905", "0.5002695", "0.50021464", "0.49938777", "0.49937373" ]
0.5795503
18
returns booleaan value overdue or not
def overdue? @due_date < Date.today end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def overdue?\n due < Date.current\n end", "def overdue?\r\n @overdue = Time.now > @due_date\r\n end", "def overdue?\n return true if @past_due\n false\n end", "def overdue? ()\n\t\t@due_date < Time.now\n end", "def overdue?\n return false if due_at.nil?\n due_at < Time.now \n end", "def is_overdue\n if @due_date\n if ( (Time.now - @due_date) > 0 )\n @status = \"overdue\"\n puts \"#{@title} is overdue! Please return!\"\n else\n days_left = @due_date.yday - Time.now.yday\n puts \"You have #{days_left} days before you need to return #{@title}.\"\n end\n\n else\n puts \"#{@title} has not been checked out.\"\n end \n end", "def overdue\n @date > Date.today\n end", "def overdue?\n Date.today > to_date\n end", "def overdue?(test)\r\n\t\tif self.overdue.present?\r\n\t\t\tself.overdue.overdue?(test)\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend", "def expired?\n overdue_days > 0\n end", "def overdue?\n next_payment_at && next_payment_at.to_date < Date.today\n end", "def is_due?\n self.datetime.past?\n end", "def is_benefit_out_of_bal\n @cur_pkg = self.get_latest_effective_package\n #@cur_pkg = self.current_package\n if @cur_pkg != nil\n #if false && @cur_pkg\n @bene_bal = ( self.monthly_benefit.to_f -\n ( self.current_package.calc_hourly_benefit.to_f * self.calc_tot_hours.to_f )\n )\n\n else\n @bene_bal = 0.0000\n end\n if @bene_bal > 0.0005 || @bene_bal < -0.0005\n true\n else\n false\n end\n end", "def time_over?\r\n return self.due_date <= Time.now\r\n end", "def is_overdue\r\n\t\tif (Time.now).to_i > book.due_date && book.status == \"Checked Out\"\r\n\t\t\tbook.status = \"Overdue\"\r\n\t\t\tputs \"#{book.title} is overdue!\"\r\n\t\telsif book.status == \"Avalable\"\r\n\t\t\tputs \"#{book.title} is available.\"\r\n\t\telse\r\n\t\t\tputs \"#{book.title} is checked out but not overdue.\"\r\n\t\tend\r\n\tend", "def must_not_be_overdue\n\t\tif self.profile.state == 'Overdue'\n\t\t\terrors.add(:base, \"This person has unpaid charges.\")\n\t\tend\n\tend", "def past_due\n stripe_status == 'past_due'\n end", "def deadline_over?(risk_register)\n return date_difference(Date.today, risk_register.target_date) < 0\n end", "def overdue_by\n @overdue_str = \"minutes\"\n \n overdue = (((self.is_due?) ? (Time.zone.now - self.datetime) : (self.datetime - Time.zone.now)) / 60).to_i \n\n if overdue > 60\n overdue /= 60\n @overdue_str = \"hours\"\n if overdue > 24\n overdue /= 24\n @overdue_str = \"days\"\n if overdue > 7\n overdue /= 7\n @overdue_str = \"weeks\"\n if overdue > 4\n overdue /= 4\n @overdue_str = \"months\"\n end\n end\n end\n end\n \n @overdue_str = @overdue_str[0..-2] if overdue == 1\n \n overdue\n end", "def overdue?\n !self.attempt_next_contact_by.nil? && self.attempt_next_contact_by < Time.current\n end", "def out_of_money()\n @total_money <= 0\n end", "def notification_due?\n notification_due = false\n if hw_coverage_end_date.present?\n planned_notification_dates.each do |planned_notice|\n if in_the_past(planned_notice) and last_notice_before(planned_notice)\n notification_due = true\n break\n end\n end\n end\n notification_due\n end", "def notification_due?\n notification_due = false\n if hw_coverage_end_date.present?\n planned_notification_dates.each do |planned_notice|\n if in_the_past(planned_notice) and last_notice_before(planned_notice)\n notification_due = true\n break\n end\n end\n end\n notification_due\n end", "def overdue?(name, since)\n interval = registered.fetch(name).fetch(:execution_interval)\n since < (interval * 2).seconds.ago\n end", "def due?\n return true if @payment_due.to_f > 0\n false\n end", "def due?\n super && !violations.empty?\n end", "def overdue\n @attributes[:overdue]\n end", "def past_due?\n self.updated_at.to_date > self.due_date\n end", "def technically_paid?\n unconfirmed_value_paid >= value_needed\n end", "def due_later?\n @due_date > Date.today\n end", "def late_or_wait?\n return 'paid' if self.paid > 0\n return 'late' if self.deadline < MyDate.today\n return 'wait' if self.deadline >= MyDate.today\n end", "def overdue_by\n @overdue_str = \"minutes\"\n @overdue_or_left = \"expired\"\n \n return \"never expires\" if self.expiration_date.nil?\n overdue = (Time.zone.now - self.expiration_date.to_datetime)\n \n if (overdue < 0)\n overdue *= -1\n @overdue_or_left = \"left\"\n end\n \n overdue /= 60\n \n if overdue > 60\n overdue /= 60\n @overdue_str = \"hours\"\n if overdue > 24\n overdue /= 24\n @overdue_str = \"days\"\n if overdue > 7\n overdue /= 7\n @overdue_str = \"weeks\"\n if overdue > 4\n overdue /= 4\n @overdue_str = \"months\"\n if overdue > 12\n overdue /= 12\n @overdue_str = \"yrs\"\n end\n end\n end\n end\n end\n \n @overdue_str = @overdue_str[0..-2] if overdue == 1\n \n overdue.round\n end", "def continuious_overstay?\n no_days_continuous_in_schengen > 90\n end", "def is_solvent?\n \t#\n \t@amount_of_loans < (@cash_deposits * @ratio_of_basil_rules - @losses)\n end", "def check_over_due\n time = Time.now\n @time_table.each{ |book, date|\n if date <= time\n puts \"Bro #{book} is overdue\"\n @overdue = true\n end\n }\n end", "def never_billed?\n self[:paid_until].blank?\n end", "def overdue?\n schedules.each do |schedule|\n # date the next scheduled occurence should be calculated from\n calc_date = [last_run, modified_on || created_on].max\n next_occurence = schedule.get_scheduled_date(calc_date)\n logger.debug \"Next scheduled occurence for schedule id \\\n #{schedule.id} is #{next_occurence}\"\n return true if next_occurence < Time.now\n end\n false\n end", "def next_payment_due_on\n return second_payment_is_due_on unless second_payment_is_paid?\n return security_deposit_is_due_on unless security_deposit_is_paid?\n nil\n end", "def is_overbudget ( cruises ) \n\tfor cruise in cruises.each\n\t\ttotalprice = totalprice.to_i + cruise.price.to_i\n\t\ttotaldays = totaldays.to_i + cruise.length.to_i\n\tend\n\tif totalprice > $max_price || (totalprice/totaldays) > $max_ppn || cruises.length > $max_cruises\n\t\treturn true\n\telse\n\t\treturn false\n\tend\nend", "def future_expense_checker (record)\n\t\tdate = record.date_paid\n \ttime = date.to_time\n \ttime.future?\n end", "def overdue?\n if is_appointment?\n start_date.to_date < Time.zone.now.to_date\n else\n open? && end_date.to_date < Time.zone.now.to_date\n end\n end", "def delinquent?\n ['past_due'].include?(status)\n end", "def money_enough?\n remaining_sum > 0\n end", "def incomplete_payment?\n past_due || incomplete\n end", "def missed_deadline?\n if self.closeDate.nil?\n self.dueDate.to_date < Date.today\n else\n self.dueDate.to_date < self.closeDate.to_date\n end\n end", "def lost?\n book.status=\"lost\" if Time.now > (book.due_date + (30*24*60*60))\n end", "def is_in_the_past? \n departureOnThe > returnOnThe \n end", "def past?\n due_on < Date.today\n end", "def due_to_cannot_be_in_the_past\n if dueTo.present? && dueTo < Date.today\n errors.add(:dueTo, \"can't be in the past\")\n end\n end", "def not_in_past?\n #return true if self.class == Reservation && self.status != 'reserved'\n if (start_date < Date.today) || (due_date < Date.today)\n errors.add(:base, \"Reservation cannot be made in the past.\\n\")\n return false\n end\n return true\n end", "def too_soon_to_renew?\n due_date_after_renewal <= due_date\n end", "def futur?\n before > 0\n end", "def due?\n due_week == Date.today.cweek ? true : false\n end", "def still_needed\r\n\t@target_fund - @fund\r\nend", "def due_date_is_not_blackout?\n if Blackout.hard_blackout_exists_on_date(due_date)\n errors.add(:base, \"Reservation cannot end on \" + due_date.strftime('%m/%d') + \" because equipment cannot be returned on that date.\\n\")\n return false\n end\n return true\n end", "def future_expense_checker (record)\n\t\tdate = record.date_incurred\n \ttime = date.to_time\n \ttime.future?\n end", "def loose?\n return true if budget.actual_earnings < 0\n return true if simulator.initial_budget and budget.total_used > 1.25 * simulator.initial_budget\n return true if simulator.actual_duration and simulator.actual_duration > 1.25 * simulator.original_duration\n return true if simulator.day and simulator.day > simulator.actual_duration\n false\n end", "def fully_paid?\n amount_owed <= 0\n end", "def due_status(date)\n return :none if date.nil?\n\n days = (date - today).to_i\n\n if days > 1\n days -= 1 if today.saturday?\n days -= 2 if today.friday?\n end\n\n if days > 1\n :not_yet_due\n elsif days == 1\n :upcoming\n elsif days == 0\n :due\n else\n :overdue\n end\n end", "def due\n proptime 'DUE'\n end", "def due\n chain lambda{ | n | n.respond_to?( :due? ) && n.due? }\n end", "def borrower_paid_outside_closing\n purchase_credits.where(:name => 'BorrowerPaidOutsideClosing').first.value rescue nil\n end", "def is_grace_period?\n self.weekly_tasks.where(:is_weekly_payment_approved_by_cashier => true ).count == self.total_weeks \n end", "def reservation_status_then_showdate ; reserved? ? -(showdate.thedate.to_i) : -1.0e15 ; end", "def rejected?\n !self.rejected_at.nil?\n end", "def can_be_unconfirmed?\n reverse_adjustment_quantity = -1*diff \n \n wh_item = self.warehouse_item\n item = self.item \n \n final_item_ready = item.ready + reverse_adjustment_quantity\n final_wh_item_ready = wh_item.ready + reverse_adjustment_quantity\n \n if final_item_ready < 0 or final_wh_item_ready < 0 \n msg = \"Akan menyebabkan jumlah item ready menjadi : #{final_item_ready}.\"\n self.errors.add(:generic_errors, msg )\n return false\n end\n \n return true \n end", "def ok_to_sum?\n status.try(:downcase) == \"closed\" && closed_reason.try(:downcase) != \"invalid\"\n end", "def get_status\n if draft\n :draft\n elsif closed || gross_amount <= paid_amount\n :closed\n elsif due_date and due_date > Date.today\n :opened\n else\n :overdue\n end\n end", "def action_subdued?(condition)\n subdued = subdue_time?(condition) || subdue_days?(condition)\n subdued && !subdue_exception?(condition)\n end", "def client_tasks_overdue\n self.find_all {|e| (e.completed.nil? or !e.completed) and e.complete_by < Time.zone.now }\n end", "def get_eligible\n #older than 1 day, not older than X date (whenever they get these cards).\nend", "def expired?\n pledging_ends_on.past?\n end", "def out_of_stock?\n quantity.zero? || reserved_count == quantity\n end", "def rejected?\n !!self.rejected_at\n end", "def expired?\n conf_item_hold_time = SystemConfiguration::Variable.get_value('booking.item_hold_time', '0').to_i\n hold_time_diff_in_hours = ((DateTime.now.to_time - self.creation_date.to_time).to_f * 24).to_i\n expired = (hold_time_diff_in_hours > conf_item_hold_time)\n expired && !force_allow_payment\n end", "def fulfilled?\n amount_remaining.zero?\n end", "def bust?; value > 21; end", "def pick_up_time_is_earlier_than_return_time\n if pick_up_time >= return_time\n errors.add(:return_time, errors.generate_message(:return_time, :too_early))\n end \n end", "def out_of_date\n last_order_detail = self.order_details.order(\"created_at DESC\").first\n last_priced = self.product_prices.order(\"created_at DESC\").first\n\n if last_order_detail.nil?\n last_date = self.updated_at\n else\n last_date = last_order_detail.updated_at\n end\n\n if last_priced.present?\n if last_date < last_priced.created_at\n last_date = last_priced.created_at\n end\n end\n\n return (self.stock <= 0 and last_date < Time.now - 6.months)\n end", "def check_deadline\n true\n end", "def must_pay_to_avoid_cancellation\n\t\tif @event.start_date < (Time.now + 1.week) && @event.paid == false \n\t\t\t#cannot book event\n\t\tend\n\tend", "def can_double_bet\n return 1 unless @bankroll < @bet\n return nil\n end", "def failed? participate\n return participate.continuous_check_in == 0 || participate.updated_at.to_date != Time.now.utc.to_date\nend", "def current?\n active? || past_due?\n end", "def waits_too_long?(account)\n is?(:asked) and self.asked <= 4.days.ago.to_date\n end", "def peutAider?\n return Date.today().years_ago(13) > self.naissance\n end", "def reminders_within_due_date\n return if due_in_days_after.blank?\n\n REMINDERS.each do |reminder|\n reminder_value = self.send(reminder)\n \n next if reminder_value.blank?\n\n if reminder_value < 0 \n errors[:base] = \"#{reminder.titleize} cannot be less than zero\"\n elsif reminder_value >= due_in_days_after\n errors[:base] = \"#{reminder.titleize} cannot be greater than the due date\"\n end\n end\n end", "def balance_negative?\n current_balance.negative?\n end", "def unpaid_grace_period_amount\n total_grace_period_amount - paid_grace_period_amount\n end", "def success?\r\n\treturn true if @fund >= @target_fund\r\n\treturn false if @fund < @target_fund\r\nend", "def can_be_rejected?\n self.applied?\n end", "def overdue\n schedules.where(:when.lte => Time.now)\n end", "def not_open\n if self.time.to_i < restaurant.open_at.to_i || self.time.to_i > restaurant.close_at.to_i\n errors.add(:date, \"Restaurant not open at that time\")\n end\n end", "def tba?\n (!self.available_on.nil? && self.available_on > self.class.upcoming_on)\n end", "def lost?\n @life <=0\n end", "def check_win_or_lose\n return @check_win_or_lose\n end", "def in_past?\n elapsed.positive?\n end", "def isImpossible(minben) \r\n \r\n sum_value = @itemValue.inject(0){|sum,item| sum+item} \r\n\r\n if (sum_value < minben) \r\n true\r\n else\r\n false\r\n end\r\n \r\n end", "def amount_is_valid_for_outstanding_balance_or_credit\n end", "def amount_remaining\n @desired_amount - @bought_amount\n end" ]
[ "0.7580483", "0.7530549", "0.752278", "0.7413455", "0.72838765", "0.7162273", "0.713849", "0.7117427", "0.6955074", "0.6895525", "0.6884943", "0.6877265", "0.6823064", "0.68216264", "0.680051", "0.67260766", "0.672285", "0.67214656", "0.6651268", "0.66407436", "0.65936893", "0.6558801", "0.6558801", "0.65512216", "0.65511703", "0.6530568", "0.65157217", "0.65144694", "0.65084445", "0.64924", "0.6487593", "0.6456654", "0.64118487", "0.64031196", "0.6398262", "0.6357169", "0.6325913", "0.6323663", "0.6320745", "0.63176113", "0.6313941", "0.6295586", "0.62663466", "0.62633014", "0.62622577", "0.62610555", "0.62562037", "0.6226209", "0.6214107", "0.61867636", "0.6186494", "0.61797404", "0.6163169", "0.61580086", "0.6150629", "0.6144022", "0.6128395", "0.6115595", "0.6111628", "0.6106652", "0.6095183", "0.60831124", "0.6077812", "0.60600597", "0.6028853", "0.60283434", "0.60221314", "0.60194236", "0.60023105", "0.5969982", "0.5966341", "0.5940148", "0.5938417", "0.5930318", "0.59117705", "0.59096134", "0.59003985", "0.5885477", "0.58767766", "0.58755785", "0.5875294", "0.5870949", "0.58669317", "0.58649695", "0.58621347", "0.58612776", "0.5856824", "0.5856807", "0.5850164", "0.5845394", "0.58423895", "0.58391786", "0.5821078", "0.5820969", "0.58172125", "0.58069587", "0.58004487", "0.57987785", "0.57951605", "0.57888365" ]
0.70379734
8
returns booleaan value duetoday or not
def due_today? @due_date == Date.today end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def due_today?\n @date == Date.today.to_s\n end", "def due_today?\n due_date == Date.due_today\n end", "def due_later?\n @due_date > Date.today\n end", "def overdue\n @date > Date.today\n end", "def overdue?\n @due_date < Date.today\n end", "def overdue?\n due < Date.current\n end", "def overdue?\n Date.today > to_date\n end", "def past?\n due_on < Date.today\n end", "def overdue? ()\n\t\t@due_date < Time.now\n end", "def due?\n due_week == Date.today.cweek ? true : false\n end", "def is_due?\n self.datetime.past?\n end", "def date_today?\n @today\n end", "def overdue?\r\n @overdue = Time.now > @due_date\r\n end", "def due_today\n @due_date_task_list.select { |duedatetask| (duedatetask.status == \"incomplete\") && (duedatetask.due_date == Date.today) }\n end", "def due_date\n return @due_date\n end", "def overdue?\n next_payment_at && next_payment_at.to_date < Date.today\n end", "def due_date\n created_at + Spree::BilletConfig.due_date.days\n end", "def due\n\t\t\t\tif read_attribute(:due) && read_attribute(:due) > 0\n\t\t\t\tTime.at(read_attribute(:due)).to_date\n\t\t\t\telse\n\t\t\t\tnil\n\t\t\t\tend\n\t\t\tend", "def due_date\n notice_date + RESPOND_BY_TIME if notice_date\n end", "def due_date\n notice_date + RESPOND_BY_TIME if notice_date\n end", "def due_date\n @due_date\n end", "def future_expense_checker (record)\n\t\tdate = record.date_paid\n \ttime = date.to_time\n \ttime.future?\n end", "def too_soon_to_renew?\n due_date_after_renewal <= due_date\n end", "def get_due_date()\n @due_date\n end", "def overdue?\n return false if due_at.nil?\n due_at < Time.now \n end", "def not_completed_due_today\n @not_done = @to_do_with_date.select { |x| x.is_done? == false }\n return @not_done.select { |x| x.due_date == Date.today }\n end", "def past_due\n stripe_status == 'past_due'\n end", "def last_payment_due_on\n entry = workshop_price.specific_payment_schedule(initial_payments_should_start_on, Date.today)\n entry ? entry[:due_on] : initial_payments_should_start_on.to_date\n end", "def due_status(date)\n return :none if date.nil?\n\n days = (date - today).to_i\n\n if days > 1\n days -= 1 if today.saturday?\n days -= 2 if today.friday?\n end\n\n if days > 1\n :not_yet_due\n elsif days == 1\n :upcoming\n elsif days == 0\n :due\n else\n :overdue\n end\n end", "def get_due_date()\n return @due_date\n end", "def date_check\n if due_date.present? && due_date < Date.today\n errors.add(:due_date, \"can't be before today\")\n end\n end", "def due\n if read_attribute(:due) && read_attribute(:due) > 0\n Time.at(read_attribute(:due)).to_date\n else\n nil\n end\n end", "def default_due_date\n #Date.parse(future_date($default_due).to_s[0..10]) # => converts to a Date object\n Date.today + $default_due\n end", "def time_over?\r\n return self.due_date <= Time.now\r\n end", "def target_response_time\n now = Time.now\n if Time.before_business_hours?(now)\n next_business_day = now.midnight\n else\n next_business_day = 1.business_day.after(now).midnight\n end\n due_date = 5.business_hour.after(next_business_day)\n end", "def past_due?\n self.updated_at.to_date > self.due_date\n end", "def future_expense_checker (record)\n\t\tdate = record.date_incurred\n \ttime = date.to_time\n \ttime.future?\n end", "def current?\n active? || past_due?\n end", "def next_payment_due_on\n return second_payment_is_due_on unless second_payment_is_paid?\n return security_deposit_is_due_on unless security_deposit_is_paid?\n nil\n end", "def today\n \"today\" if @date == Date.today\n end", "def\n get_due_date()\n @due_date\n end", "def hold_day?\n if date-7 < Time.zone.today && date >= Time.zone.today\n \"week_in\"\n elsif date < Time.zone.today\n \"finished\"\n end\n end", "def due_today\n TodosList.new(@todos.filter { |todo| todo.due_today? })\n end", "def hold_day?\n if self.date-7 < Date.today && self.date > Date.today\n return \"week_in\"\n elsif self.date < Date.today\n return \"finished\"\n end\n end", "def drink_blood?\n @drank_blood_today\n end", "def send_today?\n day_today = (Date.today - @config['start_date']).round\n (day_today % 28) < 21\nend", "def due_by\n #occurring_days = ae_definition.occurring_days\n dob = profile.kids_type.birthdate.to_date\n dob + (ae_definition.occurring_days + ae_definition.due_by_days )\n end", "def today?\n @date == Date.today\n end", "def real_days_progress_today\n\t\tdays_progresses.at(Date.today).first.try(:real) || dp_days_progress_today[0]\n\tend", "def due_date_time\n return @due_date_time\n end", "def due_date_time\n return @due_date_time\n end", "def get_due_time(user)\n Borrowing.find_by(user_id: user.id, book_id: self.id)\n .due_date\n end", "def rainy_today?\n self.rainy_today == true\n end", "def future?\n Date.today <= finish\n end", "def d_day_notice\n charge_start_date.between?(Time.zone.today - 6.days, Time.zone.today)\n end", "def due\n proptime 'DUE'\n end", "def today\n @date\n # Date.today\n end", "def is_status_free (date)\n that_date = date\n return that_date < Date.today \n #komentarz na przyszlosc: #Date.new(2009,6,13)\n end", "def notification_due?\n notification_due = false\n if hw_coverage_end_date.present?\n planned_notification_dates.each do |planned_notice|\n if in_the_past(planned_notice) and last_notice_before(planned_notice)\n notification_due = true\n break\n end\n end\n end\n notification_due\n end", "def notification_due?\n notification_due = false\n if hw_coverage_end_date.present?\n planned_notification_dates.each do |planned_notice|\n if in_the_past(planned_notice) and last_notice_before(planned_notice)\n notification_due = true\n break\n end\n end\n end\n notification_due\n end", "def missed_deadline?\n if self.closeDate.nil?\n self.dueDate.to_date < Date.today\n else\n self.dueDate.to_date < self.closeDate.to_date\n end\n end", "def overdue_by\n @overdue_str = \"minutes\"\n \n overdue = (((self.is_due?) ? (Time.zone.now - self.datetime) : (self.datetime - Time.zone.now)) / 60).to_i \n\n if overdue > 60\n overdue /= 60\n @overdue_str = \"hours\"\n if overdue > 24\n overdue /= 24\n @overdue_str = \"days\"\n if overdue > 7\n overdue /= 7\n @overdue_str = \"weeks\"\n if overdue > 4\n overdue /= 4\n @overdue_str = \"months\"\n end\n end\n end\n end\n \n @overdue_str = @overdue_str[0..-2] if overdue == 1\n \n overdue\n end", "def this_day(record)\n record.date == Date.today\n end", "def overdue?\n return true if @past_due\n false\n end", "def due_date\n if @lease.grace_period.present? && @lease.grace_period >= 0\n @date + @lease.grace_period.day\n else\n @date\n end\n end", "def closed_value\n \"to:#{midnight_today}\"\n end", "def due_date\n students = self.accessible_students \n return nil if students.length == 0\n\n date = students.first.due_date\n students.find_each do |student|\n if student.due_date \n if !date || student.due_date > date\n date = student.due_date\n end\n end\n end\n\n date\n end", "def upcoming?\n (start_date > Date.today)\n end", "def late_or_wait?\n return 'paid' if self.paid > 0\n return 'late' if self.deadline < MyDate.today\n return 'wait' if self.deadline >= MyDate.today\n end", "def is_past_due?(current_day)\n # compare the current day to the @due_date\n days_of_week = [\n \"Sunday\",\n \"Monday\",\n \"Tuesday\",\n \"Wednesday\",\n \"Thursday\",\n \"Friday\",\n \"Saturday\"\n ]\n # if no tasks on the list\n if @list.values.all? { |tasks| tasks.empty? } # goes through all the values and verifies that all of them meet a specific condition that we passed to the block and all the values are tasks which are arrays. Use built in method empty which will return true or false. Verifies if any of the tasks or our arrays return false that they are not empty\n # isn't past due, return false\n puts \"You have completed all the tasks on your list!\"\n false\n # elsif the current day is past the @due_date\n elsif days_of_week.index(@due_date) < days_of_week.index(current_day) # Where is due date in array of days of week? Using .index on an array will return the fixnum index of the due date\n # yes, it is past due. return true\n puts \"You still have tasks to complete and they were due on #{@due_date}!\"\n true\n # else the current day is before the @due_date\n else\n # return false\n puts \"You still have until #{@due_date} to complete these tasks.\"\n false\n end\n end", "def is_overdue\n if @due_date\n if ( (Time.now - @due_date) > 0 )\n @status = \"overdue\"\n puts \"#{@title} is overdue! Please return!\"\n else\n days_left = @due_date.yday - Time.now.yday\n puts \"You have #{days_left} days before you need to return #{@title}.\"\n end\n\n else\n puts \"#{@title} has not been checked out.\"\n end \n end", "def today?\n time.today?\n end", "def voided?\n if voided_on_date.nil?\n false\n else\n (voided_on_date <= Date.today)\n end\n end", "def due_date\n self.created_at.to_date + 7\n end", "def internal_due_date_time\n return @internal_due_date_time\n end", "def direction\n date_deadline < Date::today ? :past : :future\n end", "def check_dates\n if(self.d_publish.nil?) && (self.d_remove.nil?)\n self.d_remove = \"2094-03-25\"\n self.d_publish = Time.zone.today\n elsif(self.d_publish?)\n self.d_remove = \"2094-03-25\"\n elsif(self.d_remove?)\n self.d_publish = Time.zone.today\n end\n end", "def day \n\t\t(self.check_out - self.check_in).to_i\n\tend", "def vendredi_13? #methode dinstance\n Date.today.day == 13 and Date.today.friday? # on appelle methode today qui renvoie lobjet date et on compare test le jour par and=&& \n end", "def upcoming?\n (!self.available_on.nil? && self.available_on > Date.today && self.available_on <= self.class.upcoming_on)\n end", "def due_date(due)\n return DateLabelHelper::DueDateView.new(due, prefs).due_date_html\n end", "def check_out(due_date)\n\n if @due_date == nil\n @due_date = 0\n end\n\n @due_date += 7\n\n end", "def panel\n if completed?\n 'completed'\n elsif due_date && due_date.to_date > Time.zone.today\n 'upcoming'\n else\n 'past_due'\n end\n end", "def waiting_date (last_promo_item, plan)\n num = ((last_promo_item.validez - last_promo_item.created_at)/60/60/24).round\n case num\n when 7\n if (plan == 'plus')\n last_promo_item.validez + 3.days\n elsif (plan == 'basic')\n last_promo_item.validez + 10.days\n end\n when 3\n if (plan == 'plus')\n last_promo_item.validez + 2.days\n elsif (plan == 'basic')\n last_promo_item.validez + 5.days\n end\n when 1\n if (plan == 'plus')\n last_promo_item.validez + 1.days\n elsif (plan == 'basic')\n last_promo_item.validez + 2.days\n end\n else\n #Error -> Promo lasted and unselectable number of days\n end\n\n end", "def due_date_chaser(user)\n @user = user\n # Checks if the time difference in days is between 0 and 1.\n \n # Toggle the 0..0 range if you want to change. 0..0 is 24 hours, 0..1 is 48 hours....\n @items = Item.where(user_id: @user.id).where(completed: false).where.not(due_date: nil).select {|v| (0..0).include?((DateTime.parse(v.due_date) - DateTime.current()).to_i) }\n @url = 'https://fergus-cvwo.netlify.app/'\n if @items != []\n mail(to: @user.email, subject: 'You have tasks due in 24 hours!')\n end\n end", "def remaining_days\n self.paid_through - Date.today\n end", "def today?\n to_date == ::Date.current\n end", "def dueToday\n dueTodayList = \"\"\n @toDoListArray.each do |e|\n if !e.status && e.dueDate == Date.today\n dueTodayList = dueTodayList + e.printItem + \" \"\n end\n end\n dueTodayList\n end", "def pending?\n start_date > Date.today\n end", "def drank_blood_today\n return @drank_blood_today\n end", "def\n check_out(due_date)\n\n if @due_date == nil\n @due_date = 0\n end\n\n @due_date += 7\n\n end", "def dueDate\n Date.parse(@dueDate)\n end", "def new?\n available_on + 1.month >= Time.zone.today ? true : false\n rescue\n false\n end", "def available?\n (!self.available_on.nil? && self.available_on <= Date.today)\n end", "def estimated_days_progress_today\n\t\tdays_progresses.at(Date.today).first.try(:expected) || dp_days_progress_today[1]\n\tend", "def due\n DateTime.parse(value_for('due'))\n end", "def due\n chain lambda{ | n | n.respond_to?( :due? ) && n.due? }\n end", "def lessthan?\n if self.contractendon < 14.day.since.to_date && self.contractendon > Time.now.to_date\n return true\n end\n end", "def due_date\n if @values[:due_date] != nil && @values[:due_date] != \"\"\n @date_due_date ||= Date.parse(@values[:due_date])\n end\n end", "def check_in()\n @due_date = nil\n end" ]
[ "0.78485334", "0.78431356", "0.7580038", "0.7518905", "0.7500144", "0.7436945", "0.7378778", "0.725885", "0.7258464", "0.72386867", "0.7127824", "0.70372593", "0.69187444", "0.6889206", "0.6868523", "0.6867858", "0.6867445", "0.68260235", "0.6823145", "0.6823145", "0.6813691", "0.677755", "0.6762945", "0.67422277", "0.6723647", "0.6722547", "0.67215097", "0.67092603", "0.6708703", "0.670244", "0.66977733", "0.668954", "0.66762155", "0.6674421", "0.6669799", "0.6667601", "0.66287726", "0.6610692", "0.66086817", "0.660194", "0.6597787", "0.658122", "0.65801346", "0.65780497", "0.6577215", "0.6577109", "0.6568875", "0.65601623", "0.6537342", "0.65333533", "0.65333533", "0.6504827", "0.64973724", "0.6479225", "0.64548934", "0.64500386", "0.64478546", "0.6435017", "0.6423022", "0.6423022", "0.64199233", "0.6395307", "0.636594", "0.63529557", "0.63509804", "0.63466585", "0.63447785", "0.6336324", "0.63257796", "0.63150144", "0.63062316", "0.63039124", "0.6295762", "0.6291276", "0.628469", "0.62424964", "0.62408835", "0.6237106", "0.62364", "0.623602", "0.6235727", "0.623374", "0.62296593", "0.62255824", "0.62123644", "0.62113464", "0.6203399", "0.62005305", "0.61973184", "0.61894137", "0.6174573", "0.615719", "0.6153755", "0.6145793", "0.6143297", "0.613333", "0.61288685", "0.6127722", "0.61245686", "0.6123252" ]
0.7860707
0
returns booleaan value duelater or not
def due_later? @due_date > Date.today end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value_if_false\n return @value_if_false\n end", "def value_if_true\n return @value_if_true\n end", "def value_bill_movement\n value ? value : 'N/a'\n end", "def bust?; value > 21; end", "def futur?\n before > 0\n end", "def bottom_value\n @relevant_data ? points.minimum_value : nil\n end", "def get_value_number\n value ? value : 0\n end", "def value\n min_stay = [prop_min_stay.to_i, cal_min_stay.to_i].max\n\n min_stay.zero? ? nil : min_stay\n end", "def next_payment_due_on\n return second_payment_is_due_on unless second_payment_is_paid?\n return security_deposit_is_due_on unless security_deposit_is_paid?\n nil\n end", "def isBusted\n\t\tif @value > 21\n\t\t\treturn true\n\t\tend\n\t\treturn false\n\tend", "def value?\n return !self.flag?\n end", "def value\n true\n end", "def bust?\n\t\tvalue_as_int > 21 ? true : false\n\tend", "def future?\r\n @at > DateTime.now\r\n end", "def tba?\n (!self.available_on.nil? && self.available_on > self.class.upcoming_on)\n end", "def value\n # it is the real value, like 100, means R$1,00\n self.real_budget if read_attribute(:value)\n end", "def late_or_wait?\n return 'paid' if self.paid > 0\n return 'late' if self.deadline < MyDate.today\n return 'wait' if self.deadline >= MyDate.today\n end", "def expected_value; end", "def expected_value; end", "def current_value; end", "def technically_paid?\n unconfirmed_value_paid >= value_needed\n end", "def good?(value)\n value\n end", "def late?\n returning_at.past? \n end", "def is_benefit_out_of_bal\n @cur_pkg = self.get_latest_effective_package\n #@cur_pkg = self.current_package\n if @cur_pkg != nil\n #if false && @cur_pkg\n @bene_bal = ( self.monthly_benefit.to_f -\n ( self.current_package.calc_hourly_benefit.to_f * self.calc_tot_hours.to_f )\n )\n\n else\n @bene_bal = 0.0000\n end\n if @bene_bal > 0.0005 || @bene_bal < -0.0005\n true\n else\n false\n end\n end", "def min_next_bid_amount\n highest_bid_value = self.highest_bid.bid_amount \n if highest_bid_value.present? \n highest_bid_value+highest_bid_value*0.05\n else\n self.cost\n end\n end", "def can_double_bet\n return 1 unless @bankroll < @bet\n return nil\n end", "def b\n return @b\n end", "def is_in_the_past? \n departureOnThe > returnOnThe \n end", "def positive?; end", "def on? (refresh=true)\n if refresh or @cached_val.nil?\n @cached_val = if @active_high then (self.value != 0) else (self.value == 0) end\n end\n\n @cached_val\n end", "def valor_calorico\n if eficiencia_energetica() < 670\n return 1\n end\n if eficiencia_energetica() > 830\n return 3\n else\n return 2\n end\n end", "def too_low? temp # check if temp is below absolute zero\n temp < 0\nend", "def net_present_value\n lambda do |x|\n relative_payments.reduce(0) do |sum, relative_payment|\n sum + relative_payment.amount * (1 + x)**-relative_payment.offset\n end\n end\n end", "def value?(p0) end", "def value_anneal\n value_anneal_iteration(@iteration)\n end", "def value\n update 0\n @value ? @value : 0.0\n end", "def obtiene_valor_b(a)\n signo1 = get_signo(evaluar_funcion(a))\n return get_signo(evaluar_funcion(a - 1)) != signo1 ? a - 1 : a + 1\n end", "def filled?\n @value.positive?\n end", "def value\n return @value if @value\n\n return @value = 900 if royal_flush?\n return @value = 800 + high_card_bonus if straight_flush?\n return @value = 700 + high_card_bonus if four_of_a_kind?\n return @value = 600 + high_card_bonus if full_house?\n return @value = 500 + high_card_bonus if flush?\n return @value = 400 + high_card_bonus if straight?\n return @value = 300 + high_card_bonus if three_of_a_kind?\n return @value = 200 + high_card_bonus if two_pairs?\n return @value = 100 + high_card_bonus if pair?\n @value = self.cards.map {|card| card.value}.inject(:+)\n end", "def trade_value\n 0.4\n\n end", "def future_expense_checker (record)\n\t\tdate = record.date_paid\n \ttime = date.to_time\n \ttime.future?\n end", "def ayarla(toplam)\n if toplam > 0\n return 1\n else\n return 0\n end\n end", "def value\n return self.actual\n end", "def value\n return self.actual\n end", "def is_set?\n (@value - NEGATIVE) >= 0.5\n end", "def get_last_change\n lastChange ? 'Si' : 'No'\n end", "def future?\n self > self.class.current\n end", "def danger_temp\n 45\n end", "def valorsemaforo\n va = Float(valoractual)\n if va < Float(self.valorfinalrojo)\n 1\n elsif va < Float(self.valorfinalamarillo)\n 2\n else\n 3\n end\n end", "def success?\r\n\treturn true if @fund >= @target_fund\r\n\treturn false if @fund < @target_fund\r\nend", "def is_solvent?\n \t#\n \t@amount_of_loans < (@cash_deposits * @ratio_of_basil_rules - @losses)\n end", "def positive?() @positive==true end", "def value\n @calc.last\n end", "def value?(value) true end", "def borrower_paid_outside_closing\n purchase_credits.where(:name => 'BorrowerPaidOutsideClosing').first.value rescue nil\n end", "def balloon_wait\n return (@battler.nil? ? BALLOON_WAIT : @battler.balloon_wait)\n end", "def current_value\n # Examine the events to determine highest-priority value. Tie-break\n # by using the last one set.\n events_that_set_a_value = events.select(&:value_has_been_set?)\n winning_priority = events_that_set_a_value.map(&:priority).max\n winning_events = events_that_set_a_value.select { |e| e.priority == winning_priority }\n winning_event = winning_events.last # Last for tie-break\n\n if winning_event.nil?\n # No value has been set - return special no value object\n NO_VALUE_SET.new(name)\n else\n winning_event.value # May still be nil\n end\n end", "def made?\n result >= 0\n end", "def value?(value); end", "def value?(value); end", "def present_value\n # Payoff amount = 0, we’re assuming a fully amortizing loan\n payoff_amount = 0\n end", "def is_value?\n true\n end", "def trend_setter?\n self == self.round.first_entry\n end", "def future_expense_checker (record)\n\t\tdate = record.date_incurred\n \ttime = date.to_time\n \ttime.future?\n end", "def value\n @value ||= 1\n end", "def must_have_value?()\n return @df_int == nil\n end", "def value?\n @count > 0\n end", "def real_days_progress_today\n\t\tdays_progresses.at(Date.today).first.try(:real) || dp_days_progress_today[0]\n\tend", "def check_win_or_lose\n return @check_win_or_lose\n end", "def future?\n return if missing?\n\n reference_time < time\n end", "def drink_blood?\n @drank_blood_today\n end", "def actual?\n @actual\n end", "def tt_forever?\n ttend_at == InfinityValue\n end", "def emit_value?\n !mlhs? && !no_value_parent?\n end", "def present_value(rate,periods,future_value)\n present_value = future_value / (1+rate)**periods\n end", "def overdue?\n due < Date.current\n end", "def current?\n active? || past_due?\n end", "def sequential\n return true if hand_to_val.last - hand_to_val.first == 4\n return false \n end", "def extrac_actual\n if(@actual!= nil)\n aux = @actual\n @actual = @actual[:prev]\n @Max-= 1\n var = aux[:value]\n else\n var = nil\n end\n var\n end", "def future_value(rate,periods,present_value,compound_frequency = 1)\n compound_frequency = resolve_compound_frequency!(compound_frequency)\n if compound_frequency == :continuous\n return continuous_compound_fv(rate,periods,present_value)\n end\n future_value = present_value * (1+rate/compound_frequency)** (periods * compound_frequency)\n end", "def future?\n utc.future?\n end", "def make_payment_now_amount\n if payment_owed.positive?\n payment_owed\n elsif workshop_price.payment_price < balance_owed\n workshop_price.payment_price\n else\n balance_owed\n end\n end", "def pending?\n tangible? && pending != 0\n end", "def metodo_biseccion\n i = 0\n c_ant = 0\n c_act = 0\n\n # Valor inicial de A.\n factor = get_signo(@ecuacion.last.to_i) * -1\n a = ((@ecuacion.last.to_i.abs / @ecuacion.first.to_i.abs) ** (1.0/@grado)).to_i * factor;\n b = obtiene_valor_b(a)\n resultado = false\n\n loop do\n i += 1\n c_ant = c_act\n c_act = (a + b)/2.0\n\n if evaluar_funcion(c_act) >= 0\n a = c_act\n else\n b = c_act\n end\n\n if (c_act - c_ant).abs <= 0.001\n resultado = [c_ant, c_act, i]\n end\n\n break if (c_act - c_ant).abs <= 0.001\n end\n return resultado\n end", "def check_balance\n return @balance\n end", "def delivered?\n\t\tinstance_variable_defined? :@value\n\tend", "def still_needed\r\n\t@target_fund - @fund\r\nend", "def unote_finale\n @unote_finale ||= begin\n r = ((unombre_points.to_f / nombre_points_total) * 20).round(1)\n r.to_i != r || r = r.to_i\n r\n end\n end", "def old_value; end", "def decremented_value_of(prev_value)\n @debug ? (prev_value-1) : nil\n end", "def usd_value\n # CBR.ru may not update exchange rate on holidays\n # so the we need the most recent exchange rate up to date.\n # It is assumed here that exchange rate is updated at least once a month\n Time.use_zone('Europe/Moscow') do\n today = Time.zone.now\n date1 = (today-1.month).strftime(\"%d/%m/%Y\")\n date2 = today.strftime(\"%d/%m/%Y\")\n url = \"http://www.cbr.ru/scripts/XML_dynamic.asp?date_req1=#{date1}&date_req2=#{date2}&VAL_NM_RQ=R01235\"\n begin\n page = Net::HTTP::get(URI(url))\n xml = Nokogiri::XML(page)\n val = xml.xpath('//ValCurs//Record//Value').last.content\n m = val.match(/(?<rubl>\\d+)(.|,)(?<cop>\\d+)/)\n BigDecimal(\"#{m[:rubl]}.#{m[:cop]}\")\n rescue StandardError => error\n # rescuing StandardError is a bad practice\n # but for the sake of a simplification\n # we don't care here if it's a timeout, 503 or the response xml is malformed\n nil\n end\n end\n end", "def later?(target_time, ref_time)\n target_time.to_f - ref_time.to_f > 0.01\n end", "def value\n return @value unless @value.nil?\n @value = value_dec == :bool_value_true\n @value\n end", "def delivered?\n\t\t@mutex.synchronize {\n\t\t\tinstance_variable_defined? :@value\n\t\t}\n\tend", "def filled?\n @value > 0\n end", "def fine\n date_of_return = Date.parse(return_date)\n returned_date = Date.parse(user_returned_date)\n date_today = Date.today\n if date_today > date_of_return && returned == false\n fine = (date_today - date_of_return).to_i * 1.00\n return fine\n elsif date_today > date_of_return && returned == true\n fine = (returned_date - date_of_return).to_i * 1.00\n return fine\n else \n return 0.00\n end\n end", "def rest?\n @value < 0\n end", "def reservation_status_then_showdate ; reserved? ? -(showdate.thedate.to_i) : -1.0e15 ; end", "def value; end", "def value; end" ]
[ "0.6748725", "0.66375077", "0.64534223", "0.643141", "0.6367481", "0.6268652", "0.609677", "0.6090259", "0.60746455", "0.6061701", "0.6042729", "0.5998619", "0.5972934", "0.59575474", "0.5951036", "0.59450835", "0.5893244", "0.5877842", "0.5877842", "0.5862989", "0.58574384", "0.5857346", "0.5838072", "0.5831535", "0.58202606", "0.5800463", "0.57799786", "0.57601374", "0.57559085", "0.57458365", "0.574375", "0.5740929", "0.5734362", "0.5733203", "0.5728784", "0.5712834", "0.5711684", "0.5706425", "0.57058346", "0.56960225", "0.5682726", "0.56761366", "0.5673475", "0.5673475", "0.5672123", "0.5668522", "0.56672406", "0.56651753", "0.5664274", "0.56583184", "0.5656177", "0.56471556", "0.5642283", "0.5625156", "0.56026495", "0.55977374", "0.55962896", "0.559623", "0.5593572", "0.5593572", "0.5591693", "0.5588393", "0.5587612", "0.5578431", "0.5576619", "0.55752397", "0.5575207", "0.5572908", "0.55702823", "0.5562186", "0.55521244", "0.55520624", "0.5542607", "0.55425644", "0.55425066", "0.5539824", "0.55383873", "0.5533854", "0.55291945", "0.55223083", "0.55203295", "0.55186206", "0.55132556", "0.55130774", "0.55105513", "0.5505806", "0.5500721", "0.55002546", "0.54956174", "0.5481996", "0.5481791", "0.5475887", "0.5469809", "0.54668677", "0.5466806", "0.5464514", "0.54626787", "0.5462359", "0.5460078", "0.5460078" ]
0.55799085
63
retuns the string what pattern user wants
def to_displayable_string display_status = @is_completed ? "[X]" : "[ ]" display_date = due_today? ? nil : @due_date "#{display_status} #{@text} #{display_date}" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pattern_template\n pattern\n end", "def pattern_template\n pattern\n end", "def pattern\n @pattern\n end", "def pattern_template\n \"*\"\n end", "def to_regex_str\n pattern\n end", "def simplified_pattern\n pattern\n end", "def simplified_pattern\n pattern\n end", "def pattern; end", "def pattern; end", "def pattern; end", "def pattern(default = '')\n return get(:pattern, default)\n end", "def path_string\n pattern\n end", "def show_regexp(string, pattern)\n match = pattern.match(string)\n if match\n \"#{match.pre_match}->#{match[0]}<-#{match.post_match}\"\n else\n \"no match\"\n end\nend", "def exactize pattern\r\n pattern.include?(':') ? \"exact:#{pattern}\" : pattern\r\n end", "def pattern2regex(pattern); end", "def pattern_name\n return nil if (@data[:type].nil? || @data[:subtype].nil?)\n \"#{@data[:type].downcase}_#{@data[:subtype].downcase}\"\n end", "def format_patterns(patterns)\n patterns.collect {|x| \"\\\"fast:#{x}\\\"\"}.join(' ')\nend", "def to_regex_str\n if pattern == \"**\"\n \".*\"\n else\n \"[^/]+\"\n end\n end", "def pattern\n @pattern ||= Pattern.patterns[pattern_name]\n end", "def javascriptify_pattern(pattern)\n pattern.gsub!(/^\\\\A/, '^')\n pattern.gsub!(/\\\\z$/, '$')\n \"/#{pattern}/\"\n end", "def match(pattern); end", "def pattern\n attributes.fetch(:pattern)\n end", "def pattern\n attributes.fetch(:pattern)\n end", "def pattern\n attributes.fetch(:pattern)\n end", "def pattern\n pattern = params[:pattern].to_s\n if pattern.match(/^\\d+$/) &&\n (@project = Project.safe_find(pattern))\n # redirect_to(action: :show, id: project.id)\n set_ivars_for_show\n render(\"show\", location: project_path(@project.id))\n else\n query = create_query(:Project, :pattern_search, pattern: pattern)\n show_selected_projects(query)\n end\n end", "def build_regex_pattern index, pattern_element\n \"^\" + @phone_number[index..(index + pattern_element - 1)].map { |c| \"(#{NUMBER_LETTERS[c].join('|')})\" }.join + \"$\"\n end", "def generate_pattern(pattern)\n plist.dict do\n append_single('begin', pattern.begin)\n append_dictionary('beginCaptures', pattern.begin_captures)\n append_dictionary('captures', pattern.captures)\n append_single('comment', pattern.comment)\n append_single('contentName', pattern.content_name)\n append_single('disabled', 1) if pattern.disabled\n append_single('end', pattern.end)\n append_dictionary('endCaptures', pattern.end_captures)\n append_single('include', pattern.include)\n append_single('match', pattern.match)\n append_single('name', pattern.name)\n append_array('patterns', pattern.patterns)\n end\n end", "def raw(_date, pattern, _length)\n pattern[1...-1]\n end", "def name_inline_pattern( rule_name )\n name = rule_name.is_a?(Name) ? rule_name.name : rule_name\n\n attempt = [\"#{name}__pattern_\", 1]\n attempt[1] += 1 while @pattern_defs.member?(attempt.join(\"\"))\n \n name = attempt.join(\"\")\n return create_name(name)\n end", "def word_pattern(pattern, input)\n \nend", "def pattern(component)\n Parser::CurrentRuby.parse(component)\n .to_s\n .gsub(\"nil\", \"nil?\")\n .delete(\"\\n\")\n .gsub(\" \", \" \")\n end", "def inspect\n \"<Pattern: #{id}>\"\n end", "def name_pattern( base_name, subpattern = false )\n name = base_name.is_a?(Name) ? base_name.name : base_name\n\n if subpattern then\n attempt = [\"#{name}__subpattern_\", 1]\n attempt[1] += 1 while @pattern_defs.member?(attempt.join(\"\"))\n \n name = attempt.join(\"\")\n end\n\n return create_name(name)\n end", "def generate_cscope_pattern(base)\n pattern = base.downcase #in order to do case insensitive matching cscope requires lower case\n return \"^(.* )?#{pattern}\" if pattern.length <= 2\n return \"^(.* )?#{pattern}\"\n #return '^(.* )?p[a-zA-Z0-9]*a'\n end", "def compile_pattern(pattern)\n Regexp.compile(\"\\\\.(#{pattern})$\")\n end", "def patterns; end", "def make_pattern pattern\n state = :close\n rule = ''\n last_ch = ''\n pattern.split('').each do |ch|\n case ch\n when '('\n state = :open\n rule << '('\n when ')'\n state = :close\n rule << ')'\n else\n case state\n when :open\n case last_ch\n when '('\n else\n rule << '|'\n end\n rule << ch\n when :close\n rule << \"[#{ch}]\"\n end\n end\n last_ch = ch\n end\n Regexp.new rule\nend", "def get(route)\n pattern = route.gsub(/:(\\w+)/, '(?<\\1>[^\\\\/]+)')\n puts pattern # => /hello/(?<name>[^\\/]+)\n end", "def short_pattern\n /\n (?:^|\\W) # beginning of string or non-word char\n (?:(#{qualifier_regex})(?:\\s))? # qualifier (optional)\n (?:(#{REPOSITORY_NAME})? # repository name (optional)\n \\#|(?:GH\\-))(\\d+) # issue number\n (?=\n \\.+[ \\t]| # dots followed by space or non-word character\n \\.+$| # dots at end of line\n [^0-9a-zA-Z_.]| # non-word character except dot\n $ # end of line\n )\n /ix\n end", "def pattern\n pattern = params[:pattern].to_s\n loc = Location.safe_find(pattern) if /^\\d+$/.match?(pattern)\n if loc\n redirect_to(location_path(loc.id))\n else\n query = create_query(\n :Location, :pattern_search,\n pattern: Location.user_name(@user, pattern)\n )\n show_selected_locations(query, link_all_sorts: true)\n end\n end", "def state_to_pattern(state)\r\n start = state.min\r\n finish = state.max\r\n pattern = ''\r\n (start..finish).each do |i|\r\n if state.include?(i)\r\n pattern += '#'\r\n else\r\n pattern += '.'\r\n end\r\n end\r\n return pattern\r\nend", "def pattern_params\n params[:pattern]\n end", "def primer_match (primer = \"\")\n match = \"\"\n primer.each_char.each do |base|\n base_array = to_list(base)\n if base_array.size == 1\n match += base_array[0]\n else\n pattern = \"[\" + base_array.join(\"|\") + \"]\"\n match += pattern\n end\n end\n return match\nend", "def path_string\n type == :simple_resource_id ? \"\\#{#{resource_names[0]}}\" : pattern.gsub(\"{\", \"\\#{\")\n end", "def format_for_search(name)\n return unless name\n return name if name.include?('-')\n\n \"#{name}*\"\n end", "def enter_regex\n patt = get_line \"Enter (regex) pattern: \"\n #$patt = gets().chomp\n #$patt = Readline::readline('>', true)\n $patt = patt\n return patt\nend", "def regexp; end", "def regexp; end", "def output_name_from_pattern(t1name)\n file0 = params[:file_args][\"0\"] # we require this single entry for info on the data files\n prefix = file0[:prefix] || \"unkpref\"\n dsid = file0[:dsid] || \"unkdsid\"\n\n pattern = self.params[:output_filename_pattern] || \"\"\n pattern.strip!\n pattern = '{subject}-{cluster}-{task_id}-{run_number}' if pattern.blank?\n\n # Create standard keywords\n now = Time.zone.now\n components = {\n \"date\" => now.strftime(\"%Y-%m-%d\"),\n \"time\" => now.strftime(\"%H:%M:%S\"),\n \"task_id\" => self.id.to_s,\n \"run_number\" => self.run_number.to_s,\n \"cluster\" => self.bourreau.name,\n \"subject\" => dsid,\n \"prefix\" => prefix\n }\n\n # Add {1}, {2} etc keywords from t1 name\n t1_comps = t1name.split(/([a-z0-9]+)/i)\n 1.step(t1_comps.size-1,2) do |i|\n keyword = \"#{(i-1)/2+1}\"\n components[keyword] = t1_comps[i]\n end\n\n # Create new basename\n final = pattern.pattern_substitute(components) # in cbrain_extensions.rb\n\n # Validate it\n cb_error \"Pattern for new filename produces an invalid filename: '#{final}'.\" unless\n Userfile.is_legal_filename?(final)\n\n return final\n end", "def create_pattern(piece)\n Array.new(4,piece).join\n end", "def pattern(value_=nil)\n if value_\n @pattern = value_\n else\n @pattern\n end\n end", "def re; end", "def regex_for(pattern)\n return pattern if Regexp === pattern\n pattern = pattern.split('.') if String === pattern\n\n source = ''\n pattern.each_with_index do |part, index|\n if part == '*'\n source << '\\\\.' unless index == 0\n source << '[^\\.]+'\n elsif part == '#'\n source << '.*?' # .*? ?\n else\n source << '\\\\.' unless index == 0\n source << part\n end\n end\n\n Regexp.new(\"\\\\A#{source}\\\\Z\")\n end", "def extract(pattern); end", "def create_pattern\n self.pattern = pattern.nil? ? first_name.downcase : pattern\n end", "def pattern2regex(pattern)\n tail = pattern\n prefix = String.new\n while !tail.empty? do\n head, sep, tail = tail.partition(/[\\*\\?]/)\n prefix = prefix + Regexp.quote(head)\n case sep\n when '*'\n prefix += '.*'\n when '?'\n prefix += '.'\n when ''\n else\n fail \"Unpexpcted sep:#{sep}\"\n end\n end\n Regexp.new(\"^\" + prefix + \"$\", true)\n end", "def read_to(pattern); end", "def pattern\n return /^[0-9]{5}(?:-[0-9]{4})?$/\n end", "def to_regex_str\n raise \"Not implemented for multivariate ResourceId segments\" if resource_patterns.count > 1\n\n resource_pattern = if resource_patterns[0].nil?\n \"*\"\n else\n resource_patterns[0]\n end\n\n resource_pattern_regex = Gapic::PathPattern::Parser.parse(resource_pattern).to_regex_str\n\n \"(?<#{resource_names[0]}>#{resource_pattern_regex})\"\n end", "def star_pattern(stars_num)\n stars_num == 1 ? '*' : \"*#{' ' * (stars_num - 2)}*\"\nend", "def pattern\n pattern = params[:pattern].to_s\n if pattern.match?(/^\\d+$/) &&\n (herbarium_record = HerbariumRecord.safe_find(pattern))\n redirect_to(herbarium_record_path(herbarium_record.id))\n else\n query = create_query(:HerbariumRecord, :pattern_search, pattern: pattern)\n show_selected_herbarium_records(query)\n end\n end", "def build_edge_pattern(string, index, pattern_length)\n validate_pattern_builder(string.length, pattern_length)\n\n index = tokenized_index(string, index)\n part1 = string[index..string.length]\n part2 = string[0..(index + pattern_length).modulo(string.length) - 1]\n \"#{part1}#{part2}\"\n end", "def build_pattern()\n picking_pattern = { \"repetitions\" => @repetitions }\n\n pattern = \"\"\n (1..@sixteenths_per_measure).each { pattern.concat(\"0,\")}\n picking_pattern[:pattern] = pattern.slice(0..pattern.length - 2)\n\n picking_pattern\n\n end", "def pattern\n pat = params[:pattern].to_s\n if pat.match?(/^\\d+$/) &&\n (collection_number = CollectionNumber.safe_find(pat))\n redirect_to(action: :show, id: collection_number.id)\n else\n query = create_query(:CollectionNumber, :pattern_search, pattern: pat)\n show_selected_collection_numbers(query)\n end\n end", "def name_pattern\n /^#{Regexp.escape(name)}\\s\\d+$/\n end", "def start_word_pattern; end", "def fetch_pattern(type, indentation); end", "def pattern\n Regexp.union(pattern_classifiers.map(&:pattern))\n end", "def start_re; end", "def create_reg_exp(sport)\n sport_regexp = \"\"\n sport_chars = sport.split \"\"\n sport_chars.each_index do |i|\n # regular expression contains substrings of various lengths\n sport_regexp += \"|\" + \"#{sport_chars[i]}#{sport_chars[i + 1]}#{sport_chars[i + 2]}#{sport_chars[i+3]}\" if i < sport.length - 3\n sport_regexp += \"|\" + \"#{sport_chars[i]}#{sport_chars[i + 1]}#{sport_chars[i + 2]}\" if i < sport.length - 2\n sport_regexp += \"|\" + \"#{sport_chars[i]}#{sport_chars[i + 1]}\" if i < sport.length - 1\n sport_regexp += \"|\" + \"#{sport_chars[i]}\" if i < sport.length\n end\n Regexp.new sport_regexp[1, sport_regexp.length]\nend", "def pattern\n segs = @tags.map { |tagged_segment| build_segment(tagged_segment) }\n segs.last.gsub!(/\\.$/, '')\n segs.unshift \"^\"\n segs.push \"\\\\.?$\"\n Regexp.new(segs.join)\n end", "def enter_regex\n print \"Enter pattern: \"\n $patt = gets\n $patt.chomp!\n ctr = 0\nend", "def proper_start str\n return \"_#{str}\" if str.match(/^[0-9]/) \n return str\n end", "def to_s\r\n \"#{wrap}*\"\r\n end", "def tag_pattern\n @tag_pattern || 'v%s'\n end", "def parse_pattern(pattern)\n return pattern if pattern.is_a?(Regexp)\n\n pattern = pattern.split(/\\//).map do |part|\n if /^:/ =~ part\n \"(?<#{part.sub(\":\", \"\")}>\\\\d+)\"\n else\n part\n end\n end.join(\"/\")\n\n Regexp.new(\"^#{pattern}$\")\n end", "def word_pattern\n @emphasis[:word_pattern]\n end", "def url_pattern\n %r{\n (?:^|\\W) # beginning of string or non-word char\n (?:(#{qualifier_regex})(?:\\s))? # qualifier (optional)\n https://github.com/\n (#{REPOSITORY_NAME}) # repository name\n /(?:issues|pulls)/\n (\\d+) # issue number\n (?=\n \\.+[ \\t]| # dots followed by space or non-word character\n \\.+$| # dots at end of line\n [^0-9a-zA-Z_.]| # non-word character except dot\n $ # end of line\n )\n }ix\n end", "def pattern=(_arg0); end", "def pattern(neck = \"\", digits = nil)\n if digits\n if parent\n parent.pattern(@atlas + neck, digits)\n else\n Pattern.new(neck, digits).to_s\n end\n else\n digits = if gethead then gethead else [0] * (depth + 1) end\n pattern('', digits)\n end\n end", "def pattern(base, string)\n pattern = Pattern.new(base, string)\n interval = @midi.interval\n return proc do |b|\n note, duration = pattern[b]\n length = interval * duration - (interval * 0.10)\n play(note, length) if note\n end\n end", "def validate_pattern (pattern)\n\tpattern = \"ABAB\" if pattern.nil? or !PATTERNS.include?(pattern) \n\tp \"======pattern=#{pattern}==\"\n\t@pattern = pattern\nend", "def next_pattern\n return @next_pattern unless @next_pattern.nil?\n return @next_pattern = 2 if @pattern >= 4\n\n chance = @random.int(0..99)\n @next_pattern = Pattern.lookup(@pattern, chance)\n end", "def p(pattern)\n Parslet::Pattern.new(pattern)\n end", "def show_regexp(a, re) \n if a =~ re \n \"#{$`}<<#{$&}>>#{$'}\" \n else \n \"no match - #{a} - #{re}\" \n end \nend", "def to_like(pattern)\n <<~SQL\n REPLACE(REPLACE(REPLACE(#{pattern},\n #{q('%')}, #{q('\\\\%')}),\n #{q('_')}, #{q('\\\\_')}),\n #{q('*')}, #{q('%')})\n SQL\n end", "def token_pattern\n /\\A#{pattern}\\z/\n end", "def build_regex_from_pattern( pattern )\n regex_str = pattern.gsub('/','\\\\/').gsub('+','[^\"\\/\"]+').gsub('\\/#','.*').gsub('#','.*')\n Regexp.new regex_str\n end", "def cmd_list pattern = '.'\n puts \"Following mnemo's #{pattern && \"matching regexp /#{pattern}/\"} are present\"\n puts\n references_by_pattern(pattern).each do |reference|\n puts (\" \" * 4) + reference\n end\n\n puts\n puts \"Done ..\"\n end", "def string(string)\n string.gsub(/\\A(.)(.+?)(.?)\\z/) do |s|\n [\n $1,\n '*' * ($2 ? $2.length : 0),\n $3\n ].join\n end\n end", "def define_regexp\n # Default pattern if there is no tags specified on command line\n if @options[:tags].nil?\n pattern = 'TODO|FIXME'\n else\n # Parse defined tags on command line\n pattern = ''\n tags_names = @options[:tags].split(',')\n tags_names.each do |tag_name|\n pattern << (pattern.empty?) ? \"#{tag_name}\" : \"|#{tag_name}\"\n end\n end\n pattern\n end", "def sr\n underscore.gsub('_', '.?').cpp\n end", "def star(pattern, that, topic, type, index)\n input = pattern.to_s.upcase\n input = input.gsub(/(?=\\S)(\\W)/, \" \").squeeze(\" \").strip\n\n # Normalize 'that' \n formatted_that = that.to_s.upcase\n formatted_that = formatted_that.gsub(/(?=\\S)(\\W)/, \" \").squeeze(\" \").strip\n\n # Normalize 'topic'\n formatted_topic = topic.to_s.upcase\n formatted_topic = formatted_topic.gsub(/(?=\\S)(\\W)/, \" \").squeeze(\" \").strip\n\n match, template = recursive_match input.split(\" \"), formatted_that.split(\" \"), formatted_topic.split(\" \"), @nodemap\n\n return \"\" if template == nil\n\n\n # Find appropriate pattern based on the star type.\n words = nil\n if type == 'star'\n #match = match[0..match.index(THAT)]\n words = input.split(\" \")\n \n elsif type == 'thatstar'\n match = match[(match.index(THAT)+1)..match.index(STAR)]\n words = that.split(\" \")\n \n elsif type == 'topicstar'\n match = match[(match.index(TOPIC)+1)..-1]\n words = topic.split(\" \")\n \n else\n raise \"Star Type must be in ['star', 'thatstar', 'topicstar']\"\n end\n \n # compare the input string to the matched pattern, word by word.\n # At the end of this loop, if found_star is true, start and\n # end will contain the start and end indices (in \"words\") of\n # the substring that the desired star matched.\n \n found_star = false\n start = last = j = num_stars = k = 0\n \n for i in (0...words.count)\n # This condition is true after processing a star\n # that ISN'T the one we're looking for.\n next if i < k\n\n # If we're reached the end of the pattern, we're done.\n break if j == match.count\n\n if not found_star\n if [STAR, UNDERSCORE].include?(match[j]) #we got a star\n num_stars += 1\n \n # This is the star we care about.\n found_star = true if num_stars == index\n \n # Iterate through the rest of the string.\n start = i\n for k in (i...words.count)\n # If the star is at the end of the pattern,\n # we know exactly where it ends.\n if j+1 == match.count\n last = words.count\n break\n end\n # If the words have started matching the\n # pattern again, the star has ended.\n if match[j+1] == words[k]\n last = k - 1\n i = k\n break\n end\n end\n end\n # If we just finished processing the star we cared\n # about, we exit the loop early.\n break if found_star\n end\n # Move to the next element of the pattern.\n j += 1\n end\n \n # extract the star words from the original, unmutilated input.\n if found_star\n if type == 'star'\n response = pattern.split(\" \")\n response = response[start..last]\n return response.join(\" \")\n \n elsif type == 'thatstar'\n response = that.split(\" \")\n response = response[start..last]\n return response.join(\" \")\n\n elsif type == 'topicstar'\n response = topic.split(\" \")\n response = response[start..last]\n return response.join(\" \")\n end\n else \n return \"\"\n end\n end", "def prettify_matcher(matcher)\n matcher.to_s.gsub('_', ' ')\n end", "def preProcess(s)\n n = s.length().to_i\n if n==0\n return \"^$\"\n end\n ret = \"^\"\n (0..n-1).each do |re|\n ret += ('#' + s[re].to_s)\n end\n ret += '#$'\n return ret\nend", "def hide_last_four(string)\n\treturn string.gsub(/(\\d{2})-(\\d{2})-\\d{4}/, '\\1-\\2-****')\nend", "def release_tag_pattern\n\t\tprefix = self.release_tag_prefix\n\t\treturn /#{prefix}\\d+(\\.\\d+)+/\n\tend", "def pattern(**options)\n constraint || \".*?\"\n end", "def pattern( *args )\n return ::Logging::Layouts::Pattern if args.empty?\n ::Logging::Layouts::Pattern.new(*args)\n end", "def ask_search\n str = get_string(\"Enter pattern: \")\n return if str.nil? \n str = @last_regex if str == \"\"\n return if str == \"\"\n ix = next_match str\n return unless ix\n @last_regex = str\n\n @oldindex = @current_index\n @current_index = ix[0]\n @curpos = ix[1]\n ensure_visible\n end", "def end_word_pattern; end" ]
[ "0.69192666", "0.69192666", "0.6883831", "0.6836314", "0.6817363", "0.6809142", "0.6809142", "0.67848635", "0.67848635", "0.67848635", "0.6654333", "0.65936637", "0.64952683", "0.63998526", "0.6375007", "0.6333256", "0.6200795", "0.6169713", "0.6099506", "0.609021", "0.6055356", "0.6054102", "0.6054102", "0.6054102", "0.6013026", "0.600821", "0.59998065", "0.59776217", "0.5938065", "0.5936682", "0.5901686", "0.5870361", "0.58688575", "0.58562267", "0.58548385", "0.5841143", "0.5821933", "0.58009356", "0.57899904", "0.57779956", "0.57768524", "0.5774448", "0.5747561", "0.5734729", "0.57289124", "0.5726655", "0.57175314", "0.57175314", "0.57050616", "0.5702906", "0.56982666", "0.569781", "0.56925714", "0.56762326", "0.5672356", "0.566486", "0.56503385", "0.56423724", "0.56421113", "0.5641527", "0.56318706", "0.56252575", "0.56035596", "0.55934054", "0.5590805", "0.556278", "0.5557531", "0.55513114", "0.5535004", "0.5530556", "0.5525536", "0.54903567", "0.54768884", "0.54632753", "0.54630756", "0.5460281", "0.5453684", "0.5451329", "0.54508317", "0.5420276", "0.5410179", "0.5407546", "0.5397962", "0.53977734", "0.5397769", "0.53952605", "0.5378394", "0.5375491", "0.53743595", "0.5373317", "0.5362342", "0.53615934", "0.5353381", "0.53509486", "0.53464144", "0.53457284", "0.53427094", "0.5339357", "0.5336313", "0.53340125", "0.5328438" ]
0.0
-1
it will push the todo in the todolist
def add(todo) @todos.push(todo) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_todo\n puts\n desc = description('Todo description (required):')\n return if desc.nil?\n due = due_date\n priority = item_priority\n @list.add('todo',desc, { due: due, priority: priority})\n puts\n end", "def add_item_to_list(item)\n @to_do_item.push(item)\n end", "def add(todo)\n @items << Item.new(todo)\n save\n @items.last\n end", "def add_an_item\n item = Item.new\n item.description = \"Task number #{to_do_list.size+1}\"\n to_do_list << item\n end", "def manual_add\n self.metadata[:todos] ||= []\n end", "def addItem(item)\n @toDoListArray.push(item)\n end", "def todo_item_saved\n todo_list_manager.save\n end", "def create\n @todo = @list.todos.build(params[:todo])\n\n if @todo.save\n flash[:notice] = 'To do was successfully created.'\n redirect_to list_path(@list)\n else\n flash[:notice] = \"To do was not created.\"\n render :action => \"new\"\n end\n end", "def create\n @todo_item = @todo_list.todo_items.create(todo_item_params) \n redirect_to @todo_list, notice: \"Todo item added\"\n end", "def push\n end", "def create_list(project_id, list)\n record \"/projects/#{project_id}/todos/create_list\", list\n end", "def push(item)\n end", "def add_items!(items)\n add_items_to_queue!(:todo, items)\n end", "def push\n end", "def create_todo(todo)\n post_params = {\n :body => todo.post_json,\n :headers => Logan::Client.headers.merge({'Content-Type' => 'application/json'})\n }\n \n response = Logan::Client.post \"/projects/#{@project_id}/todolists/#{@id}/todos.json\", post_params\n Logan::Todo.new response\n end", "def add_item(name)\n\t\ttodo_items.push(TodoItem.new(name))\n\tend", "def add_item_to_with_date(item)\n @to_do_with_date.push(item)\n end", "def create\n\t @list = current_user.lists.find(params[:list_id])\n @todo = @list.todos.new(todo_params)\n respond_to do |format|\n if @todo.save\n\t @todo.move_to_top\n format.html { redirect_to list_todos_path, notice: 'Todo was successfully created.' }\n format.json { render action: 'show', status: :created, location: [@list, @todo] }\n\t\t\t\t#format.js { render template: \"todos/create.json.erb\" }\n\t\t\t\tformat.js { render json: { element: render_to_string( partial: 'list', locals: { todo: @todo } ) } }\n else\n format.html { render action: 'new' }\n format.json { render json: @todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_to_my_list(task)\n @my_list << task\n end", "def create(name, description, projectid)\n body = {:name => name, :description => description}\n post(\"projects/#{projectid}/todolists.json\", JSON.generate(body))\n end", "def add_todo(string)\n write_message(:todo, string)\n end", "def push(item); end", "def add(todo)\n if todo.class == Todo\n todos << todo \n else\n begin\n raise TypeError.new(\"Can only add Todo objects\")\n end\n end\n self.todos\n end", "def create_todo_item(name, list_id)\n data = {\n item: {\n name: name\n }\n }\n rest(\"post\", \"lists/#{list_id}/items\", data)\n end", "def push(info)\n\t\tadd(info)\n\tend", "def add(task)\n @list << task\n end", "def move_list(id, to)\n record \"/todos/move_list/#{id}\", :to => to\n end", "def insert(todo)\n todo = Rutodo::Database::Todo.new(\n title: todo.title,\n description: todo.description,\n done: todo.status == :finished\n )\n\n todo.save\n\n todo.as_entity\n end", "def save\n todo = { 'content' => @content, 'id' => @id, 'is_completed' => @is_completed }\n found_todo = Todo.findTodo(@id)\n\n if found_todo.empty?\n @@allTodos.push(todo)\n return Todo.presist_data\n end\n Todo.edit(todo)\n Todo.presist_data\n end", "def create_new_todo(list_id, todo_name)\n sql = \"INSERT INTO todos (name, list_id) VALUES ($1, $2)\"\n query(sql, todo_name, list_id)\n end", "def read_todo\n update\n end", "def create\n @todo = Todo.new(todo_params)\n @todo.task_list_id = @list.id\n respond_to do |format|\n if @todo.save\n format.html { redirect_to @todo, notice: 'Todo was successfully created.' }\n format.json { render :show, status: :created}\n else\n format.html { render :new }\n format.json { render json: @todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @todo_item = @todo_list.todo_items.new(todo_item_params)\n\n if @todo_item.save\n redirect_to @todo_list, notice: 'Todo item was successfully created.'\n else\n redirect_to @todo_list, alert: 'Todo item failed to be created.'\n end\n end", "def create\n @todo_list = current_user.todo_lists.build(todo_list_params)\n @todo_list.unique_id = Time.now.to_f\n\n respond_to do |format|\n if @todo_list.save\n format.html { redirect_to root_path, notice: 'Lista criada com sucesso.' }\n format.json { render :show, status: :created, location: @todo_list }\n else\n format.html { render :new }\n format.json { render json: @todo_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n raise TodoableError.new(\"Must be on new instance.\") if id\n response = Todoable.client.post(self.class.path(list), build_payload)\n assign_attributes_from_response(response)\n list.items << self\n self\n end", "def create\n @todo = @list.todos.new(params[:todo])\n\n respond_to do |format|\n if @todo.save\n format.html { redirect_to list_todo_path(@list, @todo), notice: 'Todo was successfully created.' }\n format.json { render json: @todo, status: :created, location: @todo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def add\n params.require(:task).permit(:title, :body)\n #raise params.inspect\n current_user.tasks.create({title: params[:task][:title], body: params[:task][:body]})\n ActionCable.server.broadcast 'roster_notifications_channel', update: true\n redirect_to roster_url\n end", "def create\n @newtodo = Todo.create(todo_params)\n @newtodo.save\n\n redirect_to todos_path\n end", "def create\n @todo = Todo.new(params[:todo])\n @proj=@todo.proj\n @user = User.find(session[:user])\n respond_to do |format|\n if @todo.save\n UserNotification.deliver_todo_notify(@todo) \n flash[:notice] = 'Todo was successfully created.'\n format.html { redirect_to(proj_todolists_path(@proj)) }\n format.xml { render :xml => @todo, :status => :created, :location => @todo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @todo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_todo\n\t\t\t@list = current_user.lists.find(params[:list_id])\n @todo = @list.todos.find(params[:id])\n end", "def new\n @todo = @list.todos.build\n end", "def create\n @vtodo = Vtodo.new\n @vtodo.summary = params[:vtodo][:summary]\n @vtodo.description = params[:vtodo][:description]\n @vtodo.status = ''\n list = params[:vtodo][:tags].split(\",\").each {|t| t.strip!}\n list.each do |item|\n tag = Tag.new\n tag = Tag.find_or_create_by_subject(item)\n tag.subject = item\n #tag.save \n @vtodo.tags << tag\n end\n\n respond_to do |format|\n if @vtodo.save\n flash[:notice] = 'Vtodo was successfully created.'\n format.html { redirect_to(@vtodo) }\n format.xml { render :xml => @vtodo, :status => :created, :location => @vtodo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @vtodo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def push name='create'\n \n end", "def create\n \t\t@to_do_list = ToDoList.find(params[:to_do_list_id])\n \t@to_do_item = @to_do_list.to_do_items.new(to_do_items_params)\n \n\t if @to_do_item.save\n\t \tflash[:notice] = \"You successfully created a todo item.\"\n\t \tflash[:color]= \"valid\"\n\t \tredirect_to to_do_list_path(@to_do_list)\n\t else\n\t \tflash[:notice] = \"Fail to create a todo item.\"\n\t \tflash[:color]= \"invalid\"\n\t \trender \"/to_do_list/:id/to_do_item/:id/new\"\n\t end\n\n end", "def enqueue(item)\n @todo.push(item) unless @enqueued.include?(item)\n @enqueued.add(item)\n end", "def create\n @task_list = TaskList.find(params[:task_list_id])\n @task = Task.new({ :attributes => params[:task], :task_list => @task_list }) \n \n respond_to do |format|\n if @task.valid? && @task_list.tasks << @task \n add_to_top = params[:task][:add_to_top_of_list] == \"1\" ? true : false\n if add_to_top\n @task.move_to_top\n else\n @task.move_to_bottom\n end\n @task_list.reload\n \n format.html { redirect_to(@task_list, :notice => \"task successfully added to the #{add_to_top ? 'top' : 'bottom'} of the list\") }\n format.xml { render :xml => @task, :status => :created, :location => @task }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @task.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(params, projectid, todolistid)\n\n data = params[:due_at]\n data = Date.parse(data.to_a.sort.collect{|c| c[1]}.join(\"-\"))\n\n body =\n {\n :content => params[:content],\n :due_at => data,\n :assignee =>\n {\n :id => params[:assignee_id],\n :type => params[:assignee_type]\n }\n }\n\n post(\"projects/#{projectid}/todolists/#{todolistid}/todos.json\", JSON.generate(body))\n\n end", "def push(notif)\n\n end", "def create\n @todo = Todo.new(todo_params)\n @todo.user_id = current_user.id\n respond_to do |format|\n if @todo.save\n format.html { redirect_to list_path(@todo.list), notice: 'Todo was successfully created.' }\n format.json { render :show, status: :created, location: @todo }\n else\n format.html { render :new }\n format.json { render json: @todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_item(list_id, content, responsible_party=nil, notify=true)\n record \"/todos/create_item/#{list_id}\",\n :content => content, :responsible_party => responsible_party,\n :notify => notify\n end", "def make_todo(attributes)\n ToDo.create(attributes)\n end", "def add(todo)\n raise TypeError, \"Can only add Todo objects\" unless todo.is_a?(Todo)\n @todos << todo\n end", "def create\n @todo_list = @project.todo_lists.build(params[:todo_list])\n\n respond_to do |format|\n if @todo_list.save\n flash[:notice] = 'TodoList was successfully created.'\n format.html { redirect_to(@project) }\n format.xml { render :xml => @todo_list, :status => :created, :location => @todo_list }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @todo_list.errors, :status => :unprocessable_entity }\n end\n end\n end", "def insert(category,task,priority)\n @todo_container[category] ||= []\n last_task = @todo_container[category].last\n next_index = last_task ? (last_task.index + 1): 0\n @todo_container[category] << OpenStruct.new(:priority => priority, :text => task.gsub(/\\n/,' '), :flag => true,:index => next_index)\n end", "def create\n @task = @list.tasks.build(task_params)\n @task.user = current_user\n @task.save\n redirect_to list_url(@list)\n end", "def create\n @task = @project.tasks.build(params[:task])\n if @task.save\n @task.insert_at # The top of the list.\n respond_to do |format|\n format.html do\n flash[:notice] = 'Task was created.'\n flash[:highlight_dom_id] = dom_id(@task)\n redirect_to project_tasks_path(@project)\n end\n end\n else\n respond_to do |format|\n format.html { render :action => 'new' }\n end\n end\n end", "def create_todo_item(title, description)\n new_item = Todoitem.new\n new_item.title = title\n new_item.description = description\n new_item.save\n end", "def create\n puts \"Olemme create\"\n puts current_user.id\n @todo = Todo.new(todo_params)\n @todo.user_id = current_user.id\n @todo.closed = false\n @todo.created = DateTime.now.to_datetime\n respond_to do |format|\n if @todo.save\n format.html { redirect_to todos_path, notice: 'Tehtävä luotu.' }\n format.json { render :index, status: :created, location: @todo }\n else\n format.html { render :new }\n format.json { render json: @todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def createToDo title, description\n item = Todo.new\n item.title = title\n item.description = description\n item.save\nend", "def create\n @to_do_list = ToDoList.new(params[:to_do_list])\n @to_do_list.user_id = current_user.id\n respond_to do |format|\n if @to_do_list.save\n \tformat.html { \n \tflash[:notice]=\"To do list was successfully created.\"\n \trender 'show'\n }\n format.json { render json: @to_do_list, status: :created, location: @to_do_list }\n else\n format.html { render action: \"new\" }\n format.json { render json: @to_do_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_todo_item\n @todo_list.todo_items.find(:id)\n end", "def make_to_do \n ToDo.create(user_id: @current_user.id, task_id: @selected_task.id, complete?: false, priority_level: @priority_level)\n p \"Congratulations, you've made a new To-Do!\"\n menu \nend", "def call(_obj, args, _ctx)\n Todo.create!(\n title: args[:title],\n description: args[:description],\n )\n end", "def create\n @todo = Todo.new(todo_params)\n @todo.save\n end", "def add task\n\t\t\t@count+=1\n\t\t\t@tasks[@count] = task\n\t\t\tputs \"Added task #{task}.\"\n\t\t\tupdate\n\t\tend", "def add(todo)\n raise TypeError, \"Can only add Todo objects\" unless todo.instance_of?(Todo)\n\n @todos << todo\n end", "def create\n params[:todo] = params[\"todo_\" + params[:id].to_s]\n @todo.user = current_user\n\n if @todo.save\n @status = \"success\"\n @message = \"To-do created successfully.\"\n unless request.xhr?\n flash[:notice] = @message\n redirect_to action: :index\n else\n render @todo\n end\n else\n @status = \"alert\"\n @message = \"To-do could not be created.\"\n unless request.xhr?\n flash[:alert] = @message\n redirect_to :back\n else\n render @todo\n end\n end\n end", "def set_todo\n @todo = Todo.global.find(params[:id])\n end", "def create\n todo_text = params[:todo_text]\n due_date = params[:due_date]\n new_todo = Todo.new(todo_text: todo_text, due_date: due_date, completed: false, user_id: current_user.id)\n new_todo.save\n if new_todo.save\n redirect_to todos_path\n else\n flash[:error] = new_todo.errors.full_messages.join(\" , \")\n redirect_to todos_path\n end\n end", "def create\n @todo = Todo.new(todo_params)\n if params[:todo][:list_id].present?\n @todo.list = List.find(params[:todo][:list_id])\n elsif params[:todo][:list].present?\n @todo.list = List.find(params[:todo][:list].to_i)\n else\n redirect_to root_path, notice: 'Error while adding new todo.'\n end\n\n respond_to do |format|\n if @todo.save\n format.html { redirect_to @todo.list, notice: 'Todo was successfully created.' }\n format.json { render :show, status: :created, location: @todo }\n else\n format.html { redirect_to @todo.list }\n format.json { render json: @todo.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_task_submenu\n\t\tputs \"Enter task to add to list:\"\n\t\tchoice = get_choice\n\t\t@todo_list.add_item choice\n\t\tprint_menu\n\tend", "def test_todo_already_on_list_message\n goal = \"\\\"#{@todo1}\\\" is already on this list.\"\n assert_equal(goal, @list.add(@todo1))\n end", "def venue_marktodo(id, options = {})\n post(\"venues/#{id}/marktodo\").todo\n end", "def set_listtodo\n @listtodo = Listtodo.find(params[:id])\n end", "def move\n item = TodoItem.find(params[:id])\n todo_list = TodoList.find(params[:todo_list_id])\n column = ProjectColumn.find(params[:todo_item][:column_id], todo_list.milestone.project)\n column.add_item(item)\n\n # ReorderTodoItems.create(params)\n if should_reorder_or_reparent_item?(item, column)\n todo_list = TodoList.find(params[:todo_list_id])\n # this 'reparents' a todo item to a new todo list and reorders\n todo_list.reorder_items(ordered_todo_item_ids)\n end\n\n # store activity of our users, to get an idea of how much people are really using wallsome\n activity = TodoItemActivity.new\n activity.user_id = current_user.id\n activity.basecamp_account_id = current_account.id\n activity.save\n\n render :json => item\n rescue ActiveResource::ResourceNotFound\n head 404\n end", "def backend_addTask(param) \n @Tasks.push(param) \n end", "def set_todo\n @todo = @project.todos.find(params[:id])\n end", "def create\n @task = Task.new(params[:task])\n @user = User[params[:user_id]]\n session[:current_tab] = 0\n \n respond_to do |format|\n if @task.save && @user.pending.unshift(@task)\n format.html { redirect_to action: 'index', notice: 'Todo was successfully created.' }\n format.json { render json: @task, status: :created, location: @task }\n else\n format.html { redirect_to action: 'index', error: 'Sorry, the todo could not be saved' }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_empty_record\n \n @todo = Todo.new\n @todo.name= \"New Todo Item\"\n @todo.priority = 100\n @todo.user_id=session[:user_id]\n @todo.todo_list_id=params[:todo_list_id] || 0\n @todo.save\n \n redirect_to(:controller=>:todos, :action=>:edit, :id=>@todo)\n end", "def push(item)\n @items.push(item)\n end", "def todos\n remaining_todos + completed_todos\n end", "def create\n @listtodo = Listtodo.new(listtodo_params)\n\n respond_to do |format|\n if @listtodo.save\n format.html { redirect_to @listtodo, notice: 'Listtodo was successfully created.' }\n format.json { render :show, status: :created, location: @listtodo }\n else\n format.html { render :new }\n format.json { render json: @listtodo.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_tasks(tasklist)\n tasklist.each{ |task| new_task(task)}\n end", "def add(todo)\n begin\n # raise TypeError, \"Can only add Todo objects\" unless todo.class.name == \"Todo\"\n raise TypeError, \"Can only add Todo objects\" unless todo.instance_of?(Todo)\n @todos << todo\n # rescue\n # puts \"invalid class (#{todo.class.name})\"\n end\n end", "def push(x)\n \n end", "def push(x)\n \n end", "def push (nodo)\n raise unless nodo.is_a? (ListNode)\n nodo.prev=@tail\n @tail.next=nodo\n @tail=nodo\n \n end", "def create\n @to_do = ToDo.new(todo_params)\n\n if @to_do.save\n render json: @to_do, status: :created, location: @to_do\n else\n render json: @to_do.errors, status: :unprocessable_entity\n end\n end", "def push(item)\n @items.push(item)\n end", "def push(task)\n fail('Requires implementation')\n end", "def new\n @todo = Todoo.new\n end", "def move_item(id, to)\n record \"/todos/move_item/#{id}\", :to => to\n end", "def create\n @todoit_list = TodoitList.new(todoit_list_params)\n\n respond_to do |format|\n if @todoit_list.save\n format.html { redirect_to @todoit_list, notice: 'Todoit list was successfully created.' }\n format.json { render action: 'show', status: :created, location: @todoit_list }\n else\n format.html { render action: 'new' }\n format.json { render json: @todoit_list.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_task(task)\n\t\t@tasks << task\n\tend", "def add\n # this will not execute because it will not execute the method so instalce variable wont be present in view and it will show error\n # render :index\n #@todo = Todo.create(todo_item:params[:todo_text])\n @todo = Todo.create(todo_item: params[:todo][:todo_item])\n unless @todo.valid?\n flash[:error] = @todo.errors.full_messages.join(\"<br>\").html_safe\n else\n flash[:success] = (\"Todo added successfully \").html_safe\n end\n redirect_to :action => 'index'\n end", "def todo_item_added\n todo_item = todo_list_manager.create_todo_with_content(\"\")\n todo_list_manager.todo_items.unshift(todo_item)\n #table_view.reloadData # empty cell will appear at top of table\n \n table_view.beginUpdates\n indexPathForRow = NSIndexPath.indexPathForRow(0, inSection: 0)\n table_view.insertRowsAtIndexPaths([indexPathForRow], withRowAnimation: UITableViewRowAnimationTop)\n table_view.endUpdates\n \n # enter edit mode\n visible_cells = table_view.visibleCells\n visible_cells.each do |cell|\n if cell.todo_item == todo_item\n edit_cell = cell\n edit_cell.render_label.becomeFirstResponder # user can now type\n break\n end\n end\n \n end", "def set_todo_list\n begin\n @todo_list = current_user.todo_lists.where(project_id: params[:project_id]).find(params[:id])\n rescue => exception\n head 401\n end\n end", "def set_todo\n @todo = Todo.find(params[:id])\n redirect_to login_path unless @todo.list.user == current_user\n end", "def add_task(task)\n @task_list << task\n @combined_list = @due_date_task_list + @task_list\n end", "def create\n @todo_list = TodoList.new(todo_list_params)\n\n respond_to do |format|\n if @todo_list.save\n format.html { redirect_to :back, notice: 'Todo list was successfully created.' }\n format.json { render :show, status: :created, location: :back }\n else\n format.html { render :new }\n format.json { render json: @todo_list.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7107332", "0.7011871", "0.685573", "0.6837604", "0.6781269", "0.67708915", "0.6696298", "0.6645877", "0.6641652", "0.66268045", "0.66237235", "0.6609636", "0.6584491", "0.65521884", "0.6505387", "0.6469069", "0.64397347", "0.6439244", "0.6432675", "0.63712054", "0.63649863", "0.6361751", "0.63410074", "0.6331274", "0.6322184", "0.6321988", "0.6303264", "0.629063", "0.6271058", "0.6267771", "0.6267139", "0.62671036", "0.6256089", "0.62445956", "0.62410426", "0.6216507", "0.6195217", "0.6184982", "0.61742896", "0.61694956", "0.6140588", "0.6139092", "0.6112757", "0.611151", "0.60971785", "0.6096258", "0.6091481", "0.60891706", "0.60875756", "0.6067468", "0.6062715", "0.60563403", "0.6055054", "0.6031221", "0.6027198", "0.602212", "0.60193646", "0.6013313", "0.60121965", "0.6005868", "0.5992558", "0.5988019", "0.5979357", "0.59624267", "0.5951332", "0.59476006", "0.5936555", "0.5917754", "0.589287", "0.5890082", "0.586865", "0.58636355", "0.58597225", "0.5856074", "0.58450353", "0.5842023", "0.58419436", "0.5837282", "0.5836546", "0.58340305", "0.5831013", "0.58238935", "0.5822511", "0.58133805", "0.58052224", "0.58052224", "0.58016515", "0.5801102", "0.57897097", "0.57859457", "0.5784075", "0.57805973", "0.5780185", "0.5765541", "0.5763693", "0.5760601", "0.5752427", "0.5750494", "0.574671", "0.57434624" ]
0.74936455
0
it will return the todolist of overdue
def overdue TodosList.new(@todos.filter { |todo| todo.overdue? }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def client_tasks_overdue\n self.find_all {|e| (e.completed.nil? or !e.completed) and e.complete_by < Time.zone.now }\n end", "def due_later\n TodosList.new(@todos.filter { |todo| todo.due_later? })\n end", "def dueToday\n dueTodayList = \"\"\n @toDoListArray.each do |e|\n if !e.status && e.dueDate == Date.today\n dueTodayList = dueTodayList + e.printItem + \" \"\n end\n end\n dueTodayList\n end", "def due_today\n TodosList.new(@todos.filter { |todo| todo.due_today? })\n end", "def list_overdue\n @checked_out.each do |book|\n book.is_overdue\n end\n \n puts \"The following books are overdue:\"\n @overdue.each { |book| puts \"#{book.title} - #{book.author}\" }\n end", "def due_date_task_list\n @due_date_task_list\n end", "def show_not_completed_date_items\n return @to_do_with_date.select { |x| x.is_done? == false }\n end", "def due_today\n @due_date_task_list.select { |duedatetask| (duedatetask.status == \"incomplete\") && (duedatetask.due_date == Date.today) }\n end", "def not_complete_by_date\n @not_done = show_not_completed_date_items\n return @not_done.sort_by {|x| x.due_date }\n end", "def show_not_completed_items\n return @to_do_item.select { |x| x.is_done? == false }\n end", "def listNotDue\n Todo.where(\"duedate is null\")\nend", "def find_overdue_books\n raise 'The library is not open!' unless @open\n raise 'No member is currently being served' unless @serve\n current_date = calendar.get_date\n\n book_list = @serve.get_books\n book_list.each_index do |n|\n if current_date > book_list[n].get_due_date\n puts \"#{@serve.get_name} #{book_list[n].to_s} \"\n else\n puts 'None'\n end\n end\n end", "def listAllDue\n Todo.where(\"duedate is not null\")\nend", "def selectIncompleteDueDate\n @due_items.select{|item| item.dueToday? && item.done? == 'Item incomplete'}\n end", "def overdue\n schedules.where(:when.lte => Time.now)\n end", "def show_due_tasks\n task = Task.where.not(due_date: nil).all\nend", "def not_completed_due_today\n @not_done = @to_do_with_date.select { |x| x.is_done? == false }\n return @not_done.select { |x| x.due_date == Date.today }\n end", "def incompleteItemsWithAndWithoutDates\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select!{|item| item.done? == 'Item incomplete'}\n @to_do_items.select!{|item| item.done? == 'Item incomplete'}\n @incomplete_array = @due_items.concat(@to_do_items)\n end", "def show_completed_items\n return @to_do_item.select { |x| x.is_done? == true }\n end", "def printNotDone\n notDoneList = \"\"\n @toDoListArray.each do |e|\n if !e.status\n notDoneList = notDoneList + e.printItem + \" \"\n end\n end\n notDoneList\n end", "def selectIncompleteOrderByDate\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select{|item| item.done? == 'Item incomplete'}\n end", "def index\n @todoas = Todoa.where(user_id: current_user.id,done: false).order(\"due, created_at DESC\")\n end", "def is_overdue\n if @due_date\n if ( (Time.now - @due_date) > 0 )\n @status = \"overdue\"\n puts \"#{@title} is overdue! Please return!\"\n else\n days_left = @due_date.yday - Time.now.yday\n puts \"You have #{days_left} days before you need to return #{@title}.\"\n end\n\n else\n puts \"#{@title} has not been checked out.\"\n end \n end", "def todos_remaining(list)\n list[:todos].count { |todo| !todo[:complete] }\n end", "def overdue\n @attributes[:overdue]\n end", "def overdue_books\n borrowed_books.each do |book|\n puts \"#{book.title} was due on #{book.due_date.strftime(\"%B %d, %Y\")}.}\" if book.check_overdue(book.borrower.first)\n end\n end", "def list_not_completed_this_month_date_only\n @due_this_month = not_complete_by_date.select {|x| x.due_date.month == Date.today.month}\n @anniversary_this_month = @anniversary_list.select {|x| x.month == Date.today.month}\n @anniversary_this_month = @anniversary_this_month.sort_by {|x| x.day}\n return @due_this_month + @anniversary_this_month\n end", "def due_tasks\n tasks = []\n\n all_tasks.each do |task|\n due = task.due_date.get\n\n if due.is_a?(Time) && due > Time.new\n tasks << Task.new(task.name.get, due)\n end\n end\n\n # Sorts the array of tasks by due_date\n tasks.sort! { |a,b| a.due_date <=> b.due_date }\n end", "def due(task)\n if !task.completed? && task.due_on\n days = task.due_on - Date.today\n \n css_class = if days > 10\n \"due\"\n elsif days > 5\n \"due_soon\"\n else\n \"due_alarm\"\n end\n \n content = if days == 0\n \"Due today\"\n elsif days < 0\n days *= -1\n \"Overdue #{days} #{days == 1 ? \"day\" : \"days\"}\"\n else\n \"Due in #{days} #{days == 1 ? \"day\" : \"days\"}\"\n end\n \n tag :small, content, :class => css_class\n end\n end", "def list_all_not_completed_this_month\n @due_this_month = not_complete_by_date.select {|x| x.due_date.month == Date.today.month}\n @anniversary_this_month = @anniversary_list.select {|x| x.month == Date.today.month}\n @anniversary_this_month = @anniversary_this_month.sort_by {|x| x.day}\n return @due_this_month + @anniversary_this_month + show_not_completed_items\n end", "def overdue\n @date > Date.today\n end", "def overdue_by\n @overdue_str = \"minutes\"\n \n overdue = (((self.is_due?) ? (Time.zone.now - self.datetime) : (self.datetime - Time.zone.now)) / 60).to_i \n\n if overdue > 60\n overdue /= 60\n @overdue_str = \"hours\"\n if overdue > 24\n overdue /= 24\n @overdue_str = \"days\"\n if overdue > 7\n overdue /= 7\n @overdue_str = \"weeks\"\n if overdue > 4\n overdue /= 4\n @overdue_str = \"months\"\n end\n end\n end\n end\n \n @overdue_str = @overdue_str[0..-2] if overdue == 1\n \n overdue\n end", "def get_unfinished_todos\n return Todo.where({\"user_id\" => self.id, \"completed\" => false})\n end", "def sort_due_date_incomplete\n @due_date_task_list.sort! { |duedatetask1, duedatetask2| duedatetask1.due_date <=> duedatetask2.due_date }\n @due_date_task_list.select { |duedatetask| (duedatetask.status == \"incomplete\") }\n end", "def allItemsIncompleteAndYearlyAndDue\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select!{|item| item.done? == 'Item incomplete'}\n @anniversary_items.select!{|item| item.month}\n @to_do_items.select!{|item| item.done? == 'Item incomplete'}\n @incomplete_and_month = @due_items.concat(@anniversary_items)\n @incomplete_and_month_and_no_date = @incomplete_and_month.concat(@to_do_items)\n end", "def to_do_items\n return @to_do_item\n end", "def todos\n remaining_todos + completed_todos\n end", "def show\n @task = Task.where(todo_list_id: params[:id]).order('status DESC').order('due_date').page(params[:page]).per(5)\n @task.each do |t| \n diff = (t.due_date - Date.today).to_i\n t.due_date = convert_due_date(diff)\n end\n end", "def index\n @overdue = current_user.tasks.overdue\n @today = current_user.tasks.incomplete.due_to_today\n @week = week\n @next_week = next_week\n @later = current_user.tasks.incomplete.due_to_later\n \n @empty = (@overdue + @today + @week + @next_week + @later).size == 0\n \n @incomplete = current_user.tasks.incomplete\n \n respond_with @tasks\n end", "def overdue?\n Date.today > to_date\n end", "def show_due_today\n task = Task.where(due_date: Date.today).all\nend", "def overdue?\r\n @overdue = Time.now > @due_date\r\n end", "def sort_all_incomplete\n @due_date_task_list.sort! { |duedatetask1, duedatetask2| duedatetask1.due_date <=> duedatetask2.due_date }\n @combined_list = @due_date_task_list + @task_list\n @combined_list.select { |duedatetask| (duedatetask.status == \"incomplete\") }\n end", "def index\n @date = params[:date] ? Time.parse(params[:date]).in_time_zone : Time.zone.now\n @start = @date.beginning_of_day.in_time_zone\n @finish = @date.end_of_day.in_time_zone\n @tense = determine_tense @date\n @day_name = @start == @now.beginning_of_day ? \"Today\" : @start.strftime(\"%a, %b %-d\")\n \n @tasks = case @tense\n when \"past\"\n @member.tasks.where(\"(complete = :false and due_at >= :start and due_at <= :finish) or (complete = :true and completed_at >= :start and completed_at <= :finish)\", \n true: true,\n false: false,\n nil: nil,\n start: @start,\n finish: @finish\n )\n when \"present\", \"future\"\n @member.tasks.where(\"(due_at is :nil and complete = :false) or (complete = :false and due_at is not :nil and due_at >= :start and due_at <= :finish) or (complete = :true and completed_at is not :nil and completed_at >= :start and completed_at <= :finish)\",\n true: true,\n false: false,\n nil: nil,\n start: @start,\n finish: @finish\n )\n end\n \n @incomplete = @member.tasks.where(\"due_at < ?\", @start).incomplete.by_ordinal.order(:due_at).group_by{ |t| p t.due_at.to_date }\n @complete = @tasks.complete.by_completed_at\n end", "def get_tasks_from_todoist\n return Todoist::Task.uncompleted(PROGRAMMING_PROJECT_ID)\n end", "def selectIncomplete\n @to_do_items.select {|item| item.done? == 'Item incomplete'}\n end", "def index\n @duelists = Duelist.all\n end", "def completed_todos\n todos.completed.order('completed_time DESC')\n end", "def overdue_by\n @overdue_str = \"minutes\"\n @overdue_or_left = \"expired\"\n \n return \"never expires\" if self.expiration_date.nil?\n overdue = (Time.zone.now - self.expiration_date.to_datetime)\n \n if (overdue < 0)\n overdue *= -1\n @overdue_or_left = \"left\"\n end\n \n overdue /= 60\n \n if overdue > 60\n overdue /= 60\n @overdue_str = \"hours\"\n if overdue > 24\n overdue /= 24\n @overdue_str = \"days\"\n if overdue > 7\n overdue /= 7\n @overdue_str = \"weeks\"\n if overdue > 4\n overdue /= 4\n @overdue_str = \"months\"\n if overdue > 12\n overdue /= 12\n @overdue_str = \"yrs\"\n end\n end\n end\n end\n end\n \n @overdue_str = @overdue_str[0..-2] if overdue == 1\n \n overdue.round\n end", "def is_overdue\r\n\t\tif (Time.now).to_i > book.due_date && book.status == \"Checked Out\"\r\n\t\t\tbook.status = \"Overdue\"\r\n\t\t\tputs \"#{book.title} is overdue!\"\r\n\t\telsif book.status == \"Avalable\"\r\n\t\t\tputs \"#{book.title} is available.\"\r\n\t\telse\r\n\t\t\tputs \"#{book.title} is checked out but not overdue.\"\r\n\t\tend\r\n\tend", "def show_no_date\n task = Task.where(due_date: nil).all\nend", "def index\n @todo_items = TodoItem.all\n \n \n # Collect completed tasks\n # block starts ============================\n complete = []\n @todo_items.each do |item|\n if item[:complete] == true\n complete << item \n end\n end\n # block ends ============================\n\n @completed_items = complete.count\n @all_items = @todo_items.count\n\n # Define percentage of completed tasks\n # block starts ============================\n if @all_items > 0\n percentage = (@completed_items).to_f/(@all_items).to_f * 100\n @progress = \"#{percentage}%\"\n end\n # block ends ============================\n\n\n # Define high priority items. Priority are items that are due today.\n\n priority = []\n @todo_items.each do |item|\n today = Date.today.to_s\n if item[:due].to_s == today\n priority << item\n end\n end\n\n @todays_tasks = priority.map(&:task)\n\n\n tomorrow_array = []\n @todo_items.each do |item|\n tomorrow = Date.tomorrow.to_s\n if item[:due].to_s == tomorrow\n tomorrow_array << item\n end\n end\n\n @tomorrows_tasks = tomorrow_array.map(&:task)\n\n end", "def overdue?\n @due_date < Date.today\n end", "def overdue? ()\n\t\t@due_date < Time.now\n end", "def show_not_completed_by_date_first\n @not_done_date = not_complete_by_date\n @not_done = show_not_completed_items\n return @not_done_date + @not_done\n end", "def tasks_uncompleted\n tasks_uncompleted = assigned_tasks.uncompleted.order(\"deadline DESC\")\n tasks_uncompleted += executed_tasks.uncompleted.order(\"deadline DESC\")\n tasks_uncompleted.sort_by { |h| h[:deadline] }.reverse!\n end", "def overdue_by_str\n \"#{self.overdue_by} #{@overdue_str}\"\n end", "def my_todos\r\n\t\t\t\t\tself.authored_todos | self.assigned_todos\r\n\t\t\t\tend", "def get_all_withassigned(projectid)\n get(\"projects/#{projectid}/assigned_todos.json\")\n end", "def index\n @todo_items = @todo_list.todo_items.all.order(\"completed ASC\") \n end", "def printDone\n doneList = \"\"\n @toDoListArray.each do |e|\n if e.status\n doneList = doneList + e.printItem + \" \"\n end\n end\n doneList\n end", "def get_incomplete\n @task_list.select { |task| task.status == \"incomplete\" }\n end", "def today\n tod = Time.now.strftime(\"%Y-%m-%d\")\n @tasks.each do |project_name, project_tasks|\n project_tasks.each do |task|\n if task.deadline.to_s == tod\n puts task.description\n end\n end\n end\n end", "def itemsOfThisMonth\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select!{|item| item.done? == 'Item incomplete'}\n @anniversary_items.select!{|item| item.month}\n @incomplete_and_month = @due_items.concat(@anniversary_items)\n end", "def overdue?\n due < Date.current\n end", "def get_opportunity_followup_overdue(cid, eid)\n get_my_overdue_opportunity(cid, eid)\n end", "def incomplete_tasks\n sublist { |task| task.incomplete? }.sort_by { |task| task.created_at }\n end", "def remaining_todos\n if @remaining_todos.empty? && @remaining_count > 0\n refresh\n end\n \n return @remaining_todos\n end", "def items_list\n #return self.donor.donor_items.reject{|it| it.done?}.map{|it| \" #{it.andand.item.andand.item_code} [#{it.number_donated}] \" << (it.comments.blank? ? \"\" : \"(#{it.comments}) \")}.join(\"<b>/</b>\") if (self.pickup_or_delivery == PICKUP) && self.donor\n if (self.pickup_or_delivery == PICKUP)\n the_pickup = (self.donor_pickup ? self.donor_pickup : self.donor.andand.donor_pickups.andand.first)\n return '' unless the_pickup\n \n return \"\" unless self.daily_worksheet.andand.worksheet_date\n \n # show items we've already picked up, if the current date is newer than the date of this \"DailyDelivery\"\n # TODO: make sure this date comparison works properly\n items_to_show = ((Time.now.beginning_of_day > Time.parse(self.daily_worksheet.worksheet_date.to_s)) ? the_pickup.pickedup_items_list : the_pickup.offered_items_list)\n return items_to_show\n #return items_to_show.reject{|it| it.done?}.map{|it| \" #{it.andand.item.andand.item_code} [#{it.number_offered}] \" << (it.comments.blank? ? \"\" : \"(#{it.comments}) \")}.join(\"<b>/</b>\")\n elsif ((self.pickup_or_delivery == DELIVERY) and self.delivery)\n # was delivered_items.reject{|it| it.done?}\n return self.delivery.delivered_items.still_to_deliver.ordered_by_item_category.map{|it| \" #{it.andand.item.andand.item_code} [#{it.number_requested}] \" << (it.comments.blank? ? \"\" : \"(#{it.comments}) \")}.join(\"<b>/</b>\")\n end\n end", "def all_not_done\n self.select { |todo| !todo.done? }\n end", "def todo\n sort :task_occurrence, default_column: :deadline, default_direction: :desc\n add_crumb t('breadcrumbs.todos'), community_schedule_todo_path(@community)\n @task_occurrences = @community.task_occurrences.for_user_or_open(@user).todo.order(sort_column + ' ' + sort_direction).paginate(page: params[:page],per_page: 20)\n end", "def all_incomplete_todos\n (global_incomplete_todos + local_incomplete_todos).uniq\n end", "def add_due_date_task(duedatetask)\n @due_date_task_list << duedatetask\n @combined_list = @due_date_task_list + @task_list\n end", "def final_due_date\n del = self.deliverables\n return nil unless del.size > 0\n\n dates = del.collect(&:due).delete_if { |d| d.blank?}\n \n return dates.sort[-1] \n end", "def my_todos(project_id, body)\n body.css('stories > story').select do |s|\n s.css('owned_by').text == OWNER\n end.inject({}) do |tasks, s|\n state = map_state s.css('current_state').text\n tasks[state] ||= []\n tasks[state] << s\n tasks\n end.map do |priority_group, stories|\n stories.map{|s| format_todotxt project_id, priority_group, s}\n end.flatten\nend", "def todo_list\n TodoList.find_by(user_id: current_user['sub'])\n end", "def overdue?\n return true if @past_due\n false\n end", "def completed_tasks_by_date(list,date)\n # helpers.is_today?(date)\n if (Date.today == date)\n if (list.id == self.all_task.id)\n self.completed_tasks.where([\"DATE(completed_at)=?\", date] ).order('completed_at')\n # self.completed_tasks.where([\"DATE(completed_at) BETWEEN ? AND ?\", date - 1.day , date] ).order('completed_at')\n else\n self.completed_tasks.where([\"list_id=? and DATE(completed_at)=?\",list.id, date] ).order('completed_at DESC')\n # self.completed_tasks.where([\"list_id=? and DATE(completed_at) BETWEEN ? AND ?\",list.id, date - 1.day , date] ).order('completed_at DESC')\n end\n\n else\n if (list.id == self.all_task.id)\n self.completed_tasks.where([\"DATE(completed_at) =?\",date] ).order('completed_at DESC')\n # self.completed_tasks.where([\"DATE(completed_at) =?\",date - 1.day] ).order('completed_at DESC')\n else\n self.completed_tasks.where([\"list_id=? and DATE(completed_at) =?\",list.id, date] ).order('completed_at DESC')\n # self.completed_tasks.where([\"list_id=? and DATE(completed_at) =?\",list.id, date - 1.day] ).order('completed_at DESC')\n end\n\n end\n end", "def tickler_todos\n todos.ticklers.order('completed_time DESC')\n end", "def client_tasks_open\n self.find_all {|e| e.completed.nil? or !e.completed }\n end", "def tasks_expired_warning\n user = User.joins(:tasks).take\n\n NotifierMailer.tasks_expired_warning user, user.tasks.limit(3)\n end", "def due_status(date)\n return :none if date.nil?\n\n days = (date - today).to_i\n\n if days > 1\n days -= 1 if today.saturday?\n days -= 2 if today.friday?\n end\n\n if days > 1\n :not_yet_due\n elsif days == 1\n :upcoming\n elsif days == 0\n :due\n else\n :overdue\n end\n end", "def index\n @due_dates = DueDate.all\n end", "def unread_tasks\n notifications = current_user.notifications.unread\n notifications += current_user.task_owners.unread\n \n tasks = notifications.map { |n| n.task }\n tasks = tasks.uniq\n # only get open / in progress tasks\n tasks = tasks.select { |t| (t.status == 0 or t.status == 1) }\n\n return tasks\n end", "def client_tasks_closed\n self.find_all {|e| e.completed }\n end", "def selectComplete\n @to_do_items.select {|item| item.done? == 'Item complete'}\n end", "def due_date_chaser(user)\n @user = user\n # Checks if the time difference in days is between 0 and 1.\n \n # Toggle the 0..0 range if you want to change. 0..0 is 24 hours, 0..1 is 48 hours....\n @items = Item.where(user_id: @user.id).where(completed: false).where.not(due_date: nil).select {|v| (0..0).include?((DateTime.parse(v.due_date) - DateTime.current()).to_i) }\n @url = 'https://fergus-cvwo.netlify.app/'\n if @items != []\n mail(to: @user.email, subject: 'You have tasks due in 24 hours!')\n end\n end", "def not_completed_all_by_month\n #calls the not_completed function to hopefully set a not_completed_with_date list containing a sorted list of tasks that HAVE dates\n not_completed\n return_list = []\n #check if each item in the list is in the current month\n @not_completed_with_date.each do |a|\n b = Date.strptime(\"#{a.date}\")\n if b.mon == Date.today.mon\n return_list << a\n end\n end\n return_list\n end", "def get_completed(projectid)\n get(\"projects/#{projectid}/todolists/completed.json\")\n end", "def send_overdue_notice(notice)\n p \"Reminder #{get_name} #{notice}\"\n end", "def send_overdue_notice(notice)\n p \"Reminder #{get_name} #{notice}\"\n end", "def add_todo\n puts\n desc = description('Todo description (required):')\n return if desc.nil?\n due = due_date\n priority = item_priority\n @list.add('todo',desc, { due: due, priority: priority})\n puts\n end", "def index\n @holidaytask = User.find(current_user.id).holidaytasks\n \n end", "def list_tasks\r\n unless tasks\r\n puts \"No tasks yet. Add one!\"\r\n return\r\n end\r\n # Pretty-format hash and print\r\n print \" \" + \"ITEM\".ljust(30) + \" | \" +\r\n \"WHEN DUE\".ljust(15) + \" | \" +\r\n \"WHEN ADDED\".ljust(15) + \"\\n\"\r\n tasks.each do |task|\r\n print \"<#{tasks.find_index(task) + 1}>\".ljust(5) +\r\n task[:text].ljust(30) + \" | \" +\r\n task[:due].ljust(15) + \" | \" +\r\n task[:time].ljust(15) + \"\\n\"\r\n end\r\n end", "def overdue?(test)\r\n\t\tif self.overdue.present?\r\n\t\t\tself.overdue.overdue?(test)\r\n\t\telse\r\n\t\t\tfalse\r\n\t\tend\r\n\tend", "def check_over_due\n time = Time.now\n @time_table.each{ |book, date|\n if date <= time\n puts \"Bro #{book} is overdue\"\n @overdue = true\n end\n }\n end", "def week\n @todoas = Todoa.where(user_id: current_user.id,done: false).where('due BETWEEN ? AND ?', Date.today, Date.today + 7.day)\n end", "def coming_due_events\n candidate_events.select(&:coming_due?)\n end", "def show\n @tasks=@list.tasks.where.not(\"estado = ?\",\"expirada\").order(:prioridad)\n end", "def incomplete_tasks\n # Give me all the tasks such that the task is incomplete\n @tasks.select { |task| task.incomplete? }.sort_by { |task| task.created_at }\n end" ]
[ "0.7387114", "0.7348554", "0.72605664", "0.7171583", "0.7082553", "0.707628", "0.7039311", "0.6990257", "0.6685462", "0.6665459", "0.6647593", "0.6630727", "0.65986794", "0.6557406", "0.6529509", "0.6522506", "0.6505251", "0.64968306", "0.6437389", "0.6434519", "0.64197487", "0.6413661", "0.6400112", "0.6360192", "0.63551134", "0.63359976", "0.6308587", "0.63071597", "0.630542", "0.6290288", "0.6266838", "0.6219729", "0.6151355", "0.6147967", "0.6143353", "0.6121711", "0.61021286", "0.6088523", "0.60783327", "0.60603225", "0.60579413", "0.60389715", "0.60245204", "0.6011895", "0.6011573", "0.60087", "0.60046875", "0.60001236", "0.5978453", "0.596833", "0.59610295", "0.5933027", "0.59292334", "0.59154046", "0.59108496", "0.5893401", "0.586945", "0.58505356", "0.5845541", "0.583092", "0.58281255", "0.5806605", "0.58034354", "0.5798215", "0.579615", "0.5792213", "0.5791057", "0.5788717", "0.57873845", "0.57835454", "0.5774806", "0.5774134", "0.57670844", "0.5750314", "0.574646", "0.5739415", "0.57304955", "0.5714219", "0.5707688", "0.5706329", "0.5696606", "0.5682943", "0.56785625", "0.5677057", "0.5672166", "0.56515765", "0.56443065", "0.56416357", "0.563692", "0.56349206", "0.56349206", "0.56337005", "0.5633161", "0.56318474", "0.5623006", "0.5619449", "0.56127405", "0.56112623", "0.56109154", "0.5606753" ]
0.83248234
0
it will return the todolist of duetoday
def due_today TodosList.new(@todos.filter { |todo| todo.due_today? }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dueToday\n dueTodayList = \"\"\n @toDoListArray.each do |e|\n if !e.status && e.dueDate == Date.today\n dueTodayList = dueTodayList + e.printItem + \" \"\n end\n end\n dueTodayList\n end", "def due_later\n TodosList.new(@todos.filter { |todo| todo.due_later? })\n end", "def due_date_task_list\n @due_date_task_list\n end", "def due_today\n @due_date_task_list.select { |duedatetask| (duedatetask.status == \"incomplete\") && (duedatetask.due_date == Date.today) }\n end", "def overdue\n TodosList.new(@todos.filter { |todo| todo.overdue? })\n end", "def show_due_today\n task = Task.where(due_date: Date.today).all\nend", "def listAllDue\n Todo.where(\"duedate is not null\")\nend", "def today\n tod = Time.now.strftime(\"%Y-%m-%d\")\n @tasks.each do |project_name, project_tasks|\n project_tasks.each do |task|\n if task.deadline.to_s == tod\n puts task.description\n end\n end\n end\n end", "def show\n @task = Task.where(todo_list_id: params[:id]).order('status DESC').order('due_date').page(params[:page]).per(5)\n @task.each do |t| \n diff = (t.due_date - Date.today).to_i\n t.due_date = convert_due_date(diff)\n end\n end", "def show_not_completed_date_items\n return @to_do_with_date.select { |x| x.is_done? == false }\n end", "def not_completed_due_today\n @not_done = @to_do_with_date.select { |x| x.is_done? == false }\n return @not_done.select { |x| x.due_date == Date.today }\n end", "def listNotDue\n Todo.where(\"duedate is null\")\nend", "def index\n @todoas = Todoa.where(user_id: current_user.id,done: false).order(\"due, created_at DESC\")\n end", "def due_tasks\n tasks = []\n\n all_tasks.each do |task|\n due = task.due_date.get\n\n if due.is_a?(Time) && due > Time.new\n tasks << Task.new(task.name.get, due)\n end\n end\n\n # Sorts the array of tasks by due_date\n tasks.sort! { |a,b| a.due_date <=> b.due_date }\n end", "def list_not_completed_this_month_date_only\n @due_this_month = not_complete_by_date.select {|x| x.due_date.month == Date.today.month}\n @anniversary_this_month = @anniversary_list.select {|x| x.month == Date.today.month}\n @anniversary_this_month = @anniversary_this_month.sort_by {|x| x.day}\n return @due_this_month + @anniversary_this_month\n end", "def show_due_tasks\n task = Task.where.not(due_date: nil).all\nend", "def selectIncompleteDueDate\n @due_items.select{|item| item.dueToday? && item.done? == 'Item incomplete'}\n end", "def not_complete_by_date\n @not_done = show_not_completed_date_items\n return @not_done.sort_by {|x| x.due_date }\n end", "def completed_tasks_by_date(list,date)\n # helpers.is_today?(date)\n if (Date.today == date)\n if (list.id == self.all_task.id)\n self.completed_tasks.where([\"DATE(completed_at)=?\", date] ).order('completed_at')\n # self.completed_tasks.where([\"DATE(completed_at) BETWEEN ? AND ?\", date - 1.day , date] ).order('completed_at')\n else\n self.completed_tasks.where([\"list_id=? and DATE(completed_at)=?\",list.id, date] ).order('completed_at DESC')\n # self.completed_tasks.where([\"list_id=? and DATE(completed_at) BETWEEN ? AND ?\",list.id, date - 1.day , date] ).order('completed_at DESC')\n end\n\n else\n if (list.id == self.all_task.id)\n self.completed_tasks.where([\"DATE(completed_at) =?\",date] ).order('completed_at DESC')\n # self.completed_tasks.where([\"DATE(completed_at) =?\",date - 1.day] ).order('completed_at DESC')\n else\n self.completed_tasks.where([\"list_id=? and DATE(completed_at) =?\",list.id, date] ).order('completed_at DESC')\n # self.completed_tasks.where([\"list_id=? and DATE(completed_at) =?\",list.id, date - 1.day] ).order('completed_at DESC')\n end\n\n end\n end", "def due_date\n created_at + Spree::BilletConfig.due_date.days\n end", "def todos\n remaining_todos + completed_todos\n end", "def week\n @todoas = Todoa.where(user_id: current_user.id,done: false).where('due BETWEEN ? AND ?', Date.today, Date.today + 7.day)\n end", "def index\n @due_dates = DueDate.all\n end", "def list_all_not_completed_this_month\n @due_this_month = not_complete_by_date.select {|x| x.due_date.month == Date.today.month}\n @anniversary_this_month = @anniversary_list.select {|x| x.month == Date.today.month}\n @anniversary_this_month = @anniversary_this_month.sort_by {|x| x.day}\n return @due_this_month + @anniversary_this_month + show_not_completed_items\n end", "def book_due_dates\n borrowed_books.each { |book| puts \"#{book.title} checked out by #{book.borrower.first.name}. Due date: #{book.due_date.strftime(\"%B %d, %Y\")}.\"}\n end", "def due(task)\n if !task.completed? && task.due_on\n days = task.due_on - Date.today\n \n css_class = if days > 10\n \"due\"\n elsif days > 5\n \"due_soon\"\n else\n \"due_alarm\"\n end\n \n content = if days == 0\n \"Due today\"\n elsif days < 0\n days *= -1\n \"Overdue #{days} #{days == 1 ? \"day\" : \"days\"}\"\n else\n \"Due in #{days} #{days == 1 ? \"day\" : \"days\"}\"\n end\n \n tag :small, content, :class => css_class\n end\n end", "def client_tasks_overdue\n self.find_all {|e| (e.completed.nil? or !e.completed) and e.complete_by < Time.zone.now }\n end", "def todo_msg_today; \"today\"; end", "def due_date_chaser(user)\n @user = user\n # Checks if the time difference in days is between 0 and 1.\n \n # Toggle the 0..0 range if you want to change. 0..0 is 24 hours, 0..1 is 48 hours....\n @items = Item.where(user_id: @user.id).where(completed: false).where.not(due_date: nil).select {|v| (0..0).include?((DateTime.parse(v.due_date) - DateTime.current()).to_i) }\n @url = 'https://fergus-cvwo.netlify.app/'\n if @items != []\n mail(to: @user.email, subject: 'You have tasks due in 24 hours!')\n end\n end", "def due_date(due)\n return DateLabelHelper::DueDateView.new(due, prefs).due_date_html\n end", "def show_no_date\n task = Task.where(due_date: nil).all\nend", "def tasks_data_today \n tasks_of_today = self.tasks_due_today\n tasks = []\n tasks_of_today.each do |task|\n task = {\n task_name: task.name, \n completion_value: task.completions.last.completion_value,\n completion_max: task.completion_max,\n completion_unit: task.completion_unit\n }\n tasks << task \n end\n tasks \n end", "def tickler_todos\n todos.ticklers.order('completed_time DESC')\n end", "def due_date\n @due_date\n end", "def completed_todos\n todos.completed.order('completed_time DESC')\n end", "def index\n @duelists = Duelist.all\n end", "def is_past_due?(current_day)\n # compare the current day to the @due_date\n days_of_week = [\n \"Sunday\",\n \"Monday\",\n \"Tuesday\",\n \"Wednesday\",\n \"Thursday\",\n \"Friday\",\n \"Saturday\"\n ]\n # if no tasks on the list\n if @list.values.all? { |tasks| tasks.empty? } # goes through all the values and verifies that all of them meet a specific condition that we passed to the block and all the values are tasks which are arrays. Use built in method empty which will return true or false. Verifies if any of the tasks or our arrays return false that they are not empty\n # isn't past due, return false\n puts \"You have completed all the tasks on your list!\"\n false\n # elsif the current day is past the @due_date\n elsif days_of_week.index(@due_date) < days_of_week.index(current_day) # Where is due date in array of days of week? Using .index on an array will return the fixnum index of the due date\n # yes, it is past due. return true\n puts \"You still have tasks to complete and they were due on #{@due_date}!\"\n true\n # else the current day is before the @due_date\n else\n # return false\n puts \"You still have until #{@due_date} to complete these tasks.\"\n false\n end\n end", "def not_completed_all_by_month\n #calls the not_completed function to hopefully set a not_completed_with_date list containing a sorted list of tasks that HAVE dates\n not_completed\n return_list = []\n #check if each item in the list is in the current month\n @not_completed_with_date.each do |a|\n b = Date.strptime(\"#{a.date}\")\n if b.mon == Date.today.mon\n return_list << a\n end\n end\n return_list\n end", "def find_overdue_books\n raise 'The library is not open!' unless @open\n raise 'No member is currently being served' unless @serve\n current_date = calendar.get_date\n\n book_list = @serve.get_books\n book_list.each_index do |n|\n if current_date > book_list[n].get_due_date\n puts \"#{@serve.get_name} #{book_list[n].to_s} \"\n else\n puts 'None'\n end\n end\n end", "def selectIncompleteOrderByDate\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select{|item| item.done? == 'Item incomplete'}\n end", "def overdue\n @date > Date.today\n end", "def due_date\n return @due_date\n end", "def get_due_date()\n @due_date\n end", "def\n get_due_date()\n @due_date\n end", "def index\n @date = params[:date] ? Time.parse(params[:date]).in_time_zone : Time.zone.now\n @start = @date.beginning_of_day.in_time_zone\n @finish = @date.end_of_day.in_time_zone\n @tense = determine_tense @date\n @day_name = @start == @now.beginning_of_day ? \"Today\" : @start.strftime(\"%a, %b %-d\")\n \n @tasks = case @tense\n when \"past\"\n @member.tasks.where(\"(complete = :false and due_at >= :start and due_at <= :finish) or (complete = :true and completed_at >= :start and completed_at <= :finish)\", \n true: true,\n false: false,\n nil: nil,\n start: @start,\n finish: @finish\n )\n when \"present\", \"future\"\n @member.tasks.where(\"(due_at is :nil and complete = :false) or (complete = :false and due_at is not :nil and due_at >= :start and due_at <= :finish) or (complete = :true and completed_at is not :nil and completed_at >= :start and completed_at <= :finish)\",\n true: true,\n false: false,\n nil: nil,\n start: @start,\n finish: @finish\n )\n end\n \n @incomplete = @member.tasks.where(\"due_at < ?\", @start).incomplete.by_ordinal.order(:due_at).group_by{ |t| p t.due_at.to_date }\n @complete = @tasks.complete.by_completed_at\n end", "def show_not_completed_by_date_first\n @not_done_date = not_complete_by_date\n @not_done = show_not_completed_items\n return @not_done_date + @not_done\n end", "def to_do_items\n return @to_do_item\n end", "def final_due_date\n del = self.deliverables\n return nil unless del.size > 0\n\n dates = del.collect(&:due).delete_if { |d| d.blank?}\n \n return dates.sort[-1] \n end", "def add_due_date_task(duedatetask)\n @due_date_task_list << duedatetask\n @combined_list = @due_date_task_list + @task_list\n end", "def show_completed_items\n return @to_do_item.select { |x| x.is_done? == true }\n end", "def todo\n sort :task_occurrence, default_column: :deadline, default_direction: :desc\n add_crumb t('breadcrumbs.todos'), community_schedule_todo_path(@community)\n @task_occurrences = @community.task_occurrences.for_user_or_open(@user).todo.order(sort_column + ' ' + sort_direction).paginate(page: params[:page],per_page: 20)\n end", "def get_due_time(user)\n Borrowing.find_by(user_id: user.id, book_id: self.id)\n .due_date\n end", "def get_due_date()\n return @due_date\n end", "def default_due_date\n #Date.parse(future_date($default_due).to_s[0..10]) # => converts to a Date object\n Date.today + $default_due\n end", "def itemsOfThisMonth\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select!{|item| item.done? == 'Item incomplete'}\n @anniversary_items.select!{|item| item.month}\n @incomplete_and_month = @due_items.concat(@anniversary_items)\n end", "def overdue?\n @due_date < Date.today\n end", "def due_date\n notice_date + RESPOND_BY_TIME if notice_date\n end", "def due_date\n notice_date + RESPOND_BY_TIME if notice_date\n end", "def todo_list\n TodoList.find_by(user_id: current_user['sub'])\n end", "def due_today?\n due_date == Date.due_today\n end", "def client_tasks_upcoming\n today = Time.zone.now\n self.find_all {|e| (e.completed.nil? or !e.completed) and (e.complete_by >= today and e.complete_by <= (today + 6.days)) }\n end", "def due\n\t\t\t\tif read_attribute(:due) && read_attribute(:due) > 0\n\t\t\t\tTime.at(read_attribute(:due)).to_date\n\t\t\t\telse\n\t\t\t\tnil\n\t\t\t\tend\n\t\t\tend", "def my_todos\r\n\t\t\t\t\tself.authored_todos | self.assigned_todos\r\n\t\t\t\tend", "def due_today?\n @due_date == Date.today\n end", "def overdue\n schedules.where(:when.lte => Time.now)\n end", "def index\n @todos = Todo.where(user_id: current_user.id). where(finish: false).offset(0).limit(PAGE_DISP_NUM).order(\"deadline DESC\")\n end", "def next_due_date\n del = self.deliverables\n return nil unless del.size > 0\n\n dates = del.collect(&:due).delete_if { |d| d.blank?}\n \n return dates.sort[0]\n end", "def printNotDone\n notDoneList = \"\"\n @toDoListArray.each do |e|\n if !e.status\n notDoneList = notDoneList + e.printItem + \" \"\n end\n end\n notDoneList\n end", "def digest_todos(limit=3)\n self.habitats.todos.todo_instances.system.dashboard.all({\n :completed_on => nil, \n :due_on.gt => Date.today - Preference.read_value(\"digest_todo_past_limit\", nil, :default => \"3\").to_i.days,\n :due_on.lt => Date.today + Preference.read_value(\"digest_todo_future_limit\", nil, :default => \"14\").to_i.days,\n :limit => limit\n })\n end", "def overdue?\n Date.today > to_date\n end", "def all_available_todos\n (global_available_todos + local_available_todos).uniq\n end", "def due_date\n self.created_at.to_date + 7\n end", "def show_not_completed_items\n return @to_do_item.select { |x| x.is_done? == false }\n end", "def issues_due_in_days\n due_date = options.days.day.from_now.to_date\n s = ARCondition.new [\"#{Issue.table_name}.due_date <= ?\", due_date]\n s << issue_statuses\n s << projects\n s << trackers\n Issue.find(:all, :include => [:status, :assigned_to, :author, :project, :watchers, :tracker],\n :conditions => s.conditions,\n :order => \"#{Issue.table_name}.due_date, #{Project.table_name}.name\")\n end", "def dueDate\n Date.parse(@dueDate)\n end", "def due_later?\n @due_date > Date.today\n end", "def todos #:nodoc:\n components Icalendar::Vtodo\n end", "def index\n @todoitems = @todolist.todoitems.order(:created_at)\n end", "def sort_due_date_incomplete\n @due_date_task_list.sort! { |duedatetask1, duedatetask2| duedatetask1.due_date <=> duedatetask2.due_date }\n @due_date_task_list.select { |duedatetask| (duedatetask.status == \"incomplete\") }\n end", "def list_overdue\n @checked_out.each do |book|\n book.is_overdue\n end\n \n puts \"The following books are overdue:\"\n @overdue.each { |book| puts \"#{book.title} - #{book.author}\" }\n end", "def due_date_time\n return @due_date_time\n end", "def due_date_time\n return @due_date_time\n end", "def due_status(date)\n return :none if date.nil?\n\n days = (date - today).to_i\n\n if days > 1\n days -= 1 if today.saturday?\n days -= 2 if today.friday?\n end\n\n if days > 1\n :not_yet_due\n elsif days == 1\n :upcoming\n elsif days == 0\n :due\n else\n :overdue\n end\n end", "def todays_deliverables\n self.deliverables.where('DATE(created_at) = ?', Date.today)\n end", "def index\n @todo_items = TodoItem.all\n \n \n # Collect completed tasks\n # block starts ============================\n complete = []\n @todo_items.each do |item|\n if item[:complete] == true\n complete << item \n end\n end\n # block ends ============================\n\n @completed_items = complete.count\n @all_items = @todo_items.count\n\n # Define percentage of completed tasks\n # block starts ============================\n if @all_items > 0\n percentage = (@completed_items).to_f/(@all_items).to_f * 100\n @progress = \"#{percentage}%\"\n end\n # block ends ============================\n\n\n # Define high priority items. Priority are items that are due today.\n\n priority = []\n @todo_items.each do |item|\n today = Date.today.to_s\n if item[:due].to_s == today\n priority << item\n end\n end\n\n @todays_tasks = priority.map(&:task)\n\n\n tomorrow_array = []\n @todo_items.each do |item|\n tomorrow = Date.tomorrow.to_s\n if item[:due].to_s == tomorrow\n tomorrow_array << item\n end\n end\n\n @tomorrows_tasks = tomorrow_array.map(&:task)\n\n end", "def printDone\n doneList = \"\"\n @toDoListArray.each do |e|\n if e.status\n doneList = doneList + e.printItem + \" \"\n end\n end\n doneList\n end", "def coming_due_events\n candidate_events.select(&:coming_due?)\n end", "def due_date\n students = self.accessible_students \n return nil if students.length == 0\n\n date = students.first.due_date\n students.find_each do |student|\n if student.due_date \n if !date || student.due_date > date\n date = student.due_date\n end\n end\n end\n\n date\n end", "def index\n @todo_items = @todo_list.todo_items.all.order(\"completed ASC\") \n end", "def incompleteItemsWithAndWithoutDates\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select!{|item| item.done? == 'Item incomplete'}\n @to_do_items.select!{|item| item.done? == 'Item incomplete'}\n @incomplete_array = @due_items.concat(@to_do_items)\n end", "def due_today?\n @date == Date.today.to_s\n end", "def get_unfinished_todos\n return Todo.where({\"user_id\" => self.id, \"completed\" => false})\n end", "def due_by\n #occurring_days = ae_definition.occurring_days\n dob = profile.kids_type.birthdate.to_date\n dob + (ae_definition.occurring_days + ae_definition.due_by_days )\n end", "def todos_remaining(list)\n list[:todos].count { |todo| !todo[:complete] }\n end", "def section_names_past_due_date\n if !self.section_due_dates_type && !due_date.nil? && Time.current > due_date\n return []\n end\n\n sections_past = []\n self.section_due_dates.each do |d|\n if !d.due_date.nil? && Time.current > d.due_date\n sections_past << d.section.name\n end\n end\n\n sections_past\n end", "def todays_items(opts = {})\n items_since(Date.today)\n end", "def due_date\n frm.div(:class=>\"tier2\").table(:index=>0)[0][0].text\n end", "def print_todo_list(db)\n\ttodo_list = db.execute(\"SELECT * FROM todo JOIN activities \n\t\tON activities.id = todo.activity_id AND todo.done='false'\")\n\ttoday = Time.new.strftime(\"%B %d, %Y\")\n\tputs \"\\nYour daily To-Do List for #{today}:\"\n\tputs '*~'*20+'*'\n\ttodo_list.each { |act| puts act['name'] }\nend", "def index\n date = (Date.today).to_s\n @tasks = current_user.tasks.where(task_day: date)\n end", "def my_todos(project_id, body)\n body.css('stories > story').select do |s|\n s.css('owned_by').text == OWNER\n end.inject({}) do |tasks, s|\n state = map_state s.css('current_state').text\n tasks[state] ||= []\n tasks[state] << s\n tasks\n end.map do |priority_group, stories|\n stories.map{|s| format_todotxt project_id, priority_group, s}\n end.flatten\nend" ]
[ "0.83781195", "0.80639076", "0.80233085", "0.7953399", "0.7519282", "0.7334585", "0.7211269", "0.7080071", "0.7056554", "0.70332956", "0.7003077", "0.6950114", "0.6912658", "0.6840903", "0.6753067", "0.6731556", "0.66811657", "0.6605121", "0.6572694", "0.6509702", "0.65023226", "0.6496468", "0.6486423", "0.646012", "0.6445302", "0.6441435", "0.6388572", "0.63879544", "0.6375703", "0.637107", "0.63576615", "0.6355193", "0.63358897", "0.63315314", "0.6309793", "0.62959945", "0.6261971", "0.62604225", "0.6242807", "0.62405866", "0.62332046", "0.6232638", "0.622183", "0.6208991", "0.6201065", "0.61897075", "0.61837316", "0.61802995", "0.61698985", "0.6168982", "0.61644506", "0.61576986", "0.61436987", "0.6130855", "0.6114751", "0.6103115", "0.6099818", "0.6099818", "0.6090508", "0.6090123", "0.60888225", "0.6079112", "0.6077421", "0.60721225", "0.6071597", "0.6056696", "0.60554284", "0.60538864", "0.60429513", "0.60322666", "0.598166", "0.59718615", "0.59622437", "0.59600466", "0.59562165", "0.5952182", "0.5935167", "0.5930989", "0.5930425", "0.5929763", "0.5924571", "0.5924571", "0.59096336", "0.5906458", "0.5905928", "0.58992094", "0.589645", "0.5886061", "0.5880494", "0.58784246", "0.58634955", "0.5861594", "0.5859997", "0.5857403", "0.5854397", "0.5854218", "0.58519703", "0.58505034", "0.5838121", "0.58301115" ]
0.8575246
0
it will return the todolist of duelater
def due_later TodosList.new(@todos.filter { |todo| todo.due_later? }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def due_date_task_list\n @due_date_task_list\n end", "def dueToday\n dueTodayList = \"\"\n @toDoListArray.each do |e|\n if !e.status && e.dueDate == Date.today\n dueTodayList = dueTodayList + e.printItem + \" \"\n end\n end\n dueTodayList\n end", "def due_today\n TodosList.new(@todos.filter { |todo| todo.due_today? })\n end", "def overdue\n TodosList.new(@todos.filter { |todo| todo.overdue? })\n end", "def tickler_todos\n todos.ticklers.order('completed_time DESC')\n end", "def index\n @todoas = Todoa.where(user_id: current_user.id,done: false).order(\"due, created_at DESC\")\n end", "def todos\n remaining_todos + completed_todos\n end", "def due_tasks\n tasks = []\n\n all_tasks.each do |task|\n due = task.due_date.get\n\n if due.is_a?(Time) && due > Time.new\n tasks << Task.new(task.name.get, due)\n end\n end\n\n # Sorts the array of tasks by due_date\n tasks.sort! { |a,b| a.due_date <=> b.due_date }\n end", "def listAllDue\n Todo.where(\"duedate is not null\")\nend", "def completed_todos\n todos.completed.order('completed_time DESC')\n end", "def due_today\n @due_date_task_list.select { |duedatetask| (duedatetask.status == \"incomplete\") && (duedatetask.due_date == Date.today) }\n end", "def show_not_completed_date_items\n return @to_do_with_date.select { |x| x.is_done? == false }\n end", "def todo_list\n TodoList.find_by(user_id: current_user['sub'])\n end", "def show\n @task = Task.where(todo_list_id: params[:id]).order('status DESC').order('due_date').page(params[:page]).per(5)\n @task.each do |t| \n diff = (t.due_date - Date.today).to_i\n t.due_date = convert_due_date(diff)\n end\n end", "def printNotDone\n notDoneList = \"\"\n @toDoListArray.each do |e|\n if !e.status\n notDoneList = notDoneList + e.printItem + \" \"\n end\n end\n notDoneList\n end", "def to_do_items\n return @to_do_item\n end", "def listNotDue\n Todo.where(\"duedate is null\")\nend", "def index\n @duelists = Duelist.all\n end", "def show_due_tasks\n task = Task.where.not(due_date: nil).all\nend", "def printDone\n doneList = \"\"\n @toDoListArray.each do |e|\n if e.status\n doneList = doneList + e.printItem + \" \"\n end\n end\n doneList\n end", "def my_todos\r\n\t\t\t\t\tself.authored_todos | self.assigned_todos\r\n\t\t\t\tend", "def get_unfinished_todos\n return Todo.where({\"user_id\" => self.id, \"completed\" => false})\n end", "def add_todo\n puts\n desc = description('Todo description (required):')\n return if desc.nil?\n due = due_date\n priority = item_priority\n @list.add('todo',desc, { due: due, priority: priority})\n puts\n end", "def todo\n sort :task_occurrence, default_column: :deadline, default_direction: :desc\n add_crumb t('breadcrumbs.todos'), community_schedule_todo_path(@community)\n @task_occurrences = @community.task_occurrences.for_user_or_open(@user).todo.order(sort_column + ' ' + sort_direction).paginate(page: params[:page],per_page: 20)\n end", "def show_completed_items\n return @to_do_item.select { |x| x.is_done? == true }\n end", "def todos #:nodoc:\n components Icalendar::Vtodo\n end", "def index\n @todo_items = @todo_list.todo_items.all.order(\"completed ASC\") \n end", "def todos(project_id)\n return [] if project_id.blank? || !basecamp\n @todos[project_id] ||= Basecamp::TodoList.all(project_id, false)\n end", "def index\n @todoitems = @todolist.todoitems.order(:created_at)\n end", "def show_due_today\n task = Task.where(due_date: Date.today).all\nend", "def get_tasks_from_todoist\n return Todoist::Task.uncompleted(PROGRAMMING_PROJECT_ID)\n end", "def show_not_completed_items\n return @to_do_item.select { |x| x.is_done? == false }\n end", "def not_complete_by_date\n @not_done = show_not_completed_date_items\n return @not_done.sort_by {|x| x.due_date }\n end", "def lists(project_id, complete=nil)\n records \"todo-list\", \"/projects/#{project_id}/todos/lists\", :complete => complete\n end", "def get_pending\n Rutodo::Database::Todo.where(done: false).map(&:as_entity)\n end", "def get_completed_todos\n return Todo.where({\"user_id\" => self.id, \"completed\" => true})\n end", "def not_completed_due_today\n @not_done = @to_do_with_date.select { |x| x.is_done? == false }\n return @not_done.select { |x| x.due_date == Date.today }\n end", "def client_tasks_overdue\n self.find_all {|e| (e.completed.nil? or !e.completed) and e.complete_by < Time.zone.now }\n end", "def my_todos(project_id, body)\n body.css('stories > story').select do |s|\n s.css('owned_by').text == OWNER\n end.inject({}) do |tasks, s|\n state = map_state s.css('current_state').text\n tasks[state] ||= []\n tasks[state] << s\n tasks\n end.map do |priority_group, stories|\n stories.map{|s| format_todotxt project_id, priority_group, s}\n end.flatten\nend", "def all_available_todos\n (global_available_todos + local_available_todos).uniq\n end", "def tasks_data_today \n tasks_of_today = self.tasks_due_today\n tasks = []\n tasks_of_today.each do |task|\n task = {\n task_name: task.name, \n completion_value: task.completions.last.completion_value,\n completion_max: task.completion_max,\n completion_unit: task.completion_unit\n }\n tasks << task \n end\n tasks \n end", "def index\n @todos = Todo.where(user_id: current_user.id). where(finish: false).offset(0).limit(PAGE_DISP_NUM).order(\"deadline DESC\")\n end", "def today\n tod = Time.now.strftime(\"%Y-%m-%d\")\n @tasks.each do |project_name, project_tasks|\n project_tasks.each do |task|\n if task.deadline.to_s == tod\n puts task.description\n end\n end\n end\n end", "def index\n @due_dates = DueDate.all\n end", "def todos_remaining(list)\n list[:todos].count { |todo| !todo[:complete] }\n end", "def list_all_not_completed_this_month\n @due_this_month = not_complete_by_date.select {|x| x.due_date.month == Date.today.month}\n @anniversary_this_month = @anniversary_list.select {|x| x.month == Date.today.month}\n @anniversary_this_month = @anniversary_this_month.sort_by {|x| x.day}\n return @due_this_month + @anniversary_this_month + show_not_completed_items\n end", "def todo\n @tasks = TaskDecorator.decorate_collection Task.getReadyToDoTasks\n render \"v1/tasks/index\"\n end", "def list_not_completed_this_month_date_only\n @due_this_month = not_complete_by_date.select {|x| x.due_date.month == Date.today.month}\n @anniversary_this_month = @anniversary_list.select {|x| x.month == Date.today.month}\n @anniversary_this_month = @anniversary_this_month.sort_by {|x| x.day}\n return @due_this_month + @anniversary_this_month\n end", "def create(params, projectid, todolistid)\n\n data = params[:due_at]\n data = Date.parse(data.to_a.sort.collect{|c| c[1]}.join(\"-\"))\n\n body =\n {\n :content => params[:content],\n :due_at => data,\n :assignee =>\n {\n :id => params[:assignee_id],\n :type => params[:assignee_type]\n }\n }\n\n post(\"projects/#{projectid}/todolists/#{todolistid}/todos.json\", JSON.generate(body))\n\n end", "def get_completed(projectid)\n get(\"projects/#{projectid}/todolists/completed.json\")\n end", "def task_list\n self.tasks.map do |task|\n task.text\n end\n end", "def index\n @to_dos = ToDo.all\n end", "def remaining_todos\n if @remaining_todos.empty? && @remaining_count > 0\n refresh\n end\n \n return @remaining_todos\n end", "def list_tasks\r\n unless tasks\r\n puts \"No tasks yet. Add one!\"\r\n return\r\n end\r\n # Pretty-format hash and print\r\n print \" \" + \"ITEM\".ljust(30) + \" | \" +\r\n \"WHEN DUE\".ljust(15) + \" | \" +\r\n \"WHEN ADDED\".ljust(15) + \"\\n\"\r\n tasks.each do |task|\r\n print \"<#{tasks.find_index(task) + 1}>\".ljust(5) +\r\n task[:text].ljust(30) + \" | \" +\r\n task[:due].ljust(15) + \" | \" +\r\n task[:time].ljust(15) + \"\\n\"\r\n end\r\n end", "def set_duelist\n @duelist = Duelist.find(params[:id])\n end", "def all_todos\n (global_todos.where(language: I18n.locale).to_a.delete_if{ |gt| local_todos.map(&:title).include?(gt.title) } + local_todos)\n end", "def print_todo_list(db)\n\ttodo_list = db.execute(\"SELECT * FROM todo JOIN activities \n\t\tON activities.id = todo.activity_id AND todo.done='false'\")\n\ttoday = Time.new.strftime(\"%B %d, %Y\")\n\tputs \"\\nYour daily To-Do List for #{today}:\"\n\tputs '*~'*20+'*'\n\ttodo_list.each { |act| puts act['name'] }\nend", "def index\n @todolist = Todolist.find(params[:todolist_id])\n @task = @todolist.tasks.find(params[:id])\n\n @tasks = @todolist.tasks.where(completed: false).order('created_at ASC')\n @completed_tasks = @todolist.tasks.where(completed: true).order('updated_at')\n end", "def read_todo\n update\n end", "def index\n @todo_items = TodoItem.all\n \n \n # Collect completed tasks\n # block starts ============================\n complete = []\n @todo_items.each do |item|\n if item[:complete] == true\n complete << item \n end\n end\n # block ends ============================\n\n @completed_items = complete.count\n @all_items = @todo_items.count\n\n # Define percentage of completed tasks\n # block starts ============================\n if @all_items > 0\n percentage = (@completed_items).to_f/(@all_items).to_f * 100\n @progress = \"#{percentage}%\"\n end\n # block ends ============================\n\n\n # Define high priority items. Priority are items that are due today.\n\n priority = []\n @todo_items.each do |item|\n today = Date.today.to_s\n if item[:due].to_s == today\n priority << item\n end\n end\n\n @todays_tasks = priority.map(&:task)\n\n\n tomorrow_array = []\n @todo_items.each do |item|\n tomorrow = Date.tomorrow.to_s\n if item[:due].to_s == tomorrow\n tomorrow_array << item\n end\n end\n\n @tomorrows_tasks = tomorrow_array.map(&:task)\n\n end", "def index\n @what_fixed_to_dos = WhatFixedToDo.all\n end", "def todos\n subcomponents[\"VTODO\"]\n end", "def digest_todos(limit=3)\n self.habitats.todos.todo_instances.system.dashboard.all({\n :completed_on => nil, \n :due_on.gt => Date.today - Preference.read_value(\"digest_todo_past_limit\", nil, :default => \"3\").to_i.days,\n :due_on.lt => Date.today + Preference.read_value(\"digest_todo_future_limit\", nil, :default => \"14\").to_i.days,\n :limit => limit\n })\n end", "def todo_msg_today; \"today\"; end", "def index\n @date = params[:date] ? Time.parse(params[:date]).in_time_zone : Time.zone.now\n @start = @date.beginning_of_day.in_time_zone\n @finish = @date.end_of_day.in_time_zone\n @tense = determine_tense @date\n @day_name = @start == @now.beginning_of_day ? \"Today\" : @start.strftime(\"%a, %b %-d\")\n \n @tasks = case @tense\n when \"past\"\n @member.tasks.where(\"(complete = :false and due_at >= :start and due_at <= :finish) or (complete = :true and completed_at >= :start and completed_at <= :finish)\", \n true: true,\n false: false,\n nil: nil,\n start: @start,\n finish: @finish\n )\n when \"present\", \"future\"\n @member.tasks.where(\"(due_at is :nil and complete = :false) or (complete = :false and due_at is not :nil and due_at >= :start and due_at <= :finish) or (complete = :true and completed_at is not :nil and completed_at >= :start and completed_at <= :finish)\",\n true: true,\n false: false,\n nil: nil,\n start: @start,\n finish: @finish\n )\n end\n \n @incomplete = @member.tasks.where(\"due_at < ?\", @start).incomplete.by_ordinal.order(:due_at).group_by{ |t| p t.due_at.to_date }\n @complete = @tasks.complete.by_completed_at\n end", "def mark_done\n choose do |menu|\n menu.prompt = \"What have you completed?\"\n Toodoo::Item.where{:todo_id => todo.id, finished => false}.each do |x|\n menu.choice(x.item, \"Choose this task\"){x.update(finished => true)}\n x.save\n end\n menu.choice(:back)\n end\n\n def change_due_date\n # TODO: This should display the todos on the current list in a menu\n # similarly to pick_todo_list. Once they select a todo, the menu choice block\n # should update the due date for the todo. You probably want to use\n # `ask(\"foo\", Date)` here.\n end\n\n def edit_task\n choose do |menu|\n menu.prompt = \"What item would you like to edit?\"\n Toodoo::Item.wehere{:list_id => list_id, finished => false}.each do |x|\n menu.choice(x.item, \"Edit this task\") {x.update(item: get_new_item)}\n x.save\n end\n end\n end\n\n def show_overdue\n # TODO: This should print a sorted list of todos with a due date *older*\n # than `Date.now`. They should be formatted as follows:\n # \"Date -- Eat a Cookie\"\n # \"Older Date -- Play with Puppies\"\n end\n\n def run\n puts \"Welcome to your personal TooDoo app.\"\n loop do\n choose do |menu|\n menu.layout = :menu_only\n menu.shell = true\n\n # Are we logged in yet?\n unless @user\n menu.choice(:new_user, \"Create a new user.\") { new_user }\n menu.choice(:login, \"Login with an existing account.\") { login }\n end\n\n # We're logged in. Do we have a todo list to work on?\n if @user && !@todos\n menu.choice(:delete_account, \"Delete the current user account.\") { delete_user }\n menu.choice(:new_list, \"Create a new todo list.\") { new_todo_list }\n menu.choice(:pick_list, \"Work on an existing list.\") { pick_todo_list }\n menu.choice(:remove_list, \"Delete a todo list.\") { delete_todo_list }\n end\n\n # Let's work on some todos!\n if @todos\n menu.choice(:new_task, \"Add a new task.\") { new_task }\n menu.choice(:mark_done, \"Mark a task finished.\") { mark_done }\n menu.choice(:move_date, \"Change a task's due date.\") { change_due_date }\n menu.choice(:edit_task, \"Update a task's description.\") { edit_task }\n menu.choice(:show_done, \"Toggle display of tasks you've finished.\") { @show_done = !!@show_done }\n menu.choice(:show_overdue, \"Show a list of task's that are overdue, oldest first.\") { show_overdue }\n menu.choice(:back, \"Go work on another Toodoo list!\") do\n say \"You got it!\"\n @todos = nil\n end\n end\n\n menu.choice(:quit, \"Quit!\") { exit }\n end\n end\n end\nend", "def due(task)\n if !task.completed? && task.due_on\n days = task.due_on - Date.today\n \n css_class = if days > 10\n \"due\"\n elsif days > 5\n \"due_soon\"\n else\n \"due_alarm\"\n end\n \n content = if days == 0\n \"Due today\"\n elsif days < 0\n days *= -1\n \"Overdue #{days} #{days == 1 ? \"day\" : \"days\"}\"\n else\n \"Due in #{days} #{days == 1 ? \"day\" : \"days\"}\"\n end\n \n tag :small, content, :class => css_class\n end\n end", "def add_due_date_task(duedatetask)\n @due_date_task_list << duedatetask\n @combined_list = @due_date_task_list + @task_list\n end", "def selectIncompleteOrderByDate\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select{|item| item.done? == 'Item incomplete'}\n end", "def sort_due_date_incomplete\n @due_date_task_list.sort! { |duedatetask1, duedatetask2| duedatetask1.due_date <=> duedatetask2.due_date }\n @due_date_task_list.select { |duedatetask| (duedatetask.status == \"incomplete\") }\n end", "def deadline (rest)\n id_string, datedl = rest.split(/ /,2)\n id = id_string.to_i\n #checking id the deadline entered is a valid date\n begin\n dl = Date.strptime(datedl, \"%m/%d/%Y\")\n #code using date goes here\n task = @tasks.collect { |project_name, project_tasks|\n project_tasks.find { |t| t.id == id }\n }.reject(&:nil?).first\n\n if task.nil?\n @output.printf(\"Could not find a task with an ID of %d.\\n\", id)\n return\n end\n task.deadline = dl\n #checking if the deadline is not a valid date\n rescue ArgumentError\n #code dealing with an invalid date goes here\n @output.printf('The deadline entered is not a valid date!!')\n end\n #adding the deadline to the same task(same description)if it exists in more than one project!\n @tasks.each { |project_name, project_tasks|\n project_tasks.each { |task|\n if task.id == id\n @tasks.each do |project_name, project_tasks|\n project_tasks.each do |t|\n if t.description == task.description\n t.deadline = task.deadline\n end\n end\n end\n end\n }\n\n }\n end", "def final_due_date\n del = self.deliverables\n return nil unless del.size > 0\n\n dates = del.collect(&:due).delete_if { |d| d.blank?}\n \n return dates.sort[-1] \n end", "def index\n @todoit_lists = TodoitList.all\n end", "def due_date\n @due_date\n end", "def to_do_list\n if current_staff.on_duty?\n @task_assignments = current_staff.currently_assigned_tasks\n end\n \n respond_to do |format|\n format.html # to_do_list.html.erb\n format.xml { render :xml => @task_assignments }\n end\n end", "def index\n @to_do = current_user.stuk_todo_tasks.where(state: 'to_do')\n @doing = current_user.stuk_todo_tasks.where(state: 'doing')\n @done = current_user.stuk_todo_tasks.where(state: 'done')\n end", "def all_completed_todos\n (global_completed_todos + local_completed_todos).uniq\n end", "def show\n # Date.strptime('03-02-2001', '%d-%m-%Y')\n\n # @donee = Donee.first\n\n\n # @donee_names = []\n #\n # donees = Donee.all\n # donees.each do |n|\n # @donee_names << n.name\n # end\n end", "def incompleteItemsWithAndWithoutDates\n @due_items.sort!{|x,y| x.dueDate <=> y.dueDate}\n @due_items.select!{|item| item.done? == 'Item incomplete'}\n @to_do_items.select!{|item| item.done? == 'Item incomplete'}\n @incomplete_array = @due_items.concat(@to_do_items)\n end", "def show_no_date\n task = Task.where(due_date: nil).all\nend", "def index\n @to_do_notes = ToDoNote.all\n end", "def get_all_withassigned(projectid)\n get(\"projects/#{projectid}/assigned_todos.json\")\n end", "def todos\n output = `bin/rails notes`\n return if output&.empty?\n\n heading('TODO\\'s', output)\n end", "def book_due_dates\n borrowed_books.each { |book| puts \"#{book.title} checked out by #{book.borrower.first.name}. Due date: #{book.due_date.strftime(\"%B %d, %Y\")}.\"}\n end", "def completed_tasks_by_date(list,date)\n # helpers.is_today?(date)\n if (Date.today == date)\n if (list.id == self.all_task.id)\n self.completed_tasks.where([\"DATE(completed_at)=?\", date] ).order('completed_at')\n # self.completed_tasks.where([\"DATE(completed_at) BETWEEN ? AND ?\", date - 1.day , date] ).order('completed_at')\n else\n self.completed_tasks.where([\"list_id=? and DATE(completed_at)=?\",list.id, date] ).order('completed_at DESC')\n # self.completed_tasks.where([\"list_id=? and DATE(completed_at) BETWEEN ? AND ?\",list.id, date - 1.day , date] ).order('completed_at DESC')\n end\n\n else\n if (list.id == self.all_task.id)\n self.completed_tasks.where([\"DATE(completed_at) =?\",date] ).order('completed_at DESC')\n # self.completed_tasks.where([\"DATE(completed_at) =?\",date - 1.day] ).order('completed_at DESC')\n else\n self.completed_tasks.where([\"list_id=? and DATE(completed_at) =?\",list.id, date] ).order('completed_at DESC')\n # self.completed_tasks.where([\"list_id=? and DATE(completed_at) =?\",list.id, date - 1.day] ).order('completed_at DESC')\n end\n\n end\n end", "def get_items(projectid, todolistid)\n get(\"projects/#{projectid}/todolists/#{todolistid}.json\")\n end", "def ideas_from_list_ordered_by_reminder_created_at idea_list\n idea_ids = idea_list.idea_ids.entries\n self.ideas.where(:_id.in => idea_ids).desc(:reminder_created_at)\n end", "def active_todos\n todos.active.order('created_at DESC')\n end", "def selectIncompleteDueDate\n @due_items.select{|item| item.dueToday? && item.done? == 'Item incomplete'}\n end", "def get_list(id)\n record \"/todos/list/#{id}\"\n end", "def todo_object\n task = Todo.find_by_id(self.todo_id)\n return task\n end", "def list_todo_items(opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n {}\n \n )\n\n # resource path\n path = path_replace(\"/v1/users/self/todo\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def tasks(list)\n list_obj = list.is_a?(Wunderlist::List) ? list : lists[list]\n list = list.id if list.is_a? Wunderlist::List\n\n request = prepare_request(Net::HTTP::Get.new \"#{@path}/ajax/lists/id/#{list}\")\n response = @http.request request\n result = []\n\n Nokogiri::HTML(JSON.parse(response.body)[\"data\"]).css(\"li.more\").each do |html_task|\n task = Wunderlist::Task.new\n task.id = html_task.attributes[\"id\"].value.to_i\n task.name = html_task.css(\"span.description\").first.content\n task.important = html_task.css(\"span.fav\").empty? ? false : true\n task.done = html_task.attributes[\"class\"].value.split(\" \").include?(\"done\")\n html_timestamp = html_task.css(\"span.timestamp\")\n task.date = Time.at(html_timestamp.first.attributes[\"rel\"].\n value.to_i).to_date unless html_timestamp.empty?\n task.note = html_task.css('span.note').first.content\n task.api = self\n task.list = list_obj\n\n result << task\n end\n\n result\n end", "def completed_todos\n if @completed_todos.empty? && @completed_count > 0\n refresh\n end\n \n return @completed_todos\n end", "def tasks\n task_list.tasks\n end", "def get_due_date()\n @due_date\n end", "def list_todos(model)\n # print the todos to the screen\n\n model.each do |todo|\n # each todo is a hash\n puts generate_todo_string(todo)\n end\n end", "def\n get_due_date()\n @due_date\n end", "def all_incomplete_todos\n (global_incomplete_todos + local_incomplete_todos).uniq\n end", "def details\n\t\t\"#{self.title} - #{self.due_date} - #{self.is_completed}\"\n\tend" ]
[ "0.76600075", "0.7425", "0.7318131", "0.6905841", "0.6836603", "0.6794105", "0.67571825", "0.66352", "0.6619828", "0.6590634", "0.6586511", "0.65522486", "0.65361786", "0.65172076", "0.6468035", "0.6465515", "0.63964725", "0.6368936", "0.6341448", "0.63335764", "0.63125783", "0.63045007", "0.62976277", "0.6288212", "0.62821597", "0.62124896", "0.61777836", "0.6168761", "0.61583674", "0.61546206", "0.6124778", "0.60909843", "0.6079384", "0.6077134", "0.60566515", "0.6020941", "0.59792894", "0.59774625", "0.5976732", "0.59546804", "0.59454536", "0.59415436", "0.59404355", "0.59256727", "0.59250414", "0.5920622", "0.5913652", "0.59101737", "0.5891591", "0.58858365", "0.5858811", "0.58537245", "0.58426356", "0.58313227", "0.5829719", "0.58254766", "0.5822498", "0.5821184", "0.58148164", "0.58140534", "0.5806991", "0.57882535", "0.57815456", "0.57739425", "0.5770147", "0.57636577", "0.57523173", "0.57518244", "0.574719", "0.57430625", "0.5735855", "0.5732667", "0.5726033", "0.57227093", "0.5717035", "0.571355", "0.5709356", "0.5707422", "0.5697919", "0.56962276", "0.5689981", "0.5688534", "0.56836677", "0.5678383", "0.5672714", "0.56633383", "0.5661542", "0.5661298", "0.5660241", "0.5652905", "0.5648994", "0.5648679", "0.56422925", "0.5640591", "0.5634093", "0.56264365", "0.5625172", "0.5617481", "0.5615921", "0.5615256" ]
0.8177851
0
Add diagram with Array
def add(type, *data) df = DataFrame.new({x: data[0], y: data[1], z: data[2]}) return add_with_df(df, type, :x, :y, :z) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_array ary, type, options = {}\n\n options[:colors] ||= :category10\n colors = Rubyvis::Colors.send(options[:colors])\n\n options[:panel] = vis(options) # set up panel\n ary.each_index do |i|\n options[:panel] = ary[i].vis(type, options.merge({:line_color => colors[i % colors.size]}))\n end\n\n options[:panel]\n end", "def add(new_element)\n\n case new_element\n when DrawingGroup\n @drawingArray = (@drawingArray << new_element.drawingArray).flatten\n when Drawing\n @drawingArray << new_element\n else\n raise Argument \"New_element (#{@new_element}) is not a valid input\"\n end\n \n end", "def draw_line_graph(data,data_description,serie_name=\"\")\r\n # Validate the Data and DataDescription array */\n #TODO Add method fr validate_data_description\r\n data_description = self.validate_data_description(\"draw_line_graph\",data_description)\n self.validate_data(\"draw_line_graph\",data)\r\n graph_id= 0\r\n data_description[\"values\"].each do |col_name|\r\n id = 0\r\n data_description[\"description\"].each do |keyi,valui|\r\n color_id = id if ( keyi == col_name ) \n id=id+1 \n end\r\n if ( serie_name == \"\" || serie_name == col_name )\r\n xpos = @g_area_x1 + @g_area_offset\r\n xlast = -1\r\n data.each do |key|\r\n if ( !(key[col_name].nil?))\r\n value =key[col_name]\r\n ypos = @g_area_y2 - ((value-@vmin) * @division_ratio)\r\n #Save point into the image map if option activated */\r\n self.add_to_image_map(xpos-3,ypos-3,xpos+3,ypos+3,data_description[\"description\"][col_name],key[col_name],data_description[\"unit\"][\"y\"],\"line\") if ( @build_map )\r\n xlast = -1if (!((value).is_a?(Numeric)))\r\n \r\n self.draw_line(xlast,ylast,xpos,ypos,@palette[color_id][\"r\"],@palette[color_id][\"g\"],@palette[color_id][\"b\"],true) if ( xlast != -1 )\r\n\r\n xlast = xpos\r\n ylast = ypos\r\n xlast = -1 if (!((value).is_a?(Numeric))) \r\n end\r\n xpos = xpos + @division_width\r\n end\r\n graph_id=graph_id+1\r\n end\r\n end\r\n end", "def adler_chart(i)\r\n AdlerChart.new self, i\r\n end", "def draw(arr)\n\t\texit(1) unless arr.is_a? Array\n\n\t\txs = []\n\t\tys = []\n\t\tarr.each do |a|\n\t\t\ta.each do |x,y|\n\t\t\t\txs << x\n\t\t\t\tys << y\n\t\t\tend\n\t\tend\n\t\tminX, maxX = xs.minmax\n\t\tminY, maxY = ys.minmax\n\n\t\tw = h = 768\n\t\t#margin = 50\n\t\tsurface = Cairo::ImageSurface.new(w,h)\n\t\t@cr = Cairo::Context.new(surface)\n\t\t@cr.scale(w, h)\n\t\tnw = maxX - minX\n\t\tnh = maxY - minY\n\t\t@cr.scale(1.0 / nw, 1.0 / nh)\n\t\t@cr.translate(-minX, -minY)\n\n\t\t@cr.set_line_cap(Cairo::LINE_CAP_ROUND)\n\n\t\t# Background\n\t\t@cr.set_source_rgba([0,0,0])\n\t\t@cr.paint\n\n\t\tarr.each do |obj|\n\t\t\tcolor = obj.size == 1 ? [0,255,0] : [255,255,255]\n\t\t\twidth = obj.size == 1 ? 0.2 : 0.02\n\t\t\t@cr.set_source(color)\n\t\t\t@cr.set_line_width(width)\n\t\t\t@cr.stroke_preserve\n\t\t\tpath(*obj)\n\t\t\t@cr.stroke\n\t\tend\n\n\t\t@cr.target.write_to_png(\"test.png\")\n\n\tend", "def create_graphics\n super\n draw_wanted_data\n end", "def populate_diagram\n\n # Parse the Diagram data using the #Reader\n puts \"Parsing Diagram data . . .\"\n diagram_data = @reader.get_diagram_data\n\n # Create and populate a Diagram from the parsed data\n puts \"Populating Diagram with Classes . . .\"\n\t\t\t@diagram = Diagram.new(diagram_data[:name], diagram_data[:artifacts])\n @diagram.populate!\n end", "def <<( array)\n unless @list\n # columns were not added, this most likely is the title\n @list ||= []\n _init_model array\n end\n @list << array\n @native_text = @list # 2014-05-27 - 16:34 \n fire_dimension_changed\n self\n end", "def draw_graph\n @graph = Array.new((2 * (self.down) + 1)){Array.new((2 * (self.across) + 1),\"\")}\n for i in 0..(2 * (self.down)) do\n for j in 0..(2 * (self.across)) do\n plane[i][j] == 1? graph[i][j] = '*': graph[i][j] = ' '\n end\n end\n end", "def add_data\n Sol.add_data(\"native_array\", @data.nc_array)\n Sol.add_data(\"labels\", @dimension_labels.nc_array)\n end", "def draw_new\n\t @board=Array.new(@y) {Array.new(@x){'*'}}\n\t \n end", "def add_data_elements\n \n end", "def basic_chart\n \n end", "def add(graphic)\n @child_graphics.push(graphic)\n end", "def simple_chart\n \n end", "def set_lines\n create_data_line(1)\n end", "def extend_and_draw(collection)\n collection.map do |member|\n case member\n when ::Xumlidot::Types::MethodSignature\n member.extend(::Xumlidot::Diagram::Xmi::MethodSignature)\n when ::Xumlidot::Types::Attribute\n member.extend(::Xumlidot::Diagram::Xmi::Attribute)\n end\n member.draw\n end.join(' ')\n end", "def render_graphics(types, concs)\n types.zip(concs) do |type, slices|\n make_gnuplot(type, \"#{type} atom type\", 'time (s)', 'concentration (%)') do |plot|\n # plot.yrange('[0:1]')\n plot.data += slices.map do |n, slice|\n data_set([slice.keys, slice.values])\n end\n end\n end\nend", "def initialize()\n @drawingArray = []\n @currentIndex = 0\n end", "def create_data_line(which = 1)\n create_line(\"data_line_#{which}\",\"Data_Line\", which)\n end", "def generate_graph\n end", "def create_inputs\n @inputs = Array.new(@max_size) do |i|\n add_text(base_x + i * delta_x, base_y + delta_y, delta_x, delta_y, NO_CHAR, 1)\n end\n end", "def set(a)\r\n if a.is_a?(Array)\r\n @text = a[0]\r\n @icon = a[1] if a[1]\r\n else\r\n @text = a.name + \"\\n\" + a.description\r\n @icon = a.icon_index\r\n end \r\n refresh\r\n end", "def add array\n $log.debug \"tabular got add #{array.count} #{array.inspect} \" if $log\n @list ||= []\n @list << array\n end", "def graph_first_line\n array = [\"exercise\"]\n self.most_reps.times do |n|\n array << \"set #{n+1}\" \n array << 'string'\n end\n array\n end", "def add array\n #$log.debug \"tabular got add #{array.count} #{array.inspect} \" if $log\n @list ||= []\n @list << array\n end", "def as_json\n {\n type: :diagram,\n data:\n {\n caption: caption,\n code: code,\n width: width,\n height: height\n }\n }\n end", "def plant_a_tree\n new_tree = [OrangeTree.new]\n @tree_array = @tree_array + new_tree\n end", "def create_meta(array)\n @plataforma_meta = Meta.create(x: array[0], y: array[1] + 45)\n end", "def draw_data_array(layout_array)\n y, max_y = @draw_y, @draw_y\n # Draw each data aspect at the same starting @draw_y\n layout_array.each { |dt|\n @draw_y = y\n draw_data(dt)\n max_y = @draw_y if @draw_y > max_y\n }\n @draw_y = max_y\n end", "def plot; end", "def added(array)\nend", "def relation_add_array(kind,value,sibling_id = nil)\n relation_destroy(kind,sibling_id)\n return if !value || value == nil || value.length == 0\n value.each do |v|\n Relation.create!({\n :note_id => self.id,\n :sibling_id => sibling_id,\n :kind => kind,\n :value => v.strip\n })\n end\n end", "def add_drawelement_toarrayofelements(drawElement)\n unless @elementHash[:elementtype].eql? :arrayofelements\n fail \"Can only add a drawElement to \\\"elementtype\\\"\" +\n \" \\\"arrayofelements\\\"\"\n end\n if drawElement.respond_to? \"elementhash\"\n drawElement = drawElement.elementhash\n end\n \n if @elementHash[:arrayofelements].nil?\n @elementHash[:arrayofelements] = [ drawElement ]\n else\n @elementHash[:arrayofelements].push(drawElement)\n end\n end", "def fill_content\n @content[:type] = 'line' if ! @content[:type]\n\n data[:datasets].each do |current|\n add_color(current) if ! current[:borderColor]\n current[:fill] = false if ! current[:fill]\n current[:lineTension] = 0 if ! current[:lineTension]\n raise \"chart maker needs data. content #{@content}\" if ! current[:data]\n end\n\n end", "def chart (datos)\n mayor = num_maximo(datos) #Valor maximo para saber hasta donde se mostrara en el grafico\n por_unidad = 2 #Valor por defecto de cuanto '*' o '-' se repetiran por numero\n\n datos.each do |elem| #Dibuja en el orden del arreglo cada elemento\n print_barra(elem.to_i, por_unidad, \"|\", \"*\") #Metodo que genera las barras, le paso el caracter que quiero repita\n end\n\n print_barra(mayor, por_unidad, \">\", \"-\") #Dibuja el final del grafico\n\n extra = 0 #Hace lo mismo que en print_barra\n print \" \"\n mayor.times do |i|\n if i > 9 #Cuando el valor es mayor a 10 se desalinea con las barras\n extra += 0.95 #Valor obtenido por ensayo y error :D con 1 no da, con 0.5 tampoco, con 0.9 hasta el 20 todo bien, con 9.5 hasta el 23 maximo\n end \n print \" \" * ( (por_unidad - 1) + extra ) #Esto genera mas espacios cuando el numero es mayor a 9\n print (i + 1) #Imprime el numero\n end\n print \"\\n\\n\\n\"\nend", "def gen_response_version_graph(rating_history, question_used_as_title)\n \n # TODO: sanity check\n \n # based on this example - http://teethgrinder.co.uk/open-flash-chart-2/data-lines-2.php\n # and parts from this example - http://teethgrinder.co.uk/open-flash-chart-2/x-axis-labels-3.php\n title = Title.new(\"#{question_used_as_title}\")\n \n data1 = []\n \n rating_history.keys.sort.each do | item | \n data1 << rating_history[\"#{item}\"]\n end\n \n logger.debug \" /////////////// #{data1.join(\",\")} ///////....\"\n \n line_dot = LineDot.new\n line_dot.width = 4\n line_dot.colour = '#DFC329'\n line_dot.dot_size = 5\n line_dot.values = data1\n\n # Added these lines since the previous tutorial\n tmp = []\n x_labels = XAxisLabels.new\n x_labels.set_vertical()\n rating_history.keys.sort.each do |text|\n tmp << XAxisLabel.new(text, '#0000ff', 10, 'diagonal')\n end\n x_labels.labels = tmp\n\n x = XAxis.new\n x.set_labels(x_labels)\n y = YAxis.new\n y.set_range(0,10,1)\n \n x_legend = XLegend.new(\"2010 Monthly\")\n x_legend.set_style('{font-size: 20px; color: #778877}')\n y_legend = YLegend.new(\"Monthly Average Rating\")\n y_legend.set_style('{font-size: 20px; color: #770077}')\n\n chart =OpenFlashChart.new\n chart.set_title(title)\n chart.set_x_legend(x_legend)\n chart.set_y_legend(y_legend)\n chart.x_axis = x # Added this line since the previous tutorial\n chart.y_axis = y\n\n chart.add_element(line_dot)\n \n return chart\n end", "def add_line(x, y, label=\"data #{@dataxy.length + 1}\")\n @dataxy << [label, x, y]\n end", "def draw_entry_array(x, y, w, array)\n draw_icon(array[0].to_i, x, y + (line_height - 24) / 2)\n change_color(text_color(MARW_CONFIGURATION[:colour_name]))\n tw_r = array[2] ? text_size(array[2].to_s).width + 4 : 0\n draw_text(x + 24, y, w - 24 - tw_r, line_height, array[1].to_s)\n change_color(text_color(MARW_CONFIGURATION[:colour_amount]))\n draw_text(x + 24, y, w - 24, line_height, array[2].to_s, 2) if array[2]\n end", "def initialize(slideshow)\n @sections = []\n @slideshow = slideshow\n# add_line line\n end", "def initialize(x, y, width, height)\n super\n @data = []\n self.index = 0\n activate\n end", "def import_array(rows)\n raise ArgumentError, \"Can only work with arrays\" unless rows.is_a?(Array)\n if self.labels.size > 1 and rows.dimensions == 1\n self.add_item(rows)\n else\n # self.items = self.items + rows\n rows.each do |row|\n self.add_item(row)\n end\n end\n end", "def beanplot\n end", "def graphics\n board_graphics = []\n board.each do |row|\n symbolic_row = []\n row.each {|ele| symbolic_row << ele.to_s }\n board_graphics << symbolic_row\n end\n board_graphics\n end", "def addNewBarChart(numberOpenClosed, numberOpen, numberResolved, numberResolvedKo)\n\n chartBar = ChartBarOpen.new\n\n chartBar.numberOpenClosed = numberOpenClosed\n chartBar.numberOpen = numberOpen\n chartBar.numberResolved = numberResolved\n chartBar.numberResolvedKo = numberResolvedKo\n\n @chartBarOpen << chartBar\n\n end", "def draw\n\t\tfield.each do |arr|\n\t\t\tarr.each { |i| print \" #{i} \".black.bg_cyan }\n\t\t\tputs\n\t\tend\n\tend", "def add *list\n @show = (@show + TinyPng::Path.get_all(list)).uniq\n end", "def add_example(example)\n # On redimensionne l'exemple\n example.set_dimensions(self.input_dimension, self.output_dimension)\n # On l'ajoute\n @examples.push(example)\n end", "def represent\n # grid_array will be an array of strings that represent our grid in NxN format\n grid_array=[]\n @h.times{|r| grid_array<<@grid[r*@w,@w].split('')*' '}\n grid_array\n end", "def display_array\n\t\n\t@arr.each_with_index do | val, ind |\n\t\tflow do # Printing the array inside a flow with\n\t\t\t\n\t\t\tif @editing == ind\n\t\t\t\t@i = edit_line :text => \"#{val.pred}\", :width => 40\n\t\t\t\t@j = edit_line :text => \"#{val.prob}\", :width => 40\n\t\t\t\t@k = edit_line :text => \"#{val.succ}\", :width => 100\n\t\t\t\tbutton \"Save\" do\n\t\t\t\t\t@edited_element = Rule.new(nil, nil, @i.text.to_s, nil, @j.text.to_f, @k.text.to_s)\n\t\t\t\t\t@arr[ind] = @edited_element\n\t\t\t\t\t@editing = nil\n\t\t\t\t\trefresh_display\n\t\t\t\tend\n\t\t\t\tbutton(\"x\") { @editing = nil; refresh_display }\n\t\t\telse\n\t\t\t\tpara val.pred.to_s\n\t\t\t\tpara \"--\"\n\t\t\t\tpara val.prob.to_s\n\t\t\t\tpara \"->\"\n\t\t\t\tpara val.succ.to_s\n\t\t\t\t\n\t\t\t\tbutton(\"edit\") { @editing = ind; refresh_display }\n\t\t\t\t\n\t\t\t\tbutton \"x\" do\n\t\t\t\t\tif confirm(\"You sure?\")\n\t\t\t\t\t\t@arr.delete_at(ind)\n\t\t\t\t\t\trefresh_display\n\t\t\t\t\tend #if\n\t\t\t\tend #button\n\t\t\tend\n\t\t# an edit button and a delete button\t\t\t\n\t\tend #flow\n\tend # arr.each\n\t\n\t# With an add button at the end.\n\t@add_element = flow :width => 400 do\n\t\tpara \"Predecessor:\"\n\t\t@e = edit_line :width => 40\n\t\tpara \"\\n\"\n\t\tpara \"Probability: \"\n\t\t@f = edit_line :width => 40\n\t\tpara \"\\n\"\n\t\tpara \"Successor: \"\n\t\t@g = edit_line :width => 100\n\t\tpara \"\\n\"\n\t\tbutton \"Add Rule\" do\n\t\t\t@new = Rule.new(nil, nil, @e.text.to_s, nil, @f.text.to_f, @g.text.to_s)\n\t\t\t@arr << @new\n\t\t\trefresh_display\n\t\tend #button\n\tend\n\nend", "def set_gold_chart\n @chart = [[0, 2], [0, 3], [0, 4], [0, 5], [3, 3], [5, 0], [10, 0]]\n end", "def diagram=(diagram_in)\n self.picture=diagram_in.read\n end", "def draw_stacked_bar_graph(data,data_description,alpha=50,contiguous=false)\n # /* Validate the Data and data_description array */\n data_description = validate_data_description(\"draw_bar_graph\",data_description)\n validate_data(\"draw_bar_graph\",data)\n graph_id = 0\n series = (data_description[\"values\"].count)\n if ( contiguous )\n series_width = @division_width\n else\n series_width = @division_width * 0.8\n end\n y_zero = @g_area_y2 - ((0-@vmin) * @division_ratio)\n y_zero = @g_area_y2 if ( y_zero > @g_area_y2 )\n series_id = 0\n last_value = {}\n id = 0\n color_id = 0\n data_description[\"values\"].each do |col_name|\n data_description[\"description\"].each do |key_i,value_i|\n if ( key_i == col_name )\n color_id = id\n id = id+1\n end\n end\n x_pos = @g_area_x1 + @g_area_x_offset - series_width / 2\n x_last = -1\n data.each do |key|\n if ( !key[col_name].nil?)\n if ( key[col_name].is_a?(Numeric) )\n value = key[col_name]\n if (!last_value[key].nil?)\n y_pos = @g_area_y2 - (((value+last_value[key])-@vmin) * @division_ratio)\n y_bottom = @g_area_y2 - ((last_value[key]-@vmin) * @division_ratio)\n last_value[key] += value\n else\n y_pos = @g_area_y2 - ((value-@vmin) * @division_ratio)\n y_bottom = y_zero\n last_value[key] = value\n end\n # Save point into the image map if option activated\n if ( @build_map )\n #add_to_image_map(x_pos+1,[y_bottom,y_pos].min,x_pos+series_width-1,[y_bottom,y_pos].max,data_description[\"description\"][col_name],data[key][col_name].data_description[\"unit\"][\"y\"],\"sBar\")\n end\n draw_filled_rectangle(x_pos+1,y_bottom,x_pos+series_width-1,y_pos,@palette[color_id][\"r\"],@palette[color_id][\"g\"],@palette[color_id][\"b\"],true,alpha)\n end\n end\n x_pos = x_pos + @division_width\n end\n series_id+=1\n end\n end", "def draw_paths; end", "def add_chart(chart_type, options) \n @object = GraphicFrame.new(self, chart_type, options)\n @object.chart\n end", "def initialize\n @design_components = Array.new\n end", "def predict_format_converter usages\r\n @date = []\r\n @total = []\r\n @lines = []\r\n @labels = []\r\n @table_array = []\r\n usages[:daily_usage].each do |usage|\r\n @date.append(usage[:date].to_s)\r\n\r\n @total.append(usage[:usage])\r\n end\r\n @table_array.append(\"date[i]\")\r\n @table_array.append(\"total[i]\")\r\n usages[:daily_time_periods].each_with_index do |period, index|\r\n @name =\"lines[#{index.to_s}][i]\"\r\n @table_array.append(@name)\r\n @lines.append([])\r\n @labels.append(period[:label])\r\n period[:daily_usage].each do |usage|\r\n @lines[index].append(usage[:usage])\r\n\r\n end\r\n end\r\n end", "def populate_adjacency_list_via_array(array)\n @vertices = array.flatten.uniq.map { |v| Vertex.new('WHITE', 1, nil, [], v) }\n # Only directed edges are being added to the edges list\n @edges = array.map { |edge| Edge.new(find(edge[0]), find(edge[1])) }\n populate_adjacency_list\n end", "def svg\n '<line x1= \"' + @head.x.to_s + '\" ' + \n 'y1= \"' + @head.y.to_s + '\" ' +\n 'x2= \"' + @tail.x.to_s + '\" ' +\n 'y2= \"' + @tail.y.to_s + '\" ' +\n \"\\n\\t\" +\n 'style=\"stroke:rgb(0,0,0);stroke-width:2\"/>'\n end", "def create_list\n @linkedList.append(cols/2, lines/2)\n @linkedList.append(cols/2 - 1, lines/2)\n @linkedList.append(cols/2 - 2, lines/2)\n # @linkedList.print\n end", "def graph_report\n @header = session[:tool1]\n @product = Product.find_by_id(params[:product_id])\n @array = []\n params[:value].each_with_index do |(key,val),index|\n if session[:tool1]['regions'] == key\n name = \"#{key}(Bench Mark)\"\n a = {name: name, y: val[:percentage].to_f.round(2), drilldown: key}\n @array[0] = a\n else\n session[:tool1]['bench_region'].each_with_index do |value, index| \n index = index + 1\n if value == key\n a = {name: key, y: val[:percentage].to_f.round(2), drilldown: key}\n @array[index] = a\n end\n end\n end\n \n end\n\n end", "def test_with_irregular_array3D4; show([[[0,1,0.5,0.7]]]) end", "def map\n shape = @opts.fetch :shape, 'record'\n rslt = StringIO.new\n rslt.puts \"digraph #{@model[:name]} {\"\n rslt.puts ' graph [rankdir=\"LR\"]'\n rslt.puts ''\n\n @model[:tables].each do |table|\n # nodes\n rslt.puts \" \\\"#{table[:name]}\\\" [label=\\\"#{table[:name]}\\\", shape=\\\"#{shape}\\\"]\"\n # @nodes.puts \" \\\"#{table[:name]}\\\" [label=\\\"<f0> #{table[:name]}|<f1> #{table[:desc]}\\\", shape=\\\"#{shape}\\\"]\"\n # edges\n table.fetch(:fks, []).each do |fk|\n rslt.puts \" \\\"#{table[:name]}\\\"->\\\"#{fk[:table]}\\\"\"\n end\n # graphviz\n table.fetch(:graphvizs, []).each do |text|\n rslt.puts \" #{text}\"\n end\n end\n\n rslt.puts '}'\n rslt.string\n end", "def initialize array\n @array = array\n end", "def getchart()\n # The (x, y) data for the first line\n dataX0 = [20, 90, 40, 30, 12]\n dataY0 = [10, 40, 75, 54, 20]\n\n # The (x, y) data for the second line\n dataX1 = [10, 40, 75, 54, 60]\n dataY1 = [50, 90, 40, 30, 10]\n\n # Create a XYChart object of size 450 x 450 pixels\n c = ChartDirector::XYChart.new(450, 450)\n\n # Set the plotarea at (55, 65) and of size 350 x 300 pixels, with white background\n # and a light grey border (0xc0c0c0). Turn on both horizontal and vertical grid\n # lines with light grey color (0xc0c0c0)\n c.setPlotArea(55, 65, 350, 300, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1)\n\n # Add a legend box at (50, 30) (top of the chart) with horizontal layout. Use 12\n # pts Times Bold Italic font. Set the background and border color to Transparent.\n c.addLegend(50, 30, false, \"timesbi.ttf\", 12).setBackground(\n ChartDirector::Transparent)\n\n # Add a title to the chart using 18 pts Times Bold Itatic font\n c.addTitle(\"Reaction Path\", \"timesbi.ttf\", 18)\n\n # Add a title to the y axis using 12 pts Arial Bold Italic font\n c.yAxis().setTitle(\"Temperature (Celcius)\", \"arialbi.ttf\", 12)\n\n # Set the y axis line width to 3 pixels\n c.yAxis().setWidth(3)\n\n # Add a title to the x axis using 12 pts Arial Bold Italic font\n c.xAxis().setTitle(\"Pressure (Pa)\", \"arialbi.ttf\", 12)\n\n # Set the x axis line width to 3 pixels\n c.xAxis().setWidth(3)\n\n # Add a red (0xff3333) line layer using dataX0 and dataY0\n layer1 = c.addLineLayer(dataY0, 0xff3333, \"Compound AAA\")\n layer1.setXData(dataX0)\n\n # Set the line width to 3 pixels\n layer1.setLineWidth(3)\n\n # Use 9 pixel square symbols for the data points\n layer1.getDataSet(0).setDataSymbol(ChartDirector::SquareSymbol, 9)\n\n # Add custom text labels to the first and last point on the scatter plot using\n # Arial Bold font\n layer1.addCustomDataLabel(0, 0, \"Start\", \"arialbd.ttf\")\n layer1.addCustomDataLabel(0, 4, \"End\", \"arialbd.ttf\")\n\n # Add a green (0x33ff33) line layer using dataX1 and dataY1\n layer2 = c.addLineLayer(dataY1, 0x33ff33, \"Compound BBB\")\n layer2.setXData(dataX1)\n\n # Set the line width to 3 pixels\n layer2.setLineWidth(3)\n\n # Use 11 pixel diamond symbols for the data points\n layer2.getDataSet(0).setDataSymbol(ChartDirector::DiamondSymbol, 11)\n\n # Add custom text labels to the first and last point on the scatter plot using\n # Arial Bold font\n layer2.addCustomDataLabel(0, 0, \"Start\", \"arialbd.ttf\")\n layer2.addCustomDataLabel(0, 4, \"End\", \"arialbd.ttf\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def draw(array=@board_array)\n\t\tputs \" a b c d e f g h \"\n\t\tputs \"___________________________________\"\n\t\tarray.each_with_index do |subarr, i|\n\t\t\tprint \" #{i+1} \"\n\t\t\tsubarr.each_with_index do |item, index|\n\t\t\t\tif index == 7\n\t\t\t\t\tprint item.to_s\n\t\t\t\telse\n\t\t\t\t\tprint item.to_s + \" | \"\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs \"\\n___________________________________\"\n\t\tend\n\tend", "def add_node_to_plot(node, plot, addr_offset, row_offset, addr_div, row_div)\n\tif node.has_key? :data\n\t\tnode[:data].each do |d| # d ~ {row: row, addr: addr, length: words[2].hex, val: 1}\n\t\t\tplot.set((d[:row] - row_offset)/row_div, (d[:addr] - addr_offset)/addr_div, d[:length])\n\t\tend\n\telse\n\t\tnode.each do |key, val|\n\t\t\tadd_node_to_plot(val, plot, addr_offset, row_offset, addr_div, row_div)\n\t\tend\n\tend\nend", "def createLayers()\n @layers_array = import() \n end", "def plot hsh_or_ary, type, options = {}\n vis = begin\n if hsh_or_ary.is_a?(OpenStruct)\n plot_hash hsh_or_ary, type, options\n elsif hsh_or_ary.is_a?(Array)\n plot_array hsh_or_ary, type, options\n end\n end\n\n vis.render()\n require \"rsvg2\"\n svg = RSVG::Handle.new_from_data(vis.to_svg).tap { |s| s.close }\n SciRuby::Plotter.new svg\n end", "def line_image\n \"%s%s%s %s%s%s %s%s%s\" % POT.collect{ |i| own(i) }\n end", "def create_graph(arr)\n nodes = []\n (0...arr.size).each do |i|\n node = Node.new(i)\n nodes.push(node)\n end\n nodes.each_with_index do |node,i|\n arr[i].each {|val| node.connections.push(nodes[val])} \n end\n nodes\nend", "def create_graph(arr)\n nodes = []\n (0...arr.size).each do |i|\n node = Node.new(i)\n nodes.push(node)\n end\n nodes.each_with_index do |node,i|\n arr[i].each {|val| node.connections.push(nodes[val])} \n end\n nodes\nend", "def populate_adjacency_list_via_array(array)\n @vertices = array.flatten.uniq.map { |v| Vertex.new('WHITE', 1, nil, [], v) }\n # Both forward and backward edges are being added to the edges list\n forward_edges = array.map { |edge| Edge.new(find(edge[0]), find(edge[1])) }\n backward_edges = array.map { |edge| Edge.new(find(edge[1]), find(edge[0])) }\n @edges = forward_edges + backward_edges\n populate_adjacency_list\n end", "def initialize\n @graph_command = []\n end", "def build_predictive_chart_line(name, color, index, data)\n line = ChartLine.new name, color, \"o,\" + color + \",\" + index + \",-1,4.5\"\n data.each do |key, value|\n line[key] = value\n end\n line\n end", "def create\n\t\t\tobj = []\n\t\t\t@@fonts[@font]['n'].size.times do\n\t\t\t\tobj << []\n\t\t\tend\n\t\t\tcurrent = 0\n\n\t\t\tcount = 0\n\t\t\t@text.each_byte do |c|\n\t\t\t\tif @@chars.include? c.chr\n\t\t\t\t\t@@fonts[@font][c.chr].each_with_index do |fr,ri|\n\t\t\t\t\t\tfr.each do |fc|\n\t\t\t\t\t\t\tif @rainbow\n\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@@rainbow[current], @colors[0].bg,fc)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@colors[current].fg,@colors[current].bg,fc)\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\tif @rainbow != true\n\t\t\t\t\t\t\t\tcurrent += 1 if @colors.size > 1\n\t\t\t\t\t\t\t\tcurrent = 0 if current > @colors.size\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tif @rainbow\n\t\t\t\t\t\tcurrent += 1\n\t\t\t\t\t\tcurrent = 0 if current >= @@rainbow.size\n\t\t\t\t\tend\n\n\t\t\t\t\tif count < @text.size-1\n\t\t\t\t\t\t@@fonts[@font]['n'].size.times do |ri|\n\t\t\t\t\t\t\t@space.times do\n\t\t\t\t\t\t\t\tif @rainbow\n\t\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@@rainbow[current], @colors[0].bg,Theme.get(:background).symbol)\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@colors[current].fg,@colors[current].bg,Theme.get(:background).symbol)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t# SPace\n\t\t\t\telse\n\t\t\t\t\t@@fonts[@font]['n'].size.times do |ri|\n\t\t\t\t\t\t3.times do\n\t\t\t\t\t\t\tif @rainbow\n\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@@rainbow[current], @colors[0].bg, Theme.get(:background).symbol)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@colors[current].fg,@colors[current].bg, Theme.get(:background).symbol)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tcount += 1\n\t\t\tend\n\t\t\t@obj = obj\n\t\tend", "def fill_content\n @content[:type] = 'line' if ! @content[:type]\n\n # data portion\n raise \"line chart maker needs labels . content #{@content}\" if ! data[:labels]\n data[:datasets].each do |current|\n puts \"current is #{current}\"\n add_color(current) if ! current[:borderColor]\n if ! current[:fill]\n current[:fill] = false \n if @args[:stacked] # stack chart and fill make more sense together\n current[:fill] = true\n end\n end\n current[:lineTension] = 0.1 if ! current[:lineTension]\n raise \"chart maker needs data. content #{@content}\" if ! current[:data]\n end\n end", "def make_pie_chart\n\t\trequire 'gruff'\n \t\ta = Sha.group(\"filetype\").count\n\n \t\tg = Gruff::Pie.new\n \t\tg.title = 'Filetypes'\n \n \t\ta.each do |key, value|\n \t\t puts g.data(key, a[key])\n \t\tend\n\n\t\t g.write('app/assets/images/pie.png')\n\tend", "def getchart()\n # The data for the upper and lower bounding lines\n upperY = [60, 60, 100, 100, 60, 60]\n lowerY = [40, 40, 80, 80, 40, 40]\n zoneX = [0, 2.5, 3.5, 5.5, 6.5, 10]\n\n # The data for the spline curve\n curveY = [50, 44, 54, 48, 58, 50, 90, 85, 104, 82, 96, 90, 74, 52, 35, 58, 46, 54,\n 48, 52, 50]\n curveX = [0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 8.5,\n 9, 9.5, 10]\n\n # Create a XYChart object of size 600 x 300 pixels, with a light grey (cccccc)\n # background, black border, and 1 pixel 3D border effect.\n c = ChartDirector::XYChart.new(600, 300, 0xcccccc, 0x000000, 1)\n\n # Set directory for loading images to current script directory\n c.setSearchPath(File.dirname(__FILE__))\n\n # Set the plotarea at (55, 58) and of size 520 x 195 pixels, with white\n # background. Turn on both horizontal and vertical grid lines with light grey\n # color (cccccc)\n c.setPlotArea(55, 58, 520, 195, 0xffffff, -1, -1, 0xcccccc, 0xcccccc)\n\n # Add a legend box at (55, 32) (top of the chart) with horizontal layout. Use 9\n # pts Arial Bold font. Set the background and border color to Transparent.\n c.addLegend(55, 32, false, \"arialbd.ttf\", 9).setBackground(\n ChartDirector::Transparent)\n\n # Add a title box to the chart using 15 pts Times Bold Italic font. The title is\n # in CDML and includes embedded images for highlight. The text is white (ffffff)\n # on a black background, with a 1 pixel 3D border.\n c.addTitle(\n \"<*block,valign=absmiddle*><*img=star.png*><*img=star.png*> Performance \" \\\n \"Enhancer <*img=star.png*><*img=star.png*><*/*>\", \"timesbi.ttf\", 15, 0xffffff\n ).setBackground(0x000000, -1, 1)\n\n # Add a title to the y axis\n c.yAxis().setTitle(\"Temperature\")\n\n # Add a title to the x axis using CMDL\n c.xAxis().setTitle(\n \"<*block,valign=absmiddle*><*img=clock.png*> Elapsed Time (hour)<*/*>\")\n\n # Set the axes width to 2 pixels\n c.xAxis().setWidth(2)\n c.yAxis().setWidth(2)\n\n # Add a purple (800080) spline layer to the chart with a line width of 2 pixels\n splineLayer = c.addSplineLayer(curveY, 0x800080, \"Molecular Temperature\")\n splineLayer.setXData(curveX)\n splineLayer.setLineWidth(2)\n\n # Add a line layer to the chart with two dark green (338033) data sets, and a line\n # width of 2 pixels\n lineLayer = c.addLineLayer2()\n lineLayer.addDataSet(upperY, 0x338033, \"Target Zone\")\n lineLayer.addDataSet(lowerY, 0x338033)\n lineLayer.setXData(zoneX)\n lineLayer.setLineWidth(2)\n\n # Color the zone between the upper zone line and lower zone line as\n # semi-transparent light green (8099ff99)\n c.addInterLineLayer(lineLayer.getLine(0), lineLayer.getLine(1), 0x8099ff99,\n 0x8099ff99)\n\n # If the spline line gets above the upper zone line, color to area between the\n # lines red (ff0000)\n c.addInterLineLayer(splineLayer.getLine(0), lineLayer.getLine(0), 0xff0000,\n ChartDirector::Transparent)\n\n # If the spline line gets below the lower zone line, color to area between the\n # lines blue (0000ff)\n c.addInterLineLayer(splineLayer.getLine(0), lineLayer.getLine(1),\n ChartDirector::Transparent, 0x0000ff)\n\n # Add a custom CDML text at the bottom right of the plot area as the logo\n c.addText(575, 250,\n \"<*block,valign=absmiddle*><*img=small_molecule.png*> <*block*>\" \\\n \"<*font=timesbi.ttf,size=10,color=804040*>Molecular\\nEngineering<*/*>\"\n ).setAlignment(ChartDirector::BottomRight)\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def test_add_line_1\n find = Finder.new\n char_arr = []\n char_arr.push(Node.new('C', 1))\n line = [1, 'C']\n arrayc = [\"C\", \"A\", \"K\", \"T\", \"E\",\"B\"]\n arrayi = [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"]\n assert_equal char_arr, find.add_line(char_arr, line, arrayc, arrayi)\n end", "def draw_me_a_line_chart\n\t\t@table = StatisticsTable.new\n\t\t@table.title = 'Statistiques'\n\t\t@table.axis_title = 'money'\n\t\t\n\t\t@table.add_header('string','Name')\n\t\t@table.add_header('number','Paul')\n\t\t@table.add_header('number','Joe')\n\t\t@table.add_header('number','Jean')\n\n\t\t@table.add_line(['January', 10000, 20000, 23000])\n\t\t@table.add_line(['February', 9000, 22000, 24000])\n\t\t@table.add_line(['March', 8000, 25000, 21000])\n\t\t@table.add_line(['April', 7000, 29000, 22000])\n\t\t@table.add_line(['May', 6000, 40000, 23000])\n\tend", "def add(item)\n #push item into the array\n @array << item\n view\n end", "def build_chart_line(data)\n accum = 0\n week = 0\n\n # TODO - In Ruby 1.8, hashes do NOT maintain insertion sort order!! Grr... so we have to do a stupid data structure dance...\n arr = []\n data.each { |date, estimate_diff| arr << [date, estimate_diff] }\n arr = arr.sort_by {|x| x.first }\n\n line = []\n arr.each do |point|\n # We display data by the week, only showing completed weeks\n day = get_normalized_day point[0] # date\n puts day\n if day >= (7 * (week + 1))\n line.push [week, accum]\n week = day / 7\n end\n accum += point[1] # estimate\n end\n\n line\n end", "def to_flot\n [\n { label: \"Pageviews\", data: pageviews },\n { label: \"Downloads\", data: downloads }\n ]\n end", "def create\n for i in 1 .. (@canvas_height - 1) do\n @buffer.append(i, \" \" * (@canvas_width - 1))\n end\n end", "def initialize(array)\r\n @pic = array #@pic is now \r\n end", "def initialize \n\t\t@lines = Array.new\n\t\t@boxes = Array.new\n\t\t@levels = Array.new\n\t\t@filename = \"\"\n\t\t@file = \"\"\n\t\t\n\t\t@cont = Array.new(16, 0)\n\tend", "def draw_lines\n @dim.times do |i|\n if @type.nil?\n draw_line(i+1)\n draw_edge\n puts\n elsif @type == \"allx\" || @type == \"alt\"\n draw_alt_line\n draw_edge\n puts\n end\n end\n end", "def draw\n @drawer.clear\n draw_ss\n draw_graph\n @segments.each do |s|\n s.draw(@drawer) \n end\n end", "def add_quadraticpath(controlPoint1: { :x => 0.0, :y => 0.0 }, \n endPoint: { :x => 10.0, :y => 20.0 })\n pathElement = { :elementtype => \"pathquadraticcurve\",\n :controlpoint1 => controlPoint1,\n :endpoint => endPoint }\n @pathArray.push(pathElement)\n @pathArray\n end", "def init_graph(name, data, viz_type = 'network', opts = {})\n # i = 0\n def_viz_opts = {\n #:schema => table.schema \n }\n \n gopts = {\n :data_sources => data,\n :dynamic => {\n :updateInterval => 1\n },\n :viz_type => viz_type,\n :wopts => def_viz_opts.merge(opts)\n \n }\n OMF::Web::Widget::Graph.addGraph(name, gopts) \nend", "def pie_planilla\n\n sello = make_table([ [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: 'Sello:', :size => 6, :border_bottom_width => 0 , :border_top_width => 1, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}] ,\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}] ,\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 1 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}]\n ])\n\n huella = make_table([ [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: 'Huella Dactilar:', :size => 6, :border_bottom_width => 0 , :border_top_width => 1, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}] ,\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}] ,\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}],\n [{content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 120}, {content: '', :border_bottom_width => 1 , :border_top_width => 0, :width => 100}, {content: '', :border_bottom_width => 0 , :border_top_width => 0, :width => 40}]\n ])\n table( [\n [{content:'Nombre:', colspan: 1,:size => 6, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}, {content:'Lugar:', colspan: 1,:size => 6, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}],\n [{content:'C.I:', :size => 6, :border_bottom_width => 0 , :border_top_width => 0, colspan: 1, :width => 260 }, {content:'Fecha:', colspan: 1,:size => 6, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}],\n [{content:'Fecha:', colspan: 1, :size => 6, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}, {content:'Firma:', colspan: 1, :size => 6, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}],\n [ {content: sello, colspan: 1, :border_top_width => 0,:border_bottom_width => 0, :width => 260}, {content: huella, colspan: 1, :border_bottom_width => 0 , :border_top_width => 0, :width => 260}],\n [ {content: '', colspan: 1, :border_top_width => 0, :border_bottom_width => 1, :width => 260}, {content: '', colspan: 1, :border_bottom_width => 1 , :border_top_width => 0, :width => 260}]\n ])\n\n end", "def initialize arr = []\n super arr\n end", "def seat_point_chart\n hold=[]\n availableSeats.to_a.each do |i| \n row=i[1][\"row\"]\n row_num=row_to_num(row)\n col=i[1][\"column\"]\n sp=[row,col,seat_point(row_num,col)]\n hold.push(sp)\n end\n return hold \n end", "def initialize(g, params = {})\n\n require 'set'\n \n params = { :pbar => false, :file => '', :color => true, :circo => false }.merge(params)\n @pbar = params[:pbar]\n file = params[:file]\n color = params[:color]\n circo = params[:circo]\n\n if @pbar\n require 'facets/progressbar'\n @labeling_pbar = Console::ProgressBar.new(\"Labeled nodes\", g.num_vertices)\n end\n\n # initializza etichette e contatori\n @i = 0\n @m = 0\n @l = Hash.new\n @c = Hash.new\n @ude_counter = Hash.new\n @unlabeled_v = g.vertices.to_set\n\n if g.cyclic?\n # applica l'algoritmo generalizzato\n until @unlabeled_v.empty?\n\tlabel_and_counter(g)\n\tinf_label(g)\n\t@i += 1\n end\n else\n # applica l'algoritmo lineare\n succ = Hash.new\n g.vertices.each do |v|\n\tsuccessivi = Array.new\n\tg.adjacent_vertices(v).each do |sv| \n\t successivi << sv\n\tend # each\n\tsucc[v] = successivi\n end # each\n coda = Array.new\n g.vertices.each do |v| \n\tif g.adjacent_vertices(v) == []\n\t @l[v] = 0\n\t @labeling_pbar.inc if @pbar\n\t coda.push(v) \n\tend # if\n end # each\n while coda != [] do\n\tx = coda[0]\n\tcoda.delete(x)\n\tg.prev_vertices(x).each do |v|\n\t succ[v].delete(x)\n\t if succ[v] == []\n\t @l[v] = mes(v,g)\n\t coda.push(v)\n\t @labeling_pbar.inc if @pbar\n\t end # if\n\tend # each\n end # while\n end # if\n @labeling_pbar.finish if @pbar\n count_ude(g)\n\n write_to_graphic_file(g, fmt='png', dotfile=file, color, circo) if (file != '' and file.is_a?(String))\n end", "def write(path = @path)\n \n gline = Gruff::Line.new(@size)\n @methods.each do |m, args|\n gline.send(\"#{m}=\", args)\n end\n @dataxy.each do |dxy| \n gline.dataxy(dxy[0], dxy[1], dxy[2]) \n end\n\n @filename ||= filename(@methods[:title])\n @filename ||= \"rbPlot\"\n gline.write(path + @filename + '.png')\n end", "def dotchart(*args)\n Dot.new(self, *args)\n end", "def initialize(x=Array.new,y=Array.new)\n super()\n @x = Array.new(x)\n @y = Array.new(y)\n @filename = 'temp_graph_data_' + @@graph_data_temp_file.to_s + '.txt'\n @@graph_data_temp_file = @@graph_data_temp_file+1\n end", "def chart_data_full\n {\n labels: Array.new(chart_data.length, ''),\n datasets: [\n {\n fillColor: \"rgba(220,220,220,0.2)\",\n strokeColor: \"rgba(220,220,220,1)\",\n data: chart_data\n }\n ]\n }\n end", "def chart_data_full\n {\n labels: Array.new(chart_data.length, ''),\n datasets: [\n {\n fillColor: \"rgba(220,220,220,0.2)\",\n strokeColor: \"rgba(220,220,220,1)\",\n data: chart_data\n }\n ]\n }\n end", "def manifest\n anno = IIIF::Presentation::Annotation.new('on' => path)\n anno.resource = create_resource\n canvas.images << anno\n canvas.other_content = [annotations]\n manifest = IIIF::Presentation::Manifest.new(\n '@id' => path,\n 'label' => \"Histonets - Collection Template #{id}\"\n )\n sequence.canvases << canvas\n manifest.sequences << sequence\n manifest\n end" ]
[ "0.59914404", "0.5876526", "0.57600933", "0.5715361", "0.5532969", "0.55228394", "0.5518061", "0.55106366", "0.5486477", "0.54860175", "0.5481736", "0.5452358", "0.5425963", "0.54224515", "0.53932595", "0.5371062", "0.5355002", "0.53539366", "0.53473085", "0.5339255", "0.5332486", "0.52988756", "0.52849305", "0.5283285", "0.52809423", "0.52686656", "0.52674705", "0.5255717", "0.5254509", "0.52519214", "0.5247765", "0.52239007", "0.52221555", "0.52205265", "0.5217893", "0.5214228", "0.5191314", "0.5174139", "0.51715195", "0.5169396", "0.51558197", "0.5147889", "0.51350576", "0.51252073", "0.5113607", "0.51075214", "0.5105596", "0.509493", "0.5089085", "0.5084206", "0.50481117", "0.5043737", "0.50404733", "0.503993", "0.5028896", "0.5026622", "0.5024609", "0.50225097", "0.50186926", "0.5004722", "0.4997952", "0.49855512", "0.49797556", "0.49796715", "0.49684504", "0.496656", "0.49594393", "0.49583036", "0.49535325", "0.4944352", "0.49397448", "0.49397448", "0.49329937", "0.4927408", "0.49179932", "0.4906194", "0.49054062", "0.4900426", "0.48984814", "0.48981237", "0.48887467", "0.48735267", "0.48717275", "0.4870485", "0.48678237", "0.48660457", "0.4863434", "0.4862946", "0.48618352", "0.48517656", "0.48481682", "0.4846865", "0.48420447", "0.4841168", "0.48299035", "0.4827693", "0.48260903", "0.48245084", "0.48226586", "0.48226586", "0.48176423" ]
0.0
-1
Show plot on IRuby notebook
def show Frame.new.tap {|f| f.add(self) }.show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot; end", "def show_in_iruby\n @adapter.show_in_iruby @chart\n end", "def beanplot\n end", "def view\n Rubyplot::Plotspace.new(self).view!\n end", "def configurePlot\n end", "def plot(data=[], options={})\n plot_to_image(data, options).to_blob\n end", "def display_graph()\n begin\n case\n when RUBY_PLATFORM.include?(\"linux\")\n exec(\"python3 src/plotter/plotter.py outputs/results.txt\")\n unless ARGV.include? \"--silent\"\n exec(\"xdg-open 'outputs/task_scheduling.png'\")\n exec(\"xdg-open 'outputs/power_consumption.png'\")\n end\n when RUBY_PLATFORM.include?(\"darwin\")\n exec(\"python3 src/plotter/plotter.py outputs/results.txt\")\n unless ARGV.include? \"--silent\"\n exec(\"xdg-open 'outputs/task_scheduling.png'\")\n exec(\"open 'outputs/power_consumption.png'\")\n end\n when RUBY_PLATFORM.include?(\"mswin\")\n exec(\"cmd /c python3 src/plotter/plotter.py outputs/results.txt\")\n unless ARGV.include? \"--silent\"\n exec(\"xdg-open 'outputs/task_scheduling.png'\")\n exec(\"cmd /c \\\"start 'outputs/power_consumption.png'\\\"\")\n end\n end\n rescue\n print(\"An error occured while executing the plotter.\")\n end\nend", "def dpShow(rangeopt = \"\", styles = DfltPlotStyle) \n styles = \"using 1:2 \" + styles if(@timeMode) ;\n datafile = @workfile ;\n if(saveScript?())\n datafile = '-' ;\n end\n com = sprintf(\"plot %s \\\"%s\\\" %s\",rangeopt,datafile,styles) ;\n\n @hline.each{|line|\n label = line[0] ;\n value = line[1] ;\n style = (line[2].nil?) ? \"dots\" : line[2] ;\n\n com += (\", %s title '%s' with %s\" % [value.to_s, label, style]) ; \n \n }\n\n command(com) ;\n\n if(saveScript?())\n open(@workfile){|strm|\n strm.each{|line|\n @strm << line\n }\n }\n @strm << \"e\\n\" ;\n end\n end", "def plot(*args)\n contents = parse_plot_args(PlotItem,args)\n _plot_splot(\"plot\",contents)\n nil\n end", "def plot type, options = {}\n v = vis(type, options)\n\n v.render()\n\n require \"rsvg2\"\n\n svg = RSVG::Handle.new_from_data(v.to_svg).tap { |s| s.close }\n SciRuby::Plotter.new svg\n end", "def show\n x = @plot.user.x\n y = @plot.user.y\n puts x\n puts y\n \n end", "def plot_script script, filename=nil, title=nil\n # stub method to enable documentation in yard\n end", "def show_figures(close=false)\n _pylab_helpers = PyCall.import_module('matplotlib._pylab_helpers')\n gcf = _pylab_helpers.Gcf\n kernel = ::IRuby::Kernel.instance\n gcf.get_all_fig_managers.each do |fig_manager|\n data = ::IRuby::Display.display(fig_manager.canvas.figure)\n kernel.session.send(:publish, :display_data, data: data, metadata: {})\n end\n ensure\n unless gcf.get_all_fig_managers.nil?\n Matplotlib::Pyplot.close('all')\n end\n end", "def plotGif(gp, sendcmd, ofname, xlabel, ylabel)\n [\n \"set terminal gif\" ,\n \"set output '#{ofname}'\",\n \"set xlabel '#{xlabel}'\",\n \"set ylabel '#{ylabel}'\",\n \"plot #{sendcmd}\"\n ].each{|cmd| gp.puts(cmd) }\n p ofname\nend", "def plot!\n return plot if plot && plot.valid? && plot.file_exists?\n plot.destroy if (plot)\n f = ExtendedArgumentationFramework::Framework.new(graph_representation, auto_generate_nodes: true)\n file = ExtendedArgumentationFramework::Plotter.new(f, plot_acceptability: false, edges_style: 'dir=back style=dashed').to_png\n p=Plot.create(filename: \"#{Plot::BASE_URL}/#{file}\", object: self)\n p\n end", "def visualize\n require 'open3'\n Open3.popen3('graph-easy') do |i,o,_|\n i.write to_graph_easy\n i.close\n puts o.read\n end\n end", "def to_iruby\n gif_base64 = Base64.encode64(plot)\n ['text/html', \"<img src=\\\"data:image/gif;base64, #{gif_base64}\\\">\"]\n end", "def notebook\n JupyterNotebook.new(content)\n end", "def plot(comString,doMultiPlot)\n\t\t# ---- print the options\n\t\tcom=\"echo '\\n\"+getStyleString+@oc[\"MiscOptions\"]\n\t\tcom=com+\"set multiplot;\\n\" if doMultiPlot\n\t com=com+\"plot \"+@oc[\"Range\"]+comString+\"\\n'| gnuplot -persist\"\n\t\tprintAndRun(com)\n\t\t# ---- convert to PDF\n\t\tif @oc[\"DoPDF\"]\n\t\t\tcom=\"ps2epsi foo.ps\"\n\t\t\tprintAndRun(com)\n\t\t\tcom=\"epstopdf foo.epsi\"\n\t\t\tprintAndRun(com)\n\t\t\tif @oc[\"OutputFileSpecified\"]!=\"\"\n\t\t\t\tcom=\"mv foo.pdf \"+@oc[\"OutputFileSpecified\"]\n\t\t\t\tprintAndRun(com)\n\t\t\tend\n\t\t\tcom=\"rm -f foo.ps foo.epsi\"\n\t\t\tprintAndRun(com)\n\t\tend\n\tend", "def projectPlot\n jsonLocation = CGI.escape(\"#{@scratch}/jobFile.json\")\n htmlLocation = CGI.escape(\"#{@outputDir}/htmlPages/#{@studyName1}\")\n system(\"importMicrobiomeProjectFiles.rb -j #{jsonLocation} -i #{htmlLocation} >#{@outputDir}/project_plot.log 2>#{@outputDir}/project_plot.error.log\")\n \n end", "def dmpShow(rangeopt = \"\", styles = DfltPlotStyle)\n com = sprintf(\"plot %s\",rangeopt) ;\n firstp = TRUE ;\n\n inlineDataList = [] ;\n\n @layerList.each{|k|\n next if (@workcount[k] <= 0) ;\n if(saveScript?())\n inlineDataList.push(@workfile[k]) ;\n file = '-' ;\n else\n file = @workfile[k] ;\n end\n if(firstp) then\n\tcom += \" \" ;\n\tfirstp = FALSE ;\n else\n\tcom += \", \" ;\n end\n\n localstyle = @localStyle[k] || styles ;\n using = (@timeMode ? \"using 1:2\" : \"\") ;\n\n if(title[k].nil?) then\n\tcom += sprintf(\"\\\"%s\\\" %s %s\",file,using,localstyle) ;\n else\n\tcom += sprintf(\"\\\"%s\\\" %s t \\\"%s\\\" %s\",file,using,\n title[k],localstyle) ;\n end\n }\n\n @hline.each{|line|\n label = line[0] ;\n value = line[1] ;\n style = (line[2].nil?) ? \"dots\" : line[2] ;\n\n com += (\", %s title '%s' with %s\" % [value.to_s, label, style]) ; \n \n }\n\n command(com) ;\n\n inlineDataList.each{|datafile|\n open(datafile){|strm|\n strm.each{|line|\n @strm << line ;\n }\n }\n @strm << \"e\\n\" ;\n }\n\n end", "def plot hsh_or_ary, type, options = {}\n vis = begin\n if hsh_or_ary.is_a?(OpenStruct)\n plot_hash hsh_or_ary, type, options\n elsif hsh_or_ary.is_a?(Array)\n plot_array hsh_or_ary, type, options\n end\n end\n\n vis.render()\n require \"rsvg2\"\n svg = RSVG::Handle.new_from_data(vis.to_svg).tap { |s| s.close }\n SciRuby::Plotter.new svg\n end", "def plot_script(counter = false)\n [\"set term png\",\n (if counter\n \"set output \\\"#{base}/#{counter}.png\\\"\" # \"set output \\\"#{base}/group.png\\\"\"\n else\n \"set output \\\"#{base}/group.png\\\"\"\n end),\n \"set pm3d\",\n # \"set pm3d map\",\n \"splot \\\"#{self.data_file(counter)}\\\" with pm3d title 'fitness' \"].join(\"\\n\")\n end", "def plot(p, i)\n x, y, sw, sh = p[0], p[1], p[2], p[3]\n\n @m.synchronize{\n puts \"#{x},#{y}: #{i}\"\n } \n\n end", "def replot(arg=nil)\n run \"replot #{arg}\", @last_data\n nil\n end", "def show\n IRuby.display(self)\n end", "def plot\n sanitize_plot(document.search(\"h5[text()='Plot:'] ~ div\").first.innerHTML) rescue nil\n end", "def visualize\n fc = javaobj\n vm = jnew(\"visualizer.VisuMain\")\n vm.init(fc)\n end", "def show\n\t\tputs @graph\n\tend", "def plot\n if( @itemList.length > 0 ) \n configurePlot()\n \n plotcmds = Array.new()\n \n @itemList.each { |item| plotcmds.push( item.command() ) }\n fullcmd = @plotcmd + \" \" + plotcmds.join(\", \")\n writeln( fullcmd )\n \n @itemList.each { |item| item.pipein( @gnuplot ) }\n @gnuplot.flush()\n else\n puts \"No items to plot\"\n end\n end", "def plot_against e1, e2\n Flot.new('experiment_roc_plot') do |f|\n f.points\n f.grid :hoverable => true\n f.legend :position => \"se\"\n f.yaxis 1\n f.series \"#{e1.title} against #{e2.title}\", e1.aucs_against(e2), :points => {:show => true, :radius => 1.5}\n end\nend", "def plot(*args)\n\t\t\n\t\tdata = []\n\t\tall_plots = ''\n\t\twhile args.length > 0\n\t\t\t#\n\t\t\t# NEXT PLOT\n\t\t\t#\n\t\t\t# First two values are the (x,y) points.\n\t\t\tdata << args.shift\n\t\t\tdata << args.shift\n\t\t\t\n\t\t\t# - Get the settings for this plot.\n\t\t\t# - If 'args' is not empty, there is another plot.\n\t\t\tthis_plot, args = styles(args)\n\t\t\tall_plots << this_plot\n\t\t\tall_plots << ', ' if args.length > 0\n\t\tend\n\t\t\n\t\t# TODO:\n\t\t# - Check for both Array and NMatrix.\n\t\t# - But make sure the program works without NMatrix loaded.\n\t\t#\n\t\t\n\t\t#\n\t\t# Each plot needs a separate stream of data separated by 'e' (\"end\").\n\t\t#\n\t\tnstreams = data.length / 2\n\t\t\n\t\tstream = (1..nstreams).map { |s|\n\t\t\tx = data.shift\n\t\t\ty = data.shift\n\t\t\tn = x.is_a?(Array) ? x.length - 1 : x.shape[0] - 1\n\t\t\t\n\t\t\t(0..n).map { |i| \"#{x[i]}\t#{y[i]}\\n\" }.join + \"e\\n\"\n\t\t}.join\n\t\t\n\t\t@pipe.puts \"plot #{all_plots} \\n#{stream}\"\n\tend", "def plot\n\n # Remove all elements from the dashboard. This could be changed in future releases\n # of the library.\n B.delete_all\n\n if (!@runned )\n run\n clean\n runned = true\n else\n re_run\n end\n\n end", "def scatter_plot\n print_csv_results\n FileUtils.mkdir_p(%w(gnuplot plots))\n erb(\"templates/scatter_plot.gp.erb\", \"gnuplot/scatter_plot.gp\", {:config => @config})\n system(\"#{@config[\"path_gnuplot\"] || \"gnuplot\"} gnuplot/scatter_plot.gp\")\n puts \"Draw a scatter_plot.#{@config[\"output_format\"] || \"png\"} in plots!\"\n FileUtils.rm_rf(%w(gnuplot data))\n end", "def plot_data data, series=nil, filename=nil, title=nil\n # stub method to enable documentation in yard\n\t\tend", "def raise_plot(plot_window_nb=nil)\n send_cmd \"raise #{plot_window_nb}\"\n nil\n end", "def plot(points = [])\n Gnuplot.open do |gp|\n Gnuplot::Plot.new(gp) do |plot|\n \n min_x = points.min - 1\n max_x = points.max + 1\n\n plot.terminal \"pngcairo\"\n plot.output @parameters[:fn]\n\n plot.style \"data boxplot\"\n plot.unset \"xtics\"\n plot.grid \"y2tics lc rgb \\\"#888888\\\" lw 1 lt 0\"\n plot.yrange \"[#{min_x}:#{max_x}]\"\n plot.y2range \"[#{min_x}:#{max_x}]\"\n plot.y2tics \"center rotate by 90 font \\\",15\\\"\"\n plot.unset \"ytics\"\n\n x = []\n y = []\n (min_x..max_x).to_a.each do |current_x|\n points.grep(current_x).size.times do\n x << 1\n y << current_x\n end if points.grep(current_x).size\n end\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.title = ''\n end\n\n label_index = 1\n @labels ||= []\n @labels.each do |l|\n plot.label \"#{label_index} '#{l[0]}' at #{l[1]}, #{l[2]} font 'Latin-Modern,#{l[3]}' tc rgb '#{l[4]}' rotate by 90 center\"\n label_index += 1\n end\n\n end\n end\n `convert -rotate 90 #{@parameters[:fn]} #{@parameters[:fn]}`\n @parameters[:fn]\n end", "def lower_plot(plot_window_nb=nil)\n send_cmd \"lower #{plot_window_nb}\"\n nil\n end", "def plotWxt(gp, sendcmd, ofname, xlabel, ylabel)\n [\n \"set output '#{ofname}'\",\n \"set xlabel '#{xlabel}'\",\n \"set ylabel '#{ylabel}'\",\n #\"splot '#{fname}' #{opt} title '#{nline}'\" \n #\"plot '#{fname}' #{opt} title '#{nline}'\"\n \"plot #{sendcmd}\",\n \"pause 1.2\",\n ].each{|cmd| gp.puts(cmd) }\nend", "def x_visualize\n require 'open3'\n Open3.popen3('dot -T svg | display') do |i,o,_|\n i.write to_dot\n i.close\n end\n end", "def show\n @plot = Plot.find(params[:id])\n @title = \"Plot Image\"\n\n\t if @plot.nil?\n\t\tredirect_to :action => \"index\"\n\t end\n\n\t respond_to do |format|\n\t format.html # show.html.erb\n\t format.xml { render :xml => @plot }\n\t end\n end", "def test01() ;\n range = \"[0:10][-1:1]\" ;\n Gnuplot::directMultiPlot(3,range) {|gplot|\n gplot.dmpSetTitle(0,\"foo\") ;\n gplot.dmpSetTitle(1,\"bar\") ;\n gplot.dmpSetTitle(2,\"baz\") ;\n (0...100).each{|k|\n x = 0.1 * k ;\n gplot.dmpXYPlot(0,x,x*x) ;\n gplot.dmpXYPlot(1,x,Math::sin(x)) ;\n gplot.dmpXYPlot(2,x,Math::cos(x)) ;\n gplot.dmpFlush(range) ;\n sleep 0.1 ;\n }\n }\n end", "def old_plot xmax, xmin, ymax, ymin, xdiff, ydiff, iterations, old_points\n puts \"\\e[H\\e[2J\" # clear screen\n ymax.step(ymin, -ydiff) do |y|\n print_num y\n (xmin).step(xmax, xdiff) do |x|\n itr = mandelbrot(Complex(x,y), iterations)\n #color = itr ? itr/iterations.to_f : 1.0\n #print \"*\".grayscale(color)\n whiteness = itr ? itr/iterations.to_f : 1\n print \"*\".grayscale(whiteness)\n end\n puts\n end\n (-xmax).step(xmax, xdiff) do |x|\n print_num x\n end\nend", "def splot(*args)\n contents = parse_plot_args(SPlotItem,args)\n _plot_splot(\"splot\",contents)\n nil\n end", "def plot(path = nil, **options)\n options[:output] ||= path\n plot_options = mix_options(options) do |plot_opts, anim_opts|\n plot_opts.merge(term: ['gif', anim_opts])\n end.to_h\n need_output = plot_options[:output].nil?\n plot_options[:output] = Dir.gnuplot_tmpname('anim') if need_output\n terminal = Terminal.new\n multiplot(terminal, plot_options)\n # guaranteed wait for plotting to finish\n terminal.close\n if need_output\n result = File.binread(plot_options[:output])\n File.delete(plot_options[:output])\n else\n result = nil\n end\n result\n end", "def show_graph\n url_for_data = url_for(controller.params.merge(:action => :data)).gsub('&amp;', '&')\n relative_url_path = ActionController::Base.respond_to?(:relative_url_root) ? ActionController::Base.relative_url_root : ActionController::AbstractRequest.relative_url_root\n html, div_name = controller.open_flash_chart_object_and_div_name('100%', '400', url_for_data, true, \"#{relative_url_path}/\")\n\n html << '<script type=\"text/javascript\">' << \"\\n\"\n html << \"var charts_to_image_title = '#{h(controller.title)}';\\n\" \n html << \"var charts_to_image_id = '#{div_name}';\\n\"\n html << '</script>'\n\n html\n end", "def plot(points = [])\n Gnuplot.open do |gp|\n Gnuplot::Plot.new(gp) do |plot|\n plot.terminal \"pngcairo size 460,460\"\n plot.output @parameters[:fn]\n plot.key \"off\"\n x = []\n y = []\n points << (@parameters[:high]-@parameters[:low])*2+@parameters[:high] if points.empty?\n @arrows ||= []\n if @parameters[:horizontal]\n plot.xrange \"[#{@parameters[:low]}:#{@parameters[:high]}]\"\n plot.yrange \"[0:1]\"\n plot.border 1\n plot.xtics generate_tics\n plot.unset \"ytics\"\n points.each do |p|\n x << p\n y << 0\n end\n @arrows.each do |a|\n if a[3]\n plot.arrow \"from #{a[0]}, 0.05 to #{a[1]}, 0.05 filled lc rgb '#{a[2]}'\"\n else\n plot.arrow \"from #{a[0]}, 0.05 to #{a[1]}, 0.05 heads filled lc rgb '#{a[2]}'\"\n end\n end\n else\n plot.yzeroaxis \"lt -1\"\n plot.xrange \"[-1:1]\"\n plot.yrange \"[#{@parameters[:low]}:#{@parameters[:high]}]\"\n plot.border 0\n plot.ytics \"axis #{generate_tics}\"\n plot.unset \"xtics\"\n points.each do |p|\n x << 0\n y << p\n end\n @arrows.each do |a|\n if a[3]\n plot.arrow \"from 0.1, #{a[0]} to 0.1, #{a[1]} filled lc rgb '#{a[2]}'\"\n else\n plot.arrow \"from 0.1, #{a[0]} to 0.1, #{a[1]} heads filled lc rgb '#{a[2]}'\"\n end\n end\n end\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.with = \"points pt 7 lc rgb '#{color}'\"\n ds.notitle\n end\n end\n end\n if @parameters[:horizontal]\n `convert #{@parameters[:fn]} -crop 460x100+0+360 +repage #{@parameters[:fn]}`\n else\n `convert #{@parameters[:fn]} -crop 100x460+180+0 +repage #{@parameters[:fn]}`\n end\n self\n end", "def plot_db(path: \"./\") \r\n self.plot(method: :dB, xsteps: 8, path: path) do |g|\r\n g.title = \"Decibles\"\r\n g.x_axis_label = \"Normalized Frequency\"\r\n g.y_axis_label = \"Magnitude\"\r\n end\r\n end", "def show\n @workflow = Workflow.find(params[:id])\n \n default_graph_settings = \"node [shape=box,style=filled];\\n\"\n \n @processed_graph = default_graph_settings + @workflow.graph + process_graph(@workflow)\n \n gv = IO.popen(\"/usr/local/bin/dot -q -Tpng\", \"w+\")\n gv.puts \"digraph G{\", @processed_graph, \"}\"\n gv.close_write\n @gvpng = gv.read\n\n\n gv = IO.popen(\"/usr/local/bin/dot -q -Tcmapx\", \"w+\")\n gv.puts \"digraph G{\", @processed_graph, \"}\"\n gv.close_write\n @gvmap = gv.read\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @workflow }\n end\n end", "def view\n\t `ruby #{File.dirname(__FILE__) + \"/viewer/viewer.rb\"}`\n end", "def generateSeriesPlot(xyData, options={})\n plotOptions={:width=>200, :height=>100, :imagetype=> \"png\", :xlabel=> \"\", :ylabel=> \"\"}\n plotOptions=plotOptions.merge(options)\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n plot.terminal \"#{plotOptions[:imagetype]} small enhanced size #{plotOptions[:width]},#{plotOptions[:height]} crop\"\n plot.output Rails.root.to_s+\"/public/series.png\"\n plot.ylabel plotOptions[:ylabel]\n plot.xlabel plotOptions[:xlabel]\n plot.boxwidth 0.5\n plot.grid \"\"\n plot.data << Gnuplot::DataSet.new( xyData ) do |ds|\n ds.with = \"boxes fill solid 0.5\"\n ds.notitle\n end\n end\n end\n end", "def show\n set_cell\n end", "def runSinFrSin(filename)\n\t\tstyleArr=@oc[\"StyleIndices\"].split(\",\")\n\t\tcom=\"\\\"\"+filename+\"\\\" \"\n\t\tcom=com+\"title \\\"\"+@oc[\"TitleString\"]+\"\\\" \" if @oc[\"TitleString\"]!=\"\"\n\t\tcom=com+\"with \"+@oc[\"LineType\"]+\" ls \"+styleArr[0]\n\t\tplot(com,false)\n\tend", "def draw_basic_plot(params) \n jitter = params[:jitter]\n grouplist = params[:grouplist]\n snp_list = params[:snp_list]\n x_start = params[:x_start]\n y_start = params[:y_start]\n stat_max = params[:stat_max]\n stat_min = params[:stat_min]\n data_key = params[:data_key]\n plot_labels = params[:plot_labels]\n title = params[:title]\n precision = params[:precision]\n rotate = params[:rotate] || false\n size_mult = params[:size_mult] || 1\n prefix_title = params[:prefix_title] || \"\"\n lci_key = params[:lci_key] || nil\n uci_key = params[:uci_key] || nil\n \n x = @box_size\n xmin = x\n ymin = 0\n ymax = @box_size*9 * size_mult\n y_interval = ymax-ymin\n # set stat_min to be zero\n stat_interval = stat_max - stat_min\n\n value_x = xmin * 0.7 + (@box_size * Math.sqrt(2)*0.25)/2\n \n fill_opacity = 0.9\n if Shape.get_grayscale\n fill_opacity = 1.0\n end\n \n # draw box (change to triangle) with correct color\n snp_list.included_snps.each do |snp_index|\n draw_separator = true\n snp = snp_list.snps[snp_index]\n \n #draw_separation(x_start, y_start, 0, ymax, value_x) unless lci_key\n\n # store points here for output\n points = Array.new\n lines = Array.new\n\n grouplist.groups.each do |group|\n if snp.results.has_key?(group.name)\n result = snp.results[group.name]\n if !result.values[data_key] or result.values[data_key] !~ /\\d/\n next\n end\n box_y_start = ((stat_max-result.values[data_key].to_f) / stat_interval) * y_interval\n\n if rotate\n box_y_start = y_interval - box_y_start\n end\n\n if !group.highlighted\n points << Circle.new(value_x, box_y_start, @box_size * Math.sqrt(2)*0.125, group.colorstr)\n else\n # create triangle here\n points << create_diamond(box_y_start, value_x, 1.0, group.colorstr)\n end\n \n # create a line if there is a confidence interval\n if result.values[uci_key]\n draw_separator = false\n uci_y = ((stat_max-result.values[uci_key].to_f) / stat_interval) * y_interval\n lci_y = ((stat_max-result.values[lci_key].to_f) / stat_interval) * y_interval\n if rotate\n uci_y = y_interval - uci_y\n lci_y = y_interval - lci_y\n end \n\n points.last.interval = Line.new([value_x,value_x], [lci_y,uci_y], group.colorstr)\n end\n \n end\n\n end\n draw_separation(x_start, y_start, 0, ymax, value_x)# if draw_separator\n # sort by y-midpoint\n points.sort! {|x,y| y.ymidpoint <=> x.ymidpoint}\n #lines.sort! {|x,y| y.ymidpoint <=> x.ymidpoint} unless lines.empty?\n\n # those points that overlap significantly\n if jitter\n adjust_horizontal(points, y_interval)\n end\n\n\t # iterate through points and draw all of them\n\t points.each do |point|\n if point.interval \n point.interval.xpoints[0] = point.interval.xpoints[1] = point.xmidpoint\n @canvas.g.translate(x_start,y_start) do |check|\n check.styles(:stroke_width=>2)\n point.interval.draw(check)\n end\n end \n \t end\n\n\t points.each do |point|\n \t @canvas.g.translate(x_start,y_start) do |check|\n \t check.styles(:stroke_width=>1, :fill_opacity=>fill_opacity)\n \t point.draw(check)\n \t end \n end\n \n value_x = label_step(value_x)\n end\n\n if plot_labels\n if rotate\n x_label_start = value_x + x_start+ @box_size * 0.4 \n else\n x_label_start = x_start \n end\n\n if size_mult >= 1\n write_plot_labels(x_label_start, y_start, ymax, stat_max, stat_min, y_interval, 0, prefix_title+title, false, precision, rotate)\n else\n write_plot_labels(x_label_start, y_start, ymax, stat_max, stat_min, y_interval, 0, prefix_title+title,\n false, precision, rotate, 5)\n end\n end\n end", "def rubyvis_panel # :nodoc:\n pre_vis\n #that=self\n \n @minimum_x||=@hist.min\n @maximum_x||=@hist.max\n @minimum_y||=0\n @maximum_y||=@hist.max_val\n \n margin_hor=margin_left + margin_right\n margin_vert=margin_top + margin_bottom\n \n x_scale = pv.Scale.linear(@minimum_x, @maximum_x).range(0, width - margin_hor)\n \n y_scale=Rubyvis::Scale.linear(@minimum_y, @maximum_y).range(0, height - margin_vert)\n \n y_scale.nice\n \n bins=@hist.bins.times.map {|i|\n {\n :low =>@hist.get_range(i)[0],\n :high=>@hist.get_range(i)[1],\n :value=>@hist.bin[i]\n }\n }\n @x_scale=x_scale\n @y_scale=y_scale\n # cache data\n vis=Rubyvis::Panel.new do |pan| \n pan.width width - margin_hor\n pan.height height - margin_vert\n pan.bottom margin_bottom\n pan.left margin_left\n pan.right margin_right\n pan.top margin_top\n # Y axis\n pan.rule do\n data y_scale.ticks\n bottom y_scale\n stroke_style {|d| d!=0 ? \"#eee\" : \"#000\"}\n label(:anchor=>'left') do\n text y_scale.tick_format\n end\n end\n # X axis\n pan.rule do\n data x_scale.ticks\n left x_scale\n stroke_style \"black\"\n height 5\n bottom(-5)\n label(:anchor=>'bottom') do\n text x_scale.tick_format\n end\n end\n \n pan.bar do |bar|\n bar.data(bins)\n bar.left {|v| x_scale[v[:low]]}\n bar.width {|v| x_scale[v[:high]] - x_scale[v[:low]]}\n bar.bottom 0\n bar.height {|v| y_scale[v[:value]]}\n bar.stroke_style \"black\"\n bar.line_width 1\n end\n rubyvis_normal_distribution(pan) if @line_normal_distribution\n end\n vis\n end", "def axes\n end", "def plot(points = [], points2 = [])\n Gnuplot.open do |gp|\n Gnuplot::Plot.new(gp) do |plot|\n \n min_x = (points + points2).min - 1\n max_x = (points + points2).max + 1\n\n plot.terminal \"pngcairo\"\n plot.output @parameters[:fn]\n\n plot.style \"data boxplot\"\n plot.unset \"xtics\"\n plot.grid \"y2tics lc rgb \\\"#888888\\\" lw 1 lt 0\"\n plot.yrange \"[#{min_x}:#{max_x}]\"\n plot.y2range \"[#{min_x}:#{max_x}]\"\n\n plot.xrange \"[0.6:2]\"\n plot.x2range \"[0.6:2]\"\n\n plot.y2tics \"center rotate by 90 font \\\",15\\\"\"\n plot.unset \"ytics\"\n\n x = []\n y = []\n\n (min_x..max_x).to_a.each do |current_x|\n points.grep(current_x).size.times do\n x << 1\n y << current_x\n end if points.grep(current_x).size\n end\n\n x2 = []\n y2 = []\n (min_x..max_x).to_a.each do |current_x|\n points2.grep(current_x).size.times do\n x2 << 1.6\n y2 << current_x\n end if points2.grep(current_x).size\n end\n \n plot.data = [\n Gnuplot::DataSet.new([x, y]) { |ds|\n ds.title = ''\n },\n\n Gnuplot::DataSet.new([x2, y2]) { |ds|\n ds.title = ''\n ds.linecolor = \"rgb \\\"red\\\"\"\n }\n ]\n\n label_index = 1\n @labels ||= []\n @labels.each do |l|\n plot.label \"#{label_index} '#{l[0]}' at #{l[1]}, #{l[2]} font 'Latin-Modern,#{l[3]}' tc rgb '#{l[4]}' rotate by 90 center\"\n label_index += 1\n end\n\n end\n end\n `convert -rotate 90 #{@parameters[:fn]} #{@parameters[:fn]}`\n @parameters[:fn]\n end", "def graph_it\n\t\tputs \"Calling R\"\n\t\tr = RSRuby.instance\n\n\t\tputs \"R Summary Statistics:\"\n\t\tputs \"Median Edits Per User: #{r.median(@users.values)}\"\n\t\tputs \"Average Edits Per User: #{r.mean(@users.values)}\"\n\t\tputs \"Variance in Edits Per User: #{r.var(@users.values)}\"\n\t\tputs \"The Standard Deviation is: #{r.sd(@users.values)}\"\n\n\t\tr.png(\"img_exports/#{@dataset}_edits_per_user.png\", :width=>1200, :height=>600)\n\t\tr.barplot(\t:height =>(@users.values.sort.reverse), \n\t\t\t \t\t:log=>'y',\n\t\t\t \t\t:ylab=>\"Number of Edits\", \n\t\t\t \t\t:xlab=>\"Users\", \n\t\t\t \t\t:main=>\"#{@dataset.capitalize}: Number of Edits per User\",\n\t\t\t \t\t:cex_main=>2,\n\t\t\t \t\t:cex_lab=>1.2)\n\t\tr.eval_R \"dev.off()\"\n\t\tputs \"Finished Writing Graph\"\n\tend", "def show\n graph = GraphViz.new(:G, type: :digraph)\n competency = Competency.find(params[:id])\n graphviz(graph, competency)\n @file = Tempfile.new(['foo', '.png'], \"#{Rails.root}/public/images\")\n graph.output(png: @file.path)\n end", "def request_plot(args, options)\n\n experiments = options.experiments.split(',')\n machines = options.machines.split(',')\n\n data = Ppbench::load_data(args)\n filtered_data = Ppbench::filter(\n data,\n experiments: experiments,\n machines: machines\n )\n aggregated_data = Ppbench::aggregate(filtered_data)\n\n max_x = Ppbench::maximum(aggregated_data, of: :length)\n max_y = Ppbench::maximum(aggregated_data, of: :rps)\n\n rplot = Ppbench::plotter(\n aggregated_data,\n to_plot: :rps,\n machines: machines,\n experiments: experiments,\n receive_window: options.recwindow,\n xaxis_max: options.xaxis_max == 0 ? max_x : options.xaxis_max,\n confidence: options.confidence,\n no_points: options.nopoints,\n with_bands: options.withbands,\n yaxis_max: options.yaxis_max == 0 ? max_y : options.yaxis_max,\n yaxis_steps: options.yaxis_steps,\n xaxis_steps: options.xaxis_steps,\n title: \"Requests per seconds\",\n subtitle: \"bigger is better\",\n xaxis_title: \"Message Size\",\n xaxis_unit: \"kB\",\n yaxis_title: \"Requests per seconds\",\n yaxis_unit: \"Req/sec\",\n yaxis_divisor: 1\n )\n\n pdf = pdfout(rplot, file: options.pdf, width: options.width, height: options.height)\n print(\"#{pdf}\") unless options.pdf.empty?\n print(\"#{rplot}\") if options.pdf.empty?\nend", "def begin_figure\n # do nothing\n end", "def plot_1d\n plotter = Plotter.new(:title => \"Signal: values vs. sample number\", :xtitle => \"sample number\", :ytitle => \"sample value\")\n plotter.plot_1d \"signal data\" => @data\n end", "def export_iruby(export_type='png', file_name='chart')\n IRuby.html(export(export_type, file_name))\n end", "def plot_data\n clear_lines\n @buffer.keys.each { |k| plot_data_line(k, @buffer[k]) }\n end", "def notebook\n @notebook = Notebook.new(@@auth_store) if @notebook.nil?\n @notebook\n end", "def plot_array ary, type, options = {}\n\n options[:colors] ||= :category10\n colors = Rubyvis::Colors.send(options[:colors])\n\n options[:panel] = vis(options) # set up panel\n ary.each_index do |i|\n options[:panel] = ary[i].vis(type, options.merge({:line_color => colors[i % colors.size]}))\n end\n\n options[:panel]\n end", "def show\n @notebook = Notebook.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @notebook }\n end\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def S(args)\n puts \"\\n=>\\n\"\n @image.show\n end", "def display\n puts \" #{@cells[0]} | #{@cells[1]} | #{@cells[2]} \"\n puts \"-----------\"\n puts \" #{@cells[3]} | #{@cells[4]} | #{@cells[5]} \"\n puts \"-----------\"\n puts \" #{@cells[6]} | #{@cells[7]} | #{@cells[8]} \"\n end", "def display\n puts \" #{@cells[0]} | #{@cells[1]} | #{@cells[2]} \"\n puts \"-----------\"\n puts \" #{@cells[3]} | #{@cells[4]} | #{@cells[5]} \"\n puts \"-----------\"\n puts \" #{@cells[6]} | #{@cells[7]} | #{@cells[8]} \"\n end", "def display\n grid.each { |line| p line }\n end", "def index\n @plots = Plot.all\n end", "def index\n @plots = Plot.all\n end", "def index\n @plots = Plot.all\n end", "def plot_visible_only=(v) Axlsx.validate_boolean(v); @plot_visible_only = v; end", "def to_display\n api = latest_report\n\n Inkblot::Components::IconPane.new do |ic|\n ic.fullscreen = ic.fixed_height = true\n\n ic.icons = [api[:icon], :\"#8203\", api[:wind_speed], api[:wind_dir]]\n\n ic.frame_contents = Inkblot::Components::SimpleText.new do |st|\n st.text = api[@disp]\n st.size = 60 if @disp == :temp\n end\n end\n end", "def show\n # If the current user does not have access to that notebook -> show not found\n if @notebook.user != current_user\n not_found\n end\n end", "def set_notebook\n @notebook = Notebook.find(params[:id])\n end", "def set_notebook\n @notebook = Notebook.find(params[:id])\n end", "def set_notebook\n @notebook = Notebook.find(params[:id])\n end", "def set_notebook\n @notebook = Notebook.find(params[:id])\n end", "def set_notebook\n @notebook = Notebook.find(params[:id])\n end", "def initialize(plots)\n @t = FigureMaker.default\n @margin = 0.025\n\n plots.each do |plot|\n t.def_figure(plot.title) { exec_plot(plot) }\n end\n\n end", "def initialize(backend: :default)\n @backend = backend\n @subplots_list = [Rubyplot::SubPlot.new(1, 1, 1)]\n @tasks = []\n @x_title = ''\n @y_title = ''\n @x_range = [0, 0]\n @y_range = [0, 0]\n @origin = [:default, :default]\n @x_tick_count = :default\n @y_tick_count = :default\n @title = nil\n @title_shift = 0\n @text_font = :default\n @grid = true\n @bounding_box = true\n @x_axis_padding = :default\n @y_axis_padding = :default\n if @backend == :default || @backend == :GR\n require(__dir__.to_s << '/scripting_backends/gr/gr_backend')\n end\n @active_subplot = @subplots_list[0]\n @no_subplot = true\n end", "def displayOpen( options={} ) # open the graph (preamble)\n $options = options\n if $options != nil then\n if $options.has_key? :layout then $layout = options[:layout] end\n if $options.has_key? :rankdir then $rankdir = options[:rankdir] end\n end\n puts \"digraph G {\"\n puts \" rankdir=#{$rankdir}\"\n puts \" layout=\\\"#{$layout}\\\"\"\n puts \" fontname = \\\"Bitstream Vera Sans\\\"\"\n puts \" ucd [shape=plaintext, fontsize=18, label=\\\"#{$name}\\\"] \" if $layout == :circo\nend", "def show\n @notebook = Notebook.find(params[:id])\n render json: @notebook\n end", "def display\n puts \" #{@cells[0]} \" + \"|\" + \" #{@cells[1]} \" + \"|\" + \" #{@cells[2]} \"\n puts \"-----------\"\n puts \" #{@cells[3]} \" + \"|\" + \" #{@cells[4]} \" + \"|\" + \" #{@cells[5]} \"\n puts \"-----------\"\n puts \" #{@cells[6]} \" + \"|\" + \" #{@cells[7]} \" + \"|\" + \" #{@cells[8]} \"\n end", "def plot(opts = {}, &block)\n\t\t\tdefault_opts = {:type => DOMAIN_COLORED_PLOT, :color => ChunkyPNG::Color::BLACK,\n\t\t\t\t:vert => DLINES, :horz => DLINES}\n\t\t\topts = default_opts.merge(opts)\n\t\t\tif opts[:type] == DOMAIN_COLORED_PLOT and @size > 0\n\t\t\t\twarn \"Warning in #{self.class}::plot: DOMAIN_COLORED_PLOT will overdraw existing #{@size} plots. Draw 1st for correct behavior.\"\n\t\t\tend\n\t\t\tcase opts[:type]\n\t\t\t\twhen DOMAIN_COLORED_PLOT then plotDCPlot(opts, &block)\n\t\t\t\twhen COMPLEX_CONTOUR_PLOT then plotCCPlot(opts, &block)\n\t\t\t\telse raise RangeError, \"Invalid plot type #{opts[:type]}.\"\n\t\t\tend\n\t\t\t@size += 1\n\t\tend", "def use_axes?\n end", "def plot_accuracy(your_accuracy, compare_accuracy)\n @yours = PlotGraph::Graphs.column 'Correct questions', your_accuracy, \"Performance over the days\", \"No of correct questions\"\n @comparison = PlotGraph::Graphs.bar 'Your score', 'Event Average', your_accuracy, compare_accuracy, \"Performance over the days\", \"QNo of correct questions\" \n @comparison = [@comparison] \n end", "def export(plot, export_type='png', file_name='chart')\n plot.export_iruby(export_type, file_name) if defined? IRuby\n rescue NameError\n plot.export(export_type, file_name)\n end", "def request_comparison_plot(args, options)\n\n experiments = options.experiments.split(',')\n machines = options.machines.split(',')\n\n data = Ppbench::load_data(args)\n filtered_data = Ppbench::filter(\n data,\n experiments: experiments,\n machines: machines\n )\n aggregated_data = Ppbench::aggregate(filtered_data)\n\n max_x = Ppbench::maximum(aggregated_data, of: :length)\n\n rplot = Ppbench::comparison_plotter(\n aggregated_data,\n yaxis_max: options.yaxis_max,\n to_plot: :rps,\n machines: machines,\n experiments: experiments,\n receive_window: options.recwindow,\n xaxis_max: options.xaxis_max == 0 ? max_x : options.xaxis_max,\n xaxis_steps: options.xaxis_steps,\n title: \"Requests per second in relative comparison\",\n subtitle: \"bigger is better\",\n xaxis_title: \"Message Size\",\n xaxis_unit: \"kB\",\n xaxis_divisor: 1000,\n yaxis_title: \"Ratio\",\n )\n\n pdf = pdfout(rplot, file: options.pdf, width: options.width, height: options.height)\n print(\"#{pdf}\") unless options.pdf.empty?\n print(\"#{rplot}\") if options.pdf.empty?\nend", "def index\n @tbdotreports = Tbdotreport.new\n @tbdotreports.drawDotsGraph(\"work\")\n end", "def plot(clusters, show_centroids = true)\n # Graph output by running gnuplot pipe\n Gnuplot.open do |gp|\n # Start a new plot\n Gnuplot::Plot.new(gp) do |plot|\n # Plot each cluster's points\n clusters.each do |cluster|\n # Collect all x and y coords for this cluster\n x = cluster.points.map { |p| p[0] }\n y = cluster.points.map { |p| p[1] }\n\n # Plot w/o a title (clutters things up)\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.notitle\n end\n\n next unless show_centroids\n\n # Centroid point as bigger black points\n x = [cluster.centroid.x]\n y = [cluster.centroid.y]\n\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.notitle\n ds.linecolor = '000000'\n ds.linewidth = 3\n end\n end\n end\n end\nend", "def plot_to_file(filename=\"sparklines.png\", data=[], options={})\n File.open( filename, 'wb' ) do |png|\n png << self.plot( data, options)\n end\n end", "def run_irb close_operation = JFrame::HIDE_ON_CLOSE # DISPOSE_ON_CLOSE ?\n STDERR.puts \"RubyConsole run_irb called\"\n text = javax.swing.JTextPane.new\n text.font = RubyConsole.find_font 'Monospaced', Font::PLAIN, 14, 'Menlo', 'Monaco', 'Andale Mono'\n text.margin = java.awt.Insets.new(8, 8, 8, 8)\n text.caret_color = Color.new(0xa4, 0x00, 0x00)\n text.background = Color.new(0xf2, 0xf2, 0xf2)\n text.foreground = Color.new(0xa4, 0x00, 0x00)\n\n @irb_pane = javax.swing.JScrollPane.new\n @irb_pane.viewport_view = text\n\n @file_button = javax.swing.JButton.new \"Load file\"\n\n pane = javax.swing.JPanel.new java.awt.GridBagLayout.new\n pane.add(@irb_pane, AwtUtil.getConstraints(0, 0, 1, 1, 4, 1, true, true))\n pane.add(@file_button, AwtUtil.getConstraints(0, 3, 1, 0, 1, 1, false, true))\n\n# enableEvents(WindowEvent.WINDOW_CLOSING);\n @file_button.addActionListener(self)\n\n @frame = JFrame.new \"Moneydance Interactive JRuby #{JRUBY_VERSION} Console \" +\n \"(tab will autocomplete)\"\n @frame.default_close_operation = close_operation\n @frame.set_size 800, 800\n @frame.content_pane.add pane # @frame.add pane\n\n header = \" MD - Moneydance context: ComMoneydanceAppsMdController::Main \\n\" +\n \" ROOT - Moneydance root account: ComMoneydanceAppsMdModel::RootAccount \\n\" +\n \" TRANS - Moneydance TransactionSet: ComMoneydanceAppsMdModel::TransactionSet \\n\\n\"\n\n readline = org.jruby.demo.TextAreaReadline.new text, header\n JRuby.objectspace = true # useful for code completion\n readline.hook_into_runtime_with_streams(JRuby.runtime)\n\n EventQueue.invoke_later proc { show }\n\n ARGV << '--readline' << '--prompt' << 'inf-ruby'\n IRB.start(__FILE__)\n @ruby_main.cleanup\n end", "def display_data_universe\n\n end" ]
[ "0.70270705", "0.6580019", "0.6541519", "0.6401503", "0.63217396", "0.6113924", "0.60458314", "0.6037573", "0.6013541", "0.59443295", "0.593125", "0.5924139", "0.58871317", "0.58349884", "0.58332187", "0.5793367", "0.57504535", "0.5736102", "0.5728279", "0.57273006", "0.5688665", "0.5628192", "0.5605533", "0.559909", "0.5573057", "0.5569223", "0.5567265", "0.55633557", "0.5526159", "0.5519153", "0.549519", "0.5490234", "0.54838675", "0.5441006", "0.5409033", "0.53572303", "0.5348105", "0.5341706", "0.5314958", "0.53009474", "0.52946633", "0.5224645", "0.5219233", "0.5186446", "0.5183019", "0.5160589", "0.51597536", "0.51553184", "0.512379", "0.512196", "0.511782", "0.5104562", "0.510125", "0.5086089", "0.5083649", "0.5082521", "0.5039887", "0.50064707", "0.5003957", "0.49999997", "0.4993597", "0.49903646", "0.49883172", "0.4975097", "0.49665582", "0.4965281", "0.49561337", "0.49512625", "0.49512625", "0.49512625", "0.49512625", "0.49486983", "0.49409938", "0.49409938", "0.49251693", "0.49195907", "0.49195907", "0.49195907", "0.49188015", "0.49165568", "0.49057755", "0.49057594", "0.49057594", "0.49057594", "0.49057594", "0.49030256", "0.4899392", "0.48972642", "0.48907667", "0.48876056", "0.4886043", "0.4881395", "0.48809537", "0.4873043", "0.48659974", "0.485888", "0.48560122", "0.48532102", "0.48448154", "0.48445907", "0.48442152" ]
0.0
-1
Show plot automatically on IRuby notebook
def to_iruby Frame.new.tap {|f| f.add(self) }.to_iruby end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot; end", "def configurePlot\n end", "def beanplot\n end", "def show_in_iruby\n @adapter.show_in_iruby @chart\n end", "def view\n Rubyplot::Plotspace.new(self).view!\n end", "def dpShow(rangeopt = \"\", styles = DfltPlotStyle) \n styles = \"using 1:2 \" + styles if(@timeMode) ;\n datafile = @workfile ;\n if(saveScript?())\n datafile = '-' ;\n end\n com = sprintf(\"plot %s \\\"%s\\\" %s\",rangeopt,datafile,styles) ;\n\n @hline.each{|line|\n label = line[0] ;\n value = line[1] ;\n style = (line[2].nil?) ? \"dots\" : line[2] ;\n\n com += (\", %s title '%s' with %s\" % [value.to_s, label, style]) ; \n \n }\n\n command(com) ;\n\n if(saveScript?())\n open(@workfile){|strm|\n strm.each{|line|\n @strm << line\n }\n }\n @strm << \"e\\n\" ;\n end\n end", "def show_figures(close=false)\n _pylab_helpers = PyCall.import_module('matplotlib._pylab_helpers')\n gcf = _pylab_helpers.Gcf\n kernel = ::IRuby::Kernel.instance\n gcf.get_all_fig_managers.each do |fig_manager|\n data = ::IRuby::Display.display(fig_manager.canvas.figure)\n kernel.session.send(:publish, :display_data, data: data, metadata: {})\n end\n ensure\n unless gcf.get_all_fig_managers.nil?\n Matplotlib::Pyplot.close('all')\n end\n end", "def display_graph()\n begin\n case\n when RUBY_PLATFORM.include?(\"linux\")\n exec(\"python3 src/plotter/plotter.py outputs/results.txt\")\n unless ARGV.include? \"--silent\"\n exec(\"xdg-open 'outputs/task_scheduling.png'\")\n exec(\"xdg-open 'outputs/power_consumption.png'\")\n end\n when RUBY_PLATFORM.include?(\"darwin\")\n exec(\"python3 src/plotter/plotter.py outputs/results.txt\")\n unless ARGV.include? \"--silent\"\n exec(\"xdg-open 'outputs/task_scheduling.png'\")\n exec(\"open 'outputs/power_consumption.png'\")\n end\n when RUBY_PLATFORM.include?(\"mswin\")\n exec(\"cmd /c python3 src/plotter/plotter.py outputs/results.txt\")\n unless ARGV.include? \"--silent\"\n exec(\"xdg-open 'outputs/task_scheduling.png'\")\n exec(\"cmd /c \\\"start 'outputs/power_consumption.png'\\\"\")\n end\n end\n rescue\n print(\"An error occured while executing the plotter.\")\n end\nend", "def plot!\n return plot if plot && plot.valid? && plot.file_exists?\n plot.destroy if (plot)\n f = ExtendedArgumentationFramework::Framework.new(graph_representation, auto_generate_nodes: true)\n file = ExtendedArgumentationFramework::Plotter.new(f, plot_acceptability: false, edges_style: 'dir=back style=dashed').to_png\n p=Plot.create(filename: \"#{Plot::BASE_URL}/#{file}\", object: self)\n p\n end", "def plot_script script, filename=nil, title=nil\n # stub method to enable documentation in yard\n end", "def plot(comString,doMultiPlot)\n\t\t# ---- print the options\n\t\tcom=\"echo '\\n\"+getStyleString+@oc[\"MiscOptions\"]\n\t\tcom=com+\"set multiplot;\\n\" if doMultiPlot\n\t com=com+\"plot \"+@oc[\"Range\"]+comString+\"\\n'| gnuplot -persist\"\n\t\tprintAndRun(com)\n\t\t# ---- convert to PDF\n\t\tif @oc[\"DoPDF\"]\n\t\t\tcom=\"ps2epsi foo.ps\"\n\t\t\tprintAndRun(com)\n\t\t\tcom=\"epstopdf foo.epsi\"\n\t\t\tprintAndRun(com)\n\t\t\tif @oc[\"OutputFileSpecified\"]!=\"\"\n\t\t\t\tcom=\"mv foo.pdf \"+@oc[\"OutputFileSpecified\"]\n\t\t\t\tprintAndRun(com)\n\t\t\tend\n\t\t\tcom=\"rm -f foo.ps foo.epsi\"\n\t\t\tprintAndRun(com)\n\t\tend\n\tend", "def plot_script(counter = false)\n [\"set term png\",\n (if counter\n \"set output \\\"#{base}/#{counter}.png\\\"\" # \"set output \\\"#{base}/group.png\\\"\"\n else\n \"set output \\\"#{base}/group.png\\\"\"\n end),\n \"set pm3d\",\n # \"set pm3d map\",\n \"splot \\\"#{self.data_file(counter)}\\\" with pm3d title 'fitness' \"].join(\"\\n\")\n end", "def dmpShow(rangeopt = \"\", styles = DfltPlotStyle)\n com = sprintf(\"plot %s\",rangeopt) ;\n firstp = TRUE ;\n\n inlineDataList = [] ;\n\n @layerList.each{|k|\n next if (@workcount[k] <= 0) ;\n if(saveScript?())\n inlineDataList.push(@workfile[k]) ;\n file = '-' ;\n else\n file = @workfile[k] ;\n end\n if(firstp) then\n\tcom += \" \" ;\n\tfirstp = FALSE ;\n else\n\tcom += \", \" ;\n end\n\n localstyle = @localStyle[k] || styles ;\n using = (@timeMode ? \"using 1:2\" : \"\") ;\n\n if(title[k].nil?) then\n\tcom += sprintf(\"\\\"%s\\\" %s %s\",file,using,localstyle) ;\n else\n\tcom += sprintf(\"\\\"%s\\\" %s t \\\"%s\\\" %s\",file,using,\n title[k],localstyle) ;\n end\n }\n\n @hline.each{|line|\n label = line[0] ;\n value = line[1] ;\n style = (line[2].nil?) ? \"dots\" : line[2] ;\n\n com += (\", %s title '%s' with %s\" % [value.to_s, label, style]) ; \n \n }\n\n command(com) ;\n\n inlineDataList.each{|datafile|\n open(datafile){|strm|\n strm.each{|line|\n @strm << line ;\n }\n }\n @strm << \"e\\n\" ;\n }\n\n end", "def plot(data=[], options={})\n plot_to_image(data, options).to_blob\n end", "def plotGif(gp, sendcmd, ofname, xlabel, ylabel)\n [\n \"set terminal gif\" ,\n \"set output '#{ofname}'\",\n \"set xlabel '#{xlabel}'\",\n \"set ylabel '#{ylabel}'\",\n \"plot #{sendcmd}\"\n ].each{|cmd| gp.puts(cmd) }\n p ofname\nend", "def show\n x = @plot.user.x\n y = @plot.user.y\n puts x\n puts y\n \n end", "def plot(*args)\n contents = parse_plot_args(PlotItem,args)\n _plot_splot(\"plot\",contents)\n nil\n end", "def plot type, options = {}\n v = vis(type, options)\n\n v.render()\n\n require \"rsvg2\"\n\n svg = RSVG::Handle.new_from_data(v.to_svg).tap { |s| s.close }\n SciRuby::Plotter.new svg\n end", "def lower_plot(plot_window_nb=nil)\n send_cmd \"lower #{plot_window_nb}\"\n nil\n end", "def plot\n\n # Remove all elements from the dashboard. This could be changed in future releases\n # of the library.\n B.delete_all\n\n if (!@runned )\n run\n clean\n runned = true\n else\n re_run\n end\n\n end", "def scatter_plot\n print_csv_results\n FileUtils.mkdir_p(%w(gnuplot plots))\n erb(\"templates/scatter_plot.gp.erb\", \"gnuplot/scatter_plot.gp\", {:config => @config})\n system(\"#{@config[\"path_gnuplot\"] || \"gnuplot\"} gnuplot/scatter_plot.gp\")\n puts \"Draw a scatter_plot.#{@config[\"output_format\"] || \"png\"} in plots!\"\n FileUtils.rm_rf(%w(gnuplot data))\n end", "def visualize\n require 'open3'\n Open3.popen3('graph-easy') do |i,o,_|\n i.write to_graph_easy\n i.close\n puts o.read\n end\n end", "def replot(arg=nil)\n run \"replot #{arg}\", @last_data\n nil\n end", "def projectPlot\n jsonLocation = CGI.escape(\"#{@scratch}/jobFile.json\")\n htmlLocation = CGI.escape(\"#{@outputDir}/htmlPages/#{@studyName1}\")\n system(\"importMicrobiomeProjectFiles.rb -j #{jsonLocation} -i #{htmlLocation} >#{@outputDir}/project_plot.log 2>#{@outputDir}/project_plot.error.log\")\n \n end", "def plot\n sanitize_plot(document.search(\"h5[text()='Plot:'] ~ div\").first.innerHTML) rescue nil\n end", "def plot\n if( @itemList.length > 0 ) \n configurePlot()\n \n plotcmds = Array.new()\n \n @itemList.each { |item| plotcmds.push( item.command() ) }\n fullcmd = @plotcmd + \" \" + plotcmds.join(\", \")\n writeln( fullcmd )\n \n @itemList.each { |item| item.pipein( @gnuplot ) }\n @gnuplot.flush()\n else\n puts \"No items to plot\"\n end\n end", "def plot_against e1, e2\n Flot.new('experiment_roc_plot') do |f|\n f.points\n f.grid :hoverable => true\n f.legend :position => \"se\"\n f.yaxis 1\n f.series \"#{e1.title} against #{e2.title}\", e1.aucs_against(e2), :points => {:show => true, :radius => 1.5}\n end\nend", "def visualize\n fc = javaobj\n vm = jnew(\"visualizer.VisuMain\")\n vm.init(fc)\n end", "def test01() ;\n range = \"[0:10][-1:1]\" ;\n Gnuplot::directMultiPlot(3,range) {|gplot|\n gplot.dmpSetTitle(0,\"foo\") ;\n gplot.dmpSetTitle(1,\"bar\") ;\n gplot.dmpSetTitle(2,\"baz\") ;\n (0...100).each{|k|\n x = 0.1 * k ;\n gplot.dmpXYPlot(0,x,x*x) ;\n gplot.dmpXYPlot(1,x,Math::sin(x)) ;\n gplot.dmpXYPlot(2,x,Math::cos(x)) ;\n gplot.dmpFlush(range) ;\n sleep 0.1 ;\n }\n }\n end", "def begin_figure\n # do nothing\n end", "def plot hsh_or_ary, type, options = {}\n vis = begin\n if hsh_or_ary.is_a?(OpenStruct)\n plot_hash hsh_or_ary, type, options\n elsif hsh_or_ary.is_a?(Array)\n plot_array hsh_or_ary, type, options\n end\n end\n\n vis.render()\n require \"rsvg2\"\n svg = RSVG::Handle.new_from_data(vis.to_svg).tap { |s| s.close }\n SciRuby::Plotter.new svg\n end", "def raise_plot(plot_window_nb=nil)\n send_cmd \"raise #{plot_window_nb}\"\n nil\n end", "def plot(points = [])\n Gnuplot.open do |gp|\n Gnuplot::Plot.new(gp) do |plot|\n \n min_x = points.min - 1\n max_x = points.max + 1\n\n plot.terminal \"pngcairo\"\n plot.output @parameters[:fn]\n\n plot.style \"data boxplot\"\n plot.unset \"xtics\"\n plot.grid \"y2tics lc rgb \\\"#888888\\\" lw 1 lt 0\"\n plot.yrange \"[#{min_x}:#{max_x}]\"\n plot.y2range \"[#{min_x}:#{max_x}]\"\n plot.y2tics \"center rotate by 90 font \\\",15\\\"\"\n plot.unset \"ytics\"\n\n x = []\n y = []\n (min_x..max_x).to_a.each do |current_x|\n points.grep(current_x).size.times do\n x << 1\n y << current_x\n end if points.grep(current_x).size\n end\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.title = ''\n end\n\n label_index = 1\n @labels ||= []\n @labels.each do |l|\n plot.label \"#{label_index} '#{l[0]}' at #{l[1]}, #{l[2]} font 'Latin-Modern,#{l[3]}' tc rgb '#{l[4]}' rotate by 90 center\"\n label_index += 1\n end\n\n end\n end\n `convert -rotate 90 #{@parameters[:fn]} #{@parameters[:fn]}`\n @parameters[:fn]\n end", "def plot_data data, series=nil, filename=nil, title=nil\n # stub method to enable documentation in yard\n\t\tend", "def show\n\t\tputs @graph\n\tend", "def plot(*args)\n\t\t\n\t\tdata = []\n\t\tall_plots = ''\n\t\twhile args.length > 0\n\t\t\t#\n\t\t\t# NEXT PLOT\n\t\t\t#\n\t\t\t# First two values are the (x,y) points.\n\t\t\tdata << args.shift\n\t\t\tdata << args.shift\n\t\t\t\n\t\t\t# - Get the settings for this plot.\n\t\t\t# - If 'args' is not empty, there is another plot.\n\t\t\tthis_plot, args = styles(args)\n\t\t\tall_plots << this_plot\n\t\t\tall_plots << ', ' if args.length > 0\n\t\tend\n\t\t\n\t\t# TODO:\n\t\t# - Check for both Array and NMatrix.\n\t\t# - But make sure the program works without NMatrix loaded.\n\t\t#\n\t\t\n\t\t#\n\t\t# Each plot needs a separate stream of data separated by 'e' (\"end\").\n\t\t#\n\t\tnstreams = data.length / 2\n\t\t\n\t\tstream = (1..nstreams).map { |s|\n\t\t\tx = data.shift\n\t\t\ty = data.shift\n\t\t\tn = x.is_a?(Array) ? x.length - 1 : x.shape[0] - 1\n\t\t\t\n\t\t\t(0..n).map { |i| \"#{x[i]}\t#{y[i]}\\n\" }.join + \"e\\n\"\n\t\t}.join\n\t\t\n\t\t@pipe.puts \"plot #{all_plots} \\n#{stream}\"\n\tend", "def to_iruby\n gif_base64 = Base64.encode64(plot)\n ['text/html', \"<img src=\\\"data:image/gif;base64, #{gif_base64}\\\">\"]\n end", "def show\n @plot = Plot.find(params[:id])\n @title = \"Plot Image\"\n\n\t if @plot.nil?\n\t\tredirect_to :action => \"index\"\n\t end\n\n\t respond_to do |format|\n\t format.html # show.html.erb\n\t format.xml { render :xml => @plot }\n\t end\n end", "def plotWxt(gp, sendcmd, ofname, xlabel, ylabel)\n [\n \"set output '#{ofname}'\",\n \"set xlabel '#{xlabel}'\",\n \"set ylabel '#{ylabel}'\",\n #\"splot '#{fname}' #{opt} title '#{nline}'\" \n #\"plot '#{fname}' #{opt} title '#{nline}'\"\n \"plot #{sendcmd}\",\n \"pause 1.2\",\n ].each{|cmd| gp.puts(cmd) }\nend", "def generateSeriesPlot(xyData, options={})\n plotOptions={:width=>200, :height=>100, :imagetype=> \"png\", :xlabel=> \"\", :ylabel=> \"\"}\n plotOptions=plotOptions.merge(options)\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n plot.terminal \"#{plotOptions[:imagetype]} small enhanced size #{plotOptions[:width]},#{plotOptions[:height]} crop\"\n plot.output Rails.root.to_s+\"/public/series.png\"\n plot.ylabel plotOptions[:ylabel]\n plot.xlabel plotOptions[:xlabel]\n plot.boxwidth 0.5\n plot.grid \"\"\n plot.data << Gnuplot::DataSet.new( xyData ) do |ds|\n ds.with = \"boxes fill solid 0.5\"\n ds.notitle\n end\n end\n end\n end", "def plot(p, i)\n x, y, sw, sh = p[0], p[1], p[2], p[3]\n\n @m.synchronize{\n puts \"#{x},#{y}: #{i}\"\n } \n\n end", "def old_plot xmax, xmin, ymax, ymin, xdiff, ydiff, iterations, old_points\n puts \"\\e[H\\e[2J\" # clear screen\n ymax.step(ymin, -ydiff) do |y|\n print_num y\n (xmin).step(xmax, xdiff) do |x|\n itr = mandelbrot(Complex(x,y), iterations)\n #color = itr ? itr/iterations.to_f : 1.0\n #print \"*\".grayscale(color)\n whiteness = itr ? itr/iterations.to_f : 1\n print \"*\".grayscale(whiteness)\n end\n puts\n end\n (-xmax).step(xmax, xdiff) do |x|\n print_num x\n end\nend", "def plot(points = [])\n Gnuplot.open do |gp|\n Gnuplot::Plot.new(gp) do |plot|\n plot.terminal \"pngcairo size 460,460\"\n plot.output @parameters[:fn]\n plot.key \"off\"\n x = []\n y = []\n points << (@parameters[:high]-@parameters[:low])*2+@parameters[:high] if points.empty?\n @arrows ||= []\n if @parameters[:horizontal]\n plot.xrange \"[#{@parameters[:low]}:#{@parameters[:high]}]\"\n plot.yrange \"[0:1]\"\n plot.border 1\n plot.xtics generate_tics\n plot.unset \"ytics\"\n points.each do |p|\n x << p\n y << 0\n end\n @arrows.each do |a|\n if a[3]\n plot.arrow \"from #{a[0]}, 0.05 to #{a[1]}, 0.05 filled lc rgb '#{a[2]}'\"\n else\n plot.arrow \"from #{a[0]}, 0.05 to #{a[1]}, 0.05 heads filled lc rgb '#{a[2]}'\"\n end\n end\n else\n plot.yzeroaxis \"lt -1\"\n plot.xrange \"[-1:1]\"\n plot.yrange \"[#{@parameters[:low]}:#{@parameters[:high]}]\"\n plot.border 0\n plot.ytics \"axis #{generate_tics}\"\n plot.unset \"xtics\"\n points.each do |p|\n x << 0\n y << p\n end\n @arrows.each do |a|\n if a[3]\n plot.arrow \"from 0.1, #{a[0]} to 0.1, #{a[1]} filled lc rgb '#{a[2]}'\"\n else\n plot.arrow \"from 0.1, #{a[0]} to 0.1, #{a[1]} heads filled lc rgb '#{a[2]}'\"\n end\n end\n end\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.with = \"points pt 7 lc rgb '#{color}'\"\n ds.notitle\n end\n end\n end\n if @parameters[:horizontal]\n `convert #{@parameters[:fn]} -crop 460x100+0+360 +repage #{@parameters[:fn]}`\n else\n `convert #{@parameters[:fn]} -crop 100x460+180+0 +repage #{@parameters[:fn]}`\n end\n self\n end", "def notebook\n JupyterNotebook.new(content)\n end", "def show\n IRuby.display(self)\n end", "def use_axes?\n end", "def show\n set_cell\n end", "def plot_visible_only=(v) Axlsx.validate_boolean(v); @plot_visible_only = v; end", "def x_visualize\n require 'open3'\n Open3.popen3('dot -T svg | display') do |i,o,_|\n i.write to_dot\n i.close\n end\n end", "def show!\n bind_set_draw_attention(true)\n show\n end", "def show_graph\n url_for_data = url_for(controller.params.merge(:action => :data)).gsub('&amp;', '&')\n relative_url_path = ActionController::Base.respond_to?(:relative_url_root) ? ActionController::Base.relative_url_root : ActionController::AbstractRequest.relative_url_root\n html, div_name = controller.open_flash_chart_object_and_div_name('100%', '400', url_for_data, true, \"#{relative_url_path}/\")\n\n html << '<script type=\"text/javascript\">' << \"\\n\"\n html << \"var charts_to_image_title = '#{h(controller.title)}';\\n\" \n html << \"var charts_to_image_id = '#{div_name}';\\n\"\n html << '</script>'\n\n html\n end", "def draw_basic_plot(params) \n jitter = params[:jitter]\n grouplist = params[:grouplist]\n snp_list = params[:snp_list]\n x_start = params[:x_start]\n y_start = params[:y_start]\n stat_max = params[:stat_max]\n stat_min = params[:stat_min]\n data_key = params[:data_key]\n plot_labels = params[:plot_labels]\n title = params[:title]\n precision = params[:precision]\n rotate = params[:rotate] || false\n size_mult = params[:size_mult] || 1\n prefix_title = params[:prefix_title] || \"\"\n lci_key = params[:lci_key] || nil\n uci_key = params[:uci_key] || nil\n \n x = @box_size\n xmin = x\n ymin = 0\n ymax = @box_size*9 * size_mult\n y_interval = ymax-ymin\n # set stat_min to be zero\n stat_interval = stat_max - stat_min\n\n value_x = xmin * 0.7 + (@box_size * Math.sqrt(2)*0.25)/2\n \n fill_opacity = 0.9\n if Shape.get_grayscale\n fill_opacity = 1.0\n end\n \n # draw box (change to triangle) with correct color\n snp_list.included_snps.each do |snp_index|\n draw_separator = true\n snp = snp_list.snps[snp_index]\n \n #draw_separation(x_start, y_start, 0, ymax, value_x) unless lci_key\n\n # store points here for output\n points = Array.new\n lines = Array.new\n\n grouplist.groups.each do |group|\n if snp.results.has_key?(group.name)\n result = snp.results[group.name]\n if !result.values[data_key] or result.values[data_key] !~ /\\d/\n next\n end\n box_y_start = ((stat_max-result.values[data_key].to_f) / stat_interval) * y_interval\n\n if rotate\n box_y_start = y_interval - box_y_start\n end\n\n if !group.highlighted\n points << Circle.new(value_x, box_y_start, @box_size * Math.sqrt(2)*0.125, group.colorstr)\n else\n # create triangle here\n points << create_diamond(box_y_start, value_x, 1.0, group.colorstr)\n end\n \n # create a line if there is a confidence interval\n if result.values[uci_key]\n draw_separator = false\n uci_y = ((stat_max-result.values[uci_key].to_f) / stat_interval) * y_interval\n lci_y = ((stat_max-result.values[lci_key].to_f) / stat_interval) * y_interval\n if rotate\n uci_y = y_interval - uci_y\n lci_y = y_interval - lci_y\n end \n\n points.last.interval = Line.new([value_x,value_x], [lci_y,uci_y], group.colorstr)\n end\n \n end\n\n end\n draw_separation(x_start, y_start, 0, ymax, value_x)# if draw_separator\n # sort by y-midpoint\n points.sort! {|x,y| y.ymidpoint <=> x.ymidpoint}\n #lines.sort! {|x,y| y.ymidpoint <=> x.ymidpoint} unless lines.empty?\n\n # those points that overlap significantly\n if jitter\n adjust_horizontal(points, y_interval)\n end\n\n\t # iterate through points and draw all of them\n\t points.each do |point|\n if point.interval \n point.interval.xpoints[0] = point.interval.xpoints[1] = point.xmidpoint\n @canvas.g.translate(x_start,y_start) do |check|\n check.styles(:stroke_width=>2)\n point.interval.draw(check)\n end\n end \n \t end\n\n\t points.each do |point|\n \t @canvas.g.translate(x_start,y_start) do |check|\n \t check.styles(:stroke_width=>1, :fill_opacity=>fill_opacity)\n \t point.draw(check)\n \t end \n end\n \n value_x = label_step(value_x)\n end\n\n if plot_labels\n if rotate\n x_label_start = value_x + x_start+ @box_size * 0.4 \n else\n x_label_start = x_start \n end\n\n if size_mult >= 1\n write_plot_labels(x_label_start, y_start, ymax, stat_max, stat_min, y_interval, 0, prefix_title+title, false, precision, rotate)\n else\n write_plot_labels(x_label_start, y_start, ymax, stat_max, stat_min, y_interval, 0, prefix_title+title,\n false, precision, rotate, 5)\n end\n end\n end", "def update_visualization(point)\n\t\t\n\tend", "def update_visualization(point)\n\t\t\n\tend", "def update_visualization(point)\n\t\t\n\tend", "def update_visualization(point)\n\t\t\n\tend", "def plot_1d\n plotter = Plotter.new(:title => \"Signal: values vs. sample number\", :xtitle => \"sample number\", :ytitle => \"sample value\")\n plotter.plot_1d \"signal data\" => @data\n end", "def axes\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def plot_db(path: \"./\") \r\n self.plot(method: :dB, xsteps: 8, path: path) do |g|\r\n g.title = \"Decibles\"\r\n g.x_axis_label = \"Normalized Frequency\"\r\n g.y_axis_label = \"Magnitude\"\r\n end\r\n end", "def initialize(plots)\n @t = FigureMaker.default\n @margin = 0.025\n\n plots.each do |plot|\n t.def_figure(plot.title) { exec_plot(plot) }\n end\n\n end", "def plot(path = nil, **options)\n options[:output] ||= path\n plot_options = mix_options(options) do |plot_opts, anim_opts|\n plot_opts.merge(term: ['gif', anim_opts])\n end.to_h\n need_output = plot_options[:output].nil?\n plot_options[:output] = Dir.gnuplot_tmpname('anim') if need_output\n terminal = Terminal.new\n multiplot(terminal, plot_options)\n # guaranteed wait for plotting to finish\n terminal.close\n if need_output\n result = File.binread(plot_options[:output])\n File.delete(plot_options[:output])\n else\n result = nil\n end\n result\n end", "def plot(points = [], points2 = [])\n Gnuplot.open do |gp|\n Gnuplot::Plot.new(gp) do |plot|\n \n min_x = (points + points2).min - 1\n max_x = (points + points2).max + 1\n\n plot.terminal \"pngcairo\"\n plot.output @parameters[:fn]\n\n plot.style \"data boxplot\"\n plot.unset \"xtics\"\n plot.grid \"y2tics lc rgb \\\"#888888\\\" lw 1 lt 0\"\n plot.yrange \"[#{min_x}:#{max_x}]\"\n plot.y2range \"[#{min_x}:#{max_x}]\"\n\n plot.xrange \"[0.6:2]\"\n plot.x2range \"[0.6:2]\"\n\n plot.y2tics \"center rotate by 90 font \\\",15\\\"\"\n plot.unset \"ytics\"\n\n x = []\n y = []\n\n (min_x..max_x).to_a.each do |current_x|\n points.grep(current_x).size.times do\n x << 1\n y << current_x\n end if points.grep(current_x).size\n end\n\n x2 = []\n y2 = []\n (min_x..max_x).to_a.each do |current_x|\n points2.grep(current_x).size.times do\n x2 << 1.6\n y2 << current_x\n end if points2.grep(current_x).size\n end\n \n plot.data = [\n Gnuplot::DataSet.new([x, y]) { |ds|\n ds.title = ''\n },\n\n Gnuplot::DataSet.new([x2, y2]) { |ds|\n ds.title = ''\n ds.linecolor = \"rgb \\\"red\\\"\"\n }\n ]\n\n label_index = 1\n @labels ||= []\n @labels.each do |l|\n plot.label \"#{label_index} '#{l[0]}' at #{l[1]}, #{l[2]} font 'Latin-Modern,#{l[3]}' tc rgb '#{l[4]}' rotate by 90 center\"\n label_index += 1\n end\n\n end\n end\n `convert -rotate 90 #{@parameters[:fn]} #{@parameters[:fn]}`\n @parameters[:fn]\n end", "def show\n @chart = Chart.find(params[:id])\n @chartnodes = @chart.chartnodes\n data = @chart.chartnodes.map {|node| [node.xaxis, node.yaxis]}.transpose\n if @chart.charttype == 'column'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'column',:name=> @chart.name,:data=> data[1])\n end\n elsif @chart.charttype == 'spline'\n @h1 = LazyHighCharts::HighChart.new('graph') do |f|\n f.title({ :text=> @chart.name})\n f.options[:xAxis][:categories] = data[0]\n f.series(:type=> 'spline',:name=> @chart.name,:data=> data[1])\n f.plot_options( :spline => {\n :dataLabels => {\n :enabled => true\n }})\n f.tooltip( :crosshairs => true, :shared => true)\n end\n elsif @chart.charttype == 'pie'\n @h1 = LazyHighCharts::HighChart.new('pie') do |f|\n f.chart({:defaultSeriesType=>\"pie\" , :margin=> [50, 200, 60, 170]} )\n series = {\n :type=> 'pie',\n :name=> @chart.name,\n :data=> data.transpose\n }\n f.series(series)\n f.options[:title][:text] = \"Browser share\"\n f.legend(:layout=> 'vertical',:style=> {:left=> 'auto', :bottom=> 'auto',:right=> '50px',:top=> '100px'}) \n f.plot_options(:pie=>{\n :allowPointSelect=>true, \n #:cursor=>\"pointer\" , \n :dataLabels=>{\n :enabled=>true,\n :color=>\"black\",\n :style=>{\n :font=>\"13px Trebuchet MS, Verdana, sans-serif\"\n }\n }\n })\n end\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @chart }\n end\n end", "def generatePlot( options={} )\n # Generate an array of the x hash values to easily find the minimum and maximum.\n x = Array.new\n @x_data.keys.each { |key|\n x.push(@x_data[key].to_f)\n }\n\n defaults = { :filename => \"data\",\n :numBins => 2,\n :x_label => \"X\",\n :y_label => \"Y\",\n :title => \"Title\",\n :min => x.min,\n :max => x.max,\n :logx => false,\n :logy => false,\n :linreg => false,\n :dataLabels => false,\n :doOutliers => false,\n :outlierK => 3,\n :addOutlierLabels => 0,\n :savePlot => false }\n\n options = defaults.merge(options)\n\n savePlot = options[:savePlot]\n filename = options[:filename]\n numBins = options[:numBins]\n x_label = options[:x_label]\n y_label = options[:y_label]\n title = options[:title]\n min = options[:min]\n max = options[:max]\n logx = options[:logx]\n logy = options[:logy]\n linreg = options[:linreg]\n outlierAnalysis = Array.[](options[:doOutliers],options[:outlierK])\n dataLabels = options[:dataLabels]\n addOutlierLabels = options[:addOutlierLabels]\n\n if (@plottype == :histogram)\n\n bw = (max.to_f - min.to_f) / numBins.to_f # Calculate bin width\n x_count = Array.new\n x_axis = Array.new\n\n histfile = File.new(filename + \".histo\", \"w\") # File that shows the keys that belong in each bin.\n\n # checks which values belong in each bin. Edgecases go to the lower bin.\n (1..numBins).each {|n|\n count = 0\n histfile.puts \"Values from #{(min.to_f + (n.to_f-1) * bw.to_f)} to #{min.to_f + n.to_f * bw.to_f}.\" # Label the bin in the file.\n\n if (min == x.min && n == 1) # To fix the issue with keys being left out if the bin minimum == data minimum(s)\n @x_data.keys.each {|key|\n if (@x_data[key] == x.min)\n histfile.puts key # Place a copy of the minimum(s) in the first bin\n count = count + 1 # Increment the first bin to reflect this\n end\n }\n end\n\n @x_data.keys.each {|v|\n if(((min.to_f + (n.to_f-1) * bw.to_f) < (@x_data[v].to_f)) and ((@x_data[v].to_f) <= (min.to_f + n.to_f * bw.to_f)))\n count = count + 1 # Add increment the bin counter if the key qualifies\n histfile.puts v # List the key in the bin if it qualifies\n end\n }\n\n x_count.push(count) # Add the bin count to the count array.\n }\n\n histfile.close\n\n # To check bin counts\n binSum = 0;\n (0..(numBins-1)).each { |index|\n binSum = x_count[index] + binSum\n puts \"Bin #{index} contains #{x_count[index]}\" if $verbose\n }\n puts \"There were #{binSum} samples in the plot.\" if $verbose\n\n # generates the x axis\n (1..numBins).each {|n|\n x_axis.push(min.to_f + (0.5*bw.to_f + bw.to_f * (n-1)))\n }\n\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n plot.title title\n plot.ylabel \"Frequency\"\n plot.xlabel x_label\n\n # Save the plot to a file\n if (savePlot == true)\n plot.terminal \"gif\"\n plot.output filename + \".gif\"\n end\n\n plot.arbitrary_lines << \"set xrange [\" + min.to_s + \":\" + max.to_s + \"]\" # Set x axis according to max and mins\n plot.arbitrary_lines << \"set yrange [0:#{x_count.max.to_f + x_count.max.to_f * 0.1}]\" # Make the y axis 110% of the highest count\n\n plot.data << Gnuplot::DataSet.new( [x_axis, x_count] ) do |ds|\n ds.with = \"boxes\"\n ds.notitle\n end\n end\n end\n end\n\n if (@plottype == :scatter)\n\n if(@x_data.length == @y_data.length)\n\n # generate a datafile to use in gnuplot\n datfile = filename + \".scatter\"\n\n newfile = File.new(datfile, \"w\")\n\n # pointCount tells how many points are on the graph\n pointCount = 0\n @x_data.keys.each { |i|\n newfile.puts \"#{@x_data[i]}\\t#{@y_data[i]}\"\n pointCount = pointCount + 1\n }\n\n puts \"There are #{pointCount} points on the plot.\" if $verbose\n\n newfile.close\n\n # plot data\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n\n # plot to a file\n if (savePlot == true)\n plot.terminal \"gif\"\n plot.output filename + \".gif\"\n end\n\n #apply title/labels\n plot.title title\n plot.ylabel y_label\n plot.xlabel x_label\n\n # check if graphs need to be logscaled\n if (logx)\n plot.arbitrary_lines << \"set logscale x\"\n end\n\n if (logy)\n plot.arbitrary_lines << \"set logscale y\"\n end\n\n # check if a linear regression is desired\n if (linreg)\n plot.arbitrary_lines << \"f(x) = m*x + b\"\n plot.arbitrary_lines << \"fit f(x) '\" + datfile + \"' using 1:2 via m,b\"\n end\n\n # perform outlier analysis\n if (outlierAnalysis[0])\n\n # generate array of slopes of data\n yDivX = Array.new\n @x_data.keys.each { |key|\n yDivX.push(@y_data[key].to_f / @x_data[key].to_f)\n }\n\n # apply the 5 number summary function\n summData = Array.new\n summData = yDivX.fiveNumSum # match to new function\n\n # Calculate slopes of minimum and maximum lines to show outliers\n maxline = summData[2] + outlierAnalysis[1] * (summData[3] - summData[1])\n minline = summData[2] - outlierAnalysis[1] * (summData[3] - summData[1])\n\n # Define the minline and maxline in gnuplot\n plot.arbitrary_lines << \"a(x) = #{minline}*x\"\n plot.arbitrary_lines << \"b(x) = #{maxline}*x\"\n\n end #outlier analysis\n\n\n # Generate a plot string\n plotString = \"plot '#{datfile}' notitle\"\n\n # add linear regression\n if (linreg)\n plotString = plotString + \", f(x) title 'Linear Fit'\"\n end\n\n # plot with outlier analysis\n if (outlierAnalysis[0])\n plotString = plotString + \", a(x) title 'Minimum', b(x) title 'Maximum'\"\n end\n # add data point names if desired\n if (dataLabels && addOutlierLabels == 0) # Won't label everything if outlier labeling is enabled\n @x_data.keys.each { |key|\n plot.arbitrary_lines << \"set label '#{key}' at #{@x_data[key].to_f}, #{@y_data[key].to_f}\"\n }\n end\n\n # add outlier data labels\n if ( addOutlierLabels > 0 )\n self.findOutliers( filename + \"ForLabels\", addOutlierLabels )\n @outlier_data.keys.each { |key|\n # add labels to each point where an outlier exists\n plot.arbitrary_lines << \"set label '#{key}' at #{@x_data[key].to_f}, #{@y_data[key].to_f}\"\n }\n puts \"Labeled #{@outlier_data.size} outliers.\" if $verbose\n end\n plot.arbitrary_lines << plotString\n end\n end\n\n # Regenerate the data file to add in key names.\n newfile = File.new(datfile+ \"WITHNAMES\", \"w\")\n \n newfile.puts \"Name\\tX\\tY\"\n\n @x_data.keys.each { |i|\n newfile.puts \"#{i}\\t#{@x_data[i]}\\t#{@y_data[i]}\"\n }\n\n newfile.close\n\n else\n puts \"X and Y are different sizes\"\n end # x y size check\n end # scatter\n\n end", "def runSinFrSin(filename)\n\t\tstyleArr=@oc[\"StyleIndices\"].split(\",\")\n\t\tcom=\"\\\"\"+filename+\"\\\" \"\n\t\tcom=com+\"title \\\"\"+@oc[\"TitleString\"]+\"\\\" \" if @oc[\"TitleString\"]!=\"\"\n\t\tcom=com+\"with \"+@oc[\"LineType\"]+\" ls \"+styleArr[0]\n\t\tplot(com,false)\n\tend", "def splot(*args)\n contents = parse_plot_args(SPlotItem,args)\n _plot_splot(\"splot\",contents)\n nil\n end", "def show_x_axis\n false\n end", "def plot_data\n clear_lines\n @buffer.keys.each { |k| plot_data_line(k, @buffer[k]) }\n end", "def makeChart(*options)\n\ndisplay = \"\n<div class='charts last'>\n\n<div class='left'>\n\n\n<div id='placeholder' style='width:400px;height:200px;'></div>\n<div id='overview' style='width:400px;height:50px'></div>\n<p id='overviewLegend' style='margin-left:10px'></p>\n\n<p> Try zooming. Click and drag to select a zone.</p>\n</div>\n\n<div class='right'>\n\nWeight Chart<br/>\n<div id='miniWeight' style='width:350px;height:100px;'></div>\nWater Chart<br/>\n<div id='miniWater' style='width:350px;height:100px;'></div>\n\n\nCalories Eaten<br/>\n<div id='miniCalorie' style='width:350px;height:100px;'></div>\nFitness (Calories burned not to include resting metabolism)<br/>\n<div id='miniFitness' style='width:350px;height:100px;'></div><br/>\n\nMeasurements (Total inches)<br/>\n<div id='miniMeasures' style='width:350px;height:100px;'></div>\n\n\n</div>\n\n\n\n\n<div class='last'></div>\n<script id='source' language='javascript' type='text/javascript'>\n\n\n$(function () {\nvar options = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { \n show: true, \n container: $('#overviewLegend'),\n noColumns: 2,\n }\n};\n\nvar options_overview = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { show: false}\n};\n\n\nvar plot = $.plot($('#placeholder'), \n[ #{@chartable.to_chart } ], options);\n\n\n\n\nvar overview = $.plot($('#overview'), \n[ #{@chartable.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n\n\n\n\nvar overview_1 = $.plot($('#miniWeight'), \n[ #{@miniWeight.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_2 = $.plot($('#miniWater'), \n[ #{@miniWater.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_3 = $.plot($('#miniCalorie'), \n[ #{@miniCalorie.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_4 = $.plot($('#miniFitness'), \n[ #{@miniFitness.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_5 = $.plot($('#miniMeasures'), \n[ #{@miniMeasures.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n// now connect the two\nvar internalSelection = false;\n\n$('#placeholder').bind('selected', function (event, area) {\n // do the zooming\n plot = $.plot($('#placeholder'), \n [#{@chartable.to_chart}],\n $.extend(true, {}, options, {\n xaxis: { min: area.x1, max: area.x2 }\n }));\n \n if (internalSelection)\n return; // prevent eternal loop\n internalSelection = true;\n overview.setSelection(area);\n internalSelection = false;\n});\n\n$('#overview').bind('selected', function (event, area) {\n if (internalSelection)\n return;\n internalSelection = true;\n plot.setSelection(area);\n internalSelection = false;\n});\n\n\n});\n</script>\n\"\n\nend", "def index\n @plots = Plot.all\n end", "def index\n @plots = Plot.all\n end", "def index\n @plots = Plot.all\n end", "def plot(opts = {}, &block)\n\t\t\tdefault_opts = {:type => DOMAIN_COLORED_PLOT, :color => ChunkyPNG::Color::BLACK,\n\t\t\t\t:vert => DLINES, :horz => DLINES}\n\t\t\topts = default_opts.merge(opts)\n\t\t\tif opts[:type] == DOMAIN_COLORED_PLOT and @size > 0\n\t\t\t\twarn \"Warning in #{self.class}::plot: DOMAIN_COLORED_PLOT will overdraw existing #{@size} plots. Draw 1st for correct behavior.\"\n\t\t\tend\n\t\t\tcase opts[:type]\n\t\t\t\twhen DOMAIN_COLORED_PLOT then plotDCPlot(opts, &block)\n\t\t\t\twhen COMPLEX_CONTOUR_PLOT then plotCCPlot(opts, &block)\n\t\t\t\telse raise RangeError, \"Invalid plot type #{opts[:type]}.\"\n\t\t\tend\n\t\t\t@size += 1\n\t\tend", "def rubyvis_panel # :nodoc:\n pre_vis\n #that=self\n \n @minimum_x||=@hist.min\n @maximum_x||=@hist.max\n @minimum_y||=0\n @maximum_y||=@hist.max_val\n \n margin_hor=margin_left + margin_right\n margin_vert=margin_top + margin_bottom\n \n x_scale = pv.Scale.linear(@minimum_x, @maximum_x).range(0, width - margin_hor)\n \n y_scale=Rubyvis::Scale.linear(@minimum_y, @maximum_y).range(0, height - margin_vert)\n \n y_scale.nice\n \n bins=@hist.bins.times.map {|i|\n {\n :low =>@hist.get_range(i)[0],\n :high=>@hist.get_range(i)[1],\n :value=>@hist.bin[i]\n }\n }\n @x_scale=x_scale\n @y_scale=y_scale\n # cache data\n vis=Rubyvis::Panel.new do |pan| \n pan.width width - margin_hor\n pan.height height - margin_vert\n pan.bottom margin_bottom\n pan.left margin_left\n pan.right margin_right\n pan.top margin_top\n # Y axis\n pan.rule do\n data y_scale.ticks\n bottom y_scale\n stroke_style {|d| d!=0 ? \"#eee\" : \"#000\"}\n label(:anchor=>'left') do\n text y_scale.tick_format\n end\n end\n # X axis\n pan.rule do\n data x_scale.ticks\n left x_scale\n stroke_style \"black\"\n height 5\n bottom(-5)\n label(:anchor=>'bottom') do\n text x_scale.tick_format\n end\n end\n \n pan.bar do |bar|\n bar.data(bins)\n bar.left {|v| x_scale[v[:low]]}\n bar.width {|v| x_scale[v[:high]] - x_scale[v[:low]]}\n bar.bottom 0\n bar.height {|v| y_scale[v[:value]]}\n bar.stroke_style \"black\"\n bar.line_width 1\n end\n rubyvis_normal_distribution(pan) if @line_normal_distribution\n end\n vis\n end", "def update_visualization(point)\n\t\t\t\t\n\t\t\tend", "def plot3dGeneric_old(title, label, index, baseName)\n index += 1;\n pathBase = \"#{@resultBaseDir}/#{baseName}\" ;\n begin\n gplot = Gnuplot.new(:gplot, pathBase) ;\n gplot.setTitle(title) ;\n gplot.setXYLabel(\"# of Savs (log)\", \"frequency (log)\") ;\n gplot.command(\"set ylabel rotate parallel\") ;\n gplot.command(\"set dgrid3d 100,100 spline\") ;\n gplot.command(\"set pm3d at b\") ;\n gplot.command(\"set cblabel \\\"#{label}\\\" offset -10\") ;\n gplot.command(\"set logscale xy\") ;\n gplot.command(\"set contour\") ;\n gplot.command(\"unset ztics\") ;\n gplot.command(\"set view 0,359.9999\") ; # to show y label at left.\n\n gplot.command(\"$MyData << EOD\") ;\n to_a.each{|analyzer|\n gplot.command(analyzer.genCsvRowSummary().join(\" \")) ;\n }\n gplot.command(\"EOD\") ;\n\n# gplot.command(\"splot $MyData u 1:2:#{index} w lines palette notitle\") ;\n gplot.command(\"splot $MyData u 1:2:#{index} w pm3d t '#{label}'\") ;\n\n gplot.close() ;\n\n #gplot = Gnuplot.new(\"qt\") ;\n gplot = Gnuplot.new(\"wxt\") ;\n gplot.command(\"load \\\"#{pathBase}.gpl\\\"\") ;\n gplot.setTerm(:tgif, \"#{pathBase}\") ;\n gplot.command(\"replot\") ;\n\n ensure\n gplot.close() ;\n end\n end", "def set_plot\n @plot = Plot.friendly.find(params[:id])\n end", "def show\n @workflow = Workflow.find(params[:id])\n \n default_graph_settings = \"node [shape=box,style=filled];\\n\"\n \n @processed_graph = default_graph_settings + @workflow.graph + process_graph(@workflow)\n \n gv = IO.popen(\"/usr/local/bin/dot -q -Tpng\", \"w+\")\n gv.puts \"digraph G{\", @processed_graph, \"}\"\n gv.close_write\n @gvpng = gv.read\n\n\n gv = IO.popen(\"/usr/local/bin/dot -q -Tcmapx\", \"w+\")\n gv.puts \"digraph G{\", @processed_graph, \"}\"\n gv.close_write\n @gvmap = gv.read\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @workflow }\n end\n end", "def request_plot(args, options)\n\n experiments = options.experiments.split(',')\n machines = options.machines.split(',')\n\n data = Ppbench::load_data(args)\n filtered_data = Ppbench::filter(\n data,\n experiments: experiments,\n machines: machines\n )\n aggregated_data = Ppbench::aggregate(filtered_data)\n\n max_x = Ppbench::maximum(aggregated_data, of: :length)\n max_y = Ppbench::maximum(aggregated_data, of: :rps)\n\n rplot = Ppbench::plotter(\n aggregated_data,\n to_plot: :rps,\n machines: machines,\n experiments: experiments,\n receive_window: options.recwindow,\n xaxis_max: options.xaxis_max == 0 ? max_x : options.xaxis_max,\n confidence: options.confidence,\n no_points: options.nopoints,\n with_bands: options.withbands,\n yaxis_max: options.yaxis_max == 0 ? max_y : options.yaxis_max,\n yaxis_steps: options.yaxis_steps,\n xaxis_steps: options.xaxis_steps,\n title: \"Requests per seconds\",\n subtitle: \"bigger is better\",\n xaxis_title: \"Message Size\",\n xaxis_unit: \"kB\",\n yaxis_title: \"Requests per seconds\",\n yaxis_unit: \"Req/sec\",\n yaxis_divisor: 1\n )\n\n pdf = pdfout(rplot, file: options.pdf, width: options.width, height: options.height)\n print(\"#{pdf}\") unless options.pdf.empty?\n print(\"#{rplot}\") if options.pdf.empty?\nend", "def basic_chart\n \n end", "def xaxis\n end", "def make_gnuplot(filename, title, xlabel, ylabel, &block)\n Gnuplot.open do |gp|\n Gnuplot::Plot.new(gp) do |plot|\n plot.output(\"#{config.filepath(filename)}\")\n case config.format\n when 'eps'\n plot.set(\"enc #{config.coding}\")\n plot.set(\"term postscript eps #{config.font_setup}\")\n when 'png'\n plot.set('terminal png')\n plot.set('terminal png size #{config.size}') if config.size\n else\n plot.set(\"terminal #{config.format}\")\n # plot.set(\"terminal #{config.format} #{config.font_setup}\")\n end\n\n plot.set(\"key off\")\n\n plot.title(title) unless config.notitles\n unless config.nolabels\n plot.xlabel(xlabel)\n plot.ylabel(ylabel)\n end\n\n block.call(plot)\n end\n end\nend", "def plot(clusters, show_centroids = true)\n # Graph output by running gnuplot pipe\n Gnuplot.open do |gp|\n # Start a new plot\n Gnuplot::Plot.new(gp) do |plot|\n # Plot each cluster's points\n clusters.each do |cluster|\n # Collect all x and y coords for this cluster\n x = cluster.points.map { |p| p[0] }\n y = cluster.points.map { |p| p[1] }\n\n # Plot w/o a title (clutters things up)\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.notitle\n end\n\n next unless show_centroids\n\n # Centroid point as bigger black points\n x = [cluster.centroid.x]\n y = [cluster.centroid.y]\n\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.notitle\n ds.linecolor = '000000'\n ds.linewidth = 3\n end\n end\n end\n end\nend", "def initialize(backend: :default)\n @backend = backend\n @subplots_list = [Rubyplot::SubPlot.new(1, 1, 1)]\n @tasks = []\n @x_title = ''\n @y_title = ''\n @x_range = [0, 0]\n @y_range = [0, 0]\n @origin = [:default, :default]\n @x_tick_count = :default\n @y_tick_count = :default\n @title = nil\n @title_shift = 0\n @text_font = :default\n @grid = true\n @bounding_box = true\n @x_axis_padding = :default\n @y_axis_padding = :default\n if @backend == :default || @backend == :GR\n require(__dir__.to_s << '/scripting_backends/gr/gr_backend')\n end\n @active_subplot = @subplots_list[0]\n @no_subplot = true\n end", "def activate_matplotlib(backend)\n require 'matplotlib'\n Matplotlib.interactive(true)\n\n backend = backend.to_s\n Matplotlib.rcParams['backend'] = backend\n\n require 'matplotlib/pyplot'\n Matplotlib::Pyplot.switch_backend(backend)\n\n # TODO: should support wrapping python function\n # plt = Matplotlib::Pyplot\n # plt.__pyobj__.show._needmain = false\n # plt.__pyobj__.draw_if_interactive = flag_calls(plt.__pyobj__.draw_if_interactive)\n end", "def show\n respond_to do |format|\n format.turbo_stream { render \"shared/show\", locals: { object: @plot_point } }\n end\n end", "def show_axes(state)\n @debug_axes = state ? true : false\n sim = MSPhysics::Simulation.instance\n sim.show_axes(@debug_axes) if sim\n @debug_axes\n end", "def plot_accuracy(your_accuracy, compare_accuracy)\n @yours = PlotGraph::Graphs.column 'Correct questions', your_accuracy, \"Performance over the days\", \"No of correct questions\"\n @comparison = PlotGraph::Graphs.bar 'Your score', 'Event Average', your_accuracy, compare_accuracy, \"Performance over the days\", \"QNo of correct questions\" \n @comparison = [@comparison] \n end", "def plot_fixed_dataset(**options)\n options = {:sort => false, :reverse => false }.merge(options)\n data = [30, 234, 4, 123, 200, 89, 189, 10,]\n data.sort!() if options[:sort]\n data.reverse!() if options[:reverse]\n graph.plot(data, {:line => 'i', :frame => false, :tags => true})\n end", "def show_y_axis\n false\n end", "def to_display\n api = latest_report\n\n Inkblot::Components::IconPane.new do |ic|\n ic.fullscreen = ic.fixed_height = true\n\n ic.icons = [api[:icon], :\"#8203\", api[:wind_speed], api[:wind_dir]]\n\n ic.frame_contents = Inkblot::Components::SimpleText.new do |st|\n st.text = api[@disp]\n st.size = 60 if @disp == :temp\n end\n end\n end", "def display_data_universe\n\n end", "def displayOpen( options={} ) # open the graph (preamble)\n $options = options\n if $options != nil then\n if $options.has_key? :layout then $layout = options[:layout] end\n if $options.has_key? :rankdir then $rankdir = options[:rankdir] end\n end\n puts \"digraph G {\"\n puts \" rankdir=#{$rankdir}\"\n puts \" layout=\\\"#{$layout}\\\"\"\n puts \" fontname = \\\"Bitstream Vera Sans\\\"\"\n puts \" ucd [shape=plaintext, fontsize=18, label=\\\"#{$name}\\\"] \" if $layout == :circo\nend", "def show\n graph = GraphViz.new(:G, type: :digraph)\n competency = Competency.find(params[:id])\n graphviz(graph, competency)\n @file = Tempfile.new(['foo', '.png'], \"#{Rails.root}/public/images\")\n graph.output(png: @file.path)\n end", "def t\n @figure_maker\n end", "def view\n\t `ruby #{File.dirname(__FILE__) + \"/viewer/viewer.rb\"}`\n end", "def show() end" ]
[ "0.7185896", "0.6795179", "0.6734516", "0.6483372", "0.63882226", "0.62924856", "0.6226456", "0.620727", "0.60776013", "0.60666865", "0.5918921", "0.5918042", "0.5914553", "0.58983797", "0.58823425", "0.58738077", "0.5865408", "0.58526534", "0.57181", "0.5704645", "0.5680771", "0.56506145", "0.56448275", "0.5630921", "0.5626668", "0.56142515", "0.5588712", "0.556807", "0.5555545", "0.5524442", "0.5517026", "0.55124646", "0.5484089", "0.5462698", "0.544446", "0.5440833", "0.5437868", "0.5428158", "0.5416257", "0.54152113", "0.53823483", "0.5311119", "0.53092796", "0.5294721", "0.52946824", "0.5269783", "0.52663946", "0.5262833", "0.5258259", "0.5255263", "0.52542233", "0.52517354", "0.52239704", "0.52239704", "0.52239704", "0.52239704", "0.52206284", "0.52182317", "0.5214845", "0.5214845", "0.5214845", "0.5214845", "0.5213873", "0.518715", "0.5172373", "0.51493937", "0.5142619", "0.51320666", "0.5118731", "0.5116682", "0.51109976", "0.5110963", "0.51104254", "0.5105423", "0.5105423", "0.5105423", "0.5104391", "0.5104191", "0.50963795", "0.50786895", "0.5076371", "0.5064792", "0.5058529", "0.50515455", "0.5048978", "0.50262594", "0.49981797", "0.4990174", "0.4989266", "0.4981479", "0.49809915", "0.49798328", "0.49708793", "0.49678597", "0.49639654", "0.4961334", "0.4957488", "0.49549466", "0.49438784", "0.49438685", "0.49401128" ]
0.0
-1
Shortcut method to configure plot
def configure(&block) self.instance_eval(&block) if block_given? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configurePlot\n end", "def plot; end", "def config\n PlotsConfig.instance\nend", "def configure(x: nil, y: nil, scale: nil)\n @x = x if x\n @y = y if y\n @scale = scale if scale\n self\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def set_plot\n @plot = Plot.find(params[:id])\n end", "def set_plot\n @plot = Plot.friendly.find(params[:id])\n end", "def axes(*)\n super\n end", "def beanplot\n end", "def make_settings\n stub( \n chart_width: 130, \n x_axis_label_width: 10, \n y_axis_label_width: 20, \n line_height: 4, \n x_axis_label_y_coordinate: -3 )\n end", "def axes\n end", "def set_plotarea(params)\n # Convert the user defined properties to internal properties.\n @plotarea = ChartArea.new(params)\n end", "def use_axes=(pagesettings)\n end", "def defaults_options\n self.title({ :text=>\"example test title from highcharts gem\"})\n self.legend({ :layout=>\"vertical\", :style=>{} }) \n self.xAxis({})\n self.yAxis({ :title=> {:text=> nil}, :labels=>{} })\n self.tooltip({ :enabled=>true })\n self.credits({ :enabled => false})\n self.plotOptions({ :areaspline => { } })\n self.chart({ :defaultSeriesType=>\"areaspline\" , :renderTo => nil})\n self.subtitle({})\n end", "def plot!\n return plot if plot && plot.valid? && plot.file_exists?\n plot.destroy if (plot)\n f = ExtendedArgumentationFramework::Framework.new(graph_representation, auto_generate_nodes: true)\n file = ExtendedArgumentationFramework::Plotter.new(f, plot_acceptability: false, edges_style: 'dir=back style=dashed').to_png\n p=Plot.create(filename: \"#{Plot::BASE_URL}/#{file}\", object: self)\n p\n end", "def defaults_options\n self.title({:text => nil})\n self.legend({:layout => \"vertical\", :style => {}})\n self.xAxis({})\n self.yAxis({:title => {:text => nil}, :labels => {}})\n self.tooltip({:enabled => true})\n self.credits({:enabled => false})\n self.plotOptions({:areaspline => {}})\n self.chart({:defaultSeriesType => \"line\", :renderTo => nil})\n self.subtitle({})\n end", "def plot_against e1, e2\n Flot.new('experiment_roc_plot') do |f|\n f.points\n f.grid :hoverable => true\n f.legend :position => \"se\"\n f.yaxis 1\n f.series \"#{e1.title} against #{e2.title}\", e1.aucs_against(e2), :points => {:show => true, :radius => 1.5}\n end\nend", "def use_axes?\n end", "def plot_hash hsh, type, options = {}\n options[:colors] ||= :category10\n options[:line_width] ||= 2\n\n colors = Rubyvis::Colors.send(options[:colors])\n options[:panel] = vis(options) # set up panel and store it in the options hash\n \n hsh.real.each_index do |i|\n options[:panel] = hsh.real[i].vis(type, options.merge({ :line_color => colors[i % colors.size] }))\n end if hsh.respond_to?(:real) # may not have anything but controls\n\n hsh.control.each_index do |i|\n options[:panel] = hsh.control[i].vis(type, options.merge({ :line_color => colors[i % colors.size] }))\n end if hsh.respond_to?(:control) # May not have a control set up\n\n options[:panel]\n end", "def generatePlot( options={} )\n # Generate an array of the x hash values to easily find the minimum and maximum.\n x = Array.new\n @x_data.keys.each { |key|\n x.push(@x_data[key].to_f)\n }\n\n defaults = { :filename => \"data\",\n :numBins => 2,\n :x_label => \"X\",\n :y_label => \"Y\",\n :title => \"Title\",\n :min => x.min,\n :max => x.max,\n :logx => false,\n :logy => false,\n :linreg => false,\n :dataLabels => false,\n :doOutliers => false,\n :outlierK => 3,\n :addOutlierLabels => 0,\n :savePlot => false }\n\n options = defaults.merge(options)\n\n savePlot = options[:savePlot]\n filename = options[:filename]\n numBins = options[:numBins]\n x_label = options[:x_label]\n y_label = options[:y_label]\n title = options[:title]\n min = options[:min]\n max = options[:max]\n logx = options[:logx]\n logy = options[:logy]\n linreg = options[:linreg]\n outlierAnalysis = Array.[](options[:doOutliers],options[:outlierK])\n dataLabels = options[:dataLabels]\n addOutlierLabels = options[:addOutlierLabels]\n\n if (@plottype == :histogram)\n\n bw = (max.to_f - min.to_f) / numBins.to_f # Calculate bin width\n x_count = Array.new\n x_axis = Array.new\n\n histfile = File.new(filename + \".histo\", \"w\") # File that shows the keys that belong in each bin.\n\n # checks which values belong in each bin. Edgecases go to the lower bin.\n (1..numBins).each {|n|\n count = 0\n histfile.puts \"Values from #{(min.to_f + (n.to_f-1) * bw.to_f)} to #{min.to_f + n.to_f * bw.to_f}.\" # Label the bin in the file.\n\n if (min == x.min && n == 1) # To fix the issue with keys being left out if the bin minimum == data minimum(s)\n @x_data.keys.each {|key|\n if (@x_data[key] == x.min)\n histfile.puts key # Place a copy of the minimum(s) in the first bin\n count = count + 1 # Increment the first bin to reflect this\n end\n }\n end\n\n @x_data.keys.each {|v|\n if(((min.to_f + (n.to_f-1) * bw.to_f) < (@x_data[v].to_f)) and ((@x_data[v].to_f) <= (min.to_f + n.to_f * bw.to_f)))\n count = count + 1 # Add increment the bin counter if the key qualifies\n histfile.puts v # List the key in the bin if it qualifies\n end\n }\n\n x_count.push(count) # Add the bin count to the count array.\n }\n\n histfile.close\n\n # To check bin counts\n binSum = 0;\n (0..(numBins-1)).each { |index|\n binSum = x_count[index] + binSum\n puts \"Bin #{index} contains #{x_count[index]}\" if $verbose\n }\n puts \"There were #{binSum} samples in the plot.\" if $verbose\n\n # generates the x axis\n (1..numBins).each {|n|\n x_axis.push(min.to_f + (0.5*bw.to_f + bw.to_f * (n-1)))\n }\n\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n plot.title title\n plot.ylabel \"Frequency\"\n plot.xlabel x_label\n\n # Save the plot to a file\n if (savePlot == true)\n plot.terminal \"gif\"\n plot.output filename + \".gif\"\n end\n\n plot.arbitrary_lines << \"set xrange [\" + min.to_s + \":\" + max.to_s + \"]\" # Set x axis according to max and mins\n plot.arbitrary_lines << \"set yrange [0:#{x_count.max.to_f + x_count.max.to_f * 0.1}]\" # Make the y axis 110% of the highest count\n\n plot.data << Gnuplot::DataSet.new( [x_axis, x_count] ) do |ds|\n ds.with = \"boxes\"\n ds.notitle\n end\n end\n end\n end\n\n if (@plottype == :scatter)\n\n if(@x_data.length == @y_data.length)\n\n # generate a datafile to use in gnuplot\n datfile = filename + \".scatter\"\n\n newfile = File.new(datfile, \"w\")\n\n # pointCount tells how many points are on the graph\n pointCount = 0\n @x_data.keys.each { |i|\n newfile.puts \"#{@x_data[i]}\\t#{@y_data[i]}\"\n pointCount = pointCount + 1\n }\n\n puts \"There are #{pointCount} points on the plot.\" if $verbose\n\n newfile.close\n\n # plot data\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n\n # plot to a file\n if (savePlot == true)\n plot.terminal \"gif\"\n plot.output filename + \".gif\"\n end\n\n #apply title/labels\n plot.title title\n plot.ylabel y_label\n plot.xlabel x_label\n\n # check if graphs need to be logscaled\n if (logx)\n plot.arbitrary_lines << \"set logscale x\"\n end\n\n if (logy)\n plot.arbitrary_lines << \"set logscale y\"\n end\n\n # check if a linear regression is desired\n if (linreg)\n plot.arbitrary_lines << \"f(x) = m*x + b\"\n plot.arbitrary_lines << \"fit f(x) '\" + datfile + \"' using 1:2 via m,b\"\n end\n\n # perform outlier analysis\n if (outlierAnalysis[0])\n\n # generate array of slopes of data\n yDivX = Array.new\n @x_data.keys.each { |key|\n yDivX.push(@y_data[key].to_f / @x_data[key].to_f)\n }\n\n # apply the 5 number summary function\n summData = Array.new\n summData = yDivX.fiveNumSum # match to new function\n\n # Calculate slopes of minimum and maximum lines to show outliers\n maxline = summData[2] + outlierAnalysis[1] * (summData[3] - summData[1])\n minline = summData[2] - outlierAnalysis[1] * (summData[3] - summData[1])\n\n # Define the minline and maxline in gnuplot\n plot.arbitrary_lines << \"a(x) = #{minline}*x\"\n plot.arbitrary_lines << \"b(x) = #{maxline}*x\"\n\n end #outlier analysis\n\n\n # Generate a plot string\n plotString = \"plot '#{datfile}' notitle\"\n\n # add linear regression\n if (linreg)\n plotString = plotString + \", f(x) title 'Linear Fit'\"\n end\n\n # plot with outlier analysis\n if (outlierAnalysis[0])\n plotString = plotString + \", a(x) title 'Minimum', b(x) title 'Maximum'\"\n end\n # add data point names if desired\n if (dataLabels && addOutlierLabels == 0) # Won't label everything if outlier labeling is enabled\n @x_data.keys.each { |key|\n plot.arbitrary_lines << \"set label '#{key}' at #{@x_data[key].to_f}, #{@y_data[key].to_f}\"\n }\n end\n\n # add outlier data labels\n if ( addOutlierLabels > 0 )\n self.findOutliers( filename + \"ForLabels\", addOutlierLabels )\n @outlier_data.keys.each { |key|\n # add labels to each point where an outlier exists\n plot.arbitrary_lines << \"set label '#{key}' at #{@x_data[key].to_f}, #{@y_data[key].to_f}\"\n }\n puts \"Labeled #{@outlier_data.size} outliers.\" if $verbose\n end\n plot.arbitrary_lines << plotString\n end\n end\n\n # Regenerate the data file to add in key names.\n newfile = File.new(datfile+ \"WITHNAMES\", \"w\")\n \n newfile.puts \"Name\\tX\\tY\"\n\n @x_data.keys.each { |i|\n newfile.puts \"#{i}\\t#{@x_data[i]}\\t#{@y_data[i]}\"\n }\n\n newfile.close\n\n else\n puts \"X and Y are different sizes\"\n end # x y size check\n end # scatter\n\n end", "def setup\n super\n @background_colour = @colour\n @foreground_colour = Palette.white\n @axis = :y\n end", "def update_visualization(point)\n\t\tsuper(point)\n\tend", "def set_plotarea(params)\n # Convert the user defined properties to internal properties.\n @plotarea = get_area_properties(params)\n end", "def set_tree_plot\n @tree_plot = TreePlot.find(params[:id])\n end", "def xaxis\n end", "def set_plot_point\n @plot_point = PlotPoint.find(params[:id])\n end", "def initialize( config )\n @config = config\n\n self.top_align = self.top_font = self.right_align = self.right_font = 0\n\n init_with({\n :width => 500,\n :height => 300,\n :show_x_guidelines => false,\n :show_y_guidelines => true,\n :show_data_values => true,\n\n# :min_scale_value => 0,\n\n :show_x_labels => true,\n :stagger_x_labels => false,\n :rotate_x_labels => false,\n :step_x_labels => 1,\n :step_include_first_x_label => true,\n\n :show_y_labels => true,\n :rotate_y_labels => false,\n :stagger_y_labels => false,\n :scale_integers => false,\n\n :show_x_title => false,\n :x_title => 'X Field names',\n\n :show_y_title => false,\n :y_title_text_direction => :bt,\n :y_title => 'Y Scale',\n\n :show_graph_title => false,\n :graph_title => 'Graph Title',\n :show_graph_subtitle => false,\n :graph_subtitle => 'Graph Sub Title',\n :key => true, \n :key_position => :right, # bottom or right\n\n :font_size =>12,\n :title_font_size =>16,\n :subtitle_font_size =>14,\n :x_label_font_size =>12,\n :x_title_font_size =>14,\n :y_label_font_size =>12,\n :y_title_font_size =>14,\n :key_font_size =>10,\n \n :no_css =>false,\n :add_popups =>false,\n })\n\n\t\t\t\tset_defaults if respond_to? :set_defaults\n\n init_with config\n end", "def initialize(plots)\n @t = FigureMaker.default\n @margin = 0.025\n\n plots.each do |plot|\n t.def_figure(plot.title) { exec_plot(plot) }\n end\n\n end", "def generateSeriesPlot(xyData, options={})\n plotOptions={:width=>200, :height=>100, :imagetype=> \"png\", :xlabel=> \"\", :ylabel=> \"\"}\n plotOptions=plotOptions.merge(options)\n Gnuplot.open do |gp|\n Gnuplot::Plot.new( gp ) do |plot|\n plot.terminal \"#{plotOptions[:imagetype]} small enhanced size #{plotOptions[:width]},#{plotOptions[:height]} crop\"\n plot.output Rails.root.to_s+\"/public/series.png\"\n plot.ylabel plotOptions[:ylabel]\n plot.xlabel plotOptions[:xlabel]\n plot.boxwidth 0.5\n plot.grid \"\"\n plot.data << Gnuplot::DataSet.new( xyData ) do |ds|\n ds.with = \"boxes fill solid 0.5\"\n ds.notitle\n end\n end\n end\n end", "def plot_data data, series=nil, filename=nil, title=nil\n # stub method to enable documentation in yard\n\t\tend", "def set_figure(figure)\n @figure = figure\n end", "def initialize(args = {})\n @cfg = {\n :dim => 2,\n :exp_f => 1.5, \n :cnt_f => 0.5,\n :tol => 0.001,\n :niter => 50,\n :pconv => true,\n :plotopt=> {:title => 'Nelder Mean Method Convergence',\n :xlabel => 'No. iteration',\n :ylabel => 'Objective function value',\n :yrange => [ -1 , 3 ],\n :grid => \"set grid\"\n }\n }\n @cfg.merge! args\n @simplex = Simplex.new(@cfg[:dim])\n @start_points = []\n @status = :filling\n @iteration = 0\n if @cfg[:pconv] == true # this is the plot\n @gp = GNUPlotr.new(\"/opt/local/bin/gnuplot\")\n # enable command history recording\n @gp.record = true\n # Issue raw gnuplot commands\n @gp.raw @cfg[:plotopt][:grid]\n # Some magic mapping works too:\n @gp.set_grid\n @gp.set_title @cfg[:plotopt][:title] , :font => \"Times New Roman,18\"\n @gp.set_xlabel @cfg[:plotopt][:xlabel], :font => \"Times New Roman,18\"\n @gp.set_ylabel @cfg[:plotopt][:ylabel], :font => \"Times New Roman,18\"\n @gp.set_xrange( 0 .. @cfg[:niter])\n @gp.set_yrange(@cfg[:plotopt][:yrange][0] .. @cfg[:plotopt][:yrange][1])\n end\n end", "def set_legend(params)\n @legend_position = params[:position] || 'right'\n @legend_delete_series = params[:delete_series]\n end", "def add_title(input_args=Hash.new)\n @content[:options] ||= Hash.new\n @content[:options][:scales] ||= Hash.new\n if @args[:title]\n @content[:options][:title] = {\n display: true,\n text: @args[:title]\n }\n end\n\n # adjust where x-axis start or end\n x_scale_ticks = { } # Note this doesn't work for Time, which needs to specifies its own Time Min and Max\n y_scale_ticks = { }\n\n y_axes_left = { position: 'left', id: 'y-axis-left', ticks: y_scale_ticks}\n y_axes_right = {position: 'right', id: 'y-axis-right', ticks: y_scale_ticks}\n x_axes = { ticks: x_scale_ticks }\n\n \n\n # y_label(left) is always the first color, and y_label_right is always the second color\n if @args[:y_label]\n y_axes_left[:scaleLabel] = { display: true, labelString: @args[:y_label], fontColor: @colors[0] }\n end\n if @args[:y_right_label] # Jason 090216 right y axis label doesn't work\n y_axes_right[:scaleLabel] = { display: true, labelString: @args[:y_right_label] , fontColor: @colors[1] }\n\n end\n\n if @args[:stacked] \n x_axes[:stacked] = true\n y_axes_left[:stacked] = true \n end\n @content[:options][:scales][:yAxes] = [ y_axes_left]\n if @args[:y_right_label] # Jason 090216 right y axis label doesn't work\n @content[:options][:scales][:yAxes] << y_axes_right\n end\n @content[:options][:maintainAspectRatio] = @args[:aspect_ratio]\n @content[:options][:showLines] = @args[:showLines] if @args.has_key? :showLines\n\n # Chart Zoom plugin options\n @content[:options][:pan] = { enabled: true, mode: 'xy' }\n @content[:options][:zoom] = { enabled: true, mode: 'xy'}\n\n if self.class == ChartMaker::Scatter\n if @args[:time] # x axis is time (same as localtime, time since 1970) \n x_axes[:type] = 'time'\n else # x axis is number\n x_axes[:type] = 'linear'\n end\n x_axes[:position] = 'bottom'\n end\n \n if @args[:x_label]\n x_axes[:scaleLabel] = { display: true, labelString: @args[:x_label] }\n end\n if @args[:time]\n if ! ['hour','day','week','month','year'].include? @args[:time] # check Chart.js Time Scale for all the different Time Units\n raise \"unsupported time format #{@args[:time]}\"\n end\n x_axes[:time] = {}\n x_axes[:time][:unit] = @args[:time] \n x_axes[:time][:tooltipFormat] = \"MMMM Do YYYY, h a\" # need this or time will be display in integer in tooltip mode (when you hover over data point), note this will return invalid if tooltip doesn't contain time\n if input_args[:last_month]\n #puts \"show just last month\"\n a_month_ago = Time.now.to_i - (86400 * 30) # 30 days in terms of seconds\n x_axes[:time][:min] = to_js_time(a_month_ago)\n # also if last_month, then you know a good time unit is week\n x_axes[:time][:unit] = 'week'\n end\n end\n @content[:options][:scales][:xAxes] = [ x_axes]\n=begin\n jchen I have my own tooltips callback function, check def script_content()\n so below is not needed\n @content[:options][:tooltips] = Hash.new\n @content[:options][:tooltips][:callbacks] = Hash.new\n @content[:options][:tooltips][:callbacks][:label] = \"function(tooltipItem,data) { return \\\"jason\\\"; }\"\n=end\n\n end", "def yaxis\n end", "def plot(opts = {}, &block)\n\t\t\tdefault_opts = {:type => DOMAIN_COLORED_PLOT, :color => ChunkyPNG::Color::BLACK,\n\t\t\t\t:vert => DLINES, :horz => DLINES}\n\t\t\topts = default_opts.merge(opts)\n\t\t\tif opts[:type] == DOMAIN_COLORED_PLOT and @size > 0\n\t\t\t\twarn \"Warning in #{self.class}::plot: DOMAIN_COLORED_PLOT will overdraw existing #{@size} plots. Draw 1st for correct behavior.\"\n\t\t\tend\n\t\t\tcase opts[:type]\n\t\t\t\twhen DOMAIN_COLORED_PLOT then plotDCPlot(opts, &block)\n\t\t\t\twhen COMPLEX_CONTOUR_PLOT then plotCCPlot(opts, &block)\n\t\t\t\telse raise RangeError, \"Invalid plot type #{opts[:type]}.\"\n\t\t\tend\n\t\t\t@size += 1\n\t\tend", "def initialize(height: nil, width: nil, figsize_unit: :cm)\n super(0, 0)\n @title = ''\n @nrows = 1\n @ncols = 1\n @width = (width || DEFAULT_CANVAS_DIM).to_f\n @height = (height || DEFAULT_CANVAS_DIM).to_f\n @top_spacing = 5\n @bottom_spacing = 5\n @left_spacing = 5\n @right_spacing = 5\n @subplots = nil\n @figsize_unit = figsize_unit\n set_rubyplot_artist_coords!\n setup_default_theme\n add_subplots! @nrows, @ncols\n end", "def set_chart\n @chart = InformativeChart.new\n end", "def plot(*args)\n contents = parse_plot_args(PlotItem,args)\n _plot_splot(\"plot\",contents)\n nil\n end", "def plot(points = [])\n Gnuplot.open do |gp|\n Gnuplot::Plot.new(gp) do |plot|\n plot.terminal \"pngcairo size 460,460\"\n plot.output @parameters[:fn]\n plot.key \"off\"\n x = []\n y = []\n points << (@parameters[:high]-@parameters[:low])*2+@parameters[:high] if points.empty?\n @arrows ||= []\n if @parameters[:horizontal]\n plot.xrange \"[#{@parameters[:low]}:#{@parameters[:high]}]\"\n plot.yrange \"[0:1]\"\n plot.border 1\n plot.xtics generate_tics\n plot.unset \"ytics\"\n points.each do |p|\n x << p\n y << 0\n end\n @arrows.each do |a|\n if a[3]\n plot.arrow \"from #{a[0]}, 0.05 to #{a[1]}, 0.05 filled lc rgb '#{a[2]}'\"\n else\n plot.arrow \"from #{a[0]}, 0.05 to #{a[1]}, 0.05 heads filled lc rgb '#{a[2]}'\"\n end\n end\n else\n plot.yzeroaxis \"lt -1\"\n plot.xrange \"[-1:1]\"\n plot.yrange \"[#{@parameters[:low]}:#{@parameters[:high]}]\"\n plot.border 0\n plot.ytics \"axis #{generate_tics}\"\n plot.unset \"xtics\"\n points.each do |p|\n x << 0\n y << p\n end\n @arrows.each do |a|\n if a[3]\n plot.arrow \"from 0.1, #{a[0]} to 0.1, #{a[1]} filled lc rgb '#{a[2]}'\"\n else\n plot.arrow \"from 0.1, #{a[0]} to 0.1, #{a[1]} heads filled lc rgb '#{a[2]}'\"\n end\n end\n end\n plot.data << Gnuplot::DataSet.new([x, y]) do |ds|\n ds.with = \"points pt 7 lc rgb '#{color}'\"\n ds.notitle\n end\n end\n end\n if @parameters[:horizontal]\n `convert #{@parameters[:fn]} -crop 460x100+0+360 +repage #{@parameters[:fn]}`\n else\n `convert #{@parameters[:fn]} -crop 100x460+180+0 +repage #{@parameters[:fn]}`\n end\n self\n end", "def plot_script script, filename=nil, title=nil\n # stub method to enable documentation in yard\n end", "def update_visualization(point)\n\t\t\n\tend", "def update_visualization(point)\n\t\t\n\tend", "def update_visualization(point)\n\t\t\n\tend", "def update_visualization(point)\n\t\t\n\tend", "def set_config(*args); end", "def set_config(*args); end", "def set_config(*args); end", "def set_config(*args); end", "def set_config(*args); end", "def basic_chart\n \n end", "def kwargs\n super.merge(\n {\n style: { type: 'scatter' }\n }\n )\n end", "def load_config\n\n @axis_x.move_home_timeout = 15 # seconds after which home command is aborted\n @axis_y.move_home_timeout = 15\n @axis_z.move_home_timeout = 150\n\n @axis_x.invert_axis = false\n @axis_y.invert_axis = false\n @axis_z.invert_axis = false\n\n @axis_x.steps_per_unit = 5 # steps per milimeter for example\n @axis_y.steps_per_unit = 4\n @axis_z.steps_per_unit = 157\n\n @axis_x.max = 220\n @axis_y.max = 128\n @axis_z.max = 0\n\n @axis_x.min = 0\n @axis_y.min = 0\n @axis_z.min = -70\n \n @axis_x.reverse_home = false\n @axis_y.reverse_home = false\n @axis_z.reverse_home = true\n\n end", "def view\n Rubyplot::Plotspace.new(self).view!\n end", "def call\n r = (@identity[2].to_f / @identity[1].to_f).ceil\n c = (@identity[2] % @identity[1]).zero? ? @identity[1] : @identity[2] % @identity[1]\n @ymax = 1 - (1.to_f / @identity[0]) * (r - 1) - 0.095 / @identity[0]\n @ymin = 1 - (1.to_f / @identity[0]) * r + 0.095 / @identity[0]\n @xmin = (1.to_f / @identity[1]) * (c - 1) + 0.095 / @identity[1]\n @xmax = (1.to_f / @identity[1]) * c - 0.095 / @identity[1]\n\n @x_axis_padding = Math.log((@x_range[1] - @x_range[0]), 10).round\n @y_axis_padding = Math.log((@y_range[1] - @y_range[0]), 10).round\n\n @origin[0] = @x_range[0] - @x_axis_padding if @origin[0] == :default\n @origin[1] = @y_range[0] - @y_axis_padding if @origin[1] == :default\n\n SetViewPort.new(@xmin, @xmax, @ymin, @ymax).call\n SetWindow.new(@x_range[0] - @x_axis_padding, @x_range[1] + @x_axis_padding,\n @y_range[0] - @y_axis_padding, @y_range[1] + @y_axis_padding).call\n # Make sure that window is set bigger than range figure out how to manage it\n SetTextAlign.new(2, 0).call\n @text_font = :times_roman if @text_font == :default\n SetTextFontPrecision.new(GR_FONTS[@text_font],\n GR_FONT_PRECISION[:text_precision_string]).call\n SetCharHeight.new(0.012).call\n @y_tick_count = 10 if @y_tick_count == :default\n @x_tick_count = 10 if @x_tick_count == :default # 10 ticks by default\n SetLineColorIndex.new(hex_color_to_gr_color_index(COLOR_INDEX[:black])).call\n SetLineWidth.new(1).call\n SetLineType.new(GR_LINE_TYPES[:solid]).call\n Grid.new((@x_range[1] - @x_range[0]).to_f / @x_tick_count,\n (@y_range[1] - @y_range[0]).to_f / @y_tick_count,\n 0, 0, 1, 1).call\n Axes.new((@x_range[1] - @x_range[0]).to_f / @x_tick_count,\n (@y_range[1] - @y_range[0]).to_f / @y_tick_count,\n @origin[0], @origin[1], 1, 1, 0.01).call\n AxesTitles.new(@x_title, @y_title,'').call\n @tasks.each do |task|\n task.call() if task.plot_type == :robust\n task.call(self) if task.plot_type == :lazy\n end\n end", "def chart_options\n {}\n end", "def plot(comString,doMultiPlot)\n\t\t# ---- print the options\n\t\tcom=\"echo '\\n\"+getStyleString+@oc[\"MiscOptions\"]\n\t\tcom=com+\"set multiplot;\\n\" if doMultiPlot\n\t com=com+\"plot \"+@oc[\"Range\"]+comString+\"\\n'| gnuplot -persist\"\n\t\tprintAndRun(com)\n\t\t# ---- convert to PDF\n\t\tif @oc[\"DoPDF\"]\n\t\t\tcom=\"ps2epsi foo.ps\"\n\t\t\tprintAndRun(com)\n\t\t\tcom=\"epstopdf foo.epsi\"\n\t\t\tprintAndRun(com)\n\t\t\tif @oc[\"OutputFileSpecified\"]!=\"\"\n\t\t\t\tcom=\"mv foo.pdf \"+@oc[\"OutputFileSpecified\"]\n\t\t\t\tprintAndRun(com)\n\t\t\tend\n\t\t\tcom=\"rm -f foo.ps foo.epsi\"\n\t\t\tprintAndRun(com)\n\t\tend\n\tend", "def update_visualization(point)\n\t\t\t\t\n\t\t\tend", "def initialize app, options_hash={}, &block\n super\n app.config[:gp_outdir] = options.gp_outdir\n app.config[:gp_tmpdir] = options.gp_tmpdir\n app.config[:gp_format] = options.gp_format\n\n @@base_dir = \"./#{app.config[:gp_tmpdir]}/#{app.config[:images_dir]}/\"\n\n FileUtils.mkdir_p \"#{@@base_dir}/#{app.config[:gp_outdir]}/\"\n \n term = Middleman::Gnuplot::get_gnuplot_term(options.gp_format)\n\n @@gp = Numo::Gnuplot.new\n @@gp.debug_on\n @@gp.set term:\"#{term}\"\n\n app.after_build do |builder|\n # Move generated plots to build dir\n FileUtils.cp_r @@base_dir, app.config[:build_dir]\n end\n end", "def initialize(chart, options = {})\n @show_marker = false\n @marker_symbol = options[:marker_symbol] || :default\n @smooth = false\n @labels, @data = nil, nil\n super(chart, options)\n @labels = AxDataSource.new(data: options[:labels]) unless options[:labels].nil?\n @data = NumDataSource.new(options) unless options[:data].nil?\n end", "def default_options\n { \n :x => 20,\n :y => 20,\n :gauge_color => \"ff0000\",\n :legend_color => \"cc0000\",\n }\n end", "def makeChart(*options)\n\ndisplay = \"\n<div class='charts last'>\n\n<div class='left'>\n\n\n<div id='placeholder' style='width:400px;height:200px;'></div>\n<div id='overview' style='width:400px;height:50px'></div>\n<p id='overviewLegend' style='margin-left:10px'></p>\n\n<p> Try zooming. Click and drag to select a zone.</p>\n</div>\n\n<div class='right'>\n\nWeight Chart<br/>\n<div id='miniWeight' style='width:350px;height:100px;'></div>\nWater Chart<br/>\n<div id='miniWater' style='width:350px;height:100px;'></div>\n\n\nCalories Eaten<br/>\n<div id='miniCalorie' style='width:350px;height:100px;'></div>\nFitness (Calories burned not to include resting metabolism)<br/>\n<div id='miniFitness' style='width:350px;height:100px;'></div><br/>\n\nMeasurements (Total inches)<br/>\n<div id='miniMeasures' style='width:350px;height:100px;'></div>\n\n\n</div>\n\n\n\n\n<div class='last'></div>\n<script id='source' language='javascript' type='text/javascript'>\n\n\n$(function () {\nvar options = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { \n show: true, \n container: $('#overviewLegend'),\n noColumns: 2,\n }\n};\n\nvar options_overview = {\n xaxis: { mode: 'time' },\n selection: { mode: 'x' },\n legend: { show: false}\n};\n\n\nvar plot = $.plot($('#placeholder'), \n[ #{@chartable.to_chart } ], options);\n\n\n\n\nvar overview = $.plot($('#overview'), \n[ #{@chartable.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n\n\n\n\nvar overview_1 = $.plot($('#miniWeight'), \n[ #{@miniWeight.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_2 = $.plot($('#miniWater'), \n[ #{@miniWater.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_3 = $.plot($('#miniCalorie'), \n[ #{@miniCalorie.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_4 = $.plot($('#miniFitness'), \n[ #{@miniFitness.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\nvar overview_5 = $.plot($('#miniMeasures'), \n[ #{@miniMeasures.to_chart}], \n{ lines: { show: true, lineWidth: 3 },\n shadowSize: 0,\n legend: {\n show: false },\n xaxis: { ticks: 3, mode: 'time' },\n selection: { mode: 'x' }\n});\n\n\n// now connect the two\nvar internalSelection = false;\n\n$('#placeholder').bind('selected', function (event, area) {\n // do the zooming\n plot = $.plot($('#placeholder'), \n [#{@chartable.to_chart}],\n $.extend(true, {}, options, {\n xaxis: { min: area.x1, max: area.x2 }\n }));\n \n if (internalSelection)\n return; // prevent eternal loop\n internalSelection = true;\n overview.setSelection(area);\n internalSelection = false;\n});\n\n$('#overview').bind('selected', function (event, area) {\n if (internalSelection)\n return;\n internalSelection = true;\n plot.setSelection(area);\n internalSelection = false;\n});\n\n\n});\n</script>\n\"\n\nend", "def dpShow(rangeopt = \"\", styles = DfltPlotStyle) \n styles = \"using 1:2 \" + styles if(@timeMode) ;\n datafile = @workfile ;\n if(saveScript?())\n datafile = '-' ;\n end\n com = sprintf(\"plot %s \\\"%s\\\" %s\",rangeopt,datafile,styles) ;\n\n @hline.each{|line|\n label = line[0] ;\n value = line[1] ;\n style = (line[2].nil?) ? \"dots\" : line[2] ;\n\n com += (\", %s title '%s' with %s\" % [value.to_s, label, style]) ; \n \n }\n\n command(com) ;\n\n if(saveScript?())\n open(@workfile){|strm|\n strm.each{|line|\n @strm << line\n }\n }\n @strm << \"e\\n\" ;\n end\n end", "def initialize(backend: :default)\n @backend = backend\n @subplots_list = [Rubyplot::SubPlot.new(1, 1, 1)]\n @tasks = []\n @x_title = ''\n @y_title = ''\n @x_range = [0, 0]\n @y_range = [0, 0]\n @origin = [:default, :default]\n @x_tick_count = :default\n @y_tick_count = :default\n @title = nil\n @title_shift = 0\n @text_font = :default\n @grid = true\n @bounding_box = true\n @x_axis_padding = :default\n @y_axis_padding = :default\n if @backend == :default || @backend == :GR\n require(__dir__.to_s << '/scripting_backends/gr/gr_backend')\n end\n @active_subplot = @subplots_list[0]\n @no_subplot = true\n end", "def axes3d(*)\n super\n end", "def plot3dGeneric_old(title, label, index, baseName)\n index += 1;\n pathBase = \"#{@resultBaseDir}/#{baseName}\" ;\n begin\n gplot = Gnuplot.new(:gplot, pathBase) ;\n gplot.setTitle(title) ;\n gplot.setXYLabel(\"# of Savs (log)\", \"frequency (log)\") ;\n gplot.command(\"set ylabel rotate parallel\") ;\n gplot.command(\"set dgrid3d 100,100 spline\") ;\n gplot.command(\"set pm3d at b\") ;\n gplot.command(\"set cblabel \\\"#{label}\\\" offset -10\") ;\n gplot.command(\"set logscale xy\") ;\n gplot.command(\"set contour\") ;\n gplot.command(\"unset ztics\") ;\n gplot.command(\"set view 0,359.9999\") ; # to show y label at left.\n\n gplot.command(\"$MyData << EOD\") ;\n to_a.each{|analyzer|\n gplot.command(analyzer.genCsvRowSummary().join(\" \")) ;\n }\n gplot.command(\"EOD\") ;\n\n# gplot.command(\"splot $MyData u 1:2:#{index} w lines palette notitle\") ;\n gplot.command(\"splot $MyData u 1:2:#{index} w pm3d t '#{label}'\") ;\n\n gplot.close() ;\n\n #gplot = Gnuplot.new(\"qt\") ;\n gplot = Gnuplot.new(\"wxt\") ;\n gplot.command(\"load \\\"#{pathBase}.gpl\\\"\") ;\n gplot.setTerm(:tgif, \"#{pathBase}\") ;\n gplot.command(\"replot\") ;\n\n ensure\n gplot.close() ;\n end\n end", "def graph_params(title: \"\", subtitle: \"\", caption: \"\", x_label: \"\", y_label: \"\")\n R.labs(\n title: title, \n subtitle: subtitle, \n caption: caption,\n y_label: y_label, \n x_label: x_label, \n )\n end", "def configure(conf)\n super\n end", "def initialize(chart_size='300x200', chart_title=nil, is_xy=false) # :yield: self\n super(chart_size, chart_title)\n self.is_xy = is_xy\n @line_styles = []\n yield self if block_given?\n end", "def plot_params\n params.require(:plot).permit(:title, :content)\n end", "def add_series(plot, opts={})\n plot.series(opts)\n plot\n end", "def add_series(plot, opts={})\n plot.series(opts)\n plot\n end", "def initialize chart_name, data, options = {}\n @current_scale = 1\n @chart_name = chart_name\n @data = data\n @options = options\n @max = 100\n end", "def plotType(sym, type)\n\t@plots[id(sym)][:lt] = type\n end", "def begin_figure\n @legend_keys = []\n @legend_labels = []\n end", "def initialize(frame, options={})\n @scatterStyle = :lineMarker\n @xValAxId = rand(8 ** 8)\n @yValAxId = rand(8 ** 8)\n @xValAxis = ValAxis.new(@xValAxId, @yValAxId)\n @yValAxis = ValAxis.new(@yValAxId, @xValAxId)\n super(frame, options)\n @series_type = ScatterSeries\n @d_lbls = nil\n parse_options options\n end", "def plot_params\n params.require(:plot).permit( :name, :desc )\n end", "def draw_basic_plot(params) \n jitter = params[:jitter]\n grouplist = params[:grouplist]\n snp_list = params[:snp_list]\n x_start = params[:x_start]\n y_start = params[:y_start]\n stat_max = params[:stat_max]\n stat_min = params[:stat_min]\n data_key = params[:data_key]\n plot_labels = params[:plot_labels]\n title = params[:title]\n precision = params[:precision]\n rotate = params[:rotate] || false\n size_mult = params[:size_mult] || 1\n prefix_title = params[:prefix_title] || \"\"\n lci_key = params[:lci_key] || nil\n uci_key = params[:uci_key] || nil\n \n x = @box_size\n xmin = x\n ymin = 0\n ymax = @box_size*9 * size_mult\n y_interval = ymax-ymin\n # set stat_min to be zero\n stat_interval = stat_max - stat_min\n\n value_x = xmin * 0.7 + (@box_size * Math.sqrt(2)*0.25)/2\n \n fill_opacity = 0.9\n if Shape.get_grayscale\n fill_opacity = 1.0\n end\n \n # draw box (change to triangle) with correct color\n snp_list.included_snps.each do |snp_index|\n draw_separator = true\n snp = snp_list.snps[snp_index]\n \n #draw_separation(x_start, y_start, 0, ymax, value_x) unless lci_key\n\n # store points here for output\n points = Array.new\n lines = Array.new\n\n grouplist.groups.each do |group|\n if snp.results.has_key?(group.name)\n result = snp.results[group.name]\n if !result.values[data_key] or result.values[data_key] !~ /\\d/\n next\n end\n box_y_start = ((stat_max-result.values[data_key].to_f) / stat_interval) * y_interval\n\n if rotate\n box_y_start = y_interval - box_y_start\n end\n\n if !group.highlighted\n points << Circle.new(value_x, box_y_start, @box_size * Math.sqrt(2)*0.125, group.colorstr)\n else\n # create triangle here\n points << create_diamond(box_y_start, value_x, 1.0, group.colorstr)\n end\n \n # create a line if there is a confidence interval\n if result.values[uci_key]\n draw_separator = false\n uci_y = ((stat_max-result.values[uci_key].to_f) / stat_interval) * y_interval\n lci_y = ((stat_max-result.values[lci_key].to_f) / stat_interval) * y_interval\n if rotate\n uci_y = y_interval - uci_y\n lci_y = y_interval - lci_y\n end \n\n points.last.interval = Line.new([value_x,value_x], [lci_y,uci_y], group.colorstr)\n end\n \n end\n\n end\n draw_separation(x_start, y_start, 0, ymax, value_x)# if draw_separator\n # sort by y-midpoint\n points.sort! {|x,y| y.ymidpoint <=> x.ymidpoint}\n #lines.sort! {|x,y| y.ymidpoint <=> x.ymidpoint} unless lines.empty?\n\n # those points that overlap significantly\n if jitter\n adjust_horizontal(points, y_interval)\n end\n\n\t # iterate through points and draw all of them\n\t points.each do |point|\n if point.interval \n point.interval.xpoints[0] = point.interval.xpoints[1] = point.xmidpoint\n @canvas.g.translate(x_start,y_start) do |check|\n check.styles(:stroke_width=>2)\n point.interval.draw(check)\n end\n end \n \t end\n\n\t points.each do |point|\n \t @canvas.g.translate(x_start,y_start) do |check|\n \t check.styles(:stroke_width=>1, :fill_opacity=>fill_opacity)\n \t point.draw(check)\n \t end \n end\n \n value_x = label_step(value_x)\n end\n\n if plot_labels\n if rotate\n x_label_start = value_x + x_start+ @box_size * 0.4 \n else\n x_label_start = x_start \n end\n\n if size_mult >= 1\n write_plot_labels(x_label_start, y_start, ymax, stat_max, stat_min, y_interval, 0, prefix_title+title, false, precision, rotate)\n else\n write_plot_labels(x_label_start, y_start, ymax, stat_max, stat_min, y_interval, 0, prefix_title+title,\n false, precision, rotate, 5)\n end\n end\n end", "def show_y_axis\n false\n end", "def configure(opts)\n #This is a stub, used for indexing\n end", "def initialize(title, options = {})\n @title = title\n @width = options[:width] || 250 # defaults to the small graphs\n @height = options[:height] || 200\n @data = GraphData.new\n end", "def plot_1d\n plotter = Plotter.new(:title => \"Signal: values vs. sample number\", :xtitle => \"sample number\", :ytitle => \"sample value\")\n plotter.plot_1d \"signal data\" => @data\n end", "def initialize(frame, options = {})\n @style = 18\n @view_3D = nil\n @graphic_frame = frame\n @graphic_frame.anchor.drawing.worksheet.workbook.charts << self\n @series = SimpleTypedList.new Series\n @show_legend = true\n @legend_position = :r\n @display_blanks_as = :gap\n @series_type = Series\n @title = Title.new\n @bg_color = nil\n @plot_visible_only = true\n @rounded_corners = true\n parse_options options\n start_at(*options[:start_at]) if options[:start_at]\n end_at(*options[:end_at]) if options[:end_at]\n yield self if block_given?\n end", "def set_legend(params)\n # Convert the user default properties to internal properties.\n legend_properties(params)\n end", "def plot type, options = {}\n v = vis(type, options)\n\n v.render()\n\n require \"rsvg2\"\n\n svg = RSVG::Handle.new_from_data(v.to_svg).tap { |s| s.close }\n SciRuby::Plotter.new svg\n end", "def set_figure\n @figure = Figure.find(params[:id])\n end", "def set_figure\n @figure = Figure.find(params[:id])\n end", "def data_set(data, &block)\n Gnuplot::DataSet.new(data) do |ds|\n ds.with = config.linetype\n ds.linewidth = config.linewidth\n block.call(ds) if block_given?\n end\nend", "def configure(c)\n\n c.layout = :fit\n\n c.load_inline_data ||= true\n c.enable_edit_in_form ||= true\n c.enable_edit_inline = false\n c.enable_extended_search = false\n c.enable_column_filters = false\n c.enable_pagination ||= true\n\n super\n\n end", "def initialize(x, y, label = \"\")\n super(x, y, window_width, window_height)\n refresh(label)\n end", "def plot(title, legend_titles, data)\n graph = Scruffy::Graph.new\n graph.title = title\n graph.renderer = Scruffy::Renderers::Standard.new\n data.each_index do |idx|\n graph.add(:line, legend_titles[idx], data[idx],\n {'stroke-width'=> 7, :stroke => 'black'})\n end\n graph.render :to => \"#{title}.svg\", :width=>500, :height=>400\nend", "def setup()\n super() ;\n setupScatterPolicy(getConf(:scatterPolicy)) ;\n end", "def show_legend=(v) Axlsx::validate_boolean(v); @show_legend = v; end", "def plotWxt(gp, sendcmd, ofname, xlabel, ylabel)\n [\n \"set output '#{ofname}'\",\n \"set xlabel '#{xlabel}'\",\n \"set ylabel '#{ylabel}'\",\n #\"splot '#{fname}' #{opt} title '#{nline}'\" \n #\"plot '#{fname}' #{opt} title '#{nline}'\"\n \"plot #{sendcmd}\",\n \"pause 1.2\",\n ].each{|cmd| gp.puts(cmd) }\nend", "def set_config(config)\n\t\tend", "def configure\n end", "def plot\n if( @itemList.length > 0 ) \n configurePlot()\n \n plotcmds = Array.new()\n \n @itemList.each { |item| plotcmds.push( item.command() ) }\n fullcmd = @plotcmd + \" \" + plotcmds.join(\", \")\n writeln( fullcmd )\n \n @itemList.each { |item| item.pipein( @gnuplot ) }\n @gnuplot.flush()\n else\n puts \"No items to plot\"\n end\n end", "def getchart()\n # Data for the chart\n data0 = [5, 3, 10, 4, 3, 5, 2, 5]\n data1 = [12, 6, 17, 6, 7, 9, 4, 7]\n data2 = [17, 7, 22, 7, 18, 13, 5, 11]\n\n labels = [\"North\", \"North<*br*>East\", \"East\", \"South<*br*>East\", \"South\",\n \"South<*br*>West\", \"West\", \"North<*br*>West\"]\n\n # Create a PolarChart object of size 460 x 500 pixels, with a grey (e0e0e0)\n # background and 1 pixel 3D border\n c = ChartDirector::PolarChart.new(460, 500, 0xe0e0e0, 0x000000, 1)\n\n # Add a title to the chart at the top left corner using 15pts Arial Bold Italic\n # font. Use a wood pattern as the title background.\n c.addTitle(\"Polar Area Chart Demo\", \"arialbi.ttf\", 15).setBackground(\n c.patternColor(File.dirname(__FILE__) + \"/wood.png\"))\n\n # Set center of plot area at (230, 280) with radius 180 pixels, and white (ffffff)\n # background.\n c.setPlotArea(230, 280, 180, 0xffffff)\n\n # Set the grid style to circular grid\n c.setGridStyle(false)\n\n # Add a legend box at top-center of plot area (230, 35) using horizontal layout.\n # Use 10 pts Arial Bold font, with 1 pixel 3D border effect.\n b = c.addLegend(230, 35, false, \"arialbd.ttf\", 9)\n b.setAlignment(ChartDirector::TopCenter)\n b.setBackground(ChartDirector::Transparent, ChartDirector::Transparent, 1)\n\n # Set angular axis using the given labels\n c.angularAxis().setLabels(labels)\n\n # Specify the label format for the radial axis\n c.radialAxis().setLabelFormat(\"{value}%\")\n\n # Set radial axis label background to semi-transparent grey (40cccccc)\n c.radialAxis().setLabelStyle().setBackground(0x40cccccc, 0)\n\n # Add the data as area layers\n c.addAreaLayer(data2, -1, \"5 m/s or above\")\n c.addAreaLayer(data1, -1, \"1 - 5 m/s\")\n c.addAreaLayer(data0, -1, \"less than 1 m/s\")\n\n # Output the chart\n send_data(c.makeChart2(ChartDirector::PNG), :type => \"image/png\",\n :disposition => \"inline\")\n end", "def configuring what\n puts \"Configuring: #{what}...\"\n end" ]
[ "0.91367275", "0.69612473", "0.69358647", "0.6410552", "0.6312978", "0.6312978", "0.6312978", "0.6312978", "0.61700505", "0.6160832", "0.6160349", "0.61043495", "0.60529655", "0.60326385", "0.59564346", "0.58714366", "0.58498967", "0.5799983", "0.57948774", "0.5788942", "0.57825464", "0.5744502", "0.57128274", "0.5659407", "0.565395", "0.5640282", "0.56199276", "0.5595445", "0.5588149", "0.55676925", "0.5563625", "0.5561045", "0.5554289", "0.5523754", "0.54972124", "0.54933727", "0.5489718", "0.54895383", "0.5484403", "0.54786485", "0.54747564", "0.5433079", "0.54149187", "0.5412029", "0.5412029", "0.5412029", "0.5412029", "0.54056466", "0.54056466", "0.54056466", "0.54056466", "0.54056466", "0.5385966", "0.5378909", "0.5372446", "0.5370963", "0.53465647", "0.5331312", "0.5330779", "0.53236043", "0.53228974", "0.5301693", "0.52856237", "0.5282301", "0.5280382", "0.52701473", "0.5257923", "0.52572364", "0.52326685", "0.52281547", "0.521382", "0.52117246", "0.52105194", "0.52105194", "0.519703", "0.5191423", "0.51851696", "0.51844937", "0.5176584", "0.51707315", "0.5167911", "0.51643074", "0.5154035", "0.51513505", "0.5149696", "0.5143682", "0.51434", "0.5132276", "0.5132276", "0.51282156", "0.5125936", "0.51257265", "0.5118475", "0.5117768", "0.5117414", "0.51147646", "0.5114217", "0.5111544", "0.51065326", "0.50997025", "0.5097918" ]
0.0
-1
Natural Language Understanding is the subdomain of Natural Language Processing where people used to design AI based applications have ability to understand the human languages. HashInclude Speech Processing team has a project named Virtual Assistant. For this project they appointed you as a data engineer (who has good knowledge of creating clean datasets by writing efficient code). As a data engineer your first task is to make vowel recognition dataset. In this task you have to find the presence of vowels in all possible substrings of the given string. For each given string you have to return the total number of vowels. Example Given a string "baceb" you can split it into substrings: b, ba, bac, bace, baceb, a, ac, ace, aceb, c, ce, ceb, e, eb, b. The number of vowels in each of these substrings is 0, 1, 1, 2, 2, 1, 1, 2, 2, 0, 1, 1, 1, 1, 0; if you sum up these number, you get 16 the expected output. Note: your solution should have linear time complexity.
def vowel_recognition input input, count = input.split("").map! {|x| x =~ /[a,e,i,o,u,A,E,I,O,U]/ ? x = 1 : x = 0 }, 0 input.each_with_index { |x, ind| x == 0 ? 0 : count += ((ind + 1) * (input.length - ind)) } p count end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def vowel_count (str)\n sentence = str.downcase\n letters = sentence.split(\"\")\n count = 0\n vowels = %w{a e i o u}\n letters.each do |letter|\n if vowels.include?(letter) \n count += 1\n end\n end\n puts count\nend", "def Vowel_Count(string)\n a_count=0\n e_count=0\n i_count=0\n o_count=0\n u_count=0\n for pos in 0..string.length\n word=string[pos]\n if (word==\"a\")\n a_count = a_count+1\n elsif(word==\"e\")\n e_count = e_count+1\n elsif(word==\"i\")\n i_count = i_count+1\n elsif(word==\"o\")\n o_count = o_count+1\n elsif(word==\"u\")\n u_count = u_count+1\n end\n end\n puts \"Number of A = #{a_count}\"\n puts \"Number of E = #{e_count}\"\n puts \"Number of I = #{i_count}\"\n puts \"Number of O = #{o_count}\"\n puts \"Number of U = #{u_count}\"\nend", "def getCount(inputStr)\n vowels = [\"a\",\"e\",\"i\",\"o\",\"u\"]\n count = 0\n \n letters = inputStr.split(\"\")\n letters.each { |letter|\n if vowels.include?(letter)\n count += 1\n end\n }\n count\nend", "def count_vowels(str)\n vowels = 0\n str.split('').each do |char|\n vowels += 1 if ['a', 'e', 'i', 'o', 'u'].include? char\n end\n vowels\nend", "def count_vowels(str)\n str.chars.map do |letter|\n if vowel? letter\n letter = 1\n else\n letter = 0\n end\n end.reduce(0, :+)\nend", "def vowels(str)\n the_vowels = ['a', 'e', 'i', 'o', 'u']\n vowel_count = 0\n str.split('').each { |char|\n if the_vowels.include?(char.downcase)\n vowel_count += 1\n end\n }\n\n vowel_count\nend", "def solve(string)\n vowels = 'aeiou'\n string_of_chars = string.chars\n \n count = 0\n counted = []\n \n string_of_chars.each do |char|\n if vowels.include?(char)\n count += 1\n else\n count = 0\n end\n counted << [count]\n end\n counted.max.first\n end", "def get_vowel_count(string)\n vowels = [\"a\",\"e\", \"i\", \"o\", \"u\"]\n vowel_count = 0\n string.each_char do |char|\n vowel_count += 1 if vowels.include?(char)\n end\n vowel_count\nend", "def vowel_recognition(s)\n (0...s.size).map {|i| s[i] =~ /[aeiou]/i ? (s.size - i) * (i + 1) : 0}.sum\nend", "def getCount(inputStr)\n vowels_arr=['a','e','i','o','u']\n num=0\n input_arr=inputStr.split(//)\n input_arr.each do |elem|\n vowels_arr.each do |elem2|\n if elem==elem2\n num+=1\n end\n end\n\n end\n\n return num\n\n\nend", "def VowelCount(str)\n\n # code goes here\n vowel = ['a','e','i','o','u']\n ary = str.split(//)\n counter = 0\n ary.each do |letter|\n if vowel.include? letter\n counter += 1\n end\n end\n return counter\n \nend", "def count_vowels (string)\n\n # Downcase for case insensitivity, get vowels, drop non-unique, count\n return string.downcase.scan(/[aeiou]/).uniq.count\n\nend", "def num_vowels(str)\n result = 0\n str.each_char do |chr|\n VOWELS.each do |vow|\n if chr == vow\n result +=1\n end\n end\n end\n result\nend", "def num_vowels(str)\n # your code goes here\n vowel_count = 0\n vowels = 'aeiou'\n str.downcase.each_char do |ch|\n if vowels.include?(ch)\n vowel_count += 1\n end\n end\n vowel_count\nend", "def vowel_counter(string, vowels_array, syllable_counter)\n string_by_word = string.split(' ')\n p string_by_word\n string_by_word.each do |word|\n p word\n vowels_array.each do |char|\n syllable_counter += word.count(char)\n end\n binding.pry\n # if word ends in E\n if word[-1] === 'e'\n syllable_counter -= 1\n end\n # if word ends in ES\n if word[-1] === 's'\n if word[-2] === 'e'\n syllable_counter -= 1\n end\n end\n # if word has 'AE'\n if word.include?('ae')\n syllable_counter -= 1\n end\n # if word has 'AI'\n if word.include?('ai')\n syllable_counter -= 1\n end\n # if word has 'DGE'\n if word.include?('dge')\n syllable_counter -= 1\n end\n # if word has 'EA'\n if word.include?('ea')\n syllable_counter -= 1\n end\n # if word has 'EI'\n if word.include?('ei')\n syllable_counter -= 1\n end\n # if word has 'GE'\n if word.include?('ge')\n syllable_counter -= 1\n end\n # if word has 'IE'\n if word.include?('ie')\n syllable_counter -= 1\n end\n # if word has 'OA'\n if word.include?('oa')\n syllable_counter -= 1\n end\n # if word has 'OI'\n if word.include?('oi')\n syllable_counter -= 1\n end\n # if word has 'OU'\n if word.include?('ou')\n syllable_counter -= 1\n end\n end\n # remove 21\n p syllable_counter\n end", "def vowel_count(str)\n str.split('').select { |a| a =~ /[aeiouAEIOU]/ }.length\nend", "def count_vowels(string)\n num_vowels = 0\n\n i = 0\n while i < string.length\n if (string[i] == \"a\" || string[i] == \"e\" || string[i] == \"i\" || string[i] == \"o\" || string[i] == \"u\")\n num_vowels += 1\n end\n\n i += 1\n end\n\n return num_vowels\nend", "def num_vowels(str)\r\n # your code goes here\r\n\r\n vowels = [\"a\",\"A\",\"e\",\"E\",\"i\",\"I\",\"o\",\"u\",\"U\"]\r\n num_vowels = 0\r\n\r\n i = 0\r\n while i < str.length\r\n if vowels.include?(str[i])\r\n num_vowels += 1\r\n end\r\n i += 1\r\n\r\n end\r\n num_vowels\r\nend", "def count_vowels(string)\n\t\n\tvowel_counter = 0\n\tstring_splitter = string.split(\"\")\n\t\n\tstring_splitter.each do |letter|\n\t\tif letter.include?(\"a\") \n\t\t\tvowel_counter += 1\n\t\telsif letter.include?(\"e\") \n\t\t\tvowel_counter += 1\n\t\telsif letter.include?(\"i\") \n\t\t\tvowel_counter += 1\n\t\telsif letter.include?(\"o\") \n\t\t\tvowel_counter += 1\n\t\telsif letter.include?(\"u\") \n\t\t\tvowel_counter += 1\n\t\telsif letter.include?(\"y\") \n\t\t\tvowel_counter += 1\n\t\tend\n\tend\nvowel_counter\nend", "def num_vowels(str)\n vowels = \"aeiou\"\n count = 0\n str.downcase.each_char do |char|\n if vowels.include?(char)\n count += 1\n end\n end\n return count\nend", "def count_vowels(string)\ni = 0\nvowels = 0\n while i<string.length do\n if string[i] == \"a\" || string[i] == \"e\" || string[i] == \"i\" || string[i] == \"o\" || string[i] == \"u\"\n vowels += 1\n end\n i += 1\n end\nputs vowels\nend", "def num_vowels(str)\n vowels = 'aeiou'\n count = 0\n str.downcase.each_char do |char|\n count += 1 if vowels.include?(char)\n end\n count\nend", "def vowels(text)\n vowels = %w(A E I O U)\n chars = text.upcase.split('')\n vowel_count = 0\n\n chars.each { |c| vowel_count += 1 if vowels.include? c }\n\n vowel_count.to_f / text.length\n end", "def num_vowels(str)\n # your code goes here\n new_str = str.downcase\n vowels ='aeiou'\n count = 0\n new_str.each_char do |char|\n if vowels.include?(char)\n count += 1\n end\n end\n\n count\nend", "def vowel_count(string)\n\tcounter = 0\n\tletters = string.split(\"\")\n\tletters.each do |letter|\n\t\tif letter == \"a\"\n\t\t\tcounter += 1\n\t\telsif letter == \"e\"\n\t\t\tcounter += 1\n\t\telsif letter == \"i\"\n\t\t\tcounter += 1\n\t\telsif letter == \"o\"\n\t\t\tcounter += 1\n\t\telsif letter == \"u\"\n\t\t\tcounter += 1\n\t\tend\n\tend\n\tp counter\nend", "def vowelCount(str)\n\tcount = 0\n\tstr = str.split('').each{|x| count += 1 if(%(a e i o u).include?(x))}\n\treturn count\nend", "def num_vowels(str)\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", \"I\",\"O\", \"U\"]\n count = 0\n\n chars = str.chars\n\n chars.each do |le|\n if vowels.index(le) != nil\n count += 1\n end\n\n end\n\n count\nend", "def vowel_count (string)\n\n vowel_number = 0\n i = 0\n\n while( string.length() > i )\n\n if( (string[i] == \"a\") || (string[i] == \"e\") || (string[i] == \"i\") || (string[i] == \"o\") || (string[i] == \"u\") )\n vowel_number += 1\n end\n\n i += 1\n end\n\n return vowel_number\nend", "def VowelCount(str)\n count = 0\n i = 0\n str = str.downcase.split(\"\")\n while i < str.length\n if str[i] == \"a\" || str[i] == \"e\" || str[i] == \"i\" || str[i] == \"o\" || str[i] == \"u\"\n count += 1\n end\n i += 1\n end\n return count\nend", "def vowel_count(word)\n count = 0\n vowels = \"aeiouAEIOU\"\n word.each_char do |char|\n if vowels.include?(char)\n count += 1\n end\n end\n return count\nend", "def count_vowels(word)\n count = 0 \n \n i = 0 \n while i < word.length\n char = word[i]\n \n if char == \"a\" || char == \"e\" || char == \"i\" || char == \"o\" || char == \"u\"\n count += 1\n end\n\n i += 1\n end\n\n return count\nend", "def num_vowels(str)\n vowels = \"aeiou\"\n count = 0\n str.downcase.each_char {|ch| count += 1 if vowels.include?(ch)}\n count\nend", "def VowelCount(str)\ncount=0\n\tarr=str.split(//)\n \tarr.each{|x| count=count+1 if x.match(/[aeiou]/) }\n \treturn count\nend", "def VowelCount(str)\n count = 0\n \n str.each_char do |c|\n count += 1 if c =~ /[aeiou]/\n end\n \n return count\nend", "def count_vowels(word)\n counter = 0\n i = 0\n while i < word.length\n if word[i] == 'a' ||\n word[i] == 'e' ||\n word[i] == 'i' ||\n word[i] == 'o' ||\n word[i] == 'u'\n counter += 1\n end\n i += 1\n end\n return counter\nend", "def vowel_count(word)\n count = 0 \n vowels = \"aeiou\"\n word.each_char do |char|\n if vowels.include?(char)\n count += 1\n end\n end\n\n return count\nend", "def num_vowels(str)\r\n # your code goes here\r\n vowels = ['a', 'e', 'i', 'o', 'u']\r\n num_vowels = 0\r\n str = str.downcase\r\n\r\n i = 0\r\n while i < str.length\r\n if vowels.include?(str[i])\r\n num_vowels += 1\r\n end\r\n i += 1\r\n end\r\n num_vowels\r\n\r\nend", "def VowelCount(str)\n\n # code goes here\n count = 0\n \n str.each_char do |letter|\n if letter =~ /[aeiou]/\n count += 1 \n end\n end\n \n return count\n \nend", "def count_vowels(string)\n x = 0\n vowelcount = 0\n while string.length > x\n it = string[x]\n if it == \"a\" || it == \"e\" || it == \"i\" || it == \"o\" || it == \"u\"\n vowelcount += 1\n end\n x += 1\n end\n return vowelcount\nend", "def vowel_counter(word)\n count = 0\n vowels = \"aeiouAEIOU\"\n word.each_char do |char|\n if vowels.include?(char)\n count += 1\n end\n end\n count\nend", "def count_vowels(s)\n\tp s.count('aeiou')\nend", "def VowelCount(str)\n\n counter = 0\n str.each_char do |x|\n if(x.match(/[aieou]/))\n counter += 1\n end\n end\n return counter\n \nend", "def count_vowels(word)\n totvow = 0 \n i = 0\n\n while i < word.length\n if word[i] == 'a' || word[i] == 'e' || word[i] == 'i' || word[i] == 'o' || word[i] == 'u'\n totvow += 1\n end\n\n i += 1\n end\n\n return totvow\nend", "def count_vowels(word)\n\tcounter = 0\n \ti = 0\n \twhile i < word.length\n vowel = word[i]\n if vowel == \"a\" || vowel == \"e\" || vowel == \"i\" || vowel == \"o\" || vowel == \"u\"\n counter += 1\n end\n i += 1\n end\n return counter\nend", "def count_vowels(str)\n str.count(\"aeoui\")\nend", "def count_vowels(word)\n count = 0\n i = 0\n vowels = ['a', 'e', 'i', 'o', 'u']\n \n while i < word.length\n if vowels.include? word.downcase[i] # or char == \"a\" || char == \"e\" etc.\n count += 1\n end\n i += 1\n end\n \n return count\nend", "def checkvowel(str)\n vowels = {'a' => 0, 'e' => 0, 'i' => 0, 'o' => 0, 'u' => 0}\n count = 0\n str.split(\"\").each do|char|\n if !vowels[char].nil?\n vowels[char] += 1\n count += 1\n end\n end\n puts \"Vowels found: #{count}\"\n vowels.each do |k,v|\n puts \"#{k}: #{v}\"\n end\nend", "def num_vowels(word)\r\n vowels = [\"a\", \"e\", \"i\", \"o\", \"u\"]\r\n word.chars.count {|ch| vowels.include?(ch.downcase)}\r\nend", "def num_vowels(str)\n str.count(VOWELS)\nend", "def count_vowels(word)\n\tvowels = [\"a\",\"e\",\"i\",\"o\",\"u\",\"A\",\"E\",\"I\",\"O\",\"U\"]\n \ti = 0\n \tcount = 0\n \twhile ( i < word.length)\n if( vowels.include? word[i] )\n count+=1\n end\n i+=1\n end\n return count\nend", "def VowelCount(str)\n str.count \"aeiou\" \nend", "def count_vowels\n text.scan(/[aeoui]/).length\n end", "def num_vowels(str)\n str.downcase.scan(/[aeiou]/).count\nend", "def vowel_count(string)\n\t\n\tstring.downcase.count \"aeiou\"\n\t\nend", "def VowelCount(str)\n str.scan(/[aeiouAEIOU]/).count\nend", "def count_vowels (string)\r\n array = []\r\n letters = string.split(\"\")\r\n array << letters\r\n array.each do | letters |\r\n vowels = []\r\n if letters == \"a\"\r\n vowels << letters\r\n elsif letters == \"e\"\r\n vowels << letters\r\n elsif letters == \"i\"\r\n vowels << letters\r\n elsif letters == \"o\"\r\n vowels << letters\r\n elsif letters == \"u\"\r\n else\r\n puts \"no\"\r\n end\r\n #puts array.include?(\"a\")\r\n end\r\nend", "def count_vowels(string)\n string.downcase.count('aeiou')\nend", "def count_vowels(string)\r\n list = {}\r\n a = string.count(\"a\")\r\n e = string.count(\"e\")\r\n i = string.count(\"i\")\r\n o = string.count(\"o\")\r\n u = string.count(\"u\")\r\n list[\"a\"] = a\r\n list[\"e\"] = e\r\n list[\"i\"] = i\r\n list[\"o\"] = o\r\n list[\"u\"] = u\r\n list\r\nend", "def count_vowels(word)\nend", "def countVowels(str='')\n str.scan(/[aeiou]/i).size\nend", "def count_vowels(datacontent)\n #initalize vowel_array\n vowel_list ={'a'=>0, 'e'=>0, 'i'=>0, 'o'=> 0, 'u'=>0}\n sum_of_vowels = 0\n datacontent.each_char do |i| \n vowel_list.each_key do |a|\n if i == a\n sum_of_vowels += 1\n vowel_list[i] += 1 \n end\n end\n end\n return vowel_list,sum_of_vowels\nend", "def number_of_vowels(string)\r\n count = string.downcase.scan(/[aeiou]/).size\r\n \r\n case count\r\n when 1\r\n \"There is 1 vowel in this word\"\r\n when 0 \r\n \"There are no vowels in this word\"\r\n else\r\n \"There are #{count} number of vowels\"\r\n end\r\n \r\nend", "def num_vowels(str)\n # your code goes here\n str.downcase!\n str.count(\"aeiou\")\nend", "def vowel_count(str)\n str.downcase.count('aeiou')\nend", "def getCount(input_str)\n regex = /[aeiou]/\n input_str.split('').select { |char| char if char =~ regex }.count\nend", "def count_of_upper_case_vowels\n strings = @new_content.map(&:capitalize).join.scan(/[#{VOWELS}][^#{VOWELS}]*/)\n total = 0\n\n (1..strings.size - 1).each do |index|\n prev_string = strings[index - 1]\n next unless prev_string.match(/[#{CONSONANTS.upcase}]/).nil?\n char = strings[index][0]\n next unless capitalized?(char) || (capitalized?(prev_string[0]) && prev_string.size > 2)\n total += 1\n strings[index][0] = char.upcase\n end\n total\n end", "def getCount(inputStr)\n inputStr.scan(/[aeiou]/i).size\nend", "def getCount(inputStr)\n inputStr.scan(/[aeiou]/i).size\nend", "def get_count(input_str)\n input_str.scan(/[euoai]/).size\nend", "def getCount(str)\n # str = \"abracadabra\" => 5\n vowels = [\"a\", \"i\", \"e\", \"o\", \"u\"]\n str.split(\"\").filter { |letter| vowels.include?(letter) }.count # filter is an alias for select\nend", "def get_count(input_str)\n input_str.count \"aeiou\"\nend", "def getCount(inputStr)\n inputStr.chars.count{|letter| letter=~/[aeiou]/}\nend", "def getCount(inputStr)\n inputStr.count 'aeiouAEIOU'\nend", "def getCount(inputStr)\n inputStr.scan(/[aeiou]/).count\nend", "def getCount(inputStr)\n return inputStr.count(\"aeiou\")\nend", "def getCount(inputStr)\n inputStr.count('aeiou')\nend", "def getCount(inputStr)\n inputStr.count('aeiou')\nend", "def solve(str)\n vowels = ['a','e','i','o','u'];\n alphabet = {\n :a => 1,\n :b => 2,\n :c => 3,\n :d => 4,\n :e => 5,\n :f => 6,\n :g => 7,\n :h => 8,\n :i => 9,\n :j => 10,\n :k => 11,\n :l => 12,\n :m => 13,\n :n => 14,\n :o => 15,\n :p => 16,\n :q => 17,\n :r => 18,\n :s => 19,\n :t => 20,\n :u => 21,\n :v => 22,\n :w => 23,\n :x => 24,\n :y => 25,\n :z => 26\n };\n\n max_substring_value = 0;\n current_substring_value = 0;\n\n str.chars.each do |c|\n unless vowels.include?(c)\n current_substring_value += alphabet[:\"#{c}\"];\n else\n if current_substring_value > max_substring_value\n max_substring_value = current_substring_value;\n end\n current_substring_value = 0;\n end\n end\n\n max_substring_value\nend", "def solution(s)\n return 0 if s.empty?\n t = 0\n ('A'..'Z').to_a.each do |c|\n t += s.count(c)\n end\n t + 1\nend", "def getCount(inputStr)\n #your code here\n count = 0\n inputStr.chars {|x| x.match(/[aeiou]/) ? count += 1 : count += 0 }\n count\nend", "def ordered_vowel_words(str)\n\nvowels = [\"a\",\"e\",\"i\",\"o\",\"u\",\"y\"]\nsplitted_str = str.split(\"\")\narr = []\nresults = []\n\nsplitted_str.each { |letter| arr << letter if vowels.include?(letter)}\njust_vowels = arr.uniq.join(\"\")\narr_of_vowels = vowels.combination(just_vowels.length).to_a\n\n arr_of_vowels.each { |arr| results = str if arr.join(\"\") == just_vowels }\n results = \"\" if results.empty?\n results\nend", "def counting_vowels(my_array)\n vowel_count = 0 #counter\n my_array.each do |letter|\n if (letter == 'a' or\n letter == 'e' or letter == 'i' or\n letter == 'o' or letter == 'u')\n vowel_count +=1 #incremental counter\n end\n end\n puts vowel_count #printed it out\nend", "def solve(s)\n s.split(/[aeiou]/).map{ |x| x.sum - x.size * 96 }.max\nend", "def vowels(line)\n vowels = 0\n line.each_char do |c|\n if c.scan(/[aeiou]/) != []\n vowels += 1\n end\n end\n\n return vowels\nend", "def get_count(input)\n input.count('aeiou')\nend", "def get_count(input_str)\n input_str.downcase.count(\"aeiou\")\nend", "def most_vowels(sentence)\r\n mostVowels = {\"word\" => '', \"count\" => 0}\r\n sentence.split(\" \").each do |word|\r\n \tcount = 0\r\n word.each_char do |char|\r\n if 'aeiou'.include?(char)\r\n count += 1\r\n end\r\n end\r\n if count > mostVowels[\"count\"]\r\n mostVowels[\"word\"] = word\r\n mostVowels[\"count\"] = count\r\n end\r\n end\r\n return mostVowels[\"word\"]\r\nend", "def solve(s)\n alphabet = ('a'..'z').to_a\n s.gsub(/[aeiou]/, ' ').split.map { |l| l.chars.map { |i| alphabet.index(i) + 1 }.sum }.max\nend", "def segment_length(word)\n chars_before_vowel = 0\n word.each_char do |letter|\n if is_vowel?(letter)\n break\n end\n chars_before_vowel += 1\n end\n length = word.length - chars_before_vowel\n return length\nend", "def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend", "def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend", "def getCount(s)\n s.count('aeiou')\nend", "def nice_strings(input)\n strings = input.split(\"\\n\").map(&:strip)\n nice_count = 0\n strings.each do |string|\n twinsy = twinsies(string)\n vowel_count = get_vowel_count(string)\n nice_count += 1 if !illegal(string) && vowel_count > 2 && twinsy == true\n end\n nice_count\nend", "def custom_count(string, search_characters)\n total_chars = 0\n #\n search_characters.each_char do |sc|\n # split the string and review letter & sc\n letters = string.each_char { |letter| letter == sc ? total_chars += 1 : next }\n\n end # end of do (search chars)\n\n total_chars\nend", "def getCount(inputStr)\n inputStr.downcase.count('aeiou')\nend", "def getCount(str)\n str.count(\"AEIOUaeiou\")\nend", "def most_vowels(sentence)\n\n arr = sentence.split(\" \")\n fullArr = []\n counter = 0\n vowels = \"aeiou\"\n rtrArr = []\n \n arr.each_with_index do |ele, idx|\n setupArr = []\n locCount = 0\n\n ele.each_char do |let|\n if vowels.include?(let)\n locCount += 1\n else\n next\n end\n end\n\n fullArr << setupArr.push(locCount, idx)\n end\n\n fullArr.each do |ele2|\n if ele2[0] > counter\n rtrArr[0] = arr[ele2[1]]\n counter = ele2[0]\n else\n next\n end\n end\n return rtrArr.join(\"\")\nend", "def getCount(inputStr)\n inputStr.downcase.count(\"aeiou\")\nend", "def vowels (string)\n vowels_arr = []\n count_vowels = string.scan(/[aeoui]/)\n vowels_arr << count_vowels\n puts vowels_arr\nend", "def most_vowels(sentence)\n parts = sentence.split\n hash = {}\n parts.each { |word| hash[word] = count_vowels(word)}\n hash.sort_by { |k, v| v }[-1][0]\nend" ]
[ "0.7823777", "0.7781706", "0.7780768", "0.7766419", "0.7670706", "0.76624256", "0.76400393", "0.763531", "0.7625979", "0.76021266", "0.75598127", "0.75511575", "0.75477743", "0.75397444", "0.7539731", "0.7512922", "0.7495083", "0.74829054", "0.74731475", "0.74580646", "0.7455389", "0.74448466", "0.7430162", "0.7411688", "0.7406651", "0.74024147", "0.73936105", "0.7391309", "0.7389962", "0.73826927", "0.73822093", "0.7373178", "0.7372699", "0.73716015", "0.73691773", "0.7366859", "0.7348931", "0.7343539", "0.7337663", "0.7333247", "0.7312907", "0.730944", "0.7278857", "0.7273008", "0.72653306", "0.72574914", "0.72513795", "0.72487056", "0.72451466", "0.72370374", "0.7191229", "0.71885186", "0.71550393", "0.7145131", "0.7123529", "0.7097198", "0.706521", "0.7042757", "0.69852257", "0.6983008", "0.6978076", "0.69771886", "0.69767594", "0.69728696", "0.6953459", "0.6946792", "0.69140714", "0.69140714", "0.68911815", "0.6890772", "0.687843", "0.68525726", "0.6846497", "0.68123966", "0.678702", "0.67438006", "0.67438006", "0.6723694", "0.67217773", "0.67188346", "0.6661364", "0.66434664", "0.6640057", "0.6632358", "0.6618953", "0.661792", "0.6616776", "0.66152346", "0.65770054", "0.653814", "0.653814", "0.65287566", "0.6508571", "0.6499106", "0.6480275", "0.6445047", "0.64423203", "0.64323366", "0.6425924", "0.64195114" ]
0.757697
10
Use callbacks to share common setup or constraints between actions.
def set_item @item = Item.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def set_actions\n actions :all\n end", "def define_action_helpers?; end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup_handler\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 set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end", "def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end", "def startcompany(action)\n @done = true\n action.setup\n end", "def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end", "def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end", "def define_tasks\n define_weave_task\n connect_common_tasks\n end", "def setup(&block)\n define_method(:setup, &block)\n end", "def setup\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def 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 action\n end", "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 after_set_callback; end", "def initialize(*args)\n super\n @action = :set\nend", "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 around_hooks; end", "def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end", "def release_actions; end", "def setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end", "def setup(&blk)\n @setup_block = blk\n end", "def default_action; end", "def callback_phase\n super\n end", "def advice\n end", "def _handle_action_missing(*args); end", "def call\n setup_context\n super\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.61637366", "0.60446453", "0.59452957", "0.591511", "0.58885515", "0.5834122", "0.57761765", "0.5702554", "0.5702554", "0.5652102", "0.5619581", "0.5423898", "0.5409782", "0.5409782", "0.5409782", "0.5394745", "0.53780794", "0.5356209", "0.5338898", "0.53381324", "0.5328622", "0.5309231", "0.5296901", "0.529641", "0.5296097", "0.5258364", "0.5242683", "0.5236372", "0.5236372", "0.5236372", "0.5236372", "0.5236372", "0.52346426", "0.52320486", "0.5225926", "0.52210605", "0.52171826", "0.52138335", "0.5207914", "0.52069265", "0.5176269", "0.5174653", "0.51730466", "0.51650184", "0.5161409", "0.5156175", "0.5154185", "0.5151096", "0.5151089", "0.51452935", "0.5138662", "0.51339483", "0.5113475", "0.51132", "0.51132", "0.5108031", "0.51075375", "0.5090693", "0.50892115", "0.5081523", "0.5081454", "0.5064919", "0.50545585", "0.50531805", "0.50501585", "0.50501585", "0.50329936", "0.5024674", "0.50203156", "0.50156844", "0.50149846", "0.50011337", "0.4999346", "0.49984375", "0.4988749", "0.4988749", "0.49842322", "0.49800175", "0.4979922", "0.49791628", "0.49666047", "0.49655434", "0.49559638", "0.49557537", "0.49554902", "0.4953974", "0.49519545", "0.49449277", "0.49440357", "0.49329734", "0.49315402", "0.49261367", "0.4925912", "0.4925598", "0.4924306", "0.49202663", "0.49167567", "0.49164373", "0.4915191", "0.49145022", "0.49140996" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def item_params params.fetch(:item, {}).permit(:position, :lesson_id, :teacher_id, :week_number, :day_number).merge(group_id: params[:group_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 valid_params_request?; end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\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 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 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 ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\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 post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def url_whitelist; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def 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.6981273", "0.6783789", "0.67460483", "0.6742222", "0.67354137", "0.65934366", "0.65028495", "0.6497783", "0.64826745", "0.6479415", "0.6456823", "0.6440081", "0.63800216", "0.6376521", "0.636652", "0.6319898", "0.6300256", "0.62994003", "0.6293621", "0.6292629", "0.6291586", "0.629103", "0.6282451", "0.6243152", "0.62413", "0.6219024", "0.6213724", "0.62103724", "0.61945", "0.61786324", "0.61755824", "0.6173267", "0.6163613", "0.6153058", "0.61521065", "0.6147508", "0.61234015", "0.61168665", "0.6107466", "0.6106177", "0.6091159", "0.60817343", "0.6071238", "0.6062299", "0.6021663", "0.60182893", "0.6014239", "0.6011563", "0.60080767", "0.60080767", "0.60028875", "0.60005623", "0.59964156", "0.5993086", "0.5992319", "0.5992299", "0.59801805", "0.59676576", "0.59606016", "0.595966", "0.59591126", "0.59589803", "0.5954058", "0.5953234", "0.5944434", "0.5940526", "0.59376484", "0.59376484", "0.5935253", "0.5930846", "0.5926387", "0.59256274", "0.5917907", "0.5910841", "0.590886", "0.59086543", "0.59060425", "0.58981544", "0.5898102", "0.5896809", "0.5895416", "0.58947027", "0.58923644", "0.5887903", "0.58830196", "0.5880581", "0.5873854", "0.58697754", "0.5869004", "0.58669055", "0.5866886", "0.58664906", "0.5864619", "0.58630043", "0.5862495", "0.5861368", "0.5859712", "0.5855544", "0.58551925", "0.5851284", "0.5850602" ]
0.0
-1
GET /join_user_to_assistants GET /join_user_to_assistants.json
def index @join_user_to_assistants = JoinUserToAssistant.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_join_user_to_assistant\n @join_user_to_assistant = JoinUserToAssistant.find(params[:id])\n end", "def create\n @join_user_to_assistant = JoinUserToAssistant.new(join_user_to_assistant_params)\n\n respond_to do |format|\n if @join_user_to_assistant.save\n format.html { redirect_to @join_user_to_assistant, notice: 'Join user to assistant was successfully created.' }\n format.json { render :show, status: :created, location: @join_user_to_assistant }\n else\n format.html { render :new }\n format.json { render json: @join_user_to_assistant.errors, status: :unprocessable_entity }\n end\n end\n end", "def join_for(user)\n joins.find_by_user_id(user)\n end", "def join_user_to_assistant_params\n params.require(:join_user_to_assistant).permit(:cpfk_user_id, :cpfk_assistant_id)\n end", "def new_invite\n if idea_posting.users.exists?(current_user.id)\n @joinrequest = Joinrequest.new\n respond_to do |format|\n format.html \n format.json {redirect_to @joinrequest}\n end\n end\n end", "def show\n if user_signed_in?\n @join = Join.where(user_id: current_user.id, escape_id: params[:id])\n else\n @join = []\n end\n end", "def join\n if request.post?\n if !@group.users.include?(current_user)\n @group.users << current_user\n flash[:success] = \"Thanks! Your membership must now be approved by an admin of #{@group.name}.\"\n\n #SEND OUT NOTIFICATION EMAILS\n @group.admins.each do |admin|\n Notifier.pending_user(admin, @group, current_user).deliver\n end\n\n redirect_to @group\n else\n flash[:error] = \"Error requesting to join #{@group.name}. Please try again.\"\n redirect_to @group\n end\n else #it fell back to GET (no js)\n flash[:error] = \"Please enable javascript to join.\"\n redirect_to @group\n end\n end", "def update\n respond_to do |format|\n if @join_user_to_assistant.update(join_user_to_assistant_params)\n format.html { redirect_to @join_user_to_assistant, notice: 'Join user to assistant was successfully updated.' }\n format.json { render :show, status: :ok, location: @join_user_to_assistant }\n else\n format.html { render :edit }\n format.json { render json: @join_user_to_assistant.errors, status: :unprocessable_entity }\n end\n end\n end", "def index_attending\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.attended_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end", "def join\n @room = Room.find(params.require(:room_id))\n if @room&.add_user(current_user)\n success\n else\n not_found\n end\n end", "def getUserInfo\n login_user_id = params[:my_id].to_i\n login_user = User.find(login_user_id)\n\n target_user_id = params[:target_id].to_i\n target_user = User.find(target_user_id)\n\n # target_userをフォローしているか\n login_user_follow = login_user.follows_of_from_user.pluck(:id).include?(target_user_id)\n\n # target_userの記事一覧を取得\n articles_hash = make_articles_hash(target_user.articles, target_user)\n\n if articles_hash.blank?\n res = {\n result: false,\n data: nil\n }\n else\n res = {\n result: true,\n data: {\n user_id: target_user_id,\n name: target_user.name,\n follow: login_user_follow,\n profile_image: target_user.profile_image_path,\n articles: articles_hash\n }\n }\n end\n\n render json: res\n end", "def join\n @room = OnlineMeetingRoom.find_by_id(params[:id])\n role = @room.user_role(current_user)\n unless role == :denied\n join_internal(current_user.full_name, role, :join)\n else\n flash[:notice] = \"#{t('access_denied')}\"\n redirect_to :index and return\n end\n end", "def joinGroup\n \tquery = \"SELECT user_id FROM group_meals_participants where group_meal_id = \" + GroupMeal.find_by_meal(params[:meal]).id.to_s\n \n GroupMealsParticipant.connection.select_values(query).each do |u|\n \tif(u!=current_user.id)\n \t\tu=User.find(u)\n \t\tu.alert=true\n \t\tu.alert_location=GroupMeal.find_by_meal(params[:meal]).id.to_s\n \t\tu.save\n \tend\n \tend\n @groupMealParticipant= GroupMealsParticipant.new\n @groupMealParticipant.user_id=current_user.id\n @groupMealParticipant.group_meal_id= GroupMeal.find_by_meal(params[:meal]).id\n @groupMealParticipant.save \n redirect_to(GroupMeal.find_by_meal(params[:meal]))\n end", "def join\n unless @user && @kroog && @kroog.open? && current_actor.can_follow?\n flash[:warning] = \"Error: The specified circle does not exist or cannot be joined\".t\n respond_to do |format|\n format.html do\n redirect_to(:controller => 'kroogi', :action => 'join_circles', :id => params[:id])\n end\n format.js {render :update do |page|; page << 'document.location.reload(false);'; end}\n end\n return\n end\n\n # Add the relationship directly -- no invite intermediary\n Relationship.create_kroogi_relationship(:followed => @user.id, :follower => current_actor.id, :relationshiptype_id => @kroog.relationshiptype_id, :expires_at => Time.end, :skip_activity_message => true)\n\n flash[:success] = \"You have joined the %s circle of %s\" / [@user.circle_name(params[:circle].to_i), @user.login]\n PublicQuestionHelper::set_question_artist_id(@user, self, :force_show => true)\n respond_to do |wants|\n wants.html do\n redirect_to user_url_for(@user)\n end\n wants.js {}\n end\n end", "def join\n \n #TODO add player to hunt\n #player = User.find(params[:id])\n redirect_to hunt_player_path()\n end", "def join\n circle_id = params[:circle][:circle_id]\n circle_url = File.join(SITE_URL, \"circles/#{circle_id}\")\n\n joined = CircleUser.where(circle_id: circle_id, user_id: current_user.id).first_or_initialize\n\n respond_to do |format|\n if not joined.persisted?\n joined.save\n Circle.update_counters(params[:circle][:circle_id], people_count: 1)\n User.update_counters(current_user.id, circle_count: 1)\n mod = 1\n else\n joined.delete\n Circle.update_counters(params[:circle][:circle_id], people_count: -1)\n User.update_counters(current_user.id, circle_count: -1)\n mod = -1\n end\n format.json { render json: {'status' => mod, 'circle_url' => circle_url}, status: :created }\n end\n end", "def create\n\t\tact_type = params[:offering_type]\n\t\tuser = User.find_by_id(params[:joining_user])\n\t\tact_id = params[:offering_id]\n\n\t\tif !name_is_valid?(user, act_type); raise Errors::FlowError.new(send(\"#{act_type}_path\", offering_id), \"Permission denied.\"); end\n\n\t\tacts_membership = user.send(\"#{act_type}s_membership\")\n\t\tjoining_act = act_type.camelize.constantize.find_by_id(act_id)\n\n\t\tunless joining_act; raise Errors::FlowError.new; end\n\n\t\t# gender\n\t\tif [\"male\", \"female\"].include? joining_act.gender\n\t\t\tunless user.gender == joining_act.gender; raise Errors::FlowError.new(root_path, \"This #{act_type} is #{joining_act.gender} only.\"); end\n\t\tend\n\n\t\tnumber_of_attendings = joining_act.number_of_attendings\n\t\tif acts_membership.count < number_of_attendings or number_of_attendings == 0\n\t\t\tacts_membership << joining_act\n\t\telse\n\t\t\traise Errors::FlowError.new(send(\"#{act_type}_path\", offering_id), \"Permission denied.\")\n\t\tend\n\t\t@offering = joining_act\n\t\t@members = joining_act.members\n\t\tjoining_act.create_activity :create, owner: user\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to joining_act }\n\t\t\tformat.js\n\t\tend\n\tend", "def user_joined\n user = User.find_by!(id: params[:user_id])\n return json_response({\n \"joined\": ChannelJoined.exists?({\n channel_id: params[:id],\n user_id: params[:user_id]\n })\n })\n end", "def index\n rol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"DN\" or rol.nombre == \"ACRM\"\n @achievments = Achievment.all\n else\n @achievments = Achievment.where(:sede_id=>current_user.sede)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @achievments }\n end\n end", "def user_relationship\n if request.xhr?\n organization_id = params[\"organization_id\"]\n per_page = params[:iDisplayLength] || Settings.per_page\n page = params[:iDisplayStart] ? ((params[:iDisplayStart].to_i/per_page.to_i) + 1) : 1\n params[:iSortCol_0] = 1 if params[:iSortCol_0].blank?\n sort_field = SORT_MAP_RELATIONSHIP[params[:iSortCol_0].to_i]\n # @users = User.get_all_users_except_id(current_user.id, page, per_page, params[:sSearch], sort_field + \" \" + params[:sSortDir_0],organization_id)\n @users = User.get_user_to_relationship(page, per_page, params[:sSearch], sort_field + \" \" + params[:sSortDir_0])\n render :json => @users\n return\n end\n end", "def join\n if !current_user\n flash[:notice] = t(:join_dream)\n elsif @camp.users.include?(current_user)\n flash[:notice] = t(:join_already_sent)\n else\n flash[:notice] = t(:join_dream)\n @camp.users << @user\n end\n redirect_to @camp\n end", "def search\n @lawyer = User.first\n expertise = Expertise.find_by_id(params[:id])\n @users = UserExpertise.where(expertise_id: expertise)\n end", "def join\n @group = Group.find(params[:id])\n \n if group_user = GroupUser.first(:conditions => ['group_id = ? AND user_id = ?', @group.id, current_user.id])\n if ['cancelled', 'invite_declined'].include?(group_user.status)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n elsif group_user.status == 'approved'\n flash[:error] = 'You are already member of this group.'\n else\n flash[:error] = 'You cannot join this group.'\n end\n else\n group_user = GroupUser.create(:group_id => @group.id, :user_id => current_user.id, :role_id => Role.find_by_name('User').id)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n end\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end", "def join\n @group = Group.find(params[:id])\n \n if group_user = GroupUser.first(:conditions => ['group_id = ? AND user_id = ?', @group.id, current_user.id])\n if ['cancelled', 'invite_declined'].include?(group_user.status)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n elsif group_user.status == 'approved'\n flash[:error] = 'You are already member of this group.'\n else\n flash[:error] = 'You cannot join this group.'\n end\n else\n group_user = GroupUser.create(:group_id => @group.id, :user_id => current_user.id, :role_id => Role.find_by_name('User').id)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n end\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end", "def join\n\t\t@event = Event.find(params[:id])\n\n\t\tparams[:user_id] = current_user.id unless admin? && params[:user_id]\n\n\t\t@attendance = Attendance.new\n\t\t@attendance.event_id = @event.id\n\t\t@attendance.user_id = params[:user_id]\n\t\tif @attendance.save\n\t\t\tredirect_to @event, notice: \"Joined!\"\n\t\telse\n\t\t\tredirect_to root_path, alert: \"WTF did you just try to do.\"\n\t\tend\n\tend", "def join_url(username, role, key=nil, options={})\n server = BigbluebuttonRails.configuration.select_server.call(self, :join_meeting_url)\n\n pass = case role\n when :moderator\n self.moderator_api_password\n when :attendee\n self.attendee_api_password\n when :guest\n if BigbluebuttonRails.configuration.guest_support\n options = { guest: true }.merge(options)\n end\n self.attendee_api_password\n else\n map_key_to_internal_password(key)\n end\n\n r = server.api.join_meeting_url(self.meetingid, username, pass, options)\n r.strip! unless r.nil?\n r\n end", "def join!(user)\n # It loads up all the user because in the case where the chat is saved but the chat_participations have not been saved,\n # this is the only way to ensure we don't have duplicates.\n return if self.chat_participations.map(&:user_id).include?(user.id)\n self.chat_participations.create!(:user => user)\n end", "def show\n @assist = Assist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assist }\n end\n end", "def approve_join_request\n join_request = JoinRequest.find(params[:id])\n team = join_request.team\n # Only authorize the captain to do this\n if current_user.id == team.captain_id\n membership = Membership.create(\n team_id: join_request.team_id,\n user_id: join_request.user_id,\n admin: false\n )\n if membership.valid?\n join_request.destroy\n render json: {\n team: TeamSerializer.new(team),\n user: UserSerializer.new(current_user)\n }, status: :accepted\n else\n # invalid request\n render json: {\n message: \"Invalid request\",\n errors: membership.errors.full_messages\n }, status: :not_acceptable\n end\n else\n render json: { message: \"Only the captain is allowed to accept join requests\"}, status: :not_acceptable\n end\n end", "def show\n @requests = Request.where(pet_id: params[:id]).all\n users_id = Array.new(@requests.size) \n @requests.each do |req|\n users_id.push([req.interented_id])\n end\n @interested = User.find(users_id)\n end", "def show\n @interested_user = InterestedUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @interested_user }\n end\n end", "def join \n\n #Check if user exists\n user = User.find_by!(id: params[:user_id])\n\n if (ChannelJoined.exists?({ channel_id: params[:id], user_id: params[:user_id]}))\n json_response({\n \"joined\": true\n })\n else\n joined = ChannelJoined.create!(user_id: params[:user_id], channel_id: params[:id])\n json_response(joined.channel)\n end\n \n \n end", "def get_user_leads username, password, options = {}\n do_request 'get_user_leads', options.merge(username: username, password: password)\n end", "def join\n\t @household = Household.find params[:id]\n\t current_user.update_attribute(:household_id, @household.id)\n\t redirect_to @household\n\tend", "def resumes_joining\n\t @resumes = ReqMatch.where(:status => \"JOINING\")\n\t\trender \"resumes/joining\"\n\tend", "def join\n @person = Person.find(params[:person_id])\n @group = Group.find(params[:id])\n begin\n @person.join_group(@group.id, session[:cookie])\n flash[:notice] = [ :you_have_joined_to_group, @group.title(session[:cookie]) ]\n rescue RestClient::RequestFailed => e\n flash[:error] = message_from_error(e)\n end\n redirect_to group_path(params[:id])\n end", "def landing\n \t@user = User.find(params[:id])\n @course = User.joins(:course).select(\"users.*,courses.*\").find(params[:id])\n end", "def invite_via_suggestion\n @user = User.create_with_organisation_membership_from_project_invite @invite\n\n if @user.valid?\n RequestMailer.invite_via_suggestion @user, @invite, current_user\n\n @invite.set_handled_suggested_user!\n redirect_to :dashboard, notice: \"#{@user.email} has been sent an invite\"\n elsif account_has_been_claimed? @user\n @invite.set_handled_suggested_user!\n redirect_to :dashboard, notice: \"This user has already been invited to Digital Social\" \n else\n redirect_to :dashboard, alert: \"There was an error inviting #{@user.email}, please try again later.\" \n end\n end", "def join\n @filter.profile_request(current_profile)\n respond_to do |format|\n format.html do\n# flash[:notice] = \"Your request to join #{@profile.name}'s #{@filter.name} filter has been sent.\"\n redirect_to profile_home_path(@profile.url_name)\n end\n format.json { head :no_content }\n end\n end", "def join(user)\n @mysqlHelper.insertConUser(user.getI,@id)\n @userList.getcontents.each { |users| \n \n users.userChangeFromChannel(\"204\", @id, user.getId)\n }\n @userList.add(user)\n \n end", "def show\n\tuser_completed = @user.as_json(:only => [:id, :username, :login, :email, :guild_id, :otp_secret, :otp_required_for_login])\n\t\t\t\t\t\t.merge(guild: @user.guild, achievments: @user.achievments)\n\tif self.user_owner?\n \trender json: user_completed, status: :ok\n\telse\n \trender json: user_completed.except(:email, :otp_required_for_login), status: :ok\n\tend\n end", "def lookup\n respond_to do |format|\n format.json { render json: Core::UserLookup.new(view_context) }\n end\n end", "def index\n case params[:eligible_for]\n when 'collaboration'\n @collaborators = eligible_collaborators.limit(20)\n when 'ownership'\n @collaborators = eligible_owners.limit(20)\n else\n @collaborators = User.none\n end\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def join\n course = Course.where(join_token: params[:course][:join_token]).first\n\n if course and not current_user.courses.include? course\n current_user.courses << course\n current_user.add_role :student, course\n course.assignments.each { |assignment| assignment.create_submissions_for_students }\n\n flash[:notice] = \"Successfully joined class\"\n redirect_to course_path(course.id)\n else\n flash[:notice] = \"Failed to join class\"\n redirect_to :back\n end\n end", "def join\n redirect_to '/auth/linkedin'\n end", "def join_group\n @disc_group = DiscussionGroup.find(params[:id])\n @join = DiscussionGroupUser.new(:discussion_group_id => @disc_group.id, :user_id => @login_user.id, :is_member => 1)\n if @join.save\n respond_to do |format|\n format.js\n end\n else\n render :text=>\"Fail\"\n end\n end", "def join\n @event = Event.find(params[:event_id])\n if (params[:type] == \"invite\")\n @uids = params[:uids]\n @uid_array = []\n @uid_array = @uids.split(\",\")\n\n @motlee_users = []\n @non_motlee_users = []\n\n @uid_array.each do |uid|\n motlee_user = User.where(:uid => uid).first\n\n if motlee_user.nil?\n token = params[:access_token]\n event_id = params[:event_id]\n Resque.enqueue(ProcessNewUserInvite, token, event_id, uid) \n else\n # User is already a part of Motlee\n # Add user to array of Motlee users\n @motlee_users << uid\n \n # Now we check to see if the user has already been added to the event\n @attendee = Attendee.where(\"user_id = ? AND event_id = ?\", motlee_user.id, params[:event_id]).first\n if @attendee.nil?\n # If user has not been added, create new Attendee object\n @attendee = Attendee.create(:user_id => motlee_user.id, :event_id => params[:event_id], :rsvp_status => 1)\n if (motlee_user.id != current_user.id)\n Resque.enqueue(AddEventNotification, motlee_user.id, params[:event_id], current_user.id)\n end\n end\n end\n end \n else\n @attendee = Attendee.create(:user_id => current_user.id, :event_id => @event.id, :rsvp_status => 1)\n end\n # Render a response so the devices are happy\n @event.update_attributes(:updated_at => Time.now)\n render :json => @event.as_json({:methods => [:owner, :attendee_count], \n :include => {:photos => {:include => {:comments => {}, :likes => {}}}, \n :people_attending => {:only => [:id, :uid, :name, :sign_in_count]}}})\n end", "def show\n render json: UserService.get_user(params[:id]), includes: 'questions, answers'\n end", "def show\n user = User.find(params[:id])\n render json: user.to_json(\n :include => [:topics, {:meetups => {:include => :topic}}, :comments])\n end", "def user\n name = params[:name]\n number = params[:number]\n mail = params[:mail]\n id = params[:id]\n mail = \"#{mail}@gionee.com\" if mail.present? && mail.exclude?(\"@\")\n\n scope = User.all\n scope = scope.where(:id => id) if id.present?\n scope = scope.like(name) if name.present?\n scope = scope.where(:empId => number) if number.present?\n scope = scope.joins(:email_addresses).where(:email_addresses => {:address => mail}) if mail.present?\n\n users = scope.count == User.all.count ? [] : scope.limit(30)\n hash = users.map do |user|\n {\n :name => user.name,\n :id => user.id,\n :global_id => user.login,\n :number => user.empId,\n :mail => user.mail,\n :dept => user.dept_name,\n :dept_id => user.dept.try(:id)\n }\n end\n render :json => hash\n end", "def create\n UsersAgency.selection_from_ids(current_user, params[:agency_selection])\n head :created\n end", "def index\n @accounts = current_user.person.linked_in_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def index\n if asociative_user_signed_in?\n @milestones = Milestone.where(asociative_user_id: current_asociative_user.id)\n @benefit_requesteds= BenefitRequested.where(asociative_user_id: current_asociative_user.id)\n elsif user_signed_in?\n @milestones = Milestone.where(user_id: current_user.id)\n @benefit_requesteds = BenefitRequested.where(user_id: current_user.id)\n else\n #### aca tengo que hacer la querie que me mostrara las postulaciones hechas por los usuarios\n #####\n\n\n @milestones = Milestone.all\n @benefit_requesteds = BenefitRequested.all\n end\n\n end", "def index\n @collaborators = User.includes(:github_account).\n where.not(id: params[:ineligible_user_ids]).\n limit(20)\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def index\n @teaching_assistants = TeachingAssistant.all\n end", "def join\n @game = Game.find(params[:id])\n @game.assign_team(current_user)\n redirect_to \"/games/#{@game.id}\"\n end", "def join\n @user = current_user\n @mess = Mess.find(params[:id])\n @mess_id = @mess.id\n @user.update_attributes(:mess_id => @mess_id)\n redirect_to @mess\n end", "def create\n @joined_user = JoinedUser.new(joined_user_params)\n\n respond_to do |format|\n if @joined_user.save\n format.html { redirect_to @joined_user, notice: 'Joined user was successfully created.' }\n format.json { render :show, status: :created, location: @joined_user }\n else\n format.html { render :new }\n format.json { render json: @joined_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @provider_engaged_user = ProviderEngagedUser.new(provider_engaged_user_params)\n \n @provider_engaged_users = ProviderEngagedUser.joins(:provider_master).where(\"provider_masters.id = provider_engaged_users.provider_id and provider_engaged_users.provider_id = #{session.delete(:provider_id)} \")\n # @provider_engaged_users = ProviderEngagedUser.joins(:provider_master).where(\"provider_id = #{session.delete(:provider_id)}\")\n @provider_name = session.delete(:provider_name)\n @person_infos = PersonInfo.order(:surname).where(\"surname like ?\", \"%#{params[:person_id]}\")\n \n @the_list = @person_infos.map { |a|[a.surname+\" \"+a.other_names+\" \",a.id] } \n \n respond_to do |format|\n if @provider_engaged_user.save\n format.js { flash.now[:notice] = \"Staff was successfully added.\" }\n format.html { redirect_to @provider_engaged_user, notice: 'Provider engaged user was successfully created.' }\n format.json { render :show, status: :created, location: @provider_engaged_user }\n else\n format.js {render :new}\n format.html { render :new }\n format.json { render json: @provider_engaged_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @award_labels = @user.award_labels.includes(:registrant)\n @award_label = AwardLabel.new\n\n respond_with @award_labels\n end", "def show\n user = User.find(params[:id])\n # render json: {\n # # user.to_json(include: :stories, except: :password_digest)\n # user: user,\n # stories: user.stories,\n # success: true\n # }\n render json: user.to_json(include: :stories, except: :password_digest)\n end", "def show\n @userin = UserInvestor.find(params[:id])\n if @userin.present?\n data = @userin.as_json(include: %i[product_invest])\n render json: { status: 'OK', results: data, errors: nil }, status: :ok\n else\n render json: { status: 'FAIL', results: nil,\n errors: 'user does not exist' },\n status: :not_found\n end\n end", "def index\n @people = Person.all\n respond_to do |format|\n format.json { \n render json: @people, :include => [:roles => { include: [:privileges] } ]\n }\n end\n end", "def join\n @attendance = Attendance.new(attendance_params)\n\n begin\n\n raise ArgumentError if params[:attendance][:phone_number].empty? ||\n params[:attendance][:email].empty? ||\n params[:attendance][:username].empty?\n\n user = attendance_user\n event = attendance_event\n\n respond_to do |format|\n #require 'byebug';debugger\n @attendance.user = user\n @attendance.event = event\n if @attendance.save\n AttendanceMailer.delay_for(5.second).send_email_to_consumers(@attendance.id)\n AttendanceMailer.delay_for(5.second).send_email_to_agents(@attendance.id)\n format.html { redirect_to attendance_event, notice: '感谢您的关注,我们已收到您的报名信息,将尽快联系您!' }\n format.json { render :show, status: :created, location: attendance_event }\n else\n format.html { render :new }\n format.json { render json: @attendance.errors, status: :unprocessable_entity }\n end\n end\n rescue Exception => e\n #Log the error\n logger.fatal e\n respond_to do |format|\n format.html { redirect_to attendance_event }\n end\n return\n end\n end", "def join\n\t\t@classroom = Classroom.find(params[:id])\n\n\t\tparams[:user_id] = current_user.id unless admin? && params[:user_id]\n\n\t\t@membership = Membership.new\n\t\t@membership.classroom_id = @classroom.id\n\t\t@membership.user_id = params[:user_id]\n\t\tif @membership.save\n\t\t\tredirect_to params[:redirect_url] || @classroom, notice: \"Joined!\"\n\t\telse\n\t\t\tredirect_to @classroom, alert: \"You are already a member of this class!\"\n\t\tend\n\tend", "def get_user_campaign_leads username, password, campaign_id, options = {}\n do_request 'get_user_campaign_leads', options.merge(username: username, password: password,\n campaign_id: campaign_id)\n end", "def join_user user, as=:worker\n # Try to find previous role, who was deleted before\n if role = Role.unscoped.where(user_id: user.id, project_id: self.id).first\n role.update!({\n deleted: false,\n level: self.class.parse_role(as, true)\n })\n\n role\n else\n Role.create({\n level: self.class.parse_role(as, true),\n project_id: self.id,\n user_id: user.id\n })\n end\n end", "def index\n @collaborators = User\n .includes(:chef_account)\n .where.not(id: params[:ineligible_user_ids])\n .limit(20)\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def user_info\n user = User.find_by(id: params[:id])\n progresses = user.progresses.select {|p| p.habit.user.id == params[:id]} \n \n render json: progresses\n end", "def destroy\n @join_user_to_assistant.destroy\n respond_to do |format|\n format.html { redirect_to join_user_to_assistants_url, notice: 'Join user to assistant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def show\n @join=Usermeetup.where(\"user_id = ? AND meetup_id = ?\",session[:user_id],params[:id]).exists?\n \n render \"show\"\n end", "def invite\n @meal = Meal.find(params[:meal_id])\n authorize @meal, :update?\n @user = if params[:user_id]\n User.find(params[:user_id])\n else\n User.find_by(name: params[:user_name])\n end\n @meal.invite_user @user\n redirect_to @meal\n end", "def sendMeHomeAndCreateProfile user \n if user.type == \"Applicant\"\n Profile.create(applicant_id: user.id)\n redirect_to \"/applicant\"\n else\n redirect_to \"/recruiter\"\n end\n end", "def create_or_join\n res = Conversation.create_or_join(uuid: conversation_params[:uuid])\n serializer = ConversationSerializer.new(res[:conversation])\n render json: serializer.serializable_hash.merge(user_index: res[:user_index])\n end", "def user_doing_missions\n EntrMissionUser\n .includes(:user)\n .where(\"entr_mission_users.mission_id = ? AND entr_mission_users.state = ?\", self.id, EntrMissionUser::Status::CONFIRMED)\n .collect { |l| l.user }\n end", "def join\r\n if @trip.participants.include?(current_person)\r\n redirect_to(@trip, :notice => \"You are already a participant in the #{@trip.name}.\")\r\n return\r\n elsif @trip.organizers.include?(current_person) && request.post?\r\n @trip.participants << current_person\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n else\r\n @token = params[:token]\r\n invitation = Invitation.find_by_token(@token)\r\n if invitation.nil?\r\n redirect_to(person_root_url, :error => \"The invitation link you followed is invalid.\")\r\n return\r\n end\r\n \r\n if request.post?\r\n invitation.accept(current_person)\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n end\r\n end\r\n end", "def create\n @join = Join.find_by(user_id: current_user.id, hike_id: params[:id])\n if @join\n redirect_to :back\n else\n @join = Join.create(user_id:current_user.id, hike_id:params[:id])\n redirect_to :back\n end\n end", "def index\n @goal_rewards = user.goal_rewards\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goal_rewards }\n end\n end", "def identities\n render json: current_user.identities\n end", "def search_collaborator\n # Search for email or name of collaborator\n projects = current_user.projects\n @users = Array.new\n projects.each do |project|\n project.users.each do |user|\n unless @users.include? user\n @users.push user\n end\n end\n end\n\n # Get all users if current user is a manager or admin\n if manager? || admin?\n @users = current_user.university.users\n end\n\n # Return a JSON with \"label\" and \"value\" as key required by JQueryUI autocomplete\n result = Array.new\n @users.each do |user| \n label = user.first_name + \" \" + user.last_name + \" - \" + user.email\n item = Hash[ \"label\" => label, \"value\" => user.email ]\n result.push item\n end\n\n render :json => result\n end", "def join\n @club = Club.find(params[:id])\n authorize @club\n @club.club_memberships.create! user_id: current_user.id\n redirect_to action: :show\n end", "def show\n respond_to do |format|\n\n if current_user\n format.html \n format.js\n else\n format.html {render :layout => 'join'}\n format.js\n end\n end\n end", "def show\n @conversation = Conversation.find(params[:id])\n\n if @conversation.postedByUser.present?\n @user = User.find(@conversation.postedByUser)\n end\n\n @assign_to_users = User.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conversation }\n end\n end", "def fetch_judge_details\n fail NoJudgesProvided if @judges.keys.empty?\n\n VACOLS::Staff.load_users_by_css_ids(@judges.keys).map do |judge|\n @judges[judge.sdomainid][:staff_info] = judge\n end\n end", "def join_group\n @assignment = Assignment.find(params[:id])\n @grouping = Grouping.find(params[:grouping_id])\n @user = Student.find(session[:uid])\n @user.join(@grouping.id)\n m_logger = MarkusLogger.instance\n m_logger.log(\"Student '#{@user.user_name}' joined group '#{@grouping.group.group_name}'\" +\n '(accepted invitation).')\n redirect_to action: 'student_interface', id: params[:id]\n end", "def join\n payload = { \"id\" => id }.to_json\n data = client.post \"#{api_prefix}/user/#{client.user.id}/rooms\", payload\n\n self\n end", "def get_user\n if params[:email].nil?\n render json: current_user,\n except: [\n :created_at,\n :updated_at,\n :admin_permissions\n ],\n include: {\n case_cortege: {},\n cortege: {},\n orchestra: {},\n orchestra_signup: {\n include: [\n :orchestra\n ]\n },\n funkis_application: {\n include: [\n funkis_shift_applications: {\n include: [\n funkis_shift: {\n include: [\n :funkis_category\n ],\n except: [\n :maximum_workers\n ]\n }\n ]\n }\n ]\n }\n }\n else\n user = User.find_by email:(params[:email])\n unless user.nil?\n if current_user.has_admin_permission? AdminPermission::ALL\n render json: user,\n include: {\n case_cortege: {},\n cortege: {},\n orchestra: {},\n orchestra_signup: {\n include: [\n :orchestra\n ]\n },\n funkis_application: {\n include: [\n funkis_shift_applications: {\n include: [\n funkis_shift: {\n include: [\n :funkis_category\n ],\n except: [\n :maximum_workers\n ]\n }\n ]\n }\n ],\n }\n }\n elsif current_user.has_admin_permission? AdminPermission::ORCHESTRA_ADMIN\n render json: user, except: [\n :created_at,\n :updated_at,\n :admin_permissions\n ],\n include: {\n orchestra: {},\n orchestra_signup: {\n include: [\n :orchestra\n ]\n }\n }\n\n elsif current_user.has_admin_permission? \\\n AdminPermission::LIST_CORTEGE_APPLICATIONS || AdminPermission::APPROVE_CORTEGE_APPLICATIONS\n render json: user, except: [\n :created_at,\n :updated_at,\n :admin_permissions\n ],\n include: {\n case_cortege: {},\n cortege: {},\n }\n elsif current_user.has_admin_permission? AdminPermission::LIST_FUNKIS_APPLICATIONS\n render json: user, except: [\n :created_at,\n :updated_at,\n :admin_permissions\n ],\n include: {\n case_cortege: {},\n cortege: {},\n orchestra: {},\n orchestra_signup: {\n include: [\n :orchestra\n ]\n },\n funkis_application: {\n include: [\n funkis_shift_applications: {\n include: [\n funkis_shift: {\n include: [\n :funkis_category\n ],\n except: [\n :maximum_workers\n ]\n }\n ]\n }\n ],\n }\n }\n else\n render json: user, except: [\n :created_at,\n :updated_at,\n :permissions\n ]\n end\n else\n render :status => '404', :json => {:message => 'Användare kunde inte hittas'}\n end\n end\n end", "def user_details\n @user = current_user\n invitation = @user.invitation\n if invitation.present?\n solo_restaurant_name = invitation.restaurant_id ? \n Restaurant.find(invitation.restaurant_id).name :\n invitation.restaurant_name\n @user.build_default_employment(:solo_restaurant_name => solo_restaurant_name, \n :restaurant_role => invitation.restaurant_role, :subject_matters => invitation.subject_matters)\n else\n @user.build_default_employment\n end\n @user.build_profile\n end", "def index\n user = User.find_by(id: params[:user_id])\n return respond_with contributions: [], status: :not_found if user.nil?\n contributions = user.contributions\n respond_with contributions: contributions, status: :ok\n end", "def me\n render status: 200, json: current_user.db_user.as_json(only: [:id, :email], include: { discord_identity: { }, roles: { include: { nested_roles: { include: { role_nested: { } } } } } }, methods: [:main_character])\n end", "def findFollowees\n @user = User.find(params[:id])\n @followees = @user.followees.all\n render json: @followees, status: :ok\n end", "def index\n render json: current_org.users\n end", "def show\n @organisme_employe = Organisme.where(:api_id => @employe.organisme_id)\n @role_employe = Role.where(:id => @employe.role_id)\n end", "def index\n @user = User.find(params[:user_id])\n @user_contract_ideas = @user.user_contract_ideas\n end", "def show\n @ta_as_user = User.find_by(google_email: @teaching_assistant.email)\n end", "def index\n @personnels = User.all\n end", "def request_deal\n @user = params[:user] # Instance variable => available in view\n @deal = params[:deal]\n\n sql_query = \" \\\n SELECT tasks.name, tasks.description\n FROM deals\n JOIN assignments\n ON deals.assignment_id = assignments.id\n JOIN tasks\n ON assignments.task_id = tasks.id\n WHERE deals.id = #{@deal.id};\"\n\n @initial_task = Deal.connection.execute(sql_query)[0]\n\n sql_query = \" \\\n SELECT tasks.name, tasks.description\n FROM deals\n JOIN assignments\n ON deals.assignment_proposal_id = assignments.id\n JOIN tasks\n ON assignments.task_id = tasks.id\n WHERE deals.id = #{@deal.id};\"\n\n @proposal_task = Deal.connection.execute(sql_query)[0]\n\n sql_query = \" \\\n SELECT users.first_name, users.last_name, users.email\n FROM deals\n JOIN assignments\n ON deals.assignment_proposal_id = assignments.id\n JOIN tasks\n ON assignments.task_id = tasks.id\n JOIN users\n ON assignments.user_id = users.id\n WHERE deals.id = #{@deal.id};\"\n\n @target_user = Deal.connection.execute(sql_query)[0]\n\n mail(to: @target_user[\"email\"], subject: \"#{@user.first_name} proposed you a deal for your task #{@proposal_task[\"name\"]}\")\n # This will render a view in `app/views/user_mailer`!\n end", "def new\n @interested_user = InterestedUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @interested_user }\n end\n end", "def user\n \t@user = User.find(params[:id])\n @listings = User.find(params[:id]).listings\n end", "def index\n @areas = Area.all\n @target_users = User.where(User.arel_table[:location].not_eq nil)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @areas }\n end\n end" ]
[ "0.6488062", "0.61186546", "0.59869283", "0.59228635", "0.5900942", "0.56274027", "0.5619459", "0.55861795", "0.5528946", "0.5519544", "0.54990375", "0.5449441", "0.54196227", "0.5401511", "0.53953344", "0.5351622", "0.5315177", "0.5307044", "0.5305458", "0.5287998", "0.5272919", "0.52551067", "0.5251238", "0.5251238", "0.521773", "0.521178", "0.5198803", "0.51987284", "0.51984394", "0.51921105", "0.5181616", "0.51804644", "0.51778454", "0.51730734", "0.51622486", "0.51590455", "0.5156538", "0.51476616", "0.5143035", "0.51361984", "0.51329964", "0.5131912", "0.5127998", "0.5119733", "0.50976396", "0.5083367", "0.50810796", "0.50807315", "0.5069197", "0.5050085", "0.504086", "0.5040563", "0.50315434", "0.5031127", "0.5030233", "0.5023357", "0.5015849", "0.5012621", "0.5009577", "0.50088716", "0.4997913", "0.49884006", "0.49873582", "0.4986341", "0.4980814", "0.4976718", "0.49765086", "0.49763012", "0.4970953", "0.49651667", "0.49635527", "0.49635017", "0.49627632", "0.49611676", "0.4958837", "0.4954236", "0.49538338", "0.49518934", "0.49457717", "0.49456075", "0.49448404", "0.493338", "0.49283597", "0.4928276", "0.49149302", "0.4913238", "0.49049172", "0.48980135", "0.48979944", "0.48960936", "0.48869935", "0.48859996", "0.48845884", "0.4883999", "0.48827776", "0.4879344", "0.48761368", "0.4871992", "0.48683426", "0.48675686" ]
0.7344257
0
GET /join_user_to_assistants/1 GET /join_user_to_assistants/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @join_user_to_assistants = JoinUserToAssistant.all\n end", "def set_join_user_to_assistant\n @join_user_to_assistant = JoinUserToAssistant.find(params[:id])\n end", "def create\n @join_user_to_assistant = JoinUserToAssistant.new(join_user_to_assistant_params)\n\n respond_to do |format|\n if @join_user_to_assistant.save\n format.html { redirect_to @join_user_to_assistant, notice: 'Join user to assistant was successfully created.' }\n format.json { render :show, status: :created, location: @join_user_to_assistant }\n else\n format.html { render :new }\n format.json { render json: @join_user_to_assistant.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_invite\n if idea_posting.users.exists?(current_user.id)\n @joinrequest = Joinrequest.new\n respond_to do |format|\n format.html \n format.json {redirect_to @joinrequest}\n end\n end\n end", "def join_for(user)\n joins.find_by_user_id(user)\n end", "def join_user_to_assistant_params\n params.require(:join_user_to_assistant).permit(:cpfk_user_id, :cpfk_assistant_id)\n end", "def getUserInfo\n login_user_id = params[:my_id].to_i\n login_user = User.find(login_user_id)\n\n target_user_id = params[:target_id].to_i\n target_user = User.find(target_user_id)\n\n # target_userをフォローしているか\n login_user_follow = login_user.follows_of_from_user.pluck(:id).include?(target_user_id)\n\n # target_userの記事一覧を取得\n articles_hash = make_articles_hash(target_user.articles, target_user)\n\n if articles_hash.blank?\n res = {\n result: false,\n data: nil\n }\n else\n res = {\n result: true,\n data: {\n user_id: target_user_id,\n name: target_user.name,\n follow: login_user_follow,\n profile_image: target_user.profile_image_path,\n articles: articles_hash\n }\n }\n end\n\n render json: res\n end", "def show\n if user_signed_in?\n @join = Join.where(user_id: current_user.id, escape_id: params[:id])\n else\n @join = []\n end\n end", "def join\n circle_id = params[:circle][:circle_id]\n circle_url = File.join(SITE_URL, \"circles/#{circle_id}\")\n\n joined = CircleUser.where(circle_id: circle_id, user_id: current_user.id).first_or_initialize\n\n respond_to do |format|\n if not joined.persisted?\n joined.save\n Circle.update_counters(params[:circle][:circle_id], people_count: 1)\n User.update_counters(current_user.id, circle_count: 1)\n mod = 1\n else\n joined.delete\n Circle.update_counters(params[:circle][:circle_id], people_count: -1)\n User.update_counters(current_user.id, circle_count: -1)\n mod = -1\n end\n format.json { render json: {'status' => mod, 'circle_url' => circle_url}, status: :created }\n end\n end", "def update\n respond_to do |format|\n if @join_user_to_assistant.update(join_user_to_assistant_params)\n format.html { redirect_to @join_user_to_assistant, notice: 'Join user to assistant was successfully updated.' }\n format.json { render :show, status: :ok, location: @join_user_to_assistant }\n else\n format.html { render :edit }\n format.json { render json: @join_user_to_assistant.errors, status: :unprocessable_entity }\n end\n end\n end", "def index_attending\n puts \"user: #{@current_user.json_hash[:id]}\"\n dinners = []\n @dinners = @current_user.attended_dinners\n @dinners.each do |dinner|\n dinners << dinner.all_info\n end\n render json: dinners\n end", "def joinGroup\n \tquery = \"SELECT user_id FROM group_meals_participants where group_meal_id = \" + GroupMeal.find_by_meal(params[:meal]).id.to_s\n \n GroupMealsParticipant.connection.select_values(query).each do |u|\n \tif(u!=current_user.id)\n \t\tu=User.find(u)\n \t\tu.alert=true\n \t\tu.alert_location=GroupMeal.find_by_meal(params[:meal]).id.to_s\n \t\tu.save\n \tend\n \tend\n @groupMealParticipant= GroupMealsParticipant.new\n @groupMealParticipant.user_id=current_user.id\n @groupMealParticipant.group_meal_id= GroupMeal.find_by_meal(params[:meal]).id\n @groupMealParticipant.save \n redirect_to(GroupMeal.find_by_meal(params[:meal]))\n end", "def join\n if request.post?\n if !@group.users.include?(current_user)\n @group.users << current_user\n flash[:success] = \"Thanks! Your membership must now be approved by an admin of #{@group.name}.\"\n\n #SEND OUT NOTIFICATION EMAILS\n @group.admins.each do |admin|\n Notifier.pending_user(admin, @group, current_user).deliver\n end\n\n redirect_to @group\n else\n flash[:error] = \"Error requesting to join #{@group.name}. Please try again.\"\n redirect_to @group\n end\n else #it fell back to GET (no js)\n flash[:error] = \"Please enable javascript to join.\"\n redirect_to @group\n end\n end", "def user_relationship\n if request.xhr?\n organization_id = params[\"organization_id\"]\n per_page = params[:iDisplayLength] || Settings.per_page\n page = params[:iDisplayStart] ? ((params[:iDisplayStart].to_i/per_page.to_i) + 1) : 1\n params[:iSortCol_0] = 1 if params[:iSortCol_0].blank?\n sort_field = SORT_MAP_RELATIONSHIP[params[:iSortCol_0].to_i]\n # @users = User.get_all_users_except_id(current_user.id, page, per_page, params[:sSearch], sort_field + \" \" + params[:sSortDir_0],organization_id)\n @users = User.get_user_to_relationship(page, per_page, params[:sSearch], sort_field + \" \" + params[:sSortDir_0])\n render :json => @users\n return\n end\n end", "def show\n @requests = Request.where(pet_id: params[:id]).all\n users_id = Array.new(@requests.size) \n @requests.each do |req|\n users_id.push([req.interented_id])\n end\n @interested = User.find(users_id)\n end", "def create\n\t\tact_type = params[:offering_type]\n\t\tuser = User.find_by_id(params[:joining_user])\n\t\tact_id = params[:offering_id]\n\n\t\tif !name_is_valid?(user, act_type); raise Errors::FlowError.new(send(\"#{act_type}_path\", offering_id), \"Permission denied.\"); end\n\n\t\tacts_membership = user.send(\"#{act_type}s_membership\")\n\t\tjoining_act = act_type.camelize.constantize.find_by_id(act_id)\n\n\t\tunless joining_act; raise Errors::FlowError.new; end\n\n\t\t# gender\n\t\tif [\"male\", \"female\"].include? joining_act.gender\n\t\t\tunless user.gender == joining_act.gender; raise Errors::FlowError.new(root_path, \"This #{act_type} is #{joining_act.gender} only.\"); end\n\t\tend\n\n\t\tnumber_of_attendings = joining_act.number_of_attendings\n\t\tif acts_membership.count < number_of_attendings or number_of_attendings == 0\n\t\t\tacts_membership << joining_act\n\t\telse\n\t\t\traise Errors::FlowError.new(send(\"#{act_type}_path\", offering_id), \"Permission denied.\")\n\t\tend\n\t\t@offering = joining_act\n\t\t@members = joining_act.members\n\t\tjoining_act.create_activity :create, owner: user\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to joining_act }\n\t\t\tformat.js\n\t\tend\n\tend", "def show\n @assist = Assist.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assist }\n end\n end", "def show\n @interested_user = InterestedUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @interested_user }\n end\n end", "def join\n @room = OnlineMeetingRoom.find_by_id(params[:id])\n role = @room.user_role(current_user)\n unless role == :denied\n join_internal(current_user.full_name, role, :join)\n else\n flash[:notice] = \"#{t('access_denied')}\"\n redirect_to :index and return\n end\n end", "def join\n @room = Room.find(params.require(:room_id))\n if @room&.add_user(current_user)\n success\n else\n not_found\n end\n end", "def search\n @lawyer = User.first\n expertise = Expertise.find_by_id(params[:id])\n @users = UserExpertise.where(expertise_id: expertise)\n end", "def index\n rol = Role.where(:id=>current_user.role).first\n if rol.nombre == \"DN\" or rol.nombre == \"ACRM\"\n @achievments = Achievment.all\n else\n @achievments = Achievment.where(:sede_id=>current_user.sede)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @achievments }\n end\n end", "def join\n unless @user && @kroog && @kroog.open? && current_actor.can_follow?\n flash[:warning] = \"Error: The specified circle does not exist or cannot be joined\".t\n respond_to do |format|\n format.html do\n redirect_to(:controller => 'kroogi', :action => 'join_circles', :id => params[:id])\n end\n format.js {render :update do |page|; page << 'document.location.reload(false);'; end}\n end\n return\n end\n\n # Add the relationship directly -- no invite intermediary\n Relationship.create_kroogi_relationship(:followed => @user.id, :follower => current_actor.id, :relationshiptype_id => @kroog.relationshiptype_id, :expires_at => Time.end, :skip_activity_message => true)\n\n flash[:success] = \"You have joined the %s circle of %s\" / [@user.circle_name(params[:circle].to_i), @user.login]\n PublicQuestionHelper::set_question_artist_id(@user, self, :force_show => true)\n respond_to do |wants|\n wants.html do\n redirect_to user_url_for(@user)\n end\n wants.js {}\n end\n end", "def user_joined\n user = User.find_by!(id: params[:user_id])\n return json_response({\n \"joined\": ChannelJoined.exists?({\n channel_id: params[:id],\n user_id: params[:user_id]\n })\n })\n end", "def lookup\n respond_to do |format|\n format.json { render json: Core::UserLookup.new(view_context) }\n end\n end", "def create\n UsersAgency.selection_from_ids(current_user, params[:agency_selection])\n head :created\n end", "def join\n \n #TODO add player to hunt\n #player = User.find(params[:id])\n redirect_to hunt_player_path()\n end", "def join!(user)\n # It loads up all the user because in the case where the chat is saved but the chat_participations have not been saved,\n # this is the only way to ensure we don't have duplicates.\n return if self.chat_participations.map(&:user_id).include?(user.id)\n self.chat_participations.create!(:user => user)\n end", "def index\n case params[:eligible_for]\n when 'collaboration'\n @collaborators = eligible_collaborators.limit(20)\n when 'ownership'\n @collaborators = eligible_owners.limit(20)\n else\n @collaborators = User.none\n end\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def approve_join_request\n join_request = JoinRequest.find(params[:id])\n team = join_request.team\n # Only authorize the captain to do this\n if current_user.id == team.captain_id\n membership = Membership.create(\n team_id: join_request.team_id,\n user_id: join_request.user_id,\n admin: false\n )\n if membership.valid?\n join_request.destroy\n render json: {\n team: TeamSerializer.new(team),\n user: UserSerializer.new(current_user)\n }, status: :accepted\n else\n # invalid request\n render json: {\n message: \"Invalid request\",\n errors: membership.errors.full_messages\n }, status: :not_acceptable\n end\n else\n render json: { message: \"Only the captain is allowed to accept join requests\"}, status: :not_acceptable\n end\n end", "def join\n @group = Group.find(params[:id])\n \n if group_user = GroupUser.first(:conditions => ['group_id = ? AND user_id = ?', @group.id, current_user.id])\n if ['cancelled', 'invite_declined'].include?(group_user.status)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n elsif group_user.status == 'approved'\n flash[:error] = 'You are already member of this group.'\n else\n flash[:error] = 'You cannot join this group.'\n end\n else\n group_user = GroupUser.create(:group_id => @group.id, :user_id => current_user.id, :role_id => Role.find_by_name('User').id)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n end\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end", "def join\n @group = Group.find(params[:id])\n \n if group_user = GroupUser.first(:conditions => ['group_id = ? AND user_id = ?', @group.id, current_user.id])\n if ['cancelled', 'invite_declined'].include?(group_user.status)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n elsif group_user.status == 'approved'\n flash[:error] = 'You are already member of this group.'\n else\n flash[:error] = 'You cannot join this group.'\n end\n else\n group_user = GroupUser.create(:group_id => @group.id, :user_id => current_user.id, :role_id => Role.find_by_name('User').id)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n end\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end", "def create_or_join\n res = Conversation.create_or_join(uuid: conversation_params[:uuid])\n serializer = ConversationSerializer.new(res[:conversation])\n render json: serializer.serializable_hash.merge(user_index: res[:user_index])\n end", "def landing\n \t@user = User.find(params[:id])\n @course = User.joins(:course).select(\"users.*,courses.*\").find(params[:id])\n end", "def invite_via_suggestion\n @user = User.create_with_organisation_membership_from_project_invite @invite\n\n if @user.valid?\n RequestMailer.invite_via_suggestion @user, @invite, current_user\n\n @invite.set_handled_suggested_user!\n redirect_to :dashboard, notice: \"#{@user.email} has been sent an invite\"\n elsif account_has_been_claimed? @user\n @invite.set_handled_suggested_user!\n redirect_to :dashboard, notice: \"This user has already been invited to Digital Social\" \n else\n redirect_to :dashboard, alert: \"There was an error inviting #{@user.email}, please try again later.\" \n end\n end", "def join\n\t @household = Household.find params[:id]\n\t current_user.update_attribute(:household_id, @household.id)\n\t redirect_to @household\n\tend", "def show\n user = User.find(params[:id])\n render json: user.to_json(\n :include => [:topics, {:meetups => {:include => :topic}}, :comments])\n end", "def join\n @person = Person.find(params[:person_id])\n @group = Group.find(params[:id])\n begin\n @person.join_group(@group.id, session[:cookie])\n flash[:notice] = [ :you_have_joined_to_group, @group.title(session[:cookie]) ]\n rescue RestClient::RequestFailed => e\n flash[:error] = message_from_error(e)\n end\n redirect_to group_path(params[:id])\n end", "def join_group\n @disc_group = DiscussionGroup.find(params[:id])\n @join = DiscussionGroupUser.new(:discussion_group_id => @disc_group.id, :user_id => @login_user.id, :is_member => 1)\n if @join.save\n respond_to do |format|\n format.js\n end\n else\n render :text=>\"Fail\"\n end\n end", "def join \n\n #Check if user exists\n user = User.find_by!(id: params[:user_id])\n\n if (ChannelJoined.exists?({ channel_id: params[:id], user_id: params[:user_id]}))\n json_response({\n \"joined\": true\n })\n else\n joined = ChannelJoined.create!(user_id: params[:user_id], channel_id: params[:id])\n json_response(joined.channel)\n end\n \n \n end", "def resumes_joining\n\t @resumes = ReqMatch.where(:status => \"JOINING\")\n\t\trender \"resumes/joining\"\n\tend", "def user_info\n user = User.find_by(id: params[:id])\n progresses = user.progresses.select {|p| p.habit.user.id == params[:id]} \n \n render json: progresses\n end", "def join(user)\n @mysqlHelper.insertConUser(user.getI,@id)\n @userList.getcontents.each { |users| \n \n users.userChangeFromChannel(\"204\", @id, user.getId)\n }\n @userList.add(user)\n \n end", "def show\n user = User.find(params[:id])\n # render json: {\n # # user.to_json(include: :stories, except: :password_digest)\n # user: user,\n # stories: user.stories,\n # success: true\n # }\n render json: user.to_json(include: :stories, except: :password_digest)\n end", "def join\n @filter.profile_request(current_profile)\n respond_to do |format|\n format.html do\n# flash[:notice] = \"Your request to join #{@profile.name}'s #{@filter.name} filter has been sent.\"\n redirect_to profile_home_path(@profile.url_name)\n end\n format.json { head :no_content }\n end\n end", "def join\n if !current_user\n flash[:notice] = t(:join_dream)\n elsif @camp.users.include?(current_user)\n flash[:notice] = t(:join_already_sent)\n else\n flash[:notice] = t(:join_dream)\n @camp.users << @user\n end\n redirect_to @camp\n end", "def show\n\tuser_completed = @user.as_json(:only => [:id, :username, :login, :email, :guild_id, :otp_secret, :otp_required_for_login])\n\t\t\t\t\t\t.merge(guild: @user.guild, achievments: @user.achievments)\n\tif self.user_owner?\n \trender json: user_completed, status: :ok\n\telse\n \trender json: user_completed.except(:email, :otp_required_for_login), status: :ok\n\tend\n end", "def index\n @award_labels = @user.award_labels.includes(:registrant)\n @award_label = AwardLabel.new\n\n respond_with @award_labels\n end", "def join\n\t\t@event = Event.find(params[:id])\n\n\t\tparams[:user_id] = current_user.id unless admin? && params[:user_id]\n\n\t\t@attendance = Attendance.new\n\t\t@attendance.event_id = @event.id\n\t\t@attendance.user_id = params[:user_id]\n\t\tif @attendance.save\n\t\t\tredirect_to @event, notice: \"Joined!\"\n\t\telse\n\t\t\tredirect_to root_path, alert: \"WTF did you just try to do.\"\n\t\tend\n\tend", "def create\n @provider_engaged_user = ProviderEngagedUser.new(provider_engaged_user_params)\n \n @provider_engaged_users = ProviderEngagedUser.joins(:provider_master).where(\"provider_masters.id = provider_engaged_users.provider_id and provider_engaged_users.provider_id = #{session.delete(:provider_id)} \")\n # @provider_engaged_users = ProviderEngagedUser.joins(:provider_master).where(\"provider_id = #{session.delete(:provider_id)}\")\n @provider_name = session.delete(:provider_name)\n @person_infos = PersonInfo.order(:surname).where(\"surname like ?\", \"%#{params[:person_id]}\")\n \n @the_list = @person_infos.map { |a|[a.surname+\" \"+a.other_names+\" \",a.id] } \n \n respond_to do |format|\n if @provider_engaged_user.save\n format.js { flash.now[:notice] = \"Staff was successfully added.\" }\n format.html { redirect_to @provider_engaged_user, notice: 'Provider engaged user was successfully created.' }\n format.json { render :show, status: :created, location: @provider_engaged_user }\n else\n format.js {render :new}\n format.html { render :new }\n format.json { render json: @provider_engaged_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @teaching_assistants = TeachingAssistant.all\n end", "def index\n @goal_rewards = user.goal_rewards\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @goal_rewards }\n end\n end", "def index\n @collaborators = User.includes(:github_account).\n where.not(id: params[:ineligible_user_ids]).\n limit(20)\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def index\n @accounts = current_user.person.linked_in_accounts\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @accounts }\n end\n end", "def new\n @interested_user = InterestedUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @interested_user }\n end\n end", "def user_details\n @user = current_user\n invitation = @user.invitation\n if invitation.present?\n solo_restaurant_name = invitation.restaurant_id ? \n Restaurant.find(invitation.restaurant_id).name :\n invitation.restaurant_name\n @user.build_default_employment(:solo_restaurant_name => solo_restaurant_name, \n :restaurant_role => invitation.restaurant_role, :subject_matters => invitation.subject_matters)\n else\n @user.build_default_employment\n end\n @user.build_profile\n end", "def join\n @user = current_user\n @mess = Mess.find(params[:id])\n @mess_id = @mess.id\n @user.update_attributes(:mess_id => @mess_id)\n redirect_to @mess\n end", "def show\n render json: UserService.get_user(params[:id]), includes: 'questions, answers'\n end", "def show\n @userin = UserInvestor.find(params[:id])\n if @userin.present?\n data = @userin.as_json(include: %i[product_invest])\n render json: { status: 'OK', results: data, errors: nil }, status: :ok\n else\n render json: { status: 'FAIL', results: nil,\n errors: 'user does not exist' },\n status: :not_found\n end\n end", "def create\n @join = Join.find_by(user_id: current_user.id, hike_id: params[:id])\n if @join\n redirect_to :back\n else\n @join = Join.create(user_id:current_user.id, hike_id:params[:id])\n redirect_to :back\n end\n end", "def index\n @collaborators = User\n .includes(:chef_account)\n .where.not(id: params[:ineligible_user_ids])\n .limit(20)\n\n if params[:q]\n @collaborators = @collaborators.search(params[:q])\n end\n\n respond_to do |format|\n format.json\n end\n end", "def user_repo1\n addon = Addon.joins(:user)\n .where(\"lower(users.login) = ?\", params[:login].downcase)\n .where(\"lower(repos.name) = ?\", params[:repo_name].downcase)\n .first\n render json: to_v1_repo_hash(addon)\n end", "def index\n if asociative_user_signed_in?\n @milestones = Milestone.where(asociative_user_id: current_asociative_user.id)\n @benefit_requesteds= BenefitRequested.where(asociative_user_id: current_asociative_user.id)\n elsif user_signed_in?\n @milestones = Milestone.where(user_id: current_user.id)\n @benefit_requesteds = BenefitRequested.where(user_id: current_user.id)\n else\n #### aca tengo que hacer la querie que me mostrara las postulaciones hechas por los usuarios\n #####\n\n\n @milestones = Milestone.all\n @benefit_requesteds = BenefitRequested.all\n end\n\n end", "def fetch_judge_details\n fail NoJudgesProvided if @judges.keys.empty?\n\n VACOLS::Staff.load_users_by_css_ids(@judges.keys).map do |judge|\n @judges[judge.sdomainid][:staff_info] = judge\n end\n end", "def identities\n render json: current_user.identities\n end", "def show\n @conversation = Conversation.find(params[:id])\n\n if @conversation.postedByUser.present?\n @user = User.find(@conversation.postedByUser)\n end\n\n @assign_to_users = User.all\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conversation }\n end\n end", "def join_url(username, role, key=nil, options={})\n server = BigbluebuttonRails.configuration.select_server.call(self, :join_meeting_url)\n\n pass = case role\n when :moderator\n self.moderator_api_password\n when :attendee\n self.attendee_api_password\n when :guest\n if BigbluebuttonRails.configuration.guest_support\n options = { guest: true }.merge(options)\n end\n self.attendee_api_password\n else\n map_key_to_internal_password(key)\n end\n\n r = server.api.join_meeting_url(self.meetingid, username, pass, options)\n r.strip! unless r.nil?\n r\n end", "def index\n user = User.find_by(id: params[:user_id])\n return respond_with contributions: [], status: :not_found if user.nil?\n contributions = user.contributions\n respond_with contributions: contributions, status: :ok\n end", "def show\n @join=Usermeetup.where(\"user_id = ? AND meetup_id = ?\",session[:user_id],params[:id]).exists?\n \n render \"show\"\n end", "def index\n @people = Person.all\n respond_to do |format|\n format.json { \n render json: @people, :include => [:roles => { include: [:privileges] } ]\n }\n end\n end", "def user\n name = params[:name]\n number = params[:number]\n mail = params[:mail]\n id = params[:id]\n mail = \"#{mail}@gionee.com\" if mail.present? && mail.exclude?(\"@\")\n\n scope = User.all\n scope = scope.where(:id => id) if id.present?\n scope = scope.like(name) if name.present?\n scope = scope.where(:empId => number) if number.present?\n scope = scope.joins(:email_addresses).where(:email_addresses => {:address => mail}) if mail.present?\n\n users = scope.count == User.all.count ? [] : scope.limit(30)\n hash = users.map do |user|\n {\n :name => user.name,\n :id => user.id,\n :global_id => user.login,\n :number => user.empId,\n :mail => user.mail,\n :dept => user.dept_name,\n :dept_id => user.dept.try(:id)\n }\n end\n render :json => hash\n end", "def join\n @event = Event.find(params[:event_id])\n if (params[:type] == \"invite\")\n @uids = params[:uids]\n @uid_array = []\n @uid_array = @uids.split(\",\")\n\n @motlee_users = []\n @non_motlee_users = []\n\n @uid_array.each do |uid|\n motlee_user = User.where(:uid => uid).first\n\n if motlee_user.nil?\n token = params[:access_token]\n event_id = params[:event_id]\n Resque.enqueue(ProcessNewUserInvite, token, event_id, uid) \n else\n # User is already a part of Motlee\n # Add user to array of Motlee users\n @motlee_users << uid\n \n # Now we check to see if the user has already been added to the event\n @attendee = Attendee.where(\"user_id = ? AND event_id = ?\", motlee_user.id, params[:event_id]).first\n if @attendee.nil?\n # If user has not been added, create new Attendee object\n @attendee = Attendee.create(:user_id => motlee_user.id, :event_id => params[:event_id], :rsvp_status => 1)\n if (motlee_user.id != current_user.id)\n Resque.enqueue(AddEventNotification, motlee_user.id, params[:event_id], current_user.id)\n end\n end\n end\n end \n else\n @attendee = Attendee.create(:user_id => current_user.id, :event_id => @event.id, :rsvp_status => 1)\n end\n # Render a response so the devices are happy\n @event.update_attributes(:updated_at => Time.now)\n render :json => @event.as_json({:methods => [:owner, :attendee_count], \n :include => {:photos => {:include => {:comments => {}, :likes => {}}}, \n :people_attending => {:only => [:id, :uid, :name, :sign_in_count]}}})\n end", "def join\n course = Course.where(join_token: params[:course][:join_token]).first\n\n if course and not current_user.courses.include? course\n current_user.courses << course\n current_user.add_role :student, course\n course.assignments.each { |assignment| assignment.create_submissions_for_students }\n\n flash[:notice] = \"Successfully joined class\"\n redirect_to course_path(course.id)\n else\n flash[:notice] = \"Failed to join class\"\n redirect_to :back\n end\n end", "def findFollowees\n @user = User.find(params[:id])\n @followees = @user.followees.all\n render json: @followees, status: :ok\n end", "def index\n @user = User.find(params[:user_id])\n unless can? :index, @user\n authorize! :index, WorkingExperience, :message => 'Not authorized as an administrator.'\n end\n @working_experiences = @user.working_experiences\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @working_experiences }\n end\n end", "def index\n @rol_id = Role.find_by(:name => params[:param]).id\n\n @investigations = Investigation.find_by_sql(\"select * from investigations i\n inner join (select * from users_roles ur where ur.role_id = #{@rol_id}) as ur on i.user_id = ur.user_id\")\n end", "def create\n @joined_user = JoinedUser.new(joined_user_params)\n\n respond_to do |format|\n if @joined_user.save\n format.html { redirect_to @joined_user, notice: 'Joined user was successfully created.' }\n format.json { render :show, status: :created, location: @joined_user }\n else\n format.html { render :new }\n format.json { render json: @joined_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_relationship user_id\n url = API + \"users/#{user_id}/relationship?access_token=\" + @access_token\n get(url)\n end", "def sendMeHomeAndCreateProfile user \n if user.type == \"Applicant\"\n Profile.create(applicant_id: user.id)\n redirect_to \"/applicant\"\n else\n redirect_to \"/recruiter\"\n end\n end", "def index\n\n #@user_role = params[:user_role]\n #@user_id = params[:user_id]\n\n if params[:api_id]\n @api_id = params[:api_id]\n @employes = Employe.where(:organisme_id => @api_id).all\n else\n @employes = Employe.all\n end\n\n end", "def new\n @assist = Assist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @assist }\n end\n end", "def get_user_leads username, password, options = {}\n do_request 'get_user_leads', options.merge(username: username, password: password)\n end", "def index\n @user = User.find(params[:user_id])\n @user_contract_ideas = @user.user_contract_ideas\n end", "def index\n render json: current_org.users\n end", "def show\n @organisme_employe = Organisme.where(:api_id => @employe.organisme_id)\n @role_employe = Role.where(:id => @employe.role_id)\n end", "def user_with_proficiency(skill_level)\n skill = SkillsUser.where(skill_level: skill_level, skill_id: self.id).first\n user_id = skill.user_id\n User.find_by_id(user_id)\n end", "def index\n @personnels = User.all\n end", "def join\n redirect_to '/auth/linkedin'\n end", "def fetch_user_and_followings\n @user = User.find(params[:followee_id])\n @follow = Follow.find_by(follower_id: current_user.id, followee_id: params[:followee_id])\n end", "def destroy\n @join_user_to_assistant.destroy\n respond_to do |format|\n format.html { redirect_to join_user_to_assistants_url, notice: 'Join user to assistant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def join\n @game = Game.find(params[:id])\n @game.assign_team(current_user)\n redirect_to \"/games/#{@game.id}\"\n end", "def show\n @toon_skill_level = ToonSkillLevel.find(:first, :conditions => [\"id = ?\", params[:id]], :select => \"id, toon_id, source_id, skill_level\")\n users_toon = Toon.find(:first, :conditions => [\"id = ?\", @toon_skill_level.toon_id], :select => \"id, user_id\").user_id == current_user[:id]\n respond_to do |format|\n if users_toon then\n format.html # show.html.erb\n format.xml { render :xml => @toon_skill_level }\n else\n format.html {redirect_to(signin_path, :notice => \"You can only see your own toon's professions\")}\n end\n end\n end", "def user_doing_missions\n EntrMissionUser\n .includes(:user)\n .where(\"entr_mission_users.mission_id = ? AND entr_mission_users.state = ?\", self.id, EntrMissionUser::Status::CONFIRMED)\n .collect { |l| l.user }\n end", "def index\n @appoint_responsibles = AppointResponsible.all\n # @transfered_responsibilitys = current_user.transfered_responsibilitys\n end", "def user\n \t@user = User.find(params[:id])\n @listings = User.find(params[:id]).listings\n end", "def sendreq\n newReq = Joinrequest.new(:resolved => false, :manager_id => params[:id], :property_id => params[:pid], :tenant_id => session[:user_id])\n newReq.save\n redirect_to \"/tenants/show\"\n end", "def show\n @maintain_invite_user = Maintain::InviteUser.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @maintain_invite_user }\n end\n end", "def new\n @actions = [{\"YGO战网\" => users_path}, \"参加比赛\"]\n @enroll = Enroll.new\n @enroll.name = @current_user.name if @current_user.id != 0\n @enroll.tournament = Tournament.find params[:tournament_id] if params[:tournament_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @enroll }\n end\n end", "def index\n @organization_memberships = OrganizationMembership.where(user_id: params['user_id'])\n authorize @organization_memberships\n\n render json: @organization_memberships\n end", "def index\n puts \"the current user is#{restrict_access.id}\"\n @users = User.all\n respond_with @users\n end", "def new\n # Adding user id to saved occupations, see omrails, Add Associations . . ., 26:00\n @occupation = current_user.occupations.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @occupation }\n end\n end" ]
[ "0.72808343", "0.65550655", "0.6102001", "0.59393704", "0.5917495", "0.58264613", "0.56129616", "0.55842435", "0.5569549", "0.55627906", "0.5508365", "0.53591853", "0.5349518", "0.5330689", "0.5327412", "0.53187305", "0.5304142", "0.5303415", "0.52918595", "0.5279743", "0.5277875", "0.52600634", "0.52341956", "0.51917577", "0.51871246", "0.5183754", "0.5169537", "0.51664007", "0.51617664", "0.5161576", "0.5160028", "0.5160028", "0.5155916", "0.51493204", "0.51378095", "0.5132046", "0.5121632", "0.5116867", "0.5113869", "0.5108772", "0.51082003", "0.5106524", "0.50900483", "0.5088381", "0.5086899", "0.5084688", "0.50798464", "0.5079314", "0.5076835", "0.5074166", "0.5071976", "0.50696474", "0.5065825", "0.50636595", "0.5059175", "0.5059026", "0.5053893", "0.5052454", "0.50504357", "0.5048028", "0.50454813", "0.50451005", "0.50438905", "0.50371414", "0.5033732", "0.50304824", "0.5024584", "0.50221807", "0.50193703", "0.50157607", "0.50032836", "0.49990276", "0.49936378", "0.49899516", "0.49823868", "0.49791354", "0.4975502", "0.4975148", "0.49714863", "0.49681213", "0.49659812", "0.49654248", "0.49641052", "0.49609226", "0.49564672", "0.49485493", "0.49479946", "0.49463826", "0.49367508", "0.49361053", "0.49360114", "0.4935821", "0.49326113", "0.49315655", "0.49274832", "0.49263752", "0.4923733", "0.4921715", "0.4921318", "0.4917444", "0.4914904" ]
0.0
-1
POST /join_user_to_assistants POST /join_user_to_assistants.json
def create @join_user_to_assistant = JoinUserToAssistant.new(join_user_to_assistant_params) respond_to do |format| if @join_user_to_assistant.save format.html { redirect_to @join_user_to_assistant, notice: 'Join user to assistant was successfully created.' } format.json { render :show, status: :created, location: @join_user_to_assistant } else format.html { render :new } format.json { render json: @join_user_to_assistant.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_join_user_to_assistant\n @join_user_to_assistant = JoinUserToAssistant.find(params[:id])\n end", "def index\n @join_user_to_assistants = JoinUserToAssistant.all\n end", "def join_user_to_assistant_params\n params.require(:join_user_to_assistant).permit(:cpfk_user_id, :cpfk_assistant_id)\n end", "def new_invite\n if idea_posting.users.exists?(current_user.id)\n @joinrequest = Joinrequest.new\n respond_to do |format|\n format.html \n format.json {redirect_to @joinrequest}\n end\n end\n end", "def joinGroup\n \tquery = \"SELECT user_id FROM group_meals_participants where group_meal_id = \" + GroupMeal.find_by_meal(params[:meal]).id.to_s\n \n GroupMealsParticipant.connection.select_values(query).each do |u|\n \tif(u!=current_user.id)\n \t\tu=User.find(u)\n \t\tu.alert=true\n \t\tu.alert_location=GroupMeal.find_by_meal(params[:meal]).id.to_s\n \t\tu.save\n \tend\n \tend\n @groupMealParticipant= GroupMealsParticipant.new\n @groupMealParticipant.user_id=current_user.id\n @groupMealParticipant.group_meal_id= GroupMeal.find_by_meal(params[:meal]).id\n @groupMealParticipant.save \n redirect_to(GroupMeal.find_by_meal(params[:meal]))\n end", "def create\n\t\tact_type = params[:offering_type]\n\t\tuser = User.find_by_id(params[:joining_user])\n\t\tact_id = params[:offering_id]\n\n\t\tif !name_is_valid?(user, act_type); raise Errors::FlowError.new(send(\"#{act_type}_path\", offering_id), \"Permission denied.\"); end\n\n\t\tacts_membership = user.send(\"#{act_type}s_membership\")\n\t\tjoining_act = act_type.camelize.constantize.find_by_id(act_id)\n\n\t\tunless joining_act; raise Errors::FlowError.new; end\n\n\t\t# gender\n\t\tif [\"male\", \"female\"].include? joining_act.gender\n\t\t\tunless user.gender == joining_act.gender; raise Errors::FlowError.new(root_path, \"This #{act_type} is #{joining_act.gender} only.\"); end\n\t\tend\n\n\t\tnumber_of_attendings = joining_act.number_of_attendings\n\t\tif acts_membership.count < number_of_attendings or number_of_attendings == 0\n\t\t\tacts_membership << joining_act\n\t\telse\n\t\t\traise Errors::FlowError.new(send(\"#{act_type}_path\", offering_id), \"Permission denied.\")\n\t\tend\n\t\t@offering = joining_act\n\t\t@members = joining_act.members\n\t\tjoining_act.create_activity :create, owner: user\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to joining_act }\n\t\t\tformat.js\n\t\tend\n\tend", "def join\n if request.post?\n if !@group.users.include?(current_user)\n @group.users << current_user\n flash[:success] = \"Thanks! Your membership must now be approved by an admin of #{@group.name}.\"\n\n #SEND OUT NOTIFICATION EMAILS\n @group.admins.each do |admin|\n Notifier.pending_user(admin, @group, current_user).deliver\n end\n\n redirect_to @group\n else\n flash[:error] = \"Error requesting to join #{@group.name}. Please try again.\"\n redirect_to @group\n end\n else #it fell back to GET (no js)\n flash[:error] = \"Please enable javascript to join.\"\n redirect_to @group\n end\n end", "def create\n @joined_user = JoinedUser.new(joined_user_params)\n\n respond_to do |format|\n if @joined_user.save\n format.html { redirect_to @joined_user, notice: 'Joined user was successfully created.' }\n format.json { render :show, status: :created, location: @joined_user }\n else\n format.html { render :new }\n format.json { render json: @joined_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def invite_via_suggestion\n @user = User.create_with_organisation_membership_from_project_invite @invite\n\n if @user.valid?\n RequestMailer.invite_via_suggestion @user, @invite, current_user\n\n @invite.set_handled_suggested_user!\n redirect_to :dashboard, notice: \"#{@user.email} has been sent an invite\"\n elsif account_has_been_claimed? @user\n @invite.set_handled_suggested_user!\n redirect_to :dashboard, notice: \"This user has already been invited to Digital Social\" \n else\n redirect_to :dashboard, alert: \"There was an error inviting #{@user.email}, please try again later.\" \n end\n end", "def sendMeHomeAndCreateProfile user \n if user.type == \"Applicant\"\n Profile.create(applicant_id: user.id)\n redirect_to \"/applicant\"\n else\n redirect_to \"/recruiter\"\n end\n end", "def create\n # uncomment these once you add admin\n if !check_permissions?(session[:user_type], \"create_leasing_agent\")\n redirect_to root_path\n end\n email = params[:leasing_agent][:email]\n userHash = {:email => email, :user_type => \"leasing_agent\"}\n @applicant = nil\n\n @user = User.new(userHash)\n if @user.save\n @leasing_agent = LeasingAgent.new(leasing_agent_params)\n @leasing_agent.user_id = @user.id\n respond_to do |format|\n if @leasing_agent.save\n format.html { redirect_to @leasing_agent, notice: \"Leasing agent was successfully created.\" }\n format.json { render :show, status: :created, location: @leasing_agent }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @leasing_agent.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n respond_to do |format|\n if @join_user_to_assistant.update(join_user_to_assistant_params)\n format.html { redirect_to @join_user_to_assistant, notice: 'Join user to assistant was successfully updated.' }\n format.json { render :show, status: :ok, location: @join_user_to_assistant }\n else\n format.html { render :edit }\n format.json { render json: @join_user_to_assistant.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.create!(\n email: params[:email],\n password: params[:password],\n password_confirmation: params[:password_confirmation],\n name: params[:name],\n role: 'user'\n )\n\n #unless ( params[:role].eql? 'user' )\n # establishment = Establishment.find(params[:establishment])\n # user.establishments << establishment\n #end\n\n if user.save\n render json: user.as_json(:email=>user.email), status: 201\n return\n else\n warden.custom_failure!\n render json: user.errors, status: 422\n end\n\n rescue => e\n Rails.logger.error '============================================================'\n Rails.logger.error e.message\n Rails.logger.error e.backtrace\n end", "def join\n\t\t@event = Event.find(params[:id])\n\n\t\tparams[:user_id] = current_user.id unless admin? && params[:user_id]\n\n\t\t@attendance = Attendance.new\n\t\t@attendance.event_id = @event.id\n\t\t@attendance.user_id = params[:user_id]\n\t\tif @attendance.save\n\t\t\tredirect_to @event, notice: \"Joined!\"\n\t\telse\n\t\t\tredirect_to root_path, alert: \"WTF did you just try to do.\"\n\t\tend\n\tend", "def populate_judge_team_for_testing(judge_team, judge_user, attorneys)\n judge_team.users << judge_user\n attorneys.each do |u|\n judge_team.users << u\n end\n judge_orguser = OrganizationsUser.existing_record(judge_user, judge_team)\n judge_orguser.update!(admin: true)\n end", "def add_user(user)\n super.tap do |org_user|\n class_name = (users.count == 1) ? JudgeTeamLead : DecisionDraftingAttorney\n class_name.create!(organizations_user: org_user)\n end\n end", "def create\n @mentee = Mentee.new(mentee_params)\n @users=User.all\n @user=@users.last\n @mentee[:user_id] = @user.id\n if @mentee.save\n if current_user.mentor && current_user.mentee\n @mentor = Mentor.new()\n render 'additional_mentor'\n else\n redirect_to home_path\n end\n end\n end", "def create\n @auditor_participation = @site.auditor_participations.build\n @auditor = User.find_by_email(auditor_participation_params[:email])\n @auditor_participation.user = @auditor\n\n respond_to do |format|\n if @auditor_participation.save\n format.html { redirect_to @site, notice: 'AuditorParticipation was successfully created.' }\n format.json { render :show, status: :created, location: @auditor_participation }\n else\n format.html { redirect_to @site }\n format.json { render json: @auditor_participation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @personnel = User.new\n @personnel.first_name = params[\"first_name\"]\n @personnel.last_name = params[\"last_name\"]\n @personnel.phone_number = params[\"phone_number\"]\n @personnel.title = params[\"title\"]\n @personnel.email = params[\"email\"]\n @personnel.password = params[\"email\"]\n @personnel.admin_name = current_user.fullname\n @personnel.admin_update_time = DateTime.now\n if params[\"is_verified\"].nil?\n @personnel.is_verified = false\n else\n @personnel.is_verified = true\n end\n\n\n respond_to do |format|\n if @personnel.save\n @personnel.user_roles.create(:role_id => params[\"user_role\"][\"user_role_id\"])\n format.html { redirect_to personnel_path(@personnel), notice: 'Personnel was successfully created.' }\n format.json { render :show, status: :created, location: @personnel }\n else\n format.html { render :new }\n format.json { render json: @personnel.errors, status: :unprocessable_entity }\n end\n end\n end", "def join\n @room = Room.find(params.require(:room_id))\n if @room&.add_user(current_user)\n success\n else\n not_found\n end\n end", "def join\n\t @household = Household.find params[:id]\n\t current_user.update_attribute(:household_id, @household.id)\n\t redirect_to @household\n\tend", "def create\n @residencial = Residencial.find(params[:residencial_id])\n @apartamento = Apartamento.find(params[:apartamento_id])\n @user = @apartamento.users.build(params[:user])\n\n role = Role.find_by_nome(\"condomino\")\n @user.roles << role\n password = (0...4).map{ ('a'..'z').to_a[rand(26)] }.join\n password << (0...4).map{ (0..9).to_a[rand(10)] }.join\n @user.password = password\n\n #@user = User.new(params[:residencial])\n\n respond_to do |format|\n if @user.save\n #format.html { redirect_to [@user.apartamento.residencial, @user.apartamento, @user], notice: 'User foi criado com sucesso.' }\n format.html { redirect_to residencial_apartamento_users_path, notice: 'User foi criado com sucesso.' }\n format.json { render json: @user, status: :created, location: @user }\n\n UserMailer.welcome_email(@user, password).deliver!\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 join_group\n @disc_group = DiscussionGroup.find(params[:id])\n @join = DiscussionGroupUser.new(:discussion_group_id => @disc_group.id, :user_id => @login_user.id, :is_member => 1)\n if @join.save\n respond_to do |format|\n format.js\n end\n else\n render :text=>\"Fail\"\n end\n end", "def create\n UsersAgency.selection_from_ids(current_user, params[:agency_selection])\n head :created\n end", "def sendreq\n newReq = Joinrequest.new(:resolved => false, :manager_id => params[:id], :property_id => params[:pid], :tenant_id => session[:user_id])\n newReq.save\n redirect_to \"/tenants/show\"\n end", "def join!(user)\n # It loads up all the user because in the case where the chat is saved but the chat_participations have not been saved,\n # this is the only way to ensure we don't have duplicates.\n return if self.chat_participations.map(&:user_id).include?(user.id)\n self.chat_participations.create!(:user => user)\n end", "def join\n @attendance = Attendance.new(attendance_params)\n\n begin\n\n raise ArgumentError if params[:attendance][:phone_number].empty? ||\n params[:attendance][:email].empty? ||\n params[:attendance][:username].empty?\n\n user = attendance_user\n event = attendance_event\n\n respond_to do |format|\n #require 'byebug';debugger\n @attendance.user = user\n @attendance.event = event\n if @attendance.save\n AttendanceMailer.delay_for(5.second).send_email_to_consumers(@attendance.id)\n AttendanceMailer.delay_for(5.second).send_email_to_agents(@attendance.id)\n format.html { redirect_to attendance_event, notice: '感谢您的关注,我们已收到您的报名信息,将尽快联系您!' }\n format.json { render :show, status: :created, location: attendance_event }\n else\n format.html { render :new }\n format.json { render json: @attendance.errors, status: :unprocessable_entity }\n end\n end\n rescue Exception => e\n #Log the error\n logger.fatal e\n respond_to do |format|\n format.html { redirect_to attendance_event }\n end\n return\n end\n end", "def create\n @stablishment = Stablishment.new(stablishment_params)\n @stablishment.company_user = current_user\n respond_to do |format|\n if @stablishment.save\n format.html { redirect_to @stablishment, notice: 'Stablishment was successfully created.' }\n format.json { render :show, status: :created, location: @stablishment }\n else\n format.html { render :new }\n format.json { render json: @stablishment.errors, status: :unprocessable_entity }\n end\n end\n end", "def addUser2Project( site, name, identifier, roles )\n log \"Adding user to project \"\n uid = getUserId site, name\n pid = getProjectId site, identifier\n membership = { :membership => { :user_id => uid , :role_ids => roles}}.to_json\n puts membership\n begin\n puts \"/projects/#{pid}/memberships.json\"\n response = site[\"/projects/#{pid}/memberships.json\"].post membership, :content_type => 'application/json'\n rescue => e\n puts \"Error while adding user to project: \"+ e.inspect\n end\n end", "def join\n course = Course.where(join_token: params[:course][:join_token]).first\n\n if course and not current_user.courses.include? course\n current_user.courses << course\n current_user.add_role :student, course\n course.assignments.each { |assignment| assignment.create_submissions_for_students }\n\n flash[:notice] = \"Successfully joined class\"\n redirect_to course_path(course.id)\n else\n flash[:notice] = \"Failed to join class\"\n redirect_to :back\n end\n end", "def create\n # Adding user id to saved occupations, see omrails, Add Associations . . ., 26:00\n @occupation = current_user.occupations.new(params[:occupation])\n\n #http://stackoverflow.com/questions/6480713/how-to-get-the-post-id-in-rails 10 SEPT 2013\n @skill = current_user.skills.new(params[:skill])\n @skill.occupation = Occupation.find(params[:occupation_id])\n\n respond_to do |format|\n if @occupation.save\n format.html { redirect_to @occupation, notice: 'Occupation was successfully created.' }\n format.json { render json: @occupation, status: :created, location: @occupation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @occupation.errors, status: :unprocessable_entity }\n end\n end\n end", "def join\n @plan = current_user.plans.create(:itinerary_id => params[:itinerary_id], :child_id => current_user.id, :parent_id => params[:parent_id])\n respond_to do |format|\n if @plan.save\n format.html { redirect_to(itineraries_path, :notice => 'Plan was successfully created.') }\n else\n format.html { redirect_to(itineraries_path, :notice => 'There was an error in joining this itinerary') }\n end\n end\nend", "def create\n @provider_engaged_user = ProviderEngagedUser.new(provider_engaged_user_params)\n \n @provider_engaged_users = ProviderEngagedUser.joins(:provider_master).where(\"provider_masters.id = provider_engaged_users.provider_id and provider_engaged_users.provider_id = #{session.delete(:provider_id)} \")\n # @provider_engaged_users = ProviderEngagedUser.joins(:provider_master).where(\"provider_id = #{session.delete(:provider_id)}\")\n @provider_name = session.delete(:provider_name)\n @person_infos = PersonInfo.order(:surname).where(\"surname like ?\", \"%#{params[:person_id]}\")\n \n @the_list = @person_infos.map { |a|[a.surname+\" \"+a.other_names+\" \",a.id] } \n \n respond_to do |format|\n if @provider_engaged_user.save\n format.js { flash.now[:notice] = \"Staff was successfully added.\" }\n format.html { redirect_to @provider_engaged_user, notice: 'Provider engaged user was successfully created.' }\n format.json { render :show, status: :created, location: @provider_engaged_user }\n else\n format.js {render :new}\n format.html { render :new }\n format.json { render json: @provider_engaged_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @assist = Assist.new(params[:assist])\n\n respond_to do |format|\n if @assist.save\n format.html { redirect_to @assist, notice: 'Assist was successfully created.' }\n format.json { render json: @assist, status: :created, location: @assist }\n else\n format.html { render action: \"new\" }\n format.json { render json: @assist.errors, status: :unprocessable_entity }\n end\n end\n end", "def join\n @group = Group.find(params[:id])\n \n if group_user = GroupUser.first(:conditions => ['group_id = ? AND user_id = ?', @group.id, current_user.id])\n if ['cancelled', 'invite_declined'].include?(group_user.status)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n elsif group_user.status == 'approved'\n flash[:error] = 'You are already member of this group.'\n else\n flash[:error] = 'You cannot join this group.'\n end\n else\n group_user = GroupUser.create(:group_id => @group.id, :user_id => current_user.id, :role_id => Role.find_by_name('User').id)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n end\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end", "def join\n @group = Group.find(params[:id])\n \n if group_user = GroupUser.first(:conditions => ['group_id = ? AND user_id = ?', @group.id, current_user.id])\n if ['cancelled', 'invite_declined'].include?(group_user.status)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n elsif group_user.status == 'approved'\n flash[:error] = 'You are already member of this group.'\n else\n flash[:error] = 'You cannot join this group.'\n end\n else\n group_user = GroupUser.create(:group_id => @group.id, :user_id => current_user.id, :role_id => Role.find_by_name('User').id)\n group_user.request!\n flash[:notice] = 'Your membership request was sent to group owner.'\n end\n \n respond_to do |format|\n format.html { redirect_to(groups_url) }\n format.xml { head :ok }\n end\n end", "def create\n @user = User.find(params[:user_id])\n @agency = Agency.find(params[:portaluserassignment][:agency_id])\n @p = Portaluserassignment.new\n @p.agency_id = @agency.id\n @p.user_id = @user.id\n #redirect_to root_url , notice: p\n\n\n #@user.join(@agency)\n #@portaluserassignment = Portaluserassignment.create(agency_id: @agency.id, user_id: @user.id)\n #age = params[:agency_id]\n #@portaluserassignment = Portaluserassignment.new(params[:portaluserassignment])\n\n #@portaluserassignment = @user.agencies.create(:agency_id => @agency)\n #@project = @agency.projects.build(params[:project])\n \n #@user.agencies.create!\n\n # redirect_to root_url , notice: params[:portaluserassignment][:agency_id]\n\n if @p.save\n redirect_to user_portaluserassignments_path(@user) , notice: 'Portaluserassignment was successfully created.' \n \n else\n render action: \"new\" \n \n end\nend", "def create\n @gradework = Gradework.new(gradework_params)\n\n if params.has_key?(:students) and params[:students] != [\"\"]\n students = params[:students]\n @gradework.users << User.find(students)\n end\n\n if params.has_key?(:juries) and params[:juries] != [\"\"]\n juries = params[:juries]\n @gradework.users << User.find(juries)\n end\n\n if params.has_key?(:directors) and params[:directors] =! \"\"\n directors = params[:directors]\n @gradework.users << User.find(directors)\n end\n\n respond_to do |format|\n if @gradework.save!\n format.html { redirect_to @gradework, notice: 'La tesis se creó correctamente' }\n format.json { render :show, status: :created, location: @gradework }\n else\n format.html { redirect_to @gradework, notice: 'La tesis no se pudo crear correctamente' }\n format.json { render json: @gradework.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to @user, notice: 'Thanks for joining us! :)' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @join = Join.find_by(user_id: current_user.id, hike_id: params[:id])\n if @join\n redirect_to :back\n else\n @join = Join.create(user_id:current_user.id, hike_id:params[:id])\n redirect_to :back\n end\n end", "def join\n \n #TODO add player to hunt\n #player = User.find(params[:id])\n redirect_to hunt_player_path()\n end", "def meet\n # Envia pedido de que quer conhecer o animal. \n # Isto mandaria uma proposta para o dono do shelter.\n\n # TODO: É preciso criar uma tabela associativa para saber quem já mandou proposta para o animal.\n # Assim evitaria mandar proposta múltiplas vezes.\n if params[:user_id]\n # friendly_user = User.find(params[:user_id])\n friendly_user = current_user\n AnimalMailer.meet_up_proposal(@animal, friendly_user).deliver\n end\n end", "def create\n @user = User.new(user_params)\n @user.password = (Random.rand() * 10000).floor.to_s\n @user.helping = params[:helping]\n if @user.save\n term = params[:expertise].gsub!(/\\s+/, '')\n expertise = Expertise.find_by(name: term)\n login(@user)\n redirect_to search_path(expertise.id)\n end\n end", "def create\n @equipo = Equipo.new(equipo_params)\n\n if @equipo.save\n render :show, status: :created, location: @equipo\n EquiposUsers.create(\n user_id: params[:capitan_name] ,\n equipo_id: @equipo.id\n )\n else\n render json: @equipo.errors, status: :unprocessable_entity\n end\n end", "def create\n if logged_in?\n @assist_message = current_user.assist_messages.build(assist_message_params)\n else\n @assist_message = User.first.assist_messages.build(assist_message_params)\n end\n\n respond_to do |format|\n if @assist_message.save\n format.html { redirect_to @assist_message, notice: 'Assist message was successfully created.' }\n format.json { render :show, status: :created, location: @assist_message }\n else\n format.html { render :new }\n format.json { render json: @assist_message.errors, status: :unprocessable_entity }\n end\n end\n end", "def join\n @event = Event.find(params[:event_id])\n @e = @event.user_to_events.build(:user_id => current_user.id,\n :event_id => \"#{@event.id}\",\n :owner_id => \"#{@event.user_id}\" )\n\n respond_to do |format|\n if @e.save\n @total_attendence = UserToEvent.find(\"#{@e.id}\").event.update_attributes(:no_of_guests_attending => (@event.no_of_guests_attending)+1)\n format.html { redirect_to(@event, :notice => 'Request has been sent to the meal owner.') }\n format.xml { head :ok }\n else\n format.html { redirect_to(event_path(@event), :notice => 'Something has gone wrong , please try again.') }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def join\r\n if @trip.participants.include?(current_person)\r\n redirect_to(@trip, :notice => \"You are already a participant in the #{@trip.name}.\")\r\n return\r\n elsif @trip.organizers.include?(current_person) && request.post?\r\n @trip.participants << current_person\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n else\r\n @token = params[:token]\r\n invitation = Invitation.find_by_token(@token)\r\n if invitation.nil?\r\n redirect_to(person_root_url, :error => \"The invitation link you followed is invalid.\")\r\n return\r\n end\r\n \r\n if request.post?\r\n invitation.accept(current_person)\r\n redirect_to(manage_membership_trip_url(@trip), :notice => \"You are now a participant in the #{@trip.name}.\")\r\n end\r\n end\r\n end", "def create\n @join = Join.new(user_id: current_user.id, event_id: params[:event_id])\n if @join.save\n redirect_to \"/events\"\n else\n redirect_to \"/events\"\n end\n end", "def create\n @suggest = Suggest.new(suggest_params)\n @suggest.user_id= current_user.id\n @suggest.suggest_user=current_user.nickname\n\n respond_to do |format|\n if @suggest.save\n format.html { redirect_to @suggest, notice: 'Suggest was successfully created.' }\n format.json { render :show, status: :created, location: @suggest }\n else\n format.html { render :new }\n format.json { render json: @suggest.errors, status: :unprocessable_entity }\n end\n end\n end", "def join(user)\n @mysqlHelper.insertConUser(user.getI,@id)\n @userList.getcontents.each { |users| \n \n users.userChangeFromChannel(\"204\", @id, user.getId)\n }\n @userList.add(user)\n \n end", "def join_user user, as=:worker\n # Try to find previous role, who was deleted before\n if role = Role.unscoped.where(user_id: user.id, project_id: self.id).first\n role.update!({\n deleted: false,\n level: self.class.parse_role(as, true)\n })\n\n role\n else\n Role.create({\n level: self.class.parse_role(as, true),\n project_id: self.id,\n user_id: user.id\n })\n end\n end", "def create\n group_ids = params[\"group_id\"]\n org_id = params[:organization_id]\n @user = User.new(full_name: params[:full_name], password: params[:password], password_confirmation: params[:password], email: params[:email], status: params[:status], staff_number: params[:employee_id], career_path: params[:career_path], team_leader_id: nil)\n @user.user_group_ids = group_ids\n @user.organization_id = org_id\n\n respond_to do |format|\n if @user.save\n format.json { render json: @user }\n else\n format.json { render json: @user.errors.messages, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n # Get the role_ids and privelege ids and remove them from the params hash\n # as we dont want these managed by the rails associations\n role_id = params[:user][:role_ids]\n privilege_ids = params[:user][:privilege_ids]\n\n # Get a new user service to invoke any business logic associated with creating\n # new users\n new_user_service = get_new_user_service\n # Create the user\n @user = new_user_service.build(form_params.except(:organization_ids))\n\n if @user.organization.nil?\n @user.organization_id = @organization_list.first\n org_list = @organization_list\n else\n org_list = form_params[:organization_ids]\n end\n\n respond_to do |format|\n if @user.save\n\n # set organizations\n @user.organizations = Organization.where(id: org_list)\n\n # Assign the role and privileges\n role_service = get_user_role_service\n role_service.set_roles_and_privileges @user, current_user, role_id, privilege_ids\n role_service.post_process @user\n\n # Perform an post-creation tasks such as sending emails, etc.\n new_user_service.post_process @user\n\n notify_user(:notice, \"User #{@user.name} was successfully created.\")\n format.html { redirect_to user_url(@user) }\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 create\n existing_user = User.find_by(email_id: params[:user][:email_id])\n if existing_user != nil\n if existing_user.is_realtor == true\n redirect_to login_path, notice: 'You are already registered as an Realtor'\n else\n existing_user.is_realtor = true\n existing_user.password = params[:user][:password]\n if existing_user.save\n add_realtor = Realtor.new(realtor_params)\n add_realtor.users_id = existing_user.id\n if add_realtor.save\n redirect_to login_path, notice: 'Realtor was successfully created.'\n else\n redirect_to login_path, notice: 'Error saving realtor.'\n end\n else\n redirect_to login_path, notice: 'Error saving user.'\n end\n end\n else\n @realtor = Realtor.new(realtor_params)\n @user = User.new(user_params)\n @user.is_realtor = true\n respond_to do |format|\n if @user.save\n @realtor.users_id = @user.id\n if @realtor.save\n format.html {redirect_to login_path, notice: 'Realtor was successfully created.'}\n format.json {render :show, status: :created, location: @realtor}\n else\n format.html {redirect_to login_path, notice: 'Error creating realtor'}\n format.json {render json: @realtor.errors, status: :unprocessable_entity}\n end\n else\n format.html {redirect_to login_path, notice: 'Error creating user. Please check input.'}\n format.json {render json: @user.errors, status: :unprocessable_entity}\n end\n end\n end\n end", "def create\nuser=User.find_by_id(current_user.id)\n @exprience = Exprience.new(params[:exprience])\n@exprience.user=user\n respond_to do |format|\n if @exprience.save\n format.html { redirect_to @exprience, notice: 'Exprience was successfully created.' }\n format.json { render json: @exprience, status: :created, location: @exprience }\n else\n format.html { render action: \"new\" }\n format.json { render json: @exprience.errors, status: :unprocessable_entity }\n end\n end\n end", "def invite\n @meal = Meal.find(params[:meal_id])\n authorize @meal, :update?\n @user = if params[:user_id]\n User.find(params[:user_id])\n else\n User.find_by(name: params[:user_name])\n end\n @meal.invite_user @user\n redirect_to @meal\n end", "def create\n # @group_user = GroupUser.new(params[:group_user])\n @group_user = @current_user.join_group(@group)\n respond_to do |format|\n if @group_user\n format.html { redirect_to @group, notice: 'Group user was successfully created.' }\n format.json { render json: @group_user, status: :created, location: @group_user }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n session[:return_to] ||= request.referer\n @exercise_types_in_user = ExerciseTypesInUser.new(exercise_types_in_user_params)\n @exercise_types_in_user.user_id = current_user.id\n\n respond_to do |format|\n if @exercise_types_in_user.save\n format.html { redirect_to @exercise_types_in_user, notice: 'Exercise types in user was successfully created.' }\n format.json { render :show, status: :created, location: @exercise_types_in_user }\n else\n format.html { render :new }\n format.json { render json: @exercise_types_in_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_helpdesk_user(company,password,role_id)\n if APP_URLS[:use_helpdesk]\n begin\n if role_id !=''\n url = URI.parse(APP_URLS[:helpdesk_url] + \"/users/clepsotda\")\n if url.scheme == 'https'\n uri = URI.parse(APP_URLS[:helpdesk_url] + \"/login\")\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl =true\n res = https.get(uri.path)\n c=res.response['set-cookie'].split('; ')[0]\n user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1'\n headers = {\n 'Cookie' => c,\n 'Referer' => APP_URLS[:helpdesk_url] + \"/login\",\n 'Content-Type' => 'application/x-www-form-urlencoded',\n 'User-Agent' => user_agent\n }\n\n data =\"email=#{self.email}&password=#{password}&password_confirmation=#{password}&role_id=#{role_id}&login=#{self.username}&first_name=#{self.first_name}&last_name=#{self.last_name}\"\n resp, data = https.post2(url.path, data, headers)\n else\n args={:email=>self.email,:password_confirmation=>password,:password=>password,:role_id=>role_id,:login=>self.username,:first_name=>self.first_name,:last_name=>self.last_name,:created_at=>self.created_at.to_s,:updated_at=>self.updated_at.to_s}\n Net::HTTP.post_form(url,args)\n end\n new_user = User.find_by_sql(\"SELECT * FROM helpdesk.users WHERE login = '#{self.username}'\")[0]\n connection.execute(\"INSERT INTO helpdesk.employees (company_id, user_id, created_at, updated_at)\n VALUES (#{new_user.company_id}, #{new_user.id}, '#{self.created_at}', '#{self.updated_at}');\")\n\n connection.execute(\"INSERT INTO single_signon.user_apps(product_id, product_user_id, helpdesk_user_id) VALUES ((select id FROM helpdesk.products WHERE key='#{APP_URLS[:livia_portal_key]}' LIMIT 1), #{self.id}, #{new_user.id});\")\n\n elsif self.role.name == 'lawyer'\n company_app = Company.find_by_sql(\"SELECT * FROM single_signon.company_apps where product_company_id = #{company.id} AND product_id=(select id FROM helpdesk.products WHERE key='#{APP_URLS[:livia_portal_key]}' LIMIT 1)\")\n if company_app.blank?\n company_id = Company.find_by_sql(\"SELECT * FROM helpdesk.companies WHERE name = 'LIVIA India Pvt. Ltd'\" )[0].id\n company_client_type_id = Company.find_by_sql(\"SELECT * FROM helpdesk.company_client_types WHERE company_id = #{company_id}\")[0].id\n connection.execute(\"INSERT INTO helpdesk.company_clients (name,company_id,company_client_type_id,description,created_at,updated_at)\n VALUES ('#{company.name}', #{company_id}, #{company_client_type_id} , 'created from livia portal','#{company.created_at}','#{company.updated_at}');\")\n helpdesk_company_id = Company.find_by_sql(\"SELECT * FROM helpdesk.company_clients WHERE name = '#{company.name}'\")[0].id\n connection.execute(\"INSERT INTO single_signon.company_apps(product_id, product_company_id,helpdesk_company_id) VALUES ((select id from helpdesk.products WHERE key='#{APP_URLS[:livia_portal_key]}' LIMIT 1), #{company.id}, #{helpdesk_company_id});\")\n else\n helpdesk_company_id = company_app[0].helpdesk_company_id\n end\n helpdesk_role_id = Role.find_by_sql(\"SELECT id FROM helpdesk.roles WHERE name = 'Client User'\")[0].id\n url = URI.parse(APP_URLS[:helpdesk_url] + \"/users/clepsotda\")\n if url.scheme == 'https'\n uri = URI.parse(APP_URLS[:helpdesk_url] + \"/login\")\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl =true\n res = https.get(uri.path)\n c=res.response['set-cookie'].split('; ')[0]\n user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1'\n headers = {\n 'Cookie' => c,\n 'Referer' => APP_URLS[:helpdesk_url] + \"/login\",\n 'Content-Type' => 'application/x-www-form-urlencoded',\n 'User-Agent' => user_agent\n }\n\n data =\"email=#{self.email}&password=#{password}&password_confirmation=#{password}&role_id=#{helpdesk_role_id}&login=#{self.username}&first_name=#{self.first_name}&last_name=#{self.last_name}\"\n resp, data = https.post2(url.path, data, headers)\n else\n args={:email=>self.email,:password_confirmation=>password,:password=>password,:role_id=>helpdesk_role_id,:login=>self.username,:first_name=>self.first_name,:last_name=>self.last_name,:created_at=>self.created_at.to_s,:updated_at=>self.updated_at.to_s}\n Net::HTTP.post_form(url,args)\n end\n new_user_id = User.find_by_sql(\"SELECT * FROM helpdesk.users WHERE login = '#{self.username}'\")[0].id\n connection.execute(\"INSERT INTO helpdesk.company_client_users (company_client_id, user_id, created_at, updated_at)\n VALUES (#{helpdesk_company_id},#{new_user_id}, '#{self.created_at}', '#{self.updated_at}');\")\n\n connection.execute(\"INSERT INTO single_signon.user_apps(product_id,product_user_id,helpdesk_user_id) VALUES ((select id FROM helpdesk.products WHERE key='#{APP_URLS[:livia_portal_key]}' LIMIT 1), #{self.id}, #{new_user_id});\")\n # rescue\n elsif self.role.name=='secretary' || self.role.name=='cluster_manager'\n helpdesk_role_id = Role.find_by_sql(\"SELECT id FROM helpdesk.roles WHERE name='Livian'\")[0].id\n url = URI.parse(APP_URLS[:helpdesk_url] + \"/users/clepsotda\")\n if url.scheme == 'https'\n uri = URI.parse(APP_URLS[:helpdesk_url] + \"/login\")\n https = Net::HTTP.new(uri.host, uri.port)\n https.use_ssl =true\n res = https.get(uri.path)\n c=res.response['set-cookie'].split('; ')[0]\n user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1'\n headers = {\n 'Cookie' => c,\n 'Referer' => APP_URLS[:helpdesk_url] + \"/login\",\n 'Content-Type' => 'application/x-www-form-urlencoded',\n 'User-Agent' => user_agent\n }\n\n data =\"email=#{self.email}&password=#{password}&password_confirmation=#{password}&role_id=#{helpdesk_role_id}&login=#{self.username}&first_name=#{self.first_name}&last_name=#{self.last_name}\"\n resp, data = https.post2(url.path, data, headers)\n else\n args={:email=>self.email,:password_confirmation=>password,:password=>password,:role_id=>helpdesk_role_id,:login=>self.username,:first_name=>self.first_name,:last_name=>self.last_name,:created_at=>self.created_at.to_s,:updated_at=>self.updated_at.to_s}\n Net::HTTP.post_form(url,args)\n end\n new_user = User.find_by_sql(\"SELECT * FROM helpdesk.users WHERE login = '#{self.username}'\")[0]\n connection.execute(\"INSERT INTO helpdesk.employees (company_id, user_id, created_at, updated_at)\n VALUES (#{new_user.company_id}, #{new_user.id}, '#{self.created_at}', '#{self.updated_at}');\")\n\n connection.execute(\"INSERT INTO single_signon.user_apps(product_id, product_user_id, helpdesk_user_id) VALUES ((SELECT id FROM helpdesk.products WHERE key='#{APP_URLS[:livia_portal_key]}' LIMIT 1), #{self.id},#{new_user.id});\")\n\n\n\n\n #find company\n #create_service_provider\n #create_user\n end\n end\n end\n end", "def approve_join_request\n join_request = JoinRequest.find(params[:id])\n team = join_request.team\n # Only authorize the captain to do this\n if current_user.id == team.captain_id\n membership = Membership.create(\n team_id: join_request.team_id,\n user_id: join_request.user_id,\n admin: false\n )\n if membership.valid?\n join_request.destroy\n render json: {\n team: TeamSerializer.new(team),\n user: UserSerializer.new(current_user)\n }, status: :accepted\n else\n # invalid request\n render json: {\n message: \"Invalid request\",\n errors: membership.errors.full_messages\n }, status: :not_acceptable\n end\n else\n render json: { message: \"Only the captain is allowed to accept join requests\"}, status: :not_acceptable\n end\n end", "def create\n @user = User.find(params[:id])\n user = @user.attributes\n user[\"role\"] = 2\n @user.update!(user)\n admin_params = Administrator.new.attributes\n admin_params[\"superadmin\"] = 0\n admin_params[\"user\"] = @user\n admin_params[\"geofence\"] = Geofence.first\n @administrator = Administrator.new(admin_params)\n respond_to do |format|\n if @administrator.save\n format.html { redirect_to administrators_path, notice: 'Administrator was successfully created.' }\n format.json { render :show, status: :created, location: @administrator }\n else\n format.html { render :new }\n format.json { render json: @administrator.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @corporate_user, password = User.create_corp_user(corporate_user_params)\n respond_to do |format|\n if @corporate_user.save\n admin_email = User.where(id: @corporate_user.parent_id).first.email\n InviteUser.corporate_user_confirmation(@corporate_user,admin_email,password).deliver\n format.html { redirect_to corporate_users_path, notice: \"#{APP_MSG['corporate_user']['create']}\" }\n format.json { render :show, status: :created, location: corporate_user_path }\n else\n format.html { render :new }\n format.json { render json: @corporate_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @advocate_user = AdvocateUser.new(permitted_params[:advocate_user])\n\n if @advocate_user.save\n @advocate_user.update! electoral_alliance_ids: params[:advocate_user][:electoral_alliance_ids]\n\n flash[:notice] = \"Edustaja luotu!\"\n redirect_to admin_advocate_user_path(@advocate_user)\n else\n super\n end\n end", "def attend\n user_id = current_user.id\n training_id = params[:id]\n TrainingRecord.create_new_record user_id, training_id\n redirect_to @training, notice: \"You have successfully registered for #{@training.title}\"\n end", "def user_params\n params.require(:user).permit(:adults_providing_for)\n end", "def create\n # charity_params = params[:charity]\n Rails.logger.info charity_params\n\n Rails.logger.info (\"user id params[:user_id] params[charity_user] #{params[:charity_user]}\")\n @charity = Charity.new(charity_params)\n email = charity_params[:email]\n if (User.find_by_email(email)) and current_user.email != email\n then\n set_flash_message :notice, \"email taken\" and redirect_to(\"/users\")\n \n elsif params[:charity_admin] \n @charity = Charity.new\n @charity.update(charity_params)\n @charity.charity_users.create!(:user_id => current_user.id,:role => 'admin')\n\n else\n # this is where i am from somethign awesome...\n #user = User.new \n user = User.create(:email => email,:password => \"123324324234dfadsfsad\")\n if params[:role] == \"charity_admin\"\n user.role = role\n end\n user.save\n inviter||= params[:user_id]\n invite = UserInvite.create(:user_id=> inviter, :invitee => user.id)\n invite.save\n end\n\n respond_to do |format|\n if @charity.save\n unless CharityUser.exists?(:user_id => current_user.id, :charity_id => @charity.id, :role =>\"admin\")\n CharityUser.create!(:charity_id => @charity.id, :user_id => current_user.id, :role => \"admin\")\n end\n ## Rails.logger.info ( charity now has ID - time to make the charity user admin)\n Rails.logger.info (\"user id params[:user_id] params[charity_user] #{params[:charity_user]}\")\n format.html { redirect_to @charity, notice: 'Charity was successfully created.' }\n format.json { render :show, status: :created, location: @charity }\n else\n format.html { render :new }\n format.json { render json: @charity.errors, status: :unprocessable_entity }\n end\n end\n\n # PATCH/PUT /charities/1\n # PATCH/PUT /charities/1.json\n def update\n respond_to do |format|\n if @charity.update(charity_params)\n format.html { redirect_to @charity, notice: 'Charity was successfully updated.' }\n format.json { render :show, status: :ok, location: @charity }\n else\n format.html { render :edit }\n format.json { render json: @charity.errors, status: :unprocessable_entity }\n end\n end\n end\n\n # DELETE /charities/1\n # DELETE /charities/1.json\n def destroy\n @charity.destroy\n respond_to do |format|\n format.html { redirect_to charities_url, notice: 'Charity was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n\n def admin_only\n unless current_user.admin?\n redirect_to :back, :alert => \"Access denied.\"\n end\n end\n\n def set_charity\n @charity = Charity.find(params[:id])\n end\n\n\n def charity_params\n params.require(:charity).permit(:name, :description, :url, :stripe_id, :email, :city, :state,:user_id)\n end\n\n def private\n def set_charity\n @charity = Charity.find(params[:id])\n end\n\n # Use callbacks to share common setup or constraints between actions.\n\n def plan_only\n unless current_user\n redirect_to \"/\", :alert => \"Access denied. You must be a member to suggest a charity. Explore with us as a member now for free.\"\n end\n end\n\n\n def admin_only\n unless current_user.admin?\n redirect_to :back, :alert => \"Access denied.\"\n end\n end\n \n # Never trust parameters from the scary internet, only allow the white list through.\n def charity_params\n params.require(:charity).permit(:name, :description, :url, :stripe_id, :email, :city, :state, :charity_user)\n end\n end\n end", "def join\n @event = Event.find(params[:event_id])\n if (params[:type] == \"invite\")\n @uids = params[:uids]\n @uid_array = []\n @uid_array = @uids.split(\",\")\n\n @motlee_users = []\n @non_motlee_users = []\n\n @uid_array.each do |uid|\n motlee_user = User.where(:uid => uid).first\n\n if motlee_user.nil?\n token = params[:access_token]\n event_id = params[:event_id]\n Resque.enqueue(ProcessNewUserInvite, token, event_id, uid) \n else\n # User is already a part of Motlee\n # Add user to array of Motlee users\n @motlee_users << uid\n \n # Now we check to see if the user has already been added to the event\n @attendee = Attendee.where(\"user_id = ? AND event_id = ?\", motlee_user.id, params[:event_id]).first\n if @attendee.nil?\n # If user has not been added, create new Attendee object\n @attendee = Attendee.create(:user_id => motlee_user.id, :event_id => params[:event_id], :rsvp_status => 1)\n if (motlee_user.id != current_user.id)\n Resque.enqueue(AddEventNotification, motlee_user.id, params[:event_id], current_user.id)\n end\n end\n end\n end \n else\n @attendee = Attendee.create(:user_id => current_user.id, :event_id => @event.id, :rsvp_status => 1)\n end\n # Render a response so the devices are happy\n @event.update_attributes(:updated_at => Time.now)\n render :json => @event.as_json({:methods => [:owner, :attendee_count], \n :include => {:photos => {:include => {:comments => {}, :likes => {}}}, \n :people_attending => {:only => [:id, :uid, :name, :sign_in_count]}}})\n end", "def create\n @user = current_user.children.create(params[:user].merge :email => \"design+parent_id#{current_user.id}_child_count#{current_user.children.count + 1}@newint.com.au\")\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to user_path(current_user), notice: 'User was successfully created.' }\n format.json { render json: [:institution, @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 create\n @support = Foswipe::User.new(user_params)\n @support.agent = true\n respond_to do |format|\n if @support.save\n format.html { redirect_to supports_url, notice: 'Agent was successfully created.' }\n format.json { render action: 'show', status: :created, location: @support }\n else\n format.html { render action: 'new' }\n format.json { render json: @support.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n # @repair = Repair.new(repair_params) this change to current_user jkm\n # this will let us know the user who created the repair\n \n #added jkm\n @serviceproviders = Serviceprovider.all\n \n \n @repair = current_user.repairs.new(repair_params)\n\n respond_to do |format|\n if @repair.save\n format.html { redirect_to @repair, notice: 'Repair was successfully created.' }\n format.json { render :show, status: :created, location: @repair }\n else\n format.html { render :new }\n format.json { render json: @repair.errors, status: :unprocessable_entity }\n end\n end\n end", "def another_teacher_to_section \n User.create_new_section(params[:new_teacher_to_add], params[:section], session[:selected_project_id])\n user = User.find(params[:new_teacher_to_add])\n\n redirect_to users_teachers_path, notice: \"#{user.first_name} #{user.last_name} was added to section #{params[:section]}.\"\n end", "def create\n\n @teaching = Teaching.new(teaching_params)\n @user = User.find(session[:user_id]) \n \n respond_to do |format|\n if @teaching.save\n @user.teachings << @teaching\n format.html { redirect_to @teaching, notice: 'La actividad se registro con exito.' }\n format.json { render :show, status: :created, location: @teaching }\n else\n format.html { render :new }\n format.json { render json: @teaching.errors, status: :unprocessable_entity }\n end\n end\n\n \n end", "def create\n @joined = Joined.new(joined_params)\n\n respond_to do |format|\n if @joined.save\n format.html { redirect_to @joined, notice: 'Joined was successfully created.' }\n format.json { render :show, status: :created, location: @joined }\n else\n format.html { render :new }\n format.json { render json: @joined.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user = User.new(user_params)\n\n respond_to do |format|\n if @user.save\n session[:user_skill_ids] = params[:skill_ids] unless session[:user_is_admin?]\n LocationsSkillsUsers.create(@user.id, @user.location_id, params[:skill_ids]) if params[:skill_ids]\n\n format.html { redirect_to @user, notice: 'User was successfully created.' }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if (User.find_by school_id: params[:user][:school_id])\n @user = User.find_by school_id: params[:user][:school_id]\n @user.update_attributes(user_params)\n else\n @user = User.new(user_params)\n end\n if @user.save\n\n if @user.role != TEACHER\n @member = Member.new\n @member.user_id = @user.id\n @member.project_id = session[:selected_project_id]\n @member.section_number = params[:section_number]\n @member.is_enabled = true\n @member.save\n redirect_to users_path, notice: @user.first_name + \" \" + @user.last_name + ' was successfully created and added to this section.' \n else\n redirect_to users_teachers_path, notice: @user.first_name + \" \" + @user.last_name + ' was successfully created and added to the teacher roster.'\n end\n else\n render action: 'new' \n end \n end", "def join\n if !current_user\n flash[:notice] = t(:join_dream)\n elsif @camp.users.include?(current_user)\n flash[:notice] = t(:join_already_sent)\n else\n flash[:notice] = t(:join_dream)\n @camp.users << @user\n end\n redirect_to @camp\n end", "def create\n @lawyer = Lawyer.new(lawyer_params)\n @lawyer.user_id = current_user.id\n @lawyer.save\n redirect_to cases_path\n end", "def create\n if current_user\n # render json: { status: 200, msg: \"Logged-in as #{current_user.name}\" }\n @userin = UserInvestor.new(userin_params)\n if @userin.save\n render json: { status: 'OK', results: @userin, errors: nil },\n status: :created\n else\n render json: { status: 'FAIL', results: nil,\n errors: 'failed to create user' },\n status: :unprocesable_entity\n end\n end\n end", "def create\n\n @healthlabels = Healthlabel.all;\n @dietlabels = Dietlabel.all;\n\n #create the new preference with the preference parameters we accept\n @preference = Preference.new(preference_params)\n #create the new user with the user parameters we accpet\n @user = User.new(user_params)\n\n #assign the current preference to the user\n @user.preference = @preference\n\n #create a blank recipe table entry for the user to save recipes to\n @user.savedrecipe = Savedrecipe.new\n #assign the default user role if not in user\n if @user.role == nil\n @user.role = 1;\n end\n\n respond_to do |format|\n if @user.save\n\n format.html { redirect_to new_session_path, notice: 'User was successfully created.' }\n\n format.json { render :show, status: :created, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n\n end\n\n end\n end", "def create\n\n @house = House.new(params[:house])\n @house.users_ids = current_user.id\n\n if @house.save\n redirect_to thanks_houses_url\n else\n render :new\n end\n\n end", "def join_group\n @assignment = Assignment.find(params[:id])\n @grouping = Grouping.find(params[:grouping_id])\n @user = Student.find(session[:uid])\n @user.join(@grouping.id)\n m_logger = MarkusLogger.instance\n m_logger.log(\"Student '#{@user.user_name}' joined group '#{@grouping.group.group_name}'\" +\n '(accepted invitation).')\n redirect_to action: 'student_interface', id: params[:id]\n end", "def create\n @user = User.new(user_params)\n # if params[:desk_id]\n # @desk = Desk.find(params[:desk_id])\n # elsif params[:organization_id]\n # @organization = Organization.find(params[:organization_id])\n # end\n respond_to do |format|\n if @user.save\n @show_modal = 'hide'\n set_users\n format.html { redirect_to users_path, notice: 'User was successfully created.' }\n format.js \n format.json { render action: 'show', status: :created, location: @user }\n else\n debugger\n @new_user = @user\n set_users\n @show_modal = 'show'\n format.js\n format.html { render action: 'index' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n login_user = User.find(session[:login_user_id])\n if login_user.target.present?\n return respond_to do |format|\n format.html { redirect_to login_user.target, notice: \"你只能关注一个人,你已经关注了#{login_user.target.wb_uid}了\" }\n format.json { render json: @target.errors, status: :bad_request }\n end\n end\n\n @target = Target.new(target_params)\n\n respond_to do |format|\n if @target.save\n format.html { redirect_to @target, notice: 'Target was successfully created.' }\n format.json { render :show, status: :created, location: @target }\n else\n format.html { render :new }\n format.json { render json: @target.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organisme = Organisme.find(params[:organisme_id])\n @employe = Employe.new(employe_params)\n if params[:add_education]\n @options = Organisme.order(\"name\").all.\n collect do |s|\n [s.name, s.id]\n end\n @employe.educations.build\n render :action => 'new'\n elsif params[:remove_education]\n @options = Organisme.order(\"name\").all.\n collect do |s|\n [s.name, s.id]\n end\n render :action => 'new'\n else\n respond_to do |format|\n if @employe.save\n #check if user exists already\n count = User.where(:email => @employe.courriel).count\n if count == 0\n User.create!({:email => @employe.courriel, :password => \"password\", :password_confirmation => \"password\", :superadmin_role => @employe.role == \"Directeur\", :supervisor_role => @employe.role == \"Coordonnateur\" || @employe.role == \"Intervenant\", :user_role => true})\n end\n @organisme = Organisme.find(params[:organisme_id])\n format.html { redirect_to @organisme, notice: 'Employe was successfully created.' }\n format.json { render :show, status: :created, location: @employe }\n else\n @options = Organisme.order(\"name\").all.\n collect do |s|\n [s.name, s.id]\n end\n format.html { render :new }\n format.json { render json: @employe.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def join\n @person = Person.find(params[:person_id])\n @group = Group.find(params[:id])\n begin\n @person.join_group(@group.id, session[:cookie])\n flash[:notice] = [ :you_have_joined_to_group, @group.title(session[:cookie]) ]\n rescue RestClient::RequestFailed => e\n flash[:error] = message_from_error(e)\n end\n redirect_to group_path(params[:id])\n end", "def enroll\n company = Company.find( params[:company_id])\n current_user_id = current_user( company.slug).id\n #user = User.find( current_user_id)\n course = Course.find( params[:id])\n if course.category == 1\n #public auto add user\n signup = course.course_signups.build\n signup.user_id = current_user_id\n signup.status = 1\n signup.save\n #course.users << user\n else\n #private set status to 1\n signup = course.course_signups.find_by_user_id( current_user_id)\n signup.status = 1\n signup.save\n end\n redirect_to company_trainings_path( company.slug)\n end", "def join\n unless @user && @kroog && @kroog.open? && current_actor.can_follow?\n flash[:warning] = \"Error: The specified circle does not exist or cannot be joined\".t\n respond_to do |format|\n format.html do\n redirect_to(:controller => 'kroogi', :action => 'join_circles', :id => params[:id])\n end\n format.js {render :update do |page|; page << 'document.location.reload(false);'; end}\n end\n return\n end\n\n # Add the relationship directly -- no invite intermediary\n Relationship.create_kroogi_relationship(:followed => @user.id, :follower => current_actor.id, :relationshiptype_id => @kroog.relationshiptype_id, :expires_at => Time.end, :skip_activity_message => true)\n\n flash[:success] = \"You have joined the %s circle of %s\" / [@user.circle_name(params[:circle].to_i), @user.login]\n PublicQuestionHelper::set_question_artist_id(@user, self, :force_show => true)\n respond_to do |wants|\n wants.html do\n redirect_to user_url_for(@user)\n end\n wants.js {}\n end\n end", "def create\n respond_to do |format|\n begin\n if params[\"skills_user\"][\"user_id\"]\n skill_id = params[\"skills_user\"][\"skill_id\"]\n user_ids = params[\"skills_user\"][\"user_id\"].reject{ |c| c.empty? }\n user_ids.each do |user_id|\n SkillsUser.create(skill_id: skill_id, user_id: user_id)\n end\n format.html { redirect_to skills_users_path, notice: 'Skills user was successfully created.' }\n end\n rescue\n format.html { render :new }\n format.json { render json: @skills_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def join\n @club = Club.find(params[:id])\n authorize @club\n @club.club_memberships.create! user_id: current_user.id\n redirect_to action: :show\n end", "def create\n @attorney = Attorney.new(attorney_params)\n respond_to do |format|\n if @attorney.save\n @attorney.user_id = current_user.id\n current_user.email = (attorney_params)[:email]\n current_user.password = (attorney_params)[:password]\n current_user.role = params[:role].to_i\n current_user.image = (attorney_params)[:profile_image]\n current_user.first_name = (attorney_params)[:first_name]+\" \"+(attorney_params)[:middle_name]+\" \"+(attorney_params)[:last_name]\n current_user.save\n @attorney.save\n sign_in(current_user, :bypass => true)\n format.html { redirect_to attorneys_path, notice: 'Attorney was successfully created.' }\n format.json { render :show, status: :created, location: @attorney }\n else\n format.html { render :new }\n format.json { render json: @attorney.errors, status: :unprocessable_entity }\n end\n end\n end", "def join\n\t\t@classroom = Classroom.find(params[:id])\n\n\t\tparams[:user_id] = current_user.id unless admin? && params[:user_id]\n\n\t\t@membership = Membership.new\n\t\t@membership.classroom_id = @classroom.id\n\t\t@membership.user_id = params[:user_id]\n\t\tif @membership.save\n\t\t\tredirect_to params[:redirect_url] || @classroom, notice: \"Joined!\"\n\t\telse\n\t\t\tredirect_to @classroom, alert: \"You are already a member of this class!\"\n\t\tend\n\tend", "def user_details\n @user = current_user\n invitation = @user.invitation\n if invitation.present?\n solo_restaurant_name = invitation.restaurant_id ? \n Restaurant.find(invitation.restaurant_id).name :\n invitation.restaurant_name\n @user.build_default_employment(:solo_restaurant_name => solo_restaurant_name, \n :restaurant_role => invitation.restaurant_role, :subject_matters => invitation.subject_matters)\n else\n @user.build_default_employment\n end\n @user.build_profile\n end", "def create\n @hail = current_user.hails.new(hail_params)\n\n respond_to do |format|\n if @hail.save\n format.json { render :show, status: :created, location: @hail }\n else\n format.json { render json: @hail.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n user = User.new params.require(:user).permit(:email, :full_name, :password, :password_confirmation, :invite)\n \n user.should_validate_invite!\n user.should_validate_name!\n \n if user.valid?\n \n if user.invite.data && user.invite.data[:email] == user.email\n # Activate and login\n # \n user.save!\n\n if user.invite.owner.instance_of?(Company)\n user.invite.update(data: user.invite.data.merge({ user_id: user.id }) )\n else\n user.invite.destroy\n end\n \n warden.set_user(user, scope: :user)\n\n respond_to do |format|\n format.json { render json: { state: :login, previous_path: previous_path }}\n end\n else\n # Create activation token and send email\n # \n token = Token.create(\n name: :activation,\n data: { \n full_name: user.full_name,\n address: user.email,\n password_digest: user.password_digest,\n invite_id: user.invite.id\n }\n )\n\n ProfileMailer.activation_email(token).deliver\n SlackWebhooksWorker.perform_async(\n text: t('user.activities.started_to_sign_up', name: user.full_name, email: user.email)\n ) if should_perform_sidekiq_worker?\n\n respond_to do |format|\n format.json { render json: { state: :activation }}\n end\n end\n \n else\n respond_to do |format|\n format.json { render json: { errors: user.errors }, status: 403 }\n end\n end\n \n end", "def join\n @user = current_user\n @mess = Mess.find(params[:id])\n @mess_id = @mess.id\n @user.update_attributes(:mess_id => @mess_id)\n redirect_to @mess\n end", "def create\n # puts params.inspect\n # puts realtor_params.inspect\n\n @realtor = Realtor.new(realtor_params)\n\n if (current_user.user_type != 1 and params['create_by_admin'] == 0) || realtor_params[:user_id] == nil #We do not want admins to automatically bind created users to account.\n @realtor.user = current_user\n else\n @realtor.user = User.find(realtor_params[:user_id])\n end\n\n @realtorExists = Realtor.where('user_id': @realtor.user.id)\n\n # puts @realtor.user.inspect\n\n if @realtorExists.empty?\n\n respond_to do |format|\n if @realtor.save\n format.html { redirect_to @realtor, notice: 'Realtor was successfully created.' }\n format.json { render :show, status: :created, location: @realtor }\n\n @realtor.user.user_type = 2 # set user type to realtor after creation\n @realtor.user.save # save realtor to current user\n else\n format.html { render :new }\n format.json { render json: @realtor.errors, status: :unprocessable_entity }\n end\n end\n else\n respond_to do |format|\n format.html { redirect_to new_realtor_path, notice: 'Realtor account already exists for this user.' }\n format.json { head :no_content }\n end\n end\n\n end", "def users_idea_params\n params.require(:users_idea).permit(:user_id, :idea_id)\n end", "def create\n @user = User.new()\n @user.name = params[:name]\n @user.password = params[:password]\n @user.save\n\n @address = Address.new()\n @address.address1 = params[:address1]\n @address.address2 = params[:address2]\n @address.city = params[:city]\n @address.state = params[:state]\n @address.zip5 = params[:zip5]\n @address.phone = params[:phone]\n @address.user_id = @user.id\n @address.save\n\n @userdetail = UserDetail.new()\n @userdetail.fname = params[:fname]\n @userdetail.lname = params[:lname]\n @userdetail.email = params[:email]\n @userdetail.user_id = @user.id\n @userdetail.save\n \n Mailer.confirm().deliver\n\n respond_to do |format|\n if @user.save\n format.html { redirect_to user_sites_url, notice: \"User created\" }\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\n user = User.last\n session[:user_id] = user.id\n session[:id] = user.id\n\n @userdes = UserDetail.find_by_user_id(user.id)\n session[:admin] = @userdes.admin\n end", "def create\n @toon_skill_level = ToonSkillLevel.new(params[:toon_skill_level])\n @source = Source.find(:all, :conditions => [\"crafting_allowed = ?\", true], :order => \"description\", :select => \"id, description\")\n users_toon = Toon.find(:first, :conditions => [\"id = ?\", @toon_skill_level.toon_id], :select => \"id, user_id\").user_id == current_user[:id]\n respond_to do |format|\n if @toon_skill_level.save\n \n format.html { redirect_to(@toon_skill_level, :notice => 'Toon skill level was successfully created.') }\n format.xml { render :xml => @toon_skill_level, :status => :created, :location => @toon_skill_level }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @toon_skill_level.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @user_target = UserTarget.new(user_target_params)\n\n respond_to do |format|\n if @user_target.save\n format.html { redirect_to @user_target, notice: 'User target was successfully created.' }\n format.json { render action: 'show', status: :created, location: @user_target }\n else\n format.html { render action: 'new' }\n format.json { render json: @user_target.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6666518", "0.66353935", "0.64586884", "0.6028437", "0.5963533", "0.5916752", "0.57810825", "0.5778081", "0.57468504", "0.56878847", "0.5668315", "0.5657118", "0.56373066", "0.5594424", "0.55942625", "0.5583349", "0.5573002", "0.55658644", "0.5560405", "0.555374", "0.5538975", "0.5529755", "0.55246854", "0.5508618", "0.5494153", "0.5492138", "0.54895383", "0.54889846", "0.54848176", "0.54821014", "0.5459254", "0.5430153", "0.54222095", "0.5402331", "0.5402098", "0.5402098", "0.5401991", "0.5398497", "0.53717655", "0.5371016", "0.5370828", "0.5364548", "0.5360882", "0.5351888", "0.5350972", "0.5350438", "0.5344149", "0.53392375", "0.5330977", "0.5324194", "0.5322353", "0.5321599", "0.5316581", "0.53104717", "0.53081536", "0.53077364", "0.5300444", "0.5298835", "0.5296729", "0.52954054", "0.52929294", "0.5283398", "0.5270535", "0.52691597", "0.52623904", "0.5261074", "0.52608037", "0.52436966", "0.5241863", "0.523769", "0.52354586", "0.52280897", "0.5225309", "0.52232176", "0.52183366", "0.5218037", "0.5215022", "0.52132845", "0.5210418", "0.5203031", "0.51996636", "0.5199381", "0.5198468", "0.5197363", "0.51892185", "0.51871526", "0.5185968", "0.51834345", "0.51820105", "0.5176222", "0.5175608", "0.5172831", "0.5165951", "0.5165119", "0.5161088", "0.51563203", "0.5154974", "0.5152556", "0.515196", "0.514916" ]
0.6986184
0
PATCH/PUT /join_user_to_assistants/1 PATCH/PUT /join_user_to_assistants/1.json
def update respond_to do |format| if @join_user_to_assistant.update(join_user_to_assistant_params) format.html { redirect_to @join_user_to_assistant, notice: 'Join user to assistant was successfully updated.' } format.json { render :show, status: :ok, location: @join_user_to_assistant } else format.html { render :edit } format.json { render json: @join_user_to_assistant.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_join_user_to_assistant\n @join_user_to_assistant = JoinUserToAssistant.find(params[:id])\n end", "def update\n user = User.where(:invite_token => params[:id], :status => \"invitee\").first\n role = user.roles.first\n if current_user\n role.user_id = current_user.id\n role.join_crewhmanship_or_membership!\n role.save\n user.delete\n end\n redirect_to role.course, :notice => \"Ticket claimed successfully!\"\n end", "def join_user_to_assistant_params\n params.require(:join_user_to_assistant).permit(:cpfk_user_id, :cpfk_assistant_id)\n end", "def update\n @interested_user = InterestedUser.find(params[:id])\n\n respond_to do |format|\n if @interested_user.update_attributes(params[:interested_user])\n format.html { redirect_to @interested_user, :notice => 'Interested user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @interested_user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n # this action is not provided for partyroles\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 approve_join_request\n join_request = JoinRequest.find(params[:id])\n team = join_request.team\n # Only authorize the captain to do this\n if current_user.id == team.captain_id\n membership = Membership.create(\n team_id: join_request.team_id,\n user_id: join_request.user_id,\n admin: false\n )\n if membership.valid?\n join_request.destroy\n render json: {\n team: TeamSerializer.new(team),\n user: UserSerializer.new(current_user)\n }, status: :accepted\n else\n # invalid request\n render json: {\n message: \"Invalid request\",\n errors: membership.errors.full_messages\n }, status: :not_acceptable\n end\n else\n render json: { message: \"Only the captain is allowed to accept join requests\"}, status: :not_acceptable\n end\n end", "def join\n @user = current_user\n @mess = Mess.find(params[:id])\n @mess_id = @mess.id\n @user.update_attributes(:mess_id => @mess_id)\n redirect_to @mess\n end", "def update\n group_ids = params[:group_id]\n org_id = params[:organization_id]\n @user = User.find_by_id(params[:user_id])\n current_group_ids = @user.user_group_ids\n\n respond_to do |format|\n if @user.update_attributes(full_name: params[:full_name], abbreviation: params[:abbreviation], email: params[:email], status: params[:status], staff_number: params[:employee_id], career_path: params[:career_path])\n\n is_logged = !@user.previous_changes.blank?\n if current_group_ids != group_ids\n @user.user_group_ids = group_ids\n format.json { render json: @user }\n end\n else\n format.json { render json: @user.errors.messages, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(current_user.id)\n\n #Are we updating experience?\n if( params[:experience_update] )\n @user.experiences.destroy_all #Remove all previous experience.\n\n if( !params[:experience].nil? )\n params[:experience].each do | theatre_id, experience_types |\n experience_types.each do | experience_type_id, val|\n experience = Experience.create(\n theatre_id: theatre_id,\n experience_type_id: experience_type_id,\n user_id: @user.id\n )\n end\n end\n end\n\n end\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to request.referer , flash: { success: 'User was successfully updated.' } }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n flag = !params[:user][:fellow_flag].nil? ? true :false\n #raise flag.inspect\n respond_to do |format|\n if @user.update_attributes(params[:user])\n if flag\n @access = Accessability.find_or_create_by_user_id(@user.id)\n @access.role_1 = params[:user][:create_certificates_and_reports]\n @access.role_2 = params[:user][:signoff_certificates_and_reports]\n @access.role_3 = params[:user][:access_account_settings]\n @access.save\n end\n format.html { redirect_to(settings_path, :notice => 'User was successfully updated.') }\n format.xml { head :ok }\n else\n redirect_to settings_path\n end\n end\n end", "def update\n @support_request.handler = current_user\n @support_request.current_user = current_user\n respond_to do |format|\n if @support_request.update(support_request_edit_params)\n format.html { redirect_to agent_path(@support_request), notice: 'Support request was successfully updated.' }\n format.json { render :show, status: :ok, location: agent_path(@support_request) }\n else\n format.html { render :edit }\n format.json { render json: @support_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@auth_assign_permit = Auth::AssignPermit.find(params[:id])\n if current_user.admin_group?\n @admin_user = current_user\n @owner_user = User.find(params[:id])\n\n respond_to do |format|\n if @owner_user.update_attributes(params[:user])\n format.html { redirect_to auth_assign_permit_path(@owner_user), notice: 'Assign permit was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @auth_assign_permit.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n roles = params[:user].delete(:roles)\n if roles.present?\n roles.map! { |r| r.downcase }\n ['admin', 'staff'].each do |type|\n role = @user.roles.find_by(type: Role.types[type])\n if role && !roles.include?(type)\n role.destroy\n elsif !role && roles.include?(type)\n @user.roles << Role.new(type: type)\n end\n end\n end\n\n respond_to do |format|\n if @user.update(user_params)\n format.html do\n if request.referer == settings_url\n redirect_to :settings, notice: 'Saved.'\n else\n redirect_to :attendees, notice: 'User was successfully updated.'\n end\n end\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { redirect_to :back, alert: @user.errors.full_messages.first }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n respond_to do |format|\n if @user.update_attributes(params[:user])\n if @user.role == \"support\"\n format.html { redirect_to support_users_path, notice: 'Support Staff was successfully updated.' }\n format.json { render json: @user, status: :created, location: @user }\n elsif @user.role == \"supervisor\" \n format.html { redirect_to supervisor_users_path, notice: 'Supervisor was successfully updated.' }\n format.json { render json: @user, status: :created, location: @user }\n elsif @user.role == \"user\"\n format.html { redirect_to user_users_path, notice: 'User was successfully updated.' }\n format.json { render json: @user, status: :created, location: @user }\n end \n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @assist = Assist.find(params[:id])\n\n respond_to do |format|\n if @assist.update_attributes(params[:assist])\n format.html { redirect_to @assist, notice: 'Assist was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @assist.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n redirect_back fallback_location: root_path unless current_user_admin? || (@user.id == current_user.id)\n\n unless @user\n flash[:alert] = \"We can not find account\"\n return redirect_back fallback_location: root_path\n end\n\n respond_to do |format|\n if @user&.update(user_params)\n\n if @user.user_type == \"team\"\n unless @user.team\n @team = Team.find_by(name: @user.name)\n\n if @team\n return redirect_to should_join_team_path(@team)\n else\n @user.create_team\n end\n end\n end\n\n return redirect_to users_admins_path if current_user_admin?\n format.html { redirect_to events_path, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def new_invite\n if idea_posting.users.exists?(current_user.id)\n @joinrequest = Joinrequest.new\n respond_to do |format|\n format.html \n format.json {redirect_to @joinrequest}\n end\n end\n end", "def invite\n @meal = Meal.find(params[:meal_id])\n authorize @meal, :update?\n @user = if params[:user_id]\n User.find(params[:user_id])\n else\n User.find_by(name: params[:user_name])\n end\n @meal.invite_user @user\n redirect_to @meal\n end", "def update\n #puts \"@params[:gym]: #{params[:user][:gym]}\"\n #@gym = Gym.find(params[:user][:gym])\n\n redirect_to edit_user_path(current_user) if @user != current_user\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to challenges_path, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @join_user_to_assistants = JoinUserToAssistant.all\n end", "def update\n @person.authorizer = current_person\n\n respond_to do |format|\n if @person.update(person_params)\n @person.invite!(current_person) if params['resend_invite']=='true' \n \n format.html { redirect_to :people, notice: 'Profile successfully updated.' }\n format.json { render :show, status: :ok, location: @person }\n else\n format.html { render :edit }\n format.json { render json: @person.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @maintain_invite_user = Maintain::InviteUser.find(params[:id])\n\n respond_to do |format|\n if @maintain_invite_user.update_attributes(params[:maintain_invite_user])\n format.html { redirect_to @maintain_invite_user, notice: 'Invite user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @maintain_invite_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_member\n # render :text => params\n @company = current_user.company\n # @user.type_id = params[:user_type_id]\n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { \n @agencies = @company.agencies\n flash[:alert] = @user.errors.full_messages.join(\"<br>\")\n render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:meetup])\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n super\n if resource.role == 'employer'\n @employer = resource.employer.update(employer_params)\n elsif resource.role == 'employee'\n @employee = resource.employee.update(employee_params)\n end\n end", "def update\n @user_has_credibility = UserHasCredibility.find(params[:id])\n\n respond_to do |format|\n if @user_has_credibility.update_attributes(params[:user_has_credibility])\n format.html { redirect_to @user_has_credibility, notice: 'User has credibility was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_has_credibility.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person_type_masters = PersonTypeMaster.all\n @user = User.find_by_person_id(params[:id])\n logger.info \"The selected user -s #{@user.inspect}\"\n respond_to do |format|\n if @person_info.update(person_info_params)\n format.js { flash.now[:notice] = \"Personnel was successfully updated.\" }\n format.html { redirect_to current_user, notice: 'Person info was successfully updated.' }\n format.json { render :show, status: :ok, location: @person_info }\n else\n @person_type_masters = PersonTypeMaster.all\n format.js {render :edit}\n format.html { render :edit }\n format.json { render json: @person_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @join_user_to_assistant = JoinUserToAssistant.new(join_user_to_assistant_params)\n\n respond_to do |format|\n if @join_user_to_assistant.save\n format.html { redirect_to @join_user_to_assistant, notice: 'Join user to assistant was successfully created.' }\n format.json { render :show, status: :created, location: @join_user_to_assistant }\n else\n format.html { render :new }\n format.json { render json: @join_user_to_assistant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @talk = Talk.find(params[:id])\n @new_user = User.find_by_email(params[:talk][:new_user])\n\n\n respond_to do |format|\n if @talk.update_attributes(params[:talk], :as => (admin? || @talk.user == current_user) ? :admin : :default)\n # Change to be set on e-mail request insted of directly from edit form\n if @new_user\n @talk.users << @new_user\n @talk.save\n end\n\n format.html { redirect_to :back, notice: \"Talk was successfully updated.\" }\n format.json { head :no_content }\n format.js {\n render \"update\",\n :locals => {\n :id => params[:id],\n :talk => @talk\n }\n }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @talk.errors, status: :unprocessable_entity, notice: 'Failed' }\n end\n end\n end", "def update\n respond_to do |format|\n if params[\"grade_pref\"]\n @user.grade_pref = params[\"grade_pref\"]\n end\n if params[\"location_pref\"]\n @user.location_pref = params[\"location_pref\"]\n end\n if params[\"licenses\"]\n @user.licenses.destroy_all\n params[\"licenses\"].each do |lic|\n next if lic == \"\"\n @user.licenses << License.find_by(name: lic)\n end\n end\n if params[\"add-licenses\"]\n more_licenses = params[\"add-licenses\"].split(\",\").map(&:strip)\n more_licenses.each do |lic|\n name = lic.split(\" \").map do |word| word.downcase.capitalize end.join(\" \")\n\n @user.licenses << License.find_or_create_by(name: name)\n end\n end\n #save positions\n if params[\"positions\"]\n @user.positions.destroy_all\n params[\"positions\"].each do |pos|\n next if pos == \"\"\n @user.positions << Position.find_or_create_by(title: pos)\n end\n end\n if params[\"add-positions\"]\n more_positions = params[\"add-positions\"].split(\",\").map(&:strip)\n more_positions.each do |pos|\n title = pos.split(\" \").map do |word| word.downcase.capitalize end.join(\" \")\n\n @user.positions << Position.find_or_create_by(title: title)\n end\n end\n #save endorsements\n if params[\"endorses\"]\n @user.endorsements.destroy_all\n params[\"endorses\"].each do |endo|\n next if endo == \"\"\n @user.endorsements << Endorsement.find_by(name: endo)\n end\n end\n if params[\"add-endorses\"]\n more_endorses = params[\"add-endorses\"].split(\",\").map(&:strip)\n more_endorses.each do |endo|\n name = endo.split(\" \").map do |word| word.downcase.capitalize end.join(\" \")\n\n @user.endorsements << Endorsement.find_or_create_by(name: name)\n end\n end\n #save subjects\n if params[\"subs\"]\n @user.subjects.destroy_all\n params[\"subs\"].each do |sub|\n next if sub == \"\"\n @user.subjects << Subject.find_by(subject: sub)\n end\n end\n if params[\"add-subs\"]\n more_subs = params[\"add-subs\"].split(\",\").map(&:strip)\n more_subs.each do |sub|\n subject = sub.split(\" \").map do |word| word.downcase.capitalize end.join(\" \")\n\n @user.subjects << Subject.find_or_create_by(subject: subject)\n end\n end\n if params[\"add-language\"]\n more_subs = params[\"add-language\"].split(\",\").map(&:strip)\n more_subs.each do |sub|\n subject = sub.split(\" \").map do |word| word.downcase.capitalize end.join(\" \")\n\n @user.subjects << Subject.find_or_create_by(subject: subject)\n end\n end\n #save organizations\n if params[\"orgs\"]\n @user.organizations.destroy_all\n params[\"orgs\"].each do |org|\n next if org == \"\"\n @user.organizations << Organization.find_by(name: org)\n end\n end\n if params[\"add-orgs\"]\n more_orgs = params[\"add-orgs\"].split(\",\").map(&:strip)\n more_orgs.each do |org|\n name = org.split(\" \").map do |word| word.downcase.capitalize end.join(\" \")\n\n @user.organizations << Organization.find_or_create_by(name: name)\n end\n end\n #save references\n if params[\"sources\"]\n @user.sources.destroy_all\n params[\"sources\"].each do |source|\n next if source == \"\"\n @user.sources << Source.find_or_create_by(source_name: source)\n end\n end\n if params['add-sources']\n more_sources = params['add-sources'].split(',').map(&:strip)\n more_sources.each do |source|\n source_name = source.split(' ').map do |word| word.downcase.capitalize end.join(' ')\n @user.sources << Sources.find_or_create_by(source_name: source_name)\n end\n end\n if params[\"add-flyer\"]\n more_sources = params[\"add-flyer\"].split(\",\").map(&:strip)\n more_sources.each do |source|\n source_name = source.split(\" \").map do |word| word.downcase.capitalize end.join(\" \")\n\n @user.sources << Source.find_or_create_by(source_name: source_name)\n end\n end\n if params[\"add-college\"]\n more_sources = params[\"add-college\"].split(\",\").map(&:strip)\n more_sources.each do |source|\n source_name = source.split(\" \").map do |word| word.downcase.capitalize end.join(\" \")\n\n @user.sources << Source.find_or_create_by(source_name: source_name)\n end\n end\n if params[\"grade_pref\"]\n @user.grade_pref = params[\"grade_pref\"]\n end\n if params[\"location_pref\"]\n @user.location_pref = params[\"location_pref\"]\n end\n if @user.update(user_params)\n format.html { redirect_to @user, notice: 'Your profile was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if params[:user_goal_id] && params[user_id]\n goals = @user.update!(user_goal_params)\n render json: goals, status: :accepted\n end\n end", "def update\n respond_to do |format|\n if !params[:roles].include?('president') && @member.has_role?(:president) && !Tenant.current.has_presidents\n format.html { redirect_to member_path(@member), notice: 'Please select other user as President.' }\n elsif @member.update(member_params)\n remove_roles\n add_roles(params[:roles])\n format.html { redirect_to member_path(@member), notice: 'Member was successfully updated.' }\n format.json { render :show, status: :ok, location: @member }\n else\n format.html { render :edit }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n load_user\n build_user\n assign_roles\n save_user or render :edit\n end", "def update\n respond_to do |format|\n if @joined.update(joined_params)\n format.html { redirect_to @joined, notice: 'Joined was successfully updated.' }\n format.json { render :show, status: :ok, location: @joined }\n else\n format.html { render :edit }\n format.json { render json: @joined.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @person_infos = PersonInfo.select(\"surname, other_names\")\n respond_to do |format|\n if @provider_engaged_user.update(provider_engaged_user_params)\n format.html { redirect_to @provider_engaged_user, notice: 'Provider engaged user was successfully updated.' }\n format.json { render :show, status: :ok, location: @provider_engaged_user }\n else\n format.html { render :edit }\n format.json { render json: @provider_engaged_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @entrepreneur = Entrepreneur.find(params[:id])\n @user = User.find(@entrepreneur.user_id)\n\n if @user.update_attributes(params[:user]) \n respond_to do |format|\n if @entrepreneur.update_attributes(params[:entrepreneur])\n format.html { redirect_to @entrepreneur, :notice => 'Entrepreneur was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @entrepreneur.errors, :status => :unprocessable_entity }\n end\n end\n end\n end", "def populate_judge_team_for_testing(judge_team, judge_user, attorneys)\n judge_team.users << judge_user\n attorneys.each do |u|\n judge_team.users << u\n end\n judge_orguser = OrganizationsUser.existing_record(judge_user, judge_team)\n judge_orguser.update!(admin: true)\n end", "def update\n @user = current_user\n @user.role = 'client'\n \n respond_to do |format|\n if @user.update(user_params)\n format.html { redirect_to @user, flash[:success] => \"User was successfully updated\" }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @userin = UserInvestor.find(params[:id])\n update_userin = @userin.update(userin_params)\n if update_userin\n render json: { status: 'OK', results: update_userin, errors: nil },\n status: :ok\n else\n render json: { status: 'FAIL', results: nil,\n errors: 'update user failed' },\n status: :unprocesable_entity\n end\n end", "def update\n respond_to do |format|\n if @user.update(user_params)\n members = Member.all\n available = false\n members.each do |current_member|\n if current_member.user_id == @user.id\n available = true\n end\n end\n if available == false && @user.role != TEACHER\n @member = Member.new\n @member.user_id = @user.id\n @member.project_id = session[:selected_project_id]\n @member.is_enabled = true\n @member.section_number = params['section_number']\n @member.save\n end\n if @user.role != TEACHER\n member = Member.find_by(user_id: @user.id, project_id: get_selected_project)\n member.section_number = params['section_number']\n member.save\n end\n \n if @user.role == TEACHER\n format.html { redirect_to users_teachers_path, notice: \"#{@user.first_name} was successfully updated.\"}\n else\n format.html { redirect_to users_path, notice: \"#{@user.first_name} was successfully updated.\"}\n format.json { head :no_content }\n end\n else\n format.html { render action: 'edit' }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n@users = User.all.order(nombre1: :asc)\n if params[:teaching][:user_ids]\n params[:teaching][:user_ids] = params[:teaching][:user_ids].map{|k, v| k}\n else\n params[:teaching][:user_ids] = []\n end\n \n respond_to do |format|\n if @teaching.update(teaching_params)\n format.html { redirect_to @teaching, notice: 'La actividad se actualizo con exito.' }\n format.json { render :show, status: :ok, location: @teaching }\n else\n format.html { render :edit }\n format.json { render json: @teaching.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def update\n respond_to do |format|\n if @user.update_attributes(user_params)\n if @user.role == \"instructor\"\n format.html { redirect_to(@user.instructor, :notice => \"Successfully updated #{@user.username}.\") }\n end\n if @user.role == \"parent\"\n format.html { redirect_to(@user.family, :notice => \"Successfully updated #{@user.username}.\") }\n end\n if @user.role == \"admin\"\n format.html { redirect_to(home_path, :notice => \"Successfully updated #{@user.username}.\") }\n end\n format.json { respond_with_bip(@user) }\n else\n format.html { render :action => \"edit\" }\n format.json { respond_with_bip(@user) }\n end\n end\n end", "def update\n @user = current_org.users.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to @user, notice: 'user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def updatestatus\n\n # other user\n @relationship = Relationship.find(params[:id])\n status = params[:relationship][:status]\n \n # create relationship\n if current_user.id == @relationship.follower_id \n\n @relationship.status = status\n @relationship.save\n @user = User.find(@relationship.followed_id)\n if status == \"FOLLOWING\" || status == \"REQUEST\"\n @user.update_attributes!(:notify => \"YES\")\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json=> { \n :user=>@user.as_json(:only => [:id, :name, :tender, :invitation_token, :notify, :privateprofile], :methods => [:photo_url],\n :include => { \n :drinks => { :only => [:id, :name] },\n :workvenues => { :only => [:id, :fs_venue_id, :name] }\n }\n ) \n } }\n end\n end\n end", "def update\n @user = @person.user \n can_manage_user!\n\n [:password, :password_confirmation].each do |password_key|\n params[:user].delete(password_key) if params[:user][password_key].blank?\n end\n\n # user.role\n if can? :assign_roles, User\n @user.role = params[:user][:role]\n elsif can_only_manage_crew_roles\n role = params[:user][:role] \n @user.role = role if User::USER_ROLES.include? role\n end\n params[:user].delete(:role)\n\n # user.conference_users\n if can_only_manage_crew_roles and params[:user][:conference_users_attributes].present?\n filter_conference_users(params[:user][:conference_users_attributes])\n end\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to(person_user_path(@person), notice: 'User was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @detailed_user.update(detailed_user_params)\n user = User.find_by_id(@detailed_user.user_id)\n user.detailedUsers = true\n user.save\n format.html { redirect_to user_dashboard_path, notice: 'Detailed user was successfully updated.' }\n format.json { render :show, status: :ok, location: @detailed_user }\n else\n format.html { render :edit }\n format.json { render json: @detailed_user.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 @user_situation.update(user_situation_params)\n format.html { redirect_to @user_situation, notice: 'User situation was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_situation }\n else\n format.html { render :edit }\n format.json { render json: @user_situation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_target.update(user_target_params)\n format.html { redirect_to @user_target, notice: 'User target was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @user_target.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, WorkingExperience, :message => 'Not authorized as an administrator.'\n @user = User.find(params[:user_id])\n @working_experience = @user.working_experiences.find(params[:id])\n\n respond_to do |format|\n if @working_experience.update_attributes(params[:working_experience])\n format.html { redirect_to user_working_experiences_path, notice: 'Working experience was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @working_experience.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @users_support = User.all.select { |u| u.role != 'user' }\n if current_user.role != 'user'\n @bug_ticket.bug_ticket_users.clear\n params[:users][:id].each do |user|\n @bug_ticket.bug_ticket_users.build(user_id: user) unless user.empty?\n end\n end\n respond_to do |format|\n if @bug_ticket.update(bug_ticket_params)\n format.html { redirect_to @bug_ticket, notice: 'Bug ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @bug_ticket }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bug_ticket.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user.update(user_params)\n unless session[:user_is_admin?]\n session[:user_skill_ids] = params[:skill_ids].nil? ? nil : params[:skill_ids].map{ |elem| elem.to_i }\n session[:user_email] = params[:user_email]\n end\n LocationsSkillsUsers.update(@user.id, @user.location_id, params[:skill_ids]) if params[:skill_ids]\n\n format.html { redirect_to @user, notice: 'User was successfully updated.' }\n format.json { render :show, status: :ok, location: @user }\n else\n format.html { render :edit }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @support.update(user_params)\n format.html { redirect_to supports_url, notice: 'Agent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @support.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @he = He.find(params[:id])\n if current_user.district_id and !current_user.admin?\n district = District.find(current_user.district_id)\n @centers = district.centers\n else\n @centers = Center.all\n end\n @chiefs = User.find_all_by_user_type(1)\n @nurses = User.find_all_by_user_type(2)\n respond_to do |format|\n if @he.update_attributes(params[:he])\n format.html { redirect_to @he, notice: t(:record_updated) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @he.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_responsibility.update(user_responsibility_params)\n format.html { redirect_to @user_responsibility, notice: \"User responsibility was successfully updated.\" }\n format.json { render :show, status: :ok, location: @user_responsibility }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @user_responsibility.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_captain_and_eligibility(*)\n reload # SQL caching causing users to be empty when creating team making all teams ineligible\n set_team_captain\n update_eligibility\n end", "def update\n\n @gradework.users = []\n\n if params.has_key?(:students) and params[:students] != [\"\"]\n students = params[:students]\n @gradework.users << User.find(students)\n end\n\n if params.has_key?(:juries) and params[:juries] != [\"\"]\n juries = params[:juries]\n @gradework.users << User.find(juries)\n end\n\n if params.has_key?(:directors) and params[:directors] =! \"\"\n directors = params[:directors]\n @gradework.users << User.find(directors)\n end\n\n respond_to do |format|\n if @gradework.update(gradework_params)\n format.html { redirect_to @gradework, notice: 'La tesis se modificó correctamente' }\n format.json { render :show, status: :ok, location: @gradework }\n else\n format.html { redirect_to @gradework, notice: 'La tesis no se modificó correctamente' }\n #format.html { render :edit }\n format.json { render json: @gradework.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @gradework.users = []\n\n if params.has_key?(:students) and params[:students] != [\"\"]\n students = params[:students]\n @gradework.users << User.find(students)\n end\n\n if params.has_key?(:juries) and params[:juries] != [\"\"]\n juries = params[:juries]\n @gradework.users << User.find(juries)\n end\n\n if params.has_key?(:directors) and params[:directors] =! \"\"\n directors = params[:directors]\n @gradework.users << User.find(directors)\n end\n\n respond_to do |format|\n if @gradework.update(gradework_params)\n format.html { redirect_to @gradework, notice: 'La tesis se modificó correctamente' }\n format.json { render :show, status: :ok, location: @gradework }\n else\n format.html { redirect_to @gradework, notice: 'La tesis no se modificó correctamente' }\n #format.html { render :edit }\n format.json { render json: @gradework.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @guide_post = GuidePost.find(params[:id])\n @rivers = River.all\n interested_users = TripsToUser.find_all_by_post_id(params[:id])\n @interested_user_count = interested_users.count()\n @users = []\n interested_users.each do |u|\n @users.push(User.find_by_id(u.user_who_agreed_id))\n end\n\n respond_to do |format|\n if @guide_post.update_attributes(params[:guide_post])\n format.html { redirect_to @guide_post, notice: 'Guide post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @guide_post.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n # @personnel.first_name = params[\"first_name\"]\n # @personnel.last_name = params[\"last_name\"]\n # @personnel.phone_number = params[\"phone_number\"]\n # @personnel.title = params[\"title\"]\n # @personnel.email = params[\"email\"]\n\n respond_to do |format|\n if @personnel.update(personnel_params)\n @personnel.user_roles.update(:role_id => params[\"role_id\"][\"user_role_id\"])\n format.html { redirect_to personnel_path(@personnel), notice: 'Personnel was successfully updated.' }\n format.json { render :show, status: :ok, location: @personnel }\n else\n format.html { render :edit }\n format.json { render json: @personnel.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @grant = Grant.find(params[:id])\n\n respond_to do |format|\n if @grant.update_attributes(params[:grant])\n format.html { redirect_to root_url, notice: 'Training was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @grant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n # @user = User.find(params[:id])\n # merge default value with params so if no collaborators checked, will erase\n if @user.update_attributes(user_params)\n redirect_to blogs_path\n else\n flash[:error] = \"Error saving user. Please try again. #{@user.errors.full_messages.first}.\"\n render :edit\n end\n end", "def update\n@users = User.all.order(nombre1: :asc)\n if params[:research][:user_ids]\n params[:research][:user_ids] = params[:research][:user_ids].map{|k, v| k}\n else\n params[:research][:user_ids] = []\n end\n \n respond_to do |format|\n if @research.update(research_params)\n format.html { redirect_to @research, notice: 'La actividad se actualizo con exito.' }\n format.json { render :show, status: :ok, location: @research }\n else\n format.html { render :edit }\n format.json { render json: @research.errors, status: :unprocessable_entity }\n end\n end\n\n end", "def update\n respond_to do |format|\n if @guidances_user.update(guidances_user_params)\n format.html { redirect_to @guidances_user, notice: '更新されました' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @guidances_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n params[:user][:roles].reject!(&:blank?)\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to users_url, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if params[:user][:password].blank?\n params[:user].delete(\"password\")\n params[:user].delete(\"password_confirmation\")\n end\n\n @user = User.find(params[:id])\n @user.roles = [params[:role]]\n respond_to do |format|\n if @user.update_attributes(user_params)\n User.user_organizations_associations(@user, params)\n format.html { redirect_to privileges_path, notice: 'User was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n # if @user.update_attributes(params[:user])\n # redirect_to privileges_path\n # end\n # @user = User.find(params[:id])\n # params[:user].delete(:current_password)\n # @user.update_without_password(params[:user])\n # redirect_to privileges_path\n # respond_to do |format|\n # if @user.update_attributes(params[:user])\n # format.html { redirect_to privileges_path, notice: 'User was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render action: \"edit\" }\n # format.json { render json: @user.errors, status: :unprocessable_entity }\n # end\n # end\n end", "def update\n @user = User.find(params[:id])\n authorize @user\n @departments = @user.org.departments.order(:name)\n @plans = Plan.active(@user).page(1)\n # See if the user selected a new Org via the Org Lookup and\n # convert it into an Org\n attrs = user_params\n lookup = org_from_params(params_in: attrs)\n identifiers = identifiers_from_params(params_in: attrs)\n\n # Remove the extraneous Org Selector hidden fields\n attrs = remove_org_selection_params(params_in: attrs)\n\n if @user.update(attrs)\n # If its a new Org create it\n if lookup.present? && lookup.new_record?\n lookup.save\n identifiers.each do |identifier|\n identifier.identifiable = lookup\n identifier.save\n end\n lookup.reload\n end\n @user.update(org_id: lookup.id) if lookup.present?\n\n flash.now[:notice] = success_message(@user, _('updated'))\n else\n flash.now[:alert] = failure_message(@user, _('update'))\n end\n render :edit\n end", "def update\n @user = User.find_by_slug(params[:id])\n # @wiki = Wiki.find(params[:id])\n # merge default value with params so if no collaborators checked, will erase\n if @user.update_attributes(params[:user])\n redirect_to @user\n else\n flash[:error] = \"Error saving user. Please try again.\"\n render :edit\n end\n end", "def update\n if !grant_access(\"alter_roles\", current_user)\n head(403)\n end\n @role.user_id = current_user.id\n @role.start_point = false if !params[:role][:start_point]\n respond_to do |format|\n if @role.update(role_params)\n format.html { redirect_to @role, notice: 'Role was successfully updated.' }\n format.json { render :show, status: :ok, location: @role }\n else\n format.html { render :edit }\n format.json { render json: @role.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n self.params[:user_submit][:user_answers_attributes].each do |key,value|\n params[:user_submit][:user_answers_attributes][key] = params[:user_submit][:user_answers_attributes][key].merge(:user_id => current_user.id)\n end\n @user_submit = UserSubmit.find(params[:id])\n @user_submit.update_attributes(params[:user_submit])\n @user_submit.user = current_user\n #@user_submit.exam_id = @examid\n respond_to do |format|\n @user_submit.locked = 1\n @user_submit.grade = @user_submit.exam.calc_grade(@user_submit)\n if @user_submit.save\n @user_submit.exam.locked = 1\n @user_submit.exam.save\n @user_submit.exam.questions.each do |useq|\n useq.locked = 1\n useq.answers.each do |uqa|\n uqa.locked = 1\n uqa.save\n end\n end\n \n format.html { redirect_to exams_url, notice: 'User submit was successfully created.' }\n format.json { render json: @user_submit, status: :created, location: @user_submit }\n else\n #format.html { render action: \"new\" }\n format.json { render json: @user_submit.errors, status: :unprocessable_entity }\n format.html { redirect_to exams_url, notice: 'NOTICE! You may only submit answers for this exam once. See your instructor for permission to re-take the exam.' }\n end\n end\n end", "def update\n admin_only\n\n new_tutor_ids_plus_deletion = []\n unless params[:subject][:people_teaching_attributes].blank?\n params[:subject][:people_teaching_attributes].each do |attribute|\n if attribute[1][:incoming_tutor_id].nil?\n id = attribute[1][:id]\n else\n id = attribute[1][:incoming_tutor_id]\n end\n destroy = attribute[1][:_destroy]\n new_tutor_ids_plus_deletion << [id, destroy]\n end\n end\n\n respond_to do |format|\n if @subject.update(subject_params)\n\n unless new_tutor_ids_plus_deletion == []\n new_tutor_ids_plus_deletion.each do |pair|\n if pair[1] == \"1\" #that means we should delete this one...\n e = ProvidingEnrollment.find_by_user_id_and_subject_id(pair[0], @subject.id)\n begin\n e.destroy!\n rescue\n puts 'Looks like that user was added and removed in one go...'\n end\n else #that means we should make a new one if it doesn't already exist...\n if ProvidingEnrollment.find_by_user_id_and_subject_id(pair[0], @subject.id).nil?\n e = ProvidingEnrollment.new\n e.user_id = pair[0]\n e.subject_id = @subject.id\n e.save!\n end\n end\n end\n end\n\n format.html { redirect_to @subject, notice: 'Subject was successfully updated.' }\n format.json { render :show, status: :ok, location: @subject }\n else\n format.html { render :edit }\n format.json { render json: @subject.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @support_request.handler = current_user\n @support_request.current_user = current_user\n respond_to do |format|\n if @support_request.update(support_request_params)\n format.html { redirect_to @support_request, notice: 'Support request was successfully updated.' }\n format.json { render :show, status: :ok, location: @support_request }\n else\n format.html { render :edit }\n format.json { render json: @support_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @office_target_collaboration.update(office_target_collaboration_params)\n format.html { redirect_to @office_target_collaboration, notice: 'Office target collaboration was successfully updated.' }\n format.json { render :show, status: :ok, location: @office_target_collaboration }\n else\n format.html { render :edit }\n format.json { render json: @office_target_collaboration.errors, status: :unprocessable_entity }\n end\n end\n end", "def join\n @event = Event.find(params[:event_id])\n @e = @event.user_to_events.build(:user_id => current_user.id,\n :event_id => \"#{@event.id}\",\n :owner_id => \"#{@event.user_id}\" )\n\n respond_to do |format|\n if @e.save\n @total_attendence = UserToEvent.find(\"#{@e.id}\").event.update_attributes(:no_of_guests_attending => (@event.no_of_guests_attending)+1)\n format.html { redirect_to(@event, :notice => 'Request has been sent to the meal owner.') }\n format.xml { head :ok }\n else\n format.html { redirect_to(event_path(@event), :notice => 'Something has gone wrong , please try again.') }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n #format.html { redirect_to [@user.apartamento.residencial, @user.apartamento, @user], notice: 'User foi atualiazado com sucesso.' }\n format.html { redirect_to edit_residencial_apartamento_user_path(@user.apartamento.residencial, @user.apartamento, @user), notice: 'User foi atualiazado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @student = Student.find(params[:id])\n\n respond_to do |format|\n if @student.update_attributes(params[:student]) &&\n @student.user.update_attributes({:role_pending => params[:role_pending]})\n\n format.html { redirect_to @student, notice: 'Student was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @student.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @colony_ant.update(colony_ant_params)\n format.html { redirect_to @colony_ant, notice: 'Colony ant was successfully updated.' }\n format.json { render :show, status: :ok, location: @colony_ant }\n else\n format.html { render :edit }\n format.json { render json: @colony_ant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @user = User.find(current_user.id)\n\n # if they have no interests, make interest_ids = empty array\n # otherwise it'll automatically save with one interest\n if user_params[:interest_ids].nil?\n @user.update(interest_ids: [])\n end\n @user.update(user_params)\n # save_friendships\n redirect_to profiles_path\n end", "def update\n @leave_request = LeaveRequest.find(params[:id])\n respond_to do |format|\n if @leave_request.update(leave_request_params)\n UserAudit.create({:user => current_user, :action => \"updated leave request\", :end_user => @leave_request.user.email})\n format.html { redirect_to @leave_request, notice: 'Leave request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @leave_request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @applicant.update(applicant_params)\n update_skills\n format.html { redirect_to @applicant, notice: 'Applicant was successfully updated.' }\n format.json { render :show, status: :ok, location: @applicant }\n else\n format.html { render :edit }\n format.json { render json: @applicant.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @teams = Team.order(:name)\n @user = User.find(params[:id])\n\n respond_to do |format|\n if @user.update_attributes(params[:user])\n format.html { redirect_to \"/retrospectives\", notice: \"Your profile was succesfully updated!\" }\n else\n format.html { render action: \"edit\" }\n end\n end\n end", "def update\n render json: User.update(params[\"id\"], params[\"user\"])\n end", "def update\n @screen = session.active_screen\n @form_content_reuse = params[:form_content_reuse]\n \n @role = Role.find(params[:id]) \n @role.user_ids.each{|u_id| User.find(u_id).update_attributes( :updated_at => Time.now ) }\n @role.users.clear\n @role.users = User.find(params[:role][:user_ids]) unless params[:role][:user_ids].nil?\n @role.user_ids.each{|u_id| User.find(u_id).update_attributes( :updated_at => Time.now ) }\n \n @role.update_attributes(params[:role])\n\n respond_to do |format|\n format.html # create.html.erb\n format.xml { render :xml => @role }\n end\n end", "def edit\n @user = User.find_by_id(params[:id])\n @goal = Goal.find_by_id(params[:goal_id])\n end", "def update\n return_path = params[:return_path]\n \n @user.reset_password if params[:reset_credentials]\n \n if params.has_key?(:multiselect_user_grouping_ids) && (return_path.to_s == users_path.to_s) && @user.update_attributes(params[:user]) \n @user.update_roles(params[:user][:role_ids]) if params.has_key?(:multiselect_user_role_ids)\n @user.update_groupings(params[:user][:grouping_ids])\n gflash :success => \"Profile updated.\"\n redirect_to users_path\n elsif (return_path.to_s != users_path.to_s) && @user.update_attributes(params[:user])\n gflash :success => \"Profile updated.\"\n redirect_to :back\n else\n @user.errors[:base] << \"You must assign the user to one or more groups.\" unless params[:user][:grouping_ids]\n @return_path = return_path\n respond_with(@user)\n end\n \n end", "def update\n if params[:users]\n user_ids = params[:users].keys\n user_ids.each do |id|\n @jam_circle.users << User.find(id)\n end\n end\n respond_to do |format|\n if @jam_circle.update(jam_circle_params)\n format.html { redirect_to @jam_circle }\n format.json { render :show, status: :ok, location: @jam_circle }\n else\n format.html { render :edit }\n format.json { render json: @jam_circle.errors, status: :unprocessable_entity }\n end\n end\n end", "def actions_relationship\n manager_id = params[:data]\n user_id = params[:user_id]\n message = params[:message]\n\n if message.eql?\"edit\"\n @user = User.find(user_id)\n respond_to do |format|\n if @user.update_attributes(team_leader_id: manager_id)\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity}\n end\n end\n elsif message.eql?\"remove\"\n @user = User.find(user_id)\n respond_to do |format|\n if @user.update_attributes(team_leader_id: nil)\n format.json { render json: @user }\n else\n format.json { render json: @user.errors, status: :unprocessable_entity}\n end\n end\n end\n end", "def update\n @user = User.find_by_username params[:username]\n raise ActiveRecord::RecordNotFound unless @user\n @user_role = Role.find_by_name('User')\n @roles = Role.all.order(:name)\n\n if params[:user][:current_password] # the user is changing their password\n command = ChangePasswordCommand.new(\n @user, params[:user][:current_password],\n params[:user][:password],\n params[:user][:password_confirmation],\n current_user,\n request.remote_ip)\n begin\n command.execute\n rescue ValidationError\n render 'edit'\n rescue => e\n flash['error'] = \"#{e}\"\n render 'edit'\n else\n flash['success'] = @user == current_user ?\n 'Your password has been changed.' :\n \"#{@user.username}'s password has been changed.\"\n keep_flash\n redirect_to edit_user_url(@user)\n end\n elsif params[:user][:desired_institution_id] # the user is changing their institution\n new_institution = Institution.find(params[:user][:desired_institution_id])\n command = JoinInstitutionCommand.new(@user, new_institution,\n current_user, request.remote_ip)\n begin\n command.execute\n rescue ValidationError\n render 'edit'\n rescue => e\n flash['error'] = \"#{e}\"\n render 'edit'\n else\n if @user.institution == new_institution # already joined, which means an admin did it\n flash['success'] = \"#{@user.username} is already a member of \"\\\n \"#{new_institution.name}.\"\n else\n flash['success'] = \"An administrator has been notified and will \"\\\n \"review your request to join #{new_institution.name} momentarily,\"\n end\n keep_flash\n redirect_to dashboard_path\n end\n else # the user is changing their basic info\n command = UpdateUserCommand.new(@user, user_update_params, current_user,\n request.remote_ip)\n begin\n command.execute\n rescue ValidationError\n # Gather institutions for the institution select menu.\n set_institutions_ivar\n render 'edit'\n rescue => e\n flash['error'] = \"#{e}\"\n\n # Gather institutions for the institution select menu.\n set_institutions_ivar\n render 'edit'\n else\n flash['success'] = @user == current_user ?\n 'Your profile has been updated.' :\n \"#{@user.username}'s profile has been updated.\"\n keep_flash\n redirect_to edit_user_url(@user)\n end\n end\n end", "def update_user\n end", "def profile_update_credibilty\n params.require.permit(:profile).permit(:credibility)\n end", "def update\n if current_user.user_type == 1\n respond_to do |format|\n if @professor.update(professor_params)\n format.html { redirect_to @professor, notice: 'Professor was successfully updated.' }\n format.json { render :show, status: :ok, location: @professor }\n else\n format.html { render :edit }\n format.json { render json: @professor.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def update\n @user = User.find(params[:id])\n @user.person.attributes = (params[:person])\n @roles = [Role.find_by_name(params[:user]['role'])]\n @user.roles = @roles\n respond_to do |format|\n if @user.update_attributes(params[:user]) && @user.person.save\n if params[:user][:password].length > 0\n UserNotifier.deliver_password_changed(@user, params[:user][:password]) \n end\n flash[:notice] = 'User was successfully updated.'\n format.html { redirect_to admin_users_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\t\tselect_calculation\n\t\tselect_city\n\t\tselect_rotation\n\t\tselect_role\n\t\tselect_company\n\t\tselect_calculation\n\t\tselected_role\n\t\tselected_service\n\t\tselect_service\n @proposal_hour_extra.user_update=current_admin.nome\n\n\t\trespond_to do |format|\n\t\t\tif @proposal_hour_extra.update(proposal_hour_extra_params)\n\t\t\t\tformat.html { redirect_to \"/services/#{@proposal_hour_extra.hour_extra_roles[0].role.service_id}/proposal_hour_extras/#{@proposal_hour_extra.id}\", notice: 'Proposal was successfully created.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @proposal_hour_extra }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @proposal_hour_extra.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def edit\n # @user = User.find(params[:id])\n # already in correct_user\n end", "def update\n @expertise = Expertise.find(params[:id])\n\n if @expertise.update(expertise_params)\n head :no_content\n else\n render json: @expertise.errors, status: :unprocessable_entity\n end\n end", "def update_collaboration_data(user)\n @similars.update user\n @recommendations.update user\n end", "def update\n @assessment_practice_test = AssessmentPracticeTest.find(params[:id])\n if current_user.role.id == 7\n params[:assessment_practice_test][:status] = 6\n end\n respond_to do |format|\n if@assessment_practice_test.update_attributes(params[:assessment_practice_test])\n format.html { redirect_to@assessment_practice_test, notice: 'AssessmentPracticeTest was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json:@assessment_practice_test.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exam_user = ExamUser.find(params[:id])\n\n respond_to do |format|\n if @exam_user.update_attributes(params[:exam_user])\n format.html { redirect_to @exam_user, notice: 'Exam user was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam_user.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_attorney\n if current_user.role != 1\n @attorney = Attorney.find(params[:id])\n else\n @attorney = Company.find(params[:id])\n end\n end" ]
[ "0.64857167", "0.59643155", "0.59431946", "0.5797829", "0.5788901", "0.5696062", "0.5667351", "0.563272", "0.55762", "0.5535458", "0.5522331", "0.55185026", "0.5503112", "0.550089", "0.5489815", "0.54843533", "0.5478842", "0.54710406", "0.5464877", "0.5463294", "0.5452236", "0.5449237", "0.5445457", "0.5444505", "0.5441136", "0.54363286", "0.5433878", "0.54216176", "0.5420819", "0.54144126", "0.5402023", "0.5400985", "0.53942305", "0.5392329", "0.5391889", "0.53835064", "0.53790426", "0.53741765", "0.5372721", "0.5363831", "0.5361916", "0.5359098", "0.5352754", "0.53520083", "0.53472626", "0.53455937", "0.53328896", "0.5331249", "0.53289306", "0.5324623", "0.53205144", "0.5316519", "0.5309239", "0.5308742", "0.5307609", "0.52976125", "0.5291888", "0.5289232", "0.5289232", "0.52859807", "0.5284355", "0.52825034", "0.5282436", "0.52814174", "0.528112", "0.52781296", "0.5272296", "0.5253987", "0.52468103", "0.5241225", "0.524089", "0.5234946", "0.5232655", "0.5231821", "0.52314514", "0.52297086", "0.52289087", "0.5228402", "0.52248144", "0.52247167", "0.52243906", "0.522156", "0.5221259", "0.5218917", "0.5218181", "0.52180487", "0.5217115", "0.5210735", "0.5202018", "0.5201834", "0.5199458", "0.5197731", "0.5193121", "0.5192725", "0.51920855", "0.5187848", "0.5180875", "0.5180189", "0.51794904", "0.51791203" ]
0.6742016
0
DELETE /join_user_to_assistants/1 DELETE /join_user_to_assistants/1.json
def destroy @join_user_to_assistant.destroy respond_to do |format| format.html { redirect_to join_user_to_assistants_url, notice: 'Join user to assistant was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @assist = Assist.find(params[:id])\n @assist.destroy\n\n respond_to do |format|\n format.html { redirect_to assists_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @guidances_user.destroy\n respond_to do |format|\n format.html { redirect_to guidances_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam_user = ExamUser.find(params[:id])\n @exam_user.destroy\n\n respond_to do |format|\n format.html { redirect_to exam_users_url }\n format.json { head :no_content }\n end\n end", "def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend", "def destroy\n @interested_user = InterestedUser.find(params[:id])\n @interested_user.destroy\n\n respond_to do |format|\n format.html { redirect_to interested_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @maintain_invite_user = Maintain::InviteUser.find(params[:id])\n @maintain_invite_user.destroy\n\n respond_to do |format|\n format.html { redirect_to maintain_invite_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @campaign_user_relationship = CampaignUserRelationship.find(params[:id])\n @campaign_user_relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to @campaign_user_relationship.campaign }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_has_credibility = UserHasCredibility.find(params[:id])\n @user_has_credibility.destroy\n\n respond_to do |format|\n format.html { redirect_to user_has_credibilities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = Meetup.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to meetups_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @entrepreneur = Entrepreneur.find(params[:id])\n @user = User.find(@entrepreneur.user_id)\n @entrepreneur.destroy\n @user.destroy\n \n respond_to do |format|\n format.html { redirect_to entrepreneurs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = current_org.users.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_path }\n format.json { head :no_content }\n end\n\n end", "def destroy\n @immigrant = Immigrant.find(params[:id])\n @immigrant.destroy\n\n respond_to do |format|\n format.html { redirect_to immigrants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goal = @user.goals.find(params[:id])\n @goal.destroy\n\n respond_to do |format|\n format.html { redirect_to user_goals_url(@user) }\n format.json { head :no_content }\n end\n end", "def destroy\n @membership.destroy\n respond_to do |format|\n format.html { redirect_to @user }\n format.json { head :no_content }\n end\n end", "def destroy\n user = @membership.user\n school = @membership.school\n user_roles = user.roles\n @membership.destroy\n user_roles.delete_all\n respond_to do |format|\n format.html { redirect_to school_memberships_path(@membership.school), notice: 'Scool registration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n render json: User.delete(params[\"id\"])\n end", "def destroy\n @user_target.destroy\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n @achievementuser = Achievementuser.find(params[:id])\n @achievementuser.destroy\n\n respond_to do |format|\n format.html { redirect_to achievementusers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @claimant = Claimant.find(params[:id])\n @claimant.destroy\n\n respond_to do |format|\n format.html { redirect_to claimants_url }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @user_quest = UserQuest.find(params[:id])\n @user_quest.destroy\n\n respond_to do |format|\n format.html { redirect_to user_quests_url }\n format.json { head :no_content }\n end\n end", "def destroy\n UserPlant.destroy(params[:id])\n end", "def destroy\n @applicant.destroy\n respond_to do |format|\n format.html { redirect_to applicants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n user = User.find(params[:id])\n senator = Senator.find(params[:senator_id])\n user.senators.delete(senator)\n render json: user.senators\n end", "def destroy\n @logistic = @user.logistics.find(params[:id])\n @logistic.destroy\n\n respond_to do |format|\n format.html { redirect_to user_logistics_path(@user) }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_responsibility.destroy\n respond_to do |format|\n format.html { redirect_to user_responsibilities_url, notice: \"User responsibility was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @colony_ant.destroy\n respond_to do |format|\n format.html { redirect_to colony_ants_url, notice: 'Colony ant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find params[:user_id]\n @role = Role.find params[:id]\n\n @user.roles.delete @role\n flash[:notice] = 'Assigment was successfully destroyed.'\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end", "def destroy\n @user_meal.destroy\n respond_to do |format|\n format.html { redirect_to user_meals_url, notice: 'User meal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @grant = Grant.find(params[:id])\n @grant.destroy\n\n respond_to do |format|\n format.html { redirect_to grants_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user_competency_level.destroy\n respond_to do |format|\n format.html { redirect_to user_competency_levels_url, notice: 'User competency level was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @meal_profile = MealProfile.find(params[:id])\n @meal_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to meal_profiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tribal_membership.destroy\n respond_to do |format|\n format.html { redirect_to tribal_memberships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.skills.delete_all\n \n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @applicant = Applicant.find(params[:id])\n @applicant.destroy\n\n respond_to do |format|\n format.html { redirect_to applicants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @applicant = Applicant.find(params[:id])\n @applicant.destroy\n\n respond_to do |format|\n format.html { redirect_to applicants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @guarantor = Guarantor.find(params[:id])\n @guarantor.destroy\n\n respond_to do |format|\n format.html { redirect_to guarantors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n User.cascade_delete(@user)\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end", "def destroy\n @corporate_user.destroy\n respond_to do |format|\n format.html { redirect_to corporate_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to admins_thrivers_url }\n format.json { render json: { status: 200 } }\n end\n end", "def user_management_delete_user id\n # the base uri for api requests\n query_builder = Configuration.BASE_URI.dup\n\n # prepare query string for API call\n query_builder << \"/v1/users\"\n\n # process optional query parameters\n query_builder = APIHelper.append_url_with_query_parameters query_builder, {\n \"id\" => id,\n \"client_id\" => @client_id,\n \"client_secret\" => @client_secret,\n }\n\n # validate and preprocess url\n query_url = APIHelper.clean_url query_builder\n\n # prepare headers\n headers = {\n \"user-agent\" => \"IAMDATA V1\",\n \"accept\" => \"application/json\"\n }\n\n # invoke the API call request to fetch the response\n response = Unirest.delete query_url, headers:headers\n\n # Error handling using HTTP status codes\n if response.code == 404\n raise APIException.new \"Not found\", 404, response.raw_body\n elsif response.code == 401\n raise APIException.new \"Unauthorized\", 401, response.raw_body\n elsif !(response.code.between?(200,206)) # [200,206] = HTTP OK\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\n end\n\n response.body\n end", "def destroy\n @grantee.destroy\n respond_to do |format|\n format.html { redirect_to grantees_url, notice: 'Grantee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @userin = UserInvestor.find(params[:id])\n if @userin.destroy\n render json: { status: 'OK', results: 'user investor has been deleted',\n errors: nil }, status: :ok\n else\n render json: { status: 'FAIL', results: nil,\n errors: 'user failed to delete' },\n status: :unprocesable_entity\n end\n end", "def destroy\n debugger\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@user_ids= @grade.user_ids\n\t\t@user_ids= @user_ids.sub \"[\", \"\"\n\t\t@user_ids= @user_ids.sub \"]\", \"\"\n\t\t@user_ids= @user_ids.split(\",\")\n\t\t\n\t\t@user_ids.each do |user_id|\n\t\t\tif User.find_by_id(user_id)\n\t\t\t\tUser.find_by_id(user_id).destroy\n\t\t\tend\n\t\tend\t\t\n\n\n @grade.destroy\n respond_to do |format|\n format.html { redirect_to grades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @asign_departament_user.destroy\n respond_to do |format|\n format.html { redirect_to asign_departament_users_url, notice: 'Asign departament user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @idea.users.delete(User.find_by(id: session[:id]))\n if (Participant.find_by(idea_id: @idea.id).nil?)\n Participant.destroy_all(idea_id: @idea.id)\n Content.destroy_all(idea_id: @idea.id)\n @idea.destroy\n end\n respond_to do |format|\n format.html { redirect_to ideas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @achievment.destroy\n respond_to do |format|\n format.html { redirect_to achievments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_profession.destroy\n respond_to do |format|\n format.html { redirect_to user_professions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n if @relation.user1_id == @currentUser.id or @currentUser.role == 0\n @relation.destroy\n respond_to do |format|\n format.html { redirect_to relations_url, notice: 'Relation was successfully destroyed.' }\n format.json { head :no_content }\n end\n else\n redirect_to relations_url, notice: 'You cant revoke anothers users queries'\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to residencial_apartamento_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @leadership.destroy\n respond_to do |format|\n format.html { redirect_to leaderships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n tempid = @injury.user_id\n @injury.destroy\n respond_to do |format|\n format.html { redirect_to user_path(tempid), notice: 'Injury was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @level_goal = LevelGoal.find(params[:id])\n @level_goal.destroy\n\n respond_to do |format|\n format.html { redirect_to level_goals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_collaborator = Admin::Collaborator.find(params[:id])\n @admin_collaborator.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_collaborators_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @instathreat_user.destroy\n respond_to do |format|\n format.html { redirect_to instathreat_users_url, notice: 'Instathreat user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @additional_user.destroy\n respond_to do |format|\n format.html { redirect_to additional_users_url, notice: 'Additional user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @occupant = Occupant.find(params[:id])\n @occupant.destroy\n\n respond_to do |format|\n format.html { redirect_to occupants_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Users.delete(params[\"id\"])\n end", "def destroy\n @target = current_user.targets.find(params[:id])\n @target.destroy\n\n respond_to do |format|\n format.html { redirect_to index_home_path, notice: 'Target was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_situation.destroy\n respond_to do |format|\n format.html { redirect_to user_situations_url, notice: 'User situation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n if not check_logged_in then\n return\n end\n @personal_plant = PersonalPlant.find(params[:id])\n @personal_plant.destroy\n\n respond_to do |format|\n format.html { redirect_to personal_plants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @selection = Selection.find(params[:id])\n @user = User.find(@selection.user_id);\n \n @selection.destroy\n\n respond_to do |format|\n format.html { redirect_to @user }\n format.json { head :no_content }\n end\n end", "def destroy\n @habrauser = Habrauser.find(params[:id])\n @habrauser.destroy\n\n respond_to do |format|\n format.html { redirect_to current_user }\n format.json { head :ok }\n end\n end", "def destroy\n @join = Join.find_by(user_id:current_user.id, hike_id: params[:id])\n @join.destroy\n redirect_to '/dashboard'\n end", "def destroy\n @employ = Employ.find(params[:id])\n @employ.destroy\n\n respond_to do |format|\n format.html { redirect_to employs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n Log.new({user: current_user.user, \n subject: \"user:\"+@assigned.grantee,\n operation: \"revoked access\",\n object: \"table:\"+@assigned.relation\n }).save\n @assigned.destroy\n respond_to do |format|\n format.html { redirect_to assigneds_url, notice: 'Assigned was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @euclid_user = EuclidUser.find(params[:id])\n @euclid_user.destroy\n\n respond_to do |format|\n format.html { redirect_to euclid_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @internships_user = InternshipsUser.find(params[:id])\n @internships_user.destroy\n\n respond_to do |format|\n format.html { redirect_to internships_users_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @detailed_user.destroy\n respond_to do |format|\n format.html { redirect_to detailed_users_url, notice: 'Detailed user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @alumno.destroy\n respond_to do |format|\n format.html { redirect_to grupos_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @lead = current_user.leads.find(params[:id])\n @lead.destroy\n\n respond_to do |format|\n format.html { redirect_to leads_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_id = UserId.find(params[:id])\n @user_id.destroy\n\n respond_to do |format|\n format.html { redirect_to user_ids_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @users_management.destroy\n respond_to do |format|\n format.html { redirect_to users_managements_url }\n format.json { head :no_content }\n end\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 @grant.destroy\n respond_to do |format|\n format.html { redirect_to grants_url, notice: 'Grant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @learninguser.destroy\n respond_to do |format|\n format.html { redirect_to learningusers_url, notice: 'Learninguser was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @tx_land_grants_efn.destroy\n respond_to do |format|\n format.html { redirect_to tx_land_grants_efns_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @applicant_test.destroy\n respond_to do |format|\n format.html { redirect_to applicant_url(@applicant), notice: \"Test Eliminado Correctamente\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @visitante_credenciado = VisitanteCredenciado.find(params[:id])\n @visitante_credenciado.destroy\n\n respond_to do |format|\n format.html { redirect_to visitante_credenciados_url }\n format.json { head :no_content }\n end\n \n end", "def destroy\n @users= User.all\n authorize @users\n @lodging = @travel.lodgings.find(params[:id])\n @lodging.destroy\n\n respond_to do |format|\n #format.html { redirect_to lodgings_url, notice: 'Lodging was successfully destroyed.' }\n format.html { redirect_to travel_lodgings_path(@travel),notice: 'Lodging was successfully destroyed.'}\n format.json { head :no_content }\n end\n end", "def destroy\n @employe.destroy\n respond_to do |format|\n format.html { redirect_to employes_path(api_id: @employe.organisme_id), notice: 'Employe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @grant.destroy\n respond_to do |format|\n format.html { redirect_to grants_url, notice: \"Grant was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/members?is_approved=0\" }\n format.json { head :no_content }\n end\n \n end", "def destroy\n @expense = current_user.organization.expenses.find(params[:id])\n @expense.destroy\n\n respond_to do |format|\n format.html { redirect_to expenses_url }\n format.json { head :no_content }\n end\n end", "def delete\n @person = Person.find_by_guid(params['user_id'])\n if ! @person\n render_json :status => :not_found and return\n end\n if ! ensure_same_as_logged_person(params['user_id'])\n render_json :status => :forbidden and return\n end\n @person.destroy\n @application_session.destroy\n session[:cos_session_id] = nil\n render_json :status => :ok\n end", "def destroy\n @user_household_ledger.destroy\n respond_to do |format|\n format.html { redirect_to user_household_ledgers_url, notice: \"User household ledger was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @assistencia.destroy\n respond_to do |format|\n format.html { redirect_to assistencias_url, notice: 'Assistencia was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n require_user()\n @area_of_expertise.destroy\n respond_to do |format|\n format.html { redirect_to area_of_expertises_url, notice: 'Area of expertise was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @optin_contestant = OptinContestant.find(params[:id])\n @optin_contestant.destroy\n\n respond_to do |format|\n format.html { redirect_to optin_contestants_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exercise_types_in_user.destroy\n respond_to do |format|\n format.html { redirect_to exercise_types_in_users_url, notice: 'Exercise types in user was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @ministerial_role.destroy\n respond_to do |format|\n format.html { redirect_to ministerial_roles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @personal.destroy\n respond_to do |format|\n format.html { redirect_to personals_url }\n format.json { head :no_content }\n end\n end", "def deleteEntityAssociation_membership( entity_id, gen_id)\n params = Hash.new\n params['entity_id'] = entity_id\n params['gen_id'] = gen_id\n return doCurl(\"delete\",\"/entity/association_membership\",params)\n end", "def destroy\n @accountant.destroy\n respond_to do |format|\n format.html { redirect_to accountants_url, notice: 'Accountant was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user = User.find(params[:id])\n @user.destroy\n @all_users = User.all\n\n respond_to do |format|\n format.html { redirect_to '/admins/management' }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @user_skill = UserSkill.find(params[:id])\n @user_skill.destroy\n\n respond_to do |format|\n format.html { redirect_to user_skills_url }\n format.json { head :no_content }\n end\n end", "def remove_interest\n @interest = Interest.where(\"user_id = ? and property_id= ?\",params[:user_id],params[:property_id])\n @interest.first.destroy\n\n respond_to do |format|\n format.html { redirect_to interests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @aspirant = Aspirant.find(params[:id])\n @aspirant.destroy\n\n respond_to do |format|\n format.html { redirect_to aspirants_url }\n format.json { head :ok }\n end\n end", "def destroy\n @user = @department.users.find(params[:id])\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to department_users_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.66305023", "0.65866286", "0.65855944", "0.6518632", "0.64724064", "0.64334816", "0.64238405", "0.6421914", "0.6395352", "0.6389911", "0.6377326", "0.63713765", "0.6355604", "0.6353042", "0.6338573", "0.6330434", "0.63176066", "0.6313337", "0.63094944", "0.63054067", "0.6299857", "0.6296394", "0.6287286", "0.62675595", "0.62662107", "0.62655205", "0.62646896", "0.6259123", "0.6258948", "0.6255993", "0.6254989", "0.6242959", "0.6232948", "0.62312996", "0.6230786", "0.6230786", "0.62267935", "0.62236136", "0.6220436", "0.62172526", "0.6215972", "0.6213749", "0.6208697", "0.62058455", "0.6196047", "0.6190555", "0.61804396", "0.6177264", "0.6168942", "0.6168138", "0.6164885", "0.6162908", "0.6155283", "0.6154527", "0.6153843", "0.6145105", "0.61434007", "0.6136232", "0.6133771", "0.61328936", "0.6131923", "0.6126094", "0.6121876", "0.6121742", "0.6120799", "0.6118728", "0.61179703", "0.611743", "0.61109036", "0.61105484", "0.61104697", "0.61089784", "0.61086214", "0.6108572", "0.61079055", "0.61078787", "0.6105959", "0.6100477", "0.6099729", "0.6098689", "0.6097202", "0.6096688", "0.6096078", "0.60934514", "0.6086503", "0.6079414", "0.6079352", "0.60758644", "0.6074266", "0.60741884", "0.6072484", "0.6072226", "0.6068503", "0.6067437", "0.6066662", "0.6066657", "0.6065757", "0.60612124", "0.6061014", "0.6058603" ]
0.7291304
0
Use callbacks to share common setup or constraints between actions.
def set_join_user_to_assistant @join_user_to_assistant = JoinUserToAssistant.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 join_user_to_assistant_params params.require(:join_user_to_assistant).permit(:cpfk_user_id, :cpfk_assistant_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 filtering_params\n params.permit(:email)\n end", "def active_code_params\n params[:active_code].permit\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def url_whitelist; end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def permit_request_params\n params.permit(:address)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def 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 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.69780594", "0.678054", "0.6742781", "0.67387927", "0.67346025", "0.6590683", "0.6501642", "0.6495788", "0.6479752", "0.64763314", "0.645457", "0.6437739", "0.6377168", "0.6372484", "0.6363871", "0.63179374", "0.62981373", "0.6297456", "0.62916917", "0.6290227", "0.628954", "0.62877893", "0.62814754", "0.62416226", "0.6237962", "0.62168854", "0.62127215", "0.62084496", "0.61927646", "0.6176822", "0.6174079", "0.6171225", "0.6161419", "0.61507314", "0.6150071", "0.6145409", "0.61204594", "0.61135256", "0.6105225", "0.6103249", "0.6088041", "0.6079626", "0.6070542", "0.6060409", "0.60198915", "0.6016795", "0.6010659", "0.60103244", "0.6005393", "0.6005393", "0.6000696", "0.60000104", "0.59931517", "0.59916013", "0.5991397", "0.5990416", "0.5979021", "0.5965926", "0.59582806", "0.59579134", "0.5957629", "0.5956672", "0.59518754", "0.59510773", "0.5942638", "0.5937516", "0.59361875", "0.59361875", "0.59336793", "0.5928626", "0.5925229", "0.59243226", "0.59174913", "0.5907821", "0.5907719", "0.5906177", "0.59056896", "0.5897028", "0.5896294", "0.5895856", "0.5893494", "0.58926904", "0.589066", "0.58854234", "0.58809334", "0.5878489", "0.58727074", "0.5868653", "0.5866631", "0.58666086", "0.5866305", "0.586484", "0.58631617", "0.5861481", "0.5861059", "0.5859114", "0.5858489", "0.585326", "0.58530635", "0.5848788", "0.58479697" ]
0.0
-1
Prevent sentitive data from being accidentally logged to console
def inspect to_s end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def suppress; @write = false end", "def autoflush_log; end", "def autoflush_log; end", "def logged?; false end", "def logged?; false end", "def silence!\n IO.console.raw!\n end", "def log\r\n false\r\n end", "def log_without_running\n log\n end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def log; end", "def logged?;\n false\n end", "def logging_prefs; end", "def verbose_logging; end", "def autoflush_log=(_arg0); end", "def autoflush_log=(_arg0); end", "def without_stderr; end", "def disable_log_to_screen\n @log_to_screen = false\n end", "def no_action_log\n true\n end", "def quiet; end", "def render(*)\n if (logger = WebConsole.logger) && logger.respond_to?(:silence)\n WebConsole.logger.silence { super }\n else\n super\n end\n end", "def silence_logging\n Rails.logger.silence do\n yield\n end\n end", "def disable_logging\n @session.connection.disable_logging\n end", "def silent(text)\n GitPusshuTen::Log.silent(text)\n end", "def log_without_unused_attrs(log)\n log.select! { |k| k == 'code' }\n end", "def fancy_log\n\n @log.collect { |msg| fancy_print(msg) }\n end", "def log(line)\n puts line unless RUBYMOTION_ENV == \"test\"\n end", "def supporting_method\n logger.warn 'This does nothing'\n end", "def log_denials\n @log_denials = true\n end", "def log_state\n super\n end", "def silence_deprecations; end", "def logger\n params[:secure] ? nil : super\n end", "def unsuppress_logger\n Log.silent(false)\n @logger_suppressed = nil\n end", "def silence_output\n # Store the original stderr and stdout in order to restore them later\n @original_stderr = $stderr\n @original_stdout = $stdout\n\n # Redirect stderr and stdout\n $stderr = File.new(log_file, 'w')\n $stdout = File.new(log_file, 'w')\nend", "def onquiet\n end", "def log!(message)\n log message if very_verbose\n end", "def log!(message)\n log message if very_verbose\n end", "def assume_silence\n GitReview.any_instance.stub(:puts)\nend", "def warned; end", "def disable_verbose_log()\n PureHailDB.ib_cfg_set(\"print_verbose_log\", :bool, false)\n end", "def delete_logging_statement\n super\n end", "def should_print?\n !@suppress_output\n end", "def log=(log); end", "def disable_logger_noise\n StraightServer::Config.logmaster = { 'log_level' => 'INFO', 'file' => 'straight.log' }\n @initializer.create_logger\n expect(StraightServer.logger).to receive(:info).and_return ''\n end", "def log\n end", "def disable_logging\n @communicator_logger = nil\n end", "def disable_logging\n @communicator_logger = nil\n end", "def silence_output\n # Store the original stderr and stdout in order to restore them later\n @original_stderr = $stderr\n @original_stdout = $stdout\n\n # Redirect stderr and stdout\n $stderr = File.new('/dev/null', 'w')\n $stdout = File.new('/dev/null', 'w')\nend", "def logger_output; end", "def log?\n @log ||= false\n end", "def disable_logging\n @logger = nil\n end", "def silence_output\n # @orig_stderr = $stderr\n @orig_stdout = $stdout\n \n # redirect stderr and stdout to /dev/null\n # $stderr = File.new('/dev/null', 'w')\n $stdout = File.new('/dev/null', 'w')\nend", "def quiet\n true\n end", "def none\n Internal::Logging::DevNullLogging::DEV_NULL_LOGGING\n end", "def ignore_interference_by_writer; end", "def sparkLogNormalToCout(sync = false)\n sparkEnableLog(':cout', 'eNormal', sync)\nend", "def silence_output\n @orig_stderr = $stderr\n @orig_stdout = $stdout\n \n # redirect stderr and stdout to /dev/null\n $stderr = File.new('/dev/null', 'w')\n $stdout = File.new('/dev/null', 'w')\nend", "def disable_distinct_logger=(flag)\n @@disable_distinct_logger = flag\n end", "def should_log?\n return false if @skip_logging\n true\n end", "def disable_stdout\n stdoutoutputter = Log4r::Outputter[\"#{@name.to_s}-stdout\"]\n stdoutoutputter.level = Log4r::OFF\n end", "def suppressed? ; @suppressed ; end", "def log(msg)\n puts msg unless ENV['TEST']\n end", "def option_dontlog_normal\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"option dontlog-normal \" + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end", "def silence_omniauth\n previous_logger = OmniAuth.config.logger\n OmniAuth.config.logger = Logger.new(\"/dev/null\")\n yield\n ensure\n OmniAuth.config.logger = previous_logger\n end", "def log_lines\n\n self.each do |line|\n clean_line = line.to_s.chomp.gsub(\"\\\\n\",\"\")\n log.info(x) { line } if clean_line.length > 0\n end\n\n end", "def suppress_logger(logging = nil)\n logging = params[:logging] if logging.nil?\n @logger_suppressed = false?(logging)\n Log.silent(true) if @logger_suppressed\n end", "def process_with_silent_log(method_name, *args)\n if logger\n @old_logger_level = logger.level\n if Rails.version >= '3.2'\n silence do\n process_without_silent_log(method_name, *args)\n end\n else\n logger.silence do\n process_without_silent_log(method_name, *args)\n end\n end\n else\n process_without_silent_log(method_name, *args)\n end\n end", "def log thing\n `console.orig_log(#{thing})`\n end", "def silenced\n $stdout = StringIO.new\n\n yield\n ensure\n $stdout = STDOUT\n end", "def log!(msg)\n log_info(msg)\n puts(msg)\nend", "def logging_prefs=(_arg0); end", "def suppress_ready_debug\n @prevent_ready = true\n end", "def suppress_ready_debug\n @prevent_ready = true\n end", "def load_priv()\n\t\toriginal = console.disable_output\n\n\t\tconsole.disable_output = true\n\t\tconsole.run_single('use priv')\n\t\tconsole.disable_output = original\n\tend", "def silent(string)\n to_file loggify(string, :silent)\n end", "def silence_output\n @orig_stderr = $stderr\n @orig_stdout = $stdout\n $stderr = File.new('/dev/null', 'w')\n $stdout = File.new('/dev/null', 'w')\nend", "def touch_when_logging\n touch\n end", "def silence_deprecations=(_arg0); end", "def reset_log_data\n self.class.without_logging { update_column(:log_data, nil) }\n end", "def inspect!\n warn(inspect)\n end", "def inspect!\n warn(inspect)\n end", "def ignore; end", "def log?\n @log != false\n end", "def log?\n @log != false\n end", "def log?\n @log != false\n end", "def do_ignore\n puts \"IGNORING <#{@line}> FOR NOW\"\n end", "def quietly\n d = Spy.on_instance_method(cmd_class, :display)\n yield\n assert d.has_been_called?\n d.unhook\n end", "def disable_activerecord_sql_logging\n ActiveRecord::Base.logger.level = 1\nend", "def allow_statistics_logging(contributable_or_version)\n \n # check if the current viewing/download is to be logged\n # (i.e. request is sent not by a bot and is legitimate)\n allow_logging = true\n Conf.bot_ignore_list.each do |pattern|\n if request.env['HTTP_USER_AGENT'] and request.env['HTTP_USER_AGENT'].match(pattern)\n allow_logging = false\n break\n end\n end\n \n # disallow logging of events referring to contributables / versions of them\n # that have been uploaded by current user; \n #\n # however, if there are newer versions of contributable (uploaded not by the original uploader),\n # we do want to record viewings/downloads of this newer version by the original uploader \n if allow_logging && current_user != 0\n allow_logging = false if (contributable_or_version.contributor_type == \"User\" && contributable_or_version.contributor_id == current_user.id)\n end\n \n return allow_logging\n end", "def allow_statistics_logging(contributable_or_version)\n \n # check if the current viewing/download is to be logged\n # (i.e. request is sent not by a bot and is legitimate)\n allow_logging = true\n Conf.bot_ignore_list.each do |pattern|\n if request.env['HTTP_USER_AGENT'] and request.env['HTTP_USER_AGENT'].match(pattern)\n allow_logging = false\n break\n end\n end\n \n # disallow logging of events referring to contributables / versions of them\n # that have been uploaded by current user; \n #\n # however, if there are newer versions of contributable (uploaded not by the original uploader),\n # we do want to record viewings/downloads of this newer version by the original uploader \n if allow_logging && current_user != 0\n allow_logging = false if (contributable_or_version.contributor_type == \"User\" && contributable_or_version.contributor_id == current_user.id)\n end\n \n return allow_logging\n end", "def puts(msg)\n @out.puts msg unless @silent\n end", "def log_writer; end", "def logger; end", "def logger; end", "def logger; end", "def logger; end" ]
[ "0.6903036", "0.66703516", "0.66703516", "0.66479856", "0.66479856", "0.6392523", "0.6382992", "0.62872", "0.6256819", "0.6256819", "0.6256819", "0.6256819", "0.6256819", "0.6256819", "0.6256819", "0.6256819", "0.624584", "0.6227292", "0.61632216", "0.61414635", "0.61414635", "0.61204505", "0.60793746", "0.60582584", "0.6055326", "0.6034997", "0.5967117", "0.5933886", "0.5933147", "0.59095407", "0.5909025", "0.5906248", "0.59056836", "0.5890758", "0.5888922", "0.58828396", "0.5828125", "0.5825445", "0.5818852", "0.58184993", "0.5795569", "0.5795569", "0.57883114", "0.57850873", "0.57815844", "0.57720333", "0.5741015", "0.57226163", "0.5721918", "0.5720842", "0.5703041", "0.5703041", "0.56905234", "0.5686502", "0.56417423", "0.56301755", "0.5595362", "0.55798167", "0.5579484", "0.5578758", "0.5575593", "0.55748534", "0.55687284", "0.5565011", "0.55514735", "0.55382216", "0.5534273", "0.55318224", "0.5520074", "0.5515628", "0.55096847", "0.55063725", "0.55037147", "0.54996955", "0.5497038", "0.5477664", "0.547653", "0.547653", "0.547103", "0.54547876", "0.54480183", "0.54467833", "0.5443442", "0.5439267", "0.5435553", "0.5435553", "0.54328465", "0.54292774", "0.54292774", "0.54292774", "0.54236126", "0.54223955", "0.5418648", "0.541791", "0.541791", "0.54082936", "0.54061854", "0.54061", "0.54061", "0.54061", "0.54061" ]
0.0
-1