query
stringlengths 7
9.5k
| document
stringlengths 10
1.07M
| negatives
sequencelengths 19
19
| metadata
dict |
---|---|---|---|
DELETE /admin/kpi_templates/1 DELETE /admin/kpi_templates/1.json | def destroy
@admin_kpi_template = Admin::KpiTemplate.find(params[:id])
@admin_kpi_template.destroy
respond_to do |format|
format.html { redirect_to admin_kpi_templates_url }
format.json { head :no_content }
end
end | [
"def delete\n response = CreateSend.delete \"/templates/#{template_id}.json\", {}\n end",
"def destroy\n @admin_kpi_category_template = Admin::KpiCategoryTemplate.find(params[:id])\n @admin_kpi_category_template.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_kpi_category_templates_url }\n format.json { head :no_content }\n end\n end",
"def delete(options={})\n DNSimple::Client.delete \"templates/#{id}\", options\n end",
"def delete_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _delete(path)\n puts '[+] Course template data deleted successfully'.green\nend",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to admin_templates_url, notice: 'Template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spree_admin_template.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 @api_v1_policy_group_template.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_policy_group_templates_url, notice: 'Policy group template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @label_template = Spree::LabelTemplate.find(params[:id])\n @label_template.destroy\n\n respond_to do |format|\n format.html { redirect_to label_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @one_table_template =\n @one_table.\n one_table_templates.\n by_user(current_user).\n find(params[:id])\n @one_table_template.destroy\n\n respond_to do |format|\n format.html { redirect_to one_table_one_table_templates_url(@one_table) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cluster_template.destroy\n respond_to do |format|\n format.html { redirect_to '/cluster_templates' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @config_template.destroy\n respond_to do |format|\n format.html { redirect_to config_templates_url, notice: 'Config template was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @super_admin_template = SuperAdminTemplate.find(params[:id])\n @super_admin_template.destroy\n\n respond_to do |format|\n format.html { redirect_to(super_admin_templates_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @template.destroy\n respond_to do |format|\n format.html { redirect_to templates_templates_url }\n format.json { head :no_content }\n end\n end",
"def delete(name)\n r = request('DeleteTemplate', { :name => name })\n return r['status'] == ' ok ' \n end",
"def destroy\n @sql_template = SqlTemplate.find(params[:id])\n @sql_template.destroy\n\n respond_to do |format|\n format.html { redirect_to sql_templates_url }\n format.json { head :ok }\n end\n end",
"def delete_content_template(id)\n # TODO: Inform ContentTemplateController.destroy method has been modified\n @client.raw('delete', \"/content/templates/#{id}\")\n end",
"def destroy\n @db_template = DbTemplate.find(params[:id])\n @db_template.destroy\n\n respond_to do |format|\n format.html { redirect_to db_templates_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @rcadmin_email_template.destroy\n respond_to do |format|\n\t flash[:notice] = 'Email template was successfully deleted.'\n format.html { redirect_to rcadmin_email_templates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_template_type = TemplateType.find(params[:id])\n @admin_template_type.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_template_type_types_url }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /inventory_plans GET /inventory_plans.json | def index
@inventory_plans = InventoryPlan.all
end | [
"def plans(params = {})\n scope 'default'\n get('plans/', params)\n end",
"def plans\n @api.get_plans( :project_id => @id )\n end",
"def index\n @plans = Plan.all\n \n render json: @plans\n end",
"def index\n @plans = Plan.all\n\n render json: @plans\n end",
"def plan\n return nil if request[\"plan_member\"].nil?\n plan_id = request[\"plan_member\"][\"plan\"][\"id\"]\n res = get(\"plans\", plan_id)\n end",
"def index\n @plans = @store.plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plans }\n end\n end",
"def index\n @site_plans = @product.site_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @site_plans }\n end\n end",
"def plans(query = {})\n self.class.get(\"/plans/user.json\", :query => query)\n end",
"def index\n @floor_plans = @product.floor_plans\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @floor_plans }\n end\n end",
"def get_plans(args)\n id = args[:project_id] or raise \"Missing project id (:project_id => 1)\"\n list = get('get_plans', [id])\n list.collect do |item|\n TestRail::Plan.new(item.merge({ :api => self }))\n end\n end",
"def read_service_plans()\n @client.service_plans\n end",
"def index\n @plan_resources = PlanResource.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @plan_resources }\n end\n end",
"def show\n @plan = @store.plans.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @plan }\n end\n end",
"def fetch_plans (id = nil)\n @plans = []\n parameters = {}\n @networks_by_plan = {}\n parameters[:_profile] = 'http://hl7.org/fhir/us/davinci-pdex-plan-net/StructureDefinition/plannet-InsurancePlan' \n if(id)\n parameters[:_id] = id\n end\n\n @client.search(\n FHIR::InsurancePlan,\n search: { parameters: parameters }\n )&.resource&.entry&.map do |entry|\n @plans << {\n value: entry&.resource&.id,\n name: entry&.resource&.name\n }\n @networks_by_plan [ entry&.resource&.id] = entry&.resource&.network\n end\n @plans.sort_by! { |hsh| hsh[:name] }\n rescue => exception\n redirect_to root_path, flash: { error: 'Please specify a plan network server' }\n\n end",
"def plans(type)\n validate_server_type(type) do\n perform_request(:action => 'listplans', :type => type)\n parse_returned_params_as_list('plans')\n end\n end",
"def plans\r\n PlansController.instance\r\n end",
"def index\n @test_plans = @project.test_plans\n end",
"def plans(type)\n validate_server_type(type) do\n perform_request(action: 'listplans', type: type)\n parse_returned_params_as_list('plans')\n end\n end",
"def plans\n return @plans\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /inventory_plans POST /inventory_plans.json | def create
@inventory_plan = InventoryPlan.new(inventory_plan_params)
respond_to do |format|
if @inventory_plan.save
format.html { redirect_to @inventory_plan, notice: 'Inventory plan was successfully created.' }
format.json { render :show, status: :created, location: @inventory_plan }
else
format.html { render :new }
format.json { render json: @inventory_plan.errors, status: :unprocessable_entity }
end
end
end | [
"def create_plan(options = {})\n build_response(make_request(:post, url: 'plans', options: options))\n end",
"def create(options = nil)\n request = Request.new(@client)\n path = \"/plans\"\n data = {\n \"id\"=> @id, \n \"name\"=> @name, \n \"amount\"=> @amount, \n \"currency\"=> @currency, \n \"interval\"=> @interval, \n \"trial_period\"=> @trial_period, \n \"metadata\"=> @metadata, \n \"return_url\"=> @return_url, \n \"cancel_url\"=> @cancel_url\n }\n\n response = Response.new(request.post(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"plan\"]\n \n \n return_values.push(self.fill_with_data(body))\n \n\n \n return_values[0]\n end",
"def create\n @plan = Plan.new(params[:plan])\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def create\n @plan = Plan.new(plan_params)\n\n if @plan.save\n render json: @plan, status: :created, location: @plan\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def create\n @plan = @store.plans.new(params[:plan])\n\n respond_to do |format|\n if @plan.save\n format.html { redirect_to store_plan_path(@plan), notice: 'Plan was successfully created.' }\n format.json { render json: @plan, status: :created, location: store_plan(@plan) }\n else\n @plan_types = Plan::PLAN_TYPES.to_a.map(&:reverse)\n @products = [] #it need be changed when products be done\n @frequences = [[\"Monthly\",\"monthly\"],[\"Weekly\",\"weekly\"],[\"Daily\",\"daily\"],[\"Hourly\",\"hourly\"]]\n format.html { render action: \"new\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n application_plan = application_plans.create(application_plan_create_params)\n respond_with(application_plan)\n end",
"def create\n account_plan = account_plans.create(account_plan_create_params)\n respond_with(account_plan)\n end",
"def create\n service_plan = service_plans.create(service_plan_create_params)\n respond_with(service_plan)\n end",
"def create\n @planitem = Planitem.new(planitems_params)\n\n respond_to do |format|\n if @planitem.save\n format.html { redirect_to \"#{plan_path(@planitem.sprint.quarter.name)}\", notice: 'Plan item was successfully created.' }\n format.json { render json: @planitem, status: :created, location: @planitem }\n else\n\t\t@sprint = Sprint.find(@planitem.sprint_id)\n\t\t@teams = Team.order(:name)\n\t\t@initiatives = Initiative.where(:quarter_id => @sprint.quarter_id)\n\t\t@sprints = Sprint.where(:quarter_id => @sprint.quarter_id)\n format.html { render action: \"new\" }\n format.json { render json: @planitem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n data = {}\n data[:master_plan_id] = params[:spot_plan_item][:master_plan_id]\n data[:master_plan_item_id] = params[:spot_plan_item][:master_plan_item_id]\n data[:placed_at] = Time.parse(params[:spot_plan_item][:placed_at])\n data[:version] = params[:spot_plan_item][:version]\n data[:count] = params[:spot_plan_item][:count]\n\n SpotPlanItem.transaction do\n @spot_plan_item = SpotPlanItem.create_by_data!(data)\n @spot_plan_item.master_plan_item.master_plan.is_dirty = true\n @spot_plan_item.master_plan_item.master_plan.save!\n end\n\n respond_to do |format|\n format.json { render json: @spot_plan_item, status: :created, location: @spot_plan_item }\n end\n end",
"def create\n @test_plan = TestPlan.new(test_plan_params)\n\n respond_to do |format|\n if @test_plan.save\n format.html { redirect_to @test_plan, notice: 'Test plan was successfully created.' }\n format.json { render :show, status: :created, location: @test_plan }\n else\n format.html { render :new }\n format.json { render json: @test_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @assessment_plan = AssessmentPlan.new(assessment_plan_params)\n\n respond_to do |format|\n if @assessment_plan.save\n format.html { redirect_to @assessment_plan, notice: 'Assessment plan was successfully created.' }\n format.json { render :show, status: :created, location: @assessment_plan }\n else\n format.html { render :new }\n format.json { render json: @assessment_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @planitem = Planitem.new(params[:planitem])\n\n respond_to do |format|\n if @planitem.save\n format.html { redirect_to @planitem, notice: 'Planitem was successfully created.' }\n format.json { render json: @planitem, status: :created, location: @planitem }\n else\n format.html { render action: \"new\" }\n format.json { render json: @planitem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @inventory_plans = InventoryPlan.all\n end",
"def create_plan\n \tplanAttributes = {\n \"name\" => \"POC Subscription C4\",\n \"description\" => \"Premium Subscription\",\n \"type\" => \"INFINITE\",\n \"payment_definitions\" => [\n {\n \"name\" => \"Monthly Premium Subscription\",\n \"type\" => \"REGULAR\",\n \"frequency\" => \"MONTH\",\n \"frequency_interval\" => \"1\",\n \"amount\" => {\n \"value\" => \"30\",\n \"currency\" => \"USD\"\n },\n \"cycles\" => \"0\" \n }\n ],\n \"merchant_preferences\" => {\n \"return_url\" => \"http://localhost:3000/subscription/return\",\n \"cancel_url\" => \"http://localhost:3000/subscription/cancel\",\n \"auto_bill_amount\" => \"YES\",\n \"initial_fail_amount_action\" => \"CONTINUE\",\n \"max_fail_attempts\" => \"2\"\n }\n \t}\n \tplan = Plan.new(PlanAttributes)\n plan.create #returns true\n\n logger.info \"Plan: #{plan.id}\"\n patch = Patch.new\n patch.op = \"replace\"\n patch.path = \"/\";\n patch.value = { :state => \"ACTIVE\" }\n plan.update( patch )\n end",
"def create\n @site_plan = @product.site_plans.new(site_plan_params)\n\n respond_to do |format|\n if @site_plan.save\n format.html { redirect_to \"#{product_path(@product)}/#site_plan-tab\", notice: 'Site plan was successfully created.' }\n format.json { render json: @site_plan, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @site_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @subsrcibingplan = Subsrcibingplan.new(subsrcibingplan_params)\n\n respond_to do |format|\n if @subsrcibingplan.save\n format.html { redirect_to @subsrcibingplan, notice: 'Subsrcibingplan was successfully created.' }\n format.json { render :show, status: :created, location: @subsrcibingplan }\n else\n format.html { render :new }\n format.json { render json: @subsrcibingplan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \t @user = current_user\n\t @plan = @user.splans.new(plans_params)\n \n Stripe.api_key = @user.access_code\n \n Stripe::Plan.create(\n :amount => @plan.amount,\n :interval => @plan.interval,\n :name => @plan.name,\n :id => @plan.stripe_id,\n :currency =>@plan.currency\n )\n \n\t @plan.save\n redirect_to root_path\n \t\t\n end",
"def create\r\n @testplan = Testplan.new(params[:testplan])\r\n\r\n respond_to do |format|\r\n if @testplan.save\r\n format.html { redirect_to @testplan, notice: 'Testplan was successfully created.' }\r\n format.json { render json: @testplan, status: :created, location: @testplan }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @testplan.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /inventory_plans/1 PATCH/PUT /inventory_plans/1.json | def update
respond_to do |format|
if @inventory_plan.update(inventory_plan_params)
format.html { redirect_to @inventory_plan, notice: 'Inventory plan was successfully updated.' }
format.json { render :show, status: :ok, location: @inventory_plan }
else
format.html { render :edit }
format.json { render json: @inventory_plan.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n @plan = @store.plans.find(params[:id])\n flash[:error] = \"Cannot edit that plan.\" and redirect_to store_plans_path if @plan.is_readonly\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to store_plan_path(@plan), notice: 'Plan was successfully updated.' }\n format.json { head :ok }\n else\n @plan_types = Plan::PLAN_TYPES.to_a.map(&:reverse)\n @products = [] #it need be changed when products be done\n @frequences = [[\"Monthly\",\"monthly\"],[\"Weekly\",\"weekly\"],[\"Daily\",\"daily\"],[\"Hourly\",\"hourly\"]]\n format.html { render action: \"edit\" }\n format.json { render json: @plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(options = nil)\n request = Request.new(@client)\n path = \"/plans/\" + CGI.escape(@id) + \"\"\n data = {\n \"name\"=> @name, \n \"trial_period\"=> @trial_period, \n \"metadata\"=> @metadata, \n \"return_url\"=> @return_url, \n \"cancel_url\"=> @cancel_url\n }\n\n response = Response.new(request.put(path, data, options))\n return_values = Array.new\n \n body = response.body\n body = body[\"plan\"]\n \n \n return_values.push(self.fill_with_data(body))\n \n\n \n return_values[0]\n end",
"def update\n @plan = Plan.find(params[:id])\n\n if @plan.update(plan_params)\n head :no_content\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n\n if @plan.update(params[:plan])\n head :no_content\n else\n render json: @plan.errors, status: :unprocessable_entity\n end\n end",
"def update\n @plan_resource = PlanResource.find(params[:id])\n\n respond_to do |format|\n if @plan_resource.update_attributes(params[:plan_resource])\n format.html { redirect_to @plan_resource, notice: 'Plan resource was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @plan_resource.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n service_plan.update_attributes(service_plan_update_params)\n respond_with(service_plan)\n end",
"def update\n @test_plan = TestPlan.find(params[:id])\n\n respond_to do |format|\n if @test_plan.update_attributes(params[:test_plan])\n format.html { redirect_to @test_plan, notice: 'Test plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @test_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @planitem = Planitem.find(params[:id])\n\n respond_to do |format|\n if @planitem.update_attributes(params[:planitem])\n format.html { redirect_to @planitem, notice: 'Planitem was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @planitem.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @shipping_plan = ShippingPlan.find(params[:id])\n\n respond_to do |format|\n if @shipping_plan.update_attributes(params[:shipping_plan])\n format.html { redirect_to @shipping_plan, notice: 'Shipping plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @shipping_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n application_plan.update_attributes(application_plan_update_params)\n respond_with(application_plan)\n end",
"def update\n respond_to do |format|\n if @regular_plan.update(regular_plan_params)\n format.html { redirect_to user_regular_plans_path, notice: 'Regular plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @regular_plan }\n else\n format.html { render :edit }\n format.json { render json: @regular_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @assessment_plan.update(assessment_plan_params)\n format.html { redirect_to @assessment_plan, notice: 'Assessment plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @assessment_plan }\n else\n format.html { render :edit }\n format.json { render json: @assessment_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @schedule_plan = SchedulePlan.find(params[:id])\n\n respond_to do |format|\n if @schedule_plan.update_attributes(params[:schedule_plan])\n format.html { redirect_to @schedule_plan, notice: 'Schedule plan was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @schedule_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contract_plan.update(contract_plan_params)\n format.html { redirect_to @contract_plan, notice: 'Contract plan was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract_plan }\n else\n format.html { render :edit }\n format.json { render json: @contract_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plan = Plan.find(params[:id])\n\n respond_to do |format|\n if @plan.update_attributes(params[:plan])\n format.html { redirect_to(@plan, :notice => 'Plan was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @master_plan = MasterPlan.find(params[:id])\n\n respond_to do |format|\n if @master_plan.update_attributes(params[:master_plan])\n format.html { redirect_to master_plan_path(@master_plan), notice: 'Master plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @master_plan.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sslplan = Sslplan.find(params[:id])\n\n respond_to do |format|\n if @sslplan.update_attributes(params[:sslplan])\n format.html { redirect_to @sslplan, :notice => 'Sslplan was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @sslplan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @panel_plan = Panel::Plan.find(params[:id])\n\n respond_to do |format|\n if @panel_plan.update_attributes(params[:panel_plan])\n format.html { redirect_to(@panel_plan, :notice => 'Plan was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @panel_plan.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @billing_plan.update(billing_plan_params)\n format.html { redirect_to @billing_plan, notice: 'Billing plan was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @billing_plan.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /answer_respondents GET /answer_respondents.json | def index
@answer_respondents = AnswerRespondent.all
end | [
"def index\n @reply_answers = ReplyAnswer.all\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 index\n redirect_user\n @respondents = Respondent.all\n end",
"def show\n @answer = Answer.find(params[:id])\n\n render json: @answer\n end",
"def index\n @answer_sets = AnswerSet.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @answer_sets }\n end\n end",
"def show\n @respondent = Respondent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @respondent }\n end\n end",
"def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def answer_buttons\n render json: @current_user.answer_buttons\n end",
"def index\n @replies = Reply.all\n\n render json: @replies\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 index\n @replies = Reply.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @replies }\n end\n end",
"def show\n @answer_set = AnswerSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @answer_set }\n end\n end",
"def responses\n @proposal = current_user.proposals.find(params[:id])\n @responses = @proposal.responses\n\n respond_to do |format|\n format.html # responses.html.erb\n format.xml { render :xml => @responses }\n end\n end",
"def index\n @api_v1_answers = Api::V1::Answer.all\n end",
"def responses\n localized[:responses]\n end",
"def show\n @client_answer = ClientAnswer.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @client_answer }\n end\n end",
"def answers\n object.answers.collect do |a|\n {\n id: a.id,\n user_id: a.user_id,\n alternative_id: a.alternative_id\n }\n end\n end",
"def get_answers_for\n user = current_user\n render_401 and return unless user\n prospect = User.find_by_id(params[:for_user_id])\n render_404 and return unless prospect\n\n answers = ShortQuestion.get_latest_n_answers_for(prospect.id, params[:num], params[:start])\n render :json => {\n :success => true,\n :answers => answers\n }\n end",
"def index\n @m_answers = MAnswer.all\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /answer_respondents POST /answer_respondents.json | def create
@answer_respondent = AnswerRespondent.new(answer_respondent_params)
respond_to do |format|
if @answer_respondent.save
format.html { redirect_to @answer_respondent, notice: 'Answer respondent was successfully created.' }
format.json { render :show, status: :created, location: @answer_respondent }
else
format.html { render :new }
format.json { render json: @answer_respondent.errors, status: :unprocessable_entity }
end
end
end | [
"def index\n @answer_respondents = AnswerRespondent.all\n end",
"def answer_questions\n @project = Project.find(params[:id])\n @question_responses = []\n params[:question_responses].each do |question_id, response|\n @question_responses << QuestionResponse.create!(:question_id => question_id.to_i, :user => current_user, :response => response.to_i)\n end\n \n respond_to do |format|\n format.html { redirect_to @project, notice: 'Your answers have been saved. Thanks!' }\n format.json { render json: @question_responses, status: :created, location: @project }\n end\n end",
"def answer question\n\n # find the value that should be entered\n data = request[question[:reference_identifier]]\n\n response_set.responses.where(question_id: question).delete_all\n\n case question.type\n\n when :none\n answer = question.answers.first\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => data\n })\n\n when :one\n # the value is the reference identifier of the target answer\n answer = question.answers.where(reference_identifier: data).first\n\n unless answer.nil?\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :any\n # the value is an array of the chosen answers\n answers = question.answers.where(reference_identifier: data)\n answers.each do |answer|\n response_set.responses.create({\n answer: answer,\n question: question\n })\n end\n\n when :repeater\n # the value is an array of answers\n answer = question.answers.first\n i = 0\n data.each do |value|\n response_set.responses.create({\n answer: answer,\n question: question,\n answer.value_key => value,\n response_group: i\n })\n i += 1\n end\n\n else\n throw \"not handled> #{question.inspect}\"\n end\n\n end",
"def create\n \n respond_to do |format|\n \n if !params[:questions].nil? \n params[:questions].each {\n |q| \n type = Question.find_by_id(q[0]).question_type\n answer = (type == 2 ? Answer.find_by_id(q[1]).correct : nil)\n Response.new( \n {\n \"question_id\" => q[0],\n \"answer_id\" => type == 2 ? q[1] : nil,\n \"text\" => type == 1 ? q[1] : nil,\n \"user_id\" => current_user.id,\n \"question_group_id\" => params[:response][:question_group_id],\n \"correct\" => answer\n }\n ).save\n }\n format.html { redirect_to '/responses', notice: 'Your responses were successfully saved.' }\n else\n @response = Response.new(params[:response])\n if @response.save\n format.html { redirect_to @response, notice: 'Response was successfully created.' }\n format.json { render json: @response, status: :created, location: @response }\n end\n end\n end\n end",
"def create\n @answer = Answer.new(params[:answer])\n\n if @answer.save\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end",
"def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\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 respond_to do |format|\n if @answer_respondent.update(answer_respondent_params)\n format.html { redirect_to @answer_respondent, notice: 'Answer respondent was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer_respondent }\n else\n format.html { render :edit }\n format.json { render json: @answer_respondent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @test_answer = TestAnswer.new(test_answer_params)\n\n respond_to do |format|\n if @test_answer.save\n params[:questions].each do |question|\n answer = Answer.new\n answer.test_answer_id = @test_answer.id\n answer.question_id = question.first\n answer.value = question.second.to_i\n answer.save\n end\n format.html { redirect_to @test_answer, notice: 'Test answer was successfully created.' }\n format.json { render :show, status: :created, location: @test_answer }\n else\n format.html { render :new }\n format.json { render json: @test_answer.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 setup_answers\n create :answer, question: @question1, response_id: @response.id, answer: 1, comments: 'True_1'\n create :answer, question: @question2, response_id: @response.id, answer: 0, comments: 'False_2'\n create :answer, question: @question3, response_id: @response.id, answer: 0, comments: 'Answer2_3'\n create :answer, question: @question4, response_id: @response.id, answer: 1, comments: 'Answer1_4'\n create :answer, question: @question4, response_id: @response.id, answer: 1, comments: 'Answer3_4'\nend",
"def destroy\n @answer_respondent.destroy\n respond_to do |format|\n format.html { redirect_to answer_respondents_url, notice: 'Answer respondent was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @reply_answers = ReplyAnswer.all\n end",
"def create\n @respondent = Respondent.new(params[:respondent])\n\n respond_to do |format|\n if @respondent.save\n session[:respondent_id] = @respondent.id\n\n format.html { redirect_to new1_feedback_path }\n format.json { render json: @respondent, status: :created, location: @respondent }\n else\n format.html { render action: \"new\" }\n format.json { render json: @respondent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_reply\n @realtor = Realtor.find(params[:id])\n @inquiry = Inquiry.find(params[:inquiry_id])\n @inquiry.response = params[:response][0]\n @inquiry.save\n\n ApplicationMailer.email_notify(@inquiry.hunter.user).deliver\n\n flash[:notice] = 'Reply was successfully sent.'\n redirect_to viewreplyinquiries_realtor_path(@realtor)\n end",
"def for_create_question(questions, answer_options)\n answer_options.each do |op|\n questions.answer_options.create(answer: op)\n end\n response = Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }; answers = []\n questions.answer_options.each do |ans_opt|\n answers << { option: ans_opt.answer }\n end\n response[:question] = { id: questions.id, question: questions.question, points: questions.points, correct_option: questions.correct_option, options: answers }\n PushNotification.new(@user.device_token, 'Quiz', \"New quiz is available\").Send_Notification\n render json: response, status => 200\n end",
"def create\n @given_answer = GivenAnswer.new(given_answer_params)\n\n respond_to do |format|\n if @given_answer.save\n format.html { redirect_to @given_answer, notice: 'Given answer was successfully created.' }\n format.json { render :show, status: :created, location: @given_answer }\n else\n format.html { render :new }\n format.json { render json: @given_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_reply(question,body)\n post answers_path(question.category, question), :answer => { :body => body }\n assert_response :redirect\n answer = assigns(:answer)\n follow_redirect!\n assert_response :success\n assert_template \"questions/show\"\n answer\n end",
"def create\n @m_answer = @m_question.m_answers.build(m_answer_params)\n respond_to do |format|\n if @m_answer.save\n format.html { redirect_to m_question_path(@m_question) }\n format.json { render action: 'show', status: :created, location: @m_answer }\n else\n format.html { render action: 'new' }\n format.json { render json: @m_answer.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /answer_respondents/1 PATCH/PUT /answer_respondents/1.json | def update
respond_to do |format|
if @answer_respondent.update(answer_respondent_params)
format.html { redirect_to @answer_respondent, notice: 'Answer respondent was successfully updated.' }
format.json { render :show, status: :ok, location: @answer_respondent }
else
format.html { render :edit }
format.json { render json: @answer_respondent.errors, status: :unprocessable_entity }
end
end
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 update_resource @questionnaire, questionnaire_params\n respond_with @questionnaire unless response_body\n end",
"def update\n @question = Question.find(params[:question_id])\n @reply = @question.replies.find(params[:id])\n\n respond_to do |format|\n if @reply.update_attributes(params[:reply])\n format.html { redirect_to @question, notice: 'Reponse was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @reply.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer = Answer.find(params[:id])\n\n if @answer.update(params[:answer])\n head :no_content\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @reply_answer.update(reply_answer_params)\n format.html { redirect_to @reply_answer, notice: 'Reply answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @reply_answer }\n else\n format.html { render :edit }\n format.json { render json: @reply_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_v1_answer.update(api_v1_answer_params)\n format.html { redirect_to @api_v1_answer, notice: 'Answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_answer }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @respondent = Respondent.find(params[:id])\n\n respond_to do |format|\n if @respondent.update_attributes(params[:respondent])\n format.html { redirect_to @respondent, notice: 'Respondent was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @respondent.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @client_answer = ClientAnswer.find(params[:id])\n\n respond_to do |format|\n if @client_answer.update_attributes(params[:client_answer])\n format.html { redirect_to @client_answer, notice: 'Client answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @client_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @asked_to_answer.update(asked_to_answer_params)\n format.html { redirect_to @asked_to_answer, notice: 'Asked to answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @asked_to_answer }\n else\n format.html { render :edit }\n format.json { render json: @asked_to_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @answer_set = AnswerSet.find(params[:id])\n\n respond_to do |format|\n if @answer_set.update_attributes(params[:answer_set])\n format.html { redirect_to @answer_set, notice: 'Vastausryhmän päivittäminen onnistui.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @survey_answer = SurveyAnswer.find(params[:id])\n\n respond_to do |format|\n if @survey_answer.update_attributes(params[:survey_answer])\n format.html { redirect_to @survey_answer, notice: 'Survey answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer_option.update(answer_option_params)\n format.html { redirect_to @answer_option, notice: 'Opção de resposta atualizada.' }\n format.json { render :show, status: :ok, location: @answer_option }\n else\n format.html { render :edit }\n format.json { render json: @answer_option.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answers_set.update(answers_set_params)\n format.html { redirect_to @answers_set, notice: 'Possible answers set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @answers_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prompts_answer.update(prompts_answer_params)\n format.html { redirect_to @prompts_answer, notice: \"Prompts answer was successfully updated.\" }\n format.json { render :show, status: :ok, location: @prompts_answer }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @prompts_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fake_answer.update(fake_answer_params)\n format.html { redirect_to @fake_answer, notice: 'Fake answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @fake_answer }\n else\n format.html { render :edit }\n format.json { render json: @fake_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @submitted_answer = SubmittedAnswer.find(params[:id])\n\n respond_to do |format|\n if @submitted_answer.update_attributes(params[:submitted_answer])\n format.html { redirect_to @submitted_answer, notice: 'Submitted answer was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @submitted_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @has_answers_set.update(has_answers_set_params)\n format.html { redirect_to @has_answers_set, notice: 'Has possible answers set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @has_answers_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @potential_answer.update(potential_answer_params)\n format.html { redirect_to @potential_answer, notice: 'Potential answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @potential_answer }\n else\n format.html { render :edit }\n format.json { render json: @potential_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @comment_answer.update(comment_answer_params)\n format.html { redirect_to @comment_answer.answer, notice: 'El comentario ha sido modificado satisfactoriamente!' }\n format.json { render :show, status: :ok, location: @comment_answer }\n else\n format.html { render :edit }\n format.json { render json: @comment_answer.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /answer_respondents/1 DELETE /answer_respondents/1.json | def destroy
@answer_respondent.destroy
respond_to do |format|
format.html { redirect_to answer_respondents_url, notice: 'Answer respondent was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n answer = Answer.find(params[:answer_id])\n answer.destroy\n \n render json: {success: true}\n end",
"def destroy\n @client_answer = ClientAnswer.find(params[:id])\n @client_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to client_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respondent = Respondent.find(params[:id])\n @respondent.destroy\n\n respond_to do |format|\n format.html { redirect_to respondents_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer.destroy\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 @answer = current_user.answers.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\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 @api_v1_answer.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_answers_url, notice: 'Answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @question_answer = Question::Answer.find(params[:id])\n @question_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to question_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey_answer = SurveyAnswer.find(params[:id])\n @survey_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_set = AnswerSet.find(params[:id])\n @answer_set.destroy\n\n respond_to do |format|\n format.html { redirect_to answer_sets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_type.destroy\n respond_to do |format|\n format.html { redirect_to answer_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @client_answer = ClientAnswer.find(params[:id])\n @client_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to(client_answers_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @icebreaker_answer.destroy\n respond_to do |format|\n format.html { redirect_to icebreaker_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @survey_answer.destroy\n respond_to do |format|\n format.html { redirect_to survey_questions_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post_answer.destroy\n respond_to do |format|\n format.html { redirect_to post_answers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @responder = Responder.find(params[:id])\n @responder.destroy\n\n respond_to do |format|\n format.html { redirect_to responders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_type = AnswerType.find(params[:id])\n @answer_type.destroy\n\n respond_to do |format|\n format.html { redirect_to answer_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @answer_option.destroy\n respond_to do |format|\n format.html { redirect_to answer_options_url, notice: 'Opção de resposta deletada.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_answer = TestAnswer.find(params[:id])\n @test_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to test_answers_url }\n format.json { head :ok }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set default values if nothing has input for max and backup student | def default_values
self.max_student ||= 0
self.backup_student ||= 0
end | [
"def default_values\n self.pmu_type ||= \"uncommitted\"\n self.completed ||= false\n self.max_people ||= 1\n end",
"def set_default_values\n self.base_exp ||= 0\n self.time_bonus_exp ||= 0\n end",
"def default_values\n \tself.total_worth ||= 0\n \tend",
"def set_creation_defaults\n if self.max_days == 0\n self.max_days = nil\n self.end_date = nil\n else\n self.end_date = self.start_date + self.max_days\n end\n self.percent = 0\n end",
"def set_defaults\n self.avgduration ||= 0.0\n self.totalvisits ||= 0\n end",
"def set_defaults\n\n # first apportionment\n if self.grant.present? && self.grant.grant_apportionments.count == 0\n self.sourceable ||= self.grant.sourceable\n self.name ||= 'Primary'\n self.fy_year ||= self.grant.fy_year\n self.amount ||= self.grant.amount\n self.created_by_user_id ||= self.grant.created_by_user_id\n self.updated_by_user_id ||= self.grant.updated_by_user_id\n end\n end",
"def set_defaults\n self.pet_age = 5 if pet_age.blank?\n self.energy_level = 3 if energy_level.to_i <= 0 || energy_level.to_i > 5\n self.size_id = 1 if size_id.to_i <= 0 || energy_level.to_i > 4\n self\n end",
"def set_defaults\n self.balance ||= 0\n end",
"def set_defaults\n self.avgduration ||= 0.0\n self.totalvisits ||= 0\n self.name ||= \"unnamed site\"\n end",
"def default_values\n self.five_choices = true\n self.two_choices = false\n self.final_choice = false\n self.current_stage = \"five_choices\"\n end",
"def set_max(max)\n self[:max] = (max > 0 ? max : 1)\n end",
"def set_max(max)\n self.max = (max > 0 ? max : 1)\n end",
"def max_students_valid_for_loc\n if(self.location != nil && self.max_students != nil)\n if self.location.max_capacity < self.max_students\n errors.add(:camp, \"max students cannot exceed max capacity of a location\")\n end\n end\n end",
"def preset_default_values( params_hash = {} )\n unless self.patient # Set current patient only if not set\n begin\n if params_hash[:patient_id]\n self.patient_id = params_hash[:patient_id].to_i\n end\n rescue\n self.patient_id = nil\n end\n end\n # If patient is set and price not, get the default price:\n if (self.patient_id.to_i > 0) and (self.price.to_f < 0.01)\n if p = Patient.find_by_id( self.patient_id )\n self.price = p.default_invoice_price\n end\n end\n\n unless self.date_schedule # A default date schedule must be set anyhow:\n begin \n self.date_schedule = params_hash[:date_schedule] ? params_hash[:date_schedule] : Time.now\n rescue # Set default date for this entry:\n self.date_schedule = Time.now\n end\n end\n self\n end",
"def set_max(max)\n Utility::check_types({ max=>Integer }) if $DEBUG\n @max = max if(max >= 0)\n nil\n end",
"def default_values\n self.video_quality ||= %w[HD SD].sample\n self.price ||= (5.0...11.0)\n end",
"def standardizeValue()\n minMax = []\n minMax = getMinMax(@skater_data,\"0\")\n zero(@skater_data,\"0\",minMax)\n minMax = getMinMax(@skater_data,\"1\")\n zero(@skater_data,\"1\",minMax)\n minMax = getMinMax(@goalie_data,\"G\")\n zero(@goalie_data,\"G\",minMax)\nend",
"def set_defaults\n super\n self.assessed_rating ||= transam_asset ? (transam_asset.condition_updates.last.try(:reported_condition_rating)) : ConditionType.max_rating\n self.asset_event_type ||= AssetEventType.find_by_class_name(self.name)\n end",
"def set_default\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
show how many seats available, show full if left 0 | def seats_available
available = total_student - UserEvent.joined_students_count(self.id)
if available > 0
available
else
"FULL"
end
end | [
"def remaining_seats(showing)\n booked = 0\n Booking.where(showing_id: showing.id).each do |booking|\n booked += booking.no_of_people\n end\n remaining = showing.capacity - booked\n return remaining > 0 ? \"Available Seats - #{remaining}\" : \"SOLD OUT!\"\n end",
"def seats_left\n available_seats = [total_seats - reserved_seats, 0].max\n end",
"def seats_available\n maximum_seats - EnrolledCourse.where(course_id: id).count\n end",
"def size\n # gets only the seats from the first round\n starting_seats.select{ |s| s.round == 0 }.size\n end",
"def seats_booked\n maxparticipants - seats_free\n end",
"def total_seats_left\n [self.house_capacity - vouchers.size, 0].max\n end",
"def seats_left\n student_limit - students.count\n end",
"def num_of_seats_available\n self.movie.capacity > self.movie.seats_sold ? (self.movie.seats_sold += 1) : false\n self.movie.save\n end",
"def available_seats\n reserved_seats = find_reserved_seats(date, time)\n return location.number_of_seats - reserved_seats\n end",
"def taken_seats\n @seat_numbers - @available_seats\n end",
"def total_seats\n\t\tseats + waitlist_seats\n\tend",
"def size\n starting_seats.size\n end",
"def number_of_bookings\n\t\troom_reservations.empty? ? 0 : capacity - min_disponibility\n\tend",
"def seats_free\n subevents.map(&:seats_free).min || 0\n end",
"def seats_waitlisted_same_user_same_tour\n waitlist_same_user_same_tour ? waitlist_same_user_same_tour.num_seats : 0\n end",
"def house_capacity\n has_reserved_seating? ? seatmap.seat_count : attributes['house_capacity']\n end",
"def seats_booked_same_user_same_tour\n return booking_same_user_same_tour ? booking_same_user_same_tour.num_seats : 0\n end",
"def remaining_bookings_count\n @remaining_bookings_count ||= events.map(&:seats_free).min || 0\n end",
"def print_seats_unavailable\n puts \"#{@unavailable_seats} Not available, Please select different seats \"\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
determine if an event is expired | def is_expired?
self.event_date < DateTime.now
end | [
"def is_expired?\n (!end_time.nil? and end_time < Clock.time)\n end",
"def expired?\n false\n end",
"def expired?\n Time.now > valid_until\n end",
"def expired?\n self.expiration.past? || self[:expired]\n end",
"def expired?\n expiration_timestamp && (Time.now > expiration_timestamp)\nend",
"def time_expired?\n (Time.now - @duration) > @start_time\n end",
"def expired?\n self.alert_expiration < DateTime.now\nend",
"def expired?\n @expires_in && @created_at + @expires_in <= Time.now.to_f\n end",
"def expired?\n Time.now > self.deadline\n end",
"def request_expired?\n parsed_timestamp < request_expires_at\n end",
"def expired?\n if(DateTime.now > auction_end.localtime) \n return true\n else \n return false\n end\n end",
"def expired?\n expire_date <= Time.zone.now\n end",
"def expired?\n expiry_date.expired?\n end",
"def expired?(time = Time.now)\n if expires = self.expires\n expires <= time\n else\n false\n end\n end",
"def expired_time? time\n time + self.class.ttl_in_seconds.to_i < Time.now\n end",
"def expired_data?\n updated_at < EXPIRE_PERIOD.minutes.ago\n end",
"def expired?\n return false if @task.expires_after.blank?\n\n expire_duration.from_now(@scheduled_time) < Time.now.in_time_zone(@task.time_zone)\n end",
"def tgt_expired?\n return true if @last_updated.nil? or @ticket_granting_ticket.nil?\n (@last_updated + 5) < Time.now.to_i # TGTs have an 8 hour life\n end",
"def access_token_expired?\n delegate.authorization.expired?\n #!!(Time.now >= (Time.at(expires_at) - 5 * 60))\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
validate end time cannot be earlier than start time | def end_time_cannot_be_earlier_than_start_time
if end_time && start_time
if end_time < start_time
errors.add(:end_time, "End time should not be earlier than start time.")
end
end
end | [
"def check_times\n if start_time >= end_time\n errors.add(:end_time, \"must be after Start time\")\n end \n end",
"def start_time_must_be_before_end_time\n errors.add(:start_time, \"start time cannot be after end time\") if (start_time > end_time)\n end",
"def end_time_after_start_time\n if start_time.present? && end_time.present?\n if end_time <= start_time\n errors.add(:end_time, \"must be after start time\")\n end\n end\n end",
"def start_time_before_end_time\n if start_time and end_time and start_time >= end_time\n errors.add(:start_time, \"Must be before end time\")\n errors.add(:end_time, \"Must be after start time\")\n end\n end",
"def start_comes_before_end\n return if (start_time < end_time)\n\n errors[:start_time] << \"must come before end time\"\n errors[:end_time] << \"must come after start time\"\n end",
"def end_time_after_start_time\n if self.end_time && self.end_time < self.start_time\n self.errors.add(:end_time, \"The end time must be after the start time\")\n end\n end",
"def validate_start_date_before_end_date\n\t\tif end_time <= start_time\n\t\t\terrors.add(:end_time, \"must be after start time\")\n\t\tend\n\tend",
"def starts_before_end_time\n return unless start_at.present? && end_at.present? && start_at > end_at\n\n errors.add(:start_at, 'must be before end_at')\n end",
"def start_time_lt_end_time\n\t \tif datetime_end.blank? or datetime_start.blank?\n\t \t\treturn true\n\t \tend\n\t \tif datetime_start > datetime_end\n\t \t\terrors.add(:datetime_start, \"have to be earlier than end date\")\n\t \telse\n\t \t\treturn true\n\t\t end \n \tend",
"def start_must_be_before_end_time\n unless active_start_time.nil? or active_stop_time.nil?\n errors.add(:active_start_time, \"must be before stop time\") unless\n active_start_time < active_stop_time\n end\n end",
"def start_is_before_end\n if self.started_at.present? && self.ended_at.present?\n\t\t errors.add(:started_at, \"can't be before the start time\") if self.ended_at < self.started_at\n end\n end",
"def check_for_time_difference\n if self.actual_duration.present?\n if self.start_time.present? && self.end_time.present?\n duration =(self.end_time - self.start_time)/3600\n val1 = duration.to_f.roundf2(2).to_s\n val2 = self.actual_duration.to_f.roundf2(2).to_s\n if duration > 0 && !val1.eql?(val2)\n errors.add_to_base(:tne_valid_time)\n end\n end\n end\n end",
"def ensure_started_at_is_before_ended_at\n if started_at && ended_at && started_at >= ended_at\n errors.add(:ended_at, :is_before_started_at)\n end\n end",
"def start_after_now\n unless start_time.nil? || end_time.nil?\n errors[:start_time] << \"can't be in the past\" if start_time < Time.now\n end\n end",
"def day_is_not_longer_than_24_hours\n if start_time && end_time\n errors.add(:end_time, \"must be no more than 24 hours after the start time\") unless (end_time - start_time)/3600 < 24\n end\n end",
"def end_houdd_time_is_earlier_than_start_houdd_time\n return if start_houdd_time.blank? or end_houdd_time.blank?\n if end_houdd_time < start_houdd_time\n errors.add(:base, I18n.t('activerecord.errors.models.mission.attributes.end_houdd_time_is_earlier_than_start_houdd_time'))\n end\n end",
"def shift_end_hour\n if self.start_time.hour >= 0 && self.start_time.hour <= 2 && self.end_time.hour > 2 \n errors.add(:end_time, 'must be between 7am and 3am')\n end\n if self.end_time.hour > 2 && self.end_time.hour < 7\n errors.add(:end_time, 'must be between 7am and 3am')\n end \n end",
"def workout_duration_is_valid?\n self.start_time < self.finish_time ? true : false\n end",
"def check_course_times\n self.end = start if start > self.end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /prod_cotis GET /prod_cotis.json | def index
@prod_cotis = ProdCoti.all
end | [
"def index\n @cotas = Cota.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cotas }\n end\n end",
"def index\n @costa_tropicals = CostaTropical.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @costa_tropicals }\n end\n end",
"def index\n @categoria_cotas = CategoriaCota.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categoria_cotas }\n end\n end",
"def index\n @produtos = Produto.all\n\n render json: @produtos\n end",
"def index\n if(params[:num_cartao])\n @beneficiario = Beneficiario.find_by(:num_cartao => params[:num_cartao])\n render json: @beneficiario\n else\n @beneficiarios = Beneficiario.all\n end\n end",
"def index\n @cocktails = Cocktail.where(\"oficial = ?\", false)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cocktails }\n end\n end",
"def index\n @cocktails = Cocktail.all\n #render json: @cocktails\n end",
"def get_catalog_data\n ConnectionController.service_request(\"catalog.php\",nil,\"get\",nil,nil,url_for(:controller => :Product, :action => :http_callback),nil,nil)\n end",
"def index\n @commemts = Commemt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commemts }\n end\n end",
"def index\n @procesos = Proceso.all\n\n render json: @procesos\n end",
"def show\n @costa_tropical = CostaTropical.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @costa_tropical }\n end\n end",
"def index\n @colegios = Colegio.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @colegios }\n end\n end",
"def index\n @convos = Convo.all\n render json: @convos\n end",
"def index\n @intranet_cartorios = Intranet::Cartorio.all\n end",
"def show\n @comit = Comit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comit }\n end\n end",
"def show\n render json: @produto\n end",
"def index\n @comits = Comit.find(:all, :order => 'time DESC').paginate(:page => params[:page], :per_page => 30)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @comits }\n end\n end",
"def index\n #@csosns = Csosn.all\n @csosns = Csosn.paginate(:page => params[:page], :per_page => 10)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @csosns }\n end\n end",
"def index\n @cutouts = Cutout.all\n\t\t@res = Cutout.list(params, request)\n\t\t@cutouts = @res['items']\n\t\t\n\t\tif @res['cutout']\n\t\t\t@cutout = @res['cutout']\n\t\tend\n\t\t\n respond_to do |format|\n format.json { render :json => @res.to_json(:include => {:product => {} }) }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /prod_cotis POST /prod_cotis.json | def create
@prod_coti = ProdCoti.new(prod_coti_params)
respond_to do |format|
if @prod_coti.save
format.html { redirect_to @prod_coti, notice: 'Prod coti was successfully created.' }
format.json { render :show, status: :created, location: @prod_coti }
else
format.html { render :new }
format.json { render json: @prod_coti.errors, status: :unprocessable_entity }
end
end
end | [
"def create\n @cotizclomul = Cotizclomul.new(cotizclomul_params)\n @cotizclomul.confirmacion = 'Por confirmar'\n\n numerocaracteresclave = 20\n caracteresclavecompra = %w{ 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }\n @cotizclomul.clavecompra = ''\n numerocaracteresclave.times do\n indiceletraescogida = rand(caracteresclavecompra.length)\n @cotizclomul.clavecompra = @cotizclomul.clavecompra + caracteresclavecompra[indiceletraescogida]\n end\n\n respond_to do |format|\n if @cotizclomul.save\n RemisorCotizacionesMailer.confirmacioncotizclomul(@cotizclomul).deliver_now\n p HTTParty.post('http://localhost:3002/api/prices', {body: @cotizclomul.to_json, headers: {'Content-Type': 'application/json'}})\n format.html { redirect_to @cotizclomul, notice: 'Cotizclomul was successfully created.' }\n format.json { render :show, status: :created, location: @cotizclomul }\n else\n format.html { render :new }\n format.json { render json: @cotizclomul.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cotizesccam = Cotizesccam.new(cotizesccam_params)\n @cotizesccam.confirmacion = 'Por confirmar'\n\n numerocaracteresclave = 20\n caracteresclavecompra = %w{ 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }\n @cotizesccam.clavecompra = ''\n numerocaracteresclave.times do\n indiceletraescogida = rand(caracteresclavecompra.length)\n @cotizesccam.clavecompra = @cotizesccam.clavecompra + caracteresclavecompra[indiceletraescogida]\n end\n\n respond_to do |format|\n if @cotizesccam.save\n RemisorCotizacionesMailer.confirmacioncotizesccam(@cotizesccam).deliver_now\n p HTTParty.post('http://localhost:3002/api/prices', {body: @cotizclomul.to_json, headers: {'Content-Type': 'application/json'}})\n format.html { redirect_to @cotizesccam, notice: 'Cotizesccam was successfully created.' }\n format.json { render :show, status: :created, location: @cotizesccam }\n else\n format.html { render :new }\n format.json { render json: @cotizesccam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @intranet_cartorio = Intranet::Cartorio.new(intranet_cartorio_params)\n\n respond_to do |format|\n if @intranet_cartorio.save\n format.html { redirect_to @intranet_cartorio, notice: \"Cartorio was successfully created.\" }\n format.json { render :show, status: :created, location: @intranet_cartorio }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @intranet_cartorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cotizmescam = Cotizmescam.new(cotizmescam_params)\n @cotizmescam.confirmacion = 'Por confirmar'\n\n numerocaracteresclave = 20\n caracteresclavecompra = %w{ 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }\n @cotizmescam.clavecompra = ''\n numerocaracteresclave.times do\n indiceletraescogida = rand(caracteresclavecompra.length)\n @cotizmescam.clavecompra = @cotizmescam.clavecompra + caracteresclavecompra[indiceletraescogida]\n end\n\n respond_to do |format|\n if @cotizmescam.save\n RemisorCotizacionesMailer.confirmacioncotizmescam(@cotizmescam).deliver_now\n p HTTParty.post('http://localhost:3002/api/prices', {body: @cotizmescam.to_json, headers: {'Content-Type': 'application/json'}})\n format.html { redirect_to @cotizmescam, notice: 'Cotizmescam was successfully created.' }\n format.json { render :show, status: :created, location: @cotizmescam }\n else\n format.html { render :new }\n format.json { render json: @cotizmescam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cotizmesexp = Cotizmesexp.new(cotizmesexp_params)\n @cotizmesexp.confirmacion = 'Por confirmar'\n\n numerocaracteresclave = 20\n caracteresclavecompra = %w{ 0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z }\n @cotizmesexp.clavecompra = ''\n numerocaracteresclave.times do\n indiceletraescogida = rand(caracteresclavecompra.length)\n @cotizmesexp.clavecompra = @cotizmesexp.clavecompra + caracteresclavecompra[indiceletraescogida]\n end\n\n respond_to do |format|\n if @cotizmesexp.save\n RemisorCotizacionesMailer.confirmacioncotizmesexp(@cotizmesexp).deliver_now\n p HTTParty.post('http://localhost:3002/api/prices', {body: @cotizmesexp.to_json, headers: {'Content-Type': 'application/json'}})\n format.html { redirect_to @cotizmesexp, notice: 'Cotizmesexp was successfully created.' }\n format.json { render :show, status: :created, location: @cotizmesexp }\n else\n format.html { render :new }\n format.json { render json: @cotizmesexp.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @copon = Copon.new(copon_params)\n get_product(@copon, params.require(:copon)[:product])\n set_associative_criteria @copon, params.require(:copon)\n\n respond_to do |format|\n if @copon.save\n format.html { redirect_to @copon, notice: 'Copon was successfully created.' }\n format.json { render :show, status: :created, location: @copon }\n else\n format.html { render :new }\n format.json { render json: @copon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @produto = Produto.new(produto_params)\n\n if @produto.save\n render json: @produto, status: :created, location: @produto\n else\n render json: @produto.errors, status: :unprocessable_entity\n end\n end",
"def create\n puts params\n @comit = Comit.new(params[:comit])\n\n respond_to do |format|\n if @comit.save\n format.html { redirect_to @comit, notice: 'commit was successfully created.' }\n format.json { render json: @comit, status: :created, location: @comit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @comit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cotizacione = Cotizacione.new(cotizacione_params)\n\n respond_to do |format|\n if @cotizacione.save\n format.html { redirect_to @cotizacione, notice: 'Cotizacione was successfully created.' }\n format.json { render :show, status: :created, location: @cotizacione }\n else\n format.html { render :new }\n format.json { render json: @cotizacione.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @troca_produto = TrocaProduto.new(troca_produto_params)\n\n respond_to do |format|\n if @troca_produto.save\n format.html { redirect_to @troca_produto, notice: \"Troca produto was successfully created.\" }\n format.json { render :show, status: :created, location: @troca_produto }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @troca_produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @produto = Produto.new(params[:produto])\n @produto.empresa = session[:usuario].empresa\n \n params[:produto][:preco_compra] = converte_valor_banco params[:produto][:preco_compra]\n params[:produto][:preco_venda] = converte_valor_banco params[:produto][:preco_venda]\n\n respond_to do |format|\n if @produto.save\n format.html { redirect_to @produto, notice: 'Produto was successfully created.' }\n format.json { render json: @produto, status: :created, location: @produto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @prod_of_nec = ProdOfNec.new(prod_of_nec_params)\n\n respond_to do |format|\n if @prod_of_nec.save\n format.html { redirect_to @prod_of_nec, notice: 'Prod of nec was successfully created.' }\n format.json { render action: 'show', status: :created, location: @prod_of_nec }\n else\n format.html { render action: 'new' }\n format.json { render json: @prod_of_nec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @est_prod_of_nec = EstProdOfNec.new(est_prod_of_nec_params)\n\n respond_to do |format|\n if @est_prod_of_nec.save\n format.html { redirect_to @est_prod_of_nec, notice: 'Est prod of nec was successfully created.' }\n format.json { render action: 'show', status: :created, location: @est_prod_of_nec }\n else\n format.html { render action: 'new' }\n format.json { render json: @est_prod_of_nec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @costa_tropical = CostaTropical.new(params[:costa_tropical])\n\n respond_to do |format|\n if @costa_tropical.save\n format.html { redirect_to @costa_tropical, notice: 'Costa tropical was successfully created.' }\n format.json { render json: @costa_tropical, status: :created, location: @costa_tropical }\n else\n format.html { render action: \"new\" }\n format.json { render json: @costa_tropical.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @intranet_financeiro_tipos_cobanca = Intranet::FinanceiroTiposCobanca.new(intranet_financeiro_tipos_cobanca_params)\n\n respond_to do |format|\n if @intranet_financeiro_tipos_cobanca.save\n format.html { redirect_to @intranet_financeiro_tipos_cobanca, notice: \"Financeiro tipos cobanca was successfully created.\" }\n format.json { render :show, status: :created, location: @intranet_financeiro_tipos_cobanca }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @intranet_financeiro_tipos_cobanca.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n processos = ActiveSupport::JSON.decode(params[:produto_processos]) if params[:produto_processos]\n respond_to do |format|\n if processos\n produto = Produto.find(params[:produto_processo][\"produto_id\"]) if params[:produto_processo]\n processos.each do |p|\n processo = ProdutoProcesso.create(:produto_id => produto.id, :processo_id => p[\"id\"], :tempo_padrao => p[\"tempo_padrao\"], :producao_hora => p[\"producao_hora\"])\n end\n format.html { render :json => {:success => true} }\n end\n end\n end",
"def create\n @st_produto = StProduto.new(st_produto_params)\n\n respond_to do |format|\n if @st_produto.save\n format.html { redirect_to @st_produto, notice: 'St produto was successfully created.' }\n format.json { render :show, status: :created, location: @st_produto }\n else\n format.html { render :new }\n format.json { render json: @st_produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @taco = Taco.new(taco_params)\n\n if @taco.save\n render json: @taco, status: :created, location: @taco\n else\n render json: @taco.errors, status: :unprocessable_entity\n end\n end",
"def create\n @productonegocio = Productonegocio.new(params[:productonegocio])\n\n respond_to do |format|\n if @productonegocio.save\n format.html { redirect_to @productonegocio, notice: 'Productonegocio was successfully created.' }\n format.json { render json: @productonegocio, status: :created, location: @productonegocio }\n else\n format.html { render action: \"new\" }\n format.json { render json: @productonegocio.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /prod_cotis/1 PATCH/PUT /prod_cotis/1.json | def update
respond_to do |format|
if @prod_coti.update(prod_coti_params)
format.html { redirect_to @prod_coti, notice: 'Prod coti was successfully updated.' }
format.json { render :show, status: :ok, location: @prod_coti }
else
format.html { render :edit }
format.json { render json: @prod_coti.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n respond_to do |format|\n if @cotizclomul.update(cotizclomul_params)\n format.html { redirect_to @cotizclomul, notice: 'Cotizclomul was successfully updated.' }\n format.json { render :show, status: :ok, location: @cotizclomul }\n else\n format.html { render :edit }\n format.json { render json: @cotizclomul.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @productos_json.update(productos_json_params)\n format.html { redirect_to @productos_json, notice: 'Productos json was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @productos_json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prod_of_nec.update(prod_of_nec_params)\n format.html { redirect_to @prod_of_nec, notice: 'Prod of nec was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prod_of_nec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cotiz_clo_mul.update(cotiz_clo_mul_params)\n format.html { redirect_to @cotiz_clo_mul, notice: 'Cotiz clo mul was successfully updated.' }\n format.json { render :show, status: :ok, location: @cotiz_clo_mul }\n else\n format.html { render :edit }\n format.json { render json: @cotiz_clo_mul.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @produto = Produto.find(params[:id])\n\n if @produto.update(produto_params)\n head :no_content\n else\n render json: @produto.errors, status: :unprocessable_entity\n end\n end",
"def update\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n if @productonegocio.update_attributes(params[:productonegocio])\n format.html { redirect_to @productonegocio, notice: 'Productonegocio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @productonegocio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @prod_servi.update(prod_servi_params)\n format.html { redirect_to @prod_servi, notice: 'Prod servi was successfully updated.' }\n format.json { render :show, status: :ok, location: @prod_servi }\n else\n format.html { render :edit }\n format.json { render json: @prod_servi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n set_associative_criteria @copon, params.require(:copon)\n get_product(@copon, params.require(:copon)[:product])\n respond_to do |format|\n if @copon.update(copon_params)\n format.html { redirect_to @copon, notice: 'Copon was successfully updated.' }\n format.json { render :show, status: :ok, location: @copon }\n else\n format.html { render :edit }\n format.json { render json: @copon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contract_product.update_attributes(params[:contract_product])\n format.html { redirect_to @contract_product, notice: 'Contract product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contract_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @produto.update(produto_params)\n respond_with @produto\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def editProd()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n p = Product.find(params[:id])\n status = p.update(name: params[:name], price: params[:price].to_f, category_id: params[:cat_id])\n error = \"\"\n if(p.errors.full_messages.count > 0)\n error = c.errors.full_messages[0]\n end\n render json: {status: status, reason: error, data: \"\"}\n end",
"def update\n respond_to do |format|\n if @intranet_cartorio.update(intranet_cartorio_params)\n format.html { redirect_to @intranet_cartorio, notice: \"Cartorio was successfully updated.\" }\n format.json { render :show, status: :ok, location: @intranet_cartorio }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @intranet_cartorio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @compra_produto.update(compra_produto_params)\n format.html { redirect_to @compra_produto, notice: 'Compra produto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @compra_produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @carts_product = @cart.carts_products.find(params[:id])\n\n respond_to do |format|\n if @carts_product.update_attributes(params[:carts_product])\n format.html { redirect_to @cart, notice: 'Carts product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @carts_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @complaint = Complaint.find(params[:id])\n\n if @complaint.update_attributes(params[:complaint])\n head :no_content\n else\n render json: @complaint.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @especie_catalogo.update(especie_catalogo_params)\n format.html { redirect_to @especie_catalogo, notice: 'Especie catalogo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @especie_catalogo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contato_produto = ContatoProduto.find(params[:id])\n\n respond_to do |format|\n if @contato_produto.update_attributes(params[:contato_produto])\n format.html { redirect_to [:admin, @contato_produto], notice: 'Contato produto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contato_produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @mixproducto = Mixproducto.find(params[:id])\n\n respond_to do |format|\n if @mixproducto.update_attributes(params[:mixproducto])\n format.html { redirect_to @mixproducto, notice: 'Mixproducto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mixproducto.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /prod_cotis/1 DELETE /prod_cotis/1.json | def destroy
@prod_coti.destroy
respond_to do |format|
format.html { redirect_to prod_cotis_url, notice: 'Prod coti was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @prod_cli.destroy\n respond_to do |format|\n format.html { redirect_to prod_clis_url, notice: 'produto excluido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @prod_of_nec.destroy\n respond_to do |format|\n format.html { redirect_to prod_of_necs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @productos_json.destroy\n respond_to do |format|\n format.html { redirect_to productos_jsons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @est_prod_of_nec.destroy\n respond_to do |format|\n format.html { redirect_to est_prod_of_necs_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n\n head :no_content\n end",
"def destroy\n @contato_produto = ContatoProduto.find(params[:id])\n @contato_produto.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_contato_produtos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cartorio.destroy\n respond_to do |format|\n format.html { redirect_to cartorios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @big_concert.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/big_concerts/' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prodact.destroy\n respond_to do |format|\n format.html { redirect_to prodacts_path, notice: 'Prodact was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prod_servi.destroy\n respond_to do |format|\n format.html { redirect_to prod_servis_url, notice: 'Prod servi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cotiz_clo_mul.destroy\n respond_to do |format|\n format.html { redirect_to cotiz_clo_muls_url, notice: 'Cotiz clo mul was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @intranet_cartorio.destroy\n respond_to do |format|\n format.html { redirect_to intranet_cartorios_url, notice: \"Cartorio was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @productonegocio = Productonegocio.find(params[:id])\n @productonegocio.destroy\n\n respond_to do |format|\n format.html { redirect_to productonegocios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @taco.destroy\n render json: @taco, status: :ok\n end",
"def destroy\n @cartum = Cartum.find(params[:id])\n @cartum.destroy\n\n respond_to do |format|\n format.html { redirect_to carta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @caracteristica_cartum = CaracteristicaCartum.find(params[:id])\n @caracteristica_cartum.destroy\n\n respond_to do |format|\n format.html { redirect_to caracteristica_carta_url }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
progress goal see for testing if an internal or external goal | def is_internal?
return (self.goal_type % 2) == 1
end | [
"def goal_test(state)\n return state == @goal\n end",
"def account_setup?\n self.setup?(:goal)\n end",
"def is_valid_for_execution\n (@metadata[\"short_dest_repo_name\"] == \"osrf/gazebo\" and @pr_status == :update) ? false : true\n end",
"def test_continue_truthy\n turns_remaining_miner = Prospector.new(0, @dummy_location, num_turns = 1)\n assert turns_remaining_miner.continue?\n end",
"def can_progress?\n lesson < 100 || lesson_part < 3\n end",
"def goals_progress(type)\n exp = type == \"expense\" ? true : false\n sum_actual = 0\n sum_target = 0\n self.goals.each do |goal|\n if goal.is_expense? == exp && goal.end_date >= Date.today\n sum_target += goal.target_value\n sum_actual += goal.total_actual_value\n end\n end\n sum_target == 0 ? 0 : (sum_actual/sum_target) #0% for when there is no goal matching the type.\n end",
"def check_on_track?\n result = 0 \n\n self.goals.incomplete.find_each do |goal|\n if !goal.on_track?\n # Student grade will not be on-track if there is any goal not on-track.\n result = 2\n break\n else\n # On-track if all goals are on-track.\n result = 1\n end\n end\n\n return result \n end",
"def pbInBugContest?\n return pbBugContestState.inProgress?\nend",
"def met_goal?()\n self.total_pledged() >= self.goal()\n end",
"def running_test_step; end",
"def test_actions\n pending? ? pending_actions : completed_actions\n end",
"def work_in_progress\n has_wip_label = danger_file.github.pr_labels.any? { |label| label.include? 'WIP' }\n has_wip_title = danger_file.github.pr_title.include? '[WIP]'\n\n danger_file.warn('PR is classed as Work in Progress') if has_wip_label || has_wip_title\n end",
"def test_ut_t4_mtv_pu_002\n pj = Pj.find(3)\n assert_equal FALSE, pj.has_analyzed_task?\n end",
"def pbInBugContest?\r\n return pbBugContestState.inProgress?\r\nend",
"def inform_goal_of_new_contribution\n self.goal.check_for_completion!(self.goal_participant)\n end",
"def passed?; end",
"def check_project\n return if project.dataset_names.empty?\n return unless project.done_preprocessing?(false)\n to_run = project.next_distances(true)\n to_run = project.next_inclade(true) if to_run.nil?\n queue_job(to_run) unless to_run.nil?\n end",
"def should_run_for(resource, goal)\n if @rule[1].arity == 2\n rule_accepts = @rule[1].call(resource, @params)\n else\n rule_accepts = @rule[1].call(resource)\n end\n return false unless rule_accepts\n !@extra.find do |condition|\n !condition.should_run_for(resource, goal)\n end\n end",
"def _run_checking(maestro, status, _hParams)\n return false unless status.status == :checking &&\n maestro[:status] != :active\n status.is :starting\n true\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
sets goal to ABANDONED and calls remove on children | def remove_act
# outdent children in case remove_act doesn't delete
self.children.each do |child|
if child.type != 'GoalTracker'
child.outdent
child.remove_act
end
end
# check if parent should update completeness
old_parent = self.parent
self.state = Activity::ABANDONED
self.save!
# refresh parent completeness
if !old_parent.nil?
old_parent.is_complete?
end
end | [
"def remove_finished_children\n # We call #to_a to get a copy of children, since we will remove\n # children in the block. Note that we can't use #delete_if here\n # since #children is a relation enumerator (not the relation list\n # itself)\n children = each_child.to_a\n for child in children\n child, info = child\n if info[:success].evaluate(child)\n remove_child(child)\n end\n end\n end",
"def remove_act\n # outdent children in case remove_act doesn't delete\n self.children.each do |child|\n child.outdent\n child.remove_act\n end\n \n # check if parent should update completeness\n old_parent = self.parent\n\n self.permissions.destroy_all\n self.destroy\n \n # refresh parent completeness\n if !old_parent.nil?\n old_parent.is_complete?\n end\n end",
"def remove_children\n @children.clear\n end",
"def eliminate!\n # puts \"eliminating #{self}\"\n return unless parent\n parent.add_self_time(self)\n parent.add_wait_time(self)\n children.each do |kid|\n if call = parent.find_call(kid)\n call.merge_call_tree(kid)\n else\n parent.children << kid\n # $stderr.puts \"setting parent of #{kid}\\nto #{parent}\"\n kid.parent = parent\n end\n end\n parent.children.delete(self)\n end",
"def remove_children\n copy = self.dup\n copy.really_remove_children!\n copy\n end",
"def kill_children\n #To do\n end",
"def delete_child(child); end",
"def remove_act\n # select rep_parent if it exists\n node = self\n if !self.rep_parent.nil?\n return self.destroy\n end\n\n # outdent children in case remove_act doesn't delete\n node.children.each do |child|\n child.outdent\n child.remove_act\n end\n\n # hold parent in case it need be updated\n old_parent = node.parent\n \n node.del_reps\n node.state = Activity::ARCHIVED_HABIT\n node.save!\n\n if !old_parent.nil?\n old_parent.is_complete?\n end\n end",
"def unfinish!\n @finished = nil\n children.each { |c| c.unfinish! unless c.hidden? }\n end",
"def remove\r\n return unless parent? # No need to remove if parentless\r\n\r\n parent_obj = zobj self.parent\r\n sibling_obj = zobj self.sibling\r\n\r\n clear_parent\r\n clear_sibling\r\n\r\n if parent_obj.child == self.id # Am I my parent's child?\r\n parent_obj.child = sibling_obj.id\r\n else\r\n child_obj = zobj parent_obj.child\r\n while self.id != child_obj.sibling # Next Child!\r\n raise \"malformed object tree\" if child_obj.sibling == 0\r\n child_obj = zobj child_obj.sibling\r\n end\r\n child_obj.sibling = sibling_obj.id\r\n end\r\n end",
"def clear_children!\n @children.clear\n end",
"def reprocess_child_items!\n self.child_items.delete_all\n create_child_items\n end",
"def finish\n @children.each { |kid| \n kid[:link].finish()\n kid[:link] = nil\n kid[:residue].finish()\n kid[:residue] = nil\n }\n\n @ring_positions.each { |pos,node| \n node.finish()\n }\n\n remove_relations\n \n end",
"def remove_parents!\n self.really_remove_parents!\n end",
"def remove!\n parent.children.remove self if parent\n end",
"def drop_children\n @children.clear\n context.cache.drop_below(path)\n end",
"def remove_all\n @peer.remove_all\n# @children.each { |child| scene.unindex_prop(child) } if scene\n# @children = []\n end",
"def remove_child(le)\n\t\t\t@children.delete le\n\t\t\tle.parent = nil\n\t\tend",
"def retrieve_all_children\n self.to_be_removed = false\n self.save\n\n self.tags.each do |i|\n i.to_be_removed = false\n i.save\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
add CD object to the array variable, $cd_arr | def add_cd(a_cd)
$cd_arr << a_cd
end | [
"def addCD(aCD)\n $cd_arr << aCD\nend",
"def addCD( aCD )\n $cd_arr << aCD\nend",
"def add obj\n\t\t\t@objs2 += [obj] \n\t\tend",
"def add_carray name: ,c_name: ,dimension: ,type: ,value: nil\n type = Rubex::DataType::CArray.new dimension, type\n entry = Rubex::SymbolTable::Entry.new name, c_name, type, value\n @entries[name] = entry\n @carray_entries << entry\n\n entry\n end",
"def dc_add_json_ld(element)\r\n @json_ld ||= []\r\n if element.class == Array\r\n @json_ld += element\r\n else\r\n @json_ld << element\r\n end\r\nend",
"def addComplexObject(var_Object)\n \n Common::Logger.print(Common::VAR_DEBUG, self, \"addig object [\" + var_Object.to_s() + \"] to the array list\")\n \n if(!var_Object.is_a?(SBAStore::SBAComplexObject))\n raise SBATypeError.new(\"SBAStore::SBAComplexObject expected\")\n end\n\n @VAR_COMPLEX_OBJECT_INDEX+=1\n \n # Add object to the array\n @VAR_COMPLEX_OBJECTS[@VAR_COMPLEX_OBJECT_INDEX-1] = var_Object\n @VAR_COMPLEX_OBJECTS_NAMES[@VAR_COMPLEX_OBJECT_INDEX-1] = var_Object.VAR_NAME\n @VAR_COMPLEX_OBJECTS_INDEXES[@VAR_COMPLEX_OBJECT_INDEX-1] = var_Object.VAR_ID\n \n # Add complex object to the previous complex object\n if(@VAR_COMPLEX_OBJECT_INDEX > 1)\n @VAR_COMPLEX_OBJECTS[@VAR_COMPLEX_OBJECT_INDEX-2].add(var_Object.VAR_ID)\n end\n \n Common::Logger.print(Common::VAR_DEBUG, self, \"puts [#{var_Object.to_s()}] to the array\") \n end",
"def dc_add_json_ld(element)\n @json_ld ||= []\n if element.class == Array\n @json_ld += element\n else\n @json_ld << element\n end\nend",
"def add chromosome\n\t\t@arrayChromosomes << chromosome\n\tend",
"def add_components(array)\n array.each {|comp| add_component(comp)}\n end",
"def concat(array)\n updated(@children + array.to_a)\n end",
"def add_item(array,item)\n array << item\nend",
"def add_item(item)\n @array << item\n end",
"def addAlbum(album)\r\n $album_arr << album ###add parameter to array\r\nend",
"def add_base_array(command_id, object)\n cuda_id = \"b#{command_id}_base\"\n\n if objects.include?(cuda_id)\n # Object already present\n\n if !objects[cuda_id].equal?(object)\n raise AssertionError.new(\"Adding different base array under different name\")\n end\n\n return cuda_id\n end\n\n objects[cuda_id] = object\n\n cuda_id_size = \"b#{command_id}_size\"\n if object.class == FFI::MemoryPointer\n objects[cuda_id_size] = object.size / UnionTypeStruct.size\n else\n objects[cuda_id_size] = object.size\n end\n\n # Generate code for copying data to global memory\n update_dev_struct_allocation(cuda_id, object)\n\n return cuda_id\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 concat(array)\n updated(nil, @children + array.to_a)\n end",
"def buildarray\n\n for cases in 0 .. @input.number_of_cases-1\n @item_list << @input.builditemobject #Makes array of CaseInformation objects\n end\n end",
"def cdroms=(list)\n if list.class == Array\n list = List.new(list)\n list.each_with_index do |value, index|\n if value.is_a?(Hash)\n list[index] = Cdrom.new(value)\n end\n end\n end\n @cdroms = list\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"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
prints data from the array to screen in human readable yaml format | def show_data
puts $cd_arr.to_yaml
end | [
"def showData\n puts( $cd_arr.to_yaml )\nend",
"def showData\n puts($cd_arr.to_yaml)\nend",
"def display_yaml( obj )\n puts YAML::dump(obj)\n end",
"def print\n hash(@yaml)\n end",
"def to_yaml() end",
"def display object\n # stringify symbols in YAML output for better readability\n puts object.to_yaml.gsub(/^([[:blank:]]*(- )?):(?=@?\\w+: )/, '\\1')\n rescue\n require 'pp'\n pp object\n end",
"def dump_yaml\n evaluate(@node)\n sorted_ya2yaml(:syck_compatible => true)\n end",
"def to_yaml\n output = \"\"\n next_result do |rec|\n output += rec.to_yaml+\"\\n\"\n end\n output\n end",
"def to_yaml\n # Convert the object to basic representations\n basics = to_basic\n # puts \"basics=#{basics}\"\n basics = [ basics ] unless basics.is_a?(Array)\n # Remove duplicate descriptions\n basics.uniq! { |elem| elem.first[1][\"name\"] }\n # Convert the basic representations to YAML\n return YAML.dump_stream(*basics)\n end",
"def pretty_print_tree\n puts \"Pretty Print Values In The YAML Tree - Using Psych\"\n @secret_tree.each do |node|\n puts node\n end\n end",
"def yaml\n config = fetch(@variable, {})\n stringified = if config.respond_to?(:deep_stringify_keys)\n config.deep_stringify_keys\n else\n # TODO: remove when dropping rails 3 support\n # two level stringify for rails 3 compatibility\n config.stringify_keys.each_value(&:stringify_keys!)\n end\n stringified.to_yaml\n end",
"def print_answers_yaml( iostream, answers )\n iostream.puts \"#=======================================\"\n iostream.puts \"# simp config answers\"\n iostream.puts \"#\"\n iostream.puts \"# generated on #{Time.now.to_s}\"\n iostream.puts \"#---------------------------------------\"\n iostream.puts \"# you can use these answers to quickly configure subsequent simp installations\n # by running the command:\n #\n # simp config -a /PATH/TO/THIS/FILE\n #\n # simp config will prompt for any missing items\n \".gsub(/^\\s+/, '').strip\n iostream.puts \"#=======================================\"\n iostream.puts \"---\"\n answers.each do |k,v|\n if yaml = v.to_yaml_s # filter out nil results (for ruby 1.8)\n iostream.puts yaml\n iostream.puts\n end\n end\n end",
"def to_yaml_style\n end",
"def produce_yaml\n produce_table.to_yaml\n end",
"def pretty_print_tree\n puts \"#{@file_name} - Pretty Print The YAML Dump\"\n pp @secret_ruby\n end",
"def to_yaml()\n @var_set.values.to_yaml\n end",
"def to_yaml\n to_h.to_yaml\n end",
"def show_yaml_properties(properties)\n props_subset = {}\n properties.each{|key, props|\n props_subset[key] = {}\n props_subset[key][:order] = props[:order]\n props_subset[key][:text] = props[:text]\n }\n puts \"\\nYAML dump BEGIN\\n#{YAML.dump(props_subset)}\\nYAML dump END\\n\\n\"\nend",
"def array_to_yaml(array)\n '[ ' + array.map { |s| \"'\" + s + \"'\" }.join(', ') + ' ]'\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Wraps a block catching errors and logging / replying to the source, when they happen before reraising them | def wrapping_errors(response=nil, &block)
begin
yield if block_given?
rescue StandardError => e
"Oh noes, #{e.message}".tap do |message|
log.error message
response.reply message if response
end
e.backtrace.each { |t| e.debug t }
raise e
end
end | [
"def handle_errors(&block)\n block.call\n rescue Exception => e\n handle_error(e,true)\n end",
"def _catch_warden(&block); end",
"def transform_error(&block)\n errback do |*err|\n self.fail(\n begin\n yield(*err)\n rescue => e\n e\n end)\n end\n end",
"def wrap_with_try(&block)\n ->(*args) { try { block.call(*args) } }\n end",
"def catch_errors\n begin\n yield\n rescue => error\n @on_error.call(error)\n end\n end",
"def run_or_error(message, &block)\n yield\n rescue Exception => ex\n raise \"#{message} (#{ex.message})\"\n end",
"def on_error(&block)\n raise 'Invalid block passed to Importer#on_error: block may accept 0, 1 or 2 arguments' if block.arity > 2\n \n if has_errors?\n case block.arity\n when 0 then DslProxy.exec(self, &block)\n when 1 then DslProxy.exec(self, errors, &block)\n when 2 then DslProxy.exec(self, errors, error_summary, &block)\n end\n end\n \n self\n end",
"def try(&block)\n begin\n block.call\n rescue Exception => e\n e\n end\n end",
"def capture(&block)\n if block\n begin\n block.call\n rescue Error => e\n raise # Don't capture Opbeat errors\n rescue Exception => e\n self.captureException(e)\n raise\n end\n else\n # Install at_exit hook\n at_exit do\n if $!\n logger.debug \"Caught a post-mortem exception: #{$!.inspect}\"\n self.capture_exception($!)\n end\n end\n end\n end",
"def try_operation(&block)\n log = \"\"\n begin\n yield(log)\n rescue Exception => e\n log << e.message + '\\n'\n success = false\n return success, log\n end\nend",
"def render_or_pass(&block)\n begin yield\n rescue Exception => e\n logger.error e.message\n pass\n end\n end",
"def error_block!(*keys)\n keys.each do |key|\n base = settings\n while base.respond_to?(:errors)\n if block = base.errors[key]\n # found a handler, eval and return result\n return instance_eval(&block)\n else\n base = base.superclass\n end\n end\n end\n raise boom if settings.show_exceptions? and keys == Exception\n nil\n end",
"def clean_exceptions(&block)\n begin\n block.call\n rescue Jabber::ServerError => e\n raise ServerError, e.message\n rescue ConnectionTimeout, Errno::ETIMEDOUT => e\n raise ConnectionTimeout, e.message\n rescue SystemCallError => e\n raise NoService, e.message\n rescue ReadTimeout => e\n raise e\n rescue Exception => e\n raise XmppError, e.message\n end\n end",
"def with_error_handling\n yield\n rescue => error\n report_error(error)\n Process.exit(false)\n end",
"def do_yield(&block)\n begin\n block.call\n rescue Exception => e\n puts \"Exception! #{e.to_s}\"\n Rails.logger.error \"Caught exception: #{e.to_s}\"\n raise e\n end\n end",
"def relay(thread, *errors, &block)\n on_error(block, [ thread ], Exception, *errors) do |_error|\n Thread.current == thread ? raise : thread.raise(self.new(_error))\n return _error\n end\n nil\n end",
"def map_error(&block)\n if error?\n yield exception\n else\n nil\n end\n end",
"def wrap\n old_enabled, old_inline = enabled, inline\n self.inline = false\n self.enabled = true\n yield\n rescue Exception => ex\n if ex.should_intercept?\n enter_exception(ex)\n else\n raise ex\n end\n ensure\n self.enabled = old_enabled\n self.inline = old_inline\n end",
"def and_throw(*args, &block); end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Fetches info about a single user | def fetch_user(id)
client.user(id)
end | [
"def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end",
"def fetch_user\n @user = User.find(params[:user_id])\n end",
"def get_user_info\n request :get_user_info\n end",
"def show_user()\n path = sprintf(\"/api/v2/user\")\n data_hash = {}\n post_body = nil\n \n reqHelper = PhraseApp::ParamsHelpers::BodyTypeHelper.new(data_hash, post_body)\n rc, err = PhraseApp.send_request(@credentials, \"GET\", path, reqHelper.ctype, reqHelper.body, 200)\n if err != nil\n return nil, err\n end\n \n return PhraseApp::ResponseObjects::User.new(JSON.load(rc.body)), err\n end",
"def info\n hash = {:username => @username}\n @api.request(\"users/info/?#{build_query_string(hash)}\")\n end",
"def get_user_info\n user = User.select(:email, :created_at).find_by(id: current_user.id)\n render json: user\n end",
"def details(*args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n user = args.first\n merge_user_into_options!(user, options)\n response = get('users/details', options)\n end",
"def fetch_latest_user_info\n\t\t@user_info = @client.execute(api_method: @info.userinfo.get).data\n\tend",
"def user_info\n get(api_get.body.identity).body\n end",
"def get_user(id)\n conn = @client.get do |req|\n req.url \"/api/v2/user/#{id}\"\n req.headers[\"Authorization\"] = @token\n end\n conn.body\n end",
"def user_details\n user_details_for(@qualified_username).first\n end",
"def profile\n @user = UsersService.getUserById(params[:id])\n end",
"def profile\n \t@user = UsersService.findUserById(params[:id])\n end",
"def user(user_name)\n OctocatHerder::User.fetch(user_name, connection)\n end",
"def user_info\n\t\t@user_info ||= fetch_latest_user_info\n\tend",
"def get_user_data(uid)\n @conn.get(\"/api/v1/users/#{uid}\")\n end",
"def get_user(id)\n return @client.raw(\"get\", \"/config/users/#{id}\")\n end",
"def get_user\n @user = User.find(params[:user_id])\n end",
"def get_user(handle)\n request(Net::HTTP::Get, \"/api/#{API_VERSION}/user/#{handle}\", nil, nil, false)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Consumes an input array and returns a balanced binary tree. | def build_tree(input_array)
sorted_set = input_array.sort.uniq
build_tree_aux(sorted_set, 0, sorted_set.length - 1)
end | [
"def array_to_binary(arr)\n node = Node.new(arr[0])\n arr.slice(1..-1).each {|el| insert_into_tree(node, el) }\n node\nend",
"def build_tree(array)\n #Assign first value (at 0 index) as root node, shift removes the first element, so array is shorten by 1\n @root = Node.new(array.shift) if @root.nil?\n # Take each remaining element and make it into an object of class Node\n array.each do |element|\n node = Node.new(element)\n # call upon the insert method to map out the binary tree\n insert_node(node)\n end\n end",
"def build_tree(array)\n return nil if array.empty?\n\n mid = (array.length - 1) / 2\n node = Node.new(array[mid])\n node.left = build_tree(array[0...mid])\n node.right = build_tree(array[mid+1..-1])\n node\n end",
"def balanced_binary_with_sorted_array(arr, min, max)\n return nil if min > max\n mid = (min + max) / 2\n # Always passes the next middle as next root, so the tree stays balanced.\n root = TreeNode.new(arr[mid])\n root.left = balanced_binary_with_sorted_array(arr, min, mid - 1)\n root.right = balanced_binary_with_sorted_array(arr, mid + 1, max)\n root\n end",
"def build_tree(array)\n tree = TreeNode.new(array[0], 0)\n (1..array.length-1).each {|i|\n insert_into_tree(tree, array[i], i)\n }\n tree\nend",
"def build_tree(sorted_array)\n return if sorted_array.length.zero?\n\n return Node.new(sorted_array[0]) if sorted_array.length == 1\n\n midpoint = (sorted_array.length - 1) / 2\n subtree_root = Node.new(sorted_array[midpoint])\n # Don't include the root in the left subtree.\n subtree_root.left = build_tree(sorted_array[0...midpoint])\n subtree_root.right = build_tree(sorted_array[midpoint + 1..-1])\n\n subtree_root\n end",
"def build_tree(array)\n @root = Node.new(array.shift)\n array.each do |i|\n insert(@root,i)\n end\n end",
"def sorted_array_to_bst(nums)\n node_index = nums.length/2\n\n root = TreeNode.new(nums[node_index])\n\n if node_index > 0\n root.left = sorted_array_to_bst(nums[0...node_index])\n end\n\n if node_index < nums.length - 1\n root.right = sorted_array_to_bst(nums[(node_index + 1)...nums.length])\n end\n\n root\nend",
"def set_next_binary_tree(tree, arr)\n puts \"\\n=======================================================================\"\n puts \"=======================================================================\"\n puts \"=======================================================================\"\n puts \"\\nNext Test Array: \\n \"\n p arr\n tree.build_tree(arr)\n tree.show_binary_tree\n puts \"\\n=======================================================================\\n \"\nend",
"def build_tree(array, start = 0, array_end = array.length - 1)\n return nil if start > array_end\n\n middle = (start + array_end) / 2\n node = Node.new(array[middle])\n node.left = build_tree(array, start, middle - 1)\n node.right = build_tree(array, middle + 1, array_end)\n node\n end",
"def minimal_tree(array)\n raise \"Please enter an array of at least one element\" if array.empty?\n\n midpoint = array.length/2\n root = BinaryTreeNode.new(array[midpoint])\n\n add_node = lambda do |left, right|\n return if left > right\n\n mid = left + (right-left) / 2\n\n node = BinaryTreeNode.new(array[mid])\n\n node.left = add_node.call(left, mid - 1)\n node.right = add_node.call(mid + 1, right)\n\n node\n end\n\n root.left = add_node.call(0, midpoint - 1)\n root.right = add_node.call(midpoint + 1, array.length - 1)\n\n root\nend",
"def create_bst(sorted_arr)\n\n return nil if sorted_arr.length == 0\n return BinaryNode.new(sorted_arr[0]) if sorted_arr.length == 1\n if sorted_arr.length == 2\n child = BinaryNode.new(sorted_arr[0])\n parent = BinaryNode.new(sorted_arr[1])\n parent.left = child\n return parent\n end\n\n middle = sorted_arr.length / 2\n left_start = 0\n left_end = (sorted_arr.length / 2) - 1\n right_start = left_end + 2\n right_end = sorted_arr.length\n\n cur_root = BinaryNode.new(sorted_arr[middle])\n cur_root.left = create_bst(sorted_arr[left_start..left_end])\n cur_root.right = create_bst(sorted_arr[right_start..right_end])\n\n return cur_root\n\nend",
"def build_tree(data_array)\n @root = nil # overwrites tree, even if array is empty\n data_array.each_with_index do |data, index|\n if index == 0\n @root = Node.new(data)\n else\n set_next_node(data)\n end\n end\n end",
"def sorted_array_to_bst(nums)\n return nil if nums.empty?\n mid = nums.length/2\n node = TreeNode.new(nums[mid])\n node.left = sorted_array_to_bst(nums[0..mid-1]) if mid-1 >= 0\n node.right = sorted_array_to_bst(nums[mid+1..-1]) if mid+1 <= nums.length-1\n return node\nend",
"def build_tree_from_sorted(arr)\n return nil if arr.empty?\n left, right, middle = get_left_right_middle(arr)\n @root = Node.new(middle)\n make_children(@root, left)\n make_children(@root, right)\n end",
"def build_balanced_bst(a)\n # build balanced BST\n return _build_balanced_bst(0, a.length - 1, a)\nend",
"def build_tree_2(data_array)\n root = nil\n \n data_array.each do |elem|\n node = insert_node(root, nil, elem) \n\troot ||= node\n end\n \n root\nend",
"def build_tree array\n\t\t@root = Node.new array[0]\n\t\t@nodes += 1\n\t\tarray[1..-1].each do |var|\n\t\t\tinsert(@root,var)\n\t\tend\n\tend",
"def min_height_bst(array)\n return construct_min_height_bst(array, 0, array.length - 1)\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /barks or /barks.json | def create
@bark = current_user.barks.build(bark_params)
respond_to do |format|
if @bark.save
format.html { redirect_to root_path, notice: "Bark was successfully created." }
format.json { render :show, status: :created, location: @bark }
else
format.html { render :new, status: :unprocessable_entity }
format.json { render json: @bark.errors, status: :unprocessable_entity }
end
end
end | [
"def create\n @barrack = Barrack.new(params[:barrack])\n\n respond_to do |format|\n if @barrack.save\n format.html { redirect_to @barrack, notice: 'Barrack was successfully created.' }\n format.json { render json: @barrack, status: :created, location: @barrack }\n else\n format.html { render action: \"new\" }\n format.json { render json: @barrack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @barrack = Barrack.new(barrack_params)\n\n respond_to do |format|\n if @barrack.save\n format.html { redirect_to @barrack, notice: 'Barrack was successfully created.' }\n format.json { render :show, status: :created, location: @barrack }\n else\n format.html { render :new }\n format.json { render json: @barrack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @barber = Barber.new(barber_params)\n\n respond_to do |format|\n if @barber.save\n format.html { redirect_to @barber, notice: 'Barber was successfully created.' }\n format.json { render action: 'show', status: :created, location: @barber }\n else\n format.html { render action: 'new' }\n format.json { render json: @barber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bk = Bk.new(bk_params)\n\n respond_to do |format|\n if @bk.save\n format.html { redirect_to @bk, notice: 'Bk was successfully created.' }\n format.json { render :show, status: :created, location: @bk }\n else\n format.html { render :new }\n format.json { render json: @bk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @barn = Barn.new(barn_params)\n\n respond_to do |format|\n if @barn.save\n format.html { redirect_to @barn, notice: 'Barn was successfully created.' }\n format.json { render :show, status: :created, location: @barn }\n else\n format.html { render :new }\n format.json { render json: @barn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @buket = Buket.new(buket_params)\n\n respond_to do |format|\n if @buket.save\n format.html { redirect_to @buket, notice: 'Buket was successfully created.' }\n format.json { render :show, status: :created, location: @buket }\n else\n format.html { render :new }\n format.json { render json: @buket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @barrack = Barrack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @barrack }\n end\n end",
"def create\n @non_smoking_bar = NonSmokingBar.new(params[:non_smoking_bar])\n\n respond_to do |format|\n if @non_smoking_bar.save\n format.html { redirect_to root_url, notice: 'Successfully created.' }\n format.json { render json: @non_smoking_bar, status: :created, location: @non_smoking_bar }\n else\n format.html { render action: \"new\" }\n format.json { render json: @non_smoking_bar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @brite_rt_barabasis = BriteRtBarabasi.new(brite_rt_barabasis_params)\n\n respond_to do |format|\n if @brite_rt_barabasis.save\n format.html { redirect_to @brite_rt_barabasis, notice: 'Brite rt barabasi was successfully created.' }\n format.json { render :show, status: :created, location: @brite_rt_barabasis }\n else\n format.html { render :new }\n format.json { render json: @brite_rt_barabasis.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bok = Bok.new(bok_params)\n\n respond_to do |format|\n if @bok.save\n format.html { redirect_to @bok, notice: 'Bok was successfully created.' }\n format.json { render :show, status: :created, location: @bok }\n else\n format.html { render :new }\n format.json { render json: @bok.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n megam_rest.post_billings(to_hash)\n end",
"def create\n @buket = Buket.new(params[:buket])\n\n respond_to do |format|\n if @buket.save\n format.html { redirect_to @buket, notice: 'buket.' }\n format.json { render json: @buket, status: :created, location: @buket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @buket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kb = Kb.new(params[:kb])\n\n respond_to do |format|\n if @kb.save\n format.html { redirect_to @kb, :notice => 'Kb was successfully created.' }\n format.json { render :json => @kb, :status => :created, :location => @kb }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @kb.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @bbhk = Bbhk.new(bbhk_params)\n\n respond_to do |format|\n if @bbhk.save\n format.html { redirect_to @bbhk, notice: 'Bbhk was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bbhk }\n else\n format.html { render action: 'new' }\n format.json { render json: @bbhk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar42 = Bar42.new(bar42_params)\n\n respond_to do |format|\n if @bar42.save\n format.html { redirect_to @bar42, notice: \"Bar42 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar42 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar42.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bark.update(bark_params)\n format.html { redirect_to @bark, notice: \"Bark was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bark }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar = Bar.new(params[:bar])\n\n respond_to do |format|\n if @bar.save\n format.html { redirect_to @bar, notice: 'Bar was successfully created.' }\n format.json { render json: @bar, status: :created, location: @bar }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar25 = Bar25.new(bar25_params)\n\n respond_to do |format|\n if @bar25.save\n format.html { redirect_to @bar25, notice: \"Bar25 was successfully created.\" }\n format.json { render :show, status: :created, location: @bar25 }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @bar25.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bar = Bar.new(bar_params)\n\n respond_to do |format|\n if @bar.save\n format.html { redirect_to @bar, notice: 'Bar was successfully created.' }\n format.json { render :show, status: :created, location: @bar }\n else\n format.html { render :new }\n format.json { render json: @bar.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /barks/1 or /barks/1.json | def update
respond_to do |format|
if @bark.update(bark_params)
format.html { redirect_to @bark, notice: "Bark was successfully updated." }
format.json { render :show, status: :ok, location: @bark }
else
format.html { render :edit, status: :unprocessable_entity }
format.json { render json: @bark.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n @barrack = Barrack.find(params[:id])\n\n respond_to do |format|\n if @barrack.update_attributes(params[:barrack])\n format.html { redirect_to @barrack, notice: 'Barrack was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @barrack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barrack.update(barrack_params)\n format.html { redirect_to @barrack, notice: 'Barrack was successfully updated.' }\n format.json { render :show, status: :ok, location: @barrack }\n else\n format.html { render :edit }\n format.json { render json: @barrack.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar42.update(bar42_params)\n format.html { redirect_to @bar42, notice: \"Bar42 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar42 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar42.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barber.update(barber_params)\n format.html { redirect_to @barber, notice: 'Barber was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @barber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @bar.update(bar_params)\n format.html { redirect_to @bar, notice: 'Bar was successfully updated.' }\n format.json { render :show, status: :ok, location: @bar }\n else\n format.html { render :edit }\n format.json { render json: @bar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bar = Bar.find(params[:id])\n\n respond_to do |format|\n if @bar.update_attributes(params[:bar])\n format.html { redirect_to @bar, notice: 'Bar was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @bar = Bar.find(params[:id])\n\n respond_to do |format|\n if @bar.update_attributes(params[:bar])\n format.html { redirect_to @bar, notice: 'Bar was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bar.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barter.update(barter_params)\n format.html { redirect_to @barter, notice: 'Barter was successfully updated.' }\n format.json { render :show, status: :ok, location: @barter }\n else\n format.html { render :edit }\n format.json { render json: @barter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barber.update(barber_params)\n format.html { redirect_to @barber, notice: 'Barber was successfully updated.' }\n format.json { render :show, status: :ok, location: @barber }\n else\n format.html { render :edit }\n format.json { render json: @barber.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar88.update(bar88_params)\n format.html { redirect_to @bar88, notice: \"Bar88 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar88 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar88.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar23.update(bar23_params)\n format.html { redirect_to @bar23, notice: \"Bar23 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar23 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar23.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar22.update(bar22_params)\n format.html { redirect_to @bar22, notice: \"Bar22 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar22 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar22.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @barco.update(barco_params)\n format.html { redirect_to @barco, notice: 'Barco was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @barco.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar18.update(bar18_params)\n format.html { redirect_to @bar18, notice: \"Bar18 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar18 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar18.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar55.update(bar55_params)\n format.html { redirect_to @bar55, notice: \"Bar55 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar55 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar55.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar35.update(bar35_params)\n format.html { redirect_to @bar35, notice: \"Bar35 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar35 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar35.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar25.update(bar25_params)\n format.html { redirect_to @bar25, notice: \"Bar25 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar25 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar25.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bar8.update(bar8_params)\n format.html { redirect_to @bar8, notice: \"Bar8 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @bar8 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @bar8.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
takes a string preposistion and turns it into a 2d array ands of ors with id numbers + depending on negation | def string_to_internal(preposition)
temp_kb =Array.new
#string input of format literal_name LOGICAL_PREPOSISTION
preposition_array = preposition.split
next_negated = false
sentence = []
preposition_array.each do |word|
#####################################3
# puts " word: " + word
#don't need to handle "or" as long as it is in right format, will look to "and" and the end as limiters
if (word == "AND" || word == "and")
temp_kb << sentence
sentence = []
elsif(word == "NOT" || word == "not")
next_negated = true
elsif(word == "OR" || word =="or")
else
temp = @name_hash[word]
#add variable if doesnt exist
if(temp == nil)
temp_var = Literalzs.new(word,@total_variables)
@id_array.push(temp_var)
@name_hash[word] = @total_variables
temp = @total_variables
@total_variables+=1
end
if(next_negated)
temp = temp.to_i * -1
#########################################################3333
#puts " temp negated, now is: " + temp.to_s
next_negated = false
end
sentence << temp
end
end
#need to grab last sentence since it wont be ended with and
temp_kb << sentence
return temp_kb
end | [
"def ships_from_string(str)\n arr = []\n\n str.chars.each do |ch|\n arr << 1 if ch == CHAR_SHIP\n arr << 0 if ch == CHAR_EMPTYSPACE\n end\n\n arr\n end",
"def contain_all_rots(strng, arr)\n array = strng.chars\n number = 0\n result = []\n (array.size - 1).times do \n array.rotate!\n result << array\n end\n result.map! {|y| y.join(\"\")}\n # result.all?{|x| arr.include?(x)}\nend",
"def solution(string)\n if string.length % 2 == 0\n array = string.chars\n array = array.each_slice(2).to_a\n array = array.map{|e|e.join}\n\n else\n array = string.chars\n array.push(\"_\")\n array = array.each_slice(2).to_a\n array = array.map{|e|e.join}\n end\nend",
"def solution(str)\n arr = []\n if str.length.odd? then str += '_' end\n str.chars.each_slice(2) { |x| arr.push(x.join('')) }\n arr\nend",
"def mask_array\n @mask.split('')\n end",
"def parse_codons(str)\n arr = Array.new\n codon = String::new\n len = str.length - (str.length % 3)\n str[0..len].each_char do |chr|\n codon.concat(chr)\n if codon.length == 3\n arr = arr.push(codon.dup)\n codon.clear\n end\n end\n arr\nend",
"def create_non_redundant_array(polyAs0,condition0,polyAs1,condition1,polyAs2,condition2,polyAs3,condition3)\n old_polyAs = (polyAs0 + polyAs1 + polyAs2 + polyAs3).uniq!\n polyAs = []\n for old_polyA in old_polyAs\n polyA = old_polyA + \"conditions=\"\n polyA = polyA + condition0 + \",\" if polyAs0.include?(old_polyA)\n polyA = polyA + condition1 + \",\" if polyAs1.include?(old_polyA)\n polyA = polyA + condition2 + \",\" if polyAs2.include?(old_polyA)\n polyA = polyA + condition3 + \",\" if polyAs3.include?(old_polyA)\n polyA.chomp!(\",\")\n polyAs << polyA\n end\n return polyAs\nend",
"def get_subarrays(arr)\n\n #delete all parenthases\n arr.map!{|str| str.delete(\"(\")} #\"3 1\"\n arr.map!{|str| str.delete(\")\")}\n arr.map! do |subarray|\n subarray.split(\" \").map!{|string| string.to_i}\n end\n\n return arr\n\nend",
"def word_to_coordinates(row_name, word)\n coordinates = []\n 5.times do |i|\n coordinates << \"#{row_name}#{i+1}\" if (word & (1 << i)) > 0\n end\n\n coordinates\n end",
"def parse_to_array(string)\n\tclues = string.split(\",\")\n\tfinal_return = []\n clues.each do |clue|\n\t\tif clue.include?(\"-\") == false\n\t\t\tfinal_return << clue\n\t\telse\n\t\t\trange = clue.split(\"-\")\t\n\t\t\tmin,max = range[0].to_i, range[-1].to_i\n\t\t\tfinal_return << (min..max).to_a.map(&:to_s)\n\t\tend\n end\n final_return.flatten\nend",
"def make_pyramid_array(str)\n str.split(\"\\n\").map { |line| line.split(' ').map { |ch| ch.to_i } }.reverse\nend",
"def contain_all_rots(strng, arr)\n i = 0\n empty = []\n\n if strng.length == 0\n return true\n elsif strng.length > 0\n array = strng.split('')\n\n (0...strng.length).each {|num|\n rotate = array.rotate(num)\n joined_string = rotate.join('')\n\n i += 1 if arr.include?(joined_string)\n }\n end\n\n if i == strng.length\n return true\n else\n return false\n end\nend",
"def solution(str)\n result = []\n return result if str.empty?\n str.split('').each_slice(2).with_index do |(a, b), _i|\n result.push([a, b].join(''))\n end\n result.last << '_' if result.last.length == 1\n result\nend",
"def split_input (input)\n return false if input == ''\n array_input = input.split('')\n row_input = convert_input(array_input[0].downcase)\n column_input = (array_input[1].to_i) - 1 if (/[\\d]/ === array_input[1])\n coordinate = Array.new([row_input, column_input])\n return coordinate\n end",
"def parse_mask(mask)\n and_mask = mask.gsub(\"X\", \"1\").to_i(2)\n or_mask = mask.gsub(\"X\", \"0\").to_i(2)\n\n [and_mask, or_mask]\nend",
"def specials(string)\n case string.length\n when 0 then []\n when 1 then '^$'.include?(string) ? [string] : ['.', string, \"#{string}?\"]\n else specials(string[0]).product(specials(string[1..-1]))\n .map(&:join)\n end\n end",
"def build_correct_array\n\t\tarray = []\n\t\t@phrase.letters.each {|l| array << l.gsub(/[!^a-zA-Z]/, \"_ \")}\n\t\tarray\n\tend",
"def makeArrayFromString(board_string)\n board_array = [[],[],[],[],[],[],[],[],[]]\n board_string.split(\"\").map.with_index do |val,index|\n board_array[index/9] << val\n end\n board_array\n end",
"def solution(str)\n new_arr = []\n\n characters = str.chars\n\n until characters.empty?\n new_arr << characters.shift(2).join('')\n end\n\n new_arr[-1] << '_' if str.length.odd?\n new_arr\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
turns the propositions to CNF(if needed) | def toCNF
end | [
"def convertToCNF theParsedPuzzle\nend",
"def propositional_symbols\n symbols = []\n @classified.each do |el|\n symbols.push el if el.instance_of? Proposition\n end\n symbols\n end",
"def to_peg\n new_rules = []\n\n # Look for rules containing sub-sequences\n if expr.any? {|e| e.is_a?(Array) && e.first.is_a?(Symbol)}\n # duplicate ourselves for rewriting\n this = dup\n new_rules << this\n\n expr.each_with_index do |e, index|\n next unless e.is_a?(Array) && e.first.is_a?(Symbol)\n new_rule = build(e)\n this.expr[index] = new_rule.sym\n new_rules << new_rule\n end\n\n # Return new rules after recursively applying #to_bnf\n new_rules = new_rules.map {|r| r.to_peg}.flatten\n elsif expr.first == :diff && !terminal?\n this = dup\n new_rule = build([:not, expr[2]])\n this.expr = [:seq, new_rule.sym, expr[1]]\n new_rules << this\n new_rules << new_rule\n elsif [:hex, :istr, :range].include?(expr.first)\n # This rules are fine, they just need to be terminals\n raise \"Encountered #{expr.first.inspect}, which is a #{self.kind}, not :terminal\" unless self.terminal?\n new_rules << self\n else\n new_rules << self\n end\n \n return new_rules.map {|r| r.extend(EBNF::PEG::Rule)}\n end",
"def coma!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n\n\n\n type = COMA\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 289:3: ','\n match( 0x2c )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n\n end",
"def puts_grammar(cnf)\n\t\tcnf.each {|state, production| puts \"#{state} => #{production}\"}\n\t\tprint \"\\n\"\n\tend",
"def parse_grammar \n\t\tnormalize\n\n\t\t@grammar_string.each do |line|\n\t\t\tlhs, placeholder, rhs = line.partition \"->\"\n\t\t\t# get rid of extra white space\n\t\t\tlhs.strip!\n\t\t\trhs.strip!\n\n\t\t\t# catch line with goal symbol\n\t\t\t@goal = lhs if rhs.include? \"$\"\n\n\t\t\trhs.split(\"|\").each do |rule|\n\t\t\t\t@production_rules[lhs] ||= []\n\t\t\t\t@production_rules[lhs] << rule.split(\" \")\n\t\t\tend\n\t\tend\n\tend",
"def cup\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 19 )\n cup_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return \n end\n # at line 127:6: ( 'C' | 'c' ) ( 'U' | 'u' ) ( 'P' | 'p' )\n if @input.peek( 1 ).between?( T__34, T__35 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__42, T__43 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__14, T__15 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 19 )\n memoize( __method__, cup_start_index, success ) if @state.backtracking > 0\n\n end\n \n return \n end",
"def pgnanalyse\n \n end",
"def to_s\n\t\tmap { |k,v|\n\t\t\tv.to_s + \" ::= \" + v.rules.map { |r| r.map{|e| e.inspect}.join(\" \") }.join(\" | \")\n\t\t}.join(\"\\n\")\n\tend",
"def condicion\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n\n return_value = CondicionReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n\n root_0 = nil\n\n __OP_REL114__ = nil\n valor113 = nil\n valor115 = nil\n\n\n tree_for_OP_REL114 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 123:4: valor OP_REL valor\n @state.following.push( TOKENS_FOLLOWING_valor_IN_condicion_545 )\n valor113 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor113.tree )\n end\n\n __OP_REL114__ = match( OP_REL, TOKENS_FOLLOWING_OP_REL_IN_condicion_547 )\n if @state.backtracking == 0\n tree_for_OP_REL114 = @adaptor.create_with_payload( __OP_REL114__ )\n @adaptor.add_child( root_0, tree_for_OP_REL114 )\n\n end\n\n @state.following.push( TOKENS_FOLLOWING_valor_IN_condicion_549 )\n valor115 = valor\n @state.following.pop\n if @state.backtracking == 0\n @adaptor.add_child( root_0, valor115.tree )\n end\n\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\n\n\n if @state.backtracking == 0\n return_value.tree = @adaptor.rule_post_processing( root_0 )\n @adaptor.set_token_boundaries( return_value.tree, return_value.start, return_value.stop )\n\n end\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n return_value.tree = @adaptor.create_error_node( @input, return_value.start, @input.look(-1), re )\n\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 23 )\n\n\n end\n\n return return_value\n end",
"def to_bnf\n return [self] unless rule?\n new_rules = []\n\n # Look for rules containing recursive definition and rewrite to multiple rules. If `expr` contains elements which are in array form, where the first element of that array is a symbol, create a new rule for it.\n if expr.any? {|e| e.is_a?(Array) && (BNF_OPS + TERM_OPS).include?(e.first)}\n # * Transform (a [n] rule (op1 (op2))) into two rules:\n # (a.1 [n.1] rule (op1 a.2))\n # (a.2 [n.2] rule (op2))\n # duplicate ourselves for rewriting\n this = dup\n new_rules << this\n\n expr.each_with_index do |e, index|\n next unless e.is_a?(Array) && e.first.is_a?(Symbol)\n new_rule = build(e)\n this.expr[index] = new_rule.sym\n new_rules << new_rule\n end\n\n # Return new rules after recursively applying #to_bnf\n new_rules = new_rules.map {|r| r.to_bnf}.flatten\n elsif expr.first == :opt\n this = dup\n # * Transform (rule a (opt b)) into (rule a (alt _empty b))\n this.expr = [:alt, :_empty, expr.last]\n this.cleanup = :opt\n new_rules = this.to_bnf\n elsif expr.first == :star\n # * Transform (rule a (star b)) into (rule a (alt _empty (seq b a)))\n this = dup\n this.cleanup = :star\n new_rule = this.build([:seq, expr.last, this.sym], cleanup: :merge)\n this.expr = [:alt, :_empty, new_rule.sym]\n new_rules = [this] + new_rule.to_bnf\n elsif expr.first == :plus\n # * Transform (rule a (plus b)) into (rule a (seq b (star b)\n this = dup\n this.cleanup = :plus\n this.expr = [:seq, expr.last, [:star, expr.last]]\n new_rules = this.to_bnf\n elsif [:alt, :seq].include?(expr.first)\n # Otherwise, no further transformation necessary\n new_rules << self\n elsif [:diff, :hex, :range].include?(expr.first)\n # This rules are fine, they just need to be terminals\n raise \"Encountered #{expr.first.inspect}, which is a #{self.kind}, not :terminal\" unless self.terminal?\n new_rules << self\n else\n # Some case we didn't think of\n raise \"Error trying to transform #{expr.inspect} to BNF\"\n end\n \n return new_rules\n end",
"def copula?\n @relation == 'cop' or \n (COPULAR_LEMMATA.include?([lemma, part_of_speech, language].join(',')) or\n (@empty_token_sort == 'V' and (pid.nil? or pid.is_empty? or COPULAR_LEMMATA.include?([pid.lemma, pid.part_of_speech, pid.language].join(',')))) and\n dependents.any? { |d| d.relation == 'xobj' } )\n end",
"def corder!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 11 )\n\n\n\n type = CORDER\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 297:3: ']'\n match( 0x5d )\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 11 )\n\n\n end",
"def to_std_conjunctive\n # Generate each minterm tree\n minterms = []\n each_minterm do |vars|\n vars = vars.map do |var|\n var = NodeVar.new(var)\n var = NodeNot.new(var) unless var.eval\n var\n end\n # Create the term\n term = vars.size == 1 ? vars[0] : NodeAnd.new(*vars)\n # Add the term\n minterms << term\n end\n # Conjunct them\n return minterms.size == 1 ? minterms[0] : NodeOr.new(*minterms)\n end",
"def to_ccr_procedures(xml, patient)\n if patient.procedures.present?\n xml.Procedures do\n patient.procedures.each_with_index do |procedure, index|\n xml.Procedure do\n xml.CCRDataObjectID(\"PR000#{index + 1}\")\n to_ccr_date(xml, procedure.as_point_in_time, \"Service date\") \n xml.Description do\n xml.Text(procedure.description)\n code_section(xml, procedure.codes)\n end\n xml.Status do\n xml.Text(\"Active\")\n end\n xml.Source\n end\n end\n end\n end\n end",
"def pour\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 20 )\n pour_start_index = @input.index\n\n success = false # flag used for memoization\n\n begin\n # rule memoization\n if @state.backtracking > 0 and already_parsed_rule?( __method__ )\n success = true\n return \n end\n # at line 297:7: ( 'P' | 'p' ) ( 'O' | 'o' ) ( 'U' | 'u' ) ( 'R' | 'r' )\n if @input.peek( 1 ).between?( T__12, T__13 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__18, T__19 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__14, T__15 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n if @input.peek( 1 ).between?( T__20, T__21 )\n @input.consume\n @state.error_recovery = false\n else\n @state.backtracking > 0 and raise( ANTLR3::Error::BacktrackingFailed )\n\n mse = MismatchedSet( nil )\n raise mse\n end\n\n\n\n success = true\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 20 )\n memoize( __method__, pour_start_index, success ) if @state.backtracking > 0\n\n end\n \n return \n end",
"def simplification_rules_for_conjunction\n if is_formula_and_formula?\n copy @left_sentence\n update\n elsif is_formula_and_not_formula?\n @left_sentence, @right_sentence, @operator = nil,nil,nil\n update(Constant::VALUES[:bottom])\n elsif is_formula_and_up?\n if @left_sentence.is_constant?\n copy @right_sentence\n else\n copy @left_sentence\n end\n update\n elsif is_formula_and_bottom?\n @left_sentence, @right_sentence, @operator = nil,nil,nil\n update(Constant::VALUES[:bottom])\n end\n end",
"def to_prolog\n prolog_clauses = []\n words = {} \n sentence_number = 1\n\n prolog_clauses << \"%% Unique tags in the corpus:\\n\"\n tags.map { |t,| prolog_clauses << \"brown_tag(#{t.to_prolog}).\" }\n\n @sentences.each do |s|\n prolog_clauses << \"brown_sentence(#{sentence_number},#{s.to_prolog}).\\n\"\n s.each { |e| words[\"brown_word(#{e[0].to_prolog}).\"] = true }\n sentence_number += 1\n end\n\n prolog_clauses << \"%% Unique words in the corpus\"\n words.map { |w,| prolog_clauses << w }\n\n (parse_tag_descriptions + prolog_clauses).join(\"\\n\")\n end",
"def comentarios!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 6 )\n\n type = COMENTARIOS\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 28:14: '#' ( CUALQUIERA_DENTRO_STRING_O_COMETARIO ) '#'\n match( 0x23 )\n # at line 28:18: ( CUALQUIERA_DENTRO_STRING_O_COMETARIO )\n # at line 28:20: CUALQUIERA_DENTRO_STRING_O_COMETARIO\n cualquiera_dentro_string_o_cometario!\n\n match( 0x23 )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 6 )\n\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
the way this is designed, it short circuts. so sometimes when it should say false it will say indeterminant for the whole knowledgebase returns false, true, or indetermninant as 1,1,0 (in current encoding) alike with the assignment list and literal class assignment must be parallel array to id nums (may want to use hashes instead) | def satisfiable_assignment?(assignment)
sentence_eval = 1
index = 0
while(sentence_eval == 1 && index < @kb.size)
sentence_eval = 0
all_false = true
##############################################3
# puts "kb is: " + @kb.to_s
# puts "the assignments are : " + assignment.to_s
@kb[index].each do |id|
################################################33
# puts " the atom to check : " + id.to_s
temp_id = id
if(temp_id >0)
assign = assignment[temp_id - 1]
###################################################
# puts "the atom is : " + id.to_s
# puts "the variable is assigned to: " + assignment[temp_id-1].to_s
# puts "which evaluates to: " + assign.to_s
else
assign = assignment[temp_id*-1 -1].to_i * -1
###################################################
# puts "the atom is : " + id.to_s
# puts "the variable is assigned to: " + (assignment[temp_id*-1 - 1] - 1).to_s
# puts "which evaluates to: " + assign.to_s
end
if(assign==1)
sentence_eval = 1
all_false = false
break
elsif(assign == 0)
all_false = false
end
end
if(all_false)
sentence_eval = -1
end
index+=1
end
return sentence_eval
end | [
"def assignment\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n\n\n __ID11__ = nil\n __EQUAL12__ = nil\n\n\n begin\n # at line 88:13: ID ( dim_obj )? ( EQUAL ( mega_expression | input ) ) SEMI\n __ID11__ = match( ID, TOKENS_FOLLOWING_ID_IN_assignment_731 )\n\n # --> action\n $assgn_aux = __ID11__.text\n # <-- action\n\n\n # --> action\n $quads.variable_exists?(__ID11__.text) \n # <-- action\n\n\n # --> action\n $quads.add_id(__ID11__.text, nil) \n # <-- action\n\n # at line 88:115: ( dim_obj )?\n alt_10 = 2\n look_10_0 = @input.peek( 1 )\n\n if ( look_10_0 == LKEY )\n alt_10 = 1\n end\n case alt_10\n when 1\n # at line 88:117: dim_obj\n # --> action\n $dim_aux = __ID11__.text \n # <-- action\n\n @state.following.push( TOKENS_FOLLOWING_dim_obj_IN_assignment_743 )\n dim_obj\n @state.following.pop\n\n end\n\n # --> action\n $quads.check_dim(__ID11__.text) \n # <-- action\n\n # at line 88:186: ( EQUAL ( mega_expression | input ) )\n # at line 88:188: EQUAL ( mega_expression | input )\n __EQUAL12__ = match( EQUAL, TOKENS_FOLLOWING_EQUAL_IN_assignment_753 )\n\n # --> action\n $quads.add_operator(__EQUAL12__.text) \n # <-- action\n\n # at line 88:233: ( mega_expression | input )\n alt_11 = 2\n look_11_0 = @input.peek( 1 )\n\n if ( look_11_0 == BOOL || look_11_0 == ID || look_11_0 == LPAREN || look_11_0.between?( NUM_F, NUM_I ) || look_11_0 == WORD )\n alt_11 = 1\n elsif ( look_11_0 == INPUT )\n alt_11 = 2\n else\n raise NoViableAlternative( \"\", 11, 0 )\n\n end\n case alt_11\n when 1\n # at line 88:235: mega_expression\n @state.following.push( TOKENS_FOLLOWING_mega_expression_IN_assignment_760 )\n mega_expression\n @state.following.pop\n\n # --> action\n $quads.assign_quad() \n # <-- action\n\n\n when 2\n # at line 88:279: input\n @state.following.push( TOKENS_FOLLOWING_input_IN_assignment_766 )\n input\n @state.following.pop\n\n # --> action\n $quads.assign_read() \n # <-- action\n\n\n end\n\n match( SEMI, TOKENS_FOLLOWING_SEMI_IN_assignment_774 )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n\n end\n\n return \n end",
"def assignment\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 15 )\n\n\n __ID15__ = nil\n __ASGN16__ = nil\n\n\n begin\n # at line 174:5: ID ( dim_struct )? ( ASGN ( super_expression | reading ) ) DOT\n __ID15__ = match( ID, TOKENS_FOLLOWING_ID_IN_assignment_1558 )\n\n # --> action\n $assgn_aux = __ID15__.text\n # <-- action\n\n\n # --> action\n $quads.variable_exists?(__ID15__.text) \n # <-- action\n\n\n # --> action\n $quads.add_id(__ID15__.text, nil) \n # <-- action\n\n # at line 174:107: ( dim_struct )?\n alt_17 = 2\n look_17_0 = @input.peek( 1 )\n\n if ( look_17_0 == LBRACK )\n alt_17 = 1\n end\n case alt_17\n when 1\n # at line 174:109: dim_struct\n # --> action\n $dim_aux = __ID15__.text \n # <-- action\n\n @state.following.push( TOKENS_FOLLOWING_dim_struct_IN_assignment_1570 )\n dim_struct\n @state.following.pop\n\n end\n\n # --> action\n $quads.check_dim(__ID15__.text) \n # <-- action\n\n # at line 174:180: ( ASGN ( super_expression | reading ) )\n # at line 174:182: ASGN ( super_expression | reading )\n __ASGN16__ = match( ASGN, TOKENS_FOLLOWING_ASGN_IN_assignment_1579 )\n\n # --> action\n $quads.add_operator(__ASGN16__.text) \n # <-- action\n\n # at line 174:224: ( super_expression | reading )\n alt_18 = 2\n look_18_0 = @input.peek( 1 )\n\n if ( look_18_0 == BOOL || look_18_0 == FLOAT || look_18_0 == ID || look_18_0 == INTEGER || look_18_0 == LPAR || look_18_0 == STRING )\n alt_18 = 1\n elsif ( look_18_0 == READ )\n alt_18 = 2\n else\n raise NoViableAlternative( \"\", 18, 0 )\n\n end\n case alt_18\n when 1\n # at line 174:226: super_expression\n @state.following.push( TOKENS_FOLLOWING_super_expression_IN_assignment_1585 )\n super_expression\n @state.following.pop\n\n # --> action\n $quads.assgn_quad() \n # <-- action\n\n\n when 2\n # at line 174:270: reading\n @state.following.push( TOKENS_FOLLOWING_reading_IN_assignment_1591 )\n reading\n @state.following.pop\n\n # --> action\n $quads.assgn_read() \n # <-- action\n\n\n end\n\n match( DOT, TOKENS_FOLLOWING_DOT_IN_assignment_1599 )\n\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 15 )\n\n\n end\n\n return \n end",
"def primordial; end",
"def one_classification? (set)\n return true if set.empty?\n c = set[0].classification\n set.each do |s|\n if s.classification != c\n return false\n end\n end\n return true\nend",
"def assignment?(node); end",
"def false_true\n alternatives false, true\n end",
"def boolify(val)\n\nend",
"def BTI(bool) return bool ? \"1\" : \"0\" end",
"def first_assignment?(node); end",
"def check_for_tautology\n counter = 0\n random_decision = StatementEvaluvator.new(@propositional_statement, @random_truth_values).evaluate\n if random_decision == false\n what_simulator_tells = \"False\"\n elsif random_decision == true\n @possible_truth_tables.each do |possible_truth_table|\n counter += 1\n decision = StatementEvaluvator.new(@propositional_statement, possible_truth_table).evaluate\n if decision == false\n what_simulator_tells = \"False\"\n break\n elsif decision == true && counter == @max_truth_tables\n what_simulator_tells = \"True\"\n break\n end\n end\n end\n what_simulator_tells\n end",
"def primary(arg_type)\n # -> uncomment the next line to manually enable rule tracing\n # trace_in(__method__, 9)\n str_tok = nil\n int_tok = nil\n num_tok = nil\n ref2d_tok = nil\n ref2d1_tok = nil\n ref2d2_tok = nil\n ref3d_ref2d = nil\n ref3d_ref2d2 = nil\n name_tok = nil\n func_tok = nil\n sheet1 = nil\n sheet2 = nil\n arg_count = nil\n\n begin\n # at line 100:5: ( TRUE_CONST | FALSE_CONST | str_tok= STR_CONST | int_tok= INT_CONST | num_tok= NUM_CONST | ref2d_tok= REF2D | ref2d1_tok= REF2D COLON ref2d2_tok= REF2D | LP expr[arg_type] RP | sheet1= sheet ( COLON sheet2= sheet )? BANG ref3d_ref2d= REF2D ( COLON ref3d_ref2d2= REF2D )? | FUNC_IF LP expr[\\\"V\\\"] ( SEMICOLON | COMMA ) expr[arg_type] ( SEMICOLON | COMMA ) expr[arg_type] RP | FUNC_CHOOSE LP expr[\\\"V\\\"] ( ( SEMICOLON | COMMA ) ( expr[arg_type] | ) )* RP | name_tok= NAME | func_tok= NAME LP arg_count= expr_list[arg_type_list, min_argc, max_argc] RP )\n alt_15 = 13\n alt_15 = @dfa15.predict(@input)\n case alt_15\n when 1\n # at line 100:7: TRUE_CONST\n match(TRUE_CONST, TOKENS_FOLLOWING_TRUE_CONST_IN_primary_850)\n # --> action\n\n @rpn += [PTGBOOL, 1].pack(\"C2\")\n \n # <-- action\n\n when 2\n # at line 104:7: FALSE_CONST\n match(FALSE_CONST, TOKENS_FOLLOWING_FALSE_CONST_IN_primary_868)\n # --> action\n\n @rpn += [PTGBOOL, 0].pack(\"C2\")\n \n # <-- action\n\n when 3\n # at line 108:7: str_tok= STR_CONST\n str_tok = match(STR_CONST, TOKENS_FOLLOWING_STR_CONST_IN_primary_890)\n # --> action\n\n s = str_tok.text.gsub(\"\\\"\", \"\")\n @rpn += [PTGSTR].pack(\"C\") + [s.length].pack('v') + s\n \n # <-- action\n\n when 4\n # at line 113:7: int_tok= INT_CONST\n int_tok = match(INT_CONST, TOKENS_FOLLOWING_INT_CONST_IN_primary_912)\n # --> action\n\n int_value = int_tok.text.to_i\n if int_value <= 65535\n @rpn += [PTGINT, int_value].pack(\"Cv\")\n else\n @rpn += [PTGNUM, int_value.to_f].pack(\"CE\")\n end\n \n # <-- action\n\n when 5\n # at line 122:7: num_tok= NUM_CONST\n num_tok = match(NUM_CONST, TOKENS_FOLLOWING_NUM_CONST_IN_primary_930)\n # --> action\n\n @rpn += [PTGNUM, num_tok.text.to_f].pack(\"CE\")\n \n # <-- action\n\n when 6\n # at line 126:7: ref2d_tok= REF2D\n ref2d_tok = match(REF2D, TOKENS_FOLLOWING_REF2D_IN_primary_952)\n # --> action\n\n r, c = Utilities.cell_to_packed_rowcol(ref2d_tok.text) \n ptg = PTGREFR + RVA_DELTA_REF[arg_type]\n @rpn += [ptg, r, c].pack(\"Cv2\")\n \n # <-- action\n\n when 7\n # at line 132:7: ref2d1_tok= REF2D COLON ref2d2_tok= REF2D\n ref2d1_tok = match(REF2D, TOKENS_FOLLOWING_REF2D_IN_primary_974)\n match(COLON, TOKENS_FOLLOWING_COLON_IN_primary_976)\n ref2d2_tok = match(REF2D, TOKENS_FOLLOWING_REF2D_IN_primary_982)\n # --> action\n\n r1, c1 = Utilities.cell_to_packed_rowcol(ref2d1_tok.text) \n r2, c2 = Utilities.cell_to_packed_rowcol(ref2d2_tok.text)\n ptg = PTGAREAR + RVA_DELTA_AREA[arg_type]\n @rpn += [ptg, r1, r2, c1, c2].pack(\"Cv4\")\n \n # <-- action\n\n when 8\n # at line 139:7: LP expr[arg_type] RP\n match(LP, TOKENS_FOLLOWING_LP_IN_primary_1000)\n @state.following.push(TOKENS_FOLLOWING_expr_IN_primary_1002)\n expr(arg_type)\n @state.following.pop\n match(RP, TOKENS_FOLLOWING_RP_IN_primary_1005)\n # --> action\n\n @rpn += [PTGPAREN].pack('C')\n \n # <-- action\n\n when 9\n # at line 143:7: sheet1= sheet ( COLON sheet2= sheet )? BANG ref3d_ref2d= REF2D ( COLON ref3d_ref2d2= REF2D )?\n @state.following.push(TOKENS_FOLLOWING_sheet_IN_primary_1028)\n sheet1 = sheet\n @state.following.pop\n # --> action\n \n sheet2 = sheet1\n \n # <-- action\n # at line 147:9: ( COLON sheet2= sheet )?\n alt_11 = 2\n look_11_0 = @input.peek(1)\n\n if (look_11_0 == COLON) \n alt_11 = 1\n end\n case alt_11\n when 1\n # at line 147:11: COLON sheet2= sheet\n match(COLON, TOKENS_FOLLOWING_COLON_IN_primary_1050)\n @state.following.push(TOKENS_FOLLOWING_sheet_IN_primary_1056)\n sheet2 = sheet\n @state.following.pop\n\n end\n match(BANG, TOKENS_FOLLOWING_BANG_IN_primary_1061)\n ref3d_ref2d = match(REF2D, TOKENS_FOLLOWING_REF2D_IN_primary_1065)\n # --> action\n\n ptg = PTGREF3DR + RVA_DELTA_REF[arg_type]\n r1, c1 = Utilities.cell_to_packed_rowcol(ref3d_ref2d.text)\n rpn_ref2d = [0x0000, r1, c1].pack(\"v3\")\n \n # <-- action\n # at line 153:9: ( COLON ref3d_ref2d2= REF2D )?\n alt_12 = 2\n alt_12 = @dfa12.predict(@input)\n case alt_12\n when 1\n # at line 153:11: COLON ref3d_ref2d2= REF2D\n match(COLON, TOKENS_FOLLOWING_COLON_IN_primary_1087)\n ref3d_ref2d2 = match(REF2D, TOKENS_FOLLOWING_REF2D_IN_primary_1092)\n # --> action\n\n ptg = PTGAREA3DR + RVA_DELTA_AREA[arg_type]\n r2, c2 = Utilities.cell_to_packed_rowcol(ref3d_ref2d2.text)\n rpn_ref2d = [0x0000, r1, r2, c1, c2].pack(\"v5\")\n \n # <-- action\n\n end\n # --> action\n\n @rpn += [ptg].pack(\"C\")\n @sheet_references << [sheet1, sheet2, @rpn.size]\n @rpn += rpn_ref2d\n \n # <-- action\n\n when 10\n # at line 165:7: FUNC_IF LP expr[\\\"V\\\"] ( SEMICOLON | COMMA ) expr[arg_type] ( SEMICOLON | COMMA ) expr[arg_type] RP\n match(FUNC_IF, TOKENS_FOLLOWING_FUNC_IF_IN_primary_1135)\n match(LP, TOKENS_FOLLOWING_LP_IN_primary_1145)\n @state.following.push(TOKENS_FOLLOWING_expr_IN_primary_1147)\n expr(\"V\")\n @state.following.pop\n if @input.peek(1).between?(SEMICOLON, COMMA)\n @input.consume\n @state.error_recovery = false\n else\n mse = MismatchedSet(nil)\n raise mse\n end\n\n\n # --> action\n\n @rpn += [PTGATTR, 0x02, 0].pack(\"C2v\") # tAttrIf\n pos0 = @rpn.size - 2\n \n # <-- action\n @state.following.push(TOKENS_FOLLOWING_expr_IN_primary_1176)\n expr(arg_type)\n @state.following.pop\n if @input.peek(1).between?(SEMICOLON, COMMA)\n @input.consume\n @state.error_recovery = false\n else\n mse = MismatchedSet(nil)\n raise mse\n end\n\n\n # --> action\n\n @rpn += [PTGATTR, 0x08, 0].pack(\"C2v\") # tAttrSkip\n pos1 = @rpn.size - 2\n\n @rpn = @rpn[0...pos0] + [pos1-pos0].pack(\"v\") + @rpn[(pos0+2)...(@rpn.size)] \n \n # <-- action\n @state.following.push(TOKENS_FOLLOWING_expr_IN_primary_1205)\n expr(arg_type)\n @state.following.pop\n match(RP, TOKENS_FOLLOWING_RP_IN_primary_1208)\n # --> action\n\n @rpn += [PTGATTR, 0x08, 3].pack(\"C2v\") # tAttrSkip\n @rpn += [PTGFUNCVARR, 3, 1].pack(\"C2v\") # 3 = nargs, 1 = IF func\n pos2 = @rpn.size\n\n @rpn = @rpn[0...pos1] + [pos2-(pos1+2)-1].pack(\"v\") + @rpn[(pos1+2)...(@rpn.size)]\n \n # <-- action\n\n when 11\n # at line 186:7: FUNC_CHOOSE LP expr[\\\"V\\\"] ( ( SEMICOLON | COMMA ) ( expr[arg_type] | ) )* RP\n match(FUNC_CHOOSE, TOKENS_FOLLOWING_FUNC_CHOOSE_IN_primary_1226)\n # --> action\n\n arg_type = \"R\"\n rpn_chunks = []\n \n # <-- action\n match(LP, TOKENS_FOLLOWING_LP_IN_primary_1246)\n @state.following.push(TOKENS_FOLLOWING_expr_IN_primary_1248)\n expr(\"V\")\n @state.following.pop\n # --> action\n\n rpn_start = @rpn.size\n ref_markers = [@sheet_references.size]\n \n # <-- action\n # at line 196:9: ( ( SEMICOLON | COMMA ) ( expr[arg_type] | ) )*\n loop do # decision 14\n alt_14 = 2\n look_14_0 = @input.peek(1)\n\n if (look_14_0.between?(SEMICOLON, COMMA)) \n alt_14 = 1\n\n end\n case alt_14\n when 1\n # at line 197:13: ( SEMICOLON | COMMA ) ( expr[arg_type] | )\n if @input.peek(1).between?(SEMICOLON, COMMA)\n @input.consume\n @state.error_recovery = false\n else\n mse = MismatchedSet(nil)\n raise mse\n end\n\n\n # --> action\n mark = @rpn.size \n # <-- action\n # at line 199:17: ( expr[arg_type] | )\n alt_13 = 2\n alt_13 = @dfa13.predict(@input)\n case alt_13\n when 1\n # at line 200:19: expr[arg_type]\n @state.following.push(TOKENS_FOLLOWING_expr_IN_primary_1345)\n expr(arg_type)\n @state.following.pop\n\n when 2\n # at line 201:19: \n # --> action\n @rpn += [PTGMISSARG].pack(\"C\") \n # <-- action\n\n end\n # --> action\n\n rem = @rpn.size - mark\n rpn_chunks << @rpn[mark, rem]\n ref_markers << @sheet_references.size\n \n # <-- action\n\n else\n break # out of loop for decision 14\n end\n end # loop for decision 14\n match(RP, TOKENS_FOLLOWING_RP_IN_primary_1423)\n # --> action\n\n @rpn = @rpn[0...rpn_start]\n nc = rpn_chunks.length\n chunklens = rpn_chunks.collect {|c| c.length}\n skiplens = [0] * nc\n skiplens[nc-1] = 3\n\n (nc-1).downto(1) do |i|\n skiplens[i-1] = skiplens[i] + chunklens[i] + 4\n end\n jump_pos = [2*nc + 2]\n\n (0...nc).each do |i|\n jump_pos << (jump_pos.last + chunklens[i] + 4)\n end\n chunk_shift = 2*nc + 6 # size of tAttrChoose\n\n (0...nc).each do |i|\n (ref_markers[i]...ref_markers[i+1]).each do |r|\n ref = @sheet_references[r]\n @sheet_references[r] = [ref[0], ref[1], ref[2] + chunk_shift]\n end\n chunk_shift += 4 # size of tAttrSkip\n end\n\n choose_rpn = []\n choose_rpn << [PTGATTR, 0x04, nc].pack(\"CCv\") # 0x04 is tAttrChoose\n choose_rpn << jump_pos.pack(\"v*\")\n \n (0...nc).each do |i|\n choose_rpn << rpn_chunks[i]\n choose_rpn << [PTGATTR, 0x08, skiplens[i]].pack(\"CCv\") # 0x08 is tAttrSkip\n end\n choose_rpn << [PTGFUNCVARV, nc+1, 100].pack(\"CCv\") # 100 is CHOOSE fn\n @rpn += choose_rpn.join\n \n # <-- action\n\n when 12\n # at line 246:7: name_tok= NAME\n name_tok = match(NAME, TOKENS_FOLLOWING_NAME_IN_primary_1445)\n # --> action\n\n raise \"[formula] found unexpected NAME token #{name_tok.text}\"\n \n # <-- action\n\n when 13\n # at line 250:7: func_tok= NAME LP arg_count= expr_list[arg_type_list, min_argc, max_argc] RP\n func_tok = match(NAME, TOKENS_FOLLOWING_NAME_IN_primary_1467)\n # --> action\n\n func_toku = func_tok.text.upcase\n if STD_FUNC_BY_NAME.has_key?(func_toku)\n opcode, min_argc, max_argc, func_type, arg_type_str = STD_FUNC_BY_NAME[func_toku]\n arg_type_list = arg_type_str.split\n else\n raise \"[formula] unknown function #{func_tok.text}\"\n end\n xcall = (opcode < 0)\n\n if xcall\n @xcall_references << [func_toku, @rpn.size + 1]\n @rpn += [PTGNAMEXR, 0xadde, 0xefbe, 0x0000].pack(\"Cvvv\")\n end\n \n # <-- action\n match(LP, TOKENS_FOLLOWING_LP_IN_primary_1487)\n @state.following.push(TOKENS_FOLLOWING_expr_list_IN_primary_1493)\n arg_count = expr_list(arg_type_list, min_argc, max_argc)\n @state.following.pop\n match(RP, TOKENS_FOLLOWING_RP_IN_primary_1496)\n # --> action\n\n if (arg_count > max_argc) || (arg_count < min_argc)\n raise \"incorrect number #{arg_count} of parameters for function: #{func_tok.text}\"\n end\n\n if xcall\n func_ptg = PTGFUNCVARR + RVA_DELTA[func_type]\n @rpn += [func_ptg, arg_count + 1, 255].pack(\"CCv\") # 255 is magic XCALL function\n elsif (min_argc == max_argc)\n func_ptg = PTGFUNCR + RVA_DELTA[func_type]\n @rpn += [func_ptg, opcode].pack(\"Cv\") \n elsif (arg_count == 1) && (func_tok.text.upcase === \"SUM\")\n @rpn += [PTGATTR, 0x10, 0].pack(\"CCv\") # tAttrSum\n else\n func_ptg = PTGFUNCVARR + RVA_DELTA[func_type]\n @rpn += [func_ptg, arg_count, opcode].pack(\"CCv\")\n end\n \n # <-- action\n\n end\n rescue ANTLR3::Error::RecognitionError => re\n report_error(re)\n recover(re)\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out(__method__, 9)\n\n end\n \n return \n end",
"def create_truth_table(truth_s, false_s, size)\r\n truth_table = TruthTable.new([false_s, truth_s], size)\r\n truth_table.start_table\r\n truth_table.calculate_truth_table\r\n table = truth_table.table_array\r\n table\r\nend",
"def synpred8_Jejune\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 94 )\n\n # at line 556:7: member assignment_op\n @state.following.push( TOKENS_FOLLOWING_member_IN_synpred8_Jejune_3692 )\n member\n @state.following.pop\n @state.following.push( TOKENS_FOLLOWING_assignment_op_IN_synpred8_Jejune_3694 )\n assignment_op\n @state.following.pop\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 94 )\n\n end",
"def c_bool!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 37 )\n\n\n\n type = C_BOOL\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 104:9: ( 'true' | 'false' )\n # at line 104:9: ( 'true' | 'false' )\n alt_4 = 2\n look_4_0 = @input.peek( 1 )\n\n if ( look_4_0 == 0x74 )\n alt_4 = 1\n elsif ( look_4_0 == 0x66 )\n alt_4 = 2\n else\n raise NoViableAlternative( \"\", 4, 0 )\n\n end\n case alt_4\n when 1\n # at line 104:11: 'true'\n match( \"true\" )\n\n\n when 2\n # at line 104:20: 'false'\n match( \"false\" )\n\n\n end\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 37 )\n\n\n end",
"def pep_assignment\n end",
"def positives\n\n end",
"def instantiate_unifications(unifications)\n # -- Gather Unifications --\n goals_variables = {}\n \n return_false = false\n unifications.each do |unification|\n left, right, left_goal, right_goal = unification\n \n goals_variables[left_goal] ||= {}\n goals_variables[left_goal][left] ||= []\n goals_variables[left_goal][left] << [right_goal,right]\n \n # -- Check Consistency --\n goals_variables[left_goal][left].map(&:last).map(&:value)\n values = goals_variables[left_goal][left].map{|value|\n value.last.value.value\n }\n next if values.size < 2\n \n arrays = values.any?{|value| value.is_a?(Array) }\n if arrays && !values.variables.empty?\n zipped_values = values[0].zip(*values[1..-1])\n zipped_values.each do |zipped_value|\n vars, atomics = zipped_value.partition{|v| v.type == :variable }\n return_false = true if atomics.uniq.size > 1\n vars.each do |var|\n goals_variables[var.goal] ||= {}\n goals_variables[var.goal][var] ||= []\n goals_variables[var.goal][var] << [([left_goal,right_goal]-[var.goal]).first,atomics.first]\n end\n end\n else\n return_false = values.reject{|value|\n value.is_a?(Variable) || value.is_a?(Symbol)\n }.uniq.size > 1\n end\n \n return false if return_false\n end\n \n # -- Make Instantiations --\n instantiations = []\n consistent = true\n \n goals_variables.each do |goal, variables|\n variables.each do |name, others|\n others.each do |other_goal, other|\n instantiation = goal.instantiate(name, other, other_goal)\n if instantiation\n instantiations << instantiation\n else\n consistent = false\n end\n end\n end\n end\n \n # -- Revert if inconsistent --\n if consistent\n instantiations\n else\n instantiations.each(&:remove)\n nil\n end\n end",
"def dense?; return stype == :dense; end",
"def boolean!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n\n\n type = BOOLEAN\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 193:8: ( 'true' | 'false' )\n alt_2 = 2\n look_2_0 = @input.peek( 1 )\n\n if ( look_2_0 == 0x74 )\n alt_2 = 1\n elsif ( look_2_0 == 0x66 )\n alt_2 = 2\n else\n raise NoViableAlternative( \"\", 2, 0 )\n\n end\n case alt_2\n when 1\n # at line 193:10: 'true'\n match( \"true\" )\n\n\n when 2\n # at line 193:19: 'false'\n match( \"false\" )\n\n\n end\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 28 )\n\n\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a function with two arguments that will return a list of length (n) with multiples of (x). Assume both the given number and the number of times to count will be positive numbers greater than 0. Return the results as an array (or list in Python or Haskell.) Examples: count_by(1,10) should return [1,2,3,4,5,6,7,8,9,10] count_by(2,5) should return [2,4,6,8,10] | def count_by(x, n)
a=[]
y=0
n.times {y+=x; a<<y}
a
end | [
"def counts(n)\n divisors = Array.new\n (1..n).each do |n|\n single_divisors = count n\n divisors.push(single_divisors)\n end\n divisors\n end",
"def amicableNumbersUnder n\n\t\th = Array.new\n\t\t1.upto(n) do |x|\n\t\t\ty = sum(properDivisors(x))\n\t\t\th.push x if x != y && x == sum(properDivisors(y))\n\t\tend\n\t\th\n\tend",
"def n_times(num)\n 1.upto(num) do |count|\n yield(count)\n end\nend",
"def count_to num\n ans = []\n if num >= 0\n 0.upto(num.floor) {|i| ans.push(i)} \n else\n 0.downto(num.ceil) {|i| ans.push(i)}\n end\n ans\nend",
"def count_to number\n new_num = 0\n i = 0\n new_arr = [0]\n if number < 0\n while i > number.ceil\n new_num -= 1\n new_arr << new_num\n i -= 1\n end\n end\n while i < number.floor\n new_num += 1\n new_arr << new_num\n i += 1\n end\n new_arr\n end",
"def at_least_n_factors(numbers, n)\n\n arr = []\n numbers.each do |x|\n arr << x if num_factors(x) >= n\n end\n\n arr\nend",
"def at_least_n_factors(numbers, n)\n n_factors = Array.new\n numbers.each do |num|\n list_of_factors = num_factors(num)\n if list_of_factors.length >= n\n n_factors << num\n end\n end\n n_factors\nend",
"def get_sums(total, count)\n ([1]*total).group_by.with_index {|_, i| i % count}.values.map {|a| a.inject(0, &:+)}\nend",
"def at_least_n_factors(numbers, n)\n arr = []\n numbers.each {|number| arr.push(number) if num_factors(number) >= n}\n arr\nend",
"def n_times(count)\r\n\r\n 1.upto(count) do |n|\r\n yield n\r\n end \r\n\r\nend",
"def oddCount n \n #loop through the array and extract the odd nums\n \n odds = (1...n).select { |num| num % 2 == 1 }\n # odds => [1, 3]\n return odds.length\n \nend",
"def at_least_n_factors(numbers, n)\n numbers.reduce([]) do |num_factors, curr_num|\n if num_factors(curr_num) >= n\n num_factors << curr_num\n else\n num_factors\n end\n end\nend",
"def select_every_n arr, n=1\n ans = []\n arr.each_with_index do |item, i|\n ans.push item if i%n == 0\n end\n ans\nend",
"def multiples num1, num2, divisor\n x = []\n (num1...num2).each do |i|\n if is_divisible i, divisor\n x << i\n end\n end\n x\n end",
"def project_partners(n)\n #your code here\n a = (1..n).to_a\n a.combination(2).size\nend",
"def div_sum_divisors(n)\n results = []\n (2..1_000_000).each do |num|\n results << num if (num**3) % div_sum(num) == 0\n break if results.length == n\n end\n results\nend",
"def multisum(num)\n array_of_5s = []\n (1..num).each { |n| array_of_5s.push(n) if n % 5 == 0 || n % 3 == 0 }\n array_of_5s.inject(:+)\n\nend",
"def count_primes(n)\n primes = (0..n).to_a\n primes[0] = nil\n primes[1] = nil\n\n primes.each do |current_num|\n next if current_num == nil\n break if current_num > Math.sqrt(n)\n (current_num**2).step(n, current_num) { |interval| primes[interval] = nil }\n end\n\n primes.compact.take_while { |num| num < n }.size\nend",
"def sequence(count, starting_number)\n multiples = []\n\n 1.upto(count) { |num| multiples << starting_number * num}\n multiples\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tipocuenta GET /tipocuenta.json | def index
@tipocuenta = Tipocuentum.all
end | [
"def show\n @tipocliente = Tipocliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @tipocliente }\n end\n end",
"def show\n @tip_so = TipSo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tip_so }\n end\n end",
"def show\n @tipomedalla = Tipomedalla.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipomedalla }\n end\n end",
"def show\n @tipos_projeto = TiposProjeto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipos_projeto }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def index\n @tipodetencoes = Tipodetencao.all\n end",
"def show\n @tipp = Tipp.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipp }\n end\n end",
"def show\n @tipo_nota = TipoNota.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_nota }\n end\n end",
"def show\n @telefononegocio = Telefononegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @telefononegocio }\n end\n end",
"def index\n @tiposuarios = Tiposuario.all\n end",
"def show\n @torneio = Torneio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @torneio }\n end\n end",
"def index\n @itemtipos = Itemtipo.all\n\n render json: @itemtipos\n end",
"def index\n @tacos = Taco.all\n\n render json: @tacos\n end",
"def index\n @tiposervicos = Tiposervico.all\n end",
"def index\n @tipos_eventos = TipoEvento.por_colegio(colegio.id).order(\"cuaderno_control DESC\", \"descripcion\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tipos_eventos }\n end\n end",
"def show\n @noto = Noto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @noto }\n end\n end",
"def show\n @tipocuenta = Tipocuenta.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @tipocuenta }\n end\n end",
"def index\n @tipovestuarios = Tipovestuario.all\n end",
"def index\n @tipoincidentes = Tipoincidente.all\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calls mattermost using the default Mattermost URL from the configuration data is a hash containing the data to send. Note that channel, username, and icon_url are reserved url is the Mattermost URL defined above. This can be overridden for debugging header is the default headers. This shouldn't need modified, but it's nice to have | def call_mattermost (data = {}, url = [Config['Mattermost']['url'], 'hooks', Config['Mattermost']['webhook_code']].join('/'), header = {content_type: :json, accept: :json})
if !data.has_key?(:login_id)
payload = data.merge(Config['DefaultPayload'])
else
payload = data
end
# Just in case, though we may not need text
unless payload.has_key?(:text) or payload.has_key?(:attachments)
payload['text'] = 'This was triggered on: ' + Time.now.strftime("%d/%m/%Y %H:%M") #Feel free to change this
end
response = RestClient.post url, payload.to_json, {content_type: :json, accept: :json}
return response
end | [
"def push_data(push_params)\n # Push URI\n push_uri = URI.parse(\"#{$tipboard_base_uri}/#{$apikey}/push\")\n\n # Post to API to set up tile\n push_response = Net::HTTP.post_form(push_uri, push_params)\nend",
"def send_message(mes,token,user_id)\n #Open a direct message\n options = {\n token: token,\n user: user_id\n }\n channel_id = post('https://slack.com/api/im.open', options).channel.id\n\n #Send the message\n options = {\n token: token,\n channel: channel_id,\n text: mes\n }\n post('https://slack.com/api/chat.postMessage', options)\nend",
"def send_post(post)\n title = CGI.unescapeHTML(post['title'])\n author = post['author']\n url = post['url']\n time = post['created']\n link = 'https://reddit.com' + post['permalink']\n preview = post['thumbnail']\n # Create an Embed\n Bot.channel(Config['channel']).send_embed do |emb|\n emb.color = '3498db'\n emb.author = { name: title, url: link}\n emb.image = { url: preview }\n emb.url = link\n emb.add_field name: 'Link:', value: url, inline: false\n emb.footer = { text: \"Posted by /u/#{author} @ #{Time.at(time).strftime('%a, %d %b %H:%M')}\", icon_url: Bot.profile.avatar_url }\n end\nend",
"def post_quickreplies(quickreplies, data)\n\tindex = 1\n\temojis = []\n\tmessage = \"Please select one of the following options for further inquiries: \\n\"\n\tfor reply in quickreplies do\n\t\tnum_as_emoji = \":#{$nums[index]}:\"\n\t\toption_str = \"#{num_as_emoji} #{reply} \\n\"\n\t\tmessage += option_str\n\t\temojis.push(\"#{$nums[index]}\")\n\t\tindex += 1\n\tend\n\n\t# sometimes we're getting 'data' from RTM API and not web, and the data for channel info lives in a different place\n\tchannel_send = data['channel']\n\tchannel_send = data['item']['channel'] if !channel_send\n\tchatbot_response = $web_client.chat_postMessage channel: channel_send, text: \"#{message}\", as_user: true\n\tputs \"Chatbot result_response: #{chatbot_response.ts}\"\n\tfor i in 0...quickreplies.size\n\t\tsession_id = data.user\n\t\treply_text = quickreplies[i] \n\t\tputs \"Adding emoji: #{emojis[i]} on #{chatbot_response.channel} at #{chatbot_response.ts}\" if DEBUG_MODE\n\t\t$web_client.reactions_add(name: emojis[i], channel: chatbot_response.channel, timestamp: chatbot_response.ts)\n\n\t\t# store info about the message with reaction emojis we just sent by setting something in the sessions obj\n\t\t# hashed by: $sessions[session_id][chatbot_response.channel][chatbot_response.ts] \n\t\t# session_id here is just user_id from slack\n\t\t$sessions[session_id] = {} if !$sessions.key? session_id\n\t\t$sessions[session_id][chatbot_response.channel] = {} if !$sessions[session_id].key? chatbot_response.channel\n\t\t$sessions[session_id][chatbot_response.channel][chatbot_response.ts] = {} if !$sessions[session_id][chatbot_response.channel].key? chatbot_response.ts\n\t\t# puts \"SESSION PRINT: #{$sessions.inspect}\" if DEBUG_MODE\n\t\t$sessions[session_id][chatbot_response.channel][chatbot_response.ts][emojis[i]] = reply_text\n\t\t\n\tend\nend",
"def pm(content = nil)\n if content\n # Recursively call pm to get the channel, then send a message to it\n channel = pm\n channel.send_message(content)\n else\n # If no message was specified, return the PM channel\n @bot.private_channel(@id)\n end\n end",
"def posts(before = nil)\n uri = \"/channels/#{self.id}/posts\"\n uri += \"/#{before}\" if before \n uri += \"/0/60?_=#{Time.now.to_i}\"\n request = Mattermost.get(\"/channels/#{self.id}/posts/0/60?_=#{Time.now.to_i}\")\n response = {}\n request.parsed_response['posts'].each do |_, post|\n response[k] = Post.new(post)\n end\n response\n end",
"def http_send url, form_data, headers, &block\n if form_data['action'] == 'query'\n log.debug(\"GET: #{form_data.inspect}, #{@cookies.inspect}\")\n headers[:params] = form_data\n RestClient.get url, headers, &block\n else\n log.debug(\"POST: #{form_data.inspect}, #{@cookies.inspect}\")\n RestClient.post url, form_data, headers, &block\n end\n end",
"def push_tileconfig(tile_name, tileconfig_params)\n # Tileconfig URI\n tileconfig_uri = URI.parse(\"#{$tipboard_base_uri}/#{$apikey}/tileconfig/\" + tile_name)\n\n # Post to API to set up tileconfig\n tileconfig_response = Net::HTTP.post_form(tileconfig_uri, tileconfig_params)\nend",
"def http_post(curl, data, url)\n\n # Define the post data\n data2 = ''\n\n # Loop through the data[\"post_data\"] passed in to build up the post data string\n data[\"post_data\"].each do |key, value|\n if (data2 != '') then\n data2 = data2 + '&'\n end\n # If the value is null we don't just want it to look like: item=\n if (value.nil?) then\n data2 = data2 + CGI::escape(key.to_s) + '='\n else\n data2 = data2 + CGI::escape(key.to_s) + '=' + CGI::escape(value.to_s)\n end\n end\n\n # Define the url we want to hit\n curl.url = url\n # Specify the headers we want to hit\n curl.headers = data['header']\n\n # perform the call\n curl.post(data2)\n\n curl.headers = nil\n\n # Set headers to nil so none get reused elsewhere\n curl.headers = nil\n\n # return the curl object\n return curl\n\nend",
"def send_rich_media_message to, title, description, pic_url\n send_multiple_rich_messages to, [{ title: title, description: description, picurl: pic_url }]\n end",
"def pm(content = nil)\n if content\n # Recursively call pm to get the channel, then send a message to it\n channel = pm\n channel.send_message(content)\n else\n # If no message was specified, return the PM channel\n @bot.pm_channel(@id)\n end\n end",
"def send_slack_message\n begin\n is_pull_request = ARGV[0]\n \tbuild_passed = ARGV[1]\n user = ARGV[2]\n build_link = ARGV[3]\n slack_webhook_url = ARGV[4]\n channel = nil\n\n if is_pull_request == \"true\"\n if build_passed == \"true\"\n pretext = \"Hey @#{user}, your pull request build just passed!\"\n color = \"#7CD197\"\n fallback = \"Hey @#{user}, your pull request build just passed. Go check it out here: #{build_link}\"\n else\n pretext = \"Oh no!! @#{user}, your pull request build failed!\"\n color = \"#B0171F\"\n fallback = \"Oh no!! @#{user}, your pull request build failed. Diagnose the issue here: #{build_link}\"\n end \n else\n # Channel override for generic build plans that are not for pull requests\n if ARGV.length > 5\n channel = ARGV[5]\n plan_name = ARGV[6]\n if build_passed == \"true\"\n pretext = \"Hey team, #{plan_name} passed!\"\n color = \"#7CD197\"\n fallback = \"Hey team, #{plan_name} just had a passing build! Check it out here: #{build_link}\"\n else\n pretext = \"Oh no!! #{plan_name} just failed!\"\n color = \"#B0171F\"\n fallback = \"Oh no! #{plan_name} just failed! Diagnose the issue here: #{build_link}\"\n end\n end\n end\n\n unless channel.nil?\n # channel must contain # as the first character \n channel_or_user = channel\n else\n channel_or_user = '@' + user\n end\n \n puts \"Sending message to user: #{channel_or_user} with message: #{pretext}\"\n\n \turi = URI(slack_webhook_url)\n\n # Create client\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n\n dict = {\n \t:channel => \"#{channel_or_user}\",\n \t:username => \"Buildbot\",\n :icon_emoji => \":bamboo_atlassian:\",\n :attachments => [ \n {\n :fallback => \"#{fallback}\",\n :pretext => \"#{pretext}\",\n :title => \"#{build_link}\",\n :title_link => \"#{build_link}\",\n :color => \"#{color}\"\n }\n ]\n }\n body = JSON.dump(dict)\n\n # Create Request\n req = Net::HTTP::Post.new(uri)\n # Add headers\n req.add_field \"Content-Type\", \"application/json\"\n # Set header and body\n req.body = body\n\n # Fetch Request\n res = http.request(req)\n puts \"Response HTTP Status Code: #{res.code}\"\n puts \"Response HTTP Response Body: #{res.body}\"\n rescue StandardError => e\n\tputs \"HTTP Request failed (#{e.message})\"\n end\nend",
"def post_to_slack\n system(\"curl -X POST --data-urlencode 'payload={\\\"channel\\\": \\\"#hedgehogs\\\", \\\"username\\\": \\\"Toto, Min and Fumi\\\", \\\"text\\\": \\\"現在、小屋の気温は #{@temparature.round(1)}℃です\\\"}' https://hooks.slack.com/services/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\")\n end",
"def post(message, params = {})\n return if options[:quiet]\n ActiveResource::Base.logger = Logger.new(STDOUT) if options[:trace]\n Socialcast::CommandLine::Message.configure_from_credentials\n response = Socialcast::CommandLine::Message.create params.merge(:body => message)\n say \"Message has been posted: #{response.permalink_url}\"\n end",
"def send_push_notification(user, message, link=nil)\n puts \"SENDING PUSH NOTIFICATION\"\n\n opts = {\n \"msg\" => message,\n \"alias\" => user.email,\n \"platform\" => [0,1],\n \"badge\" => user.notification_counts[:all]\n }\n if !link.nil?\n opts[\"payload['link']\"] = link\n end\n\n ObjectActivity.pushbots_api(\"http://api.pushbots.com/push/all\", opts)\n\n # begin\n # uri = URI.parse(\"http://api.pushbots.com/push/all\")\n # http = Net::HTTP.new(uri.host)\n # request = Net::HTTP::Post.new(uri.request_uri)\n # if Rails.env == 'production'\n # request[\"x-pushbots-appid\"] = \"5526d36017795905498b4580\"\n # request[\"x-pushbots-secret\"] = \"46ef6a7a6548800948b40f9846668519\"\n # else\n # request[\"x-pushbots-appid\"] = \"568ecf7f1779592c338b4567\"\n # request[\"x-pushbots-secret\"] = \"8a25aab58e55347d3555bf48a0474c30\"\n # end\n #\n # request[\"Content-Type\"] = \"application/json\"\n # opts = {\n # \"msg\" => message,\n # \"alias\" => user.email,\n #\n # \"platform\" => [0,1],\n # \"badge\" => user.notification_counts[:all]\n #\n # # \"payload['mytest']\" => 'My Test'\n # # \"sound\" => \"event\",\n #\n # # Below options don't seem to work...\n # # \"OpenURL\" => \"users\",\n # # \"payload\" => {\"OpenURL\" => \"http://google.com\"}.to_json\n # }\n # if !link.nil?\n # opts[\"payload['link']\"] = link\n # end\n # request.set_form_data(opts)\n # response = http.request(request)\n # #puts response\n # rescue\n # end\n end",
"def set_whats_new_url(args = {}) \n put(\"/globalsettings.json/news/url\", args)\nend",
"def curl_form_data(uri, form_data=[], options={})\n curl = Pkg::Util::Tool.find_tool(\"curl\") or fail \"Couldn't find curl. Curl is required for posting jenkins to trigger a build. Please install curl and try again.\"\n #\n # Begin constructing the post string.\n # First, assemble the form_data arguments\n #\n post_string = \"-i \"\n form_data.each do |param|\n post_string << \"#{param} \"\n end\n\n # Add the uri\n post_string << \"#{uri}\"\n\n # If this is quiet, we're going to silence all output\n if options[:quiet]\n post_string << \" >/dev/null 2>&1\"\n end\n\n %x{#{curl} #{post_string}}\n return $?.success?\nend",
"def curl_form_data(uri, form_data=[], options={})\n curl = find_tool(\"curl\") or fail \"Couldn't find curl. Curl is required for posting jenkins to trigger a build. Please install curl and try again.\"\n #\n # Begin constructing the post string.\n # First, assemble the form_data arguments\n #\n post_string = \"-i \"\n form_data.each do |param|\n post_string << \"#{param} \"\n end\n\n # Add the uri\n post_string << \"#{uri}\"\n\n # If this is quiet, we're going to silence all output\n if options[:quiet]\n post_string << \" >/dev/null 2>&1\"\n end\n\n %x{#{curl} #{post_string}}\n return $?.success?\nend",
"def post_with_curl\n url = @settings.webhook_url\n `curl -is -X POST -H \"Content-Type:application/json\" -d '#{get_body}' '#{url}'`\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
upload_file moves the file to the webserver from the config file filename: The full path of the image file video_filename: Used to generate a unique MD5 hash for each image file | def upload_file (filename, video_filename)
# new filename is the md5 of the old filename, plus "jpg"
new_filename = Digest::MD5.hexdigest video_filename
new_filename += '.jpg'
FileUtils.mv(filename, [Config['WebServer']['webroot'], Config['WebServer']['preview_dir'], new_filename].join('/'))
return [Config['WebServer']['url'], Config['WebServer']['preview_dir'], new_filename].join('/')
end | [
"def upload_file\n\tproject = self.use_case.project\n\n\tfile = url_path.read\n whole_name = url_path.original_filename\n final_name = self.name + \".v1.0\" + File.extname(whole_name)\n file_path = project.name + \"/UseCases/\" + self.name + \"/\" + final_name\n dbsession = DropboxSession.deserialize(project.dropbox_token)\n client = DropboxClient.new(dbsession)\n response = client.put_file(file_path, file)\n link = client.shares(response[\"path\"])\n self.url_path = link[\"url\"]\n end",
"def upload_video_at_s3(filename, filepath) \n\t\tbegin\n\t\t\ts3 = Aws::S3::Resource.new\n\t\t\tobj = s3.bucket(ENV['AWS_S3_BUCKET'] || 'tv-guide-s3-bucket').object(filename)\n\t\t\tif obj.upload_file(filepath)\n\t\t\t\tself.update(video_filename: filename) \n\n\t\t\t\tFile.delete(filepath) \n\t\t\tend\n\t\trescue StandardError => e\n\t \tRails.logger.info \"================================================upload_video_at_s3:69\"\n\t \tRails.logger.info e\n\t\tend\n\tend",
"def process_uploaded_video_file\n if @video_file.present?\n video_file_stream = if @video_file.respond_to?(:path, true)\n File.open(@video_file.path)\n else\n @video_file\n end\n @uploaded_video_token = local_or_global_kaltura_client.\n media_service.upload(video_file_stream)\n raise ActsAsKaltura::Video::NoUploadedTokenFound if @uploaded_video_token.nil?\n end\n end",
"def upload_file(file_uri, html_filename, destination_path)\n\n # binding.pry\n if(file_uri[/^http/])\n # TODO Sjekke at filen ligger på samme server eller annen server\n filename = file_uri\n else\n filename = (Pathname.new(html_filename).parent + Pathname.new(file_uri)).to_s\n end\n\n\n basename = Pathname.new(file_uri).basename.to_s\n destination_filename = destination_path + '/' + basename\n\n content = nil\n begin\n # puts \"Filename => \" + filename.to_s\n timeout(15) do # Makes open-uri timeout after 10 seconds.\n begin\n content = open(filename).read\n rescue\n puts \"Error: Timeout: \" + filename\n log_error('timed-out',filename)\n return nil\n end\n end\n rescue\n puts \"Logging error: File not found : \" + filename if(@debug)\n log_error('file-not-found',filename)\n end\n if(content)then\n # Downcase path but not destination_filename:\n arr = destination_filename.split(/\\//)\n destination_filename = arr[0..arr.size-2].join(\"/\").downcase + \"/\" + arr.last\n\n puts \"File uri : \" + file_uri if(@debug)\n puts \" Copying : \" + filename if(@debug)\n puts \" To : \" + destination_filename if(@debug)\n\n if(@vortex.exists?(destination_filename))\n puts \" Warning : \" + destination_filename + \" exists on server.\"\n else\n # binding.pry\n @vortex.put_string(destination_filename, content)\n log_upload('file', filename.sub(@html_dir,''), destination_filename.sub(@vortex_path,''))\n end\n end\n end",
"def upload_file(upload_url, upload_file, vapp_template, config = {})\n # Set chunksize to 5M if not specified otherwise\n chunk_size = (config[:chunksize] || 5_242_880)\n @logger.debug(\"Set chunksize to #{chunk_size} bytes\")\n\n # Set progressbar to default format if not specified otherwise\n progressbar_format = (\n config[:progressbar_format] || '%t Progress: %p%% %e'\n )\n\n # Open our file for upload\n upload_file_handle = File.new(upload_file, 'rb')\n file_name = File.basename(upload_file_handle)\n\n # FIXME: I removed the filename below because I recall a weird issue\n # of upload failing because if a too long filename\n # (tsugliani)\n # => Added the filename back, needs more testing (frapposelli)\n progressbar_title = \"Uploading #{file_name}\"\n\n # Create a progressbar object if progress bar is enabled\n if config[:progressbar_enable] == true &&\n upload_file_handle.size.to_i > chunk_size\n progressbar = ProgressBar.create(\n :title => progressbar_title,\n :starting_at => 0,\n :total => upload_file_handle.size.to_i,\n :format => progressbar_format\n )\n else\n puts progressbar_title\n end\n # Create a new HTTP client\n clnt = HTTPClient.new\n\n # Set SSL proto to TLSv1\n clnt.ssl_config.ssl_version = :TLSv1\n \n # Suppress SSL depth message\n clnt.ssl_config.verify_callback = proc { |ok, ctx|; true }\n\n # Perform ranged upload until the file reaches its end\n until upload_file_handle.eof?\n\n # Create ranges for this chunk upload\n range_start = upload_file_handle.pos\n range_stop = upload_file_handle.pos.to_i + chunk_size\n\n # Read current chunk\n file_content = upload_file_handle.read(chunk_size)\n\n # If statement to handle last chunk transfer if is > than filesize\n if range_stop.to_i > upload_file_handle.size.to_i\n content_range = \"bytes #{range_start.to_s}-\" +\n \"#{upload_file_handle.size.to_s}/\" +\n \"#{upload_file_handle.size.to_s}\"\n range_len = upload_file_handle.size.to_i - range_start.to_i\n else\n content_range = \"bytes #{range_start.to_s}-\" +\n \"#{range_stop.to_s}/\" +\n \"#{upload_file_handle.size.to_s}\"\n range_len = range_stop.to_i - range_start.to_i\n end\n\n # Build headers\n extheader = {\n 'x-vcloud-authorization' => @auth_key,\n 'Content-Range' => content_range,\n 'Content-Length' => range_len.to_s\n }\n\n upload_request = \"#{@host_url}#{upload_url}\"\n\n # Massive debug when LOG=DEBUG\n # Using awesome_print to get nice XML output for better readability\n if @logger.level == 1\n ap \"[#{Time.now.ctime}] -> SEND PUT #{upload_request}\"\n ap 'SEND HEADERS'\n ap extheader\n ap 'SEND BODY'\n ap '<data omitted>'\n end\n\n begin\n\n response = clnt.request(\n 'PUT',\n upload_request,\n nil,\n file_content,\n extheader\n )\n\n unless response.ok?\n fail Errors::UnattendedCodeError, :message => response.status\n end\n\n if config[:progressbar_enable] == true &&\n upload_file_handle.size.to_i > chunk_size\n params = {\n 'method' => :get,\n 'command' => \"/vAppTemplate/vappTemplate-#{vapp_template}\"\n }\n response, _headers = send_request(params)\n\n response.css(\n \"Files File [name='#{file_name}']\"\n ).each do |file|\n progressbar.progress = file[:bytesTransferred].to_i\n end\n end\n\n rescue\n # FIXME: HUGE FIXME!!!!\n # DO SOMETHING WITH THIS, IT'S JUST STUPID AS IT IS NOW!!!\n retry_time = (config[:retry_time] || 5)\n puts \"Range #{content_range} failed to upload, \" +\n \"retrying the chunk in #{retry_time.to_s} seconds, \" +\n 'to stop this task press CTRL+C.'\n sleep retry_time.to_i\n retry\n end\n end\n upload_file_handle.close\n end",
"def upload\n credentials = {}\n if @destinations\n @destinations.each_pair do |site, c| \n credentials.merge!(site => \"#{c[0]}:#{c[1]}\")\n end\n end\n \n result = HTTP.post(\"/video\", {\n :title => @title, \n :description => @description, \n :tags => @tags, \n :category => @category, \n :file => @file, \n :url => @url, \n :ping => @ping,\n :watermark_image_url => @watermark_image_url,\n :watermark_position => @watermark_position,\n :convert => @convert,\n :stat => @stat\n }.merge(credentials)\n )\n \n Video.new(Video.hpricot_to_hash(result))\n end",
"def upload_file(file_uri, html_filename, destination_path)\n if(file_uri[/^http/])\n # TODO Sjekke at filen ligger på samme server eller annen server\n filename = file_uri\n else\n # binding.pry\n filename = (Pathname.new(html_filename.to_s).parent + Pathname.new(file_uri)).to_s\n end\n\n basename = Pathname.new(file_uri).basename.to_s\n destination_filename = destination_path + '/' + basename\n\n content = nil\n begin\n # puts \"Filename => \" + filename.to_s\n timeout(15) do # Makes open-uri timeout after 10 seconds.\n begin\n content = open(filename).read\n rescue\n puts \"Error: Timeout: \" + filename\n log_error('timed-out',filename)\n return nil\n end\n end\n rescue\n puts \"Logging error: File not found : \" + filename if(@debug)\n log_error('file-not-found',filename)\n end\n if(content)then\n puts \"File uri : \" + file_uri if(@debug)\n puts \" Copying : \" + filename if(@debug)\n puts \" To : \" + destination_filename if(@debug)\n @vortex.put_string(destination_filename, content)\n log_upload('file', file_uri , destination_filename.sub(@vortex_path,''))\n end\n end",
"def upload_file\n project = self.task.project\n task = self.task\n\n file = url_path.read\n self.original_name = url_path.original_filename\n self.version = DocumentTask.where(:name => self.name).count + 1\n\n final_name = \"#{self.name}.v#{self.version}#{File.extname(original_name)}\"\n file_path = project.name + \"/\" + task.name + \"/\" + final_name\n dbsession = DropboxSession.deserialize(project.dropbox_token)\n client = DropboxClient.new(dbsession)\n response = client.put_file(file_path, file)\n link = client.shares(response[\"path\"])\n self.url_path = link[\"url\"]\n end",
"def upload\n Oynx_Back.upload(options, config[\"name\"], File.join(Dir.pwd, config[\"name\"]))\n end",
"def upload_file(f)\n # grabs the compiled asset from public_path\n full_file_path = File.join(File.dirname(@manifest.dir), f)\n one_year = 31557600\n mime = Rack::Mime.mime_type(File.extname(f)) \n file = {\n :key => f,\n :public => true,\n :content_type => mime,\n :cache_control => \"public, max-age=#{one_year}\",\n :expires => CGI.rfc1123_date(Time.now + one_year) \n }\n\n gzipped = \"#{full_file_path}.gz\" \n\n if File.exists?(gzipped)\n original_size = File.size(full_file_path)\n gzipped_size = File.size(gzipped)\n\n if gzipped_size < original_size\n file.merge!({\n :body => File.open(gzipped),\n :content_encoding => 'gzip'\n })\n log \"Uploading #{gzipped} in place of #{f}\"\n else\n file.merge!({\n :body => File.open(full_file_path)\n })\n log \"Gzip exists but has larger file size, uploading #{f}\"\n end\n else\n file.merge!({\n :body => File.open(full_file_path)\n })\n log \"Uploading #{f}\"\n end\n # put in reduced redundancy option here later if desired\n\n file = bucket.files.create( file )\n end",
"def do_file_upload\n #TODO deal with .gitkeep\n max_size = 500000\n total_upload_max = 1000000\n file = params[:file]\n file_size = file.size\n if file_size > max_size\n flash[:upload_error] = \"Error: File too large. Max size = #{max_size}B. Given size = #{file_size}.\"\n else\n upload_total = UploadTotal.take\n new_upload_total = upload_total.upload_total + file_size\n if new_upload_total > total_upload_max\n flash[:upload_error] = \"Error: Total upload limit reached. Limit = #{total_upload_max}B.\"\n else\n File.open(File.join(upload_dir, file.original_filename), 'wb') do |f|\n f.write(file.read)\n end\n upload_total.upload_total = new_upload_total\n upload_total.save\n end\n end\n redirect_to :back\n end",
"def upload(file_name)\n #fazendo o upload da imagem\n #usando Dir.pwd serve para obter o caminho do diretorio principal do projeto\n # guardo na variavel thumb e chamo no find\n #como o imput esta com display: none usa o visible: false para ignorar o display\n thumb = Dir.pwd + \"/features/support/fixtures/images/\" + file_name\n find(\"#thumbnail input[type=file]\", visible: false).set thumb\n end",
"def create\n uploaded_file = params[:file_upload][:my_file]\n uuid = Digest::SHA2.hexdigest(\"#{Time.now.utc}_#{srand}_#{uploaded_file.original_filename}\").first(8)\n first_dir = uuid[0..1]\n second_dir = uuid[2..3]\n file_prefix = uuid[4..-1]\n upload_filename = if APP_CONFIG[:mask_uploads]\n Digest::SHA2.hexdigest(uploaded_file.original_filename).first(32)\n else\n uploaded_file.original_filename.gsub(/\\s+/, '_')\n end\n upload_path = File.join(first_dir, second_dir, \"#{file_prefix}_#{upload_filename}\")\n new_asset = Asset.new()\n new_asset.filename = upload_path\n new_asset.web_dir = 'upload'\n new_asset.original_filename = if APP_CONFIG[:mask_uploads]\n upload_filename\n else\n uploaded_file.original_filename\n end\n if new_asset.valid?\n FileUtils.mkdir_p(File.dirname(new_asset.filename))\n FileUtils.cp(uploaded_file.tempfile, new_asset.filename)\n FileUtils.chmod(0644, new_asset.filename)\n new_asset.save\n else\n # gotta return false if not valid\n end\n redirect_to :controller => :admin\n end",
"def upload_file\n upload_thumb if Rails.configuration.thumbnails_enabled\n file_s3_obj.write(@file.tempfile.open, content_type: @file.content_type)\n end",
"def upload\n end",
"def upload_file\n counter = 1\n @file_name = params[:NewFile].original_filename\n # break it up into file and extension\n # we need this to check the types and to build new names if necessary\n ext = File.extname(@file_name)\n path = File.basename(@file_name, ext)\n\n # check to make sure this extension isn't in deny and is in allow\n filetype = params[:Type].downcase.to_sym\n if type_allowed(filetype, ext)\n while File.exist?(File.join(@options[:dir], @file_name))\n @file_name = \"#{path}(#{counter})#{ext}\"\n @error = 201\n counter += 1\n end\n\n File.open(\"#{@options[:dir]}#{@file_name}\", 'wb') do |f| \n f.write(params[:NewFile].read)\n end\n else\n # invalid file type\n @error = 202\n end\n\n render :template => 'fckeditor/upload_file'\n end",
"def upload(config={})\n\n\t\tfile_name = config.delete(:file_name)\n\t\tpath_to_s3_folder = config.delete(:path_to_s3_folder)\n\n\t\tif file_name.nil? || file_name.empty?\n\t\t\traise ArgumentError, \"file_names is either empty or contains no values\"\n\t\telsif file_name==''\n\t\t\traise ArgumentError, \"File Names is passed as empty string. Pass appropriate values\"\n\t\tend\n\n\t\tfile_names = Array.new\n\t\tfile_names = file_name if file_name.is_a? Array\n\n\t\tfile_names.push(file_name) if file_name.is_a? String\n\t\tfile_names.each {|file|\n\t\t\t#raise ArgumentError, \"File name does not exist in the main directory\" if File.exists?(file)==false\n\t\t\tfinal_file_path = path_to_s3_folder + file\n\t\t\t@s3.buckets[@bucket_name].objects[final_file_path].write(:file => file)\n\t\t\tputs \"#{file} successfully uploaded\"\n\t\t} unless file_names.nil?\n\tend",
"def upload file, ticket_id, auth_token\n params = {\n :auth_token => auth_token,\n :ticket_id => ticket_id\n }\n params[:api_sig] = generate_api_sig params\n\n c = Curl::Easy.new('http://vimeo.com/services/upload')\n c.multipart_form_post = true\n c.http_post(\n *(params.map { |k,v| Curl::PostField.content(k.to_s, v) } +\n [Curl::PostField.file('video', file)])\n )\n end",
"def upload_image_to_aws\n\n puts \"HERE\"\n\n file_name = params[:file]\n\n puts file_name.tempfile\n\n key = SecureRandom.hex + \".jpg\"\n\n obj = S3_BUCKET.object(key)\n obj.upload_file(file_name.tempfile)\n\n\n response = {\n success: true,\n url: 'https://s3-us-west-2.amazonaws.com/mailfunnels-dev/' + key\n }\n\n render json: response\n\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates previews for each movie file in the transcode directory filename: The full path of the video file to output options: allows you to pass the following values for configuration. If not set they'll be pulled from your config framegrab_grid: (string) Something like '5x6' or '2x4' to specify the size of the grid framegrab_interval: (integer) The interval at which to grab frames in seconds. If set to zero it will determine it based on grid size and duration framegrab_height: (integer) The height of the generated frames in pixels. | def generate_previews(filename, options = {})
framegrab_grid = options['framegrab_grid'] || Config['PreviewSettings']['default_grid']
framegrab_interval = options['framegrab_interval'] || Config['PreviewSettings']['default_interval']
framegrab_height = options['framegrab_height'] || Config['PreviewSettings']['default_height']
base_filename = File.basename(filename)
filesize = File.size(filename)
file_info = Mediainfo.new filename
if framegrab_interval.to_i == 0
total_images = 1
framegrab_grid.split('x').each do |x|
total_images *= x.to_i
end
framegrab_interval = file_info.duration / total_images
end
count = 0
units = ['bytes', 'KB', 'MB', 'GB', 'TB']
loop do
break if filesize < 1024.0
count += 1
filesize /= 1024.0
end
pretty_filesize = filesize.round(2).to_s + ' ' + units[count]
duration = file_info.duration
remainder = 0
count = 0
units = ['sec','min','h']
loop do
break if duration < 60
count += 1
remainder = duration % 60
duration /= 60
end
pretty_duration = duration.round(0).to_s + ' ' + units[count]
if remainder > 0
pretty_duration += ' ' + remainder.round(0).to_s + ' ' + units[count-1]
end
command = "ffmpeg -loglevel panic -y -i \"#{filename}\" -frames 1 -q:v 1 -vf \"select='isnan(prev_selected_t)+gte(t-prev_selected_t\," + framegrab_interval.to_s + ")',scale=-1:" + framegrab_height.to_s + ",tile=" + framegrab_grid + "\" '/tmp/video_preview.jpg'"
# puts command
if system(command)
# # Now that the preview is generated, post it to Mattermost
if !(uploaded_file_url = upload_file('/tmp/video_preview.jpg', base_filename))
call_mattermost({:text => "We ran into a problem uploading the file. Have someone look at this!"})
else
message = "![#{base_filename}](#{uploaded_file_url})\n\n"
message+= "|#{base_filename}|[(preview)](#{uploaded_file_url})|\n"
message+= "|-|-:|\n"
message+= "|File Size| **#{pretty_filesize}**|\n"
message+= "|Duration| **#{pretty_duration}**|\n"
message+= "|Format| **#{file_info.format}**|"
actions = Config['FileOperations']
attachments_actions = []
actions.keys.each do |key|
action_hash = {
'name': key,
'integration': {
'url': [Config['Webhook']['url'], 'run-command'].join('/'),
'context': {
'command': key,
'filename': File.realpath(filename)
}
}
}
attachments_actions.push(action_hash)
end
attachments = [
{
"text": message,
"actions": attachments_actions
}]
payload = {:attachments => attachments}
call_mattermost(payload)
end
else
Log.error "There was an error running the command: #{command}"
call_mattermost({:text => "### DANGER WILL ROBINSON\nERROR"})
end
end | [
"def generate_compilation\n puts \"Generating compilation\"\n get_selected_vines\n pathArray = [];\n @selected_vines.each do |vid|\n vine = Vine.find(vid)\n pathArray.push vine.path\n end\n if pathArray.count > 0\n return outputFile = execute_ffmpeg(pathArray)\n end\n end",
"def gen_highlights_for_multi_sessions(session_count, video_dir, txt_dir, dst_video)\n mpg_videos = []\n seg_filenames = []\n k = 1\n (1..session_count).each do |i|\n src_video = File.join(video_dir, \"session#{i}.mp4\")\n txt_file = File.join(txt_dir, \"session#{i}.txt\")\n pairs = get_time_pairs(txt_file)\n pairs.each do |pair|\n outmp4 = File.join($tmp_folder, \"#{k}.mp4\")\n outmpg = File.join($tmp_folder, \"#{k}.mpg\")\n seg_filenames << outmpg\n cmd_str = \"#{$ffmpeg} -ss #{pair[0]} -t #{pair[1] - pair[0] + 2} -i \\\"#{src_video}\\\" #{outmp4}\"\n p cmd_str\n system(cmd_str) unless File.exists? outmp4\n cmd_str = \"#{$ffmpeg} -i #{outmp4} -qscale:v 1 #{outmpg}\"\n p cmd_str\n system(cmd_str) unless File.exists? outmpg\n k = k + 1\n end\n end\n all_segs = seg_filenames.join('|')\n mpg_all = File.join($tmp_folder, 'all.mpg')\n cmd_str = \"#{$ffmpeg} -i \\\"concat:#{all_segs}\\\" -c copy #{mpg_all}\"\n p cmd_str\n system(cmd_str) unless File.exists? mpg_all\n cmd_str = \"#{$ffmpeg} -i #{mpg_all} -qscale:v 1 #{dst_video}\"\n p cmd_str\n system(cmd_str)\nend",
"def process\n\t\t\textract_relevant_parts_of_video\n\t\t\tcreate_still_images\n\t\t\tcreate_animated_image\n\t\tend",
"def prepare_video\n max_attempts = 3\n attempts_made = 0\n delay = 1.0\n\n begin # Fixes #79\n ScreenRecorder.logger.info 'Running ffprobe to prepare video (output) file.'\n FFMPEG::Movie.new(options.output)\n rescue Errno::EAGAIN, Errno::EACCES\n attempts_made += 1\n ScreenRecorder.logger.error \"Failed to run ffprobe. Retrying... (#{attempts_made}/#{max_attempts})\"\n sleep(delay)\n retry if attempts_made < max_attempts\n raise\n end\n end",
"def screenshots(num_thumbnail_imgs)\n puts \"transcoded_movie thumbnail generation\"\n\t puts \"number of thumbnails #{num_thumbnail_imgs}\"\n\t \n\t \n\t #skipping some frames from begining and ending to take screenshots\n\t init_time = 15\n seek_t = ($transcoded_movie.duration - init_time*2) / num_thumbnail_imgs.to_i\n \t \n\t \n\t i = 0\n\t \n\t while i < num_thumbnail_imgs.to_i do\n filename = \"thumbnail_#{i}.jpg\"\n \n \t #, preserve_aspect_ratio: :width\n # keeping 160x90 to preserve aspect ratio 16:9 \n\t\t \n\t\t puts \"generating #{filename}\"\n \n\t\t $transcoded_movie.screenshot(filename, seek_time: (init_time + seek_t * i), resolution: '160x90')\n\t\t i += 1\n end #end while\t \n end",
"def test03()\n movieFileName = \"movie03.mov\"\n # In this example source file and output dimensions are both 1280x720\n sourceMovie = File.join($directory, \"images/testinput-movingimages.mov\")\n utiFileType = \"com.apple.quicktime-movie\"\n\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 # Importer the movie file\n movieImporterName = SecureRandom.uuid\n movieImporter = theCommands.make_createmovieimporter(sourceMovie,\n name: movieImporterName)\n\n contextSize = MIShapes.make_size(1280, 720)\n bitmapObject = theCommands.make_createbitmapcontext(size: contextSize,\n profile: :kCGColorSpaceGenericRGB)\n\n # movieFilePath = File.join(File.expand_path(\"~/Desktop\"), movieFileName)\n movieFilePath = File.join(Dir.tmpdir(), movieFileName)\n # Create the video frames writer object\n movieWriter = theCommands.make_createvideoframeswriter(movieFilePath,\n addtocleanup: true,\n utifiletype: utiFileType,\n pathsubstitutionkey: nil)\n\n # Now add the ProRes422 input to the video writer object\n frameduration = MIMovie::MovieTime.make_movietime(timevalue: 400,\n timescale: 6000)\n addVideoInputCommand = CommandModule.make_addinputto_videowritercommand(\n movieWriter, preset: :prores422preset, framesize: contextSize,\n frameduration: frameduration)\n theCommands.add_command(addVideoInputCommand)\n\n # Prepare to loop over accessing frames and add frames to video frame writer\n # Will do nothing else other than halve the speed by doubling frame duration\n # time.\n # lets get 60 frames.\n numberOfFrames = 60\n imageID = SecureRandom.uuid\n trackID = MIMovie::MovieTrackIdentifier.make_movietrackid_from_mediatype(\n mediatype: :vide, trackindex: 0)\n currentTime = MIMovie::MovieTime.make_movietime(timevalue: 120, timescale: 30)\n \n # I've needed to use drawing to a bitmap context because my old laptop is\n # incapable of creating the necessary color correction data to go from\n # the profile of the image frame from the movie importer to the pixel buffer.\n # Drawing to bitmap slows down the processing of the movie frames. When\n # writing a script for computers with better hardware and optimizing for\n # speed you could leave out the draw image code and swap it for the commented\n # out code.\n \n numberOfFrames.times do |frameIndex|\n currentTime = MIMovie::MovieTime.make_movietime(timevalue: 60 + frameIndex,\n timescale: 30)\n # frameOptions = MIMovie::FrameOptions.new\n # frameOptions.frametime = currentTime\n # frameOptions.tracks = [trackID]\n #==================================================================\n drawImageElement = MIDrawImageElement.new\n drawImageElement.set_moviefile_imagesource(source_object: movieImporter,\n frametime: currentTime, tracks: [trackID])\n drawImageElement.destinationrectangle = MIShapes.make_rectangle(\n size: contextSize)\n drawImageCommand = CommandModule.make_drawelement(bitmapObject, \n drawinstructions: drawImageElement, createimage: true)\n theCommands.add_command(drawImageCommand)\n addImageToWriterInput = CommandModule.make_addimageto_videoinputwriter(\n movieWriter, sourceobject: bitmapObject)\n #==================================================================\n # addImageToWriterInput = CommandModule.make_addimageto_videoinputwriter(\n # movieWriter, imageoptions: frameOptions, sourceobject: movieImporter)\n theCommands.add_command(addImageToWriterInput)\n end\n \n finalize = CommandModule.make_finishwritingframescommand(movieWriter)\n theCommands.add_command(finalize)\n result = Smig.perform_commands(theCommands)\n # The above will throw if an error occured.\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 FileUtils.rm_f(movieFilePath) unless movieFilePath.nil?\n# `open #{movieFilePath}`\n end\nend",
"def outputs\n VIDEO_PRESETS.map do |variant, preset_id|\n {\n key: \"#{name}-#{variant}\",\n thumbnail_pattern: \"#{name}-#{variant}-{count}\",\n preset_id: preset_id,\n segment_duration: SEGMENT_DURATION\n }\n end\n end",
"def mux(options={})\n if File.file?(options[:output])\n File.delete(options[:output])\n end\n\n create do |mp4creator|\n mp4creator.create = options[:audio]\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.create = options[:video]\n mp4creator.rate = options[:frame_rate].to_f\n mp4creator.file = options[:output]\n end\n\n if options[:hint]\n create do |mp4creator|\n mp4creator.hint = 1\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.hint = 2\n mp4creator.file = options[:output]\n end\n\n create do |mp4creator|\n mp4creator.optimize = true\n mp4creator.file = options[:output]\n end\n end\n end",
"def video(filename, opts = {})\n n = input(filename, opts)\n @videos << n\n n\n end",
"def scan_strategy\n `ffmpeg -i #{@video_file} -f image2 -vf fps=fps=1/#{@interval} #{@shot_path}/%05d.png`\n end",
"def make_createvideoframeswriter(movieFilePath,\n addtocleanup: true,\n utifiletype: :\"com.apple.quicktime-movie\",\n name: nil,\n pathsubstitutionkey: nil)\n theName = SecureRandom.uuid if name.nil?\n theName = name unless name.nil?\n videoWriterObject = SmigIDHash.make_objectid(objectname: theName,\n objecttype: :videoframeswriter)\n createWriter = CommandModule.make_createvideoframeswriter(movieFilePath,\n utifiletype: utifiletype,\n name: theName,\n pathsubstitutionkey: pathsubstitutionkey)\n self.add_command(createWriter)\n if addtocleanup\n self.add_tocleanupcommands_closeobject(videoWriterObject)\n end\n videoWriterObject\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 split_movie(file_path)\n OSX.require_framework(\"QTKit\")\n splitted_files = Array.new\n movie, error = OSX::QTMovie.movieWithFile_error(file_path) # Load in the original movie\n if(error != nil || movie == nil) # Check if we can load the movie\n $stderr.puts \"Could not open #{file_path}, #{error.localizedDescription}\"\n exit(-1)\n end\n \n # a QTTime structure has a timeValue and timeScale we need\n # to dived the timeValue by the timeScale to get the time\n # in seconds. If we devide that by 60 we get the time in\n # minutes\n time_scale = movie.duration.timeScale\n total_time = (movie.duration.timeValue / time_scale) / 60\n \n # If the total time is below 10 minutes we don't have to\n # split the movie\n if(total_time < 10)\n splitted_files.push(file_path)\n return splitted_files\n end\n \n # If the totol time is above 10 minutes we have to calculate\n # how many parts we need to make. No part can be over 10 minutes.\n parts = total_time.to_i / 10\n \n if(total_time.modulo(10) != 0)\n parts = parts + 1\n end\n \n # Parts are always 10 minutes long (or shorter)\n part_duration = OSX::QTMakeTime(600 * time_scale, time_scale)\n temp_dir = Dir.tmpdir()\n attributes = OSX::NSDictionary.dictionaryWithObjectsAndKeys(OSX::NSNumber.numberWithBool(true), \"QTMovieFlatten\", nil)\n movies = Array.new\n \n # For every part we extract the time selection out of the original movie\n # and write it out to a new, temporary file. We store the paths to the\n # temporary files\n parts.times do |i|\n begin_time = OSX::QTMakeTime(i * 600 * time_scale, time_scale)\n range = OSX::QTMakeTimeRange(begin_time, part_duration)\n movie_part, error = movie.movieWithTimeRange_error(range)\n \n if(error != nil || movie_part == nil)\n $stderr.puts \"Could not generate subclip, #{error.localizedDescription}\"\n exit(-1)\n end\n \n # Writing out the temporary file and storing the path in the movies array\n temp_file_path = temp_dir + \"/\" + File.basename(file_path, File.extname(file_path)) + \"-\" + i.to_s + \".mov\"\n movie_part.writeToFile_withAttributes(temp_file_path, attributes)\n movies.push(temp_file_path)\n end\n return movies \n end",
"def video_gen(slide)\n term = slide['term']\n kind = slide['kind']\n index = slide['index']\n audio = slide['audio']\n image = slide['image']\n raise \"audio is required fof #{term}\" unless audio\n raise \"image is required fof #{term}\" unless image\n file_name = file_name_gen(slide, \".mpg\")\n audio = command_arg(slide['audio'])\n image = command_arg(slide['image'])\n video = command_arg(file_name)\n `ffmpeg -loop 1 -y -i #{image} -i #{audio} -acodec libmp3lame -vcodec mpeg4 -shortest -qscale:v 1 #{video}`\n slide['video'] = file_name\nend",
"def extractImages\n cmd = Poplib::Cmd.new(FFMPEG_EXT_CMD_FMT % [@movie_path, @interval.to_f/100.0, @tmpdir])\n puts \" extracting images: %s\" % cmd.cmdstr\n tcmd = \"mp4info %s\" % @movie_path\n begin\n totalf = (`#{tcmd}`.match(/([0-9]+\\.[0-9]+) sec/)[1].to_f)/10\n rescue => e\n puts e.backtrace.join \"\\n\"\n puts \"RESCUING, Carry on my son...\"\n totalf = 1.0\n end\n progthread = Thread.new{\n out = $stdout.clone\n ostr = ''\n cnt = 0\n idx = -2\n while true\n cnt = Dir.entries(@tmpdir).count - 2\n percent = ((cnt.to_f/totalf.to_f)*100).to_i\n bstr = \"\\b\" * ostr.length\n out.print bstr\n perstr = '=' * 50\n (percent == 0) ? x = 0 : x = percent/2\n perstr.insert x, (\"<[%s%%]>\" % percent.to_s)\n if cnt > 0 and idx > 0\n r = cnt.to_f/idx.to_f\n x = ((totalf.to_f/r) - idx.to_f).to_i\n else\n x = 0\n r = 0.0\n end\n ostr = \"%s of %s: [%s] ~%s (%.2f imgs/sec)\" % [cnt, totalf, perstr, Time.at(x).gmtime.strftime('%R:%S'), r] \n out.print ostr\n sleep 1\n idx += 1\n end\n }\n sleep 3\n cmd.runBig\n progthread.kill\n puts \"\\n extraction complete.\"\n end",
"def process_video\n ffmpeg_command = self.video_format.conversion_command.gsub(\"%%FFMPEG%%\", Video.find(self.video_id).ffmpeg_binary).gsub(\"%%INPUTFILE%%\", \"$input_file$\")\n ffmpeg_command = ffmpeg_command.gsub(\"%%OUTPUTFILE%%\", \"$output_file$\" )\n # Regexp that grabs the current encoding size\n ffmpeg_command =~ /-s[ ](([0-9][0-9]?[0-9]?[0-9]?[0-9]?)x([0-9][0-9]?[0-9]?[0-9]?[0-9]?))/\n encoding_dimensions = $1\n encoding_width = $2.to_i\n encoding_height = $3.to_i\n # Get aspect ratios\n encoding_aspect_ratio = (encoding_width.to_f / encoding_height.to_f)\n flipped_ratio = (self.video.height.to_f / self.video.width.to_f)\n pad_details = \"\"\n # Calculate if padding must be applied on top/bottom or left/right\n if self.video.aspect_ratio >= encoding_aspect_ratio\n new_height = (encoding_width / self.video.aspect_ratio).round\n # Now check that height is divisible by 8 to prevent encode artifacts.\n height_remainder = (new_height % 8)\n new_height = new_height - height_remainder\n new_width = encoding_width - (height_remainder * self.video.aspect_ratio).round\n new_width = ((new_width % 2) == 0) ? new_width : (new_width - 1)\n pad_left = ((encoding_width - new_width) / 2).round\n pad_right = encoding_width - new_width - pad_left\n pad_top = ((encoding_height - new_height) / 2).round\n pad_bottom = encoding_height - new_height - pad_top\n #pad_details = \"-padleft #{pad_left} -padright #{pad_right} -padtop #{pad_top} -padbottom #{pad_bottom}\"\n pad_details = \"-vf pad=#{encoding_width}:#{encoding_height}:#{pad_left}:#{pad_top}\" \n correct_dimensions = \"#{encoding_width - (pad_left + pad_right)}x#{encoding_height - (pad_top + pad_bottom)}\"\n else\n new_width = (encoding_height / flipped_ratio).round\n # Make sure frame size is divisible by 2, or ffmpeg chokes.\n new_width = ((new_width % 2) == 0) ? new_width : (new_width - 1)\n pad_left = ((encoding_width - new_width) / 2).round\n pad_right = encoding_width - new_width - pad_left\n #pad_details = \"-padleft #{pad_left} -padright #{pad_right}\"\n pad_details = \"-vf pad=#{encoding_width}:#{encoding_height}:#{pad_left}:0\" \n correct_dimensions = \"#{encoding_width - (pad_left + pad_right)}x#{encoding_height}\"\n end\n ffmpeg_command = ffmpeg_command.gsub(\"$output_file$\", \"#{pad_details} $output_file$\")\n ffmpeg_command = ffmpeg_command.gsub(encoding_dimensions, correct_dimensions)\n transcoder = RVideo::Transcoder.new\n recipe = ffmpeg_command\n outputfile = Pathname.new(RAILS_ROOT + \"/public/system/tmp/\" + self.video.file.basename + \"-\" + self.video_format.title.gsub(\" \", \"\") + \".\" + self.video_format.output_file_extension)\n processing_valid = true\n begin\n puts \"Encoding #{self.video.title == \"\" ? self.video.title : self.video.file_file_name} in #{self.video_format.title} Format\\n\"\n transcoder.execute(recipe, {\n :input_file => self.video.file.path,\n :output_file => outputfile.to_s\n })\n rescue RVideo::TranscoderError => e\n processing_valid = false\n puts \"Transcode has failed: #{e.class} - #{e}\\n\"\n self.video.errors.add_to_base \"<strong>#{self.video_format.title}</strong><br />Transcode has failed: #{e.class} - #{e}\"\n end\n if processing_valid\n # Make sure that qt-faststart is run on the file.\n qtoutputfile = Pathname.new(RAILS_ROOT + \"/public/system/tmp/\" + self.video.file.basename + \"-\" + self.video_format.title.gsub(\" \", \"\") + \"-qt.\" + self.video_format.output_file_extension)\n if (system \"`which qt-faststart` #{outputfile.to_s} #{qtoutputfile.to_s}\")\n # Set qt-faststart encoded video into paperclip file\n File.open(qtoutputfile, 'r') do |f|\n self.file = f\n end\n else\n # Set encoded video into paperclip file\n File.open(outputfile, 'r') do |f|\n self.file = f\n end\n end\n self.save!\n puts \"Transcode successful\\n\"\n end\n outputfile.unlink rescue nil\n qtoutputfile.unlink rescue nil\n end",
"def run\n @files.each do |file|\n generate_tracklist(file)\n end\n end",
"def ffmpeg_libvpx_cmd(input_path, output_path, bitrate, output_size, force=false)\n replace = force ? \"-y\" : \"\"\n return [\n \"ffmpeg -i '#{input_path}' -threads 8\",\n \"-c:v libvpx -pix_fmt yuv420p -crf 10 -b:v #{bitrate} -s #{output_size} -movflags +faststart -r 29.97 -c:a libvorbis -aq 5 #{replace} '#{output_path}'\"\n ]\nend",
"def process_previews!\n source = Magick::ImageList.new(preview_path).first\n\n previews.each do |name, blk|\n path = File.join(@dir, \"#{name}_preview.jpg\")\n\n copy = source.copy\n blk.call(copy)\n copy.write(path)\n\n @paths << path\n end\n\n @paths\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Runs the command defined in the config file input_filename: The full path of the file you want to run the command on file_operation: One of the defined file operations in the config file | def run_command(input_filename, file_operation)
Log.info "Inside run_command"
if !Config['FileOperations'].key?(file_operation)
return "#{file_operation} isn't a valid preset"
end
transcode_settings = Config['FileOperations'][file_operation]
Log.info transcode_settings.to_s
begin
if !transcode_settings.key?('command')
return "#{file_operation} doesn't have a command"
end
command_template = transcode_settings['command']
filename = File.basename(input_filename)
base_filename = File.basename(input_filename, File.extname(input_filename))
if transcode_settings.key?('location')
output_filename = [transcode_settings['location'], base_filename].join('/')
else
output_filename = [Config['WebServer']['webroot'], Config['WebServer']['transcode_dir'], base_filename].join('/')
end
command = command_template % {input_filename:input_filename, output_filename: output_filename}
Log.info command
# Update the channel to let them know what's happening
call_mattermost({:text => "Running command #{file_operation} on file #{filename}"})
if system(command)
if transcode_settings.key?('text')
output_text = transcode_settings['text'] % {input_filename:input_filename, output_filename: output_filename}
else
output_text = "Finished running command #{file_operation} on file #{filename}"
end
call_mattermost({:text => output_text})
else
call_mattermost({:text => "ERROR: Could not run command #{file_operation} on file #{filename}"})
end
rescue Exception => e
Log.error e.to_s
return 'There was an error'
end
end | [
"def execute!\n from_file(filename)\n end",
"def execute_file(file_name)\r\n puts \"Loading file #{file_name}...\"\r\n execute(Parser.new(StringSource.new(IO.readlines(file_name))))\r\n end",
"def execute_each_fileline \n output = parse_input_command\n create_output_file output\n print_output output\n end",
"def run(operation, versioned_file)\n versioned_file.modify do |version, directory, original|\n operation.run version, directory, original\n end\n end",
"def run(filename, options) end",
"def execute_file_ops!(file_ops)\n file_ops.each do |op|\n case op[:op]\n when :delete\n FileUtils.rm_r op[:path] if File.exist? op[:path]\n when :copy\n target_dir = File.dirname op[:to]\n FileUtils.mkdir_p target_dir unless File.exist? target_dir\n if File.exist? op[:from]\n FileUtils.cp_r op[:from], op[:to]\n else\n print \"Source does not have file #{op[:from]}\\n\"\n end\n end\n end\n end",
"def define_operation(file_operation, options = {})\n operation = FilePipeline.load file_operation\n self << operation.new(**options)\n self\n end",
"def file(filename, options = {})\n return unless @shell.applicable?(options)\n @command << ' ' << @shell.escape_filename(filename)\n @last_arg = :file\n end",
"def execute_file(path)\n execute_text File.read(path)\n end",
"def run_file(filename, preloading = false)\n begin\n result = RSpec::Core::CommandLine.new([\"-f\", \"p\", filename]).run(io, io)\n rescue LoadError => e\n io << \"\\nCould not load file #{filename}: #{e.message}\\n\\n\"\n result = 1\n rescue Exception => e\n io << \"Exception when running #{filename}: #{e.message}\"\n io << e.backtrace[0..7].join(\"\\n\")\n result = 1\n end\n\n if preloading\n puts io.string\n else\n channel.write(\"command\" => \"result\", \"filename\" => filename, \"return_code\" => result.to_i, \"text\" => io.string, \"worker_number\" => worker_number)\n end\n end",
"def process_command_file\n gather_command\n create_command_structure\n end",
"def run_from_file(filename)\n file = File.new(filename, 'r')\n content = file.read\n file.close\n run(content)\n end",
"def set_run_input_file(run, input, filename)\n # get the run from the uuid if that is what is passed in\n if not run.instance_of? Run\n run = run(run)\n end\n\n path = \"#{@links[:runs]}/#{run.uuid}/#{run.inputs}/input/#{input}\"\n set_attribute(path, Fragments::RUNINPUTFILE % filename, \"application/xml\")\n rescue AttributeNotFoundError => e\n if get_runs.has_key? run.uuid\n raise e\n else\n raise RunNotFoundError.new(run.uuid)\n end\n end",
"def convert_file input_file_path:, input_options:, output_file_path:, output_options:, fx: {}\n converter = Sox::Cmd.new\n converter.add_input input_file_path, input_options\n converter.set_output output_file_path, output_options\n converter.set_effects fx\n converter.run\n end",
"def handle_input_file_or_command(str, options)\n if options.input.nil?\n # No input source was specified yet, so this is the input file.\n confirm_input_file_viability(str)\n options.input = File.open(str,\"r\")\n\n else\n # We already have an input source, so this must be a command.\n # Store it in an array, so that arguments to this command can be extracted\n # from ARGV and added into here later\n raise Error.new(\"Multiple commands were specified\") unless options.command.nil?\n options.command = [str]\n end\nend",
"def sqlite_run_file_via_cli(filename, dbfilepath)\n prt \"==== Opening Command Line ====\\n\" if $options[:verbose]\n cmd = \"#{$options[:sqlite_bin]} \\\"#{dbfilepath}\\\" < #{filename}\"\n prt \"Executing: #{cmd}\"\n system(cmd)\n prt \"\\n\\n\"\n end",
"def test_run_file_input\n workflow = File.open($wkf_pass, \"r\")\n\n T2Server::Run.create($uri, $wkf_pass, $creds, $conn_params) do |run|\n\n assert_nothing_raised(T2Server::AttributeNotFoundError) do\n run.input_port(\"IN\").file = $file_input\n end\n\n run.start\n assert(run.running?)\n assert_nothing_raised(T2Server::RunStateError) { run.wait }\n assert_equal(run.output_port(\"OUT\").value, \"Hello, World!\")\n end\n\n workflow.close\n end",
"def execute()\n if !File.exist?(@filename)\n print \"#{Term::ANSIColor.red}source file not found: #{@filename}#{Term::ANSIColor.reset}\\n\" # if Morpheus::Logging.debug?\n else\n Morpheus::Logging::DarkPrinter.puts \"executing source file #{@filename}\" if Morpheus::Logging.debug?\n end\n file_contents = File.read(@filename)\n lines = file_contents.split(\"\\n\")\n cmd_results = []\n line_num = 0\n lines.each_with_index do |line, line_index|\n line_num = line_index + 1\n line = line.strip\n next if line.empty?\n next if line =~ /^\\#/ # skip comments\n \n cmd_exit_code = 0\n cmd_err = nil\n cmd_result = nil\n begin\n cmd_result = Morpheus::Cli::CliRegistry.exec_expression(line)\n rescue SystemExit => err\n if err.success?\n cmd_result = true\n else\n puts \"#{red} source file: #{@filename}, line: #{line_num}, command: #{line}, error: #{err}#{reset}\"\n cmd_result = false\n end\n rescue => err\n # raise err\n puts \"#{red} source file: #{@filename}, line: #{line_num}, command: #{line}, error: #{err}#{reset}\"\n cmd_result = false\n end\n cmd_results << cmd_result\n end\n return cmd_results\n end",
"def execute\n run_command current_or_selected_files\nend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The position of the data dictionary header within the page. | def pos_data_dictionary_header
pos_page_body
end | [
"def pos_header\n @position - 2\n end",
"def pos_header\n @position - 2\n end",
"def header_position\n C.archive_read_header_position archive\n end",
"def pe_header_offset\n deref(e_lfanew_offset)\n end",
"def data_chunk_start_pos\n read_page_header_and_data_chunk_start unless defined? @data_chunk_start\n\n @data_chunk_start\n end",
"def relative_header_offset; end",
"def section_headers_offset\n self[:e_shoff]\n end",
"def program_headers_offset\n self[:e_phoff]\n end",
"def offset\n fil_header[:offset]\n end",
"def local_header_offset; end",
"def go_to_page_header_start_pos\n input_io.seek(page_header_start_pos, IO::SEEK_SET)\n end",
"def offset_for(the_page)\n offset = @initial_offset\n each do |page|\n if page.header == the_page.header\n return offset\n else\n offset += page.length\n end\n end\n\n return nil\n end",
"def header_start( item_no )\n header_size + item_no * ITEM_HEADER_SIZE\n end",
"def relative_header_offset=(_arg0); end",
"def pos_fseg_header\n pos_index_header + size_index_header\n end",
"def header\n _, @count, @stringOffset = @bytes[0, 6].unpack('nnn')\n end",
"def read_page_header_and_data_chunk_start\n go_to_page_header_start_pos \n page_header = ::PageHeader.new\n page_header.read(proto)\n\n @page_header ||= page_header\n @data_chunk_start = input_io.pos\n end",
"def position\n _response_word.fetch(\"position\", nil)\n end",
"def local_header_offset=(_arg0); end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The size of the data dictionary header. | def size_data_dictionary_header
((8 * 3) + (4 * 7) + 4 + Innodb::FsegEntry::SIZE)
end | [
"def size_data_dictionary_header\n ((8 * 3) + (4 * 7) + 4 + Innodb::FsegEntry::SIZE)\n end",
"def header_size\n TYPE_SIZE\n end",
"def header_length\n @header_length ||= @data[20, 4].unpack('N*')[0]\n end",
"def byte_size(); @data.byte_size + 4; end",
"def size_fil_header\n 4 + 4 + 4 + 4 + 8 + 2 + 8 + 4\n end",
"def size_fil_header\n 4 + 4 + 4 + 4 + 8 + 2 + 8 + 4\n end",
"def data_size\n @iplimage_struct.image_size\n end",
"def header_length\n @header_length ||= DBF_HEADER_SIZE + columns.size * 32 + 1\n end",
"def size\n if @object_data.key?('size')\n return @object_data['size']\n else\n return get.size\n end\n end",
"def table_size_bytes\n data[:table_size_bytes]\n end",
"def archive_size_in_bytes\n data[:archive_size_in_bytes]\n end",
"def archive_size_in_bytes\n data.archive_size_in_bytes\n end",
"def show_elf_h_size\n\t\t\tputs \" Size of this header: #{@elf_h_size} (bytes)\"\n\t\tend",
"def size_record_header\n case page_header[:format]\n when :compact\n RECORD_NEXT_SIZE + RECORD_COMPACT_BITS_SIZE\n when :redundant\n RECORD_NEXT_SIZE + RECORD_REDUNDANT_BITS_SIZE\n end\n end",
"def msg_size; @msg_size ||= PackedHeader.new(4, 'N'); end",
"def size\n CF.CFDataGetLength(self)\n end",
"def dataSize\n @Length - 4\n end",
"def size\n %w(name data client_id extras).map do |attr|\n if (value = attributes[attr.to_sym]).is_a?(String)\n value.bytesize\n elsif value.nil?\n 0\n else\n value.to_json.bytesize\n end\n end.sum\n end",
"def data_len_bytes()\n 2\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /krishes GET /krishes.json | def index
@krishes = Krish.all
end | [
"def index\n @kushis = Kushi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kushis }\n end\n end",
"def show\n @kushi = Kushi.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kushi }\n end\n end",
"def index\n @sheds = Shed.all\n\n render json: @sheds\n end",
"def show\n @konyu_rireki = KonyuRireki.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @konyu_rireki }\n end\n end",
"def show\n @heli_kit = HeliKit.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heli_kit }\n end\n end",
"def index\n @kids = Kid.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kids }\n end\n end",
"def index\n @khs = Kh.all\n end",
"def show\n render json: @shed\n end",
"def index\n @karyalay_samagris = KaryalaySamagri.all\n render json: @karyalay_samagris\n end",
"def index\n @sharks = Shark.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sharks }\n end\n end",
"def show\n @rink = Rink.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rink }\n end\n end",
"def index\n @lyks = Lyk.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lyks }\n end\n end",
"def index\n @kraje = Kraj.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kraje }\n end\n end",
"def show\n @kern = Kern.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kern }\n end\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render :json => @skull }\n end\n end",
"def index\n @geeks = Geek.all\n render json: @geeks\n end",
"def show\n @hitchhiker = Hitchhiker.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hitchhiker }\n end\n end",
"def show\n @kf_sickness = Kf::Sickness.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_sickness }\n end\n end",
"def show\n @koti = Koti.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @koti }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /krishes POST /krishes.json | def create
@krish = Krish.new(krish_params)
respond_to do |format|
if @krish.save
format.html { redirect_to @krish, notice: 'Krish was successfully created.' }
format.json { render action: 'show', status: :created, location: @krish }
else
format.html { render action: 'new' }
format.json { render json: @krish.errors, status: :unprocessable_entity }
end
end
end | [
"def create\n @shed = Shed.new(shed_params)\n\n if @shed.save\n render json: @shed, status: :created, location: @shed\n else\n render json: @shed.errors, status: :unprocessable_entity\n end\n end",
"def create\n @knjige = Knjige.new(knjige_params)\n\n respond_to do |format|\n if @knjige.save\n format.html { redirect_to @knjige, notice: 'Knjige was successfully created.' }\n format.json { render :show, status: :created, location: @knjige }\n else\n format.html { render :new }\n format.json { render json: @knjige.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kim = Kim.new(kim_params)\n\n respond_to do |format|\n if @kim.save\n format.html { redirect_to @kim, notice: 'Kim was successfully created.' }\n format.json { render :show, status: :created, location: @kim }\n else\n format.html { render :new }\n format.json { render json: @kim.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kraj = Kraj.new(params[:kraj])\n\n respond_to do |format|\n if @kraj.save\n format.html { redirect_to @kraj, notice: 'Kraj was successfully created.' }\n format.json { render json: @kraj, status: :created, location: @kraj }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kraj.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @krishes = Krish.all\n end",
"def create\n @rakiety = Rakiety.new(rakiety_params)\n\n respond_to do |format|\n if @rakiety.save\n format.html { redirect_to @rakiety, notice: 'Rakiety was successfully created.' }\n format.json { render :show, status: :created, location: @rakiety }\n else\n format.html { render :new }\n format.json { render json: @rakiety.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @heli_kit = HeliKit.new(params[:heli_kit])\n\n respond_to do |format|\n if @heli_kit.save\n format.html { redirect_to @heli_kit, notice: 'Heli kit was successfully created.' }\n format.json { render json: @heli_kit, status: :created, location: @heli_kit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @heli_kit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @jikken = Jikken.new(jikken_params)\n\n respond_to do |format|\n if @jikken.save\n format.html { redirect_to @jikken, notice: 'Jikken was successfully created.' }\n format.json { render :show, status: :created, location: @jikken }\n else\n format.html { render :new }\n format.json { render json: @jikken.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shikaku = Shikaku.new(shikaku_params)\n\n respond_to do |format|\n if @shikaku.save\n format.html { redirect_to @shikaku, notice: 'Shikaku was successfully created.' }\n format.json { render :show, status: :created, location: @shikaku }\n else\n format.html { render :new }\n format.json { render json: @shikaku.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @hk = Hk.new(hk_params)\n\n respond_to do |format|\n if @hk.save\n format.html { redirect_to @hk, notice: 'Hk was successfully created.' }\n format.json { render action: 'show', status: :created, location: @hk }\n else\n format.html { render action: 'new' }\n format.json { render json: @hk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kick = Kick.new(kick_params)\n\n\n if @kick.save\n render json: @kick\n else\n render json: @kick.errors\n end\n end",
"def create\n @rink = Rink.new(rink_params)\n\n respond_to do |format|\n if @rink.save\n format.html { redirect_to @rink, notice: 'Rink was successfully created.' }\n format.json { render :show, status: :created, location: @rink }\n else\n format.html { render :new }\n format.json { render json: @rink.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @rink = Rink.new(params[:rink])\n\n respond_to do |format|\n if @rink.save\n format.html { redirect_to @rink, notice: 'Rink was successfully created.' }\n format.json { render json: @rink, status: :created, location: @rink }\n else\n format.html { render action: \"new\" }\n format.json { render json: @rink.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @keihi = Keihi.new(keihi_params)\n\n respond_to do |format|\n if @keihi.save\n format.html { redirect_to @keihi, notice: 'Keihi was successfully created.' }\n format.json { render :show, status: :created, location: @keihi }\n else\n format.html { render :new }\n format.json { render json: @keihi.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @kh = Kh.new(kh_params)\n\n respond_to do |format|\n if @kh.save\n format.html { redirect_to @kh, notice: 'Kh was successfully created.' }\n format.json { render :show, status: :created, location: @kh }\n else\n format.html { render :new }\n format.json { render json: @kh.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @scratcher = Scratcher.new(permitted_params)\n\n if @scratcher.save\n render json: @scratcher, status: :created, location: @scratcher\n else\n render json: @scratcher.errors, status: :unprocessable_entity\n end\n end",
"def create\n @kingdom = Kingdom.new(kingdom_params)\n\n respond_to do |format|\n if @kingdom.save\n format.html { redirect_to @kingdom, notice: 'Kingdom was successfully created.' }\n format.json { render :show, status: :created, location: @kingdom }\n else\n format.html { render :new }\n format.json { render json: @kingdom.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n puts 'Received POST request (create)'\n @whiskey = Whiskey.new(whiskey_params)\n\n if @whiskey.save\n render json: @whiskey\n else\n render json: @whiskey.errors\n end\n end",
"def create\n @hiker = Hiker.new(hiker_params)\n\n respond_to do |format|\n if @hiker.save\n format.html { redirect_to @hiker, notice: 'Hiker was successfully created.' }\n format.json { render :show, status: :created, location: @hiker }\n else\n format.html { render :new }\n format.json { render json: @hiker.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /krishes/1 DELETE /krishes/1.json | def destroy
@krish.destroy
respond_to do |format|
format.html { redirect_to krishes_url }
format.json { head :no_content }
end
end | [
"def destroy\n @json.destroy\n\n head :no_content\n end",
"def destroy\n @kushi = Kushi.find(params[:id])\n @kushi.destroy\n\n respond_to do |format|\n format.html { redirect_to kushis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @koszyk = Koszyk.find(params[:id])\n @koszyk.destroy\n\n respond_to do |format|\n format.html { redirect_to koszyks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hoik = Hoik.find(params[:id])\n @hoik.destroy\n\n respond_to do |format|\n format.html { redirect_to hoiks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kid.destroy\n respond_to do |format|\n format.html { redirect_to kids_url }\n format.json { head :no_content }\n end\n end",
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @koti = Koti.find(params[:id])\n @koti.destroy\n\n respond_to do |format|\n format.html { redirect_to kotis_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hk.destroy\n respond_to do |format|\n format.html { redirect_to hks_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def delete\n Client.delete(\"/kits/#{@id}\")\n end",
"def destroy\n @kraj = Kraj.find(params[:id])\n @kraj.destroy\n\n respond_to do |format|\n format.html { redirect_to kraje_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @knol.destroy\n respond_to do |format|\n format.html { redirect_to knols_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kaiten.destroy\n respond_to do |format|\n format.html { redirect_to kaitens_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @squawk = Squawk.find(params[:id])\n @squawk.destroy\n\n respond_to do |format|\n format.html { redirect_to squawks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kid = Kid.find(params[:id])\n @kid.destroy\n\n respond_to do |format|\n format.html { redirect_to kids_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @surkle.destroy\n respond_to do |format|\n format.html { redirect_to surkles_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kumo.destroy\n respond_to do |format|\n format.html { redirect_to kumos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rink = Rink.find(params[:id])\n @rink.destroy\n\n respond_to do |format|\n format.html { redirect_to rinks_url }\n format.json { head :no_content }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Toggle guest access on or off | def toggle_guest_access
raise NotImplementedError
end | [
"def toggle_guest_access\n # re-join the room to get the guest url\n verify_response(post(\"room/#{id}/toggle_guest_access\"), :success) && join(true)\n end",
"def toggle_admin\n if @user.is_admin?\n @user.revoke_admin\n else\n @user.grant_admin(current_user, session[:pwd])\n end\n redirect_to edit_user_path(@user)\n end",
"def not_guest!\n self.guest = false\n end",
"def guest_access\n get_state('m.room.guest_access')[:guest_access]&.to_sym\n end",
"def guest_access?\n guest_access == :can_join\n end",
"def gueststandby\n assert_privileges(params[:pressed])\n vm_button_operation('standby_guest', 'standby')\n end",
"def guest?\n false\n end",
"def gueststandby\n assert_privileges(params[:pressed])\n generic_button_operation('standby_guest', _('Standby Guest'), vm_button_action)\n end",
"def toggleAdminMode\n self.inAdminMode = !inAdminMode if isAdmin\n self.save\n end",
"def guest_access=(guest_access)\n client.api.set_room_guest_access(id, guest_access)\n tinycache_adapter.write(:guest_access, guest_access)\n guest_access\n end",
"def guest_access=(guest_access)\n room_state['m.room.guest_access'] = { guest_access: guest_access }\n guest_access\n end",
"def allow_guests=(allow_guests)\n self.guest_access = (allow_guests ? :can_join : :forbidden)\n allow_guests\n end",
"def toggle_auth(status, source_text)\n status_string = status == :enable ? 'true' : 'false'\n %w(dbms.security.authorization_enabled dbms.security.auth_enabled).each do |key|\n source_text = set_property(source_text, key, status_string)\n end\n source_text\n end",
"def is_guest?\n return true if user.guest == true\n end",
"def toggle_superadmin_mode_link(navigator)\n return unless current_ubiquo_user.is_superadmin?\n if superadmin_mode?\n navigator.add_link(:method => :delete) do |link|\n link.text = t(\"ubiquo.auth.back_from_superadmin_mode\")\n link.url = ubiquo.superadmin_mode_path\n end\n else\n navigator.add_link(:method => :post) do |link|\n link.text = t(\"ubiquo.auth.go_to_superadmin_mode\")\n link.url = ubiquo.superadmin_mode_path\n end\n end\n end",
"def toggle\n @user.toggle\n redirect_to :back\n end",
"def guests_disabled?\n !AppConfig.check(:enable_guests)\n end",
"def enable_guest_checkout\n self.guest = true\n self.save\n end",
"def toggle_admin\n member = @church.user_relationships.where(user_id: params[:user_id]).take\n flag = params[:flag].to_bool\n if member.update(is_admin: flag)\n render_success_message 'Admin role successfully updated', (flag ? \"<span class='label label-default display-block'>Administrator</span>\" : '')\n else\n render_error_model member\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Get the url for guest access | def guest_url
if guest_access_enabled?
"http://#{@campfire.subdomain}.campfirenow.com/#{guest_invite_code}"
else
nil
end
end | [
"def guest_url\n \"#{@connection.uri}/#{guest_invite_code}\" if guest_access_enabled?\n end",
"def guest_url\n join\n link = (Hpricot(@room.body)/\"#guest_access h4\").first\n link.inner_html if link\n end",
"def guest_link\n return guest_hearing_link if guest_hearing_link.present?\n\n \"#{VirtualHearing.base_url}?join=1&media=&escalate=1&\" \\\n \"conference=#{formatted_alias_or_alias_with_host}&\" \\\n \"pin=#{guest_pin}&role=guest\"\n end",
"def guest_invite_code\n join\n guest_url.scan(/\\/(\\w*)$/).to_s\n end",
"def redirect_guest\n redirect_to explore_comparisons_path if @context.guest?\n end",
"def list_guests_for_guest_access_portal(args = {}) \n get(\"/guestaccess.json/#{args[:portalId]}/guest\", args)\nend",
"def get_guest_access_portal(args = {}) \n get(\"/guestaccess.json/gap/#{args[:portalId]}\", args)\nend",
"def get_a_guest(args = {}) \n get(\"/guestaccess.json/#{args[:guestId]}\", args)\nend",
"def admin_link\n equipment_reservation_url(self, :host => CONSTANTS[:base_url_host])\n end",
"def seller_url\r\n ['http:', user.user_url].join('//') rescue nil\r\n end",
"def url\r\n if is_community?\r\n \"http://community.livejournal.com/\"\r\n else\r\n \"http://#{login}.livejournal.com/\"\r\n end\r\n end",
"def url\n if remote_url.present?\n remote_url\n else\n \"/users/#{username}\"\n end\n end",
"def guest_access\n client.api.get_room_guest_access(id)[:guest_access].to_sym\n end",
"def invite_redirect_url\n return @invite_redirect_url\n end",
"def identity_url(hsh)\n if APP_CONFIG[:restricted_names].include?(hsh[:username].split('.').last)\n hsh[:username]\n else\n \"#{hsh[:username]}.#{AppConfig.host(request.host)}\"\n end\n end",
"def toggle_guest_access\n # re-join the room to get the guest url\n verify_response(post(\"room/#{id}/toggle_guest_access\"), :success) && join(true)\n end",
"def url\n '/users/show/' + login\n end",
"def _profile_url\n \"http://\" + [env[\"HTTP_HOST\"], env[\"SCRIPT_NAME\"], @profile.nickname].join('/').squeeze('/')\n end",
"def require_guest\n redirect_to(:dashboard) if current_user\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The invite code use for guest | def guest_invite_code
load
@active_token_value
end | [
"def guest_invite_code\n join\n guest_url.scan(/\\/(\\w*)$/).to_s\n end",
"def generate_invite_code\n self.invite_code = SecureRandom.hex(3)\n end",
"def generate_invite_code\n self.invite_code = generate_token\n end",
"def use_invitation_code(icode)\n self.email = icode.invitation.email if icode and icode.invitation.guest?\n end",
"def random_invite_code\n self.invite_code = rand(36**16).to_s(36)\n end",
"def invite\n \n end",
"def get_invitation_code\n session[:invitation_code] || params[:code]\n end",
"def guest_url\n \"#{@connection.uri}/#{guest_invite_code}\" if guest_access_enabled?\n end",
"def invite_code\n\t\tres = {}\n\t\tuser = User.find_by_token(params[:token])\n\t\tif user\n\t\t\tres[:status] = \"0\"\n\t\t\tres[:invite_code] = user.invite_code\n\t\telse\n\t\t\tres[:status] = \"1\"\n\t\tend\n\t\trender json: res\n\tend",
"def encrypted_invitation_token; end",
"def invite ( usr, chn )\n send \"INVITE #{usr} #{chn}\"\n end",
"def raw_invitation_token; end",
"def with_invite=(boolean)\n if boolean\n self[:invite_code] = SecureRandom.hex(6)\n end\n end",
"def invite_again\n @guest = Guest.new\n @sent_already = true\n if logged_in?\n unless params[:id].nil?\n @guest = User.find(params[:id])\n end\n @message = \"Here's your invitation to visit Foodmoves. \" +\n \"Please let me know that you got this message.\"\n end\n render :action => 'new', :layout => 'yui_t7_custom'\n end",
"def invitation_code_check\r\n return unless invitation_code = get_invitation_code\r\n \r\n if invitation_code.blank? or !(code = Code.find_by_unique_hash(invitation_code))\r\n flash[:error] = 'Invitation code is not found!'\r\n redirect_to(root_url) and return\r\n end\r\n \r\n resource = code.invitation.resource\r\n \r\n if code.invitation.user\t \r\n\t self.current_user = code.invitation.user\r\n end\r\n\r\n if logged_in?\t \r\n # make current_user a member of @debate\r\n code.invitation.connect!(current_user)\r\n session[:invitation_code] = nil # unset\r\n flash[:notice] = \"You successfully join the #{resource.class.to_s.downcase}\"\r\n redirect_to resource\r\n else\r\n\t puts \"no\"\r\n session[:invitation_code] = invitation_code\r\n store_location\r\n #redirect_to signup_url\r\n end\r\n end",
"def make_activation_code\n self.crypted_email = Digest::SHA1.hexdigest(self.email) if self.facebook_id.nil?\n self.status = self.status.nil? ? false : self.status\n if self.status\n self.activation_code = nil\n self.activated_at = Time.now\n else\n self.activation_code = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )\n self.activated_at = nil\n end\n self.role_id = self.role_id.nil? ? 2 : self.role_id\n end",
"def guest_url\n if guest_access_enabled?\n \"http://#{@campfire.subdomain}.campfirenow.com/#{guest_invite_code}\"\n else\n nil\n end\n end",
"def generate_invitation_key\n self.invitation_key ||= 'I'.freeze + SecureRandom.base64(8)\n end",
"def encrypt_code(e=nil)\n\t\tUser.encrypt((e || self.email), self.activation_code)\n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Change the name of the room | def name=(name)
connection.post("/room/#{@id}.json", :body => { :room => { :name => name } })
end | [
"def room_name=(value)\n @room_name = value\n end",
"def set_name(new_name)\n @name = new_name\n @@all_rooms[@id] = self\n end",
"def set_room_name(room_id, name, **params)\n content = {\n name: name\n }\n send_state_event(room_id, 'm.room.name', content, **params)\n end",
"def name\n if @name == @id\n return \"Room \\##{@id}\"\n else\n return @name\n end\n end",
"def reload_name!\n room_state.expire('m.room.name')\n end",
"def getNameOfRoom\n return @name\n end",
"def room_name\n if params[:new_room].blank? == false\n params[:new_room]\n elsif params[:room]\n params[:room]\n else\n \"\"\n end\n end",
"def room_name\n room.name\n end",
"def change_name(new_name)\n\t\t@name = new_name\n\tend",
"def room_name\n return @room_name\n end",
"def room_name\n if room_id && !room_id.empty?\n ChatService.room_name(room_id)\n end\n end",
"def set_name\n self.update(name: \"Small Washer ##{self.id}\" ) unless self.name\n end",
"def set_name\n self.update(name: \"Medium Washer ##{self.id}\") unless self.name\n end",
"def set_name\n self.update(name: \"Xtra-Large Washer ##{self.id}\") unless self.name\n end",
"def set_name\n self.update(name: \"Large Washer ##{self.id}\") unless self.name\n end",
"def get_room_name\n\t\treturn object.room_name\n\tend",
"def set_player_name(msg, name=nil)\n player = get_player msg\n unless name\n msg.reply player.name\n return\n end\n if player.name\n msg.reply \"The majestic #{player.name} refuses to change his name!\"\n return\n end\n player.name = name\n player.save\n msg.reply \"Welcome, #{player.name}!\"\n end",
"def set_name(player_name)\n @player_name = player_name\n end",
"def name\n client.api.get_room_name(id)[:name]\n rescue MatrixNotFoundError\n # No room name has been specified\n nil\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /tuberculoses GET /tuberculoses.json | def index
@tuberculoses = Tuberculose.all
end | [
"def index\n @tenures = Tenure.all\n render json: @tenures\n end",
"def index\n @otakus = Otaku.all\n\n render json: @otakus\n end",
"def index\n @user_tickets = list_tickets\n #render json: {tic: @user_tickets}\n end",
"def index\n @tipees = Tipee.all\n json_response(@tipees)\n end",
"def index\n @tacks = Tack.all\n\n render json: @tacks\n end",
"def list\n http.get(\"/takers\") do |response|\n respond_with_collection(response)\n end\n end",
"def index\n @tees = Tee.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tees }\n end\n end",
"def index\n @tcuota = Tcuotum.all\n end",
"def retrieve_tubes\n show do\n title \"Retrieve tubes and spin down\"\n \n timer initial: { hours: 0, minutes: 15, seconds: 0}\n \n check \"After timer finishes, retrieve all #{operations.length} tubes from 42 C heat block.\"\n check \"Spin the tube down for 20 seconds on a small tabletop centrifuge.\"\n check \"Remove all the supernatant carefully with a 1000 µl pipettor (~400 L total)\"\n end\n end",
"def index\n @universes = Universe.all.page(params[:page]).per(25)\n respond_to do |format|\n format.html\n format.json { render json: @universes }\n end\n end",
"def index\n @tees = Tee.all\n respond_with @tees\n end",
"def index\n @timetable_u = TimetableUnit.where timetable_id:params['timetable_id']\n\n respond_to do |format|\n format.html\n format.json { render :json => @timetable_u }\n end\n end",
"def index\n @tenures = Tenure.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @tenures\n end",
"def index\n @tutorados = Tutorado.all\n\n render json: @tutorados, status: :ok\n end",
"def index\n @tattooers = Tattooer.all\n end",
"def index\n @tuiters = Tuiter.all\n end",
"def index\n # @tossups = Tossup.all\n end",
"def index\n @terrins = Terrin.all\n end",
"def index\n @timers = Timer.all\n\n render json: @timers\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /pharmas GET /pharmas.json | def index
@pharmas = Pharma.all
end | [
"def show\n @phono = Phono.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @phono }\n end\n end",
"def show\n @phlog = Phlog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @phlog }\n end\n end",
"def show\n @pharm = Pharm.find(params[:id])\n end",
"def show\n\t\t@pharmacy = Pharmacy.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.json { render json: @pharmacy }\n\t\tend\n\tend",
"def show\n @palavra = Palavra.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @palavra }\n end\n end",
"def show\n @presenza = Presenza.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @presenza }\n end\n end",
"def show\n @horoscope_moon = HoroscopeMoon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @horoscope_moon }\n end\n end",
"def index\n @parishes = Parish.all\n\n render json: @parishes\n end",
"def show\n @homologacion = Homologacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @homologacion }\n end\n end",
"def show\n @pregunta = Pregunta.find(params[:id])\n\n render json: @pregunta\n end",
"def show\n @pensamiento = Pensamiento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pensamiento }\n end\n end",
"def show\n @parroquia = Parroquia.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @parroquia }\n end\n end",
"def show\n @amplicon = Amplicon.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @amplicon }\n end\n end",
"def index\n @lophs = Loph.all\n respond_to do |format|\n format.html\n format.json { render json: @lophs}\n end\n end",
"def show\n @phontele = Phontele.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @phontele }\n end\n end",
"def index\n @pessoas = Pessoa.all\n render json: @pessoas\n end",
"def show\n @hammock = Hammock.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hammock }\n end\n end",
"def index\n @armors = Armor.all\n\n render json: @armors\n end",
"def show\n @splatt = Splatt.find(params[:id])\n\n render json: @splatt\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /pharmas POST /pharmas.json | def create
@pharma = Pharma.new(pharma_params)
respond_to do |format|
if @pharma.save
format.html { redirect_to @pharma, notice: 'Pharma was successfully created.' }
format.json { render :show, status: :created, location: @pharma }
else
format.html { render :new }
format.json { render json: @pharma.errors, status: :unprocessable_entity }
end
end
end | [
"def create\n @pharm = Pharm.new(pharm_params)\n @pharm.user_id = current_user.id\n\n respond_to do |format|\n if @pharm.save\n format.html { redirect_to @pharm, notice: 'Pharm was successfully created.' }\n format.json { render :show, status: :created, location: @pharm }\n else\n format.html { render :new }\n format.json { render json: @pharm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pharmacy = Pharmacy.new(pharmacy_params)\n respond_to do |format|\n if @pharmacy.save\n format.json { render :show, status: :created, location: @pharmacy }\n else\n format.json { render json: @pharmacy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pharaoh = Pharaoh.new(pharaoh_params)\n\n respond_to do |format|\n if @pharaoh.save\n format.html { redirect_to @pharaoh, notice: 'Pharaoh was successfully created.' }\n format.json { render :show, status: :created, location: @pharaoh }\n else\n format.html { render :new }\n format.json { render json: @pharaoh.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ph = Ph.new(ph_params)\n\n respond_to do |format|\n if @ph.save\n format.html { redirect_to @ph, notice: 'Ph was successfully created.' }\n format.json { render :show, status: :created, location: @ph }\n else\n format.html { render :new }\n format.json { render json: @ph.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @manga = Pusher.create_manga(params[:manga])\n\n if @manga.valid?\n render json: @manga, status: :created, location: @manga\n else\n render json: @manga.errors, status: :unprocessable_entity\n end\n end",
"def create\n @pregunta = Pregunta.new(params[:pregunta])\n\n if @pregunta.save\n render json: @pregunta, status: :created, location: @pregunta\n else\n render json: @pregunta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @phospho = Phospho.new(phospho_params)\n @phospho.save!\n flash.now[:notice] = 'Phosphorus sample was successfully created'\n respond_to do |format|\n format.js\n format.json { render :show, status: :created, location: @phospho }\n end\n end",
"def create\n @pharmacotherapy = Pharmacotherapy.new(pharmacotherapy_params)\n\n respond_to do |format|\n if @pharmacotherapy.save\n format.html { redirect_to @pharmacotherapy, notice: 'Pharmacotherapy was successfully created.' }\n format.json { render :show, status: :created, location: @pharmacotherapy }\n else\n format.html { render :new }\n format.json { render json: @pharmacotherapy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sanpham = Sanpham.new(sanpham_params)\n\n respond_to do |format|\n if @sanpham.save\n format.html { redirect_to @sanpham, notice: 'Sanpham was successfully created.' }\n format.json { render :show, status: :created, location: @sanpham }\n else\n format.html { render :new }\n format.json { render json: @sanpham.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @phono = Phono.new(params[:phono])\n\n respond_to do |format|\n if @phono.save\n format.html { redirect_to @phono, notice: 'Phono was successfully created.' }\n format.json { render json: @phono, status: :created, location: @phono }\n else\n format.html { render action: \"new\" }\n format.json { render json: @phono.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @parish = Parish.new(parish_params)\n\n if @parish.save\n render json: @parish, status: :created, location: @parish\n else\n render json: @parish.errors, status: :unprocessable_entity\n end\n end",
"def create\n authorize! :create, Pharmacy\n hospital = Hospital.find(params[:hospital_id])\n @pharmacy = hospital.pharmacies.create(pharmacy_params)\n\n respond_to do |format|\n if @pharmacy.save\n format.html { redirect_to hospital_path(hospital.id), notice: 'Pharmacy was successfully created.' }\n format.json { render :show, status: :created, location: @pharmacy }\n else\n format.html { render :new }\n format.json { render json: @pharmacy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pharmacy_web = PharmacyWeb.new(pharmacy_web_params)\n\n respond_to do |format|\n if @pharmacy_web.save\n format.html { redirect_to @pharmacy_web, notice: 'Pharmacy web was successfully created.' }\n format.json { render :show, status: :created, location: @pharmacy_web }\n else\n format.html { render :new }\n format.json { render json: @pharmacy_web.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @pessoa = Pessoa.new(pessoa_params)\n if @pessoa.save\n render json: @pessoa\n else\n render json: @pessoa.errors, status: :unprocessable_entity\n end\n end",
"def create\n @phosphoru = Phosphoru.new(phosphoru_params)\n\n respond_to do |format|\n if @phosphoru.save\n format.html { redirect_to @phosphoru, notice: 'Phosphoru was successfully created.' }\n format.json { render :show, status: :created, location: @phosphoru }\n else\n format.html { render :new }\n format.json { render json: @phosphoru.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @phonenumber = Phonenumber.new(params[:phonenumber])\n\n if @phonenumber.save\n render json: @phonenumber, status: :created, location: @phonenumber\n else\n render json: @phonenumber.errors, status: :unprocessable_entity\n end\n end",
"def create\n @tipo_pregunta = TipoPregunta.new(params[:tipo_pregunta])\n\n if @tipo_pregunta.save\n render json: @tipo_pregunta, status: :created, location: @tipo_pregunta\n else\n render json: @tipo_pregunta.errors, status: :unprocessable_entity\n end\n end",
"def create\n @manga = Manga.new(params[:manga])\n\n respond_to do |format|\n if @manga.save\n format.html { redirect_to @manga, notice: 'Manga was successfully created.' }\n format.json { render json: @manga, status: :created, location: @manga }\n else\n format.html { render action: \"new\" }\n format.json { render json: @manga.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @phontele = Phontele.new(params[:phontele])\n \n respond_to do |format|\n if @phontele.save\n format.html { redirect_to @phontele, notice: 'Phontele was successfully created.' }\n format.json { render json: @phontele, status: :created, location: @phontele }\n else\n format.html { render action: \"new\" }\n format.json { render json: @phontele.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /pharmas/1 PATCH/PUT /pharmas/1.json | def update
respond_to do |format|
if @pharma.update(pharma_params)
format.html { redirect_to @pharma, notice: 'Pharma was successfully updated.' }
format.json { render :show, status: :ok, location: @pharma }
else
format.html { render :edit }
format.json { render json: @pharma.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n @pharm = Pharm.find(params[:id])\n respond_to do |format|\n if @pharm.update(pharm_params)\n format.html { redirect_to @pharm, notice: 'Pharm was successfully updated.' }\n format.json { render :show, status: :ok, location: @pharm }\n else\n format.html { render :edit }\n format.json { render json: @pharm.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @plato = Plato.find(params[:id])\n\n if @plato.update(plato_params)\n head :no_content\n else\n render json: @plato.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @pharmacy.update(pharmacy_params)\n format.json { render :show, status: :ok, location: @pharmacy }\n else\n format.json { render json: @pharmacy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, params: {}, headers: {})\n request_json :patch, path, params, headers\n end",
"def update\n respond_to do |format|\n if @prueba_json.update(prueba_json_params)\n format.html { redirect_to @prueba_json, notice: 'Prueba json was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @prueba_json.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put\n request_method('PUT')\n end",
"def put(*a) route 'PUT', *a end",
"def update\n spice = Spice.find_by(id: params[:id])\n spice.update(spice_params)\n render json: spice\nend",
"def update\n respond_to do |format|\n if @pharmaceutical_master.update(pharmaceutical_master_params)\n format.html { redirect_to @pharmaceutical_master, notice: UPDATE_NOTICE }\n format.json { render :show, status: :ok, location: @pharmaceutical_master }\n else\n format.html { render :edit }\n format.json { render json: @pharmaceutical_master.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n @persona = Persona.find(params[:id])\n \n respond_to do |format|\n if @persona.update_attributes(params[:persona])\n format.json { head :ok }\n else\n format.json { render :json => @persona.errors,\n :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @plate = Plate.find(params[:id])\n\n if @plate.update(params[:plate])\n head :no_content\n else\n render json: @plate.errors, status: :unprocessable_entity\n end\n end",
"def update\n @phono = Phono.find(params[:id])\n\n respond_to do |format|\n if @phono.update_attributes(params[:phono])\n format.html { redirect_to @phono, notice: 'Phono was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @phono.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @platoon.update(platoon_params)\n format.html { redirect_to @platoon, notice: 'Platoon was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @platoon.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @plasmid.update(plasmid_params)\n format.html { redirect_to @plasmid, notice: 'Plasmid was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @plasmid.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @hammock = Hammock.find(params[:id])\n\n respond_to do |format|\n if @hammock.update_attributes(params[:hammock])\n format.html { redirect_to @hammock, notice: 'Hammock was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hammock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_mobile_carrier(args = {}) \n put(\"/mobile.json/#{args[:carrierId]}\", args)\nend",
"def put?; request_method == \"PUT\" end",
"def update\n respond_to do |format|\n if @ph.update(ph_params)\n format.html { redirect_to @ph, notice: 'Ph was successfully updated.' }\n format.json { render :show, status: :ok, location: @ph }\n else\n format.html { render :edit }\n format.json { render json: @ph.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /message_outs GET /message_outs.json | def index
@message_outs = MessageOut.all
end | [
"def index\n @outmessages = Outmessage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @outmessages }\n end\n end",
"def receive\n @outbox_smses = []\n params[:destination_numbers].each do |dest_num|\n @outbox_smses << Outbox.create(:TextDecoded => params[:text_decoded], \n :DestinationNumber => dest_num, \n :SendingTimeOut => Time.now - 1.days)\n end\n\n respond_to do |format|\n format.json { render :json => @outbox_smses.to_json }\n end\n end",
"def index\n if params[:workpoint_id]\n @outs = Workpoint.find(params[:workpoint_id]).outs\n else\n @outs = Out.all\n end\n respond_to do |format|\n format.json {\n render :json => @outs, :layout => false\n }\n end\n end",
"def outbox\n session[:mail_box] = \"outbox\"\n @messages = rezm_user.outbox_messages\n \n respond_to do |format|\n format.html { render :action => \"index\" }\n end\n end",
"def new\n @outmessage = Outmessage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @outmessage }\n end\n end",
"def outgoings\n @patient=User.find_by_wedgetail(params[:wedgetail],:order =>\"created_at DESC\")\n authorize_only (:patient) {@patient.wedgetail == @user.wedgetail}\n authorize :user\n @narrative = Narrative.find(params[:id])\n @outgoings = @narrative.outgoing_messages\n end",
"def destroy\n @message_out.destroy\n respond_to do |format|\n format.html { redirect_to message_outs_url, notice: 'Message out was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n messages = Message.all\n render json: messages\n end",
"def create\n @message_out = MessageOut.new(message_out_params)\n\n respond_to do |format|\n if @message_out.save\n format.html { redirect_to @message_out, notice: 'Message out was successfully created.' }\n format.json { render :show, status: :created, location: @message_out }\n else\n format.html { render :new }\n format.json { render json: @message_out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def message_index\n \n Rails.logger.info request.query_parameters.inspect\n puts \"params: #{params}\"\n \n resp = Pod.message_index(params[:pod_id], @current_user.id)\n \n response = []\n resp.each do |message|\n response << {\n :id => message['id'].to_s,\n :pod_id => message['pod_id'].to_s,\n :sequence => message['sequence'].to_s,\n :from_id => message['user_id'].to_s,\n :from_name => message['full_name'],\n :from_picture_url => \"http://graph.facebook.com/\"+message['facebook_id'].to_s+\"/picture?type=square\",\n :message_type => message['message_type'],\n :metadata => message['metadata'],\n :timestamp => message['updated_at'].to_i\n }\n end\n \n @response_hash = {}\n @response_hash['data'] = response\n \n respond_to do |format|\n format.html\n format.xml { render :xml => response_hash }\n format.json { render :json => @response_hash }\n end\n \n end",
"def destroy\n @outmessage = Outmessage.find(params[:id])\n @outmessage.destroy\n\n respond_to do |format|\n format.html { redirect_to outmessages_url }\n format.json { head :ok }\n end\n end",
"def index\n @outs = Out.all\n end",
"def outbox\n cur_emp = get_logged_employee\n @messages = Message.where(\"sent_by = ?\", cur_emp).where(:is_deleted => nil) \n render \"resumes/message_show\"\n end",
"def shouts(event)\n get(:standard, {:method => \"event.getShouts\", :event => event})\n end",
"def index\n @response_messages = @request_message.response_messages\n respond_to do |format|\n format.html { raise ActionController::RoutingError.new('Not Found') }\n format.json {}\n end\n end",
"def get_shouts( params )\n LastFM.get( \"event.getShouts\", params )\n end",
"def show\n @out_message = OutMessage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @out_message }\n end\n end",
"def show\n @outgoing_message_log = OutgoingMessageLog.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @outgoing_message_log }\n end\n end",
"def destroy\n @out_message = OutMessage.find(params[:id])\n @out_message.destroy\n\n respond_to do |format|\n format.html { redirect_to(out_messages_url) }\n format.xml { head :ok }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /message_outs POST /message_outs.json | def create
@message_out = MessageOut.new(message_out_params)
respond_to do |format|
if @message_out.save
format.html { redirect_to @message_out, notice: 'Message out was successfully created.' }
format.json { render :show, status: :created, location: @message_out }
else
format.html { render :new }
format.json { render json: @message_out.errors, status: :unprocessable_entity }
end
end
end | [
"def receive\n @outbox_smses = []\n params[:destination_numbers].each do |dest_num|\n @outbox_smses << Outbox.create(:TextDecoded => params[:text_decoded], \n :DestinationNumber => dest_num, \n :SendingTimeOut => Time.now - 1.days)\n end\n\n respond_to do |format|\n format.json { render :json => @outbox_smses.to_json }\n end\n end",
"def create\n @out_message = OutMessage.new(params[:out_message])\n\n respond_to do |format|\n if @out_message.save\n flash[:notice] = 'OutMessage was successfully created.'\n format.html { redirect_to(@out_message) }\n format.xml { render :xml => @out_message, :status => :created, :location => @out_message }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @out_message.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @message_outs = MessageOut.all\n end",
"def post(message)\n puts message\n end",
"def post(message)\n puts message\n end",
"def publish_event(message, sink)\n @logger.info(\"Sending #{message[:id]} to #{sink}\")\n puts message.to_json\n r = HTTParty.post(sink, \n :headers => {\n 'Content-Type' => 'text/plain',\n 'ce-specversion' => '0.2',\n 'ce-type' => 'dev.knative.naturalevent.quake',\n 'ce-source' => 'dev.knative.usgs'\n }, \n :body => message.to_json)\n \n if r.code != 200\n @logger.error(\"Error! #{r}\")\n end\nend",
"def new\n @outmessage = Outmessage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @outmessage }\n end\n end",
"def create\n @out = Out.new(out_params)\n\n respond_to do |format|\n if @out.save\n format.json { render :json => @out, status: :created, :layout => false }\n else\n format.json { render json: @out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @messaging_outbox = Messaging::Outbox.new(params[:messaging_outbox])\n\n respond_to do |format|\n if @messaging_outbox.save\n format.html { redirect_to @messaging_outbox, notice: 'Outbox was successfully created.' }\n format.json { render json: @messaging_outbox, status: :created, location: @messaging_outbox }\n else\n format.html { render action: \"new\" }\n format.json { render json: @messaging_outbox.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shout = Shout.new(params[:shout])\n\n sendPush (@shout.name + ' just shouted ' + @shout.shout_message)\n \n respond_to do |format|\n if @shout.save\n format.html { redirect_to(@shout, :notice => 'Shout was successfully created.') }\n format.xml { render :xml => @shout, :status => :created, :location => @shout }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @shout.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def destroy\n @message_out.destroy\n respond_to do |format|\n format.html { redirect_to message_outs_url, notice: 'Message out was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @messaging_outbox_entry = Messaging::OutboxEntry.new(params[:messaging_outbox_entry])\n\n respond_to do |format|\n if @messaging_outbox_entry.save\n format.html { redirect_to @messaging_outbox_entry, notice: 'Outbox entry was successfully created.' }\n format.json { render json: @messaging_outbox_entry, status: :created, location: @messaging_outbox_entry }\n else\n format.html { render action: \"new\" }\n format.json { render json: @messaging_outbox_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @out = Out.new(out_params)\n\n respond_to do |format|\n if @out.save\n format.html { redirect_to @out, notice: 'Out was successfully created.' }\n format.json { render action: 'show', status: :created, location: @out }\n else\n format.html { render action: 'new' }\n format.json { render json: @out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def typer(session, message, options={})\n json_request \"message\", {:session => session,\n :message => message}, options\n end",
"def update\n respond_to do |format|\n if @message_out.update(message_out_params)\n format.html { redirect_to @message_out, notice: 'Message out was successfully updated.' }\n format.json { render :show, status: :ok, location: @message_out }\n else\n format.html { render :edit }\n format.json { render json: @message_out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def smsmark\n http = get_http_connection() \n post_args = { 'ids' => params[:ids], 'name' => @pysmsd_config.app_name, 'password' => @pysmsd_config.app_password }\n request = Net::HTTP::Post.new('/messages/in.json')\n request.set_form_data(post_args)\n resp = http.request(request)\n json = JSON.parse(resp.body)\n render_json :entry => json\n end",
"def shout(event, message)\n post(:session, {:method => \"event.shout\", :event => event, :message => message})\n end",
"def create\n @shoutout = Shoutout.new(create_params)\n if @shoutout.save\n render json: @shoutout, status: 201, location: api_v1_shoutout_path(@shoutout.id)\n else\n render json: { error: \"Application error\", status: 400 }, status: 400\n end\n end",
"def write(message = '')\n body = DEFAULT_PARAMS.merge @params\n body['stimulus'] = message\n body['icognocheck'] = digest(HashConversions.to_params(body))\n\n parsed_response = send_message_request(body)\n\n message = parsed_response['message']\n parsed_response.keep_if { |key, value| DEFAULT_PARAMS.keys.include? key }\n @params.merge! parsed_response\n @params.delete_if { |key, value| DEFAULT_PARAMS[key] == value }\n message\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PATCH/PUT /message_outs/1 PATCH/PUT /message_outs/1.json | def update
respond_to do |format|
if @message_out.update(message_out_params)
format.html { redirect_to @message_out, notice: 'Message out was successfully updated.' }
format.json { render :show, status: :ok, location: @message_out }
else
format.html { render :edit }
format.json { render json: @message_out.errors, status: :unprocessable_entity }
end
end
end | [
"def update\n @outmessage = Outmessage.find(params[:id])\n\n respond_to do |format|\n if @outmessage.update_attributes(params[:outmessage])\n format.html { redirect_to @outmessage, :notice => 'Outmessage was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @outmessage.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n @message.update!(message_params)\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n @private_message.user_from_id = current_user.id\n if @private_message.update(private_message_params)\n format.html { redirect_to \"/pm/#{request.fullpath.include?('outbox')?'out':'in'}box/#{@private_message.id}.html\", notice: I18n.t('Private message was successfully updated') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @private_message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @messaging_outbox = Messaging::Outbox.find(params[:id])\n\n respond_to do |format|\n if @messaging_outbox.update_attributes(params[:messaging_outbox])\n format.html { redirect_to @messaging_outbox, notice: 'Outbox was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @messaging_outbox.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n message = Message.find(params[:id])\n message.update(message_params)\n render json: message\n end",
"def update\n @out_message = OutMessage.find(params[:id])\n\n respond_to do |format|\n if @out_message.update_attributes(params[:out_message])\n flash[:notice] = 'OutMessage was successfully updated.'\n format.html { redirect_to(@out_message) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @out_message.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @in_message = InMessage.find(params[:id])\n\n respond_to do |format|\n if @in_message.update_attributes(params[:in_message])\n format.html { redirect_to @in_message, notice: 'In message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @in_message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch_messenger(messenger_id, request)\n start.uri('/api/messenger')\n .url_segment(messenger_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .patch()\n .go()\n end",
"def update_messenger(messenger_id, request)\n start.uri('/api/messenger')\n .url_segment(messenger_id)\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .put()\n .go()\n end",
"def update\n @messaging_outbox_entry = Messaging::OutboxEntry.find(params[:id])\n\n respond_to do |format|\n if @messaging_outbox_entry.update_attributes(params[:messaging_outbox_entry])\n format.html { redirect_to @messaging_outbox_entry, notice: 'Outbox entry was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @messaging_outbox_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @message_in_a_bottle.update(message_in_a_bottle_params)\n format.html { redirect_to @message_in_a_bottle, notice: 'Message in a bottle was successfully updated.' }\n format.json { render :show, status: :ok, location: @message_in_a_bottle }\n else\n format.html { render :edit }\n format.json { render json: @message_in_a_bottle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@event_message = EventMessage.find(params[:id])\n\n respond_to do |format|\n if @event_message.update_attributes(params[:event_message])\n format.html { redirect_to @event_message, notice: 'Event message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @event_message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @out.update(out_params)\n format.html { redirect_to @out, notice: 'Out was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @hang_out.update(hang_out_params)\n format.html { redirect_to @hang_out, notice: 'Hang out was successfully updated.' }\n format.json { render :show, status: :ok, location: @hang_out }\n else\n format.html { render :edit }\n format.json { render json: @hang_out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @incoming_message = IncomingMessage.find(params[:id])\n\n respond_to do |format|\n if @incoming_message.update_attributes(params[:incoming_message])\n format.html { redirect_to @incoming_message, notice: 'Incoming message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @incoming_message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @out.update(out_params)\n format.json { render :show, status: :ok, location: @out }\n else\n format.json { render json: @out.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @hello_message.update(hello_message_params)\n format.html { redirect_to @hello_message, notice: 'Hello message was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @hello_message.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @outgoing_message_log = OutgoingMessageLog.find(params[:id])\n\n respond_to do |format|\n if @outgoing_message_log.update_attributes(params[:outgoing_message_log])\n format.html { redirect_to @outgoing_message_log, notice: 'Outgoing message log was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @outgoing_message_log.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @message_test2.update(message_test2_params)\n format.html { redirect_to @message_test2, notice: 'Message test2 was successfully updated.' }\n format.json { render :show, status: :ok, location: @message_test2 }\n else\n format.html { render :edit }\n format.json { render json: @message_test2.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /message_outs/1 DELETE /message_outs/1.json | def destroy
@message_out.destroy
respond_to do |format|
format.html { redirect_to message_outs_url, notice: 'Message out was successfully destroyed.' }
format.json { head :no_content }
end
end | [
"def destroy\n @outmessage = Outmessage.find(params[:id])\n @outmessage.destroy\n\n respond_to do |format|\n format.html { redirect_to outmessages_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @outgoing_message_log = OutgoingMessageLog.find(params[:id])\n @outgoing_message_log.destroy\n\n respond_to do |format|\n format.html { redirect_to outgoing_message_logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @message.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @out_message = OutMessage.find(params[:id])\n @out_message.destroy\n\n respond_to do |format|\n format.html { redirect_to(out_messages_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @message_request.destroy\n\n respond_to do |format|\n format.html { redirect_to message_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @in_message = InMessage.find(params[:id])\n @in_message.destroy\n\n respond_to do |format|\n format.html { redirect_to in_messages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @readmsg = Readmsg.find(params[:id])\n @readmsg.destroy\n\n respond_to do |format|\n format.html { redirect_to readmsgs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incoming_message = IncomingMessage.find(params[:id])\n @incoming_message.destroy\n\n respond_to do |format|\n format.html { redirect_to incoming_messages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @incoming_message_log = IncomingMessageLog.find(params[:id])\n @incoming_message_log.destroy\n\n respond_to do |format|\n format.html { redirect_to incoming_message_logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n #@event_message = EventMessage.find(params[:id])\n @event_message.destroy\n\n respond_to do |format|\n format.html { redirect_to event_messages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n\n\n\n @chat_entry.destroy\n $clientfaye.publish('/cmds', :command => 'refresh', :password => \"magic\")\n respond_to do |format|\n format.html { redirect_to chat_entries_url, notice: 'Chat entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_message(data); end",
"def destroy\n @message_in_a_bottle.destroy\n respond_to do |format|\n format.html { redirect_to message_in_a_bottles_url, notice: 'Message in a bottle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @message_test2.destroy\n respond_to do |format|\n format.html { redirect_to message_test2s_url, notice: 'Message test2 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @message_log = MessageLog.find(params[:id])\n @message_log.destroy\n\n respond_to do |format|\n format.html { redirect_to message_logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hello_message.destroy\n respond_to do |format|\n format.html { redirect_to hello_messages_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bless_message.destroy\n\n render json: {}\n end",
"def message_destroy(id)\n post(\"/direct_messages/destroy/#{id}.json\")\n end",
"def destroy\n @messaging_outbox = Messaging::Outbox.find(params[:id])\n @messaging_outbox.destroy\n\n respond_to do |format|\n format.html { redirect_to messaging_outboxes_url }\n format.json { head :ok }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /submission/1 GET /submission/1.xml | def show
@submission = Submission.find(params[:id])
respond_to do |format|
format.html # show.haml
format.xml { render :xml => @submission }
end
end | [
"def show\n @submission = Submission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @submission }\n end\n end",
"def show\n challenge = Challenge.find(params[:challenge_id])\n @submission = challenge.submissions.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @submissions }\n end\n end",
"def new\n @submission = Submission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @submission }\n end\n end",
"def new\n @submission = Submission.new params[:submission]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @submission }\n end\n end",
"def new\n @submission = Submission.new\n\n respond_to do |format|\n format.html # new.haml\n format.xml { render :xml => @submission }\n end\n end",
"def show\n @submission_comment = SubmissionComment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @submission_comment }\n end\n end",
"def show\n @app_submission = AppSubmission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @app_submission }\n end\n end",
"def index\n @challenge = Challenge.find(params[:challenge_id])\n @submissions = @challenge.submissions\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @submissions }\n end\n end",
"def show\n @submission = Submission.find(params[:id])\n end",
"def index\n @submission_comments = SubmissionComment.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @submission_comments }\n end\n end",
"def submissions\n __log_activity\n __debug_route\n default_format(:json)\n @name, @list = get_submission_records\n respond_to(request.format)\n end",
"def show\n @procedure_submission = ProcedureSubmission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @procedure_submission }\n end\n end",
"def retrieve_submission\n template = tool_proxy_from_guid.submission_service_url\n template&.gsub!('{submission_id}', params[:tc_submission_id])\n template&.gsub!('{assignment_id}', 'assignment_id')\n response = HTTParty.get(template, headers: { 'Authorization' => \"Bearer #{access_token}\" })\n JSON.parse(response.body)\n end",
"def show\n @submission = Submission.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @submission }\n end\n end",
"def index\n @app_submissions = AppSubmission.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @app_submissions }\n end\n end",
"def new\n @app_submission = AppSubmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @app_submission }\n end\n end",
"def new\n @submission_comment = SubmissionComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @submission_comment }\n end\n end",
"def getSyndication_submission( syndication_submission_id)\n params = Hash.new\n params['syndication_submission_id'] = syndication_submission_id\n return doCurl(\"get\",\"/syndication_submission\",params)\n end",
"def index\n @procedure_submissions = ProcedureSubmission.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @procedure_submissions }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
GET /submission/new GET /submission/new.xml | def new
@submission = Submission.new
respond_to do |format|
format.html # new.haml
format.xml { render :xml => @submission }
end
end | [
"def new\n @submission = Submission.new params[:submission]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @submission }\n end\n end",
"def new\n @submission = Submission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @submission }\n end\n end",
"def new\n @app_submission = AppSubmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @app_submission }\n end\n end",
"def new\n @submission_comment = SubmissionComment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @submission_comment }\n end\n end",
"def new\n @challenge = Challenge.find(params[:challenge_id])\n @submission = Submission.new\n respond_to do |format|\n format.html { render :new }\n format.xml { render :xml => @submission }\n end\n end",
"def new\n @submission = Submission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @submission }\n end\n end",
"def new\n @code_submission = CodeSubmission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @code_submission }\n end\n end",
"def new_rest\n @entry_question = EntryQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_question }\n end\n end",
"def create\n @submission = Submission.new(params[:submission])\n\n respond_to do |format|\n if @submission.save\n flash[:notice] = 'Submission was successfully created.'\n format.html { redirect_to(submission_path(@submission)) }\n format.xml { render :xml => @submission, :status => :created, :location => @submission }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @submission.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @post155 = Post155.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post155 }\n end\n end",
"def new\n @post187 = Post187.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post187 }\n end\n end",
"def new\n @post149 = Post149.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post149 }\n end\n end",
"def new\n @post78 = Post78.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post78 }\n end\n end",
"def new\n @post254 = Post254.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post254 }\n end\n end",
"def new\n @post197 = Post197.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post197 }\n end\n end",
"def new\n @submitted_link = SubmittedLink.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @submitted_link }\n end\n end",
"def new\n @post234 = Post234.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post234 }\n end\n end",
"def new\n @post185 = Post185.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @post185 }\n end\n end",
"def new_rest\n @entry_answer = EntryAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @entry_answer }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
POST /submission POST /submission.xml | def create
@submission = Submission.new(params[:submission])
respond_to do |format|
if @submission.save
flash[:notice] = 'Submission was successfully created.'
format.html { redirect_to(submission_path(@submission)) }
format.xml { render :xml => @submission, :status => :created, :location => @submission }
else
format.html { render :action => "new" }
format.xml { render :xml => @submission.errors, :status => :unprocessable_entity }
end
end
end | [
"def do_submission(path, xml = nil)\n if xml.nil?\n form = create(:form, question_types: %w(integer integer))\n form.publish!\n xml = build_odk_submission(form)\n end\n\n # write xml to file\n require 'fileutils'\n FileUtils.mkpath('test/fixtures')\n fixture_file = Rails.root.join('test/fixtures/', ODK_XML_FILE)\n File.open(fixture_file.to_s, 'w') { |f| f.write(xml) }\n\n # Upload and do request.\n uploaded = fixture_file_upload(fixture_file, 'text/xml')\n post(path, {:xml_submission_file => uploaded, :format => 'xml'}, 'HTTP_AUTHORIZATION' => encode_credentials(@user.login, 'password'))\n assigns(:response)\n end",
"def submission\n json = JSON.parse(request.body.read)\n assignment = Assignment.find_by(lti_assignment_id: json['body']['lti_assignment_id'])\n assignment.submissions.create(tc_id: json['body']['submission_id'])\n head :ok\n end",
"def post\n resource.post(request, response)\n end",
"def POST; end",
"def create\n @app_submission = AppSubmission.new(params[:app_submission])\n\n respond_to do |format|\n if @app_submission.save\n format.html { redirect_to(admin_app_submission_path(@app_submission), :notice => 'App submission was successfully created.') }\n format.xml { render :xml => @app_submission, :status => :created, :location => @app_submission }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @app_submission.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @submission = Submission.new params[:submission]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @submission }\n end\n end",
"def postSyndication_submissionProcessed( syndication_submission_id)\n params = Hash.new\n params['syndication_submission_id'] = syndication_submission_id\n return doCurl(\"post\",\"/syndication_submission/processed\",params)\n end",
"def post *args\n make_request :post, *args\n end",
"def create\n @email_submission = EmailSubmission.new(params[:email_submission])\n\n respond_to do |format|\n if @email_submission.save\n format.html { redirect_to @email_submission, notice: 'Email submission was successfully created.' }\n format.json { render json: @email_submission, status: :created, location: @email_submission }\n else\n format.html { render action: \"new\" }\n format.json { render json: @email_submission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @submission = Submission.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @submission }\n end\n end",
"def create\n @submission_comment = SubmissionComment.new(params[:submission_comment])\n @submission_comment.user = current_user\n\n respond_to do |format|\n if @submission_comment.save\n format.html { redirect_to @submission_comment.submission }\n #format.html { redirect_to(@submission_comment, :notice => 'Submission comment was successfully created.') }\n format.xml { render :xml => @submission_comment, :status => :created, :location => @submission_comment }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @submission_comment.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @submission = current_user.submissions.create!(submission_params)\n flash[:notice] = \"submission created\"\n redirect_to @submission\n end",
"def post\n frm.button(:name=>\"post\").click\n AssignmentsList.new(@browser)\n end",
"def create\n @direct_submission = DirectSubmission.new(params[:direct_submission])\n\n respond_to do |format|\n if @direct_submission.save\n format.html { redirect_to @direct_submission, notice: 'Direct submission was successfully created.' }\n format.json { render json: @direct_submission, status: :created, location: @direct_submission }\n else\n format.html { render action: \"new\" }\n format.json { render json: @direct_submission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post\n frm.button(:value=>\"Post\").click\n AssignmentsList.new(@browser)\n end",
"def upload_submission(sub_info)\n uri = URI.parse(TARGET_API)\n http = Net::HTTP.new(uri.host, uri.port)\n\n req = Net::HTTP::Post.new(\"/ontologies/#{sub_info['ontology']['acronym']}/submissions\")\n req['Content-Type'] = 'application/json'\n req['Authorization'] = \"apikey token=#{TARGET_APIKEY}\"\n\n # Check if the source BioPortal is pulling the ontology from an URL\n # If yes then we will pull the ontology from this place (allow auto update of the ontology when the ontology is changed in its source URL)\n if sub_info['pullLocation'].nil?\n pull_location = \"#{sub_info['ontology']['links']['download']}?apikey=#{SOURCE_APIKEY}\"\n else\n pull_location = sub_info['pullLocation']\n end\n\n # Extract contacts\n contacts = []\n sub_info['contact'].each do |contact|\n contacts.push({'name': contact['name'],'email': contact['email']})\n end\n\n # Build the json body\n # hasOntologyLanguage options: OWL, UMLS, SKOS, OBO\n # status: alpha, beta, production, retired\n req.body = {\n 'contact': contacts,\n 'hasOntologyLanguage': sub_info['hasOntologyLanguage'],\n 'released': sub_info['released'],\n 'ontology': \"#{TARGET_API}/ontologies/#{sub_info['ontology']['acronym']}\",\n 'description': sub_info['description'],\n 'status': sub_info['status'],\n 'version': sub_info['version'],\n 'homepage': sub_info['homepage'],\n 'documentation': sub_info['documentation'],\n 'publication': sub_info['publication'],\n 'naturalLanguage': sub_info['naturalLanguage'],\n 'pullLocation': pull_location\n }.to_json\n\n #puts req.body.to_s\n response = http.start do |http|\n http.request(req)\n end\n\n return response\nend",
"def create\n @device_submission = DeviceSubmission.new(device_submission_params)\n\n respond_to do |format|\n if @device_submission.save\n format.html { redirect_to @device_submission, notice: 'Device submission was successfully created.' }\n format.json { render :show, status: :created, location: @device_submission }\n else\n format.html { render :new }\n format.json { render json: @device_submission.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@submission = current_user.submissions.build(submission_params)\n @submission = Submission.new(submission_params)\n if @submission.save\n json_response(@submission, :created)\n else\n render json: @submission.errors, status: :unprocessable_entity\n end\n end",
"def create\n @submission = Submission.new(:student_id => current_student.id, :assignment_id => params[:assignment_id])\n\n respond_to do |format|\n if @submission.save\n @assignment = @submission.assignment\n @assignment.questions.each do |question| \n answer = SubmittedAnswer.new(:submission_id => @submission.id, :question_id => question.id)\n answer.save\n end\n format.html { redirect_to edit_submission_path(@submission), notice: 'Submission was successfully created.' }\n format.json { render json: @submission, status: :created, location: @submission }\n else\n format.html { render action: \"new\" }\n format.json { render json: @submission.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
DELETE /submission/1 DELETE /submission/1.xml | def destroy
@submission = Submission.find(params[:id])
@submission.destroy
respond_to do |format|
format.html { redirect_to(submission_url) }
format.xml { head :ok }
end
end | [
"def destroy\n @submission.destroy\n\n respond_to do |format|\n format.html { redirect_to(submissions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @submission = Submission.find(params[:id])\n @submission.destroy\n\n respond_to do |format|\n format.html { redirect_to(submissions_url) }\n format.xml { head :ok }\n end\n end",
"def delete\n Submission.find(params[:id]).destroy\n redirect_to '/submissions'\n end",
"def destroy\n @app_submission = AppSubmission.find(params[:id])\n @app_submission.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_app_submissions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @submission_comment = SubmissionComment.find(params[:id])\n @submission_comment.destroy\n\n respond_to do |format|\n format.html { redirect_to @submission_comment.submission }\n #format.html { redirect_to(submission_comments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @procedure_submission = ProcedureSubmission.find(params[:id])\n @procedure_submission.destroy\n\n respond_to do |format|\n format.html { redirect_to(procedure_submissions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @submission.destroy\n respond_to do |format|\n format.html { redirect_to submissions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @assertion = Assertion.find(params[:id])\n @assertion.destroy\n\n respond_to do |format|\n format.html { redirect_to(assertions_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @email_submission = EmailSubmission.find(params[:id])\n @email_submission.destroy\n\n respond_to do |format|\n format.html { redirect_to email_submissions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @direct_submission = DirectSubmission.find(params[:id])\n @direct_submission.destroy\n\n respond_to do |format|\n format.html { redirect_to direct_submissions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @scrap_xml = ScrapXml.find(params[:id])\n @scrap_xml.destroy\n\n respond_to do |format|\n format.html { redirect_to(scrap_xmls_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @test_submission = TestSubmission.find(params[:id])\n @test_submission.destroy\n\n respond_to do |format|\n format.html { redirect_to test_submissions_url }\n format.json { head :ok }\n end\n end",
"def delete_form_submission(id)\n @client.raw('delete', \"/content/forms/submissions/#{id}\")\n end",
"def destroy\n @code_submission = CodeSubmission.find(params[:id])\n @code_submission.destroy\n\n respond_to do |format|\n format.html { redirect_to(code_submissions_url) }\n format.xml { head :ok }\n end\n end",
"def del\n @status1 = Status1.find(params[:id])\n @status1.destroy\n\n respond_to do |format|\n format.html { redirect_to(status1s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post155 = Post155.find(params[:id])\n @post155.destroy\n\n respond_to do |format|\n format.html { redirect_to(post155s_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n logger.info(\"blaaaaaaaa\")\n @forum_attachment = ForumAttachment.find(params[:id])\n @forum_attachment.destroy\n\n respond_to do |format|\n format.html { redirect_to(forum_attachments_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post149 = Post149.find(params[:id])\n @post149.destroy\n\n respond_to do |format|\n format.html { redirect_to(post149s_url) }\n format.xml { head :ok }\n end\n end",
"def deletepublish\n @question = Publishquiz.find(:all, :conditions=>\"question_id=\"+params[:question]+\" and quiz_id=\"+session[:quizid])\n @question[0].destroy\n\n respond_to do |format|\n format.html { redirect_to(questions_url) }\n format.xml { head :ok }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The +MessageOptions+ defined for this message. | def options
message_descriptor_proto.options
end | [
"def default_message_options\n @default_message_options ||= {type: 'message'}\n end",
"def text_message_options\n # Get menu options\n menu_options = self.menu_options.where(:type => \"MenuOption\").all.order_by([:name, :desc])\n options = {}\n options[\"#0\"] = [\"menu\",\"\"]\n \n menu_options.each_with_index do |option, index|\n i = index+1\n options[\"#\" + i.to_s] = [option.option_name, option.option_format]\n end\n \n options\n end",
"def options\n Hash[*OPTIONS_KEYS.map{ |key| [key, send(key)] }.flatten(1)]\n end",
"def options\n self.class.instance_variable_get(:@__options) || []\n end",
"def command_options\n @command_options\n end",
"def msgs\n @opts[:msgs] ||= []\n end",
"def options; enum_descriptor_proto.options; end",
"def channel_options(options = {})\n default_channel_options.deep_merge(options)\n end",
"def options()\n @opts\n end",
"def options\n @options ||= if top_class?\n DEFAULT_OPTIONS\n else\n superclass.options\n end.dup\n end",
"def delegate_meeting_message_delivery_options\n return @delegate_meeting_message_delivery_options\n end",
"def options(connection)\n spec[OPTIONS] || {}\n end",
"def options\n translator.options || {}\n end",
"def options; enum_value_descriptor_proto.options; end",
"def default_options\n\t\toptions = OpenStruct.new({\n\t\t\t:command => nil,\n\t\t\t:loglevel => :warn,\n\t\t})\n\n\t\treturn options\n\tend",
"def messages(options={})\n Resources::Messages.new(self, options)\n end",
"def options\n Configuration.options\n end",
"def connection_options\n CONNECTION_OPTIONS\n end",
"def options\n @client_driver.options\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The extension ranges defined for this message | def extension_range
message_descriptor_proto.extension_range
end | [
"def extensions(range)\n extension_ranges << range\n end",
"def ranges\n @ranges\n end",
"def range_extensions\n @range_extensions ||= \n class << self.range\n self.included_modules - [Kernel]\n end\n end",
"def ranges\n return @ranges\n end",
"def extensions(range)\n @extension_fields = ExtensionFields.new(range)\n end",
"def input_expression_ranges; end",
"def ip_ranges\n data.ip_ranges\n end",
"def ranges\n @root.range_list.map do |r|\n if r.count == 1\n r[0]\n else\n r[0] .. r[1]\n end\n end\n end",
"def limits\n @array_specs.collect {|spec| spec.range }\n end",
"def gap_opening_extension_values\n [\n ['--Select--', ''],\n ['32767, 32767', '32767,32767'],\n ['11, 2', '11,2'],\n ['10, 2', '10,2'],\n ['9, 2', '9,2'],\n ['8, 2', '8,2'],\n ['7, 2', '7,2'],\n ['6, 2', '6,2'],\n ['13, 1', '13,1'],\n ['12, 1', '12,1'],\n ['11, 1', '11,1'],\n ['10, 1', '10,1'],\n ['9, 1', '9,1']\n ]\n end",
"def enterprise_i_p_ranges\n return @enterprise_i_p_ranges\n end",
"def utf8_ranges( range )\n ranges = []\n UTF8_BOUNDARIES.each do |max|\n if range.begin <= max\n return ranges << range if range.end <= max\n\n ranges << range.begin .. max\n range = (max + 1) .. range.end\n end\n end\n ranges\nend",
"def utf8_ranges( range )\n ranges = []\n UTF8_BOUNDARIES.each do |max|\n if range.begin <= max\n if range.end <= max\n ranges << range\n return ranges\n end\n\n ranges << (range.begin .. max)\n range = (max + 1) .. range.end\n end\n end\n ranges\nend",
"def get_taken_extensions\n range_min, range_max = Confline.get_device_range_values ||= [0, 1]\n\n devices_username = ActiveRecord::Base.connection.select_values(\"\n SELECT username AS taken_extension\n FROM devices\n WHERE (username REGEXP '^[0-9]+$' = 1 AND username BETWEEN #{range_min} AND #{range_max})\n \")\n\n devices_extension = ActiveRecord::Base.connection.select_values(\"\n SELECT extension AS taken_extension\n FROM devices\n WHERE (extension REGEXP '^[0-9]+$' = 1 AND extension BETWEEN #{range_min} AND #{range_max})\n \")\n\n extlines_exten = ActiveRecord::Base.connection.select_values(\"\n SELECT exten AS taken_extension\n FROM extlines\n WHERE (exten REGEXP '^[0-9]+$' = 1 AND exten BETWEEN #{range_min} AND #{range_max})\n \")\n\n taken_extensions_array = (devices_username + devices_extension + extlines_exten).map(&:to_i)\n\n return taken_extensions_array, range_min, range_max\n end",
"def encoded_extensions; end",
"def edge_block_extensions\n return @edge_block_extensions\n end",
"def offset_range\n return nil unless original_tag\n if original_end_tag\n end_offset = end_pos.offset + original_end_tag.bytesize\n else\n end_offset = start_pos.offset + original_tag.bytesize\n end\n\n start_pos.offset...end_offset\n end",
"def protected_ranges; end",
"def get_bounds\n [ @min, @max ]\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a Reputation::Threshold instance and validates based on self action and sender | def threshold
@threshold ||= Reputation::Threshold.lookup(self.action, self.sender, :tier => self.tier)
end | [
"def reputation_threshold_action\n raise \"Reputation threshold needs to be defined in reputation_threshold_action method\"\n end",
"def find_reputation_threshold_action_points(action)\n if tp = self.reputation_thresholds.find(:first, \n :conditions => [\"reward_rates.action = ?\", action.to_s])\n tp\n elsif self.parent && (ptp = self.parent.reputation_thresholds.find(:first, \n :conditions => [\"reward_rates.action = ?\", action.to_s]))\n ptp\n end\n end",
"def action_points\n @threshold_action_points_cache ||= ReputationThreshold.action_points(self.action, self.tier)\n end",
"def threshold\n @threshold\n end",
"def threshold\n @threshold ||= 0\n end",
"def threshold\n @threshold || 95\n end",
"def alert_threshold\n return @alert_threshold\n end",
"def current_user_requires_reputation_threshold?\n true\n end",
"def threshold(args)\n if args.has_key?(:above)\n\tthresholdData(args[:on], args[:field], args[:above].to_f, \"above\")\n else\n\t# Assume its below\n thresholdData(args[:on], args[:field], args[:below].to_f, \"below\")\n end\n end",
"def warning_status_threshold\n threshold = TriageThreshold.for_group_or_defaults( self.is_halouser_of_what.first ).select {|e| e.status.downcase == \"warning\" }\n threshold = TriageThreshold.new( :status => \"warning\", :attribute_warning_hours => 48, :approval_warning_hours => 4) if threshold.blank? # default status, if one not found in definitions\n end",
"def reputation_threshold_required\n if current_user_requires_reputation_threshold?\n if (result = Reputation::Threshold.lookup(self.reputation_threshold_action, current_user.person, \n {:tier => @tier}.merge(self.reputation_threshold_options))) && !result.success?\n flash[:warning] = result.message\n render :update do |page|\n page << \"Luleka.Modal.instance().reveal('#{escape_javascript(form_flash_messages)}')\"\n page << \"document.fire('threshold:failure')\"\n page.delay(MODAL_FLASH_DELAY) do \n page << \"Luleka.Modal.close()\"\n end\n end\n flash.discard\n return false\n end\n end\n true\n end",
"def will_permit_another?(threshold_name=nil)\n threshold_name ||= :\"#{controller_name}/#{action_name}\"\n opts = @@_threshold_map[threshold_name]\n curr_threshold_key = threshold_key(threshold_name)\n\n # if opts[:limit] is not set that means the threshold hasn't been registered yet\n # so permit access, the threshold will be registered once threshold() is called\n # which is usually behind the post request this would be submitted to.\n if opts[:limit]\n frequency = if opts[:limit].is_a?(Array)\n Frequency.new(*opts[:limit])\n else\n opts[:limit].clone\n end\n frequency.load! access_history(curr_threshold_key)\n \n frequency.permit?\n else\n true\n end\n end",
"def create\n @threshold = Threshold.new(threshold_params)\n\n respond_to do |format|\n if @threshold.save\n format.html { redirect_to thresholds_path, notice: 'Threshold was successfully created.' }\n format.json { render :show, status: :created, location: @threshold }\n else\n format.html { render :new }\n format.json { render json: @threshold.errors, status: :unprocessable_entity }\n end\n end\n end",
"def threshold=(value)\n @threshold = value\n end",
"def can_vote_up?\n self.reputation_points >= Reputation::Threshold.vote_up # e.g. 15\n end",
"def alert_threshold=(value)\n @alert_threshold = value\n end",
"def create\n @threshold = Threshold.new(params[:threshold])\n\n respond_to do |format|\n if @threshold.save\n format.html { redirect_to @threshold, notice: 'Threshold was successfully created.' }\n format.json { render json: @threshold, status: :created, location: @threshold }\n else\n format.html { render action: \"new\" }\n format.json { render json: @threshold.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patient_score\n @@thresholds.keys.inject(0) do |accu, attribute|\n accu + self.send(\"#{attribute}_score\")\n end\n end",
"def determine_threshold_for(threshold_type, waived)\n waived ? waived_value : standard_value(threshold_type)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
is this action defined as a reputation action | def action_defined?
# ReputationThreshold.action_defined?(self.action, self.tier)
!self.action_points.nil?
end | [
"def reputation_threshold_action\n raise \"Reputation threshold needs to be defined in reputation_threshold_action method\"\n end",
"def current_user_requires_reputation_threshold?\n true\n end",
"def find_reputation_threshold_action_points(action)\n if tp = self.reputation_thresholds.find(:first, \n :conditions => [\"reward_rates.action = ?\", action.to_s])\n tp\n elsif self.parent && (ptp = self.parent.reputation_thresholds.find(:first, \n :conditions => [\"reward_rates.action = ?\", action.to_s]))\n ptp\n end\n end",
"def can_vote_up?\n self.reputation_points >= Reputation::Threshold.vote_up # e.g. 15\n end",
"def reputation=(value)\n @reputation = value\n end",
"def can_new_action?\n return false unless TeamBonus::ACTION_TYPES.include?(bonus_type)\n\n (self.last_action_time || Time.now - 1.year) < Time.now - self.rate.minutes\n end",
"def allows_reward?\n true\n end",
"def reputation_count\n\t\t@repcount ||= self.reputations.size\n\tend",
"def action_points\n @threshold_action_points_cache ||= ReputationThreshold.action_points(self.action, self.tier)\n end",
"def reputation\n return @reputation\n end",
"def action?\n self.class.rule_type == :action\n end",
"def reputation()\n return MicrosoftGraph::Security::ThreatIntelligence::Hosts::Item::Reputation::ReputationRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def quest_rewarded?(quest_id)\n quest_revealed?(quest_id) && quest(quest_id).status?(:reward)\n end",
"def can_vote_down?\n self.reputation_points >= Reputation::Threshold.vote_down # e.g. 100\n end",
"def allows_reward?\n false\n end",
"def threshold\n @threshold ||= Reputation::Threshold.lookup(self.action, self.sender, :tier => self.tier)\n end",
"def skill?; current_action._?(:item)._?(:is_a?, ::RPG::Skill); end",
"def can?(user, action)\n return false unless @actions.key? action\n user.power_in(@room) >= @actions[action]\n end",
"def action_allowed?(action_name, user)\n return false\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns the threshold points that are defined for certain action either in database or globally | def action_points
@threshold_action_points_cache ||= ReputationThreshold.action_points(self.action, self.tier)
end | [
"def find_reputation_threshold_action_points(action)\n if tp = self.reputation_thresholds.find(:first, \n :conditions => [\"reward_rates.action = ?\", action.to_s])\n tp\n elsif self.parent && (ptp = self.parent.reputation_thresholds.find(:first, \n :conditions => [\"reward_rates.action = ?\", action.to_s]))\n ptp\n end\n end",
"def threshold\n @threshold ||= Reputation::Threshold.lookup(self.action, self.sender, :tier => self.tier)\n end",
"def threshold\n @threshold\n end",
"def collect_thresholds_for(threshold)\n active_thresholds = Array.new()\n threshold.indicators.each_value { |value| \n active_thresholds << value if(value.is_active)\n }\n return active_thresholds\n end",
"def threshold\n @threshold ||= 0\n end",
"def threshold\n @threshold || 95\n end",
"def threshold_spy\n return (user_science_level(defender, spy_id) - user_science_level(attacker, spy_id))*0.05+0.5 \n end",
"def reputation_threshold_action\n raise \"Reputation threshold needs to be defined in reputation_threshold_action method\"\n end",
"def monitor_points\n return @possible_points\n end",
"def subsample_thresholds_required\n SUBSAMPLE_THRESHOLDS.select {|sample| sample < self.points}\n end",
"def threshold(args)\n if args.has_key?(:above)\n\tthresholdData(args[:on], args[:field], args[:above].to_f, \"above\")\n else\n\t# Assume its below\n thresholdData(args[:on], args[:field], args[:below].to_f, \"below\")\n end\n end",
"def get_threshold\n d = self.vspecs.select(:value).where(name: 'threshold').first\n return d != nil ? d.value : d\n end",
"def actual_target_threshold\n [(@params.target_threshold * distance_to_next_pipe * @params.dist_thresh_mult), @params.target_threshold].min\n end",
"def threshold_patser\n\t\t\t\treturn self.threshold_fpr(2 ** -@ic)\n\t\t\tend",
"def get_threshold_params(threshold)\n case threshold\n when 'success'\n name = 'SUCCESS'\n ordinal = 0\n color = 'BLUE'\n when 'unstable'\n name = 'UNSTABLE'\n ordinal = 1\n color = 'YELLOW'\n when 'failure'\n name = 'FAILURE'\n ordinal = 2\n color = 'RED'\n end\n return name, ordinal, color\n end",
"def collect_active_thresholds\n @warnings = Hash.new()\n @warnings[:air_temperature] = collect_thresholds_for(@temperature_threshold)\n @warnings[:wind_speed] = collect_thresholds_for(@wind_threshold)\n @warnings[:rain] = collect_thresholds_for(@rain_threshold)\n nil\n end",
"def get_pass_threshold() @pass_thresh end",
"def patient_score\n @@thresholds.keys.inject(0) do |accu, attribute|\n accu + self.send(\"#{attribute}_score\")\n end\n end",
"def exceeded_thresholds\n session[:merb_threshold_exceeded_thresholds] ||= []\n session[:merb_threshold_exceeded_thresholds] \n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
is a sender assigned? | def sender?
!!self.sender
end | [
"def sender? usr\r\n usr.id == user_id\r\n end",
"def sender? usr\n usr.id == user_id\n end",
"def was_sent_by?(actor)\n (self.sender.class == actor.class) && (self.sender.id == actor.id)\n end",
"def sender?(message)\n if message.sender == id\n true\n else\n false\n end\n end",
"def is_sender?(user_id)\r\n user_id.to_s == self.sender.to_s ? out = true : out = false\r\n return out\r\n end",
"def sender_allowed?\n true\n end",
"def replied?\n receiver.ties_to?(sender)\n end",
"def sender\n @sender ||= participants.detect(&:sender)\n end",
"def copy_sender?(subscriber)\n false\n end",
"def sender_contains\n return @sender_contains\n end",
"def from_admin?\n if self.sender == self.receiver\n true\n else\n false\n end\n end",
"def same_sender?(next_line)\n @sender == next_line.sender\n end",
"def notice_sender\n interpret_target(self.class.sender) if self.class.sender\n end",
"def reflexive?\n sender_id == receiver_id\n end",
"def sender=(value)\n @sender = value\n end",
"def sender_email?\n !self.sender_email.blank?\n end",
"def sender\n return @sender\n end",
"def sender_name\n if self.sender\n self.sender.name\n else\n @sender_name\n end\n end",
"def sender_is_claimant?\n mail.from.first == email_receipt.user.email\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
produces an html href to the faq pages | def link_to_faq(text, options={})
html = "<a"
html += " class=\"#{options[:class]}\"" if options[:class]
html += " href=\"/faq\""
html += ">"
html += text
html += "</a>"
html
end | [
"def link_to(questionnaire)\n \"<a href='/print/%s'>%s</a>\" % ([questionnaire['_id']] * 2)\n end",
"def link_to_faq(title_or_faq, *args)\n if title_or_faq.is_a?(Faq)\n faq = title_or_faq\n title = faq.question\n else\n faq = args.delete(0)\n title = title_or_faq\n end\n\n link_to(title, refinery.faqs_faqs_path(:anchor => dom_id(faq)), *args)\n end",
"def faq_links_section\n $tracer.trace(__method__)\n return ToolTag.new(div.className(\"/faqlinks/\"), __method__, self)\n end",
"def faq\n end",
"def render\n <<-HTML\n <div class=\"relative\">\n <a href=\"#{url}\"class=\"#{position_classes}f6 link dim br2 ph3 pv2 dib white bg-blue\" data-help-link=\"Y\" target=\"cbf-help\">#{Icon.new(:question).render} #{text}</a>\n </div>\n HTML\n end",
"def faq\n render 'faq'\n end",
"def generate_html\n return \"<a href='../#{@reference_location}'>PDF #{@filename}</a>\"\n end",
"def href_template; end",
"def help_link(help_entry_name=nil)\n docs_url = \"https://docs.megam.co/nilavu\"\n\n if help_entry_name\n docs_url += \"/#{help_entry_name}\"\n link_text = \"Help for #{help_entry_name.underscore_humanize}\"\n else\n docs_url += \"/#index\"\n link_text =\"Help\"\n end\n link_to_ link_text, docs_url, { :target => '_blank'}\n end",
"def faq\n respond_to do |format|\n format.html # faq.html.erb\n format.xml { render :xml => nil }\n end\n end",
"def link_to_gfm(body, url, html_options = {})\n gfm_body = gfm(body, html_options)\n\n gfm_body.gsub!(%r{<a.*?>.*?</a>}m) do |match|\n \"</a>#{match}#{link_to(\"\", url, html_options)[0..-5]}\" # \"</a>\".length +1\n end\n\n link_to(gfm_body.html_safe, url, html_options)\n end",
"def faq\n render :action => 'faq'\n end",
"def href (request=nil)\n\n fei.href(request)\n end",
"def help_link(question)\n return nil if question.help_text.blank?\n link_text = question.help_link_text.blank? ? \"Help\" : question.help_link_text\n link_to link_text, \n \t\t\t\tapply_help_url(question.offering, question), \n \t\t\t\t:popup => ['help', 'height=500,width=400,toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=1'],\n \t\t\t\t:class => 'help'\n \t\n end",
"def link_markup(descr = nil)\n descr = \"View resource.\" if descr == nil\n\n link = @reference_action_def.doi\n link = @reference_action_def.link if link.empty?\n return \"<a href=\\\"#{link}\\\" target=\\\"_blank\\\">#{descr}</a>\"\n end",
"def render_acmpdf_link(entry)\n pdflink = ''\n if entry.field?(:acmpdflink)\n pdflink = '<div class=\"pure-button csl-pdf\"><a href=\"' + entry.acmpdflink.to_s + '\">PDF</a></div>'\n end\n\n pdflink\n end",
"def render_acmpdf_link(entry)\n pdflink =\"\"\n if entry.field?(:acmpdflink)\n pdflink = \"<div class=\\\"pure-button csl-pdf\\\"><a href=\\\"\" + entry.acmpdflink.to_s + \"\\\">PDF</a></div>\"\n end\n \n return pdflink\n end",
"def FAQ\r\n \r\nend",
"def generate_link(failure_file_details, file_path)\n \"<strong><a href='xdoclet/#{failure_file_details[0].gsub(/\\//, \"_\").gsub(/\\.rb/, \".rb.html\")}' target='_blank'>#{file_path}</a></strong><br/>\"\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Defines a singleton_method in the receiver. The method parameter can be a Proc or Method object. If a block is specified, it is used as the method body. This block is evaluated using instance_eval. | def define_singleton_method(symbol, method)
# TODO
end | [
"def redefine_singleton_method(method, &block); end",
"def create_method(name, &block)\n singleton_class.send(:define_method, name, &block)\n end",
"def binop_define_singleton_method(name, op, receiver)\n [:method_add_block,\n [:command_call,\n [:var_ref, [:@ident, receiver.to_s]],\n :\".\",\n [:@ident, \"define_singleton_method\"],\n [:args_add_block,\n [[:symbol_literal, [:symbol, [:@ident, name.to_s]]]],\n false]],\n [:block,\n [:block_var,\n [:params,\n [[:@ident, \"x\"], [:@ident, \"y\"]],\n nil,\n nil,\n nil,\n nil],\n nil],\n [[:binary,\n [:var_ref, [:@ident, \"x\"]],\n op,\n [:var_ref, [:@ident, \"y\"]]]]]]\n end",
"def define_and_call_method(method, &block)\n self.class.send(:define_method, method, block)\n send method\n end",
"def idempotently_define_singleton_method(name, &definition); end",
"def binop_define_singleton_method(name, op, receiver)\n s(:iter,\n s(:call, s(:lvar, receiver), :define_singleton_method,\n s(:lit, name)),\n s(:args, :x, :y),\n s(:call, s(:lvar, :x), op, s(:lvar, :y)))\n end",
"def on_method_definition(node)\n scope = definitions\n method = Definition::RubyMethod.new_from_node(\n node,\n :parents => [scope],\n :method_type => call_type,\n :instance_type => :instance\n )\n\n if method.receiver\n existing = scope.lookup(method.receiver.type, method.receiver.name)\n\n if existing\n scope = method.receiver = existing\n else\n return\n end\n end\n\n scope.add(method.method_type, method.name, method)\n\n associate_node_definition(node, method)\n\n @definitions << method\n end",
"def bind(receiver)\n unless Rubinius::Type.object_kind_of? receiver, @defined_in\n if Rubinius::Type.object_kind_of?(@defined_in, Class) and\n Rubinius::Type.singleton_class_object(@defined_in)\n raise TypeError, \"illegal attempt to rebind a singleton method to another object\"\n end\n\n raise TypeError, \"Must be bound to an object of kind #{@defined_in}\"\n end\n\n Method.new receiver, @defined_in, @executable, @name\n end",
"def remove_possible_singleton_method(method)\n singleton_class.instance_eval do\n remove_possible_method(method)\n end\n end",
"def cache_shared_method(symbol, &block)\r\n define_method(symbol, &block)\r\n end",
"def call_symbol_or_block(method, *args)\n if method.is_a?(Symbol)\n send(method, *args)\n elsif method.respond_to?(:call)\n instance_exec(*args, &method)\n end\n end",
"def define_method(name, &blk); @server_class.class_eval { define_method(name, &blk) }; end",
"def define_method sym, &block\n %s(printf \"define_method %s\\n\" (callm (callm sym to_s) __get_raw))\n end",
"def override_singleton_method(instance, klass_name, meth)\n saved_meth_name = get_saved_method_name(meth, 'singleton')\n if instance.respond_to?(saved_meth_name, true)\n Sqreen.log.debug { \"#{saved_meth_name} found #{instance.class}##{instance.object_id} already instrumented\" }\n return nil\n elsif instance.frozen?\n Sqreen.log.debug { \"#{instance.class}##{instance.object_id} is frozen, not reinstrumenting\" }\n return nil\n end\n raise Sqreen::NotImplementedYet, \"#{instance.inspect} doesn't respond to define_singleton_method\" unless instance.respond_to?(:define_singleton_method)\n p = Instrumentation.define_callback_method(meth, saved_meth_name,\n klass_name)\n instance.define_singleton_method(saved_meth_name, instance.method(meth))\n instance.define_singleton_method(meth, p)\n # Hide saved method (its only available in this syntax)\n eval <<-RUBY, binding, __FILE__, __LINE__ + 1\n class << instance\n private :#{saved_meth_name}\n end\n saved_meth_name\n RUBY\n end",
"def create_method( name, &block )\n self.class.send( :define_method, name, &block )\n end",
"def inject_instance_method(method,options={},&block)\n\n unbound_method= self.instance_method(method).clone\n\n self.class_eval do\n undef_method method\n define_method(\n method,\n Proc.new { |*args|\n\n begin\n case options[:add].to_s.downcase[0]\n when \"a\"\n unbound_method.bind(self).call(*args)\n block.call_with_binding(self.binding?,*args)\n\n else\n block.call_with_binding(self.binding?,*args)\n unbound_method.bind(self).call(*args)\n end\n end\n\n }\n )\n end\n\n end",
"def redefine_method(method, &block); end",
"def register_method(method, &block)\n self.class.register_method(method, &block)\n end",
"def add_shared_method(symbol, &block)\r\n @dictionary.delete(symbol)\r\n purge_shared_method(symbol)\r\n @dictionary[symbol] = block\r\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Edit a particular Address in the database | def edit_address(edited_address)
address = Address.find(edited_address.uid)
address.attributes = edited_address.attributes
address.save!
end | [
"def edit\r\n @address = Address.find(params[:id])\r\n end",
"def edit\n\t\t@address = current_user.addresses.find(params[:id])\n\tend",
"def edit\n\t@address=Address.new\n\t@address=Address.find(params[:id])\nend",
"def update\n @address = @addressable.addresses.find_by_id(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to current_user, notice: 'address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_address(order_or_user, address_id, expect_success, values, type=nil)\n visit_edit_address(order_or_user, address_id)\n fill_in_address(values, type)\n click_button Spree.t('actions.update')\n\n if expect_success\n expect_address_collection_path(order_or_user)\n expect(page).to have_content(Spree.t(:successfully_updated, resource: Spree::Address.model_name.human))\n else\n expect(page).to have_no_content(Spree.t(:successfully_updated, resource: Spree::Address.model_name.human))\n expect(path_with_query).to eq(spree.admin_address_path(address_id, user_id: @user_id, order_id: @order_id))\n end\n end",
"def edit_address\n traveller = Traveller.find(params[:pk])\n address = params[:value]\n\n coordinates = GoogleAPIGeocoder.do_geocode(address)\n\n if coordinates.nil?\n render json: {success: false, msg: 'Unable to find the location of the given address. Please check that it is correct.'}\n else\n traveller.update(address: address, latitude: coordinates[0], longitude: coordinates[1])\n\n if current_user.nil?\n if session[:trip] != nil\n travellers = session[:trip].travellers\n travellers[travellers.index(traveller)].address = params[:value]\n end\n\n if session[:travellers] != nil\n session[:travellers][session[:travellers].index(traveller)].address = params[:value]\n end\n end\n\n render json: {success: true}\n end\n end",
"def update_address\n @address = Spree::Address.where(id: params[:address][:id]).first\n @address.update_attributes(address_params_list) if @address.present?\n @user = current_user\n end",
"def update\n @address = current_user.addresses.find(params[:id])\n\n respond_to do |format|\n if @address.update_attributes(params[:address])\n format.html { redirect_to user_address_path(current_user, @address), notice: 'Address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_address(new_address)\r\n update(address: new_address)\r\n end",
"def set_address(new_address)\n update(address: new_address)\n end",
"def update_address\n @account = Account.new\n @account.address = populate_address_data\n if address_search?\n perform_address_search\n elsif @account.update_address(address_params, current_user, address_validation_contexts)\n redirect_to account_path\n else\n render('edit_address', status: :unprocessable_entity)\n end\n end",
"def update_address(id, params)\n put(\"addresses/#{id}\", address: params, change_case: false)\n end",
"def update\n self.class.update_address_by_id(self.id, self)\n end",
"def update\n authorize! :save_in_address_book, address_book_user\n\n address_params = address_book_params\n default_flag = address_params.delete(:default)\n @address = address_book_user.save_in_address_book(address_params, default_flag)\n if @address.valid?\n render :show, status: :ok\n else\n invalid_resource!(@address)\n end\n end",
"def update\n @user_address = UserAddress.find(params[:id])\n\n respond_to do |format|\n if @user_address.update_attributes(params[:user_address])\n format.html { redirect_to(@user_address, :notice => 'User address was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @user_address.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @taddress = Taddress.find(params[:id])\n \n respond_to do |format|\n if @taddress.update_attributes(params[:taddress])\n format.html { redirect_to @taddress, notice: 'Taddress was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @taddress.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @blog_address = BlogAddress.find(params[:id])\n\n respond_to do |format|\n if @blog_address.update_attributes(params[:blog_address])\n format.html { redirect_to @blog_address, notice: 'Blog address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @blog_address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @address.update(address_params)\n format.html { redirect_to @address, notice: 'Address was successfully updated.' }\n format.json { render :show, status: :ok, location: api_v1_addresses_url(@address) }\n else\n format.html { render :edit }\n format.json { render json: @address.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @descriptive_address = DescriptiveAddress.find(params[:id])\n\n respond_to do |format|\n if @descriptive_address.update_attributes(params[:descriptive_address])\n format.html { redirect_to @descriptive_address, notice: 'Descriptive address was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @descriptive_address.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Delete a particular Address from the database | def delete_address(address)
address.delete!
end | [
"def delete\n @address = Address.find(params[:address_id])\n end",
"def delete_address(id)\n delete(\"addresses/#{id}\")\n end",
"def delete\n self.class.delete_address_by_id(self.id)\n end",
"def delete_address(application_id, address_id)\n address_to_delete = address(application_id, address_id)\n\n @tropo_client.delete(\"applications/#{application_id.to_s}/addresses/#{address_to_delete['type']}/#{address_id.to_s}\")\n end",
"def destroy\n @address = @user.addresses.find(params[:id])\n if @address.destroy\n return_message(200, :ok)\n else\n return_message(200, :fail, {:err => format_errors(@address.errors.messages)})\n end\n end",
"def destroy\n puts \"try to delete address... current_user.id:#{current_user.id}\"\n @customer = User.find_by(id: params[:id])\n address = @customer.addresses.find_by(id: params[:format])\n address.deleted = true\n address.save!\n puts \"Successfully!\"\n redirect_to edit_my_addresses_path(@customer)\n end",
"def delete\n @carddav_backend.delete_address_book(@address_book_info['id'])\n end",
"def delete_address_book(address_book_id)\n ds = @sequel[\"DELETE FROM #{@cards_table_name} WHERE addressbookid = ?\", address_book_id]\n ds.delete\n\n ds = @sequel[\"DELETE FROM #{@address_books_table_name} WHERE id = ?\", address_book_id]\n ds.delete\n\n ds = @sequel[\"DELETE FROM #{@address_book_changes_table_name} WHERE id = ?\", address_book_id]\n ds.delete\n end",
"def delete_address\n @mailing_list_address.destroy if @ok\n render 'update_addresses'\n end",
"def delete\n\n address_id = params[:address_id]\n if @address = Address.find_by(id: address_id)\n\n if @address.is_primary?\n flash[:danger] = \"Unable to delete default shipping address.\"\n else\n @address.update_columns(is_visible: false)\n flash[:success] = \"Successfully deleted address.\"\n end\n redirect_to checkout_addresses_path\n else\n flash[:danger] = \"Unable to set address.\"\n redirect_to checkout_addresses_path\n end\n\n \tend",
"def delete_by_id(id)\n delete_address_by_id(id)\n end",
"def remove_bill_address\n @address = BillAddress.find(params[:address_id])\n @address.destroy\n redirect_to session[:check_out_url]\n end",
"def delete_address_book(address_book_id)\n end",
"def destroy\n @customer = User.find_by(id: params[:customer_id])\n address = @customer.addresses.find_by(id: params[:id])\n address.deleted = true\n address.save!\n #redirect_to customer_addresses_path(@customer)\n end",
"def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to(addresses_url) }\n format.xml { head :ok }\n end\n end",
"def destroy_by_body\n @address = Adress.find(address_delete_param[:id])\n id = @paddressid\n\n if @address.destroy\n render json: { status: 'DELETE Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error to delete a Address', errors: @address.errors }, status: :unprocessable_entity\n end\n end",
"def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to(:action=>'index') }\n format.xml { head :ok }\n end\n end",
"def destroy\n @address = Address.find(params[:id])\n @address.destroy\n\n respond_to do |format|\n format.html { redirect_to addresses_url }\n format.json { head :no_content }\n end\n end",
"def delete_address(order_or_user, address_id, expect_success)\n address_id = address_id.id if address_id.is_a?(Spree::Address)\n\n visit_addresses(order_or_user)\n\n click_link \"delete-address-#{address_id}\"\n\n if expect_success\n expect(page).to have_content(Spree.t(:successfully_removed, resource: Spree::Address.model_name.human))\n else\n expect(page).to have_no_content(Spree.t(:successfully_removed, resource: Spree::Address.model_name.human))\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Cleanse Address through third party service using SOA pattern (psuedocode) | def cleanse_address(address)
cleansed_address = SOAAddressCleanser.cleanse_address(address)
cleansed_address.save!
end | [
"def normalize_address address\n funcs = [\n :remove_whitespaces,\n :full_to_half,\n :kansuuji,\n :separator,\n :remove_ignore_symbol,\n :remove_parenthesis,\n :remove_japan_prefix,\n :remove_zip_code,\n :remove_choume,\n :normalize_floor,\n :remove_building_name,\n :remove_nearly\n ]\n funcs.each do |func|\n address = send(func, address)\n end\n address\n end",
"def normalize_address opts={}\n\t\t\tserver_url = \"http://b2b.correos.cl:8008/ServicioNormalizacionExterno/cch/ws/distribucionGeografica/externo/implementacion/ServicioExternoNormalizacion.asmx\"\n\t\t\t# default values\n\t\t\topts[:request_id] ||= rand(10000)\n\n\t\t\t# check params\n\t\t\tCityboxApi.check_params [:full_address, :commune], opts\n\n\t\t\txml = \"<?xml version='1.0' encoding='utf-8'?>\n\t\t\t\t\t<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>\n\t\t\t\t\t <soap:Body>\n\t\t\t\t\t <normalizarDireccion xmlns='http://tempuri.org/'>\n\t\t\t\t\t <usuario>#{@user}</usuario>\n\t\t\t\t\t <contrasena>#{@password}</contrasena>\n\t\t\t\t\t <id>#{opts[:request_id]}</id>\n\t\t\t\t\t <direccion>#{opts[:full_address]}</direccion>\n\t\t\t\t\t <comuna>#{opts[:commune]}</comuna>\n\t\t\t\t\t </normalizarDireccion>\n\t\t\t\t\t </soap:Body>\n\t\t\t\t\t</soap:Envelope>\"\n\n\t\t\tbegin\n\t\t\t\txml_response = RestClient.post server_url, xml, content_type: \"text/xml\"\n\t\t\t\tjson_response = Crack::XML.parse(xml_response)\n\t\t\t\tjson_response[\"soap:Envelope\"][\"soap:Body\"][\"normalizarDireccionResponse\"][\"normalizarDireccionResult\"]\n\t\t\trescue => error\n\t\t\t\treturn CityboxApi.catch_error(error)\n\t\t\tend\n\t\tend",
"def to_intraddress(q)\n #Split Address Line 1 and 2 into arrays\n addressline1Arr = q.addressline1 == nil ? [\"\"] : q.addressline1.split(\",\")\n addressline2Arr = q.addressline2 == nil ? [\"\"] : q.addressline2.split(\",\")\n\n \n #check for organisation first\n if q.isorganisation then \n self.organisation = addressline1Arr[0] \n addressline1Arr.delete_at(0)\n self.streetname = extract_street_name(addressline2Arr.last) \n self.propertyno = extract_prop_no(addressline2Arr.first) \n \n addressline2Arr[addressline2Arr.length - 1] = addressline2Arr.last.delete(self.streetname).strip\n addressline2Arr[0] = addressline2Arr.first.delete(self.propertyno).strip\n\n addressline2Arr.delete_if { |x| x.length == 0}\n\n else\n if is_propno_present(addressline1Arr[0]) then \n extract_prop_no_street(addressline1Arr[0]) \n addressline1Arr.delete_at(0)\n elsif is_propno_present(addressline2Arr[0]) then \n extract_prop_no_street(addressline2Arr[0]) \n addressline2Arr.delete_at(0)\n else\n if addressline1Arr[0].match(/Flat/) then\n self.streetname = addressline2Arr[0]\n addressline2Arr.delete_at(0)\n else\n if addressline1Arr.length > 1 then\n self.streetname = addressline1Arr[1]\n addressline1Arr.delete_at(1)\n else\n self.streetname = addressline2Arr[0]\n addressline2Arr.delete_at(0)\n end\n end\n end\n end\n #Address Line 3 Sweep up, gather all the remaining data left and\n #put into address line 3\n self.addressline3 = addressline1Arr.concat(addressline2Arr).join(\",\")\n self.postcode = q.postcode\n self.town = q.town\n \n end",
"def fix(address)\n @address = address\n end",
"def normalize_address(address)\n normalize(address).split(' ').map { |word| StreetAbbrevs[word] || word }.join(' ')\n end",
"def simple_addresses(postcode, house_number = nil, options = {})\n content = addresses(postcode, house_number, options)\n\n return content if content.error\n simplify(content)\n end",
"def request_saas_for_new_address\n\n r = SaasApi::WalletAddress::Generate.new.perform\n return r unless r.success?\n\n @new_known_address = r.data[:address].downcase\n @known_address_id = r.data[:known_address_id]\n\n\n success\n end",
"def remove_trusted_address\n super\n end",
"def normalize_address(address)\n # Remove leading zeros from the address\n address = address.to_i(16).to_s(16)\n CB::Ethereum::Util.sanitize_address(address)\n end",
"def addShippingAddress(subscriptionId, result)\n \n passThru = result.hosted_page.pass_thru_content\n shippingAddress = JSON.parse(passThru) \n ChargeBee::Address.update({\n :label => \"Shipping Address\",\n :subscription_id => subscriptionId,\n :addr => shippingAddress.fetch(\"address\"),\n :extended_addr => shippingAddress.fetch(\"extended_addr\"),\n :city => shippingAddress.fetch(\"city\"),\n :state => shippingAddress.fetch(\"state\"),\n :zip => shippingAddress.fetch(\"zip_code\")\n })\n \n end",
"def street_services=(_arg0); end",
"def full_street_address\n postcode_only_address\n end",
"def set_for_postcode_search\n @show_manual_address = false\n @address_read_only = false\n @address_summary.postcode = ''\n @address_detail = Address.new(default_country: params[:address][:default_country])\n end",
"def cleanup\n self.value.strip!\n if is_phone? && get_area_code(value).blank? && !international? \n self.value = add_area_code(get_area_code(source.mobile_number),value)\n end\n end",
"def remove_address\r\n return self if @adresse.nil?\r\n\r\n @adresse.remove_partner(self)\r\n @adresse = nil\r\n self\r\n end",
"def secondary_address; end",
"def prune_address\n address = (@address.select { |_k, v| v }).to_h\n address[:country] = address[:country][:alpha2]\n @street = address.delete(:street)\n\n address.delete(:postal_code) if @level > 4\n address.delete(:city) if ([3, 4, 7] & [@level]).any?\n address.delete(:state) if @level == 4\n address\n end",
"def prepare_address(address_from_form)\n #delete http:// and www\t\n \ttemp_string = address_from_form.sub(\"https://\", \"\").sub(\"http://\", \"\").sub(\"www.\", \"\")\n #check if there is a slash in the end\n \tif temp_string.last == '/' or temp_string.last == '\\\\'\n \t string = temp_string.sub(temp_string.last, \"\") #delete slash (last char)\t\n \telse #there was no slash in the end so return temp_string\n \t string = temp_string\t\n \tend\n \treturn string\n end",
"def delete_address(address)\n address.delete!\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Validate zipcode through third party service using SOA pattern (psuedocode) | def validate_zip(address)
return SOAZipValidator(address.city, address.zipcode)
end | [
"def zipvalidate(postcode)\n !!postcode.match(/\\A[1-46][\\d]{5}\\z/)\nend",
"def zip_code\n @zip_code || (@address_line3 if @address_line3 =~ /(?i)^[a-z0-9][a-z0-9\\- ]{0,10}[a-z0-9]$/)\n end",
"def validation_of_zip_code(code)\n\n # check type\n for str in code.chars\n if !/\\A\\d+\\z/.match(code)\n return false\n end \n end\n\n # check length\n if code.length == 5\n return true\n else\n return false\n end\nend",
"def zipCodeCheck(zip)\n\t\tuntil (zipValidate(zipInputConvert(zip)) == true)\n\t\t\tzip = zipRe()\n\t\tend\n\t\treturn zip\n\tend",
"def test_IsValid_002_ZipCode\n\n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_IsValid_002_ZipCode\")\n puts2(\"#######################\")\n\n #$VERBOSE=true\n\n # Define an array of zip codes to try\n aZipCodes = [ \"80021\", \"12345\", \"123456\", \"1\", \"1234\", \"12345-1234\", \"12345-123\", \"00000\" ]\n\n # Loop\n aZipCodes.each do | sZipCode |\n\n puts2(\"\\nZip Code = \" + sZipCode.to_s)\n if(sZipCode.isValid_ZipCode?) # Check validity\n puts2(\"Valid\")\n else\n puts2(\"Invalid\")\n end # Check validity\n end # Loop\n\n end",
"def is_zipcode?(address_or_zipcode)\n\t\t/\\d{5}(-| )\\d{4}$|^\\d{5}$/.match(address_or_zipcode) != nil\n\tend",
"def match_zip(code)\n regexp = Regexp.new('^(\\s*\\d{5}(?:[-]\\d{4})?\\s*)$')\n match = regexp.match(code)\n match ? match[0] : nil\n end",
"def validates_zip_code_according_to_publisher(*config)\n validates_each(:zip_code, *config) do |model, attr, zip|\n if zip.present?\n valid = false\n if model.publisher\n model.publisher.country_codes.each do |country_code|\n regex = postal_code_regex(country_code)\n if regex.present?\n valid = true if regex =~ zip\n else\n # valid if there's no validation regex\n valid = true\n end\n end\n else\n valid = true\n end\n unless valid\n model.errors.add(attr, I18n.t(\"activerecord.errors.messages.invalid\"))\n end\n end\n end\n end",
"def match_postal_code(postal_code)\n /\\A\\s*(?<fsa>[a-zA-Z]\\d[a-zA-Z])\\s*(?<ldu>\\d[a-zA-Z]\\d)\\s*\\z/\n .match(postal_code)\n end",
"def zip_code_entered?\n zip_code.present?\n end",
"def valid_pincode\n response = Net::HTTP.get(pincode_verification_url)\n data = JSON.parse(response)\n fields = data['records']\n errors.add(:pincode, 'not a valid pincode') if fields.blank?\n end",
"def validates_zip_code(*config)\n validates_each(:zip_code, *config) do |model, attr, zip|\n if zip.present?\n regex = postal_code_regex(model.country_code)\n if regex.present?\n unless regex =~ zip\n model.errors.add(attr, I18n.t(\"activerecord.errors.messages.invalid\"))\n end\n end\n end\n end\n end",
"def enter_zip_code\n #binding.pry\n @valid_zip_code = false\n until @valid_zip_code == true\n puts \"Please enter your zip code.\"\n @zipcode = gets.strip\n @check_zip_code = @zipcode.split(\"\")\n #binding.pry\n if @check_zip_code.all? {|digit| @@valid_numbers.include?(digit)} && @zipcode.length == 5\n @valid_zip_code = true \n else\n puts \"#{@@mag}Invalid zip code. Please try again.#{@@white}\"\n next\n end\n end\n end",
"def zip_code_valid?(zip_to_check)\n VALID_US_ZIP_CODES.include?(zip_to_check)\n end",
"def match_zip_or_postcode(code)\n match_zip(code) || match_postcode(code)\n end",
"def fix_up_zip_code(zip)\n return nil unless zip.present?\n return nil if (zip =~ /\\A(\\d{5})/).nil?\n $1\n end",
"def is_valid_zip(zip)\n\n pattern = /\\A[0-9]{5}(-[0-9]{4})?/\n return !pattern.match(zip).nil?\n\nend",
"def check_match_zip_code?\n parse_header = @page.search(\".//h1[@class='list-results-header']//strong\")\n return false if !parse_header.present?\n content_header = parse_header.text&.downcase&.squish\n return nil if !content_header.present?\n content_header.include?(@raw_zip_code) ? true : false\n end",
"def test_identify_ca_postcode\n search_check \"A1B 2C3\", %w[ca_postcode osm_nominatim]\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Nathan Tests def run_tests root = BinaryTreeNode.new(50) left = root.insert_left(30) right = root.insert_right(80) left_left = left.insert_left(20) left_right = left.insert_right(40) right_left = right.insert_left(70) right_right = right.insert_right(90) assert_true(root) root = BinaryTreeNode.new(50) left = root.insert_left(30) right = root.insert_right(80) left_left = left.insert_left(20) left_right = left.insert_right(60) right_left = right.insert_left(70) right_right = right.insert_right(90) assert_false(root) end def assert_true(value) p binary_search_tree?(value) ? "Pass" : "Fail" end def assert_false(value) p binary_search_tree?(value) ? "Fail" : "Pass" end run_tests Interview Cake Tests | def run_tests
desc = 'valid full tree'
tree = BinaryTreeNode.new(50)
left = tree.insert_left(30)
right = tree.insert_right(70)
left.insert_left(10)
left.insert_right(40)
right.insert_left(60)
right.insert_right(80)
result = binary_search_tree?(tree)
assert_true(result, desc)
desc = 'both subtrees valid'
tree = BinaryTreeNode.new(50)
left = tree.insert_left(30)
right = tree.insert_right(80)
left.insert_left(20)
left.insert_right(60)
right.insert_left(70)
right.insert_right(90)
result = binary_search_tree?(tree)
assert_false(result, desc)
desc = 'descending linked list'
tree = BinaryTreeNode.new(50)
left = tree.insert_left(40)
left_left = left.insert_left(30)
left_left_left = left_left.insert_left(20)
left_left_left.insert_left(10)
result = binary_search_tree?(tree)
assert_true(result, desc)
desc = 'out of order linked list'
tree = BinaryTreeNode.new(50)
right = tree.insert_right(70)
right_right = right.insert_right(60)
right_right.insert_right(80)
result = binary_search_tree?(tree)
assert_false(result, desc)
desc = 'one node tree'
tree = BinaryTreeNode.new(50)
result = binary_search_tree?(tree)
assert_true(result, desc)
end | [
"def test_it_can_have_nodes_inserted\n # tree = create_binary_search_tree(4)\n tree = Bst.new(10)\n tree.insert(11)\n tree.insert(5)\n binding.pry\n \n \n assert_instance_of Node, tree.root_node\n end",
"def test_make_root_node\n tree = BinarySearchTree.new\n tree.insert(61, \"Bill & Ted's Excellent Adventure\")\n\n assert_equal nil, tree.root.left\n assert_equal nil, tree.root.right\n assert_equal 61, tree.root.score\n assert_equal \"Bill & Ted's Excellent Adventure\", tree.root.title\n end",
"def test_tree_starts_empty\n tree = BinarySearchTree.new\n assert_nil tree.root\n end",
"def test_insert_root_node_returns_depth\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n assert_equal 0, tree.root.depth\n end",
"def test_load_returns_number_of_movies_inserted\n tree = BinarySearchTree.new\n assert_equal 99, tree.load('./data/movies.txt')\n end",
"def test_left_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@left_child1, @root.left_child, \"The left child should be 'left_child1\")\n assert_not_same(@right_child1, @root.left_child, \"The right_child1 is not the left child\")\n end",
"def test_new_tree_empty_root\n assert_equal nil, @tree.root\n end",
"def test_initialize\n assert_not_nil(@root, \"Binary tree's Root should have been created\")\n assert_nil(@root.left_child, \"The initial left child of root should be nil\")\n assert_nil(@root.right_child, \"The initial right child of root should be nil\")\n assert_equal(@root.children.size, 0, \"Initially no children should be present\")\n end",
"def test_insert_second_node_returns_depth\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n movie_b = tree.insert(40, \"movie b\")\n assert_equal 1, tree.root.left_node.depth\n end",
"def test_each_leaf\n setup_test_tree\n\n nodes = []\n @root.each_leaf { |node| nodes << node }\n\n assert_equal(3, nodes.length, \"Should have THREE LEAF NODES\")\n assert(!nodes.include?(@root), \"Should not have root\")\n assert(nodes.include?(@child1), \"Should have child 1\")\n assert(nodes.include?(@child2), \"Should have child 2\")\n assert(!nodes.include?(@child3), \"Should not have child 3\")\n assert(nodes.include?(@child4), \"Should have child 4\")\n end",
"def test_print_tree\n setup_test_tree\n #puts\n #@root.print_tree\n end",
"def test_leaves_works\n tree = BinarySearchTree.new\n tree.insert(50, \"movie a\")\n tree.insert(40, \"movie b\")\n tree.insert(60, \"movie c\")\n tree.insert(45, \"movie d\")\n tree.insert(20, \"movie e\")\n tree.insert(55, \"movie f\")\n tree.insert(80, \"movie g\")\n assert_equal 4, tree.leaves\n end",
"def test_right_child\n @root << @left_child1\n @root << @right_child1\n assert_same(@right_child1, @root.right_child, \"The right child should be 'right_child1\")\n assert_not_same(@left_child1, @root.right_child, \"The left_child1 is not the left child\")\n end",
"def test_insert_returns_depth_0_if_just_root\n return_value = @tree.insert(\"a\")\n assert_equal 0, return_value\n end",
"def test_insert_returns_1_when_2_nodes_added\n @tree.insert(\"b\")\n return_value = @tree.insert(\"a\")\n assert_equal 1, return_value\n end",
"def test_bfs(tree, data, expect_msg)\n puts \"------------------------------------------------------------\"\n puts \"------------------------------------------------------------\"\n puts \"\\nBreadth-first-search (with debug) for '#{data}':\"\n puts \"\\nExpected: #{expect_msg}\\n \"\n node = tree.breadth_first_search_with_debug(data)\n if node.nil?\n puts \"\\nNode Returned: nil\"\n else\n puts \"\\nNode found:\"\n node.show_stats\n end\n version_match = true if tree.breadth_first_search(data) == node\n puts \"\\nMethod's debug version matches non-debug version: #{version_match.to_s}\"\n puts \"\\nEnd of Test...\"\n puts \"------------------------------------------------------------\"\nend",
"def test_attrs\n #test BinTree attr\n tree = BinTree.new\n test_val = tree.root\n assert test_val == nil\n\n #test TreeNode value\n test_node = TreeNode.new(18)\n test_val = test_node.value\n assert_equal(test_val, 18)\n\n #test TreeNode left set value and read value\n test_left = TreeNode.new(1)\n test_node.left = test_left\n assert_equal(test_left, test_node.left)\n\n #test TreeNode right set value and read value\n test_right = TreeNode.new(23)\n test_node.right = test_right\n assert_equal(test_right, test_node.right)\n end",
"def test_insert_node_to_left_of_root\n @tree.insert(\"b\")\n @tree.insert(\"a\")\n refute_equal nil, @tree.root.left\n end",
"def test(params)\n require 'test/unit'\n params_desc = {\n :root => { :mandatory => false, :type => :string,\n :default => '.' },\n :includes => { :mandatory => true, :type => :string },\n :excludes => { :mandatory => false, :type => :string },\n :dotmatch => { :mandatory => false, :type => :boolean,\n :default => false },\n :dir => { :mandatory => false, :type => :string,\n :default => '.' }\n }\n check_parameters(params, params_desc)\n root = params[:root]\n includes = params[:includes]\n excludes = params[:excludes]\n dotmatch = params[:dotmatch]\n dir = params[:dir]\n error \"Test directory '#{dir}' not found\" if \n not (File.exists?(dir) and File.directory?(dir))\n files = filter_files(root, includes, excludes, dotmatch)\n files.map! { |file| File.expand_path(File.join(root, file)) }\n size = (files.kind_of?(Array) ? files.size : 1)\n puts \"Running #{size} unit test(s)\"\n for file in files\n load file\n end\n old_dir = Dir.pwd\n begin\n Dir.chdir(dir)\n if Bee::VersionDependant::ruby_lower_than('1.9.2')\n runner = Test::Unit::AutoRunner.new(false)\n else\n runner = MiniTest::Unit.new()\n end\n ok = runner.run\n error \"Test failure\" if not ok\n ensure\n Dir.chdir(old_dir)\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=> Delete customer from db | def delete()
sql = "DELETE from customers WHERE id = $1"
values = [@id]
SqlRunner.run(sql, values)
# => Deleting customer record, nothing to return
end | [
"def delete_a_customer\n @customer.delete\n end",
"def delete\n appctrl_delete( 'Customer' )\n end",
"def delete_customer\n Stripe::Customer.delete(\n @user,\n )\n end",
"def delete_customer(options = {})\n requires! options, :customer_number\n\n request = build_request(__method__, options)\n commit(__method__, request)\n end",
"def delete\n\t DB.exec(\"DELETE FROM clients WHERE id=#{self.id.to_i};\")\n\tend",
"def destroy\n @rcadmin_customer.destroy\n respond_to do |format|\n flash[:notice] = 'Customer was successfully deleted.'\n format.html { redirect_to rcadmin_customers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n begin\n amc_customer = Customer.find(params[:id])\n amc_customer.destroy\n rescue\n end\n redirect_to customer_show_amc_path\n end",
"def delete(params = {})\n req = WebPay::CustomerIdRequest.create(params)\n raw_response = @client._request(:delete, 'customers' + '/' + req.id.to_s, req)\n WebPay::CustomerResponse.new(raw_response)\n end",
"def destroy\n @customer_db.destroy\n respond_to do |format|\n format.html { redirect_to customer_dbs_url, notice: 'Customer db was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @customer = User.find_by(id: params[:customer_id])\n address = @customer.addresses.find_by(id: params[:id])\n address.deleted = true\n address.save!\n #redirect_to customer_addresses_path(@customer)\n end",
"def delete(customer)\n xml = customer.to_delete_xml\n response = do_http_post(url_for_resource(\"customer\"), xml)\n if response.code.to_i == 200\n path_to_node = \"//xmlns:RestResponse/xmlns:Success\"\n Quickeebooks::Windows::Model::Customer.from_xml_ns(response.body, path_to_node)\n else\n nil\n end \n end",
"def destroy\n\n @customer = Customer.find(params[:id])\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to(customers_url) }\n format.xml { customers :ok }\n end\n end",
"def destroy\n @admin_customer.destroy\n respond_to do |format|\n format.html { redirect_to admin_customers_url, notice: \"Customer was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n response = client.execute_request('customer.delete', {\n data: {\n customer_id: self.customer_id\n }\n })\n\n if response.success? && response.fetch('status') == 'success'\n @errors = []\n return true\n end\n\n @errors = response.errors\n return false\n end",
"def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to customers_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to(customers_url) }\n format.json { head :ok }\n end\n end",
"def destroy\n @customer_app.destroy\n end",
"def destroy\n get_customer\n @customer_phone = @customer.phones.find(params[:id])\n @customer_phone.destroy\n end",
"def destroy\n @customer = Customer.find(params[:id])\n @customer.destroy\n\n respond_to do |format|\n format.html { redirect_to(customers_url) }\n format.xml { head :ok }\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
=> Display all the films a particular customer has bought ticket for | def films()
sql = "SELECT films.* FROM films INNER JOIN tickets ON tickets.film_id = films.id WHERE customer_id = $1"
values = [@id]
film_data = SqlRunner.run(sql, values)
return Film.map_items(film_data)
end | [
"def films_for_customer()\n sql = \"SELECT films.* FROM films\n INNER JOIN tickets ON films.id = tickets.film_id\n WHERE customer_id = $1\"\n values = [@id]\n film_data = SqlRunner.run(sql, values)\n return Film.map_items(film_data)\n end",
"def customers_for_film()\n sql = \"SELECT name FROM customers\n INNER JOIN tickets ON customers.id = tickets.customer_id\n WHERE film_id = $1 ORDER BY name\"\n values = [@id]\n customer_data = SqlRunner.run(sql, values)\n return Customer.map_items(customer_data)\n end",
"def find_films_for_each_customer()\n sql = \"SELECT films.*\n FROM films\n INNER JOIN tickets\n ON tickets.film_id = films.id\n WHERE customer_id = $1\"\n values = [@id]\n films = SqlRunner.run(sql, values)\n result = films.map {|film| Film.new(film)}\n return result\n end",
"def return_screenings_for_films_ticket()\n sql = \"SELECT screenings.* FROM screenings\n \tINNER JOIN films\n \tON films.id = screenings.film_id\n \tINNER JOIN tickets\n \tON films.id = tickets.film_id\n \tINNER JOIN customers\n \tON customers.id = tickets.customer_id\n \tWHERE customers.id = $1;\"\n values = [@id]\n screen_hashs = SqlRunner.run(sql, values)\n screenings = screen_hashs.map { |screening| Screening.new(screening) }\n return screenings\n end",
"def count_customers_for_film()\n sql = \"SELECT tickets.* FROM tickets\n INNER JOIN films\n ON tickets.film_id = films.id\n WHERE films.id = $1\"\n values = [@id]\n tickets = SqlRunner.run(sql, values)\n number_of_tickets = tickets.count\n return number_of_tickets\n end",
"def customers_booked\n sql = \"SELECT customers.* FROM customers\n INNER JOIN tickets ON customers.id = tickets.customer_id\n WHERE film_id = $1\"\n values = [@id]\n result = SqlRunner.run(sql,values)\n return result.map{ |customer| Customer.new(customer)}\n end",
"def films_per_customer\n films_booked = film()\n films_booked.each {|film_booked| @counter += 1}\n return @counter\n end",
"def tickets()\n sql = \"SELECT * FROM tickets WHERE customer_id = #{id}\"\n return Customer.map_items(sql)\n end",
"def buy_film_ticket(film, screening)\n # Checks if seat available, if so creates ticket, reduces customer's wallet by\n # price of film and returns new ticket.\n\n # #screening = Screening.find_screening(film.id, date, time)\n\n available_seats = screening.check_available_seats()\n\n if available_seats == 0\n return nil\n end\n\n new_ticket = Ticket.new({'customer_id' => @id, 'film_id' => film.id,\n 'screening_id' => screening.id})\n\n new_ticket.save()\n\n #update tickets sold by 1\n\n screening.increase_tickets_sold()\n\n @funds -= film.price\n\n update()\n\n return new_ticket\n end",
"def booked_customers()\n sql = \"SELECT customers.* FROM customers\n INNER JOIN tickets\n \tON customers.id = tickets.customer_id\n INNER JOIN screenings\n \tON tickets.screening_id = screenings.id\n WHERE screenings.film_id = $1\n ORDER BY customers.id;\"\n values = [@id]\n result = SqlRunner.run(sql, values) # array of hashes.\n booked_customers = result.map { |customer| Customer.new(customer) }\n return booked_customers\n end",
"def screenings_of film\n film_name = (film.is_a?(OdeonUk::Film) ? film.name : film)\n screenings.select { |s| s.film_name == film_name }\n end",
"def favorites \n\t\t\tcustomer = Customer.find(params[:customer_id])\n\t\t\t@favorites = customer.favorites\n\t\tend",
"def buy_ticket(film_id)\n sql = \"SELECT price FROM films\n INNER JOIN tickets ON tickets.film_id = $1\n WHERE tickets.customer_id = $2\"\n values = [film_id, @id]\n price = SqlRunner.run(sql, values).first()['price'].to_i()\n p price\n @funds -= price if @funds >= price\n update()\n end",
"def index\n @customer_matters = CustomerMatter.all\n end",
"def buy(film)\n if @funds >= film.film_price\n bought_ticket = Ticket.new({ 'customer_id' => @id, 'film_id' => film.id})\n bought_ticket.save\n @funds -= film.film_price\n update\n end\n return \"insufficient funds, ask your mate for a loan\"\n end",
"def index\n @filmmakers = Filmmaker.all\n end",
"def list_customers_by_product\n\t\ttransactions = Transaction.find_transactions_by_object(self)\n\t\tunless transactions.nil?\n\t\t\tputs \"--------------------------------------------------------------------\"\n\t\t\tputs \"Customers who bought #{@title} | Price | Date\"\n\t\t\tputs \"--------------------------------------------------------------------\"\n\t\t\ttransactions.each do |transaction|\n\t\t\t\tputs \"#{transaction.customer.name} | #{transaction.product.price} | #{transaction.date}\"\n\t\t\tend\n\t\t\tputs \"\"\n\t\tend\n\tend",
"def buy_tickets\n tally = films().map {|ticket| ticket.price.to_f}\n tally.each {|price| @wallet -= price}\n num_of_tickets\n screenings = tickets().map{|ticket| ticket.screening}\n screenings_flat = screenings.flatten\n screenings_flat.map {|screening| screening.tickets_available -= 1}\n screenings_flat.each {|screening| p screening.update }\n update()\n end",
"def customer\n @@all.select {|review| self.restaurant.customers}\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given an account type, set the account_params_key. | def account_params_key
@account_params_key ||= Account.config.account_type_to_param(account_type)
end | [
"def register_account_type_params\n if params[:account][:account_type]\n params.require(:account).require(:account_type).permit(AccountType.attribute_list)\n else\n {}\n end\n end",
"def set_account_type\n @account_type = account.class.to_s\n end",
"def account_type_to_param(account_type)\n account_type.to_s.underscore.tr(\"/\", \"_\")\n end",
"def setaccount( bitcoinaddress, account )\n {\n method: :setaccount,\n params:[bitcoinaddress, account]\n }\n end",
"def set_account\n unless self.role_before_type_cast == 0\n key = Eth::Key.new\n data = SecureRandom.alphanumeric(8)\n unique_id = self.id.to_s\n\n Client.personal_import_raw_key(key.private_hex,data) rescue nil \n self.account_password = Encrypt_me.call(self.id,self.created_at,data) rescue nil\n self.account_address = self.role_before_type_cast == 0 ? Client.personal_list_accounts[\"result\"][0] : key.address rescue nil #get_new_address(data) \n\n self.save rescue nil\n\n end\n end",
"def set_account_data(type, account_data)\n client.api.set_room_account_data(client.mxid, id, type, account_data)\n true\n end",
"def account_type=(type)\n case type\n when TEMP_DUPLICATE\n @account_type = 'duplicate'\n when NORMAL\n @account_type = 'normal'\n when INTERDOMAIN_TRUST\n @account_type = 'interdomain_trust'\n when WORKSTATION_TRUST\n @account_type = 'workstation_trust'\n when SERVER_TRUST\n @account_type = 'server_trust'\n else\n @account_type = 'unknown'\n end\n end",
"def update_account_type username, account_id, account_type, account_sub_type, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret\n url = \"https://financialdatafeed.platform.intuit.com/v1/accounts/#{account_id}\"\n write_to_log(\n \"=================================================\",\n __method__,\n \"=================================================\",\n \"url\",\n url,\n \"user_id\",\n username\n )\n if account_type == \"Banking\"\n acct_type = IntuitIdsAggcat::BankingAccountType.new\n elsif account_type == \"Credit\"\n acct_type = IntuitIdsAggcat::CreditAccountType.new\n elsif account_type == \"Loan\"\n acct_type = IntuitIdsAggcat::LoanType.new\n elsif account_type == \"Investment\"\n acct_type = IntuitIdsAggcat::InvestmentAccountType.new\n elsif account_type == \"Rewards\"\n acct_type = IntuitIdsAggcat::RewardsAccountType.new\n end\n acct_type.account_type = account_sub_type\n response = oauth_put_request url, acct_type.save_to_xml.to_s, oauth_token_info\n if response.present? && response[:response_code] == \"200\"\n 200\n else\n IntuitIdsAggcat::Client::ServiceError.new(response)\n end\n end",
"def user_account_type=(value)\n @user_account_type = value\n end",
"def setaccount(bitcoinaddress, account)\n @api.request 'setaccount', bitcoinaddress, account\n end",
"def vpp_token_account_type=(value)\n @vpp_token_account_type = value\n end",
"def assign_params\n account.assign_attributes(account_params)\n account\n end",
"def setaccount(namecoin_address, account)\n request :setaccount, namecoin_address, account\n end",
"def setaccount(bitcoinaddress, account)\n bitcoin.setaccount bitcoinaddress, account\n end",
"def assign_account(account_id)\n self.account_id = account_id\n end",
"def set_bucket_type_props(bucket_type, props)\n stringify_keys!(props)\n\n bucket_type = bucket_type.name if bucket_type.respond_to?(:name)\n bucket_type_props = bucket_type_data(bucket_type)[:props]\n bucket_type_props.merge!(props)\n bucket_type_props\n end",
"def account_params\n return ActionController::Parameters.new unless params.key?(account_params_key)\n permitted = send(\"account_params_for_#{action}\")\n params.require(account_params_key).permit(*permitted)\n end",
"def test_set_account_type\n account = BankAccount.new('Alice', 5000, 'business')\n account.type= 'personal'\n assert_equal('personal', account.type)\n end",
"def account_params_for_build\n [\n :account_number,\n :description,\n :affiliate_id,\n :affiliate_other,\n :remittance_information,\n :formatted_expires_at,\n :outside_contact_info,\n :ar_number,\n ] + permitted_account_params\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Applies strong_param rules to the passed in params based on the current `action`. Assumes params are guarenteed to be an instantiated `ActionController::Parameters` object. Silently returns an empty params hash if the `account_params_key` is missing. | def account_params
return ActionController::Parameters.new unless params.key?(account_params_key)
permitted = send("account_params_for_#{action}")
params.require(account_params_key).permit(*permitted)
end | [
"def strong_params(*args)\n #byebug\n params.require(controller_name.singularize.to_sym).permit(*args)\n end",
"def app_safe_params\n return safe_params if self.respond_to?(:safe_params)\n\n params.permit\n end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def secure_params\n @secure_params ||= params.require(params_namespace.singularize.to_sym).permit(*permitted_params)\n end",
"def parse_params(permitted_params)\n require_params = {}\n permitted_params.each_with_index do |(key, value), index|\n require_params[key] = if !index.zero?\n relationship_params(key, value)\n else\n params.require(:attributes).permit(*value)\n end\n end\n require_params\n end",
"def permitted_params_for(action)\n send(\"permitted_#{action}_params\")\n end",
"def resource_active_model_permitted_params\n permitted_name = params.key?(effective_resource.name) ? effective_resource.name : effective_resource.resource_name\n\n if Rails.env.development?\n Rails.logger.info \"Effective::CrudController#resource_permitted_params:\"\n Rails.logger.info \"params.require(:#{permitted_name}).permit!\"\n end\n\n if params[permitted_name].present?\n params.require(permitted_name).permit!\n else\n params.require((effective_resource.namespaces + [effective_resource.resource_name]).join('_')).permit!\n end\n end",
"def permit_all_params options = {}\n prepend_before_filter do\n self.params.deep_permit!\n end\n end",
"def permit_params_on_update *keys\n filter_strong_params :permit, [:update], keys\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def unsafe_params\n ActiveSupport::Deprecation.warn(\"Using `unsafe_params` isn't a great plan\", caller(1))\n params.dup.tap(&:permit!)\n end",
"def process_params(permitted_params)\n single_resource = data_root.respond_to?(:to_hash)\n data = Array.wrap(data_root)\n mapping = if params[:id].blank?\n data.map { |attrs| attrs.permit(permitted_params) }\n else\n data.index_by { |d| d[:id].to_s }\n .transform_values { |attrs| attrs.permit(permitted_params) }\n .slice(*params[:id])\n end\n single_resource ? mapping.first : mapping\n end",
"def process_params\n set_params_authable if process_params_authable?\n set_params_ownerable if process_params_ownerable?\n set_params_sub_action\n end",
"def require_params_on_update *keys\n filter_strong_params :require, [:update], keys\n end",
"def resource_permitted_params\n raise 'expected resource class to have effective_resource do .. end' if effective_resource.model.blank?\n\n permitted_params = permitted_params_for(resource, effective_resource.namespaces)\n permitted_name = params.key?(effective_resource.name) ? effective_resource.name : effective_resource.resource_name\n\n if Rails.env.development?\n Rails.logger.info \"Effective::CrudController#resource_permitted_params:\"\n Rails.logger.info \"params.require(:#{permitted_name}).permit(#{permitted_params.to_s[1...-1]})\"\n end\n\n params.require(permitted_name).permit(*permitted_params)\n end",
"def sane_params\n request_schema.sanitized_params if request_schema\n end",
"def action_params(verb, params)\n action_param_key = ((verb == :get) ? :query : :body)\n action_params = (params[action_param_key] || {})\n action_params[:uh] ||= modhash if (logged_in? && verb == :post)\n {action_param_key => action_params}\n end",
"def params\n @sanitized_params ||= _sanitized_params(request.params)\n end",
"def sanitize_params(params)\n sanitized = params.to_hash\n\n self.class.definitions.each do |key, rules|\n send(\"sanitize_#{key}!\", sanitized, rules)\n end\n\n sanitized.symbolize_keys\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Simply assigns the strong_params to the account new/persisted account object. | def assign_params
account.assign_attributes(account_params)
account
end | [
"def assign_account(account_id)\n self.account_id = account_id\n end",
"def create_account\n set_user\n set_payer\n set_user_sport\n save_account\n end",
"def account_params\n return ActionController::Parameters.new unless params.key?(account_params_key)\n permitted = send(\"account_params_for_#{action}\")\n params.require(account_params_key).permit(*permitted)\n end",
"def create\n #@current_account = CurrentAccount.new(current_account_params)\n @current_account = current_user.current_accounts.new(current_account_params)\n\n respond_to do |format|\n if @current_account.save\n format.html { redirect_to @current_account, flash: { success: \"AccountPayable was successfully created.\" } }\n format.json { render :show, status: :created, location: @current_account }\n else\n format.html { render :new }\n format.json { render json: @current_account.errors, status: :unprocessable_entity }\n end\n end\n end",
"def account_params_for_build\n [\n :account_number,\n :description,\n :affiliate_id,\n :affiliate_other,\n :remittance_information,\n :formatted_expires_at,\n :outside_contact_info,\n :ar_number,\n ] + permitted_account_params\n end",
"def set_account\n unless self.role_before_type_cast == 0\n key = Eth::Key.new\n data = SecureRandom.alphanumeric(8)\n unique_id = self.id.to_s\n\n Client.personal_import_raw_key(key.private_hex,data) rescue nil \n self.account_password = Encrypt_me.call(self.id,self.created_at,data) rescue nil\n self.account_address = self.role_before_type_cast == 0 ? Client.personal_list_accounts[\"result\"][0] : key.address rescue nil #get_new_address(data) \n\n self.save rescue nil\n\n end\n end",
"def create\n @account = current_user.accounts.new(account_params)\n\n if @account.save\n render json: @account, status: :created, location: @account\n else\n render json: @account.errors, status: :unprocessable_entity\n end\n end",
"def create\n @user.account = Account.new if @user.account.nil?\n\n if @user.account.save_with_stripe(params)\n redirect_to user_url(@user), notice: 'Account was successfully created.'\n else\n handle_account_errors(@user, params)\n render :new\n end\n end",
"def create\n\t\tif @user.paypal_account\n\t\t\t@paypal_account = @user.paypal_account\n\t\t\t@paypal_account.update(\n\t\t\t\tpaypal_account_params\n\t\t\t)\n\t\telse\n\t\t\t@paypal_account = PaypalAccount.create(paypal_account_params)\n\t\tend\n\trescue\n\t \tflash[:error] = t('errors.messages.not_saved')\n\t \tredirect_to(:back)\t\n\tend",
"def create\n #@broker_acct = BrokerAcct.new(broker_acct_params)\n #@broker_acct.account = current_account\n @acct = BrokerAcct.new(broker_acct_params)\n @acct.email = current_account.email if @acct.email.blank?\n @acct.account = current_account\n\n respond_to do |format|\n if @acct.save\n format.html { render :profile, notice: 'Broker Account was successfully created.' }\n format.json { render :profile, status: :created, location: @acct }\n else\n format.html { render :new }\n format.json { render json: @acct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_account(**attributes)\n AccountProfile.new put(\"account/profile\", body: attributes).body\n end",
"def create_account\n account = accounts.build\n create_account_user(account)\n end",
"def create\n @account_book = AccountBook.create(account_book_params)\n set_after_account_book\n end",
"def account_update_params\n params.require(:user).permit(:email, :first_name, :last_name, :password, :password_confirmation, :nationality, :phone, :occupation, :photo, :current_password)\n end",
"def create\n @acct = EmployeeAcct.new(employee_acct_params)\n @acct.account = current_account\n\n respond_to do |format|\n if @acct.save\n format.html { redirect_to \"/\", notice: 'Employee Account was successfully created.' }\n format.json { redirect_to \"/\", status: :created, location: @acct }\n else\n format.html { render :new }\n format.json { render json: @acct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def copy_account_to_user(account)\n return account if account.current_user.nil?\n\n account.current_user.phone_number = account.contact_number\n account.current_user.email_address = account.email_address\n account.current_user.email_address_confirmation = account.email_address_confirmation\n account\n end",
"def new_account=(account)\n @new_account = self.account_ids.include?(account.id) ? nil : account\n end",
"def save\n return unless Yext::Api::Validators::AccountValidator.new(self).valid?\n\n updates = { account_id: account_id, accountName: accountName }\n updates[:accountId] = accountId if accountId != account_id\n\n scope.with(Yext::Api::Concerns::AccountChild.with_account_path(\"\")).\n where(updates).\n put\n\n save_account_id\n end",
"def create\n @current_account = @customer.current_accounts.new(current_account_params)\n\n respond_to do |format|\n if @current_account.save\n @accounting_record = CurrentAccount.create_accounting_record(@current_account.detail, @current_account.debit) \n format.html { redirect_to store_customers_path(@customer), notice: 'Current account was successfully created.' }\n format.json { render :show, status: :created, location: @current_account }\n else\n format.html { render :new }\n format.json { render json: @current_account.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sets the `action` which is used to load the proper set of account_params. The action should always get set before `account_params` is called. | def set_action(action)
@action = action
end | [
"def set_action(action)\n params[:action] = action\n end",
"def action=(action)\n unless action\n raise Occi::Core::Errors::InstanceValidationError,\n 'Missing valid action'\n end\n\n @action = action\n reset_attributes!\n\n action\n end",
"def account_params\n return ActionController::Parameters.new unless params.key?(account_params_key)\n permitted = send(\"account_params_for_#{action}\")\n params.require(account_params_key).permit(*permitted)\n end",
"def initialize(action:, action_params:)\n @action = action\n @action_params = action_params\n end",
"def setAction(action)\n unless /(?i)^(join|shuffle|extract|delete)$/.match(action)\n raise Error.new(Pdfcrowd.create_invalid_value_message(action, \"setAction\", \"pdf-to-pdf\", \"Allowed values are join, shuffle, extract, delete.\", \"set_action\"), 470);\n end\n \n @fields['action'] = action\n self\n end",
"def prepare_params_for(action, options = {})\n options.stringify_keys!\n params = deep_copy(RubyProvisioningApi.configuration.send(\"#{self.name.demodulize.underscore}_actions\")[action])\n options.each_pair do |k, v|\n params[:url].gsub!(k, v)\n end\n params\n end",
"def set_failsafe_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def _call_action(action)\n arguments, defaults = self.class.action_argument_list[action]\n \n args = arguments.map do |arg, default|\n arg = arg\n p = params.key?(arg.to_sym)\n raise BadRequest unless p || (defaults && defaults.include?(arg))\n p ? params[arg.to_sym] : default\n end\n __send__(action, *args)\n end",
"def update_action_params\n params[:rpp] = @rpp\n params[:offset] = @offset\n end",
"def action=(action)\n if action && !VALID_ACTIONS.include?(action.to_sym)\n raise ArgumentError, \"Invalid Action (#{action}), use: #{VALID_ACTIONS*' '}\"\n end\n command[:action] = action\n end",
"def action_set_record_vars(action)\n action.description = @edit[:new][:description]\n action.action_type = @edit[:new][:action_type]\n @edit[:new][:options][:ae_hash] = {}\n @edit[:new][:attrs]&.each do |pair|\n @edit[:new][:options][:ae_hash][pair[0]] = pair[1] if pair[0].present? && pair[1].present?\n end\n @edit[:new][:options].delete(\"ae_hash\".to_sym) if @edit[:new][:options][:ae_hash].empty?\n @edit[:new][:object_message] = @edit[:new][:options][:ae_message] unless @edit[:new][:options][:ae_message].nil?\n @edit[:new][:object_request] = @edit[:new][:options][:ae_request] unless @edit[:new][:options][:ae_request].nil?\n\n if @edit[:new][:action_type] == \"evaluate_alerts\" # Handle evaluate_alerts action type\n @edit[:new][:options][:alert_guids] = [] # Create the array in options\n @edit[:new][:alerts].each_value do |a| # Go thru the alerts hash\n @edit[:new][:options][:alert_guids].push(a) # Add all alert guids to the array\n end\n end\n\n if @edit[:new][:options]\n action.options = if @edit[:new][:options][:scan_item_set_name]\n {:scan_item_set_name => @edit[:new][:options][:scan_item_set_name]}\n else\n copy_hash(@edit[:new][:options])\n end\n end\n end",
"def params(request, action)\n request[:generatePaymentToken] = true if action == :store\n request\n end",
"def fill_controller_action_attributes\n return if controller_action.blank?\n route = controller_action.split('#')\n self.controller, self.action = route.first, route.last\n end",
"def default_action_input_params(action)\n {}\n end",
"def adjust_action\n if params[:action] == 'index' and @section.try(:single_article_mode)\n # ... but only if there is one published article\n unless @section.articles.blank? || (@section.articles.first.draft? && !has_permission?('update', 'section'))\n @action_name = @_params[:action] = request.parameters['action'] = 'show'\n end\n end\n end",
"def params_check_action(action)\n case action\n when :list\n p = params.reject do |k, v|\n [FILTER_KEY, SEARCH_KEY].include?(k)\n end\n unless p.empty?\n error 400, convert(body_for(:invalid_params, p))\n end\n when :read\n p = params.reject { |k, v| k == SHOW_KEY }\n unless [nil, \"all\"].include?(params[SHOW_KEY])\n error 400, convert(body_for(:invalid_params,\n { SHOW_KEY => params[SHOW_KEY] }))\n end\n unless p.empty?\n error 400, convert(body_for(:invalid_params, p))\n end\n when :create\n # No need to complain. If there are problems,\n # params_check_action_and_role will catch them.\n when :update\n if params.empty?\n error 400, convert(body_for(:no_params))\n end\n when :delete\n unless params.empty?\n error 400, convert(body_for(:invalid_params, p))\n end\n else\n raise Error, \"Unexpected: #{action.inspect}\"\n end\n end",
"def process(action, *args)\n action, options = action if action.is_a?(Array)\n @_action_options = options || {}\n super\n end",
"def set_minimum_up_member_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def action(entity, action)\n self.detail_action.entity = entity\n self.detail_action.action = action\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Given an account, set the account_type. Only used for `update`. | def set_account_type
@account_type = account.class.to_s
end | [
"def user_account_type=(value)\n @user_account_type = value\n end",
"def update_account_type username, account_id, account_type, account_sub_type, oauth_token_info = IntuitIdsAggcat::Client::Saml.get_tokens(username), consumer_key = IntuitIdsAggcat.config.oauth_consumer_key, consumer_secret = IntuitIdsAggcat.config.oauth_consumer_secret\n url = \"https://financialdatafeed.platform.intuit.com/v1/accounts/#{account_id}\"\n write_to_log(\n \"=================================================\",\n __method__,\n \"=================================================\",\n \"url\",\n url,\n \"user_id\",\n username\n )\n if account_type == \"Banking\"\n acct_type = IntuitIdsAggcat::BankingAccountType.new\n elsif account_type == \"Credit\"\n acct_type = IntuitIdsAggcat::CreditAccountType.new\n elsif account_type == \"Loan\"\n acct_type = IntuitIdsAggcat::LoanType.new\n elsif account_type == \"Investment\"\n acct_type = IntuitIdsAggcat::InvestmentAccountType.new\n elsif account_type == \"Rewards\"\n acct_type = IntuitIdsAggcat::RewardsAccountType.new\n end\n acct_type.account_type = account_sub_type\n response = oauth_put_request url, acct_type.save_to_xml.to_s, oauth_token_info\n if response.present? && response[:response_code] == \"200\"\n 200\n else\n IntuitIdsAggcat::Client::ServiceError.new(response)\n end\n end",
"def account_type=(type)\n case type\n when TEMP_DUPLICATE\n @account_type = 'duplicate'\n when NORMAL\n @account_type = 'normal'\n when INTERDOMAIN_TRUST\n @account_type = 'interdomain_trust'\n when WORKSTATION_TRUST\n @account_type = 'workstation_trust'\n when SERVER_TRUST\n @account_type = 'server_trust'\n else\n @account_type = 'unknown'\n end\n end",
"def set_account_data(type, account_data)\n client.api.set_room_account_data(client.mxid, id, type, account_data)\n true\n end",
"def account=(account)\n @account = account ? Struct::Account.new(account) : account\n end",
"def setaccount(bitcoinaddress, account)\n @api.request 'setaccount', bitcoinaddress, account\n end",
"def vpp_token_account_type=(value)\n @vpp_token_account_type = value\n end",
"def account_type(account_type_id)\n result = nil\n public_connection(HTTP_GET, \"/api/accounts/#{account_type_id}.xml\") do |xml|\n result = AccountType.new xml\n end\n result\n end",
"def test_set_account_type\n account = BankAccount.new('Alice', 5000, 'business')\n account.type= 'personal'\n assert_equal('personal', account.type)\n end",
"def change_account(new_account)\n @current_account = new_account\n end",
"def setaccount( bitcoinaddress, account )\n {\n method: :setaccount,\n params:[bitcoinaddress, account]\n }\n end",
"def setaccount(bitcoinaddress, account)\n bitcoin.setaccount bitcoinaddress, account\n end",
"def setaccount(namecoin_address, account)\n request :setaccount, namecoin_address, account\n end",
"def account_type\n self.class.account_type\n end",
"def account_type\n AccountType.find(account_type_id)\n end",
"def update(organisation_id, account_number, name, classification, type, tax, currency, options = {})\n body = options.has_key?(:body) ? options[:body] : {}\n body[:organisation_id] = organisation_id\n body[:account_number] = account_number\n body[:name] = name\n body[:classification] = classification\n body[:type] = type\n body[:tax] = tax\n body[:currency] = currency\n\n response = @client.post \"/core.account/update/#{@account_id}\", body, options\n\n return response\n end",
"def assign_account(account_id)\n self.account_id = account_id\n end",
"def setaccount(dogecoinaddress, account)\n dogecoin.setaccount dogecoinaddress, account\n end",
"def set_account\n unless self.role_before_type_cast == 0\n key = Eth::Key.new\n data = SecureRandom.alphanumeric(8)\n unique_id = self.id.to_s\n\n Client.personal_import_raw_key(key.private_hex,data) rescue nil \n self.account_password = Encrypt_me.call(self.id,self.created_at,data) rescue nil\n self.account_address = self.role_before_type_cast == 0 ? Client.personal_list_accounts[\"result\"][0] : key.address rescue nil #get_new_address(data) \n\n self.save rescue nil\n\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Build the owner account_user. Only used for `build`. | def build_account_users
account.account_users.build(
user_id: owner_user.id,
user_role: "Owner",
created_by: current_user.id,
)
account
end | [
"def build_user(attrs)\n user = User.new(client, attrs)\n user = if client.user == user\n client.user\n elsif @creator == user\n creator\n elsif result = @listeners && listener(user.id) || @moderators && moderator(user.id) || friend(user.id)\n result\n else\n user\n end\n user.attributes = attrs\n user\n end",
"def create_nufs_account_with_owner(owner=:owner)\n owner=instance_variable_get(\"@#{owner.to_s}\")\n FactoryGirl.create(:nufs_account, :account_users_attributes => [ FactoryGirl.attributes_for(:account_user, :user => owner) ])\n end",
"def owner\n @owner ||= User.new(connection, :login => @attributes[:owner])\n end",
"def build_admin_user\n @admin_user = AdminUser.new\n @admin_user.build_address\n end",
"def make_user(params = {})\n self.user= account.users.build_with_fields params.reverse_merge(:email => email, :invitation => self)\n end",
"def build_user(data)\n User.new(data)\n end",
"def build_user\n doc.at('User').try(:remove)\n\n return unless user.present?\n\n Nokogiri::XML::Builder.with(xml_package_data) do |xml|\n xml.send('User') {\n xml.send('Email', user[:email])\n xml.send('Phone', user[:phone])\n xml.send('FullName') {\n xml.send('FirstName', user[:first_name])\n xml.send('LastName', user[:last_name])\n xml.send('MiddleName', user[:middle_name])\n }\n }\n end\n end",
"def create_account_user(account)\n AccountUser.new(user: self, account: account)\n end",
"def build_resource(*args)\n # Call the parent function to build the User model.\n super\n \n # If we have :omniauth in our session cookie we will build\n # an authentication for the new user from that and then \n # check to make sure the user is valid (i.e. get the password\n # from someone who created an account via LinkedIn or Facebook).\n if session[:omniauth]\n @user.build_authentication(session[:omniauth])\n @user.valid?\n end\n end",
"def set_owner_from_creator\n self.owner = creator\n end",
"def owner\n membership = self.memberships.find_by(role: Landlord::Role.owner)\n raise \"account has no user assigned as owner\" unless membership\n membership.user\n end",
"def add_owner_user email\n add_access_role_scope_value :owner, :user, email\n end",
"def build_user(options={})\n @user = User.new({:persist => false})\n @person = @user.person = Advocate.new\n \n @address = @person.build_business_address({:country_code => \"DE\"})\n @person.attributes = {:profession_advocate => true}.merge(params[:person] || {}).merge(options[:person] || {})\n\n @user.attributes = params[:user] || {}\n @person.user = @user\n @user\n end",
"def create_user_and_accounts\n User.create(uuid: @auth_payload[:sub]) unless current_user\n AccountsGenerator.generate_accounts_for_user(current_user) if Account.for_user(current_user).empty?\n end",
"def add_owner(user)\n add_user user, Membership::OWNER\n end",
"def merge_owner!(user)\n self.merge_user!(user, \"owner\")\n self[:owner_id] = self.delete(:owner_user_id) unless self[:owner_user_id].nil?\n self\n end",
"def set_owner_id\n if self.admin? == false || (self.admin? && @guild[:owner_id] == nil)\n @guild[:owner_id] = session[:user_id]\n end\n return 1\n end",
"def create_org_user\n org_user = OrganizationUser.new(:organization_id => self.signup_organization_id, :user_id => self.id, :manager => self.signup_organization_manager)\n ok = org_user.save\n return ok\n end",
"def apply_owner_metadata\n owner = owner_from_attributes || user\n curation_concern.edit_users += [owner.user_key]\n curation_concern.owner = owner.user_key\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the affiliate_id if the account type supports affiliates, the affiliate param is present, and the affiliate exists. Also ensure affiliate_other gets wiped out if the affiliate_id does not point to `Other`. | def set_affiliate
if affiliate.present?
account.affiliate_id = affiliate.id
account.affiliate_other = affiliate.subaffiliates_enabled? ? account_params[:affiliate_other] : nil
else
account.affiliate_id = account.affiliate_other = nil
end
account
end | [
"def affiliate= affiliate\n if affiliate\n if affiliate.class != affiliate_class # self.class.to_s != \"#{affiliate.class.to_s}Reference\"\n raise \"Attempt to affiliate #{self.class.to_s} reference with #{affiliate.class} object.\"\n elsif affiliate_id && (affiliate_id != affiliate.id)\n raise \"Attempt to create ambiguous reference by asserting new affiliate\"\n else\n self.affiliate_id = affiliate.id\n end\n end\n end",
"def set_affiliate_id\n set_affiliate_id_from_params || set_affiliate_id_from_session\n end",
"def affiliate\n @affiliate || Affiliate.with_id(@data_object.user_affiliate)\n end",
"def set_affiliate_id_from_params\n if !params[:a_aid].blank?\n self.current_affiliate_id = params[:a_aid]\n session[:moolamoola_affiliate] = true\n elsif !params[:affiliate_id].blank?\n self.current_affiliate_id = params[:affiliate_id]\n elsif !params[:aff_id].blank?\n self.current_affiliate_id = params[:aff_id]\n end\n end",
"def using_affiliate?(account_type)\n affiliate_account_types.include?(account_type.to_s.classify)\n end",
"def affiliation=(affil)\n affiliations.clear\n affiliations << affil\n end",
"def set_affiliate_id_from_cookie\n self.current_affiliate_id = cookies[:affiliate_id] unless cookies[:affiliate_id].blank? || session[:affiliate_id] == cookies[:affiliate_id]\n end",
"def set_affiliate_id_from_session\n self.current_affiliate_id = session[:affiliate_id] unless session[:affiliate_id].blank?\n end",
"def affiliation=(affil)\n affiliations.clear\n affiliations << affil\n end",
"def current_affiliate_id\n @current_affiliate_id ||= set_affiliate_id\n end",
"def associated_with_affiliate?(aff_id)\n (aff_id == @data_object.user_affiliate) ||\n role_assoc_with_affiliate?(aff_id)\n end",
"def affiliates_enabled?\n affiliate_account_types.present?\n end",
"def claim_affiliate\n # Claim affiliate\n raise if !self.is_first_store_purchase?\n raise if AffiliateClaimStore.where(store_purchase: self).present?\n\n # Find owner referred by\n affiliate = self.try(:owner).try(:affiliate_referred_by).try(:affiliate)\n raise if affiliate.blank?\n\n # Find affiliate publisher\n publisher = affiliate.publisher\n\n # Hitung commission berdasarkan berapa banyak publisher telah menghasilkan\n # store_purchase yang berhasil di close (bayar)\n aff_success = publisher.affiliate_referring(type: \"store\", status: \"success\")\n if aff_success.count < 10\n commission = AffiliateCommissionStore.find_by(quantity: 0)\n elsif aff_success.count >= 10\n commission = AffiliateCommissionStore.find_by(quantity: 10)\n end\n\n # Create AffiliateClaim record\n # Commission akan diberikan ketika store_purchase statusnya closed\n AffiliateClaimStore.create(affiliate: affiliate, store_purchase: self, commission: commission)\n\n rescue\n nil\n end",
"def affiliate_affiliations\n @affiliate_affiliations ||= Affiliation.find_by_uid(uid)\n end",
"def update\n respond_to do |format|\n if @affiliate.update(affiliate_params)\n format.html { redirect_to @affiliate, notice: 'Affiliate was successfully updated.' }\n format.json { render :show, status: :ok, location: @affiliate }\n else\n format.html { render :edit }\n format.json { render json: @affiliate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def claim_affiliate\n # Claim affiliate\n raise if !self.is_first_contest?\n raise if AffiliateClaimContest.where(contest: self).present?\n\n # Find owner referred by\n affiliate = self.try(:owner).try(:affiliate_referred_by).try(:affiliate)\n raise if affiliate.blank?\n\n # Find affiliate publisher\n publisher = affiliate.publisher\n\n # Hitung commission berdasarkan berapa banyak publisher telah menghasilkan\n # contest yang berhasil di close (bayar)\n aff_success = publisher.affiliate_referring(type: \"contest\", status: \"success\")\n if aff_success.count < 10\n commission = AffiliateCommissionContest.find_by(quantity: 0)\n elsif aff_success.count >= 10\n commission = AffiliateCommissionContest.find_by(quantity: 10)\n end\n\n # Create AffiliateClaim record\n # Commission akan diberikan ketika contest statusnya closed\n AffiliateClaimContest.create(affiliate: affiliate, contest: self, commission: commission)\n\n rescue\n nil\n end",
"def register_affiliate_role\n Role.set_user_role(@data_object.user_id, \n user_affiliate, \n nil,\n RoleNameTable::REGISTERED,\n TargetTable::AFFILIATE,\n user_affiliate)\n end",
"def add_affiliate_constraints\n return unless @data.aff_id || @data.reg_id\n\n extra = \"\"\n\n case @data.selection_type\n when TEAMPAK\n if @data.reg_id\n extra = \"mem_region=#{@data.reg_id}\"\n else\n extra = \"mem_affiliate=#{@data.aff_id}\"\n end\n when USER\n if @data.aff_id\n extra = \"user_affiliate=#{@data.aff_id}\"\n end\n when TEAM\n if @data.reg_id\n extra = \"mem_region=#{@data.reg_id} and team_mem_id=mem_id\"\n else\n extra = \"mem_affiliate=#{@data.aff_id} and team_mem_id=mem_id\"\n end\n @data.tables ||= []\n @data.tables << MembershipTable\n end\n\n if @data.where_clause\n @data.where_clause += \" and \" + extra\n else\n @data.where_clause = extra\n end\n end",
"def current_affiliate_id=(value)\n session[:affiliate_id] = value\n # cookies[:affiliate_id] = { :value => value, :expires => 1000.day.from_now } if value\n @current_affiliate_id = value || false\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Set the facility if the account type is scoped to facility. | def set_facility
return unless account.per_facility? && facility&.id
account.account_facility_joins.build(facility: facility)
account
end | [
"def facility=(f)\n Log.facility=(f)\n end",
"def set_facilities\n if user_signed_in?\n if current_user.role == \"site_admin\"\n @userfacilities = Facility.all\n else\n @userfacilities = current_user.facility_relationships.includes(:facility_roles).where.not(facility_roles: {name: 'climber'}).all\n end\n end\n end",
"def update_facility_id\n if @claim_information.billing_provider_npi && @facility_npi_hash[@claim_information.billing_provider_npi]\n @claim_information.facility_id = @facility_npi_hash[@claim_information.billing_provider_npi][:facility_id]\n @claim_information.active = @claim_information.facility_id?\n elsif @claim_information.facility_id.nil?\n @claim_information.active = false\n end\n end",
"def facility(val)\n @default_header.facility = val\n end",
"def per_facility?(account_type)\n facility_account_types.include?(account_type.to_s.classify)\n end",
"def facility( *values )\n if values.empty?\n @facility\n else\n # deprecate, but should still work\n Yell.__deprecate__( \"0.6.0\", \"Use :facility= for setting the Syslog facility\" )\n\n self.facility = values\n end\n end",
"def current_facility\n @facility ||= load_facility\n end",
"def current_facility\n current_facility ||= (current_user.facilities.find_by(id: params[:facility_id]) || current_user.facilities.first)\n end",
"def scoped_account=(scoped_account)\n @scoped_account = scoped_account\n end",
"def is_faculty\r\n self.user_type == User::Types::Faculty\r\n end",
"def set_organisation_uid\n client = ServiceRegistry.service(:auth_api_client).new(@auth_token)\n organisations = client.organisations(types: [:law_firm])\n\n if organisations.empty?\n false\n else\n defence_request.organisation_uid = organisations.first.uid\n end\n end",
"def update_facility(patient, datatype)\n return nil unless datatype['facility']\n return nil if datatype.facility['type']\n # Need to build new facility and assign it in order to actually save it in DB\n new_datatype_facility = {}\n\n # Assign type to be 'COL' for collection\n new_datatype_facility['type'] = 'COL'\n new_datatype_facility['values'] = [{}]\n\n # Convert single facility into collection containing 1 facility\n start_time = datatype.facility['start_time']\n end_time = datatype.facility['end_time']\n\n # Convert times from 1505203200 format to 09/12/2017 8:00 AM format\n if start_time\n converted_start_time = Time.at(start_time).getutc().strftime(\"%m/%d/%Y %l:%M %p\")\n else\n converted_start_time = nil\n end\n\n if end_time\n converted_end_time = Time.at(end_time).getutc().strftime(\"%m/%d/%Y %l:%M %p\")\n else\n converted_end_time = nil\n end\n\n # start/end time -> locationPeriodLow/High\n new_datatype_facility['values'][0]['locationPeriodLow'] = converted_start_time\n new_datatype_facility['values'][0]['locationPeriodHigh'] = converted_end_time\n\n # name -> display\n new_datatype_facility['values'][0]['display'] = datatype.facility['name']\n\n # code\n if datatype.facility['code']\n code_system = datatype.facility['code']['code_system']\n code = datatype.facility['code']['code']\n new_datatype_facility['values'][0]['code'] = {'code_system'=>code_system, 'code'=>code}\n print_helper(\"Facility\", patient)\n datatype.facility = new_datatype_facility\n else\n print_helper(\"-Facility\", patient)\n datatype.remove_attribute(:facility)\n end\nend",
"def type_accounting!()\n @type = TAC_PLUS_ACCT\n end",
"def ability_resource\n current_facility\n end",
"def set_facility_debug_level(facility,level)\n # Create faciltiy_level if it's not created already\n @@facility_level= {} if !defined?(@@facility_level)\n\n @@facility_level[facility]=level\n \n # Create debug level if it's not already created\n @@debug_level=0 if !defined?(@@debug_level)\n end",
"def update\n @facility = Facility.find(params[:id])\n @facility.update(facilities_params)\n redirect_to admins_url\n end",
"def get_facility \n claim = (eobs.collect {|eob| (eob.claim_information unless eob.claim_information.nil?)}).first\n\n if claim\n Output835.log.info \"\\n There's a claim associated with an eob, the claim id : #{claim.id},\n patient account num : #{claim.patient_account_number}\"\n (claim.facility = facility)\n end\n claim || facility\n end",
"def facility\n @facility ||= self.class.name.gsub(/::/, \".\").gsub(/([a-z])([A-Z])/, \"\\\\1_\\\\2\").downcase + \"[%x]\" % object_id\n end",
"def facility\n @facility ||= self.class.to_s.gsub(/::/, \".\").gsub(/([a-z])([A-Z])/, \"\\\\1_\\\\2\").downcase + \"[%x]\" % object_id\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return the bank activity for the specified date | def activity(date)
main_ledger_account.activity(date)
end | [
"def activity(date)\n ledger_entries.for_date(date).sum(:debit) - ledger_entries.for_date(date).sum(:credit)\n end",
"def activities_on_date(date)\n get(\"/user/#{@user_id}/activities/date/#{format_date(date)}.json\")\n end",
"def daily_activity_summary(date)\n get_call(\"user/#{user_id}/activities/date/#{format_date(date)}.json\")\n end",
"def activities_in_date_range(from_date, to_date)\n from_date = format_date from_date\n to_date = format_date to_date\n\n @dealing_platform.gather \"history/activity/#{from_date}/#{to_date}\", :activities, AccountActivity\n end",
"def daily_activity_summary(date = Date.today)\n get(\"user/#{user_id}/activities/date/#{format_date(date)}.json\")\n end",
"def balance(date = nil)\n return @starting_balance if @transactions.empty?\n\n update_balances\n date = end_date if date.nil?\n\n raise \"Transaction set begins later than this date\" if date < start_date\n raise \"Transaction set ends before this date\" if date > end_date\n\n @balances[date.to_date]\n end",
"def activity_on_date_range(activity, start, finish)\n get(\"/user/#{@user_id}/activities/#{activity}/date/#{format_date(start)}/#{format_date(finish)}.json\")\n end",
"def transactions_in_date_range(from_date, to_date, transaction_type = :all)\n validate_transaction_type transaction_type\n\n from_date = format_date from_date\n to_date = format_date to_date\n\n url = \"history/transactions/#{transaction_type.to_s.upcase}/#{from_date}/#{to_date}\"\n\n @dealing_platform.gather url, :transactions, AccountTransaction\n end",
"def balance(date = Time.now)\n total = 0\n\n transactions.sort_by(&:transaction_at).each do |transaction|\n break if transaction.transaction_at.end_of_day > date.end_of_day\n\n total += transaction.adjusted_amount\n end\n\n total\n end",
"def balance(date=nil)\n date ||= Time.now.strftime(\"%Y-%m-%d\")\n validate_date(date)\n\n transaction_sum = BankTransaction.where(\"bank_account_id = ? AND date <= ?\", id, date).sum('cents')\n sum = initial_cents + transaction_sum\n balance = get_formatted_balance(date, sum, currency)\n end",
"def balance(date = Time.now)\n total = 0\n accounts.each do |account|\n total += account.balance(date)\n end\n\n total\n end",
"def calorie_expenditure(date = Time.zone.now.to_date)\n date = Time.zone.parse(date.to_s)\n a = user_activities.find(:all, :conditions => ['activity_date BETWEEN ? and ?', date.beginning_of_day.utc, date.end_of_day.utc])\n return a.inject(0) { |s,activity| s += activity.calories }\n end",
"def bill_date\n return if record['actions'].none?\n\n Time.zone.parse(record.dig('actions', 0, 'dateAction'))\n end",
"def calculate_balance(by_date)\n @balance = 0.00\n @transactions.each do |t|\n if (by_date >= (Date.parse t[0]))\n if (t[2] == @name)\n @balance += t.last.to_f\n else\n @balance -= t.last.to_f\n end\n t.each {|attr| print (\"#{attr}, \")}\n puts \"end.\"\n end\n end\n puts\n puts \"Total balance: #{balance}\"\n end",
"def date(date_name)\r\n case date_name\r\n when :start\r\n return self.accommodation_histories.last.from\r\n when :end\r\n return self.accommodation_histories.last.to\r\n else\r\n return 0\r\n end\r\n end",
"def index\n @plan_visits = PlanVisit.index_all(params[:date], current_user)\n end",
"def daily_balances(start_date, end_date)\n LedgerAccountHelper.daily_balances(main_ledger_account, start_date, end_date)\n end",
"def daily_activity\n\t\t@work_flows = WorkFlow.where(is_active: true)\n\t\t@workflows = WorkFlow.where(is_active: true, is_in_use: false)\n\t\tif request.post? or session[:daily_activity_report_date].present?\n\t\t\tif request.post?\n\t\t\t\t@daily_report_date = params[:daily_report_date]\n\t\t\t\tsession[:daily_activity_report_date] = @daily_report_date\n\t\t\telse\n\t\t\t\t@daily_report_date = session[:daily_activity_report_date]\n\t\t\tend\n\t\t\tdate = L1.set_db_date_format(@daily_report_date)\n\t\t\tq_string = \"STR_TO_DATE( '#{date}', '%Y-%m-%d') = STR_TO_DATE(timestamp_logs.created_at, '%Y-%m-%d')\"\n\t\t\tworkflow = params[:work_flow]\n\t\t\tif workflow.present? \n\t\t\t\t@searched_work_flow = workflow\n\t\t\t\tq_string += \"and timestamp_logs.work_flow_id = #{workflow}\"\n\t\t\telse\n\t\t\t\t@searched_work_flow = @workflow.id\n\t\t\t\tq_string += \"and timestamp_logs.work_flow_id = #{@workflow.id}\"\n\t\t\tend\n\t\t\t@report_serach_result = WorkFlow.daily_report_serach(q_string)\n\t\tend\n\tend",
"def get_statement(start_date = '2016-08-29', end_date = '2016-09-01') \n return nil unless @access_token\n\n @timestamp = Time.now.iso8601(3)\n @start_date = start_date.to_s\n @end_date = end_date.to_s\n @path = \"/banking/v3/corporates/\"\n @relative_url = \"#{@path}#{@corporate_id}/accounts/#{@account_number}/statements?EndDate=#{@end_date}&StartDate=#{@start_date}\"\n begin\n response = RestClient.get(\"#{@base_url}#{@relative_url}\",\n \"Content-Type\": 'application/json',\n \"Authorization\": \"Bearer #{@access_token}\",\n \"Origin\": @domain,\n \"X-BCA-Key\": @api_key,\n \"X-BCA-Timestamp\": @timestamp,\n \"X-BCA-Signature\": signature)\n elements = JSON.parse response.body\n statements = []\n\n elements['Data'].each do |element|\n year = Date.parse(@start_date).strftime('%m').to_i.eql?(12) ? Date.parse(@start_date).strftime('%Y') : Date.parse(@end_date).strftime('%Y')\n date = element['TransactionDate'].eql?(\"PEND\") ? element['TransactionDate'] : \"#{element['TransactionDate']}/#{year}\"\n attribute = {\n date: date,\n brance_code: element['BranchCode'],\n type: element['TransactionType'],\n amount: element['TransactionAmount'].to_f,\n name: element['TransactionName'],\n trailer: element['Trailer']\n }\n statements << BcaStatement::Entities::Statement.new(attribute)\n end\n statements\n rescue RestClient::ExceptionWithResponse => err\n return nil\n end \n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return daily balances for a date range... | def daily_balances(start_date, end_date)
LedgerAccountHelper.daily_balances(main_ledger_account, start_date, end_date)
end | [
"def daily_balances(start_date, end_date)\n balance = balance(start_date)\n\n data = execute_sql(daily_balances_sql(start_date, end_date))\n\n balances = Array.new\n ((start_date)..(end_date)).each do |date|\n delta = if data[date].present?\n delta = data[date]['activity'].to_d\n else\n 0.00\n end\n balances << {:date => date, :balance => balance, :activity => delta }\n balance += delta\n end\n balances\n end",
"def get_daily_balances\n daily_balances = []\n balance = 0.00\n #ensure it's sorted first\n @transactions.sort_by! { |k| k[:date] }.each_with_index do |t,i|\n balance += t[:amount]\n if i == @transactions.length-1 || t[:date] != @transactions[i+1][:date]\n daily_balances << {:date => t[:date], :balance => safe_float(balance)}\n end\n end\n daily_balances\n end",
"def daily_balances\n # create a hash of date => transaction array\n transactions_by_date = @transactions.group_by { |t| t.date }\n # create a hash of date => total amount of transactions for a given day\n daily_changes = transactions_by_date.reduce(Hash.new(BigDecimal.new(\"0\"))) do |h, (k, v)|\n h[k] = v.reduce(0) do |total, t|\n total += t.signed_amount\n end\n h\n end\n daily_balances = {}\n current_balance = starting_balance\n (transactions_by_date.keys.min..transactions_by_date.keys.max).each do |d|\n current_balance += daily_changes[d]\n daily_balances[d] = current_balance\n end\n daily_balances.reduce([]) do |ary, (k, v)|\n ary << {date: k, amount: v}\n end\n end",
"def balance_range(from_date, to_date)\n parsed_from_date = validate_date(from_date)\n parsed_to_date = validate_date(to_date)\n return [] if from_date > to_date\n\n balance = []\n transactions = BankTransaction.select(\"date(date) as date, currency, sum(cents) as cents\").group(\"date(date)\").having(\"bank_account_id = ? AND date >= ? AND date <= ?\", id, from_date, to_date)\n sum = initial_cents\n transactions.each do |t|\n sum += t.cents\n balance << get_formatted_balance(t.date, sum, t.currency)\n end\n\n if balance.empty? || balance.first[:date] != parsed_from_date\n balance.unshift balance(from_date)\n end\n\n if balance.empty? || balance.last[:date] != parsed_to_date\n balance << balance(to_date)\n end\n\n balance\n end",
"def balance(date = Time.now)\n total = 0\n\n transactions.sort_by(&:transaction_at).each do |transaction|\n break if transaction.transaction_at.end_of_day > date.end_of_day\n\n total += transaction.adjusted_amount\n end\n\n total\n end",
"def average_calorie_balance(range = 1.week.ago.to_date..Time.zone.now.to_date)\n acb = 0\n count = 0\n range.each do |date|\n cb = calorie_balance(date)\n if cb\n acb += cb\n count += 1\n end\n end\n return acb / count if count > 0\n return 0\n end",
"def balance(period, date = Date.today)\n self.lines.where(:period => period).on(date).sum(:amount)\n end",
"def balance(date = nil)\n return @starting_balance if @transactions.empty?\n\n update_balances\n date = end_date if date.nil?\n\n raise \"Transaction set begins later than this date\" if date < start_date\n raise \"Transaction set ends before this date\" if date > end_date\n\n @balances[date.to_date]\n end",
"def balance(date = Time.now)\n total = 0\n accounts.each do |account|\n total += account.balance(date)\n end\n\n total\n end",
"def calculate_balance(days_after_opening)\n if (days_after_opening < 30)\n return @balance\n else # For day 30, problem didn't specify what happens after day 30 period\n @transaction_days.push(30)\n accrued_interest = 0\n\n @balance_activity.each_with_index do |b, index|\n accrued_interest += (b * (@apr / 365) * (@transaction_days[index+1] - @transaction_days[index]))\n end\n\n return @balance + accrued_interest.round(2)\n end\n end",
"def calculate_balance_forward\n invoices.each do |invoice|\n if date_range.is_active? && invoice.issue_date < date_range.start_date\n @balances[invoice.customer_id] += invoice.amount_due\n end\n end\n end",
"def balance(date=nil)\n date ||= Time.now.strftime(\"%Y-%m-%d\")\n validate_date(date)\n\n transaction_sum = BankTransaction.where(\"bank_account_id = ? AND date <= ?\", id, date).sum('cents')\n sum = initial_cents + transaction_sum\n balance = get_formatted_balance(date, sum, currency)\n end",
"def calc_daily_credit_debit\n credit = Transaction.sum(:amount, :conditions => \"date IS '#{Date.current}' AND sign IS 'c' \") # change this to transactiontype_id 1\n debit = Transaction.sum(:amount, :conditions => \"date IS '#{Date.current}' AND sign IS 'd' \") # change this to transactiontype_id 4 (2 + 5)\n @dailytotal = credit - debit\n return @dailytotal\n end",
"def calc_balance_map(txs)\n balance_map = {}\n last_date = nil\n txs.each_with_index do |tx, i|\n date = tx.date.to_date\n next if last_date == date\n transactions_on_day = find_transactions_on_date(txs, i, date)\n balance_map[date] = calc_weighted_average_balance(transactions_on_day)\n balance_map[date.next_day] = transactions_on_day.last.balance\n last_date = date\n end\n return balance_map\nend",
"def trading_days_between(date1, date2)\n trading_day_count(date1, date2, false)\n end",
"def generate_daily_report(start_date, end_date)\n\n array_of_days = []\n\n (start_date..end_date).each do |day|\n start_of_day = day\n end_of_day = day + 1\n array_of_days << {:start => start_of_day, :end => end_of_day}\n end\n\n return generate_report(array_of_days)\n end",
"def daily_usage(start_date, end_date)\r\n #generate dates between start and end inclusive\r\n current_date = start_date\r\n dates = [current_date]\r\n while current_date < end_date do\r\n current_date = current_date + 1\r\n dates.push(current_date)\r\n end\r\n # create array of usages (per day)\r\n usages = []\r\n dates.each do |date|\r\n hash = {}\r\n hash[:date] = date\r\n hash[:usage] = predict(date)\r\n usages.push(hash)\r\n end\r\n\r\n return usages\r\n end",
"def negative_balances(date = nil)\n update_balances\n date = end_date if date.nil?\n\n raise \"Transaction set begins later than this date\" if date < start_date\n raise \"Transaction set ends before this date\" if date > end_date\n\n negatives = {}\n @balances.each do |d, b|\n negatives[d] = b if b < 0 && d <= date.to_date\n end\n\n negatives\n end",
"def calculate_balance(by_date)\n @balance = 0.00\n @transactions.each do |t|\n if (by_date >= (Date.parse t[0]))\n if (t[2] == @name)\n @balance += t.last.to_f\n else\n @balance -= t.last.to_f\n end\n t.each {|attr| print (\"#{attr}, \")}\n puts \"end.\"\n end\n end\n puts\n puts \"Total balance: #{balance}\"\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add errors if name_is_valid? returns false | def name_is_valid
errors.add(:name,'Invalid empty string for name.') unless name_is_valid?
end | [
"def name_is_valid\n errors.add(:name,\"Invalid string for name.\") unless name_is_valid?\n end",
"def check_name\n\t \terrors.push('Name is not valid') unless valid_name?\n\t end",
"def check_name\n self.errors.add('This', :name_blank) if (self.employee_user_id.blank? && self.name.blank?)\n end",
"def last_name_is_valid\n errors.add(:name, \"Invalid string for last name.\") unless last_name_is_valid?\n end",
"def name_not_blank\n if self.name.blank?\n self.errors.add(:name, I18n.t('stage.errors.blank_name'))\n end\n end",
"def name_cannot_be_empty\n if self.name == \"\"\n self.errors[:base] << \"Name cannot be empty\"\n end\n end",
"def name_validation\n if status != User.attending_status[:not_attending] && name.strip.blank?\n errors.add(:name, \"A name is required for all attendees.\")\n end\n end",
"def username_validation\n if name && !username\n errors.add(\"Please enter a username!\")\n end\n end",
"def first_name_is_valid\n errors.add(:name, \"Invalid string for first name.\") unless first_name_is_valid?\n end",
"def name_valid_format\n if name.present? and not name.match(/[\\w]+([\\s]+[\\w]+){1}+/)\n errors.add :name , \"must be seperated by space and should not contain any special characters.\"\n end\n end",
"def validate\n super\n errors.add(:name, 'cannot be empty') if name.blank?\n errors.add(:name, 'is not a valid URL') unless valid_url?(name)\n end",
"def name_cannot_be_bad\n if self.name.strip == \"\"\n self.errors[:base] << \"Building name cannot be empty\"\n elsif Building.exists? name: self.name.strip\n self.errors[:base] << self.name.strip + \" already exists\"\n end\n end",
"def last_name_is_valid\n errors.add(:last_name,'Invalid empty string for last name.') unless last_name_is_valid?\n end",
"def validate!\n super\n help! '`NAME` is required.' unless @name\n end",
"def name_is_valid?\n return false unless not_nil_and_string(self.name)\n return self.name.length > 0\n end",
"def name_presence\n errors.add \"artist\", \"can't be blank\" if name == \"\"\n end",
"def edit_valid_name\n if self.name.strip == \"\"\n self.errors[:base] << \"Building name cannot be empty\"\n elsif Building.exists? name: self.name.strip\n oldName = Building.find(self.id).name\n #change to casecmp?\n if self.name.strip != oldName\n self.errors[:base] << self.name.strip + \" already exists\"\n end\n end\n end",
"def first_name_is_valid\n errors.add(:first_name,'Invalid empty string for first name.') unless first_name_is_valid?\n end",
"def validate_name\n if name == nil || name.empty?\n errors.add(:name, \"Must enter a name\")\n elsif name.size < 3\n errors.add(:name, \"Must be 3 or more characters\")\n # match all words .scan(/\\w+/)\n elsif name.scan(/\\w+/).size > 2\n errors.add(:name, \"Must be two words or less\")\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests if the name of course is not nil and is a string and returns true or false. | def name_is_valid?
return false unless not_nil_and_string(self.name)
return self.name.length > 0
end | [
"def valid?\n @name.is_a?(String) &&\n !@name.empty? &&\n (@variant.nil? || @variant.is_a?(String))\n end",
"def valid_name?(name)\n !name.strip.empty?\nend",
"def card_name_is_a_string_and_not_null\n value_is_a_string(target: :card_name, value: card_name, nullable: false)\n end",
"def name_valid(name)\n if !name.empty?\n self.name = name\n return true\n else\n return false\n end\n end",
"def valid_name?\n self.class.valid_name?(name)\n end",
"def valid_c_name?(name)\n return false if name.empty?\n name =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/\n end",
"def full_name?\n !full_name.blank?\n end",
"def string?\n type == \"string\"\n end",
"def can_show? str\n \treturn not(str.nil? || str === \"\")\n end",
"def string?\n type == \"STRING\"\n end",
"def not_nil_and_string(str)\n return true unless ((str == nil) or (not str.instance_of? String))\n return false\n end",
"def is_string?\n @name.is_a?(String) && @stack.empty?\n end",
"def is_strname?(); @type == GRT_STRNAME; end",
"def is_valid?\n is_valid_string?\n end",
"def has_name?\n @name_record != nil && @name_record.length > 0\n end",
"def name_is_valid?(user, name)\n\t\t\tuser.respond_to? \"#{name}s_participating\" and [\"event\",\"class\",\"game\", \"offering_session\", \"personal_trainer\", \"group_training\"].include? name.underscore\n\t\tend",
"def meaningless?(param)\n (param.is_a?(String) and param.to_s.strip.blank?)\n end",
"def valid?\n return false if @title.nil? || @title == \"\"\n\n true\n end",
"def name_valid?\n\t\tif self.name == nil\n\t\t\treturn false\n\t\telsif VALID_NAME_REGEX !~ self.name || self.name.empty? || self.name.length > MAX_CREDENTIAL_LENGTH\n\t\t\treturn false\n\t\tend\n\t\ttrue\n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add errors if start_time_is_valid? return false | def start_time_is_valid
errors.add(:start_time,'Invalid empty string for start time.') unless start_time_is_valid?
end | [
"def start_time_is_valid?\n return false unless not_nil_and_string(self.start_time)\n return self.start_time.length > 0\n end",
"def check_time\t\n\t\treturn unless errors.blank? #this will ensure the right error count on top area\n\t\tif @start_date.present? && @start_time.present?\n\t\t\t#concatenate start_date and start_time\n\t\t\tstart_at = Time.parse(\"#{@start_date} #{@start_time}\") \n\t\t\t#variable that holds the time 12 hours from now\n\t\t\tstart_at_plus_12_hours = Time.now + (12.hours)\n\t\t\tif start_at <= Time.now\n\t\t\t\terrors.add(:start_date, \"Please do not enter a past date or past time.\")\n\t\t\t\terrors.add(:start_time, \"Please do not enter a past date or past time.\")\n\t\t\telsif start_at < start_at_plus_12_hours \n\t\t\t\terrors.add(:start_date, \"Please only enter a time 12 hours from now\")\n\t\t\tend\n\t\tend\n\tend",
"def start_time_present?\n if start_time.blank?\n errors.add('start_time',\"Please select appointment time\")\n end\n end",
"def start_date_time_format\n errors.add(:start_date_time, 'must be a valid datetime') if ((DateTime.parse(start_date_time.to_s) rescue ArgumentError) == ArgumentError)\n end",
"def valid_start_date\n errors.add(:start_date, 'The start date cannot be parsed.') unless start_date_is_valid?\n end",
"def valid_start_date\n errors.add(:start_date, 'invalid.') unless start_date_is_valid?\n end",
"def check_times\n if start_time >= end_time\n errors.add(:end_time, \"must be after Start time\")\n end \n end",
"def start_comes_before_end\n return if (start_time < end_time)\n\n errors[:start_time] << \"must come before end time\"\n errors[:end_time] << \"must come after start time\"\n end",
"def start_time_must_be_before_end_time\n errors.add(:start_time, \"start time cannot be after end time\") if (start_time > end_time)\n end",
"def start_time_before_end_time\n if start_time and end_time and start_time >= end_time\n errors.add(:start_time, \"Must be before end time\")\n errors.add(:end_time, \"Must be after start time\")\n end\n end",
"def start_is_before_end\n if self.started_at.present? && self.ended_at.present?\n\t\t errors.add(:started_at, \"can't be before the start time\") if self.ended_at < self.started_at\n end\n end",
"def validate_future_start_time\n\t\tif start_time <= Time.now\n\t\t\terrors.add(:start_time, \"must be in the future\")\n\t\tend\n\tend",
"def starts_before_end_time\n return unless start_at.present? && end_at.present? && start_at > end_at\n\n errors.add(:start_at, 'must be before end_at')\n end",
"def validate_start_date_before_end_date\n\t\tif end_time <= start_time\n\t\t\terrors.add(:end_time, \"must be after start time\")\n\t\tend\n\tend",
"def invalid_schedule_time\n if !self.start_time.blank?\n if Schedule.check_invalid_duration(self.id, self.start_time, self.duration).count > 0\n errors.add_to_base \"Time conflict; a schedule exists and occurs during this time\"\n end\n end\n end",
"def end_time_is_valid\n errors.add(:end_time,'Invalid empty string for end time.') unless end_time_is_valid?\n end",
"def start_must_be_before_end_time\n unless active_start_time.nil? or active_stop_time.nil?\n errors.add(:active_start_time, \"must be before stop time\") unless\n active_start_time < active_stop_time\n end\n end",
"def time_valid\n if self.valid_from and self.valid_to then\n errors.add(:valid_from,\n \"must be before the valid to date. #{self.valid_from} >= #{self.valid_to}\") unless self.valid_from < self.valid_to\n else\n if self.valid_from or self.valid_to then\n errors.add(:valid_from,\n \" must be set when valid_to is set.\") unless self.valid_from\n errors.add(:valid_to,\n \" must be set when valid_from is set.\") unless self.valid_to\n end\n end\n end",
"def start_time_lt_end_time\n\t \tif datetime_end.blank? or datetime_start.blank?\n\t \t\treturn true\n\t \tend\n\t \tif datetime_start > datetime_end\n\t \t\terrors.add(:datetime_start, \"have to be earlier than end date\")\n\t \telse\n\t \t\treturn true\n\t\t end \n \tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests if start_time of course is not nil and a string and returns true or false. | def start_time_is_valid?
return false unless not_nil_and_string(self.start_time)
return self.start_time.length > 0
end | [
"def has_start_time?\n !start_time.blank?\n end",
"def start_time_is_valid\n errors.add(:start_time,'Invalid empty string for start time.') unless start_time_is_valid?\n end",
"def start_time_present?\n if start_time.blank?\n errors.add('start_time',\"Please select appointment time\")\n end\n end",
"def presence_of_start_date\n return if course.nil?\n if course.is_training? or course.is_open?\n unless start_date.present?\n errors.add(:start_date, :blank)\n end\n end\n end",
"def self_directed_started?\n if course&.advance_start_at_duration\n !start_at.present? || start_at - course.advance_start_at_duration < Time.zone.now\n else\n started?\n end\n end",
"def started?\n !@start_time.nil?\n end",
"def start_date?\r\n !event_start_date.blank?\r\n end",
"def time?(text)\n if datetime?(text)\n extract = Nickel.parse(text).occurrences[0].start_time\n extract.nil? ? false : true\n else\n false\n end\n\n rescue RuntimeError => e\n Failure.save_case(text, e)\n return false\n end",
"def based_on_start_time?\n @based_on == :start_time\n end",
"def self_directed_started?(course_user = nil)\n if course&.advance_start_at_duration\n time_for(course_user).start_at.blank? ||\n time_for(course_user).start_at - course.advance_start_at_duration < Time.zone.now\n else\n started?\n end\n end",
"def started?\n started_at.present?\n end",
"def start_date_is_valid?\n begin\n date = USDateParse(self.start_date)\n rescue\n return false\n end\n return true\n end",
"def end_time_is_valid?\n return false unless not_nil_and_string(self.end_time)\n return self.end_time.length > 0\n end",
"def is_start?\n type == TYPES[:start]\n end",
"def appt_started?\n appointment.start_date.present?\n end",
"def has_not_started?\n start_date > Time.now\n end",
"def start_date_is_valid?\n begin\n date = USDateParse(self.start_date)\n self.start_date = date.strftime(\"%m/%d/%y\")\n rescue\n return false\n end\n return true\n end",
"def start_is_before_end\n if self.started_at.present? && self.ended_at.present?\n\t\t errors.add(:started_at, \"can't be before the start time\") if self.ended_at < self.started_at\n end\n end",
"def is_date_nil\n\t\tif @start_date.blank? && @start_time.blank?\n\t\t\terrors.add(:start_date, \"Please enter a date.\")\n\t\t\terrors.add(:start_time, \"Please enter a time.\")\n\t\tend\n\n\t\tif @start_date.blank? && @start_time.present?\n\t\t\terrors.add(:start_date, \"Please enter a date.\")\n\t\tend\n\n\t\tif @start_time.blank? && @start_date.present?\n\t\t\terrors.add(:start_time, \"Please enter a time.\")\n\t\tend\n\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds errors if end_time_is_valid? returns false | def end_time_is_valid
errors.add(:end_time,'Invalid empty string for end time.') unless end_time_is_valid?
end | [
"def end_time_is_valid?\n return false unless not_nil_and_string(self.end_time)\n return self.end_time.length > 0\n end",
"def check_lesson_time_ending\r\n unless (start_time.strftime(\"%H:%M\").include? \"00\")\r\n errors.add(:start_time, \"Start time must end with ':00'\")\r\n end\r\n unless (end_time.strftime(\"%H:%M\").include? \"00\")\r\n errors.add(:end_time, \"Finish time must end with ':00'\")\r\n end\r\n end",
"def end_time_after_start_time\n if start_time.present? && end_time.present?\n if end_time <= start_time\n errors.add(:end_time, \"must be after start time\")\n end\n end\n end",
"def valid_end_date\n errors.add(:end_date, 'The end date cannot be parsed.') unless end_date_is_valid?\n end",
"def check_times\n if start_time >= end_time\n errors.add(:end_time, \"must be after Start time\")\n end \n end",
"def end_time_after_start_time\n if self.end_time && self.end_time < self.start_time\n self.errors.add(:end_time, \"The end time must be after the start time\")\n end\n end",
"def end_time=(value)\n super time_for(value)\n rescue ArgumentError\n errors.add :end_time, \"is invalid\"\n super nil\n end",
"def shift_end_hour\n if self.start_time.hour >= 0 && self.start_time.hour <= 2 && self.end_time.hour > 2 \n errors.add(:end_time, 'must be between 7am and 3am')\n end\n if self.end_time.hour > 2 && self.end_time.hour < 7\n errors.add(:end_time, 'must be between 7am and 3am')\n end \n end",
"def end_time_cannot_be_earlier_than_start_time\n\t\tif end_time && start_time \n\t\t\tif end_time < start_time\n\t\t\t\terrors.add(:end_time, \"End time should not be earlier than start time.\")\n\t\t\tend\n\t\tend\n\tend",
"def start_time_is_valid\n errors.add(:start_time,'Invalid empty string for start time.') unless start_time_is_valid?\n end",
"def check_time\t\n\t\treturn unless errors.blank? #this will ensure the right error count on top area\n\t\tif @start_date.present? && @start_time.present?\n\t\t\t#concatenate start_date and start_time\n\t\t\tstart_at = Time.parse(\"#{@start_date} #{@start_time}\") \n\t\t\t#variable that holds the time 12 hours from now\n\t\t\tstart_at_plus_12_hours = Time.now + (12.hours)\n\t\t\tif start_at <= Time.now\n\t\t\t\terrors.add(:start_date, \"Please do not enter a past date or past time.\")\n\t\t\t\terrors.add(:start_time, \"Please do not enter a past date or past time.\")\n\t\t\telsif start_at < start_at_plus_12_hours \n\t\t\t\terrors.add(:start_date, \"Please only enter a time 12 hours from now\")\n\t\t\tend\n\t\tend\n\tend",
"def invalid_schedule_time\n if !self.start_time.blank?\n if Schedule.check_invalid_duration(self.id, self.start_time, self.duration).count > 0\n errors.add_to_base \"Time conflict; a schedule exists and occurs during this time\"\n end\n end\n end",
"def stop_date_is_not_in_the_future\n errors.add(:stop_date_time, 'must come on or before midnight') if (stop_date_time && (stop_date_time > DateTime.now.end_of_day )) \n end",
"def ends_in_the_future\n return unless end_at.present? && Time.current > end_at\n\n errors.add(:end_at, 'must be in the future')\n end",
"def day_is_not_longer_than_24_hours\n if start_time && end_time\n errors.add(:end_time, \"must be no more than 24 hours after the start time\") unless (end_time - start_time)/3600 < 24\n end\n end",
"def start_time_must_be_before_end_time\n errors.add(:start_time, \"start time cannot be after end time\") if (start_time > end_time)\n end",
"def check_end_date_validation\n unless self.event_ends_on.blank?\n if self.event_ends_on < self.event_starts_on\n #Add errror\n self.errors.add(:event_ends_on, \"date should be greater than event start on date\")\n end\n end\n end",
"def calculate_end_time\n start_time = validate_start_time\n duration = validate_duration\n if start_time && duration\n self.end_time = start_time + (duration.hours - 60)\n end\n end",
"def start_time_before_end_time\n if start_time and end_time and start_time >= end_time\n errors.add(:start_time, \"Must be before end time\")\n errors.add(:end_time, \"Must be after start time\")\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests if end_time of course is not nil and a string and returns true or false | def end_time_is_valid?
return false unless not_nil_and_string(self.end_time)
return self.end_time.length > 0
end | [
"def end_time_is_valid\n errors.add(:end_time,'Invalid empty string for end time.') unless end_time_is_valid?\n end",
"def check_lesson_time_ending\r\n unless (start_time.strftime(\"%H:%M\").include? \"00\")\r\n errors.add(:start_time, \"Start time must end with ':00'\")\r\n end\r\n unless (end_time.strftime(\"%H:%M\").include? \"00\")\r\n errors.add(:end_time, \"Finish time must end with ':00'\")\r\n end\r\n end",
"def ended?\n end_time < Time.now.utc\n end",
"def start_time_is_valid?\n return false unless not_nil_and_string(self.start_time)\n return self.start_time.length > 0\n end",
"def ended?\n ended_at.present?\n end",
"def based_on_end_time?\n !based_on_start_time?\n end",
"def finished?\n !start_time.nil? && !end_time.nil?\n end",
"def workout_duration_is_valid?\n self.start_time < self.finish_time ? true : false\n end",
"def has_start_time?\n !start_time.blank?\n end",
"def time?(text)\n if datetime?(text)\n extract = Nickel.parse(text).occurrences[0].start_time\n extract.nil? ? false : true\n else\n false\n end\n\n rescue RuntimeError => e\n Failure.save_case(text, e)\n return false\n end",
"def ends_at_midnight?\n end_time == DAY_LENGTH\n end",
"def ensure_timing_has_value\n\t\tif (self.start_time.blank? || self.end_time.blank?)\n\t\t\tself.errors[:timing] << \"=> Provide start and end timing for Company\"\n\t\t\treturn false\n\t\tend\n\t\ttrue\n\tend",
"def end_time_after_start_time\n if start_time.present? && end_time.present?\n if end_time <= start_time\n errors.add(:end_time, \"must be after start time\")\n end\n end\n end",
"def end_date_set?\n end_date != nil\n end",
"def valid_duration?(text)\n ! /^[0-9]+:[0-9]{2,}:[0-9]{2,}$/.match(text).nil?\n end",
"def end_date_is_valid?\n begin\n date = USDateParse(self.end_date)\n rescue\n return false\n end\n return true\n end",
"def stopped?\n !@end_time.nil?\n end",
"def is_expired?\n (!end_time.nil? and end_time < Clock.time)\n end",
"def ends_in_the_future\n return unless end_at.present? && Time.current > end_at\n\n errors.add(:end_at, 'must be in the future')\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds errors if number_of_classes_is_valid? returns false | def number_of_classes_is_valid
errors.add(:number_of_classes, 'Invalid number of classes') unless number_of_classes_is_valid?
end | [
"def number_of_classes_is_valid?\n return ((self.number_of_classes != nil) and (self.number_of_classes > 0))\n end",
"def class_max_is_valid\n errors.add(:class_max,'Invalid class max value.') unless class_max_is_valid?\n end",
"def validate_as_component\n counts = Hash.new(0)\n to_ach.each do |record|\n unless record.valid?\n klass = record.class\n errors[\"#{klass}##{counts[klass] += 1}\"] = record.errors\n end\n end\n end",
"def class_min_is_valid\n errors.add(:class_min,'Invalid class min value.') unless class_min_is_valid?\n end",
"def subclass_validations ; true ; end",
"def step_validation\n step_index = form_steps[:pages].index(form_step)\n\n title_step = form_steps[:pages].index('title')\n if title_step && title_step <= step_index\n self.errors['name'] << 'You must enter a name for the dataset' if self.name.blank? || self.name.strip.blank?\n end\n\n connector_step = form_steps[:pages].index('connector')\n if connector_step && connector_step == step_index\n self.errors['type'] << 'You must enter a connector type' unless CONNECTOR_TYPES.include? self.type\n self.errors['provider'] << 'You must enter a connector provider' unless CONNECTOR_PROVIDERS.include? self.provider\n self.errors['connector_url'] << 'You must enter a valid url' \\\n unless self.connector_url && !self.connector_url.blank? && valid_url?(self.connector_url)\n if self.connector_url.present? && self.data_path.present? && !valid_xpath?(self.data_path)\n self.errors['data_path'] << 'If the JSON file is not structured as an array of objects in document root, please provide the path to data in Xpath format. Otherwise leave blank.'\n end\n end\n\n pages_step = form_steps[:pages].index('labels')\n if pages_step && pages_step <= step_index\n unless self.legend && self.legend.is_a?(Hash)\n self.errors['legend'] << 'Labels not correctly defined'\n return\n end\n self.errors['legend'] << 'Latitude and Longitude have to be filled together' if self.legend[:lat].blank? ^ self.legend[:long].blank?\n self.errors['legend'] << 'Country and Region have to be filled together' if self.legend[:country].blank? ^ self.legend[:region].blank?\n end\n end",
"def validation_class(meth, *klasses)\n klasses << 'has-error' if has_errors?(meth)\n klasses.compact.join(' ').html_safe\n end",
"def validate!\n # Validate each of the configured classes and store the results into\n # a hash.\n errors = self.class.configures_list.inject({}) do |container, data|\n key, _ = data\n recorder = ErrorRecorder.new\n send(key.to_sym).validate(recorder)\n container[key.to_sym] = recorder if !recorder.errors.empty?\n container\n end\n\n return if errors.empty?\n raise Errors::ConfigValidationFailed.new(:messages => Util::TemplateRenderer.render(\"config/validation_failed\", :errors => errors))\n end",
"def step_validation\n step_index = form_steps[:pages].index(form_step)\n\n if self.form_steps[:pages].index('title') <= step_index\n self.errors['name'] << 'You must enter a name for the dataset' if self.name.blank? || self.name.strip.blank?\n end\n\n if self.form_steps[:pages].index('connector') <= step_index\n self.errors['type'] << 'You must enter a connector type' unless CONNECTOR_TYPES.include? self.type\n self.errors['provider'] << 'You must enter a connector provider' unless CONNECTOR_PROVIDERS.include? self.provider\n self.errors['connector_url'] << 'You must enter a valid url' \\\n unless self.connector_url && !self.connector_url.blank? && valid_url?(self.connector_url)\n end\n\n if self.form_steps[:pages].index('labels') <= step_index\n unless self.legend && self.legend.is_a?(Hash)\n self.errors['legend'] << 'Labels not correctly defined'\n return\n end\n self.errors['legend'] << 'Latitude and Longitude have to be filled together' if\n self.legend[:lat].blank? ^ self.legend[:long].blank?\n self.errors['legend'] << 'Country and Region have to be filled together' if\n self.legend[:country].blank? ^ self.legend[:region].blank?\n end\n end",
"def failed_validations\n all_validations.select { |validation| validation.failed? }\n end",
"def step_validation\n form_steps = form_steps(false, false, true)\n step_index = form_steps[:pages].index(form_step)\n\n title_step = form_steps[:pages].index('title')\n if title_step && title_step <= step_index\n errors['name'] << 'You must enter a name for the dataset' if name.blank? || name.strip.blank?\n end\n\n connector_step = form_steps[:pages].index('connector')\n if connector_step && connector_step == step_index\n unless CONNECTOR_TYPES.include? type\n errors['type'] << 'You must enter a connector type'\n end\n unless CONNECTOR_PROVIDERS.include? provider\n errors['provider'] << 'You must enter a connector provider'\n end\n unless connector_url && !connector_url.blank? && valid_url?(connector_url)\n errors['connector_url'] << 'You must enter a valid url'\n end\n if connector_url.present? && data_path.present? && !valid_xpath?(data_path)\n errors['data_path'] << 'If the JSON file is not structured as an array of objects in document root, please provide the path to data in Xpath format. Otherwise leave blank.'\n end\n end\n\n pages_step = form_steps[:pages].index('labels')\n\n return unless pages_step && pages_step <= step_index\n\n unless legend&.is_a?(Hash)\n errors['legend'] << 'Labels not correctly defined'\n return\n end\n if legend[:lat].blank? ^ legend[:long].blank?\n errors['legend'] << 'Latitude and Longitude have to be filled together'\n end\n if legend[:country].blank? ^ legend[:region].blank?\n errors['legend'] << 'Country and Region have to be filled together'\n end\n end",
"def run_validations!\n super\n include_typecasting_errors\n errors.empty?\n end",
"def validation_errors\n errors = []\n ErrorCompiler.with_errors(errors) do |e|\n check_schools_consistency_in_each_round(e)\n check_legitimate_progress_through_rounds(e)\n check_wildcards(e)\n end\n errors\n end",
"def perform_validations\n remove_max_zero_items\n validate_ungrouped_minimums\n end",
"def course_id_is_valid\n errors.add(:course_id, \"No valid class was selected.\") unless course_id_is_valid?\n end",
"def validate_class_for(attribute, class_array)\n return true if class_array.include? @attributes[attribute].class\n add_error(attribute, \"must be a #{class_array.join(\" or \")} object (not #{@attributes[attribute].class})\")\n false \n end",
"def skip_superclass_validations?\n @skip_superclass_validations\n end",
"def set_errors\n @errors = []\n if self.college_name == \"\" || self.college_name == nil\n @errors << \"Must include valid College name\"\n end\n\n if self.conference_id == 0 || self.conference_id == nil\n @errors << \"Must choose Conference\"\n end\n end",
"def validation()\n\t @immediate_age = validate_single_field(@immediate_age,\"Immediate age cannot be converted into a number\",1.0)\n\t @commencement_age = validate_single_field(@commencement_age,\"Commencement age cannot be converted into a number\",1.0)\n\t @secondary_age = validate_single_field(@secondary_age,\"Spousal age cannot be converted into a number\",1.0)\n\t @joint_survivor_type = validate_single_field(@joint_survivor_type,\"JS Type cannot be converted into a number\",3.0)\n @joint_survivor_percent = validate_single_field(@joint_survivor_percent,\"JS percent cannot be converted into a number\",4.0)\n validate_mortality(@primary_mortality,\"Primary\")\n validate_mortality(@secondary_mortality,\"Secondary\") \n\t\t@interest_segment_a = validate_single_field(@interest_segment_a,\"Interest segment A cannot be converted into a number\",2.0)\n @interest_segment_b = validate_single_field(@interest_segment_b,\"Interest segment B cannot be converted into a number\",2.0)\n @interest_segment_c = validate_single_field(@interest_segment_c,\"Interest segment C cannot be converted into a number\",2.0) \n @certain_period = validate_single_field(@certain_period,\"Certain period cannot be converted into a number\",1.0)\n @temporary_period = validate_single_field(@temporary_period,\"Temporary period cannot be converted into a number\",1.0)\n @rounding = validate_single_field(@rounding,\"Rounding cannot be converted into a number\",5.0) \n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests if number_of_classes for course is not nil and is greater than 0 and returns true or false. | def number_of_classes_is_valid?
return ((self.number_of_classes != nil) and (self.number_of_classes > 0))
end | [
"def class_how_full?\n return [self.students.count, self.class_max]\n end",
"def only_has_regular_classes?\n object.courses.pluck(:type).all? { |class_type| class_type != 'Course::Training' }\n end",
"def last_of_course?\n \tchapter_count == lesson.chapters.count && lesson.lesson_count == course.lessons.count\n end",
"def class_max_is_valid?\n if ((self.class_max == nil) or (self.class_min == nil)); return false; end\n return ((self.class_max > 0) and (self.class_max >= self.class_min))\n end",
"def number_of_classes_is_valid\n errors.add(:number_of_classes, 'Invalid number of classes') unless number_of_classes_is_valid?\n end",
"def space_available?\n total_students < class_size\n end",
"def other_categories_remaining?\n course.assessment_categories.count > 1\n end",
"def critical?\n courses.size > 0\n end",
"def need_training?\n @need_training ||= (user_questions.count < 10)\n end",
"def critical?\n course_profs.size > 0\n end",
"def section_classes_all_there?\n section_classes_to_check.all?(&:all_there?)\n end",
"def class_in_search_result?(course_code, section_number)\n count = results_count class_results_count_element\n verify_block do\n if count > 50\n wait_until(2) { class_row_elements.length == 51 }\n logger.warn \"Skipping a test with #{course_code} because there are more than 50 results\"\n sleep 1\n else\n wait_until(Utils.medium_wait) do\n class_row_elements.length == count + 1\n class_link(course_code, section_number).when_visible 3\n end\n end\n end\n end",
"def sections_classes_all_there?\n sections_classes_to_check.flatten.all?(&:all_there?)\n end",
"def good?\n score <= Constants::THRESHOLDS[@class_type]\n end",
"def is_valid_cup_count?\n if (self.large_cup_count.present? || self.medium_cup_count.present? || self.small_cup_count.present?)\n part_small_cup_count = self.small_cup_count || small_cup_count\n part_medium_cup_count = self.medium_cup_count || medium_cup_count\n part_large_cup_count = self.large_cup_count || large_cup_count\n if(part_large_cup_count < part_medium_cup_count && part_medium_cup_count > 0)\n errors.add(:base,\"Large Cup Count should be Greater than Medium Cup Count\") #adds error to Active Model in order to stop record from being saved\n else\n if(part_medium_cup_count < part_small_cup_count && part_small_cup_count > 0)\n errors.add(:base,\"Medium Cup Count should be Greater than Small Cup Count\")\n else\n return true\n end\n end\n end\n end",
"def passing?\n return (self.product_tests.size > 0) && (self.product_tests.size == self.count_passing)\n end",
"def any_class_feature?(features)\n !features.select { |f| class_feature?(f) }.empty?\n end",
"def has_classes?\n c = @context.classes.find{|c| c.document_self}\n c ? true : false\n end",
"def has_required_proficiencies( a_class )\n #\n # if its specialized, we just let it thru\n #return true unless a_class.course.is_general\n \n #\n # currently, there aren't proficiencies below 100, so\n # if its a 100 course, we just let it thru\n return true if a_class.course.level == 100\n \n @path_semesters_sorted = list_of_instances_in_path\n proficiencies = list_of_proficiencies_in_path_for_class( a_class )\n \n max_slot = a_class.course.highest_slot_filled\n # if max_slot is 0, there are no incoming_proficiencies!!!\n return true if max_slot == 0\n \n logger.debug( \"proficiencies in path:\" )\n proficiencies.each do |p| logger.debug \" \" + p.fullname end\n \n 1.upto max_slot do |i|\n required_profs = a_class.course.incoming_proficiencies_for_slot(i)\n slot_requirements_met = true\n required_profs.each do |p|\n slot_requirements_met = false unless proficiencies.include?(p)\n logger.debug \"missing : \" + p.fullname unless proficiencies.include?(p)\n end\n return true if slot_requirements_met\n end\n false\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds errors if days_of_week_are_valid? returns false | def days_of_week_are_valid
errors.add(:days_of_week, "The days of the week are invalid.") unless days_of_week_are_valid?
end | [
"def day_of_the_week_correctness\n\t\tif day_of_the_week.blank?\n\t\t\treturn\n\t\tend\n\t\tif day_of_the_week < 0 or day_of_the_week > 6\n\t\t\terrors.add(:day_of_the_week, 'must be before 0 and 6')\n\t\tend\n\tend",
"def day_of_week(days)\n @validations[:day_of_week] ||= {}\n @validation_types[:day_of_week] ||= IceCube::DayOfWeekValidation.new(self)\n days.each do |day, occurrences|\n unless day.is_a?(Integer)\n raise ArgumentError.new('Argument must be a valid day of week') unless IceCube::DAYS.has_key?(day)\n day = IceCube::DAYS[day]\n end\n raise ArgumentError.new('Argument must be a valid day of week (0-6)') unless day >= 0 && day <= 6\n # add the day\n @validations[:day_of_week][day] ||= []\n @validations[:day_of_week][day].concat(occurrences)\n @validations[:day_of_week][day].uniq!\n end\n self\n end",
"def holiday_cannot_be_on_weekends\n if (self.date.strftime(\"%u\") == \"6\" or self.date.strftime(\"%u\") == \"7\")\n errors.add(:date, \"Holiday should not be on weekends\")\n end\n end",
"def holiday_cannot_be_on_weekends\n if (self.date.cwday == 6 or self.date.cwday == 7)\n errors.add(:date, \"Holiday should not be on weekends\")\n end\n end",
"def weekdate_must_be_sunday\n errors.add(:weekdate, 'must be a sunday') unless self.weekdate.wday == 0 # 0 is sunday\n end",
"def on_day_of_week(*days)\n days = days.collect{|d| numberize_day_of_week(d) }\n set_of_days = days.to_set\n raise ArgumentError, 'invalid days of week (0..6 are valid)' unless set_of_days.subset?(ALL_DAYS_OF_WEEK)\n @day_of_week = set_of_days\n self\n end",
"def days_of_week_are_valid?\n if (self.sunday == nil); return false; end\n if (self.monday == nil); return false; end\n if (self.tuesday == nil); return false; end\n if (self.wednesday == nil); return false; end\n if (self.thursday == nil); return false; end\n if (self.friday == nil); return false; end\n if (self.saturday == nil); return false; end\n\n if ((self.sunday != true) and (self.sunday != false)); return false; end\n if ((self.monday != true) and (self.monday != false)); return false; end\n if ((self.tuesday != true) and (self.tuesday != false)); return false; end\n if ((self.wednesday != true) and (self.wednesday != false)); return false; end\n if ((self.thursday != true) and (self.thursday != false)); return false; end\n if ((self.friday != true) and (self.friday != false)); return false; end\n if ((self.saturday != true) and (self.saturday != false)); return false; end\n return true\n end",
"def validate_day_of_week_index(day_of_week_index)\n day_of_week_index_optons = ['First','Second','Third','Fourth','Last']\n if day_of_week_index_optons.include? (day_of_week_index)\n return true\n else\n raise \"Days of Week Index value '#{day_of_week_index}' is invalid. Valid options are 'First','Second','Third','Fourth','Last'.\"\n end\n end",
"def validate_week_of\n input_week_of = self.week_of\n # correct day, assuming input week is a Time object\n # http://ruby-doc.org/core-2.2.0/Time.html#method-i-sunday-3F\n return input_week_of.monday?\n end",
"def validate_time_windows_days(definition, scope, attribute, days)\n valid_days = [:all, :sunday, :monday, :tuesday, :wednesday, :thursday, :friday, :saturday]\n if must_be_either(valid_days, days.keys)\n days.each do |day, conditions|\n if is_an_array?(conditions)\n if !conditions.empty?\n conditions.each do |condition|\n validate_time_window_condition(definition, scope, attribute, condition)\n end\n else\n invalid(definition, \"#{scope} #{attribute} days #{day} must include at least one time window\")\n end\n else\n invalid(definition, \"#{scope} #{attribute} days #{day} must be in an array\")\n end\n end\n else\n invalid(definition, \"#{scope} #{attribute} days must be valid days of the week or 'all'\")\n end\n end",
"def schedule_day_or_week_must_have_question\n errors.add(:base, \"Either day or week has to contain character ?\") if (schedule_day != \"?\") && (schedule_week != \"?\")\n end",
"def validation_errors\n travel_dates.valid?\n errors.each.to_a + travel_dates.errors\n end",
"def at_least_one_working_day_selected\n errors.add(:working_days, \"must be selected for at least one day\") if self.number_of_days_worked_in_a_week == 0\n end",
"def valid_week?(week)\n (1..21).include?(week.to_i)\n end",
"def at_least_one_day_selected\n unless monday or tuesday or wednesday or thursday or friday or saturday or sunday\n errors.add :on_days, \"At least one day must be selected\"\n end\n end",
"def bad_days_in_a_week(date)\n return @bad_days_in_a_week if @bad_days_in_a_week\n bad_days = 0\n day = Date.parse(date)\n for i in 0..6\n bad_days +=1 if bad_day?((day + i.days).to_s)\n end\n @bad_days_in_a_week = bad_days\n bad_days\n end",
"def fee_per_meeting_is_valid\n errors.add(:fee_per_meeting, 'The fee per meeting is invalid.') unless fee_per_meeting_is_valid?\n end",
"def days_of_week=(value)\n @days_of_week = value\n end",
"def check_for_errors\n if params[:booking]\n begin\n @start_date = params[:booking][:start_date].to_date\n # Don't allow dates in the past\n if @start_date < Time.now.to_date\n raise BookingError, \"Error: Start date can't be in the past\"\n end\n @end_date = params[:booking][:end_date].to_date\n # Don't allow start date to be after end date\n if @end_date < @start_date\n raise BookingError, \"Error: Start date needs to be before end date\"\n end\n # Check if dates are available\n date_arr = (@start_date..@end_date).to_a\n unavail_days = UnavailableDay.where(listing_id: @listing.id, day: date_arr)\n unless unavail_days.empty?\n raise BookingError, \"Error: Dates not available\"\n end\n # Calculate booking cost\n @num_days = date_arr.count\n if @num_days < 7\n # Daily rate\n @amount = @num_days * @listing.daily_price\n else\n # Weekly rate if renting 1 week or more\n @amount = (@num_days * (@listing.weekly_price / 7.0)).to_i\n end\n # Check for dodgy form manipulation\n if params[:booking][:total_cost] && @amount != params[:booking][:total_cost].to_i\n raise BookingError, \"Error: Amount Incorrect - Payment Stopped\"\n end\n # Catches custom errors above and invalid dates\n rescue BookingError, ArgumentError => e\n redirect_to new_listing_booking_path(@listing), alert: e.message\n return\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests that none of the days for course are nil and that the days's values are either true or false and returns true or false. | def days_of_week_are_valid?
if (self.sunday == nil); return false; end
if (self.monday == nil); return false; end
if (self.tuesday == nil); return false; end
if (self.wednesday == nil); return false; end
if (self.thursday == nil); return false; end
if (self.friday == nil); return false; end
if (self.saturday == nil); return false; end
if ((self.sunday != true) and (self.sunday != false)); return false; end
if ((self.monday != true) and (self.monday != false)); return false; end
if ((self.tuesday != true) and (self.tuesday != false)); return false; end
if ((self.wednesday != true) and (self.wednesday != false)); return false; end
if ((self.thursday != true) and (self.thursday != false)); return false; end
if ((self.friday != true) and (self.friday != false)); return false; end
if ((self.saturday != true) and (self.saturday != false)); return false; end
return true
end | [
"def perfectDayChecker day\n\t\t\t# If all five prayers were performed\n\t\t\tif day[:fajr] == 2 && day[:zuhr] == 2 && day[:asr] == 2 && day[:maghrib] == 2 && day[:isha] == 2\n\t\t\t \ttrue \t# Return true\n\t\t\telse\n\t\t\t\tfalse\t# Return false\n\t\t\tend\n\t\tend",
"def dates_not_nil?\n !from.nil? && !to.nil?\n end",
"def validate_daily_wellness\n if self.survey_type == \"Post-Practice\"\n return true\n elsif self.survey_type == \"Daily Wellness\"\n # check that all fields are not nil, since we are in daily wellness\n if !(self.hours_of_sleep.nil?) && (self.quality_of_sleep.nil?) && !(self.academic_stress.nil?) && !(self.life_stress.nil?) && !(self.soreness.nil?) && !(self.ounces_of_water_consumed.nil?) && !(self.hydration_quality.nil?)\n # validate the types of all of the fields, and that all are above 0\n if validate_sleep_field(self.hours_of_sleep) && validate_categorical_field(self.quality_of_sleep) && validate_categorical_field(self.academic_stress) && validate_categorical_field(self.life_stress) && validate_categorical_field(self.soreness) && validate_water_field(self.ounces_of_water_consumed) && validate_boolean_type(self.hydration_quality)\n return true\n else\n return false\n end\n else\n return false\n end\n else\n return false\n end\n end",
"def check_1\n people_in_morning_shifts = @days.map(&:morning)\n people_in_night_shifts = @days.map(&:night)\n\n no_more_than_3(people_in_morning_shifts) &&\n no_more_than_3(people_in_night_shifts)\n 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 valid?\n @dates && @table\n end",
"def completely_valid?\n course_valid = course.valid?\n valid? && course_valid\n end",
"def one_day_presence?\n if %w(day0 day1 day2 day3 day4 day5 day6 day7 ).all?{|attr| self[attr].blank? || self[attr].nil? }\n errors.add :base, \"At least one day must be populated\"\n raise ActiveRecord::RecordInvalid\n end\n end",
"def has_calendar?\n \t\t!calendar.nil?\n \tend",
"def valid_day?(month, day)\n pass_test = TRUE \n if month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12\n if day > 31 || day < 1\n pass_test = FALSE\n end \n end\n\n if month == 4 || month == 6 || month == 9 || month == 11\n if day > 30 || day < 1\n pass_test = FALSE\n end\n end\n return pass_test\nend",
"def all_days?\n @weekdays.all? { |_day, day_selected| day_selected }\n end",
"def registration_dates_given?\n registration_period.present? &&\n registration_period.start_date.present? &&\n registration_period.end_date.present?\n end",
"def all_day?\n !! all_day\n end",
"def past_all_due_dates?\n # If no section due dates /!\\ do not check empty? it could be wrong\n return false if !due_date.nil? && Time.current < due_date\n return false if assessment_section_properties.any? { |sec| !sec.due_date.nil? && Time.current < sec.due_date }\n\n true\n end",
"def valid_month_day_combination?\n return false if not @@valid_months.include?(@month)\n return false if not @@valid_days.include?(@day)\n return MmDdYyyyDate.numbers_of_days_in_month(@month) >= @day.to_i\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 include_day_or_empty?(day)\n self.include_day?(day) || self.day_set.empty?\n end",
"def draft_check\n draft_tutorial = self.draft\n draft_chapters = self.chapters.where({draft: true}).empty?\n draft_steps = self.steps.where({draft: true}).empty?\n\n if draft_tutorial == true || draft_chapters == false || draft_steps == false\n return true\n else\n return false\n end\n end",
"def dates_valid?\n date_check(params[:start_date]) && date_check(params[:end_date]) && dates_sequential?\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds errors if class_min_is_valid? returns false | def class_min_is_valid
errors.add(:class_min,'Invalid class min value.') unless class_min_is_valid?
end | [
"def class_max_is_valid\n errors.add(:class_max,'Invalid class max value.') unless class_max_is_valid?\n end",
"def number_of_classes_is_valid\n errors.add(:number_of_classes, 'Invalid number of classes') unless number_of_classes_is_valid?\n end",
"def subclass_validations ; true ; end",
"def class_min_is_valid?\n if ((self.class_min == nil) or (self.class_max == nil)); return false; end\n return ((self.class_min > 0) and (self.class_max >= self.class_min))\n end",
"def invalid!\n @invalid = true\n add_class(:invalid)\n end",
"def course_id_is_valid\n errors.add(:course_id, \"No valid class was selected.\") unless course_id_is_valid?\n end",
"def validation_class(meth, *klasses)\n klasses << 'has-error' if has_errors?(meth)\n klasses.compact.join(' ').html_safe\n end",
"def form_errors_class\n {:class => 'error'}\n end",
"def run_validations!\n super\n include_typecasting_errors\n errors.empty?\n end",
"def add_error_class_to(options)\n options[:label][:class].blank? ? options[:label][:class] = ERROR_CSS_CLASS : options[:label][:class] += ERROR_CSS_CLASS\n end",
"def classroom_is_valid\n errors.add(:classroom,\"Invalid empty string for classroom.\") unless classroom_is_valid?\n end",
"def skip_superclass_validations?\n @skip_superclass_validations\n end",
"def class_max_is_valid?\n if ((self.class_max == nil) or (self.class_min == nil)); return false; end\n return ((self.class_max > 0) and (self.class_max >= self.class_min))\n end",
"def perform_validations\n remove_max_zero_items\n validate_ungrouped_minimums\n end",
"def number_of_classes_is_valid?\n return ((self.number_of_classes != nil) and (self.number_of_classes > 0))\n end",
"def before_validation!\n return unless model_instance\n unless valid?\n errors.each do |name, message|\n model_instance.errors.add(\"#{column_name}.#{name}\", message)\n end\n end\n end",
"def validation_class\n if self.required?\n if self.style == 'drop-down'\n 'validate-selection' \n elsif self.style == 'rating'\n 'validate-rating'\n elsif self.style == 'acceptance'\n 'required'\n else\n 'validate-one-required'\n end\n else\n ''\n end\n end",
"def set_errors\n @errors = []\n if self.college_name == \"\" || self.college_name == nil\n @errors << \"Must include valid College name\"\n end\n\n if self.conference_id == 0 || self.conference_id == nil\n @errors << \"Must choose Conference\"\n end\n end",
"def check_validity\n unless @validator.valid? \n raise MicroformatInternalNotValid, \"The microformat does not have the required html classes\"\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests that class_min is not nil or that the class_max has not been set. It checks that the class_min is greater than 0 and that the class_max is greater than the class_min. It returns true or false. | def class_min_is_valid?
if ((self.class_min == nil) or (self.class_max == nil)); return false; end
return ((self.class_min > 0) and (self.class_max >= self.class_min))
end | [
"def class_max_is_valid?\n if ((self.class_max == nil) or (self.class_min == nil)); return false; end\n return ((self.class_max > 0) and (self.class_max >= self.class_min))\n end",
"def rating_check_max_greater_min\n\t\t\treturn if self.min_rating.nil? || self.max_rating.nil?\n\n\t\t\tif (self.min_rating <= self.max_rating)\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:max_rating, \"min_rating not less then max_rating\")\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def class_max_is_valid\n errors.add(:class_max,'Invalid class max value.') unless class_max_is_valid?\n end",
"def class_min_is_valid\n errors.add(:class_min,'Invalid class min value.') unless class_min_is_valid?\n end",
"def limits_ok?\n status = true\n if (@min.exp.to_s.include? '/') || (@max.exp.to_s.include? '/')\n return status\n end\n if @min.exp.nil? ^ @max.exp.nil?\n @limit_type = :single_sided\n if @typ.exp\n # status = false\n Origen.log.debug \"Spec #{@name} has a typical limit defined with either min or max. They are mutually exclusive, use 'target' when using min or max\"\n end\n elsif @min.exp && @max.exp\n @limit_type = :double_sided\n # Both min and max must be numerical to compare them\n if @min.value.is_a?(Numeric) && @max.value.is_a?(Numeric)\n # Check that min and max make sense\n if @max.value <= @min.value || @min.value >= @max.value\n status = false\n Origen.log.debug \"Spec #{@name} has min (#{@min.value}) and max (#{@max.value}) reversed\"\n end\n # Check that target is OK\n unless @target.nil?\n if @target.value <= @min.value || @target.value >= @max.value\n status = false\n Origen.log.debug \"Spec #{@name} has a target (#{@target.value}) that is not within the min (#{@min.value}) and max #{@max.value}) values\"\n end\n end\n end\n end\n status\n end",
"def limits_ok?\n status = true\n if (@min.exp.to_s.include? '/') || (@max.exp.to_s.include? '/')\n return status\n end\n\n if @min.exp.nil? ^ @max.exp.nil?\n @limit_type = :single_sided\n if @typ.exp\n # status = false\n Origen.log.debug \"Spec #{@name} has a typical limit defined with either min or max. They are mutually exclusive, use 'target' when using min or max\"\n end\n elsif @min.exp && @max.exp\n @limit_type = :double_sided\n # Both min and max must be numerical to compare them\n if @min.value.is_a?(Numeric) && @max.value.is_a?(Numeric)\n # Check that min and max make sense\n if @max.value <= @min.value || @min.value >= @max.value\n status = false\n Origen.log.debug \"Spec #{@name} has min (#{@min.value}) and max (#{@max.value}) reversed\"\n end\n # Check that target is OK\n unless @target.nil?\n if @target.value <= @min.value || @target.value >= @max.value\n status = false\n Origen.log.debug \"Spec #{@name} has a target (#{@target.value}) that is not within the min (#{@min.value}) and max #{@max.value}) values\"\n end\n end\n end\n end\n status\n end",
"def min_can_not_be_bigger_than_max\n if !max_credits.nil? && !min_credits.nil? && min_credits.to_int > max_credits.to_int\n errors.add(:minimum_credits, \"can't be greater than maximum credits\")\n end\n end",
"def between?(min, max)\n self >= min and self <= max\n end",
"def define_min_and_max\n @min = acceptable_min\n @max = acceptable_max\n\n # If necessary, adjust a value depending on the other\n @min ||= floor\n @max ||= @min + ceiling || ceiling # rubocop:disable Naming/MemoizedInstanceVariableName\n end",
"def min_is_less_than_max_estimate\n if self.min_estimated_minutes.present? && self.max_estimated_minutes.present?\n errors.add(:min_estimated_minutes, \"must be less than the maximum\") if self.max_estimated_minutes < self.min_estimated_minutes\n end\n end",
"def be_between(min, max); end",
"def between(min, max, &block)\n return false unless (1..min).all? { try(&block) }\n (min..max).all? { try(&block) } # only using all?'s shortcut property\n true\n end",
"def out_of_bound?(value, min, max)\n return value > max || value < min\n end",
"def between(num, min, max)\n if min <= num && max >= num\n return true\n else \n return false\n end\nend",
"def number_of_classes_is_valid?\n return ((self.number_of_classes != nil) and (self.number_of_classes > 0))\n end",
"def rating_check_min\n\t\t\treturn if self.min_rating.nil?\n\n\t\t\tif ((self.min_rating==0 || self.min_rating>99) && self.min_rating<3000)\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:min_rating, \"doesnt have correct max_rating\")\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def max_and_min_set?(pagefile, min, max)\n logger.trace(\"Checking if #{pagefile} has max and initial disk size values set\")\n powershell_code = <<-CODE\n $page_file = '#{pagefile}';\n $driveLetter = $page_file.split(':')[0];\n $page_file_settings = Get-CimInstance -ClassName Win32_PageFileSetting -Filter \"SettingID='pagefile.sys @ $($driveLetter):'\" -Property * -ErrorAction Stop;\n if ($page_file_settings.InitialSize -eq #{min} -and $page_file_settings.MaximumSize -eq #{max})\n { return $true }\n else\n { return $false }\n CODE\n powershell_exec!(powershell_code).result\n end",
"def rating_check_max\n\t\t\treturn if self.max_rating.nil?\n\t\n\t\t\tif ((self.max_rating==0 || self.max_rating>99) && self.max_rating<3000)\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:max_rating, \"doesnt have correct max_rating\")\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def gte_min?(integer_value)\n return true if min.nil?\n integer_value >= min\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds errors if class_max_is_valid? returns false | def class_max_is_valid
errors.add(:class_max,'Invalid class max value.') unless class_max_is_valid?
end | [
"def number_of_classes_is_valid\n errors.add(:number_of_classes, 'Invalid number of classes') unless number_of_classes_is_valid?\n end",
"def class_min_is_valid\n errors.add(:class_min,'Invalid class min value.') unless class_min_is_valid?\n end",
"def class_max_is_valid?\n if ((self.class_max == nil) or (self.class_min == nil)); return false; end\n return ((self.class_max > 0) and (self.class_max >= self.class_min))\n end",
"def validate_max_errors=(_arg0); end",
"def number_of_classes_is_valid?\n return ((self.number_of_classes != nil) and (self.number_of_classes > 0))\n end",
"def class_min_is_valid?\n if ((self.class_min == nil) or (self.class_max == nil)); return false; end\n return ((self.class_min > 0) and (self.class_max >= self.class_min))\n end",
"def subclass_validations ; true ; end",
"def validates_max_value(max, atts, opts=OPTS)\n validatable_attributes_for_type(:max_value, atts, opts) do |a,v,m|\n validation_error_message(m, max) if !v.nil? && v > max\n end\n end",
"def course_id_is_valid\n errors.add(:course_id, \"No valid class was selected.\") unless course_id_is_valid?\n end",
"def validate\n if offering_review_criterion && !score.blank? && score > max_score\n errors.add(:score, \"cannot be greater than the maximum score of #{max_score}\") \n end\n end",
"def validation_class(meth, *klasses)\n klasses << 'has-error' if has_errors?(meth)\n klasses.compact.join(' ').html_safe\n end",
"def reduce_max_times_if_no_more_registrations\n errors.add(:max_times, 'already has more registrations') if max_times_changed? && max_times < registrations.count && max_times != 0\n end",
"def invalid!\n @invalid = true\n add_class(:invalid)\n end",
"def validate_class_for(attribute, class_array)\n return true if class_array.include? @attributes[attribute].class\n add_error(attribute, \"must be a #{class_array.join(\" or \")} object (not #{@attributes[attribute].class})\")\n false \n end",
"def form_errors_class\n {:class => 'error'}\n end",
"def invalid_field_error_class\n (\"Invalid\" + self.field_name.split(\"_\").map(&:capitalize).join + \\\n \"FieldError\").classify.safe_constantize\n end",
"def validate_as_component\n counts = Hash.new(0)\n to_ach.each do |record|\n unless record.valid?\n klass = record.class\n errors[\"#{klass}##{counts[klass] += 1}\"] = record.errors\n end\n end\n end",
"def add_error_class_to(options)\n options[:label][:class].blank? ? options[:label][:class] = ERROR_CSS_CLASS : options[:label][:class] += ERROR_CSS_CLASS\n end",
"def rating_check_max\n\t\t\treturn if self.max_rating.nil?\n\t\n\t\t\tif ((self.max_rating==0 || self.max_rating>99) && self.max_rating<3000)\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:max_rating, \"doesnt have correct max_rating\")\n\t\t\t\treturn false\n\t\t\tend\n\t\tend"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests that class_max is not nil or that the class_min has not been set. It checks that the class_max is greater than 0 and that the class_max is greater than the class_min. It returns true or false. | def class_max_is_valid?
if ((self.class_max == nil) or (self.class_min == nil)); return false; end
return ((self.class_max > 0) and (self.class_max >= self.class_min))
end | [
"def class_min_is_valid?\n if ((self.class_min == nil) or (self.class_max == nil)); return false; end\n return ((self.class_min > 0) and (self.class_max >= self.class_min))\n end",
"def class_max_is_valid\n errors.add(:class_max,'Invalid class max value.') unless class_max_is_valid?\n end",
"def rating_check_max_greater_min\n\t\t\treturn if self.min_rating.nil? || self.max_rating.nil?\n\n\t\t\tif (self.min_rating <= self.max_rating)\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:max_rating, \"min_rating not less then max_rating\")\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def class_min_is_valid\n errors.add(:class_min,'Invalid class min value.') unless class_min_is_valid?\n end",
"def limits_ok?\n status = true\n if (@min.exp.to_s.include? '/') || (@max.exp.to_s.include? '/')\n return status\n end\n if @min.exp.nil? ^ @max.exp.nil?\n @limit_type = :single_sided\n if @typ.exp\n # status = false\n Origen.log.debug \"Spec #{@name} has a typical limit defined with either min or max. They are mutually exclusive, use 'target' when using min or max\"\n end\n elsif @min.exp && @max.exp\n @limit_type = :double_sided\n # Both min and max must be numerical to compare them\n if @min.value.is_a?(Numeric) && @max.value.is_a?(Numeric)\n # Check that min and max make sense\n if @max.value <= @min.value || @min.value >= @max.value\n status = false\n Origen.log.debug \"Spec #{@name} has min (#{@min.value}) and max (#{@max.value}) reversed\"\n end\n # Check that target is OK\n unless @target.nil?\n if @target.value <= @min.value || @target.value >= @max.value\n status = false\n Origen.log.debug \"Spec #{@name} has a target (#{@target.value}) that is not within the min (#{@min.value}) and max #{@max.value}) values\"\n end\n end\n end\n end\n status\n end",
"def limits_ok?\n status = true\n if (@min.exp.to_s.include? '/') || (@max.exp.to_s.include? '/')\n return status\n end\n\n if @min.exp.nil? ^ @max.exp.nil?\n @limit_type = :single_sided\n if @typ.exp\n # status = false\n Origen.log.debug \"Spec #{@name} has a typical limit defined with either min or max. They are mutually exclusive, use 'target' when using min or max\"\n end\n elsif @min.exp && @max.exp\n @limit_type = :double_sided\n # Both min and max must be numerical to compare them\n if @min.value.is_a?(Numeric) && @max.value.is_a?(Numeric)\n # Check that min and max make sense\n if @max.value <= @min.value || @min.value >= @max.value\n status = false\n Origen.log.debug \"Spec #{@name} has min (#{@min.value}) and max (#{@max.value}) reversed\"\n end\n # Check that target is OK\n unless @target.nil?\n if @target.value <= @min.value || @target.value >= @max.value\n status = false\n Origen.log.debug \"Spec #{@name} has a target (#{@target.value}) that is not within the min (#{@min.value}) and max #{@max.value}) values\"\n end\n end\n end\n end\n status\n end",
"def min_can_not_be_bigger_than_max\n if !max_credits.nil? && !min_credits.nil? && min_credits.to_int > max_credits.to_int\n errors.add(:minimum_credits, \"can't be greater than maximum credits\")\n end\n end",
"def rating_check_max\n\t\t\treturn if self.max_rating.nil?\n\t\n\t\t\tif ((self.max_rating==0 || self.max_rating>99) && self.max_rating<3000)\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:max_rating, \"doesnt have correct max_rating\")\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def number_of_classes_is_valid?\n return ((self.number_of_classes != nil) and (self.number_of_classes > 0))\n end",
"def capacities_correct?(max, init, final)\n correct = true\n 0.upto(max.size-1) { |i|\n correct = false if max[i] < init[i] || max[i] < final[i]\n }\n return correct\n end",
"def between?(min, max)\n self >= min and self <= max\n end",
"def define_min_and_max\n @min = acceptable_min\n @max = acceptable_max\n\n # If necessary, adjust a value depending on the other\n @min ||= floor\n @max ||= @min + ceiling || ceiling # rubocop:disable Naming/MemoizedInstanceVariableName\n end",
"def min_is_less_than_max_estimate\n if self.min_estimated_minutes.present? && self.max_estimated_minutes.present?\n errors.add(:min_estimated_minutes, \"must be less than the maximum\") if self.max_estimated_minutes < self.min_estimated_minutes\n end\n end",
"def max?\n @number == @max_num\n end",
"def out_of_bound?(value, min, max)\n return value > max || value < min\n end",
"def max_and_min_set?(pagefile, min, max)\n logger.trace(\"Checking if #{pagefile} has max and initial disk size values set\")\n powershell_code = <<-CODE\n $page_file = '#{pagefile}';\n $driveLetter = $page_file.split(':')[0];\n $page_file_settings = Get-CimInstance -ClassName Win32_PageFileSetting -Filter \"SettingID='pagefile.sys @ $($driveLetter):'\" -Property * -ErrorAction Stop;\n if ($page_file_settings.InitialSize -eq #{min} -and $page_file_settings.MaximumSize -eq #{max})\n { return $true }\n else\n { return $false }\n CODE\n powershell_exec!(powershell_code).result\n end",
"def rating_check_min\n\t\t\treturn if self.min_rating.nil?\n\n\t\t\tif ((self.min_rating==0 || self.min_rating>99) && self.min_rating<3000)\n\t\t\t\treturn true\n\t\t\telse\n\t\t\t\terrors.add(:min_rating, \"doesnt have correct max_rating\")\n\t\t\t\treturn false\n\t\t\tend\n\t\tend",
"def maximum_set?\n maximum != 0\n end",
"def class_how_full?\n return [self.students.count, self.class_max]\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds errors if fee_per_meeting_is_valid? returns false | def fee_per_meeting_is_valid
errors.add(:fee_per_meeting, 'The fee per meeting is invalid.') unless fee_per_meeting_is_valid?
end | [
"def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end",
"def fee_per_meeting_is_valid?\n return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))\n end",
"def fee_for_additional_materials_is_valid\n errors.add(:fee_for_additional_materials, 'The fee for additional materials is invalid.') unless fee_for_additional_materials_is_valid?\n end",
"def validate_meal\n meal.events.each do |event|\n next if event.valid?\n errors = event.errors.map do |attrib, msg|\n attrib == :base ? msg : \"#{Calendars::Event.human_attribute_name(attrib)}: #{msg}\"\n end.join(\", \")\n meal.errors.add(:base,\n \"The following error(s) occurred in making a #{event.calendar_name} event \"\\\n \"for this meal: #{errors}.\")\n end\n\n # Since we are copying these errors to the meal base, we don't need them in the\n # events base anymore.\n meal.errors.delete(:\"events.base\")\n end",
"def total_fee_is_valid?\n return ((self.total_fee != nil) and (self.total_fee >= 0))\n end",
"def days_of_week_are_valid\n errors.add(:days_of_week, \"The days of the week are invalid.\") unless days_of_week_are_valid?\n end",
"def check_for_errors\n if params[:booking]\n begin\n @start_date = params[:booking][:start_date].to_date\n # Don't allow dates in the past\n if @start_date < Time.now.to_date\n raise BookingError, \"Error: Start date can't be in the past\"\n end\n @end_date = params[:booking][:end_date].to_date\n # Don't allow start date to be after end date\n if @end_date < @start_date\n raise BookingError, \"Error: Start date needs to be before end date\"\n end\n # Check if dates are available\n date_arr = (@start_date..@end_date).to_a\n unavail_days = UnavailableDay.where(listing_id: @listing.id, day: date_arr)\n unless unavail_days.empty?\n raise BookingError, \"Error: Dates not available\"\n end\n # Calculate booking cost\n @num_days = date_arr.count\n if @num_days < 7\n # Daily rate\n @amount = @num_days * @listing.daily_price\n else\n # Weekly rate if renting 1 week or more\n @amount = (@num_days * (@listing.weekly_price / 7.0)).to_i\n end\n # Check for dodgy form manipulation\n if params[:booking][:total_cost] && @amount != params[:booking][:total_cost].to_i\n raise BookingError, \"Error: Amount Incorrect - Payment Stopped\"\n end\n # Catches custom errors above and invalid dates\n rescue BookingError, ArgumentError => e\n redirect_to new_listing_booking_path(@listing), alert: e.message\n return\n end\n end\n end",
"def edit_fee_fields_filled\n if !params[:edit_fees].nil?\n edit_fees_vals = params[:edit_fees].values\n edit_fees_vals.each_slice(3) do |fee, time, remove|\n if fee.empty? || time.empty?\n return false\n end\n end\n end\n return true\n end",
"def valid_registration_date\n errors.add(:registration_deadline, 'invalid.') unless registration_date_is_valid?\n end",
"def validation_errors\n travel_dates.valid?\n errors.each.to_a + travel_dates.errors\n end",
"def validate_amortization()\n return if !fee?\n\n raise \"fee_amortization_type not set\" if !self.fee_amortization_type\n\n case self.fee_amortization_type.code.to_sym\n when :not_amortized, :interest_ratio\n nullify_amort_amount_and_dates\n when :straight_line_with_amount_and_duration_by_day,\n :straight_line_with_amount_and_duration_by_month\n validate_amort_amount\n validate_amort_dates\n else\n errors.add(:fee_amortization_type, \"系统不支持该中间业务收入摊销方式\")\n end\n end",
"def valid_registration_date\n errors.add(:registration_deadline, 'The registration deadline could not be parsed.') unless registration_date_is_valid?\n end",
"def validate_funding\n # randomize funding method!\n validate_random_day 'Funding Method', EngagementRequest::FUNDING_METHODS[self.funding_method]\n\n # sponsor is funding it!\n if self.cost_center != self.sponsor.department.cost_center\n add_validation \"Cost Center should match the Sponsor's cost center\"\n end\n\n # detailed estimate must be funding approved!\n if self.detailed_estimate? && ! (self.approved? || self.budget?)\n add_validation EngagementRequest::ENGAGEMENT_TYPES[self.engagement_type] + ' must have budget ' +\n EngagementRequest::FUNDING_STATUSES[\"approved\"] + ' or ' +\n EngagementRequest::FUNDING_STATUSES[\"budget\"]\n end\n # scheduling or rescue must have budget!\n if (self.scheduling? || self.rescue?) && ! self.budget?\n add_validation EngagementRequest::ENGAGEMENT_TYPES[self.engagement_type] + ' must have ' +\n EngagementRequest::FUNDING_STATUSES[\"budget\"]\n end\n\n # must have a decent budget!\n if self.budget_allocated < 100_000\n add_validation 'Projects with a budget of less than $100,000 are not accepted'\n end\n end",
"def fee_for_additional_materials_is_valid?\n return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))\n end",
"def set_errors\n @errors = []\n if self.college_name == \"\" || self.college_name == nil\n @errors << \"Must include valid College name\"\n end\n\n if self.conference_id == 0 || self.conference_id == nil\n @errors << \"Must choose Conference\"\n end\n end",
"def verify_fees(test_data)\n fees = test_data[UseOfCollections::FEE_GRP.name] || [UseOfCollections.empty_fee]\n fees.each_with_index do |fee, index|\n verify_values_match(fee[UseOfCollections::FEE_CURRENCY.name], element_value(fee_currency_input index))\n verify_values_match(fee[UseOfCollections::FEE_VALUE.name], element_value(fee_value_input index))\n verify_values_match(fee[UseOfCollections::FEE_NOTE.name], element_value(fee_note_input index))\n end\n end",
"def failed_validations\n all_validations.select { |validation| validation.failed? }\n end",
"def verify_fees(test_data)\n fees = test_data[CoreUseOfCollectionsData::FEE_GRP.name] || [CoreUseOfCollectionsData.empty_fee]\n fees.each_with_index do |fee, index|\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_CURRENCY.name], element_value(fee_currency_input index))\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_VALUE.name], element_value(fee_value_input index))\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_NOTE.name], element_value(fee_note_input index))\n end\n end",
"def time_period_for_room_reservation\n time_period = (self.start_date.year * 12 + self.start_date.month) - (Date.today.year * 12 + Date.today.month)\n errors.add(:start_date, \"you can book your room before 6 months only\") if time_period > 6\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests that the fee_per_meeting for course is not nil and greater than or equal to 0 and returns true or false. | def fee_per_meeting_is_valid?
return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))
end | [
"def total_fee_is_valid?\n return ((self.total_fee != nil) and (self.total_fee >= 0))\n end",
"def scholarship_amount_is_valid?\n return false unless self.scholarship_amount != nil\n course = Course.find_by_id(self.course_id)\n return false unless course #make sure course is non-nil\n return ((self.scholarship_amount >= 0) and (self.scholarship_amount <= course.total_fee)) #Make sure the scholarship fee is non-negative and that it is also less than or equal to the total course fee\n end",
"def free?\n self.setupFee == 0 && self.laborFee == 0 && self.oneTimeFee == 0 && self.recurringFee == 0 && self.hourlyRecurringFee == 0\n end",
"def fee_per_meeting_is_valid\n errors.add(:fee_per_meeting, 'The fee per meeting is invalid.') unless fee_per_meeting_is_valid?\n end",
"def fee_for_additional_materials_is_valid?\n return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))\n end",
"def add_fee_filled_or_empty\n if !params[:add_fee].nil?\n add_fee_keys = params[:add_fee].keys\n add_fee_vals = params[:add_fee].values\n add_fee_vals.each_slice(3) do |student_type, amount, time_period|\n if !((!student_type.empty? && !amount.empty? && !time_period.empty?) ||\n (student_type.empty? && amount.empty? && time_period.empty?))\n return false\n end\n end\n end\n return true\n end",
"def can_guest_afford_fee(cash)\n cash > room_fee_per_guest ? true : false\n end",
"def has_excess_funds\n true if total_contributions > goal_amount\n end",
"def calculated?\n fee_type&.calculated?.nil? ? true : fee_type.calculated?\n end",
"def zero_payment?\r\n total_amount_paid_for_claim.to_f.zero?\r\n end",
"def can_pay_total?\n\n conf_payment_enabled = SystemConfiguration::Variable.get_value('booking.payment', 'false').to_bool\n conf_payment_total = (['total','deposit_and_total'].include?(SystemConfiguration::Variable.get_value('booking.payment_amount_setup', 'deposit')))\n\n if self.status == :pending_confirmation\n (conf_payment_enabled or force_allow_payment) and conf_payment_total and self.total_paid == 0 and ((!expired? and payment_cadence_allowed?) or force_allow_payment)\n elsif self.status == :confirmed # Confirmed in the back-office without payment\n (conf_payment_enabled or force_allow_payment) and conf_payment_total and self.total_paid == 0 and self.total_pending > 0\n else\n return false\n end\n\n end",
"def is_percentage_fee_overriden?\n if !self.override_percentage_fee.blank? and self.override_percentage_fee > 0 and self.override_percentage_fee != StaticDataLancer::JOB_ORDER_PERCENTAGE_FEE\n return true\n else\n return false\n end\n end",
"def cash_valid\n\t\tif self.incoming_cash\n\t\t\tif ! self.incoming_cash.between?(0,1000000000)\n\t\t\t\treturn false\n\t\t\tend\n\t\t\tif self.incoming_cash > Team.find(self.offeree_id).cash_balance\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\tif self.outgoing_cash\n\t\t\tif ! self.outgoing_cash.between?(0,1000000000)\n\t\t\t\treturn false\n\t\t\tend\n\t\t\tif self.outgoing_cash > Team.find(self.offeror_id).cash_balance\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\treturn true\n\tend",
"def allowed_to_pay_renewal_member_fee?\n return false if admin?\n\n (current_member? || in_grace_period?) &&\n requirements_for_renewal.requirements_excluding_payments_met?(self)\n end",
"def fee?\n self.instance_of?(SecurityDeposit) ? false : true\n end",
"def booking_deadline_has_passed?\n Date.current > deadline\n end",
"def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end",
"def remaining_hours?\n remaining_hours > 0\n end",
"def check_fee_category\n self.has_paid_fees?\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds errors if fee_for_additional_materials returns false | def fee_for_additional_materials_is_valid
errors.add(:fee_for_additional_materials, 'The fee for additional materials is invalid.') unless fee_for_additional_materials_is_valid?
end | [
"def fee_for_additional_materials_is_valid?\n return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))\n end",
"def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end",
"def validate_materials\n if !self.materials || self.materials.size == 0\n errors.add(:materials, :at_least_one, :count => 1)\n end\n end",
"def fee_per_meeting_is_valid\n errors.add(:fee_per_meeting, 'The fee per meeting is invalid.') unless fee_per_meeting_is_valid?\n end",
"def mods_assets_update_validation\n i = 0\n desc_metadata = params[:asset][:descMetadata]\n unless desc_metadata.nil?\n while desc_metadata.has_key? \"person_#{i}_computing_id\".to_sym\n if desc_metadata[\"person_#{i}_first_name\".to_sym][\"0\"].blank? or desc_metadata[\"person_#{i}_last_name\".to_sym][\"0\"].blank?\n flash[:error] = \"The First and Last names are required for all authors.\"\n return false\n end\n i += 1\n end\n end\n return true\n end",
"def check_add_errors(items)\n flag = false\n items = items.compact\n items.each_with_index do |item, index|\n \n if item.errors.any?\n item.errors.full_messages.each do |message|\n errors.add :base, \"#{message}\"\n end\n flag = true\n end\n \n if not item.valid?\n puts \"IMPORT --- item not valid: #{item.inspect}\".red\n errors.add :base, item.errors.full_messages\n flag = true\n end\n end\n return flag\n end",
"def edit_fee_fields_filled\n if !params[:edit_fees].nil?\n edit_fees_vals = params[:edit_fees].values\n edit_fees_vals.each_slice(3) do |fee, time, remove|\n if fee.empty? || time.empty?\n return false\n end\n end\n end\n return true\n end",
"def materials_data_valid?\n @materials_data.size > 0\n end",
"def add_fee_filled_or_empty\n if !params[:add_fee].nil?\n add_fee_keys = params[:add_fee].keys\n add_fee_vals = params[:add_fee].values\n add_fee_vals.each_slice(3) do |student_type, amount, time_period|\n if !((!student_type.empty? && !amount.empty? && !time_period.empty?) ||\n (student_type.empty? && amount.empty? && time_period.empty?))\n return false\n end\n end\n end\n return true\n end",
"def create\n @additional_fee = AdditionalFee.new(additional_fee_params)\n\n respond_to do |format|\n if @additional_fee.save\n format.html { redirect_to @additional_fee, notice: 'Additional fee was successfully created.' }\n format.json { render :show, status: :created, location: @additional_fee }\n else\n format.html { render :new }\n format.json { render json: @additional_fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validate_material\n\n type = params[:material_type]\n id = params[:material_id]\n\n begin\n item = get_materials_item id, type\n rescue ActiveRecord::RecordNotFound => rnf\n render json: {\n :message => \"Invalid material type (#{type}) or id (#{id})\"},\n :status => 400\n return\n end\n\n end",
"def attr_modifications\n errors.add( :group_id, I18n.t( 'sir_items.msg.bad_grp_chg' )) \\\n unless sir_entries.empty? || ( @prev_group_id == group_id ) || @prev_group_id.nil?\n errors.add( :status, I18n.t( 'sir_items.msg.bad_status' )) \\\n unless status != 0 || sir_entries.empty?\n end",
"def valid_income_item\n self.errors[:item_id] << I18n.t('errors.messages.income_detail.item_not_for_sale') unless item_for_sale?\n end",
"def add_errors(member_alias)\n @errors[:schedule_not_fetched] = \"-#{member_alias}- #{@errors[:schedule_not_fetched]}\"\n end",
"def transaction_validation(model)\n return if model.effective_date.present?\n\n model.errors.add(:base, :missing_about_the_transaction, link_id: 'add_transaction_details')\n end",
"def valid?\n @errors = []\n\n if !manual_journal_id.nil? && manual_journal_id !~ GUID_REGEX\n @errors << ['manual_journal_id', 'must be blank or a valid Xero GUID']\n end\n\n if narration.blank?\n \t@errors << ['narration', \"can't be blank\"]\n end\n\n unless date\n @errors << ['date', \"can't be blank\"]\n end\n\n # Make sure all journal_items are valid.\n unless journal_lines.all? { | journal_line | journal_line.valid? }\n @errors << ['journal_lines', \"at least one journal line invalid\"]\n end\n\n # make sure there are at least 2 journal lines\n unless journal_lines.length > 1\n \t@errors << ['journal_lines', \"journal must contain at least two individual journal lines\"]\n end\n\n if journal_lines.length > 100\n \t@errors << ['journal_lines', \"journal must contain less than one hundred journal lines\"]\n end\n\n unless journal_lines.sum(&:line_amount).to_f == 0.0\n \t@errors << ['journal_lines', \"the total debits must be equal to total credits\"]\n end\n\n @errors.size == 0\n end",
"def total_fee_is_valid?\n return ((self.total_fee != nil) and (self.total_fee >= 0))\n end",
"def validate_meal\n meal.events.each do |event|\n next if event.valid?\n errors = event.errors.map do |attrib, msg|\n attrib == :base ? msg : \"#{Calendars::Event.human_attribute_name(attrib)}: #{msg}\"\n end.join(\", \")\n meal.errors.add(:base,\n \"The following error(s) occurred in making a #{event.calendar_name} event \"\\\n \"for this meal: #{errors}.\")\n end\n\n # Since we are copying these errors to the meal base, we don't need them in the\n # events base anymore.\n meal.errors.delete(:\"events.base\")\n end",
"def update\n respond_to do |format|\n if @additional_fee.update(additional_fee_params)\n format.html { redirect_to @additional_fee, notice: 'Additional fee was successfully updated.' }\n format.json { render :show, status: :ok, location: @additional_fee }\n else\n format.html { render :edit }\n format.json { render json: @additional_fee.errors, status: :unprocessable_entity }\n end\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests that fee_for_additional_material for course is not nil and greater than or equal to 0 and returns true or false. | def fee_for_additional_materials_is_valid?
return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))
end | [
"def total_fee_is_valid?\n return ((self.total_fee != nil) and (self.total_fee >= 0))\n end",
"def fee_per_meeting_is_valid?\n return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))\n end",
"def fee_for_additional_materials_is_valid\n errors.add(:fee_for_additional_materials, 'The fee for additional materials is invalid.') unless fee_for_additional_materials_is_valid?\n end",
"def add_fee_filled_or_empty\n if !params[:add_fee].nil?\n add_fee_keys = params[:add_fee].keys\n add_fee_vals = params[:add_fee].values\n add_fee_vals.each_slice(3) do |student_type, amount, time_period|\n if !((!student_type.empty? && !amount.empty? && !time_period.empty?) ||\n (student_type.empty? && amount.empty? && time_period.empty?))\n return false\n end\n end\n end\n return true\n end",
"def free?\n self.setupFee == 0 && self.laborFee == 0 && self.oneTimeFee == 0 && self.recurringFee == 0 && self.hourlyRecurringFee == 0\n end",
"def scholarship_amount_is_valid?\n return false unless self.scholarship_amount != nil\n course = Course.find_by_id(self.course_id)\n return false unless course #make sure course is non-nil\n return ((self.scholarship_amount >= 0) and (self.scholarship_amount <= course.total_fee)) #Make sure the scholarship fee is non-negative and that it is also less than or equal to the total course fee\n end",
"def calculated?\n fee_type&.calculated?.nil? ? true : fee_type.calculated?\n end",
"def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end",
"def claim_amount_required?\n @full_repayment_of_ads != 'Y'\n end",
"def validate_total_effort?\n self.production_rate? && self.estimated_size? && self.total_effort?\n end",
"def has_excess_funds\n true if total_contributions > goal_amount\n end",
"def zero_payment?\r\n total_amount_paid_for_claim.to_f.zero?\r\n end",
"def total_mismatch?\n !total_mass.equal?(total_score)\n end",
"def redeemable?\n credits and credits > 0 and item_type != 'Credits'\n end",
"def ready_for_tax_calc?\n @effective_date.present? && @flbt_type.present? && property_type.present? && amounts_for_tax_calc?\n end",
"def bonus_grade?\n return false if grade_entry_item.nil?\n grade_entry_item.bonus?\n end",
"def paid_enough?\n errors.add(:paid,'You don\\'t paid enough') unless self.product.value <= self.total_paid\n end",
"def free_cart?\n total_amount <= 0\n end",
"def allowed_to_pay_renewal_member_fee?\n return false if admin?\n\n (current_member? || in_grace_period?) &&\n requirements_for_renewal.requirements_excluding_payments_met?(self)\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Adds errors if total_fee_is_valid? returns false | def total_fee_is_valid
errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?
end | [
"def fee_for_additional_materials_is_valid\n errors.add(:fee_for_additional_materials, 'The fee for additional materials is invalid.') unless fee_for_additional_materials_is_valid?\n end",
"def fee_per_meeting_is_valid\n errors.add(:fee_per_meeting, 'The fee per meeting is invalid.') unless fee_per_meeting_is_valid?\n end",
"def total_fee_is_valid?\n return ((self.total_fee != nil) and (self.total_fee >= 0))\n end",
"def fee_for_additional_materials_is_valid?\n return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))\n end",
"def fee_per_meeting_is_valid?\n return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))\n end",
"def total_fee\n fee + fee2 + fee3 + fee4\n end",
"def scholarship_amount_is_valid\n errors.add(:scholarship_amount, \"An invalid scholarship amount was given.\") unless scholarship_amount_is_valid?\n end",
"def sum_exists\n if rows.empty? && !sum_cents\n errors.add(:base, \"Payment is not valid without sum\")\n end\n end",
"def add_fee_filled_or_empty\n if !params[:add_fee].nil?\n add_fee_keys = params[:add_fee].keys\n add_fee_vals = params[:add_fee].values\n add_fee_vals.each_slice(3) do |student_type, amount, time_period|\n if !((!student_type.empty? && !amount.empty? && !time_period.empty?) ||\n (student_type.empty? && amount.empty? && time_period.empty?))\n return false\n end\n end\n end\n return true\n end",
"def fee\n @fee || DEFAULT_FEE\n end",
"def edit_fee_fields_filled\n if !params[:edit_fees].nil?\n edit_fees_vals = params[:edit_fees].values\n edit_fees_vals.each_slice(3) do |fee, time, remove|\n if fee.empty? || time.empty?\n return false\n end\n end\n end\n return true\n end",
"def transaction_validation(model)\n return if model.effective_date.present?\n\n model.errors.add(:base, :missing_about_the_transaction, link_id: 'add_transaction_details')\n end",
"def validate_amount\n amount = sale.total_amount\n sales_id = sale.id\n sale_penalty = sale.penalty\n total_payment = 0\n total_amount_sale = amount + sale_penalty\n payments_query = Payment.where(sale_id: sales_id)\n payments_query.each do |payment|\n total_payment += payment.amount\n end\n if total_payment == total_amount_sale\n sale.customer.update(state: \"sinDeuda\")\n sale.pago!\n else\n unless sale.customer.state == \"conDeuda\"\n sale.customer.update(state: \"conDeuda\")\n end\n end\n end",
"def total_amount_validation\n @items.each do |i|\n next if i[:quantity].to_i * (i[:unit_price].to_i - i[:total_discount_amount].to_i) == i[:total_amount].to_i\n\n raise Klarna::Checkout::Errors::OrderValidationError.new(\n 'inconsistent_order_line_totals', 'total_line_amount_not_matching_qty_times_unit_price'\n )\n end\n end",
"def total_guests_validity\n return unless guests.present? && adults.present? && children.present? && infants.present?\n unless guests == adults + children + infants\n errors.add(:guests, :should_be_total)\n end\n end",
"def total_correcto\n suma = subtotal + iva + ieps\n unless suma == total\n errors.add(:total, 'La sumatoria del subtotal, IVA e IEPS, no concuerda')\n end\n end",
"def validate_meal\n meal.events.each do |event|\n next if event.valid?\n errors = event.errors.map do |attrib, msg|\n attrib == :base ? msg : \"#{Calendars::Event.human_attribute_name(attrib)}: #{msg}\"\n end.join(\", \")\n meal.errors.add(:base,\n \"The following error(s) occurred in making a #{event.calendar_name} event \"\\\n \"for this meal: #{errors}.\")\n end\n\n # Since we are copying these errors to the meal base, we don't need them in the\n # events base anymore.\n meal.errors.delete(:\"events.base\")\n end",
"def paid_enough?\n errors.add(:paid,'You don\\'t paid enough') unless self.product.value <= self.total_paid\n end",
"def verify_fees(test_data)\n fees = test_data[CoreUseOfCollectionsData::FEE_GRP.name] || [CoreUseOfCollectionsData.empty_fee]\n fees.each_with_index do |fee, index|\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_CURRENCY.name], element_value(fee_currency_input index))\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_VALUE.name], element_value(fee_value_input index))\n verify_values_match(fee[CoreUseOfCollectionsData::FEE_NOTE.name], element_value(fee_note_input index))\n end\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Tests that course's total_fee is not nil and is greater than or equal to 0 and returns true or false. | def total_fee_is_valid?
return ((self.total_fee != nil) and (self.total_fee >= 0))
end | [
"def fee_per_meeting_is_valid?\n return ((self.fee_per_meeting != nil) and (self.fee_per_meeting >= 0))\n end",
"def scholarship_amount_is_valid?\n return false unless self.scholarship_amount != nil\n course = Course.find_by_id(self.course_id)\n return false unless course #make sure course is non-nil\n return ((self.scholarship_amount >= 0) and (self.scholarship_amount <= course.total_fee)) #Make sure the scholarship fee is non-negative and that it is also less than or equal to the total course fee\n end",
"def fee_for_additional_materials_is_valid?\n return ((self.fee_for_additional_materials != nil) and (self.fee_for_additional_materials >= 0))\n end",
"def free?\n self.setupFee == 0 && self.laborFee == 0 && self.oneTimeFee == 0 && self.recurringFee == 0 && self.hourlyRecurringFee == 0\n end",
"def total_fee_is_valid\n errors.add(:total_fee,'The total fee is invalid.') unless total_fee_is_valid?\n end",
"def check_fee_category\n self.has_paid_fees?\n end",
"def fee?\n self.instance_of?(SecurityDeposit) ? false : true\n end",
"def can_pay_total?\n\n conf_payment_enabled = SystemConfiguration::Variable.get_value('booking.payment', 'false').to_bool\n conf_payment_total = (['total','deposit_and_total'].include?(SystemConfiguration::Variable.get_value('booking.payment_amount_setup', 'deposit')))\n\n if self.status == :pending_confirmation\n (conf_payment_enabled or force_allow_payment) and conf_payment_total and self.total_paid == 0 and ((!expired? and payment_cadence_allowed?) or force_allow_payment)\n elsif self.status == :confirmed # Confirmed in the back-office without payment\n (conf_payment_enabled or force_allow_payment) and conf_payment_total and self.total_paid == 0 and self.total_pending > 0\n else\n return false\n end\n\n end",
"def has_excess_funds\n true if total_contributions > goal_amount\n end",
"def hasRemainingBudget(cost)\n if (cost < (overall_budget - actual_overall_spent)) &&\n (cost < (daily_budget - actual_daily_spent))\n return true\n else\n return false\n end\n end",
"def calculated?\n fee_type&.calculated?.nil? ? true : fee_type.calculated?\n end",
"def can_guest_afford_fee(cash)\n cash > room_fee_per_guest ? true : false\n end",
"def has_discount?\n return false if discount_in_cents.nil?\n discount_in_cents > 0\n end",
"def add_fee_filled_or_empty\n if !params[:add_fee].nil?\n add_fee_keys = params[:add_fee].keys\n add_fee_vals = params[:add_fee].values\n add_fee_vals.each_slice(3) do |student_type, amount, time_period|\n if !((!student_type.empty? && !amount.empty? && !time_period.empty?) ||\n (student_type.empty? && amount.empty? && time_period.empty?))\n return false\n end\n end\n end\n return true\n end",
"def balance_sufficient?\n @money_required <= @balance\n end",
"def cash_valid\n\t\tif self.incoming_cash\n\t\t\tif ! self.incoming_cash.between?(0,1000000000)\n\t\t\t\treturn false\n\t\t\tend\n\t\t\tif self.incoming_cash > Team.find(self.offeree_id).cash_balance\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\tif self.outgoing_cash\n\t\t\tif ! self.outgoing_cash.between?(0,1000000000)\n\t\t\t\treturn false\n\t\t\tend\n\t\t\tif self.outgoing_cash > Team.find(self.offeror_id).cash_balance\n\t\t\t\treturn false\n\t\t\tend\n\t\tend\n\t\treturn true\n\tend",
"def discount_running?\n !discount_period.nil? && discount_period > 0\n end",
"def paid_enough?\n errors.add(:paid,'You don\\'t paid enough') unless self.product.value <= self.total_paid\n end",
"def zero_payment?\r\n total_amount_paid_for_claim.to_f.zero?\r\n end"
] | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |